Merge branch 'master' into minestrike-update

Conflicts:
	Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java
This commit is contained in:
Cheese 2015-11-11 07:43:50 +11:00
commit 520eb55b88
290 changed files with 11619 additions and 9128 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
From f037882f13b3ea9d0a0137260e365a4332a8e751 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:23:18 +1300
Subject: [PATCH] LivingEntity changes
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
index 48e2508..fb623ae 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -392,4 +392,20 @@ public interface LivingEntity extends Entity, Damageable, ProjectileSource {
* @return whether the operation was successful
*/
public boolean setLeashHolder(Entity holder);
+
+ public boolean shouldBreakLeash();
+
+ public void setShouldBreakLeash(boolean shouldBreakLeash);
+
+ public boolean shouldPullWhileLeashed();
+
+ public void setPullWhileLeashed(boolean pullWhileLeashed);
+
+ public boolean isVegetated();
+
+ public void setVegetated(boolean vegetated);
+
+ public boolean isGhost();
+
+ public void setGhost(boolean ghost);
}
--
1.9.5.msysgit.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,804 @@
From 9f12f0f7abe2a94fe4a724a7c17245b9c0f33a70 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:16:07 +1300
Subject: [PATCH] Modifiy entity
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index e345dd7..cb9ba53 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -137,6 +137,31 @@ public abstract class Entity implements ICommandListener {
this.die();
}
+ private boolean _silent;
+ private boolean _invisible;
+
+ public boolean isSilent()
+ {
+ return _silent;
+ }
+
+ public void setSilent(boolean silent)
+ {
+ _silent = silent;
+ }
+
+ public boolean isMineplexInvisible()
+ {
+ return _invisible;
+ }
+
+ public void setMineplexInvisible(boolean invisible)
+ {
+ _invisible = invisible;
+
+ setInvisible(isMineplexInvisible() || isInvisible());
+ }
+
public Entity(World world) {
this.id = Entity.entityCount++;
this.j = 1.0D;
@@ -684,7 +709,9 @@ public abstract class Entity implements ICommandListener {
this.makeSound(this.P(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
}
- this.a(blockposition, block);
+ if (!isSilent())
+ this.a(blockposition, block);
+
block.a(this.world, blockposition, this); // CraftBukkit moved from above
}
}
@@ -786,7 +813,7 @@ public abstract class Entity implements ICommandListener {
}
public void makeSound(String s, float f, float f1) {
- if (!this.R()) {
+ if (!isSilent() && !this.R()) {
this.world.makeSound(this, s, f, f1);
}
@@ -984,6 +1011,10 @@ public abstract class Entity implements ICommandListener {
this.lastZ = this.locZ = d2;
this.lastYaw = this.yaw = f;
this.lastPitch = this.pitch = f1;
+
+ if (this instanceof EntityLiving)
+ ((EntityLiving) this).aK = f;
+
double d3 = (double) (this.lastYaw - f);
if (d3 < -180.0D) {
@@ -1537,7 +1568,7 @@ public abstract class Entity implements ICommandListener {
if (entity == null) {
if (this.vehicle != null) {
// CraftBukkit start
- if ((this.bukkitEntity instanceof LivingEntity) && (this.vehicle.getBukkitEntity() instanceof Vehicle)) {
+ if ((this.bukkitEntity instanceof LivingEntity) && vehicle.getBukkitEntity() instanceof Vehicle) {
VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
pluginManager.callEvent(event);
@@ -1557,7 +1588,7 @@ public abstract class Entity implements ICommandListener {
if ((this.bukkitEntity instanceof LivingEntity) && (entity.getBukkitEntity() instanceof Vehicle) && entity.world.isChunkLoaded((int) entity.locX >> 4, (int) entity.locZ >> 4, true)) {
// It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are.
VehicleExitEvent exitEvent = null;
- if (this.vehicle != null && this.vehicle.getBukkitEntity() instanceof Vehicle) {
+ if (this.vehicle != null) {
exitEvent = new VehicleExitEvent((Vehicle) this.vehicle.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
pluginManager.callEvent(exitEvent);
diff --git a/src/main/java/net/minecraft/server/EntityBat.java b/src/main/java/net/minecraft/server/EntityBat.java
new file mode 100644
index 0000000..c078fa6
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityBat.java
@@ -0,0 +1,206 @@
+package net.minecraft.server;
+
+import java.util.Calendar;
+
+public class EntityBat extends EntityAmbient {
+
+ private BlockPosition a;
+ private boolean _vegetated;
+
+ public EntityBat(World world) {
+ super(world);
+ this.setSize(0.5F, 0.9F);
+ this.setAsleep(true);
+
+ _vegetated = false;
+ }
+
+ public void setVegetated(boolean flag) {
+ _vegetated = flag;
+ }
+
+ public boolean isVegetated() {
+ return _vegetated;
+ }
+
+ protected void h() {
+ super.h();
+ this.datawatcher.a(16, new Byte((byte) 0));
+ }
+
+ protected float bB() {
+ return 0.1F;
+ }
+
+ protected float bC() {
+ return super.bC() * 0.95F;
+ }
+
+ protected String z() {
+ return this.isAsleep() && this.random.nextInt(4) != 0 ? null : "mob.bat.idle";
+ }
+
+ protected String bo() {
+ return "mob.bat.hurt";
+ }
+
+ protected String bp() {
+ return "mob.bat.death";
+ }
+
+ public boolean ae() {
+ return false;
+ }
+
+ protected void s(Entity entity) {}
+
+ protected void bL() {}
+
+ protected void initAttributes()
+ {
+ super.initAttributes();
+ this.getAttributeInstance(GenericAttributes.maxHealth).setValue(6.0D);
+ }
+
+ public boolean isAsleep() {
+ return (this.datawatcher.getByte(16) & 1) != 0;
+ }
+
+ public void setAsleep(boolean flag) {
+ byte b0 = this.datawatcher.getByte(16);
+
+ if (flag) {
+ this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 1)));
+ } else {
+ this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -2)));
+ }
+
+ }
+
+ public void t_() {
+ super.t_();
+
+ if (isVegetated())
+ return;
+
+ if (this.isAsleep()) {
+ this.motX = this.motY = this.motZ = 0.0D;
+ this.locY = (double) MathHelper.floor(this.locY) + 1.0D - (double) this.length;
+ } else {
+ this.motY *= 0.6000000238418579D;
+ }
+
+ }
+
+ protected void E() {
+ super.E();
+
+ if (isVegetated())
+ return;
+
+ BlockPosition blockposition = new BlockPosition(this);
+ BlockPosition blockposition1 = blockposition.up();
+
+ if (this.isAsleep()) {
+ if (!this.world.getType(blockposition1).getBlock().isOccluding()) {
+ this.setAsleep(false);
+ this.world.a((EntityHuman) null, 1015, blockposition, 0);
+ } else {
+ if (this.random.nextInt(200) == 0) {
+ this.aK = (float) this.random.nextInt(360);
+ }
+
+ if (this.world.findNearbyPlayer(this, 4.0D) != null) {
+ this.setAsleep(false);
+ this.world.a((EntityHuman) null, 1015, blockposition, 0);
+ }
+ }
+ } else {
+ if (this.a != null && (!this.world.isEmpty(this.a) || this.a.getY() < 1)) {
+ this.a = null;
+ }
+
+ if (this.a == null || this.random.nextInt(30) == 0 || this.a.c((double) ((int) this.locX), (double) ((int) this.locY), (double) ((int) this.locZ)) < 4.0D) {
+ this.a = new BlockPosition((int) this.locX + this.random.nextInt(7) - this.random.nextInt(7), (int) this.locY + this.random.nextInt(6) - 2, (int) this.locZ + this.random.nextInt(7) - this.random.nextInt(7));
+ }
+
+ double d0 = (double) this.a.getX() + 0.5D - this.locX;
+ double d1 = (double) this.a.getY() + 0.1D - this.locY;
+ double d2 = (double) this.a.getZ() + 0.5D - this.locZ;
+
+ this.motX += (Math.signum(d0) * 0.5D - this.motX) * 0.10000000149011612D;
+ this.motY += (Math.signum(d1) * 0.699999988079071D - this.motY) * 0.10000000149011612D;
+ this.motZ += (Math.signum(d2) * 0.5D - this.motZ) * 0.10000000149011612D;
+ float f = (float) (MathHelper.b(this.motZ, this.motX) * 180.0D / 3.1415927410125732D) - 90.0F;
+ float f1 = MathHelper.g(f - this.yaw);
+
+ this.ba = 0.5F;
+ this.yaw += f1;
+ if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).getBlock().isOccluding()) {
+ this.setAsleep(true);
+ }
+ }
+
+ }
+
+ protected boolean s_() {
+ return false;
+ }
+
+ public void e(float f, float f1) {}
+
+ protected void a(double d0, boolean flag, Block block, BlockPosition blockposition) {}
+
+ public boolean aI() {
+ return true;
+ }
+
+ public boolean damageEntity(DamageSource damagesource, float f) {
+ if (this.isInvulnerable(damagesource)) {
+ return false;
+ } else {
+ if (!this.world.isClientSide && this.isAsleep()) {
+ this.setAsleep(false);
+ }
+
+ return super.damageEntity(damagesource, f);
+ }
+ }
+
+ public void a(NBTTagCompound nbttagcompound) {
+ super.a(nbttagcompound);
+ this.datawatcher.watch(16, Byte.valueOf(nbttagcompound.getByte("BatFlags")));
+ }
+
+ public void b(NBTTagCompound nbttagcompound) {
+ super.b(nbttagcompound);
+ nbttagcompound.setByte("BatFlags", this.datawatcher.getByte(16));
+ }
+
+ public boolean bR() {
+ BlockPosition blockposition = new BlockPosition(this.locX, this.getBoundingBox().b, this.locZ);
+
+ if (blockposition.getY() >= this.world.F()) {
+ return false;
+ } else {
+ int i = this.world.getLightLevel(blockposition);
+ byte b0 = 4;
+
+ if (this.a(this.world.Y())) {
+ b0 = 7;
+ } else if (this.random.nextBoolean()) {
+ return false;
+ }
+
+ return i > this.random.nextInt(b0) ? false : super.bR();
+ }
+ }
+
+ private boolean a(Calendar calendar) {
+ return calendar.get(2) + 1 == 10 && calendar.get(5) >= 20 || calendar.get(2) + 1 == 11 && calendar.get(5) <= 3;
+ }
+
+ public float getHeadHeight() {
+ return this.length / 2.0F;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/EntityBlaze.java b/src/main/java/net/minecraft/server/EntityBlaze.java
new file mode 100644
index 0000000..a759e00
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityBlaze.java
@@ -0,0 +1,207 @@
+package net.minecraft.server;
+
+public class EntityBlaze extends EntityMonster {
+
+ private float a = 0.5F;
+ private int b;
+
+ public EntityBlaze(World world) {
+ super(world);
+ this.fireProof = true;
+ this.b_ = 10;
+ this.goalSelector.a(4, new EntityBlaze.PathfinderGoalBlazeFireball(this));
+ this.goalSelector.a(5, new PathfinderGoalMoveTowardsRestriction(this, 1.0D));
+ this.goalSelector.a(7, new PathfinderGoalRandomStroll(this, 1.0D));
+ this.goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8.0F));
+ this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
+ this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this, true, new Class[0]));
+ this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget(this, EntityHuman.class, true));
+ }
+
+ protected void initAttributes() {
+ super.initAttributes();
+ this.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(6.0D);
+ this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.23000000417232513D);
+ this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(48.0D);
+ }
+
+ protected void h() {
+ super.h();
+ this.datawatcher.a(16, new Byte((byte) 0));
+ }
+
+ protected String z() {
+ return "mob.blaze.breathe";
+ }
+
+ protected String bo() {
+ return "mob.blaze.hit";
+ }
+
+ protected String bp() {
+ return "mob.blaze.death";
+ }
+
+ public float c(float f) {
+ return 1.0F;
+ }
+
+ public void m() {
+ if (!isVegetated() && !this.onGround && this.motY < 0.0D) {
+ this.motY *= 0.6D;
+ }
+
+ if (this.world.isClientSide) {
+ if (this.random.nextInt(24) == 0 && !this.R()) {
+ this.world.a(this.locX + 0.5D, this.locY + 0.5D, this.locZ + 0.5D, "fire.fire", 1.0F + this.random.nextFloat(), this.random.nextFloat() * 0.7F + 0.3F, false);
+ }
+
+ for (int i = 0; i < 2; ++i) {
+ this.world.addParticle(EnumParticle.SMOKE_LARGE, this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D, new int[0]);
+ }
+ }
+
+ super.m();
+ }
+
+ protected void E() {
+ if (this.U()) {
+ this.damageEntity(DamageSource.DROWN, 1.0F);
+ }
+
+ --this.b;
+ if (this.b <= 0) {
+ this.b = 100;
+ this.a = 0.5F + (float) this.random.nextGaussian() * 3.0F;
+ }
+
+ EntityLiving entityliving = this.getGoalTarget();
+
+ if (!isVegetated() && entityliving != null && entityliving.locY + (double) entityliving.getHeadHeight() > this.locY + (double) this.getHeadHeight() + (double) this.a) {
+ this.motY += (0.30000001192092896D - this.motY) * 0.30000001192092896D;
+ this.ai = true;
+ }
+
+ super.E();
+ }
+
+ public void e(float f, float f1) {}
+
+ protected Item getLoot() {
+ return Items.BLAZE_ROD;
+ }
+
+ public boolean isBurning() {
+ return this.n();
+ }
+
+ protected void dropDeathLoot(boolean flag, int i) {
+ if (flag) {
+ int j = this.random.nextInt(2 + i);
+
+ for (int k = 0; k < j; ++k) {
+ this.a(Items.BLAZE_ROD, 1);
+ }
+ }
+
+ }
+
+ public boolean n() {
+ return (this.datawatcher.getByte(16) & 1) != 0;
+ }
+
+ public void a(boolean flag) {
+ byte b0 = this.datawatcher.getByte(16);
+
+ if (flag) {
+ b0 = (byte) (b0 | 1);
+ } else {
+ b0 &= -2;
+ }
+
+ this.datawatcher.watch(16, Byte.valueOf(b0));
+ }
+
+ protected boolean n_() {
+ return true;
+ }
+
+ static class PathfinderGoalBlazeFireball extends PathfinderGoal {
+
+ private EntityBlaze a;
+ private int b;
+ private int c;
+
+ public PathfinderGoalBlazeFireball(EntityBlaze entityblaze) {
+ this.a = entityblaze;
+ this.a(3);
+ }
+
+ public boolean a() {
+ EntityLiving entityliving = this.a.getGoalTarget();
+
+ return entityliving != null && entityliving.isAlive();
+ }
+
+ public void c() {
+ this.b = 0;
+ }
+
+ public void d() {
+ this.a.a(false);
+ }
+
+ public void e() {
+ --this.c;
+ EntityLiving entityliving = this.a.getGoalTarget();
+ double d0 = this.a.h(entityliving);
+
+ if (d0 < 4.0D) {
+ if (this.c <= 0) {
+ this.c = 20;
+ this.a.r(entityliving);
+ }
+
+ this.a.getControllerMove().a(entityliving.locX, entityliving.locY, entityliving.locZ, 1.0D);
+ } else if (d0 < 256.0D) {
+ double d1 = entityliving.locX - this.a.locX;
+ double d2 = entityliving.getBoundingBox().b + (double) (entityliving.length / 2.0F) - (this.a.locY + (double) (this.a.length / 2.0F));
+ double d3 = entityliving.locZ - this.a.locZ;
+
+ if (this.c <= 0) {
+ ++this.b;
+ if (this.b == 1) {
+ this.c = 60;
+ this.a.a(true);
+ } else if (this.b <= 4) {
+ this.c = 6;
+ } else {
+ this.c = 100;
+ this.b = 0;
+ this.a.a(false);
+ }
+
+ if (this.b > 1) {
+ float f = MathHelper.c(MathHelper.sqrt(d0)) * 0.5F;
+
+ this.a.world.a((EntityHuman) null, 1009, new BlockPosition((int) this.a.locX, (int) this.a.locY, (int) this.a.locZ), 0);
+
+ for (int i = 0; i < 1; ++i) {
+ EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.a.world, this.a, d1 + this.a.bc().nextGaussian() * (double) f, d2, d3 + this.a.bc().nextGaussian() * (double) f);
+
+ entitysmallfireball.locY = this.a.locY + (double) (this.a.length / 2.0F) + 0.5D;
+ this.a.world.addEntity(entitysmallfireball);
+ }
+ }
+ }
+
+ this.a.getControllerLook().a(entityliving, 10.0F, 10.0F);
+ } else {
+ this.a.getNavigation().n();
+ this.a.getControllerMove().a(entityliving.locX, entityliving.locY, entityliving.locZ, 1.0D);
+ }
+
+ super.e();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
index d246ae7..ed7f549 100644
--- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
+++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
@@ -51,6 +51,18 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.ah = true;
}
+ public void setTargetBlock(int x, int y, int z) {
+ // Mineplex
+ this.a = x;
+ this.b = y;
+ this.c = z;
+ this.target = null;
+ }
+
+ public void setTargetEntity(Entity e) {
+ this.target = e;
+ }
+
protected void initAttributes() {
super.initAttributes();
this.getAttributeInstance(GenericAttributes.maxHealth).setValue(200.0D);
@@ -170,7 +182,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.c += this.random.nextGaussian() * 2.0D;
}
- if (this.bw || d2 < 100.0D || d2 > 22500.0D || this.positionChanged || this.E) {
+ if (!isVegetated() && (this.bw || d2 < 100.0D || d2 > 22500.0D || this.positionChanged || this.E)) {
this.cf();
}
@@ -253,7 +265,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
this.bs.setPositionRotation(this.locX + (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ + (double) (f11 * 4.5F), 0.0F, 0.0F);
this.bt.t_();
this.bt.setPositionRotation(this.locX - (double) (f12 * 4.5F), this.locY + 2.0D, this.locZ - (double) (f11 * 4.5F), 0.0F, 0.0F);
- if (!this.world.isClientSide && this.hurtTicks == 0) {
+ if (!this.world.isClientSide && this.hurtTicks == 0 && !isGhost()) {
this.a(this.world.getEntities(this, this.bs.getBoundingBox().grow(4.0D, 2.0D, 4.0D).c(0.0D, -2.0D, 0.0D)));
this.a(this.world.getEntities(this, this.bt.getBoundingBox().grow(4.0D, 2.0D, 4.0D).c(0.0D, -2.0D, 0.0D)));
this.b(this.world.getEntities(this, this.bn.getBoundingBox().grow(1.0D, 1.0D, 1.0D)));
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
index 7a42040..d3403a1 100644
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
@@ -17,6 +17,8 @@ public class EntityFallingBlock extends Entity {
private float fallHurtAmount = 2.0F;
public NBTTagCompound tileEntityData;
+ public boolean spectating;
+
public EntityFallingBlock(World world) {
super(world);
}
@@ -42,7 +44,15 @@ public class EntityFallingBlock extends Entity {
protected void h() {}
public boolean ad() {
- return !this.dead;
+ return !this.dead && !spectating;
+ }
+
+ @Override
+ public boolean damageEntity(DamageSource damagesource, float f)
+ {
+ CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f);
+
+ return true;
}
public void t_() {
diff --git a/src/main/java/net/minecraft/server/EntityHorse.java b/src/main/java/net/minecraft/server/EntityHorse.java
index f131419..f293118 100644
--- a/src/main/java/net/minecraft/server/EntityHorse.java
+++ b/src/main/java/net/minecraft/server/EntityHorse.java
@@ -125,6 +125,9 @@ public class EntityHorse extends EntityAnimal implements IInventoryListener {
private void c(int i, boolean flag) {
int j = this.datawatcher.getInt(16);
+ if (isVegetated())
+ return;
+
if (flag) {
this.datawatcher.watch(16, Integer.valueOf(j | i));
} else {
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index a8a327d..b7647bc 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -34,6 +34,10 @@ public abstract class EntityInsentient extends EntityLiving {
private Entity bp;
private NBTTagCompound bq;
+ private boolean _vegetated;
+ private boolean _shouldBreakLeash = true;
+ private boolean _pullWhileLeashed = true;
+
public EntityInsentient(World world) {
super(world);
this.goalSelector = new PathfinderGoalSelector(world != null && world.methodProfiler != null ? world.methodProfiler : null);
@@ -53,6 +57,32 @@ public abstract class EntityInsentient extends EntityLiving {
this.persistent = !isTypeNotPersistent();
// CraftBukkit end
}
+
+ public void setVegetated(boolean flag) {
+ _vegetated = flag;
+ }
+
+ public void setShouldBreakLeash(boolean shouldBreakLeash)
+ {
+ _shouldBreakLeash = shouldBreakLeash;
+ }
+
+ public void setPullWhileLeashed(boolean pullWhileLeashed)
+ {
+ _pullWhileLeashed = pullWhileLeashed;
+ }
+
+ public boolean isVegetated() {
+ return _vegetated;
+ }
+
+ public boolean shouldBreakLeash() {
+ return shouldBreakLeash();
+ }
+
+ public boolean shouldPullWhileLeashed() {
+ return _pullWhileLeashed;
+ }
protected void initAttributes() {
super.initAttributes();
@@ -148,7 +178,7 @@ public abstract class EntityInsentient extends EntityLiving {
public void K() {
super.K();
this.world.methodProfiler.a("mobBaseTick");
- if (this.isAlive() && this.random.nextInt(1000) < this.a_++) {
+ if (!isSilent() && this.isAlive() && this.random.nextInt(1000) < this.a_++) {
this.a_ = -this.w();
this.x();
}
@@ -770,7 +800,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
public final boolean e(EntityHuman entityhuman) {
- if (this.cc() && this.getLeashHolder() == entityhuman) {
+ if (this.cc() && this.getLeashHolder() == entityhuman && _shouldBreakLeash) {
// CraftBukkit start - fire PlayerUnleashEntityEvent
if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this, this.getLeashHolder()));
@@ -835,7 +865,7 @@ public abstract class EntityInsentient extends EntityLiving {
}
public void unleash(boolean flag, boolean flag1) {
- if (this.bo) {
+ if (this.bo && _shouldBreakLeash) {
this.bo = false;
this.bp = null;
if (!this.world.isClientSide && flag1) {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 3c852fd..b861dbe 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -101,6 +101,18 @@ public abstract class EntityLiving extends Entity {
this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE);
}
+ private boolean _ghost;
+
+ public boolean isGhost()
+ {
+ return _ghost;
+ }
+
+ public void setGhost(boolean ghost)
+ {
+ _ghost = ghost;
+ }
+
public EntityLiving(World world) {
super(world);
this.initAttributes();
@@ -1783,7 +1795,7 @@ public abstract class EntityLiving extends Entity {
}
public boolean ad() {
- return !this.dead;
+ return !isGhost() && !this.dead;
}
public boolean ae() {
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 3810f86..44ac587 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -65,10 +65,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
// Spigot start
public boolean collidesWithEntities = true;
+ public boolean spectating;
+
@Override
public boolean ad()
{
- return this.collidesWithEntities && super.ad(); // (first !this.isDead near bottom of EntityLiving)
+ return !spectating && this.collidesWithEntities && super.ad(); // (first !this.isDead near bottom of EntityLiving)
}
@Override
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index 2d22327..83e71c1 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
@@ -9,6 +9,8 @@ public class EntityTNTPrimed extends Entity {
public float yield = 4; // CraftBukkit - add field
public boolean isIncendiary = false; // CraftBukkit - add field
+ public boolean spectating;
+
public EntityTNTPrimed(World world) {
super(world);
this.k = true;
@@ -37,7 +39,7 @@ public class EntityTNTPrimed extends Entity {
}
public boolean ad() {
- return !this.dead;
+ return !spectating && !this.dead;
}
public void t_() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 5317cff..60e8584 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -74,6 +74,46 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
}
+ public boolean shouldBreakLeash()
+ {
+ return ((EntityInsentient) getHandle()).shouldBreakLeash();
+ }
+
+ public void setShouldBreakLeash(boolean shouldBreakLeash)
+ {
+ ((EntityInsentient) getHandle()).setShouldBreakLeash(shouldBreakLeash);
+ }
+
+ public boolean shouldPullWhileLeashed()
+ {
+ return ((EntityInsentient) getHandle()).shouldPullWhileLeashed();
+ }
+
+ public void setPullWhileLeashed(boolean pullWhileLeashed)
+ {
+ ((EntityInsentient) getHandle()).setPullWhileLeashed(pullWhileLeashed);
+ }
+
+ public boolean isVegetated()
+ {
+ return ((EntityInsentient) getHandle()).isVegetated();
+ }
+
+ public void setVegetated(boolean vegetated)
+ {
+ ((EntityInsentient) getHandle()).setVegetated(vegetated);
+ }
+
+ public boolean isGhost()
+ {
+ return getHandle().isGhost();
+ }
+
+ public void setGhost(boolean ghost)
+ {
+ getHandle().setGhost(ghost);
+ }
+
public double getHealth() {
return Math.min(Math.max(0, getHandle().getHealth()), getMaxHealth());
}
--
1.9.5.msysgit.0

View File

@ -0,0 +1,235 @@
From 71c20f9d0c8bfa388f6bf0ba1a7b765a83e9de2a Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:21:32 +1300
Subject: [PATCH] Chunk changes
diff --git a/src/main/java/com/mineplex/spigot/ChunkAddEntityEvent.java b/src/main/java/com/mineplex/spigot/ChunkAddEntityEvent.java
new file mode 100644
index 0000000..3f16935
--- /dev/null
+++ b/src/main/java/com/mineplex/spigot/ChunkAddEntityEvent.java
@@ -0,0 +1,31 @@
+package com.mineplex.spigot;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class ChunkAddEntityEvent extends Event
+{
+ private static final HandlerList handlers = new HandlerList();
+ private Entity _entity;
+
+ public ChunkAddEntityEvent(Entity _entity)
+ {
+ this._entity = _entity;
+ }
+
+ public Entity getEntity()
+ {
+ return _entity;
+ }
+
+ public HandlerList getHandlers()
+ {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList()
+ {
+ return handlers;
+ }
+}
diff --git a/src/main/java/com/mineplex/spigot/ChunkPreLoadEvent.java b/src/main/java/com/mineplex/spigot/ChunkPreLoadEvent.java
new file mode 100644
index 0000000..564efe6
--- /dev/null
+++ b/src/main/java/com/mineplex/spigot/ChunkPreLoadEvent.java
@@ -0,0 +1,60 @@
+package com.mineplex.spigot;
+
+import org.bukkit.World;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class ChunkPreLoadEvent extends Event implements Cancellable
+{
+ private static final HandlerList handlers = new HandlerList();
+ private boolean _cancelled;
+ private World _world;
+ private int _x;
+ private int _z;
+
+ public ChunkPreLoadEvent(World world, int x, int z)
+ {
+ _world = world;
+ _x = x;
+ _z = z;
+ }
+
+ public World getWorld()
+ {
+ return _world;
+ }
+
+ public int getX()
+ {
+ return _x;
+ }
+
+ public int getZ()
+ {
+ return _z;
+ }
+
+ @Override
+ public boolean isCancelled()
+ {
+ return _cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel)
+ {
+ _cancelled = cancel;
+ }
+
+ @Override
+ public HandlerList getHandlers()
+ {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList()
+ {
+ return handlers;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 022ba31..464d0c2 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -11,6 +11,8 @@ import java.util.Map;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue;
+
+import com.mineplex.spigot.ChunkAddEntityEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -660,6 +662,9 @@ public class Chunk {
entity.die();
}
+ ChunkAddEntityEvent event = new ChunkAddEntityEvent(entity.bukkitEntity);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+
int k = MathHelper.floor(entity.locY / 16.0D);
if (k < 0) {
@@ -1317,6 +1322,10 @@ public class Chunk {
return this.done;
}
+ public void setDone(boolean done) {
+ this.done = done;
+ }
+
public void d(boolean flag) {
this.done = flag;
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 975d666..a55bd6c 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -8,6 +8,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+
+import com.mineplex.spigot.ChunkPreLoadEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -88,6 +90,13 @@ public class ChunkProviderServer implements IChunkProvider {
}
+ private boolean callChunkPreLoad(int i, int j)
+ {
+ ChunkPreLoadEvent event = new ChunkPreLoadEvent(world.getWorld(), i, j);
+ world.getServer().getPluginManager().callEvent(event);
+ return event.isCancelled();
+ }
+
// CraftBukkit start - Add async variant, provide compatibility
public Chunk getChunkIfLoaded(int x, int z) {
return chunks.get(LongHash.toLong(x, z));
@@ -109,10 +118,30 @@ public class ChunkProviderServer implements IChunkProvider {
// We can only use the queue for already generated chunks
if (chunk == null && loader != null && loader.chunkExists(world, i, j)) {
if (runnable != null) {
- ChunkIOExecutor.queueChunkLoad(world, loader, this, i, j, runnable);
+ if (callChunkPreLoad(i, j))
+ {
+ runnable.run();
+ chunk = new EmptyChunk(world, i, j);
+ chunk.setDone(true);
+ chunks.put(LongHash.toLong(i, j), chunk);
+ }
+ else
+ {
+ ChunkIOExecutor.queueChunkLoad(world, loader, this, i, j, runnable);
+ }
+
return null;
} else {
- chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
+ if (callChunkPreLoad(i, j))
+ {
+ chunk = new EmptyChunk(world, i, j);
+ chunk.setDone(true);
+ chunks.put(LongHash.toLong(i, j), chunk);
+ }
+ else
+ {
+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
+ }
}
} else if (chunk == null) {
chunk = originalGetChunkAt(i, j);
@@ -131,6 +160,20 @@ public class ChunkProviderServer implements IChunkProvider {
boolean newChunk = false;
// CraftBukkit end
+ Server server = world.getServer();
+
+ if (chunk == null && server != null)
+ {
+ if (callChunkPreLoad(i, j))
+ {
+ chunk = new EmptyChunk(world, i, j);
+ chunk.setDone(true);
+ chunks.put(LongHash.toLong(i, j), chunk);
+
+ return chunk;
+ }
+ }
+
if (chunk == null) {
world.timings.syncChunkLoadTimer.startTiming(); // Spigot
chunk = this.loadChunk(i, j);
@@ -158,7 +201,6 @@ public class ChunkProviderServer implements IChunkProvider {
chunk.addEntities();
// CraftBukkit start
- Server server = world.getServer();
if (server != null) {
/*
* If it's a new world, the first few chunks are generated inside
--
1.9.5.msysgit.0

View File

@ -0,0 +1,353 @@
From 47c08a6099856faf0049c0b0cdde495a8ae4166e Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:22:05 +1300
Subject: [PATCH] Packet listener changes
diff --git a/src/main/java/com/mineplex/spigot/IPacketVerifier.java b/src/main/java/com/mineplex/spigot/IPacketVerifier.java
new file mode 100644
index 0000000..f86dfd1
--- /dev/null
+++ b/src/main/java/com/mineplex/spigot/IPacketVerifier.java
@@ -0,0 +1,8 @@
+package com.mineplex.spigot;
+
+import net.minecraft.server.Packet;
+
+public interface IPacketVerifier
+{
+ public boolean handlePacket(Packet packet);
+}
\ No newline at end of file
diff --git a/src/main/java/com/mineplex/spigot/PacketProcessor.java b/src/main/java/com/mineplex/spigot/PacketProcessor.java
new file mode 100644
index 0000000..5695899
--- /dev/null
+++ b/src/main/java/com/mineplex/spigot/PacketProcessor.java
@@ -0,0 +1,250 @@
+package com.mineplex.spigot;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.HashMap;
+import io.netty.util.concurrent.GenericFutureListener;
+
+import net.minecraft.server.NetworkManager;
+import net.minecraft.server.IChatBaseComponent;
+
+import net.minecraft.server.Packet;
+import net.minecraft.server.PacketListenerPlayIn;
+import net.minecraft.server.IUpdatePlayerListBox;
+import net.minecraft.server.PlayerConnection;
+import net.minecraft.server.PacketPlayInChat;
+import net.minecraft.server.PacketPlayInTabComplete;
+import net.minecraft.server.PacketPlayInClientCommand;
+import net.minecraft.server.PacketPlayInSettings;
+import net.minecraft.server.PacketPlayInTransaction;
+import net.minecraft.server.PacketPlayInEnchantItem;
+import net.minecraft.server.PacketPlayInWindowClick;
+import net.minecraft.server.PacketPlayInCloseWindow;
+import net.minecraft.server.PacketPlayInCustomPayload;
+import net.minecraft.server.PacketPlayInUseEntity;
+import net.minecraft.server.PacketPlayInKeepAlive;
+import net.minecraft.server.PacketPlayInFlying;
+import net.minecraft.server.PacketPlayInAbilities;
+import net.minecraft.server.PacketPlayInBlockDig;
+import net.minecraft.server.PacketPlayInEntityAction;
+import net.minecraft.server.PacketPlayInSteerVehicle;
+import net.minecraft.server.PacketPlayInHeldItemSlot;
+import net.minecraft.server.PacketPlayInSetCreativeSlot;
+import net.minecraft.server.PacketPlayInUpdateSign;
+import net.minecraft.server.PacketPlayInBlockPlace;
+import net.minecraft.server.PacketPlayInSpectate;
+import net.minecraft.server.PacketPlayInResourcePackStatus;
+import net.minecraft.server.PacketPlayInArmAnimation;
+
+public class PacketProcessor implements PacketListenerPlayIn, IUpdatePlayerListBox
+{
+ private IPacketVerifier _packetVerifier;
+ private PlayerConnection _packetListener;
+ private static volatile HashMap<Class, Boolean> _listenedPackets = new HashMap<Class, Boolean>();
+
+ public PacketProcessor(PlayerConnection packetListener)
+ {
+ _packetListener = packetListener;
+ }
+
+ public void setPacketVerifier(IPacketVerifier verifier)
+ {
+ _packetVerifier = verifier;
+ }
+
+ public void c()
+ {
+ _packetListener.c();
+ }
+
+ public static void addPacket(Class packetClass, boolean forceMainThread)
+ {
+ _listenedPackets.put(packetClass, forceMainThread);
+ }
+
+ public static void removePacket(Class packetClass)
+ {
+ _listenedPackets.remove(packetClass);
+ }
+
+ public void processOutgoingPacket(Packet packet, NetworkManager networkManager)
+ {
+ if (!_listenedPackets.containsKey(packet.getClass()))
+ {
+ networkManager.handle(packet);
+ return;
+ }
+
+ boolean addDefaultPacket = true;
+
+ if (_packetVerifier != null)
+ {
+ if (!_packetVerifier.handlePacket(packet))
+ {
+ addDefaultPacket = false;
+ }
+ }
+
+ if (addDefaultPacket)
+ {
+ networkManager.handle(packet);
+ }
+ }
+
+ public void processIncomingPacket(final Packet packet)
+ {
+ if (!_listenedPackets.containsKey(packet.getClass()))
+ {
+ packet.a(_packetListener);
+ return;
+ }
+
+ if (!_packetListener.player.u().isMainThread() && _listenedPackets.get(packet.getClass()))
+ {
+ _packetListener.player.u().postToMainThread(new Runnable()
+ {
+ public void run()
+ {
+ processIncomingPacket(packet);
+ }
+ });
+
+ return;
+ }
+
+ boolean addDefaultPacket = true;
+
+ if (_packetVerifier != null)
+ {
+ if (!_packetVerifier.handlePacket(packet))
+ {
+ addDefaultPacket = false;
+ }
+ }
+
+ if (addDefaultPacket)
+ {
+ packet.a(_packetListener);
+ }
+ }
+
+ public void a(PacketPlayInChat packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInTabComplete packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInClientCommand packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInSettings packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInTransaction packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInEnchantItem packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInWindowClick packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInCloseWindow packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInCustomPayload packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInUseEntity packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInKeepAlive packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInFlying packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInAbilities packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInBlockDig packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInEntityAction packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInSteerVehicle packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInHeldItemSlot packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInSetCreativeSlot packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInUpdateSign packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInBlockPlace packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInSpectate packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInResourcePackStatus packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(PacketPlayInArmAnimation packet)
+ {
+ processIncomingPacket(packet);
+ }
+
+ public void a(IChatBaseComponent packet)
+ {
+ _packetListener.a(packet);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index 9d23c6c..83a600c 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -27,6 +27,8 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
+import com.mineplex.spigot.PacketProcessor;
+
public class NetworkManager extends SimpleChannelInboundHandler<Packet> {
private static final Logger g = LogManager.getLogger();
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index 5740e49..5edef3e 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -62,6 +62,8 @@ import org.bukkit.inventory.InventoryView;
import org.bukkit.util.NumberConversions;
// CraftBukkit end
+import com.mineplex.spigot.PacketProcessor;
+
public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerListBox {
private static final Logger c = LogManager.getLogger();
@@ -87,15 +89,20 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
private boolean checkMovement = true;
private boolean processedDisconnect; // CraftBukkit - added
+ public PacketProcessor PacketVerifier;
+
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
this.minecraftServer = minecraftserver;
this.networkManager = networkmanager;
- networkmanager.a((PacketListener) this);
this.player = entityplayer;
entityplayer.playerConnection = this;
// CraftBukkit start - add fields and methods
this.server = minecraftserver.server;
+
+
+ PacketVerifier = new PacketProcessor(this);
+ networkmanager.a(PacketVerifier);
}
private final org.bukkit.craftbukkit.CraftServer server;
@@ -904,7 +911,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
// CraftBukkit end
try {
- this.networkManager.handle(packet);
+ PacketVerifier.processOutgoingPacket(packet, networkManager);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Sending packet");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent");
@@ -1408,9 +1415,12 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
if (this.player.dead) return; // CraftBukkit
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.u());
- CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
+ if (packetplayinclosewindow.id == player.activeContainer.windowId)
+ {
+ CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit
- this.player.p();
+ this.player.p();
+ }
}
public void a(PacketPlayInWindowClick packetplayinwindowclick) {
--
1.9.5.msysgit.0

View File

@ -0,0 +1,428 @@
From 702360d29859ed580b44255ccb7f2f124e6aa24b Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:22:36 +1300
Subject: [PATCH] Inventory changes
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index e9a3c50..9fd6359 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -441,8 +441,8 @@ public class CraftInventory implements Inventory {
return InventoryType.ENCHANTING;
} else if (inventory instanceof TileEntityBrewingStand) {
return InventoryType.BREWING;
- } else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) {
- return ((CraftInventoryCustom.MinecraftInventory) inventory).getType();
+ } else if (inventory instanceof MinecraftInventory) {
+ return ((MinecraftInventory) inventory).getType();
} else if (inventory instanceof InventoryEnderChest) {
return InventoryType.ENDER_CHEST;
} else if (inventory instanceof InventoryMerchant) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
index 947c493..eed9afa 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryCustom.java
@@ -31,168 +31,4 @@ public class CraftInventoryCustom extends CraftInventory {
public CraftInventoryCustom(InventoryHolder owner, int size, String title) {
super(new MinecraftInventory(owner, size, title));
}
-
- static class MinecraftInventory implements IInventory {
- private final ItemStack[] items;
- private int maxStack = MAX_STACK;
- private final List<HumanEntity> viewers;
- private final String title;
- private InventoryType type;
- private final InventoryHolder owner;
-
- public MinecraftInventory(InventoryHolder owner, InventoryType type) {
- this(owner, type.getDefaultSize(), type.getDefaultTitle());
- this.type = type;
- }
-
- public MinecraftInventory(InventoryHolder owner, InventoryType type, String title) {
- this(owner, type.getDefaultSize(), title);
- this.type = type;
- }
-
- public MinecraftInventory(InventoryHolder owner, int size) {
- this(owner, size, "Chest");
- }
-
- public MinecraftInventory(InventoryHolder owner, int size, String title) {
- Validate.notNull(title, "Title cannot be null");
- Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters");
- this.items = new ItemStack[size];
- this.title = title;
- this.viewers = new ArrayList<HumanEntity>();
- this.owner = owner;
- this.type = InventoryType.CHEST;
- }
-
- public int getSize() {
- return items.length;
- }
-
- public ItemStack getItem(int i) {
- return items[i];
- }
-
- public ItemStack splitStack(int i, int j) {
- ItemStack stack = this.getItem(i);
- ItemStack result;
- if (stack == null) return null;
- if (stack.count <= j) {
- this.setItem(i, null);
- result = stack;
- } else {
- result = CraftItemStack.copyNMSStack(stack, j);
- stack.count -= j;
- }
- this.update();
- return result;
- }
-
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack stack = this.getItem(i);
- ItemStack result;
- if (stack == null) return null;
- if (stack.count <= 1) {
- this.setItem(i, null);
- result = stack;
- } else {
- result = CraftItemStack.copyNMSStack(stack, 1);
- stack.count -= 1;
- }
- return result;
- }
-
- public void setItem(int i, ItemStack itemstack) {
- items[i] = itemstack;
- if (itemstack != null && this.getMaxStackSize() > 0 && itemstack.count > this.getMaxStackSize()) {
- itemstack.count = this.getMaxStackSize();
- }
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public void update() {}
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public ItemStack[] getContents() {
- return items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- viewers.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- viewers.remove(who);
- }
-
- public List<HumanEntity> getViewers() {
- return viewers;
- }
-
- public InventoryType getType() {
- return type;
- }
-
- public InventoryHolder getOwner() {
- return owner;
- }
-
- public boolean b(int i, ItemStack itemstack) {
- return true;
- }
-
- @Override
- public void startOpen(EntityHuman entityHuman) {
-
- }
-
- @Override
- public void closeContainer(EntityHuman entityHuman) {
-
- }
-
- @Override
- public int getProperty(int i) {
- return 0;
- }
-
- @Override
- public void b(int i, int i1) {
-
- }
-
- @Override
- public int g() {
- return 0;
- }
-
- @Override
- public void l() {
-
- }
-
- @Override
- public String getName() {
- return title;
- }
-
- @Override
- public boolean hasCustomName() {
- return title != null;
- }
-
- @Override
- public IChatBaseComponent getScoreboardDisplayName() {
- return new ChatComponentText(title);
- }
- }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index 23f05f4..fdaf026 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -26,7 +26,7 @@ import net.minecraft.server.NBTTagString;
import org.bukkit.craftbukkit.util.CraftChatMessage;
@DelegateDeserialization(ItemStack.class)
-public final class CraftItemStack extends ItemStack {
+public class CraftItemStack extends ItemStack {
public static net.minecraft.server.ItemStack asNMSCopy(ItemStack original) {
if (original instanceof CraftItemStack) {
@@ -95,26 +95,30 @@ public final class CraftItemStack extends ItemStack {
/**
* Mirror
*/
- private CraftItemStack(net.minecraft.server.ItemStack item) {
+ protected CraftItemStack(net.minecraft.server.ItemStack item) {
this.handle = item;
}
- private CraftItemStack(ItemStack item) {
+ protected CraftItemStack(ItemStack item) {
this(item.getTypeId(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null);
}
- private CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) {
+ protected CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) {
setType(type);
setAmount(amount);
setDurability(durability);
setItemMeta(itemMeta);
}
- private CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) {
+ protected CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) {
this(Material.getMaterial(typeId), amount, durability, itemMeta);
}
+ public net.minecraft.server.ItemStack getHandle() {
+ return handle;
+ }
+
@Override
public int getTypeId() {
return handle != null ? CraftMagicNumbers.getId(handle.getItem()) : 0;
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java
new file mode 100644
index 0000000..f0d8f81
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/MinecraftInventory.java
@@ -0,0 +1,177 @@
+package org.bukkit.craftbukkit.inventory;
+
+import net.minecraft.server.*;
+import org.apache.commons.lang.Validate;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.inventory.InventoryHolder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MinecraftInventory implements IInventory
+{
+ private final ItemStack[] items;
+ private int maxStack = MAX_STACK;
+ private final List<HumanEntity> viewers;
+ private final String title;
+ private InventoryType type;
+ private final InventoryHolder owner;
+
+ public MinecraftInventory(InventoryHolder owner, InventoryType type) {
+ this(owner, type.getDefaultSize(), type.getDefaultTitle());
+ this.type = type;
+ }
+
+ public MinecraftInventory(InventoryHolder owner, InventoryType type, String title) {
+ this(owner, type.getDefaultSize(), title);
+ this.type = type;
+ }
+
+ public MinecraftInventory(InventoryHolder owner, int size) {
+ this(owner, size, "Chest");
+ }
+
+ public MinecraftInventory(InventoryHolder owner, int size, String title) {
+ Validate.notNull(title, "Title cannot be null");
+ Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters");
+ this.items = new ItemStack[size];
+ this.title = title;
+ this.viewers = new ArrayList<HumanEntity>();
+ this.owner = owner;
+ this.type = InventoryType.CHEST;
+ }
+
+ public int getSize() {
+ return items.length;
+ }
+
+ public ItemStack getItem(int i) {
+ return items[i];
+ }
+
+ public ItemStack splitStack(int i, int j) {
+ ItemStack stack = this.getItem(i);
+ ItemStack result;
+ if (stack == null) return null;
+ if (stack.count <= j) {
+ this.setItem(i, null);
+ result = stack;
+ } else {
+ result = CraftItemStack.copyNMSStack(stack, j);
+ stack.count -= j;
+ }
+ this.update();
+ return result;
+ }
+
+ public ItemStack splitWithoutUpdate(int i) {
+ ItemStack stack = this.getItem(i);
+ ItemStack result;
+ if (stack == null) return null;
+ if (stack.count <= 1) {
+ this.setItem(i, null);
+ result = stack;
+ } else {
+ result = CraftItemStack.copyNMSStack(stack, 1);
+ stack.count -= 1;
+ }
+ return result;
+ }
+
+ public void setItem(int i, ItemStack itemstack) {
+ items[i] = itemstack;
+ if (itemstack != null && this.getMaxStackSize() > 0 && itemstack.count > this.getMaxStackSize()) {
+ itemstack.count = this.getMaxStackSize();
+ }
+ }
+
+ public int getMaxStackSize() {
+ return maxStack;
+ }
+
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
+
+ public void update() {}
+
+ public boolean a(EntityHuman entityhuman) {
+ return true;
+ }
+
+ public ItemStack[] getContents() {
+ return items;
+ }
+
+ public void onOpen(CraftHumanEntity who) {
+ viewers.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who) {
+ viewers.remove(who);
+ }
+
+ public List<HumanEntity> getViewers() {
+ return viewers;
+ }
+
+ public InventoryType getType() {
+ return type;
+ }
+
+ public InventoryHolder getOwner() {
+ return owner;
+ }
+
+ public boolean b(int i, ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public void startOpen(EntityHuman entityHuman) {
+
+ }
+
+ @Override
+ public void closeContainer(EntityHuman entityHuman) {
+
+ }
+
+ @Override
+ public int getProperty(int i) {
+ return 0;
+ }
+
+ @Override
+ public void b(int i, int i1) {
+
+ }
+
+ @Override
+ public int g() {
+ return 0;
+ }
+
+ @Override
+ public void l() {
+
+ }
+
+ @Override
+ public String getName() {
+ return title;
+ }
+
+ @Override
+ public boolean hasCustomName() {
+ return title != null;
+ }
+
+ @Override
+ public IChatBaseComponent getScoreboardDisplayName() {
+ return new ChatComponentText(title);
+ }
+}
--
1.9.5.msysgit.0

View File

@ -0,0 +1,277 @@
From 088fc9372c061edac80ee5cce669382ebed0b1e3 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 23 Oct 2015 21:23:00 +1300
Subject: [PATCH] Misc changes
diff --git a/src/main/java/net/minecraft/server/ControllerLook.java b/src/main/java/net/minecraft/server/ControllerLook.java
new file mode 100644
index 0000000..2263d5d
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ControllerLook.java
@@ -0,0 +1,101 @@
+package net.minecraft.server;
+
+public class ControllerLook
+{
+ private EntityInsentient a;
+ private float b;
+ private float c;
+ private boolean d;
+ private double e;
+ private double f;
+ private double g;
+
+ public ControllerLook(EntityInsentient paramEntityInsentient)
+ {
+ this.a = paramEntityInsentient;
+ }
+
+ public void a(Entity paramEntity, float paramFloat1, float paramFloat2) {
+ this.e = paramEntity.locX;
+ if ((paramEntity instanceof EntityLiving))
+ this.f = (paramEntity.locY + paramEntity.getHeadHeight());
+ else {
+ this.f = ((paramEntity.getBoundingBox().b + paramEntity.getBoundingBox().e) / 2.0D);
+ }
+ this.g = paramEntity.locZ;
+ this.b = paramFloat1;
+ this.c = paramFloat2;
+ this.d = true;
+ }
+
+ public void a(double paramDouble1, double paramDouble2, double paramDouble3, float paramFloat1, float paramFloat2) {
+ this.e = paramDouble1;
+ this.f = paramDouble2;
+ this.g = paramDouble3;
+ this.b = paramFloat1;
+ this.c = paramFloat2;
+ this.d = true;
+ }
+
+ public void a() {
+ if (a.isVegetated())
+ return;
+ this.a.pitch = 0.0F;
+
+ if (this.d) {
+ this.d = false;
+
+ double d1 = this.e - this.a.locX;
+ double d2 = this.f - (this.a.locY + this.a.getHeadHeight());
+ double d3 = this.g - this.a.locZ;
+ double d4 = MathHelper.sqrt(d1 * d1 + d3 * d3);
+
+ float f1 = (float)(MathHelper.b(d3, d1) * 180.0D / 3.141592741012573D) - 90.0F;
+ float f2 = (float)-(MathHelper.b(d2, d4) * 180.0D / 3.141592741012573D);
+ this.a.pitch = a(this.a.pitch, f2, this.c);
+ this.a.aK = a(this.a.aK, f1, this.b);
+ } else {
+ this.a.aK = a(this.a.aK, this.a.aI, 10.0F);
+ }
+
+ float f3 = MathHelper.g(this.a.aK - this.a.aI);
+
+ if (!this.a.getNavigation().m())
+ {
+ if (f3 < -75.0F) {
+ this.a.aK = (this.a.aI - 75.0F);
+ }
+ if (f3 > 75.0F)
+ this.a.aK = (this.a.aI + 75.0F);
+ }
+ }
+
+ private float a(float paramFloat1, float paramFloat2, float paramFloat3)
+ {
+ float f1 = MathHelper.g(paramFloat2 - paramFloat1);
+ if (f1 > paramFloat3) {
+ f1 = paramFloat3;
+ }
+ if (f1 < -paramFloat3) {
+ f1 = -paramFloat3;
+ }
+ return paramFloat1 + f1;
+ }
+
+ public boolean b() {
+ return this.d;
+ }
+
+ public double e()
+ {
+ return this.e;
+ }
+
+ public double f() {
+ return this.f;
+ }
+
+ public double g() {
+ return this.g;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
index c30867d..b86369b 100644
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
@@ -132,7 +132,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
System.err.println( "If you do not agree to the above EULA please stop your server and remove this flag immediately." );
}
// Spigot End
- if (!this.p.a() && !eulaAgreed) { // Spigot
+ if (false && !this.p.a() && !eulaAgreed) { // Spigot
DedicatedServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
this.p.b();
return false;
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index eb54e7f..66c3d0c 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -133,7 +133,7 @@ public abstract class EntityHuman extends EntityLiving {
if (this.g != null) {
ItemStack itemstack = this.inventory.getItemInHand();
- if (itemstack == this.g) {
+ if (ItemStack.equals(itemstack, this.g)) {
if (this.h <= 25 && this.h % 4 == 0) {
this.b(itemstack, 5);
}
diff --git a/src/main/java/net/minecraft/server/TileEntityBeacon.java b/src/main/java/net/minecraft/server/TileEntityBeacon.java
index 4f280dd..73a288c 100644
--- a/src/main/java/net/minecraft/server/TileEntityBeacon.java
+++ b/src/main/java/net/minecraft/server/TileEntityBeacon.java
@@ -59,7 +59,7 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
this.A();
}
- private void A() {
+ public void A() {
if (this.i && this.j > 0 && !this.world.isClientSide && this.k > 0) {
double d0 = (double) (this.j * 10 + 10);
byte b0 = 0;
@@ -94,7 +94,7 @@ public class TileEntityBeacon extends TileEntityContainer implements IUpdatePlay
}
- private void B() {
+ public void B() {
int i = this.j;
int j = this.position.getX();
int k = this.position.getY();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 2759425..f57c785 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -412,7 +412,7 @@ public final class CraftServer implements Server {
int delta = Integer.MAX_VALUE;
for (Player player : getOnlinePlayers()) {
if (player.getName().toLowerCase().startsWith(lowerName)) {
- int curDelta = Math.abs(player.getName().length() - lowerName.length());
+ int curDelta = player.getName().length() - lowerName.length();
if (curDelta < delta) {
found = player;
delta = curDelta;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 49c7fa6..0cd36e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -836,7 +836,7 @@ public class CraftWorld implements World {
public <T> void playEffect(Location loc, Effect effect, T data, int radius) {
if (data != null) {
- Validate.isTrue(data.getClass().isAssignableFrom(effect.getData()), "Wrong kind of data for this effect!");
+ Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
} else {
Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!");
}
@@ -1122,10 +1122,6 @@ public class CraftWorld implements World {
public <T extends Entity> T addEntity(net.minecraft.server.Entity entity, SpawnReason reason) throws IllegalArgumentException {
Preconditions.checkArgument(entity != null, "Cannot spawn null entity");
- if (entity instanceof EntityInsentient) {
- ((EntityInsentient) entity).prepare(getHandle().E(new BlockPosition(entity)), (GroupDataEntity) null);
- }
-
world.addEntity(entity, reason);
return (T) entity.getBukkitEntity();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 29082aa..e979f69 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -325,7 +325,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public <T> void playEffect(Location loc, Effect effect, T data) {
if (data != null) {
- Validate.isTrue(data.getClass().isAssignableFrom(effect.getData()), "Wrong kind of data for this effect!");
+ Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
} else {
Validate.isTrue(effect.getData() == null, "Wrong kind of data for this effect!");
}
@@ -870,10 +870,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public void hidePlayer(Player player) {
+ hidePlayer(player, false, true);
+ }
+
+ public void hidePlayer(Player player, boolean override, boolean hideList)
+ {
Validate.notNull(player, "hidden player cannot be null");
if (getHandle().playerConnection == null) return;
if (equals(player)) return;
- if (hiddenPlayers.contains(player.getUniqueId())) return;
+ if (!override && hiddenPlayers.contains(player.getUniqueId())) return;
hiddenPlayers.add(player.getUniqueId());
//remove this player from the hidden player's EntityTrackerEntry
@@ -885,11 +890,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
//remove the hidden player from this player user list
- getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, other));
+ if (hideList)
+ getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, other));
}
@Override
public void showPlayer(Player player) {
+ showPlayer(player, true);
+ }
+
+ public void showPlayer(Player player, boolean showList)
+ {
Validate.notNull(player, "shown player cannot be null");
if (getHandle().playerConnection == null) return;
if (equals(player)) return;
@@ -899,7 +910,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
EntityTracker tracker = ((WorldServer) entity.world).tracker;
EntityPlayer other = ((CraftPlayer) player).getHandle();
- getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other));
+ if (showList)
+ getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, other));
EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.getId());
if (entry != null && !entry.trackedPlayers.contains(getHandle())) {
@@ -1363,13 +1375,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public boolean getCollidesWithEntities()
{
- return getHandle().collidesWithEntities;
+ return !getHandle().spectating;
}
@Override
public void setCollidesWithEntities(boolean collides)
{
- getHandle().collidesWithEntities = collides;
+ getHandle().spectating = collides;
getHandle().k = collides; // First boolean of Entity
}
--
1.9.5.msysgit.0

View File

@ -0,0 +1,605 @@
From 9aded83bc47bf6ba8076fc2ed03ebbe480df1296 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 28 Oct 2015 09:00:24 +1300
Subject: [PATCH] EntityGuardian is now vegetateable
diff --git a/src/main/java/net/minecraft/server/EntityGuardian.java b/src/main/java/net/minecraft/server/EntityGuardian.java
new file mode 100644
index 0000000..c14caf2
--- /dev/null
+++ b/src/main/java/net/minecraft/server/EntityGuardian.java
@@ -0,0 +1,590 @@
+package net.minecraft.server;
+
+import com.google.common.base.Predicate;
+import java.util.*;
+
+public class EntityGuardian extends EntityMonster
+{
+ static class ControllerMoveGuardian extends ControllerMove
+ {
+
+ public void c()
+ {
+ if(!this.f || g.getNavigation().m())
+ {
+ g.k(0.0F);
+ EntityGuardian.a(g, false);
+ return;
+ }
+ double d = b - g.locX;
+ double d1 = c - g.locY;
+ double d2 = this.d - g.locZ;
+ double d3 = d * d + d1 * d1 + d2 * d2;
+ d3 = MathHelper.sqrt(d3);
+ d1 /= d3;
+ float f = (float)((MathHelper.b(d2, d) * 180D) / 3.1415927410125732D) - 90F;
+ g.yaw = a(g.yaw, f, 30F);
+ g.aI = g.yaw;
+ float f1 = (float)(e * g.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue());
+ g.k(g.bI() + (f1 - g.bI()) * 0.125F);
+ double d4 = Math.sin((double)(g.ticksLived + g.getId()) * 0.5D) * 0.050000000000000003D;
+ double d5 = Math.cos((g.yaw * 3.141593F) / 180F);
+ double d6 = Math.sin((g.yaw * 3.141593F) / 180F);
+ g.motX += d4 * d5;
+ g.motZ += d4 * d6;
+ d4 = Math.sin((double)(g.ticksLived + g.getId()) * 0.75D) * 0.050000000000000003D;
+ g.motY += d4 * (d6 + d5) * 0.25D;
+ g.motY += (double)g.bI() * d1 * 0.10000000000000001D;
+ ControllerLook controllerlook = g.getControllerLook();
+ double d7 = g.locX + (d / d3) * 2D;
+ double d8 = (double)g.getHeadHeight() + g.locY + (d1 / d3) * 1.0D;
+ double d9 = g.locZ + (d2 / d3) * 2D;
+ double d10 = controllerlook.e();
+ double d11 = controllerlook.f();
+ double d12 = controllerlook.g();
+ if(!controllerlook.b())
+ {
+ d10 = d7;
+ d11 = d8;
+ d12 = d9;
+ }
+ g.getControllerLook().a(d10 + (d7 - d10) * 0.125D, d11 + (d8 - d11) * 0.125D, d12 + (d9 - d12) * 0.125D, 10F, 40F);
+ EntityGuardian.a(g, true);
+ }
+
+ private EntityGuardian g;
+
+ public ControllerMoveGuardian(EntityGuardian entityguardian)
+ {
+ super(entityguardian);
+ g = entityguardian;
+ }
+ }
+
+ static class PathfinderGoalGuardianAttack extends PathfinderGoal
+ {
+
+ public boolean a()
+ {
+ EntityLiving entityliving = a.getGoalTarget();
+ return entityliving != null && entityliving.isAlive();
+ }
+
+ public boolean b()
+ {
+ return super.b() && (a.isElder() || a.h(a.getGoalTarget()) > 9D);
+ }
+
+ public void c()
+ {
+ b = -10;
+ a.getNavigation().n();
+ a.getControllerLook().a(a.getGoalTarget(), 90F, 90F);
+ a.ai = true;
+ }
+
+ public void d()
+ {
+ EntityGuardian.a(a, 0);
+ a.setGoalTarget(null);
+ EntityGuardian.a(a).f();
+ }
+
+ public void e()
+ {
+ EntityLiving entityliving = a.getGoalTarget();
+ a.getNavigation().n();
+ a.getControllerLook().a(entityliving, 90F, 90F);
+ if(!a.hasLineOfSight(entityliving))
+ {
+ a.setGoalTarget(null);
+ return;
+ }
+ b++;
+ if(b == 0)
+ {
+ EntityGuardian.a(a, a.getGoalTarget().getId());
+ a.world.broadcastEntityEffect(a, (byte)21);
+ } else
+ if(b >= a.cm())
+ {
+ float f = 1.0F;
+ if(a.world.getDifficulty() == EnumDifficulty.HARD)
+ f += 2.0F;
+ if(a.isElder())
+ f += 2.0F;
+ entityliving.damageEntity(DamageSource.b(a, a), f);
+ entityliving.damageEntity(DamageSource.mobAttack(a), (float)a.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).getValue());
+ a.setGoalTarget(null);
+ } else
+ if(b >= 60)
+ if(b % 20 != 0);
+ super.e();
+ }
+
+ private EntityGuardian a;
+ private int b;
+
+ public PathfinderGoalGuardianAttack(EntityGuardian entityguardian)
+ {
+ a = entityguardian;
+ a(3);
+ }
+ }
+
+ static class EntitySelectorGuardianTargetHumanSquid
+ implements Predicate
+ {
+
+ public boolean a(EntityLiving entityliving)
+ {
+ return ((entityliving instanceof EntityHuman) || (entityliving instanceof EntitySquid)) && entityliving.h(a) > 9D;
+ }
+
+ public boolean apply(Object obj)
+ {
+ return a((EntityLiving)obj);
+ }
+
+ private EntityGuardian a;
+
+ public EntitySelectorGuardianTargetHumanSquid(EntityGuardian entityguardian)
+ {
+ a = entityguardian;
+ }
+ }
+
+
+ public EntityGuardian(World world)
+ {
+ super(world);
+ b_ = 10;
+ setSize(0.85F, 0.85F);
+ goalSelector.a(4, new PathfinderGoalGuardianAttack(this));
+ PathfinderGoalMoveTowardsRestriction pathfindergoalmovetowardsrestriction;
+ goalSelector.a(5, pathfindergoalmovetowardsrestriction = new PathfinderGoalMoveTowardsRestriction(this, 1.0D));
+ goalSelector.a(7, goalRandomStroll = new PathfinderGoalRandomStroll(this, 1.0D, 80));
+ goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 8F));
+ goalSelector.a(8, new PathfinderGoalLookAtPlayer(this, EntityGuardian.class, 12F, 0.01F));
+ goalSelector.a(9, new PathfinderGoalRandomLookaround(this));
+ goalRandomStroll.a(3);
+ pathfindergoalmovetowardsrestriction.a(3);
+ targetSelector.a(1, new PathfinderGoalNearestAttackableTarget(this, EntityLiving.class, 10, true, false, new EntitySelectorGuardianTargetHumanSquid(this)));
+ moveController = new ControllerMoveGuardian(this);
+ b = a = random.nextFloat();
+ }
+
+ public void initAttributes()
+ {
+ super.initAttributes();
+ getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(6D);
+ getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.5D);
+ getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(16D);
+ getAttributeInstance(GenericAttributes.maxHealth).setValue(30D);
+ }
+
+ public void a(NBTTagCompound nbttagcompound)
+ {
+ super.a(nbttagcompound);
+ setElder(nbttagcompound.getBoolean("Elder"));
+ }
+
+ public void b(NBTTagCompound nbttagcompound)
+ {
+ super.b(nbttagcompound);
+ nbttagcompound.setBoolean("Elder", isElder());
+ }
+
+ protected NavigationAbstract b(World world)
+ {
+ return new NavigationGuardian(this, world);
+ }
+
+ protected void h()
+ {
+ super.h();
+ datawatcher.a(16, Integer.valueOf(0));
+ datawatcher.a(17, Integer.valueOf(0));
+ }
+
+ private boolean a(int j)
+ {
+ return (datawatcher.getInt(16) & j) != 0;
+ }
+
+ private void a(int j, boolean flag)
+ {
+ int k = datawatcher.getInt(16);
+ if(flag)
+ datawatcher.watch(16, Integer.valueOf(k | j));
+ else
+ datawatcher.watch(16, Integer.valueOf(k & ~j));
+ }
+
+ public boolean n()
+ {
+ return a(2);
+ }
+
+ private void l(boolean flag)
+ {
+ a(2, flag);
+ }
+
+ public int cm()
+ {
+ return !isElder() ? 80 : 60;
+ }
+
+ public boolean isElder()
+ {
+ return a(4);
+ }
+
+ public void setElder(boolean flag)
+ {
+ a(4, flag);
+ if(flag)
+ {
+ setSize(1.9975F, 1.9975F);
+ getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.30000001192092896D);
+ getAttributeInstance(GenericAttributes.ATTACK_DAMAGE).setValue(8D);
+ getAttributeInstance(GenericAttributes.maxHealth).setValue(80D);
+ bX();
+ goalRandomStroll.setTimeBetweenMovement(400);
+ }
+ }
+
+ private void b(int j)
+ {
+ datawatcher.watch(17, Integer.valueOf(j));
+ }
+
+ public boolean cp()
+ {
+ return datawatcher.getInt(17) != 0;
+ }
+
+ public EntityLiving cq()
+ {
+ if(!cp())
+ return null;
+ if(world.isClientSide)
+ {
+ if(bo != null)
+ return bo;
+ Entity entity = world.a(datawatcher.getInt(17));
+ if(entity instanceof EntityLiving)
+ {
+ bo = (EntityLiving)entity;
+ return bo;
+ } else
+ {
+ return null;
+ }
+ } else
+ {
+ return getGoalTarget();
+ }
+ }
+
+ public void i(int j)
+ {
+ super.i(j);
+ if(j == 16)
+ {
+ if(isElder() && width < 1.0F)
+ setSize(1.9975F, 1.9975F);
+ } else
+ if(j == 17)
+ {
+ bp = 0;
+ bo = null;
+ }
+ }
+
+ public int w()
+ {
+ return 160;
+ }
+
+ protected String z()
+ {
+ if(!V())
+ return "mob.guardian.land.idle";
+ if(isElder())
+ return "mob.guardian.elder.idle";
+ else
+ return "mob.guardian.idle";
+ }
+
+ protected String bo()
+ {
+ if(!V())
+ return "mob.guardian.land.hit";
+ if(isElder())
+ return "mob.guardian.elder.hit";
+ else
+ return "mob.guardian.hit";
+ }
+
+ protected String bp()
+ {
+ if(!V())
+ return "mob.guardian.land.death";
+ if(isElder())
+ return "mob.guardian.elder.death";
+ else
+ return "mob.guardian.death";
+ }
+
+ protected boolean s_()
+ {
+ return false;
+ }
+
+ public float getHeadHeight()
+ {
+ return length * 0.5F;
+ }
+
+ public float a(BlockPosition blockposition)
+ {
+ if(world.getType(blockposition).getBlock().getMaterial() == Material.WATER)
+ return (10F + world.o(blockposition)) - 0.5F;
+ else
+ return super.a(blockposition);
+ }
+
+ public void m()
+ {
+ if(world.isClientSide)
+ {
+ b = a;
+ if(!V())
+ {
+ c = 2.0F;
+ if(motY > 0.0D && bq && !R())
+ world.a(locX, locY, locZ, "mob.guardian.flop", 1.0F, 1.0F, false);
+ bq = motY < 0.0D && world.d((new BlockPosition(this)).down(), false);
+ } else
+ if(n())
+ {
+ if(c < 0.5F)
+ c = 4F;
+ else
+ c = c + (0.5F - c) * 0.1F;
+ } else
+ {
+ c = c + (0.125F - c) * 0.2F;
+ }
+ a += c;
+ bn = bm;
+ if(!V())
+ bm = random.nextFloat();
+ else
+ if(n())
+ bm = bm + (0.0F - bm) * 0.25F;
+ else
+ bm = bm + (1.0F - bm) * 0.06F;
+ if(n() && V())
+ {
+ Vec3D vec3d = d(0.0F);
+ for(int j = 0; j < 2; j++)
+ world.addParticle(EnumParticle.WATER_BUBBLE, (locX + (random.nextDouble() - 0.5D) * (double)width) - vec3d.a * 1.5D, (locY + random.nextDouble() * (double)length) - vec3d.b * 1.5D, (locZ + (random.nextDouble() - 0.5D) * (double)width) - vec3d.c * 1.5D, 0.0D, 0.0D, 0.0D, new int[0]);
+
+ }
+ if(cp())
+ {
+ if(bp < cm())
+ bp++;
+ EntityLiving entityliving = cq();
+ if(entityliving != null)
+ {
+ getControllerLook().a(entityliving, 90F, 90F);
+ getControllerLook().a();
+ double d = q(0.0F);
+ double d1 = entityliving.locX - locX;
+ double d2 = (entityliving.locY + (double)(entityliving.length * 0.5F)) - (locY + (double)getHeadHeight());
+ double d3 = entityliving.locZ - locZ;
+ double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
+ d1 /= d4;
+ d2 /= d4;
+ d3 /= d4;
+ for(double d5 = random.nextDouble(); d5 < d4;)
+ {
+ d5 += (1.8D - d) + random.nextDouble() * (1.7D - d);
+ world.addParticle(EnumParticle.WATER_BUBBLE, locX + d1 * d5, locY + d2 * d5 + (double)getHeadHeight(), locZ + d3 * d5, 0.0D, 0.0D, 0.0D, new int[0]);
+ }
+
+ }
+ }
+ }
+ if(isVegetated() || inWater)
+ setAirTicks(300);
+ else
+ if(onGround)
+ {
+ motY += 0.5D;
+ motX += (random.nextFloat() * 2.0F - 1.0F) * 0.4F;
+ motZ += (random.nextFloat() * 2.0F - 1.0F) * 0.4F;
+ yaw = random.nextFloat() * 360F;
+ onGround = false;
+ ai = true;
+ }
+ if(cp())
+ yaw = aK;
+ super.m();
+ }
+
+ public float q(float f)
+ {
+ return ((float)bp + f) / (float)cm();
+ }
+
+ protected void E()
+ {
+ super.E();
+ if(isElder())
+ {
+ int i = 1200;
+ int j = 1200;
+ int k = 6000;
+ int m = 2;
+
+ if ((this.ticksLived + getId()) % 1200 == 0) {
+ MobEffectList mobeffectlist = MobEffectList.SLOWER_DIG;
+ List list = world.b(EntityPlayer.class, new Predicate() {
+
+ public boolean a(EntityPlayer entityplayer1)
+ {
+ return h(entityplayer1) < 2500D && entityplayer1.playerInteractManager.c();
+ }
+
+ public boolean apply(Object obj)
+ {
+ return a((EntityPlayer)obj);
+ }
+ }
+);
+ Iterator iterator = list.iterator();
+ do
+ {
+ if(!iterator.hasNext())
+ break;
+ EntityPlayer entityplayer = (EntityPlayer)iterator.next();
+ if(!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < 2 || entityplayer.getEffect(mobeffectlist).getDuration() < 1200)
+ {
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(10, 0.0F));
+ entityplayer.addEffect(new MobEffect(mobeffectlist.id, 6000, 2));
+ }
+ } while(true);
+ }
+ if(!ck())
+ a(new BlockPosition(this), 16);
+ }
+ }
+
+ protected void dropDeathLoot(boolean flag, int j)
+ {
+ int k = random.nextInt(3) + random.nextInt(j + 1);
+ if(k > 0)
+ a(new ItemStack(Items.PRISMARINE_SHARD, k, 0), 1.0F);
+ if(random.nextInt(3 + j) > 1)
+ a(new ItemStack(Items.FISH, 1, ItemFish.EnumFish.COD.a()), 1.0F);
+ else
+ if(random.nextInt(3 + j) > 1)
+ a(new ItemStack(Items.PRISMARINE_CRYSTALS, 1, 0), 1.0F);
+ if(flag && isElder())
+ a(new ItemStack(Blocks.SPONGE, 1, 1), 1.0F);
+ }
+
+ protected void getRareDrop()
+ {
+ ItemStack itemstack = ((PossibleFishingResult)WeightedRandom.a(random, EntityFishingHook.j())).a(random);
+ a(itemstack, 1.0F);
+ }
+
+ protected boolean n_()
+ {
+ return true;
+ }
+
+ public boolean canSpawn()
+ {
+ return world.a(getBoundingBox(), this) && world.getCubes(this, getBoundingBox()).isEmpty();
+ }
+
+ public boolean bR()
+ {
+ return (random.nextInt(20) == 0 || !world.j(new BlockPosition(this))) && super.bR();
+ }
+
+ public boolean damageEntity(DamageSource damagesource, float f)
+ {
+ if(!n() && !damagesource.isMagic() && (damagesource.i() instanceof EntityLiving))
+ {
+ EntityLiving entityliving = (EntityLiving)damagesource.i();
+ if(!damagesource.isExplosion())
+ {
+ entityliving.damageEntity(DamageSource.a(this), 2.0F);
+ entityliving.makeSound("damage.thorns", 0.5F, 1.0F);
+ }
+ }
+ goalRandomStroll.f();
+ return super.damageEntity(damagesource, f);
+ }
+
+ public int bQ()
+ {
+ return 180;
+ }
+
+ public void g(float f, float f1)
+ {
+ if(bM())
+ {
+ if(V())
+ {
+ a(f, f1, 0.1F);
+ move(motX, motY, motZ);
+ motX *= 0.89999997615814209D;
+ motY *= 0.89999997615814209D;
+ motZ *= 0.89999997615814209D;
+ if(!n() && getGoalTarget() == null)
+ motY -= 0.0050000000000000001D;
+ } else
+ {
+ super.g(f, f1);
+ }
+ } else
+ {
+ super.g(f, f1);
+ }
+ }
+
+ static void a(EntityGuardian entityguardian, int j)
+ {
+ entityguardian.b(j);
+ }
+
+ static PathfinderGoalRandomStroll a(EntityGuardian entityguardian)
+ {
+ return entityguardian.goalRandomStroll;
+ }
+
+ static void a(EntityGuardian entityguardian, boolean flag)
+ {
+ entityguardian.l(flag);
+ }
+
+ private float a;
+ private float b;
+ private float c;
+ private float bm;
+ private float bn;
+ private EntityLiving bo;
+ private int bp;
+ private boolean bq;
+ public PathfinderGoalRandomStroll goalRandomStroll;
+}
--
1.9.5.msysgit.0

View File

@ -0,0 +1,43 @@
From d3b44ea22080f4d15bf45b74b46b989b29f7b039 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Fri, 30 Oct 2015 20:02:58 +1300
Subject: [PATCH] Controller look vegetateHead, Entity collide changes
diff --git a/src/main/java/net/minecraft/server/ControllerLook.java b/src/main/java/net/minecraft/server/ControllerLook.java
index 2263d5d..f2d7b1e 100644
--- a/src/main/java/net/minecraft/server/ControllerLook.java
+++ b/src/main/java/net/minecraft/server/ControllerLook.java
@@ -37,9 +37,15 @@ public class ControllerLook
this.d = true;
}
+ public void vegetateHead(boolean vegetate)
+ {
+ _vegeHead = vegetate;
+ }
+
+ private boolean _vegeHead;
+
public void a() {
- if (a.isVegetated())
- return;
+ if (_vegeHead)return;
this.a.pitch = 0.0F;
if (this.d) {
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index cb9ba53..8660762 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1087,6 +1087,7 @@ public abstract class Entity implements ICommandListener {
int numCollisions = 0; // Spigot
public void collide(Entity entity) {
if (entity.passenger != this && entity.vehicle != this) {
+ if ((!(entity instanceof EntityLiving) || !((EntityLiving) entity).isGhost()) && (!(this instanceof EntityLiving) || !((EntityLiving) this).isGhost()))
if (!entity.noclip && !this.noclip) {
double d0 = entity.locX - this.locX;
double d1 = entity.locZ - this.locZ;
--
1.9.5.msysgit.0

View File

@ -0,0 +1,139 @@
From a793ae3653b54c211b2c40147e031449d3e1cf72 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Tue, 3 Nov 2015 21:21:02 +1300
Subject: [PATCH] Vegetate head ai
diff --git a/src/main/java/net/minecraft/server/ControllerLook.java b/src/main/java/net/minecraft/server/ControllerLook.java
index f2d7b1e..1538ca6 100644
--- a/src/main/java/net/minecraft/server/ControllerLook.java
+++ b/src/main/java/net/minecraft/server/ControllerLook.java
@@ -9,6 +9,28 @@ public class ControllerLook
private double e;
private double f;
private double g;
+ private boolean _allowInput = true;
+ private boolean _resetPitch = true;
+
+ public boolean isPitchReset()
+ {
+ return _resetPitch;
+ }
+
+ public boolean setPitchReset(boolean resetPitch)
+ {
+ _resetPitch = resetPitch;
+ }
+
+ public boolean isAllowInput()
+ {
+ return _allowInput;
+ }
+
+ public void setAllowInput(boolean allowInput)
+ {
+ _allowInput = allowInput;
+ }
public ControllerLook(EntityInsentient paramEntityInsentient)
{
@@ -16,6 +38,9 @@ public class ControllerLook
}
public void a(Entity paramEntity, float paramFloat1, float paramFloat2) {
+
+ if (!isAllowInput())
+ return;
this.e = paramEntity.locX;
if ((paramEntity instanceof EntityLiving))
this.f = (paramEntity.locY + paramEntity.getHeadHeight());
@@ -29,6 +54,8 @@ public class ControllerLook
}
public void a(double paramDouble1, double paramDouble2, double paramDouble3, float paramFloat1, float paramFloat2) {
+ if (!isAllowInput())
+ return;
this.e = paramDouble1;
this.f = paramDouble2;
this.g = paramDouble3;
@@ -37,15 +64,8 @@ public class ControllerLook
this.d = true;
}
- public void vegetateHead(boolean vegetate)
- {
- _vegeHead = vegetate;
- }
-
- private boolean _vegeHead;
-
public void a() {
- if (_vegeHead)return;
+ if (isResetPitch())
this.a.pitch = 0.0F;
if (this.d) {
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index b7647bc..c2ef000 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -512,6 +512,7 @@ public abstract class EntityInsentient extends EntityLiving {
this.world.methodProfiler.a("move");
this.moveController.c();
this.world.methodProfiler.c("look");
+ if (!isVegetatedHead())
this.lookController.a();
this.world.methodProfiler.c("jump");
this.g.b();
@@ -542,6 +543,8 @@ public abstract class EntityInsentient extends EntityLiving {
float f2 = (float) (MathHelper.b(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
float f3 = (float) (-(MathHelper.b(d2, d3) * 180.0D / 3.1415927410125732D));
+ if (isVegetatedHead())
+ return;
this.pitch = this.b(this.pitch, f3, f1);
this.yaw = this.b(this.yaw, f2, f);
}
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index b861dbe..4de7e4c 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -113,6 +113,18 @@ public abstract class EntityLiving extends Entity {
_ghost = ghost;
}
+ private boolean _vegetateHead;
+
+ public boolean isHeadVegetated()
+ {
+ return _vegetateHead;
+ }
+
+ public void setHeadVegetated(boolean vegetateHead)
+ {
+ _vegetateHead = vegetateHead;
+ }
+
public EntityLiving(World world) {
super(world);
this.initAttributes();
@@ -1497,6 +1509,8 @@ public abstract class EntityLiving extends Entity {
SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
this.m();
+ if (isVegetatedHead())
+ return;
SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
double d0 = this.locX - this.lastX;
double d1 = this.locZ - this.lastZ;
@@ -1607,6 +1621,7 @@ public abstract class EntityLiving extends Entity {
this.pitch = (float) ((double) this.pitch + (this.bh - (double) this.pitch) / (double) this.bc);
--this.bc;
this.setPosition(d0, d1, d2);
+ if (!isHeadVegetated())
this.setYawPitch(this.yaw, this.pitch);
} else if (!this.bM()) {
this.motX *= 0.98D;
--
1.9.5.msysgit.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
From cddf775b575f0db92e478c858283869ac0b9bdc2 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Mon, 9 Nov 2015 00:07:26 +1300
Subject: [PATCH] Add IEntitySelector, have isGhost() return the same as
isSpectator()
diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
new file mode 100644
index 0000000..1536600
--- /dev/null
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
@@ -0,0 +1,103 @@
+package net.minecraft.server;
+
+import com.google.common.base.Predicate;
+
+public final class IEntitySelector
+{
+ public static class EntitySelectorEquipable
+ implements Predicate
+ {
+
+ public boolean a(Entity entity)
+ {
+ if(!entity.isAlive())
+ return false;
+ if(!(entity instanceof EntityLiving))
+ return false;
+ EntityLiving entityliving = (EntityLiving)entity;
+ if(entityliving.getEquipment(EntityInsentient.c(a)) != null)
+ return false;
+ if(entityliving instanceof EntityInsentient)
+ return ((EntityInsentient)entityliving).bY();
+ if(entityliving instanceof EntityArmorStand)
+ return true;
+ return entityliving instanceof EntityHuman;
+ }
+
+ public boolean apply(Object obj)
+ {
+ return a((Entity)obj);
+ }
+
+ private final ItemStack a;
+
+ public EntitySelectorEquipable(ItemStack itemstack)
+ {
+ a = itemstack;
+ }
+ }
+
+
+ public static final Predicate a = new Predicate() {
+
+ public boolean a(Entity entity)
+ {
+ return entity.isAlive();
+ }
+
+ public boolean apply(Object obj)
+ {
+ return a((Entity)obj);
+ }
+
+ }
+;
+ public static final Predicate b = new Predicate() {
+
+ public boolean a(Entity entity)
+ {
+ return entity.isAlive() && entity.passenger == null && entity.vehicle == null;
+ }
+
+ public boolean apply(Object obj)
+ {
+ return a((Entity)obj);
+ }
+
+ }
+;
+ public static final Predicate c = new Predicate() {
+
+ public boolean a(Entity entity)
+ {
+ return (entity instanceof IInventory) && entity.isAlive();
+ }
+
+ public boolean apply(Object obj)
+ {
+ return a((Entity)obj);
+ }
+
+ }
+;
+ public static final Predicate d = new Predicate() {
+
+ public boolean a(Entity entity)
+ {
+ if (entity instanceof EntityLiving && ((EntityLiving) entity).isGhost())
+ {
+ return false;
+ }
+
+ return !(entity instanceof EntityHuman) || !((EntityHuman)entity).isSpectator();
+ }
+
+ public boolean apply(Object obj)
+ {
+ return a((Entity)obj);
+ }
+
+ }
+;
+
+}
--
1.9.5.msysgit.0

View File

@ -0,0 +1,22 @@
From e81762b9aa4f28474b2ccd06ae6ad5b7c840e1ba Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Mon, 9 Nov 2015 00:13:21 +1300
Subject: [PATCH] Add player spectator
diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
index 1536600..f86cf48 100644
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
@@ -89,7 +89,7 @@ public final class IEntitySelector
return false;
}
- return !(entity instanceof EntityHuman) || !((EntityHuman)entity).isSpectator();
+ return !(entity instanceof EntityHuman) || !(((EntityHuman)entity).isSpectator() && !((EntityPlayer)entity).spectating);
}
public boolean apply(Object obj)
--
1.9.5.msysgit.0

View File

@ -0,0 +1,22 @@
From 5dac54f90504022449cbd5ea23e5306f17523fe2 Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Mon, 9 Nov 2015 02:41:31 +1300
Subject: [PATCH] Fixed ai typo
diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
index f86cf48..b4d70ad 100644
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
@@ -89,7 +89,7 @@ public final class IEntitySelector
return false;
}
- return !(entity instanceof EntityHuman) || !(((EntityHuman)entity).isSpectator() && !((EntityPlayer)entity).spectating);
+ return !(entity instanceof EntityHuman) || !(((EntityHuman)entity).isSpectator() || ((EntityPlayer)entity).spectating);
}
public boolean apply(Object obj)
--
1.9.5.msysgit.0

View File

@ -0,0 +1,64 @@
From ea74383b4c0f5160f0d890d9377bd0d72e31db0c Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 11 Nov 2015 00:21:54 +1300
Subject: [PATCH] Fix casting bug
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 60e8584..746961e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -76,32 +76,44 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
public boolean shouldBreakLeash()
{
- return ((EntityInsentient) getHandle()).shouldBreakLeash();
+ if (getHandle() instanceof EntityInsentient)
+ return ((EntityInsentient) getHandle()).shouldBreakLeash();
+
+ return false;
}
public void setShouldBreakLeash(boolean shouldBreakLeash)
{
- ((EntityInsentient) getHandle()).setShouldBreakLeash(shouldBreakLeash);
+ if (getHandle() instanceof EntityInsentient)
+ ((EntityInsentient) getHandle()).setShouldBreakLeash(shouldBreakLeash);
}
public boolean shouldPullWhileLeashed()
{
- return ((EntityInsentient) getHandle()).shouldPullWhileLeashed();
+ if (getHandle() instanceof EntityInsentient)
+ return ((EntityInsentient) getHandle()).shouldPullWhileLeashed();
+
+ return false;
}
public void setPullWhileLeashed(boolean pullWhileLeashed)
{
- ((EntityInsentient) getHandle()).setPullWhileLeashed(pullWhileLeashed);
+ if (getHandle() instanceof EntityInsentient)
+ ((EntityInsentient) getHandle()).setPullWhileLeashed(pullWhileLeashed);
}
public boolean isVegetated()
{
- return ((EntityInsentient) getHandle()).isVegetated();
+ if (getHandle() instanceof EntityInsentient)
+ return ((EntityInsentient) getHandle()).isVegetated();
+
+ return false;
}
public void setVegetated(boolean vegetated)
{
- ((EntityInsentient) getHandle()).setVegetated(vegetated);
+ if (getHandle() instanceof EntityInsentient)
+ ((EntityInsentient) getHandle()).setVegetated(vegetated);
}
public boolean isGhost()
--
1.9.5.msysgit.0

View File

@ -6,6 +6,8 @@
<directory url="file://$PROJECT_DIR$/Nautilus.Game.PvP" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.ServerMonitor" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.Game.Clans" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Nautilus.Game.Arcade" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.Hub" includeSubdirectories="true" />
</excludeFromCompile>
<resourceExtensions />
<wildcardResourcePatterns>
@ -24,7 +26,7 @@
</profile>
<profile default="false" name="Annotation profile for bungee" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<sourceTestOutputDir name="target\generated-test-sources\test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
</profile>

View File

@ -11,6 +11,9 @@
<fileset dir="../Mineplex.Database/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.PlayerCache/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.EnjinTranslator/bin">
<include name="**/*.class"/>

View File

@ -1,73 +0,0 @@
package net.minecraft.server.v1_7_R4;
import java.io.IOException;
public class PacketPlayOutChat
extends Packet
{
private IChatBaseComponent a;
private boolean b;
private byte _chatType = 0;
public PacketPlayOutChat()
{
this.b = true;
}
public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent)
{
this(ichatbasecomponent, true);
}
public PacketPlayOutChat(IChatBaseComponent ichatbasecomponent, boolean flag)
{
this.b = true;
this.a = ichatbasecomponent;
this.b = flag;
}
public PacketPlayOutChat(String text)
{
this(ChatSerializer.a(text));
}
public void a(PacketDataSerializer packetdataserializer)
throws IOException
{
this.a = ChatSerializer.a(packetdataserializer.c(32767));
}
public void b(PacketDataSerializer packetdataserializer)
throws IOException
{
packetdataserializer.a(ChatSerializer.a(this.a));
if (packetdataserializer.version >= 16) {
packetdataserializer.writeByte(_chatType);
}
}
public void setChatType(byte chatType)
{
_chatType = chatType;
}
public void a(PacketPlayOutListener packetplayoutlistener)
{
packetplayoutlistener.a(this);
}
public String b()
{
return String.format("message='%s'", new Object[] { this.a });
}
public boolean d()
{
return this.b;
}
public void handle(PacketListener packetlistener)
{
a((PacketPlayOutListener)packetlistener);
}
}

View File

@ -1,207 +0,0 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package net.minecraft.server.v1_7_R4;
import java.io.IOException;
import java.util.Calendar;
import java.util.Iterator;
import org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftScoreboard;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage;
import org.bukkit.scoreboard.Team;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import net.minecraft.util.com.mojang.authlib.properties.PropertyMap;
public class PacketPlayOutPlayerInfo extends Packet {
public static final String NOTCH_SKIN = "eyJ0aW1lc3RhbXAiOjE0Mjc4MjgyMzMwNDUsInByb2ZpbGVJZCI6IjA2OWE3OWY0NDRlOTQ3MjZhNWJlZmNhOTBlMzhhYWY1IiwicHJvZmlsZU5hbWUiOiJOb3RjaCIsImlzUHVibGljIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTExNmU2OWE4NDVlMjI3ZjdjYTFmZGRlOGMzNTdjOGM4MjFlYmQ0YmE2MTkzODJlYTRhMWY4N2Q0YWU5NCJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2Y2ODhlMGU2OTliM2Q5ZmU0NDhiNWJiNTBhM2EyODhmOWM1ODk3NjJiM2RhZTgzMDg4NDIxMjJkY2I4MSJ9fX0=";
public static final String NOTCH_SIGNATURE = "WrBmNqkpkjh6VJY26jOOMNS6oSOPi0MTm9WWc0t4EMUHchUbTd6/1sT2O2zz2s7xwmCeUxuIhvRREa+1bIPzIIbXJLjhxiBWMdTJbQhv6zBb1U2SZb7eb5cYrFTD6rvxy0rOarScxCBdeOXpr1coxrvN8a6VkgLhc/dGhFx0ZmORxELBLFiCNi+4WE//MI+KioAq84Gdf0ltT9ZLWdlHNFV2ynBgcx2MfNTA2lrpdKEUVOYD7xhPoOdHa5d1hzdDxbYPGDgM0FzYjzNUlBx8SLvHEpyBB7XyOsIGnfqrS0ltIDTq82wgLrEwDRncuQN18w6IiQbNK06MZBDyNnIp79mmUYvRj+Zl0dPBrZok2q2uQ08hZ87ufU3jhjY39kr+iEaPYMvfWaBxt3ALjopsZRCGSlEukMzITjeYxhfVKuQ0fhWKRfwWn/Jv2de2h+i+t7nulvN3MV3rJVrS6OXsx87p/vm9biU7Hs07T8VSGONfkxXmsgYEtY6m2egU5pmqFnsKM0MwwnZJ7Sxz2EjiPikoGzJzpv4ncj3rhelIKJKjDk9jSAz7nPzc8/UdOiTrfy4ezr3jFVAVatiKr+kS/HNXHWiCFdufhpG4DVCrSkwkFBJw030pJ6ICVhpuYq5yOswQB5QOp0JDWc2Rdth7SVmvxthSCL9G2ksfm+v7sKw=";
public static final int ADD_PLAYER = 0;
public static final int UPDATE_GAMEMODE = 1;
public static final int UPDATE_LATENCY = 2;
public static final int UPDATE_DISPLAY_NAME = 3;
public static final int REMOVE_PLAYER = 4;
public int action;
public GameProfile player;
public int gamemode;
public int ping;
public String username;
public String _tabName;
public PacketPlayOutPlayerInfo() {
}
public static PacketPlayOutPlayerInfo addPlayer(EntityPlayer player) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 0;
packet.username = player.listName;
packet.player = player.getProfile();
packet.ping = player.ping;
packet.gamemode = player.playerInteractManager.getGameMode().getId();
packet._tabName = getFormattedName(player);
return packet;
}
public static PacketPlayOutPlayerInfo updatePing(EntityPlayer player) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 2;
packet.username = player.listName;
packet.player = player.getProfile();
packet.ping = player.ping;
return packet;
}
public static PacketPlayOutPlayerInfo updateGamemode(EntityPlayer player) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 1;
packet.username = player.listName;
packet.player = player.getProfile();
packet.gamemode = player.playerInteractManager.getGameMode().getId();
return packet;
}
public static PacketPlayOutPlayerInfo updateDisplayName(EntityPlayer player) {
return updateDisplayName(player, getFormattedName(player));
}
public static PacketPlayOutPlayerInfo updateDisplayName(EntityPlayer player, String displayName)
{
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 3;
packet.username = player.listName;
packet.player = player.getProfile();
packet._tabName = displayName;
return packet;
}
public static PacketPlayOutPlayerInfo removePlayer(EntityPlayer player) {
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
packet.action = 4;
packet.username = player.listName;
packet.player = player.getProfile();
return packet;
}
public void a(PacketDataSerializer packetdataserializer) throws IOException {
}
public void b(PacketDataSerializer packetdataserializer) throws IOException {
if(packetdataserializer.version >= 20) {
Calendar c = Calendar.getInstance();
packetdataserializer.b(this.action);
packetdataserializer.b(1);
packetdataserializer.writeUUID(this.player.getId());
switch(this.action) {
case 0:
packetdataserializer.a(this.player.getName());
PropertyMap properties = this.player.getProperties();
// April Fools
if (isAprilFools() && properties.size() == 0)
{
// add texture if no textures exist
properties.put("textures", new Property("textures", NOTCH_SKIN, NOTCH_SIGNATURE));
}
packetdataserializer.b(properties.size());
Iterator var3 = properties.values().iterator();
while(var3.hasNext()) {
Property property = (Property)var3.next();
// April Fools
if (isAprilFools() && property.getName().equalsIgnoreCase("textures"))
{
System.out.println("Applying notch texture for : " + property.getName());
System.out.println("Skin: " + property.getValue());
System.out.println("Signature: " + property.getSignature());
packetdataserializer.a(property.getName());
packetdataserializer.a(NOTCH_SKIN);
packetdataserializer.writeBoolean(true);
packetdataserializer.a(NOTCH_SIGNATURE);
}
else
{
packetdataserializer.a(property.getName());
packetdataserializer.a(property.getValue());
packetdataserializer.writeBoolean(property.hasSignature());
if(property.hasSignature()) {
packetdataserializer.a(property.getSignature());
}
}
}
packetdataserializer.b(this.gamemode);
packetdataserializer.b(this.ping);
packetdataserializer.writeBoolean(this.username != null);
if(this.username != null) {
// packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this.username)[0]));
packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this._tabName)[0]));
}
break;
case 1:
packetdataserializer.b(this.gamemode);
break;
case 2:
packetdataserializer.b(this.ping);
break;
case 3:
packetdataserializer.writeBoolean(this.username != null);
if(this.username != null) {
// packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this.username)[0]));
packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this._tabName)[0]));
}
case 4:
}
} else {
packetdataserializer.a(this.username);
packetdataserializer.writeBoolean(this.action != 4);
packetdataserializer.writeShort(this.ping);
}
}
public void a(PacketPlayOutListener packetplayoutlistener) {
packetplayoutlistener.a(this);
}
public void handle(PacketListener packetlistener) {
this.a((PacketPlayOutListener)((PacketPlayOutListener)packetlistener));
}
private static String getFormattedName(EntityPlayer player)
{
String name = player.getName();
if (isAprilFools()) name = "Notch";
CraftScoreboard scoreboard = player.getBukkitEntity().getScoreboard();
if (scoreboard != null)
{
Team team = scoreboard.getPlayerTeam(player.getBukkitEntity());
if (team != null)
name = team.getPrefix() + name + team.getSuffix();
}
return name;
}
public static boolean isAprilFools()
{
Calendar c = Calendar.getInstance();
// return true;
return c.get(Calendar.MONTH) == Calendar.APRIL && c.get(Calendar.DAY_OF_MONTH) == 1;
}
}

View File

@ -1,121 +0,0 @@
package net.minecraft.server.v1_7_R4;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class PacketPlayOutScoreboardTeam
extends Packet
{
private String a = "";
private String b = "";
private String c = "";
private String d = "";
private String _nameTagVisibility;
private Collection e = new ArrayList();
private int f;
private int g;
public PacketPlayOutScoreboardTeam() {}
public PacketPlayOutScoreboardTeam(ScoreboardTeam scoreboardteam, int i)
{
this.a = scoreboardteam.getName();
this.f = i;
if ((i == 0) || (i == 2))
{
this.b = scoreboardteam.getDisplayName();
this.c = scoreboardteam.getPrefix();
this.d = scoreboardteam.getSuffix();
this.g = scoreboardteam.packOptionData();
this._nameTagVisibility = scoreboardteam.getNametagVisibility();
}
if (i == 0) {
this.e.addAll(scoreboardteam.getPlayerNameSet());
}
}
public PacketPlayOutScoreboardTeam(ScoreboardTeam scoreboardteam, Collection collection, int i)
{
if ((i != 3) && (i != 4)) {
throw new IllegalArgumentException("Method must be join or leave for player constructor");
}
if ((collection != null) && (!collection.isEmpty()))
{
this.f = i;
this.a = scoreboardteam.getName();
this.e.addAll(collection);
this._nameTagVisibility = _nameTagVisibility;
}
else
{
throw new IllegalArgumentException("Players cannot be null/empty");
}
}
public void a(PacketDataSerializer packetdataserializer)
throws IOException
{
this.a = packetdataserializer.c(16);
this.f = packetdataserializer.readByte();
if ((this.f == 0) || (this.f == 2))
{
this.b = packetdataserializer.c(32);
this.c = packetdataserializer.c(16);
this.d = packetdataserializer.c(16);
this.g = packetdataserializer.readByte();
}
if ((this.f == 0) || (this.f == 3) || (this.f == 4))
{
short short1 = packetdataserializer.readShort();
for (int i = 0; i < short1; i++) {
this.e.add(packetdataserializer.c(40));
}
}
}
public void b(PacketDataSerializer packetdataserializer)
throws IOException
{
packetdataserializer.a(this.a);
packetdataserializer.writeByte(this.f);
if ((this.f == 0) || (this.f == 2))
{
packetdataserializer.a(this.b);
packetdataserializer.a(this.c);
packetdataserializer.a(this.d);
packetdataserializer.writeByte(this.g);
if (packetdataserializer.version >= 16)
{
packetdataserializer.a(_nameTagVisibility);
packetdataserializer.writeByte(EnumChatFormat.WHITE.ordinal());
}
}
if ((this.f == 0) || (this.f == 3) || (this.f == 4))
{
if (packetdataserializer.version < 16) {
packetdataserializer.writeShort(this.e.size());
} else {
packetdataserializer.b(this.e.size());
}
Iterator iterator = this.e.iterator();
while (iterator.hasNext())
{
String s = (String)iterator.next();
packetdataserializer.a(s);
}
}
}
public void a(PacketPlayOutListener packetplayoutlistener)
{
packetplayoutlistener.a(this);
}
public void handle(PacketListener packetlistener)
{
a((PacketPlayOutListener)packetlistener);
}
}

View File

@ -1,42 +0,0 @@
package net.minecraft.server.v1_7_R4;
import net.minecraft.server.v1_7_R4.ItemStack;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
import net.minecraft.server.v1_7_R4.PacketListener;
import net.minecraft.server.v1_7_R4.PacketPlayOutListener;
public class PacketPlayOutSetSlot extends Packet {
public int a;
public int b;
public ItemStack c;
public PacketPlayOutSetSlot() {
}
public PacketPlayOutSetSlot(int i, int j, ItemStack itemstack) {
this.a = i;
this.b = j;
this.c = itemstack == null?null:itemstack.cloneItemStack();
}
public void a(PacketPlayOutListener packetplayoutlistener) {
packetplayoutlistener.a(this);
}
public void a(PacketDataSerializer packetdataserializer) {
this.a = packetdataserializer.readByte();
this.b = packetdataserializer.readShort();
this.c = packetdataserializer.c();
}
public void b(PacketDataSerializer packetdataserializer) {
packetdataserializer.writeByte(this.a);
packetdataserializer.writeShort(this.b);
packetdataserializer.a(this.c);
}
public void handle(PacketListener packetlistener) {
this.a((PacketPlayOutListener)packetlistener);
}
}

View File

@ -1,179 +0,0 @@
package net.minecraft.server.v1_7_R4;
import java.io.IOException;
import java.util.HashMap;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
import net.minecraft.server.v1_7_R4.PacketListener;
import net.minecraft.server.v1_7_R4.PacketPlayOutListener;
public class PacketPlayOutWorldParticles extends Packet {
private String a;
private float b;
private float c;
private float d;
private float e;
private float f;
private float g;
private float h;
private int i;
private boolean _displayFar;
public PacketPlayOutWorldParticles() {
}
public PacketPlayOutWorldParticles(String s, float f, float f1, float f2, float f3, float f4, float f5, float f6, int i) {
this(s, f, f1, f2, f3, f4, f5, f6, i, false);
}
public PacketPlayOutWorldParticles(String s, float f, float f1, float f2, float f3, float f4, float f5, float f6, int i, boolean displayFar) {
this.a = s;
this.b = f;
this.c = f1;
this.d = f2;
this.e = f3;
this.f = f4;
this.g = f5;
this.h = f6;
this.i = i;
_displayFar = displayFar;
}
public void a(PacketDataSerializer packetdataserializer) throws IOException {
this.a = packetdataserializer.c(64);
this.b = packetdataserializer.readFloat();
this.c = packetdataserializer.readFloat();
this.d = packetdataserializer.readFloat();
this.e = packetdataserializer.readFloat();
this.f = packetdataserializer.readFloat();
this.g = packetdataserializer.readFloat();
this.h = packetdataserializer.readFloat();
this.i = packetdataserializer.readInt();
}
public void b(PacketDataSerializer packetdataserializer) throws IOException {
String[] parts = this.a.split("_");
PacketPlayOutWorldParticles.Particle particle = PacketPlayOutWorldParticles.Particle.find(parts[0]);
if(particle == null) {
particle = PacketPlayOutWorldParticles.Particle.CRIT;
}
if(packetdataserializer.version < 17) {
packetdataserializer.a(this.a);
} else {
packetdataserializer.writeInt(particle.ordinal());
packetdataserializer.writeBoolean(_displayFar);
}
packetdataserializer.writeFloat(this.b);
packetdataserializer.writeFloat(this.c);
packetdataserializer.writeFloat(this.d);
packetdataserializer.writeFloat(this.e);
packetdataserializer.writeFloat(this.f);
packetdataserializer.writeFloat(this.g);
packetdataserializer.writeFloat(this.h);
packetdataserializer.writeInt(this.i);
if(packetdataserializer.version >= 17) {
for(int i = 0; i < particle.extra; ++i) {
int toWrite = 0;
if(parts.length - 1 > i) {
try {
toWrite = Integer.parseInt(parts[i + 1]);
if(particle.extra == 1 && parts.length == 3) {
++i;
toWrite |= Integer.parseInt(parts[i + 1]) << 12;
}
} catch (NumberFormatException var7) {
;
}
}
packetdataserializer.b(toWrite);
}
}
}
public void a(PacketPlayOutListener packetplayoutlistener) {
packetplayoutlistener.a(this);
}
public void handle(PacketListener packetlistener) {
this.a((PacketPlayOutListener)packetlistener);
}
private static enum Particle {
EXPLOSION_NORMAL("explode"),
EXPLOSION_LARGE("largeexplode"),
EXPLOSION_HUGE("hugeexplosion"),
FIREWORKS_SPARK("fireworksSpark"),
WATER_BUBBLE("bubble"),
WATER_SPLASH("splash"),
WATER_WAKE("wake"),
SUSPENDED("suspended"),
SUSPENDED_DEPTH("depthsuspend"),
CRIT("crit"),
CRIT_MAGIC("magicCrit"),
SMOKE_NORMAL("smoke"),
SMOKE_LARGE("largesmoke"),
SPELL("spell"),
SPELL_INSTANT("instantSpell"),
SPELL_MOB("mobSpell"),
SPELL_MOB_AMBIENT("mobSpellAmbient"),
SPELL_WITCH("witchMagic"),
DRIP_WATER("dripWater"),
DRIP_LAVA("dripLava"),
VILLAGER_ANGRY("angryVillager"),
VILLAGER_HAPPY("happyVillager"),
TOWN_AURA("townaura"),
NOTE("note"),
PORTAL("portal"),
ENCHANTMENT_TABLE("enchantmenttable"),
FLAME("flame"),
LAVA("lava"),
FOOTSTEP("footstep"),
CLOUD("cloud"),
REDSTONE("reddust"),
SNOWBALL("snowballpoof"),
SNOW_SHOVEL("snowshovel"),
SLIME("slime"),
HEART("heart"),
BARRIER("barrier"),
ICON_CRACK("iconcrack", 2),
BLOCK_CRACK("blockcrack", 1),
BLOCK_DUST("blockdust", 1),
WATER_DROP("droplet"),
ITEM_TAKE("take"),
MOB_APPEARANCE("mobappearance");
public final String name;
public final int extra;
private static final HashMap<String, PacketPlayOutWorldParticles.Particle> particleMap;
private Particle(String name) {
this(name, 0);
}
private Particle(String name, int extra) {
this.name = name;
this.extra = extra;
}
public static PacketPlayOutWorldParticles.Particle find(String part) {
return (PacketPlayOutWorldParticles.Particle)particleMap.get(part);
}
static {
particleMap = new HashMap();
PacketPlayOutWorldParticles.Particle[] var0 = values();
int var1 = var0.length;
for(int var2 = 0; var2 < var1; ++var2) {
PacketPlayOutWorldParticles.Particle particle = var0[var2];
particleMap.put(particle.name, particle);
}
}
}
}

View File

@ -1,135 +0,0 @@
package net.minecraft.server.v1_7_R4;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class ScoreboardTeam
extends ScoreboardTeamBase
{
private final Scoreboard a;
private final String b;
private final Set c = new HashSet();
private String d;
private String e = "";
private String f = "";
private String _nametagVisibility = "always";
private boolean g = true;
private boolean h = true;
public ScoreboardTeam(Scoreboard paramScoreboard, String paramString)
{
this.a = paramScoreboard;
this.b = paramString;
this.d = paramString;
}
public String getName()
{
return this.b;
}
public String getDisplayName()
{
return this.d;
}
public void setDisplayName(String paramString)
{
if (paramString == null) {
throw new IllegalArgumentException("Name cannot be null");
}
this.d = paramString;
this.a.handleTeamChanged(this);
}
public Collection getPlayerNameSet()
{
return this.c;
}
public String getPrefix()
{
return this.e;
}
public void setPrefix(String paramString)
{
if (paramString == null) {
throw new IllegalArgumentException("Prefix cannot be null");
}
this.e = paramString;
this.a.handleTeamChanged(this);
}
public String getSuffix()
{
return this.f;
}
public void setSuffix(String paramString)
{
if (paramString == null) {
throw new IllegalArgumentException("Suffix cannot be null");
}
this.f = paramString;
this.a.handleTeamChanged(this);
}
public String getFormattedName(String paramString)
{
return getPrefix() + paramString + getSuffix();
}
public static String getPlayerDisplayName(ScoreboardTeamBase paramScoreboardTeamBase, String paramString)
{
if (paramScoreboardTeamBase == null) {
return paramString;
}
return paramScoreboardTeamBase.getFormattedName(paramString);
}
public boolean allowFriendlyFire()
{
return this.g;
}
public void setAllowFriendlyFire(boolean paramBoolean)
{
this.g = paramBoolean;
this.a.handleTeamChanged(this);
}
public boolean canSeeFriendlyInvisibles()
{
return this.h;
}
public void setCanSeeFriendlyInvisibles(boolean paramBoolean)
{
this.h = paramBoolean;
this.a.handleTeamChanged(this);
}
public String getNametagVisibility()
{
return _nametagVisibility;
}
public void setNametagVisibility(String visibility)
{
_nametagVisibility = visibility;
}
public int packOptionData()
{
int i = 0;
if (allowFriendlyFire()) {
i |= 0x1;
}
if (canSeeFriendlyInvisibles()) {
i |= 0x2;
}
return i;
}
}

View File

@ -1,225 +0,0 @@
package org.bukkit.craftbukkit.v1_7_R4.scoreboard;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.scoreboard.Team;
import org.bukkit.scoreboard.TeamNameTagVisibility;
import net.minecraft.server.v1_7_R4.ScoreboardTeam;
import com.google.common.collect.ImmutableSet;
import org.apache.commons.lang.Validate;
final class CraftTeam
extends CraftScoreboardComponent
implements Team
{
private final ScoreboardTeam team;
CraftTeam(CraftScoreboard scoreboard, ScoreboardTeam team)
{
super(scoreboard);
this.team = team;
scoreboard.teams.put(team.getName(), this);
}
public String getName()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getName();
}
public String getDisplayName()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getDisplayName();
}
public void setDisplayName(String displayName)
throws IllegalStateException
{
Validate.notNull(displayName, "Display name cannot be null");
Validate.isTrue(displayName.length() <= 32, "Display name '" + displayName + "' is longer than the limit of 32 characters");
CraftScoreboard scoreboard = checkState();
this.team.setDisplayName(displayName);
}
public String getPrefix()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getPrefix();
}
public void setPrefix(String prefix)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(prefix, "Prefix cannot be null");
Validate.isTrue(prefix.length() <= 32, "Prefix '" + prefix + "' is longer than the limit of 32 characters");
CraftScoreboard scoreboard = checkState();
this.team.setPrefix(prefix);
}
public String getSuffix()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getSuffix();
}
public void setSuffix(String suffix)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(suffix, "Suffix cannot be null");
Validate.isTrue(suffix.length() <= 32, "Suffix '" + suffix + "' is longer than the limit of 32 characters");
CraftScoreboard scoreboard = checkState();
this.team.setSuffix(suffix);
}
public boolean allowFriendlyFire()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.allowFriendlyFire();
}
// Mineplex
@Override
public void setNameTagVisibility(TeamNameTagVisibility visibility) throws IllegalStateException
{
this.team.setNametagVisibility(visibility.toString());
}
public void setAllowFriendlyFire(boolean enabled)
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
this.team.setAllowFriendlyFire(enabled);
}
public boolean canSeeFriendlyInvisibles()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.canSeeFriendlyInvisibles();
}
public void setCanSeeFriendlyInvisibles(boolean enabled)
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
this.team.setCanSeeFriendlyInvisibles(enabled);
}
public Set<OfflinePlayer> getPlayers()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
ImmutableSet.Builder<OfflinePlayer> players = ImmutableSet.builder();
for (Object o : this.team.getPlayerNameSet()) {
players.add(Bukkit.getOfflinePlayer(o.toString()));
}
return players.build();
}
public Set<String> getEntries()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
ImmutableSet.Builder<String> entries = ImmutableSet.builder();
for (Object o : this.team.getPlayerNameSet()) {
entries.add(o.toString());
}
return entries.build();
}
public int getSize()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getPlayerNameSet().size();
}
public void addPlayer(OfflinePlayer player)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(player, "OfflinePlayer cannot be null");
addEntry(player.getName());
}
public void addEntry(String entry)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(entry, "Entry cannot be null");
CraftScoreboard scoreboard = checkState();
scoreboard.board.addPlayerToTeam(entry, this.team.getName());
}
public boolean removePlayer(OfflinePlayer player)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(player, "OfflinePlayer cannot be null");
return removeEntry(player.getName());
}
public boolean removeEntry(String entry)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(entry, "Entry cannot be null");
CraftScoreboard scoreboard = checkState();
if (!this.team.getPlayerNameSet().contains(entry)) {
return false;
}
scoreboard.board.removePlayerFromTeam(entry, this.team);
return true;
}
public boolean hasPlayer(OfflinePlayer player)
throws IllegalArgumentException, IllegalStateException
{
Validate.notNull(player, "OfflinePlayer cannot be null");
return hasEntry(player.getName());
}
public boolean hasEntry(String entry)
throws IllegalArgumentException, IllegalStateException
{
Validate.notNull("Entry cannot be null");
CraftScoreboard scoreboard = checkState();
return this.team.getPlayerNameSet().contains(entry);
}
public void unregister()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
scoreboard.board.removeTeam(this.team);
scoreboard.teams.remove(this.team.getName());
setUnregistered();
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -81,7 +81,7 @@ public class LobbyBalancer implements Listener, Runnable
InetSocketAddress socketAddress = new InetSocketAddress(server.getPublicAddress(), server.getPort());
_plugin.getProxy().getServers().put(server.getName(), _plugin.getProxy().constructServerInfo(server.getName(), socketAddress, "LobbyBalancer", false));
if (server.getName().toUpperCase().contains("LOBBY"))
if (server.getName().toUpperCase().startsWith("LOBBY"))
{
if (server.getMotd() == null || !server.getMotd().contains("Restarting"))
{

View File

@ -1,8 +1,8 @@
package mineplex.core.common;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.NBTTagCompound;
import net.minecraft.server.v1_8_R3.World;
public class DummyEntity extends Entity
{
@ -12,17 +12,20 @@ public class DummyEntity extends Entity
}
@Override
protected void c()
protected void h()
{
}
@Override
protected void a(NBTTagCompound nbttagcompound)
protected void a(NBTTagCompound nbtTagCompound)
{
}
@Override
protected void b(NBTTagCompound nbttagcompound)
protected void b(NBTTagCompound nbtTagCompound)
{
}
}

View File

@ -1,10 +1,10 @@
package mineplex.core.common.jsonchat;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.ChatSerializer;
import net.minecraft.server.v1_7_R4.PacketPlayOutChat;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -119,25 +119,12 @@ public class JsonMessage
*/
public void send(MessageType messageType, Player... players)
{
send(messageType, false, players);
}
/**
* Send a message to players using the new 1.8 message types
*
* @param messageType Message type to send
* @param defaultToChat Only applies to MessageType.ABOVE_HOTBAR. If true, it will send this to chat for 1.7 clients
* @param players Players to send to
*/
public void send(MessageType messageType, boolean defaultToChat, Player... players)
{
PacketPlayOutChat chatPacket = new PacketPlayOutChat(ChatSerializer.a(toString()));
chatPacket.setChatType(messageType.getId());
PacketPlayOutChat chatPacket = new PacketPlayOutChat(IChatBaseComponent.ChatSerializer.a(toString()));
chatPacket.b = messageType.getId();
for (Player player : players)
{
if (defaultToChat || messageType != MessageType.ABOVE_HOTBAR || UtilPlayer.is1_8(player))
((CraftPlayer) player).getHandle().playerConnection.sendPacket(chatPacket);
UtilPlayer.sendPacket(player, chatPacket);
}
}

View File

@ -2,7 +2,7 @@ package mineplex.core.common.util;
import java.util.HashMap;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory;
import org.bukkit.inventory.ItemStack;
public class InventoryUtil

View File

@ -1,48 +1,41 @@
package mineplex.core.common.util;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.minecraft.server.v1_7_R4.Block;
import net.minecraft.server.v1_7_R4.BlockContainer;
import net.minecraft.server.v1_7_R4.Blocks;
import net.minecraft.server.v1_7_R4.ChunkCoordIntPair;
import net.minecraft.server.v1_7_R4.ChunkSection;
import net.minecraft.server.v1_7_R4.EnumSkyBlock;
import net.minecraft.server.v1_7_R4.ExceptionWorldConflict;
import net.minecraft.server.v1_7_R4.IContainer;
import net.minecraft.server.v1_7_R4.IProgressUpdate;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import net.minecraft.server.v1_7_R4.PacketPlayOutMapChunkBulk;
import net.minecraft.server.v1_7_R4.PacketPlayOutMultiBlockChange;
import net.minecraft.server.v1_7_R4.RegionFile;
import net.minecraft.server.v1_7_R4.RegionFileCache;
import net.minecraft.server.v1_7_R4.TileEntity;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.CraftChunk;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_8_R3.ExceptionWorldConflict;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.IProgressUpdate;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.PacketPlayOutMultiBlockChange;
import net.minecraft.server.v1_8_R3.RegionFile;
import net.minecraft.server.v1_8_R3.RegionFileCache;
public class MapUtil
{
public static void ReplaceOreInChunk(Chunk chunk, Material replacee, Material replacer)
/*public static void ReplaceOreInChunk(Chunk chunk, Material replacee, Material replacer)
{
net.minecraft.server.v1_7_R4.Chunk c = ((CraftChunk) chunk).getHandle();
net.minecraft.server.v1_8_R3.Chunk c = ((CraftChunk) chunk).getHandle();
for (int x = 0; x < 16; x++)
{
@ -54,7 +47,7 @@ public class MapUtil
int bY = y & 0xFF;
int bZ = c.locZ << 4 | z & 0xF;
if (c.getType(bX & 0xF, bY, bZ & 0xF).k() == replacee.getId())
if (c.getTypeAbs(bX, bY, bZ).k() == replacee.getId())
{
c.b(bX & 0xF, bY, bZ & 0xF, replacer.getId());
}
@ -63,7 +56,7 @@ public class MapUtil
}
c.initLighting();
}
}*/
public static void QuickChangeBlockAt(Location location, Material setTo)
{
@ -94,10 +87,12 @@ public class MapUtil
public static void QuickChangeBlockAt(World world, int x, int y, int z, int id, int data)
{
Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
net.minecraft.server.v1_7_R4.Chunk c = ((CraftChunk) chunk).getHandle();
net.minecraft.server.v1_8_R3.Chunk c = ((CraftChunk) chunk).getHandle();
c.a(x & 0xF, y, z & 0xF, Block.getById(id), data);
((CraftWorld) world).getHandle().notify(x, y, z);
//c.a(x & 0xF, y, z & 0xF, Block.getById(id), data);
IBlockData blockData = CraftMagicNumbers.getBlock(id).fromLegacyData(data);
c.a(getBlockPos(x, y, z), blockData);
((CraftWorld) world).getHandle().notify(getBlockPos(x, y, z));
}
public static int GetHighestBlockInCircleAt(World world, int bx, int bz, int radius)
@ -152,7 +147,7 @@ public class MapUtil
Block.getById(id), data))
{
if (notifyPlayers)
((CraftWorld) world).getHandle().notify(x, y, z);
((CraftWorld) world).getHandle().notify(getBlockPos(x, y, z));
}
}
@ -161,13 +156,15 @@ public class MapUtil
world.getBlockAt(x, y, z).setTypeIdAndData(id, data, notifyPlayers);
}
private static boolean changeChunkBlock(int x, int y, int z, net.minecraft.server.v1_7_R4.Chunk chunk, Block block,
private static boolean changeChunkBlock(int x, int y, int z, net.minecraft.server.v1_8_R3.Chunk chunk, Block block,
byte data)
{
return chunk.a(x, y, z, block, data);
chunk.a(getBlockPos(x, y, z), block.fromLegacyData(data));
return true; // todo?
// return chunk.a(x, y, z, block, data);
}
public static void SendChunkForPlayer(net.minecraft.server.v1_7_R4.Chunk chunk, Player player)
public static void SendChunkForPlayer(net.minecraft.server.v1_8_R3.Chunk chunk, Player player)
{
SendChunkForPlayer(chunk.locX, chunk.locZ, player);
}
@ -184,8 +181,8 @@ public class MapUtil
Player player)
{
// System.out.println("Sending MultiBlockChunk " + x + ", " + z);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutMultiBlockChange(dirtyCount,
dirtyBlocks, ((CraftWorld) world).getHandle().getChunkAt(x, z)));
UtilPlayer.sendPacket(player, new PacketPlayOutMultiBlockChange(dirtyCount, dirtyBlocks, ((CraftWorld) world).getHandle()
.getChunkAt(x, z)));
}
public static void UnloadWorld(JavaPlugin plugin, World world)
@ -216,7 +213,7 @@ public class MapUtil
Bukkit.getPluginManager().callEvent(new WorldUnloadEvent(((CraftWorld) world).getHandle().getWorld()));
Iterator<net.minecraft.server.v1_7_R4.Chunk> chunkIterator = ((CraftWorld) world).getHandle().chunkProviderServer.chunks
Iterator<net.minecraft.server.v1_8_R3.Chunk> chunkIterator = ((CraftWorld) world).getHandle().chunkProviderServer.chunks
.values().iterator();
for (Entity entity : world.getEntities())
@ -226,7 +223,7 @@ public class MapUtil
while (chunkIterator.hasNext())
{
net.minecraft.server.v1_7_R4.Chunk chunk = chunkIterator.next();
net.minecraft.server.v1_8_R3.Chunk chunk = chunkIterator.next();
chunk.removeEntities();
}
@ -251,23 +248,7 @@ public class MapUtil
System.out.println("Error removing world from bukkit master list: " + ex.getMessage());
}
MinecraftServer ms = null;
try
{
Field f = server.getClass().getDeclaredField("console");
f.setAccessible(true);
ms = (MinecraftServer) f.get(server);
f.setAccessible(false);
}
catch (IllegalAccessException ex)
{
System.out.println("Error getting minecraftserver variable: " + ex.getMessage());
}
catch (NoSuchFieldException ex)
{
System.out.println("Error getting minecraftserver variable: " + ex.getMessage());
}
MinecraftServer ms = server.getServer();
ms.worlds.remove(ms.worlds.indexOf(craftWorld.getHandle()));
}
@ -303,4 +284,9 @@ public class MapUtil
return true;
}
public static BlockPosition getBlockPos(int x, int y, int z)
{
return new BlockPosition(x, y, z);
}
}

View File

@ -6,8 +6,8 @@ import java.util.Scanner;
import java.util.UUID;
import java.util.logging.Level;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

View File

@ -4,16 +4,17 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import net.minecraft.server.v1_7_R4.Blocks;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.WorldServer;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.inventory.ItemStack;
public class UtilBlock
@ -52,7 +53,7 @@ public class UtilBlock
*/
public static HashSet<Byte> fullSolid = new HashSet<Byte>();
/**
* A list of blocks that are non-solid, but offer resistance. Eg lily, fence gate, portal
* A list of blocks that are non-solid, but can't be moved through. Eg lily, fence gate, portal
*/
public static HashSet<Byte> blockPassSet = new HashSet<Byte>();
/**
@ -61,188 +62,225 @@ public class UtilBlock
public static HashSet<Byte> blockAirFoliageSet = new HashSet<Byte>();
static {
blockAirFoliageSet.add((byte)0);
blockAirFoliageSet.add((byte)6);
blockAirFoliageSet.add((byte)31);
blockAirFoliageSet.add((byte)32);
blockAirFoliageSet.add((byte)37);
blockAirFoliageSet.add((byte)38);
blockAirFoliageSet.add((byte)39);
blockAirFoliageSet.add((byte)40);
blockAirFoliageSet.add((byte)51);
blockAirFoliageSet.add((byte)59);
blockAirFoliageSet.add((byte)104);
blockAirFoliageSet.add((byte)105);
blockAirFoliageSet.add((byte)115);
blockAirFoliageSet.add((byte)141);
blockAirFoliageSet.add((byte)142);
blockPassSet.add((byte)0);
blockPassSet.add((byte)6);
blockPassSet.add((byte)8);
blockPassSet.add((byte)9);
blockPassSet.add((byte)10);
blockPassSet.add((byte)11);
blockPassSet.add((byte)26);
blockPassSet.add((byte)27);
blockPassSet.add((byte)28);
blockPassSet.add((byte)30);
blockPassSet.add((byte)31);
blockPassSet.add((byte)32);
blockPassSet.add((byte)37);
blockPassSet.add((byte)38);
blockPassSet.add((byte)39);
blockPassSet.add((byte)40);
blockPassSet.add((byte)50);
blockPassSet.add((byte)51);
blockPassSet.add((byte)55);
blockPassSet.add((byte)59);
blockPassSet.add((byte)63);
blockPassSet.add((byte)64);
blockPassSet.add((byte)65);
blockPassSet.add((byte)66);
blockPassSet.add((byte)68);
blockPassSet.add((byte)69);
blockPassSet.add((byte)70);
blockPassSet.add((byte)71);
blockPassSet.add((byte)72);
blockPassSet.add((byte)75);
blockPassSet.add((byte)76);
blockPassSet.add((byte)77);
blockPassSet.add((byte)78);
blockPassSet.add((byte)83);
blockPassSet.add((byte)90);
blockPassSet.add((byte)92);
blockPassSet.add((byte)93);
blockPassSet.add((byte)94);
blockPassSet.add((byte)96);
blockPassSet.add((byte)101);
blockPassSet.add((byte)102);
blockPassSet.add((byte)104);
blockPassSet.add((byte)105);
blockPassSet.add((byte)106);
blockPassSet.add((byte)107);
blockPassSet.add((byte)111);
blockPassSet.add((byte)115);
blockPassSet.add((byte)116);
blockPassSet.add((byte)117);
blockPassSet.add((byte)118);
blockPassSet.add((byte)119);
blockPassSet.add((byte)120);
blockPassSet.add((byte)171);
fullSolid.add((byte)1); //
fullSolid.add((byte)2); //
fullSolid.add((byte)3); //
fullSolid.add((byte)4); //
fullSolid.add((byte)5); //
fullSolid.add((byte)7); //
fullSolid.add((byte)12); //
fullSolid.add((byte)13); //
fullSolid.add((byte)14); //
fullSolid.add((byte)15); //
fullSolid.add((byte)16); //
fullSolid.add((byte)17); //
fullSolid.add((byte)19); //
fullSolid.add((byte)20); //
fullSolid.add((byte)21); //
fullSolid.add((byte)22); //
fullSolid.add((byte)23); //
fullSolid.add((byte)24); //
fullSolid.add((byte)25); //
fullSolid.add((byte)29); //
fullSolid.add((byte)33); //
fullSolid.add((byte)35); //
fullSolid.add((byte)41); //
fullSolid.add((byte)42); //
fullSolid.add((byte)43); //
fullSolid.add((byte)44); //
fullSolid.add((byte)45); //
fullSolid.add((byte)46); //
fullSolid.add((byte)47); //
fullSolid.add((byte)48); //
fullSolid.add((byte)49); //
fullSolid.add((byte)56); //
fullSolid.add((byte)57); //
fullSolid.add((byte)58); //
fullSolid.add((byte)60); //
fullSolid.add((byte)61); //
fullSolid.add((byte)62); //
fullSolid.add((byte)73); //
fullSolid.add((byte)74); //
fullSolid.add((byte)79); //
fullSolid.add((byte)80); //
fullSolid.add((byte)82); //
fullSolid.add((byte)84); //
fullSolid.add((byte)86); //
fullSolid.add((byte)87); //
fullSolid.add((byte)88); //
fullSolid.add((byte)89); //
fullSolid.add((byte)91); //
fullSolid.add((byte)95); //
fullSolid.add((byte)97); //
fullSolid.add((byte)98); //
fullSolid.add((byte)99); //
fullSolid.add((byte)100); //
fullSolid.add((byte)103); //
fullSolid.add((byte)110); //
fullSolid.add((byte)112); //
fullSolid.add((byte)121); //
fullSolid.add((byte)123); //
fullSolid.add((byte)124); //
fullSolid.add((byte)125); //
fullSolid.add((byte)126); //
fullSolid.add((byte)129); //
fullSolid.add((byte)133); //
fullSolid.add((byte)137); //
fullSolid.add((byte)138); //
fullSolid.add((byte)152); //
fullSolid.add((byte)153); //
fullSolid.add((byte)155); //
fullSolid.add((byte)158); //
blockUseSet.add((byte)23); //Dispenser
blockUseSet.add((byte)26); //Bed
blockUseSet.add((byte)33); //Piston
blockUseSet.add((byte)47); //Bookcase
blockUseSet.add((byte)54); //Chest
blockUseSet.add((byte)58); //Workbench
blockUseSet.add((byte)61); //Furnace
blockUseSet.add((byte)62); //Furnace
blockUseSet.add((byte)64); //Wood Door
blockUseSet.add((byte)69); //Lever
blockUseSet.add((byte)71); //Iron Door
blockUseSet.add((byte)77); //Button
blockUseSet.add((byte)85); //Fence (stupid minecraft)
blockUseSet.add((byte)93); //Repeater
blockUseSet.add((byte)94); //Repeater
blockUseSet.add((byte)96); //Trapdoor
blockUseSet.add((byte)107); //Fence Gate
blockUseSet.add((byte)113); //Nether Fence (stupid minecraft)
blockUseSet.add((byte)116); //Enchantment Table
blockUseSet.add((byte)117); //Brewing Stand
blockUseSet.add((byte)130); //Ender Chest
blockUseSet.add((byte)145); //Anvil
blockUseSet.add((byte)146); //Trapped Chest
blockUseSet.add((byte)154); //Hopper
blockUseSet.add((byte)158); //Dropper
blockUseSet.add((byte)184); //Fences/Gates
blockUseSet.add((byte)185); //Fences/Gates
blockUseSet.add((byte)186); //Fences/Gates
blockUseSet.add((byte)187); //Fences/Gates
blockUseSet.add((byte)188); //Fences/Gates
blockUseSet.add((byte)189); //Fences/Gates
blockUseSet.add((byte)190); //Fences/Gates
blockUseSet.add((byte)191); //Fences/Gates
blockUseSet.add((byte)192); //Fences/Gates
blockUseSet.add((byte)193); //Wood Doors
blockUseSet.add((byte)194); //Wood Doors
blockUseSet.add((byte)195); //Wood Doors
blockUseSet.add((byte)196); //Wood Doors
blockUseSet.add((byte)197); //Wood Doors
blockAirFoliageSet.add((byte) Material.AIR.getId());
blockAirFoliageSet.add((byte) Material.SAPLING.getId());
blockAirFoliageSet.add((byte) Material.LONG_GRASS.getId());
blockAirFoliageSet.add((byte) Material.DEAD_BUSH.getId());
blockAirFoliageSet.add((byte) Material.YELLOW_FLOWER.getId());
blockAirFoliageSet.add((byte) Material.RED_ROSE.getId());
blockAirFoliageSet.add((byte) Material.BROWN_MUSHROOM.getId());
blockAirFoliageSet.add((byte) Material.RED_MUSHROOM.getId());
blockAirFoliageSet.add((byte) Material.FIRE.getId());
blockAirFoliageSet.add((byte) Material.CROPS.getId());
blockAirFoliageSet.add((byte) Material.PUMPKIN_STEM.getId());
blockAirFoliageSet.add((byte) Material.MELON_STEM.getId());
blockAirFoliageSet.add((byte) Material.NETHER_WARTS.getId());
blockAirFoliageSet.add((byte) Material.TRIPWIRE_HOOK.getId());
blockAirFoliageSet.add((byte) Material.TRIPWIRE.getId());
blockAirFoliageSet.add((byte) Material.CARROT.getId());
blockAirFoliageSet.add((byte) Material.POTATO.getId());
blockAirFoliageSet.add((byte) Material.DOUBLE_PLANT.getId());
blockAirFoliageSet.add((byte) Material.STANDING_BANNER.getId());
blockAirFoliageSet.add((byte) Material.WALL_BANNER.getId());
blockPassSet.add((byte) Material.AIR.getId());
blockPassSet.add((byte) Material.SAPLING.getId());
blockPassSet.add((byte) Material.WATER.getId());
blockPassSet.add((byte) Material.STATIONARY_WATER.getId());
blockPassSet.add((byte) Material.LAVA.getId());
blockPassSet.add((byte) Material.STATIONARY_LAVA.getId());
blockPassSet.add((byte) Material.BED_BLOCK.getId());
blockPassSet.add((byte) Material.POWERED_RAIL.getId());
blockPassSet.add((byte) Material.DETECTOR_RAIL.getId());
blockPassSet.add((byte) Material.WEB.getId());
blockPassSet.add((byte) Material.LONG_GRASS.getId());
blockPassSet.add((byte) Material.DEAD_BUSH.getId());
blockPassSet.add((byte) Material.YELLOW_FLOWER.getId());
blockPassSet.add((byte) Material.RED_ROSE.getId());
blockPassSet.add((byte) Material.BROWN_MUSHROOM.getId());
blockPassSet.add((byte) Material.RED_MUSHROOM.getId());
blockPassSet.add((byte) Material.TORCH.getId());
blockPassSet.add((byte) Material.FIRE.getId());
blockPassSet.add((byte) Material.REDSTONE_WIRE.getId());
blockPassSet.add((byte) Material.CROPS.getId());
blockPassSet.add((byte) Material.SIGN_POST.getId());
blockPassSet.add((byte) Material.WOODEN_DOOR.getId());
blockPassSet.add((byte) Material.LADDER.getId());
blockPassSet.add((byte) Material.RAILS.getId());
blockPassSet.add((byte) Material.WALL_SIGN.getId());
blockPassSet.add((byte) Material.LEVER.getId());
blockPassSet.add((byte) Material.STONE_PLATE.getId());
blockPassSet.add((byte) Material.IRON_DOOR_BLOCK.getId());
blockPassSet.add((byte) Material.WOOD_PLATE.getId());
blockPassSet.add((byte) Material.REDSTONE_TORCH_OFF.getId());
blockPassSet.add((byte) Material.REDSTONE_TORCH_ON.getId());
blockPassSet.add((byte) Material.STONE_BUTTON.getId());
blockPassSet.add((byte) Material.SNOW.getId());
blockPassSet.add((byte) Material.SUGAR_CANE_BLOCK.getId());
blockPassSet.add((byte) Material.FENCE.getId());
blockPassSet.add((byte) Material.PORTAL.getId());
blockPassSet.add((byte) Material.CAKE_BLOCK.getId());
blockPassSet.add((byte) Material.DIODE_BLOCK_OFF.getId());
blockPassSet.add((byte) Material.DIODE_BLOCK_ON.getId());
blockPassSet.add((byte) Material.TRAP_DOOR.getId());
blockPassSet.add((byte) Material.IRON_FENCE.getId());
blockPassSet.add((byte) Material.THIN_GLASS.getId());
blockPassSet.add((byte) Material.PUMPKIN_STEM.getId());
blockPassSet.add((byte) Material.MELON_STEM.getId());
blockPassSet.add((byte) Material.VINE.getId());
blockPassSet.add((byte) Material.FENCE_GATE.getId());
blockPassSet.add((byte) Material.WATER_LILY.getId());
blockPassSet.add((byte) Material.NETHER_WARTS.getId());
blockPassSet.add((byte) Material.ENCHANTMENT_TABLE.getId());
blockPassSet.add((byte) Material.BREWING_STAND.getId());
blockPassSet.add((byte) Material.CAULDRON.getId());
blockPassSet.add((byte) Material.ENDER_PORTAL.getId());
blockPassSet.add((byte) Material.ENDER_PORTAL_FRAME.getId());
blockPassSet.add((byte) Material.DAYLIGHT_DETECTOR.getId());
blockPassSet.add((byte) Material.STAINED_GLASS_PANE.getId());
blockPassSet.add((byte) Material.IRON_TRAPDOOR.getId());
blockPassSet.add((byte) Material.DAYLIGHT_DETECTOR_INVERTED.getId());
blockPassSet.add((byte) Material.BIRCH_FENCE_GATE.getId());
blockPassSet.add((byte) Material.JUNGLE_FENCE_GATE.getId());
blockPassSet.add((byte) Material.DARK_OAK_FENCE_GATE.getId());
blockPassSet.add((byte) Material.ACACIA_FENCE_GATE.getId());
blockPassSet.add((byte) Material.SPRUCE_FENCE.getId());
blockPassSet.add((byte) Material.BIRCH_FENCE.getId());
blockPassSet.add((byte) Material.JUNGLE_FENCE.getId());
blockPassSet.add((byte) Material.DARK_OAK_FENCE.getId());
blockPassSet.add((byte) Material.ACACIA_FENCE.getId());
blockPassSet.add((byte) Material.SPRUCE_DOOR.getId());
blockPassSet.add((byte) Material.BIRCH_DOOR.getId());
blockPassSet.add((byte) Material.JUNGLE_DOOR.getId());
blockPassSet.add((byte) Material.ACACIA_DOOR.getId());
blockPassSet.add((byte) Material.DARK_OAK_DOOR.getId());
fullSolid.add((byte) Material.STONE.getId());
fullSolid.add((byte) Material.GRASS.getId());
fullSolid.add((byte) Material.DIRT.getId());
fullSolid.add((byte) Material.COBBLESTONE.getId());
fullSolid.add((byte) Material.WOOD.getId());
fullSolid.add((byte) Material.BEDROCK.getId());
fullSolid.add((byte) Material.SAND.getId());
fullSolid.add((byte) Material.GRAVEL.getId());
fullSolid.add((byte) Material.GOLD_ORE.getId());
fullSolid.add((byte) Material.IRON_ORE.getId());
fullSolid.add((byte) Material.COAL_ORE.getId());
fullSolid.add((byte) Material.LOG.getId());
fullSolid.add((byte) Material.LEAVES.getId());
fullSolid.add((byte) Material.SPONGE.getId());
fullSolid.add((byte) Material.GLASS.getId());
fullSolid.add((byte) Material.LAPIS_ORE.getId());
fullSolid.add((byte) Material.LAPIS_BLOCK.getId());
fullSolid.add((byte) Material.DISPENSER.getId());
fullSolid.add((byte) Material.SANDSTONE.getId());
fullSolid.add((byte) Material.NOTE_BLOCK.getId());
fullSolid.add((byte) Material.PISTON_STICKY_BASE.getId());
fullSolid.add((byte) Material.PISTON_BASE.getId());
fullSolid.add((byte) Material.WOOL.getId());
fullSolid.add((byte) Material.GOLD_BLOCK.getId());
fullSolid.add((byte) Material.IRON_BLOCK.getId());
fullSolid.add((byte) Material.DOUBLE_STEP.getId());
fullSolid.add((byte) Material.STEP.getId());
fullSolid.add((byte) Material.BRICK.getId());
fullSolid.add((byte) Material.TNT.getId());
fullSolid.add((byte) Material.BOOKSHELF.getId());
fullSolid.add((byte) Material.MOSSY_COBBLESTONE.getId());
fullSolid.add((byte) Material.OBSIDIAN.getId());
fullSolid.add((byte) Material.DIAMOND_ORE.getId());
fullSolid.add((byte) Material.DIAMOND_BLOCK.getId());
fullSolid.add((byte) Material.WORKBENCH.getId());
fullSolid.add((byte) Material.SOIL.getId());
fullSolid.add((byte) Material.FURNACE.getId());
fullSolid.add((byte) Material.BURNING_FURNACE.getId());
fullSolid.add((byte) Material.REDSTONE_ORE.getId());
fullSolid.add((byte) Material.GLOWING_REDSTONE_ORE.getId());
fullSolid.add((byte) Material.ICE.getId());
fullSolid.add((byte) Material.SNOW_BLOCK.getId());
fullSolid.add((byte) Material.CLAY.getId());
fullSolid.add((byte) Material.JUKEBOX.getId());
fullSolid.add((byte) Material.PUMPKIN.getId());
fullSolid.add((byte) Material.NETHERRACK.getId());
fullSolid.add((byte) Material.SOUL_SAND.getId());
fullSolid.add((byte) Material.GLOWSTONE.getId());
fullSolid.add((byte) Material.JACK_O_LANTERN.getId());
fullSolid.add((byte) Material.STAINED_GLASS.getId());
fullSolid.add((byte) Material.MONSTER_EGGS.getId());
fullSolid.add((byte) Material.SMOOTH_BRICK.getId());
fullSolid.add((byte) Material.HUGE_MUSHROOM_1.getId());
fullSolid.add((byte) Material.HUGE_MUSHROOM_2.getId());
fullSolid.add((byte) Material.MELON_BLOCK.getId());
fullSolid.add((byte) Material.MYCEL.getId());
fullSolid.add((byte) Material.NETHER_BRICK.getId());
fullSolid.add((byte) Material.ENDER_STONE.getId());
fullSolid.add((byte) Material.REDSTONE_LAMP_OFF.getId());
fullSolid.add((byte) Material.REDSTONE_LAMP_ON.getId());
fullSolid.add((byte) Material.WOOD_DOUBLE_STEP.getId());
fullSolid.add((byte) Material.WOOD_STEP.getId());
fullSolid.add((byte) Material.EMERALD_ORE.getId());
fullSolid.add((byte) Material.EMERALD_BLOCK.getId());
fullSolid.add((byte) Material.COMMAND.getId());
fullSolid.add((byte) Material.BEACON.getId());
fullSolid.add((byte) Material.REDSTONE_BLOCK.getId());
fullSolid.add((byte) Material.QUARTZ_ORE.getId());
fullSolid.add((byte) Material.QUARTZ_BLOCK.getId());
fullSolid.add((byte) Material.DROPPER.getId());
fullSolid.add((byte) Material.STAINED_CLAY.getId());
fullSolid.add((byte) Material.LEAVES_2.getId());
fullSolid.add((byte) Material.LOG_2.getId());
fullSolid.add((byte) Material.PRISMARINE.getId());
fullSolid.add((byte) Material.SEA_LANTERN.getId());
fullSolid.add((byte) Material.HAY_BLOCK.getId());
fullSolid.add((byte) Material.HARD_CLAY.getId());
fullSolid.add((byte) Material.COAL_BLOCK.getId());
fullSolid.add((byte) Material.PACKED_ICE.getId());
fullSolid.add((byte) Material.RED_SANDSTONE.getId());
fullSolid.add((byte) Material.DOUBLE_STONE_SLAB2.getId());
blockUseSet.add((byte) Material.DISPENSER.getId());
blockUseSet.add((byte) Material.BED_BLOCK.getId());
blockUseSet.add((byte) Material.PISTON_BASE.getId());
blockUseSet.add((byte) Material.BOOKSHELF.getId());
blockUseSet.add((byte) Material.CHEST.getId());
blockUseSet.add((byte) Material.WORKBENCH.getId());
blockUseSet.add((byte) Material.FURNACE.getId());
blockUseSet.add((byte) Material.BURNING_FURNACE.getId());
blockUseSet.add((byte) Material.WOODEN_DOOR.getId());
blockUseSet.add((byte) Material.LEVER.getId());
blockUseSet.add((byte) Material.IRON_DOOR_BLOCK.getId());
blockUseSet.add((byte) Material.STONE_BUTTON.getId());
blockUseSet.add((byte) Material.FENCE.getId());
blockUseSet.add((byte) Material.DIODE_BLOCK_OFF.getId());
blockUseSet.add((byte) Material.DIODE_BLOCK_ON.getId());
blockUseSet.add((byte) Material.TRAP_DOOR.getId());
blockUseSet.add((byte) Material.FENCE_GATE.getId());
blockUseSet.add((byte) Material.NETHER_FENCE.getId());
blockUseSet.add((byte) Material.ENCHANTMENT_TABLE.getId());
blockUseSet.add((byte) Material.BREWING_STAND.getId());
blockUseSet.add((byte) Material.ENDER_CHEST.getId());
blockUseSet.add((byte) Material.ANVIL.getId());
blockUseSet.add((byte) Material.TRAPPED_CHEST.getId());
blockUseSet.add((byte) Material.HOPPER.getId());
blockUseSet.add((byte) Material.DROPPER.getId());
blockUseSet.add((byte) Material.BIRCH_FENCE_GATE.getId());
blockUseSet.add((byte) Material.JUNGLE_FENCE_GATE.getId());
blockUseSet.add((byte) Material.DARK_OAK_FENCE_GATE.getId());
blockUseSet.add((byte) Material.ACACIA_FENCE_GATE.getId());
blockUseSet.add((byte) Material.SPRUCE_FENCE.getId());
blockUseSet.add((byte) Material.BIRCH_FENCE.getId());
blockUseSet.add((byte) Material.JUNGLE_FENCE.getId());
blockUseSet.add((byte) Material.DARK_OAK_FENCE.getId());
blockUseSet.add((byte) Material.ACACIA_FENCE.getId());
blockUseSet.add((byte) Material.SPRUCE_DOOR.getId());
blockUseSet.add((byte) Material.BIRCH_DOOR.getId());
blockUseSet.add((byte) Material.JUNGLE_DOOR.getId());
blockUseSet.add((byte) Material.ACACIA_DOOR.getId());
blockUseSet.add((byte) Material.DARK_OAK_DOOR.getId());
}
public static boolean solid(Block block)
@ -451,8 +489,9 @@ public class UtilBlock
if (block.getType() != Material.AIR)
{
float f3 = (damageBlocksEqually ? Blocks.DIRT : world.getType(block.getX(), block.getY(),
block.getZ())).a((net.minecraft.server.v1_7_R4.Entity) null);
Blocks.DIRT.a((net.minecraft.server.v1_8_R3.Entity) null);
float f3 = (damageBlocksEqually ? Blocks.DIRT : world.getType(new BlockPosition(block.getX(), block.getY(),
block.getZ())).getBlock()).a((net.minecraft.server.v1_8_R3.Entity) null);
f1 -= (f3 + 0.3F) * f2;
}

View File

@ -5,22 +5,23 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
import net.minecraft.server.v1_7_R4.EntityBat;
import net.minecraft.server.v1_7_R4.EntityCreature;
import net.minecraft.server.v1_7_R4.EntityEnderDragon;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.server.v1_7_R4.EntityInsentient;
import net.minecraft.server.v1_7_R4.EntityLiving;
import net.minecraft.server.v1_7_R4.EntityTrackerEntry;
import net.minecraft.server.v1_7_R4.Navigation;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityHeadRotation;
import net.minecraft.server.v1_7_R4.PathfinderGoal;
import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_7_R4.PathfinderGoalMoveTowardsRestriction;
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround;
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector;
import net.minecraft.server.v1_7_R4.WorldServer;
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import net.minecraft.server.v1_8_R3.EntityBat;
import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.EntityEnderDragon;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_8_R3.EntityLiving;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.NavigationAbstract;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
import net.minecraft.server.v1_8_R3.PathfinderGoal;
import net.minecraft.server.v1_8_R3.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_8_R3.PathfinderGoalMoveTowardsRestriction;
import net.minecraft.server.v1_8_R3.PathfinderGoalRandomLookaround;
import net.minecraft.server.v1_8_R3.PathfinderGoalSelector;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -28,10 +29,11 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -60,29 +62,24 @@ public class UtilEnt
public static void silence(Entity entity, boolean silence)
{
((CraftEntity)entity).getHandle().Silent = silence;
((CraftEntity)entity).getHandle().setSilent(silence);
}
public static void ghost(Entity entity, boolean ghost, boolean invisible)
{
if (entity instanceof LivingEntity)
{
((CraftLivingEntity)entity).getHandle().ghost = ghost;
((CraftLivingEntity)entity).getHandle().setGhost(ghost);
}
((CraftEntity)entity).getHandle().Invisible = invisible;
// ((CraftEntity)entity).getHandle().Invisible = invisible;
((CraftEntity)entity).getHandle().setInvisible(invisible);
}
public static void Leash(LivingEntity leashed, Entity holder, boolean pull, boolean breakable)
{
if (((CraftEntity)leashed).getHandle() instanceof EntityInsentient)
{
EntityInsentient creature = (EntityInsentient)((CraftEntity)leashed).getHandle();
creature.PullWhileLeashed = pull;
creature.BreakLeash = breakable;
}
leashed.setPullWhileLeashed(pull);
leashed.setShouldBreakLeash(breakable);
leashed.setLeashHolder(holder);
}
@ -132,7 +129,7 @@ public class UtilEnt
{
Vegetate(entity, false);
}
public static void Vegetate(Entity entity, boolean mute)
{
try
@ -167,7 +164,7 @@ public class UtilEnt
if (_bsRestrictionGoal == null)
{
_bsRestrictionGoal = EntityCreature.class.getDeclaredField("bs");
_bsRestrictionGoal = EntityCreature.class.getDeclaredField("c");
_bsRestrictionGoal.setAccessible(true);
}
@ -178,10 +175,10 @@ public class UtilEnt
{
EntityInsentient creature = (EntityInsentient)((CraftEntity)entity).getHandle();
creature.Vegetated = true;
creature.Silent = mute;
((List)_pathfinderBList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear();
creature.setVegetated(true);
creature.setSilent(mute);
((List) _pathfinderBList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear();
((List)_pathfinderCList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear();
((List)_pathfinderBList.get(((PathfinderGoalSelector)_targetSelector.get(creature)))).clear();
@ -190,14 +187,14 @@ public class UtilEnt
if (((CraftEntity)entity).getHandle() instanceof EntityBat)
{
((EntityBat)((CraftEntity)entity).getHandle()).Vegetated = true;
((EntityBat)((CraftEntity)entity).getHandle()).setVegetated(true);
}
if (((CraftEntity)entity).getHandle() instanceof EntityEnderDragon)
{
EntityEnderDragon creature = (EntityEnderDragon)((CraftEntity)entity).getHandle();
creature.Vegetated = true;
creature.setVegetated(true);
}
}
catch (IllegalArgumentException e)
@ -217,7 +214,7 @@ public class UtilEnt
e.printStackTrace();
}
}
public static void removeGoalSelectors(Entity entity)
{
try
@ -509,7 +506,7 @@ public class UtilEnt
public static boolean isGrounded(Entity ent)
{
AxisAlignedBB box = ((CraftEntity)ent).getHandle().boundingBox;
AxisAlignedBB box = ((CraftEntity)ent).getHandle().getBoundingBox();
Location bottom_corner_1 = new Location(ent.getWorld(), box.a, ent.getLocation().getY()-0.1, box.c);
Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f);
@ -616,24 +613,57 @@ public class UtilEnt
return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec));
}
public static void setFakeHead(Entity ent, boolean fakeHead)
{
net.minecraft.server.v1_8_R3.Entity ec = ((CraftEntity) ent).getHandle();
ec.setFakeHead(fakeHead);
}
public static void CreatureForceLook(Entity ent, float pitch, float yaw)
{
net.minecraft.server.v1_8_R3.Entity ec = ((CraftEntity) ent).getHandle();
ec.setFakeHead(true);
ec.fakePitch = pitch;
ec.fakeYaw = yaw;
}
public static boolean CreatureLook(Entity ent, float pitch, float yaw)
{
if (!(ent instanceof LivingEntity))
return false;
EntityLiving ec = ((CraftLivingEntity) ent).getHandle();
Location loc = ent.getLocation();
ec.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), yaw, pitch);
ec.al = true;
ec.yaw = yaw;
ec.pitch = pitch;
ec.aK = yaw;
ec.fakePitch = pitch;
ec.fakeYaw = yaw;
EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ec.world).tracker.trackedEntities.get(ec.getId());
EntityTrackerEntry entry = (EntityTrackerEntry) ((WorldServer) ec.getWorld()).tracker.trackedEntities.get(ec.getId());
entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, (byte) (ec.yaw * 256.0F / 360.0F)));
byte ya = (byte) (yaw * 256.0F / 360.0F);
byte pi = (byte) (pitch * 256.0F / 360.0F);
entry.yRot = ya;
entry.xRot = pi;
entry.i = ya;
// Looks like both packets need to be sent. EntityLook packet for body yaw and head pitch. Head rotation for head yaw.
entry.broadcast(new PacketPlayOutEntity.PacketPlayOutEntityLook(ent.getEntityId(), ya, pi, ec.onGround));
entry.broadcast(new PacketPlayOutEntityHeadRotation(ec, ya));
return true;
}
public static boolean CreatureLook(Entity ent, float yaw)
{
return CreatureLook(ent, 0, yaw);
}
public static void CreatureMove(Entity ent, Location target, float speed)
{
if (!(ent instanceof Creature))
@ -641,9 +671,9 @@ public class UtilEnt
if (UtilMath.offset(ent.getLocation(), target) < 0.1)
return;
EntityCreature ec = ((CraftCreature)ent).getHandle();
Navigation nav = ec.getNavigation();
NavigationAbstract nav = ec.getNavigation();
if (UtilMath.offset(ent.getLocation(), target) > 16)
{
@ -695,7 +725,7 @@ public class UtilEnt
{
try
{
Field field = net.minecraft.server.v1_7_R4.Entity.class.getDeclaredField("entityCount");
Field field = net.minecraft.server.v1_8_R3.Entity.class.getDeclaredField("entityCount");
field.setAccessible(true);
int entityId = field.getInt(null);
if (modifynumber) {

View File

@ -1,14 +1,14 @@
package mineplex.core.common.util;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFirework;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFirework;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.FireworkMeta;
@ -18,9 +18,9 @@ public class UtilFirework
{
public static void playFirework(Location loc, FireworkEffect fe)
{
Firework firework = (Firework) loc.getWorld().spawn(loc, Firework.class);
Firework firework = loc.getWorld().spawn(loc, Firework.class);
FireworkMeta data = (FireworkMeta) firework.getFireworkMeta();
FireworkMeta data = firework.getFireworkMeta();
data.clearEffects();
data.setPower(1);
data.addEffect(fe);
@ -35,9 +35,9 @@ public class UtilFirework
{
try
{
Firework fw = (Firework) loc.getWorld().spawn(loc, Firework.class);
Firework fw = loc.getWorld().spawn(loc, Firework.class);
FireworkMeta data = (FireworkMeta) fw.getFireworkMeta();
FireworkMeta data = fw.getFireworkMeta();
data.clearEffects();
data.setPower(power);
data.addEffect(fe);
@ -59,7 +59,6 @@ public class UtilFirework
public void detonateFirework(Firework firework)
{
((CraftWorld)firework.getWorld()).getHandle().broadcastEntityEffect(((CraftEntity)firework).getHandle(), (byte)17);
firework.remove();
}
@ -85,9 +84,12 @@ public class UtilFirework
firework.setFireworkMeta(data);
((CraftFirework) firework).getHandle().expectedLifespan = 1;
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(firework.getEntityId());
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[]
{
firework.getEntityId()
});
for (Player viewing : UtilServer.getPlayers())
{
if (player == viewing)

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@ -70,13 +71,13 @@ public class UtilInv
public static boolean contains(Player player, String itemNameContains, Material item, byte data, int required)
{
return contains(player, itemNameContains, item, data, required, true, true);
return contains(player, itemNameContains, item, data, required, true, true, true);
}
public static boolean contains(Player player, String itemNameContains, Material item, byte data, int required, boolean checkArmor, boolean checkCursor)
public static boolean contains(Player player, String itemNameContains, Material item, byte data, int required, boolean checkArmor, boolean checkCursor, boolean checkCrafting)
{
for (ItemStack stack : getItems(player, checkArmor, checkCursor))
for (ItemStack stack : getItems(player, checkArmor, checkCursor, checkCrafting))
{
if (required <= 0)
{
@ -154,18 +155,25 @@ public class UtilInv
PlayerInventory inv = player.getInventory();
inv.clear();
inv.setArmorContents(new ItemStack[4]);
player.setItemOnCursor(new ItemStack(Material.AIR));
inv.setArmorContents(new ItemStack[4]);
player.setItemOnCursor(new ItemStack(Material.AIR));
Inventory openInventory = player.getOpenInventory().getTopInventory();
if (openInventory.getHolder() == player)
{
openInventory.clear();
}
player.saveData();
}
public static ArrayList<ItemStack> getItems(Player player)
{
return getItems(player, true, true);
return getItems(player, true, true, true);
}
public static ArrayList<ItemStack> getItems(Player player, boolean getArmor, boolean getCursor)
public static ArrayList<ItemStack> getItems(Player player, boolean getArmor, boolean getCursor, boolean getCrafting)
{
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
PlayerInventory inv = player.getInventory();
@ -197,6 +205,22 @@ public class UtilInv
items.add(cursorItem.clone());
}
if (getCrafting)
{
Inventory openInventory = player.getOpenInventory().getTopInventory();
if (openInventory.getHolder() == player && openInventory.getType() == InventoryType.CRAFTING)
{
for (ItemStack item : openInventory.getContents())
{
if (item != null && item.getType() != Material.AIR)
{
items.add(item.clone());
}
}
}
}
return items;
}
@ -357,11 +381,12 @@ public class UtilInv
return getAmount(player, mat, true);
}
public static int getAmount(Player player, Material mat, boolean includeArmorAndCursor)
public static int getAmount(Player player, Material mat, boolean includeArmorAndCursorAndCrafting)
{
int amount = 0;
for (ItemStack item : getItems(player, true, true))
for (ItemStack item : getItems(player, includeArmorAndCursorAndCrafting, includeArmorAndCursorAndCrafting,
includeArmorAndCursorAndCrafting))
{
if (item.getType() == mat)
{

View File

@ -3,7 +3,8 @@ package mineplex.core.common.util;
import java.lang.reflect.Field;
import mineplex.core.common.util.UtilParticle.ViewDist;
import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles;
import net.minecraft.server.v1_8_R3.EnumParticle;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldParticles;
import org.bukkit.Location;
import org.bukkit.Material;
@ -13,30 +14,26 @@ public class UtilParticle
{
public enum ViewDist
{
SHORT(8),
NORMAL(24),
LONG(48),
LONGER(96),
MAX(256);
SHORT(8), NORMAL(24), LONG(48), LONGER(96), MAX(256);
private int _dist;
ViewDist(int dist)
{
_dist = dist;
}
public int getDist()
{
return _dist;
}
}
public enum ParticleType
{
ANGRY_VILLAGER("angryVillager", "Lightning Cloud", Material.INK_SACK, (byte) 11),
ANGRY_VILLAGER(EnumParticle.VILLAGER_ANGRY, "angryVillager", "Lightning Cloud", Material.INK_SACK, (byte) 11),
BLOCK_CRACK("blockcrack_1_0")
BLOCK_CRACK(EnumParticle.BLOCK_CRACK, "blockcrack")
{
@Override
public String getParticle(Material type, int data)
@ -45,7 +42,7 @@ public class UtilParticle
}
},
BLOCK_DUST("blockdust_1_0")
BLOCK_DUST(EnumParticle.BLOCK_DUST, "blockdust")
{
@Override
public String getParticle(Material type, int data)
@ -54,37 +51,37 @@ public class UtilParticle
}
},
BUBBLE("bubble"),
BUBBLE(EnumParticle.WATER_BUBBLE, "bubble"),
CLOUD("cloud", "White Smoke", Material.INK_SACK, (byte) 7),
CLOUD(EnumParticle.CLOUD, "cloud", "White Smoke", Material.INK_SACK, (byte) 7),
CRIT("crit", "Brown Magic", Material.INK_SACK, (byte) 14),
CRIT(EnumParticle.CRIT, "crit", "Brown Magic", Material.INK_SACK, (byte) 14),
DEPTH_SUSPEND("depthSuspend"),
DEPTH_SUSPEND(EnumParticle.SUSPENDED_DEPTH, "depthSuspend"),
DRIP_LAVA("dripLava", "Lava Drip", Material.LAVA_BUCKET, (byte) 0),
DRIP_LAVA(EnumParticle.DRIP_LAVA, "dripLava", "Lava Drip", Material.LAVA_BUCKET, (byte) 0),
DRIP_WATER("dripWater", "Water Drop", Material.WATER_BUCKET, (byte) 0),
DRIP_WATER(EnumParticle.DRIP_WATER, "dripWater", "Water Drop", Material.WATER_BUCKET, (byte) 0),
DROPLET("droplet", "Water Splash", Material.INK_SACK, (byte) 4),
DROPLET(EnumParticle.WATER_DROP, "droplet", "Water Splash", Material.INK_SACK, (byte) 4),
ENCHANTMENT_TABLE("enchantmenttable", "Enchantment Words", Material.BOOK, (byte) 0),
ENCHANTMENT_TABLE(EnumParticle.ENCHANTMENT_TABLE, "enchantmenttable", "Enchantment Words", Material.BOOK, (byte) 0),
EXPLODE("explode", "Big White Smoke", Material.INK_SACK, (byte) 15),
EXPLODE(EnumParticle.EXPLOSION_NORMAL, "explode", "Big White Smoke", Material.INK_SACK, (byte) 15),
FIREWORKS_SPARK("fireworksSpark", "White Sparkle", Material.GHAST_TEAR, (byte) 0),
FIREWORKS_SPARK(EnumParticle.FIREWORKS_SPARK, "fireworksSpark", "White Sparkle", Material.GHAST_TEAR, (byte) 0),
FLAME("flame", "Flame", Material.BLAZE_POWDER, (byte) 0),
FLAME(EnumParticle.FLAME, "flame", "Flame", Material.BLAZE_POWDER, (byte) 0),
FOOTSTEP("footstep", "Foot Step", Material.LEATHER_BOOTS, (byte) 0),
FOOTSTEP(EnumParticle.FOOTSTEP, "footstep", "Foot Step", Material.LEATHER_BOOTS, (byte) 0),
HAPPY_VILLAGER("happyVillager", "Emerald Sparkle", Material.EMERALD, (byte) 0),
HAPPY_VILLAGER(EnumParticle.VILLAGER_HAPPY, "happyVillager", "Emerald Sparkle", Material.EMERALD, (byte) 0),
HEART("heart", "Love Heart", Material.APPLE, (byte) 0),
HEART(EnumParticle.HEART, "heart", "Love Heart", Material.APPLE, (byte) 0),
HUGE_EXPLOSION("hugeexplosion", "Huge Explosion", Material.TNT, (byte) 0),
HUGE_EXPLOSION(EnumParticle.EXPLOSION_HUGE, "hugeexplosion", "Huge Explosion", Material.TNT, (byte) 0),
ICON_CRACK("iconcrack_1_0")
ICON_CRACK(EnumParticle.ITEM_CRACK, "iconcrack")
{
@Override
public String getParticle(Material type, int data)
@ -93,66 +90,84 @@ public class UtilParticle
}
},
INSTANT_SPELL("instantSpell"),
INSTANT_SPELL(EnumParticle.SPELL_INSTANT, "instantSpell"),
LARGE_EXPLODE("largeexplode", "Explosion", Material.FIREBALL, (byte) 0),
LARGE_EXPLODE(EnumParticle.EXPLOSION_LARGE, "largeexplode", "Explosion", Material.FIREBALL, (byte) 0),
LARGE_SMOKE("largesmoke", "Black Smoke", Material.INK_SACK, (byte) 0),
LARGE_SMOKE(EnumParticle.SMOKE_LARGE, "largesmoke", "Black Smoke", Material.INK_SACK, (byte) 0),
LAVA("lava", "Lava Debris", Material.LAVA, (byte) 0),
SMOKE(EnumParticle.SMOKE_NORMAL, "smoke", "Smoke", Material.INK_SACK, (byte) 0),
MAGIC_CRIT("magicCrit", "Teal Magic", Material.INK_SACK, (byte) 6),
LAVA(EnumParticle.LAVA, "lava", "Lava Debris", Material.LAVA, (byte) 0),
MAGIC_CRIT(EnumParticle.CRIT_MAGIC, "magicCrit", "Teal Magic", Material.INK_SACK, (byte) 6),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz
*/
MOB_SPELL("mobSpell", "Black Swirls", Material.getMaterial(2263), (byte) 0),
MOB_SPELL(EnumParticle.SPELL_MOB, "mobSpell", "Black Swirls", Material.getMaterial(2263), (byte) 0),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz
*/
MOB_SPELL_AMBIENT("mobSpellAmbient", "Transparent Black Swirls", Material.getMaterial(2266), (byte) 0),
NOTE("note", "Musical Note", Material.JUKEBOX, (byte) 0),
PORTAL("portal", "Portal Effect", Material.INK_SACK, (byte) 5),
MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_AMBIENT, "mobSpellAmbient", "Transparent Black Swirls", Material
.getMaterial(2266), (byte) 0),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz. Offset y if 0 will default to 1, counter by making it 0.0001
* To do certain colors, use "no / 24F" for the random X value, 1 for speed. 0 for count.
*/
NOTE(EnumParticle.NOTE, "note", "Musical Note", Material.JUKEBOX, (byte) 0),
PORTAL(EnumParticle.PORTAL, "portal", "Portal Effect", Material.INK_SACK, (byte) 5),
/**
* Can be colored if count is 0, color is RGB and depends on the offset of xyz. Offset y if 0 will default to 1, counter
* by making it 0.0001
*/
RED_DUST("reddust", "Red Smoke", Material.INK_SACK, (byte) 1),
RED_DUST(EnumParticle.REDSTONE, "reddust", "Red Smoke", Material.INK_SACK, (byte) 1),
SLIME("slime", "Slime Particles", Material.SLIME_BALL, (byte) 0),
SLIME(EnumParticle.SLIME, "slime", "Slime Particles", Material.SLIME_BALL, (byte) 0),
SNOW_SHOVEL("snowshovel", "Snow Puffs", Material.SNOW_BALL, (byte) 0),
SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL, "snowshovel", "Snow Puffs", Material.SNOW_BALL, (byte) 0),
SNOWBALL_POOF("snowballpoof"),
SNOWBALL_POOF(EnumParticle.SNOWBALL, "snowballpoof"),
SPELL("spell", "White Swirls", Material.getMaterial(2264), (byte) 0),
SPELL(EnumParticle.SPELL, "spell", "White Swirls", Material.getMaterial(2264), (byte) 0),
SPLASH("splash"),
SPLASH(EnumParticle.WATER_SPLASH, "splash"),
SUSPEND("suspended"),
SUSPEND(EnumParticle.SUSPENDED, "suspended"),
TOWN_AURA("townaura", "Black Specks", Material.COAL, (byte) 0),
TOWN_AURA(EnumParticle.TOWN_AURA, "townaura", "Black Specks", Material.COAL, (byte) 0),
WITCH_MAGIC("witchMagic", "Purple Magic", Material.INK_SACK, (byte) 13);
WITCH_MAGIC(EnumParticle.SPELL_WITCH, "witchMagic", "Purple Magic", Material.INK_SACK, (byte) 13),
MOB_APPEARANCE(EnumParticle.MOB_APPEARANCE, "mobappearance"),
BARRIER(EnumParticle.BARRIER, "barrier"),
ITEM_TAKE(EnumParticle.ITEM_TAKE, "take"),
WATER_WAKE(EnumParticle.WATER_WAKE, "wake");
public EnumParticle particle;
public String particleName;
private boolean _friendlyData;
private String _friendlyName;
private Material _material;
private byte _data;
ParticleType(String particleName)
ParticleType(EnumParticle particle, String particleName)
{
this.particleName = particleName;
_friendlyData = false;
this.particle = particle;
}
ParticleType(String particleName, String friendlyName, Material material, byte data)
ParticleType(EnumParticle particle, String particleName, String friendlyName, Material material, byte data)
{
this.particleName = particleName;
this.particle = particle;
_friendlyData = true;
_friendlyName = friendlyName;
_material = material;
@ -173,9 +188,9 @@ public class UtilParticle
{
if (_friendlyName == null)
{
return toString();
return toString();
}
return _friendlyName;
}
@ -203,28 +218,48 @@ public class UtilParticle
private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY,
float offsetZ, float speed, int count, boolean displayFar)
{
String[] parts = particleName.split("_");
int[] details = new int[parts.length - 1];
for (int i = 0; i < details.length; i++)
{
details[i] = Integer.parseInt(parts[i + 1]);
}
ParticleType particleType = ParticleType.CRIT;
for (ParticleType type : ParticleType.values())
{
if (type.particleName.equalsIgnoreCase(parts[0]))
{
particleType = type;
}
}
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleType.particle, displayFar,
(float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed,
count, details);
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(particleName, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, displayFar);
return packet;
}
public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players)
public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players)
{
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, players);
}
public static void PlayParticle(String particle, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players)
public static void PlayParticle(String particle, Location location, float offsetX, float offsetY, float offsetZ, float speed,
int count, ViewDist dist, Player... players)
{
PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true);
for (Player player : players)
{
//Out of range for player
// Out of range for player
if (UtilMath.offset(player.getLocation(), location) > dist.getDist())
continue;
UtilPlayer.sendPacket(player, packet);
}
}

View File

@ -6,16 +6,16 @@ import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PlayerConnection;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PlayerConnection;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -590,17 +590,15 @@ public class UtilPlayer
return (((CraftEntity) player).getHandle().getDataWatcher().getByte(0) & 1 << 4) != 0;
}
public static boolean is1_8(Player player)
{
return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion() >= 47;
}
public static void sendPacket(Player player, Packet... packets)
{
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
for (Packet packet : packets)
{
if (packet == null)
continue;
connection.sendPacket(packet);
}
}

View File

@ -1,192 +1,193 @@
package mineplex.core.common.util;
import net.minecraft.server.v1_7_R4.ChatSerializer;
import net.minecraft.server.v1_7_R4.IChatBaseComponent;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.spigotmc.ProtocolInjector;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerListHeaderFooter;
import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
public class UtilTabTitle
{
private static final int PROTOCOL_VERSION = 47;
public static void broadcastHeader(String header)
{
broadcastHeaderAndFooter(header, null);
}
public static void broadcastHeader(String header)
{
broadcastHeaderAndFooter(header, null);
}
public static void broadcastFooter(String footer)
{
broadcastHeaderAndFooter(null, footer);
}
public static void broadcastFooter(String footer)
{
broadcastHeaderAndFooter(null, footer);
}
public static void broadcastHeaderAndFooter(String header, String footer)
{
for (Player player : Bukkit.getOnlinePlayers())
doHeaderAndFooter(player, header, footer);
}
public static void setHeaderAndFooter(Player player, String header, String footer)
{
doHeaderAndFooter(player, header, footer);
}
public static void broadcastHeaderAndFooter(String header, String footer)
{
for (Player player : Bukkit.getOnlinePlayers())
doHeaderAndFooter(player, header, footer);
}
public static void setHeader(Player p, String header)
{
doHeaderAndFooter(p, header, null);
}
public static void setHeaderAndFooter(Player player, String header, String footer)
{
doHeaderAndFooter(player, header, footer);
}
public static void setHeader(Player p, String header)
{
doHeaderAndFooter(p, header, null);
}
public static void setFooter(Player p, String footer)
{
doHeaderAndFooter(p, null, footer);
}
public static void setFooter(Player p, String footer)
{
doHeaderAndFooter(p, null, footer);
}
public static void doHeaderAndFooter(Player p, String rawHeader, String rawFooter)
{
CraftPlayer player = (CraftPlayer) p;
if (player.getHandle().playerConnection.networkManager.getVersion() != PROTOCOL_VERSION) return;
IChatBaseComponent header = ChatSerializer.a(TextConverter.convert(rawHeader));
IChatBaseComponent footer = ChatSerializer.a(TextConverter.convert(rawFooter));
if (header == null || footer == null)
{
TabTitleCache titleCache = TabTitleCache.getTabTitle(p.getUniqueId());
if (titleCache != null)
{
if (header == null)
{
String headerString = titleCache.getHeader();
if (headerString != null)
{
rawHeader = headerString;
header = ChatSerializer.a(TextConverter.convert(headerString));
}
}
if (footer == null)
{
String footerString = titleCache.getFooter();
if (footerString != null)
{
rawHeader = footerString;
header = ChatSerializer.a(TextConverter.convert(footerString));
}
}
}
}
TabTitleCache.addTabTitle(p.getUniqueId(), new TabTitleCache(rawHeader, rawFooter));
ProtocolInjector.PacketTabHeader packet = new ProtocolInjector.PacketTabHeader(header, footer);
player.getHandle().playerConnection.sendPacket(packet);
}
private static class TextConverter
{
public static String convert(String text)
{
if (text == null || text.length() == 0)
{
return "\"\"";
}
char c;
int i;
int len = text.length();
StringBuilder sb = new StringBuilder(len + 4);
String t;
sb.append('"');
for (i = 0; i < len; i += 1)
{
c = text.charAt(i);
switch (c)
{
case '\\':
case '"':
sb.append('\\');
sb.append(c);
break;
case '/':
sb.append('\\');
sb.append(c);
break;
case '\b':
sb.append("\\b");
break;
case '\t':
sb.append("\\t");
break;
case '\n':
sb.append("\\n");
break;
case '\f':
sb.append("\\f");
break;
case '\r':
sb.append("\\r");
break;
default:
if (c < ' ')
{
t = "000" + Integer.toHexString(c);
sb.append("\\u").append(t.substring(t.length() - 4));
}
else
{
sb.append(c);
}
}
}
sb.append('"');
return sb.toString();
}
public static String setPlayerName(Player player, String text)
{
return text.replaceAll("(?i)\\{PLAYER\\}", player.getName());
}
}
private static class TabTitleCache
{
final private static Map<UUID, TabTitleCache> playerTabTitles = new HashMap<>();
private String header;
private String footer;
public TabTitleCache(String header, String footer)
{
this.header = header;
this.footer = footer;
}
public static TabTitleCache getTabTitle(UUID uuid)
{
return playerTabTitles.get(uuid);
}
public static void addTabTitle(UUID uuid, TabTitleCache titleCache)
{
playerTabTitles.put(uuid, titleCache);
}
public static void removeTabTitle(UUID uuid)
{
playerTabTitles.remove(uuid);
}
public String getHeader()
{
return header;
}
public String getFooter()
{
return footer;
}
}
public static void doHeaderAndFooter(Player p, String rawHeader, String rawFooter)
{
IChatBaseComponent header = IChatBaseComponent.ChatSerializer.a(TextConverter.convert(rawHeader));
IChatBaseComponent footer = IChatBaseComponent.ChatSerializer.a(TextConverter.convert(rawFooter));
if (header == null || footer == null)
{
TabTitleCache titleCache = TabTitleCache.getTabTitle(p.getUniqueId());
if (titleCache != null)
{
if (header == null)
{
String headerString = titleCache.getHeader();
if (headerString != null)
{
rawHeader = headerString;
header = IChatBaseComponent.ChatSerializer.a(TextConverter.convert(headerString));
}
}
if (footer == null)
{
String footerString = titleCache.getFooter();
if (footerString != null)
{
rawHeader = footerString;
header = IChatBaseComponent.ChatSerializer.a(TextConverter.convert(footerString));
}
}
}
}
TabTitleCache.addTabTitle(p.getUniqueId(), new TabTitleCache(rawHeader, rawFooter));
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
packet.a = header;
packet.b = footer;
UtilPlayer.sendPacket(p, packet);
}
private static class TextConverter
{
public static String convert(String text)
{
if (text == null || text.length() == 0)
{
return "\"\"";
}
char c;
int i;
int len = text.length();
StringBuilder sb = new StringBuilder(len + 4);
String t;
sb.append('"');
for (i = 0; i < len; i += 1)
{
c = text.charAt(i);
switch (c)
{
case '\\':
case '"':
sb.append('\\');
sb.append(c);
break;
case '/':
sb.append('\\');
sb.append(c);
break;
case '\b':
sb.append("\\b");
break;
case '\t':
sb.append("\\t");
break;
case '\n':
sb.append("\\n");
break;
case '\f':
sb.append("\\f");
break;
case '\r':
sb.append("\\r");
break;
default:
if (c < ' ')
{
t = "000" + Integer.toHexString(c);
sb.append("\\u").append(t.substring(t.length() - 4));
}
else
{
sb.append(c);
}
}
}
sb.append('"');
return sb.toString();
}
public static String setPlayerName(Player player, String text)
{
return text.replaceAll("(?i)\\{PLAYER\\}", player.getName());
}
}
private static class TabTitleCache
{
final private static Map<UUID, TabTitleCache> playerTabTitles = new HashMap<>();
private String header;
private String footer;
public TabTitleCache(String header, String footer)
{
this.header = header;
this.footer = footer;
}
public static TabTitleCache getTabTitle(UUID uuid)
{
return playerTabTitles.get(uuid);
}
public static void addTabTitle(UUID uuid, TabTitleCache titleCache)
{
playerTabTitles.put(uuid, titleCache);
}
public static void removeTabTitle(UUID uuid)
{
playerTabTitles.remove(uuid);
}
public String getHeader()
{
return header;
}
public String getFooter()
{
return footer;
}
}
}

View File

@ -14,15 +14,6 @@ public class UtilTextBottom
//1.8
msg.send(MessageType.ABOVE_HOTBAR, players);
//1.7 Players
for (Player player : players)
{
if (!UtilPlayer.is1_8(player))
{
UtilTextTop.display(text, player);
}
}
}
public static void displayProgress(double amount, Player... players)
@ -59,21 +50,7 @@ public class UtilTextBottom
progressBar += "";
}
//Send to Player
for (Player player : players)
{
//1.7 - Add Color
if (!UtilPlayer.is1_8(player))
{
UtilTextTop.displayProgress((prefix == null ? "" : C.cYellow + C.Bold + prefix) + (suffix == null ? "" : ChatColor.RESET + C.Bold + " - " + C.cGreen + C.Bold + suffix),
amount, player);
}
//1.8
else
{
display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players);
}
}
display((prefix == null ? "" : prefix + ChatColor.RESET + " ") + progressBar + (suffix == null ? "" : ChatColor.RESET + " " + suffix), players);
}
}

View File

@ -1,12 +1,11 @@
package mineplex.core.common.util;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.ChatMessage;
import org.spigotmc.ProtocolInjector.PacketTitle;
import org.spigotmc.ProtocolInjector.PacketTitle.Action;
import net.minecraft.server.v1_8_R3.ChatMessage;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
/**
* Created by Shaun on 9/5/2014.
@ -52,7 +51,7 @@ public class UtilTextMiddle
text = "";
ChatMessage message = new ChatMessage(text);
PacketTitle packet = new PacketTitle(Action.TITLE, message);
PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, message);
sendPacket(packet, players);
}
@ -67,7 +66,7 @@ public class UtilTextMiddle
text = "";
ChatMessage message = new ChatMessage(text);
PacketTitle packet = new PacketTitle(Action.SUBTITLE, message);
PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, message);
sendPacket(packet, players);
}
@ -78,7 +77,7 @@ public class UtilTextMiddle
*/
private static void setTimings(int fadeInTicks, int stayTicks, int fadeOutTicks, Player... players)
{
PacketTitle packet = new PacketTitle(Action.TIMES, fadeInTicks, stayTicks, fadeOutTicks);
PacketPlayOutTitle packet = new PacketPlayOutTitle(fadeInTicks, stayTicks, fadeOutTicks);
sendPacket(packet, players);
}
@ -87,7 +86,7 @@ public class UtilTextMiddle
*/
public static void clear(Player... players)
{
PacketTitle packet = new PacketTitle(Action.CLEAR);
PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.CLEAR, null);
sendPacket(packet, players);
}
@ -98,18 +97,15 @@ public class UtilTextMiddle
*/
public static void reset(Player... players)
{
PacketTitle packet = new PacketTitle(Action.RESET);
PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.RESET, null);
sendPacket(packet, players);
}
private static void sendPacket(PacketTitle packet, Player... players)
private static void sendPacket(Packet packet, Player... players)
{
for (Player player : players)
{
if (UtilPlayer.is1_8(player))
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
UtilPlayer.sendPacket(player, packet);
}
}

View File

@ -1,16 +1,16 @@
package mineplex.core.common.util;
import mineplex.core.common.DummyEntity;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -38,23 +38,19 @@ public class UtilTextTop
deleteOld(player);
healthPercent = Math.min(1, healthPercent);
boolean halfHealth = UtilPlayer.is1_8(player);
//Display Dragon
{
Location loc = player.getLocation().subtract(0, 200, 0);
((CraftPlayer)player).getHandle().playerConnection.sendPacket(getDragonPacket(text, healthPercent, halfHealth, loc));
UtilPlayer.sendPacket(player, getDragonPacket(text, healthPercent, loc));
}
//Display Wither (as well as Dragon)
if (UtilPlayer.is1_8(player))
{
Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(24));
((CraftPlayer)player).getHandle().playerConnection.sendPacket(getWitherPacket(text, healthPercent, halfHealth, loc));
}
Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(24));
UtilPlayer.sendPacket(player, getWitherPacket(text, healthPercent, loc));
//Remove
Bukkit.getServer().getScheduler().runTaskLater(Bukkit.getPluginManager().getPlugins()[0], new Runnable()
@ -68,19 +64,22 @@ public class UtilTextTop
private static void deleteOld(Player player)
{
//Delete Dragon (All Clients)
PacketPlayOutEntityDestroy destroyDragonPacket = new PacketPlayOutEntityDestroy(EntityDragonId);
((CraftPlayer)player).getHandle().playerConnection.sendPacket(destroyDragonPacket);
//Delete Wither (1.8+ Only)
if (UtilPlayer.is1_8(player))
{
PacketPlayOutEntityDestroy destroyWitherPacket = new PacketPlayOutEntityDestroy(EntityWitherId);
((CraftPlayer)player).getHandle().playerConnection.sendPacket(destroyWitherPacket);
}
// Delete Dragon (All Clients)
PacketPlayOutEntityDestroy destroyDragonPacket = new PacketPlayOutEntityDestroy(new int[]
{
EntityDragonId
});
UtilPlayer.sendPacket(player, destroyDragonPacket);
// Delete Wither (1.8+ Only)
PacketPlayOutEntityDestroy destroyWitherPacket = new PacketPlayOutEntityDestroy(new int[]
{
EntityWitherId
});
UtilPlayer.sendPacket(player, destroyWitherPacket);
}
public static PacketPlayOutSpawnEntityLiving getDragonPacket(String text, double healthPercent, boolean halfHealth, Location loc)
public static PacketPlayOutSpawnEntityLiving getDragonPacket(String text, double healthPercent, Location loc)
{
PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
@ -108,7 +107,7 @@ public class UtilTextTop
return mobPacket;
}
public static PacketPlayOutSpawnEntityLiving getWitherPacket(String text, double healthPercent, boolean halfHealth, Location loc)
public static PacketPlayOutSpawnEntityLiving getWitherPacket(String text, double healthPercent, Location loc)
{
PacketPlayOutSpawnEntityLiving mobPacket = new PacketPlayOutSpawnEntityLiving();
@ -143,13 +142,11 @@ public class UtilTextTop
watcher.a(0, (Byte) (byte) 0); //Flags, 0x20 = invisible
watcher.a(6, (Float) (float) health);
watcher.a(2, (String) text); //Entity name
watcher.a(10, (String) text); //Entity name
watcher.a(3, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show
watcher.a(11, (Byte) (byte) 0); //Show name, 1 = show, 0 = don't show
watcher.a(16, (Integer) (int) health); //Health
watcher.a(20, (Integer) (int) 881); //Inv
int i1 = watcher.getInt(0);
int i1 = watcher.getByte(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
return watcher;

View File

@ -2,133 +2,148 @@ package mineplex.core.common.util;
import java.io.File;
import net.minecraft.server.v1_7_R4.ConvertProgressUpdater;
import net.minecraft.server.v1_7_R4.Convertable;
import net.minecraft.server.v1_7_R4.EntityTracker;
import net.minecraft.server.v1_7_R4.EnumDifficulty;
import net.minecraft.server.v1_7_R4.EnumGamemode;
import net.minecraft.server.v1_7_R4.IWorldAccess;
import net.minecraft.server.v1_7_R4.ServerNBTManager;
import net.minecraft.server.v1_7_R4.WorldLoaderServer;
import net.minecraft.server.v1_7_R4.WorldManager;
import net.minecraft.server.v1_7_R4.WorldServer;
import net.minecraft.server.v1_7_R4.WorldSettings;
import net.minecraft.server.v1_7_R4.WorldType;
import net.minecraft.server.v1_8_R3.Convertable;
import net.minecraft.server.v1_8_R3.EntityTracker;
import net.minecraft.server.v1_8_R3.EnumDifficulty;
import net.minecraft.server.v1_8_R3.IDataManager;
import net.minecraft.server.v1_8_R3.IProgressUpdate;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.ServerNBTManager;
import net.minecraft.server.v1_8_R3.WorldData;
import net.minecraft.server.v1_8_R3.WorldLoaderServer;
import net.minecraft.server.v1_8_R3.WorldManager;
import net.minecraft.server.v1_8_R3.WorldServer;
import net.minecraft.server.v1_8_R3.WorldSettings;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.generator.ChunkGenerator;
public class WorldUtil
public class WorldUtil
{
public static World LoadWorld(WorldCreator creator)
{
CraftServer server = (CraftServer)Bukkit.getServer();
if (creator == null)
{
throw new IllegalArgumentException("Creator may not be null");
}
CraftServer server = (CraftServer) Bukkit.getServer();
if (creator == null)
{
throw new IllegalArgumentException("Creator may not be null");
}
String name = creator.name();
System.out.println("Loading world '" + name + "'");
ChunkGenerator generator = creator.generator();
File folder = new File(server.getWorldContainer(), name);
World world = server.getWorld(name);
WorldType type = WorldType.getType(creator.type().getName());
boolean generateStructures = creator.generateStructures();
String name = creator.name();
ChunkGenerator generator = creator.generator();
File folder = new File(server.getWorldContainer(), name);
World world = server.getWorld(name);
net.minecraft.server.v1_8_R3.WorldType type = net.minecraft.server.v1_8_R3.WorldType.getType(creator.type().getName());
boolean generateStructures = creator.generateStructures();
if (world != null)
{
return world;
}
if (world != null)
{
return world;
}
if ((folder.exists()) && (!folder.isDirectory()))
{
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
}
if ((folder.exists()) && (!folder.isDirectory()))
{
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
}
if (generator == null)
{
generator = server.getGenerator(name);
}
if (generator == null)
{
generator = server.getGenerator(name);
}
Convertable converter = new WorldLoaderServer(server.getWorldContainer());
if (converter.isConvertable(name))
{
server.getLogger().info("Converting world '" + name + "'");
converter.convert(name, new ConvertProgressUpdater(server.getServer()));
}
Convertable converter = new WorldLoaderServer(server.getWorldContainer());
if (converter.isConvertable(name))
{
server.getLogger().info("Converting world '" + name + "'");
converter.convert(name, new IProgressUpdate()
{
private long b = System.currentTimeMillis();
int dimension = server.getWorlds().size() + 1;
boolean used = false;
do
{
for (WorldServer worldServer : server.getServer().worlds)
{
used = worldServer.dimension == dimension;
if (used)
{
dimension++;
break;
}
}
} while(used);
boolean hardcore = false;
public void a(String s)
{
}
System.out.println("Loaded world with dimension : " + dimension);
WorldServer internal = new WorldServer(server.getServer(), new ServerNBTManager(server.getWorldContainer(), name, true), name, dimension, new WorldSettings(creator.seed(), EnumGamemode.getById(server.getDefaultGameMode().getValue()), generateStructures, hardcore, type), server.getServer().methodProfiler, creator.environment(), generator);
boolean containsWorld = false;
for (World otherWorld : server.getWorlds())
{
if (otherWorld.getName().equalsIgnoreCase(name.toLowerCase()))
{
containsWorld = true;
break;
}
}
if (!containsWorld)
return null;
public void a(int i)
{
if (System.currentTimeMillis() - this.b >= 1000L)
{
this.b = System.currentTimeMillis();
MinecraftServer.LOGGER.info("Converting... " + i + "%");
}
}
System.out.println("Created world with dimension : " + dimension);
internal.scoreboard = server.getScoreboardManager().getMainScoreboard().getHandle();
internal.worldMaps = server.getServer().worlds.get(0).worldMaps;
internal.tracker = new EntityTracker(internal); // CraftBukkit
internal.addIWorldAccess((IWorldAccess) new WorldManager(server.getServer(), internal));
internal.difficulty = EnumDifficulty.HARD;
internal.setSpawnFlags(true, true);
internal.savingDisabled = true;
server.getServer().worlds.add(internal);
public void c(String s)
{
}
});
}
int dimension = 10 + server.getServer().worlds.size();
boolean used = false;
do
for (WorldServer s : server.getServer().worlds)
{
used = s.dimension == dimension;
if (used)
{
dimension++;
break;
}
}
while (used);
boolean hardcore = false;
/*
for (WorldServer worlder : server.getServer().worlds)
{
System.out.println(worlder.getWorldData().getName() + " with dimension: " + worlder.dimension);
}
*/
if (generator != null)
{
internal.getWorld().getPopulators().addAll(generator.getDefaultPopulators(internal.getWorld()));
}
Object sdm = new ServerNBTManager(server.getWorldContainer(), name, true);
WorldData worlddata = ((IDataManager) sdm).getWorldData();
if (worlddata == null)
{
WorldSettings worldSettings = new WorldSettings(creator.seed(),
WorldSettings.EnumGamemode.getById(server.getDefaultGameMode().getValue()), generateStructures, hardcore, type);
worldSettings.setGeneratorSettings(creator.generatorSettings());
worlddata = new WorldData(worldSettings, name);
}
worlddata.checkName(name);
WorldServer internal = (WorldServer) new WorldServer(server.getServer(), (IDataManager) sdm, worlddata, dimension,
server.getServer().methodProfiler, creator.environment(), generator).b();
server.getPluginManager().callEvent(new WorldInitEvent(internal.getWorld()));
server.getPluginManager().callEvent(new WorldLoadEvent(internal.getWorld()));
/*
for (WorldServer worlder : server.getServer().worlds)
{
System.out.println(worlder.getWorldData().getName() + " with dimension: " + worlder.dimension);
}
*/
return internal.getWorld();
boolean containsWorld = false;
for (World otherWorld : server.getWorlds())
{
if (otherWorld.getName().equalsIgnoreCase(name.toLowerCase()))
{
containsWorld = true;
break;
}
}
if (!containsWorld)
return null;
internal.scoreboard = server.getScoreboardManager().getMainScoreboard().getHandle();
internal.tracker = new EntityTracker(internal);
internal.addIWorldAccess(new WorldManager(server.getServer(), internal));
internal.worldData.setDifficulty(EnumDifficulty.EASY);
internal.setSpawnFlags(true, true);
server.getServer().worlds.add(internal);
if (generator != null)
{
internal.getWorld().getPopulators().addAll(generator.getDefaultPopulators(internal.getWorld()));
}
server.getPluginManager().callEvent(new WorldInitEvent(internal.getWorld()));
server.getPluginManager().callEvent(new WorldLoadEvent(internal.getWorld()));
/*
for (WorldServer worlder : server.getServer().worlds)
{
System.out.println(worlder.getWorldData().getName() + " with dimension: " + worlder.dimension);
}
*/
return internal.getWorld();
}
}

View File

@ -174,7 +174,15 @@ public class ZipUtil
int size;
byte[] buffer = new byte[2048];
fileOutputStream = new FileOutputStream(outputDirectory + File.separator + entry.getName());
String fileName = outputDirectory + File.separator + entry.getName();
if (fileName.endsWith("/"))
{
new File(fileName).mkdirs();
continue;
}
fileOutputStream = new FileOutputStream(fileName);
bufferedOutputStream = new BufferedOutputStream(fileOutputStream, buffer.length);
while ((size = zipInputStream.read(buffer, 0, buffer.length)) != -1)

View File

@ -1,6 +1,5 @@
package mineplex.core;
import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -9,28 +8,30 @@ import java.util.UUID;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.event.CustomTagEvent;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.WatchableObject;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
@ -49,234 +50,266 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer>>();
private NautHashMap<String, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<String, NautHashMap<Integer, String>>();
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityVehicleMap = new NautHashMap<String, NautHashMap<Integer, Integer>>();
private HashSet<String> _loggedIn = new HashSet<String>();
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
private NautHashMap<UUID, Long> _exemptTimeMap = new NautHashMap<UUID, Long>();
private NautHashMap<UUID, NautHashMap<CheckType, Long>> _doubleStrike = new NautHashMap<UUID, NautHashMap<CheckType, Long>>();
private Field _destroyId;
private PacketHandler _packetHandler;
public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler)
{
super("Custom Tag Fix", plugin);
packetHandler.addPacketHandler(this);
try
{
_destroyId = PacketPlayOutEntityDestroy.class.getDeclaredField("a");
_destroyId.setAccessible(true);
}
catch (Exception exception)
{
System.out.println("Field exception in CustomTagFix : ");
exception.printStackTrace();
}
_packetHandler = packetHandler;
packetHandler.addPacketHandler(this, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class,
PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class,
PacketPlayInUseEntity.class);
NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
NCPHookManager.addHook(CheckType.ALL, this);
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_entityMap.remove(event.getPlayer().getName());
_entityNameMap.remove(event.getPlayer().getName());
_entityVehicleMap.remove(event.getPlayer().getName());
_loggedIn.remove(event.getPlayer());
}
@EventHandler
public void ncpExempt(final PlayerToggleFlightEvent event)
{
long ignoreTime = System.currentTimeMillis() + 1500;
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{
_exemptTimeMap.put(event.getPlayer().getUniqueId(), Math.max(ignoreTime, _exemptTimeMap.get(event.getPlayer().getUniqueId())));
_exemptTimeMap.put(event.getPlayer().getUniqueId(),
Math.max(ignoreTime, _exemptTimeMap.get(event.getPlayer().getUniqueId())));
return;
}
try
{
NCPExemptionManager.exemptPermanently(event.getPlayer());
}
catch (Exception exception)
{
}
_exemptTimeMap.put(event.getPlayer().getUniqueId(), ignoreTime);
}
@EventHandler
public void ncpExemptVelocity(final PlayerVelocityEvent event)
{
long ignoreTime = System.currentTimeMillis() + (long)(event.getVelocity().length() * 2000);
long ignoreTime = System.currentTimeMillis() + (long) (event.getVelocity().length() * 2000);
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{
_exemptTimeMap.put(event.getPlayer().getUniqueId(), Math.max(ignoreTime, _exemptTimeMap.get(event.getPlayer().getUniqueId())));
_exemptTimeMap.put(event.getPlayer().getUniqueId(),
Math.max(ignoreTime, _exemptTimeMap.get(event.getPlayer().getUniqueId())));
return;
}
_exemptTimeMap.put(event.getPlayer().getUniqueId(), ignoreTime);
}
@EventHandler
public void unexempt(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Iterator<Entry<UUID, Long>> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext();)
{
final Entry<UUID, Long> entry = iterator.next();
if (System.currentTimeMillis() > entry.getValue())
{
iterator.remove();
}
}
for (Iterator<Entry<UUID, NautHashMap<CheckType, Long>>> iterator = _doubleStrike.entrySet().iterator(); iterator.hasNext();)
for (Iterator<Entry<UUID, NautHashMap<CheckType, Long>>> iterator = _doubleStrike.entrySet().iterator(); iterator
.hasNext();)
{
Entry<UUID, NautHashMap<CheckType, Long>> entry = iterator.next();
for (Iterator<Entry<CheckType, Long>> innerIterator = entry.getValue().entrySet().iterator(); innerIterator.hasNext();)
{
final Entry<CheckType, Long> entry2 = innerIterator.next();
if (System.currentTimeMillis() > entry2.getValue())
{
innerIterator.remove();
}
}
if (entry.getValue() == null || entry.getValue().size() == 0)
iterator.remove();
}
}
@EventHandler
public void cleanMap(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (Iterator<String> iterator = _loggedIn.iterator(); iterator.hasNext();)
{
String player = iterator.next();
if (Bukkit.getPlayerExact(player) == null)
{
iterator.remove();
_entityMap.remove(player);
_entityNameMap.remove(player);
_entityVehicleMap.remove(player);
}
}
if (Bukkit.getServer().getOnlinePlayers().size() < _loggedIn.size())
{
System.out.println("PROBLEM - _loggedIn TOOOOOO BIIIIIGGGGG.");
}
}
@SuppressWarnings("unchecked")
public void handle(PacketInfo packetInfo)
{
if (packetInfo.isCancelled())
return;
Packet packet = packetInfo.getPacket();
Player owner = packetInfo.getPlayer();
PacketVerifier verifier = packetInfo.getVerifier();
if (owner.isOnline() && UtilPlayer.is1_8(owner))
if (owner.isOnline())
{
if (owner.isOnline() && !_entityMap.containsKey(owner.getName()))
{
_entityMap.put(owner.getName(), new NautHashMap<Integer, Integer>());
_entityNameMap.put(owner.getName(), new NautHashMap<Integer, String>());
_entityVehicleMap.put(owner.getName(), new NautHashMap<Integer, Integer>());
_loggedIn.add(owner.getName());
}
if (packet instanceof PacketPlayOutSpawnEntityLiving)
{
PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving)packet;
PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving) packet;
// Ignore Armor stand packets
if (spawnPacket.b == 30 || spawnPacket.l == null || spawnPacket.l.c() == null || spawnPacket.a == 777777)
if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId() || spawnPacket.l == null || spawnPacket.l.c() == null
|| spawnPacket.a == 777777)
{
if (spawnPacket.b == 30)
if (spawnPacket.b == EntityType.ARMOR_STAND.getTypeId())
{
_ignoreSkulls.add(spawnPacket.a);
_ignoreSkulls.add(spawnPacket.a);
}
return;
}
for (WatchableObject watchable : (List<WatchableObject>)spawnPacket.l.c())
for (WatchableObject watchable : (List<WatchableObject>) spawnPacket.l.c())
{
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1)
if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1)
{
final String entityName = spawnPacket.l.getString(10);
if (entityName.isEmpty())
{
_entityNameMap.get(owner.getName()).remove(spawnPacket.a);
return;
}
if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner.getName()).get(spawnPacket.a)));
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[]
{
_entityMap.get(owner.getName()).get(spawnPacket.a)
}));
_entityNameMap.get(owner.getName()).remove(spawnPacket.a);
_entityMap.get(owner.getName()).remove(spawnPacket.a);
}
final String entityName = spawnPacket.l.getString(2);
if (entityName.isEmpty())
{
return;
}
int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier);
_entityMap.get(owner.getName()).put(spawnPacket.a, newId);
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, newId);
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true);
break;
}
}
}
else if (packet instanceof PacketPlayOutEntityMetadata)
{
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet;
if (!_entityMap.get(owner.getName()).containsKey(metaPacket.a) && metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a))
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet;
if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a))
{
String entityName = "";
boolean nameShowing = false;
for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b)
boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a);
String currentName = _entityNameMap.get(owner.getName()).get(metaPacket.a);
if (currentName == null)
{
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1)
currentName = "";
}
String newName = currentName;
boolean newDisplay = isDisplaying;
for (WatchableObject watchable : (List<WatchableObject>) metaPacket.b)
{
if (watchable.a() == 3 && watchable.b() instanceof Byte)
{
nameShowing = true;
newDisplay = ((Byte) watchable.b()) == 1;
}
if ((watchable.a() == 10 || watchable.a() == 2) && watchable.b() instanceof String)
if (watchable.a() == 2 && watchable.b() instanceof String)
{
entityName = (String)watchable.b();
newName = (String) watchable.b();
}
}
if (nameShowing && !entityName.isEmpty())
// If the name has changed and the name should be showing, or the name display status has changed.
if ((!newName.equals(currentName) && newDisplay) || newDisplay != isDisplaying)
{
int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier);
_entityMap.get(owner.getName()).put(metaPacket.a, newId);
_entityNameMap.get(owner.getName()).put(metaPacket.a, entityName);
}
else if (!entityName.isEmpty())
{
_entityNameMap.get(owner.getName()).remove(metaPacket.a);
// If name is still being displayed
if (newDisplay)
{
int newId;
if (isDisplaying) // Sending metadata
{
newId = _entityMap.get(owner.getName()).get(metaPacket.a);
}
else
// Spawning new entity
{
newId = UtilEnt.getNewEntityId();
_entityMap.get(owner.getName()).put(metaPacket.a, newId);
}
sendProtocolPackets(owner, metaPacket.a, newId, newName, verifier, !isDisplaying);
_entityNameMap.get(owner.getName()).put(metaPacket.a, newName);
}
else
{ // Lets delete it
int id = _entityMap.get(owner.getName()).get(metaPacket.a);
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[]
{
id
}));
_entityMap.get(owner.getName()).remove(metaPacket.a);
_entityNameMap.get(owner.getName()).remove(metaPacket.a);
}
}
}
}
@ -284,13 +317,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
try
{
for (int id : (int[])_destroyId.get(packet))
for (int id : ((PacketPlayOutEntityDestroy) packet).a)
{
if (_entityMap.get(owner.getName()).containsKey(id))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner.getName()).get(id)));
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[]
{
_entityMap.get(owner.getName()).get(id)
}));
_entityMap.get(owner.getName()).remove(id);
_entityVehicleMap.get(owner.getName()).remove(id);
_entityNameMap.get(owner.getName()).remove(id);
}
}
@ -299,155 +334,41 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
exception.printStackTrace();
}
}
else if (packet instanceof PacketPlayOutSpawnEntity)
{
PacketPlayOutSpawnEntity spawnPacket = (PacketPlayOutSpawnEntity) packet;
if (spawnPacket.j == 66 && spawnPacket.a != 777777)
{
_ignoreSkulls.add(spawnPacket.a);
}
}
/*
else if (packet instanceof PacketPlayOutAttachEntity)
else if (packet instanceof PacketPlayOutSpawnEntity)
{
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity)packet;
/* TODO dynamic attach handling?
if (attachPacket.c == -1)
PacketPlayOutSpawnEntity spawnPacket = (PacketPlayOutSpawnEntity) packet;
if (spawnPacket.j == 66 && spawnPacket.a != 777777)
{
if (_entityVehicleMap.get(owner).containsKey(attachPacket.b) && _entityNameMap.get(owner).containsKey(_entityVehicleMap.get(owner).get(attachPacket.b)))
{
int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, _entityVehicleMap.get(owner).get(attachPacket.b), newId, _entityNameMap.get(owner).get(_entityVehicleMap.get(owner).get(attachPacket.b)), verifier);
_entityMap.get(owner).put(attachPacket.b, newId);
_entityVehicleMap.get(owner).remove(attachPacket.b);
packetInfo.setCancelled(true);
}
}
else
{
_entityVehicleMap.get(owner).put(attachPacket.b, attachPacket.c);
}
if (_entityMap.get(owner).containsKey(attachPacket.c))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(attachPacket.c)));
_entityMap.get(owner).remove(attachPacket.c);
}
else
*/
/*
//System.out.println(owner.getName() + " id=" + owner.getEntityId() + " recieving AttachPacket b=" + attachPacket.b + " c=" + attachPacket.c);
if (attachPacket.c == -1 && _entityMap.get(owner).containsKey(attachPacket.b))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(attachPacket.b)));
_entityMap.get(owner).remove(attachPacket.b);
}
else if (attachPacket.c == owner.getEntityId())
{
if (_entityMap.get(owner).containsKey(attachPacket.b))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(attachPacket.b)));
}
PacketPlayOutSpawnEntityLiving armorPacket = new PacketPlayOutSpawnEntityLiving();
armorPacket.a = UtilEnt.getNewEntityId();
armorPacket.b = (byte) 30;
armorPacket.c = (int)EnumEntitySize.SIZE_2.a(100);
armorPacket.d = (int)MathHelper.floor(64 * 32.0D);
armorPacket.e = (int)EnumEntitySize.SIZE_2.a(100);
armorPacket.i = (byte) ((int) (0 * 256.0F / 360.0F));
armorPacket.j = (byte) ((int) (0 * 256.0F / 360.0F));
armorPacket.k = (byte) ((int) (0 * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
armorPacket.f = (int)(var4 * 8000.0D);
armorPacket.g = (int)(var6 * 8000.0D);
armorPacket.h = (int)(var8 * 8000.0D);
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte)0));
watcher.a(1, Short.valueOf((short)300));
watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0));
watcher.a(4, Byte.valueOf((byte)0));
watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte)0));
watcher.a(9, Byte.valueOf((byte)0));
watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte)0));
// Set invisible
int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
armorPacket.l = watcher;
// Spawn armor packet
verifier.bypassProcess(armorPacket);
PacketPlayOutAttachEntity attachPacket2 = new PacketPlayOutAttachEntity();
attachPacket2.c = owner.getEntityId();
attachPacket2.b = armorPacket.a;
attachPacket2.a = 0;
// Send armor attach to player.
verifier.bypassProcess(attachPacket2);
// Change original packet to attach to armor stand
attachPacket.c = armorPacket.a;
_entityMap.get(owner).put(attachPacket.b, armorPacket.a);
_ignoreSkulls.add(spawnPacket.a);
}
}
else if (packet instanceof PacketPlayInUseEntity)
{
PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet;
for (Entry<Integer, Integer> entry : _entityMap.get(owner.getName()).entrySet())
{
if (entry.getValue() == usePacket.a)
{
PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity();
newPacket.a = entry.getKey();
newPacket.action = usePacket.action;
newPacket.c = usePacket.c;
if (_packetHandler.handlePacket(owner, newPacket))
{
((CraftPlayer) owner).getHandle().playerConnection.a(newPacket);
}
break;
}
}
}
*/
}
}
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName, final PacketVerifier packetList)
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName,
final PacketVerifier packetList, final boolean newPacket)
{
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event);
@ -457,107 +378,102 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
public void run()
{
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = newEntityId;
packet.b = (byte) 30;
packet.c = (int)EnumEntitySize.SIZE_2.a(100);
packet.d = (int)MathHelper.floor(64 * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(100);
packet.i = (byte) ((int) (0 * 256.0F / 360.0F));
packet.j = (byte) ((int) (0 * 256.0F / 360.0F));
packet.k = (byte) ((int) (0 * 256.0F / 360.0F));
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int)(var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D);
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)owner.getWorld()).getHandle()));
watcher.a(0, Byte.valueOf((byte)0));
watcher.a(1, Short.valueOf((short)300));
watcher.a(0, Byte.valueOf((byte) 0));
watcher.a(1, Short.valueOf((short) 300));
watcher.a(2, "");
watcher.a(3, Byte.valueOf((byte) 0));
watcher.a(4, Byte.valueOf((byte)0));
watcher.a(4, Byte.valueOf((byte) 0));
watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte)0));
watcher.a(9, Byte.valueOf((byte)0));
watcher.a(8, Byte.valueOf((byte) 0));
watcher.a(9, Byte.valueOf((byte) 0));
watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte)0));
// Set invisible
int i1 = watcher.getInt(0);
watcher.watch(0, Byte.valueOf((byte)(i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte)(b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
watcher.watch(2, finalEntityName);
watcher.watch(3, Byte.valueOf((byte)1));
packet.l = watcher;
packetList.bypassProcess(packet);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = packet.a;
vehiclePacket.c = entityId;
packetList.bypassProcess(vehiclePacket);
/* TODO dynamic attach handling?
if (_entityVehicleMap.get(owner).containsValue(entityId))
{
vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
for (Entry<Integer, Integer> entry : _entityVehicleMap.get(owner).entrySet())
{
if (entry.getValue() == entityId)
vehiclePacket.b = entry.getKey();
}
watcher.a(10, Byte.valueOf((byte) 0));
vehiclePacket.c = packet.a;
// Set invisible
int i1 = watcher.getByte(0);
watcher.watch(0, Byte.valueOf((byte) (i1 | 1 << 5)));
// Set small
byte b1 = watcher.getByte(10);
b1 = (byte) (b1 | 0x1);
watcher.watch(10, Byte.valueOf(b1));
watcher.watch(2, finalEntityName);
watcher.watch(3, Byte.valueOf((byte) 1));
if (newPacket)
{
final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = newEntityId;
spawnPacket.b = (byte) 30;
spawnPacket.c = (int) MathHelper.floor(100 * 32);
spawnPacket.d = (int) MathHelper.floor(64 * 32.0D);
spawnPacket.e = (int) MathHelper.floor(100 * 32);
spawnPacket.i = (byte) ((int) (0 * 256.0F / 360.0F));
spawnPacket.j = (byte) ((int) (0 * 256.0F / 360.0F));
spawnPacket.k = (byte) ((int) (0 * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
spawnPacket.f = (int) (var4 * 8000.0D);
spawnPacket.g = (int) (var6 * 8000.0D);
spawnPacket.h = (int) (var8 * 8000.0D);
spawnPacket.l = watcher;
UtilPlayer.sendPacket(owner, spawnPacket);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = entityId;
UtilPlayer.sendPacket(owner, vehiclePacket);
}
else
{
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
entityMetadata.a = newEntityId;
entityMetadata.b = watcher.c();
packetList.bypassProcess(entityMetadata);
}
*/
}
});
}
@ -578,28 +494,28 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
public boolean onCheckFailure(CheckType checkType, Player player, IViolationInfo violationInfo)
{
boolean failure = false;
if (checkType == CheckType.MOVING_SURVIVALFLY || checkType == CheckType.MOVING_PASSABLE)
{
{
failure = _exemptTimeMap.containsKey(player.getUniqueId());
if (failure)
MovingData.getData(player).clearFlyData();
}
// This is the second strike system.
if (!failure)
{
if (!_doubleStrike.containsKey(player.getUniqueId()) || !_doubleStrike.get(player.getUniqueId()).containsKey(checkType.getParent()))
if (!_doubleStrike.containsKey(player.getUniqueId())
|| !_doubleStrike.get(player.getUniqueId()).containsKey(checkType.getParent()))
failure = true;
if (!_doubleStrike.containsKey(player.getUniqueId()))
_doubleStrike.put(player.getUniqueId(), new NautHashMap<CheckType, Long>());
_doubleStrike.get(player.getUniqueId()).put(checkType.getParent(), System.currentTimeMillis() + 5000);
}
return failure;
}
}

View File

@ -0,0 +1,183 @@
package mineplex.core;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerAnimationType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class PacketsInteractionFix extends MiniPlugin implements IPacketHandler
{
private HashMap<String, HashSet<Integer>> _armorStands = new HashMap<String, HashSet<Integer>>();
private HashSet<Player> _leftClicked = new HashSet<Player>();
private int _lastTick;
public PacketsInteractionFix(JavaPlugin plugin, PacketHandler packetHandler)
{
super("Packets Interaction Fix", plugin);
packetHandler.addPacketHandler(this, true, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutEntityDestroy.class,
PacketPlayInUseEntity.class);
}
private void checkLeftClicks()
{
if (MinecraftServer.currentTick == _lastTick)
{
return;
}
_lastTick = MinecraftServer.currentTick;
_leftClicked.clear();
}
@EventHandler
public void onArmAnimation(PlayerAnimationEvent event)
{
if (event.getAnimationType() != PlayerAnimationType.ARM_SWING)
{
return;
}
checkLeftClicks();
Player player = event.getPlayer();
if (_leftClicked.remove(player))
{
return;
}
CraftEventFactory.callPlayerInteractEvent(((CraftPlayer) player).getHandle(), Action.LEFT_CLICK_AIR,
((CraftPlayer) player).getHandle().inventory.getItemInHand());
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
_leftClicked.remove(event.getPlayer().getName());
_armorStands.remove(event.getPlayer().getName());
}
@EventHandler
public void removeDeadNames(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
checkLeftClicks();
Iterator<String> itel = _armorStands.keySet().iterator();
while (itel.hasNext())
{
String name = itel.next();
Player player = Bukkit.getPlayerExact(name);
if (player != null)
{
continue;
}
itel.remove();
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if (!event.getAction().name().contains("LEFT"))
{
return;
}
checkLeftClicks();
_leftClicked.add(event.getPlayer());
}
@Override
public void handle(PacketInfo packetInfo)
{
Player player = packetInfo.getPlayer();
if (!player.isOnline())
{
return;
}
if (packetInfo.isCancelled())
{
return;
}
if (!_armorStands.containsKey(player.getName()))
{
_armorStands.put(player.getName(), new HashSet<Integer>());
}
HashSet<Integer> list = _armorStands.get(player.getName());
if (packetInfo.getPacket() instanceof PacketPlayOutSpawnEntityLiving)
{
PacketPlayOutSpawnEntityLiving packet = (PacketPlayOutSpawnEntityLiving) packetInfo.getPacket();
if (packet.b != EntityType.ARMOR_STAND.getTypeId())
{
return;
}
list.add(packet.a);
}
else if (packetInfo.getPacket() instanceof PacketPlayOutEntityDestroy)
{
PacketPlayOutEntityDestroy packet = (PacketPlayOutEntityDestroy) packetInfo.getPacket();
list.removeAll(Arrays.asList(packet.a));
}
else if (packetInfo.getPacket() instanceof PacketPlayInUseEntity)
{
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) packetInfo.getPacket();
if (!list.contains(packet.a))
{
return;
}
if (packet.action == EnumEntityUseAction.ATTACK)
{
return;
}
CraftEventFactory.callPlayerInteractEvent(((CraftPlayer) player).getHandle(), Action.RIGHT_CLICK_AIR,
((CraftPlayer) player).getHandle().inventory.getItemInHand());
}
}
}

View File

@ -1,54 +0,0 @@
package mineplex.core;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
public class TablistFix extends MiniPlugin
{
public TablistFix(JavaPlugin plugin)
{
super("Tablist Fix", plugin);
}
// This is sort of experimental!
@EventHandler(priority = EventPriority.MONITOR)
public void onJoin(PlayerJoinEvent event)
{/*
final Player player = event.getPlayer();
runSyncLater(new Runnable()
{
@Override
public void run()
{
if (!player.isOnline())
return;
PacketPlayOutPlayerInfo packet = PacketPlayOutPlayerInfo.updateDisplayName(((CraftPlayer) player).getHandle());
if (UtilPlayer.is1_8(player))
{
UtilPlayer.sendPacket(player, packet);
}
for (Player other : UtilServer.getPlayers())
{
if (other.equals(player) || !other.canSee(player))
continue;
if (UtilPlayer.is1_8(other))
UtilPlayer.sendPacket(other, packet);
}
}
}, 20L);
*/
}
}

View File

@ -8,6 +8,7 @@ import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import com.google.gson.Gson;
import mineplex.core.MiniPlugin;
import mineplex.core.account.command.TestRank;
import mineplex.core.account.command.UpdateRank;
@ -28,7 +29,6 @@ import mineplex.playerCache.PlayerInfo;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -426,6 +426,25 @@ public class CoreClientManager extends MiniPlugin
}, name, uuid, rank, perm);
}
public void SaveRank(final Callback<Rank> callback, final String name, final UUID uuid, Rank rank, boolean perm)
{
_repository.saveRank(new Callback<Rank>()
{
public void run(Rank newRank)
{
if (_plugin.getServer().getPlayer(name) != null)
{
CoreClient client = Get(name);
client.SetRank(newRank, false);
}
if (callback != null)
callback.run(newRank);
}
}, name, uuid, rank, perm);
}
public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
{
_repository.matchPlayerName(new Callback<List<String>>()

View File

@ -1,6 +1,6 @@
package mineplex.core.account.event;
import org.bukkit.craftbukkit.libs.com.google.gson.stream.JsonWriter;
import com.google.gson.stream.JsonWriter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

View File

@ -11,7 +11,7 @@ import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
import com.google.gson.reflect.TypeToken;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.ILoginProcessor;

View File

@ -6,7 +6,7 @@ import java.sql.SQLException;
import mineplex.core.database.DBPool;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class AntiHackRepository

View File

@ -62,7 +62,7 @@ import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -72,8 +72,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
{
@ -405,7 +405,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (!_enabled)
return;
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, -1);
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, (byte) -1);
}
public void IncreaseSize(Entity player)
@ -413,7 +413,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (!_enabled)
return;
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, 1);
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, (byte) 1);
}
// DAILY BONUS
@ -892,7 +892,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (client.getHologram() == null)
{
double yAdd = UtilPlayer.is1_8(player) ? 2.18 : 2.3;
double yAdd = 2.18;
hologram = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), "");
hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST);
hologram.addPlayer(player);

View File

@ -9,7 +9,6 @@ import mineplex.core.recharge.Recharge;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.TabCompleteEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;

View File

@ -4,14 +4,17 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.Items;
import net.minecraft.server.v1_7_R4.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_7_R4.PacketPlayOutSetSlot;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.ChatMessage;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.Items;
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -19,6 +22,7 @@ import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.PetSorter;
@ -166,11 +170,11 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
PetTagPage petTagPage = new PetTagPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Repairing", getPlayer(), pet, petPurchase);
EntityPlayer entityPlayer = ((CraftPlayer) getPlayer()).getHandle();
int containerCounter = entityPlayer.nextContainerCounter();
entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerCounter, 8, "Repairing", 0, true));
UtilPlayer.sendPacket(player, new PacketPlayOutOpenWindow(containerCounter, "minecraft:anvil", new ChatMessage(Blocks.ANVIL.a() + ".name", new Object[0])));
entityPlayer.activeContainer = new AnvilContainer(entityPlayer.inventory, petTagPage.getInventory());
entityPlayer.activeContainer.windowId = containerCounter;
entityPlayer.activeContainer.addSlotListener(entityPlayer);
entityPlayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_7_R4.ItemStack(Items.NAME_TAG)));
UtilPlayer.sendPacket(player, new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_8_R3.ItemStack(Items.NAME_TAG)));
getShop().setCurrentPageForPlayer(getPlayer(), petTagPage);
}

View File

@ -17,8 +17,8 @@ import mineplex.core.pet.repository.token.PetToken;
import mineplex.core.shop.page.ConfirmationPage;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.playerCache.PlayerCache;
import net.minecraft.server.v1_7_R4.ItemStack;
import net.minecraft.server.v1_7_R4.Items;
import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.Items;
import org.bukkit.ChatColor;
import org.bukkit.Material;

View File

@ -2,9 +2,11 @@ package mineplex.core.creature.command;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -110,7 +112,7 @@ public class MobCommand extends MultiCommandBase<Creature>
HashSet<Entity> entSet = new HashSet<Entity>();
for (int i = 0 ; i < count ; i++)
{
entSet.add(Plugin.SpawnEntity(caller.getTargetBlock(null, 0).getLocation().add(0.5, 1, 0.5), type));
entSet.add(Plugin.SpawnEntity(caller.getTargetBlock((Set<Material>) null, 0).getLocation().add(0.5, 1, 0.5), type));
}
//Search Vars

View File

@ -9,59 +9,43 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseArmorStand;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguiseLiving;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseRabbit;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_7_R4.Block;
import net.minecraft.server.v1_7_R4.Chunk;
import net.minecraft.server.v1_7_R4.ChunkAddEntityEvent;
import net.minecraft.server.v1_7_R4.ChunkSection;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.EntityTrackerEntry;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutAnimation;
import net.minecraft.server.v1_7_R4.PacketPlayOutBed;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityStatus;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityVelocity;
import net.minecraft.server.v1_7_R4.PacketPlayOutMapChunk;
import net.minecraft.server.v1_7_R4.PacketPlayOutMapChunkBulk;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedSoundEffect;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMoveLook;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateAttributes;
import net.minecraft.server.v1_7_R4.WorldServer;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Chunk;
import net.minecraft.server.v1_8_R3.ChunkSection;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.PacketPlayOutAnimation;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutBed;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk;
import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunkBulk;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.PlayerInfoData;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityVelocity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedSoundEffect;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -75,6 +59,26 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin;
import com.mineplex.spigot.ChunkAddEntityEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguiseLiving;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseRabbit;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.timing.TimingManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
private NautHashMap<Integer, DisguiseBase> _spawnPacketMap = new NautHashMap<Integer, DisguiseBase>();
@ -89,18 +93,8 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
private boolean _handlingPacket = false;
private Field _attributesA;
private Field _attributesB;
private Field _soundB;
private Field _soundC;
private Field _soundD;
private Field _bedA;
private Field _bedB;
private Field _bedD;
private Field _xChunk;
private Field _zChunk;
private Field _eStatusId;
private Field _eStatusState;
private Chunk _bedChunk;
private boolean _bedPackets;
@ -109,37 +103,22 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
super("Disguise Manager", plugin);
packetHandler.addPacketHandler(this);
packetHandler.addPacketHandler(this, PacketPlayOutAnimation.class, PacketPlayOutBed.class,
PacketPlayOutEntityStatus.class, PacketPlayOutMapChunk.class, PacketPlayOutMapChunkBulk.class,
PacketPlayOutNamedEntitySpawn.class, PacketPlayOutPlayerInfo.class,
PacketPlayOutEntity.PacketPlayOutRelEntityMove.class, PacketPlayOutEntity.PacketPlayOutRelEntityMoveLook.class,
PacketPlayOutSpawnEntity.class, PacketPlayOutEntityVelocity.class, PacketPlayOutEntityDestroy.class,
PacketPlayOutEntityTeleport.class, PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntityLiving.class,
PacketPlayOutUpdateAttributes.class, PacketPlayOutEntityEquipment.class, PacketPlayOutNamedSoundEffect.class);
try
{
_attributesA = PacketPlayOutUpdateAttributes.class.getDeclaredField("a");
_attributesA.setAccessible(true);
_attributesB = PacketPlayOutUpdateAttributes.class.getDeclaredField("b");
_attributesB.setAccessible(true);
_soundB = PacketPlayOutNamedSoundEffect.class.getDeclaredField("b");
_soundB.setAccessible(true);
_soundC = PacketPlayOutNamedSoundEffect.class.getDeclaredField("c");
_soundC.setAccessible(true);
_soundD = PacketPlayOutNamedSoundEffect.class.getDeclaredField("d");
_soundD.setAccessible(true);
_bedA = PacketPlayOutBed.class.getDeclaredField("a");
_bedA.setAccessible(true);
_bedB = PacketPlayOutBed.class.getDeclaredField("b");
_bedB.setAccessible(true);
_bedD = PacketPlayOutBed.class.getDeclaredField("d");
_bedD.setAccessible(true);
_eStatusId = PacketPlayOutEntityStatus.class.getDeclaredField("a");
_eStatusId.setAccessible(true);
_eStatusState = PacketPlayOutEntityStatus.class.getDeclaredField("b");
_eStatusState.setAccessible(true);
_bedChunk = new Chunk(null, 0, 0);
_bedChunk = new Chunk(((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(), 0, 0);
Field cSection = Chunk.class.getDeclaredField("sections");
cSection.setAccessible(true);
ChunkSection chunkSection = new ChunkSection(0, false);
Block block = Block.getById(Material.BED_BLOCK.getId());
ChunkSection chunkSection = new ChunkSection(0, true);
Block block = Block.getById(Material.BED_BLOCK.getId());
// block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"),"byId")
// .get(null))[Material.BED_BLOCK.getId()];
@ -149,17 +128,20 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH
})
{
chunkSection.setTypeId(1 + face.getModX(), 0, 1 + face.getModZ(), block);
chunkSection.setData(1 + face.getModX(), 0, 1 + face.getModZ(), face.ordinal());
chunkSection.setSkyLight(1 + face.getModX(), 0, 1 + face.getModZ(), 0);
chunkSection.setEmittedLight(1 + face.getModX(), 0, 1 + face.getModZ(), 0);
int x = 1 + face.getModX();
int z = 1 + face.getModZ();
chunkSection.setType(x, 0, z, block.fromLegacyData(face.ordinal()));
chunkSection.a(x, 0, z, 0);
chunkSection.b(x, 0, z, 0);
}
ChunkSection[] chunkSections = new ChunkSection[16];
chunkSections[0] = chunkSection;
cSection.set(_bedChunk, chunkSections);
_bedChunk.world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
// TODO
// _bedChunk.world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
_xChunk = Chunk.class.getField("locX");
_xChunk.setAccessible(true);
@ -226,13 +208,13 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
@EventHandler
public void ChunkAddEntity(ChunkAddEntityEvent event)
{
DisguiseBase disguise = _entityDisguiseMap.get(event.GetEntity().getUniqueId().toString());
DisguiseBase disguise = _entityDisguiseMap.get(event.getEntity().getUniqueId().toString());
if (disguise != null)
{
disguise.setEntity(event.GetEntity());
_spawnPacketMap.put(event.GetEntity().getEntityId(), disguise);
_entityDisguiseMap.remove(event.GetEntity().getUniqueId().toString());
disguise.setEntity(event.getEntity());
_spawnPacketMap.put(event.getEntity().getEntityId(), disguise);
_entityDisguiseMap.remove(event.getEntity().getUniqueId().toString());
if (disguise instanceof DisguiseRabbit)
{
@ -427,10 +409,10 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
Packet[] packets = new Packet[2];
// Make unload
packets[0] = new PacketPlayOutMapChunk(_bedChunk, true, 0, UtilPlayer.is1_8(player) ? 48 : 0);
packets[0] = new PacketPlayOutMapChunk(_bedChunk, true, 0);
// Make load
packets[1] = new PacketPlayOutMapChunkBulk(Arrays.asList(_bedChunk), UtilPlayer.is1_8(player) ? 48 : 0);
packets[1] = new PacketPlayOutMapChunkBulk(Arrays.asList(_bedChunk));
return packets;
}
@ -439,26 +421,26 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
prepareChunk(oldLoc);
return new PacketPlayOutMapChunk(_bedChunk, true, 0, UtilPlayer.is1_8(player) ? 48 : 0);
return new PacketPlayOutMapChunk(_bedChunk, true, 0);
}
private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise, boolean is18)
private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise)
{
try
{
PacketPlayOutBed bedPacket = new PacketPlayOutBed();
_bedA.set(bedPacket, playerDisguise.GetEntityId());
bedPacket.a = playerDisguise.GetEntityId();
int chunkX = getChunk(recieving.getX());
int chunkZ = getChunk(recieving.getZ());
_bedB.set(bedPacket, (chunkX * 16) + 1 + playerDisguise.getSleepingDirection().getModX());
_bedD.set(bedPacket, (chunkZ * 16) + 1 + playerDisguise.getSleepingDirection().getModZ());
bedPacket.b = new BlockPosition((chunkX * 16) + 1 + playerDisguise.getSleepingDirection().getModX(), 0, (chunkZ * 16)
+ 1 + playerDisguise.getSleepingDirection().getModZ());
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.GetEntity());
teleportPacket.c += (int) ((is18 ? 0.07D : 0.25D) * 32);
teleportPacket.c += (int) (0.35D * 32);
return new Packet[]
{
@ -502,7 +484,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
&& ((DisguisePlayer) entry.getKey()).getSleepingDirection() != null)
{
packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey(), UtilPlayer.is1_8(player))));
packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey())));
}
}
}
@ -522,7 +504,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
return _spawnPacketMap.get(entity.getEntityId());
}
private EntityTrackerEntry getEntityTracker(net.minecraft.server.v1_7_R4.Entity entity)
private EntityTrackerEntry getEntityTracker(net.minecraft.server.v1_8_R3.Entity entity)
{
return (EntityTrackerEntry) ((WorldServer) entity.world).tracker.trackedEntities.get(entity.getId());
}
@ -536,8 +518,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
final Player owner = packetInfo.getPlayer();
final PacketVerifier packetVerifier = packetInfo.getVerifier();
if (UtilPlayer.is1_8(owner)
&& (packet instanceof PacketPlayOutRelEntityMoveLook || packet instanceof PacketPlayOutRelEntityMove))
if (packet instanceof PacketPlayOutRelEntityMoveLook || packet instanceof PacketPlayOutRelEntityMove)
{
int entityId = -1;
@ -577,17 +558,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
rabbitHops.put(owner.getEntityId(), System.currentTimeMillis());
PacketPlayOutEntityStatus entityStatus = new PacketPlayOutEntityStatus();
try
{
_eStatusId.set(entityStatus, entityId);
_eStatusState.set(entityStatus, (byte) 1);
handlePacket(entityStatus, packetVerifier);
}
catch (Exception ex)
{
ex.printStackTrace();
}
entityStatus.a = entityId;
entityStatus.b = (byte) 1;
handlePacket(entityStatus, packetVerifier);
}
}
}
@ -595,9 +570,13 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
if (packet instanceof PacketPlayOutPlayerInfo)
{
if (_blockedNames.contains(((PacketPlayOutPlayerInfo) packet).username))
for (PlayerInfoData info : ((PacketPlayOutPlayerInfo) packet).b)
{
packetInfo.setCancelled(true);
if (_blockedNames.contains(info.a().getName()))
{
packetInfo.setCancelled(true);
break;
}
}
}
else if (packet instanceof PacketPlayOutSpawnEntity || packet instanceof PacketPlayOutSpawnEntityLiving
@ -643,20 +622,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
}
else if (packet instanceof PacketPlayOutUpdateAttributes)
{
int entityId = -1;
try
{
entityId = (int) _attributesA.get((PacketPlayOutUpdateAttributes) packet);
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
int entityId = ((PacketPlayOutUpdateAttributes) packet).a;
if (_spawnPacketMap.containsKey(entityId)
&& owner.getEntityId() != entityId
@ -831,11 +797,6 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
final Player player = packetInfo.getPlayer();
if (!UtilPlayer.is1_8(player) && (disguise instanceof DisguiseRabbit || disguise instanceof DisguiseArmorStand))
{
return;
}
final PacketVerifier packetVerifier = packetInfo.getVerifier();
if (disguise instanceof DisguisePlayer)
@ -853,7 +814,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
if (pDisguise.getSleepingDirection() != null)
{
for (Packet packet : getBedPackets(player.getLocation(), pDisguise, UtilPlayer.is1_8(player)))
for (Packet packet : getBedPackets(player.getLocation(), pDisguise))
{
handlePacket(packet, packetVerifier);
}
@ -1067,7 +1028,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
continue;
if (otherPlayer.getLocation().subtract(0, .5, 0).getBlock().getTypeId() != 0)
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(
UtilPlayer.sendPacket(player, new PacketPlayOutEntityTeleport(
((CraftPlayer) otherPlayer).getHandle()));
}
}
@ -1122,9 +1083,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
if (disguise.GetEntity() == ((CraftPlayer) player).getHandle())
continue;
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
entityPlayer.playerConnection.sendPacket(disguise.GetMetaDataPacket());
UtilPlayer.sendPacket(player, disguise.GetMetaDataPacket());
}
}
@ -1143,20 +1102,18 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
EntityPlayer disguisedPlayer = (EntityPlayer) disguise.GetEntity();
if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid)
disguiseIterator.remove();
try{
else
{
for (Iterator<Player> playerIterator = _disguisePlayerMap.get(disguise).iterator(); playerIterator.hasNext();)
{
Player player = playerIterator.next();
if (!player.isOnline() || !player.isValid())
playerIterator.remove();
}
}
catch (Exception exception) {}
}
}
}

View File

@ -1,7 +1,6 @@
package mineplex.core.disguise.disguises;
import org.bukkit.entity.*;
import org.spigotmc.ProtocolData;
public abstract class DisguiseAgeable extends DisguiseCreature
{
@ -9,23 +8,23 @@ public abstract class DisguiseAgeable extends DisguiseCreature
{
super(disguiseType, entity);
DataWatcher.a(12, new ProtocolData.IntByte(0, (byte)0));
DataWatcher.a(12, new Byte((byte)0));
}
public void UpdateDataWatcher()
{
super.UpdateDataWatcher();
DataWatcher.watch(12, DataWatcher.getIntByte(12));
DataWatcher.watch(12, DataWatcher.getByte(12));
}
public boolean isBaby()
{
return DataWatcher.getIntByte(12).value < 0;
return DataWatcher.getByte(12) < 0;
}
public void setBaby()
{
DataWatcher.watch(12, new ProtocolData.IntByte(-24000, (byte) ( -1 )));
DataWatcher.watch(12, new Byte((byte) ( -1 )));
}
}

View File

@ -2,32 +2,40 @@ package mineplex.core.disguise.disguises;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.Vector3f;
public class DisguiseArmorStand extends DisguiseInsentient
{
private Vector _headPosition = new Vector();
public DisguiseArmorStand(org.bukkit.entity.Entity entity)
{
super(entity);
DataWatcher.a(10, (byte) 0);
for (int i = 11; i < 17; i++)
{
DataWatcher.a(i, new Vector(0, 0, 0));
DataWatcher.a(i, new Vector3f(0, 0, 0));
}
// Rotations are from -360 to 360
}
private Vector3f convert(Vector vector)
{
return new Vector3f((float) vector.getX(), (float) vector.getY(), (float) vector.getZ());
}
private Vector convert(Vector3f vector)
{
return new Vector(vector.getX(), vector.getY(), vector.getZ());
}
public Vector getHeadPosition()
{
return _headPosition.clone();
return convert(DataWatcher.h(11));
}
protected String getHurtSound()
@ -41,9 +49,9 @@ public class DisguiseArmorStand extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId();
packet.b = (byte) 30;
packet.c = (int) EnumEntitySize.SIZE_2.a(Entity.locX);
packet.c = (int) MathHelper.floor(Entity.locX * 32.0D);
packet.d = (int) MathHelper.floor(Entity.locY * 32.0D);
packet.e = (int) EnumEntitySize.SIZE_2.a(Entity.locZ);
packet.e = (int) MathHelper.floor(Entity.locZ * 32.0D);
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
@ -95,7 +103,7 @@ public class DisguiseArmorStand extends DisguiseInsentient
public void setBodyPosition(Vector vector)
{
DataWatcher.watch(12, vector);
DataWatcher.watch(12, convert(vector));
}
public void setHasArms()
@ -105,18 +113,17 @@ public class DisguiseArmorStand extends DisguiseInsentient
public void setHeadPosition(Vector vector)
{
_headPosition = vector;
DataWatcher.watch(11, vector);
DataWatcher.watch(11, convert(vector));
}
public void setLeftArmPosition(Vector vector)
{
DataWatcher.watch(13, vector);
DataWatcher.watch(13, convert(vector));
}
public void setLeftLegPosition(Vector vector)
{
DataWatcher.watch(15, vector);
DataWatcher.watch(15, convert(vector));
}
public void setRemoveBase()
@ -126,12 +133,12 @@ public class DisguiseArmorStand extends DisguiseInsentient
public void setRightArmPosition(Vector vector)
{
DataWatcher.watch(14, vector);
DataWatcher.watch(14, convert(vector));
}
public void setRightLegPosition(Vector vector)
{
DataWatcher.watch(16, vector);
DataWatcher.watch(16, convert(vector));
}
public void setSmall()

View File

@ -1,14 +1,18 @@
package mineplex.core.disguise.disguises;
import mineplex.core.common.*;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.IntHashMap;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.WorldServer;
public abstract class DisguiseBase
{
@ -33,7 +37,7 @@ public abstract class DisguiseBase
_soundDisguise = this;
}
public void setEntity(org.bukkit.entity.Entity entity)
{
Entity = ((CraftEntity) entity).getHandle();
@ -53,6 +57,24 @@ public abstract class DisguiseBase
return new PacketPlayOutEntityMetadata(Entity.getId(), DataWatcher, true);
}
public void resendMetadata()
{
if (Entity == null || !Entity.getBukkitEntity().isValid() || !(Entity.world instanceof WorldServer))
return;
IntHashMap<EntityTrackerEntry> tracker = ((WorldServer) Entity.world).tracker.trackedEntities;
if (tracker.get(Entity.getId()) == null)
return;
Packet packet = GetMetaDataPacket();
for (EntityPlayer player : tracker.get(Entity.getId()).trackedPlayers)
{
UtilPlayer.sendPacket(player.getBukkitEntity(), packet);
}
}
public void setSoundDisguise(DisguiseBase soundDisguise)
{
_soundDisguise = soundDisguise;

View File

@ -2,9 +2,9 @@ package mineplex.core.disguise.disguises;
import java.util.Random;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
public class DisguiseBlock extends DisguiseBase
{

View File

@ -1,9 +1,8 @@
package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.entity.*;
public abstract class DisguiseCreature extends DisguiseInsentient
@ -28,9 +27,9 @@ public abstract class DisguiseCreature extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId();
packet.b = (byte) getDisguiseType().getTypeId();
packet.c = (int)EnumEntitySize.SIZE_2.a(Entity.locX);
packet.d = (int)MathHelper.floor(Entity.locY * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(Entity.locZ);
packet.c = (int) MathHelper.floor(Entity.locX*32D);
packet.d = (int) MathHelper.floor(Entity.locY * 32.0D);
packet.e = (int) MathHelper.floor(Entity.locZ*32D);
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));

View File

@ -2,12 +2,11 @@ package mineplex.core.disguise.disguises;
import java.util.Arrays;
import net.minecraft.server.v1_7_R4.MobEffect;
import net.minecraft.server.v1_7_R4.MobEffectList;
import net.minecraft.server.v1_7_R4.PotionBrewer;
import net.minecraft.server.v1_8_R3.MobEffect;
import net.minecraft.server.v1_8_R3.MobEffectList;
import net.minecraft.server.v1_8_R3.PotionBrewer;
import org.bukkit.entity.*;
import org.spigotmc.ProtocolData;
public class DisguiseEnderman extends DisguiseMonster
{
@ -15,9 +14,9 @@ public class DisguiseEnderman extends DisguiseMonster
{
super(EntityType.ENDERMAN, entity);
DataWatcher.a(16, new ProtocolData.ByteShort( (short) 0 ) );
DataWatcher.a(17, new Byte((byte)0));
DataWatcher.a(18, new Byte((byte)0));
DataWatcher.a(16, new Short( (short) 0));
DataWatcher.a(17, new Byte( (byte) 0));
DataWatcher.a(18, new Byte( (byte) 0));
int i = PotionBrewer.a(Arrays.asList(new MobEffect(MobEffectList.FIRE_RESISTANCE.id, 777)));
DataWatcher.watch(8, Byte.valueOf((byte)(PotionBrewer.b(Arrays.asList(new MobEffect(MobEffectList.FIRE_RESISTANCE.id, 777))) ? 1 : 0)));
@ -29,12 +28,12 @@ public class DisguiseEnderman extends DisguiseMonster
super.UpdateDataWatcher();
DataWatcher.watch(0, Byte.valueOf((byte)(DataWatcher.getByte(0) & ~(1 << 0))));
DataWatcher.watch(16, new ProtocolData.ByteShort( DataWatcher.getShort(16) ));
DataWatcher.watch(16, DataWatcher.getShort(16));
}
public void SetCarriedId(int i)
{
DataWatcher.watch(16, new ProtocolData.ByteShort( (short)(i & 0xFF)) );
DataWatcher.watch(16, new Short( (short)(i & 0xFF)) );
}
public int GetCarriedId()

View File

@ -1,7 +1,6 @@
package mineplex.core.disguise.disguises;
import org.bukkit.entity.*;
import org.spigotmc.ProtocolData;
public class DisguiseHorse extends DisguiseAnimal
{

View File

@ -1,15 +1,13 @@
package mineplex.core.disguise.disguises;
import org.spigotmc.ProtocolData;
public abstract class DisguiseHuman extends DisguiseLiving
{
public DisguiseHuman(org.bukkit.entity.Entity entity)
{
super(entity);
DataWatcher.a(10, new ProtocolData.HiddenByte( (byte) 0 ) ); // Spigot - protocol patch, handle new metadata value
DataWatcher.a(16, new ProtocolData.DualByte( (byte) 0, (byte) 0 ) );
DataWatcher.a(10, (byte) 0); // todo
DataWatcher.a(16, (byte) 0);
DataWatcher.a(17, Float.valueOf(0.0F));
DataWatcher.a(18, Integer.valueOf(0));
}

View File

@ -13,12 +13,6 @@ public abstract class DisguiseInsentient extends DisguiseLiving
DataWatcher.a(3, Byte.valueOf((byte) 0));
DataWatcher.a(2, "");
if (!(this instanceof DisguiseArmorStand))
{
DataWatcher.a(11, Byte.valueOf((byte) 0));
DataWatcher.a(10, "");
}
}
public void setName(String name)
@ -36,19 +30,17 @@ public abstract class DisguiseInsentient extends DisguiseLiving
}
}
DataWatcher.watch(10, name);
DataWatcher.watch(2, name);
}
public boolean hasCustomName()
{
return DataWatcher.getString(10).length() > 0;
return DataWatcher.getString(2).length() > 0;
}
public void setCustomNameVisible(boolean visible)
{
DataWatcher.watch(11, Byte.valueOf((byte)(visible ? 1 : 0)));
DataWatcher.watch(3, Byte.valueOf((byte)(visible ? 1 : 0)));
}

View File

@ -4,12 +4,12 @@ import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_7_R4.EntityLiving;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_8_R3.EntityLiving;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
public abstract class DisguiseLiving extends DisguiseBase
{

View File

@ -1,9 +1,8 @@
package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
public class DisguiseMagmaCube extends DisguiseInsentient
{
@ -29,9 +28,9 @@ public class DisguiseMagmaCube extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId();
packet.b = (byte) 62;
packet.c = (int)EnumEntitySize.SIZE_2.a(Entity.locX);
packet.c = (int)MathHelper.floor(Entity.locX * 32D);
packet.d = (int)MathHelper.floor(Entity.locY * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(Entity.locZ);
packet.e = (int)MathHelper.floor(Entity.locZ * 32D);
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));

View File

@ -5,18 +5,20 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.spigotmc.ProtocolData;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayInSettings;
import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayInSettings;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo;
import net.minecraft.server.v1_8_R3.WorldSettings;
import net.minecraft.server.v1_8_R3.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
public class DisguisePlayer extends DisguiseHuman
{
@ -67,37 +69,21 @@ public class DisguisePlayer extends DisguiseHuman
public boolean getSneaking()
{
return _sneaking;
}
public Packet getOldInfoPacket(boolean add)
{
PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo();
if(Entity instanceof Player)
{
playerInfo.username = Entity.getName();
playerInfo.action = add ? 0 : 4;
playerInfo.ping = 90;
playerInfo.player = ((CraftPlayer) (Player) Entity).getProfile();
playerInfo.gamemode = 0;
}
return playerInfo;
}
public Packet getNewInfoPacket(boolean add)
{
PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo();
newDisguiseInfo.a = add ? EnumPlayerInfoAction.ADD_PLAYER : EnumPlayerInfoAction.REMOVE_PLAYER;
public Packet getNewInfoPacket(boolean add)
{
PacketPlayOutPlayerInfo newDisguiseInfo = new PacketPlayOutPlayerInfo();
newDisguiseInfo.username = _profile.getName();
newDisguiseInfo.action = add ? 0 : 4;
newDisguiseInfo.ping = 90;
newDisguiseInfo.player = _profile;
newDisguiseInfo.gamemode = 0;
PacketPlayOutPlayerInfo.PlayerInfoData info = newDisguiseInfo.new PlayerInfoData(_profile, 90,
WorldSettings.EnumGamemode.SURVIVAL, null);
return newDisguiseInfo;
}
newDisguiseInfo.b.add(info);
return newDisguiseInfo;
}
@SuppressWarnings("static-access")
@Override
public void UpdateDataWatcher()
{
@ -119,7 +105,7 @@ public class DisguisePlayer extends DisguiseHuman
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
packet.a = Entity.getId();
packet.b = _profile;
packet.b = _profile.getId();
packet.c = MathHelper.floor(loc.getX() * 32.0D);
packet.d = MathHelper.floor(loc.getY() * 32.0D);
packet.e = MathHelper.floor(loc.getZ() * 32.0D);
@ -135,7 +121,7 @@ public class DisguisePlayer extends DisguiseHuman
{
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn();
packet.a = Entity.getId();
packet.b = _profile;
packet.b = _profile.getId();
packet.c = MathHelper.floor(Entity.locX * 32.0D);
packet.d = MathHelper.floor(Entity.locY * 32.0D);
packet.e = MathHelper.floor(Entity.locZ * 32.0D);

View File

@ -1,9 +1,8 @@
package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
public class DisguiseRabbit extends DisguiseInsentient
{
@ -25,9 +24,9 @@ public class DisguiseRabbit extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId();
packet.b = (byte) 101;
packet.c = (int) EnumEntitySize.SIZE_2.a(Entity.locX);
packet.c = (int) MathHelper.floor(Entity.locX * 32D);
packet.d = (int) MathHelper.floor(Entity.locY * 32.0D);
packet.e = (int) EnumEntitySize.SIZE_2.a(Entity.locZ);
packet.e = (int) MathHelper.floor(Entity.locZ * 32D);
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));

View File

@ -1,9 +1,8 @@
package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
public class DisguiseSlime extends DisguiseInsentient
{
@ -29,9 +28,9 @@ public class DisguiseSlime extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId();
packet.b = (byte) 55;
packet.c = (int)EnumEntitySize.SIZE_2.a(Entity.locX);
packet.c = (int) MathHelper.floor(Entity.locX * 32D);
packet.d = (int)MathHelper.floor(Entity.locY * 32.0D);
packet.e = (int)EnumEntitySize.SIZE_2.a(Entity.locZ);
packet.e = (int)MathHelper.floor(Entity.locZ * 32D);
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));

View File

@ -15,12 +15,12 @@ public class DisguiseWither extends DisguiseMonster
DataWatcher.a(20, new Integer(0));
}
public int ca()
public int getInvulTime()
{
return DataWatcher.getInt(20);
}
public void s(int i)
public void setInvulTime(int i)
{
DataWatcher.watch(20, Integer.valueOf(i));
}

View File

@ -1,6 +1,5 @@
package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_7_R4.BlockCloth;
import org.bukkit.entity.*;
public class DisguiseWolf extends DisguiseTameableAnimal
@ -11,7 +10,7 @@ public class DisguiseWolf extends DisguiseTameableAnimal
DataWatcher.a(18, new Float(20F));
DataWatcher.a(19, new Byte((byte)0));
DataWatcher.a(20, new Byte((byte)BlockCloth.b(1)));
DataWatcher.a(20, new Byte((byte)14));
}
public boolean isAngry()

View File

@ -5,11 +5,11 @@ import java.sql.SQLException;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.gson.Gson;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.ClientWebResponseEvent;

View File

@ -3,17 +3,21 @@ package mineplex.core.friend.ui;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.friend.FriendManager;
import mineplex.core.itemstack.ItemBuilder;
import net.minecraft.server.v1_7_R4.ContainerAnvil;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.ChatMessage;
import net.minecraft.server.v1_8_R3.ContainerAnvil;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.PacketPlayOutOpenWindow;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
@ -31,7 +35,7 @@ public class AddFriendPage implements Listener
public AnvilContainer(EntityHuman entity)
{
super(entity.inventory, entity.world, 0, 0, 0, entity);
super(entity.inventory, entity.world, new BlockPosition(0, 0, 0), entity);
}
@Override
@ -48,10 +52,10 @@ public class AddFriendPage implements Listener
if (getSlot(2).hasItem())
{
net.minecraft.server.v1_7_R4.ItemStack itemstack = getSlot(2).getItem();
net.minecraft.server.v1_8_R3.ItemStack itemstack = getSlot(2).getItem();
if (StringUtils.isBlank(origString))
itemstack.t();
itemstack.r();
else
{
itemstack.c(this.n);
@ -163,9 +167,9 @@ public class AddFriendPage implements Listener
AnvilContainer container = new AnvilContainer(p);
int c = p.nextContainerCounter();
PacketPlayOutOpenWindow packet = new PacketPlayOutOpenWindow(c, 8, "Repairing", 0, true);
PacketPlayOutOpenWindow packet = new PacketPlayOutOpenWindow(c, "minecraft:anvil", new ChatMessage(Blocks.ANVIL.a() + ".name", new Object[0]));
p.playerConnection.sendPacket(packet);
UtilPlayer.sendPacket(_player, packet);
// Set their active container to the container
p.activeContainer = container;

View File

@ -8,8 +8,8 @@ import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
@ -21,7 +21,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C;

View File

@ -1,85 +0,0 @@
package mineplex.core.friend.ui;
import java.util.UUID;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
import net.minecraft.util.com.mojang.authlib.GameProfile;
public class LineTracker
{
private String _line = null;
private String _oldLine = null;
private PacketPlayOutPlayerInfo _clearOldPacket;
private PacketPlayOutPlayerInfo _addNewPacket;
private PacketPlayOutPlayerInfo _clearNewPacket;
public LineTracker(String line)
{
setLine(line);
}
public boolean setLine(String s)
{
if (s != null && s.length() > 16)
s = s.substring(0, 16);
if (_line != null && _line.compareTo(s) == 0)
return false;
_oldLine = _line;
_line = s;
if (_oldLine != null)
{
_clearOldPacket = new PacketPlayOutPlayerInfo();
_clearOldPacket.username = _oldLine;
_clearOldPacket.action = PacketPlayOutPlayerInfo.REMOVE_PLAYER;
_clearOldPacket.ping = 0;
_clearOldPacket.player = new GameProfile(UUID.randomUUID(), _oldLine);
}
if (_line != null)
{
_addNewPacket = new PacketPlayOutPlayerInfo();
_addNewPacket.username = _line;
_addNewPacket.action = PacketPlayOutPlayerInfo.ADD_PLAYER;
_addNewPacket.ping = 0;
_addNewPacket.player = new GameProfile(UUID.randomUUID(), _line);
_clearNewPacket = new PacketPlayOutPlayerInfo();
_clearNewPacket.username = _line;
_clearNewPacket.action = PacketPlayOutPlayerInfo.REMOVE_PLAYER;
_clearNewPacket.ping = 0;
_clearNewPacket.player = new GameProfile(UUID.randomUUID(), _line);
}
return true;
}
public void displayLineToPlayer(EntityPlayer entityPlayer)
{
if (_oldLine != null)
{
entityPlayer.playerConnection.sendPacket(_clearOldPacket);
}
if (_line != null)
{
entityPlayer.playerConnection.sendPacket(_addNewPacket);
}
}
public void removeLineForPlayer(EntityPlayer entityPlayer)
{
if (_line != null)
{
entityPlayer.playerConnection.sendPacket(_clearNewPacket);
}
}
public void clearOldLine()
{
_oldLine = null;
}
}

View File

@ -1,116 +0,0 @@
package mineplex.core.friend.ui;
import java.util.HashSet;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import mineplex.core.common.util.NautHashMap;
public class TabList implements Listener
{
private static int MAX_SLOTS = 64;
private static int COLUMN_SLOTS = 16;
private static NautHashMap<Integer, String> _invisibleHolders = new NautHashMap<Integer, String>();
private NautHashMap<Integer, LineTracker> _tabSlots = new NautHashMap<Integer, LineTracker>();
private HashSet<Integer> _updatedSlots = new HashSet<Integer>();
private boolean _update;
static {
String spaces = "";
for (int i=0; i < MAX_SLOTS; i++)
{
int markerSymbol = i / COLUMN_SLOTS;
String symbol = null;
if (i % COLUMN_SLOTS == 0)
spaces = "";
else
spaces += " ";
if (markerSymbol == 0)
{
symbol = ChatColor.GREEN + "";
}
else if (markerSymbol == 1)
{
symbol = ChatColor.RED + "";
}
else if (markerSymbol == 2)
{
symbol = ChatColor.BLUE + "";
}
else if (markerSymbol == 3)
{
symbol = ChatColor.BLACK + "";
}
_invisibleHolders.put(i, symbol + spaces);
}
}
public TabList()
{
for (Integer i=0; i < MAX_SLOTS; i++)
{
_tabSlots.put(i, new LineTracker(_invisibleHolders.get(i)));
}
}
public void set(int column, int row, String lineContent)
{
int index = row * 4 + column;
if (index >= MAX_SLOTS)
return;
if (lineContent == null || lineContent.isEmpty())
lineContent = _invisibleHolders.get(index);
if (_tabSlots.get(index).setLine(lineContent))
{
_updatedSlots.add(index);
_update = true;
}
}
public void refreshForPlayer(Player player)
{
EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
int indexChanged = MAX_SLOTS;
for (int i=0; i < MAX_SLOTS; i++)
{
if (indexChanged == MAX_SLOTS && _updatedSlots.contains(i))
{
indexChanged = i;
}
else if (indexChanged != MAX_SLOTS && !_updatedSlots.contains(i))
{
_tabSlots.get(i).removeLineForPlayer(entityPlayer);
}
}
for (int i=indexChanged; i < MAX_SLOTS; i++)
{
_tabSlots.get(i).displayLineToPlayer(entityPlayer);
}
_update = false;
_updatedSlots.clear();
}
public boolean shouldUpdate()
{
return _update;
}
}

View File

@ -21,8 +21,8 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFallingSand;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFallingSand;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player;

View File

@ -8,7 +8,7 @@ import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;

View File

@ -4,7 +4,7 @@ import java.util.HashSet;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFallingSand;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFallingSand;
import org.bukkit.entity.Bat;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item;

View File

@ -2,6 +2,7 @@ package mineplex.core.gadget.gadgets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Location;
@ -111,7 +112,7 @@ public class ItemPaintbrush extends ItemGadget
if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD))
return;
Block block = player.getTargetBlock(null, 100);
Block block = player.getTargetBlock((HashSet<Byte>)null, 100);
if (block == null || block.getType() != Material.STAINED_CLAY)
return;
@ -158,7 +159,7 @@ public class ItemPaintbrush extends ItemGadget
continue;
}
Block block = player.getTargetBlock(null, 100);
Block block = player.getTargetBlock((HashSet<Byte>)null, 100);
if (block == null || block.getType() != Material.WOOL)
continue;

View File

@ -1,7 +1,5 @@
package mineplex.core.gadget.gadgets;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -9,6 +7,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.*;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.util.C;
import mineplex.core.common.util.ProfileLoader;
import mineplex.core.common.util.UUIDFetcher;

View File

@ -1,12 +1,12 @@
package mineplex.core.gadget.gadgets;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.*;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.util.C;
import mineplex.core.common.util.ProfileLoader;
import mineplex.core.common.util.UUIDFetcher;

View File

@ -27,7 +27,7 @@ public class ParticleLegend extends ParticleGadget
C.cGreen + "Unlocked with Legend Rank",
},
-2,
Material.ENDER_PORTAL, (byte)0);
Material.ENDER_PORTAL_FRAME, (byte)0);
}
@EventHandler

View File

@ -20,7 +20,12 @@ public enum GameDisplay
DragonsTeams("Dragons Teams", Material.ENDER_STONE, (byte)0, GameCategory.TEAM_VARIANT, 14),
Draw("Draw My Thing", Material.BOOK_AND_QUILL, (byte)0, GameCategory.CLASSICS, 15),
Evolution("Evolution", Material.EMERALD, (byte)0, GameCategory.ARCADE, 16),
<<<<<<< HEAD
Gravity("Gravity", Material.ENDER_PORTAL, (byte)0, GameCategory.EXTRA, 18),
=======
//FlappyBird(FlappyBird.class, "Flappy Bird", Material.FEATHER, (byte)0, GameCategory.ARCADE, 17),
Gravity("Gravity", Material.SEA_LANTERN, (byte)0, GameCategory.EXTRA, 18),
>>>>>>> master
Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19),
HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20),
HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52),

View File

@ -4,15 +4,17 @@ public class Giveaway
{
private int _id;
private String _name;
private String _prettyName;
private String _header;
private String _message;
private boolean _notifyNetwork;
private int _notifyCooldown;
public Giveaway(int id, String name, String header, String message, boolean notifyNetwork, int notifyCooldown)
public Giveaway(int id, String name, String prettyName, String header, String message, boolean notifyNetwork, int notifyCooldown)
{
_id = id;
_name = name;
_prettyName = prettyName;
_header = header;
_message = message;
_notifyNetwork = notifyNetwork;
@ -29,6 +31,11 @@ public class Giveaway
return _name;
}
public String getPrettyName()
{
return _prettyName;
}
public String getMessage()
{
return _message;

View File

@ -1,30 +1,43 @@
package mineplex.core.giveaway;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.giveaway.redis.GiveawayMessage;
import mineplex.core.giveaway.redis.GiveawayMessageHandler;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region;
import mineplex.serverdata.commands.ServerCommandManager;
public class GiveawayManager extends MiniPlugin
public class GiveawayManager extends MiniDbClientPlugin<PlayerGiveawayData>
{
private CoreClientManager _clientManager;
private ServerStatusManager _statusManager;
private GiveawayRepository _repository;
private HashMap<String, Giveaway> _giveawayMap;
private HashMap<String, GiveawayCooldown> _cooldownMap;
public GiveawayManager(JavaPlugin plugin, CoreClientManager clientManager)
public GiveawayManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager)
{
super("Giveaway Manager", plugin);
super("Giveaway Manager", plugin, clientManager);
_clientManager = clientManager;
_statusManager = statusManager;
_repository = new GiveawayRepository(plugin);
_giveawayMap = _repository.loadGiveaways();
_cooldownMap = _repository.loadCooldowns();
@ -32,7 +45,7 @@ public class GiveawayManager extends MiniPlugin
ServerCommandManager.getInstance().registerCommandType("GiveawayMessage", GiveawayMessage.class, new GiveawayMessageHandler());
}
public void attemptToGiveaway(final String giveawayName, final String cooldownName, Player player, final Callback<GiveawayResponse> callback)
public void attemptToGiveaway(final String giveawayName, final String cooldownName, final Player player, final Callback<GiveawayResponse> callback)
{
final int accountId = _clientManager.getAccountId(player);
@ -63,10 +76,10 @@ public class GiveawayManager extends MiniPlugin
{
final GiveawayResponse response;
if (_repository.canGiveaway(accountId, giveawayName))
if (_repository.canGiveaway(accountId, giveawayName, cooldownName))
{
UUID uuid = UUID.randomUUID();
if (_repository.addGiveaway(accountId, giveaway.getId(), cooldown.getId(), Region.US, "", uuid))
if (_repository.addGiveaway(accountId, giveaway.getId(), cooldown.getId(), _statusManager.getRegion(), _statusManager.getCurrentServerName(), uuid))
{
response = new GiveawayResponse(uuid);
}
@ -85,6 +98,22 @@ public class GiveawayManager extends MiniPlugin
@Override
public void run()
{
try
{
if (response.isSuccess())
{
Get(player).addGiveawayReward(new GiveawayReward(giveaway.getPrettyName(), response.getGiveawayId().toString().replace("-", "")));
notifyPlayer(player);
GiveawayMessage message = new GiveawayMessage(giveawayName, player.getName(), giveaway.getMessage(), giveaway.getHeader());
message.publish();
}
}
catch (Exception e)
{
}
if (callback != null) callback.run(response);
}
});
@ -101,4 +130,51 @@ public class GiveawayManager extends MiniPlugin
{
return _cooldownMap.containsKey(name);
}
@EventHandler
public void notifyGiveaway(UpdateEvent event)
{
if (event.getType() == UpdateType.MIN_01)
{
for (Player player : UtilServer.getPlayers())
notifyPlayer(player);
}
}
@EventHandler
public void join(PlayerJoinEvent event)
{
notifyPlayer(event.getPlayer());
}
public void notifyPlayer(Player player)
{
PlayerGiveawayData data = Get(player);
if (!data.getGiveawayRewards().isEmpty())
{
GiveawayReward reward = data.getGiveawayRewards().poll();
UtilPlayer.message(player, F.main("Giveaway", "You have a prize to claim!"));
UtilPlayer.message(player, F.main("Giveaway", "You have won " + F.elem(reward.getName())));
UtilPlayer.message(player, F.main("Giveaway", "To claim your reward please take a screenshot and contact support"));
UtilPlayer.message(player, F.main("Giveaway", "Reward Key: " + F.elem(reward.getUuid())));
}
}
@Override
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{
Set(playerName, _repository.loadPlayerGiveaway(resultSet));
}
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT g.prettyName, ag.uuid FROM accountGiveaway AS ag INNER JOIN giveaway AS g ON ag.giveawayId = g.id WHERE ag.claimed = 0 AND ag.accountId = " + accountId + ";";
}
@Override
protected PlayerGiveawayData AddPlayer(String player)
{
return new PlayerGiveawayData();
}
}

View File

@ -8,6 +8,7 @@ import java.sql.Types;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
@ -20,7 +21,7 @@ import mineplex.serverdata.Region;
public class GiveawayRepository extends RepositoryBase
{
private static final String INSERT_GIVEAWAY = "INSERT INTO Account.accountGiveaway (giveawayId, accountId, cooldownId, region, serverName, time, uuid) VALUES (?, ?, ?, ?, ?, now(), ?)";
private static final String LOAD_GIVEAWAY = "SELECT id, name, header, message, max, notifyNetwork, notifyCooldown, canWinTwice FROM Account.giveaway WHERE enabled = TRUE";
private static final String LOAD_GIVEAWAY = "SELECT id, name, prettyName, header, message, max, notifyNetwork, notifyCooldown, canWinTwice FROM Account.giveaway WHERE enabled = TRUE";
private static final String LOAD_COOLDOWN = "SELECT id, name, cooldown FROM Account.giveawayCooldown";
public GiveawayRepository(JavaPlugin plugin)
@ -28,17 +29,18 @@ public class GiveawayRepository extends RepositoryBase
super(plugin, DBPool.ACCOUNT);
}
public boolean canGiveaway(int accountId, String giveawayName)
public boolean canGiveaway(int accountId, String giveawayName, String cooldownName)
{
try (Connection connection = getConnection();
CallableStatement callableStatement = connection.prepareCall("{call check_giveaway(?, ?, ?)}"))
CallableStatement callableStatement = connection.prepareCall("{call check_giveaway(?, ?, ?, ?)}"))
{
callableStatement.setInt(1, accountId);
callableStatement.setString(2, giveawayName);
callableStatement.registerOutParameter(3, Types.BOOLEAN);
callableStatement.setString(3, cooldownName);
callableStatement.registerOutParameter(4, Types.BOOLEAN);
callableStatement.executeUpdate();
boolean pass = callableStatement.getBoolean(3);
boolean pass = callableStatement.getBoolean(4);
return pass;
}
catch (Exception e)
@ -66,14 +68,15 @@ public class GiveawayRepository extends RepositoryBase
{
int id = resultSet.getInt(1);
String name = resultSet.getString(2);
String header = resultSet.getString(3);
String message = resultSet.getString(4);
int max = resultSet.getInt(5);
boolean notifyNetwork = resultSet.getBoolean(6);
int notifyCooldown = resultSet.getInt(7);
boolean canWinTwice = resultSet.getBoolean(8);
String prettyName = resultSet.getString(3);
String header = resultSet.getString(4);
String message = resultSet.getString(5);
int max = resultSet.getInt(6);
boolean notifyNetwork = resultSet.getBoolean(7);
int notifyCooldown = resultSet.getInt(8);
boolean canWinTwice = resultSet.getBoolean(9);
Giveaway giveaway = new Giveaway(id, name, header, message, notifyNetwork, notifyCooldown);
Giveaway giveaway = new Giveaway(id, name, prettyName, header, message, notifyNetwork, notifyCooldown);
map.put(name, giveaway);
}
}
@ -102,6 +105,21 @@ public class GiveawayRepository extends RepositoryBase
return map;
}
public PlayerGiveawayData loadPlayerGiveaway(ResultSet resultSet) throws SQLException
{
PlayerGiveawayData giveawayData = new PlayerGiveawayData();
while (resultSet.next())
{
String name = resultSet.getString(1);
String uuid = resultSet.getString(2);
GiveawayReward reward = new GiveawayReward(name, uuid);
giveawayData.addGiveawayReward(reward);
}
return giveawayData;
}
@Override
protected void initialize()
{

View File

@ -0,0 +1,23 @@
package mineplex.core.giveaway;
public class GiveawayReward
{
private String _name;
private String _uuid;
public GiveawayReward(String name, String uuid)
{
_name = name;
_uuid = uuid;
}
public String getName()
{
return _name;
}
public String getUuid()
{
return _uuid;
}
}

View File

@ -0,0 +1,26 @@
package mineplex.core.giveaway;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
public class PlayerGiveawayData
{
private Queue<GiveawayReward> _giveawayRewards;
public PlayerGiveawayData()
{
_giveawayRewards = new LinkedList<GiveawayReward>();
}
public void addGiveawayReward(GiveawayReward reward)
{
_giveawayRewards.add(reward);
}
public Queue<GiveawayReward> getGiveawayRewards()
{
return _giveawayRewards;
}
}

View File

@ -7,22 +7,18 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import net.minecraft.server.v1_7_R4.DataWatcher;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_7_R4.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
@ -34,7 +30,6 @@ public class Hologram
BLACKLIST, WHITELIST;
}
private Packet _destroy1_7;
private Packet _destroy1_8;
/**
* 1.7 packets uses both EntityIDs while 1.8 uses only the first.
@ -50,7 +45,6 @@ public class Hologram
private Location _location;
private boolean _makeDestroyPackets = true;
private boolean _makeSpawnPackets = true;
private Packet[] _packets1_7;
private Packet[] _packets1_8;
private HashSet<String> _playersInList = new HashSet<String>();
private ArrayList<Player> _playersTracking = new ArrayList<Player>();
@ -58,6 +52,7 @@ public class Hologram
private HologramTarget _target = HologramTarget.BLACKLIST;
private int _viewDistance = 70;
protected Vector relativeToEntity;
private boolean _hideBoundingBox;
public Hologram(HologramManager hologramManager, Location location, String... text)
{
@ -83,6 +78,17 @@ public class Hologram
return this;
}
/**
* Warning! Bounding box if hidden will hide holograms for 1.8 to 1.8.2
*
* @return
*/
public Hologram setHideBoundingBox()
{
_hideBoundingBox = true;
return this;
}
/**
* Is there a player entry in the hologram for Whitelist and Blacklist
*/
@ -99,7 +105,7 @@ public class Hologram
return _playersInList.contains(player);
}
protected Packet getDestroyPacket(Player player)
protected Packet getDestroyPacket()
{
if (_makeDestroyPackets)
{
@ -107,7 +113,7 @@ public class Hologram
_makeDestroyPackets = false;
}
return UtilPlayer.is1_8(player) ? _destroy1_8 : _destroy1_7;
return _destroy1_8;
}
public Entity getEntityFollowing()
@ -153,7 +159,7 @@ public class Hologram
return _playersTracking;
}
protected Packet[] getSpawnPackets(Player player)
protected Packet[] getSpawnPackets()
{
if (_makeSpawnPackets)
{
@ -161,7 +167,7 @@ public class Hologram
_makeSpawnPackets = false;
}
return UtilPlayer.is1_8(player) ? _packets1_8 : _packets1_7;
return _packets1_8;
}
/**
@ -219,26 +225,20 @@ public class Hologram
private void makeDestroyPacket()
{
int[] entityIds1_7 = new int[_entityIds.size() * 2];
int[] entityIds1_8 = new int[_entityIds.size()];
for (int i = 0; i < _entityIds.size(); i++)
{
Entry<Integer, Integer> entry = _entityIds.get(i);
entityIds1_7[i * 2] = entry.getKey();
entityIds1_7[(i * 2) + 1] = entry.getValue();
entityIds1_8[i] = entry.getKey();
}
_destroy1_7 = new PacketPlayOutEntityDestroy(entityIds1_7);
_destroy1_8 = new PacketPlayOutEntityDestroy(entityIds1_8);
}
private void makeSpawnPackets()
{
_packets1_7 = new Packet[_hologramText.length * 3];
_packets1_8 = new Packet[_hologramText.length * 1];
if (_entityIds.size() < _hologramText.length)
@ -263,13 +263,6 @@ public class Hologram
{
Entry<Integer, Integer> entityIds = this._entityIds.get(textRow);
Packet[] packets1_7 = makeSpawnPackets1_7(textRow, entityIds.getKey(), entityIds.getValue(), _hologramText[textRow]);
for (int i = 0; i < packets1_7.length; i++)
{
_packets1_7[(textRow * 3) + i] = packets1_7[i];
}
Packet[] packets1_8 = makeSpawnPackets1_8(textRow, entityIds.getKey(), _hologramText[textRow]);
for (int i = 0; i < packets1_8.length; i++)
@ -279,47 +272,6 @@ public class Hologram
}
}
private Packet[] makeSpawnPackets1_7(int height, int witherId, int horseId, String horseName)
{
// Spawn wither skull
PacketPlayOutSpawnEntity spawnWitherSkull = new PacketPlayOutSpawnEntity();
spawnWitherSkull.a = witherId;
spawnWitherSkull.b = (int) (getLocation().getX() * 32);
spawnWitherSkull.c = (int) ((getLocation().getY() + 54.6 + ((double) height * 0.285D)) * 32);
spawnWitherSkull.d = (int) (getLocation().getZ() * 32);
spawnWitherSkull.j = 66;
// Spawn horse
PacketPlayOutSpawnEntityLiving spawnHorse = new PacketPlayOutSpawnEntityLiving();
DataWatcher watcher = new DataWatcher(null);
spawnHorse.a = horseId;
spawnHorse.b = 100;
spawnHorse.c = (int) (getLocation().getX() * 32);
spawnHorse.d = (int) ((getLocation().getY() + 54.83 + ((double) height * 0.285D) + 0.23D) * 32);
spawnHorse.e = (int) (getLocation().getZ() * 32);
spawnHorse.l = watcher;
// Setup datawatcher
watcher.a(0, (byte) 0);
watcher.a(1, (short) 300);
watcher.a(10, horseName);
watcher.a(11, (byte) 1);
watcher.a(12, -1700000);
// Make horse ride wither
PacketPlayOutAttachEntity attachEntity = new PacketPlayOutAttachEntity();
attachEntity.b = horseId;
attachEntity.c = witherId;
return new Packet[]
{
spawnWitherSkull, spawnHorse, attachEntity
};
}
private Packet[] makeSpawnPackets1_8(int textRow, int entityId, String lineOfText)
{
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
@ -328,7 +280,7 @@ public class Hologram
packet.a = entityId;
packet.b = 30;
packet.c = (int) (getLocation().getX() * 32);
packet.d = (int) ((getLocation().getY() + -2.1 + ((double) textRow * 0.285)) * 32);
packet.d = (int) ((getLocation().getY() + (_hideBoundingBox ? 0 : -2.1) + ((double) textRow * 0.285)) * 32);
packet.e = (int) (getLocation().getZ() * 32);
packet.l = watcher;
@ -336,7 +288,11 @@ public class Hologram
watcher.a(0, (byte) 32);
watcher.a(2, lineOfText);
watcher.a(3, (byte) 1);
// watcher.a(10, (byte) 16); // TODO Uncomment after we can enforce 1.8.3
if (_hideBoundingBox)
{
watcher.a(10, (byte) 16); // TODO Uncomment after we can enforce 1.8.3
}
// Also correct hologram positioning
return new Packet[]
@ -416,7 +372,7 @@ public class Hologram
if (player.getWorld() == getLocation().getWorld())
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(getDestroyPacket(player));
UtilPlayer.sendPacket(player, getDestroyPacket());
}
}
}
@ -430,10 +386,7 @@ public class Hologram
_playersTracking.add(player);
itel.remove();
for (Packet packet : getSpawnPackets(player))
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
UtilPlayer.sendPacket(player, getSpawnPackets());
}
}
if (!canSee.isEmpty())
@ -445,7 +398,6 @@ public class Hologram
int y = (int) Math.floor(32 * _lastMovement.getY());
int z = (int) Math.floor(32 * _lastMovement.getZ());
Packet[] packets1_7 = new Packet[_hologramText.length];
Packet[] packets1_8 = new Packet[_hologramText.length];
int i = 0;
@ -455,14 +407,13 @@ public class Hologram
_lastMovement.subtract(new Vector(x / 32D, y / 32D, z / 32D));
for (Entry<Integer, Integer> entityId : this._entityIds)
{
PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove();
PacketPlayOutEntity.PacketPlayOutRelEntityMove relMove = new PacketPlayOutEntity.PacketPlayOutRelEntityMove();
relMove.a = entityId.getKey();
relMove.b = (byte) x;
relMove.c = (byte) y;
relMove.d = (byte) z;
packets1_7[i] = relMove;
packets1_8[i] = relMove;
i++;
}
@ -476,24 +427,14 @@ public class Hologram
for (Entry<Integer, Integer> entityId : this._entityIds)
{
for (int b = 0; b < 2; b++)
{
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
teleportPacket.a = entityId.getKey();
teleportPacket.b = x;
teleportPacket.c = (int) Math
.floor((oldLocation.getY() + (b == 0 ? 54.6 : -2.1) + ((double) i * 0.285)) * 32);
teleportPacket.d = z;
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
teleportPacket.a = entityId.getKey();
teleportPacket.b = x;
teleportPacket.c = (int) Math
.floor((oldLocation.getY() + (-2.1) + ((double) i * 0.285)) * 32);
teleportPacket.d = z;
if (b == 0)
{
packets1_7[i] = teleportPacket;
}
else
{
packets1_8[i] = teleportPacket;
}
}
packets1_8[i] = teleportPacket;
i++;
}
@ -501,9 +442,9 @@ public class Hologram
for (Player player : canSee)
{
for (Packet packet : UtilPlayer.is1_8(player) ? packets1_8 : packets1_7)
for (Packet packet : packets1_8)
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
UtilPlayer.sendPacket(player, packet);
}
}
}
@ -534,10 +475,8 @@ public class Hologram
if (isInUse())
{
int[] destroy1_7 = new int[0];
int[] destroy1_8 = new int[0];
ArrayList<Packet> packets1_7 = new ArrayList<Packet>();
ArrayList<Packet> packets1_8 = new ArrayList<Packet>();
if (_hologramText.length != newText.length)
@ -555,8 +494,6 @@ public class Hologram
Entry<Integer, Integer> entry = new HashMap.SimpleEntry(UtilEnt.getNewEntityId(), UtilEnt.getNewEntityId());
_entityIds.add(entry);
packets1_7.addAll(Arrays.asList(makeSpawnPackets1_7(i, entry.getKey(), entry.getValue(), newText[i])));
packets1_8.addAll(Arrays.asList(makeSpawnPackets1_8(i, entry.getKey(), newText[i])));
}
// If less lines than previously
@ -565,11 +502,6 @@ public class Hologram
// Remove entity id and send destroy packets
Entry<Integer, Integer> entry = _entityIds.remove(newText.length);
destroy1_7 = Arrays.copyOf(destroy1_7, destroy1_7.length + 2);
destroy1_7[destroy1_7.length - 2] = entry.getKey();
destroy1_7[destroy1_7.length - 1] = entry.getValue();
destroy1_8 = Arrays.copyOf(destroy1_8, destroy1_8.length + 1);
destroy1_8[destroy1_8.length - 1] = entry.getKey();
}
@ -577,21 +509,6 @@ public class Hologram
{
// Send update metadata packets
Entry<Integer, Integer> entry = _entityIds.get(i);
PacketPlayOutEntityMetadata metadata1_7 = new PacketPlayOutEntityMetadata();
metadata1_7.a = entry.getValue();
DataWatcher watcher1_7 = new DataWatcher(null);
watcher1_7.a(0, (byte) 0);
watcher1_7.a(1, (short) 300);
watcher1_7.a(10, newText[i]);
watcher1_7.a(11, (byte) 1);
watcher1_7.a(12, -1700000);
metadata1_7.b = watcher1_7.c();
packets1_7.add(metadata1_7);
PacketPlayOutEntityMetadata metadata1_8 = new PacketPlayOutEntityMetadata();
@ -610,11 +527,6 @@ public class Hologram
}
}
if (destroy1_7.length > 0)
{
packets1_7.add(new PacketPlayOutEntityDestroy(destroy1_7));
}
if (destroy1_8.length > 0)
{
packets1_8.add(new PacketPlayOutEntityDestroy(destroy1_8));
@ -622,9 +534,9 @@ public class Hologram
for (Player player : _playersTracking)
{
for (Packet packet : UtilPlayer.is1_8(player) ? packets1_8 : packets1_7)
for (Packet packet : packets1_8)
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
UtilPlayer.sendPacket(player, packet);
}
}
}
@ -656,10 +568,7 @@ public class Hologram
for (Player player : _playersTracking)
{
for (Packet packet : getSpawnPackets(player))
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
UtilPlayer.sendPacket(player, getSpawnPackets());
}
_lastMovement = new Vector();
@ -678,7 +587,7 @@ public class Hologram
for (Player player : _playersTracking)
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(getDestroyPacket(player));
UtilPlayer.sendPacket(player, getDestroyPacket());
}
_playersTracking.clear();

View File

@ -4,13 +4,14 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_8_R3.Packet;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -83,20 +84,18 @@ public class HologramManager implements Listener
itel2.remove();
if (player.getWorld() == hologram.getLocation().getWorld())
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(hologram.getDestroyPacket(player));
UtilPlayer.sendPacket(player, hologram.getDestroyPacket());
}
}
}
for (Player player : canSee)
{
if (!hologram.getPlayersTracking().contains(player))
{
hologram.getPlayersTracking().add(player);
for (Packet packet : hologram.getSpawnPackets(player))
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
{
if (!hologram.getPlayersTracking().contains(player))
{
hologram.getPlayersTracking().add(player);
UtilPlayer.sendPacket(player, hologram.getSpawnPackets());
}
}
}
}

View File

@ -7,8 +7,19 @@ import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.EnchantingInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
@ -27,12 +38,12 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
private static Object _inventoryLock = new Object();
private InventoryRepository _repository;
private NautHashMap<String, Item> _items = new NautHashMap<String, Item>();
private NautHashMap<Integer, String> _itemIdNameMap = new NautHashMap<Integer, String>();
private NautHashMap<Player, NautHashMap<String, Integer>> _inventoryQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
public InventoryManager(JavaPlugin plugin, CoreClientManager clientManager)
{
super("Inventory Manager", plugin, clientManager);
@ -51,7 +62,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
private void updateItems()
{
List<Item> items = _repository.retrieveItems();
synchronized (_inventoryLock)
{
for (Item item : items)
@ -68,20 +79,20 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
{
Get(player).addItem(new ClientItem(_items.get(item), count));
}
if (!_inventoryQueue.containsKey(player))
_inventoryQueue.put(player, new NautHashMap<String, Integer>());
int totalAmount = count;
if (_inventoryQueue.get(player).containsKey(item))
totalAmount += _inventoryQueue.get(player).get(item);
_inventoryQueue.get(player).put(item, totalAmount);
}
public void addItemToInventory(final Callback<Boolean> callback, final Player player, final String item, final int count)
{
{
addItemToInventoryForOffline(new Callback<Boolean>()
{
public void run(Boolean success)
@ -90,13 +101,13 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
{
System.out.println("Add item to Inventory FAILED for " + player.getName());
}
if (callback != null)
callback.run(success);
}
}, player.getUniqueId(), item, count);
}
public boolean validItem(String item)
{
synchronized (_inventoryLock)
@ -104,7 +115,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
return _items.containsKey(item);
}
}
public Item getItem(String itemName)
{
Item item = null;
@ -121,6 +132,17 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
}
public void addItemToInventoryForOffline(final Callback<Boolean> callback, final UUID uuid, final String item, final int count)
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{
public void run()
{
addItemToInventoryForOffline(callback, PlayerCache.getInstance().getPlayer(uuid).getAccountId(), item, count);
}
});
}
public void addItemToInventoryForOffline(final Callback<Boolean> callback, final int accountId, final String item, final int count)
{
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{
@ -139,7 +161,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
synchronized (_inventoryLock)
{
final boolean success = _repository.incrementClientInventoryItem(PlayerCache.getInstance().getPlayer(uuid).getAccountId(), _items.get(item).Id, count);
final boolean success = _repository.incrementClientInventoryItem(accountId, _items.get(item).Id, count);
if (callback != null)
{
@ -155,19 +177,114 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
}
});
}
@EventHandler
public void onOpenEnchantingTable(InventoryOpenEvent event)
{
if (event.getInventory().getType() != InventoryType.ENCHANTING)
{
return;
}
int level = ((Player) event.getPlayer()).getLevel();
for (HumanEntity viewer : event.getViewers())
{
level = Math.max(((Player) viewer).getLevel(), level);
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4));
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event)
{
if (event.getBlock().getType() != Material.ENCHANTMENT_TABLE)
{
return;
}
((EnchantingInventory) event.getBlock().getState()).setSecondary(new ItemStack(Material.AIR));
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent event)
{
if (event.getInventory().getType() != InventoryType.ENCHANTING)
{
return;
}
if (event.getViewers().size() > 1)
{
int level = ((Player) event.getPlayer()).getLevel();
for (HumanEntity viewer : event.getViewers())
{
level = Math.max(((Player) viewer).getLevel(), level);
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4));
return;
}
event.getInventory().setItem(1, new ItemStack(Material.AIR));
}
@EventHandler
public void onInventoryClick(final InventoryClickEvent event)
{
if (event.getView().getTopInventory().getType() != InventoryType.ENCHANTING)
{
return;
}
if (event.getSlot() == 1)
{
event.setCancelled(true);
return;
}
if (event.getSlot() != 2)
{
return;
}
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
{
public void run()
{
Inventory inv = event.getInventory();
if (inv.getViewers().isEmpty())
{
return;
}
int level = 0;
for (HumanEntity viewer : inv.getViewers())
{
level = Math.max(((Player) viewer).getLevel(), level);
}
event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, level, (byte) 4));
}
});
}
@EventHandler
public void updateInventoryQueue(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
for (final Player player : _inventoryQueue.keySet())
{
for (final String item : _inventoryQueue.get(player).keySet())
{
final int count = _inventoryQueue.get(player).get(item);
addItemToInventoryForOffline(new Callback<Boolean>()
{
public void run(Boolean success)
@ -175,7 +292,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
if (!success)
{
System.out.println("Add item to Inventory FAILED for " + player);
if (_items.containsKey(item))
{
Get(player).addItem(new ClientItem(_items.get(item), -count));
@ -184,16 +301,15 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
}
}, player.getUniqueId(), item, count);
}
//Clean
// Clean
_inventoryQueue.get(player).clear();
}
//Clean
// Clean
_inventoryQueue.clear();
}
@Override
protected ClientInventory AddPlayer(String player)
{

View File

@ -9,9 +9,11 @@ import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkEffectMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
@ -20,349 +22,376 @@ import org.bukkit.potion.Potion;
public class ItemBuilder
{
private static ArrayList<String> split(String string, int maxLength)
{
String[] split = string.split(" ");
string = "";
ArrayList<String> newString = new ArrayList<String>();
for (int i = 0; i < split.length; i++)
{
string += (string.length() == 0 ? "" : " ") + split[i];
if (ChatColor.stripColor(string).length() > maxLength)
{
newString
.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
string = "";
}
}
if (string.length() > 0)
newString.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
return newString;
}
private static ArrayList<String> split(String string, int maxLength)
{
String[] split = string.split(" ");
string = "";
ArrayList<String> newString = new ArrayList<String>();
for (int i = 0; i < split.length; i++)
{
string += (string.length() == 0 ? "" : " ") + split[i];
if (ChatColor.stripColor(string).length() > maxLength)
{
newString
.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
string = "";
}
}
if (string.length() > 0)
newString.add((newString.size() > 0 ? ChatColor.getLastColors(newString.get(newString.size() - 1)) : "") + string);
return newString;
}
private int _amount;
private Color _color;
private short _data;
private final HashMap<Enchantment, Integer> _enchants = new HashMap<Enchantment, Integer>();
private final List<String> _lore = new ArrayList<String>();
private Material _mat;
// private Potion potion;
private String _title = null;
private boolean _unbreakable;
private int _amount;
private Color _color;
private short _data;
private final HashMap<Enchantment, Integer> _enchants = new HashMap<Enchantment, Integer>();
private final List<String> _lore = new ArrayList<String>();
private Material _mat;
// private Potion potion;
private String _title = null;
private boolean _unbreakable;
private String _playerHeadName = null;
public ItemBuilder(ItemStack item)
{
this(item.getType(), item.getDurability());
this._amount = item.getAmount();
this._enchants.putAll(item.getEnchantments());
if (item.getType() == Material.POTION)
{
// setPotion(Potion.fromItemStack(item));
}
if (item.hasItemMeta())
{
ItemMeta meta = item.getItemMeta();
if (meta.hasDisplayName())
{
this._title = meta.getDisplayName();
}
if (meta.hasLore())
{
this._lore.addAll(meta.getLore());
}
if (meta instanceof LeatherArmorMeta)
{
this.setColor(((LeatherArmorMeta) meta).getColor());
}
this._unbreakable = meta.spigot().isUnbreakable();
}
}
public ItemBuilder(ItemStack item)
{
this(item.getType(), item.getDurability());
_amount = item.getAmount();
_enchants.putAll(item.getEnchantments());
if (item.getType() == Material.POTION)
{
// setPotion(Potion.fromItemStack(item));
}
if (item.hasItemMeta())
{
ItemMeta meta = item.getItemMeta();
public ItemBuilder(Material mat)
{
this(mat, 1);
}
if (meta.hasDisplayName())
{
_title = meta.getDisplayName();
}
public ItemBuilder(Material mat, int amount)
{
this(mat, amount, (short) 0);
}
if (meta.hasLore())
{
_lore.addAll(meta.getLore());
}
public ItemBuilder(Material mat, int amount, short data)
{
this._mat = mat;
this._amount = amount;
this._data = data;
}
if (meta instanceof LeatherArmorMeta)
{
setColor(((LeatherArmorMeta) meta).getColor());
}
public ItemBuilder(Material mat, short data)
{
this(mat, 1, data);
}
_unbreakable = meta.spigot().isUnbreakable();
}
}
public ItemBuilder addEnchantment(Enchantment enchant, int level)
{
if (_enchants.containsKey(enchant))
{
_enchants.remove(enchant);
}
_enchants.put(enchant, level);
return this;
}
public ItemBuilder(Material mat)
{
this(mat, 1);
}
public ItemBuilder addLore(String... lores)
{
for (String lore : lores)
{
this._lore.add(ChatColor.GRAY + lore);
}
return this;
}
public ItemBuilder(Material mat, int amount)
{
this(mat, amount, (short) 0);
}
public ItemBuilder addLore(String lore, int maxLength)
{
this._lore.addAll(split(lore, maxLength));
return this;
}
public ItemBuilder(Material mat, int amount, short data)
{
_mat = mat;
_amount = amount;
_data = data;
}
public ItemBuilder addLores(List<String> lores)
{
this._lore.addAll(lores);
return this;
}
public ItemBuilder(Material mat, short data)
{
this(mat, 1, data);
}
public ItemBuilder addLores(List<String> lores, int maxLength)
{
for (String lore : lores)
{
addLore(lore, maxLength);
}
return this;
}
public ItemBuilder addEnchantment(Enchantment enchant, int level)
{
if (_enchants.containsKey(enchant))
{
_enchants.remove(enchant);
}
_enchants.put(enchant, level);
return this;
}
public ItemBuilder addLores(String[] description, int maxLength)
{
return addLores(Arrays.asList(description), maxLength);
}
public ItemBuilder addLore(String... lores)
{
for (String lore : lores)
{
_lore.add(ChatColor.GRAY + lore);
}
return this;
}
public ItemStack build()
{
Material mat = this._mat;
if (mat == null)
{
mat = Material.AIR;
Bukkit.getLogger().warning("Null material!");
}
else if (mat == Material.AIR)
{
Bukkit.getLogger().warning("Air material!");
}
ItemStack item = new ItemStack(mat, this._amount, this._data);
ItemMeta meta = item.getItemMeta();
if (meta != null)
{
if (this._title != null)
{
meta.setDisplayName(this._title);
}
if (!this._lore.isEmpty())
{
meta.setLore(this._lore);
}
if (meta instanceof LeatherArmorMeta)
{
((LeatherArmorMeta) meta).setColor(this._color);
}
public ItemBuilder addLore(String lore, int maxLength)
{
_lore.addAll(split(lore, maxLength));
return this;
}
public ItemBuilder addLores(List<String> lores)
{
_lore.addAll(lores);
return this;
}
public ItemBuilder addLores(List<String> lores, int maxLength)
{
for (String lore : lores)
{
addLore(lore, maxLength);
}
return this;
}
public ItemBuilder addLores(String[] description, int maxLength)
{
return addLores(Arrays.asList(description), maxLength);
}
public ItemStack build()
{
Material mat = _mat;
if (mat == null)
{
mat = Material.AIR;
Bukkit.getLogger().warning("Null material!");
}
else if (mat == Material.AIR)
{
Bukkit.getLogger().warning("Air material!");
}
ItemStack item = new ItemStack(mat, _amount, _data);
ItemMeta meta = item.getItemMeta();
if (meta != null)
{
if (_title != null)
{
meta.setDisplayName(_title);
}
if (!_lore.isEmpty())
{
meta.setLore(_lore);
}
if (meta instanceof LeatherArmorMeta && _color != null)
{
((LeatherArmorMeta) meta).setColor(_color);
}
else if (meta instanceof SkullMeta && _playerHeadName != null)
{
((SkullMeta) meta).setOwner(_playerHeadName);
}
meta.spigot().setUnbreakable(isUnbreakable());
item.setItemMeta(meta);
}
item.addUnsafeEnchantments(this._enchants);
// if (this.potion != null) {
// this.potion.apply(item);
// }
return item;
}
else if (meta instanceof FireworkEffectMeta && _color != null)
{
((FireworkEffectMeta) meta).setEffect(FireworkEffect.builder().withColor(_color).build());
}
@Override
public ItemBuilder clone()
{
ItemBuilder newBuilder = new ItemBuilder(this._mat);
meta.spigot().setUnbreakable(isUnbreakable());
item.setItemMeta(meta);
}
newBuilder.setTitle(this._title);
for (String lore : this._lore)
{
newBuilder.addLore(lore);
}
for (Map.Entry<Enchantment, Integer> entry : this._enchants.entrySet())
{
newBuilder.addEnchantment(entry.getKey(), entry.getValue());
}
newBuilder.setColor(this._color);
// newBuilder.potion = this.potion;
item.addUnsafeEnchantments(_enchants);
// if (potion != null) {
// potion.apply(item);
// }
return item;
}
return newBuilder;
}
@Override
public ItemBuilder clone()
{
ItemBuilder newBuilder = new ItemBuilder(_mat);
public HashMap<Enchantment, Integer> getAllEnchantments()
{
return this._enchants;
}
newBuilder.setTitle(_title);
public Color getColor()
{
return this._color;
}
for (String lore : _lore)
{
newBuilder.addLore(lore);
}
public short getData()
{
return this._data;
}
for (Map.Entry<Enchantment, Integer> entry : _enchants.entrySet())
{
newBuilder.addEnchantment(entry.getKey(), entry.getValue());
}
public int getEnchantmentLevel(Enchantment enchant)
{
return this._enchants.get(enchant);
}
newBuilder.setColor(_color);
// newBuilder.potion = potion;
public List<String> getLore()
{
return this._lore;
}
return newBuilder;
}
public String getTitle()
{
return this._title;
}
public HashMap<Enchantment, Integer> getAllEnchantments()
{
return _enchants;
}
public Material getType()
{
return this._mat;
}
public Color getColor()
{
return _color;
}
public boolean hasEnchantment(Enchantment enchant)
{
return this._enchants.containsKey(enchant);
}
public short getData()
{
return _data;
}
public boolean isItem(ItemStack item)
{
ItemMeta meta = item.getItemMeta();
if (item.getType() != this.getType())
{
return false;
}
if (!meta.hasDisplayName() && this.getTitle() != null)
{
return false;
}
if (!meta.getDisplayName().equals(this.getTitle()))
{
return false;
}
if (!meta.hasLore() && !this.getLore().isEmpty())
{
return false;
}
if (meta.hasLore())
{
for (String lore : meta.getLore())
{
if (!this.getLore().contains(lore))
{
return false;
}
}
}
for (Enchantment enchant : item.getEnchantments().keySet())
{
if (!this.hasEnchantment(enchant))
{
return false;
}
}
return true;
}
public int getEnchantmentLevel(Enchantment enchant)
{
return _enchants.get(enchant);
}
public boolean isUnbreakable()
{
return this._unbreakable;
}
public List<String> getLore()
{
return _lore;
}
public ItemBuilder setAmount(int amount)
{
this._amount = amount;
return this;
}
public String getTitle()
{
return _title;
}
public ItemBuilder setColor(Color color)
{
if (!this._mat.name().contains("LEATHER_"))
{
throw new IllegalArgumentException("Can only dye leather armor!");
}
this._color = color;
return this;
}
public Material getType()
{
return _mat;
}
public ItemBuilder setData(short newData)
{
this._data = newData;
return this;
}
public boolean hasEnchantment(Enchantment enchant)
{
return _enchants.containsKey(enchant);
}
public ItemBuilder setPotion(Potion potion)
{
if (this._mat != Material.POTION)
{
this._mat = Material.POTION;
}
// this.potion = potion;
return this;
}
public boolean isItem(ItemStack item)
{
ItemMeta meta = item.getItemMeta();
public ItemBuilder setRawTitle(String title)
{
this._title = title;
return this;
}
if (item.getType() != getType())
{
return false;
}
public ItemBuilder setTitle(String title)
{
this._title = (title == null ? null
: (title.length() > 2 && ChatColor.getLastColors(title.substring(0, 2)).length() == 0 ? ChatColor.WHITE : ""))
+ title;
return this;
}
if (!meta.hasDisplayName() && getTitle() != null)
{
return false;
}
public ItemBuilder setTitle(String title, int maxLength)
{
if (title != null && ChatColor.stripColor(title).length() > maxLength)
{
ArrayList<String> lores = split(title, maxLength);
for (int i = 1; i < lores.size(); i++)
{
this._lore.add(lores.get(i));
}
title = lores.get(0);
}
setTitle(title);
return this;
}
if (!meta.getDisplayName().equals(getTitle()))
{
return false;
}
public ItemBuilder setType(Material mat)
{
this._mat = mat;
return this;
}
if (!meta.hasLore() && !getLore().isEmpty())
{
return false;
}
public ItemBuilder setUnbreakable(boolean setUnbreakable)
{
this._unbreakable = setUnbreakable;return this;
}
if (meta.hasLore())
{
for (String lore : meta.getLore())
{
if (!getLore().contains(lore))
{
return false;
}
}
}
for (Enchantment enchant : item.getEnchantments().keySet())
{
if (!hasEnchantment(enchant))
{
return false;
}
}
return true;
}
public boolean isUnbreakable()
{
return _unbreakable;
}
public ItemBuilder setAmount(int amount)
{
_amount = amount;
return this;
}
public ItemBuilder setColor(Color color)
{
/* (!_mat.name().contains("LEATHER_"))
{
throw new IllegalArgumentException("Can only dye leather armor!");
}*/
_color = color;
return this;
}
public ItemBuilder setData(short newData)
{
_data = newData;
return this;
}
public ItemBuilder setPotion(Potion potion)
{
if (_mat != Material.POTION)
{
_mat = Material.POTION;
}
return this;
}
public ItemBuilder setRawTitle(String title)
{
_title = title;
return this;
}
public ItemBuilder setTitle(String title)
{
_title = (title == null ? null
: (title.length() > 2 && ChatColor.getLastColors(title.substring(0, 2)).length() == 0 ? ChatColor.WHITE : ""))
+ title;
return this;
}
public ItemBuilder setTitle(String title, int maxLength)
{
if (title != null && ChatColor.stripColor(title).length() > maxLength)
{
ArrayList<String> lores = split(title, maxLength);
for (int i = 1; i < lores.size(); i++)
{
_lore.add(lores.get(i));
}
title = lores.get(0);
}
setTitle(title);
return this;
}
public ItemBuilder setType(Material mat)
{
_mat = mat;
return this;
}
public ItemBuilder setUnbreakable(boolean setUnbreakable)
{
_unbreakable = setUnbreakable;
return this;
}
public ItemBuilder setPlayerHead(String playerName)
{

View File

@ -16,7 +16,7 @@ import mineplex.core.common.util.UtilTime;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;

View File

@ -14,9 +14,12 @@ import javax.imageio.ImageIO;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilServer;
import net.minecraft.server.v1_7_R4.EntityItemFrame;
import net.minecraft.server.v1_7_R4.PersistentCollection;
import net.minecraft.server.v1_7_R4.WorldServer;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.EntityItemFrame;
import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.PersistentCollection;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -24,7 +27,7 @@ import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
@ -53,7 +56,7 @@ public class BlockMap implements Listener
{
// Make sure the world doesn't change the mapcount information
PersistentCollection collection = ((CraftWorld) corner1.getWorld()).getHandle().worldMaps;
Field f = collection.getClass().getDeclaredField("a");
Field f = collection.getClass().getDeclaredField("b");
f.setAccessible(true);
f.set(collection, null);
}
@ -338,27 +341,27 @@ public class BlockMap implements Listener
private ItemFrame spawnItemFrame(Block block, BlockFace bf)
{
int dir;
EnumDirection dir;
switch (bf)
{
default:
case SOUTH:
dir = 0;
dir = EnumDirection.SOUTH;
break;
case WEST:
dir = 1;
dir = EnumDirection.WEST;
break;
case NORTH:
dir = 2;
dir = EnumDirection.NORTH;
break;
case EAST:
dir = 3;
dir = EnumDirection.EAST;
break;
}
WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
EntityItemFrame entity = new EntityItemFrame(world, block.getX(), block.getY(), block.getZ(), dir);
EntityItemFrame entity = new EntityItemFrame(world, new BlockPosition(block.getX(), block.getY(), block.getZ()), dir);
entity.setDirection(dir);

View File

@ -1,6 +1,6 @@
package mineplex.core.map;
import net.minecraft.server.v1_7_R4.WorldMap;
import net.minecraft.server.v1_8_R3.WorldMap;
import org.bukkit.Bukkit;
import org.bukkit.Location;

Some files were not shown because too many files have changed in this diff Show More