3 Commits

Author SHA1 Message Date
ebf9f36635 Bungeecord join error fix 2023-05-21 11:05:16 +02:00
3b36fcdbbf Word mistake correction 2023-05-20 17:29:48 +02:00
dd713732c6 version 1.1 release 2023-05-17 17:09:05 +02:00
5 changed files with 26 additions and 9 deletions

View File

@ -18,6 +18,7 @@ import net.minestom.server.event.GlobalEventHandler;
import net.minestom.server.event.inventory.InventoryPreClickEvent;
import net.minestom.server.event.item.ItemDropEvent;
import net.minestom.server.event.player.*;
import net.minestom.server.extras.bungee.BungeeCordProxy;
import net.minestom.server.timer.TaskSchedule;
import java.time.Duration;
@ -31,6 +32,7 @@ public class Main {
System.setProperty("minestom.chunk-view-distance", "16");
MinecraftServer minecraftServer = MinecraftServer.init();
MinecraftServer.getConnectionManager().setPlayerProvider(MuseumPlayer::new);
MinecraftServer.setBrandName("mhsl.eu:worldmuseum_by_olischma");
//update Taskbar
MinecraftServer.getSchedulerManager().scheduleTask(new TablistUpdateTask(), TaskSchedule.tick(20), TaskSchedule.tick(20));
@ -44,6 +46,11 @@ public class Main {
Config config = Config.getInstance();
config.loadConfig();
World startworld = config.getStart_world();
if (config.isBungeecordEnabled()) {
BungeeCordProxy.enable();
System.out.println("[Info] Bungeecord enabled");
}
// Add an event callback to specify the spawning instance (and the spawn position)
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
@ -72,15 +79,17 @@ public class Main {
globalEventHandler.addListener(PlayerLoginEvent.class, event -> {
final MuseumPlayer player = (MuseumPlayer) event.getPlayer();
player.setSyncCooldown(Duration.ofSeconds(3));
SkinCache.setSkin(player);
event.setSpawningInstance(startworld);
player.setPermissionLevel(4);
player.setRespawnPoint(startworld.getSpawn());
player.setGameMode(GameMode.SURVIVAL);
MinecraftServer.getSchedulerManager().scheduleNextTick(() -> {
SkinCache.setSkin(player);
player.setAllowFlying(true);
player.getInventory().setItemStack(0, ItemManager.getCompassItem());
player.getInventory().setItemStack(8, ItemManager.getBedItem());
});
System.out.println("[Join] Player " + player.getUsername() +" joined the server.");
});
@ -90,7 +99,7 @@ public class Main {
if (args.length != 0) System.out.println("Given port doesn't work.");
}
// Start the server on port default port 25565 if none is given
System.out.println("Running on " + IP + ":" + PORT);
System.out.println("[Info] Running on " + IP + ":" + PORT);
minecraftServer.start(IP, PORT);
}
}

View File

@ -1,3 +1,4 @@
{
"start_world": "world"
"start_world": "world",
"bungeecord": false
}

View File

@ -6,6 +6,6 @@ import java.util.function.Consumer;
public class DisconnectListener implements Consumer<PlayerDisconnectEvent> {
@Override
public void accept(PlayerDisconnectEvent playerDisconnectEvent) {
System.out.println("[Join] Player " + playerDisconnectEvent.getPlayer().getUsername() +" left the server.");
System.out.println("[Disconnect] Player " + playerDisconnectEvent.getPlayer().getUsername() +" left the server.");
}
}

View File

@ -12,6 +12,7 @@ import java.io.IOException;
public class Config {
private static Config instance;
private World start_world;
private boolean bungeecordEnabled = false;
public static Config getInstance() {
if (instance == null) instance = new Config();
return instance;
@ -28,6 +29,7 @@ public class Config {
System.out.println("no starting world set");
System.exit(0);
}
this.bungeecordEnabled = config.get("bungeecord").getAsBoolean();
}catch (IOException e) {
e.printStackTrace();
@ -41,7 +43,8 @@ public class Config {
FileWriter fileWriter = new FileWriter("config.json");
String default_config = """
{
"start_world": "world"
"start_world": "world",
"bungeecord": false
}""";
fileWriter.write(default_config);
fileWriter.close();
@ -54,4 +57,8 @@ public class Config {
public World getStart_world() {
return start_world;
}
public boolean isBungeecordEnabled() {
return bungeecordEnabled;
}
}

View File

@ -15,7 +15,7 @@ import java.io.*;
import java.util.UUID;
public class World extends InstanceContainer {
private final static DimensionType dimension = DimensionType.builder(NamespaceID.from("mhsl:worldview_by_olischma")).height(400).ambientLight(2.0f).build();
private final static DimensionType dimension = DimensionType.builder(NamespaceID.from("mhsl.eu:worldview_by_olischma")).height(400).ambientLight(2.0f).build();
private final ItemStack item;
private String name = "default";
private Pos spawn = new Pos(0,0,0);