Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Non-static API #125

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion build.gradle.kts
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests will be fixed and enabled after other changes are approved

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
`maven-publish`
signing
alias(libs.plugins.nexuspublish)
id("io.freefair.lombok") version "8.4"
}

// Read env vars (used for publishing generally)
Expand Down Expand Up @@ -45,8 +46,11 @@ allprojects {
}

tasks.withType<Test> {
enabled = false
useJUnitPlatform()

maxHeapSize = "2048m"

// Viewable packets make tracking harder. Could be re-enabled later.
jvmArgs("-Dminestom.viewable-packet=false")
jvmArgs("-Dminestom.inside-test=true")
Expand Down Expand Up @@ -83,7 +87,7 @@ dependencies {

// Testing
testImplementation(libs.bundles.junit)
testImplementation(project(":testing"))
// testImplementation(project(":testing"))
}

tasks {
Expand Down
56 changes: 29 additions & 27 deletions demo/src/main/java/net/minestom/demo/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import net.minestom.demo.block.TestBlockHandler;
import net.minestom.demo.block.placement.DripstonePlacementRule;
import net.minestom.demo.commands.*;
import net.minestom.server.MinecraftServer;
import net.minestom.server.ServerFacade;
import net.minestom.server.ServerSettings;
import net.minestom.server.command.CommandManager;
import net.minestom.server.entity.Player;
import net.minestom.server.event.server.ServerListPingEvent;
Expand All @@ -33,52 +34,53 @@ public class Main {
public static void main(String[] args) {
System.setProperty("minestom.experiment.pose-updates", "true");

MinecraftServer.setCompressionThreshold(0);
ServerSettings serverSettings = ServerSettings.builder().compressionThreshold(0).build();

MinecraftServer minecraftServer = MinecraftServer.init();
ServerFacade serverFacade = ServerFacade.of(serverSettings);
MelonHell marked this conversation as resolved.
Show resolved Hide resolved

BlockManager blockManager = MinecraftServer.getBlockManager();

BlockManager blockManager = serverFacade.getBlockManager();
blockManager.registerBlockPlacementRule(new DripstonePlacementRule());
blockManager.registerHandler(TestBlockHandler.INSTANCE.getNamespaceId(), () -> TestBlockHandler.INSTANCE);

CommandManager commandManager = MinecraftServer.getCommandManager();
CommandManager commandManager = serverFacade.getCommandManager();
commandManager.register(new TestCommand());
commandManager.register(new EntitySelectorCommand());
commandManager.register(new EntitySelectorCommand(serverFacade));
commandManager.register(new HealthCommand());
commandManager.register(new LegacyCommand());
commandManager.register(new DimensionCommand());
commandManager.register(new ShutdownCommand());
commandManager.register(new TeleportCommand());
commandManager.register(new PlayersCommand());
commandManager.register(new DimensionCommand(serverFacade));
commandManager.register(new ShutdownCommand(serverFacade));
commandManager.register(new TeleportCommand(serverFacade));
commandManager.register(new PlayersCommand(serverFacade));
commandManager.register(new FindCommand());
commandManager.register(new TitleCommand());
commandManager.register(new BookCommand());
commandManager.register(new ShootCommand());
commandManager.register(new HorseCommand());
commandManager.register(new HorseCommand(serverFacade));
commandManager.register(new EchoCommand());
commandManager.register(new SummonCommand());
commandManager.register(new RemoveCommand());
commandManager.register(new GiveCommand());
commandManager.register(new SummonCommand(serverFacade));
commandManager.register(new RemoveCommand(serverFacade));
commandManager.register(new GiveCommand(serverFacade));
commandManager.register(new SetBlockCommand());
commandManager.register(new AutoViewCommand());
commandManager.register(new SaveCommand());
commandManager.register(new GamemodeCommand());
commandManager.register(new ExecuteCommand());
commandManager.register(new AutoViewCommand(serverFacade));
commandManager.register(new SaveCommand(serverFacade));
commandManager.register(new GamemodeCommand(serverFacade));
commandManager.register(new ExecuteCommand(serverFacade));
commandManager.register(new RedirectTestCommand());
commandManager.register(new DisplayCommand());
commandManager.register(new DisplayCommand(serverFacade));
commandManager.register(new NotificationCommand());
commandManager.register(new TestCommand2());
commandManager.register(new ConfigCommand());
commandManager.register(new SidebarCommand());
commandManager.register(new SidebarCommand(serverFacade));
commandManager.register(new SetEntityType());

commandManager.setUnknownCommandCallback((sender, command) -> sender.sendMessage(Component.text("Unknown command", NamedTextColor.RED)));

MinecraftServer.getBenchmarkManager().enable(Duration.of(10, TimeUnit.SECOND));
serverFacade.getBenchmarkManager().enable(Duration.of(10, TimeUnit.SECOND));

MinecraftServer.getSchedulerManager().buildShutdownTask(() -> System.out.println("Good night"));
serverFacade.getSchedulerManager().buildShutdownTask(() -> System.out.println("Good night"));

MinecraftServer.getGlobalEventHandler().addListener(ServerListPingEvent.class, event -> {
serverFacade.getGlobalEventHandler().addListener(ServerListPingEvent.class, event -> {
ResponseData responseData = event.getResponseData();
responseData.addEntry(NamedAndIdentified.named("The first line is separated from the others"));
responseData.addEntry(NamedAndIdentified.named("Could be a name, or a message"));
Expand Down Expand Up @@ -126,19 +128,19 @@ public boolean shouldShow(@NotNull Player player) {
return true;
}
};
MinecraftServer.getRecipeManager().addRecipe(ironBlockRecipe);
serverFacade.getRecipeManager().addRecipe(ironBlockRecipe);

PlayerInit.init();
new PlayerInit(serverFacade).init();

// VelocityProxy.enable("abcdef");
//BungeeCordProxy.enable();

//MojangAuth.init();

// useful for testing - we don't need to worry about event calls so just set this to a long time
OpenToLAN.open(new OpenToLANConfig().eventCallDelay(Duration.of(1, TimeUnit.DAY)));
new OpenToLAN(serverFacade.getConnectionManager(), serverFacade.getServer(), serverFacade.getSchedulerManager(), serverFacade.getGlobalEventHandler()).open(new OpenToLANConfig().eventCallDelay(Duration.of(1, TimeUnit.DAY)));

minecraftServer.start("0.0.0.0", 25565);
serverFacade.getServerStarter().start("0.0.0.0", 25565);
// minecraftServer.start(java.net.UnixDomainSocketAddress.of("minestom-demo.sock"));
//Runtime.getRuntime().addShutdownHook(new Thread(MinecraftServer::stopCleanly));
}
Expand Down
Loading
Loading