mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-25 22:14:53 +02:00
Comments for MinecraftServer
This commit is contained in:
parent
c130fb6144
commit
19ab2cbd50
|
@ -57,6 +57,12 @@ import java.io.IOException;
|
|||
import java.net.Proxy;
|
||||
import java.security.KeyPair;
|
||||
|
||||
/**
|
||||
* The main server class used to start the server and retrieve all the managers.
|
||||
* <p>
|
||||
* The server needs to be initialized with {@link #init()} and started with {@link #start(String, int)}.
|
||||
* You should register all of your dimensions, biomes, commands, events, etc... in-between.
|
||||
*/
|
||||
public class MinecraftServer {
|
||||
@Getter
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(MinecraftServer.class);
|
||||
|
@ -87,8 +93,6 @@ public class MinecraftServer {
|
|||
public static final int CHUNK_VIEW_DISTANCE = 10;
|
||||
public static final int ENTITY_VIEW_DISTANCE = 5;
|
||||
public static final int COMPRESSION_THRESHOLD = 256;
|
||||
// TODO
|
||||
public static final int MAX_PACKET_SIZE = 300_000;
|
||||
// Can be modified at performance cost when increased
|
||||
public static final int TICK_PER_SECOND = 20;
|
||||
private static final int MS_TO_SEC = 1000;
|
||||
|
@ -105,6 +109,8 @@ public class MinecraftServer {
|
|||
|
||||
//Rate Limiting
|
||||
private static int rateLimit = 0;
|
||||
// TODO
|
||||
public static final int MAX_PACKET_SIZE = 300_000;
|
||||
|
||||
private static PacketListenerManager packetListenerManager;
|
||||
private static NettyServer nettyServer;
|
||||
|
@ -413,6 +419,11 @@ public class MinecraftServer {
|
|||
return dimensionTypeManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the manager handling biomes.
|
||||
*
|
||||
* @return the biome manager
|
||||
*/
|
||||
public static BiomeManager getBiomeManager() {
|
||||
return biomeManager;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class ChatClickEvent {
|
|||
}
|
||||
|
||||
/**
|
||||
* Open an URL when clicked
|
||||
* Opens an URL when clicked.
|
||||
*
|
||||
* @param url the URL to open
|
||||
* @return the chat click event
|
||||
|
@ -24,7 +24,7 @@ public class ChatClickEvent {
|
|||
}
|
||||
|
||||
/**
|
||||
* Run a command when clicked
|
||||
* Runs a command when clicked.
|
||||
*
|
||||
* @param command the command to run
|
||||
* @return the chat click event
|
||||
|
@ -34,7 +34,7 @@ public class ChatClickEvent {
|
|||
}
|
||||
|
||||
/**
|
||||
* Write a string in the player's chat when clicked
|
||||
* Writes a string in the player's chat when clicked.
|
||||
*
|
||||
* @param command the command to suggest
|
||||
* @return the chat click event
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ChatHoverEvent {
|
|||
}
|
||||
|
||||
/**
|
||||
* Show a {@link ColoredText} when hovered
|
||||
* Shows a {@link ColoredText} when hovered.
|
||||
*
|
||||
* @param text the text to show
|
||||
* @return the chat hover event
|
||||
|
@ -54,7 +54,7 @@ public class ChatHoverEvent {
|
|||
}
|
||||
|
||||
/**
|
||||
* Show a raw text when hovered
|
||||
* Shows a raw text when hovered.
|
||||
*
|
||||
* @param text the text to show
|
||||
* @return the chat hover event
|
||||
|
@ -64,7 +64,7 @@ public class ChatHoverEvent {
|
|||
}
|
||||
|
||||
/**
|
||||
* Show an item when hovered
|
||||
* Shows an item when hovered.
|
||||
*
|
||||
* @param itemStack the item to show
|
||||
* @return the chat hover event
|
||||
|
@ -75,7 +75,7 @@ public class ChatHoverEvent {
|
|||
}
|
||||
|
||||
/**
|
||||
* Show an entity when hovered
|
||||
* Shows an entity when hovered.
|
||||
*
|
||||
* @param entity the entity to show
|
||||
* @return the chat hover event
|
||||
|
|
|
@ -36,7 +36,6 @@ public class ExtensionManager {
|
|||
|
||||
public void loadExtensions() {
|
||||
Check.stateCondition(loaded, "Extensions are already loaded!");
|
||||
|
||||
this.loaded = true;
|
||||
|
||||
if (!extensionFolder.exists()) {
|
||||
|
@ -61,7 +60,7 @@ public class ExtensionManager {
|
|||
log.error("Failed to get URL.", e);
|
||||
return;
|
||||
}
|
||||
InputStream extensionInputStream = loader.getResourceAsStream("extension.json");
|
||||
final InputStream extensionInputStream = loader.getResourceAsStream("extension.json");
|
||||
if (extensionInputStream == null) {
|
||||
StringBuilder urlsString = new StringBuilder();
|
||||
for (int i = 0; i < urls.length; i++) {
|
||||
|
@ -76,8 +75,8 @@ public class ExtensionManager {
|
|||
}
|
||||
JsonObject extensionDescriptionJson = JsonParser.parseReader(new InputStreamReader(extensionInputStream)).getAsJsonObject();
|
||||
|
||||
String mainClass = extensionDescriptionJson.get("entrypoint").getAsString();
|
||||
String extensionName = extensionDescriptionJson.get("name").getAsString();
|
||||
final String mainClass = extensionDescriptionJson.get("entrypoint").getAsString();
|
||||
final String extensionName = extensionDescriptionJson.get("name").getAsString();
|
||||
|
||||
// Get ExtensionDescription (authors, version etc.)
|
||||
Extension.ExtensionDescription extensionDescription;
|
||||
|
@ -166,6 +165,7 @@ public class ExtensionManager {
|
|||
descriptionField.set(extension, LoggerFactory.getLogger(extensionClass));
|
||||
} catch (IllegalAccessException e) {
|
||||
// We made it accessible, should not occur
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
log.error("Main class '{}' in '{}' has no logger field.", mainClass, extensionName, e);
|
||||
}
|
||||
|
@ -198,8 +198,8 @@ public class ExtensionManager {
|
|||
// this allows developers to have their extension discovered while working on it, without having to build a jar and put in the extension folder
|
||||
if (System.getProperty(INDEV_CLASSES_FOLDER) != null && System.getProperty(INDEV_RESOURCES_FOLDER) != null) {
|
||||
log.info("Found indev folders for extension. Adding to list of discovered extensions.");
|
||||
String extensionClasses = System.getProperty(INDEV_CLASSES_FOLDER);
|
||||
String extensionResources = System.getProperty(INDEV_RESOURCES_FOLDER);
|
||||
final String extensionClasses = System.getProperty(INDEV_CLASSES_FOLDER);
|
||||
final String extensionResources = System.getProperty(INDEV_RESOURCES_FOLDER);
|
||||
try (InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(extensionResources, "extension.json")))) {
|
||||
DiscoveredExtension extension = new DiscoveredExtension();
|
||||
extension.files = new File[]{new File(extensionClasses), new File(extensionResources)};
|
||||
|
@ -246,7 +246,7 @@ public class ExtensionManager {
|
|||
* Extensions are allowed to apply Mixin transformers, the magic happens here.
|
||||
*/
|
||||
private void setupCodeModifiers(List<DiscoveredExtension> extensions) {
|
||||
ClassLoader cl = getClass().getClassLoader();
|
||||
final ClassLoader cl = getClass().getClassLoader();
|
||||
if (!(cl instanceof MinestomOverwriteClassLoader)) {
|
||||
log.warn("Current class loader is not a MinestomOverwriteClassLoader, but " + cl + ". This disables code modifiers (Mixin support is therefore disabled)");
|
||||
return;
|
||||
|
@ -256,13 +256,13 @@ public class ExtensionManager {
|
|||
for (DiscoveredExtension extension : extensions) {
|
||||
try {
|
||||
if (extension.description.has("codeModifiers")) {
|
||||
JsonArray codeModifierClasses = extension.description.getAsJsonArray("codeModifiers");
|
||||
final JsonArray codeModifierClasses = extension.description.getAsJsonArray("codeModifiers");
|
||||
for (JsonElement elem : codeModifierClasses) {
|
||||
modifiableClassLoader.loadModifier(extension.files, elem.getAsString());
|
||||
}
|
||||
}
|
||||
if (extension.description.has("mixinConfig")) {
|
||||
String mixinConfigFile = extension.description.get("mixinConfig").getAsString();
|
||||
final String mixinConfigFile = extension.description.get("mixinConfig").getAsString();
|
||||
Mixins.addConfiguration(mixinConfigFile);
|
||||
log.info("Found mixin in extension " + extension.description.get("name").getAsString() + ": " + mixinConfigFile);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user