2020-10-11 16:02:26 +02:00
|
|
|
package demo;
|
2020-02-17 17:33:53 +01:00
|
|
|
|
2020-10-11 16:02:26 +02: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;
|
2020-05-04 18:15:29 +02:00
|
|
|
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());
|
2020-05-05 15:55:21 +02:00
|
|
|
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();
|
2020-07-14 13:35:07 +02:00
|
|
|
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());
|
2020-11-02 02:53:12 +01:00
|
|
|
commandManager.register(new HealthCommand());
|
2020-07-24 01:03:24 +02:00
|
|
|
commandManager.register(new SimpleCommand());
|
|
|
|
commandManager.register(new DimensionCommand());
|
2020-07-29 05:03:07 +02:00
|
|
|
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
|
|
|
|
2020-05-04 18:15:29 +02:00
|
|
|
StorageManager storageManager = MinecraftServer.getStorageManager();
|
2020-05-06 22:35:32 +02:00
|
|
|
storageManager.defineDefaultStorageSystem(FileStorageSystem::new);
|
2020-05-04 18:15:29 +02:00
|
|
|
|
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
|
|
|
|
2020-07-31 20:44:58 +02: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");
|
2020-11-15 08:03:33 +01:00
|
|
|
//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
|
|
|
}
|
|
|
|
|
|
|
|
}
|