From 8049288b86fab6851313ff825b7f88c24562f8d2 Mon Sep 17 00:00:00 2001 From: juanmuscaria Date: Thu, 27 Feb 2020 21:14:33 -0300 Subject: [PATCH] Timings v2 implemented! It still has some bugs but it is functional. Updated a small part of the bukkit api. --- build.gradle | 3 +- .../common/eventhandler/EventBus.java.patch | 66 +++++++ patches/net/minecraft/block/Block.java.patch | 23 ++- .../net/minecraft/entity/Entity.java.patch | 75 ++++---- .../entity/EntityLivingBase.java.patch | 82 ++++---- .../network/NetHandlerPlayServer.java.patch | 111 ++++++----- .../server/MinecraftServer.java.patch | 138 +++++++------- .../dedicated/DedicatedServer.java.patch | 12 +- .../tileentity/TileEntity.java.patch | 14 +- patches/net/minecraft/world/World.java.patch | 134 ++++++------- .../minecraft/world/WorldServer.java.patch | 39 +++- .../chunk/storage/AnvilChunkLoader.java.patch | 12 +- .../world/gen/ChunkProviderServer.java.patch | 27 ++- patches/org/bukkit/Bukkit.java.patch | 12 +- patches/org/bukkit/Server.java.patch | 32 +++- patches/org/bukkit/UnsafeValues.java.patch | 15 ++ patches/org/bukkit/command/Command.java.patch | 21 +-- .../command/FormattedCommandAlias.java.patch | 18 ++ .../command/SimpleCommandMap.java.patch | 36 +++- .../command/defaults/ReloadCommand.java.patch | 2 +- .../defaults/TimingsCommand.java.patch | 11 +- .../defaults/VersionCommand.java.patch | 2 +- patches/org/bukkit/entity/Player.java.patch | 7 +- .../plugin/SimplePluginManager.java.patch | 54 ++++-- .../plugin/java/JavaPluginLoader.java.patch | 110 ++++++----- .../bukkit/util/CachedServerIcon.java.patch | 10 + .../co/aikar/timings/MinecraftTimings.java | 9 + .../java/co/aikar/timings/TimingHistory.java | 2 +- .../co/aikar/timings/TimingHistoryEntry.java | 2 +- src/main/java/co/aikar/timings/Timings.java | 4 +- .../java/co/aikar/timings/TimingsExport.java | 36 ++-- .../co/aikar/timings/WorldTimingsHandler.java | 8 + .../io/github/crucible/CrucibleConfigs.java | 29 +++ .../github/crucible/CrucibleModContainer.java | 6 +- .../io/github/crucible/CrucibleTimings.java | 18 ++ .../org/bukkit/craftbukkit/CraftServer.java | 24 +++ .../org/bukkit/craftbukkit/SpigotTimings.java | 178 ------------------ .../craftbukkit/entity/CraftPlayer.java | 8 + .../craftbukkit/scheduler/CraftScheduler.java | 9 +- .../craftbukkit/scheduler/CraftTask.java | 13 +- .../craftbukkit/util/CraftIconCache.java | 2 + .../craftbukkit/util/CraftMagicNumbers.java | 11 ++ .../java/org/spigotmc/ActivationRange.java | 8 +- src/main/java/org/spigotmc/AntiXray.java | 6 +- .../org/spigotmc/CustomTimingsHandler.java | 54 +++++- 45 files changed, 881 insertions(+), 612 deletions(-) create mode 100644 patches/cpw/mods/fml/common/eventhandler/EventBus.java.patch create mode 100644 patches/org/bukkit/UnsafeValues.java.patch create mode 100644 patches/org/bukkit/command/FormattedCommandAlias.java.patch create mode 100644 patches/org/bukkit/util/CachedServerIcon.java.patch create mode 100644 src/main/java/io/github/crucible/CrucibleTimings.java delete mode 100644 src/main/java/org/bukkit/craftbukkit/SpigotTimings.java diff --git a/build.gradle b/build.gradle index 71fd7cc5..c90f3579 100644 --- a/build.gradle +++ b/build.gradle @@ -104,7 +104,8 @@ def gitInfo(String key) { ext.mcVersion = "1.7.10" ext.forgeVersion = "1614" ext.revision = "1.0.7" -version = "${mcVersion}-${forgeVersion}.${revision}" +ext.crucibleVersion = "3.0" +version = "${mcVersion}-${crucibleVersion}" launch4j { jreMinVersion = '1.8.0' diff --git a/patches/cpw/mods/fml/common/eventhandler/EventBus.java.patch b/patches/cpw/mods/fml/common/eventhandler/EventBus.java.patch new file mode 100644 index 00000000..676fd203 --- /dev/null +++ b/patches/cpw/mods/fml/common/eventhandler/EventBus.java.patch @@ -0,0 +1,66 @@ +--- ../src-base/minecraft/cpw/mods/fml/common/eventhandler/EventBus.java ++++ ../src-work/minecraft/cpw/mods/fml/common/eventhandler/EventBus.java +@@ -9,6 +9,9 @@ + + import javax.annotation.Nonnull; + ++import co.aikar.timings.Timing; ++import io.github.crucible.CrucibleTimings; ++import net.minecraft.server.MinecraftServer; + import org.apache.logging.log4j.Level; + + import com.google.common.base.Preconditions; +@@ -131,19 +134,43 @@ + + public boolean post(Event event) + { +- IEventListener[] listeners = event.getListenerList().getListeners(busID); +- int index = 0; +- try +- { +- for (; index < listeners.length; index++) ++ if (MinecraftServer.serverStarted) { //Only use timings after the startup. ++ Timing eventTiming = CrucibleTimings.getEventTiming(event); //Crucible ++ eventTiming.startTiming(); //Crucible ++ IEventListener[] listeners = event.getListenerList().getListeners(busID); ++ int index = 0; ++ try + { +- listeners[index].invoke(event); ++ for (; index < listeners.length; index++) ++ { ++ Timing listenerTimings = CrucibleTimings.getListenerTiming(listeners[index],eventTiming); //Crucible ++ listenerTimings.startTiming(); //Crucible ++ listeners[index].invoke(event); ++ listenerTimings.stopTiming(); //Crucible ++ } + } ++ catch (Throwable throwable) ++ { ++ exceptionHandler.handleException(this, event, listeners, index, throwable); ++ Throwables.propagate(throwable); ++ } ++ eventTiming.stopTiming(); //Crucible + } +- catch (Throwable throwable) +- { +- exceptionHandler.handleException(this, event, listeners, index, throwable); +- Throwables.propagate(throwable); ++ else { //Original code. ++ IEventListener[] listeners = event.getListenerList().getListeners(busID); ++ int index = 0; ++ try ++ { ++ for (; index < listeners.length; index++) ++ { ++ listeners[index].invoke(event); ++ } ++ } ++ catch (Throwable throwable) ++ { ++ exceptionHandler.handleException(this, event, listeners, index, throwable); ++ Throwables.propagate(throwable); ++ } + } + return (event.isCancelable() ? event.isCanceled() : false); + } diff --git a/patches/net/minecraft/block/Block.java.patch b/patches/net/minecraft/block/Block.java.patch index 2e7b3fd1..6393d61f 100644 --- a/patches/net/minecraft/block/Block.java.patch +++ b/patches/net/minecraft/block/Block.java.patch @@ -16,7 +16,20 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.RotationHelper; -@@ -122,6 +124,7 @@ +@@ -118,10 +120,20 @@ + public Block.SoundType stepSound; + public float blockParticleGravity; + protected final Material blockMaterial; ++ // Paper start ++ public co.aikar.timings.Timing timing; ++ public co.aikar.timings.Timing getTiming() { ++ if (timing == null) { ++ timing = co.aikar.timings.MinecraftTimings.getBlockTiming(this); ++ } ++ return timing; ++ } ++ // Paper end + public float slipperiness; private String unlocalizedName; @SideOnly(Side.CLIENT) protected IIcon blockIcon; @@ -24,7 +37,7 @@ private static final String __OBFID = "CL_00000199"; public final cpw.mods.fml.common.registry.RegistryDelegate delegate = -@@ -133,6 +136,8 @@ +@@ -133,6 +145,8 @@ public static Block getBlockById(int p_149729_0_) { @@ -33,7 +46,7 @@ Block ret = (Block)blockRegistry.getObjectById(p_149729_0_); return ret == null ? Blocks.air : ret; } -@@ -564,6 +569,10 @@ +@@ -564,6 +578,10 @@ public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_) { @@ -44,7 +57,7 @@ AxisAlignedBB axisalignedbb1 = this.getCollisionBoundingBoxFromPool(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_); if (axisalignedbb1 != null && p_149743_5_.intersectsWith(axisalignedbb1)) -@@ -954,13 +963,18 @@ +@@ -954,13 +972,18 @@ if (this.canSilkHarvest(p_149636_1_, p_149636_2_, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_) && EnchantmentHelper.getSilkTouchModifier(p_149636_2_)) { ArrayList items = new ArrayList(); @@ -67,7 +80,7 @@ ForgeEventFactory.fireBlockHarvesting(items, p_149636_1_, this, p_149636_3_, p_149636_4_, p_149636_5_, p_149636_6_, 0, 1.0f, true, p_149636_2_); for (ItemStack is : items) { -@@ -1131,6 +1145,23 @@ +@@ -1131,6 +1154,23 @@ return this; } diff --git a/patches/net/minecraft/entity/Entity.java.patch b/patches/net/minecraft/entity/Entity.java.patch index 9bdedde2..9687a1af 100644 --- a/patches/net/minecraft/entity/Entity.java.patch +++ b/patches/net/minecraft/entity/Entity.java.patch @@ -1,6 +1,14 @@ --- ../src-base/minecraft/net/minecraft/entity/Entity.java +++ ../src-work/minecraft/net/minecraft/entity/Entity.java -@@ -45,13 +45,51 @@ +@@ -1,5 +1,7 @@ + package net.minecraft.entity; + ++import co.aikar.timings.MinecraftTimings; ++import co.aikar.timings.Timing; + import cpw.mods.fml.common.FMLLog; + import cpw.mods.fml.relauncher.Side; + import cpw.mods.fml.relauncher.SideOnly; +@@ -45,13 +47,50 @@ import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraft.world.WorldServer; @@ -22,7 +30,6 @@ +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Painting; +import org.bukkit.entity.Vehicle; -+import org.spigotmc.CustomTimingsHandler; // Spigot +import org.bukkit.event.entity.EntityCombustByEntityEvent; +import org.bukkit.event.painting.PaintingBreakByEntityEvent; +import org.bukkit.event.vehicle.VehicleBlockCollisionEvent; @@ -52,7 +59,7 @@ private static int nextEntityID; private int entityId; public double renderDistanceWeight; -@@ -100,12 +138,12 @@ +@@ -100,12 +139,12 @@ protected Random rand; public int ticksExisted; public int fireResistance; @@ -68,7 +75,7 @@ private double entityRiderPitchDelta; private double entityRiderYawDelta; public boolean addedToChunk; -@@ -126,16 +164,27 @@ +@@ -126,16 +165,27 @@ public int dimension; protected int teleportDirection; private boolean invulnerable; @@ -87,7 +94,7 @@ - protected HashMap extendedProperties; + // Spigot start -+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot ++ public Timing tickTimer = MinecraftTimings.getEntityTimings(this); // Paper + public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this); + public final boolean defaultActivationState; + public long activatedTick = 0; @@ -99,7 +106,7 @@ public int getEntityId() { -@@ -159,7 +208,7 @@ +@@ -159,7 +209,7 @@ this.rand = new Random(); this.fireResistance = 1; this.firstUpdate = true; @@ -108,7 +115,7 @@ this.myEntitySize = Entity.EnumEntitySize.SIZE_2; this.worldObj = p_i1582_1_; this.setPosition(0.0D, 0.0D, 0.0D); -@@ -167,8 +216,15 @@ +@@ -167,8 +217,15 @@ if (p_i1582_1_ != null) { this.dimension = p_i1582_1_.provider.dimensionId; @@ -124,7 +131,7 @@ this.dataWatcher = new DataWatcher(this); this.dataWatcher.addObject(0, Byte.valueOf((byte)0)); this.dataWatcher.addObject(1, Short.valueOf((short)300)); -@@ -186,6 +242,14 @@ +@@ -186,6 +243,14 @@ protected abstract void entityInit(); @@ -139,7 +146,7 @@ public DataWatcher getDataWatcher() { return this.dataWatcher; -@@ -277,6 +341,41 @@ +@@ -277,6 +342,41 @@ protected void setRotation(float p_70101_1_, float p_70101_2_) { @@ -181,7 +188,7 @@ this.rotationYaw = p_70101_1_ % 360.0F; this.rotationPitch = p_70101_2_ % 360.0F; } -@@ -343,7 +442,7 @@ +@@ -343,7 +443,7 @@ if (this.inPortal) { @@ -190,7 +197,7 @@ { if (this.ridingEntity == null && this.portalCounter++ >= i) { -@@ -457,7 +556,35 @@ +@@ -457,7 +557,35 @@ { if (!this.isImmuneToFire) { @@ -227,7 +234,7 @@ this.setFire(15); } } -@@ -492,6 +619,30 @@ +@@ -492,6 +620,30 @@ public void moveEntity(double p_70091_1_, double p_70091_3_, double p_70091_5_) { @@ -253,12 +260,12 @@ + + // CraftBukkit end + if (!CauldronHooks.checkEntitySpeed(this, p_70091_1_, p_70091_3_, p_70091_5_)) return; // Check for entities violating the speed limit -+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot ++ MinecraftTimings.entityMoveTimer.startTiming(); // Spigot + if (this.noClip) { this.boundingBox.offset(p_70091_1_, p_70091_3_, p_70091_5_); -@@ -756,6 +907,34 @@ +@@ -756,6 +908,34 @@ d10 = this.posY - d4; d11 = this.posZ - d5; @@ -293,7 +300,7 @@ if (this.canTriggerWalking() && !flag && this.ridingEntity == null) { int j1 = MathHelper.floor_double(this.posX); -@@ -798,6 +977,8 @@ +@@ -798,6 +978,8 @@ } } @@ -302,7 +309,7 @@ try { this.func_145775_I(); -@@ -809,7 +990,8 @@ +@@ -809,7 +991,8 @@ this.addEntityCrashInfo(crashreportcategory); throw new ReportedException(crashreport); } @@ -312,7 +319,7 @@ boolean flag2 = this.isWet(); if (this.worldObj.func_147470_e(this.boundingBox.contract(0.001D, 0.001D, 0.001D))) -@@ -820,8 +1002,20 @@ +@@ -820,8 +1003,20 @@ { ++this.fire; @@ -334,16 +341,16 @@ this.setFire(8); } } -@@ -839,6 +1033,8 @@ +@@ -839,6 +1034,8 @@ this.worldObj.theProfiler.endSection(); } + -+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot ++ MinecraftTimings.entityMoveTimer.stopTiming(); // Spigot } protected String getSwimSound() -@@ -867,7 +1063,18 @@ +@@ -867,7 +1064,18 @@ try { @@ -363,7 +370,7 @@ } catch (Throwable throwable) { -@@ -928,6 +1135,7 @@ +@@ -928,6 +1136,7 @@ return null; } @@ -371,7 +378,7 @@ protected void dealFireDamage(int p_70081_1_) { if (!this.isImmuneToFire) -@@ -935,7 +1143,16 @@ +@@ -935,7 +1144,16 @@ this.attackEntityFrom(DamageSource.inFire, (float)p_70081_1_); } } @@ -388,7 +395,7 @@ public final boolean isImmuneToFire() { return this.isImmuneToFire; -@@ -1184,6 +1401,8 @@ +@@ -1184,6 +1402,8 @@ public void onCollideWithPlayer(EntityPlayer p_70100_1_) {} @@ -397,7 +404,7 @@ public void applyEntityCollision(Entity p_70108_1_) { if (p_70108_1_.riddenByEntity != this && p_70108_1_.ridingEntity != this) -@@ -1310,6 +1529,20 @@ +@@ -1310,6 +1530,20 @@ { p_70109_1_.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY + (double)this.ySize, this.posZ})); p_70109_1_.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ})); @@ -418,7 +425,7 @@ p_70109_1_.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch})); p_70109_1_.setFloat("FallDistance", this.fallDistance); p_70109_1_.setShort("Fire", (short)this.fire); -@@ -1320,6 +1553,12 @@ +@@ -1320,6 +1554,12 @@ p_70109_1_.setInteger("PortalCooldown", this.timeUntilPortal); p_70109_1_.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits()); p_70109_1_.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits()); @@ -431,7 +438,7 @@ if (customEntityData != null) { p_70109_1_.setTag("ForgeData", customEntityData); -@@ -1370,7 +1609,7 @@ +@@ -1370,7 +1610,7 @@ this.motionX = nbttaglist1.func_150309_d(0); this.motionY = nbttaglist1.func_150309_d(1); this.motionZ = nbttaglist1.func_150309_d(2); @@ -440,7 +447,7 @@ if (Math.abs(this.motionX) > 10.0D) { this.motionX = 0.0D; -@@ -1385,7 +1624,7 @@ +@@ -1385,7 +1625,7 @@ { this.motionZ = 0.0D; } @@ -449,7 +456,7 @@ this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.func_150309_d(0); this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.func_150309_d(1); this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.func_150309_d(2); -@@ -1436,6 +1675,76 @@ +@@ -1436,6 +1676,76 @@ { this.setPosition(this.posX, this.posY, this.posZ); } @@ -526,7 +533,7 @@ } catch (Throwable throwable) { -@@ -1653,6 +1962,31 @@ +@@ -1653,6 +1963,31 @@ public void mountEntity(Entity p_70078_1_) { @@ -558,7 +565,7 @@ this.entityRiderPitchDelta = 0.0D; this.entityRiderYawDelta = 0.0D; -@@ -1660,6 +1994,20 @@ +@@ -1660,6 +1995,20 @@ { if (this.ridingEntity != null) { @@ -579,7 +586,7 @@ this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch); this.ridingEntity.riddenByEntity = null; } -@@ -1668,22 +2016,61 @@ +@@ -1668,22 +2017,61 @@ } else { @@ -648,7 +655,7 @@ this.ridingEntity = p_70078_1_; p_70078_1_.riddenByEntity = this; } -@@ -1860,12 +2247,59 @@ +@@ -1860,12 +2248,59 @@ public void onStruckByLightning(EntityLightningBolt p_70077_1_) { @@ -710,7 +717,7 @@ } } -@@ -2038,46 +2472,83 @@ +@@ -2038,46 +2473,83 @@ { this.worldObj.theProfiler.startSection("changeDimension"); MinecraftServer minecraftserver = MinecraftServer.getServer(); @@ -811,7 +818,7 @@ public float func_145772_a(Explosion p_145772_1_, World p_145772_2_, int p_145772_3_, int p_145772_4_, int p_145772_5_, Block p_145772_6_) { return p_145772_6_.getExplosionResistance(this, p_145772_2_, p_145772_3_, p_145772_4_, p_145772_5_, posX, posY + getEyeHeight(), posZ); -@@ -2474,4 +2945,14 @@ +@@ -2474,4 +2946,14 @@ } } } diff --git a/patches/net/minecraft/entity/EntityLivingBase.java.patch b/patches/net/minecraft/entity/EntityLivingBase.java.patch index f1bf914e..405d5211 100644 --- a/patches/net/minecraft/entity/EntityLivingBase.java.patch +++ b/patches/net/minecraft/entity/EntityLivingBase.java.patch @@ -1,7 +1,9 @@ --- ../src-base/minecraft/net/minecraft/entity/EntityLivingBase.java +++ ../src-work/minecraft/net/minecraft/entity/EntityLivingBase.java -@@ -2,12 +2,9 @@ +@@ -1,15 +1,14 @@ + package net.minecraft.entity; ++import co.aikar.timings.MinecraftTimings; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.Collection; @@ -15,8 +17,11 @@ + import net.minecraft.block.Block; import net.minecraft.block.material.Material; ++import net.minecraft.client.Minecraft; import net.minecraft.enchantment.EnchantmentHelper; -@@ -50,14 +47,30 @@ + import net.minecraft.entity.ai.attributes.AttributeModifier; + import net.minecraft.entity.ai.attributes.BaseAttributeMap; +@@ -50,14 +49,29 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.ForgeHooks; @@ -32,7 +37,6 @@ +import org.bukkit.event.entity.EntityRegainHealthEvent; +import org.bukkit.inventory.Inventory; +// CraftBukkit end -+import org.bukkit.craftbukkit.SpigotTimings; // Spigot +import org.bukkit.craftbukkit.inventory.CraftItemStack; // Cauldron + +import com.google.common.base.Function; @@ -49,7 +53,7 @@ private final ItemStack[] previousEquipment = new ItemStack[5]; public boolean isSwingInProgress; public int swingProgressInt; -@@ -83,7 +96,7 @@ +@@ -83,7 +97,7 @@ public float rotationYawHead; public float prevRotationYawHead; public float jumpMovementFactor = 0.02F; @@ -58,7 +62,7 @@ protected int recentlyHit; protected boolean dead; protected int entityAge; -@@ -93,7 +106,7 @@ +@@ -93,7 +107,7 @@ protected float field_70763_ax; protected float field_70741_aB; protected int scoreValue; @@ -67,7 +71,7 @@ protected boolean isJumping; public float moveStrafing; public float moveForward; -@@ -104,21 +117,26 @@ +@@ -104,21 +118,26 @@ protected double newPosZ; protected double newRotationYaw; protected double newRotationPitch; @@ -97,7 +101,7 @@ this.preventEntitySpawning = true; this.field_70770_ap = (float)(Math.random() + 1.0D) * 0.01F; this.setPosition(this.posX, this.posY, this.posZ); -@@ -173,7 +191,18 @@ +@@ -173,7 +192,18 @@ } else if (!this.worldObj.isRemote && this.fallDistance > 3.0F) { @@ -117,7 +121,7 @@ } block.onFallenUpon(this.worldObj, i, j, k, this, this.fallDistance); -@@ -234,7 +263,12 @@ +@@ -234,7 +264,12 @@ } else { @@ -131,7 +135,7 @@ } if (this.isEntityAlive() && this.isWet()) -@@ -299,6 +333,22 @@ +@@ -299,6 +334,22 @@ this.worldObj.theProfiler.endSection(); } @@ -154,7 +158,7 @@ public boolean isChild() { return false; -@@ -308,22 +358,21 @@ +@@ -308,22 +359,21 @@ { ++this.deathTime; @@ -186,7 +190,7 @@ this.setDead(); for (i = 0; i < 20; ++i) -@@ -485,6 +534,22 @@ +@@ -485,6 +535,22 @@ } } @@ -209,7 +213,7 @@ if (p_70037_1_.hasKey("HealF", 99)) { this.setHealth(p_70037_1_.getFloat("HealF")); -@@ -514,25 +579,21 @@ +@@ -514,25 +580,21 @@ protected void updatePotionEffects() { @@ -247,7 +251,7 @@ } int i; -@@ -614,12 +675,14 @@ +@@ -614,12 +676,14 @@ public boolean isPotionActive(int p_82165_1_) { @@ -264,7 +268,7 @@ } public PotionEffect getActivePotionEffect(Potion p_70660_1_) -@@ -710,25 +773,66 @@ +@@ -710,25 +774,66 @@ } } @@ -332,7 +336,7 @@ this.dataWatcher.updateObject(6, Float.valueOf(MathHelper.clamp_float(p_70606_1_, 0.0F, this.getMaxHealth()))); } -@@ -757,11 +861,12 @@ +@@ -757,11 +862,12 @@ } else { @@ -347,7 +351,7 @@ this.limbSwingAmount = 1.5F; boolean flag = true; -@@ -773,16 +878,27 @@ +@@ -773,16 +879,27 @@ return false; } @@ -378,7 +382,7 @@ this.hurtTime = this.maxHurtTime = 10; } -@@ -938,6 +1054,22 @@ +@@ -938,6 +1055,22 @@ if (!ForgeHooks.onLivingDrops(this, p_70645_1_, capturedDrops, i, recentlyHit > 0, j)) { @@ -401,7 +405,7 @@ for (EntityItem item : capturedDrops) { worldObj.spawnEntityInWorld(item); -@@ -1010,8 +1142,17 @@ +@@ -1010,8 +1143,17 @@ if (i > 0) { @@ -420,7 +424,7 @@ int j = MathHelper.floor_double(this.posX); int k = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset); int l = MathHelper.floor_double(this.posZ); -@@ -1065,7 +1206,7 @@ +@@ -1065,7 +1207,7 @@ { int i = 25 - this.getTotalArmorValue(); float f1 = p_70655_2_ * (float)i; @@ -429,7 +433,7 @@ p_70655_2_ = f1 / 25.0F; } -@@ -1089,7 +1230,8 @@ +@@ -1089,7 +1231,8 @@ int j; float f1; @@ -439,7 +443,7 @@ { i = (this.getActivePotionEffect(Potion.resistance).getAmplifier() + 1) * 5; j = 25 - i; -@@ -1122,26 +1264,218 @@ +@@ -1122,26 +1265,218 @@ } } @@ -669,25 +673,25 @@ } public CombatTracker func_110142_aN() -@@ -1558,6 +1892,7 @@ +@@ -1558,6 +1893,7 @@ public void onUpdate() { if (ForgeHooks.onLivingUpdate(this)) return; -+ SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot ++ MinecraftTimings.timerEntityBaseTick.startTiming(); // Spigot super.onUpdate(); if (!this.worldObj.isRemote) -@@ -1608,7 +1943,9 @@ +@@ -1608,7 +1944,9 @@ } } -+ SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot ++ MinecraftTimings.timerEntityBaseTick.stopTiming(); // Spigot this.onLivingUpdate(); -+ SpigotTimings.timerEntityTickRest.startTiming(); // Spigot ++ MinecraftTimings.timerEntityTickRest.startTiming(); // Spigot double d0 = this.posX - this.prevPosX; double d1 = this.posZ - this.prevPosZ; float f = (float)(d0 * d0 + d1 * d1); -@@ -1621,7 +1958,8 @@ +@@ -1621,7 +1959,8 @@ { f3 = 1.0F; f2 = (float)Math.sqrt((double)f) * 3.0F; @@ -697,49 +701,49 @@ } if (this.swingProgress > 0.0F) -@@ -1682,6 +2020,7 @@ +@@ -1682,6 +2021,7 @@ this.worldObj.theProfiler.endSection(); this.field_70764_aw += f2; -+ SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot ++ MinecraftTimings.timerEntityTickRest.stopTiming(); // Spigot } protected float func_110146_f(float p_110146_1_, float p_110146_2_) -@@ -1757,6 +2096,7 @@ +@@ -1757,6 +2097,7 @@ this.motionZ = 0.0D; } -+ SpigotTimings.timerEntityAI.startTiming(); // Spigot ++ MinecraftTimings.timerEntityAI.startTiming(); // Spigot this.worldObj.theProfiler.startSection("ai"); if (this.isMovementBlocked()) -@@ -1783,6 +2123,7 @@ +@@ -1783,6 +2124,7 @@ } } -+ SpigotTimings.timerEntityAI.stopTiming(); // Spigot ++ MinecraftTimings.timerEntityAI.stopTiming(); // Spigot this.worldObj.theProfiler.endSection(); this.worldObj.theProfiler.startSection("jump"); -@@ -1811,13 +2152,17 @@ +@@ -1811,13 +2153,17 @@ this.moveStrafing *= 0.98F; this.moveForward *= 0.98F; this.randomYawVelocity *= 0.9F; -+ SpigotTimings.timerEntityAIMove.startTiming(); // Spigot ++ MinecraftTimings.timerEntityAIMove.startTiming(); // Spigot this.moveEntityWithHeading(this.moveStrafing, this.moveForward); -+ SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot ++ MinecraftTimings.timerEntityAIMove.stopTiming(); // Spigot this.worldObj.theProfiler.endSection(); this.worldObj.theProfiler.startSection("push"); if (!this.worldObj.isRemote) { -+ SpigotTimings.timerEntityAICollision.startTiming(); // Spigot ++ MinecraftTimings.timerEntityAICollision.startTiming(); // Spigot this.collideWithNearbyEntities(); -+ SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot ++ MinecraftTimings.timerEntityAICollision.stopTiming(); // Spigot } this.worldObj.theProfiler.endSection(); -@@ -1829,17 +2174,36 @@ +@@ -1829,17 +2175,36 @@ { List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D)); diff --git a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch index 1b814e1d..b1a52816 100644 --- a/patches/net/minecraft/network/NetHandlerPlayServer.java.patch +++ b/patches/net/minecraft/network/NetHandlerPlayServer.java.patch @@ -1,6 +1,13 @@ --- ../src-base/minecraft/net/minecraft/network/NetHandlerPlayServer.java +++ ../src-work/minecraft/net/minecraft/network/NetHandlerPlayServer.java -@@ -13,6 +13,7 @@ +@@ -1,5 +1,6 @@ + package net.minecraft.network; + ++import co.aikar.timings.MinecraftTimings; + import com.google.common.base.Charsets; + import com.google.common.collect.Lists; + import io.netty.buffer.Unpooled; +@@ -13,6 +14,7 @@ import java.util.Iterator; import java.util.Random; import java.util.concurrent.Callable; @@ -8,7 +15,7 @@ import net.minecraft.block.material.Material; import net.minecraft.command.server.CommandBlockLogic; import net.minecraft.crash.CrashReport; -@@ -32,6 +33,7 @@ +@@ -32,6 +34,7 @@ import net.minecraft.inventory.ContainerMerchant; import net.minecraft.inventory.ContainerRepair; import net.minecraft.inventory.Slot; @@ -16,7 +23,7 @@ import net.minecraft.item.ItemEditableBook; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemWritableBook; -@@ -61,6 +63,7 @@ +@@ -61,6 +64,7 @@ import net.minecraft.network.play.server.S00PacketKeepAlive; import net.minecraft.network.play.server.S02PacketChat; import net.minecraft.network.play.server.S08PacketPlayerPosLook; @@ -24,7 +31,7 @@ import net.minecraft.network.play.server.S23PacketBlockChange; import net.minecraft.network.play.server.S2FPacketSetSlot; import net.minecraft.network.play.server.S32PacketConfirmTransaction; -@@ -81,19 +84,75 @@ +@@ -81,19 +85,75 @@ import net.minecraft.util.IChatComponent; import net.minecraft.util.IntHashMap; import net.minecraft.util.ReportedException; @@ -102,7 +109,7 @@ public class NetHandlerPlayServer implements INetHandlerPlayServer { private static final Logger logger = LogManager.getLogger(); -@@ -107,13 +166,12 @@ +@@ -107,13 +167,12 @@ private long field_147379_i; private static Random field_147376_j = new Random(); private long field_147377_k; @@ -120,7 +127,7 @@ private static final String __OBFID = "CL_00001452"; public NetHandlerPlayServer(MinecraftServer p_i1530_1_, NetworkManager p_i1530_2_, EntityPlayerMP p_i1530_3_) -@@ -123,8 +181,41 @@ +@@ -123,8 +182,41 @@ p_i1530_2_.setNetHandler(this); this.playerEntity = p_i1530_3_; p_i1530_3_.playerNetServerHandler = this; @@ -162,7 +169,7 @@ public void onNetworkTick() { this.field_147366_g = false; -@@ -139,10 +230,16 @@ +@@ -139,10 +231,16 @@ this.sendPacket(new S00PacketKeepAlive(this.field_147378_h)); } @@ -179,7 +186,7 @@ if (this.field_147375_m > 0) { -@@ -162,6 +259,24 @@ +@@ -162,6 +260,24 @@ public void kickPlayerFromServer(String p_147360_1_) { @@ -204,7 +211,7 @@ final ChatComponentText chatcomponenttext = new ChatComponentText(p_147360_1_); this.netManager.scheduleOutboundPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener[] {new GenericFutureListener() { -@@ -170,8 +285,8 @@ +@@ -170,8 +286,8 @@ { NetHandlerPlayServer.this.netManager.closeChannel(chatcomponenttext); } @@ -215,7 +222,7 @@ this.netManager.disableAutoRead(); } -@@ -180,8 +295,18 @@ +@@ -180,8 +296,18 @@ this.playerEntity.setEntityActionState(p_147358_1_.func_149620_c(), p_147358_1_.func_149616_d(), p_147358_1_.func_149618_e(), p_147358_1_.func_149617_f()); } @@ -234,7 +241,7 @@ WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); this.field_147366_g = true; -@@ -199,8 +324,75 @@ +@@ -199,8 +325,75 @@ } } @@ -311,7 +318,7 @@ double d1; double d2; double d3; -@@ -280,13 +472,6 @@ +@@ -280,13 +473,6 @@ d3 = p_147347_1_.func_149472_e(); d4 = p_147347_1_.func_149471_f() - p_147347_1_.func_149467_d(); @@ -325,7 +332,7 @@ if (Math.abs(p_147347_1_.func_149464_c()) > 3.2E7D || Math.abs(p_147347_1_.func_149472_e()) > 3.2E7D) { this.kickPlayerFromServer("Illegal position"); -@@ -315,10 +500,14 @@ +@@ -315,10 +501,14 @@ //BUGFIX: min -> max, grabs the highest distance double d7 = Math.max(Math.abs(d4), Math.abs(this.playerEntity.motionX)); double d8 = Math.max(Math.abs(d5), Math.abs(this.playerEntity.motionY)); @@ -341,7 +348,7 @@ { logger.warn(this.playerEntity.getCommandSenderName() + " moved too quickly! " + d4 + "," + d5 + "," + d6 + " (" + d7 + ", " + d8 + ", " + d9 + ")"); this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, this.playerEntity.rotationYaw, this.playerEntity.rotationPitch); -@@ -413,21 +602,85 @@ +@@ -413,21 +603,85 @@ public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_) { @@ -432,7 +439,7 @@ this.playerEntity.dropOneItem(false); } else if (p_147345_1_.func_149506_g() == 3) -@@ -490,7 +743,17 @@ +@@ -490,7 +744,17 @@ } else { @@ -450,7 +457,7 @@ } } else if (p_147345_1_.func_149506_g() == 2) -@@ -517,6 +780,34 @@ +@@ -517,6 +781,34 @@ public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement p_147346_1_) { WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); @@ -485,7 +492,7 @@ ItemStack itemstack = this.playerEntity.inventory.getCurrentItem(); boolean flag = false; boolean placeResult = true; -@@ -532,12 +823,20 @@ +@@ -532,12 +824,20 @@ { return; } @@ -508,7 +515,7 @@ } else if (p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit() - 1 && (p_147346_1_.func_149568_f() == 1 || p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit())) { -@@ -548,17 +847,24 @@ +@@ -548,17 +848,24 @@ } else { @@ -541,7 +548,7 @@ flag = true; } -@@ -615,7 +921,7 @@ +@@ -615,7 +922,7 @@ this.playerEntity.openContainer.detectAndSendChanges(); this.playerEntity.isChangingQuantityOnly = false; @@ -550,7 +557,7 @@ { this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem())); } -@@ -624,14 +930,34 @@ +@@ -624,14 +931,34 @@ public void onDisconnect(IChatComponent p_147231_1_) { @@ -590,7 +597,7 @@ if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner())) { logger.info("Stopping singleplayer server as player logged out"); -@@ -657,6 +983,18 @@ +@@ -657,6 +984,18 @@ } } @@ -609,7 +616,7 @@ try { this.netManager.scheduleOutboundPacket(p_147359_1_, new GenericFutureListener[0]); -@@ -679,20 +1017,37 @@ +@@ -679,20 +1018,37 @@ public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_) { @@ -648,7 +655,7 @@ { ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.cannotSend", new Object[0]); chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED); -@@ -708,51 +1063,430 @@ +@@ -708,51 +1064,430 @@ { if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i))) { @@ -925,14 +932,14 @@ private void handleSlashCommand(String p_147361_1_) { - this.serverController.getCommandManager().executeCommand(this.playerEntity, p_147361_1_); -+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot ++ MinecraftTimings.playerCommandTimer.startTiming(); // Paper + // CraftBukkit start + CraftPlayer player = this.getPlayerB(); + + // Thermos - block specified commands completely - no one will ever believe you. + if(net.minecraftforge.cauldron.configuration.CauldronConfig.instance.blockedCMDs.contains(p_147361_1_)) + { -+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot ++ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper + return; + } + @@ -950,7 +957,7 @@ + + if (event.isCancelled()) + { -+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot ++ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper + return; + } + @@ -969,14 +976,14 @@ + if (this.server.getCommandMap().getCommand(event.getMessage().substring(1, space != -1 ? space : event.getMessage().length())) != null) + { + this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1)); -+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot ++ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper + return; + } + else + // process vanilla command + { + this.server.dispatchVanillaCommand(event.getPlayer(), event.getMessage().substring(1)); -+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot ++ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper + return; + } + } @@ -984,7 +991,7 @@ + { + player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command"); + java.util.logging.Logger.getLogger(NetHandlerPlayServer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); -+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot ++ MinecraftTimings.playerCommandTimer.stopTiming(); // Paper + return; + } + @@ -1091,7 +1098,7 @@ if (p_147357_1_.func_149513_d() == 1) { this.playerEntity.setSneaking(true); -@@ -772,7 +1506,7 @@ +@@ -772,7 +1507,7 @@ else if (p_147357_1_.func_149513_d() == 3) { this.playerEntity.wakeUpPlayer(false, true, true); @@ -1100,7 +1107,7 @@ } else if (p_147357_1_.func_149513_d() == 6) { -@@ -789,8 +1523,20 @@ +@@ -789,8 +1524,20 @@ public void processUseEntity(C02PacketUseEntity p_147340_1_) { @@ -1122,7 +1129,7 @@ this.playerEntity.func_143004_u(); if (entity != null) -@@ -805,9 +1551,53 @@ +@@ -805,9 +1552,53 @@ if (this.playerEntity.getDistanceSqToEntity(entity) < d0) { @@ -1176,7 +1183,7 @@ } else if (p_147340_1_.func_149565_c() == C02PacketUseEntity.Action.ATTACK) { -@@ -819,6 +1609,13 @@ +@@ -819,6 +1610,13 @@ } this.playerEntity.attackTargetEntityWithCurrentItem(entity); @@ -1190,7 +1197,7 @@ } } } -@@ -829,12 +1626,24 @@ +@@ -829,12 +1627,24 @@ this.playerEntity.func_143004_u(); C16PacketClientStatus.EnumState enumstate = p_147342_1_.func_149435_c(); @@ -1216,7 +1223,7 @@ } else if (this.playerEntity.getServerForPlayer().getWorldInfo().isHardcoreModeEnabled()) { -@@ -857,7 +1666,7 @@ +@@ -857,7 +1667,7 @@ return; } @@ -1225,7 +1232,7 @@ } break; -@@ -871,17 +1680,461 @@ +@@ -871,17 +1681,461 @@ public void processCloseWindow(C0DPacketCloseWindow p_147356_1_) { @@ -1688,7 +1695,7 @@ if (ItemStack.areItemStacksEqual(p_147351_1_.func_149546_g(), itemstack)) { this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(p_147351_1_.func_149548_c(), p_147351_1_.func_149547_f(), true)); -@@ -903,6 +2156,12 @@ +@@ -903,6 +2157,12 @@ } this.playerEntity.sendContainerAndContentsToPlayer(this.playerEntity.openContainer, arraylist); @@ -1701,7 +1708,7 @@ } } } -@@ -925,9 +2184,61 @@ +@@ -925,9 +2185,61 @@ boolean flag = p_147344_1_.func_149627_c() < 0; ItemStack itemstack = p_147344_1_.func_149625_d(); boolean flag1 = p_147344_1_.func_149627_c() >= 1 && p_147344_1_.func_149627_c() < 36 + InventoryPlayer.getHotbarSize(); @@ -1764,7 +1771,7 @@ if (flag1 && flag2 && flag3) { if (itemstack == null) -@@ -956,6 +2267,11 @@ +@@ -956,6 +2268,11 @@ public void processConfirmTransaction(C0FPacketConfirmTransaction p_147339_1_) { @@ -1776,7 +1783,7 @@ Short oshort = (Short)this.field_147372_n.lookup(this.playerEntity.openContainer.windowId); if (oshort != null && p_147339_1_.func_149533_d() == oshort.shortValue() && this.playerEntity.openContainer.windowId == p_147339_1_.func_149532_c() && !this.playerEntity.openContainer.isPlayerNotUsingContainer(this.playerEntity)) -@@ -966,6 +2282,11 @@ +@@ -966,6 +2283,11 @@ public void processUpdateSign(C12PacketUpdateSign p_147343_1_) { @@ -1788,7 +1795,7 @@ this.playerEntity.func_143004_u(); WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); -@@ -980,6 +2301,7 @@ +@@ -980,6 +2302,7 @@ if (!tileentitysign.func_145914_a() || tileentitysign.func_145911_b() != this.playerEntity) { this.serverController.logWarning("Player " + this.playerEntity.getCommandSenderName() + " just tried to change non-editable sign"); @@ -1796,7 +1803,7 @@ return; } } -@@ -990,6 +2312,7 @@ +@@ -990,6 +2313,7 @@ for (j = 0; j < 4; ++j) { boolean flag = true; @@ -1804,7 +1811,7 @@ if (p_147343_1_.func_149589_f()[j].length() > 15) { -@@ -1018,7 +2341,29 @@ +@@ -1018,7 +2342,29 @@ int k = p_147343_1_.func_149586_d(); i = p_147343_1_.func_149585_e(); TileEntitySign tileentitysign1 = (TileEntitySign)tileentity; @@ -1835,7 +1842,7 @@ tileentitysign1.markDirty(); worldserver.markBlockForUpdate(j, k, i); } -@@ -1041,7 +2386,22 @@ +@@ -1041,7 +2387,22 @@ public void processPlayerAbilities(C13PacketPlayerAbilities p_147348_1_) { @@ -1859,7 +1866,7 @@ } public void processTabComplete(C14PacketTabComplete p_147341_1_) -@@ -1066,8 +2426,9 @@ +@@ -1066,8 +2427,9 @@ public void processVanilla250Packet(C17PacketCustomPayload p_147349_1_) { PacketBuffer packetbuffer; @@ -1871,7 +1878,7 @@ if ("MC|BEdit".equals(p_147349_1_.func_149559_c())) { -@@ -1075,34 +2436,50 @@ +@@ -1075,34 +2437,50 @@ try { @@ -1932,7 +1939,7 @@ } finally { -@@ -1117,37 +2494,47 @@ +@@ -1117,37 +2495,47 @@ try { @@ -1993,7 +2000,7 @@ } finally { -@@ -1174,9 +2561,12 @@ +@@ -1174,9 +2562,12 @@ ((ContainerMerchant)container).setCurrentRecipeIndex(i); } } @@ -2007,7 +2014,7 @@ } } else if ("MC|AdvCdm".equals(p_147349_1_.func_149559_c())) -@@ -1222,9 +2612,12 @@ +@@ -1222,9 +2613,12 @@ this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.setCommand.success", new Object[] {s1})); } } @@ -2022,7 +2029,7 @@ } finally { -@@ -1257,9 +2650,12 @@ +@@ -1257,9 +2651,12 @@ tileentitybeacon.markDirty(); } } @@ -2037,7 +2044,7 @@ } } } -@@ -1281,6 +2677,13 @@ +@@ -1281,6 +2678,13 @@ containerrepair.updateItemName(""); } } @@ -2051,7 +2058,7 @@ } } -@@ -1292,39 +2695,54 @@ +@@ -1292,39 +2696,54 @@ } } diff --git a/patches/net/minecraft/server/MinecraftServer.java.patch b/patches/net/minecraft/server/MinecraftServer.java.patch index 883081f2..b2b02863 100644 --- a/patches/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/net/minecraft/server/MinecraftServer.java.patch @@ -1,17 +1,21 @@ --- ../src-base/minecraft/net/minecraft/server/MinecraftServer.java +++ ../src-work/minecraft/net/minecraft/server/MinecraftServer.java -@@ -1,5 +1,6 @@ +@@ -1,5 +1,9 @@ package net.minecraft.server; ++import co.aikar.timings.FullServerTickHandler; ++import co.aikar.timings.MinecraftTimings; ++import co.aikar.timings.TimingsManager; +import com.avaje.ebean.LogLevel; import com.google.common.base.Charsets; import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfileRepository; -@@ -12,10 +13,12 @@ +@@ -12,10 +16,13 @@ import cpw.mods.fml.common.StartupQuery; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import io.github.crucible.CrucibleConfigs; ++import io.github.crucible.CrucibleTimings; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; @@ -20,7 +24,7 @@ import java.awt.GraphicsEnvironment; import java.awt.image.BufferedImage; import java.io.File; -@@ -33,7 +36,10 @@ +@@ -33,7 +40,10 @@ import java.util.Random; import java.util.UUID; import java.util.concurrent.Callable; @@ -31,7 +35,7 @@ import net.minecraft.command.CommandBase; import net.minecraft.command.ICommandManager; import net.minecraft.command.ICommandSender; -@@ -50,6 +56,7 @@ +@@ -50,6 +60,7 @@ import net.minecraft.profiler.PlayerUsageSnooper; import net.minecraft.profiler.Profiler; import net.minecraft.server.dedicated.DedicatedServer; @@ -39,7 +43,7 @@ import net.minecraft.server.gui.IUpdatePlayerListBox; import net.minecraft.server.management.PlayerProfileCache; import net.minecraft.server.management.ServerConfigurationManager; -@@ -72,6 +79,7 @@ +@@ -72,6 +83,7 @@ import net.minecraft.world.storage.ISaveFormat; import net.minecraft.world.storage.ISaveHandler; import net.minecraft.world.storage.WorldInfo; @@ -47,7 +51,7 @@ import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -@@ -79,19 +87,57 @@ +@@ -79,19 +91,56 @@ import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.WorldEvent; @@ -61,7 +65,6 @@ +import net.minecraft.world.chunk.storage.AnvilSaveHandler; + +import org.bukkit.World.Environment; -+import org.bukkit.craftbukkit.SpigotTimings; // Spigot +import org.bukkit.craftbukkit.util.Waitable; +import org.bukkit.event.server.RemoteServerCommandEvent; +import org.bukkit.event.world.WorldSaveEvent; @@ -108,7 +111,7 @@ private final ServerStatusResponse field_147147_p = new ServerStatusResponse(); private final Random field_147146_q = new Random(); @SideOnly(Side.SERVER) -@@ -135,8 +181,41 @@ +@@ -135,8 +184,42 @@ private long field_147142_T = 0L; private final GameProfileRepository field_152365_W; private final PlayerProfileCache field_152366_X; @@ -142,6 +145,7 @@ + public static boolean useJline = true; + public static boolean useConsole = true; + public static boolean callingForgeTick = false; ++ public static boolean serverStarted = false; + public static List> bannedTileEntityUpdates = new ArrayList>(); + // Cauldron end private static final String __OBFID = "CL_00001462"; @@ -150,7 +154,7 @@ public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_) { this.field_152366_X = new PlayerProfileCache(this, field_152367_a); -@@ -149,10 +228,73 @@ +@@ -149,10 +232,73 @@ this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString()); this.field_147143_S = this.field_152364_T.createMinecraftSessionService(); this.field_152365_W = this.field_152364_T.createProfileRepository(); @@ -225,7 +229,7 @@ protected void convertMapIfNeeded(String p_71237_1_) { if (this.getActiveAnvilConverter().isOldMapFormat(p_71237_1_)) -@@ -172,6 +314,7 @@ +@@ -172,6 +318,7 @@ MinecraftServer.logger.info("Converting... " + p_73718_1_ + "%"); } } @@ -233,7 +237,7 @@ @SideOnly(Side.CLIENT) public void resetProgressAndMessage(String p_73721_1_) {} @SideOnly(Side.CLIENT) -@@ -195,10 +338,17 @@ +@@ -195,10 +342,17 @@ protected void loadAllWorlds(String p_71247_1_, String p_71247_2_, long p_71247_3_, WorldType p_71247_5_, String p_71247_6_) { @@ -253,7 +257,7 @@ WorldSettings worldsettings; if (worldinfo == null) -@@ -215,11 +365,79 @@ +@@ -215,11 +369,79 @@ { worldsettings.enableBonusChest(); } @@ -336,7 +340,7 @@ world.addWorldAccess(new WorldManager(this, world)); if (!this.isSinglePlayer()) -@@ -227,12 +445,14 @@ +@@ -227,12 +449,14 @@ world.getWorldInfo().setGameType(this.getGameType()); } @@ -354,7 +358,7 @@ } protected void initialWorldChunkLoad() -@@ -244,9 +464,12 @@ +@@ -244,9 +468,12 @@ int i = 0; this.setUserMessage("menu.generatingTerrain"); byte b0 = 0; @@ -367,7 +371,7 @@ long j = getSystemTimeMillis(); for (int k = -192; k <= 192 && this.isServerRunning(); k += 16) -@@ -265,7 +488,8 @@ +@@ -265,7 +492,8 @@ worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + k >> 4, chunkcoordinates.posZ + l >> 4); } } @@ -377,7 +381,7 @@ this.clearCurrentTask(); } -@@ -292,19 +516,17 @@ +@@ -292,46 +520,68 @@ { this.currentTask = null; this.percentDone = 0; @@ -402,13 +406,17 @@ if (worldserver != null) { -@@ -313,25 +535,45 @@ ++ worldserver.timings.worldSave.startTiming(); //Crucible + if (!p_71267_1_) + { logger.info("Saving chunks for level \'" + worldserver.getWorldInfo().getWorldName() + "\'/" + worldserver.provider.getDimensionName()); } - try + worldserver.saveAllChunks(true, (IProgressUpdate) null); ++ worldserver.timings.worldIOFlush.startTiming(); + worldserver.flush(); ++ worldserver.timings.worldIOFlush.stopTiming(); + WorldSaveEvent event = new WorldSaveEvent(worldserver.getWorld()); + this.server.getPluginManager().callEvent(event); + // Cauldron start - save world configs @@ -428,6 +436,7 @@ + worldserver.sushchestvoConfig.save(); + } + // Cauldron end ++ worldserver.timings.worldSave.stopTiming(); //Crucible } } + @@ -453,7 +462,7 @@ if (this.func_147137_ag() != null) { this.func_147137_ag().terminateEndpoints(); -@@ -347,7 +589,14 @@ +@@ -347,7 +597,14 @@ if (this.worldServers != null) { logger.info("Saving worlds"); @@ -469,7 +478,7 @@ for (int i = 0; i < this.worldServers.length; ++i) { -@@ -380,6 +629,13 @@ +@@ -380,6 +637,13 @@ this.serverRunning = false; } @@ -483,7 +492,7 @@ public void run() { try -@@ -392,45 +648,55 @@ +@@ -392,45 +656,56 @@ this.field_147147_p.func_151315_a(new ChatComponentText(this.motd)); this.field_147147_p.func_151321_a(new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.7.10", 5)); this.func_147138_a(this.field_147147_p); @@ -505,6 +514,7 @@ + logger.log(org.apache.logging.log4j.Level.INFO, "[Thermos] Refusing to lock affinity, disabled in cauldron.yml"); + } + try { ++ serverStarted = true; //Crucible while (this.serverRunning) { - long j = getSystemTimeMillis(); @@ -566,7 +576,7 @@ FMLCommonHandler.instance().handleServerStopping(); FMLCommonHandler.instance().expectServerStopped(); // has to come before finalTick to avoid race conditions } -@@ -448,6 +714,14 @@ +@@ -448,6 +723,14 @@ catch (Throwable throwable1) { logger.error("Encountered an unexpected exception", throwable1); @@ -581,7 +591,7 @@ CrashReport crashreport = null; if (throwable1 instanceof ReportedException) -@@ -477,6 +751,7 @@ +@@ -477,6 +760,7 @@ { try { @@ -589,7 +599,7 @@ this.stopServer(); this.serverStopped = true; } -@@ -486,6 +761,16 @@ +@@ -486,6 +770,16 @@ } finally { @@ -606,7 +616,7 @@ FMLCommonHandler.instance().handleServerStopped(); this.serverStopped = true; this.systemExitNow(); -@@ -497,6 +782,11 @@ +@@ -497,6 +791,11 @@ { File file1 = this.getFile("server-icon.png"); @@ -618,7 +628,7 @@ if (file1.isFile()) { ByteBuf bytebuf = Unpooled.buffer(); -@@ -512,7 +802,7 @@ +@@ -512,7 +811,7 @@ } catch (Exception exception) { @@ -627,27 +637,28 @@ } finally { -@@ -532,8 +822,12 @@ +@@ -532,8 +831,14 @@ public void tick() { -+ SpigotTimings.serverTickTimer.startTiming(); // Spigot ++ TimingsManager.FULL_SERVER_TICK.startTiming(); + WatchdogThread.tick(); // Thermos - be a good little WatchDog and actually restart if there's a problem! long i = System.nanoTime(); + callingForgeTick = true; // Cauldron start - handle loadOnProviderRequests during forge tick event ++ CrucibleTimings.forgePreTick.startTiming(); FMLCommonHandler.instance().onPreServerTick(); ++ CrucibleTimings.forgePreTick.stopTiming(); + callingForgeTick = false; // Cauldron end ++this.tickCounter; if (this.startProfiling) -@@ -562,12 +856,21 @@ +@@ -562,11 +867,18 @@ this.field_147147_p.func_151318_b().func_151330_a(agameprofile); } - if (this.tickCounter % 900 == 0) + if ((this.autosavePeriod > 0) && ((this.tickCounter % this.autosavePeriod) == 0)) // CraftBukkit { -+ SpigotTimings.worldSaveTimer.startTiming(); // Spigot this.theProfiler.startSection("save"); this.serverConfigManager.saveAllPlayerData(); - this.saveAllWorlds(true); @@ -660,11 +671,9 @@ + e.printStackTrace(); + } this.theProfiler.endSection(); -+ SpigotTimings.worldSaveTimer.stopTiming(); // Spigot } - this.theProfiler.startSection("tallying"); -@@ -575,25 +878,57 @@ +@@ -575,25 +887,58 @@ this.theProfiler.endSection(); this.theProfiler.startSection("snooper"); @@ -683,33 +692,34 @@ this.theProfiler.endSection(); this.theProfiler.endSection(); + callingForgeTick = true; // Cauldron start - handle loadOnProviderRequests during forge tick event ++ CrucibleTimings.forgePostTick.startTiming(); FMLCommonHandler.instance().onPostServerTick(); ++ CrucibleTimings.forgePostTick.stopTiming(); + callingForgeTick = false; // Cauldron end -+ SpigotTimings.serverTickTimer.stopTiming(); // Spigot -+ org.spigotmc.CustomTimingsHandler.tick(); // Spigot ++ TimingsManager.FULL_SERVER_TICK.stopTiming(); } public void updateTimeLightAndEntities() { this.theProfiler.startSection("levels"); -+ SpigotTimings.schedulerTimer.startTiming(); // Spigot + // CraftBukkit start ++ MinecraftTimings.bukkitSchedulerTimer.startTiming(); + this.server.getScheduler().mainThreadHeartbeat(this.tickCounter); -+ SpigotTimings.schedulerTimer.stopTiming(); // Spigot ++ MinecraftTimings.bukkitSchedulerTimer.stopTiming(); // Crucible + + // Run tasks that are waiting on processing -+ SpigotTimings.processQueueTimer.startTiming(); // Spigot ++ MinecraftTimings.processQueueTimer.startTiming(); //Crucible + while (!processQueue.isEmpty()) + { + processQueue.remove().run(); + } -+ SpigotTimings.processQueueTimer.stopTiming(); // Spigot ++ MinecraftTimings.processQueueTimer.stopTiming(); //Crucible + -+ SpigotTimings.chunkIOTickTimer.startTiming(); // Spigot ++ MinecraftTimings.chunkIOTickTimer.startTiming(); //Crucible net.minecraftforge.common.chunkio.ChunkIOExecutor.tick(); -+ SpigotTimings.chunkIOTickTimer.stopTiming(); // Spigot ++ MinecraftTimings.chunkIOTickTimer.stopTiming(); //Crucible + -+ SpigotTimings.timeUpdateTimer.startTiming(); // Spigot ++ MinecraftTimings.timeUpdateTimer.startTiming(); //Crucible + // Send time updates to everyone, it will get the right time from the world the player is in. + if (this.tickCounter % 20 == 0) + { @@ -719,12 +729,12 @@ + entityplayermp.playerNetServerHandler.sendPacket(new S03PacketTimeUpdate(entityplayermp.worldObj.getTotalWorldTime(), entityplayermp.getPlayerTime(), entityplayermp.worldObj.getGameRules().getGameRuleBooleanValue("doDaylightCycle"))); // for per player time + } + } -+ SpigotTimings.timeUpdateTimer.stopTiming(); // Spigot ++ MinecraftTimings.timeUpdateTimer.stopTiming(); //Crucible + int i; Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0); -@@ -602,19 +937,21 @@ +@@ -602,19 +947,21 @@ int id = ids[x]; long j = System.nanoTime(); @@ -749,7 +759,7 @@ this.theProfiler.startSection("tick"); FMLCommonHandler.instance().onPreWorldTick(worldserver); -@@ -622,22 +959,46 @@ +@@ -622,22 +969,46 @@ try { @@ -798,13 +808,13 @@ worldserver.addWorldInfoToCrashReport(crashreport); throw new ReportedException(crashreport); } -@@ -645,10 +1006,12 @@ +@@ -645,10 +1016,12 @@ FMLCommonHandler.instance().onPostWorldTick(worldserver); this.theProfiler.endSection(); this.theProfiler.startSection("tracker"); -+ worldserver.timings.tracker.startTiming(); // Spigot ++ worldserver.timings.tracker1.startTiming(); // Spigot worldserver.getEntityTracker().updateTrackedEntities(); -+ worldserver.timings.tracker.stopTiming(); // Spigot ++ worldserver.timings.tracker1.stopTiming(); // Spigot this.theProfiler.endSection(); this.theProfiler.endSection(); - } @@ -812,29 +822,29 @@ worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j; } -@@ -656,15 +1019,21 @@ +@@ -656,15 +1029,21 @@ this.theProfiler.endStartSection("dim_unloading"); DimensionManager.unloadWorlds(worldTickTimes); this.theProfiler.endStartSection("connection"); -+ SpigotTimings.connectionTimer.startTiming(); // Spigot ++ MinecraftTimings.connectionTimer.startTiming(); //Crucible this.func_147137_ag().networkTick(); -+ SpigotTimings.connectionTimer.stopTiming(); // Spigot ++ MinecraftTimings.connectionTimer.stopTiming(); //Crucible this.theProfiler.endStartSection("players"); -+ SpigotTimings.playerListTimer.startTiming(); // Spigot ++ MinecraftTimings.playerListTimer.startTiming(); //Crucible this.serverConfigManager.sendPlayerInfoToAllPlayers(); -+ SpigotTimings.playerListTimer.stopTiming(); // Spigot ++ MinecraftTimings.playerListTimer.stopTiming(); //Crucible this.theProfiler.endStartSection("tickables"); -+ SpigotTimings.tickablesTimer.startTiming(); // Spigot ++ MinecraftTimings.tickablesTimer.startTiming(); //Crucible for (i = 0; i < this.tickables.size(); ++i) { ((IUpdatePlayerListBox)this.tickables.get(i)).update(); } -+ SpigotTimings.tickablesTimer.stopTiming(); // Spigot ++ MinecraftTimings.tickablesTimer.stopTiming(); //Crucible this.theProfiler.endSection(); } -@@ -699,6 +1068,13 @@ +@@ -699,6 +1078,13 @@ public WorldServer worldServerForDimension(int p_71218_1_) { @@ -848,7 +858,7 @@ WorldServer ret = DimensionManager.getWorld(p_71218_1_); if (ret == null) { -@@ -784,13 +1160,14 @@ +@@ -784,13 +1170,14 @@ public List getPossibleCompletions(ICommandSender p_71248_1_, String p_71248_2_) { @@ -867,7 +877,7 @@ if (list != null) { -@@ -798,40 +1175,25 @@ +@@ -798,40 +1185,25 @@ while (iterator.hasNext()) { @@ -916,7 +926,7 @@ } public static MinecraftServer getServer() -@@ -1034,7 +1396,7 @@ +@@ -1034,7 +1406,7 @@ public boolean isServerInOnlineMode() { @@ -925,7 +935,7 @@ } public void setOnlineMode(boolean p_71229_1_) -@@ -1124,7 +1486,7 @@ +@@ -1124,7 +1496,7 @@ public NetworkSystem func_147137_ag() { @@ -934,7 +944,7 @@ } @SideOnly(Side.CLIENT) -@@ -1259,8 +1621,11 @@ +@@ -1259,8 +1631,11 @@ { Bootstrap.func_151354_b(); @@ -946,7 +956,7 @@ boolean flag = true; String s = null; String s1 = "."; -@@ -1271,7 +1636,7 @@ +@@ -1271,7 +1646,7 @@ for (int j = 0; j < p_main_0_.length; ++j) { @@ -955,7 +965,7 @@ String s4 = j == p_main_0_.length - 1 ? null : p_main_0_[j + 1]; boolean flag3 = false; -@@ -1356,16 +1721,34 @@ +@@ -1356,16 +1731,34 @@ { dedicatedserver.setGuiEnabled(); } @@ -996,7 +1006,7 @@ } catch (Exception exception) { -@@ -1400,15 +1783,70 @@ +@@ -1400,15 +1793,70 @@ @SideOnly(Side.SERVER) public String getPlugins() { @@ -1072,7 +1082,7 @@ } @SideOnly(Side.SERVER) -@@ -1455,9 +1893,218 @@ +@@ -1455,9 +1903,218 @@ return this.serverStopped; } diff --git a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch index 71f1b6bb..0b16178e 100644 --- a/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,6 +1,9 @@ --- ../src-base/minecraft/net/minecraft/server/dedicated/DedicatedServer.java +++ ../src-work/minecraft/net/minecraft/server/dedicated/DedicatedServer.java -@@ -3,6 +3,7 @@ +@@ -1,8 +1,10 @@ + package net.minecraft.server.dedicated; + ++import co.aikar.timings.MinecraftTimings; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -8,7 +11,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; -@@ -34,9 +35,19 @@ +@@ -34,9 +36,18 @@ import net.minecraft.world.World; import net.minecraft.world.WorldSettings; import net.minecraft.world.WorldType; @@ -21,7 +24,6 @@ +import org.apache.logging.log4j.Level; + +import org.bukkit.craftbukkit.LoggerOutputStream; -+import org.bukkit.craftbukkit.SpigotTimings; // Spigot +import org.bukkit.event.server.ServerCommandEvent; +// CraftBukkit end + @@ -240,7 +242,7 @@ public void executePendingCommands() { -+ SpigotTimings.serverCommandTimer.startTiming(); // Spigot ++ MinecraftTimings.serverCommandTimer.startTiming(); // Spigot while (!this.pendingCommandList.isEmpty()) { - ServerCommand servercommand = (ServerCommand)this.pendingCommandList.remove(0); @@ -254,7 +256,7 @@ + this.server.dispatchServerCommand(this.console, servercommand); + // CraftBukkit end } -+ SpigotTimings.serverCommandTimer.stopTiming(); // Spigot ++ MinecraftTimings.serverCommandTimer.stopTiming(); // Spigot } public boolean isDedicatedServer() diff --git a/patches/net/minecraft/tileentity/TileEntity.java.patch b/patches/net/minecraft/tileentity/TileEntity.java.patch index 556dc371..e5c5c844 100644 --- a/patches/net/minecraft/tileentity/TileEntity.java.patch +++ b/patches/net/minecraft/tileentity/TileEntity.java.patch @@ -1,11 +1,17 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntity.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntity.java -@@ -22,20 +22,32 @@ +@@ -1,5 +1,7 @@ + package net.minecraft.tileentity; + ++import co.aikar.timings.MinecraftTimings; ++import co.aikar.timings.Timing; + import cpw.mods.fml.common.FMLLog; + import cpw.mods.fml.relauncher.Side; + import cpw.mods.fml.relauncher.SideOnly; +@@ -22,20 +24,30 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -+import org.bukkit.craftbukkit.Overridden; -+import org.spigotmc.CustomTimingsHandler; // Spigot +import org.bukkit.inventory.InventoryHolder; // CraftBukkit + public class TileEntity @@ -23,7 +29,7 @@ protected boolean tileEntityInvalid; public int blockMetadata = -1; public Block blockType; -+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot ++ public Timing tickTimer = MinecraftTimings.getTileEntityTimings(this); // Paper private static final String __OBFID = "CL_00000340"; + @Override diff --git a/patches/net/minecraft/world/World.java.patch b/patches/net/minecraft/world/World.java.patch index a6a6aac5..ae11d503 100644 --- a/patches/net/minecraft/world/World.java.patch +++ b/patches/net/minecraft/world/World.java.patch @@ -1,7 +1,9 @@ --- ../src-base/minecraft/net/minecraft/world/World.java +++ ../src-work/minecraft/net/minecraft/world/World.java -@@ -2,9 +2,11 @@ +@@ -1,10 +1,13 @@ + package net.minecraft.world; ++import co.aikar.timings.*; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + @@ -12,7 +14,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; -@@ -12,6 +14,9 @@ +@@ -12,6 +15,9 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.Callable; @@ -22,7 +24,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockHopper; import net.minecraft.block.BlockLiquid; -@@ -23,11 +28,15 @@ +@@ -23,11 +29,15 @@ import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.entity.Entity; @@ -38,7 +40,7 @@ import net.minecraft.pathfinding.PathEntity; import net.minecraft.pathfinding.PathFinder; import net.minecraft.profiler.Profiler; -@@ -51,7 +60,6 @@ +@@ -51,7 +61,6 @@ import net.minecraft.world.storage.ISaveHandler; import net.minecraft.world.storage.MapStorage; import net.minecraft.world.storage.WorldInfo; @@ -46,7 +48,7 @@ import cpw.mods.fml.common.FMLLog; import com.google.common.collect.ImmutableSetMultimap; -@@ -67,9 +75,63 @@ +@@ -67,9 +76,61 @@ import net.minecraftforge.event.entity.EntityEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.world.WorldEvent; @@ -90,8 +92,6 @@ +// Spigot Start +import net.minecraft.entity.item.EntityXPOrb; + -+import org.bukkit.craftbukkit.SpigotTimings; -+ +// Spigot end +// Cauldron start +import net.minecraft.nbt.NBTTagCompound; @@ -110,7 +110,7 @@ public abstract class World implements IBlockAccess { /** -@@ -82,16 +144,15 @@ +@@ -82,16 +143,15 @@ public final MapStorage perWorldStorage; public boolean scheduledUpdatesAreImmediate; @@ -132,7 +132,7 @@ protected final int DIST_HASH_MAGIC = 1013904223; public float prevRainingStrength; public float rainingStrength; -@@ -99,27 +160,92 @@ +@@ -99,27 +159,92 @@ public float thunderingStrength; public int lastLightningBolt; public EnumDifficulty difficultySetting; @@ -233,7 +233,7 @@ private static final String __OBFID = "CL_00000140"; public boolean restoringBlockSnapshots = false; public boolean captureBlockSnapshots = false; -@@ -166,6 +292,27 @@ +@@ -166,6 +291,27 @@ return this.provider.worldChunkMgr; } @@ -243,7 +243,7 @@ + public boolean keepSpawnInMemory = false; // Cauldron - default to false to give forge's keepLoaded higher priority + public ChunkGenerator generator; + public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot -+ public final SpigotTimings.WorldTimingsHandler timings; // Spigot ++ public final WorldTimingsHandler timings; // Crucible + private org.spigotmc.TickLimiter entityLimiter; // Spigot + private org.spigotmc.TickLimiter tileLimiter; // Spigot + private int tileTickPosition; // Spigot @@ -261,7 +261,7 @@ @SideOnly(Side.CLIENT) public World(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvider p_i45368_3_, WorldSettings p_i45368_4_, Profiler p_i45368_5_) { -@@ -179,6 +326,12 @@ +@@ -179,6 +325,12 @@ this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_); this.provider = p_i45368_3_; perWorldStorage = new MapStorage((ISaveHandler)null); @@ -274,7 +274,7 @@ } // Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes -@@ -207,8 +360,182 @@ +@@ -207,8 +359,182 @@ this.calculateInitialWeather(); } @@ -384,7 +384,7 @@ + this.perWorldStorage = new MapStorage((ISaveHandler) null); + } + -+ timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings ++ timings = new WorldTimingsHandler(this); // Crucible - code below can generate new world and access timings + if (!this.worldInfo.isInitialized()) + { + try @@ -457,7 +457,7 @@ this.ambientTickCountdown = this.rand.nextInt(12000); this.spawnHostileMobs = true; this.spawnPeacefulMobs = true; -@@ -216,7 +543,6 @@ +@@ -216,7 +542,6 @@ this.lightUpdateBlockList = new int[32768]; this.saveHandler = p_i45369_1_; this.theProfiler = p_i45369_5_; @@ -465,7 +465,7 @@ this.worldInfo = p_i45369_1_.loadWorldInfo(); if (p_i45369_4_ != null) -@@ -235,15 +561,33 @@ +@@ -235,15 +560,33 @@ if (this.worldInfo == null) { this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_); @@ -500,7 +500,7 @@ if (this instanceof WorldServer) { this.perWorldStorage = new MapStorage(new WorldSpecificSaveHandler((WorldServer)this, p_i45369_1_)); -@@ -294,6 +638,7 @@ +@@ -294,6 +637,7 @@ this.calculateInitialSkylight(); this.calculateInitialWeather(); } @@ -508,7 +508,7 @@ private static MapStorage s_mapStorage; private static ISaveHandler s_savehandler; -@@ -336,6 +681,18 @@ +@@ -336,6 +680,18 @@ public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_) { @@ -527,7 +527,7 @@ if (p_147439_1_ >= -30000000 && p_147439_3_ >= -30000000 && p_147439_1_ < 30000000 && p_147439_3_ < 30000000 && p_147439_2_ >= 0 && p_147439_2_ < 256) { Chunk chunk = null; -@@ -376,35 +733,60 @@ +@@ -376,35 +732,60 @@ return this.checkChunksExist(p_72873_1_ - p_72873_4_, p_72873_2_ - p_72873_4_, p_72873_3_ - p_72873_4_, p_72873_1_ + p_72873_4_, p_72873_2_ + p_72873_4_, p_72873_3_ + p_72873_4_); } @@ -616,7 +616,7 @@ { return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_); } -@@ -421,6 +803,27 @@ +@@ -421,6 +802,27 @@ public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_) { @@ -644,7 +644,7 @@ if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000) { if (p_147465_2_ < 0) -@@ -448,8 +851,22 @@ +@@ -448,8 +850,22 @@ this.capturedBlockSnapshots.add(blockSnapshot); } @@ -667,7 +667,7 @@ if (!flag && blockSnapshot != null) { this.capturedBlockSnapshots.remove(blockSnapshot); -@@ -460,6 +877,7 @@ +@@ -460,6 +876,7 @@ this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_); this.theProfiler.endSection(); @@ -675,7 +675,7 @@ if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates { // Modularize client and physic updates -@@ -496,6 +914,19 @@ +@@ -496,6 +913,19 @@ public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_) { @@ -695,7 +695,7 @@ if (p_72805_1_ >= -30000000 && p_72805_3_ >= -30000000 && p_72805_1_ < 30000000 && p_72805_3_ < 30000000) { if (p_72805_2_ < 0) -@@ -511,7 +942,7 @@ +@@ -511,7 +941,7 @@ Chunk chunk = this.getChunkFromChunkCoords(p_72805_1_ >> 4, p_72805_3_ >> 4); p_72805_1_ &= 15; p_72805_3_ &= 15; @@ -704,7 +704,7 @@ } } else -@@ -610,6 +1041,12 @@ +@@ -610,6 +1040,12 @@ public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_) { @@ -717,7 +717,7 @@ this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_); } -@@ -694,6 +1131,21 @@ +@@ -694,6 +1130,21 @@ try { @@ -739,7 +739,7 @@ block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_); } catch (Throwable throwable1) -@@ -947,14 +1399,13 @@ +@@ -947,14 +1398,13 @@ { int l = p_72972_2_ >> 4; int i1 = p_72972_4_ >> 4; @@ -756,7 +756,7 @@ return chunk.getSavedLightValue(p_72972_1_, p_72972_2_ & 15, p_72972_3_, p_72972_4_ & 15); } } -@@ -1304,9 +1755,24 @@ +@@ -1304,9 +1754,24 @@ this.weatherEffects.add(p_72942_1_); return true; } @@ -782,7 +782,7 @@ // do not drop any items while restoring blocksnapshots. Prevents dupes if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false; -@@ -1319,23 +1785,99 @@ +@@ -1319,23 +1784,99 @@ flag = true; } @@ -884,7 +884,7 @@ return true; } } -@@ -1346,6 +1888,8 @@ +@@ -1346,6 +1887,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_); } @@ -893,7 +893,7 @@ } public void onEntityRemoved(Entity p_72847_1_) -@@ -1354,6 +1898,8 @@ +@@ -1354,6 +1897,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_); } @@ -902,7 +902,7 @@ } public void removeEntity(Entity p_72900_1_) -@@ -1397,6 +1943,19 @@ +@@ -1397,6 +1942,19 @@ } this.loadedEntityList.remove(p_72973_1_); @@ -922,7 +922,7 @@ this.onEntityRemoved(p_72973_1_); } -@@ -1407,42 +1966,62 @@ +@@ -1407,42 +1965,62 @@ public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_) { @@ -1000,7 +1000,7 @@ for (int j2 = 0; j2 < list.size(); ++j2) { AxisAlignedBB axisalignedbb1 = ((Entity)list.get(j2)).getBoundingBox(); -@@ -1797,11 +2376,22 @@ +@@ -1797,11 +2375,22 @@ Entity entity; CrashReport crashreport; CrashReportCategory crashreportcategory; @@ -1023,31 +1023,34 @@ try { ++entity.ticksExisted; -@@ -1862,10 +2452,14 @@ +@@ -1862,11 +2451,15 @@ this.unloadedEntityList.clear(); this.theProfiler.endStartSection("regular"); + org.spigotmc.ActivationRange.activateEntities(this); // Spigot + timings.entityTick.startTiming(); // Spigot - -- for (i = 0; i < this.loadedEntityList.size(); ++i) -- { -- entity = (Entity)this.loadedEntityList.get(i); ++ TimingHistory.entityTicks += this.loadedEntityList.size(); // Paper + int entitiesThisCycle = 0; + if (tickPosition < 0) tickPosition = 0; + for (entityLimiter.initTick(); entitiesThisCycle < loadedEntityList.size() && (entitiesThisCycle % 10 == 0 || entityLimiter.shouldContinue()); tickPosition++, entitiesThisCycle++) { + tickPosition = (tickPosition < loadedEntityList.size()) ? tickPosition : 0; + entity = (Entity)this.loadedEntityList.get(this.tickPosition); +- for (i = 0; i < this.loadedEntityList.size(); ++i) +- { +- entity = (Entity)this.loadedEntityList.get(i); +- if (entity.ridingEntity != null) { -@@ -1884,7 +2478,9 @@ + if (!entity.ridingEntity.isDead && entity.ridingEntity.riddenByEntity == entity) +@@ -1884,7 +2477,10 @@ { try { -+ SpigotTimings.tickEntityTimer.startTiming(); // Spigot ++ ++TimingHistory.entityTicks; // Paper //TODO ? ++ MinecraftTimings.tickEntityTimer.startTiming(); // Spigot this.updateEntity(entity); -+ SpigotTimings.tickEntityTimer.stopTiming(); // Spigot ++ MinecraftTimings.tickEntityTimer.stopTiming(); // Spigot } catch (Throwable throwable1) { @@ -1195,11 +1198,12 @@ { if (this.chunkExists(tileentity1.xCoord >> 4, tileentity1.zCoord >> 4)) { -@@ -2016,17 +2655,24 @@ +@@ -2016,17 +2655,25 @@ this.addedTileEntityList.clear(); } + timings.tileEntityPending.stopTiming(); // Spigot ++ co.aikar.timings.TimingHistory.tileEntityTicks += this.tilesTicked; // Paper this.theProfiler.endSection(); this.theProfiler.endSection(); + @@ -1223,7 +1227,7 @@ } public void updateEntity(Entity p_72870_1_) -@@ -2036,11 +2682,16 @@ +@@ -2036,11 +2683,16 @@ public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_) { @@ -1243,7 +1247,7 @@ if (!canUpdate) { -@@ -2048,9 +2699,30 @@ +@@ -2048,9 +2700,30 @@ MinecraftForge.EVENT_BUS.post(event); canUpdate = event.canUpdate; } @@ -1275,7 +1279,7 @@ p_72866_1_.lastTickPosX = p_72866_1_.posX; p_72866_1_.lastTickPosY = p_72866_1_.posY; p_72866_1_.lastTickPosZ = p_72866_1_.posZ; -@@ -2134,6 +2806,7 @@ +@@ -2134,6 +2807,7 @@ p_72866_1_.riddenByEntity = null; } } @@ -1283,7 +1287,7 @@ } } -@@ -2570,7 +3243,7 @@ +@@ -2570,7 +3244,7 @@ return; } @@ -1292,7 +1296,7 @@ { if (this.field_147481_N) { -@@ -2606,12 +3279,32 @@ +@@ -2606,12 +3280,32 @@ public void removeTileEntity(int p_147475_1_, int p_147475_2_, int p_147475_3_) { Chunk chunk = getChunkFromChunkCoords(p_147475_1_ >> 4, p_147475_3_ >> 4); @@ -1325,7 +1329,7 @@ this.field_147483_b.add(p_147457_1_); } -@@ -2718,7 +3411,15 @@ +@@ -2718,7 +3412,15 @@ if (i <= 0) { @@ -1342,7 +1346,7 @@ } } -@@ -2754,7 +3455,15 @@ +@@ -2754,7 +3456,15 @@ if (j <= 0) { @@ -1359,7 +1363,7 @@ } } -@@ -2777,8 +3486,41 @@ +@@ -2777,8 +3487,41 @@ protected void setActivePlayerChunksAndCheckLight() { this.activeChunkSet.clear(); @@ -1402,7 +1406,7 @@ int i; EntityPlayer entityplayer; int j; -@@ -2788,17 +3530,28 @@ +@@ -2788,17 +3531,28 @@ for (i = 0; i < this.playerEntities.size(); ++i) { entityplayer = (EntityPlayer)this.playerEntities.get(i); @@ -1437,7 +1441,7 @@ } this.theProfiler.endSection(); -@@ -2810,7 +3563,7 @@ +@@ -2810,7 +3564,7 @@ this.theProfiler.startSection("playerCheckLight"); @@ -1446,7 +1450,7 @@ { i = this.rand.nextInt(this.playerEntities.size()); entityplayer = (EntityPlayer)this.playerEntities.get(i); -@@ -3034,9 +3787,9 @@ +@@ -3034,9 +3788,9 @@ } } @@ -1458,7 +1462,7 @@ { return false; } -@@ -3166,6 +3919,28 @@ +@@ -3166,6 +3920,28 @@ } } @@ -1487,7 +1491,7 @@ this.theProfiler.endSection(); return true; } -@@ -3188,7 +3963,7 @@ +@@ -3188,7 +3964,7 @@ public List getEntitiesWithinAABBExcludingEntity(Entity p_94576_1_, AxisAlignedBB p_94576_2_, IEntitySelector p_94576_3_) { @@ -1496,7 +1500,7 @@ int i = MathHelper.floor_double((p_94576_2_.minX - MAX_ENTITY_RADIUS) / 16.0D); int j = MathHelper.floor_double((p_94576_2_.maxX + MAX_ENTITY_RADIUS) / 16.0D); int k = MathHelper.floor_double((p_94576_2_.minZ - MAX_ENTITY_RADIUS) / 16.0D); -@@ -3219,7 +3994,7 @@ +@@ -3219,7 +3995,7 @@ int j = MathHelper.floor_double((p_82733_2_.maxX + MAX_ENTITY_RADIUS) / 16.0D); int k = MathHelper.floor_double((p_82733_2_.minZ - MAX_ENTITY_RADIUS) / 16.0D); int l = MathHelper.floor_double((p_82733_2_.maxZ + MAX_ENTITY_RADIUS) / 16.0D); @@ -1505,7 +1509,7 @@ for (int i1 = i; i1 <= j; ++i1) { -@@ -3284,8 +4059,21 @@ +@@ -3284,8 +4060,21 @@ { Entity entity = (Entity)this.loadedEntityList.get(j); @@ -1528,7 +1532,7 @@ ++i; } } -@@ -3298,6 +4086,7 @@ +@@ -3298,6 +4087,7 @@ for (int i = 0; i < p_72868_1_.size(); ++i) { Entity entity = (Entity)p_72868_1_.get(i); @@ -1536,7 +1540,7 @@ if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this))) { loadedEntityList.add(entity); -@@ -3314,8 +4103,17 @@ +@@ -3314,8 +4104,17 @@ public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_) { Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_); @@ -1555,7 +1559,7 @@ } public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_) -@@ -3464,6 +4262,12 @@ +@@ -3464,6 +4263,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1568,7 +1572,7 @@ double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_); if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4)) -@@ -3489,7 +4293,12 @@ +@@ -3489,7 +4294,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1582,7 +1586,7 @@ if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) { double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_); -@@ -3660,6 +4469,18 @@ +@@ -3660,6 +4470,18 @@ public void updateAllPlayersSleepingFlag() {} @@ -1601,7 +1605,7 @@ public float getWeightedThunderStrength(float p_72819_1_) { return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_); -@@ -3932,8 +4753,8 @@ +@@ -3932,8 +4754,8 @@ */ public void addTileEntity(TileEntity entity) { @@ -1612,7 +1616,7 @@ { dest.add(entity); } -@@ -4029,4 +4850,147 @@ +@@ -4029,4 +4851,147 @@ } return count; } diff --git a/patches/net/minecraft/world/WorldServer.java.patch b/patches/net/minecraft/world/WorldServer.java.patch index 3f10c6f0..a3fcd631 100644 --- a/patches/net/minecraft/world/WorldServer.java.patch +++ b/patches/net/minecraft/world/WorldServer.java.patch @@ -210,13 +210,13 @@ + timings.doChunkUnload.stopTiming(); // Spigot this.theProfiler.endStartSection("tickPending"); -+ timings.doTickPending.startTiming(); // Spigot ++ timings.chunkTicksBlocks.startTiming(); // Paper this.tickUpdates(false); -+ timings.doTickPending.stopTiming(); // Spigot ++ timings.chunkTicksBlocks.stopTiming(); // Paper this.theProfiler.endStartSection("tickBlocks"); -+ timings.doTickTiles.startTiming(); // Spigot ++ timings.chunkTicksBlocks.startTiming(); // Spigot this.func_147456_g(); -+ timings.doTickTiles.stopTiming(); // Spigot ++ timings.chunkTicksBlocks.stopTiming(); // Spigot this.theProfiler.endStartSection("chunkMap"); + timings.doChunkMap.startTiming(); // Spigot this.thePlayerManager.updatePlayerInstances(); @@ -670,7 +670,26 @@ if (chunkposition != null) { i = chunkposition.chunkPosX; -@@ -876,6 +1158,20 @@ +@@ -799,14 +1081,16 @@ + p_73044_2_.displayProgressMessage("Saving level"); + } + ++ timings.worldSaveLevel.startTiming(); //Crucible + this.saveLevel(); +- ++ timings.worldSaveLevel.stopTiming(); //Crucible + if (p_73044_2_ != null) + { + p_73044_2_.resetProgresAndWorkingMessage("Saving chunks"); + } +- ++ timings.worldSaveChunks.startTiming(); //Crucible + this.chunkProvider.saveChunks(p_73044_1_, p_73044_2_); ++ timings.worldSaveChunks.stopTiming(); //Crucible + MinecraftForge.EVENT_BUS.post(new WorldEvent.Save(this)); + ArrayList arraylist = Lists.newArrayList(this.theChunkProviderServer.func_152380_a()); + Iterator iterator = arraylist.iterator(); +@@ -876,6 +1160,20 @@ public boolean addWeatherEffect(Entity p_72942_1_) { @@ -691,7 +710,7 @@ if (super.addWeatherEffect(p_72942_1_)) { this.mcServer.getConfigurationManager().sendToAllNear(p_72942_1_.posX, p_72942_1_.posY, p_72942_1_.posZ, 512.0D, this.provider.dimensionId, new S2CPacketSpawnGlobalEntity(p_72942_1_)); -@@ -894,13 +1190,24 @@ +@@ -894,13 +1192,24 @@ public Explosion newExplosion(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_) { @@ -717,7 +736,7 @@ if (!p_72885_10_) { explosion.affectedBlockPositions.clear(); -@@ -977,7 +1284,8 @@ +@@ -977,7 +1286,8 @@ { boolean flag = this.isRaining(); super.updateWeather(); @@ -727,7 +746,7 @@ if (this.prevRainingStrength != this.rainingStrength) { this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); -@@ -987,11 +1295,9 @@ +@@ -987,11 +1297,9 @@ { this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); } @@ -741,7 +760,7 @@ if (flag != this.isRaining()) { if (flag) -@@ -1006,6 +1312,33 @@ +@@ -1006,6 +1314,33 @@ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); } @@ -775,7 +794,7 @@ } protected int func_152379_p() -@@ -1069,4 +1402,53 @@ +@@ -1069,4 +1404,53 @@ this(); } } diff --git a/patches/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch b/patches/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch index 50dee45b..0285ba88 100644 --- a/patches/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch +++ b/patches/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch @@ -184,7 +184,7 @@ public void loadEntities(World p_75823_1_, NBTTagCompound p_75823_2_, Chunk chunk) { -+ p_75823_1_.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot ++ //p_75823_1_.timings.syncChunkLoadEntitiesTimer.startTiming(); // Spigot NBTTagList nbttaglist1 = p_75823_2_.getTagList("Entities", 10); if (nbttaglist1 != null) @@ -224,8 +224,8 @@ } } -+ p_75823_1_.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot -+ p_75823_1_.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot ++ // p_75823_1_.timings.syncChunkLoadEntitiesTimer.stopTiming(); // Spigot ++ // p_75823_1_.timings.syncChunkLoadTileEntitiesTimer.startTiming(); // Spigot NBTTagList nbttaglist2 = p_75823_2_.getTagList("TileEntities", 10); if (nbttaglist2 != null) @@ -260,8 +260,8 @@ } } -+ p_75823_1_.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot -+ p_75823_1_.timings.syncChunkLoadTileTicksTimer.startTiming(); // Spigot ++ //p_75823_1_.timings.syncChunkLoadTileEntitiesTimer.stopTiming(); // Spigot ++ //p_75823_1_.timings.syncChunkLoadTileTicksTimer.startTiming(); // Spigot if (p_75823_2_.hasKey("TileTicks", 9)) { NBTTagList nbttaglist3 = p_75823_2_.getTagList("TileTicks", 10); @@ -269,7 +269,7 @@ } } } -+ p_75823_1_.timings.syncChunkLoadTileTicksTimer.stopTiming(); // Spigot ++ //p_75823_1_.timings.syncChunkLoadTileTicksTimer.stopTiming(); // Spigot // return chunk; } diff --git a/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch b/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch index 0ae9942b..19be474b 100644 --- a/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch +++ b/patches/net/minecraft/world/gen/ChunkProviderServer.java.patch @@ -75,7 +75,7 @@ + public Chunk defaultEmptyChunk; + public IChunkProvider currentChunkProvider; + public IChunkLoader currentChunkLoader; -+ public boolean loadChunkOnProvideRequest = MinecraftServer.getServer().cauldronConfig.loadChunkOnRequest.getValue(); // Cauldron - if true, allows mods to force load chunks. to disable, set load-chunk-on-request in cauldron.yml to false ++ public boolean loadChunkOnProvideRequest = MinecraftServer.cauldronConfig.loadChunkOnRequest.getValue(); // Cauldron - if true, allows mods to force load chunks. to disable, set load-chunk-on-request in cauldron.yml to false + public int initialTick; // Cauldron counter to keep track of when this loader was created + public List loadedChunks = new ArrayList(); // Cauldron - vanilla compatibility + public WorldServer worldObj; @@ -418,9 +418,11 @@ } } -@@ -277,6 +467,35 @@ +@@ -276,21 +466,56 @@ + if (this.currentChunkProvider != null) { ++ try (co.aikar.timings.Timing ignored = this.worldObj.timings.syncChunkLoadPopulateTimer.startTiming()) { // Paper //Crucible - Is this right? I think so this.currentChunkProvider.populate(p_73153_1_, p_73153_2_, p_73153_3_); + // CraftBukkit start + BlockSand.fallInstantly = true; @@ -453,10 +455,14 @@ + // CraftBukkit end GameRegistry.generateWorld(p_73153_2_, p_73153_3_, worldObj, currentChunkProvider, p_73153_1_); chunk.setChunkModified(); ++ } // Paper } -@@ -286,11 +505,14 @@ + } + } + public boolean saveChunks(boolean p_73151_1_, IProgressUpdate p_73151_2_) { ++ try (co.aikar.timings.Timing timed = worldObj.timings.chunkSaveData.startTiming()) { // Paper - Timings //Crucible - Is this right? I think so int i = 0; - ArrayList arraylist = Lists.newArrayList(this.loadedChunks); + // Cauldron start - use thread-safe method for iterating loaded chunks @@ -472,7 +478,16 @@ if (p_73151_1_) { -@@ -325,36 +547,76 @@ +@@ -309,7 +534,7 @@ + } + } + } +- ++ } // Paper - Timings + return true; + } + +@@ -325,36 +550,76 @@ { if (!this.worldObj.levelSaving) { @@ -567,7 +582,7 @@ if (this.currentChunkLoader != null) { this.currentChunkLoader.chunkTick(); -@@ -371,7 +633,8 @@ +@@ -371,7 +636,8 @@ public String makeString() { @@ -577,7 +592,7 @@ } public List getPossibleCreatures(EnumCreatureType p_73155_1_, int p_73155_2_, int p_73155_3_, int p_73155_4_) -@@ -386,8 +649,35 @@ +@@ -386,8 +652,35 @@ public int getLoadedChunkCount() { diff --git a/patches/org/bukkit/Bukkit.java.patch b/patches/org/bukkit/Bukkit.java.patch index c5475fdc..cf1f288b 100644 --- a/patches/org/bukkit/Bukkit.java.patch +++ b/patches/org/bukkit/Bukkit.java.patch @@ -16,15 +16,7 @@ public static List matchPlayer(String name) { return server.matchPlayer(name); } -@@ -301,6 +299,7 @@ - */ - public static void reload() { - server.reload(); -+ org.spigotmc.CustomTimingsHandler.reload(); // Spigot - } - - /** -@@ -447,7 +446,6 @@ +@@ -447,7 +445,6 @@ /** * @see Server#getPlayerExact(String name) */ @@ -32,7 +24,7 @@ public static Player getPlayerExact(String name) { return server.getPlayerExact(name); } -@@ -747,4 +745,29 @@ +@@ -747,4 +744,29 @@ public static UnsafeValues getUnsafe() { return server.getUnsafe(); } diff --git a/patches/org/bukkit/Server.java.patch b/patches/org/bukkit/Server.java.patch index 82408283..10a7b19a 100644 --- a/patches/org/bukkit/Server.java.patch +++ b/patches/org/bukkit/Server.java.patch @@ -1,6 +1,14 @@ --- ../src-base/minecraft/org/bukkit/Server.java +++ ../src-work/minecraft/org/bukkit/Server.java -@@ -308,23 +308,17 @@ +@@ -41,6 +41,7 @@ + + import org.bukkit.inventory.ItemFactory; + import org.bukkit.inventory.meta.ItemMeta; ++import org.jetbrains.annotations.NotNull; + + /** + * Represents a server implementation. +@@ -308,23 +309,17 @@ *

* This method may not return objects for offline players. * @@ -24,7 +32,7 @@ public Player getPlayerExact(String name); /** -@@ -334,12 +328,9 @@ +@@ -334,12 +329,9 @@ * This list is not sorted in any particular order. If an exact match is * found, the returned list will only contain a single result. * @@ -37,7 +45,7 @@ public List matchPlayer(String name); /** -@@ -916,4 +907,53 @@ +@@ -916,4 +908,71 @@ */ @Deprecated UnsafeValues getUnsafe(); @@ -67,6 +75,24 @@ + throw new UnsupportedOperationException( "Not supported yet." ); + } + ++ // Paper start ++ @NotNull ++ public org.bukkit.configuration.file.YamlConfiguration getBukkitConfig() ++ { ++ throw new UnsupportedOperationException( "Not supported yet." ); ++ } ++ @NotNull ++ public org.bukkit.configuration.file.YamlConfiguration getSpigotConfig() ++ { ++ throw new UnsupportedOperationException("Not supported yet."); ++ } ++ @NotNull ++ public org.bukkit.configuration.file.YamlConfiguration getPaperConfig() ++ { ++ throw new UnsupportedOperationException("Not supported yet."); ++ } ++ // Paper end ++ + /** + * Sends the component to the player + * diff --git a/patches/org/bukkit/UnsafeValues.java.patch b/patches/org/bukkit/UnsafeValues.java.patch new file mode 100644 index 00000000..5afc6e3e --- /dev/null +++ b/patches/org/bukkit/UnsafeValues.java.patch @@ -0,0 +1,15 @@ +--- ../src-base/minecraft/org/bukkit/UnsafeValues.java ++++ ../src-work/minecraft/org/bukkit/UnsafeValues.java +@@ -30,4 +30,12 @@ + Achievement getAchievementFromInternalName(String name); + + List tabCompleteInternalStatisticOrAchievementName(String token, List completions); ++ ++ // Paper start ++ /** ++ * Server name to report to timings v2 ++ * @return name ++ */ ++ String getTimingsServerName(); ++ // Paper end + } diff --git a/patches/org/bukkit/command/Command.java.patch b/patches/org/bukkit/command/Command.java.patch index b82033f9..fb13427d 100644 --- a/patches/org/bukkit/command/Command.java.patch +++ b/patches/org/bukkit/command/Command.java.patch @@ -1,26 +1,11 @@ --- ../src-base/minecraft/org/bukkit/command/Command.java +++ ../src-work/minecraft/org/bukkit/command/Command.java -@@ -31,6 +31,7 @@ +@@ -31,6 +31,8 @@ protected String usageMessage; private String permission; private String permissionMessage; -+ public org.spigotmc.CustomTimingsHandler timings; // Spigot ++ public co.aikar.timings.Timing timings; // Paper ++ public String getTimingName() {return getName();} // Paper protected Command(String name) { this(name, "", "/" + name, new ArrayList()); -@@ -44,6 +45,7 @@ - this.usageMessage = usageMessage; - this.aliases = aliases; - this.activeAliases = new ArrayList(aliases); -+ this.timings = new org.spigotmc.CustomTimingsHandler("** Command: " + name); // Spigot - } - - /** -@@ -200,6 +202,7 @@ - public boolean setLabel(String name) { - this.nextLabel = name; - if (!isRegistered()) { -+ this.timings = new org.spigotmc.CustomTimingsHandler("** Command: " + name); // Spigot - this.label = name; - return true; - } diff --git a/patches/org/bukkit/command/FormattedCommandAlias.java.patch b/patches/org/bukkit/command/FormattedCommandAlias.java.patch new file mode 100644 index 00000000..efcf9453 --- /dev/null +++ b/patches/org/bukkit/command/FormattedCommandAlias.java.patch @@ -0,0 +1,18 @@ +--- ../src-base/minecraft/org/bukkit/command/FormattedCommandAlias.java ++++ ../src-work/minecraft/org/bukkit/command/FormattedCommandAlias.java +@@ -14,6 +14,7 @@ + + public FormattedCommandAlias(String alias, String[] formatStrings) { + super(alias); ++ timings = co.aikar.timings.TimingsManager.getCommandTiming("minecraft", this); // Spigot + this.formatStrings = formatStrings; + } + +@@ -121,4 +122,7 @@ + private static boolean inRange(int i, int j, int k) { + return i >= j && i <= k; + } ++ ++ @Override // Paper ++ public String getTimingName() {return "Command Forwarder - " + super.getTimingName();} // Paper + } diff --git a/patches/org/bukkit/command/SimpleCommandMap.java.patch b/patches/org/bukkit/command/SimpleCommandMap.java.patch index 83faf219..7cc5417a 100644 --- a/patches/org/bukkit/command/SimpleCommandMap.java.patch +++ b/patches/org/bukkit/command/SimpleCommandMap.java.patch @@ -11,28 +11,52 @@ public class SimpleCommandMap implements CommandMap { private static final Pattern PATTERN_ON_SPACE = Pattern.compile(" ", Pattern.LITERAL); protected final Map knownCommands = new HashMap(); -@@ -176,12 +180,19 @@ +@@ -35,7 +39,7 @@ + register("bukkit", new VersionCommand("version")); + register("bukkit", new ReloadCommand("reload")); + register("bukkit", new PluginsCommand("plugins")); +- register("bukkit", new TimingsCommand("timings")); ++ register("bukkit", new co.aikar.timings.TimingsCommand("timings")); + } + + public void setFallbackCommands() { +@@ -100,6 +104,7 @@ + * {@inheritDoc} + */ + public boolean register(String label, String fallbackPrefix, Command command) { ++ command.timings = co.aikar.timings.TimingsManager.getCommandTiming(fallbackPrefix, command); // Paper + label = label.toLowerCase().trim(); + fallbackPrefix = fallbackPrefix.toLowerCase().trim(); + boolean registered = register(label, command, false, fallbackPrefix); +@@ -175,13 +180,26 @@ + return false; } ++ // Paper start - Plugins do weird things to workaround normal registration ++ if (target.timings == null) { ++ target.timings = co.aikar.timings.TimingsManager.getCommandTiming(null, target); ++ } ++ // Paper end ++ try { -+ target.timings.startTiming(); // Spigot ++ try (co.aikar.timings.Timing ignored = target.timings.startTiming()) { // Paper - use try with resources // Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false) target.execute(sender, sentCommandLabel, Arrays_copyOfRange(args, 1, args.length)); -+ target.timings.stopTiming(); // Spigot ++ } // target.timings.stopTiming(); // Spigot // Paper } catch (CommandException ex) { -+ target.timings.stopTiming(); // Spigot ++ //target.timings.stopTiming(); // Spigot //Paper + server.getPluginManager().callEvent(new ServerExceptionEvent(new ServerCommandException(ex, target, sender, args))); // Paper throw ex; } catch (Throwable ex) { - throw new CommandException("Unhandled exception executing '" + commandLine + "' in " + target, ex); -+ target.timings.stopTiming(); // Spigot ++ //target.timings.stopTiming(); // Spigot //Paper + String msg = "Unhandled exception executing '" + commandLine + "' in " + target; + server.getPluginManager().callEvent(new ServerExceptionEvent(new ServerCommandException(ex, target, sender, args))); // Paper + throw new CommandException(msg, ex); } // return true as command was handled -@@ -248,9 +259,12 @@ +@@ -248,9 +266,12 @@ try { return target.tabComplete(sender, commandName, args); } catch (CommandException ex) { diff --git a/patches/org/bukkit/command/defaults/ReloadCommand.java.patch b/patches/org/bukkit/command/defaults/ReloadCommand.java.patch index fd2c9bfd..12865562 100644 --- a/patches/org/bukkit/command/defaults/ReloadCommand.java.patch +++ b/patches/org/bukkit/command/defaults/ReloadCommand.java.patch @@ -18,7 +18,7 @@ + { if (!testPermission(sender)) return true; -+ org.spigotmc.CustomTimingsHandler.reload(); // Spigot: TODO: Why is this here? ++ //org.spigotmc.CustomTimingsHandler.reload(); // Spigot: TODO: Why is this here? Bukkit.reload(); Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete."); + } diff --git a/patches/org/bukkit/command/defaults/TimingsCommand.java.patch b/patches/org/bukkit/command/defaults/TimingsCommand.java.patch index 0d0fd874..db5700fa 100644 --- a/patches/org/bukkit/command/defaults/TimingsCommand.java.patch +++ b/patches/org/bukkit/command/defaults/TimingsCommand.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/org/bukkit/command/defaults/TimingsCommand.java +++ ../src-work/minecraft/org/bukkit/command/defaults/TimingsCommand.java -@@ -19,23 +19,103 @@ +@@ -19,23 +19,102 @@ import com.google.common.collect.ImmutableList; @@ -14,7 +14,6 @@ + +import org.bukkit.command.RemoteConsoleCommandSender; +import org.bukkit.plugin.SimplePluginManager; -+import org.spigotmc.CustomTimingsHandler; +// Spigot end + public class TimingsCommand extends BukkitCommand { @@ -36,7 +35,7 @@ + if ( "on".equals( args[0] ) ) + { + ( (SimplePluginManager) Bukkit.getPluginManager() ).useTimings( true ); -+ CustomTimingsHandler.reload(); ++ //CustomTimingsHandler.reload(); + sender.sendMessage( "Enabled Timings & Reset" ); + return; + } else if ( "off".equals( args[0] ) ) @@ -54,7 +53,7 @@ + + boolean paste = "paste".equals( args[0] ); + if ("reset".equals(args[0])) { -+ CustomTimingsHandler.reload(); ++ //CustomTimingsHandler.reload(); + sender.sendMessage("Timings reset"); + } else if ("merged".equals(args[0]) || "report".equals(args[0]) || paste) { + long sampleTime = System.nanoTime() - timingStart; @@ -68,7 +67,7 @@ + try { + fileTimings = ( paste ) ? new PrintStream( bout ) : new PrintStream( timings ); + -+ CustomTimingsHandler.printTimings(fileTimings); ++ //CustomTimingsHandler.printTimings(fileTimings); + fileTimings.println( "Sample time " + sampleTime + " (" + sampleTime / 1E9 + "s)" ); + + // ++++< @@ -108,7 +107,7 @@ if (!sender.getServer().getPluginManager().useTimings()) { sender.sendMessage("Please enable timings by setting \"settings.plugin-profiling\" to true in bukkit.yml"); return true; -@@ -118,4 +198,79 @@ +@@ -118,4 +197,79 @@ } return ImmutableList.of(); } diff --git a/patches/org/bukkit/command/defaults/VersionCommand.java.patch b/patches/org/bukkit/command/defaults/VersionCommand.java.patch index 51d51690..c480bd57 100644 --- a/patches/org/bukkit/command/defaults/VersionCommand.java.patch +++ b/patches/org/bukkit/command/defaults/VersionCommand.java.patch @@ -40,7 +40,7 @@ - } - } + sender.sendMessage("This server is running §3Crucible§r (Thermos fork by CrucibleMC Team) " + Bukkit.getVersion()); -+ sender.sendMessage("§9https://github.com/CrucibleMC/Crucible"); ++ sender.sendMessage("§9 https://github.com/CrucibleMC/Crucible"); + sender.sendMessage("Bukkit version:" + Bukkit.getBukkitVersion()); return true; } diff --git a/patches/org/bukkit/entity/Player.java.patch b/patches/org/bukkit/entity/Player.java.patch index ea99a031..07dfe75e 100644 --- a/patches/org/bukkit/entity/Player.java.patch +++ b/patches/org/bukkit/entity/Player.java.patch @@ -35,7 +35,7 @@ public void updateInventory(); /** -@@ -1035,4 +1025,239 @@ +@@ -1035,4 +1025,244 @@ * @see Player#setHealthScaled(boolean) */ public double getHealthScale(); @@ -270,6 +270,11 @@ + { + throw new UnsupportedOperationException( "Not supported yet." ); + } ++ ++ public int getPing() ++ { ++ throw new UnsupportedOperationException( "Not supported yet." ); ++ } + } + + Spigot spigot(); diff --git a/patches/org/bukkit/plugin/SimplePluginManager.java.patch b/patches/org/bukkit/plugin/SimplePluginManager.java.patch index 0e9fb716..2616040b 100644 --- a/patches/org/bukkit/plugin/SimplePluginManager.java.patch +++ b/patches/org/bukkit/plugin/SimplePluginManager.java.patch @@ -39,22 +39,21 @@ while (!plugins.isEmpty()) { boolean missingDependency = true; Iterator pluginIterator = plugins.keySet().iterator(); -@@ -295,6 +311,7 @@ - } - } +@@ -331,12 +347,20 @@ -+ org.bukkit.command.defaults.TimingsCommand.timingStart = System.nanoTime(); // Spigot - return result.toArray(new Plugin[result.size()]); - } + if (result != null) { + plugins.add(result); +- lookupNames.put(result.getDescription().getName(), result); ++ lookupNames.put(result.getDescription().getName().toLowerCase(java.util.Locale.ENGLISH), result); // Paper + } -@@ -337,6 +354,14 @@ return result; } + public synchronized Plugin loadModPlugin(Plugin plugin) { + if (plugin != null && plugin.getDescription() != null) { + plugins.add(plugin); -+ lookupNames.put(plugin.getDescription().getName(), plugin); ++ lookupNames.put(plugin.getDescription().getName().toLowerCase(java.util.Locale.ENGLISH), plugin); // Paper + } + return plugin; + } @@ -62,7 +61,16 @@ private void checkUpdate(File file) { if (updateDirectory == null || !updateDirectory.isDirectory()) { return; -@@ -403,7 +428,8 @@ +@@ -357,7 +381,7 @@ + * @return Plugin if it exists, otherwise null + */ + public synchronized Plugin getPlugin(String name) { +- return lookupNames.get(name.replace(' ', '_')); ++ return lookupNames.get(name.replace(' ', '_').toLowerCase(java.util.Locale.ENGLISH)); // Paper + } + + public synchronized Plugin[] getPlugins() { +@@ -403,7 +427,8 @@ try { plugin.getPluginLoader().enablePlugin(plugin); } catch (Throwable ex) { @@ -72,7 +80,7 @@ } HandlerList.bakeAll(); -@@ -422,32 +448,37 @@ +@@ -422,32 +447,37 @@ try { plugin.getPluginLoader().disablePlugin(plugin); } catch (Throwable ex) { @@ -115,9 +123,31 @@ } } } -@@ -727,4 +758,11 @@ +@@ -555,7 +585,8 @@ + throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled"); + } + +- if (useTimings) { ++ executor = new co.aikar.timings.TimedEventExecutor(executor, plugin, null, event); // Paper ++ if (false) { // Spigot - RL handles useTimings check now // Paper + getEventListeners(event).register(new TimedRegisteredListener(listener, executor, priority, plugin, ignoreCancelled)); + } else { + getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled)); +@@ -716,7 +747,7 @@ + } + + public boolean useTimings() { +- return useTimings; ++ return co.aikar.timings.Timings.isTimingsEnabled(); // Spigot + } + + /** +@@ -725,6 +756,13 @@ + * @param use True if per event timing code should be used + */ public void useTimings(boolean use) { - useTimings = use; +- useTimings = use; ++ co.aikar.timings.Timings.setTimingsEnabled(use); // Paper } + + // Paper start diff --git a/patches/org/bukkit/plugin/java/JavaPluginLoader.java.patch b/patches/org/bukkit/plugin/java/JavaPluginLoader.java.patch index 23fa4626..bbfcedc2 100644 --- a/patches/org/bukkit/plugin/java/JavaPluginLoader.java.patch +++ b/patches/org/bukkit/plugin/java/JavaPluginLoader.java.patch @@ -1,37 +1,62 @@ --- ../src-base/minecraft/org/bukkit/plugin/java/JavaPluginLoader.java +++ ../src-work/minecraft/org/bukkit/plugin/java/JavaPluginLoader.java -@@ -1,5 +1,15 @@ +@@ -1,22 +1,13 @@ package org.bukkit.plugin.java; +-import java.io.File; +-import java.io.FileNotFoundException; +-import java.io.IOException; +-import java.io.InputStream; +-import java.lang.reflect.InvocationTargetException; +-import java.lang.reflect.Method; +-import java.util.Arrays; +-import java.util.HashMap; +-import java.util.HashSet; +-import java.util.LinkedHashMap; +-import java.util.Map; +-import java.util.Set; +-import java.util.jar.JarEntry; +-import java.util.jar.JarFile; +-import java.util.logging.Level; +-import java.util.regex.Pattern; +// Cauldron start -+import java.io.BufferedReader; -+import java.io.InputStreamReader; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; ++import com.google.common.collect.ImmutableList; +import net.md_5.specialsource.InheritanceMap; +import net.md_5.specialsource.JarMapping; +import net.md_5.specialsource.transformer.MavenShade; -+// Cauldron end -+ - import java.io.File; - import java.io.FileNotFoundException; - import java.io.IOException; -@@ -10,6 +20,7 @@ - import java.util.HashMap; - import java.util.HashSet; - import java.util.LinkedHashMap; -+import java.util.List; - import java.util.Map; - import java.util.Set; - import java.util.jar.JarEntry; -@@ -39,16 +50,20 @@ - import org.bukkit.plugin.RegisteredListener; - import org.bukkit.plugin.TimedRegisteredListener; - import org.bukkit.plugin.UnknownDependencyException; -+import org.spigotmc.CustomTimingsHandler; // Spigot + import org.apache.commons.lang.Validate; + import org.bukkit.Server; + import org.bukkit.Warning; +@@ -29,27 +20,28 @@ + import org.bukkit.event.Listener; + import org.bukkit.event.server.PluginDisableEvent; + import org.bukkit.event.server.PluginEnableEvent; +-import org.bukkit.plugin.AuthorNagException; +-import org.bukkit.plugin.EventExecutor; +-import org.bukkit.plugin.InvalidDescriptionException; +-import org.bukkit.plugin.InvalidPluginException; +-import org.bukkit.plugin.Plugin; +-import org.bukkit.plugin.PluginDescriptionFile; +-import org.bukkit.plugin.PluginLoader; +-import org.bukkit.plugin.RegisteredListener; +-import org.bukkit.plugin.TimedRegisteredListener; +-import org.bukkit.plugin.UnknownDependencyException; ++import org.bukkit.plugin.*; import org.yaml.snakeyaml.error.YAMLException; -+import com.google.common.collect.ImmutableList; ++import java.io.*; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.util.*; ++import java.util.jar.JarEntry; ++import java.util.jar.JarFile; ++import java.util.logging.Level; ++import java.util.regex.Pattern; ++ ++// Cauldron end + /** * Represents a Java plugin loader, allowing plugins in the form of .jar @@ -42,11 +67,11 @@ - private final Map> classes = new HashMap>(); + private final Map> classes = new java.util.concurrent.ConcurrentHashMap>(); // Spigot private final Map loaders = new LinkedHashMap(); -+ public static final CustomTimingsHandler pluginParentTimer = new CustomTimingsHandler("** Plugins"); // Spigot - +- /** * This class was not meant to be constructed explicitly -@@ -59,43 +74,41 @@ + */ +@@ -59,43 +51,41 @@ server = instance; } @@ -100,7 +125,7 @@ file, oldDataFolder, dataFolder -@@ -104,14 +117,19 @@ +@@ -104,14 +94,19 @@ if (dataFolder.exists() && !dataFolder.isDirectory()) { throw new InvalidPluginException(String.format( @@ -123,7 +148,7 @@ if (loaders == null) { throw new UnknownDependencyException(pluginName); } -@@ -122,7 +140,7 @@ +@@ -122,7 +117,7 @@ } } @@ -132,7 +157,7 @@ try { loader = new PluginClassLoader(this, getClass().getClassLoader(), description, dataFolder, file); } catch (InvalidPluginException ex) { -@@ -136,6 +154,26 @@ +@@ -136,6 +131,26 @@ return loader.plugin; } @@ -159,36 +184,29 @@ public PluginDescriptionFile getPluginDescription(File file) throws InvalidDescriptionException { Validate.notNull(file, "File cannot be null"); -@@ -283,13 +321,19 @@ +@@ -283,8 +298,8 @@ } } -+ final CustomTimingsHandler timings = new CustomTimingsHandler("Plugin: " + plugin.getDescription().getFullName() + " Event: " + listener.getClass().getName() + "::" + method.getName()+"("+eventClass.getSimpleName()+")", pluginParentTimer); // Spigot - EventExecutor executor = new EventExecutor() { - public void execute(Listener listener, Event event) throws EventException { +- EventExecutor executor = new EventExecutor() { +- public void execute(Listener listener, Event event) throws EventException { ++ EventExecutor executor = new co.aikar.timings.TimedEventExecutor(new EventExecutor() { // Paper ++ public void execute(Listener listener, Event event) throws EventException { // Paper try { if (!eventClass.isAssignableFrom(event.getClass())) { return; - } -+ // Spigot start -+ boolean isAsync = event.isAsynchronous(); -+ if (!isAsync) timings.startTiming(); - method.invoke(listener, event); -+ if (!isAsync) timings.stopTiming(); -+ // Spigot end - } catch (InvocationTargetException ex) { - throw new EventException(ex.getCause()); - } catch (Throwable t) { -@@ -297,7 +341,7 @@ +@@ -296,8 +311,8 @@ + throw new EventException(t); } } - }; +- }; - if (useTimings) { ++ }, plugin, method, eventClass); + if (false) { // Spigot - RL handles useTimings check now eventSet.add(new TimedRegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); } else { eventSet.add(new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); -@@ -324,6 +368,10 @@ +@@ -324,6 +339,10 @@ jPlugin.setEnabled(true); } catch (Throwable ex) { server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); @@ -199,7 +217,7 @@ } // Perhaps abort here, rather than continue going, but as it stands, -@@ -362,4 +410,44 @@ +@@ -362,4 +381,44 @@ } } } diff --git a/patches/org/bukkit/util/CachedServerIcon.java.patch b/patches/org/bukkit/util/CachedServerIcon.java.patch new file mode 100644 index 00000000..ec7292c8 --- /dev/null +++ b/patches/org/bukkit/util/CachedServerIcon.java.patch @@ -0,0 +1,10 @@ +--- ../src-base/minecraft/org/bukkit/util/CachedServerIcon.java ++++ ../src-work/minecraft/org/bukkit/util/CachedServerIcon.java +@@ -12,4 +12,6 @@ + * @see Server#loadServerIcon(java.io.File) + * @see ServerListPingEvent#setServerIcon(CachedServerIcon) + */ +-public interface CachedServerIcon {} ++public interface CachedServerIcon { ++ public String getData(); // Paper ++} diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java index 5462e378..020b73ea 100644 --- a/src/main/java/co/aikar/timings/MinecraftTimings.java +++ b/src/main/java/co/aikar/timings/MinecraftTimings.java @@ -44,6 +44,15 @@ public final class MinecraftTimings { public static final Timing antiXrayUpdateTimer = Timings.ofSafe("anti-xray - update"); public static final Timing antiXrayObfuscateTimer = Timings.ofSafe("anti-xray - obfuscate"); + // Crucible start + public static final Timing entityMoveTimer = Timings.ofSafe("## entityMove"); + public static final Timing timerEntityBaseTick = Timings.ofSafe("## livingEntityBaseTick"); + public static final Timing timerEntityAI = Timings.ofSafe("## livingEntityAI"); + public static final Timing timerEntityAICollision = Timings.ofSafe("## livingEntityAICollision"); + public static final Timing timerEntityAIMove = Timings.ofSafe("## livingEntityAIMove"); + public static final Timing timerEntityTickRest = Timings.ofSafe("## livingEntityTickRest"); + //Crucible end + private static final Map, String> taskNameCache = new MapMaker().weakKeys().makeMap(); private MinecraftTimings() {} diff --git a/src/main/java/co/aikar/timings/TimingHistory.java b/src/main/java/co/aikar/timings/TimingHistory.java index 63d45ddf..0706d224 100644 --- a/src/main/java/co/aikar/timings/TimingHistory.java +++ b/src/main/java/co/aikar/timings/TimingHistory.java @@ -336,7 +336,7 @@ private static class PingRecord { final Collection onlinePlayers = Bukkit.getOnlinePlayers(); int totalPing = 0; for (Player player : onlinePlayers) { - //totalPing += player.spigot().getPing(); + totalPing += player.spigot().getPing(); } avg = onlinePlayers.isEmpty() ? 0 : totalPing / onlinePlayers.size(); } diff --git a/src/main/java/co/aikar/timings/TimingHistoryEntry.java b/src/main/java/co/aikar/timings/TimingHistoryEntry.java index 86d5ac6b..298133f7 100644 --- a/src/main/java/co/aikar/timings/TimingHistoryEntry.java +++ b/src/main/java/co/aikar/timings/TimingHistoryEntry.java @@ -44,7 +44,7 @@ List export() { List result = data.export(); if (children.length > 0) { result.add( - toArrayMapper(children, new Function() { + toArrayMapper(children, new FunctionStub() { @NotNull @Override public Object apply(TimingData child) { diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java index 0b34e0d0..540120fa 100644 --- a/src/main/java/co/aikar/timings/Timings.java +++ b/src/main/java/co/aikar/timings/Timings.java @@ -268,7 +268,7 @@ These do not have isPrimaryThread() checks in the startTiming/stopTiming ================= */ @NotNull - static TimingHandler ofSafe(@NotNull String name) { + public static TimingHandler ofSafe(@NotNull String name) { return ofSafe(null, name, null); } @@ -282,7 +282,7 @@ static Timing ofSafe(@Nullable Plugin plugin, @NotNull String name) { } @NotNull - static TimingHandler ofSafe(@NotNull String name, @Nullable Timing groupHandler) { + public static TimingHandler ofSafe(@NotNull String name, @Nullable Timing groupHandler) { return ofSafe(null, name, groupHandler); } diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java index 5de3e733..396e2e03 100644 --- a/src/main/java/co/aikar/timings/TimingsExport.java +++ b/src/main/java/co/aikar/timings/TimingsExport.java @@ -94,11 +94,11 @@ static void reportTimings() { return; } final long lastStartDiff = now - TimingsManager.timingStart; - if (lastStartDiff < 180000) { - listeners.sendMessage(ChatColor.RED + "Please wait at least 3 minutes before generating a Timings report. Unlike Timings v1, v2 benefits from longer timings and is not as useful with short timings. (" + (int)((180000 - lastStartDiff) / 1000) + " seconds)"); - listeners.done(); - return; - } + //if (lastStartDiff < 180000) { + // listeners.sendMessage(ChatColor.RED + "Please wait at least 3 minutes before generating a Timings report. Unlike Timings v1, v2 benefits from longer timings and is not as useful with short timings. (" + (int)((180000 - lastStartDiff) / 1000) + " seconds)"); + // listeners.done(); + // return; + //} listeners.sendMessage(ChatColor.GREEN + "Preparing Timings Report..."); lastReport = now; Map parent = createObject( @@ -109,13 +109,13 @@ static void reportTimings() { pair("end", System.currentTimeMillis() / 1000), pair("sampletime", (System.currentTimeMillis() - TimingsManager.timingStart) / 1000) ); - //TODO: stub + if (!TimingsManager.privacy) { appendObjectData(parent, - //pair("server", Bukkit.getUnsafe().getTimingsServerName()), - pair("motd", Bukkit.getServer().getMotd()), - pair("online-mode", Bukkit.getServer().getOnlineMode())//, - //pair("icon", Bukkit.getServer().getServerIcon().getData()) + pair("server", Bukkit.getUnsafe().getTimingsServerName()), + pair("motd", Bukkit.getServer().getMotd()), + pair("online-mode", Bukkit.getServer().getOnlineMode()), + pair("icon", Bukkit.getServer().getServerIcon().getData()) ); } @@ -203,12 +203,12 @@ static void reportTimings() { // Information on the users Config - //TODO: stub - //parent.put("config", createObject( - // pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)), - // pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)), - // pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)) - //)); + + parent.put("config", createObject( + pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)), + pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null))//, + //pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)) + )); new TimingsExport(listeners, parent, history).start(); } @@ -291,8 +291,8 @@ public void run() { hostName = InetAddress.getLocalHost().getHostName(); } catch (Exception ignored) {} //TODO: stub - //con.setRequestProperty("User-Agent", "Paper/" + Bukkit.getUnsafe().getTimingsServerName() + "/" + hostName); - con.setRequestProperty("User-Agent", "Crucible" + "/" + hostName); + con.setRequestProperty("User-Agent", "Paper/" + Bukkit.getUnsafe().getTimingsServerName() + "/" + hostName); + //con.setRequestProperty("User-Agent", "Paper/CrucibleServer" + "/" + hostName); con.setRequestMethod("POST"); con.setInstanceFollowRedirects(false); diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java index 46e2d486..1d926bcf 100644 --- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -76,6 +76,10 @@ public class WorldTimingsHandler { public final Timing chunkUnloadPOISerialization; public final Timing chunkUnloadDataSave; + //Crucible Start + public final Timing worldIOFlush; + //Crucible End + public WorldTimingsHandler(World server) { String name = server.worldInfo.getWorldName() +" - "; @@ -147,6 +151,10 @@ public WorldTimingsHandler(World server) { chunkUnloadPrepareSave = Timings.ofSafe(name + "Chunk unload - Async Save Prepare"); chunkUnloadPOISerialization = Timings.ofSafe(name + "Chunk unload - POI Data Serialization"); chunkUnloadDataSave = Timings.ofSafe(name + "Chunk unload - Data Serialization"); + + //Crucible start + worldIOFlush = Timings.ofSafe(name + "World save - IO Flush"); + //Crucible end } public static Timing getTickList(WorldServer worldserver, String timingsType) { diff --git a/src/main/java/io/github/crucible/CrucibleConfigs.java b/src/main/java/io/github/crucible/CrucibleConfigs.java index ba929528..9e1f1cca 100644 --- a/src/main/java/io/github/crucible/CrucibleConfigs.java +++ b/src/main/java/io/github/crucible/CrucibleConfigs.java @@ -1,5 +1,7 @@ package io.github.crucible; +import co.aikar.timings.Timings; +import co.aikar.timings.TimingsManager; import net.cubespace.Yamler.Config.Comment; import net.cubespace.Yamler.Config.ConfigMode; import net.cubespace.Yamler.Config.InvalidConfigurationException; @@ -7,6 +9,8 @@ import java.io.File; import java.time.ZoneId; +import java.util.Arrays; +import java.util.List; import java.util.TimeZone; public class CrucibleConfigs extends YamlConfig { @@ -54,6 +58,20 @@ public class CrucibleConfigs extends YamlConfig { @Comment("Sets the server max tick time, experimental, can cause problems!") public int crucible_tickHandler_serverTickTime = 1000000000; + public boolean timings_enable = true; + + public boolean timings_verbose = true; + + public boolean timings_serverNamePrivacy = false; + + public List timings_hiddenConfigEntries = Arrays.asList("database", "settings.bungeecord-addresses"); + + public int timings_historyInterval = 300; + + public int timings_historyLength = 3600; + + public String timings_serverName = "Crucible Server"; + private CrucibleConfigs() { CONFIG_FILE = new File("Crucible.yml"); CONFIG_MODE = ConfigMode.PATH_BY_UNDERSCORE; @@ -75,6 +93,7 @@ private CrucibleConfigs() { crucible_vmTimeZone_timeZoneId = TimeZone.getDefault().getID(); } } + timings(); } public void save() { @@ -88,4 +107,14 @@ public void save() { public int getTickTime() { return crucible_tickHandler_serverTickTime / crucible_tickHandler_serverTickRate; } + + private void timings() { + TimingsManager.privacy = timings_serverNamePrivacy; + TimingsManager.hiddenConfigs = timings_hiddenConfigEntries; + + Timings.setVerboseTimingsEnabled(timings_verbose); + Timings.setTimingsEnabled(timings_enable); + Timings.setHistoryInterval(timings_historyInterval * 20); + Timings.setHistoryLength(timings_historyLength * 20); + } } diff --git a/src/main/java/io/github/crucible/CrucibleModContainer.java b/src/main/java/io/github/crucible/CrucibleModContainer.java index 23f921fc..c2bf907a 100644 --- a/src/main/java/io/github/crucible/CrucibleModContainer.java +++ b/src/main/java/io/github/crucible/CrucibleModContainer.java @@ -37,6 +37,7 @@ public class CrucibleModContainer extends DummyModContainer implements Plugin { private PluginLoader dummyPluginLoader; private PluginDescriptionFile dummyPluginDescription; private boolean isPluginEnabled = false; + private java.util.logging.Logger pluginLogger; public CrucibleModContainer() { super(new ModMetadata()); @@ -202,6 +203,7 @@ public void onDisable() { @Override public void onLoad() { + getLogger().info("Crucible DummyPlugin injected successfully!"); } @Override @@ -229,7 +231,9 @@ public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { @Override public java.util.logging.Logger getLogger() { - return Bukkit.getLogger(); + if (pluginLogger == null) + pluginLogger = new PluginLogger(this); + return pluginLogger; } @Override diff --git a/src/main/java/io/github/crucible/CrucibleTimings.java b/src/main/java/io/github/crucible/CrucibleTimings.java new file mode 100644 index 00000000..3edf63a0 --- /dev/null +++ b/src/main/java/io/github/crucible/CrucibleTimings.java @@ -0,0 +1,18 @@ +package io.github.crucible; + +import co.aikar.timings.Timing; +import co.aikar.timings.Timings; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.IEventListener; + +public class CrucibleTimings { + public static final Timing forgePreTick = Timings.ofSafe("Forge Pre Server Tick"); + public static final Timing forgePostTick = Timings.ofSafe("Forge Post Server Tick"); + + public static Timing getEventTiming(Event event) { + return Timings.ofSafe("Post Event - " + event.getClass().getName()); + } + public static Timing getListenerTiming(IEventListener event, Timing timing) { + return Timings.ofSafe("## Listener - " + event.getClass().getSimpleName(),timing); + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 5b1ff145..f96bff3b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -108,6 +108,7 @@ import org.bukkit.scheduler.BukkitWorker; import org.bukkit.util.StringUtil; import org.bukkit.util.permissions.DefaultPermissions; +import org.jetbrains.annotations.NotNull; import org.spigotmc.SpigotConfig; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.SafeConstructor; @@ -223,11 +224,34 @@ public CraftPlayer apply(EntityPlayerMP player) { } this.spigot = new Server.Spigot(){ + @Deprecated @Override public YamlConfiguration getConfig() { return SpigotConfig.getConfig(); } + @NotNull + @Override + public YamlConfiguration getBukkitConfig() + { + return configuration; + } + + @NotNull + @Override + public YamlConfiguration getSpigotConfig() + { + return org.spigotmc.SpigotConfig.getConfig(); + } + + @NotNull + @Override + public YamlConfiguration getPaperConfig() + { + //return com.destroystokyo.paper.PaperConfig.config; + return null;//TODO implement PaperConfig + } + @Override public void broadcast(BaseComponent component) { for (Player player : CraftServer.this.getOnlinePlayers()) { diff --git a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java b/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java deleted file mode 100644 index dd324047..00000000 --- a/src/main/java/org/bukkit/craftbukkit/SpigotTimings.java +++ /dev/null @@ -1,178 +0,0 @@ -package org.bukkit.craftbukkit; - -import com.google.common.collect.Maps; - -import net.minecraft.entity.Entity; -import net.minecraft.server.*; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import org.bukkit.plugin.java.JavaPluginLoader; -import org.spigotmc.CustomTimingsHandler; -import org.bukkit.scheduler.BukkitTask; - -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.craftbukkit.scheduler.CraftTask; - -public class SpigotTimings { - - public static final CustomTimingsHandler serverTickTimer = new CustomTimingsHandler("** Full Server Tick"); - public static final CustomTimingsHandler playerListTimer = new CustomTimingsHandler("Player List"); - public static final CustomTimingsHandler connectionTimer = new CustomTimingsHandler("Connection Handler"); - public static final CustomTimingsHandler tickablesTimer = new CustomTimingsHandler("Tickables"); - public static final CustomTimingsHandler schedulerTimer = new CustomTimingsHandler("Scheduler"); - public static final CustomTimingsHandler chunkIOTickTimer = new CustomTimingsHandler("ChunkIOTick"); - public static final CustomTimingsHandler timeUpdateTimer = new CustomTimingsHandler("Time Update"); - public static final CustomTimingsHandler serverCommandTimer = new CustomTimingsHandler("Server Command"); - public static final CustomTimingsHandler worldSaveTimer = new CustomTimingsHandler("World Save"); - - public static final CustomTimingsHandler entityMoveTimer = new CustomTimingsHandler("** entityMove"); - public static final CustomTimingsHandler tickEntityTimer = new CustomTimingsHandler("** tickEntity"); - public static final CustomTimingsHandler activatedEntityTimer = new CustomTimingsHandler("** activatedTickEntity"); - public static final CustomTimingsHandler tickTileEntityTimer = new CustomTimingsHandler("** tickTileEntity"); - - public static final CustomTimingsHandler timerEntityBaseTick = new CustomTimingsHandler("** livingEntityBaseTick"); - public static final CustomTimingsHandler timerEntityAI = new CustomTimingsHandler("** livingEntityAI"); - public static final CustomTimingsHandler timerEntityAICollision = new CustomTimingsHandler("** livingEntityAICollision"); - public static final CustomTimingsHandler timerEntityAIMove = new CustomTimingsHandler("** livingEntityAIMove"); - public static final CustomTimingsHandler timerEntityTickRest = new CustomTimingsHandler("** livingEntityTickRest"); - - public static final CustomTimingsHandler processQueueTimer = new CustomTimingsHandler("processQueue"); - public static final CustomTimingsHandler schedulerSyncTimer = new CustomTimingsHandler("** Scheduler - Sync Tasks", JavaPluginLoader.pluginParentTimer); - - public static final CustomTimingsHandler playerCommandTimer = new CustomTimingsHandler("** playerCommand"); - - public static final CustomTimingsHandler entityActivationCheckTimer = new CustomTimingsHandler("entityActivationCheck"); - public static final CustomTimingsHandler checkIfActiveTimer = new CustomTimingsHandler("** checkIfActive"); - - public static final HashMap entityTypeTimingMap = new HashMap(); - public static final HashMap tileEntityTypeTimingMap = new HashMap(); - public static final HashMap pluginTaskTimingMap = new HashMap(); - - /** - * Gets a timer associated with a plugins tasks. - * @param task - * @param period - * @return - */ - public static CustomTimingsHandler getPluginTaskTimings(BukkitTask task, long period) { - if (!task.isSync()) { - return null; - } - String plugin; - final CraftTask ctask = (CraftTask) task; - - if (task.getOwner() != null) { - plugin = task.getOwner().getDescription().getFullName(); - } else if (ctask.timingName != null) { - plugin = "CraftScheduler"; - } else { - plugin = "Unknown"; - } - String taskname = ctask.getTaskName(); - - String name = "Task: " + plugin + " Runnable: " + taskname; - if (period > 0) { - name += "(interval:" + period +")"; - } else { - name += "(Single)"; - } - CustomTimingsHandler result = pluginTaskTimingMap.get(name); - if (result == null) { - result = new CustomTimingsHandler(name, SpigotTimings.schedulerSyncTimer); - pluginTaskTimingMap.put(name, result); - } - return result; - } - - /** - * Get a named timer for the specified entity type to track type specific timings. - * @param entity - * @return - */ - public static CustomTimingsHandler getEntityTimings(Entity entity) { - String entityType = entity.getClass().getSimpleName(); - CustomTimingsHandler result = entityTypeTimingMap.get(entityType); - if (result == null) { - result = new CustomTimingsHandler("** tickEntity - " + entityType, activatedEntityTimer); - entityTypeTimingMap.put(entityType, result); - } - return result; - } - - /** - * Get a named timer for the specified tile entity type to track type specific timings. - * @param entity - * @return - */ - public static CustomTimingsHandler getTileEntityTimings(TileEntity entity) { - String entityType = entity.getClass().getSimpleName(); - CustomTimingsHandler result = tileEntityTypeTimingMap.get(entityType); - if (result == null) { - result = new CustomTimingsHandler("** tickTileEntity - " + entityType, tickTileEntityTimer); - tileEntityTypeTimingMap.put(entityType, result); - } - return result; - } - - /** - * Set of timers per world, to track world specific timings. - */ - public static class WorldTimingsHandler { - public final CustomTimingsHandler mobSpawn; - public final CustomTimingsHandler doChunkUnload; - public final CustomTimingsHandler doPortalForcer; - public final CustomTimingsHandler doTickPending; - public final CustomTimingsHandler doTickTiles; - public final CustomTimingsHandler doVillages; - public final CustomTimingsHandler doChunkMap; - public final CustomTimingsHandler doChunkGC; - public final CustomTimingsHandler doSounds; - public final CustomTimingsHandler entityTick; - public final CustomTimingsHandler tileEntityTick; - public final CustomTimingsHandler tileEntityPending; - public final CustomTimingsHandler tracker; - public final CustomTimingsHandler doTick; - public final CustomTimingsHandler tickEntities; - - public final CustomTimingsHandler syncChunkLoadTimer; - public final CustomTimingsHandler syncChunkLoadDataTimer; - public final CustomTimingsHandler syncChunkLoadStructuresTimer; - public final CustomTimingsHandler syncChunkLoadEntitiesTimer; - public final CustomTimingsHandler syncChunkLoadTileEntitiesTimer; - public final CustomTimingsHandler syncChunkLoadTileTicksTimer; - public final CustomTimingsHandler syncChunkLoadPostTimer; - - public WorldTimingsHandler(World server) { - String name = server.worldInfo.getWorldName() +" - "; - - mobSpawn = new CustomTimingsHandler("** " + name + "mobSpawn"); - doChunkUnload = new CustomTimingsHandler("** " + name + "doChunkUnload"); - doTickPending = new CustomTimingsHandler("** " + name + "doTickPending"); - doTickTiles = new CustomTimingsHandler("** " + name + "doTickTiles"); - doVillages = new CustomTimingsHandler("** " + name + "doVillages"); - doChunkMap = new CustomTimingsHandler("** " + name + "doChunkMap"); - doSounds = new CustomTimingsHandler("** " + name + "doSounds"); - doChunkGC = new CustomTimingsHandler("** " + name + "doChunkGC"); - doPortalForcer = new CustomTimingsHandler("** " + name + "doPortalForcer"); - entityTick = new CustomTimingsHandler("** " + name + "entityTick"); - tileEntityTick = new CustomTimingsHandler("** " + name + "tileEntityTick"); - tileEntityPending = new CustomTimingsHandler("** " + name + "tileEntityPending"); - - syncChunkLoadTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad"); - syncChunkLoadDataTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad - Data"); - syncChunkLoadStructuresTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Structures"); - syncChunkLoadEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Entities"); - syncChunkLoadTileEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileEntities"); - syncChunkLoadTileTicksTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileTicks"); - syncChunkLoadPostTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Post"); - - - tracker = new CustomTimingsHandler(name + "tracker"); - doTick = new CustomTimingsHandler(name + "doTick"); - tickEntities = new CustomTimingsHandler(name + "tickEntities"); - } - } -} \ No newline at end of file diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index d5f04d34..b83f5866 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1460,6 +1460,14 @@ public void sendMessage(BaseComponent component) { CraftPlayer.this.getHandle().playerNetServerHandler.sendPacket(packet); } + // Paper start + @Override + public int getPing() + { + return getHandle().ping; + } + // Paper end + }; public Player.Spigot spigot() diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java index 520dd0ca..74fb069d 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -14,6 +14,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; +import co.aikar.timings.MinecraftTimings; import org.apache.commons.lang.Validate; import org.bukkit.plugin.IllegalPluginAccessException; import org.bukkit.plugin.Plugin; @@ -186,7 +187,7 @@ private boolean check(final Iterable collection) { } } return false; - }}); + }}){{this.timings=co.aikar.timings.MinecraftTimings.getCancelTasksTimer();}}; // Paper handle(task, 0L); for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) { if (taskPending == task) { @@ -346,9 +347,7 @@ public void mainThreadHeartbeat(final int currentTick) { } if (task.isSync()) { try { - task.timings.startTiming(); // Spigot task.run(); - task.timings.stopTiming(); // Spigot } catch (final Throwable throwable) { task.getOwner().getLogger().log( Level.WARNING, @@ -373,8 +372,10 @@ public void mainThreadHeartbeat(final int currentTick) { runners.remove(task.getTaskId()); } } + MinecraftTimings.bukkitSchedulerFinishTimer.startTiming(); pending.addAll(temp); temp.clear(); + MinecraftTimings.bukkitSchedulerFinishTimer.stopTiming(); debugHead = debugHead.getNextHead(currentTick); } @@ -406,6 +407,7 @@ private int nextId() { } private void parsePending() { + MinecraftTimings.bukkitSchedulerPendingTimer.startTiming(); CraftTask head = this.head; CraftTask task = head.getNext(); CraftTask lastTask = head; @@ -424,6 +426,7 @@ private void parsePending() { task.setNext(null); } this.head = lastTask; + MinecraftTimings.bukkitSchedulerPendingTimer.stopTiming(); } private boolean isReady(final int currentTick) { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java index d99c99c1..50586ac3 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java @@ -1,8 +1,9 @@ package org.bukkit.craftbukkit.scheduler; +import co.aikar.timings.MinecraftTimings; +import co.aikar.timings.NullTimingHandler; +import co.aikar.timings.Timing; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.SpigotTimings; // Spigot -import org.spigotmc.CustomTimingsHandler; // Spigot import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitTask; @@ -24,7 +25,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot private final Plugin plugin; private final int id; - final CustomTimingsHandler timings; // Spigot + public Timing timings; // Paper CraftTask() { this(null, null, -1, -1); } @@ -47,7 +48,7 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot this.id = id; this.period = period; this.timingName = timingName == null && task == null ? "Unknown" : timingName; - timings = this.isSync() ? SpigotTimings.getPluginTaskTimings(this, period) : null; + timings = task != null ? MinecraftTimings.getPluginTaskTimings(this, period) : NullTimingHandler.NULL; // Paper } CraftTask(final Plugin plugin, final Runnable task, final int id, final long period) { @@ -68,7 +69,9 @@ public boolean isSync() { } public void run() { - task.run(); + try (Timing ignored = timings.startTiming()) { // Paper + task.run(); + } // Paper } long getPeriod() { diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java index e52ef47b..e9b21a87 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftIconCache.java @@ -8,4 +8,6 @@ public class CraftIconCache implements CachedServerIcon { public CraftIconCache(final String value) { this.value = value; } + + public String getData() { return value; } // Paper } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 8346eced..0285eeb6 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -5,6 +5,7 @@ import java.util.List; +import io.github.crucible.CrucibleConfigs; import org.bukkit.Achievement; import org.bukkit.Material; import org.bukkit.Statistic; @@ -131,4 +132,14 @@ public List tabCompleteInternalStatisticOrAchievementName(String token, } return matches; } + + // Paper start + @Override + public String getTimingsServerName() { + //return com.destroystokyo.paper.PaperConfig.timingsServerName; + return CrucibleConfigs.configs.timings_serverName; //Crucible + } + // Paper end + + } \ No newline at end of file diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java index 8bc7eea3..d0e32d1f 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import co.aikar.timings.MinecraftTimings; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.chunk.Chunk; import net.minecraft.entity.Entity; @@ -30,7 +31,6 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; -import org.bukkit.craftbukkit.SpigotTimings; // Cauldron start import net.minecraft.entity.EnumCreatureType; import net.minecraftforge.common.DimensionManager; @@ -144,7 +144,7 @@ public static void growBB(AxisAlignedBB target, AxisAlignedBB source, int x, int */ public static void activateEntities(World world) { - SpigotTimings.entityActivationCheckTimer.startTiming(); + MinecraftTimings.entityActivationCheckTimer.startTiming(); // Cauldron start - proxy world support final int miscActivationRange = world.getSpigotConfig().miscActivationRange; final int animalActivationRange = world.getSpigotConfig().animalActivationRange; @@ -180,7 +180,7 @@ public static void activateEntities(World world) } } } - SpigotTimings.entityActivationCheckTimer.stopTiming(); + MinecraftTimings.entityActivationCheckTimer.stopTiming(); } /** @@ -292,7 +292,6 @@ public static boolean checkEntityImmunities(Entity entity) */ public static boolean checkIfActive(Entity entity) { - SpigotTimings.checkIfActiveTimer.startTiming(); boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState; @@ -328,7 +327,6 @@ public static boolean checkIfActive(Entity entity) { isActive = true; } - SpigotTimings.checkIfActiveTimer.stopTiming(); return isActive; } } diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java index 36f24489..3a13f0d2 100644 --- a/src/main/java/org/spigotmc/AntiXray.java +++ b/src/main/java/org/spigotmc/AntiXray.java @@ -1,13 +1,15 @@ package org.spigotmc; +import co.aikar.timings.MinecraftTimings; +import co.aikar.timings.Timing; import gnu.trove.set.TByteSet; import gnu.trove.set.hash.TByteHashSet; public class AntiXray { - private static final CustomTimingsHandler update = new CustomTimingsHandler( "xray - update" ); - private static final CustomTimingsHandler obfuscate = new CustomTimingsHandler( "xray - obfuscate" ); + private static final Timing update = MinecraftTimings.antiXrayUpdateTimer; + private static final Timing obfuscate = MinecraftTimings.antiXrayObfuscateTimer; /*========================================================================*/ // Used to keep track of which blocks to obfuscate private final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ]; diff --git a/src/main/java/org/spigotmc/CustomTimingsHandler.java b/src/main/java/org/spigotmc/CustomTimingsHandler.java index 1a6effe1..b07e5b79 100644 --- a/src/main/java/org/spigotmc/CustomTimingsHandler.java +++ b/src/main/java/org/spigotmc/CustomTimingsHandler.java @@ -83,7 +83,7 @@ public CustomTimingsHandler(@NotNull String name) { plugin = TimingsManager.getPluginByClassloader(calling); } catch (Exception ignored) {} - new AuthorNagException("Deprecated use of CustomTimingsHandler. Please Switch to Timings.of ASAP").printStackTrace(); + //new AuthorNagException("Deprecated use of CustomTimingsHandler. Please Switch to Timings.of ASAP").printStackTrace(); if (plugin != null) { timing = Timings.of(plugin, "(Deprecated API) " + name); } else { @@ -100,6 +100,58 @@ public CustomTimingsHandler(@NotNull String name) { handler = timing; } + //#perguiça + public CustomTimingsHandler(@NotNull String name, CustomTimingsHandler parent) { + if (sunReflectAvailable == null) { + String javaVer = System.getProperty("java.version"); + String[] elements = javaVer.split("\\."); + + int major = Integer.parseInt(elements.length >= 2 ? elements[1] : javaVer); + if (major <= 8) { + sunReflectAvailable = true; + + try { + Class reflection = Class.forName("sun.reflect.Reflection"); + getCallerClass = reflection.getMethod("getCallerClass", int.class); + } catch (ClassNotFoundException | NoSuchMethodException ignored) { + } + } else { + sunReflectAvailable = false; + } + } + + Class calling = null; + if (sunReflectAvailable) { + try { + calling = (Class) getCallerClass.invoke(null, 2); + } catch (IllegalAccessException | InvocationTargetException ignored) { + } + } + + Timing timing; + + Plugin plugin = null; + try { + plugin = TimingsManager.getPluginByClassloader(calling); + } catch (Exception ignored) {} + + //new AuthorNagException("Deprecated use of CustomTimingsHandler. Please Switch to Timings.of ASAP").printStackTrace(); + if (plugin != null) { + timing = Timings.of(plugin, "(Deprecated API) " + name,parent.handler); + } else { + try { + final Method ofSafe = TimingsManager.class.getDeclaredMethod("getHandler", String.class, String.class, Timing.class); + ofSafe.setAccessible(true); + timing = (Timing) ofSafe.invoke(null,"Minecraft", "(Deprecated API) " + name, parent.handler); + } catch (Exception e) { + e.printStackTrace(); + Bukkit.getLogger().log(Level.SEVERE, "This handler could not be registered"); + timing = Timings.NULL_HANDLER; + } + } + handler = timing; + } + public void startTiming() { handler.startTiming(); } public void stopTiming() { handler.stopTiming(); }