Merge remote-tracking branch 'origin/master' into Myst_KITS

Conflicts:
	Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/paintball/PlayerCopy.java
This commit is contained in:
Mysticate 2015-11-14 14:50:48 -05:00
commit 746aab7786
447 changed files with 17501 additions and 10094 deletions

BIN
Art/Treasure/4Qq2m6x.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

BIN
Art/Treasure/canc.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

BIN
Art/Treasure/xxiJkbb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

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

@ -0,0 +1,37 @@
From 896df3218cf190a29901619e762b5399517dbfbd Mon Sep 17 00:00:00 2001
From: libraryaddict <libraryaddict115@yahoo.co.nz>
Date: Wed, 11 Nov 2015 11:43:17 +1300
Subject: [PATCH] Fix schedulers
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 1d29ae7..55e2afd 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -705,6 +705,11 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
}
public void B() {
+ SpigotTimings.schedulerTimer.startTiming(); // Spigot
+ // CraftBukkit start
+ this.server.getScheduler().mainThreadHeartbeat(this.ticks);
+ SpigotTimings.schedulerTimer.stopTiming(); // Spigot
+
this.methodProfiler.a("jobs");
Queue queue = this.j;
@@ -718,11 +723,6 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
this.methodProfiler.c("levels");
- SpigotTimings.schedulerTimer.startTiming(); // Spigot
- // CraftBukkit start
- this.server.getScheduler().mainThreadHeartbeat(this.ticks);
- SpigotTimings.schedulerTimer.stopTiming(); // Spigot
-
// Run tasks that are waiting on processing
SpigotTimings.processQueueTimer.startTiming(); // Spigot
while (!processQueue.isEmpty()) {
--
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$/Nautilus.Game.PvP" includeSubdirectories="true" />
<directory url="file://$PROJECT_DIR$/Mineplex.ServerMonitor" 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$/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> </excludeFromCompile>
<resourceExtensions /> <resourceExtensions />
<wildcardResourcePatterns> <wildcardResourcePatterns>
@ -24,7 +26,7 @@
</profile> </profile>
<profile default="false" name="Annotation profile for bungee" enabled="true"> <profile default="false" name="Annotation profile for bungee" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" /> <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" /> <outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" /> <processorPath useClasspath="true" />
</profile> </profile>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="DataSourceManagerImpl" format="xml" hash="1293212710"> <component name="DataSourceManagerImpl" format="xml" hash="4268976312">
<data-source source="LOCAL" name="Mineplex" uuid="14dfc55d-5343-47c4-ab24-76a055b8059e"> <data-source source="LOCAL" name="Mineplex" uuid="14dfc55d-5343-47c4-ab24-76a055b8059e">
<driver-ref>mysql</driver-ref> <driver-ref>mysql</driver-ref>
<synchronize>true</synchronize> <synchronize>true</synchronize>
@ -13,7 +13,6 @@
<property name="characterSetResults" value="utf8" /> <property name="characterSetResults" value="utf8" />
<property name="yearIsDateType" value="false" /> <property name="yearIsDateType" value="false" />
</driver-properties> </driver-properties>
<libraries />
</data-source> </data-source>
</component> </component>
</project> </project>

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="PROJECT" charset="UTF-8" />
</component>
</project> </project>

View File

@ -11,6 +11,9 @@
<fileset dir="../Mineplex.Database/bin"> <fileset dir="../Mineplex.Database/bin">
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<fileset dir="../Mineplex.PlayerCache/bin">
<include name="**/*.class"/>
</fileset>
<fileset dir="../Mineplex.EnjinTranslator/bin"> <fileset dir="../Mineplex.EnjinTranslator/bin">
<include name="**/*.class"/> <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()); InetSocketAddress socketAddress = new InetSocketAddress(server.getPublicAddress(), server.getPort());
_plugin.getProxy().getServers().put(server.getName(), _plugin.getProxy().constructServerInfo(server.getName(), socketAddress, "LobbyBalancer", false)); _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")) if (server.getMotd() == null || !server.getMotd().contains("Restarting"))
{ {

View File

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

View File

@ -1,10 +1,10 @@
package mineplex.core.common.jsonchat; 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 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.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
@ -119,25 +119,12 @@ public class JsonMessage
*/ */
public void send(MessageType messageType, Player... players) public void send(MessageType messageType, Player... players)
{ {
send(messageType, false, players); PacketPlayOutChat chatPacket = new PacketPlayOutChat(IChatBaseComponent.ChatSerializer.a(toString()));
} chatPacket.b = messageType.getId();
/**
* 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());
for (Player player : players) for (Player player : players)
{ {
if (defaultToChat || messageType != MessageType.ABOVE_HOTBAR || UtilPlayer.is1_8(player)) UtilPlayer.sendPacket(player, chatPacket);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(chatPacket);
} }
} }

View File

@ -2,7 +2,7 @@ package mineplex.core.common.util;
import java.util.HashMap; 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; import org.bukkit.inventory.ItemStack;
public class InventoryUtil public class InventoryUtil

View File

@ -1,48 +1,41 @@
package mineplex.core.common.util; package mineplex.core.common.util;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; 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.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.CraftChunk; import org.bukkit.craftbukkit.v1_8_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer; import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; 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.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin; 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 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++) for (int x = 0; x < 16; x++)
{ {
@ -54,7 +47,7 @@ public class MapUtil
int bY = y & 0xFF; int bY = y & 0xFF;
int bZ = c.locZ << 4 | z & 0xF; 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()); c.b(bX & 0xF, bY, bZ & 0xF, replacer.getId());
} }
@ -63,7 +56,7 @@ public class MapUtil
} }
c.initLighting(); c.initLighting();
} }*/
public static void QuickChangeBlockAt(Location location, Material setTo) 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) public static void QuickChangeBlockAt(World world, int x, int y, int z, int id, int data)
{ {
Chunk chunk = world.getChunkAt(x >> 4, z >> 4); 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); //c.a(x & 0xF, y, z & 0xF, Block.getById(id), data);
((CraftWorld) world).getHandle().notify(x, y, z); 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) public static int GetHighestBlockInCircleAt(World world, int bx, int bz, int radius)
@ -152,7 +147,7 @@ public class MapUtil
Block.getById(id), data)) Block.getById(id), data))
{ {
if (notifyPlayers) 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); 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) 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); SendChunkForPlayer(chunk.locX, chunk.locZ, player);
} }
@ -184,8 +181,8 @@ public class MapUtil
Player player) Player player)
{ {
// System.out.println("Sending MultiBlockChunk " + x + ", " + z); // System.out.println("Sending MultiBlockChunk " + x + ", " + z);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutMultiBlockChange(dirtyCount, UtilPlayer.sendPacket(player, new PacketPlayOutMultiBlockChange(dirtyCount, dirtyBlocks, ((CraftWorld) world).getHandle()
dirtyBlocks, ((CraftWorld) world).getHandle().getChunkAt(x, z))); .getChunkAt(x, z)));
} }
public static void UnloadWorld(JavaPlugin plugin, World world) public static void UnloadWorld(JavaPlugin plugin, World world)
@ -216,7 +213,7 @@ public class MapUtil
Bukkit.getPluginManager().callEvent(new WorldUnloadEvent(((CraftWorld) world).getHandle().getWorld())); 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(); .values().iterator();
for (Entity entity : world.getEntities()) for (Entity entity : world.getEntities())
@ -226,7 +223,7 @@ public class MapUtil
while (chunkIterator.hasNext()) 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(); chunk.removeEntities();
} }
@ -251,23 +248,7 @@ public class MapUtil
System.out.println("Error removing world from bukkit master list: " + ex.getMessage()); System.out.println("Error removing world from bukkit master list: " + ex.getMessage());
} }
MinecraftServer ms = null; MinecraftServer ms = server.getServer();
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());
}
ms.worlds.remove(ms.worlds.indexOf(craftWorld.getHandle())); ms.worlds.remove(ms.worlds.indexOf(craftWorld.getHandle()));
} }
@ -303,4 +284,9 @@ public class MapUtil
return true; 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.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import net.minecraft.util.com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.util.com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -428,4 +428,15 @@ public class UtilAlg
{ {
return a.getWorld() == b.getWorld() && a.getX() == b.getX() && a.getY() == b.getY() && a.getZ() == b.getZ(); return a.getWorld() == b.getWorld() && a.getX() == b.getX() && a.getY() == b.getY() && a.getZ() == b.getZ();
} }
public static int randomMidpoint(int min, int max)
{
int variance = max - min;
int value = UtilMath.r(variance);
value += min;
return value;
}
} }

View File

@ -4,16 +4,17 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import net.minecraft.server.v1_7_R4.Blocks; import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_7_R4.WorldServer; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; 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; import org.bukkit.inventory.ItemStack;
public class UtilBlock public class UtilBlock
@ -52,7 +53,7 @@ public class UtilBlock
*/ */
public static HashSet<Byte> fullSolid = new HashSet<Byte>(); 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>(); public static HashSet<Byte> blockPassSet = new HashSet<Byte>();
/** /**
@ -61,188 +62,225 @@ public class UtilBlock
public static HashSet<Byte> blockAirFoliageSet = new HashSet<Byte>(); public static HashSet<Byte> blockAirFoliageSet = new HashSet<Byte>();
static { 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);
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)0); blockPassSet.add((byte) Material.AIR.getId());
blockPassSet.add((byte)6); blockPassSet.add((byte) Material.SAPLING.getId());
blockPassSet.add((byte)8); blockPassSet.add((byte) Material.WATER.getId());
blockPassSet.add((byte)9); blockPassSet.add((byte) Material.STATIONARY_WATER.getId());
blockPassSet.add((byte)10); blockPassSet.add((byte) Material.LAVA.getId());
blockPassSet.add((byte)11); blockPassSet.add((byte) Material.STATIONARY_LAVA.getId());
blockPassSet.add((byte)26); blockPassSet.add((byte) Material.BED_BLOCK.getId());
blockPassSet.add((byte)27); blockPassSet.add((byte) Material.POWERED_RAIL.getId());
blockPassSet.add((byte)28); blockPassSet.add((byte) Material.DETECTOR_RAIL.getId());
blockPassSet.add((byte)30); blockPassSet.add((byte) Material.WEB.getId());
blockPassSet.add((byte)31); blockPassSet.add((byte) Material.LONG_GRASS.getId());
blockPassSet.add((byte)32); blockPassSet.add((byte) Material.DEAD_BUSH.getId());
blockPassSet.add((byte)37); blockPassSet.add((byte) Material.YELLOW_FLOWER.getId());
blockPassSet.add((byte)38); blockPassSet.add((byte) Material.RED_ROSE.getId());
blockPassSet.add((byte)39); blockPassSet.add((byte) Material.BROWN_MUSHROOM.getId());
blockPassSet.add((byte)40); blockPassSet.add((byte) Material.RED_MUSHROOM.getId());
blockPassSet.add((byte)50); blockPassSet.add((byte) Material.TORCH.getId());
blockPassSet.add((byte)51); blockPassSet.add((byte) Material.FIRE.getId());
blockPassSet.add((byte)55); blockPassSet.add((byte) Material.REDSTONE_WIRE.getId());
blockPassSet.add((byte)59); blockPassSet.add((byte) Material.CROPS.getId());
blockPassSet.add((byte)63); blockPassSet.add((byte) Material.SIGN_POST.getId());
blockPassSet.add((byte)64); blockPassSet.add((byte) Material.WOODEN_DOOR.getId());
blockPassSet.add((byte)65); blockPassSet.add((byte) Material.LADDER.getId());
blockPassSet.add((byte)66); blockPassSet.add((byte) Material.RAILS.getId());
blockPassSet.add((byte)68); blockPassSet.add((byte) Material.WALL_SIGN.getId());
blockPassSet.add((byte)69); blockPassSet.add((byte) Material.LEVER.getId());
blockPassSet.add((byte)70); blockPassSet.add((byte) Material.STONE_PLATE.getId());
blockPassSet.add((byte)71); blockPassSet.add((byte) Material.IRON_DOOR_BLOCK.getId());
blockPassSet.add((byte)72); blockPassSet.add((byte) Material.WOOD_PLATE.getId());
blockPassSet.add((byte)75); blockPassSet.add((byte) Material.REDSTONE_TORCH_OFF.getId());
blockPassSet.add((byte)76); blockPassSet.add((byte) Material.REDSTONE_TORCH_ON.getId());
blockPassSet.add((byte)77); blockPassSet.add((byte) Material.STONE_BUTTON.getId());
blockPassSet.add((byte)78); blockPassSet.add((byte) Material.SNOW.getId());
blockPassSet.add((byte)83); blockPassSet.add((byte) Material.SUGAR_CANE_BLOCK.getId());
blockPassSet.add((byte)90); blockPassSet.add((byte) Material.FENCE.getId());
blockPassSet.add((byte)92); blockPassSet.add((byte) Material.PORTAL.getId());
blockPassSet.add((byte)93); blockPassSet.add((byte) Material.CAKE_BLOCK.getId());
blockPassSet.add((byte)94); blockPassSet.add((byte) Material.DIODE_BLOCK_OFF.getId());
blockPassSet.add((byte)96); blockPassSet.add((byte) Material.DIODE_BLOCK_ON.getId());
blockPassSet.add((byte)101); blockPassSet.add((byte) Material.TRAP_DOOR.getId());
blockPassSet.add((byte)102); blockPassSet.add((byte) Material.IRON_FENCE.getId());
blockPassSet.add((byte)104); blockPassSet.add((byte) Material.THIN_GLASS.getId());
blockPassSet.add((byte)105); blockPassSet.add((byte) Material.PUMPKIN_STEM.getId());
blockPassSet.add((byte)106); blockPassSet.add((byte) Material.MELON_STEM.getId());
blockPassSet.add((byte)107); blockPassSet.add((byte) Material.VINE.getId());
blockPassSet.add((byte)111); blockPassSet.add((byte) Material.FENCE_GATE.getId());
blockPassSet.add((byte)115); blockPassSet.add((byte) Material.WATER_LILY.getId());
blockPassSet.add((byte)116); blockPassSet.add((byte) Material.NETHER_WARTS.getId());
blockPassSet.add((byte)117); blockPassSet.add((byte) Material.ENCHANTMENT_TABLE.getId());
blockPassSet.add((byte)118); blockPassSet.add((byte) Material.BREWING_STAND.getId());
blockPassSet.add((byte)119); blockPassSet.add((byte) Material.CAULDRON.getId());
blockPassSet.add((byte)120); blockPassSet.add((byte) Material.ENDER_PORTAL.getId());
blockPassSet.add((byte)171); 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());
fullSolid.add((byte)1); // blockPassSet.add((byte) Material.BIRCH_FENCE_GATE.getId());
fullSolid.add((byte)2); // blockPassSet.add((byte) Material.JUNGLE_FENCE_GATE.getId());
fullSolid.add((byte)3); // blockPassSet.add((byte) Material.DARK_OAK_FENCE_GATE.getId());
fullSolid.add((byte)4); // blockPassSet.add((byte) Material.ACACIA_FENCE_GATE.getId());
fullSolid.add((byte)5); // blockPassSet.add((byte) Material.SPRUCE_FENCE.getId());
fullSolid.add((byte)7); // blockPassSet.add((byte) Material.BIRCH_FENCE.getId());
fullSolid.add((byte)12); // blockPassSet.add((byte) Material.JUNGLE_FENCE.getId());
fullSolid.add((byte)13); // blockPassSet.add((byte) Material.DARK_OAK_FENCE.getId());
fullSolid.add((byte)14); // blockPassSet.add((byte) Material.ACACIA_FENCE.getId());
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 blockPassSet.add((byte) Material.SPRUCE_DOOR.getId());
blockUseSet.add((byte)26); //Bed blockPassSet.add((byte) Material.BIRCH_DOOR.getId());
blockUseSet.add((byte)33); //Piston blockPassSet.add((byte) Material.JUNGLE_DOOR.getId());
blockUseSet.add((byte)47); //Bookcase blockPassSet.add((byte) Material.ACACIA_DOOR.getId());
blockUseSet.add((byte)54); //Chest blockPassSet.add((byte) Material.DARK_OAK_DOOR.getId());
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 fullSolid.add((byte) Material.STONE.getId());
blockUseSet.add((byte)185); //Fences/Gates fullSolid.add((byte) Material.GRASS.getId());
blockUseSet.add((byte)186); //Fences/Gates fullSolid.add((byte) Material.DIRT.getId());
blockUseSet.add((byte)187); //Fences/Gates fullSolid.add((byte) Material.COBBLESTONE.getId());
blockUseSet.add((byte)188); //Fences/Gates fullSolid.add((byte) Material.WOOD.getId());
blockUseSet.add((byte)189); //Fences/Gates fullSolid.add((byte) Material.BEDROCK.getId());
blockUseSet.add((byte)190); //Fences/Gates fullSolid.add((byte) Material.SAND.getId());
blockUseSet.add((byte)191); //Fences/Gates fullSolid.add((byte) Material.GRAVEL.getId());
blockUseSet.add((byte)192); //Fences/Gates 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)193); //Wood Doors blockUseSet.add((byte) Material.DISPENSER.getId());
blockUseSet.add((byte)194); //Wood Doors blockUseSet.add((byte) Material.BED_BLOCK.getId());
blockUseSet.add((byte)195); //Wood Doors blockUseSet.add((byte) Material.PISTON_BASE.getId());
blockUseSet.add((byte)196); //Wood Doors blockUseSet.add((byte) Material.BOOKSHELF.getId());
blockUseSet.add((byte)197); //Wood Doors 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) public static boolean solid(Block block)
@ -451,8 +489,9 @@ public class UtilBlock
if (block.getType() != Material.AIR) if (block.getType() != Material.AIR)
{ {
float f3 = (damageBlocksEqually ? Blocks.DIRT : world.getType(block.getX(), block.getY(), Blocks.DIRT.a((net.minecraft.server.v1_8_R3.Entity) null);
block.getZ())).a((net.minecraft.server.v1_7_R4.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; f1 -= (f3 + 0.3F) * f2;
} }

View File

@ -5,22 +5,23 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import net.minecraft.server.v1_7_R4.AxisAlignedBB; import net.minecraft.server.v1_8_R3.AxisAlignedBB;
import net.minecraft.server.v1_7_R4.EntityBat; import net.minecraft.server.v1_8_R3.EntityBat;
import net.minecraft.server.v1_7_R4.EntityCreature; import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_7_R4.EntityEnderDragon; import net.minecraft.server.v1_8_R3.EntityEnderDragon;
import net.minecraft.server.v1_7_R4.EntityHuman; import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_7_R4.EntityInsentient; import net.minecraft.server.v1_8_R3.EntityInsentient;
import net.minecraft.server.v1_7_R4.EntityLiving; import net.minecraft.server.v1_8_R3.EntityLiving;
import net.minecraft.server.v1_7_R4.EntityTrackerEntry; import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_7_R4.Navigation; import net.minecraft.server.v1_8_R3.NavigationAbstract;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityHeadRotation; import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_7_R4.PathfinderGoal; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityHeadRotation;
import net.minecraft.server.v1_7_R4.PathfinderGoalLookAtPlayer; import net.minecraft.server.v1_8_R3.PathfinderGoal;
import net.minecraft.server.v1_7_R4.PathfinderGoalMoveTowardsRestriction; import net.minecraft.server.v1_8_R3.PathfinderGoalLookAtPlayer;
import net.minecraft.server.v1_7_R4.PathfinderGoalRandomLookaround; import net.minecraft.server.v1_8_R3.PathfinderGoalMoveTowardsRestriction;
import net.minecraft.server.v1_7_R4.PathfinderGoalSelector; import net.minecraft.server.v1_8_R3.PathfinderGoalRandomLookaround;
import net.minecraft.server.v1_7_R4.WorldServer; import net.minecraft.server.v1_8_R3.PathfinderGoalSelector;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -28,10 +29,11 @@ import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity; 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.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -60,31 +62,29 @@ public class UtilEnt
public static void silence(Entity entity, boolean silence) 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) public static void ghost(Entity entity, boolean ghost, boolean invisible)
{ {
if (entity instanceof LivingEntity) 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); ((CraftEntity)entity).getHandle().setInvisible(invisible);
} }
public static void Leash(LivingEntity leashed, Entity holder, boolean pull, boolean breakable) 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.setLeashHolder(holder); leashed.setLeashHolder(holder);
if (!(((CraftLivingEntity)leashed).getHandle() instanceof EntityInsentient))
return;
((EntityInsentient)((CraftLivingEntity)leashed).getHandle()).setPullWhileLeashed(pull);
((EntityInsentient)((CraftLivingEntity)leashed).getHandle()).setShouldBreakLeash(breakable);
} }
public static void addLookAtPlayerAI(Entity entity, float dist) public static void addLookAtPlayerAI(Entity entity, float dist)
@ -167,7 +167,7 @@ public class UtilEnt
if (_bsRestrictionGoal == null) if (_bsRestrictionGoal == null)
{ {
_bsRestrictionGoal = EntityCreature.class.getDeclaredField("bs"); _bsRestrictionGoal = EntityCreature.class.getDeclaredField("c");
_bsRestrictionGoal.setAccessible(true); _bsRestrictionGoal.setAccessible(true);
} }
@ -178,10 +178,10 @@ public class UtilEnt
{ {
EntityInsentient creature = (EntityInsentient)((CraftEntity)entity).getHandle(); EntityInsentient creature = (EntityInsentient)((CraftEntity)entity).getHandle();
creature.Vegetated = true; creature.setVegetated(true);
creature.Silent = mute; creature.setSilent(mute);
((List)_pathfinderBList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear(); ((List) _pathfinderBList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear();
((List)_pathfinderCList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear(); ((List)_pathfinderCList.get(((PathfinderGoalSelector)_goalSelector.get(creature)))).clear();
((List)_pathfinderBList.get(((PathfinderGoalSelector)_targetSelector.get(creature)))).clear(); ((List)_pathfinderBList.get(((PathfinderGoalSelector)_targetSelector.get(creature)))).clear();
@ -190,14 +190,14 @@ public class UtilEnt
if (((CraftEntity)entity).getHandle() instanceof EntityBat) if (((CraftEntity)entity).getHandle() instanceof EntityBat)
{ {
((EntityBat)((CraftEntity)entity).getHandle()).Vegetated = true; ((EntityBat)((CraftEntity)entity).getHandle()).setVegetated(true);
} }
if (((CraftEntity)entity).getHandle() instanceof EntityEnderDragon) if (((CraftEntity)entity).getHandle() instanceof EntityEnderDragon)
{ {
EntityEnderDragon creature = (EntityEnderDragon)((CraftEntity)entity).getHandle(); EntityEnderDragon creature = (EntityEnderDragon)((CraftEntity)entity).getHandle();
creature.Vegetated = true; creature.setVegetated(true);
} }
} }
catch (IllegalArgumentException e) catch (IllegalArgumentException e)
@ -435,10 +435,23 @@ public class UtilEnt
LivingEntity ent = (LivingEntity)cur; LivingEntity ent = (LivingEntity)cur;
//Feet
double offset = UtilMath.offset(loc, ent.getLocation()); double offset = UtilMath.offset(loc, ent.getLocation());
if (offset < dR) if (offset < dR)
{
ents.put(ent, 1 - (offset/dR)); ents.put(ent, 1 - (offset/dR));
continue;
}
//Eyes
offset = UtilMath.offset(loc, ent.getEyeLocation());
if (offset < dR)
{
ents.put(ent, 1 - (offset/dR));
continue;
}
} }
return ents; return ents;
@ -496,7 +509,7 @@ public class UtilEnt
public static boolean isGrounded(Entity ent) 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_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); Location bottom_corner_2 = new Location(ent.getWorld(), box.d, ent.getLocation().getY()-0.1, box.f);
@ -603,24 +616,57 @@ public class UtilEnt
return CreatureLook(ent, UtilAlg.GetPitch(vec), UtilAlg.GetYaw(vec)); 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) public static boolean CreatureLook(Entity ent, float pitch, float yaw)
{ {
if (!(ent instanceof LivingEntity)) if (!(ent instanceof LivingEntity))
return false; return false;
EntityLiving ec = ((CraftLivingEntity) ent).getHandle(); EntityLiving ec = ((CraftLivingEntity) ent).getHandle();
Location loc = ent.getLocation();
ec.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), yaw, pitch); ec.yaw = yaw;
ec.al = true; 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; 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) public static void CreatureMove(Entity ent, Location target, float speed)
{ {
if (!(ent instanceof Creature)) if (!(ent instanceof Creature))
@ -630,7 +676,7 @@ public class UtilEnt
return; return;
EntityCreature ec = ((CraftCreature)ent).getHandle(); EntityCreature ec = ((CraftCreature)ent).getHandle();
Navigation nav = ec.getNavigation(); NavigationAbstract nav = ec.getNavigation();
if (UtilMath.offset(ent.getLocation(), target) > 16) if (UtilMath.offset(ent.getLocation(), target) > 16)
{ {
@ -682,7 +728,7 @@ public class UtilEnt
{ {
try 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); field.setAccessible(true);
int entityId = field.getInt(null); int entityId = field.getInt(null);
if (modifynumber) { if (modifynumber) {

View File

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

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; 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) 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) if (required <= 0)
{ {
@ -157,15 +158,22 @@ public class UtilInv
inv.setArmorContents(new ItemStack[4]); inv.setArmorContents(new ItemStack[4]);
player.setItemOnCursor(new ItemStack(Material.AIR)); player.setItemOnCursor(new ItemStack(Material.AIR));
Inventory openInventory = player.getOpenInventory().getTopInventory();
if (openInventory.getHolder() == player)
{
openInventory.clear();
}
player.saveData(); player.saveData();
} }
public static ArrayList<ItemStack> getItems(Player player) 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>(); ArrayList<ItemStack> items = new ArrayList<ItemStack>();
PlayerInventory inv = player.getInventory(); PlayerInventory inv = player.getInventory();
@ -197,6 +205,22 @@ public class UtilInv
items.add(cursorItem.clone()); 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; return items;
} }
@ -357,11 +381,12 @@ public class UtilInv
return getAmount(player, mat, true); 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; int amount = 0;
for (ItemStack item : getItems(player, true, true)) for (ItemStack item : getItems(player, includeArmorAndCursorAndCrafting, includeArmorAndCursorAndCrafting,
includeArmorAndCursorAndCrafting))
{ {
if (item.getType() == mat) if (item.getType() == mat)
{ {

View File

@ -3,7 +3,8 @@ package mineplex.core.common.util;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import mineplex.core.common.util.UtilParticle.ViewDist; 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.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -13,11 +14,7 @@ public class UtilParticle
{ {
public enum ViewDist public enum ViewDist
{ {
SHORT(8), SHORT(8), NORMAL(24), LONG(48), LONGER(96), MAX(256);
NORMAL(24),
LONG(48),
LONGER(96),
MAX(256);
private int _dist; private int _dist;
@ -34,9 +31,9 @@ public class UtilParticle
public enum ParticleType 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 @Override
public String getParticle(Material type, int data) 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 @Override
public String getParticle(Material type, int data) 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 @Override
public String getParticle(Material type, int data) 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 * 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 * 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), MOB_SPELL_AMBIENT(EnumParticle.SPELL_MOB_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),
/** /**
* 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.
*/ */
RED_DUST("reddust", "Red Smoke", Material.INK_SACK, (byte) 1), NOTE(EnumParticle.NOTE, "note", "Musical Note", Material.JUKEBOX, (byte) 0),
SLIME("slime", "Slime Particles", Material.SLIME_BALL, (byte) 0), PORTAL(EnumParticle.PORTAL, "portal", "Portal Effect", Material.INK_SACK, (byte) 5),
SNOW_SHOVEL("snowshovel", "Snow Puffs", Material.SNOW_BALL, (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
*/
RED_DUST(EnumParticle.REDSTONE, "reddust", "Red Smoke", Material.INK_SACK, (byte) 1),
SNOWBALL_POOF("snowballpoof"), SLIME(EnumParticle.SLIME, "slime", "Slime Particles", Material.SLIME_BALL, (byte) 0),
SPELL("spell", "White Swirls", Material.getMaterial(2264), (byte) 0), SNOW_SHOVEL(EnumParticle.SNOW_SHOVEL, "snowshovel", "Snow Puffs", Material.SNOW_BALL, (byte) 0),
SPLASH("splash"), SNOWBALL_POOF(EnumParticle.SNOWBALL, "snowballpoof"),
SUSPEND("suspended"), SPELL(EnumParticle.SPELL, "spell", "White Swirls", Material.getMaterial(2264), (byte) 0),
TOWN_AURA("townaura", "Black Specks", Material.COAL, (byte) 0), SPLASH(EnumParticle.WATER_SPLASH, "splash"),
WITCH_MAGIC("witchMagic", "Purple Magic", Material.INK_SACK, (byte) 13); SUSPEND(EnumParticle.SUSPENDED, "suspended"),
TOWN_AURA(EnumParticle.TOWN_AURA, "townaura", "Black Specks", Material.COAL, (byte) 0),
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; public String particleName;
private boolean _friendlyData; private boolean _friendlyData;
private String _friendlyName; private String _friendlyName;
private Material _material; private Material _material;
private byte _data; private byte _data;
ParticleType(String particleName) ParticleType(EnumParticle particle, String particleName)
{ {
this.particleName = particleName; this.particleName = particleName;
_friendlyData = false; _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.particleName = particleName;
this.particle = particle;
_friendlyData = true; _friendlyData = true;
_friendlyName = friendlyName; _friendlyName = friendlyName;
_material = material; _material = material;
@ -203,25 +218,45 @@ public class UtilParticle
private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY, private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY,
float offsetZ, float speed, int count, boolean displayFar) 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; return packet;
} }
public static void PlayParticle(ParticleType type,Location location, float offsetX, float offsetY, float offsetZ, public static void PlayParticle(ParticleType type, Location location, float offsetX, float offsetY, float offsetZ,
float speed, int count, ViewDist dist, Player... players) float speed, int count, ViewDist dist, Player... players)
{ {
PlayParticle(type.particleName, location, offsetX, offsetY, offsetZ, speed, count, dist, 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, public static void PlayParticle(String particle, Location location, float offsetX, float offsetY, float offsetZ, float speed,
float speed, int count, ViewDist dist, Player... players) int count, ViewDist dist, Player... players)
{ {
PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true); PacketPlayOutWorldParticles packet = getPacket(particle, location, offsetX, offsetY, offsetZ, speed, count, true);
for (Player player : players) for (Player player : players)
{ {
//Out of range for player // Out of range for player
if (UtilMath.offset(player.getLocation(), location) > dist.getDist()) if (UtilMath.offset(player.getLocation(), location) > dist.getDist())
continue; continue;

View File

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

View File

@ -84,6 +84,8 @@ public class UtilRadar
text += C.cPurple + C.Bold + "] Radar"; text += C.cPurple + C.Bold + "] Radar";
UtilTextTop.display(text, player);
if(bossBar) if(bossBar)
{ {
UtilTextTop.display(text, player); UtilTextTop.display(text, player);

View File

@ -1,19 +1,19 @@
package mineplex.core.common.util; 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.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; 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 public class UtilTabTitle
{ {
private static final int PROTOCOL_VERSION = 47;
public static void broadcastHeader(String header) public static void broadcastHeader(String header)
{ {
broadcastHeaderAndFooter(header, null); broadcastHeaderAndFooter(header, null);
@ -51,10 +51,8 @@ public class UtilTabTitle
public static void doHeaderAndFooter(Player p, String rawHeader, String rawFooter) public static void doHeaderAndFooter(Player p, String rawHeader, String rawFooter)
{ {
CraftPlayer player = (CraftPlayer) p; IChatBaseComponent header = IChatBaseComponent.ChatSerializer.a(TextConverter.convert(rawHeader));
if (player.getHandle().playerConnection.networkManager.getVersion() != PROTOCOL_VERSION) return; IChatBaseComponent footer = IChatBaseComponent.ChatSerializer.a(TextConverter.convert(rawFooter));
IChatBaseComponent header = ChatSerializer.a(TextConverter.convert(rawHeader));
IChatBaseComponent footer = ChatSerializer.a(TextConverter.convert(rawFooter));
if (header == null || footer == null) if (header == null || footer == null)
{ {
TabTitleCache titleCache = TabTitleCache.getTabTitle(p.getUniqueId()); TabTitleCache titleCache = TabTitleCache.getTabTitle(p.getUniqueId());
@ -66,7 +64,7 @@ public class UtilTabTitle
if (headerString != null) if (headerString != null)
{ {
rawHeader = headerString; rawHeader = headerString;
header = ChatSerializer.a(TextConverter.convert(headerString)); header = IChatBaseComponent.ChatSerializer.a(TextConverter.convert(headerString));
} }
} }
if (footer == null) if (footer == null)
@ -75,14 +73,17 @@ public class UtilTabTitle
if (footerString != null) if (footerString != null)
{ {
rawHeader = footerString; rawHeader = footerString;
header = ChatSerializer.a(TextConverter.convert(footerString)); header = IChatBaseComponent.ChatSerializer.a(TextConverter.convert(footerString));
} }
} }
} }
} }
TabTitleCache.addTabTitle(p.getUniqueId(), new TabTitleCache(rawHeader, rawFooter)); TabTitleCache.addTabTitle(p.getUniqueId(), new TabTitleCache(rawHeader, rawFooter));
ProtocolInjector.PacketTabHeader packet = new ProtocolInjector.PacketTabHeader(header, footer); PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
player.getHandle().playerConnection.sendPacket(packet); packet.a = header;
packet.b = footer;
UtilPlayer.sendPacket(p, packet);
} }
private static class TextConverter private static class TextConverter

View File

@ -14,15 +14,6 @@ public class UtilTextBottom
//1.8 //1.8
msg.send(MessageType.ABOVE_HOTBAR, players); 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) public static void displayProgress(double amount, Player... players)
@ -60,20 +51,6 @@ public class UtilTextBottom
progressBar += ""; 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; 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 org.bukkit.entity.Player;
import net.minecraft.server.v1_7_R4.ChatMessage; import net.minecraft.server.v1_8_R3.ChatMessage;
import net.minecraft.server.v1_8_R3.Packet;
import org.spigotmc.ProtocolInjector.PacketTitle; import net.minecraft.server.v1_8_R3.PacketPlayOutTitle;
import org.spigotmc.ProtocolInjector.PacketTitle.Action;
/** /**
* Created by Shaun on 9/5/2014. * Created by Shaun on 9/5/2014.
@ -52,7 +51,7 @@ public class UtilTextMiddle
text = ""; text = "";
ChatMessage message = new ChatMessage(text); ChatMessage message = new ChatMessage(text);
PacketTitle packet = new PacketTitle(Action.TITLE, message); PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, message);
sendPacket(packet, players); sendPacket(packet, players);
} }
@ -67,7 +66,7 @@ public class UtilTextMiddle
text = ""; text = "";
ChatMessage message = new ChatMessage(text); ChatMessage message = new ChatMessage(text);
PacketTitle packet = new PacketTitle(Action.SUBTITLE, message); PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.SUBTITLE, message);
sendPacket(packet, players); sendPacket(packet, players);
} }
@ -78,7 +77,7 @@ public class UtilTextMiddle
*/ */
private static void setTimings(int fadeInTicks, int stayTicks, int fadeOutTicks, Player... players) 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); sendPacket(packet, players);
} }
@ -87,7 +86,7 @@ public class UtilTextMiddle
*/ */
public static void clear(Player... players) public static void clear(Player... players)
{ {
PacketTitle packet = new PacketTitle(Action.CLEAR); PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.CLEAR, null);
sendPacket(packet, players); sendPacket(packet, players);
} }
@ -98,18 +97,15 @@ public class UtilTextMiddle
*/ */
public static void reset(Player... players) public static void reset(Player... players)
{ {
PacketTitle packet = new PacketTitle(Action.RESET); PacketPlayOutTitle packet = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.RESET, null);
sendPacket(packet, players); sendPacket(packet, players);
} }
private static void sendPacket(PacketTitle packet, Player... players) private static void sendPacket(Packet packet, Player... players)
{ {
for (Player player : players) for (Player player : players)
{ {
if (UtilPlayer.is1_8(player)) UtilPlayer.sendPacket(player, packet);
{
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
} }
} }

View File

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

View File

@ -2,23 +2,22 @@ package mineplex.core.common.util;
import java.io.File; import java.io.File;
import net.minecraft.server.v1_7_R4.ConvertProgressUpdater; import net.minecraft.server.v1_8_R3.Convertable;
import net.minecraft.server.v1_7_R4.Convertable; import net.minecraft.server.v1_8_R3.EntityTracker;
import net.minecraft.server.v1_7_R4.EntityTracker; import net.minecraft.server.v1_8_R3.EnumDifficulty;
import net.minecraft.server.v1_7_R4.EnumDifficulty; import net.minecraft.server.v1_8_R3.IDataManager;
import net.minecraft.server.v1_7_R4.EnumGamemode; import net.minecraft.server.v1_8_R3.IProgressUpdate;
import net.minecraft.server.v1_7_R4.IWorldAccess; import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_7_R4.ServerNBTManager; import net.minecraft.server.v1_8_R3.ServerNBTManager;
import net.minecraft.server.v1_7_R4.WorldLoaderServer; import net.minecraft.server.v1_8_R3.WorldData;
import net.minecraft.server.v1_7_R4.WorldManager; import net.minecraft.server.v1_8_R3.WorldLoaderServer;
import net.minecraft.server.v1_7_R4.WorldServer; import net.minecraft.server.v1_8_R3.WorldManager;
import net.minecraft.server.v1_7_R4.WorldSettings; import net.minecraft.server.v1_8_R3.WorldServer;
import net.minecraft.server.v1_7_R4.WorldType; import net.minecraft.server.v1_8_R3.WorldSettings;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; 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.WorldInitEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
@ -27,18 +26,17 @@ public class WorldUtil
{ {
public static World LoadWorld(WorldCreator creator) public static World LoadWorld(WorldCreator creator)
{ {
CraftServer server = (CraftServer)Bukkit.getServer(); CraftServer server = (CraftServer) Bukkit.getServer();
if (creator == null) if (creator == null)
{ {
throw new IllegalArgumentException("Creator may not be null"); throw new IllegalArgumentException("Creator may not be null");
} }
String name = creator.name(); String name = creator.name();
System.out.println("Loading world '" + name + "'");
ChunkGenerator generator = creator.generator(); ChunkGenerator generator = creator.generator();
File folder = new File(server.getWorldContainer(), name); File folder = new File(server.getWorldContainer(), name);
World world = server.getWorld(name); World world = server.getWorld(name);
WorldType type = WorldType.getType(creator.type().getName()); net.minecraft.server.v1_8_R3.WorldType type = net.minecraft.server.v1_8_R3.WorldType.getType(creator.type().getName());
boolean generateStructures = creator.generateStructures(); boolean generateStructures = creator.generateStructures();
if (world != null) if (world != null)
@ -60,28 +58,55 @@ public class WorldUtil
if (converter.isConvertable(name)) if (converter.isConvertable(name))
{ {
server.getLogger().info("Converting world '" + name + "'"); server.getLogger().info("Converting world '" + name + "'");
converter.convert(name, new ConvertProgressUpdater(server.getServer())); converter.convert(name, new IProgressUpdate()
{
private long b = System.currentTimeMillis();
public void a(String s)
{
} }
int dimension = server.getWorlds().size() + 1; public void a(int i)
{
if (System.currentTimeMillis() - this.b >= 1000L)
{
this.b = System.currentTimeMillis();
MinecraftServer.LOGGER.info("Converting... " + i + "%");
}
}
public void c(String s)
{
}
});
}
int dimension = 10 + server.getServer().worlds.size();
boolean used = false; boolean used = false;
do do
for (WorldServer s : server.getServer().worlds)
{ {
for (WorldServer worldServer : server.getServer().worlds) used = s.dimension == dimension;
{
used = worldServer.dimension == dimension;
if (used) if (used)
{ {
dimension++; dimension++;
break; break;
} }
} }
} while(used); while (used);
boolean hardcore = false; boolean hardcore = false;
System.out.println("Loaded world with dimension : " + dimension); Object sdm = new ServerNBTManager(server.getWorldContainer(), name, true);
WorldData worlddata = ((IDataManager) sdm).getWorldData();
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); 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();
boolean containsWorld = false; boolean containsWorld = false;
for (World otherWorld : server.getWorlds()) for (World otherWorld : server.getWorlds())
@ -96,23 +121,13 @@ public class WorldUtil
if (!containsWorld) if (!containsWorld)
return null; return null;
System.out.println("Created world with dimension : " + dimension);
internal.scoreboard = server.getScoreboardManager().getMainScoreboard().getHandle(); 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);
/* internal.tracker = new EntityTracker(internal);
for (WorldServer worlder : server.getServer().worlds) internal.addIWorldAccess(new WorldManager(server.getServer(), internal));
{ internal.worldData.setDifficulty(EnumDifficulty.EASY);
System.out.println(worlder.getWorldData().getName() + " with dimension: " + worlder.dimension); internal.setSpawnFlags(true, true);
} server.getServer().worlds.add(internal);
*/
if (generator != null) if (generator != null)
{ {

View File

@ -174,7 +174,15 @@ public class ZipUtil
int size; int size;
byte[] buffer = new byte[2048]; 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); bufferedOutputStream = new BufferedOutputStream(fileOutputStream, buffer.length);
while ((size = zipInputStream.read(buffer, 0, buffer.length)) != -1) while ((size = zipInputStream.read(buffer, 0, buffer.length)) != -1)

View File

@ -12,8 +12,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Database"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.5.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/> <classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.PlayerCache"/> <classpathentry combineaccessrules="false" kind="src" path="/Mineplex.PlayerCache"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -1,6 +1,5 @@
package mineplex.core; package mineplex.core;
import java.lang.reflect.Field;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -9,28 +8,31 @@ import java.util.UUID;
import mineplex.core.common.DummyEntity; import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.event.CustomTagEvent; import mineplex.core.event.CustomTagEvent;
import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketHandler;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.packethandler.PacketVerifier; import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.packethandler.PacketInfo; import mineplex.core.packethandler.PacketInfo;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_7_R4.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_7_R4.EnumEntitySize; import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject;
import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_7_R4.WatchableObject; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Bukkit; 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.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
@ -49,31 +51,19 @@ 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, 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, 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<String> _loggedIn = new HashSet<String>();
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>(); private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
private NautHashMap<UUID, Long> _exemptTimeMap = new NautHashMap<UUID, Long>(); private NautHashMap<UUID, Long> _exemptTimeMap = new NautHashMap<UUID, Long>();
private NautHashMap<UUID, NautHashMap<CheckType, Long>> _doubleStrike = new NautHashMap<UUID, NautHashMap<CheckType, Long>>(); private NautHashMap<UUID, NautHashMap<CheckType, Long>> _doubleStrike = new NautHashMap<UUID, NautHashMap<CheckType, Long>>();
private Field _destroyId;
public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler) public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler)
{ {
super("Custom Tag Fix", plugin); super("Custom Tag Fix", plugin);
packetHandler.addPacketHandler(this); packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class,
PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class,
try PacketPlayInUseEntity.class);
{
_destroyId = PacketPlayOutEntityDestroy.class.getDeclaredField("a");
_destroyId.setAccessible(true);
}
catch (Exception exception)
{
System.out.println("Field exception in CustomTagFix : ");
exception.printStackTrace();
}
NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this); NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this); NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
@ -85,7 +75,6 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
_entityMap.remove(event.getPlayer().getName()); _entityMap.remove(event.getPlayer().getName());
_entityNameMap.remove(event.getPlayer().getName()); _entityNameMap.remove(event.getPlayer().getName());
_entityVehicleMap.remove(event.getPlayer().getName());
_loggedIn.remove(event.getPlayer()); _loggedIn.remove(event.getPlayer());
} }
@ -96,7 +85,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId())) 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; return;
} }
@ -115,10 +105,11 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
@EventHandler @EventHandler
public void ncpExemptVelocity(final PlayerVelocityEvent event) 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())) 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; return;
} }
@ -141,7 +132,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
} }
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(); Entry<UUID, NautHashMap<CheckType, Long>> entry = iterator.next();
@ -175,7 +167,6 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
iterator.remove(); iterator.remove();
_entityMap.remove(player); _entityMap.remove(player);
_entityNameMap.remove(player); _entityNameMap.remove(player);
_entityVehicleMap.remove(player);
} }
} }
@ -195,24 +186,24 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
Player owner = packetInfo.getPlayer(); Player owner = packetInfo.getPlayer();
PacketVerifier verifier = packetInfo.getVerifier(); PacketVerifier verifier = packetInfo.getVerifier();
if (owner.isOnline() && UtilPlayer.is1_8(owner)) if (owner.isOnline())
{ {
if (owner.isOnline() && !_entityMap.containsKey(owner.getName())) if (owner.isOnline() && !_entityMap.containsKey(owner.getName()))
{ {
_entityMap.put(owner.getName(), new NautHashMap<Integer, Integer>()); _entityMap.put(owner.getName(), new NautHashMap<Integer, Integer>());
_entityNameMap.put(owner.getName(), new NautHashMap<Integer, String>()); _entityNameMap.put(owner.getName(), new NautHashMap<Integer, String>());
_entityVehicleMap.put(owner.getName(), new NautHashMap<Integer, Integer>());
_loggedIn.add(owner.getName()); _loggedIn.add(owner.getName());
} }
if (packet instanceof PacketPlayOutSpawnEntityLiving) if (packet instanceof PacketPlayOutSpawnEntityLiving)
{ {
PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving)packet; PacketPlayOutSpawnEntityLiving spawnPacket = (PacketPlayOutSpawnEntityLiving) packet;
// Ignore Armor stand packets // 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);
} }
@ -220,77 +211,119 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
return; 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 (_entityMap.get(owner.getName()).containsKey(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()) if (entityName.isEmpty())
{ {
_entityNameMap.get(owner.getName()).remove(spawnPacket.a);
return; return;
} }
if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner.getName()).get(spawnPacket.a)));
}
int newId = UtilEnt.getNewEntityId(); 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);
_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; break;
} }
} }
} }
else if (packet instanceof PacketPlayOutEntityMetadata) else if (packet instanceof PacketPlayOutEntityMetadata)
{ {
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata)packet; PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet;
if (!_entityMap.get(owner.getName()).containsKey(metaPacket.a) && metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a)) if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a))
{ {
String entityName = ""; boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a);
boolean nameShowing = false; String currentName = _entityNameMap.get(owner.getName()).get(metaPacket.a);
for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b) if (currentName == null)
{ {
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1) currentName = "";
{
nameShowing = true;
} }
if ((watchable.a() == 10 || watchable.a() == 2) && watchable.b() instanceof String)
String newName = currentName;
boolean newDisplay = isDisplaying;
for (WatchableObject watchable : (List<WatchableObject>) metaPacket.b)
{ {
entityName = (String)watchable.b(); if (watchable.a() == 3 && watchable.b() instanceof Byte)
{
newDisplay = ((Byte) watchable.b()) == 1;
}
if (watchable.a() == 2 && watchable.b() instanceof String)
{
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(); // If name is still being displayed
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier); 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); _entityMap.get(owner.getName()).put(metaPacket.a, newId);
_entityNameMap.get(owner.getName()).put(metaPacket.a, entityName);
} }
else if (!entityName.isEmpty())
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); _entityNameMap.get(owner.getName()).remove(metaPacket.a);
} }
} }
} }
}
else if (packet instanceof PacketPlayOutEntityDestroy) else if (packet instanceof PacketPlayOutEntityDestroy)
{ {
try try
{ {
for (int id : (int[])_destroyId.get(packet)) for (int id : ((PacketPlayOutEntityDestroy) packet).a)
{ {
if (_entityMap.get(owner.getName()).containsKey(id)) 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); _entityMap.get(owner.getName()).remove(id);
_entityVehicleMap.get(owner.getName()).remove(id);
_entityNameMap.get(owner.getName()).remove(id); _entityNameMap.get(owner.getName()).remove(id);
} }
} }
@ -308,146 +341,31 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
_ignoreSkulls.add(spawnPacket.a); _ignoreSkulls.add(spawnPacket.a);
} }
} }
/* else if (packet instanceof PacketPlayInUseEntity)
else if (packet instanceof PacketPlayOutAttachEntity)
{ {
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity)packet; PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet;
/* TODO dynamic attach handling? for (Entry<Integer, Integer> entry : _entityMap.get(owner.getName()).entrySet())
if (attachPacket.c == -1)
{ {
if (_entityVehicleMap.get(owner).containsKey(attachPacket.b) && _entityNameMap.get(owner).containsKey(_entityVehicleMap.get(owner).get(attachPacket.b))) if (entry.getValue() == usePacket.a)
{ {
int newId = UtilEnt.getNewEntityId(); PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity();
sendProtocolPackets(owner, _entityVehicleMap.get(owner).get(attachPacket.b), newId, _entityNameMap.get(owner).get(_entityVehicleMap.get(owner).get(attachPacket.b)), verifier); newPacket.a = entry.getKey();
_entityMap.get(owner).put(attachPacket.b, newId); newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK
_entityVehicleMap.get(owner).remove(attachPacket.b); : EnumEntityUseAction.INTERACT;
packetInfo.setCancelled(true);
}
}
else
{ {
_entityVehicleMap.get(owner).put(attachPacket.b, attachPacket.c); ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket);
}
break;
} }
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);
} }
} }
*/
} }
} }
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); CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event); _plugin.getServer().getPluginManager().callEvent(event);
@ -457,15 +375,43 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
public void run() public void run()
{ {
final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle()));
packet.a = newEntityId;
packet.b = (byte) 30; watcher.a(0, Byte.valueOf((byte) 0));
packet.c = (int)EnumEntitySize.SIZE_2.a(100); watcher.a(1, Short.valueOf((short) 300));
packet.d = (int)MathHelper.floor(64 * 32.0D); watcher.a(2, "");
packet.e = (int)EnumEntitySize.SIZE_2.a(100); watcher.a(3, Byte.valueOf((byte) 0));
packet.i = (byte) ((int) (0 * 256.0F / 360.0F)); watcher.a(4, Byte.valueOf((byte) 0));
packet.j = (byte) ((int) (0 * 256.0F / 360.0F)); watcher.a(7, Integer.valueOf(0));
packet.k = (byte) ((int) (0 * 256.0F / 360.0F)); 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.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 var2 = 3.9D;
double var4 = 0; double var4 = 0;
@ -502,62 +448,29 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
var8 = var2; var8 = var2;
} }
packet.f = (int)(var4 * 8000.0D); spawnPacket.f = (int) (var4 * 8000.0D);
packet.g = (int)(var6 * 8000.0D); spawnPacket.g = (int) (var6 * 8000.0D);
packet.h = (int)(var8 * 8000.0D); spawnPacket.h = (int) (var8 * 8000.0D);
final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld)owner.getWorld()).getHandle())); spawnPacket.l = watcher;
watcher.a(0, Byte.valueOf((byte)0)); UtilPlayer.sendPacket(owner, spawnPacket);
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));
watcher.watch(2, finalEntityName);
watcher.watch(3, Byte.valueOf((byte)1));
packet.l = watcher;
packetList.bypassProcess(packet);
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0; vehiclePacket.a = 0;
vehiclePacket.b = packet.a; vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = entityId; vehiclePacket.c = entityId;
packetList.bypassProcess(vehiclePacket); UtilPlayer.sendPacket(owner, 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();
} }
else
{
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
entityMetadata.a = newEntityId;
entityMetadata.b = watcher.c();
vehiclePacket.c = packet.a; packetList.bypassProcess(entityMetadata);
} }
*/
} }
}); });
} }
@ -590,7 +503,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
// This is the second strike system. // This is the second strike system.
if (!failure) 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; failure = true;
if (!_doubleStrike.containsKey(player.getUniqueId())) if (!_doubleStrike.containsKey(player.getUniqueId()))
@ -602,4 +516,3 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
return failure; return failure;
} }
} }

View File

@ -108,6 +108,11 @@ public abstract class MiniPlugin implements Listener
_plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, runnable); _plugin.getServer().getScheduler().runTaskAsynchronously(_plugin, runnable);
} }
public void runAsync(Runnable runnable, long time)
{
_plugin.getServer().getScheduler().runTaskLaterAsynchronously(_plugin, runnable, time);
}
public void runSync(Runnable runnable) public void runSync(Runnable runnable)
{ {
_plugin.getServer().getScheduler().runTask(_plugin, runnable); _plugin.getServer().getScheduler().runTask(_plugin, runnable);

View File

@ -0,0 +1,160 @@
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.EntityPlayer;
import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_8_R3.MovingObjectPosition;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.Vec3D;
import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode;
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.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>>();
public PacketsInteractionFix(JavaPlugin plugin, PacketHandler packetHandler)
{
super("Packets Interaction Fix", plugin);
packetHandler.addPacketHandler(this, true, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutEntityDestroy.class,
PacketPlayInUseEntity.class);
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
_armorStands.remove(event.getPlayer().getName());
}
@EventHandler
public void removeDeadNames(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
Iterator<String> itel = _armorStands.keySet().iterator();
while (itel.hasNext())
{
String name = itel.next();
Player player = Bukkit.getPlayerExact(name);
if (player != null)
{
continue;
}
itel.remove();
}
}
@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 (packet.action == EnumEntityUseAction.ATTACK)
{
EntityPlayer nmsPlayer = ((CraftPlayer) packetInfo.getPlayer()).getHandle();
float f1 = nmsPlayer.pitch;
float f2 = nmsPlayer.yaw;
double d0 = nmsPlayer.locX;
double d1 = nmsPlayer.locY + nmsPlayer.getHeadHeight();
double d2 = nmsPlayer.locZ;
Vec3D vec3d = new Vec3D(d0, d1, d2);
float f3 = MathHelper.cos(-f2 * 0.01745329F - 3.141593F);
float f4 = MathHelper.sin(-f2 * 0.01745329F - 3.141593F);
float f5 = -MathHelper.cos(-f1 * 0.01745329F);
float f6 = MathHelper.sin(-f1 * 0.01745329F);
float f7 = f4 * f5;
float f8 = f3 * f5;
nmsPlayer.playerInteractManager.getGameMode();
double d3 = nmsPlayer.playerInteractManager.getGameMode() == EnumGamemode.CREATIVE ? 5 : 4.5;
Vec3D vec3d1 = vec3d.add(f7 * d3, f6 * d3, f8 * d3);
MovingObjectPosition movingobjectposition = nmsPlayer.world.rayTrace(vec3d, vec3d1, false);
if (movingobjectposition != null && movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.BLOCK)
{
CraftEventFactory.callPlayerInteractEvent(nmsPlayer, Action.LEFT_CLICK_AIR,
nmsPlayer.inventory.getItemInHand());
}
return;
}
if (!list.contains(packet.a))
{
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.UUID;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import com.google.gson.Gson;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.account.command.TestRank; import mineplex.core.account.command.TestRank;
import mineplex.core.account.command.UpdateRank; import mineplex.core.account.command.UpdateRank;
@ -28,7 +29,6 @@ import mineplex.playerCache.PlayerInfo;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -426,6 +426,25 @@ public class CoreClientManager extends MiniPlugin
}, name, uuid, rank, perm); }, 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) public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
{ {
_repository.matchPlayerName(new Callback<List<String>>() _repository.matchPlayerName(new Callback<List<String>>()

View File

@ -1,6 +1,6 @@
package mineplex.core.account.event; 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.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;

View File

@ -11,7 +11,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; 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 org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.ILoginProcessor; import mineplex.core.account.ILoginProcessor;

View File

@ -277,8 +277,8 @@ public enum Achievement
//Champions //Champions
CHAMPIONS_WINS("Champion", 600, CHAMPIONS_WINS("Champion", 600,
new String[]{"Champions Domination.Wins", "Champions TDM.Wins"}, new String[]{"Champions Domination.Wins", "Champions TDM.Wins", "Champions Capture the Flag.Wins"},
new String[]{"Win 80 games of Dominate or TDM"}, new String[]{"Win 80 games of Dominate, TDM, or CTF"},
new int[]{80}, new int[]{80},
AchievementCategory.CHAMPIONS), AchievementCategory.CHAMPIONS),
@ -295,29 +295,41 @@ public enum Achievement
AchievementCategory.CHAMPIONS), AchievementCategory.CHAMPIONS),
CHAMPIONS_ASSASSINATION("Assassination", 1000, CHAMPIONS_ASSASSINATION("Assassination", 1000,
new String[]{"Champions Domination.Assassination", "Champions TDM.Assassination"}, new String[]{"Champions Domination.Assassination", "Champions TDM.Assassination", "Champions Capture the Flag.Assassination"},
new String[]{"Kill 40 players with Backstab without", "taking any damage from them"}, new String[]{"Kill 40 players with Backstab without", "taking any damage from them"},
new int[]{40}, new int[]{40},
AchievementCategory.CHAMPIONS), AchievementCategory.CHAMPIONS),
CHAMPIONS_MASS_ELECTROCUTION("Mass Electrocution", 1200, CHAMPIONS_MASS_ELECTROCUTION("Mass Electrocution", 1200,
new String[]{"Champions Domination.MassElectrocution", "Champions TDM.MassElectrocution"}, new String[]{"Champions Domination.MassElectrocution", "Champions TDM.MassElectrocution", "Champions Capture the Flag.MassElectrocution"},
new String[]{"Hit 4 enemies with a Lightning Orb"}, new String[]{"Hit 4 enemies with a Lightning Orb"},
new int[]{1}, new int[]{1},
AchievementCategory.CHAMPIONS), AchievementCategory.CHAMPIONS),
CHAMPIONS_THE_LONGEST_SHOT("The Longest Shot", 1200, CHAMPIONS_THE_LONGEST_SHOT("The Longest Shot", 1200,
new String[]{"Champions Domination.TheLongestShot", "Champions TDM.TheLongestShot"}, new String[]{"Champions Domination.TheLongestShot", "Champions TDM.TheLongestShot", "Champions Capture the Flag.TheLongestShot"},
new String[]{"Kill someone using Longshot who", "is over 64 Blocks away from you"}, new String[]{"Kill someone using Longshot who", "is over 64 Blocks away from you"},
new int[]{1}, new int[]{1},
AchievementCategory.CHAMPIONS), AchievementCategory.CHAMPIONS),
CHAMPIONS_EARTHQUAKE("Earthquake", 1200, CHAMPIONS_EARTHQUAKE("Earthquake", 1200,
new String[]{"Champions Domination.Earthquake", "Champions TDM.Earthquake"}, new String[]{"Champions Domination.Earthquake", "Champions TDM.Earthquake", "Champions Capture the Flag.Earthquake"},
new String[]{"Launch 5 enemies using Seismic Slam"}, new String[]{"Launch 5 enemies using Seismic Slam"},
new int[]{1}, new int[]{1},
AchievementCategory.CHAMPIONS), AchievementCategory.CHAMPIONS),
CHAMPIONS_CAPTURES("Sticky Fingers", 2500,
new String[]{"Champions Capture the Flag.Captures"},
new String[]{"Capture the Enemy Flag 20 times"},
new int[]{20},
AchievementCategory.CHAMPIONS),
CHAMPIONS_CLUTCH("Clutch", 600,
new String[]{"Champions Capture the Flag.Clutch"},
new String[]{"Kill the Enemy Flag Carrier in Sudden Death"},
new int[]{1},
AchievementCategory.CHAMPIONS),
//Paintball //Paintball
SUPER_PAINTBALL_WINS("Paintball King", 600, SUPER_PAINTBALL_WINS("Paintball King", 600,
new String[]{"Super Paintball.Wins"}, new String[]{"Super Paintball.Wins"},
@ -755,9 +767,6 @@ public enum Achievement
; ;
private static String[] _colors = { C.cAqua, C.cGreen, C.cDGray, C.cPurple, C.cYellow, C.cGray };
private static int _negativeCount = 0;
private String _name; private String _name;
private String[] _desc; private String[] _desc;
private String[] _stats; private String[] _stats;
@ -823,10 +832,7 @@ public enum Achievement
public static String getExperienceString(int level) public static String getExperienceString(int level)
{ {
if (level < 0) if (level < 0)
{ return C.cPurple + level;
_negativeCount++;
return _colors[_negativeCount % _colors.length] + level;
}
if (level < 20) if (level < 20)
return C.cGray + level; return C.cGray + level;

View File

@ -78,8 +78,8 @@ public enum AchievementCategory
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED },
Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "Extra Tools Kit"), Material.BOOK_AND_QUILL, 0, GameCategory.CLASSICS, "Extra Tools Kit"),
CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM"}, CHAMPIONS("Champions", new String[] {"Champions Domination", "Champions TDM", "Champions Capture the Flag"},
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED, new StatDisplay("Flags Captured", "Captures") },
Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"), Material.BEACON, 0, GameCategory.CHAMPIONS, "Extra Class Skills"),
MASTER_BUILDERS("Master Builders", null, MASTER_BUILDERS("Master Builders", null,

View File

@ -6,7 +6,7 @@ import java.sql.SQLException;
import mineplex.core.database.DBPool; 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; import org.bukkit.entity.Player;
public class AntiHackRepository public class AntiHackRepository

View File

@ -1,5 +1,9 @@
package mineplex.core.blockrestore; package mineplex.core.blockrestore;
import java.util.HashMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -19,6 +23,8 @@ public class BlockRestoreData
protected long _meltDelay = 0; protected long _meltDelay = 0;
protected long _meltLast = 0; protected long _meltLast = 0;
protected HashMap<Location, Byte> _pad = new HashMap<Location, Byte>();
public BlockRestoreData(Block block, int toID, byte toData, int fromID, byte fromData, long expireDelay, long meltDelay) public BlockRestoreData(Block block, int toID, byte toData, int fromID, byte fromData, long expireDelay, long meltDelay)
{ {
_block = block; _block = block;
@ -136,6 +142,11 @@ public class BlockRestoreData
{ {
if (_toID == 78 && _toData == (byte)7) if (_toID == 78 && _toData == (byte)7)
_block.setTypeIdAndData(80, (byte)0, true); _block.setTypeIdAndData(80, (byte)0, true);
else if (_toID == 8 || _toID == 9 || _toID == 79)
{
handleLilypad(false);
_block.setTypeIdAndData(_toID, _toData, true);
}
else else
_block.setTypeIdAndData(_toID, _toData, true); _block.setTypeIdAndData(_toID, _toData, true);
} }
@ -143,6 +154,7 @@ public class BlockRestoreData
public void restore() public void restore()
{ {
_block.setTypeIdAndData(_fromID, _fromData, true); _block.setTypeIdAndData(_fromID, _fromData, true);
handleLilypad(true);
} }
public void setFromId(int i) public void setFromId(int i)
@ -154,4 +166,24 @@ public class BlockRestoreData
{ {
_fromData = i; _fromData = i;
} }
private void handleLilypad(boolean restore)
{
if (restore)
{
for (Location l : _pad.keySet())
{
l.getBlock().setType(Material.WATER_LILY);
l.getBlock().setData(_pad.get(l));
}
}
else
{
if (_block.getRelative(BlockFace.UP, 1).getType() == Material.WATER_LILY)
{
_pad.put(_block.getRelative(BlockFace.UP, 1).getLocation(), _block.getRelative(BlockFace.UP, 1).getData());
_block.getRelative(BlockFace.UP, 1).setType(Material.AIR);
}
}
}
} }

View File

@ -32,6 +32,7 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.database.DBPool; import mineplex.core.database.DBPool;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
@ -61,7 +62,7 @@ import org.jooq.SQLDialect;
import org.jooq.impl.DSL; import org.jooq.impl.DSL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; 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.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -71,8 +72,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
{ {
@ -165,7 +166,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
updateOffSet(); updateOffSet();
} }
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager) public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, GiveawayManager giveawayManager)
{ {
super("Bonus", plugin); super("Bonus", plugin);
_repository = new BonusRepository(plugin, this, donationManager); _repository = new BonusRepository(plugin, this, donationManager);
@ -174,7 +175,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_npcManager = npcManager; _npcManager = npcManager;
_hologramManager = hologramManager; _hologramManager = hologramManager;
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, _rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, giveawayManager,
100, 250, 100, 250,
500, 1000, 500, 1000,
4000, 6000, 4000, 6000,
@ -404,7 +405,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (!_enabled) if (!_enabled)
return; return;
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, -1); ((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, (byte) -1);
} }
public void IncreaseSize(Entity player) public void IncreaseSize(Entity player)
@ -412,7 +413,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (!_enabled) if (!_enabled)
return; return;
((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, 1); ((CraftEntity)_carlNpc.getEntity()).getHandle().getDataWatcher().watch(16, (byte) 1);
} }
// DAILY BONUS // DAILY BONUS
@ -891,7 +892,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (client.getHologram() == null) 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 = new Hologram(_hologramManager, _carlNpc.getLocation().clone().add(0, yAdd, 0), "");
hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST);
hologram.addPlayer(player); hologram.addPlayer(player);

View File

@ -3,6 +3,7 @@ package mineplex.core.bonuses.gui;
import java.util.ArrayList; import java.util.ArrayList;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gui.DisplayItem; import mineplex.core.gui.DisplayItem;
@ -109,7 +110,14 @@ public class SpinGui extends SimpleGui
} }
} }
_rewardData = _reward.giveReward(RewardType.SpinnerReal, getPlayer()); _reward.giveReward(RewardType.SpinnerReal, getPlayer(), new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
_rewardData = data;
}
});
} }
private void tick() private void tick()

View File

@ -134,9 +134,10 @@ public class Chat extends MiniPlugin
public void preventMe(PlayerCommandPreprocessEvent event) public void preventMe(PlayerCommandPreprocessEvent event)
{ {
if (event.getMessage().toLowerCase().startsWith("/me ") if (event.getMessage().toLowerCase().startsWith("/me ")
|| event.getMessage().toLowerCase().startsWith("/bukkit")) || event.getMessage().toLowerCase().startsWith("/bukkit")
|| event.getMessage().toLowerCase().startsWith("/minecraft"))
{ {
event.getPlayer().sendMessage(F.main(getName(), "No, you!")); event.getPlayer().sendMessage(F.main(getName(), "Nope, not allowed!"));
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

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

View File

@ -4,14 +4,17 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.minecraft.server.v1_7_R4.EntityPlayer; import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_7_R4.Items; import net.minecraft.server.v1_8_R3.ChatMessage;
import net.minecraft.server.v1_7_R4.PacketPlayOutOpenWindow; import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_7_R4.PacketPlayOutSetSlot; 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.ChatColor;
import org.bukkit.Material; 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.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
@ -19,6 +22,7 @@ import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType; import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.cosmetic.ui.CosmeticShop;
import mineplex.core.cosmetic.ui.PetSorter; 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); PetTagPage petTagPage = new PetTagPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "Repairing", getPlayer(), pet, petPurchase);
EntityPlayer entityPlayer = ((CraftPlayer) getPlayer()).getHandle(); EntityPlayer entityPlayer = ((CraftPlayer) getPlayer()).getHandle();
int containerCounter = entityPlayer.nextContainerCounter(); 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 = new AnvilContainer(entityPlayer.inventory, petTagPage.getInventory());
entityPlayer.activeContainer.windowId = containerCounter; entityPlayer.activeContainer.windowId = containerCounter;
entityPlayer.activeContainer.addSlotListener(entityPlayer); 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); 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.ConfirmationPage;
import mineplex.core.shop.page.ShopPageBase; import mineplex.core.shop.page.ShopPageBase;
import mineplex.playerCache.PlayerCache; import mineplex.playerCache.PlayerCache;
import net.minecraft.server.v1_7_R4.ItemStack; import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_7_R4.Items; import net.minecraft.server.v1_8_R3.Items;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -2,9 +2,11 @@ package mineplex.core.creature.command;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.World; 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.Ageable;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -110,7 +112,7 @@ public class MobCommand extends MultiCommandBase<Creature>
HashSet<Entity> entSet = new HashSet<Entity>(); HashSet<Entity> entSet = new HashSet<Entity>();
for (int i = 0 ; i < count ; i++) 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 //Search Vars

View File

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

View File

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

View File

@ -2,15 +2,13 @@ package mineplex.core.disguise.disguises;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import net.minecraft.server.v1_7_R4.EnumEntitySize; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.Vector3f;
public class DisguiseArmorStand extends DisguiseInsentient public class DisguiseArmorStand extends DisguiseInsentient
{ {
private Vector _headPosition = new Vector();
public DisguiseArmorStand(org.bukkit.entity.Entity entity) public DisguiseArmorStand(org.bukkit.entity.Entity entity)
{ {
super(entity); super(entity);
@ -19,15 +17,25 @@ public class DisguiseArmorStand extends DisguiseInsentient
for (int i = 11; i < 17; i++) 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 // 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() public Vector getHeadPosition()
{ {
return _headPosition.clone(); return convert(DataWatcher.h(11));
} }
protected String getHurtSound() protected String getHurtSound()
@ -41,9 +49,9 @@ public class DisguiseArmorStand extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId(); packet.a = Entity.getId();
packet.b = (byte) 30; 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.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.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 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) public void setBodyPosition(Vector vector)
{ {
DataWatcher.watch(12, vector); DataWatcher.watch(12, convert(vector));
} }
public void setHasArms() public void setHasArms()
@ -105,18 +113,17 @@ public class DisguiseArmorStand extends DisguiseInsentient
public void setHeadPosition(Vector vector) public void setHeadPosition(Vector vector)
{ {
_headPosition = vector; DataWatcher.watch(11, convert(vector));
DataWatcher.watch(11, vector);
} }
public void setLeftArmPosition(Vector vector) public void setLeftArmPosition(Vector vector)
{ {
DataWatcher.watch(13, vector); DataWatcher.watch(13, convert(vector));
} }
public void setLeftLegPosition(Vector vector) public void setLeftLegPosition(Vector vector)
{ {
DataWatcher.watch(15, vector); DataWatcher.watch(15, convert(vector));
} }
public void setRemoveBase() public void setRemoveBase()
@ -126,12 +133,12 @@ public class DisguiseArmorStand extends DisguiseInsentient
public void setRightArmPosition(Vector vector) public void setRightArmPosition(Vector vector)
{ {
DataWatcher.watch(14, vector); DataWatcher.watch(14, convert(vector));
} }
public void setRightLegPosition(Vector vector) public void setRightLegPosition(Vector vector)
{ {
DataWatcher.watch(16, vector); DataWatcher.watch(16, convert(vector));
} }
public void setSmall() public void setSmall()

View File

@ -1,14 +1,18 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import mineplex.core.common.*; import mineplex.core.common.*;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_7_R4.DataWatcher; import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_7_R4.Entity; import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; 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 public abstract class DisguiseBase
{ {
@ -53,6 +57,24 @@ public abstract class DisguiseBase
return new PacketPlayOutEntityMetadata(Entity.getId(), DataWatcher, true); 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) public void setSoundDisguise(DisguiseBase soundDisguise)
{ {
_soundDisguise = soundDisguise; _soundDisguise = soundDisguise;

View File

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

View File

@ -1,9 +1,8 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_7_R4.EnumEntitySize; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
import org.bukkit.entity.*; import org.bukkit.entity.*;
public abstract class DisguiseCreature extends DisguiseInsentient public abstract class DisguiseCreature extends DisguiseInsentient
@ -28,9 +27,9 @@ public abstract class DisguiseCreature extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId(); packet.a = Entity.getId();
packet.b = (byte) getDisguiseType().getTypeId(); packet.b = (byte) getDisguiseType().getTypeId();
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.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.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 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 java.util.Arrays;
import net.minecraft.server.v1_7_R4.MobEffect; import net.minecraft.server.v1_8_R3.MobEffect;
import net.minecraft.server.v1_7_R4.MobEffectList; import net.minecraft.server.v1_8_R3.MobEffectList;
import net.minecraft.server.v1_7_R4.PotionBrewer; import net.minecraft.server.v1_8_R3.PotionBrewer;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.spigotmc.ProtocolData;
public class DisguiseEnderman extends DisguiseMonster public class DisguiseEnderman extends DisguiseMonster
{ {
@ -15,9 +14,9 @@ public class DisguiseEnderman extends DisguiseMonster
{ {
super(EntityType.ENDERMAN, entity); super(EntityType.ENDERMAN, entity);
DataWatcher.a(16, new ProtocolData.ByteShort( (short) 0 ) ); DataWatcher.a(16, new Short( (short) 0));
DataWatcher.a(17, new Byte((byte)0)); DataWatcher.a(17, new Byte( (byte) 0));
DataWatcher.a(18, new Byte((byte)0)); DataWatcher.a(18, new Byte( (byte) 0));
int i = PotionBrewer.a(Arrays.asList(new MobEffect(MobEffectList.FIRE_RESISTANCE.id, 777))); 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))); 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(); super.UpdateDataWatcher();
DataWatcher.watch(0, Byte.valueOf((byte)(DataWatcher.getByte(0) & ~(1 << 0)))); 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) 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() public int GetCarriedId()

View File

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

View File

@ -1,15 +1,13 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import org.spigotmc.ProtocolData;
public abstract class DisguiseHuman extends DisguiseLiving public abstract class DisguiseHuman extends DisguiseLiving
{ {
public DisguiseHuman(org.bukkit.entity.Entity entity) public DisguiseHuman(org.bukkit.entity.Entity entity)
{ {
super(entity); super(entity);
DataWatcher.a(10, new ProtocolData.HiddenByte( (byte) 0 ) ); // Spigot - protocol patch, handle new metadata value DataWatcher.a(10, (byte) 0); // todo
DataWatcher.a(16, new ProtocolData.DualByte( (byte) 0, (byte) 0 ) ); DataWatcher.a(16, (byte) 0);
DataWatcher.a(17, Float.valueOf(0.0F)); DataWatcher.a(17, Float.valueOf(0.0F));
DataWatcher.a(18, Integer.valueOf(0)); 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(3, Byte.valueOf((byte) 0));
DataWatcher.a(2, ""); DataWatcher.a(2, "");
if (!(this instanceof DisguiseArmorStand))
{
DataWatcher.a(11, Byte.valueOf((byte) 0));
DataWatcher.a(10, "");
}
} }
public void setName(String name) public void setName(String name)
@ -36,19 +30,17 @@ public abstract class DisguiseInsentient extends DisguiseLiving
} }
} }
DataWatcher.watch(10, name);
DataWatcher.watch(2, name); DataWatcher.watch(2, name);
} }
public boolean hasCustomName() public boolean hasCustomName()
{ {
return DataWatcher.getString(10).length() > 0; return DataWatcher.getString(2).length() > 0;
} }
public void setCustomNameVisible(boolean visible) public void setCustomNameVisible(boolean visible)
{ {
DataWatcher.watch(11, Byte.valueOf((byte)(visible ? 1 : 0)));
DataWatcher.watch(3, 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 java.util.Random;
import org.bukkit.Material; 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 org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_7_R4.EntityLiving; import net.minecraft.server.v1_8_R3.EntityLiving;
import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
public abstract class DisguiseLiving extends DisguiseBase public abstract class DisguiseLiving extends DisguiseBase
{ {

View File

@ -1,9 +1,8 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_7_R4.EnumEntitySize; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
public class DisguiseMagmaCube extends DisguiseInsentient public class DisguiseMagmaCube extends DisguiseInsentient
{ {
@ -29,9 +28,9 @@ public class DisguiseMagmaCube extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId(); packet.a = Entity.getId();
packet.b = (byte) 62; 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.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.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F)); packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));

View File

@ -0,0 +1,16 @@
package mineplex.core.disguise.disguises;
import org.bukkit.entity.*;
public class DisguiseMooshroom extends DisguiseAnimal
{
public DisguiseMooshroom(org.bukkit.entity.Entity entity)
{
super(EntityType.MUSHROOM_COW, entity);
}
public String getHurtSound()
{
return "mob.cow.hurt";
}
}

View File

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

View File

@ -1,9 +1,8 @@
package mineplex.core.disguise.disguises; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_7_R4.EnumEntitySize; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
public class DisguiseRabbit extends DisguiseInsentient public class DisguiseRabbit extends DisguiseInsentient
{ {
@ -25,9 +24,9 @@ public class DisguiseRabbit extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId(); packet.a = Entity.getId();
packet.b = (byte) 101; 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.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.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 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; package mineplex.core.disguise.disguises;
import net.minecraft.server.v1_7_R4.EnumEntitySize; import net.minecraft.server.v1_8_R3.MathHelper;
import net.minecraft.server.v1_7_R4.MathHelper; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_7_R4.Packet; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
public class DisguiseSlime extends DisguiseInsentient public class DisguiseSlime extends DisguiseInsentient
{ {
@ -29,9 +28,9 @@ public class DisguiseSlime extends DisguiseInsentient
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId(); packet.a = Entity.getId();
packet.b = (byte) 55; 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.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.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F)); packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 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)); DataWatcher.a(20, new Integer(0));
} }
public int ca() public int getInvulTime()
{ {
return DataWatcher.getInt(20); return DataWatcher.getInt(20);
} }
public void s(int i) public void setInvulTime(int i)
{ {
DataWatcher.watch(20, Integer.valueOf(i)); DataWatcher.watch(20, Integer.valueOf(i));
} }

View File

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

View File

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

View File

@ -3,23 +3,28 @@ package mineplex.core.friend.ui;
import mineplex.core.command.CommandCenter; import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.friend.FriendManager; import mineplex.core.friend.FriendManager;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import net.minecraft.server.v1_7_R4.ContainerAnvil; import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_7_R4.EntityHuman; import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_7_R4.EntityPlayer; import net.minecraft.server.v1_8_R3.ChatMessage;
import net.minecraft.server.v1_7_R4.PacketPlayOutOpenWindow; 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.apache.commons.lang.StringUtils;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; 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.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
public class AddFriendPage implements Listener public class AddFriendPage implements Listener
@ -30,7 +35,7 @@ public class AddFriendPage implements Listener
public AnvilContainer(EntityHuman entity) 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 @Override
@ -47,10 +52,10 @@ public class AddFriendPage implements Listener
if (getSlot(2).hasItem()) 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)) if (StringUtils.isBlank(origString))
itemstack.t(); itemstack.r();
else else
{ {
itemstack.c(this.n); itemstack.c(this.n);
@ -92,6 +97,15 @@ public class AddFriendPage implements Listener
HandlerList.unregisterAll(this); HandlerList.unregisterAll(this);
} }
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
if (event.getPlayer() == _player)
{
unregisterListener();
}
}
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) public void onInventoryClick(InventoryClickEvent event)
{ {
@ -153,9 +167,9 @@ public class AddFriendPage implements Listener
AnvilContainer container = new AnvilContainer(p); AnvilContainer container = new AnvilContainer(p);
int c = p.nextContainerCounter(); 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 // Set their active container to the container
p.activeContainer = container; p.activeContainer = container;

View File

@ -8,8 +8,8 @@ import java.util.Iterator;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; 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.craftbukkit.v1_7_R4.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -18,9 +18,10 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; 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.command.CommandCenter;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
@ -130,7 +131,7 @@ public class FriendsGUI implements Listener
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name); builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name); // builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
@ -275,7 +276,7 @@ public class FriendsGUI implements Listener
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name); builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name); // builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
@ -573,6 +574,15 @@ public class FriendsGUI implements Listener
} }
} }
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
if (event.getPlayer() == _player)
{
unregisterListener();
}
}
@EventHandler @EventHandler
public void OnInventoryClose(InventoryCloseEvent event) public void OnInventoryClose(InventoryCloseEvent event)
{ {

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.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFallingSand; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFallingSand;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -8,7 +8,7 @@ import org.bukkit.Color;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.FireworkEffect.Type; 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.EnderPearl;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -45,7 +45,7 @@ public class ItemFleshHook extends ItemGadget implements IThrown
UtilAction.velocity(item, player.getLocation().getDirection(), UtilAction.velocity(item, player.getLocation().getDirection(),
1.6, false, 0, 0.2, 10, false); 1.6, false, 0, 0.2, 10, false);
Manager.getProjectileManager().AddThrow(item, player, this, -1, true, true, true, Manager.getProjectileManager().AddThrow(item, player, this, -1, true, true, true, true,
Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, null, 0, UpdateType.TICK, 0.5f); Sound.FIRE_IGNITE, 1.4f, 0.8f, ParticleType.CRIT, null, 0, UpdateType.TICK, 0.5f);
//Inform //Inform

View File

@ -4,7 +4,7 @@ import java.util.HashSet;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; 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.Bat;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;

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