#ByPander - World creation error

1 messages · Page 1 of 1 (latest)

bright geyser
#

Hey @west night,
what do u mean with "its done sync"? I am pretty new to spigot.

candid frost
#

Async cant interact with non thread safe objects/methods

bright geyser
candid frost
#

Code?

bright geyser
# candid frost Code?

WorldCreator wc = new WorldCreator("BingoWorld" + worldNumber); wc.environment(World.Environment.NORMAL); wc.type(WorldType.NORMAL); world = wc.createWorld(); assert world != null; WorldBorder wb = world.getWorldBorder(); wb.setCenter(0,0); wb.setSize(2000);

Do u need more code?

candid frost
#

Clazz

bright geyser
#

Here is the Class:
`package de.bypander.bingo.BingoGame;

import org.bukkit.*;
import org.bukkit.entity.Player;

import java.util.Objects;
import java.util.UUID;

public class BingoGame {
World world;
UUID[] gamePlayer;
QueueManager queueManager;

public BingoGame(UUID[] player, int worldNumber, QueueManager manager) {
    queueManager = manager;

    WorldCreator wc = new WorldCreator("BingoWorld" + worldNumber);
    wc.environment(World.Environment.NORMAL);
    wc.type(WorldType.NORMAL);
    world = wc.createWorld();
    assert world != null;
    WorldBorder wb = world.getWorldBorder();
    wb.setCenter(0,0);
    wb.setSize(2000);


    int i = 0;
    for (UUID value : player) {
        if (value != null) {
            i++;
        }
    }
    gamePlayer = new UUID[i];
    int k = 0;
    for (int j = 0; j < gamePlayer.length; j++) {
        if (player[j] != null) {
            gamePlayer[k] = player[j];
            k++;
        }
    }


    for (int l = 320; l > -64; l--) {
        if (!world.getBlockAt(0, l, 0).isEmpty()) {
            break;
        }
    }
    for (UUID uuid : player) {
        Objects.requireNonNull(Bukkit.getPlayerExact(Objects.requireNonNull(Bukkit.getPlayer(uuid)).getName())).teleport(new Location(world, 0, 0, 0, 0, 0));
    }
}

}`

candid frost
#

Did you created class using async task or promises?

west night
#

as it takes a very long time to create a world

bright geyser
west night
#

cant tell you, ive never dealt with world creation (atleast not on spigot)

bright geyser
# candid frost Did you created class using async task or promises?

Do you mean when i call the constructor?
Here is the method where i am calling the constructor:

public void startRound() { for (UUID value : loggedPlayer) { if (value != null) { Objects.requireNonNull(Bukkit.getPlayer(value)).sendMessage(ChatColor.GRAY.toString() + "The Bingo round is starting. This could take a few moments."); } } new BingoGame(loggedPlayer, worldNumber, this); worldNumber++; }

west night
#

no need for the toString()

#

and the constructor shouldnt be magicaly running stuff