Index: pom.xml IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/pom.xml b/pom.xml --- a/pom.xml (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/pom.xml (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -345,6 +345,7 @@ + spigot Index: src/main/java/net/minecraft/server/CommandDispatcher.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java --- a/src/main/java/net/minecraft/server/CommandDispatcher.java (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/src/main/java/net/minecraft/server/CommandDispatcher.java (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -7,7 +7,6 @@ import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder; -import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.RootCommandNode; @@ -22,7 +21,6 @@ // CraftBukkit start import com.google.common.base.Joiner; import java.util.LinkedHashSet; -import org.bukkit.craftbukkit.command.VanillaCommandWrapper; import org.bukkit.event.player.PlayerCommandSendEvent; import org.bukkit.event.server.ServerCommandEvent; // CraftBukkit end @@ -34,79 +32,18 @@ // CraftBukkit start public final CommandDispatcher init(boolean flag) { - CommandAdvancement.a(this.b); - CommandExecute.a(this.b); - CommandBossBar.a(this.b); CommandClear.a(this.b); - CommandClone.a(this.b); - CommandData.a(this.b); - CommandDatapack.a(this.b); - CommandDebug.a(this.b); CommandGamemodeDefault.a(this.b); - CommandDifficulty.a(this.b); - CommandEffect.a(this.b); - CommandMe.a(this.b); - CommandEnchant.a(this.b); - CommandXp.a(this.b); - CommandFill.a(this.b); - CommandForceload.a(this.b); - CommandFunction.a(this.b); CommandGamemode.a(this.b); CommandGamerule.a(this.b); CommandGive.a(this.b); CommandHelp.a(this.b); - CommandKick.a(this.b); - CommandKill.a(this.b); - CommandList.a(this.b); - CommandLocate.a(this.b); - CommandLoot.a(this.b); - CommandTell.a(this.b); - CommandParticle.a(this.b); - CommandPlaySound.a(this.b); - CommandPublish.a(this.b); CommandReload.a(this.b); - CommandRecipe.a(this.b); - CommandReplaceItem.a(this.b); - CommandSay.a(this.b); - CommandSchedule.a(this.b); - CommandScoreboard.a(this.b); - CommandSeed.a(this.b); - CommandSetBlock.a(this.b); - CommandSpawnpoint.a(this.b); - CommandSetWorldSpawn.a(this.b); CommandSpectate.a(this.b); - CommandSpreadPlayers.a(this.b); - CommandStopSound.a(this.b); - CommandSummon.a(this.b); - CommandTag.a(this.b); - CommandTeam.a(this.b); - CommandTeamMsg.a(this.b); CommandTeleport.a(this.b); - CommandTellRaw.a(this.b); CommandTime.a(this.b); - CommandTitle.a(this.b); - CommandTrigger.a(this.b); - CommandWeather.a(this.b); - CommandWorldBorder.a(this.b); - if (SharedConstants.b) { - GameTestHarnessTestCommand.a(this.b); - } - if (flag) { - CommandBanIp.a(this.b); - CommandBanList.a(this.b); - CommandBan.a(this.b); - CommandDeop.a(this.b); - CommandOp.a(this.b); - CommandPardon.a(this.b); - CommandPardonIP.a(this.b); - CommandSaveAll.a(this.b); - CommandSaveOff.a(this.b); - CommandSaveOn.a(this.b); - CommandIdleTimeout.a(this.b); - CommandStop.a(this.b); - CommandWhitelist.a(this.b); - } + CommandStop.a(this.b); this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> { // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); // CraftBukkit Index: src/main/java/net/minecraft/server/DedicatedServer.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java --- a/src/main/java/net/minecraft/server/DedicatedServer.java (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/src/main/java/net/minecraft/server/DedicatedServer.java (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -151,12 +151,13 @@ thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(DedicatedServer.LOGGER)); thread.start(); DedicatedServer.LOGGER.info("Starting minecraft server version " + SharedConstants.getGameVersion().getName()); - if (Runtime.getRuntime().maxMemory() / 1024L / 1024L < 512L) { - DedicatedServer.LOGGER.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); - } DedicatedServer.LOGGER.info("Loading properties"); DedicatedServerProperties dedicatedserverproperties = this.propertyManager.getProperties(); + long l = SystemUtils.getMonotonicNanos() - MinecraftServer.startNanos; + String s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); + + DedicatedServer.LOGGER.info("({})! For loading properties", s2); if (this.isEmbeddedServer()) { this.b("127.0.0.1"); @@ -170,6 +171,10 @@ org.spigotmc.SpigotConfig.init((File) options.valueOf("spigot-settings")); org.spigotmc.SpigotConfig.registerCommands(); // Spigot end + l = SystemUtils.getMonotonicNanos() - MinecraftServer.startNanos; + s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); + + DedicatedServer.LOGGER.info("({})! For loading spigot-settings", s2); this.setSpawnAnimals(dedicatedserverproperties.spawnAnimals); this.setSpawnNPCs(dedicatedserverproperties.spawnNpcs); @@ -194,6 +199,10 @@ DedicatedServer.LOGGER.info("Generating keypair"); this.a(MinecraftEncryption.b()); + l = SystemUtils.getMonotonicNanos() - MinecraftServer.startNanos; + s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); + + DedicatedServer.LOGGER.info("({})! For Encryption + Properties", s2); DedicatedServer.LOGGER.info("Starting Minecraft server on {}:{}", this.getServerIp().isEmpty() ? "*" : this.getServerIp(), this.getPort()); try { @@ -208,8 +217,11 @@ // CraftBukkit start // this.a((PlayerList) (new DedicatedPlayerList(this))); // Spigot - moved up server.loadPlugins(); - server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); // CraftBukkit end + l = SystemUtils.getMonotonicNanos() - MinecraftServer.startNanos; + s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); + + DedicatedServer.LOGGER.info("({})! For loading Plugins", s2); if (!this.getOnlineMode()) { DedicatedServer.LOGGER.warn("**** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!"); @@ -233,7 +245,6 @@ return false; } else { this.convertable = new Convertable(server.getWorldContainer().toPath(), server.getWorldContainer().toPath().resolve("../backups"), this.dataConverterManager); // CraftBukkit - moved from MinecraftServer constructor - long i = SystemUtils.getMonotonicNanos(); String s = dedicatedserverproperties.levelSeed; String s1 = dedicatedserverproperties.generatorSettings; long j = (new Random()).nextLong(); @@ -256,6 +267,10 @@ TileEntitySkull.a(this.getUserCache()); TileEntitySkull.a(this.getMinecraftSessionService()); UserCache.a(this.getOnlineMode()); + l = SystemUtils.getMonotonicNanos() - MinecraftServer.startNanos; + s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); + + DedicatedServer.LOGGER.info("({})! For Initializing stuff", s2); DedicatedServer.LOGGER.info("Preparing level \"{}\"", this.getWorld()); JsonObject jsonobject = new JsonObject(); @@ -272,8 +287,8 @@ } this.a(this.getWorld(), this.getWorld(), j, worldtype, jsonobject); - long l = SystemUtils.getMonotonicNanos() - i; - String s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); + l = SystemUtils.getMonotonicNanos() - MinecraftServer.startNanos; + s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); DedicatedServer.LOGGER.info("Done ({})! For help, type \"help\"", s2); if (dedicatedserverproperties.announcePlayerAchievements != null) { Index: src/main/java/net/minecraft/server/DispenserRegistry.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/net/minecraft/server/DispenserRegistry.java b/src/main/java/net/minecraft/server/DispenserRegistry.java --- a/src/main/java/net/minecraft/server/DispenserRegistry.java (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/src/main/java/net/minecraft/server/DispenserRegistry.java (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -7,16 +7,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -// CraftBukkit start -import java.util.List; -import org.bukkit.Location; -import org.bukkit.TreeType; -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.util.DummyGeneratorAccess; -import org.bukkit.event.block.BlockDispenseEvent; -import org.bukkit.event.world.StructureGrowEvent; -// CraftBukkit end - public class DispenserRegistry { public static final PrintStream a = System.out; @@ -30,79 +20,16 @@ throw new IllegalStateException("Unable to load registries"); } else { BlockFire.c(); - BlockComposter.c(); + //BlockComposter.c(); if (EntityTypes.getName(EntityTypes.PLAYER) == null) { throw new IllegalStateException("Failed loading EntityTypes"); } else { - PotionBrewer.a(); - PlayerSelector.a(); + //PotionBrewer.a(); + //PlayerSelector.a(); IDispenseBehavior.c(); ArgumentRegistry.a(); d(); } - // CraftBukkit start - easier than fixing the decompile - DataConverterFlattenData.map(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}"); - DataConverterFlattenData.map(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}"); - DataConverterFlattenData.map(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}"); - DataConverterFlattenData.map(1011, "{Name:'minecraft:oak_sign',Properties:{rotation:'3'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'3'}}"); - DataConverterFlattenData.map(1012, "{Name:'minecraft:oak_sign',Properties:{rotation:'4'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'4'}}"); - DataConverterFlattenData.map(1013, "{Name:'minecraft:oak_sign',Properties:{rotation:'5'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'5'}}"); - DataConverterFlattenData.map(1014, "{Name:'minecraft:oak_sign',Properties:{rotation:'6'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'6'}}"); - DataConverterFlattenData.map(1015, "{Name:'minecraft:oak_sign',Properties:{rotation:'7'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'7'}}"); - DataConverterFlattenData.map(1016, "{Name:'minecraft:oak_sign',Properties:{rotation:'8'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'8'}}"); - DataConverterFlattenData.map(1017, "{Name:'minecraft:oak_sign',Properties:{rotation:'9'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'9'}}"); - DataConverterFlattenData.map(1018, "{Name:'minecraft:oak_sign',Properties:{rotation:'10'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'10'}}"); - DataConverterFlattenData.map(1019, "{Name:'minecraft:oak_sign',Properties:{rotation:'11'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'11'}}"); - DataConverterFlattenData.map(1020, "{Name:'minecraft:oak_sign',Properties:{rotation:'12'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'12'}}"); - DataConverterFlattenData.map(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}"); - DataConverterFlattenData.map(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}"); - DataConverterFlattenData.map(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}"); - DataConverterMaterialId.ID_MAPPING.put(323, "minecraft:oak_sign"); - - DataConverterFlattenData.map(1440, "{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}", new String[]{"{Name:\'minecraft:portal\',Properties:{axis:\'x\'}}"}); - - DataConverterMaterialId.ID_MAPPING.put(409, "minecraft:prismarine_shard"); - DataConverterMaterialId.ID_MAPPING.put(410, "minecraft:prismarine_crystals"); - DataConverterMaterialId.ID_MAPPING.put(411, "minecraft:rabbit"); - DataConverterMaterialId.ID_MAPPING.put(412, "minecraft:cooked_rabbit"); - DataConverterMaterialId.ID_MAPPING.put(413, "minecraft:rabbit_stew"); - DataConverterMaterialId.ID_MAPPING.put(414, "minecraft:rabbit_foot"); - DataConverterMaterialId.ID_MAPPING.put(415, "minecraft:rabbit_hide"); - DataConverterMaterialId.ID_MAPPING.put(416, "minecraft:armor_stand"); - - DataConverterMaterialId.ID_MAPPING.put(423, "minecraft:mutton"); - DataConverterMaterialId.ID_MAPPING.put(424, "minecraft:cooked_mutton"); - DataConverterMaterialId.ID_MAPPING.put(425, "minecraft:banner"); - DataConverterMaterialId.ID_MAPPING.put(426, "minecraft:end_crystal"); - DataConverterMaterialId.ID_MAPPING.put(427, "minecraft:spruce_door"); - DataConverterMaterialId.ID_MAPPING.put(428, "minecraft:birch_door"); - DataConverterMaterialId.ID_MAPPING.put(429, "minecraft:jungle_door"); - DataConverterMaterialId.ID_MAPPING.put(430, "minecraft:acacia_door"); - DataConverterMaterialId.ID_MAPPING.put(431, "minecraft:dark_oak_door"); - DataConverterMaterialId.ID_MAPPING.put(432, "minecraft:chorus_fruit"); - DataConverterMaterialId.ID_MAPPING.put(433, "minecraft:chorus_fruit_popped"); - DataConverterMaterialId.ID_MAPPING.put(434, "minecraft:beetroot"); - DataConverterMaterialId.ID_MAPPING.put(435, "minecraft:beetroot_seeds"); - DataConverterMaterialId.ID_MAPPING.put(436, "minecraft:beetroot_soup"); - DataConverterMaterialId.ID_MAPPING.put(437, "minecraft:dragon_breath"); - DataConverterMaterialId.ID_MAPPING.put(438, "minecraft:splash_potion"); - DataConverterMaterialId.ID_MAPPING.put(439, "minecraft:spectral_arrow"); - DataConverterMaterialId.ID_MAPPING.put(440, "minecraft:tipped_arrow"); - DataConverterMaterialId.ID_MAPPING.put(441, "minecraft:lingering_potion"); - DataConverterMaterialId.ID_MAPPING.put(442, "minecraft:shield"); - DataConverterMaterialId.ID_MAPPING.put(443, "minecraft:elytra"); - DataConverterMaterialId.ID_MAPPING.put(444, "minecraft:spruce_boat"); - DataConverterMaterialId.ID_MAPPING.put(445, "minecraft:birch_boat"); - DataConverterMaterialId.ID_MAPPING.put(446, "minecraft:jungle_boat"); - DataConverterMaterialId.ID_MAPPING.put(447, "minecraft:acacia_boat"); - DataConverterMaterialId.ID_MAPPING.put(448, "minecraft:dark_oak_boat"); - DataConverterMaterialId.ID_MAPPING.put(449, "minecraft:totem_of_undying"); - DataConverterMaterialId.ID_MAPPING.put(450, "minecraft:shulker_shell"); - DataConverterMaterialId.ID_MAPPING.put(452, "minecraft:iron_nugget"); - DataConverterMaterialId.ID_MAPPING.put(453, "minecraft:knowledge_book"); - - DataConverterSpawnEgg.ID_MAPPING[23] = "Arrow"; - // CraftBukkit end } } } Index: src/main/java/net/minecraft/server/IDispenseBehavior.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/net/minecraft/server/IDispenseBehavior.java b/src/main/java/net/minecraft/server/IDispenseBehavior.java --- a/src/main/java/net/minecraft/server/IDispenseBehavior.java (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/src/main/java/net/minecraft/server/IDispenseBehavior.java (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -1,16 +1,9 @@ package net.minecraft.server; -import java.util.Iterator; -import java.util.List; import java.util.Random; // CraftBukkit start -import org.bukkit.Location; -import org.bukkit.TreeType; -import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.util.DummyGeneratorAccess; import org.bukkit.event.block.BlockDispenseEvent; -import org.bukkit.event.world.StructureGrowEvent; // CraftBukkit end public interface IDispenseBehavior { @@ -49,176 +42,6 @@ entityspectralarrow.fromPlayer = EntityArrow.PickupStatus.ALLOWED; return entityspectralarrow; } - })); - BlockDispenser.a((IMaterial) Items.EGG, (IDispenseBehavior) (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { - return (IProjectile) SystemUtils.a((new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entityegg) -> { // CraftBukkit - decompile error - entityegg.setItem(itemstack); - }); - } - })); - BlockDispenser.a((IMaterial) Items.SNOWBALL, (IDispenseBehavior) (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { - return (IProjectile) SystemUtils.a((new EntitySnowball(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitysnowball) -> { // CraftBukkit - decompile error - entitysnowball.setItem(itemstack); - }); - } - })); - BlockDispenser.a((IMaterial) Items.EXPERIENCE_BOTTLE, (IDispenseBehavior) (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack) { - return (IProjectile) SystemUtils.a((new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitythrownexpbottle) -> { // CraftBukkit - decompile error - entitythrownexpbottle.setItem(itemstack); - }); - } - - @Override - protected float a() { - return super.a() * 0.5F; - } - - @Override - protected float getPower() { - return super.getPower() * 1.25F; - } - })); - BlockDispenser.a((IMaterial) Items.SPLASH_POTION, new IDispenseBehavior() { - @Override - public ItemStack dispense(ISourceBlock isourceblock, ItemStack itemstack) { - return (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { - return (IProjectile) SystemUtils.a((new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { // CraftBukkit - decompile error - entitypotion.setItem(itemstack1); - }); - } - - @Override - protected float a() { - return super.a() * 0.5F; - } - - @Override - protected float getPower() { - return super.getPower() * 1.25F; - } - }).dispense(isourceblock, itemstack); - } - }); - BlockDispenser.a((IMaterial) Items.LINGERING_POTION, new IDispenseBehavior() { - @Override - public ItemStack dispense(ISourceBlock isourceblock, ItemStack itemstack) { - return (new DispenseBehaviorProjectile() { - @Override - protected IProjectile a(World world, IPosition iposition, ItemStack itemstack1) { - return (IProjectile) SystemUtils.a((new EntityPotion(world, iposition.getX(), iposition.getY(), iposition.getZ())), (entitypotion) -> { // CraftBukkit - decompile error - entitypotion.setItem(itemstack1); - }); - } - - @Override - protected float a() { - return super.a() * 0.5F; - } - - @Override - protected float getPower() { - return super.getPower() * 1.25F; - } - }).dispense(isourceblock, itemstack); - } - }); - DispenseBehaviorItem dispensebehavioritem = new DispenseBehaviorItem() { - @Override - public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - EntityTypes entitytypes = ((ItemMonsterEgg) itemstack.getItem()).b(itemstack.getTag()); - - // CraftBukkit start - World world = isourceblock.getWorld(); - ItemStack itemstack1 = itemstack.cloneAndSubtract(1); - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - itemstack.add(1); - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - itemstack.add(1); - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - - entitytypes.spawnCreature(isourceblock.getWorld(), itemstack, (EntityHuman) null, isourceblock.getBlockPosition().shift(enumdirection), EnumMobSpawn.DISPENSER, enumdirection != EnumDirection.UP, false); - // itemstack.subtract(1); // Handled during event processing - // CraftBukkit end - return itemstack; - } - }; - Iterator iterator = ItemMonsterEgg.f().iterator(); - - while (iterator.hasNext()) { - ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) iterator.next(); - - BlockDispenser.a((IMaterial) itemmonsteregg, (IDispenseBehavior) dispensebehavioritem); - } - - BlockDispenser.a((IMaterial) Items.ARMOR_STAND, (IDispenseBehavior) (new DispenseBehaviorItem() { - @Override - public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); - World world = isourceblock.getWorld(); - - // CraftBukkit start - ItemStack itemstack1 = itemstack.cloneAndSubtract(1); - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - itemstack.add(1); - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - itemstack.add(1); - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - // CraftBukkit end - - EntityArmorStand entityarmorstand = new EntityArmorStand(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D); - - EntityTypes.a(world, (EntityHuman) null, (Entity) entityarmorstand, itemstack.getTag()); - entityarmorstand.yaw = enumdirection.n(); - world.addEntity(entityarmorstand); - // itemstack.subtract(1); // CraftBukkit - Handled during event processing - return itemstack; - } })); BlockDispenser.a((IMaterial) Items.FIREWORK_ROCKET, (IDispenseBehavior) (new DispenseBehaviorItem() { @Override @@ -326,139 +149,6 @@ protected void a(ISourceBlock isourceblock) { isourceblock.getWorld().triggerEffect(1018, isourceblock.getBlockPosition(), 0); } - })); - BlockDispenser.a((IMaterial) Items.OAK_BOAT, (IDispenseBehavior) (new DispenseBehaviorBoat(EntityBoat.EnumBoatType.OAK))); - BlockDispenser.a((IMaterial) Items.SPRUCE_BOAT, (IDispenseBehavior) (new DispenseBehaviorBoat(EntityBoat.EnumBoatType.SPRUCE))); - BlockDispenser.a((IMaterial) Items.BIRCH_BOAT, (IDispenseBehavior) (new DispenseBehaviorBoat(EntityBoat.EnumBoatType.BIRCH))); - BlockDispenser.a((IMaterial) Items.JUNGLE_BOAT, (IDispenseBehavior) (new DispenseBehaviorBoat(EntityBoat.EnumBoatType.JUNGLE))); - BlockDispenser.a((IMaterial) Items.DARK_OAK_BOAT, (IDispenseBehavior) (new DispenseBehaviorBoat(EntityBoat.EnumBoatType.DARK_OAK))); - BlockDispenser.a((IMaterial) Items.ACACIA_BOAT, (IDispenseBehavior) (new DispenseBehaviorBoat(EntityBoat.EnumBoatType.ACACIA))); - DispenseBehaviorItem dispensebehavioritem1 = new DispenseBehaviorItem() { - private final DispenseBehaviorItem b = new DispenseBehaviorItem(); - - @Override - public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - ItemBucket itembucket = (ItemBucket) itemstack.getItem(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - World world = isourceblock.getWorld(); - - // CraftBukkit start - int x = blockposition.getX(); - int y = blockposition.getY(); - int z = blockposition.getZ(); - IBlockData iblockdata = world.getType(blockposition); - Material material = iblockdata.getMaterial(); - if (world.isEmpty(blockposition) || !material.isBuildable() || material.isReplaceable() || ((iblockdata.getBlock() instanceof IFluidContainer) && ((IFluidContainer) iblockdata.getBlock()).canPlace(world, blockposition, iblockdata, itembucket.fluidType))) { - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - - itembucket = (ItemBucket) CraftItemStack.asNMSCopy(event.getItem()).getItem(); - } - // CraftBukkit end - - if (itembucket.a((EntityHuman) null, world, blockposition, (MovingObjectPositionBlock) null)) { - itembucket.a(world, itemstack, blockposition); - // CraftBukkit start - Handle stacked buckets - Item item = Items.BUCKET; - itemstack.subtract(1); - if (itemstack.isEmpty()) { - itemstack.setItem(Items.BUCKET); - itemstack.setCount(1); - } else if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { - this.b.dispense(isourceblock, new ItemStack(item)); - } - // CraftBukkit end - return itemstack; - } else { - return this.b.dispense(isourceblock, itemstack); - } - } - }; - - BlockDispenser.a((IMaterial) Items.LAVA_BUCKET, (IDispenseBehavior) dispensebehavioritem1); - BlockDispenser.a((IMaterial) Items.WATER_BUCKET, (IDispenseBehavior) dispensebehavioritem1); - BlockDispenser.a((IMaterial) Items.SALMON_BUCKET, (IDispenseBehavior) dispensebehavioritem1); - BlockDispenser.a((IMaterial) Items.COD_BUCKET, (IDispenseBehavior) dispensebehavioritem1); - BlockDispenser.a((IMaterial) Items.PUFFERFISH_BUCKET, (IDispenseBehavior) dispensebehavioritem1); - BlockDispenser.a((IMaterial) Items.TROPICAL_FISH_BUCKET, (IDispenseBehavior) dispensebehavioritem1); - BlockDispenser.a((IMaterial) Items.BUCKET, (IDispenseBehavior) (new DispenseBehaviorItem() { - private final DispenseBehaviorItem b = new DispenseBehaviorItem(); - - @Override - public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - IBlockData iblockdata = world.getType(blockposition); - Block block = iblockdata.getBlock(); - - if (block instanceof IFluidSource) { - FluidType fluidtype = ((IFluidSource) block).removeFluid(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata); // CraftBukkit - - if (!(fluidtype instanceof FluidTypeFlowing)) { - return super.a(isourceblock, itemstack); - } else { - Item item = fluidtype.a(); - - // CraftBukkit start - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - - fluidtype = ((IFluidSource) block).removeFluid(world, blockposition, iblockdata); // From above - // CraftBukkit end - - itemstack.subtract(1); - if (itemstack.isEmpty()) { - return new ItemStack(item); - } else { - if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(new ItemStack(item)) < 0) { - this.b.dispense(isourceblock, new ItemStack(item)); - } - - return itemstack; - } - } - } else { - return super.a(isourceblock, itemstack); - } - } })); BlockDispenser.a((IMaterial) Items.FLINT_AND_STEEL, (IDispenseBehavior) (new DispenseBehaviorMaybe() { @Override @@ -512,360 +202,6 @@ itemstack.setCount(0); } - return itemstack; - } - })); - BlockDispenser.a((IMaterial) Items.BONE_MEAL, (IDispenseBehavior) (new DispenseBehaviorMaybe() { - @Override - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - this.dispensed = true; - World world = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - // CraftBukkit start - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - - world.captureTreeGeneration = true; - // CraftBukkit end - - if (!ItemBoneMeal.a(itemstack, world, blockposition) && !ItemBoneMeal.a(itemstack, world, blockposition, (EnumDirection) null)) { - this.dispensed = false; - } else if (!world.isClientSide) { - world.triggerEffect(2005, blockposition, 0); - } - // CraftBukkit start - world.captureTreeGeneration = false; - if (world.capturedBlockStates.size() > 0) { - TreeType treeType = BlockSapling.treeType; - BlockSapling.treeType = null; - Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); - List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); - world.capturedBlockStates.clear(); - StructureGrowEvent structureEvent = null; - if (treeType != null) { - structureEvent = new StructureGrowEvent(location, treeType, false, null, blocks); - org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); - } - if (structureEvent == null || !structureEvent.isCancelled()) { - for (org.bukkit.block.BlockState blockstate : blocks) { - blockstate.update(true); - } - } - } - // CraftBukkit end - - return itemstack; - } - })); - BlockDispenser.a((IMaterial) Blocks.TNT, (IDispenseBehavior) (new DispenseBehaviorItem() { - @Override - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - // EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (EntityLiving) null); - - // CraftBukkit start - ItemStack itemstack1 = itemstack.cloneAndSubtract(1); - org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - itemstack.add(1); - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - itemstack.add(1); - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - - EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), (EntityLiving) null); - // CraftBukkit end - - world.addEntity(entitytntprimed); - world.playSound((EntityHuman) null, entitytntprimed.locX(), entitytntprimed.locY(), entitytntprimed.locZ(), SoundEffects.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); - // itemstack.subtract(1); // CraftBukkit - handled above - return itemstack; - } - })); - DispenseBehaviorMaybe dispensebehaviormaybe = new DispenseBehaviorMaybe() { - @Override - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - this.dispensed = ItemArmor.a(isourceblock, itemstack); - return itemstack; - } - }; - - BlockDispenser.a((IMaterial) Items.CREEPER_HEAD, (IDispenseBehavior) dispensebehaviormaybe); - BlockDispenser.a((IMaterial) Items.ZOMBIE_HEAD, (IDispenseBehavior) dispensebehaviormaybe); - BlockDispenser.a((IMaterial) Items.DRAGON_HEAD, (IDispenseBehavior) dispensebehaviormaybe); - BlockDispenser.a((IMaterial) Items.SKELETON_SKULL, (IDispenseBehavior) dispensebehaviormaybe); - BlockDispenser.a((IMaterial) Items.PLAYER_HEAD, (IDispenseBehavior) dispensebehaviormaybe); - BlockDispenser.a((IMaterial) Items.WITHER_SKELETON_SKULL, (IDispenseBehavior) (new DispenseBehaviorMaybe() { - @Override - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); - EnumDirection enumdirection = (EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING); - BlockPosition blockposition = isourceblock.getBlockPosition().shift(enumdirection); - - // CraftBukkit start - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - // CraftBukkit end - - if (world.isEmpty(blockposition) && BlockWitherSkull.b(world, blockposition, itemstack)) { - world.setTypeAndData(blockposition, (IBlockData) Blocks.WITHER_SKELETON_SKULL.getBlockData().set(BlockSkull.a, enumdirection.m() == EnumDirection.EnumAxis.Y ? 0 : enumdirection.opposite().get2DRotationValue() * 4), 3); - TileEntity tileentity = world.getTileEntity(blockposition); - - if (tileentity instanceof TileEntitySkull) { - BlockWitherSkull.a(world, blockposition, (TileEntitySkull) tileentity); - } - - itemstack.subtract(1); - this.dispensed = true; - } else { - this.dispensed = ItemArmor.a(isourceblock, itemstack); - } - - return itemstack; - } - })); - BlockDispenser.a((IMaterial) Blocks.CARVED_PUMPKIN, (IDispenseBehavior) (new DispenseBehaviorMaybe() { - @Override - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - BlockPumpkinCarved blockpumpkincarved = (BlockPumpkinCarved) Blocks.CARVED_PUMPKIN; - - // CraftBukkit start - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - // CraftBukkit end - - if (world.isEmpty(blockposition) && blockpumpkincarved.a((IWorldReader) world, blockposition)) { - if (!world.isClientSide) { - world.setTypeAndData(blockposition, blockpumpkincarved.getBlockData(), 3); - } - - itemstack.subtract(1); - this.dispensed = true; - } else { - this.dispensed = ItemArmor.a(isourceblock, itemstack); - } - - return itemstack; - } - })); - BlockDispenser.a((IMaterial) Blocks.SHULKER_BOX.getItem(), (IDispenseBehavior) (new DispenseBehaviorShulkerBox())); - EnumColor[] aenumcolor = EnumColor.values(); - int i = aenumcolor.length; - - for (int j = 0; j < i; ++j) { - EnumColor enumcolor = aenumcolor[j]; - - BlockDispenser.a((IMaterial) BlockShulkerBox.a(enumcolor).getItem(), (IDispenseBehavior) (new DispenseBehaviorShulkerBox())); - } - - BlockDispenser.a((IMaterial) Items.GLASS_BOTTLE.getItem(), (IDispenseBehavior) (new DispenseBehaviorMaybe() { - private final DispenseBehaviorItem c = new DispenseBehaviorItem(); - - private ItemStack a(ISourceBlock isourceblock, ItemStack itemstack, ItemStack itemstack1) { - itemstack.subtract(1); - if (itemstack.isEmpty()) { - return itemstack1.cloneItemStack(); - } else { - if (((TileEntityDispenser) isourceblock.getTileEntity()).addItem(itemstack1.cloneItemStack()) < 0) { - this.c.dispense(isourceblock, itemstack1.cloneItemStack()); - } - - return itemstack; - } - } - - @Override - public ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - this.dispensed = false; - World world = isourceblock.getWorld(); - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - IBlockData iblockdata = world.getType(blockposition); - Block block = iblockdata.getBlock(); - - // CraftBukkit start - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - // CraftBukkit end - - if (block.a(TagsBlock.BEEHIVES) && (Integer) iblockdata.get(BlockBeehive.c) >= 5) { - ((BlockBeehive) iblockdata.getBlock()).a(world.getMinecraftWorld(), iblockdata, blockposition, (EntityHuman) null, TileEntityBeehive.ReleaseStatus.BEE_RELEASED); - this.dispensed = true; - return this.a(isourceblock, itemstack, new ItemStack(Items.pX)); - } else if (world.getFluid(blockposition).a(TagsFluid.WATER)) { - this.dispensed = true; - return this.a(isourceblock, itemstack, PotionUtil.a(new ItemStack(Items.POTION), Potions.WATER)); - } else { - return super.a(isourceblock, itemstack); - } - } - })); - BlockDispenser.a((IMaterial) Items.SHEARS.getItem(), (IDispenseBehavior) (new DispenseBehaviorMaybe() { - @Override - protected ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) { - World world = isourceblock.getWorld(); - // CraftBukkit start - org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(isourceblock.getBlockPosition().getX(), isourceblock.getBlockPosition().getY(), isourceblock.getBlockPosition().getZ()); - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack); - - BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); - if (!BlockDispenser.eventFired) { - world.getServer().getPluginManager().callEvent(event); - } - - if (event.isCancelled()) { - return itemstack; - } - - if (!event.getItem().equals(craftItem)) { - // Chain to handler for new item - ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem()); - IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.REGISTRY.get(eventStack.getItem()); - if (idispensebehavior != IDispenseBehavior.NONE && idispensebehavior != this) { - idispensebehavior.dispense(isourceblock, eventStack); - return itemstack; - } - } - // CraftBukkit end - - if (!world.p_()) { - this.dispensed = false; - BlockPosition blockposition = isourceblock.getBlockPosition().shift((EnumDirection) isourceblock.getBlockData().get(BlockDispenser.FACING)); - List list = world.a(EntitySheep.class, new AxisAlignedBB(blockposition)); - Iterator iterator1 = list.iterator(); - - while (iterator1.hasNext()) { - EntitySheep entitysheep = (EntitySheep) iterator1.next(); - - if (entitysheep.isAlive() && !entitysheep.isSheared() && !entitysheep.isBaby()) { - // CraftBukkit start - if (CraftEventFactory.callBlockShearEntityEvent(entitysheep, bukkitBlock, craftItem).isCancelled()) { - continue; - } - // CraftBukkit end - entitysheep.shear(); - if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) { - itemstack.setCount(0); - } - - this.dispensed = true; - break; - } - } - - if (!this.dispensed) { - IBlockData iblockdata = world.getType(blockposition); - - if (iblockdata.a(TagsBlock.BEEHIVES)) { - int k = (Integer) iblockdata.get(BlockBeehive.c); - - if (k >= 5) { - if (itemstack.isDamaged(1, world.random, (EntityPlayer) null)) { - itemstack.setCount(0); - } - - BlockBeehive.a(world, blockposition); - ((BlockBeehive) iblockdata.getBlock()).a(world, iblockdata, blockposition, (EntityHuman) null, TileEntityBeehive.ReleaseStatus.BEE_RELEASED); - this.dispensed = true; - } - } - } - } - return itemstack; } })); Index: src/main/java/net/minecraft/server/JsonList.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java --- a/src/main/java/net/minecraft/server/JsonList.java (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/src/main/java/net/minecraft/server/JsonList.java (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -156,6 +156,8 @@ } public void save() throws IOException { + if(!c.canWrite()) + return; Collection collection = this.d.values(); String s = this.b.toJson(collection); BufferedWriter bufferedwriter = null; Index: src/main/java/net/minecraft/server/MinecraftServer.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/src/main/java/net/minecraft/server/MinecraftServer.java (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -30,19 +30,7 @@ import java.nio.file.Paths; import java.security.KeyPair; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Random; -import java.util.UUID; +import java.util.*; import java.util.Map.Entry; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; @@ -168,11 +156,12 @@ private boolean forceTicks; // CraftBukkit end // Spigot start - public static final int TPS = 20; - public static final int TICK_TIME = 1000000000 / TPS; + public static int TPS = 20; + public static int TICK_TIME = 1000000000 / TPS; private static final int SAMPLE_INTERVAL = 100; public final double[] recentTps = new double[ 3 ]; public final SlackActivityAccountant slackActivityAccountant = new SlackActivityAccountant(); + public static long startNanos; // Spigot end public MinecraftServer(OptionSet options, Proxy proxy, DataFixer datafixer, CommandDispatcher commanddispatcher, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache, WorldLoadListenerFactory worldloadlistenerfactory, String s) { @@ -449,10 +438,8 @@ } } this.a(this.getDifficulty(), true); - for (WorldServer worldserver : this.getWorlds()) { - this.loadSpawn(worldserver.getChunkProvider().playerChunkMap.worldLoadListener, worldserver); - this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld())); - } + + this.getWorlds().forEach(worldserver -> this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld()))); this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD); this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP)); @@ -1132,6 +1119,7 @@ } public static void main(final OptionSet optionset) { // CraftBukkit - replaces main(String[] astring) + startNanos = SystemUtils.getMonotonicNanos(); /* CraftBukkit start - Replace everything OptionParser optionparser = new OptionParser(); OptionSpec optionspec = optionparser.accepts("nogui"); @@ -1162,36 +1150,27 @@ DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support dedicatedserversettings.save(); - java.nio.file.Path java_nio_file_path1 = Paths.get("eula.txt"); - EULA eula = new EULA(java_nio_file_path1); - - if (optionset.has("initSettings")) { // CraftBukkit - MinecraftServer.LOGGER.info("Initialized '" + java_nio_file_path.toAbsolutePath().toString() + "' and '" + java_nio_file_path1.toAbsolutePath().toString() + "'"); - return; - } // Spigot Start - boolean eulaAgreed = Boolean.getBoolean( "com.mojang.eula.agree" ); - if ( eulaAgreed ) - { - System.err.println( "You have used the Spigot command line EULA agreement flag." ); - System.err.println( "By using this setting you are indicating your agreement to Mojang's EULA (https://account.mojang.com/documents/minecraft_eula)." ); - System.err.println( "If you do not agree to the above EULA please stop your server and remove this flag immediately." ); - } - // Spigot End - if (!eula.a() && !eulaAgreed) { // Spigot - MinecraftServer.LOGGER.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info."); - return; - } - CrashReport.h(); - DispenserRegistry.init(); - DispenserRegistry.c(); + Thread registryThread = new Thread(() -> { + DispenserRegistry.init(); + DispenserRegistry.c(); + }, "RegistryInitializer"); + registryThread.start(); + long l = SystemUtils.getMonotonicNanos() - MinecraftServer.startNanos; + String s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); + + LOGGER.info("({})! For Loading Registries", s2); File s = (File) optionset.valueOf("universe"); // CraftBukkit YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString()); MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService(); GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); UserCache usercache = new UserCache(gameprofilerepository, new File(s, MinecraftServer.b.getName())); + l = SystemUtils.getMonotonicNanos() - MinecraftServer.startNanos; + s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); + + LOGGER.info("({})! For Initializing Repositories", s2); // CraftBukkit start String s1 = (String) Optional.ofNullable(optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName); final DedicatedServer dedicatedserver = new DedicatedServer(optionset, dedicatedserversettings, DataConverterRegistry.a(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, usercache, WorldLoadListenerLogger::new, s1); @@ -1242,6 +1221,10 @@ dedicatedserver.setEraseCache(true); } + l = SystemUtils.getMonotonicNanos() - MinecraftServer.startNanos; + s2 = String.format(Locale.ROOT, "%.3fs", (double) l / 1.0E9D); + + LOGGER.info("({})! For Initializing Dedicated Server", s2); dedicatedserver.serverThread.start(); // CraftBukkit end } catch (Exception exception) { @@ -1724,47 +1707,39 @@ } private void b(WorldData worlddata) { - List list = Lists.newArrayList(this.resourcePackRepository.d()); - Iterator iterator = this.resourcePackRepository.b().iterator(); - - while (iterator.hasNext()) { - ResourcePackLoader resourcepackloader = (ResourcePackLoader) iterator.next(); + Thread reloadResource = new Thread(() -> { + List list = Lists.newArrayList(this.resourcePackRepository.d()); + Iterator iterator = this.resourcePackRepository.b().iterator(); + while (iterator.hasNext()) { + ResourcePackLoader resourcepackloader = (ResourcePackLoader) iterator.next(); - if (!worlddata.N().contains(resourcepackloader.e()) && !list.contains(resourcepackloader)) { - MinecraftServer.LOGGER.info("Found new data pack {}, loading it automatically", resourcepackloader.e()); - resourcepackloader.h().a(list, resourcepackloader, (resourcepackloader1) -> { - return resourcepackloader1; - }, false); - } - } + if (!worlddata.N().contains(resourcepackloader.e()) && !list.contains(resourcepackloader)) { + MinecraftServer.LOGGER.info("Found new data pack {}, loading it automatically", resourcepackloader.e()); + resourcepackloader.h().a(list, resourcepackloader, (resourcepackloader1) -> { + return resourcepackloader1; + }, false); + } + } - this.resourcePackRepository.a((Collection) list); - List list1 = Lists.newArrayList(); + this.resourcePackRepository.a((Collection) list); + List list1 = Lists.newArrayList(); - this.resourcePackRepository.d().forEach((resourcepackloader1) -> { - list1.add(resourcepackloader1.d()); - }); - CompletableFuture completablefuture = this.ae.a(this.executorService, this, list1, MinecraftServer.i); - - this.awaitTasks(completablefuture::isDone); - - try { - completablefuture.get(); - } catch (Exception exception) { - MinecraftServer.LOGGER.error("Failed to reload data packs", exception); - } - - worlddata.O().clear(); - worlddata.N().clear(); - this.resourcePackRepository.d().forEach((resourcepackloader1) -> { - worlddata.O().add(resourcepackloader1.e()); - }); - this.resourcePackRepository.b().forEach((resourcepackloader1) -> { - if (!this.resourcePackRepository.d().contains(resourcepackloader1)) { - worlddata.N().add(resourcepackloader1.e()); - } - + this.resourcePackRepository.d().forEach((resourcepackloader1) -> { + list1.add(resourcepackloader1.d()); + }); + this.ae.a(this.executorService, this, list1, MinecraftServer.i); + worlddata.O().clear(); + worlddata.N().clear(); + this.resourcePackRepository.d().forEach((resourcepackloader1) -> { + worlddata.O().add(resourcepackloader1.e()); + }); + this.resourcePackRepository.b().forEach((resourcepackloader1) -> { + if (!this.resourcePackRepository.d().contains(resourcepackloader1)) { + worlddata.N().add(resourcepackloader1.e()); + } + }); }); + reloadResource.start(); } public void a(CommandListenerWrapper commandlistenerwrapper) { @@ -2075,7 +2050,8 @@ } private void bb() { - Block.REGISTRY_ID.forEach(IBlockData::c); + Thread blockRegistry = new Thread(() -> Block.REGISTRY_ID.forEach(IBlockData::c)); + blockRegistry.start(); } // CraftBukkit start Index: src/main/java/org/bukkit/craftbukkit/CraftServer.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -38,6 +38,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.concurrent.*; import java.util.function.Consumer; import java.util.logging.Level; import java.util.logging.Logger; @@ -234,6 +235,7 @@ public boolean ignoreVanillaPermissions = false; private final List playerView; public int reloadCount; + private boolean allPluginsLoaded = false; static { ConfigurationSerialization.registerClass(CraftOfflinePlayer.class); @@ -347,22 +349,38 @@ public void loadPlugins() { pluginManager.registerInterface(JavaPluginLoader.class); - File pluginFolder = (File) console.options.valueOf("plugins"); + Thread pluginloader = new Thread(() -> { + File pluginFolder = (File) console.options.valueOf("plugins"); - if (pluginFolder.exists()) { - Plugin[] plugins = pluginManager.loadPlugins(pluginFolder); - for (Plugin plugin : plugins) { - try { - String message = String.format("Loading %s", plugin.getDescription().getFullName()); - plugin.getLogger().info(message); - plugin.onLoad(); - } catch (Throwable ex) { - Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, ex.getMessage() + " initializing " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); + if (pluginFolder.exists()) { + Plugin[] plugins = pluginManager.loadPlugins(pluginFolder); + ThreadPoolExecutor group = new ThreadPoolExecutor(2, 4, 5, TimeUnit.SECONDS, new ArrayBlockingQueue(Math.min(plugins.length, 1))); + for (Plugin plugin : plugins) { + group.execute(() -> { + try { + String message = String.format("Loading %s", plugin.getDescription().getFullName()); + plugin.getLogger().info(message); + plugin.onLoad(); + } catch (Throwable ex) { + Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, ex.getMessage() + " initializing " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); + } + }); } - } - } else { - pluginFolder.mkdir(); - } + try { + while (!group.getQueue().isEmpty()) { + Thread.sleep(10); + } + enablePlugins(PluginLoadOrder.STARTUP); + } catch (InterruptedException e) { + logger.severe(e.getMessage()); + e.printStackTrace(); + System.exit(1); + } + } else { + pluginFolder.mkdir(); + } + }); + pluginloader.start(); } public void enablePlugins(PluginLoadOrder type) { @@ -831,7 +849,6 @@ )); } loadPlugins(); - enablePlugins(PluginLoadOrder.STARTUP); enablePlugins(PluginLoadOrder.POSTWORLD); getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.RELOAD)); } Index: src/main/java/org/bukkit/craftbukkit/Main.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java --- a/src/main/java/org/bukkit/craftbukkit/Main.java (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/src/main/java/org/bukkit/craftbukkit/Main.java (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -181,23 +181,6 @@ System.setProperty(jline.TerminalFactory.JLINE_TERMINAL, jline.UnsupportedTerminal.class.getName()); } - if (options.has("noconsole")) { - useConsole = false; - } - - if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { - Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L); - - Calendar deadline = Calendar.getInstance(); - deadline.add(Calendar.DAY_OF_YEAR, -21); - if (buildDate.before(deadline.getTime())) { - System.err.println("*** Error, this build is outdated ***"); - System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***"); - System.err.println("*** Server will start in 20 seconds ***"); - Thread.sleep(TimeUnit.SECONDS.toMillis(20)); - } - } - System.out.println("Loading libraries, please wait..."); MinecraftServer.main(options); } catch (Throwable t) { Index: src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java --- a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java (revision 22fba2706e53d3d24a5901b2881c3d97f9781f34) +++ b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java (revision a16617e368c59c772e5873c8c3a4040444e4ea57) @@ -66,10 +66,6 @@ } public static ConsoleCommandSender getInstance() { - if (Bukkit.getConsoleSender() != null) { - return Bukkit.getConsoleSender(); - } else { - return new ColouredConsoleSender(); - } + return new ColouredConsoleSender(); } }