Solved Problems with a Thread

Discussion in 'Plugin Development' started by Oneric-1st, Feb 20, 2013.

Thread Status:
Not open for further replies.
  1. Hi,

    I work on a Plugin that edit parts of the World often.
    Now every time it's editing a bigger area the server lags extremly.
    So I wanted to put the World-Editing Code parts into an own Thread that use methods like wait() and yield() to reduce the lags. But when I try to use it, the Server crashs and I have no idea why.
    Hope you can help me.

    Here's the Error Report:

    Show Spoiler

    Code:
    ---- Minecraft Crash Report ----
    // Hey, that tickles! Hehehe!
     
    Time: 20.02.13 20:46
    Description: Exception ticking world
     
    java.lang.IllegalStateException: TickNextTick list out of synch
    at net.minecraft.server.v1_4_R1.WorldServer.a(WorldServer.java:456)
    at net.minecraft.server.v1_4_R1.WorldServer.doTick(WorldServer.java:172)
    at net.minecraft.server.v1_4_R1.MinecraftServer.r(MinecraftServer.java:572)
    at net.minecraft.server.v1_4_R1.DedicatedServer.r(DedicatedServer.java:224)
    at net.minecraft.server.v1_4_R1.MinecraftServer.q(MinecraftServer.java:494)
    at net.minecraft.server.v1_4_R1.MinecraftServer.run(MinecraftServer.java:427)
    at net.minecraft.server.v1_4_R1.ThreadServerApplication.run(SourceFile:849)
     
     
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    Show Spoiler

    Code:
    -- Head --
    Stacktrace:
    at net.minecraft.server.v1_4_R1.WorldServer.a(WorldServer.java:456)
    at net.minecraft.server.v1_4_R1.WorldServer.doTick(WorldServer.java:172)
     
    -- Affected level --
    Details:
    Level name: world
    All players: 1 total; [EntityPlayer['nkioe'/161, l='world', x=998,25, y=83,00, z=999,51](nkioe at 998.2537830319898,83.0,999.5142604112625)]
    Chunk stats: ServerChunkCache: 703 Drop: 0
    Level seed: 7334392542878787279
    Level generator: ID 00 - default, ver 1. Features enabled: true
    Level generator options:
    Level spawn location: World: (1,74,-10), Chunk: (at 1,4,6 in 0,-1; contains blocks 0,0,-16 to 15,255,-1), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
    Level time: 527191 game time, 529519 day time
    Level dimension: 0
    Level storage version: 0x04ABD - Anvil
    Level weather: Rain time: 49471 (now: false), thunder time: 94469 (now: false)
    Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
    Stacktrace:
    at net.minecraft.server.v1_4_R1.MinecraftServer.r(MinecraftServer.java:572)
    at net.minecraft.server.v1_4_R1.DedicatedServer.r(DedicatedServer.java:224)
    at net.minecraft.server.v1_4_R1.MinecraftServer.q(MinecraftServer.java:494)
    at net.minecraft.server.v1_4_R1.MinecraftServer.run(MinecraftServer.java:427)
    at net.minecraft.server.v1_4_R1.ThreadServerApplication.run(SourceFile:849)
     
    -- System Details --
    Details:
    Minecraft Version: 1.4.7
    Operating System: Windows 7 (amd64) version 6.1
    Java Version: 1.7.0_09, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 699359848 bytes (666 MB) / 1029046272 bytes (981 MB) up to 1029046272 bytes (981 MB)
    JVM Flags: 2 total; -Xms1024M -Xmx1024M
    AABB Pool Size: 1896 (106176 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    Suspicious classes: $Proxy3, $Proxy4[com.avaje.ebean.config.dbplatform.DatabasePlatform, SQLitePlatform], [com.google.common.base.Predicate, Function, Joiner, ...], [com.google.common.collect.ImmutableCollection, ImmutableList, Maps, ...], [com.google.common.io.Files, InputSupplier, OutputSupplier], [net.minecraft.server.v1_4_R1.ICommandListener, IMojangStatistics, IDataManager, ...], [org.apache.commons.lang.Validate, UnhandledException, StringUtils, ...], [org.apache.commons.lang.exception.Nestable, NestableRuntimeException], [org.apache.commons.lang.math.NumberUtils], [org.bukkit.World, BlockChangeDelegate, Server, ...], [org.bukkit.block.BlockState, BlockFace, Block, ...], [org.bukkit.command.CommandSender, RemoteConsoleCommandSender, CommandException, ...], [org.bukkit.command.defaults.VanillaCommand, SaveCommand, SaveOnCommand, ...], [org.bukkit.configuration.ConfigurationSection, Configuration, MemorySection, ...], [org.bukkit.configuration.file.FileConfiguration, YamlConfiguration, FileConfigurationOptions, ...], [org.bukkit.configuration.serialization.ConfigurationSerializable, ConfigurationSerialization, DelegateDeserialization, ...], [org.bukkit.conversations.Conversable, ConversationCanceller], [org.bukkit.craftbukkit.Main], [org.bukkit.craftbukkit.libs.com.google.gson.JsonDeserializer, JsonParseException, GsonBuilder, ...], [org.bukkit.craftbukkit.libs.com.google.gson.annotations.SerializedName], [org.bukkit.craftbukkit.libs.com.google.gson.internal.Excluder, $Gson$Preconditions, Primitives, ...], [org.bukkit.craftbukkit.libs.com.google.gson.internal.bind.JsonTreeReader, JsonTreeWriter, BigDecimalTypeAdapter, ...], [org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken], [org.bukkit.craftbukkit.libs.com.google.gson.stream.JsonReader, JsonWriter, MalformedJsonException, ...], [org.bukkit.craftbukkit.libs.jline.TerminalFactory, Terminal, Flavor, ...], [org.bukkit.craftbukkit.libs.jline.console.ConsoleReader, CursorBuffer, ConsoleKeys, ...], [org.bukkit.craftbukkit.libs.jline.console.completer.CompletionHandler, CandidateListCompletionHandler], [org.bukkit.craftbukkit.libs.jline.console.history.History, MemoryHistory], [org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader, Configuration, Log], [org.bukkit.craftbukkit.libs.joptsimple.OptionException, OptionParser, OptionSpec, ...], [org.bukkit.craftbukkit.libs.joptsimple.internal.AbbreviationMap, ReflectionException, Reflection, ...], [org.bukkit.craftbukkit.libs.joptsimple.util.KeyValuePair], [org.bukkit.craftbukkit.v1_4_R1.LoggerOutputStream, CraftServer, CraftOfflinePlayer, ...], [org.bukkit.craftbukkit.v1_4_R1.block.CraftBlock, CraftBlockState], [org.bukkit.craftbukkit.v1_4_R1.chunkio.ChunkIOExecutor, ChunkIOProvider, QueuedChunk], [org.bukkit.craftbukkit.v1_4_R1.command.ServerCommandSender, CraftConsoleCommandSender, ColouredConsoleSender], [org.bukkit.craftbukkit.v1_4_R1.conversations.ConversationTracker], [org.bukkit.craftbukkit.v1_4_R1.enchantments.CraftEnchantment], [org.bukkit.craftbukkit.v1_4_R1.entity.CraftEntity, CraftLivingEntity, CraftHumanEntity, ...], [org.bukkit.craftbukkit.v1_4_R1.event.CraftEventFactory], [org.bukkit.craftbukkit.v1_4_R1.generator.InternalChunkGenerator, CustomChunkGenerator, NormalChunkGenerator, ...], [org.bukkit.craftbukkit.v1_4_R1.help.SimpleHelpMap, CommandAliasHelpTopic, HelpYamlReader, ...], [org.bukkit.craftbukkit.v1_4_R1.inventory.CraftItemStack, CraftRecipe, CraftShapedRecipe, ...], [org.bukkit.craftbukkit.v1_4_R1.metadata.EntityMetadataStore, PlayerMetadataStore, WorldMetadataStore, ...], [org.bukkit.craftbukkit.v1_4_R1.potion.CraftPotionEffectType, CraftPotionBrewer], [org.bukkit.craftbukkit.v1_4_R1.scheduler.CraftScheduler, CraftTask, CraftAsyncTask, ...], [org.bukkit.craftbukkit.v1_4_R1.updater.AutoUpdater, BukkitDLUpdaterService, DateDeserializer, ...], [org.bukkit.craftbukkit.v1_4_R1.util.Waitable, ServerShutdownThread, TerminalConsoleHandler, ...], [org.bukkit.enchantments.Enchantment, EnchantmentWrapper], [org.bukkit.entity.Entity, Damageable, LivingEntity, ...], [org.bukkit.event.Event, Cancellable, Listener, ...], [org.bukkit.event.block.BlockEvent, BlockFadeEvent, BlockGrowEvent, ...], [org.bukkit.event.entity.EntityEvent, EntityInteractEvent, EntityDamageEvent, ...], [org.bukkit.event.hanging.HangingEvent, HangingPlaceEvent], [org.bukkit.event.inventory.InventoryEvent, InventoryOpenEvent, PrepareItemCraftEvent, ...], [org.bukkit.event.painting.PaintingEvent, PaintingPlaceEvent, PaintingBreakEvent, ...], [org.bukkit.event.player.PlayerEvent, PlayerInteractEvent, PlayerFishEvent, ...], [org.bukkit.event.server.ServerEvent, MapInitializeEvent, ServerCommandEvent, ...], [org.bukkit.event.vehicle.VehicleEvent, VehicleCollisionEvent, VehicleBlockCollisionEvent, ...], [org.bukkit.event.weather.WeatherEvent, ThunderChangeEvent, WeatherChangeEvent, ...], [org.bukkit.event.world.WorldEvent, WorldSaveEvent, WorldInitEvent, ...], [org.bukkit.generator.ChunkGenerator], [org.bukkit.help.HelpMap, HelpTopic, IndexHelpTopic, ...], [org.bukkit.inventory.ItemStack, Recipe, ShapedRecipe, ...], [org.bukkit.inventory.meta.ItemMeta, Repairable, BookMeta, ...], [org.bukkit.map.MapView], [org.bukkit.material.MaterialData, Tree, Directional, ...], [org.bukkit.metadata.Metadatable, MetadataStore, MetadataStoreBase], [org.bukkit.permissions.ServerOperator, Permissible, PermissionDefault, ...], [org.bukkit.plugin.ServicesManager, PluginManager, SimpleServicesManager, ...], [org.bukkit.plugin.java.JavaPluginLoader, PluginClassLoader, JavaPlugin], [org.bukkit.plugin.messaging.PluginMessageRecipient, Messenger, StandardMessenger, ...], [org.bukkit.potion.PotionEffectType, PotionEffectTypeWrapper, PotionBrewer, ...], [org.bukkit.scheduler.BukkitScheduler, BukkitTask, BukkitWorker], [org.bukkit.util.Vector, BlockVector, Java15Compat, ...], [org.bukkit.util.permissions.DefaultPermissions, CommandPermissions, BroadcastPermissions], [org.fusesource.hawtjni.runtime.Library], [org.fusesource.jansi.AnsiOutputStream, WindowsAnsiOutputStream, AnsiConsole, ...], [org.fusesource.jansi.internal.Kernel32, CONSOLE_SCREEN_BUFFER_INFO, COORD, ...], [org.yaml.snakeyaml.DumperOptions, ScalarStyle, FlowStyle, ...], [org.yaml.snakeyaml.composer.Composer, ComposerException], [org.yaml.snakeyaml.constructor.BaseConstructor, SafeConstructor, Constructor, ...], [org.yaml.snakeyaml.emitter.Emitable, Emitter, EmitterException, ...], [org.yaml.snakeyaml.error.YAMLException, MarkedYAMLException, Mark], [org.yaml.snakeyaml.events.Event, NodeEvent, AliasEvent, ...], [org.yaml.snakeyaml.external.com.google.gdata.util.common.base.Escaper, UnicodeEscaper, PercentEscaper], [org.yaml.snakeyaml.introspector.PropertyUtils, BeanAccess], [org.yaml.snakeyaml.nodes.Node, CollectionNode, MappingNode, ...], [org.yaml.snakeyaml.parser.Parser, ParserImpl, ParserException, ...], [org.yaml.snakeyaml.reader.UnicodeReader, StreamReader, ReaderException], [org.yaml.snakeyaml.representer.BaseRepresenter, SafeRepresenter, Representer, ...], [org.yaml.snakeyaml.resolver.Resolver, ResolverTuple], [org.yaml.snakeyaml.scanner.Scanner, ScannerImpl, ScannerException, ...], [org.yaml.snakeyaml.serializer.Serializer, SerializerException], [org.yaml.snakeyaml.tokens.Token, AliasToken, ScalarToken, ...], [org.yaml.snakeyaml.util.UriEncoder, ArrayStack]
    IntCache: cache: 0, tcache: 0, allocated: 3, tallocated: 63
    CraftBukkit Information:
    Running: CraftBukkit version git-Bukkit-1.4.7-R1.0-b2624jnks (MC: 1.4.7) (Implementing API version 1.4.7-R1.0) true
    Plugins: { WorldEdit v5.5.1 com.sk89q.worldedit.bukkit.WorldEditPlugin [], WallsPlugin v0.1.5 oneric.bukkit.walls.src.WallsPlugin [Oneric aka cmdmole],}
    Warnings: DEFAULT
    Threads: { RUNNABLE Connection #1 read thread: [java.net.SocketInputStream.socketRead0(Native Method), java.net.SocketInputStream.read(Unknown Source), java.net.SocketInputStream.read(Unknown Source), java.io.FilterInputStream.read(Unknown Source), net.minecraft.v1_4_R1.org.bouncycastle.crypto.io.CipherInputStream.a(Unknown Source), net.minecraft.v1_4_R1.org.bouncycastle.crypto.io.CipherInputStream.read(Unknown Source), java.io.FilterInputStream.read(Unknown Source), net.minecraft.server.v1_4_R1.Packet.a(Packet.java:93), net.minecraft.server.v1_4_R1.NetworkManager.i(NetworkManager.java:190), net.minecraft.server.v1_4_R1.NetworkManager.c(NetworkManager.java:344), net.minecraft.server.v1_4_R1.NetworkReaderThread.run(SourceFile:93)], TIMED_WAITING File IO Thread: [java.lang.Thread.sleep(Native Method), net.minecraft.server.v1_4_R1.FileIOThread.b(SourceFile:43), net.minecraft.server.v1_4_R1.FileIOThread.run(SourceFile:22), java.lang.Thread.run(Unknown Source)], RUNNABLE Attach Listener: [], WAITING Reference Handler: [java.lang.Object.wait(Native Method), java.lang.Object.wait(Object.java:503), java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)], RUNNABLE Listen thread: [java.net.DualStackPlainSocketImpl.accept0(Native Method), java.net.DualStackPlainSocketImpl.socketAccept(Unknown Source), java.net.AbstractPlainSocketImpl.accept(Unknown Source), java.net.PlainSocketImpl.accept(Unknown Source), java.net.ServerSocket.implAccept(Unknown Source), java.net.ServerSocket.accept(Unknown Source), net.minecraft.server.v1_4_R1.DedicatedServerConnectionThread.run(DedicatedServerConnectionThread.java:62)], RUNNABLE Thread-5: [org.fusesource.jansi.internal.Kernel32._getch(Native Method), org.fusesource.jansi.internal.WindowsSupport.readByte(WindowsSupport.java:46), org.bukkit.craftbukkit.libs.jline.WindowsTerminal.readByte(WindowsTerminal.java:184), org.bukkit.craftbukkit.libs.jline.WindowsTerminal.access$000(WindowsTerminal.java:53), org.bukkit.craftbukkit.libs.jline.WindowsTerminal$1.read(WindowsTerminal.java:151), java.io.FilterInputStream.read(Unknown Source), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader$1.read(ConsoleReader.java:167), org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:267), org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:204), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readCharacter(ConsoleReader.java:995), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLine(ConsoleReader.java:1167), net.minecraft.server.v1_4_R1.ThreadCommandReader.run(ThreadCommandReader.java:31)], WAITING Chunk I/O Executor Thread-1: [sun.misc.Unsafe.park(Native Method), java.util.concurrent.locks.LockSupport.park(Unknown Source), java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source), java.util.concurrent.LinkedBlockingQueue.take(Unknown Source), java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source), java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source), java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source), java.lang.Thread.run(Unknown Source)], TIMED_WAITING Connection #1 write thread: [java.lang.Thread.sleep(Native Method), net.minecraft.server.v1_4_R1.NetworkWriterThread.run(NetworkWriterThread.java:38)], TIMED_WAITING pool-1-thread-1: [sun.misc.Unsafe.park(Native Method), java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source), java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(Unknown Source), java.util.concurrent.SynchronousQueue$TransferStack.transfer(Unknown Source), java.util.concurrent.SynchronousQueue.poll(Unknown Source), java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source), java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source), java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source), java.lang.Thread.run(Unknown Source)], TIMED_WAITING Thread-4: [java.lang.Thread.sleep(Native Method), net.minecraft.server.v1_4_R1.ThreadSleepForever.run(SourceFile:52)], WAITING Finalizer: [java.lang.Object.wait(Native Method), java.lang.ref.ReferenceQueue.remove(Unknown Source), java.lang.ref.ReferenceQueue.remove(Unknown Source), java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)], RUNNABLE Signal Dispatcher: [], RUNNABLE Thread-13: [net.minecraft.server.v1_4_R1.World.b(World.java:618), net.minecraft.server.v1_4_R1.World.c(World.java:2141), net.minecraft.server.v1_4_R1.World.z(World.java:2051), net.minecraft.server.v1_4_R1.World.setRawTypeId(World.java:331), net.minecraft.server.v1_4_R1.World.setTypeId(World.java:398), org.bukkit.craftbukkit.v1_4_R1.block.CraftBlock.setTypeId(CraftBlock.java:107), oneric.bukkit.walls.src.ArenaManagementBase.setOthers(ArenaManagementBase.java:67), oneric.bukkit.walls.src.ArenaManagementBase.run(ArenaManagementBase.java:48), java.lang.Thread.run(Unknown Source)], RUNNABLE DestroyJavaVM: [], TIMED_WAITING Snooper Timer: [java.lang.Object.wait(Native Method), java.util.TimerThread.mainLoop(Unknown Source), java.util.TimerThread.run(Unknown Source)], RUNNABLE Server thread: [java.lang.Thread.dumpThreads(Native Method), java.lang.Thread.getAllStackTraces(Unknown Source), org.bukkit.craftbukkit.v1_4_R1.CraftCrashReport.call(CraftCrashReport.java:28), net.minecraft.server.v1_4_R1.CrashReportSystemDetails.a(SourceFile:74), net.minecraft.server.v1_4_R1.CrashReport.h(CrashReport.java:43), net.minecraft.server.v1_4_R1.CrashReport.<init>(CrashReport.java:30), net.minecraft.server.v1_4_R1.CrashReport.a(CrashReport.java:214), net.minecraft.server.v1_4_R1.MinecraftServer.r(MinecraftServer.java:574), net.minecraft.server.v1_4_R1.DedicatedServer.r(DedicatedServer.java:224), net.minecraft.server.v1_4_R1.MinecraftServer.q(MinecraftServer.java:494), net.minecraft.server.v1_4_R1.MinecraftServer.run(MinecraftServer.java:427), net.minecraft.server.v1_4_R1.ThreadServerApplication.run(SourceFile:849)],}
    Recent tasks from 3797-3827{WorldEdit:[email protected],}
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: ~~ERROR~~ NoSuchFieldError: worldServer
    Player Count: 1 / 20; [EntityPlayer['nkioe'/161, l='world', x=998,25, y=83,00, z=999,51](nkioe at 998.2537830319898,83.0,999.5142604112625)]
    Is Modded: Definitely; Server brand changed to 'craftbukkit'
    Type: Dedicated Server (map_server.txt)
    




    And here's my code:

    onCommand:
    Show Spoiler

    Code:
    if(com.getName().equalsIgnoreCase("test"))
    {
    if(arg.length == 2)
    {
    WallsArena arena = new WallsArena(4, Integer.parseInt(arg[0]), Integer.parseInt(arg[1]), player.getWorld().getName());
    /*ArenaManagementBase manager = new ArenaManagementBase(arena, plugin);*/
     
    Thread manager = new Thread(new ArenaManagementBase(arena, plugin));
    manager.start();
     
    //manager.copyOriginal(Integer.parseInt(arg[0]), Integer.parseInt(arg[1]));
    //manager.setOthers(0, 0, Integer.parseInt(arg[0]), Integer.parseInt(arg[1]));
     
    /////////
     
    List<Entity> entList = player.getServer().getWorld(player.getWorld().getName()).getEntities();//get all entities in the world
     
    for(int i = 0; i < entList.toArray().length; i++){//loop through the list
    if (entList.get(i) instanceof Item){//make sure we aren't deleting mobs/players
    entList.get(i).remove();//remove it
     
    }
    }
     
    ////////
     
     
    player.sendMessage(ChatColor.GREEN + "Finished !"); // I know this Message will come instantly with using a Thread
     
    return true;
    }
    }
     
    


    The Thread Class:
    Show Spoiler

    Code:
    package oneric.bukkit.walls.src;
     
    public class ArenaManagementBase extends ArenaManagement implements Runnable{
     
     
     
     
    private int[] idsOriginal;
    private byte[] metasOriginal;
     
     
     
     
     
    public ArenaManagementBase(WallsArena wArena, WallsPlugin plugin)
    {
    super(wArena, plugin);
     
    idsOriginal = new int[arena.xWide * arena.yWide * this.currentWorld.getMaxHeight()];
    metasOriginal = new byte[arena.xWide * arena.yWide * this.currentWorld.getMaxHeight()];
     
    /*
    this.copyOriginal(arena.xWide, arena.yWide);
     
    for(int i = 1; i <= arena.AnzahlGruppen; i++)
    {
    this.setOthers(this.pos.get(i)[0], this.pos.get(i)[1], arena.xWide, arena.yWide);
    }
    */
     
     
     
     
     
    }
     
     
     
     
     
    @Override
    public void run()
    {
    this.copyOriginal(arena.xWide, arena.yWide);
     
    for(int i = 1; i <= arena.AnzahlGruppen; i++)
    {
    this.setOthers(this.pos.get(i)[0], this.pos.get(i)[1], arena.xWide, arena.yWide);
    }
    }
     
     
     
     
    public void setOthers(int xDef, int yDef, int xWide, int yWide)
    {
    this.currentWorld.setGameRuleValue("doTileDrops", "false");
    int counter = 0;
     
    for(int x = xDef; x < xWide + xDef; x++)
    {
    for(int z = yDef; z < yWide + yDef; z++)
    {
    for(int y = 0; y < this.currentWorld.getMaxHeight(); y++)
    {
     
    this.currentWorld.getBlockAt(x, y, z).setTypeId(idsOriginal[counter]);
    this.currentWorld.getBlockAt(x, y, z).setData(metasOriginal[counter]);
    counter++;
     
    }
    }
    }
     
    this.currentWorld.setGameRuleValue("doTileDrops", "true");
     
     
     
    ///////////
     
     
     
     
     
     
     
     
    }
     
     
     
     
    public void copyOriginal(int xWide, int yWide)
    {
     
    int counter = 0;
     
    for(int x = arena.defaultPosition[0]; x < xWide + arena.defaultPosition[0]; x++)
    {
    for(int z = arena.defaultPosition[1]; z < yWide + arena.defaultPosition[1]; z++)
    {
    for(int y = 0; y < this.currentWorld.getMaxHeight(); y++)
    {
     
    idsOriginal[counter] = this.currentWorld.getBlockTypeIdAt(x, y, z);
    metasOriginal[counter] = this.currentWorld.getBlockAt(x, y, z).getData();
    counter++;
     
    }
    }
    }
     
    }
     
     
     
     
     
     
     
     
     
    }
     
    


    Thanks for your help
     
  2. Offline

    Tirelessly

    You can't edit the world or call the bukkit API from a different thread.
     
  3. Hmm..

    But how can I reduce the lags ?

    Have nobody an idea ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  4. Offline

    jbman223

    Do the Bukkit calls Synchronously, while keeping everything else async.
     
  5. ??

    Sorry but I don't understand what you wanted to say.

    I tested the command( which start the Thread ) again and I notice that, if I just edit really small areas it works perfectly and no Error shows up.

    So you CAN edit the world with an Thread.

    But whats the the Problem ? Why is this Error showing up ?

    Nobody ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  6. Offline

    chaseoes

    You CAN, but it's bad.

    There's nothing you can do to reduce lag when doing large operations.
     
  7. :(
     
Thread Status:
Not open for further replies.

Share This Page