Jump to content

Minecraft Random Spawn Programmieren HILFE?! (Plugin 1.16.5)


Milanius

Empfohlene Beiträge

Ich möchte ein Random Spawn Plugin programmieren (ich benutze Eclipse) aber es funktioniert nicht. Was funktioniert nicht? Könntet ihr mir Helfen Danke im Vorraus!

public class onJoin implements Listener {
	
	Location locationRaw;
	Location locationRaw2;
	Location location;
	Location location2;
	
	@EventHandler
	private void onPlayerJoin(PlayerJoinEvent e) {
		for(Player p : Bukkit.getOnlinePlayers()) {
			
			World world = Bukkit.getWorlds().get(0);
			int X = getRandom(1500, -1500);
			int Y = getRandom(250, 1);
			Block blockY = world.getBlockAt(location2);
			if(blockY.getType() == Material.GRASS_BLOCK) {
				int rawY = world.getHighestBlockYAt(locationRaw2);
				int Z = getRandom(1500, -1500);
	
				locationRaw2 = new Location(world, X, Y, Z);
				locationRaw = new Location(world, X, rawY, Z);
				location = new Location(world, X, rawY -2, Z);
				location2 = new Location(world, X, rawY -1, Z);
				
				Block block1 = world.getBlockAt(locationRaw);
				block1.setType(Material.AIR);
				Block block2 = world.getBlockAt(locationRaw);
				block2.setType(Material.AIR);
				Block block3 = world.getBlockAt(location2);
				block3.setType(Material.AIR);
				
				p.setBedSpawnLocation(location);
				p.teleport(location);
			}
		}
	}
	
	public int getRandom(int lower, int upper) {
	    Random random = new Random();
	    return random.nextInt((upper - lower) + 1) + lower;
	}

}

 

Link zu diesem Kommentar
Auf anderen Seiten teilen

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde dich hier an.

Jetzt anmelden
×
×
  • Neu erstellen...
B
B