2020-04-24 03:25:58 +02:00
|
|
|
package net.minestom.server;
|
2019-08-03 15:25:24 +02:00
|
|
|
|
2020-06-22 00:04:19 +02:00
|
|
|
import com.mojang.authlib.AuthenticationService;
|
|
|
|
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
|
|
|
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
|
|
|
import lombok.Getter;
|
|
|
|
import lombok.Setter;
|
2020-08-05 10:56:16 +02:00
|
|
|
import net.minestom.server.advancements.AdvancementManager;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.benchmark.BenchmarkManager;
|
|
|
|
import net.minestom.server.command.CommandManager;
|
|
|
|
import net.minestom.server.data.DataManager;
|
2020-08-15 13:32:36 +02:00
|
|
|
import net.minestom.server.data.DataType;
|
|
|
|
import net.minestom.server.data.SerializableData;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.entity.EntityManager;
|
2020-07-06 23:20:20 +02:00
|
|
|
import net.minestom.server.entity.EntityType;
|
2020-06-22 00:04:19 +02:00
|
|
|
import net.minestom.server.extras.mojangAuth.MojangCrypt;
|
2020-07-06 23:20:20 +02:00
|
|
|
import net.minestom.server.fluids.Fluid;
|
2020-05-18 21:11:59 +02:00
|
|
|
import net.minestom.server.gamedata.loottables.LootTableManager;
|
2020-06-23 18:17:02 +02:00
|
|
|
import net.minestom.server.gamedata.tags.TagManager;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.instance.InstanceManager;
|
2020-07-06 23:20:20 +02:00
|
|
|
import net.minestom.server.instance.block.Block;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.instance.block.BlockManager;
|
2020-08-15 13:32:36 +02:00
|
|
|
import net.minestom.server.instance.block.CustomBlock;
|
|
|
|
import net.minestom.server.instance.block.rule.BlockPlacementRule;
|
2020-07-06 23:20:20 +02:00
|
|
|
import net.minestom.server.item.Enchantment;
|
|
|
|
import net.minestom.server.item.Material;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.listener.manager.PacketListenerManager;
|
|
|
|
import net.minestom.server.network.ConnectionManager;
|
|
|
|
import net.minestom.server.network.PacketProcessor;
|
2020-07-02 15:56:43 +02:00
|
|
|
import net.minestom.server.network.PacketWriterUtils;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.network.netty.NettyServer;
|
2020-07-02 15:56:43 +02:00
|
|
|
import net.minestom.server.network.packet.server.play.PluginMessagePacket;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.network.packet.server.play.ServerDifficultyPacket;
|
2020-07-06 23:20:20 +02:00
|
|
|
import net.minestom.server.particle.Particle;
|
2020-04-28 02:33:15 +02:00
|
|
|
import net.minestom.server.ping.ResponseDataConsumer;
|
2020-08-10 23:30:56 +02:00
|
|
|
import net.minestom.server.plugins.PluginManager;
|
2020-07-06 23:20:20 +02:00
|
|
|
import net.minestom.server.potion.PotionType;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.recipe.RecipeManager;
|
2020-05-01 21:29:34 +02:00
|
|
|
import net.minestom.server.registry.ResourceGatherer;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.scoreboard.TeamManager;
|
2020-07-06 23:20:20 +02:00
|
|
|
import net.minestom.server.sound.Sound;
|
|
|
|
import net.minestom.server.stat.StatisticType;
|
2020-05-10 16:02:49 +02:00
|
|
|
import net.minestom.server.storage.StorageFolder;
|
2020-05-04 18:15:29 +02:00
|
|
|
import net.minestom.server.storage.StorageManager;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.timer.SchedulerManager;
|
2020-07-01 21:03:53 +02:00
|
|
|
import net.minestom.server.utils.thread.MinestomThread;
|
2020-07-02 15:56:43 +02:00
|
|
|
import net.minestom.server.utils.validate.Check;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.world.Difficulty;
|
2020-07-13 14:12:21 +02:00
|
|
|
import net.minestom.server.world.DimensionTypeManager;
|
2020-08-12 19:08:04 +02:00
|
|
|
import net.minestom.server.world.biomes.BiomeManager;
|
2020-05-10 16:02:49 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2019-08-03 15:25:24 +02:00
|
|
|
|
2020-05-01 21:29:34 +02:00
|
|
|
import java.io.IOException;
|
2020-06-22 00:04:19 +02:00
|
|
|
import java.net.Proxy;
|
|
|
|
import java.security.KeyPair;
|
2020-05-01 21:29:34 +02:00
|
|
|
|
2020-02-17 17:33:53 +01:00
|
|
|
public class MinecraftServer {
|
2020-06-22 00:04:19 +02:00
|
|
|
@Getter
|
2020-05-10 16:02:49 +02:00
|
|
|
private final static Logger LOGGER = LoggerFactory.getLogger(MinecraftServer.class);
|
2019-08-03 15:25:24 +02:00
|
|
|
|
2020-08-12 19:08:04 +02:00
|
|
|
public static final int PROTOCOL_VERSION = 751;
|
2020-05-10 19:39:25 +02:00
|
|
|
|
2020-04-13 17:17:21 +02:00
|
|
|
// Threads
|
|
|
|
public static final String THREAD_NAME_BENCHMARK = "Ms-Benchmark";
|
|
|
|
|
2020-04-17 01:16:02 +02:00
|
|
|
public static final String THREAD_NAME_MAIN_UPDATE = "Ms-MainUpdate";
|
|
|
|
|
2020-07-03 16:44:21 +02:00
|
|
|
public static final String THREAD_NAME_TICK = "Ms-Tick";
|
|
|
|
|
2020-04-13 17:17:21 +02:00
|
|
|
public static final String THREAD_NAME_PACKET_WRITER = "Ms-PacketWriterPool";
|
2019-09-02 06:02:12 +02:00
|
|
|
public static final int THREAD_COUNT_PACKET_WRITER = 2;
|
2020-04-13 17:17:21 +02:00
|
|
|
|
|
|
|
public static final String THREAD_NAME_BLOCK_BATCH = "Ms-BlockBatchPool";
|
2019-09-07 11:42:33 +02:00
|
|
|
public static final int THREAD_COUNT_BLOCK_BATCH = 2;
|
2020-04-13 17:17:21 +02:00
|
|
|
|
|
|
|
public static final String THREAD_NAME_SCHEDULER = "Ms-SchedulerPool";
|
|
|
|
public static final int THREAD_COUNT_SCHEDULER = 1;
|
|
|
|
|
2020-07-07 13:55:43 +02:00
|
|
|
public static final String THREAD_NAME_PARALLEL_CHUNK_SAVING = "Ms-ParallelChunkSaving";
|
|
|
|
public static final int THREAD_COUNT_PARALLEL_CHUNK_SAVING = 4;
|
|
|
|
|
2020-02-17 17:33:53 +01:00
|
|
|
// Config
|
2020-08-13 03:08:03 +02:00
|
|
|
public static final int CHUNK_VIEW_DISTANCE = 10;
|
2020-04-17 01:16:02 +02:00
|
|
|
public static final int ENTITY_VIEW_DISTANCE = 5;
|
2020-06-28 22:07:48 +02:00
|
|
|
public static final int COMPRESSION_THRESHOLD = 256;
|
2020-08-15 13:32:36 +02:00
|
|
|
// Can be modified at performance cost when increased
|
|
|
|
public static final int TICK_PER_SECOND = 20;
|
2020-02-09 15:34:09 +01:00
|
|
|
private static final int MS_TO_SEC = 1000;
|
2020-08-15 13:32:36 +02:00
|
|
|
public static final int TICK_MS = MS_TO_SEC / TICK_PER_SECOND;
|
2020-03-29 20:58:30 +02:00
|
|
|
|
2020-08-13 03:08:03 +02:00
|
|
|
@Getter @Setter
|
|
|
|
private static boolean hardcoreLook = false;
|
|
|
|
|
2020-06-22 00:04:19 +02:00
|
|
|
//Extras
|
|
|
|
@Getter
|
|
|
|
@Setter
|
|
|
|
private static boolean fixLighting = true;
|
|
|
|
|
2020-08-13 19:52:59 +02:00
|
|
|
//Rate Limiting
|
|
|
|
private static int rateLimit = 0;
|
|
|
|
|
2019-08-11 00:36:20 +02:00
|
|
|
// Networking
|
2019-08-03 15:25:24 +02:00
|
|
|
private static PacketProcessor packetProcessor;
|
2019-08-20 17:41:07 +02:00
|
|
|
private static PacketListenerManager packetListenerManager;
|
2020-04-17 01:16:02 +02:00
|
|
|
private static NettyServer nettyServer;
|
2019-08-03 15:25:24 +02:00
|
|
|
|
2019-08-11 00:36:20 +02:00
|
|
|
// In-Game Manager
|
2020-04-15 16:35:25 +02:00
|
|
|
private static ConnectionManager connectionManager;
|
2019-08-11 07:42:56 +02:00
|
|
|
private static InstanceManager instanceManager;
|
2019-08-18 23:52:11 +02:00
|
|
|
private static BlockManager blockManager;
|
2019-08-11 00:36:20 +02:00
|
|
|
private static EntityManager entityManager;
|
2020-04-01 13:16:18 +02:00
|
|
|
private static CommandManager commandManager;
|
|
|
|
private static RecipeManager recipeManager;
|
2020-05-04 18:15:29 +02:00
|
|
|
private static StorageManager storageManager;
|
2019-09-01 06:18:41 +02:00
|
|
|
private static DataManager dataManager;
|
2019-09-21 20:42:27 +02:00
|
|
|
private static TeamManager teamManager;
|
2019-09-23 19:56:08 +02:00
|
|
|
private static SchedulerManager schedulerManager;
|
2020-04-13 17:17:21 +02:00
|
|
|
private static BenchmarkManager benchmarkManager;
|
2020-07-13 14:12:21 +02:00
|
|
|
private static DimensionTypeManager dimensionTypeManager;
|
2020-08-12 19:08:04 +02:00
|
|
|
private static BiomeManager biomeManager;
|
2020-08-05 10:56:16 +02:00
|
|
|
private static AdvancementManager advancementManager;
|
2019-08-03 15:25:24 +02:00
|
|
|
|
2020-08-10 23:30:56 +02:00
|
|
|
private static PluginManager pluginManager;
|
|
|
|
|
2020-04-17 01:16:02 +02:00
|
|
|
private static UpdateManager updateManager;
|
2020-02-17 17:33:53 +01:00
|
|
|
private static MinecraftServer minecraftServer;
|
|
|
|
|
2020-04-15 16:35:25 +02:00
|
|
|
// Data
|
2020-04-28 02:33:15 +02:00
|
|
|
private static ResponseDataConsumer responseDataConsumer;
|
2020-07-02 15:56:43 +02:00
|
|
|
private static String brandName = "Minestom";
|
2020-04-15 16:35:25 +02:00
|
|
|
private static Difficulty difficulty = Difficulty.NORMAL;
|
2020-05-18 21:11:59 +02:00
|
|
|
private static LootTableManager lootTableManager;
|
2020-06-23 18:17:02 +02:00
|
|
|
private static TagManager tagManager;
|
2020-04-15 16:35:25 +02:00
|
|
|
|
2020-06-22 00:04:19 +02:00
|
|
|
//Mojang Auth
|
|
|
|
@Getter
|
|
|
|
private static KeyPair keyPair = MojangCrypt.generateKeyPair();
|
|
|
|
@Getter
|
|
|
|
private static AuthenticationService authService = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
|
|
|
|
@Getter
|
|
|
|
private static MinecraftSessionService sessionService = authService.createMinecraftSessionService();
|
|
|
|
|
2020-02-17 17:33:53 +01:00
|
|
|
public static MinecraftServer init() {
|
2020-08-12 07:46:07 +02:00
|
|
|
if (minecraftServer != null) // don't init twice
|
2020-08-10 14:50:39 +02:00
|
|
|
return minecraftServer;
|
2020-07-06 23:20:20 +02:00
|
|
|
// warmup/force-init registries
|
|
|
|
// without this line, registry types that are not loaded explicitly will have an internal empty registry in Registries
|
|
|
|
// That can happen with PotionType for instance, if no code tries to access a PotionType field
|
|
|
|
// TODO: automate (probably with code generation)
|
|
|
|
Block.values();
|
|
|
|
Material.values();
|
|
|
|
PotionType.values();
|
|
|
|
Enchantment.values();
|
|
|
|
EntityType.values();
|
|
|
|
Sound.values();
|
|
|
|
Particle.values();
|
|
|
|
StatisticType.values();
|
|
|
|
Fluid.values();
|
|
|
|
|
2019-08-03 15:25:24 +02:00
|
|
|
connectionManager = new ConnectionManager();
|
2019-08-11 00:36:20 +02:00
|
|
|
packetProcessor = new PacketProcessor();
|
2019-08-20 17:41:07 +02:00
|
|
|
packetListenerManager = new PacketListenerManager();
|
2019-08-11 00:36:20 +02:00
|
|
|
|
2019-08-11 07:42:56 +02:00
|
|
|
instanceManager = new InstanceManager();
|
2019-08-18 23:52:11 +02:00
|
|
|
blockManager = new BlockManager();
|
2019-08-11 00:36:20 +02:00
|
|
|
entityManager = new EntityManager();
|
2020-04-01 13:16:18 +02:00
|
|
|
commandManager = new CommandManager();
|
|
|
|
recipeManager = new RecipeManager();
|
2020-05-04 18:15:29 +02:00
|
|
|
storageManager = new StorageManager();
|
2019-09-01 06:18:41 +02:00
|
|
|
dataManager = new DataManager();
|
2019-09-21 20:42:27 +02:00
|
|
|
teamManager = new TeamManager();
|
2019-09-23 19:56:08 +02:00
|
|
|
schedulerManager = new SchedulerManager();
|
2020-04-13 17:17:21 +02:00
|
|
|
benchmarkManager = new BenchmarkManager();
|
2020-07-13 14:12:21 +02:00
|
|
|
dimensionTypeManager = new DimensionTypeManager();
|
2020-08-12 19:08:04 +02:00
|
|
|
biomeManager = new BiomeManager();
|
2020-08-05 10:56:16 +02:00
|
|
|
advancementManager = new AdvancementManager();
|
2019-08-03 15:25:24 +02:00
|
|
|
|
2020-04-17 01:16:02 +02:00
|
|
|
updateManager = new UpdateManager();
|
|
|
|
|
2020-08-10 23:30:56 +02:00
|
|
|
pluginManager = PluginManager.getInstance();
|
|
|
|
|
2020-05-18 21:11:59 +02:00
|
|
|
lootTableManager = new LootTableManager();
|
2020-06-23 18:17:02 +02:00
|
|
|
tagManager = new TagManager();
|
2020-05-18 21:11:59 +02:00
|
|
|
|
2020-04-17 01:16:02 +02:00
|
|
|
nettyServer = new NettyServer(packetProcessor);
|
2019-09-02 06:02:12 +02:00
|
|
|
|
2020-04-10 10:31:49 +02:00
|
|
|
// Registry
|
2020-05-01 21:29:34 +02:00
|
|
|
try {
|
2020-08-13 03:08:03 +02:00
|
|
|
ResourceGatherer.ensureResourcesArePresent("1.16.2", null); // TODO: provide a way to give a path override, probably via launch arguments?
|
2020-05-01 21:29:34 +02:00
|
|
|
} catch (IOException e) {
|
2020-05-10 16:02:49 +02:00
|
|
|
LOGGER.error("An error happened during resource gathering. Minestom will attempt to load anyway, but things may not work, and crashes can happen.", e);
|
2020-05-01 21:29:34 +02:00
|
|
|
}
|
2020-04-10 10:31:49 +02:00
|
|
|
|
2020-02-17 17:33:53 +01:00
|
|
|
minecraftServer = new MinecraftServer();
|
|
|
|
|
|
|
|
return minecraftServer;
|
|
|
|
}
|
|
|
|
|
2020-07-02 15:56:43 +02:00
|
|
|
/**
|
|
|
|
* Get the current server brand name
|
|
|
|
*
|
|
|
|
* @return the server brand name
|
|
|
|
*/
|
|
|
|
public static String getBrandName() {
|
|
|
|
return brandName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the server brand name, update the name to all connected players
|
|
|
|
*
|
2020-08-07 09:14:50 +02:00
|
|
|
* @param brandName the server brand name
|
2020-07-02 15:56:43 +02:00
|
|
|
*/
|
|
|
|
public static void setBrandName(String brandName) {
|
|
|
|
Check.notNull(brandName, "The brand name cannot be null");
|
|
|
|
MinecraftServer.brandName = brandName;
|
|
|
|
|
|
|
|
PluginMessagePacket brandMessage = PluginMessagePacket.getBrandPacket();
|
|
|
|
PacketWriterUtils.writeAndSend(connectionManager.getOnlinePlayers(), brandMessage);
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the max number of packets a client can send over 1 second
|
|
|
|
*
|
|
|
|
* @return the packet count limit over 1 second
|
|
|
|
*/
|
|
|
|
public static int getRateLimit() {
|
|
|
|
return rateLimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Change the number of packet a client can send over 1 second without being disconnected
|
|
|
|
*
|
|
|
|
* @param rateLimit the number of packet, 0 to disable
|
|
|
|
*/
|
|
|
|
public static void setRateLimit(int rateLimit) {
|
|
|
|
MinecraftServer.rateLimit = rateLimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the server difficulty showed in game option
|
|
|
|
*
|
|
|
|
* @return the server difficulty
|
|
|
|
*/
|
2020-04-15 16:35:25 +02:00
|
|
|
public static Difficulty getDifficulty() {
|
|
|
|
return difficulty;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Change the server difficulty and send the appropriate packet to all connected clients
|
|
|
|
*
|
|
|
|
* @param difficulty the new server difficulty
|
|
|
|
*/
|
2020-04-15 16:35:25 +02:00
|
|
|
public static void setDifficulty(Difficulty difficulty) {
|
|
|
|
MinecraftServer.difficulty = difficulty;
|
2020-08-15 13:32:36 +02:00
|
|
|
|
|
|
|
// The difficulty packet
|
|
|
|
ServerDifficultyPacket serverDifficultyPacket = new ServerDifficultyPacket();
|
|
|
|
serverDifficultyPacket.difficulty = difficulty;
|
|
|
|
serverDifficultyPacket.locked = true; // Can only be modified on singleplayer
|
|
|
|
// Send the packet to all online players
|
|
|
|
PacketWriterUtils.writeAndSend(connectionManager.getOnlinePlayers(), serverDifficultyPacket);
|
2020-04-15 16:35:25 +02:00
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling all incoming packets
|
|
|
|
*
|
|
|
|
* @return the packet listener manager
|
|
|
|
*/
|
2020-02-17 17:33:53 +01:00
|
|
|
public static PacketListenerManager getPacketListenerManager() {
|
|
|
|
return packetListenerManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the netty server
|
|
|
|
*
|
|
|
|
* @return the netty server
|
|
|
|
*/
|
2020-04-17 01:16:02 +02:00
|
|
|
public static NettyServer getNettyServer() {
|
|
|
|
return nettyServer;
|
2020-02-17 17:33:53 +01:00
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling all registered instances
|
|
|
|
*
|
|
|
|
* @return the instance manager
|
|
|
|
*/
|
2020-02-17 17:33:53 +01:00
|
|
|
public static InstanceManager getInstanceManager() {
|
|
|
|
return instanceManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling {@link CustomBlock} and {@link BlockPlacementRule}
|
|
|
|
*
|
|
|
|
* @return the block manager
|
|
|
|
*/
|
2020-02-17 17:33:53 +01:00
|
|
|
public static BlockManager getBlockManager() {
|
|
|
|
return blockManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling waiting players
|
|
|
|
*
|
|
|
|
* @return the entity manager
|
|
|
|
*/
|
2020-02-17 17:33:53 +01:00
|
|
|
public static EntityManager getEntityManager() {
|
|
|
|
return entityManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling commands
|
|
|
|
*
|
|
|
|
* @return the command manager
|
|
|
|
*/
|
2020-04-01 13:16:18 +02:00
|
|
|
public static CommandManager getCommandManager() {
|
|
|
|
return commandManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling recipes show to the clients
|
|
|
|
*
|
|
|
|
* @return the recipe manager
|
|
|
|
*/
|
2020-04-01 13:16:18 +02:00
|
|
|
public static RecipeManager getRecipeManager() {
|
|
|
|
return recipeManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling storage
|
|
|
|
*
|
|
|
|
* @return the storage manager
|
|
|
|
*/
|
2020-05-04 18:15:29 +02:00
|
|
|
public static StorageManager getStorageManager() {
|
|
|
|
return storageManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling {@link DataType} used by {@link SerializableData}
|
|
|
|
*
|
|
|
|
* @return the data manager
|
|
|
|
*/
|
2020-02-17 17:33:53 +01:00
|
|
|
public static DataManager getDataManager() {
|
|
|
|
return dataManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling teams
|
|
|
|
*
|
|
|
|
* @return the team manager
|
|
|
|
*/
|
2020-02-17 17:33:53 +01:00
|
|
|
public static TeamManager getTeamManager() {
|
|
|
|
return teamManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling scheduled tasks
|
|
|
|
*
|
|
|
|
* @return the scheduler manager
|
|
|
|
*/
|
2020-02-17 17:33:53 +01:00
|
|
|
public static SchedulerManager getSchedulerManager() {
|
|
|
|
return schedulerManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling server monitoring
|
|
|
|
*
|
|
|
|
* @return the benchmark manager
|
|
|
|
*/
|
2020-04-13 17:17:21 +02:00
|
|
|
public static BenchmarkManager getBenchmarkManager() {
|
|
|
|
return benchmarkManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling server connections
|
|
|
|
*
|
|
|
|
* @return the connection manager
|
|
|
|
*/
|
2020-02-17 17:33:53 +01:00
|
|
|
public static ConnectionManager getConnectionManager() {
|
|
|
|
return connectionManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the consumer executed to show server-list data
|
|
|
|
*
|
|
|
|
* @return the response data consumer
|
|
|
|
*/
|
2020-04-28 02:33:15 +02:00
|
|
|
public static ResponseDataConsumer getResponseDataConsumer() {
|
|
|
|
return responseDataConsumer;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling loot tables
|
|
|
|
*
|
|
|
|
* @return the loot table manager
|
|
|
|
*/
|
2020-05-18 21:11:59 +02:00
|
|
|
public static LootTableManager getLootTableManager() {
|
|
|
|
return lootTableManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling dimensions
|
|
|
|
*
|
|
|
|
* @return the dimension manager
|
|
|
|
*/
|
2020-07-13 14:12:21 +02:00
|
|
|
public static DimensionTypeManager getDimensionTypeManager() {
|
|
|
|
return dimensionTypeManager;
|
|
|
|
}
|
|
|
|
|
2020-08-12 19:08:04 +02:00
|
|
|
public static BiomeManager getBiomeManager() {
|
|
|
|
return biomeManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling advancements
|
|
|
|
*
|
|
|
|
* @return the advancement manager
|
|
|
|
*/
|
2020-08-05 10:56:16 +02:00
|
|
|
public static AdvancementManager getAdvancementManager() {
|
|
|
|
return advancementManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling tags
|
|
|
|
*
|
|
|
|
* @return the tag manager
|
|
|
|
*/
|
2020-06-23 18:17:02 +02:00
|
|
|
public static TagManager getTagManager() {
|
|
|
|
return tagManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the manager handling the server ticks
|
|
|
|
*
|
|
|
|
* @return the update manager
|
|
|
|
*/
|
2020-08-06 16:28:04 +02:00
|
|
|
public static UpdateManager getUpdateManager() {
|
|
|
|
return updateManager;
|
|
|
|
}
|
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Start the server
|
|
|
|
*
|
|
|
|
* @param address the server address
|
|
|
|
* @param port the server port
|
|
|
|
* @param responseDataConsumer the response data consumer, can be null
|
|
|
|
*/
|
2020-04-28 02:33:15 +02:00
|
|
|
public void start(String address, int port, ResponseDataConsumer responseDataConsumer) {
|
2020-05-10 16:02:49 +02:00
|
|
|
LOGGER.info("Starting Minestom server.");
|
2020-04-28 02:33:15 +02:00
|
|
|
MinecraftServer.responseDataConsumer = responseDataConsumer;
|
2020-04-17 01:16:02 +02:00
|
|
|
updateManager.start();
|
|
|
|
nettyServer.start(address, port);
|
2020-08-10 23:30:56 +02:00
|
|
|
long t1 = -System.nanoTime();
|
|
|
|
pluginManager.loadPlugins();
|
|
|
|
LOGGER.info("Plugins loaded in " + (t1+System.nanoTime())/1_000_000D + "ms");
|
2020-05-10 16:02:49 +02:00
|
|
|
LOGGER.info("Minestom server started successfully.");
|
2019-08-10 04:47:19 +02:00
|
|
|
}
|
2019-08-10 08:44:35 +02:00
|
|
|
|
2020-08-15 13:32:36 +02:00
|
|
|
/**
|
|
|
|
* Start the server
|
|
|
|
*
|
|
|
|
* @param address the server address
|
|
|
|
* @param port the server port
|
|
|
|
*/
|
2020-05-10 19:39:25 +02:00
|
|
|
public void start(String address, int port) {
|
|
|
|
start(address, port, null);
|
|
|
|
}
|
|
|
|
|
2020-04-28 19:22:54 +02:00
|
|
|
/**
|
|
|
|
* Stops this server properly (saves if needed, kicking players, etc.)
|
|
|
|
*/
|
|
|
|
public static void stopCleanly() {
|
2020-05-10 16:02:49 +02:00
|
|
|
LOGGER.info("Stopping Minestom server.");
|
2020-04-28 19:22:54 +02:00
|
|
|
updateManager.stop();
|
|
|
|
nettyServer.stop();
|
|
|
|
schedulerManager.shutdown();
|
2020-05-10 16:02:49 +02:00
|
|
|
storageManager.getLoadedFolders().forEach(StorageFolder::close);
|
2020-07-01 21:03:53 +02:00
|
|
|
LOGGER.info("Shutting down all thread pools.");
|
|
|
|
benchmarkManager.disable();
|
|
|
|
commandManager.stopConsoleThread();
|
2020-07-01 22:17:35 +02:00
|
|
|
MinestomThread.shutdownAll();
|
2020-05-10 16:02:49 +02:00
|
|
|
LOGGER.info("Minestom server stopped successfully.");
|
2020-04-28 19:22:54 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 15:25:24 +02:00
|
|
|
}
|