Minestom/src/test/java/demo/Main.java

78 lines
3.1 KiB
Java
Raw Normal View History

package demo;
2020-02-17 17:33:53 +01:00
import demo.blocks.BurningTorchBlock;
import demo.blocks.StoneBlock;
import demo.blocks.UpdatableBlockDemo;
2020-11-12 03:09:36 +01:00
import demo.commands.*;
2020-11-20 18:16:45 +01:00
import io.netty.handler.traffic.GlobalChannelTrafficShapingHandler;
2020-04-24 03:25:58 +02:00
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandManager;
2020-11-14 04:09:38 +01:00
import net.minestom.server.extras.optifine.OptifineSupport;
2020-04-24 03:25:58 +02:00
import net.minestom.server.instance.block.BlockManager;
import net.minestom.server.instance.block.rule.vanilla.RedstonePlacementRule;
2020-11-18 19:39:06 +01:00
import net.minestom.server.network.netty.NettyServer;
import net.minestom.server.storage.StorageManager;
import net.minestom.server.storage.systems.FileStorageSystem;
2020-04-24 03:25:58 +02:00
import net.minestom.server.utils.time.TimeUnit;
import net.minestom.server.utils.time.UpdateOption;
2020-04-01 13:16:18 +02:00
2020-02-17 17:33:53 +01:00
public class Main {
public static void main(String[] args) {
2020-11-19 02:28:56 +01:00
//System.setProperty("io.netty.leakDetection.targetRecords", "10");
//ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
2020-11-18 19:39:06 +01:00
2020-02-17 17:33:53 +01:00
MinecraftServer minecraftServer = MinecraftServer.init();
2020-11-19 02:28:56 +01:00
MinecraftServer.setShouldProcessNettyErrors(false);
2020-11-18 19:39:06 +01:00
final NettyServer nettyServer = MinecraftServer.getNettyServer();
2020-11-20 18:16:45 +01:00
final GlobalChannelTrafficShapingHandler trafficHandler = nettyServer.getGlobalTrafficHandler();
trafficHandler.setReadChannelLimit(500_000);
2020-11-21 23:08:56 +01:00
trafficHandler.setReadLimit(500_000);
2020-11-18 19:39:06 +01:00
2020-02-17 17:33:53 +01:00
BlockManager blockManager = MinecraftServer.getBlockManager();
2020-04-01 13:16:18 +02:00
blockManager.registerCustomBlock(new StoneBlock());
blockManager.registerCustomBlock(new UpdatableBlockDemo());
blockManager.registerCustomBlock(new BurningTorchBlock());
2020-04-01 13:16:18 +02:00
2020-04-12 10:24:25 +02:00
blockManager.registerBlockPlacementRule(new RedstonePlacementRule());
2020-04-01 13:16:18 +02:00
CommandManager commandManager = MinecraftServer.getCommandManager();
commandManager.register(new TestCommand());
2020-11-09 23:48:34 +01:00
commandManager.register(new GamemodeCommand());
2020-11-12 03:09:36 +01:00
commandManager.register(new EntitySelectorCommand());
commandManager.register(new HealthCommand());
2020-07-24 01:03:24 +02:00
commandManager.register(new SimpleCommand());
commandManager.register(new DimensionCommand());
commandManager.register(new ShutdownCommand());
2020-11-12 03:09:36 +01:00
commandManager.register(new TeleportCommand());
2020-11-18 19:39:06 +01:00
commandManager.register(new PlayersCommand());
2020-04-01 13:16:18 +02:00
2020-11-02 04:13:43 +01:00
commandManager.setUnknownCommandCallback((sender, command) -> sender.sendMessage("unknown command"));
2020-08-21 01:32:59 +02:00
StorageManager storageManager = MinecraftServer.getStorageManager();
storageManager.defineDefaultStorageSystem(FileStorageSystem::new);
2020-04-17 21:34:01 +02:00
MinecraftServer.getBenchmarkManager().enable(new UpdateOption(10 * 1000, TimeUnit.MILLISECOND));
2020-02-17 17:33:53 +01:00
MinecraftServer.getSchedulerManager().buildShutdownTask(() -> System.out.println("Good night")).schedule();
2020-04-28 19:22:54 +02:00
2020-03-20 19:50:22 +01:00
PlayerInit.init();
2020-11-14 04:09:38 +01:00
OptifineSupport.enable();
2020-11-14 23:18:52 +01:00
//VelocityProxy.enable("rBeJJ79W4MVU");
//BungeeCordProxy.enable();
2020-11-09 23:48:34 +01:00
2020-11-16 17:02:40 +01:00
//MojangAuth.init();
2020-06-22 00:57:53 +02:00
2020-08-11 01:41:14 +02:00
minecraftServer.start("0.0.0.0", 25565, PlayerInit.getResponseDataConsumer());
2020-11-26 02:13:38 +01:00
Runtime.getRuntime().addShutdownHook(new Thread(MinecraftServer::stopCleanly));
2020-02-17 17:33:53 +01:00
}
}