diff --git a/Plugins/.idea/compiler.xml b/Plugins/.idea/compiler.xml index 6fce5b033..438bdb117 100644 --- a/Plugins/.idea/compiler.xml +++ b/Plugins/.idea/compiler.xml @@ -6,7 +6,6 @@ - diff --git a/Plugins/Classpath.Dummy/Classpath.Dummy.iml b/Plugins/Classpath.Dummy/Classpath.Dummy.iml index c576490ad..62272ae21 100644 --- a/Plugins/Classpath.Dummy/Classpath.Dummy.iml +++ b/Plugins/Classpath.Dummy/Classpath.Dummy.iml @@ -12,5 +12,4 @@ - - + \ No newline at end of file diff --git a/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/EntityTrackerEntry.java b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/EntityTrackerEntry.java new file mode 100644 index 000000000..8eab32db2 --- /dev/null +++ b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/EntityTrackerEntry.java @@ -0,0 +1,537 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package net.minecraft.server.v1_7_R4; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import net.minecraft.server.v1_7_R4.AttributeMapServer; +import net.minecraft.server.v1_7_R4.Block; +import net.minecraft.server.v1_7_R4.DataWatcher; +import net.minecraft.server.v1_7_R4.Entity; +import net.minecraft.server.v1_7_R4.EntityArrow; +import net.minecraft.server.v1_7_R4.EntityBoat; +import net.minecraft.server.v1_7_R4.EntityEgg; +import net.minecraft.server.v1_7_R4.EntityEnderCrystal; +import net.minecraft.server.v1_7_R4.EntityEnderDragon; +import net.minecraft.server.v1_7_R4.EntityEnderPearl; +import net.minecraft.server.v1_7_R4.EntityEnderSignal; +import net.minecraft.server.v1_7_R4.EntityExperienceOrb; +import net.minecraft.server.v1_7_R4.EntityFallingBlock; +import net.minecraft.server.v1_7_R4.EntityFireball; +import net.minecraft.server.v1_7_R4.EntityFireworks; +import net.minecraft.server.v1_7_R4.EntityFishingHook; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.server.v1_7_R4.EntityInsentient; +import net.minecraft.server.v1_7_R4.EntityItem; +import net.minecraft.server.v1_7_R4.EntityItemFrame; +import net.minecraft.server.v1_7_R4.EntityLeash; +import net.minecraft.server.v1_7_R4.EntityLiving; +import net.minecraft.server.v1_7_R4.EntityMinecartAbstract; +import net.minecraft.server.v1_7_R4.EntityPainting; +import net.minecraft.server.v1_7_R4.EntityPlayer; +import net.minecraft.server.v1_7_R4.EntityPotion; +import net.minecraft.server.v1_7_R4.EntitySmallFireball; +import net.minecraft.server.v1_7_R4.EntitySnowball; +import net.minecraft.server.v1_7_R4.EntityTNTPrimed; +import net.minecraft.server.v1_7_R4.EntityThrownExpBottle; +import net.minecraft.server.v1_7_R4.EntityWitherSkull; +import net.minecraft.server.v1_7_R4.IAnimal; +import net.minecraft.server.v1_7_R4.ItemStack; +import net.minecraft.server.v1_7_R4.ItemWorldMap; +import net.minecraft.server.v1_7_R4.Items; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.MobEffect; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutAttachEntity; +import net.minecraft.server.v1_7_R4.PacketPlayOutBed; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEffect; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityHeadRotation; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityLook; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityVelocity; +import net.minecraft.server.v1_7_R4.PacketPlayOutNamedEntitySpawn; +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.PacketPlayOutSpawnEntityExperienceOrb; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityPainting; +import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateAttributes; +import net.minecraft.server.v1_7_R4.WorldMap; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerVelocityEvent; +import org.bukkit.util.Vector; +import org.spigotmc.AsyncCatcher; + +public class EntityTrackerEntry { + private static final Logger p = LogManager.getLogger(); + public Entity tracker; + public int b; + public int c; + public int xLoc; + public int yLoc; + public int zLoc; + public int yRot; + public int xRot; + public int i; + public double j; + public double k; + public double l; + public int m; + private double q; + private double r; + private double s; + private boolean isMoving; + private boolean u; + private int v; + private Entity w; + private boolean x; + public boolean n; + public Set trackedPlayers = new HashSet(); + + public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) { + this.tracker = entity; + this.b = i; + this.c = j; + this.u = flag; + this.xLoc = MathHelper.floor(entity.locX * 32.0D); + this.yLoc = MathHelper.floor(entity.locY * 32.0D); + this.zLoc = MathHelper.floor(entity.locZ * 32.0D); + this.yRot = MathHelper.d(entity.yaw * 256.0F / 360.0F); + this.xRot = MathHelper.d(entity.pitch * 256.0F / 360.0F); + this.i = MathHelper.d(entity.getHeadRotation() * 256.0F / 360.0F); + } + + public boolean equals(Object object) { + return object instanceof EntityTrackerEntry?((EntityTrackerEntry)object).tracker.getId() == this.tracker.getId():false; + } + + public int hashCode() { + return this.tracker.getId(); + } + + public void track(List list) { + this.n = false; + if(!this.isMoving || this.tracker.e(this.q, this.r, this.s) > 16.0D) { + this.q = this.tracker.locX; + this.r = this.tracker.locY; + this.s = this.tracker.locZ; + this.isMoving = true; + this.n = true; + this.scanPlayers(list); + } + + if(this.w != this.tracker.vehicle || this.tracker.vehicle != null && this.m % 60 == 0) { + this.w = this.tracker.vehicle; + this.broadcast(new PacketPlayOutAttachEntity(0, this.tracker, this.tracker.vehicle)); + } + + if(this.tracker instanceof EntityItemFrame) { + EntityItemFrame cancelled = (EntityItemFrame)this.tracker; + ItemStack player = cancelled.getItem(); + if(this.m % 10 == 0 && player != null && player.getItem() instanceof ItemWorldMap) { + WorldMap velocity = Items.MAP.getSavedMap(player, this.tracker.world); + Iterator event = this.trackedPlayers.iterator(); + + while(event.hasNext()) { + EntityHuman i1 = (EntityHuman)event.next(); + EntityPlayer j1 = (EntityPlayer)i1; + velocity.a(j1, player); + Packet k1 = Items.MAP.c(player, this.tracker.world, j1); + if(k1 != null) { + j1.playerConnection.sendPacket(k1); + } + } + } + + this.b(); + } else if(this.m % this.c == 0 || this.tracker.al || this.tracker.getDataWatcher().a()) { + int var23; + int var24; + if(this.tracker.vehicle == null) { + ++this.v; + var23 = this.tracker.as.a(this.tracker.locX); + var24 = MathHelper.floor(this.tracker.locY * 32.0D); + int var28 = this.tracker.as.a(this.tracker.locZ); + int var30 = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F); + int var32 = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F); + int var33 = var23 - this.xLoc; + int var34 = var24 - this.yLoc; + int l1 = var28 - this.zLoc; + Object object = null; + boolean flag = Math.abs(var33) >= 4 || Math.abs(var34) >= 4 || Math.abs(l1) >= 4 || this.m % 60 == 0; + boolean flag1 = Math.abs(var30 - this.yRot) >= 4 || Math.abs(var32 - this.xRot) >= 4; + if(flag) { + this.xLoc = var23; + this.yLoc = var24; + this.zLoc = var28; + } + + if(flag1) { + this.yRot = var30; + this.xRot = var32; + } + + if(this.m > 0 || this.tracker instanceof EntityArrow) { + if(var33 >= -128 && var33 < 128 && var34 >= -128 && var34 < 128 && l1 >= -128 && l1 < 128 && this.v <= 400 && !this.x) { + if(flag && flag1) { + object = new PacketPlayOutRelEntityMoveLook(this.tracker.getId(), (byte)var33, (byte)var34, (byte)l1, (byte)var30, (byte)var32, this.tracker.onGround); + } else if(flag) { + object = new PacketPlayOutRelEntityMove(this.tracker.getId(), (byte)var33, (byte)var34, (byte)l1, this.tracker.onGround); + } else if(flag1) { + object = new PacketPlayOutEntityLook(this.tracker.getId(), (byte)var30, (byte)var32, this.tracker.onGround); + } + } else { + this.v = 0; + if(this.tracker instanceof EntityPlayer) { + this.scanPlayers(new ArrayList(this.trackedPlayers)); + } + + object = new PacketPlayOutEntityTeleport(this.tracker.getId(), var23, var24, var28, (byte)var30, (byte)var32, this.tracker.onGround); + } + } + + if(this.u) { + double d0 = this.tracker.motX - this.j; + double d1 = this.tracker.motY - this.k; + double d2 = this.tracker.motZ - this.l; + double d3 = 0.02D; + double d4 = d0 * d0 + d1 * d1 + d2 * d2; + if(d4 > d3 * d3 || d4 > 0.0D && this.tracker.motX == 0.0D && this.tracker.motY == 0.0D && this.tracker.motZ == 0.0D) { + this.j = this.tracker.motX; + this.k = this.tracker.motY; + this.l = this.tracker.motZ; + this.broadcast(new PacketPlayOutEntityVelocity(this.tracker.getId(), this.j, this.k, this.l)); + } + } + + if(object != null) { + this.broadcast((Packet)object); + } + + this.b(); + this.x = false; + } else { + var23 = MathHelper.d(this.tracker.yaw * 256.0F / 360.0F); + var24 = MathHelper.d(this.tracker.pitch * 256.0F / 360.0F); + boolean var27 = Math.abs(var23 - this.yRot) >= 4 || Math.abs(var24 - this.xRot) >= 4; + if(var27) { + this.broadcast(new PacketPlayOutEntityLook(this.tracker.getId(), (byte)var23, (byte)var24, this.tracker.onGround)); + this.yRot = var23; + this.xRot = var24; + } + + this.xLoc = this.tracker.as.a(this.tracker.locX); + this.yLoc = MathHelper.floor(this.tracker.locY * 32.0D); + this.zLoc = this.tracker.as.a(this.tracker.locZ); + this.b(); + this.x = true; + } + + var23 = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F); + if(Math.abs(var23 - this.i) >= 4) { + this.broadcast(new PacketPlayOutEntityHeadRotation(this.tracker, (byte)var23)); + this.i = var23; + } + + this.tracker.al = false; + } + + ++this.m; + if(this.tracker.velocityChanged) { + boolean var25 = false; + if(this.tracker instanceof EntityPlayer) { + Player var26 = (Player)this.tracker.getBukkitEntity(); + Vector var29 = var26.getVelocity(); + PlayerVelocityEvent var31 = new PlayerVelocityEvent(var26, var29); + this.tracker.world.getServer().getPluginManager().callEvent(var31); + if(var31.isCancelled()) { + var25 = true; + } else if(!var29.equals(var31.getVelocity())) { + var26.setVelocity(var29); + } + } + + if(!var25) { + this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker)); + } + + this.tracker.velocityChanged = false; + } + + } + + private void b() { + DataWatcher datawatcher = this.tracker.getDataWatcher(); + if(datawatcher.a()) { + this.broadcastIncludingSelf(new PacketPlayOutEntityMetadata(this.tracker.getId(), datawatcher, false)); + } + + if(this.tracker instanceof EntityLiving) { + AttributeMapServer attributemapserver = (AttributeMapServer)((EntityLiving)this.tracker).getAttributeMap(); + Set set = attributemapserver.getAttributes(); + if(!set.isEmpty()) { + if(this.tracker instanceof EntityPlayer) { + ((EntityPlayer)this.tracker).getBukkitEntity().injectScaledMaxHealth(set, false); + } + + this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set)); + } + + set.clear(); + } + + } + + public void broadcast(Packet packet) { + Iterator iterator = this.trackedPlayers.iterator(); + + while(iterator.hasNext()) { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + entityplayer.playerConnection.sendPacket(packet); + } + + } + + public void broadcastIncludingSelf(Packet packet) { + this.broadcast(packet); + if(this.tracker instanceof EntityPlayer) { + ((EntityPlayer)this.tracker).playerConnection.sendPacket(packet); + } + + } + + public void a() { + Iterator iterator = this.trackedPlayers.iterator(); + + while(iterator.hasNext()) { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + entityplayer.d(this.tracker); + } + + } + + public void a(EntityPlayer entityplayer) { + if(this.trackedPlayers.contains(entityplayer)) { + entityplayer.d(this.tracker); + this.trackedPlayers.remove(entityplayer); + } + + } + + public void updatePlayer(EntityPlayer entityplayer) { + AsyncCatcher.catchOp("player tracker update"); + if(entityplayer != this.tracker) { + double d0 = entityplayer.locX - (double)(this.xLoc / 32); + double d1 = entityplayer.locZ - (double)(this.zLoc / 32); + if(d0 >= (double)(-this.b) && d0 <= (double)this.b && d1 >= (double)(-this.b) && d1 <= (double)this.b) { + if(!this.trackedPlayers.contains(entityplayer) && (this.d(entityplayer) || this.tracker.attachedToPlayer)) { + if(this.tracker instanceof EntityPlayer) { + CraftPlayer packet = ((EntityPlayer)this.tracker).getBukkitEntity(); + if(!entityplayer.getBukkitEntity().canSee(packet)) { + return; + } + } + + entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId())); + this.trackedPlayers.add(entityplayer); + Packet var10 = this.c(); + if(this.tracker instanceof EntityPlayer) { + entityplayer.playerConnection.sendPacket(PacketPlayOutPlayerInfo.addPlayer(entityplayer, (EntityPlayer)this.tracker)); + } + + entityplayer.playerConnection.sendPacket(var10); + if(!this.tracker.getDataWatcher().d()) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(this.tracker.getId(), this.tracker.getDataWatcher(), true)); + } + + if(this.tracker instanceof EntityLiving) { + AttributeMapServer entityliving = (AttributeMapServer)((EntityLiving)this.tracker).getAttributeMap(); + Collection iterator = entityliving.c(); + if(this.tracker.getId() == entityplayer.getId()) { + ((EntityPlayer)this.tracker).getBukkitEntity().injectScaledMaxHealth(iterator, false); + } + + if(!iterator.isEmpty()) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(this.tracker.getId(), iterator)); + } + } + + this.j = this.tracker.motX; + this.k = this.tracker.motY; + this.l = this.tracker.motZ; + if(this.u && !(var10 instanceof PacketPlayOutSpawnEntityLiving)) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityVelocity(this.tracker.getId(), this.tracker.motX, this.tracker.motY, this.tracker.motZ)); + } + + if(this.tracker.vehicle != null) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutAttachEntity(0, this.tracker, this.tracker.vehicle)); + } + + if(this.tracker.passenger != null) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutAttachEntity(0, this.tracker.passenger, this.tracker)); + } + + if(this.tracker instanceof EntityInsentient && ((EntityInsentient)this.tracker).getLeashHolder() != null) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutAttachEntity(1, this.tracker, ((EntityInsentient)this.tracker).getLeashHolder())); + } + + if(this.tracker instanceof EntityLiving) { + for(int var11 = 0; var11 < 5; ++var11) { + ItemStack var13 = ((EntityLiving)this.tracker).getEquipment(var11); + if(var13 != null) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEquipment(this.tracker.getId(), var11, var13)); + } + } + } + + if(this.tracker instanceof EntityHuman) { + EntityHuman var12 = (EntityHuman)this.tracker; + if(var12.isSleeping()) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutBed(var12, MathHelper.floor(this.tracker.locX), MathHelper.floor(this.tracker.locY), MathHelper.floor(this.tracker.locZ))); + } + } + + this.i = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F); + this.broadcast(new PacketPlayOutEntityHeadRotation(this.tracker, (byte)this.i)); + if(this.tracker instanceof EntityLiving) { + EntityLiving var14 = (EntityLiving)this.tracker; + Iterator var15 = var14.getEffects().iterator(); + + while(var15.hasNext()) { + MobEffect mobeffect = (MobEffect)var15.next(); + entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(this.tracker.getId(), mobeffect)); + } + } + } + } else if(this.trackedPlayers.contains(entityplayer)) { + this.trackedPlayers.remove(entityplayer); + entityplayer.d(this.tracker); + } + } + + } + + private boolean d(EntityPlayer entityplayer) { + return entityplayer.r().getPlayerChunkMap().a(entityplayer, this.tracker.ah, this.tracker.aj); + } + + public void scanPlayers(List list) { + for(int i = 0; i < list.size(); ++i) { + this.updatePlayer((EntityPlayer)list.get(i)); + } + + } + + private Packet c() { + if(this.tracker.dead) { + return null; + } else if(this.tracker instanceof EntityItem) { + return new PacketPlayOutSpawnEntity(this.tracker, 2, 1); + } else if(this.tracker instanceof EntityPlayer) { + return new PacketPlayOutNamedEntitySpawn((EntityHuman)this.tracker); + } else if(this.tracker instanceof EntityMinecartAbstract) { + EntityMinecartAbstract packetplayoutspawnentity3 = (EntityMinecartAbstract)this.tracker; + return new PacketPlayOutSpawnEntity(this.tracker, 10, packetplayoutspawnentity3.m()); + } else if(this.tracker instanceof EntityBoat) { + return new PacketPlayOutSpawnEntity(this.tracker, 1); + } else if(!(this.tracker instanceof IAnimal) && !(this.tracker instanceof EntityEnderDragon)) { + if(this.tracker instanceof EntityFishingHook) { + EntityHuman packetplayoutspawnentity2 = ((EntityFishingHook)this.tracker).owner; + return new PacketPlayOutSpawnEntity(this.tracker, 90, packetplayoutspawnentity2 != null?packetplayoutspawnentity2.getId():this.tracker.getId()); + } else if(this.tracker instanceof EntityArrow) { + Entity packetplayoutspawnentity1 = ((EntityArrow)this.tracker).shooter; + return new PacketPlayOutSpawnEntity(this.tracker, 60, packetplayoutspawnentity1 != null?packetplayoutspawnentity1.getId():this.tracker.getId()); + } else if(this.tracker instanceof EntitySnowball) { + return new PacketPlayOutSpawnEntity(this.tracker, 61); + } else if(this.tracker instanceof EntityPotion) { + return new PacketPlayOutSpawnEntity(this.tracker, 73, ((EntityPotion)this.tracker).getPotionValue()); + } else if(this.tracker instanceof EntityThrownExpBottle) { + return new PacketPlayOutSpawnEntity(this.tracker, 75); + } else if(this.tracker instanceof EntityEnderPearl) { + return new PacketPlayOutSpawnEntity(this.tracker, 65); + } else if(this.tracker instanceof EntityEnderSignal) { + return new PacketPlayOutSpawnEntity(this.tracker, 72); + } else if(this.tracker instanceof EntityFireworks) { + return new PacketPlayOutSpawnEntity(this.tracker, 76); + } else { + PacketPlayOutSpawnEntity packetplayoutspawnentity; + if(this.tracker instanceof EntityFireball) { + EntityFireball entityleash3 = (EntityFireball)this.tracker; + packetplayoutspawnentity = null; + byte b0 = 63; + if(this.tracker instanceof EntitySmallFireball) { + b0 = 64; + } else if(this.tracker instanceof EntityWitherSkull) { + b0 = 66; + } + + if(entityleash3.shooter != null) { + packetplayoutspawnentity = new PacketPlayOutSpawnEntity(this.tracker, b0, ((EntityFireball)this.tracker).shooter.getId()); + } else { + packetplayoutspawnentity = new PacketPlayOutSpawnEntity(this.tracker, b0, 0); + } + + packetplayoutspawnentity.d((int)(entityleash3.dirX * 8000.0D)); + packetplayoutspawnentity.e((int)(entityleash3.dirY * 8000.0D)); + packetplayoutspawnentity.f((int)(entityleash3.dirZ * 8000.0D)); + return packetplayoutspawnentity; + } else if(this.tracker instanceof EntityEgg) { + return new PacketPlayOutSpawnEntity(this.tracker, 62); + } else if(this.tracker instanceof EntityTNTPrimed) { + return new PacketPlayOutSpawnEntity(this.tracker, 50); + } else if(this.tracker instanceof EntityEnderCrystal) { + return new PacketPlayOutSpawnEntity(this.tracker, 51); + } else if(this.tracker instanceof EntityFallingBlock) { + EntityFallingBlock entityleash2 = (EntityFallingBlock)this.tracker; + return new PacketPlayOutSpawnEntity(this.tracker, 70, Block.getId(entityleash2.f()) | entityleash2.data << 16); + } else if(this.tracker instanceof EntityPainting) { + return new PacketPlayOutSpawnEntityPainting((EntityPainting)this.tracker); + } else if(this.tracker instanceof EntityItemFrame) { + EntityItemFrame entityleash1 = (EntityItemFrame)this.tracker; + packetplayoutspawnentity = new PacketPlayOutSpawnEntity(this.tracker, 71, entityleash1.direction); + packetplayoutspawnentity.a(MathHelper.d((float)(entityleash1.x * 32))); + packetplayoutspawnentity.b(MathHelper.d((float)(entityleash1.y * 32))); + packetplayoutspawnentity.c(MathHelper.d((float)(entityleash1.z * 32))); + return packetplayoutspawnentity; + } else if(this.tracker instanceof EntityLeash) { + EntityLeash entityleash = (EntityLeash)this.tracker; + packetplayoutspawnentity = new PacketPlayOutSpawnEntity(this.tracker, 77); + packetplayoutspawnentity.a(MathHelper.d((float)(entityleash.x * 32))); + packetplayoutspawnentity.b(MathHelper.d((float)(entityleash.y * 32))); + packetplayoutspawnentity.c(MathHelper.d((float)(entityleash.z * 32))); + return packetplayoutspawnentity; + } else if(this.tracker instanceof EntityExperienceOrb) { + return new PacketPlayOutSpawnEntityExperienceOrb((EntityExperienceOrb)this.tracker); + } else { + throw new IllegalArgumentException("Don\'t know how to add " + this.tracker.getClass() + "!"); + } + } + } else { + this.i = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F); + return new PacketPlayOutSpawnEntityLiving((EntityLiving)this.tracker); + } + } + + public void clear(EntityPlayer entityplayer) { + AsyncCatcher.catchOp("player tracker clear"); + if(this.trackedPlayers.contains(entityplayer)) { + this.trackedPlayers.remove(entityplayer); + entityplayer.d(this.tracker); + } + + } +} diff --git a/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutPlayerInfo.java b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutPlayerInfo.java index 0073d28e3..494e17435 100644 --- a/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutPlayerInfo.java +++ b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PacketPlayOutPlayerInfo.java @@ -11,6 +11,7 @@ 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.entity.Player; import org.bukkit.scoreboard.Team; import net.minecraft.util.com.mojang.authlib.GameProfile; import net.minecraft.util.com.mojang.authlib.properties.Property; @@ -37,6 +38,18 @@ public class PacketPlayOutPlayerInfo extends Packet { public PacketPlayOutPlayerInfo() { } + public static PacketPlayOutPlayerInfo addPlayer(EntityPlayer sendTo, 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(sendTo, player); + return packet; + } + public static PacketPlayOutPlayerInfo addPlayer(EntityPlayer player) { PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(); packet.action = 0; @@ -67,8 +80,9 @@ public class PacketPlayOutPlayerInfo extends Packet { return packet; } - public static PacketPlayOutPlayerInfo updateDisplayName(EntityPlayer player) { - return updateDisplayName(player, getFormattedName(player)); + public static PacketPlayOutPlayerInfo updateDisplayName(EntityPlayer sendPacketTo, EntityPlayer player) + { + return updateDisplayName(player, getFormattedName(sendPacketTo, player)); } public static PacketPlayOutPlayerInfo updateDisplayName(EntityPlayer player, String displayName) @@ -177,7 +191,7 @@ public class PacketPlayOutPlayerInfo extends Packet { } public void handle(PacketListener packetlistener) { - this.a((PacketPlayOutListener)((PacketPlayOutListener)packetlistener)); + this.a((PacketPlayOutListener) ((PacketPlayOutListener) packetlistener)); } private static String getFormattedName(EntityPlayer player) @@ -197,6 +211,23 @@ public class PacketPlayOutPlayerInfo extends Packet { return name; } + private static String getFormattedName(EntityPlayer sendPacketTo, EntityPlayer player) + { + String name = player.getName(); + + if (isAprilFools()) name = "Notch"; + + CraftScoreboard scoreboard = sendPacketTo.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(); diff --git a/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PlayerList.java b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PlayerList.java new file mode 100644 index 000000000..e4da8080d --- /dev/null +++ b/Plugins/Classpath.Dummy/src/net/minecraft/server/v1_7_R4/PlayerList.java @@ -0,0 +1,1074 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package net.minecraft.server.v1_7_R4; + +import java.io.File; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.Map.Entry; +import java.util.concurrent.CopyOnWriteArrayList; +import net.minecraft.server.v1_7_R4.ChunkCoordinates; +import net.minecraft.server.v1_7_R4.Entity; +import net.minecraft.server.v1_7_R4.EntityHuman; +import net.minecraft.server.v1_7_R4.EntityPlayer; +import net.minecraft.server.v1_7_R4.EntityTypes; +import net.minecraft.server.v1_7_R4.EnumGamemode; +import net.minecraft.server.v1_7_R4.GameProfileBanEntry; +import net.minecraft.server.v1_7_R4.GameProfileBanList; +import net.minecraft.server.v1_7_R4.IChatBaseComponent; +import net.minecraft.server.v1_7_R4.IPlayerFileData; +import net.minecraft.server.v1_7_R4.IpBanEntry; +import net.minecraft.server.v1_7_R4.IpBanList; +import net.minecraft.server.v1_7_R4.LoginListener; +import net.minecraft.server.v1_7_R4.MathHelper; +import net.minecraft.server.v1_7_R4.MinecraftServer; +import net.minecraft.server.v1_7_R4.MobEffect; +import net.minecraft.server.v1_7_R4.NBTTagCompound; +import net.minecraft.server.v1_7_R4.NetworkManager; +import net.minecraft.server.v1_7_R4.OpList; +import net.minecraft.server.v1_7_R4.OpListEntry; +import net.minecraft.server.v1_7_R4.Packet; +import net.minecraft.server.v1_7_R4.PacketPlayOutAbilities; +import net.minecraft.server.v1_7_R4.PacketPlayOutChat; +import net.minecraft.server.v1_7_R4.PacketPlayOutCustomPayload; +import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEffect; +import net.minecraft.server.v1_7_R4.PacketPlayOutExperience; +import net.minecraft.server.v1_7_R4.PacketPlayOutGameStateChange; +import net.minecraft.server.v1_7_R4.PacketPlayOutHeldItemSlot; +import net.minecraft.server.v1_7_R4.PacketPlayOutLogin; +import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo; +import net.minecraft.server.v1_7_R4.PacketPlayOutRespawn; +import net.minecraft.server.v1_7_R4.PacketPlayOutScoreboardTeam; +import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnPosition; +import net.minecraft.server.v1_7_R4.PacketPlayOutUpdateTime; +import net.minecraft.server.v1_7_R4.PlayerChunkMap; +import net.minecraft.server.v1_7_R4.PlayerConnection; +import net.minecraft.server.v1_7_R4.PlayerDistanceComparator; +import net.minecraft.server.v1_7_R4.PlayerInteractManager; +import net.minecraft.server.v1_7_R4.Scoreboard; +import net.minecraft.server.v1_7_R4.ScoreboardObjective; +import net.minecraft.server.v1_7_R4.ScoreboardScore; +import net.minecraft.server.v1_7_R4.ScoreboardServer; +import net.minecraft.server.v1_7_R4.ScoreboardTeam; +import net.minecraft.server.v1_7_R4.ScoreboardTeamBase; +import net.minecraft.server.v1_7_R4.ServerStatisticManager; +import net.minecraft.server.v1_7_R4.StatisticList; +import net.minecraft.server.v1_7_R4.UserCache; +import net.minecraft.server.v1_7_R4.WhiteList; +import net.minecraft.server.v1_7_R4.WhiteListEntry; +import net.minecraft.server.v1_7_R4.WorldServer; +import net.minecraft.util.com.google.common.base.Charsets; +import net.minecraft.util.com.google.common.collect.Lists; +import net.minecraft.util.com.google.common.collect.Maps; +import net.minecraft.util.com.mojang.authlib.GameProfile; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.TravelAgent; +import org.bukkit.WeatherType; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_7_R4.CraftServer; +import org.bukkit.craftbukkit.v1_7_R4.CraftTravelAgent; +import org.bukkit.craftbukkit.v1_7_R4.CraftWorld; +import org.bukkit.craftbukkit.v1_7_R4.chunkio.ChunkIOExecutor; +import org.bukkit.craftbukkit.v1_7_R4.command.ColouredConsoleSender; +import org.bukkit.craftbukkit.v1_7_R4.command.ConsoleCommandCompleter; +import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; +import org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerLoginEvent; +import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerLoginEvent.Result; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; +import org.bukkit.util.Vector; +import org.spigotmc.SpigotConfig; +import org.spigotmc.event.player.PlayerSpawnLocationEvent; + +public abstract class PlayerList { + public static final File a = new File("banned-players.json"); + public static final File b = new File("banned-ips.json"); + public static final File c = new File("ops.json"); + public static final File d = new File("whitelist.json"); + private static final Logger g = LogManager.getLogger(); + private static final SimpleDateFormat h = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z"); + private final MinecraftServer server; + public final List players = new CopyOnWriteArrayList(); + private final GameProfileBanList j; + private final IpBanList k; + private final OpList operators; + private final WhiteList whitelist; + private final Map n; + public IPlayerFileData playerFileData; + public boolean hasWhitelist; + protected int maxPlayers; + private int q; + private EnumGamemode r; + private boolean s; + private int t; + private CraftServer cserver; + private int currentPing = 0; + + public PlayerList(MinecraftServer minecraftserver) { + minecraftserver.server = new CraftServer(minecraftserver, this); + minecraftserver.console = ColouredConsoleSender.getInstance(); + minecraftserver.reader.addCompleter(new ConsoleCommandCompleter(minecraftserver.server)); + this.cserver = minecraftserver.server; + this.j = new GameProfileBanList(a); + this.k = new IpBanList(b); + this.operators = new OpList(c); + this.whitelist = new WhiteList(d); + this.n = Maps.newHashMap(); + this.server = minecraftserver; + this.j.a(false); + this.k.a(false); + this.maxPlayers = 8; + } + + public void a(NetworkManager networkmanager, EntityPlayer entityplayer) { + GameProfile gameprofile = entityplayer.getProfile(); + UserCache usercache = this.server.getUserCache(); + GameProfile gameprofile1 = usercache.a(gameprofile.getId()); + if(gameprofile1 == null) { + gameprofile.getName(); + } else { + gameprofile1.getName(); + } + + usercache.a(gameprofile); + NBTTagCompound nbttagcompound = this.a(entityplayer); + entityplayer.spawnIn(this.server.getWorldServer(entityplayer.dimension)); + entityplayer.playerInteractManager.a((WorldServer)entityplayer.world); + String s1 = "local"; + if(networkmanager.getSocketAddress() != null) { + s1 = networkmanager.getSocketAddress().toString(); + } + + CraftPlayer bukkitPlayer = entityplayer.getBukkitEntity(); + PlayerSpawnLocationEvent ev = new PlayerSpawnLocationEvent(bukkitPlayer, bukkitPlayer.getLocation()); + Bukkit.getPluginManager().callEvent(ev); + Location loc = ev.getSpawnLocation(); + WorldServer world = ((CraftWorld)loc.getWorld()).getHandle(); + entityplayer.spawnIn(world); + entityplayer.setPosition(loc.getX(), loc.getY(), loc.getZ()); + entityplayer.b(loc.getYaw(), loc.getPitch()); + WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); + ChunkCoordinates chunkcoordinates = worldserver.getSpawn(); + this.a(entityplayer, (EntityPlayer)null, worldserver); + PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer); + int maxPlayers = this.getMaxPlayers(); + if(maxPlayers > 60) { + maxPlayers = 60; + } + + playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worldserver.getWorldData().isHardcore(), worldserver.worldProvider.dimension, worldserver.difficulty, maxPlayers, worldserver.getWorldData().getType())); + entityplayer.getBukkitEntity().sendSupportedChannels(); + playerconnection.sendPacket(new PacketPlayOutCustomPayload("MC|Brand", this.getServer().getServerModName().getBytes(Charsets.UTF_8))); + playerconnection.sendPacket(new PacketPlayOutSpawnPosition(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z)); + playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities)); + playerconnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); + entityplayer.getStatisticManager().d(); + entityplayer.getStatisticManager().updateStatistics(entityplayer); + this.sendScoreboard((ScoreboardServer)worldserver.getScoreboard(), entityplayer); + this.server.az(); + this.c(entityplayer); + worldserver = this.server.getWorldServer(entityplayer.dimension); + playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch); + this.b(entityplayer, worldserver); + if(this.server.getResourcePack().length() > 0) { + entityplayer.setResourcePack(this.server.getResourcePack()); + } + + Iterator iterator = entityplayer.getEffects().iterator(); + + while(iterator.hasNext()) { + MobEffect entity = (MobEffect)iterator.next(); + playerconnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), entity)); + } + + entityplayer.syncInventory(); + if(nbttagcompound != null && nbttagcompound.hasKeyOfType("Riding", 10)) { + Entity entity1 = EntityTypes.a(nbttagcompound.getCompound("Riding"), worldserver); + if(entity1 != null) { + entity1.attachedToPlayer = true; + worldserver.addEntity(entity1); + entityplayer.mount(entity1); + entity1.attachedToPlayer = false; + } + } + + g.info(entityplayer.getName() + "[" + s1 + "] logged in with entity id " + entityplayer.getId() + " at ([" + entityplayer.world.worldData.getName() + "] " + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")"); + } + + public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { + HashSet hashset = new HashSet(); + Iterator iterator = scoreboardserver.getTeams().iterator(); + + while(iterator.hasNext()) { + ScoreboardTeam i = (ScoreboardTeam)iterator.next(); + entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardTeam(i, 0)); + } + + for(int var10 = 0; var10 < 3; ++var10) { + ScoreboardObjective scoreboardobjective = scoreboardserver.getObjectiveForSlot(var10); + if(scoreboardobjective != null && !hashset.contains(scoreboardobjective)) { + List list = scoreboardserver.getScoreboardScorePacketsForObjective(scoreboardobjective); + Iterator iterator1 = list.iterator(); + + while(iterator1.hasNext()) { + Packet packet = (Packet)iterator1.next(); + entityplayer.playerConnection.sendPacket(packet); + } + + hashset.add(scoreboardobjective); + } + } + + } + + public void setPlayerFileData(WorldServer[] aworldserver) { + if(this.playerFileData == null) { + this.playerFileData = aworldserver[0].getDataManager().getPlayerFileData(); + } + } + + public void a(EntityPlayer entityplayer, WorldServer worldserver) { + WorldServer worldserver1 = entityplayer.r(); + if(worldserver != null) { + worldserver.getPlayerChunkMap().removePlayer(entityplayer); + } + + worldserver1.getPlayerChunkMap().addPlayer(entityplayer); + worldserver1.chunkProviderServer.getChunkAt((int)entityplayer.locX >> 4, (int)entityplayer.locZ >> 4); + } + + public int d() { + return PlayerChunkMap.getFurthestViewableBlock(this.s()); + } + + public NBTTagCompound a(EntityPlayer entityplayer) { + NBTTagCompound nbttagcompound = ((WorldServer)this.server.worlds.get(0)).getWorldData().i(); + NBTTagCompound nbttagcompound1; + if(entityplayer.getName().equals(this.server.M()) && nbttagcompound != null) { + entityplayer.f(nbttagcompound); + nbttagcompound1 = nbttagcompound; + g.debug("loading single player"); + } else { + nbttagcompound1 = this.playerFileData.load(entityplayer); + } + + return nbttagcompound1; + } + + protected void b(EntityPlayer entityplayer) { + this.playerFileData.save(entityplayer); + ServerStatisticManager serverstatisticmanager = (ServerStatisticManager)this.n.get(entityplayer.getUniqueID()); + if(serverstatisticmanager != null) { + serverstatisticmanager.b(); + } + + } + + public void c(EntityPlayer entityplayer) { + this.cserver.detectListNameConflict(entityplayer); + this.players.add(entityplayer); + WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); + PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(this.cserver.getPlayer(entityplayer), "§e" + entityplayer.getName() + " joined the game."); + this.cserver.getPluginManager().callEvent(playerJoinEvent); + String joinMessage = playerJoinEvent.getJoinMessage(); + int i; + if(joinMessage != null && joinMessage.length() > 0) { + IChatBaseComponent[] packet = CraftChatMessage.fromString(joinMessage); + i = packet.length; + + for(int entityplayer1 = 0; entityplayer1 < i; ++entityplayer1) { + IChatBaseComponent line = packet[entityplayer1]; + this.server.getPlayerList().sendAll(new PacketPlayOutChat(line)); + } + } + + this.cserver.onPlayerJoin(playerJoinEvent.getPlayer()); + ChunkIOExecutor.adjustPoolSize(this.getPlayerCount()); + if(entityplayer.world == worldserver && !worldserver.players.contains(entityplayer)) { + worldserver.addEntity(entityplayer); + this.a(entityplayer, (WorldServer)null); + } + + EntityPlayer var10; + for(i = 0; i < this.players.size(); ++i) { + var10 = (EntityPlayer)this.players.get(i); + if(var10.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { + PacketPlayOutPlayerInfo var9 = PacketPlayOutPlayerInfo.addPlayer(var10, entityplayer); + var10.playerConnection.sendPacket(var9); + } + } + + for(i = 0; i < this.players.size(); ++i) { + var10 = (EntityPlayer)this.players.get(i); + if(entityplayer.getBukkitEntity().canSee(var10.getBukkitEntity())) { + entityplayer.playerConnection.sendPacket(PacketPlayOutPlayerInfo.addPlayer(entityplayer, var10)); + } + } + + } + + public void d(EntityPlayer entityplayer) { + entityplayer.r().getPlayerChunkMap().movePlayer(entityplayer); + } + + public String disconnect(EntityPlayer entityplayer) { + entityplayer.a(StatisticList.f); + CraftEventFactory.handleInventoryCloseEvent(entityplayer); + PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(this.cserver.getPlayer(entityplayer), "§e" + entityplayer.getName() + " left the game."); + this.cserver.getPluginManager().callEvent(playerQuitEvent); + entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); + this.b(entityplayer); + WorldServer worldserver = entityplayer.r(); + if(entityplayer.vehicle != null && !(entityplayer.vehicle instanceof EntityPlayer)) { + worldserver.removeEntity(entityplayer.vehicle); + g.debug("removing player mount"); + } + + worldserver.kill(entityplayer); + worldserver.getPlayerChunkMap().removePlayer(entityplayer); + this.players.remove(entityplayer); + this.n.remove(entityplayer.getUniqueID()); + ChunkIOExecutor.adjustPoolSize(this.getPlayerCount()); + PacketPlayOutPlayerInfo packet = PacketPlayOutPlayerInfo.removePlayer(entityplayer); + + for(int i = 0; i < this.players.size(); ++i) { + EntityPlayer entityplayer1 = (EntityPlayer)this.players.get(i); + if(entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) { + entityplayer1.playerConnection.sendPacket(packet); + } else { + entityplayer1.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity()); + } + } + + this.cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity()); + return playerQuitEvent.getQuitMessage(); + } + + public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) { + SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress(); + EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(0), gameprofile, new PlayerInteractManager(this.server.getWorldServer(0))); + CraftPlayer player = entity.getBukkitEntity(); + PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((InetSocketAddress)socketaddress).getAddress(), ((InetSocketAddress)loginlistener.networkManager.getRawAddress()).getAddress()); + String s; + if(this.j.isBanned(gameprofile) && !this.j.get(gameprofile).hasExpired()) { + GameProfileBanEntry ipbanentry1 = (GameProfileBanEntry)this.j.get(gameprofile); + s = "You are banned from this server!\nReason: " + ipbanentry1.getReason(); + if(ipbanentry1.getExpires() != null) { + s = s + "\nYour ban will be removed on " + h.format(ipbanentry1.getExpires()); + } + + if(!ipbanentry1.hasExpired()) { + event.disallow(Result.KICK_BANNED, s); + } + } else if(!this.isWhitelisted(gameprofile)) { + event.disallow(Result.KICK_WHITELIST, SpigotConfig.whitelistMessage); + } else if(this.k.isBanned(socketaddress) && !this.k.get(socketaddress).hasExpired()) { + IpBanEntry ipbanentry = this.k.get(socketaddress); + s = "Your IP address is banned from this server!\nReason: " + ipbanentry.getReason(); + if(ipbanentry.getExpires() != null) { + s = s + "\nYour ban will be removed on " + h.format(ipbanentry.getExpires()); + } + + event.disallow(Result.KICK_BANNED, s); + } else if(this.players.size() >= this.maxPlayers) { + event.disallow(Result.KICK_FULL, SpigotConfig.serverFullMessage); + } + + this.cserver.getPluginManager().callEvent(event); + if(event.getResult() != Result.ALLOWED) { + loginlistener.disconnect(event.getKickMessage()); + return null; + } else { + return entity; + } + } + + public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { + UUID uuid = EntityHuman.a(gameprofile); + ArrayList arraylist = Lists.newArrayList(); + + EntityPlayer entityplayer; + for(int iterator = 0; iterator < this.players.size(); ++iterator) { + entityplayer = (EntityPlayer)this.players.get(iterator); + if(entityplayer.getUniqueID().equals(uuid)) { + arraylist.add(entityplayer); + } + } + + Iterator var7 = arraylist.iterator(); + + while(var7.hasNext()) { + entityplayer = (EntityPlayer)var7.next(); + entityplayer.playerConnection.disconnect("You logged in from another location"); + } + + return player; + } + + public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag) { + return this.moveToWorld(entityplayer, i, flag, (Location)null, true); + } + + public EntityPlayer moveToWorld(EntityPlayer entityplayer, int i, boolean flag, Location location, boolean avoidSuffocation) { + entityplayer.r().getTracker().untrackPlayer(entityplayer); + entityplayer.r().getPlayerChunkMap().removePlayer(entityplayer); + this.players.remove(entityplayer); + this.server.getWorldServer(entityplayer.dimension).removeEntity(entityplayer); + ChunkCoordinates chunkcoordinates = entityplayer.getBed(); + boolean flag1 = entityplayer.isRespawnForced(); + EntityPlayer entityplayer1 = entityplayer; + World fromWorld = entityplayer.getBukkitEntity().getWorld(); + entityplayer.viewingCredits = false; + entityplayer.playerConnection = entityplayer.playerConnection; + entityplayer.copyTo(entityplayer, flag); + entityplayer.d(entityplayer.getId()); + ChunkCoordinates chunkcoordinates1; + if(location == null) { + boolean worldserver = false; + CraftWorld actualDimension = (CraftWorld)this.server.server.getWorld(entityplayer.spawnWorld); + if(actualDimension != null && chunkcoordinates != null) { + chunkcoordinates1 = EntityHuman.getBed(actualDimension.getHandle(), chunkcoordinates, flag1); + if(chunkcoordinates1 != null) { + worldserver = true; + location = new Location(actualDimension, (double)chunkcoordinates1.x + 0.5D, (double)chunkcoordinates1.y, (double)chunkcoordinates1.z + 0.5D); + } else { + entityplayer.setRespawnPosition((ChunkCoordinates)null, true); + entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0.0F)); + } + } + + if(location == null) { + actualDimension = (CraftWorld)this.server.server.getWorlds().get(0); + chunkcoordinates = actualDimension.getHandle().getSpawn(); + location = new Location(actualDimension, (double)chunkcoordinates.x + 0.5D, (double)chunkcoordinates.y, (double)chunkcoordinates.z + 0.5D); + } + + Player iterator = this.cserver.getPlayer(entityplayer); + PlayerRespawnEvent event = new PlayerRespawnEvent(iterator, location, worldserver); + this.cserver.getPluginManager().callEvent(event); + if(entityplayer.playerConnection.isDisconnected()) { + return entityplayer; + } + + location = event.getRespawnLocation(); + entityplayer.reset(); + } else { + location.setWorld(this.server.getWorldServer(i).getWorld()); + } + + WorldServer worldserver1 = ((CraftWorld)location.getWorld()).getHandle(); + entityplayer.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); + worldserver1.chunkProviderServer.getChunkAt((int)entityplayer.locX >> 4, (int)entityplayer.locZ >> 4); + + while(avoidSuffocation && !worldserver1.getCubes(entityplayer1, entityplayer1.boundingBox).isEmpty()) { + entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ); + } + + byte actualDimension1 = (byte)worldserver1.getWorld().getEnvironment().getId(); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn((byte)(actualDimension1 >= 0?-1:0), worldserver1.difficulty, worldserver1.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode())); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(actualDimension1, worldserver1.difficulty, worldserver1.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode())); + entityplayer1.spawnIn(worldserver1); + entityplayer1.dead = false; + entityplayer1.playerConnection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch)); + entityplayer1.setSneaking(false); + chunkcoordinates1 = worldserver1.getSpawn(); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(chunkcoordinates1.x, chunkcoordinates1.y, chunkcoordinates1.z)); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel)); + this.b(entityplayer1, worldserver1); + if(!entityplayer.playerConnection.isDisconnected()) { + worldserver1.getPlayerChunkMap().addPlayer(entityplayer1); + worldserver1.addEntity(entityplayer1); + this.players.add(entityplayer1); + } + + this.updateClient(entityplayer1); + entityplayer1.updateAbilities(); + Iterator iterator1 = entityplayer1.getEffects().iterator(); + + while(iterator1.hasNext()) { + MobEffect event1 = (MobEffect)iterator1.next(); + entityplayer1.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer1.getId(), event1)); + } + + entityplayer1.setHealth(entityplayer1.getHealth()); + if(fromWorld != location.getWorld()) { + PlayerChangedWorldEvent event2 = new PlayerChangedWorldEvent(entityplayer1.getBukkitEntity(), fromWorld); + Bukkit.getServer().getPluginManager().callEvent(event2); + } + + if(entityplayer.playerConnection.isDisconnected()) { + this.b(entityplayer1); + } + + return entityplayer1; + } + + public void changeDimension(EntityPlayer entityplayer, int i, TeleportCause cause) { + WorldServer exitWorld = null; + if(entityplayer.dimension < 10) { + Iterator enter = this.server.worlds.iterator(); + + while(enter.hasNext()) { + WorldServer exit = (WorldServer)enter.next(); + if(exit.dimension == i) { + exitWorld = exit; + } + } + } + + Location enter1 = entityplayer.getBukkitEntity().getLocation(); + Location exit1 = null; + boolean useTravelAgent = false; + if(exitWorld != null) { + if(cause == TeleportCause.END_PORTAL && i == 0) { + exit1 = entityplayer.getBukkitEntity().getBedSpawnLocation(); + if(exit1 == null || ((CraftWorld)exit1.getWorld()).getHandle().dimension != 0) { + exit1 = exitWorld.getWorld().getSpawnLocation(); + } + } else { + exit1 = this.calculateTarget(enter1, exitWorld); + useTravelAgent = true; + } + } + + TravelAgent agent = exit1 != null?(TravelAgent)((CraftWorld)exit1.getWorld()).getHandle().getTravelAgent():CraftTravelAgent.DEFAULT; + PlayerPortalEvent event = new PlayerPortalEvent(entityplayer.getBukkitEntity(), enter1, exit1, agent, cause); + event.useTravelAgent(useTravelAgent); + Bukkit.getServer().getPluginManager().callEvent(event); + if(!event.isCancelled() && event.getTo() != null) { + exit1 = event.useTravelAgent()?event.getPortalTravelAgent().findOrCreate(event.getTo()):event.getTo(); + if(exit1 != null) { + exitWorld = ((CraftWorld)exit1.getWorld()).getHandle(); + Vector velocity = entityplayer.getBukkitEntity().getVelocity(); + boolean before = exitWorld.chunkProviderServer.forceChunkLoad; + exitWorld.chunkProviderServer.forceChunkLoad = true; + exitWorld.getTravelAgent().adjustExit(entityplayer, exit1, velocity); + exitWorld.chunkProviderServer.forceChunkLoad = before; + this.moveToWorld(entityplayer, exitWorld.dimension, true, exit1, false); + if(entityplayer.motX != velocity.getX() || entityplayer.motY != velocity.getY() || entityplayer.motZ != velocity.getZ()) { + entityplayer.getBukkitEntity().setVelocity(velocity); + } + + } + } + } + + public void a(Entity entity, int i, WorldServer worldserver, WorldServer worldserver1) { + Location exit = this.calculateTarget(entity.getBukkitEntity().getLocation(), worldserver1); + this.repositionEntity(entity, exit, true); + } + + public Location calculateTarget(Location enter, net.minecraft.server.v1_7_R4.World target) { + WorldServer worldserver = ((CraftWorld)enter.getWorld()).getHandle(); + WorldServer worldserver1 = target.getWorld().getHandle(); + int i = worldserver.dimension; + double y = enter.getY(); + float yaw = enter.getYaw(); + float pitch = enter.getPitch(); + double d0 = enter.getX(); + double d1 = enter.getZ(); + double d2 = 8.0D; + if(worldserver1.dimension == -1) { + d0 /= d2; + d1 /= d2; + } else if(worldserver1.dimension == 0) { + d0 *= d2; + d1 *= d2; + } else { + ChunkCoordinates chunkcoordinates; + if(i == 1) { + worldserver1 = (WorldServer)this.server.worlds.get(0); + chunkcoordinates = worldserver1.getSpawn(); + } else { + chunkcoordinates = worldserver1.getDimensionSpawn(); + } + + d0 = (double)chunkcoordinates.x; + y = (double)chunkcoordinates.y; + d1 = (double)chunkcoordinates.z; + yaw = 90.0F; + pitch = 0.0F; + } + + if(i != 1) { + d0 = (double)MathHelper.a((int)d0, -29999872, 29999872); + d1 = (double)MathHelper.a((int)d1, -29999872, 29999872); + } + + return new Location(worldserver1.getWorld(), d0, y, d1, yaw, pitch); + } + + public void repositionEntity(Entity entity, Location exit, boolean portal) { + int i = entity.dimension; + WorldServer worldserver = (WorldServer)entity.world; + WorldServer worldserver1 = ((CraftWorld)exit.getWorld()).getHandle(); + worldserver.methodProfiler.a("moving"); + entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); + if(entity.isAlive()) { + worldserver.entityJoinedWorld(entity, false); + } + + worldserver.methodProfiler.b(); + if(i != 1) { + worldserver.methodProfiler.a("placing"); + if(entity.isAlive()) { + if(portal) { + Vector velocity = entity.getBukkitEntity().getVelocity(); + worldserver1.getTravelAgent().adjustExit(entity, exit, velocity); + entity.setPositionRotation(exit.getX(), exit.getY(), exit.getZ(), exit.getYaw(), exit.getPitch()); + if(entity.motX != velocity.getX() || entity.motY != velocity.getY() || entity.motZ != velocity.getZ()) { + entity.getBukkitEntity().setVelocity(velocity); + } + } + + worldserver1.addEntity(entity); + worldserver1.entityJoinedWorld(entity, false); + } + + worldserver.methodProfiler.b(); + } + + entity.spawnIn(worldserver1); + } + + public void tick() { + if(++this.t > 600) { + this.t = 0; + } + + try { + if(!this.players.isEmpty()) { + this.currentPing = (this.currentPing + 1) % this.players.size(); + EntityPlayer e = (EntityPlayer)this.players.get(this.currentPing); + if(e.lastPing == -1 || Math.abs(e.ping - e.lastPing) > 20) { + PacketPlayOutPlayerInfo packet = PacketPlayOutPlayerInfo.updatePing(e); + Iterator var3 = this.players.iterator(); + + while(var3.hasNext()) { + EntityPlayer splayer = (EntityPlayer)var3.next(); + if(splayer.getBukkitEntity().canSee(e.getBukkitEntity())) { + splayer.playerConnection.sendPacket(packet); + } + } + + e.lastPing = e.ping; + } + } + } catch (Exception var5) { + ; + } + + } + + public void sendAll(Packet packet) { + for(int i = 0; i < this.players.size(); ++i) { + ((EntityPlayer)this.players.get(i)).playerConnection.sendPacket(packet); + } + + } + + public void a(Packet packet, int i) { + for(int j = 0; j < this.players.size(); ++j) { + EntityPlayer entityplayer = (EntityPlayer)this.players.get(j); + if(entityplayer.dimension == i) { + entityplayer.playerConnection.sendPacket(packet); + } + } + + } + + public String b(boolean flag) { + String s = ""; + ArrayList arraylist = Lists.newArrayList(this.players); + + for(int i = 0; i < arraylist.size(); ++i) { + if(i > 0) { + s = s + ", "; + } + + s = s + ((EntityPlayer)arraylist.get(i)).getName(); + if(flag) { + s = s + " (" + ((EntityPlayer)arraylist.get(i)).getUniqueID().toString() + ")"; + } + } + + return s; + } + + public String[] f() { + String[] astring = new String[this.players.size()]; + + for(int i = 0; i < this.players.size(); ++i) { + astring[i] = ((EntityPlayer)this.players.get(i)).getName(); + } + + return astring; + } + + public GameProfile[] g() { + GameProfile[] agameprofile = new GameProfile[this.players.size()]; + + for(int i = 0; i < this.players.size(); ++i) { + agameprofile[i] = ((EntityPlayer)this.players.get(i)).getProfile(); + } + + return agameprofile; + } + + public GameProfileBanList getProfileBans() { + return this.j; + } + + public IpBanList getIPBans() { + return this.k; + } + + public void addOp(GameProfile gameprofile) { + this.operators.add(new OpListEntry(gameprofile, this.server.l())); + Player player = this.server.server.getPlayer(gameprofile.getId()); + if(player != null) { + player.recalculatePermissions(); + } + + } + + public void removeOp(GameProfile gameprofile) { + this.operators.remove(gameprofile); + Player player = this.server.server.getPlayer(gameprofile.getId()); + if(player != null) { + player.recalculatePermissions(); + } + + } + + public boolean isWhitelisted(GameProfile gameprofile) { + return !this.hasWhitelist || this.operators.d(gameprofile) || this.whitelist.d(gameprofile); + } + + public boolean isOp(GameProfile gameprofile) { + return this.operators.d(gameprofile) || this.server.N() && ((WorldServer)this.server.worlds.get(0)).getWorldData().allowCommands() && this.server.M().equalsIgnoreCase(gameprofile.getName()) || this.s; + } + + public EntityPlayer getPlayer(String s) { + Iterator iterator = this.players.iterator(); + + while(iterator.hasNext()) { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + if(entityplayer.getName().equalsIgnoreCase(s)) { + return entityplayer; + } + } + + return null; + } + + public List a(ChunkCoordinates chunkcoordinates, int i, int j, int k, int l, int i1, int j1, Map map, String s, String s1, net.minecraft.server.v1_7_R4.World world) { + if(this.players.isEmpty()) { + return Collections.emptyList(); + } else { + Object object = new ArrayList(); + boolean flag = k < 0; + boolean flag1 = s != null && s.startsWith("!"); + boolean flag2 = s1 != null && s1.startsWith("!"); + int k1 = i * i; + int l1 = j * j; + k = MathHelper.a(k); + if(flag1) { + s = s.substring(1); + } + + if(flag2) { + s1 = s1.substring(1); + } + + for(int i2 = 0; i2 < this.players.size(); ++i2) { + EntityPlayer entityplayer = (EntityPlayer)this.players.get(i2); + if((world == null || entityplayer.world == world) && (s == null || flag1 != s.equalsIgnoreCase(entityplayer.getName()))) { + if(s1 != null) { + ScoreboardTeamBase f = entityplayer.getScoreboardTeam(); + String s2 = f == null?"":f.getName(); + if(flag2 == s1.equalsIgnoreCase(s2)) { + continue; + } + } + + if(chunkcoordinates != null && (i > 0 || j > 0)) { + float var22 = chunkcoordinates.e(entityplayer.getChunkCoordinates()); + if(i > 0 && var22 < (float)k1 || j > 0 && var22 > (float)l1) { + continue; + } + } + + if(this.a((EntityHuman)entityplayer, (Map)map) && (l == EnumGamemode.NONE.getId() || l == entityplayer.playerInteractManager.getGameMode().getId()) && (i1 <= 0 || entityplayer.expLevel >= i1) && entityplayer.expLevel <= j1) { + ((List)object).add(entityplayer); + } + } + } + + if(chunkcoordinates != null) { + Collections.sort((List)object, new PlayerDistanceComparator(chunkcoordinates)); + } + + if(flag) { + Collections.reverse((List)object); + } + + if(k > 0) { + object = ((List)object).subList(0, Math.min(k, ((List)object).size())); + } + + return (List)object; + } + } + + private boolean a(EntityHuman entityhuman, Map map) { + if(map != null && map.size() != 0) { + Iterator iterator = map.entrySet().iterator(); + + Entry entry; + boolean flag; + int i; + do { + if(!iterator.hasNext()) { + return true; + } + + entry = (Entry)iterator.next(); + String s = (String)entry.getKey(); + flag = false; + if(s.endsWith("_min") && s.length() > 4) { + flag = true; + s = s.substring(0, s.length() - 4); + } + + Scoreboard scoreboard = entityhuman.getScoreboard(); + ScoreboardObjective scoreboardobjective = scoreboard.getObjective(s); + if(scoreboardobjective == null) { + return false; + } + + ScoreboardScore scoreboardscore = entityhuman.getScoreboard().getPlayerScoreForObjective(entityhuman.getName(), scoreboardobjective); + i = scoreboardscore.getScore(); + if(i < ((Integer)entry.getValue()).intValue() && flag) { + return false; + } + } while(i <= ((Integer)entry.getValue()).intValue() || flag); + + return false; + } else { + return true; + } + } + + public void sendPacketNearby(double d0, double d1, double d2, double d3, int i, Packet packet) { + this.sendPacketNearby((EntityHuman)null, d0, d1, d2, d3, i, packet); + } + + public void sendPacketNearby(EntityHuman entityhuman, double d0, double d1, double d2, double d3, int i, Packet packet) { + for(int j = 0; j < this.players.size(); ++j) { + EntityPlayer entityplayer = (EntityPlayer)this.players.get(j); + if((entityhuman == null || !(entityhuman instanceof EntityPlayer) || entityplayer.getBukkitEntity().canSee(((EntityPlayer)entityhuman).getBukkitEntity())) && entityplayer != entityhuman && entityplayer.dimension == i) { + double d4 = d0 - entityplayer.locX; + double d5 = d1 - entityplayer.locY; + double d6 = d2 - entityplayer.locZ; + if(d4 * d4 + d5 * d5 + d6 * d6 < d3 * d3) { + entityplayer.playerConnection.sendPacket(packet); + } + } + } + + } + + public void savePlayers() { + for(int i = 0; i < this.players.size(); ++i) { + this.b((EntityPlayer)this.players.get(i)); + } + + } + + public void addWhitelist(GameProfile gameprofile) { + this.whitelist.add(new WhiteListEntry(gameprofile)); + } + + public void removeWhitelist(GameProfile gameprofile) { + this.whitelist.remove(gameprofile); + } + + public WhiteList getWhitelist() { + return this.whitelist; + } + + public String[] getWhitelisted() { + return this.whitelist.getEntries(); + } + + public OpList getOPs() { + return this.operators; + } + + public String[] n() { + return this.operators.getEntries(); + } + + public void reloadWhitelist() { + } + + public void b(EntityPlayer entityplayer, WorldServer worldserver) { + entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean("doDaylightCycle"))); + if(worldserver.Q()) { + entityplayer.setPlayerWeather(WeatherType.DOWNFALL, false); + } + + } + + public void updateClient(EntityPlayer entityplayer) { + entityplayer.updateInventory(entityplayer.defaultContainer); + entityplayer.getBukkitEntity().updateScaledHealth(); + entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex)); + } + + public int getPlayerCount() { + return this.players.size(); + } + + public int getMaxPlayers() { + return this.maxPlayers; + } + + public String[] getSeenPlayers() { + return ((WorldServer)this.server.worlds.get(0)).getDataManager().getPlayerFileData().getSeenPlayers(); + } + + public boolean getHasWhitelist() { + return this.hasWhitelist; + } + + public void setHasWhitelist(boolean flag) { + this.hasWhitelist = flag; + } + + public List b(String s) { + ArrayList arraylist = new ArrayList(); + Iterator iterator = this.players.iterator(); + + while(iterator.hasNext()) { + EntityPlayer entityplayer = (EntityPlayer)iterator.next(); + if(entityplayer.s().equals(s)) { + arraylist.add(entityplayer); + } + } + + return arraylist; + } + + public int s() { + return this.q; + } + + public MinecraftServer getServer() { + return this.server; + } + + public NBTTagCompound t() { + return null; + } + + private void a(EntityPlayer entityplayer, EntityPlayer entityplayer1, net.minecraft.server.v1_7_R4.World world) { + if(entityplayer1 != null) { + entityplayer.playerInteractManager.setGameMode(entityplayer1.playerInteractManager.getGameMode()); + } else if(this.r != null) { + entityplayer.playerInteractManager.setGameMode(this.r); + } + + entityplayer.playerInteractManager.b(world.getWorldData().getGameType()); + } + + public void u() { + while(!this.players.isEmpty()) { + EntityPlayer p = (EntityPlayer)this.players.get(0); + p.playerConnection.disconnect(this.server.server.getShutdownMessage()); + if(!this.players.isEmpty() && this.players.get(0) == p) { + this.players.remove(0); + } + } + + } + + public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { + IChatBaseComponent[] var2 = ichatbasecomponent; + int var3 = ichatbasecomponent.length; + + for(int var4 = 0; var4 < var3; ++var4) { + IChatBaseComponent component = var2[var4]; + this.sendMessage(component, true); + } + + } + + public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) { + this.server.sendMessage(ichatbasecomponent); + this.sendAll(new PacketPlayOutChat(ichatbasecomponent, flag)); + } + + public void sendMessage(IChatBaseComponent ichatbasecomponent) { + this.sendMessage(ichatbasecomponent, true); + } + + public ServerStatisticManager a(EntityHuman entityhuman) { + UUID uuid = entityhuman.getUniqueID(); + ServerStatisticManager serverstatisticmanager = uuid == null?null:(ServerStatisticManager)this.n.get(uuid); + if(serverstatisticmanager == null) { + File file1 = new File(this.server.getWorldServer(0).getDataManager().getDirectory(), "stats"); + File file2 = new File(file1, uuid.toString() + ".json"); + if(!file2.exists()) { + File file3 = new File(file1, entityhuman.getName() + ".json"); + if(file3.exists() && file3.isFile()) { + file3.renameTo(file2); + } + } + + serverstatisticmanager = new ServerStatisticManager(this.server, file2); + serverstatisticmanager.a(); + this.n.put(uuid, serverstatisticmanager); + } + + return serverstatisticmanager; + } + + public void a(int i) { + this.q = i; + if(this.server.worldServer != null) { + WorldServer[] aworldserver = this.server.worldServer; + int j = aworldserver.length; + + for(int k = 0; k < j; ++k) { + WorldServer worldserver = aworldserver[k]; + if(worldserver != null) { + worldserver.getPlayerChunkMap().a(i); + } + } + } + + } +} diff --git a/Plugins/Classpath.Dummy/src/net/minecraft/util/com/mojang/authlib/yggdrasil/ProfileCache.java b/Plugins/Classpath.Dummy/src/net/minecraft/util/com/mojang/authlib/yggdrasil/ProfileCache.java new file mode 100644 index 000000000..dfd8bd2e7 --- /dev/null +++ b/Plugins/Classpath.Dummy/src/net/minecraft/util/com/mojang/authlib/yggdrasil/ProfileCache.java @@ -0,0 +1,13 @@ +package net.minecraft.util.com.mojang.authlib.yggdrasil; + +import java.util.UUID; + +import net.minecraft.util.com.mojang.authlib.GameProfile; + +public interface ProfileCache +{ + public GameProfile attemptToLoadProfile(String playerName); + + public void cacheProfile(GameProfile response); + +} diff --git a/Plugins/Classpath.Dummy/src/net/minecraft/util/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java b/Plugins/Classpath.Dummy/src/net/minecraft/util/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java new file mode 100644 index 000000000..f54d71064 --- /dev/null +++ b/Plugins/Classpath.Dummy/src/net/minecraft/util/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java @@ -0,0 +1,145 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package net.minecraft.util.com.mojang.authlib.yggdrasil; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; +import net.minecraft.util.com.google.common.base.Strings; +import net.minecraft.util.com.google.common.collect.Iterables; +import net.minecraft.util.com.google.common.collect.Sets; +import net.minecraft.util.com.mojang.authlib.Agent; +import net.minecraft.util.com.mojang.authlib.GameProfile; +import net.minecraft.util.com.mojang.authlib.GameProfileRepository; +import net.minecraft.util.com.mojang.authlib.HttpAuthenticationService; +import net.minecraft.util.com.mojang.authlib.ProfileLookupCallback; +import net.minecraft.util.com.mojang.authlib.exceptions.AuthenticationException; +import net.minecraft.util.com.mojang.authlib.yggdrasil.ProfileNotFoundException; +import net.minecraft.util.com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; +import net.minecraft.util.com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class YggdrasilGameProfileRepository implements GameProfileRepository { + private static final Logger LOGGER = LogManager.getLogger(); + private static final String BASE_URL = "https://api.mojang.com/"; + private static final String SEARCH_PAGE_URL = "https://api.mojang.com/profiles/"; + private static final int ENTRIES_PER_PAGE = 2; + private static final int MAX_FAIL_COUNT = 3; + private static final int DELAY_BETWEEN_PAGES = 100; + private static final int DELAY_BETWEEN_FAILURES = 750; + private final YggdrasilAuthenticationService authenticationService; + + private static ProfileCache _profileCache; + + public YggdrasilGameProfileRepository(YggdrasilAuthenticationService authenticationService) { + this.authenticationService = authenticationService; + } + + public static void setProfileCache(ProfileCache profileCache) + { + _profileCache = profileCache; + } + + public void findProfilesByNames(String[] names, Agent agent, ProfileLookupCallback callback) { + HashSet criteria = Sets.newHashSet(); + String[] page = names; + int i$ = names.length; + + for(int request = 0; request < i$; ++request) { + String failCount = page[request]; + if(!Strings.isNullOrEmpty(failCount)) { + criteria.add(failCount.toLowerCase()); + } + } + + if (_profileCache != null) + { + // Attempt to load profiles from cache + Iterator iterator = criteria.iterator(); + while (iterator.hasNext()) + { + String name = iterator.next(); +// System.out.println("Trying to load profile from cache (GameProfileRepository): " + name); + GameProfile profile = _profileCache.attemptToLoadProfile(name); + if (profile != null) + { +// System.out.println("Successfully loaded profile: " + name); + iterator.remove(); + callback.onProfileLookupSucceeded(profile); + } + } + } + + byte var19 = 0; + Iterator var20 = Iterables.partition(criteria, 2).iterator(); + + while(var20.hasNext()) { + List var21 = (List)var20.next(); + int var22 = 0; + + while(true) { + boolean failed = false; + + try { + ProfileSearchResultsResponse var23 = (ProfileSearchResultsResponse)this.authenticationService.makeRequest(HttpAuthenticationService.constantURL("https://api.mojang.com/profiles/" + agent.getName().toLowerCase()), var21, ProfileSearchResultsResponse.class); + var22 = 0; + LOGGER.debug("Page {} returned {} results, parsing", new Object[]{Integer.valueOf(var19), Integer.valueOf(var23.getProfiles().length)}); + HashSet var24 = Sets.newHashSet(var21); + GameProfile[] var25 = var23.getProfiles(); + int name1 = var25.length; + + for(int i$1 = 0; i$1 < name1; ++i$1) { + GameProfile profile = var25[i$1]; + LOGGER.debug("Successfully looked up profile {}", new Object[]{profile}); + var24.remove(profile.getName().toLowerCase()); + callback.onProfileLookupSucceeded(profile); + } + + Iterator var26 = var24.iterator(); + + while(var26.hasNext()) { + String var27 = (String)var26.next(); + LOGGER.debug("Couldn\'t find profile {}", new Object[]{var27}); + callback.onProfileLookupFailed(new GameProfile((UUID)null, var27), new ProfileNotFoundException("Server did not find the requested profile")); + } + + try { + Thread.sleep(100L); + } catch (InterruptedException var17) { + ; + } + } catch (AuthenticationException var18) { + AuthenticationException e = var18; + ++var22; + if(var22 == 3) { + Iterator ignored = var21.iterator(); + + while(ignored.hasNext()) { + String name = (String)ignored.next(); + LOGGER.debug("Couldn\'t find profile {} because of a server error", new Object[]{name}); + callback.onProfileLookupFailed(new GameProfile((UUID)null, name), e); + } + } else { + try { + Thread.sleep(750L); + } catch (InterruptedException var16) { + ; + } + + failed = true; + } + } + + if(!failed) { + break; + } + } + } + + } +} diff --git a/Plugins/Classpath.Dummy/src/net/minecraft/util/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java b/Plugins/Classpath.Dummy/src/net/minecraft/util/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java new file mode 100644 index 000000000..756060251 --- /dev/null +++ b/Plugins/Classpath.Dummy/src/net/minecraft/util/com/mojang/authlib/yggdrasil/YggdrasilMinecraftSessionService.java @@ -0,0 +1,178 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + +package net.minecraft.util.com.mojang.authlib.yggdrasil; + +import java.net.URL; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.spec.X509EncodedKeySpec; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import net.minecraft.util.com.google.common.collect.Iterables; +import net.minecraft.util.com.google.gson.Gson; +import net.minecraft.util.com.google.gson.GsonBuilder; +import net.minecraft.util.com.google.gson.JsonParseException; +import net.minecraft.util.com.mojang.authlib.GameProfile; +import net.minecraft.util.com.mojang.authlib.HttpAuthenticationService; +import net.minecraft.util.com.mojang.authlib.exceptions.AuthenticationException; +import net.minecraft.util.com.mojang.authlib.exceptions.AuthenticationUnavailableException; +import net.minecraft.util.com.mojang.authlib.minecraft.HttpMinecraftSessionService; +import net.minecraft.util.com.mojang.authlib.minecraft.InsecureTextureException; +import net.minecraft.util.com.mojang.authlib.minecraft.MinecraftProfileTexture; +import net.minecraft.util.com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; +import net.minecraft.util.com.mojang.authlib.properties.Property; +import net.minecraft.util.com.mojang.authlib.yggdrasil.request.JoinMinecraftServerRequest; +import net.minecraft.util.com.mojang.authlib.yggdrasil.response.HasJoinedMinecraftServerResponse; +import net.minecraft.util.com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse; +import net.minecraft.util.com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload; +import net.minecraft.util.com.mojang.authlib.yggdrasil.response.Response; +import net.minecraft.util.com.mojang.util.UUIDTypeAdapter; +import net.minecraft.util.org.apache.commons.codec.Charsets; +import net.minecraft.util.org.apache.commons.codec.binary.Base64; +import net.minecraft.util.org.apache.commons.io.IOUtils; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class YggdrasilMinecraftSessionService extends HttpMinecraftSessionService { + private static final Logger LOGGER = LogManager.getLogger(); + private static final String BASE_URL = "https://sessionserver.mojang.com/session/minecraft/"; + private static final URL JOIN_URL = HttpAuthenticationService.constantURL("https://sessionserver.mojang.com/session/minecraft/join"); + private static final URL CHECK_URL = HttpAuthenticationService.constantURL("https://sessionserver.mojang.com/session/minecraft/hasJoined"); + private final PublicKey publicKey; + private final Gson gson = (new GsonBuilder()).registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); + + private static ProfileCache _profileCache; + + public static void setProfileCache(ProfileCache cacher) + { + _profileCache = cacher; + } + + protected YggdrasilMinecraftSessionService(YggdrasilAuthenticationService authenticationService) { + super(authenticationService); + + try { + X509EncodedKeySpec e = new X509EncodedKeySpec(IOUtils.toByteArray(YggdrasilMinecraftSessionService.class.getResourceAsStream("/yggdrasil_session_pubkey.der"))); + KeyFactory keyFactory = KeyFactory.getInstance("RSA"); + this.publicKey = keyFactory.generatePublic(e); + } catch (Exception var4) { + throw new Error("Missing/invalid yggdrasil public key!"); + } + } + + public void joinServer(GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException { + JoinMinecraftServerRequest request = new JoinMinecraftServerRequest(); + request.accessToken = authenticationToken; + request.selectedProfile = profile.getId(); + request.serverId = serverId; + this.getAuthenticationService().makeRequest(JOIN_URL, request, Response.class); + } + + public GameProfile hasJoinedServer(GameProfile user, String serverId) throws AuthenticationUnavailableException { + HashMap arguments = new HashMap(); + arguments.put("username", user.getName()); + arguments.put("serverId", serverId); + URL url = HttpAuthenticationService.concatenateURL(CHECK_URL, HttpAuthenticationService.buildQuery(arguments)); + + try { + HasJoinedMinecraftServerResponse e = (HasJoinedMinecraftServerResponse)this.getAuthenticationService().makeRequest(url, (Object)null, HasJoinedMinecraftServerResponse.class); + if(e != null && e.getId() != null) { + GameProfile result = new GameProfile(e.getId(), user.getName()); + if(e.getProperties() != null) { + result.getProperties().putAll(e.getProperties()); + } + + return result; + } else { + return null; + } + } catch (AuthenticationUnavailableException var7) { + throw var7; + } catch (AuthenticationException var8) { + return null; + } + } + + public Map getTextures(GameProfile profile, boolean requireSecure) { + Property textureProperty = (Property)Iterables.getFirst(profile.getProperties().get("textures"), (Object)null); + if(textureProperty == null) { + return new HashMap(); + } else { + if(requireSecure) { + if(!textureProperty.hasSignature()) { + LOGGER.error("Signature is missing from textures payload"); + throw new InsecureTextureException("Signature is missing from textures payload"); + } + + if(!textureProperty.isSignatureValid(this.publicKey)) { + LOGGER.error("Textures payload has been tampered with (signature invalid)"); + throw new InsecureTextureException("Textures payload has been tampered with (signature invalid)"); + } + } + + MinecraftTexturesPayload result; + try { + String e = new String(Base64.decodeBase64(textureProperty.getValue()), Charsets.UTF_8); + result = (MinecraftTexturesPayload)this.gson.fromJson(e, MinecraftTexturesPayload.class); + } catch (JsonParseException var6) { + LOGGER.error("Could not decode textures payload", var6); + return new HashMap(); + } + + return (Map)(result.getTextures() == null?new HashMap():result.getTextures()); + } + } + + public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) { + if(profile.getId() == null) { + return profile; + } else { + try { + if (requireSecure && _profileCache != null) + { + GameProfile repoProfile = _profileCache.attemptToLoadProfile(profile.getName()); + if (repoProfile != null) + { + profile.getProperties().putAll(repoProfile.getProperties()); + return repoProfile; + } + } + + URL e = HttpAuthenticationService.constantURL("https://sessionserver.mojang.com/session/minecraft/profile/" + UUIDTypeAdapter.fromUUID(profile.getId())); + e = HttpAuthenticationService.concatenateURL(e, "unsigned=" + !requireSecure); + MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) this.getAuthenticationService().makeRequest(e, (Object) null, MinecraftProfilePropertiesResponse.class); + if (response == null) + { + LOGGER.debug("Couldn\'t fetch profile properties for " + profile + " as the profile does not exist"); + return profile; + } + else + { + GameProfile result = new GameProfile(response.getId(), response.getName()); + result.getProperties().putAll(response.getProperties()); + profile.getProperties().putAll(response.getProperties()); + + if (requireSecure && _profileCache != null) + { + _profileCache.cacheProfile(result); + System.out.println("Added new profile to repository"); + } + LOGGER.debug("Successfully fetched profile properties for " + profile); + return result; + } + } catch (AuthenticationException var6) { + LOGGER.warn("Couldn\'t look up profile properties for " + profile, var6); + return profile; + } + } + } + + public YggdrasilAuthenticationService getAuthenticationService() { + return (YggdrasilAuthenticationService)super.getAuthenticationService(); + } +} diff --git a/Plugins/Libraries/craftbukkit.jar b/Plugins/Libraries/craftbukkit.jar index 907f40c1d..54cd0474d 100644 Binary files a/Plugins/Libraries/craftbukkit.jar and b/Plugins/Libraries/craftbukkit.jar differ diff --git a/Plugins/Mineplex.Core/Mineplex.Core.iml b/Plugins/Mineplex.Core/Mineplex.Core.iml index 1a3abf88d..d7237e088 100644 --- a/Plugins/Mineplex.Core/Mineplex.Core.iml +++ b/Plugins/Mineplex.Core/Mineplex.Core.iml @@ -13,12 +13,12 @@ + - \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java b/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java index 1fd02a703..3ff19ae95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/TablistFix.java @@ -32,22 +32,34 @@ public class TablistFix extends MiniPlugin 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; + PacketPlayOutPlayerInfo packet = PacketPlayOutPlayerInfo.updateDisplayName(((CraftPlayer) other).getHandle(), ((CraftPlayer) player).getHandle()); + PacketPlayOutPlayerInfo toLoginPlayer = PacketPlayOutPlayerInfo.updateDisplayName(((CraftPlayer) player).getHandle(), ((CraftPlayer) other).getHandle()); - if (UtilPlayer.is1_8(other)) + if (other.canSee(player) && UtilPlayer.is1_8(other)) UtilPlayer.sendPacket(other, packet); + + if (player.canSee(other) && UtilPlayer.is1_8(player)) + UtilPlayer.sendPacket(player, toLoginPlayer); } } }, 20L); + + } + + public static void refreshForPlayer(Player player) + { + if (!UtilPlayer.is1_8(player)) + return; + + for (Player other : UtilServer.getPlayers()) + { + if (player.canSee(other)) + { + PacketPlayOutPlayerInfo packet = PacketPlayOutPlayerInfo.updateDisplayName(((CraftPlayer) player).getHandle(), ((CraftPlayer) other).getHandle()); + UtilPlayer.sendPacket(player, packet); + } + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java new file mode 100644 index 000000000..ea296c34d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileCacheManager.java @@ -0,0 +1,71 @@ +package mineplex.core.profileCache; + +import java.util.UUID; + +import org.bukkit.plugin.java.JavaPlugin; +import net.minecraft.util.com.google.gson.Gson; +import net.minecraft.util.com.google.gson.GsonBuilder; +import net.minecraft.util.com.mojang.authlib.GameProfile; +import net.minecraft.util.com.mojang.authlib.properties.PropertyMap; +import net.minecraft.util.com.mojang.authlib.yggdrasil.ProfileCache; +import net.minecraft.util.com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository; +import net.minecraft.util.com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; +import net.minecraft.util.com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse; +import net.minecraft.util.com.mojang.util.UUIDTypeAdapter; + +import mineplex.core.MiniPlugin; +import mineplex.serverdata.Region; +import mineplex.serverdata.redis.RedisDataRepository; +import mineplex.serverdata.servers.ServerManager; + +public class ProfileCacheManager extends MiniPlugin implements ProfileCache +{ + private RedisDataRepository _profileRepository; + private Gson _gson; + + public ProfileCacheManager(JavaPlugin plugin) + { + super("Profile Cache", plugin); + + _profileRepository = new RedisDataRepository(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(), + Region.ALL, ProfileData.class, "profileCacheRepo"); + + GsonBuilder builder = new GsonBuilder(); + builder.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()); + builder.registerTypeAdapter(UUID.class, new UUIDTypeAdapter()); + builder.registerTypeAdapter(ProfileSearchResultsResponse.class, new net.minecraft.util.com.mojang.authlib.yggdrasil.response.ProfileSearchResultsResponse.Serializer()); + _gson = builder.create(); + + YggdrasilMinecraftSessionService.setProfileCache(this); + YggdrasilGameProfileRepository.setProfileCache(this); + } + + + @Override + public GameProfile attemptToLoadProfile(String playerName) + { + ProfileData profile = _profileRepository.getElement(playerName.toLowerCase()); + + if (profile != null) + { + PropertyMap propertyMap = _gson.fromJson(profile.getPropertyMap(), PropertyMap.class); + GameProfile gameProfile = new GameProfile(profile.getUuid(), profile.getPlayerName()); + gameProfile.getProperties().putAll(propertyMap); + +// System.out.println("Loaded profile " + playerName + " from repository!"); + return gameProfile; + } + +// System.out.println("Profile Null"); + + return null; + } + + @Override + public void cacheProfile(GameProfile profile) + { +// System.out.println("Cached profile: " + profile.getName()); + ProfileData data = new ProfileData(profile.getId(), profile.getName(), _gson.toJson(profile.getProperties())); + _profileRepository.addElement(data, 60 * 60 * 24); // 1 day + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileData.java b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileData.java new file mode 100644 index 000000000..8c55a8073 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/profileCache/ProfileData.java @@ -0,0 +1,40 @@ +package mineplex.core.profileCache; + +import java.util.UUID; + +import mineplex.serverdata.data.Data; + +public class ProfileData implements Data +{ + private UUID _uuid; + private String _playerName; + private String _propertyMap; + + public ProfileData(UUID uuid, String playerName, String propertyMap) + { + _uuid = uuid; + _playerName = playerName; + _propertyMap = propertyMap; + } + + public String getPlayerName() + { + return _playerName; + } + + public String getPropertyMap() + { + return _propertyMap; + } + + public UUID getUuid() + { + return _uuid; + } + + @Override + public String getDataId() + { + return _playerName.toLowerCase(); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java index 0452a13cb..9ecce2164 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java @@ -10,6 +10,7 @@ import net.minecraft.server.v1_7_R4.EntityPlayer; import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -118,7 +119,7 @@ public abstract class ShopBase implements Listene return false; } - protected ShopPageBase> getOpeningPageForPlayer(Player player) + protected ShopPageBase> getOpeningPageForPlayer(HumanEntity player) { return _playerPageMap.get(player.getName()); } @@ -126,10 +127,19 @@ public abstract class ShopBase implements Listene @EventHandler public void onInventoryClick(InventoryClickEvent event) { - if (_playerPageMap.containsKey(event.getWhoClicked().getName()) && _playerPageMap.get(event.getWhoClicked().getName()).getName().equalsIgnoreCase(event.getInventory().getName())) + if (isPlayerInShop(event.getWhoClicked())) { - _playerPageMap.get(event.getWhoClicked().getName()).playerClicked(event); - event.setCancelled(true); + ShopPageBase page = getOpeningPageForPlayer(event.getWhoClicked()); + + if (page.matchesInventory(event.getInventory())) + { + _playerPageMap.get(event.getWhoClicked().getName()).playerClicked(event); + + if (event.getRawSlot() < page.getSize()) + { + event.setCancelled(true); + } + } } } @@ -238,7 +248,7 @@ public abstract class ShopBase implements Listene protected abstract ShopPageBase> buildPagesFor(Player player); - public boolean isPlayerInShop(Player player) + public boolean isPlayerInShop(HumanEntity player) { return _playerPageMap.containsKey(player.getName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java index cf6a5061b..bb41d48a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/page/ShopPageBase.java @@ -135,27 +135,25 @@ public abstract class ShopPageBase implements IRelat private Teleport _teleport; private ConditionManager _condition; private ClassCombatShop _classShop; + private ClassManager _classManager; + public ClassManager getClassManager() { return _classManager; } + private WarManager _warManager; private ProjectileManager _projectileManager; private WorldEventManager _worldEvent; @@ -515,7 +518,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat String message = event.getMessage(); message = _chat.getFilteredMessage(event.getPlayer(), message); ClanRelation rel = _clanUtility.rel(clan, otherClan); - String formatted = rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message; + String formatted = rel.getColor(true) + clan.getName() + " " + C.cYellow + event.getPlayer().getName() + " " + C.cWhite + message; other.sendMessage(formatted); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java index bb6f3c542..63cf0571c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansPlayerScoreboard.java @@ -34,16 +34,23 @@ public class ClansPlayerScoreboard extends PlayerScoreboard for (Player otherPlayer : Bukkit.getOnlinePlayers()) { if (otherPlayer.equals(player)) - continue; + { + ClanInfo clan = _clansManager.getClan(player); + ClanRelation rel = _clansManager.getClanUtility().rel(clan, clan); + // Add Self to Self + add(getScoreboard(), otherPlayer, clan, rel); + } + else + { + ClanInfo clan = _clansManager.getClan(player); + ClanInfo otherClan = _clansManager.getClan(otherPlayer); + ClanRelation rel = _clansManager.getClanUtility().rel(clan, otherClan); - ClanInfo clan = _clansManager.getClan(player); - ClanInfo otherClan = _clansManager.getClan(otherPlayer); - ClanRelation rel = _clansManager.getClanUtility().rel(clan, otherClan); - - // Add Other to Self - add(getScoreboard(), otherPlayer, otherClan, rel); - // Add Self to Other - add(otherPlayer.getScoreboard(), player, clan, rel); + // Add Other to Self + add(getScoreboard(), otherPlayer, otherClan, rel); + // Add Self to Other + add(otherPlayer.getScoreboard(), player, clan, rel); + } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java index f54efeceb..84453b58d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/scoreboard/ClansScoreboardManager.java @@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; +import mineplex.core.TablistFix; import mineplex.core.account.CoreClientManager; import mineplex.core.donation.DonationManager; import mineplex.core.scoreboard.PlayerScoreboard; @@ -72,6 +73,7 @@ public class ClansScoreboardManager extends ScoreboardManager for (Player player : clanInfo.getOnlinePlayers()) { refresh(player); + TablistFix.refreshForPlayer(player); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index ee4c0fabe..89f49e5a6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -4,6 +4,8 @@ import java.util.HashMap; import java.util.HashSet; import mineplex.core.MiniPlugin; +import mineplex.minecraft.game.classcombat.Class.ClientClass; +import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.core.itemstack.ItemStackFactory; @@ -43,6 +45,7 @@ import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; @@ -71,6 +74,23 @@ public class Gameplay extends MiniPlugin _foodDecrease = new WeightSet(new Weight(10, true), new Weight(90, false)); } + + @EventHandler + public void onBowShoot(EntityShootBowEvent event) + { + if (event.getEntity() instanceof Player) + { + Player player = (Player) event.getEntity(); + ClientClass playerClass = _clansManager.getClassManager().Get(player); + + if (!playerClass.IsGameClass(ClassType.Assassin, ClassType.Ranger)) + { + notify(player, "You cannot use bows without the proper class!"); + event.setCancelled(true); + } + } + } + @EventHandler public void BucketEmpty(PlayerBucketEmptyEvent event) { @@ -591,4 +611,9 @@ public class Gameplay extends MiniPlugin { return _damageManager; } + + public static void notify(Player player, String message) + { + UtilPlayer.message(player, F.main("Clans", message)); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/Smelter.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/Smelter.java index 7fb1195bc..d7eb12c4d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/Smelter.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/items/smelting/Smelter.java @@ -1,5 +1,7 @@ package mineplex.game.clans.items.smelting; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; import mineplex.game.clans.items.GearManager; import org.bukkit.Material; @@ -19,7 +21,7 @@ public class Smelter player.getInventory().setItemInHand(returns); } - // TODO: Notify player of smelt success/failure? + notify(player, "You have successfully smelted your item!"); } public static ItemStack smeltItem(ItemStack item) @@ -109,4 +111,9 @@ public class Smelter return null; } } + + private static void notify(Player player, String message) + { + UtilPlayer.message(player, F.main("Smelter", message)); + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java new file mode 100644 index 000000000..b93f992fa --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ClansShopPage.java @@ -0,0 +1,67 @@ +package mineplex.game.clans.shop; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.Clans; +import mineplex.game.clans.clans.ClansManager; + +public abstract class ClansShopPage> extends ShopPageBase +{ + + /** + * Constructor + * @param plugin + * @param shop + * @param clientManager + * @param donationManager + * @param name + * @param player + * @param slots + */ + public ClansShopPage(ClansManager plugin, T shop, CoreClientManager clientManager, + DonationManager donationManager, String name, Player player, int slots) + { + super(plugin, shop, clientManager, donationManager, name, player, slots); + } + + /** + * Constructor + * @param plugin + * @param shop + * @param clientManager + * @param donationManager + * @param name + * @param player + */ + public ClansShopPage(ClansManager plugin, T shop, CoreClientManager clientManager, + DonationManager donationManager, String name, Player player) + { + super(plugin, shop, clientManager, donationManager, name, player); + } + + public void addShopItem(int slot, Material material, int buyPrice, int sellPrice) + { + addShopItem(slot, material, buyPrice, sellPrice, Clans.prettifyName(material)); + } + + public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, byte data) + { + addShopItem(slot, material, buyPrice, sellPrice, Clans.prettifyName(material)); + } + + public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, String displayName) + { + addShopItem(slot, material, buyPrice, sellPrice, (byte)0, displayName, 1); + } + + public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, byte data, String displayName, int amount) + { + PvpItem item = new PvpItem(material, data, 1, displayName, buyPrice, sellPrice, 64); + addButton(slot, item, new ShopItemButton>(this, buyPrice, sellPrice, material, data, amount)); + } +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpShopButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpShopButton.java deleted file mode 100644 index 5f0adb9c1..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpShopButton.java +++ /dev/null @@ -1,115 +0,0 @@ -package mineplex.game.clans.shop; - -import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.Callback; -import mineplex.core.common.util.F; -import mineplex.core.common.util.InventoryUtil; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.shop.item.IButton; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.ShopPageBase; -import mineplex.game.clans.clans.ClansManager; - -public class PvpShopButton> implements IButton -{ - protected PageType Page; - protected PvpItem Item; - - public PvpShopButton(PageType page, PvpItem item) - { - Page = page; - Item = item; - } - - - @Override - public void onClick(final Player player, ClickType clickType) - { - int balance = Page.getDonationManager().Get(player.getName()).getGold(); - int cost = Item.getPrice(); - int tempAmount = Item.getAmount(); - - if (clickType == ClickType.SHIFT_LEFT) - { - cost *= Item.getBulkCount() == -1 ? 1 : Item.getBulkCount(); - tempAmount = Item.getBulkCount() == -1 ? Item.getAmount() : Item.getBulkCount(); - } - - final int deliveryAmount = tempAmount; - - if (clickType == ClickType.LEFT || clickType == ClickType.SHIFT_LEFT) - { - if (cost > balance) - { - Page.playDenySound(player); - UtilPlayer.message(player, F.main(Page.getPlugin().getName(), "You do not have enough funds to purchase " + deliveryAmount + " " + Item.GetName() + ".")); - return; - } - else - { - Page.getDonationManager().rewardGold(new Callback() - { - public void run(Boolean result) - { - if (result) - { - Page.playAcceptSound(player); - ShopItem item = Item.clone(); - item.setAmount(deliveryAmount); - player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Item.getType(), Item.getData().getData(), Item.getAmount(), Item.GetName(), new String[] {}, player.getName() + " Shop", false)); - } - else - { - Page.playDenySound(player); - UtilPlayer.message(player, F.main(Page.getPlugin().getName(), "An error occurred processing your purchase.")); - } - } - }, "Clans", player.getName(), Page.getClientManager().Get(player).getAccountId(), -cost); - } - } - else if (clickType == ClickType.RIGHT || clickType == ClickType.SHIFT_RIGHT) - { - int removed = 1; - ItemStack dumbItem = new ItemStack(Item.getType(), Item.getAmount(), Item.getDurability()); - - if (InventoryUtil.first((CraftInventory)player.getInventory(), 36, dumbItem, true) == -1) - { - Page.playDenySound(player); - UtilPlayer.message(player, F.main(Page.getPlugin().getName(), "You do not have " + deliveryAmount + " " + Item.GetName() + " in your inventory.")); - return; - } - - if (clickType == ClickType.RIGHT) - { - if (player.getInventory().contains(Item.getType(), Item.getAmount())) - InventoryUtil.removeItem((CraftInventory)player.getInventory(), 36, dumbItem); - } - else - removed = InventoryUtil.getCountOfObjectsRemoved((CraftInventory)player.getInventory(), 36, dumbItem); - - final int creditAmount = removed * Item.getPrice() / 2; - System.out.println("Crediting " + player.getName() + " with " + creditAmount + " gold."); - Page.getDonationManager().rewardGold(new Callback() - { - public void run(Boolean result) - { - if (result) - { - Page.playAcceptSound(player); - System.out.println("Credited " + player.getName() + " with " + creditAmount + " gold."); - } - else - { - Page.playDenySound(player); - UtilPlayer.message(player, F.main(Page.getPlugin().getName(), "An error occurred processing your return.")); - } - } - }, "Clans", player.getName(), Page.getClientManager().Get(player).getAccountId(), creditAmount); - } - } -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java index d5c3f63ea..e230e7c46 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/ShopItemButton.java @@ -1,5 +1,6 @@ package mineplex.game.clans.shop; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventory; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -18,15 +19,20 @@ public class ShopItemButton> implements IButton { private int _buyPrice; private int _sellPrice; + private ItemStack _item; private T _page; - private PvpItem _item; - public ShopItemButton(T page, PvpItem item, int buyPrice, int sellPrice) + public ShopItemButton(T page, int buyPrice, int sellPrice, Material material, byte data, int amount) { _page = page; - _item = item; _sellPrice = sellPrice; _buyPrice = buyPrice; + _item = new ItemStack(material, amount, data); + } + + public ShopItemButton(T page, int buyPrice, int sellPrice, Material material) + { + this(page, buyPrice, sellPrice, material, (byte)0, 1); } @Override @@ -37,9 +43,8 @@ public class ShopItemButton> implements IButton if (clickType == ClickType.SHIFT_RIGHT || clickType == ClickType.RIGHT) { int amount = 1; // # of items removed/sold from inventory - ItemStack dumbItem = new ItemStack(_item.getType(), amount); - if (!hasItem(player, dumbItem)) + if (!hasItem(player, _item)) { _page.playDenySound(player); notify(player, "You do not have any of the appropriate item in your inventory!"); @@ -48,11 +53,11 @@ public class ShopItemButton> implements IButton if (shiftClick) { - amount = InventoryUtil.getCountOfObjectsRemoved((CraftInventory)player.getInventory(), 36, dumbItem); + amount = InventoryUtil.getCountOfObjectsRemoved((CraftInventory)player.getInventory(), 36, _item); } else { - InventoryUtil.removeItem((CraftInventory)player.getInventory(), 36, dumbItem); + InventoryUtil.removeItem((CraftInventory)player.getInventory(), 36, _item); } int reward = amount * _sellPrice; @@ -108,7 +113,8 @@ public class ShopItemButton> implements IButton private void giftItem(Player player, int amount) { - ItemStack item = new ItemStack(_item.getType(), amount); + ItemStack item = _item.clone(); + item.setAmount(amount); player.getInventory().addItem(item); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java index 5e00d6962..a97b503de 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/BankPage.java @@ -15,9 +15,6 @@ import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.economy.GoldManager; -import mineplex.game.clans.shop.PvpItem; -import mineplex.game.clans.shop.PvpShopButton; -import mineplex.game.clans.shop.building.BuildingPage; public class BankPage extends ShopPageBase { @@ -120,11 +117,6 @@ public class BankPage extends ShopPageBase ShopItem shopItem = new ShopItem(Material.GOLD_RECORD, title, new String[] {" ", playerGoldString, purchaseString, goldString}, 0, true, true); addButton(3, shopItem, button); } - - public void addPvpItem(int slot, PvpItem item) - { - addButton(slot, item, new PvpShopButton(this, item)); - } public boolean hasEnoughGold() { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java index 8c0131c87..1589acf09 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/bank/CashInButton.java @@ -37,6 +37,7 @@ public class CashInButton implements IButton GoldToken token = (GoldToken) cursorItem; GoldManager.getInstance().cashIn(player, token); player.setItemOnCursor(null); // Delete the gold token on cursor + _page.playAcceptSound(player); _page.refresh(); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/building/BuildingPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/building/BuildingPage.java index 94496a783..30e7b9eb6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/building/BuildingPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/building/BuildingPage.java @@ -7,12 +7,11 @@ import mineplex.core.donation.DonationManager; import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.shop.ClansShopPage; import mineplex.game.clans.shop.PvpItem; -import mineplex.game.clans.shop.PvpShopButton; import mineplex.game.clans.shop.ShopItemButton; -import mineplex.game.clans.shop.mining.MiningPage; -public class BuildingPage extends ShopPageBase +public class BuildingPage extends ClansShopPage { public BuildingPage(ClansManager plugin, BuildingShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player) { @@ -44,15 +43,4 @@ public class BuildingPage extends ShopPageBase addShopItem(24, Material.QUARTZ_BLOCK, 75, 15); addShopItem(25, Material.CLAY, 30, 6); } - - public void addShopItem(int slot, Material material, int buyPrice, int sellPrice) - { - addShopItem(slot, material, buyPrice, sellPrice, (byte) 0); - } - - public void addShopItem(int slot, Material material, int buyPrice, int sellPrice, byte data) - { - PvpItem item = new PvpItem(material, (byte)0, 1, Clans.prettifyName(material), buyPrice, sellPrice, 64); - addButton(slot, item, new ShopItemButton(this, item, buyPrice, sellPrice)); - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/farming/FarmingPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/farming/FarmingPage.java index 34870557a..6cfbedfca 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/farming/FarmingPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/farming/FarmingPage.java @@ -7,10 +7,12 @@ import mineplex.core.donation.DonationManager; import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.shop.ClansShopPage; import mineplex.game.clans.shop.PvpItem; import mineplex.game.clans.shop.ShopItemButton; +import mineplex.game.clans.shop.mining.MiningShop; -public class FarmingPage extends ShopPageBase +public class FarmingPage extends ClansShopPage { public FarmingPage(ClansManager plugin, FarmingShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player) { @@ -38,10 +40,4 @@ public class FarmingPage extends ShopPageBase addShopItem(15, Material.ROTTEN_FLESH, 5, 5); addShopItem(16, Material.SPIDER_EYE, 5, 5); } - - public void addShopItem(int slot, Material material, int buyPrice, int sellPrice) - { - PvpItem item = new PvpItem(material, (byte)0, 1, Clans.prettifyName(material), buyPrice, sellPrice, 64); - addButton(slot, item, new ShopItemButton(this, item, buyPrice, sellPrice)); - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/mining/MiningPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/mining/MiningPage.java index ba652fffb..62199bd4b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/mining/MiningPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/mining/MiningPage.java @@ -7,10 +7,11 @@ import mineplex.core.donation.DonationManager; import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.shop.ClansShopPage; import mineplex.game.clans.shop.PvpItem; import mineplex.game.clans.shop.ShopItemButton; -public class MiningPage extends ShopPageBase +public class MiningPage extends ClansShopPage { public MiningPage(ClansManager plugin, MiningShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player) { @@ -30,10 +31,4 @@ public class MiningPage extends ShopPageBase addShopItem(6, Material.REDSTONE, 10, 2); addShopItem(7, Material.LAPIS_BLOCK, 500, 100); } - - public void addShopItem(int slot, Material material, int buyPrice, int sellPrice) - { - PvpItem item = new PvpItem(material, (byte)0, 1, Clans.prettifyName(material), buyPrice, sellPrice, 64); - addButton(slot, item, new ShopItemButton(this, item, buyPrice, sellPrice)); - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java index cbe765f10..6448dfeb7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/pvp/PvpPage.java @@ -4,12 +4,10 @@ import org.bukkit.Material; import mineplex.core.account.CoreClientManager; import mineplex.core.donation.DonationManager; -import mineplex.core.shop.page.ShopPageBase; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.shop.PvpItem; -import mineplex.game.clans.shop.PvpShopButton; +import mineplex.game.clans.shop.ClansShopPage; -public class PvpPage extends ShopPageBase +public class PvpPage extends ClansShopPage { public PvpPage(ClansManager plugin, PvpShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player) { @@ -21,49 +19,45 @@ public class PvpPage extends ShopPageBase @Override protected void buildPage() { - addPvpItem(9, new PvpItem(Material.GOLD_HELMET, (byte)0, 1, "Mage Helmet", 875, 175, 4)); - addPvpItem(18, new PvpItem(Material.GOLD_CHESTPLATE, (byte)0, 1, "Mage Chestplate", 1400, 280, 4)); - addPvpItem(27, new PvpItem(Material.GOLD_LEGGINGS, (byte)0, 1, "Mage Leggings", 1225, 245, 4)); - addPvpItem(36, new PvpItem(Material.GOLD_BOOTS, (byte)0, 1, "Mage Boots", 700, 140, 4)); - - addPvpItem(10, new PvpItem(Material.LEATHER_HELMET, (byte)0, 1, "Assassin Helmet", 625, 125, 4)); - addPvpItem(19, new PvpItem(Material.LEATHER_CHESTPLATE, (byte)0, 1, "Assassin Chestplate", 1000, 200, 4)); - addPvpItem(28, new PvpItem(Material.LEATHER_LEGGINGS, (byte)0, 1, "Assassin Leggings", 875, 125, 4)); - addPvpItem(37, new PvpItem(Material.LEATHER_BOOTS, (byte)0, 1, "Assassin Boots", 500, 100, 4)); - - addPvpItem(11, new PvpItem(Material.CHAINMAIL_HELMET, (byte)0, 1, "Ranger Helmet", 750, 150, 4)); - addPvpItem(20, new PvpItem(Material.CHAINMAIL_CHESTPLATE, (byte)0, 1, "Ranger Chestplate", 1200, 240, 4)); - addPvpItem(29, new PvpItem(Material.CHAINMAIL_LEGGINGS, (byte)0, 1, "Ranger Leggings", 1050, 210, 4)); - addPvpItem(38, new PvpItem(Material.CHAINMAIL_BOOTS, (byte)0, 1, "Ranger Boots", 600, 120, 4)); + addShopItem(9, Material.GOLD_HELMET, 875, 175, "Mage Helmet"); + addShopItem(18, Material.GOLD_CHESTPLATE, 1400, 280, "Mage Chestplate"); + addShopItem(27, Material.GOLD_LEGGINGS, 1225, 245, "Mage Leggings"); + addShopItem(36, Material.GOLD_BOOTS, 700, 140, "Mage Boots"); - addPvpItem(12, new PvpItem(Material.IRON_HELMET, (byte)0, 1, "Knight Helmet", 750, 150, 4)); - addPvpItem(21, new PvpItem(Material.IRON_CHESTPLATE, (byte)0, 1, "Knight Chestplate", 1200, 240, 4)); - addPvpItem(30, new PvpItem(Material.IRON_LEGGINGS, (byte)0, 1, "Knight Leggings", 1050, 210, 4)); - addPvpItem(39, new PvpItem(Material.IRON_BOOTS, (byte)0, 1, "Knight Boots", 600, 120, 4)); + addShopItem(10, Material.LEATHER_HELMET, 625, 125, "Assassin Helmet"); + addShopItem(19, Material.LEATHER_CHESTPLATE, 1000, 200, "Assassin Chestplate"); + addShopItem(28, Material.LEATHER_LEGGINGS, 875, 125, "Assassin Leggings"); + addShopItem(37, Material.LEATHER_BOOTS, 500, 100, "Assassin Boots"); - addPvpItem(13, new PvpItem(Material.DIAMOND_HELMET, (byte)0, 1, "Brute Helmet", 1000, 200, 4)); - addPvpItem(22, new PvpItem(Material.DIAMOND_CHESTPLATE, (byte)0, 1, "Brute Chestplate", 1600, 320, 4)); - addPvpItem(31, new PvpItem(Material.DIAMOND_LEGGINGS, (byte)0, 1, "Brute Leggings", 1400, 280, 4)); - addPvpItem(40, new PvpItem(Material.DIAMOND_BOOTS, (byte)0, 1, "Brute Boots", 800, 160, 4)); - - addPvpItem(15, new PvpItem(Material.IRON_SWORD, (byte)0, 1, "Iron Sword", 320, 160, 4)); - addPvpItem(16, new PvpItem(Material.DIAMOND_SWORD, (byte)0, 1, "Power Sword", 800, 400, 4)); - addPvpItem(17, new PvpItem(Material.GOLD_SWORD, (byte)0, 1, "Booster Sword", 800, 400, 4)); - - addPvpItem(24, new PvpItem(Material.IRON_AXE, (byte)0, 1, "Iron Axe", 470, 95, 4)); - addPvpItem(25, new PvpItem(Material.DIAMOND_AXE, (byte)0, 1, "Power Axe", 800, 400, 4)); - addPvpItem(26, new PvpItem(Material.GOLD_AXE, (byte)0, 1, "Booster Axe", 800, 400, 4)); - - addPvpItem(33, new PvpItem(Material.BOW, (byte)0, 1, "Standard Bow", 175, 35, 4)); - addPvpItem(34, new PvpItem(Material.ARROW, (byte)0, 16, "Arrows", 10, 2)); + addShopItem(11, Material.CHAINMAIL_HELMET, 750, 150, "Ranger Helmet"); + addShopItem(20, Material.CHAINMAIL_CHESTPLATE, 1200, 240, "Ranger Chestplate"); + addShopItem(29, Material.CHAINMAIL_LEGGINGS, 1050, 210, "Ranger Leggings"); + addShopItem(38, Material.CHAINMAIL_BOOTS, 600, 120, "Ranger Boots"); - addPvpItem(51, new PvpItem(Material.ENCHANTMENT_TABLE, (byte)0, 1, "Class Shop", 30000)); - addPvpItem(52, new PvpItem(Material.TNT, (byte)0, 1, "TNT", 30000, 1)); - addPvpItem(53, new PvpItem(Material.BREWING_STAND_ITEM, (byte)0, 1, "TNT Generator", 300000)); + addShopItem(12, Material.IRON_HELMET, 750, 150, "Knight Helmet"); + addShopItem(21, Material.IRON_CHESTPLATE, 1200, 240, "Knight Chestplate"); + addShopItem(30, Material.IRON_LEGGINGS, 1050, 210, "Knight Leggings"); + addShopItem(39, Material.IRON_BOOTS, 600, 120, "Knight Boots"); + + addShopItem(13, Material.DIAMOND_HELMET, 1000, 200, "Brute Helmet"); + addShopItem(22, Material.DIAMOND_CHESTPLATE, 1600, 320, "Brute Chestplate"); + addShopItem(31, Material.DIAMOND_LEGGINGS, 1400, 280, "Brute Leggings"); + addShopItem(40, Material.DIAMOND_BOOTS, 800, 160, "Brute Boots"); + + addShopItem(15, Material.IRON_SWORD, 320, 160, "Iron Sword"); + addShopItem(16, Material.DIAMOND_SWORD, 800, 400, "Power Sword"); + addShopItem(17, Material.GOLD_SWORD, 800, 400, "Booster Sword"); + + addShopItem(24, Material.IRON_AXE, 470, 95, "Iron Axe"); + addShopItem(25, Material.DIAMOND_AXE, 800, 400, "Power Axe"); + addShopItem(26, Material.GOLD_AXE, 800, 400, "Booster Axe"); + + addShopItem(33, Material.BOW, 175, 35, "Standard Bow"); + addShopItem(34, Material.ARROW, 10, 2, (byte)0, "Arrows", 16); + + //addPvpItem(51, new PvpItem(Material.ENCHANTMENT_TABLE, (byte)0, 1, "Class Shop", 30000)); + //addPvpItem(52, new PvpItem(Material.TNT, (byte)0, 1, "TNT", 30000, 1)); + //addPvpItem(53, new PvpItem(Material.BREWING_STAND_ITEM, (byte)0, 1, "TNT Generator", 300000)); } - public void addPvpItem(int slot, PvpItem item) - { - addButton(slot, item, new PvpShopButton(this, item)); - } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 322c608e3..559cde77f 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -116,7 +116,7 @@ public class Spawn extends MiniPlugin UtilTextMiddle.display(null, message, 0, 20, 0, cur); _clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true); } - else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 1000)) + else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600)) { UtilTextMiddle.display(null, ChatColor.GREEN + "Safe!", 0, 60, 20, cur); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java index 7d926f568..009b572db 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java @@ -6,10 +6,7 @@ import org.bukkit.Material; import mineplex.core.account.CoreClientManager; import mineplex.core.donation.DonationManager; import mineplex.core.shop.page.ShopPageBase; -import mineplex.game.clans.Clans; import mineplex.game.clans.clans.ClansManager; -import mineplex.game.clans.shop.PvpItem; -import mineplex.game.clans.shop.PvpShopButton; import mineplex.game.clans.spawn.Spawn; public class TravelPage extends ShopPageBase diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 8890b8e4b..eba17a96a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -3,6 +3,8 @@ package mineplex.hub; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import net.minecraft.util.com.mojang.authlib.yggdrasil.ProfileCache; + import mineplex.core.CustomTagFix; import mineplex.core.TablistFix; import mineplex.core.account.CoreClientManager; @@ -34,6 +36,7 @@ import mineplex.core.pet.PetManager; import mineplex.core.poll.PollManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; +import mineplex.core.profileCache.ProfileCacheManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.punish.Punish; import mineplex.core.recharge.Recharge; @@ -86,6 +89,7 @@ public class Hub extends JavaPlugin implements IRelation CoreClientManager clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(clientManager); + new ProfileCacheManager(this); ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); VisibilityManager.Initialize(this); Give.Initialize(this); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 3e17d1070..3e0a50929 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -14,15 +14,12 @@ import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.server.ServerManager; -import mineplex.hub.server.ui.button.SelectBETAButton; -import mineplex.hub.server.ui.button.SelectBHButton; import mineplex.hub.server.ui.button.SelectBLDButton; import mineplex.hub.server.ui.button.SelectBRButton; import mineplex.hub.server.ui.button.SelectCSButton; import mineplex.hub.server.ui.button.SelectDMTButton; import mineplex.hub.server.ui.button.SelectDOMButton; import mineplex.hub.server.ui.button.SelectMINButton; -import mineplex.hub.server.ui.button.SelectMSButton; import mineplex.hub.server.ui.button.SelectPLAYERButton; import mineplex.hub.server.ui.button.SelectSGButton; import mineplex.hub.server.ui.button.SelectSKYButton; @@ -196,9 +193,9 @@ public class ServerGameMenu extends ShopPageBase getButtonMap().put(8, new SelectWIZButton(this)); getButtonMap().put(18, new SelectCSButton(this)); - getButtonMap().put(20, new SelectBHButton(this)); +// getButtonMap().put(20, new SelectBHButton(this)); getButtonMap().put(22, new SelectSSMButton(this)); - getButtonMap().put(24, new SelectMSButton(this)); +// getButtonMap().put(24, new SelectMSButton(this)); getButtonMap().put(26, new SelectDMTButton(this)); getButtonMap().put(36, new SelectDOMButton(this)); getButtonMap().put(38, new SelectTDMButton(this)); diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java index c7c13b2f6..a73c2aae2 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Class/ClientClass.java @@ -474,13 +474,21 @@ public class ClientClass { return _gameClass; } - - public boolean IsGameClass(ClassType type) + + public boolean IsGameClass(ClassType... types) { if (GetGameClass() == null) return false; + + for (ClassType type : types) + { + if (type == GetGameClass().GetType()) + { + return true; + } + } - return GetGameClass().GetType() == type; + return false; } public Collection GetSkills() diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HeavyArrows.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HeavyArrows.java index 429d86e16..9e8bb2454 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HeavyArrows.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Ranger/HeavyArrows.java @@ -100,7 +100,7 @@ public class HeavyArrows extends Skill if (level == 0) return; //Knockback - event.AddKnockback(GetName(), 1.1 + (0.1 * level)); + event.AddKnockback(GetName(), 0.55d + (0.1 * level)); event.AddMod(GetName(), GetName(), 1 + level, true); }