mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-07 17:08:30 +01:00
commit
642e1133ee
@ -2,7 +2,7 @@ package net.minestom.server.bossbar;
|
||||
|
||||
/**
|
||||
* Represents the displayed color of a {@link BossBar}.
|
||||
* @deprecated Use {@link net.kyori.adventure.bossbar.BossBar}
|
||||
* @deprecated Use {@link net.kyori.adventure.bossbar.BossBar.Color}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum BarColor {
|
||||
|
@ -3,7 +3,7 @@ package net.minestom.server.bossbar;
|
||||
/**
|
||||
* Used to define the number of segments on a {@link BossBar}.
|
||||
*
|
||||
* @deprecated Use {@link net.kyori.adventure.bossbar.BossBar}
|
||||
* @deprecated Use {@link net.kyori.adventure.bossbar.BossBar.Overlay}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum BarDivision {
|
||||
|
@ -20,7 +20,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
* <p>
|
||||
* You can retrieve all the boss bars of a {@link Player} with {@link #getBossBars(Player)}.
|
||||
*
|
||||
* @deprecated Use {@link net.kyori.adventure.audience.Audience#showBossBar(net.kyori.adventure.bossbar.BossBar)}
|
||||
* @deprecated Use {@link net.kyori.adventure.bossbar.BossBar}
|
||||
*/
|
||||
@Deprecated
|
||||
public class BossBar implements Viewable {
|
||||
|
@ -1,9 +1,11 @@
|
||||
package net.minestom.server.chat;
|
||||
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a click event for a specific portion of the message.
|
||||
* @deprecated Use {@link ClickEvent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ChatClickEvent {
|
||||
|
@ -4,24 +4,31 @@ import it.unimi.dsi.fastutil.chars.Char2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.ComponentBuilder;
|
||||
import net.kyori.adventure.text.format.*;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.minestom.server.color.Color;
|
||||
import net.minestom.server.color.DyeColor;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents a color in a text. You can either use one of the pre-made colors
|
||||
* or make your own using RGB. {@link ChatColor#fromRGB(byte, byte, byte)}.
|
||||
* <p>
|
||||
* Immutable class.
|
||||
* @deprecated For chat colors, use {@link TextColor} or {@link NamedTextColor}. For styles, use {@link TextDecoration}.
|
||||
* For colors in other contexts, see {@link Color} or {@link DyeColor}.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class ChatColor {
|
||||
public final class ChatColor implements StyleBuilderApplicable {
|
||||
|
||||
// Special
|
||||
public static final ChatColor NO_COLOR = new ChatColor();
|
||||
@ -310,4 +317,26 @@ public final class ChatColor {
|
||||
|
||||
return header + code + footer;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Contract(mutates = "param")
|
||||
public void styleApply(Style.@NotNull Builder style) {
|
||||
if (this.isEmpty()) {
|
||||
style.color(NamedTextColor.WHITE);
|
||||
} else if (Objects.equals(this.codeName, "reset")) {
|
||||
style.color(NamedTextColor.WHITE);
|
||||
|
||||
for (TextDecoration value : TextDecoration.NAMES.values()) {
|
||||
style.decoration(value, TextDecoration.State.FALSE);
|
||||
}
|
||||
} else if (this.isSpecial() && this.codeName != null) {
|
||||
TextDecoration decoration = TextDecoration.NAMES.value(this.codeName);
|
||||
|
||||
if (decoration != null) {
|
||||
style.decorate(decoration);
|
||||
}
|
||||
} else {
|
||||
style.color(TextColor.color(this.red, this.green, this.blue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Represents a hover event for a specific portion of the message.
|
||||
* @deprecated Use {@link HoverEvent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ChatHoverEvent {
|
||||
|
@ -2,10 +2,12 @@ package net.minestom.server.chat;
|
||||
|
||||
|
||||
import com.google.gson.*;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Class used to convert JSON string to proper chat message representation.
|
||||
* @deprecated Use {@link GsonComponentSerializer}
|
||||
*/
|
||||
@Deprecated
|
||||
public final class ChatParser {
|
||||
|
@ -2,6 +2,8 @@ package net.minestom.server.chat;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -16,6 +18,7 @@ import java.util.regex.Pattern;
|
||||
* <p>
|
||||
* To create one, you simply call one of the static methods like {@link #of(ChatColor, String)},
|
||||
* you can then continue to append text with {@link #append(ChatColor, String)}.
|
||||
* @deprecated Use {@link Component#text(String, TextColor)}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ColoredText extends JsonMessage {
|
||||
|
@ -16,6 +16,7 @@ import java.util.Objects;
|
||||
* Examples are {@link ColoredText} and {@link RichMessage}.
|
||||
*
|
||||
* @see <a href="https://wiki.vg/Chat">Chat Format</a>
|
||||
* @deprecated Use {@link Component}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class JsonMessage implements ComponentLike {
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.chat;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -18,6 +19,7 @@ import java.util.List;
|
||||
* You will need to call the static method to initialize the message {@link #of(ColoredText)},
|
||||
* events can be assigned with {@link #setClickEvent(ChatClickEvent)} and {@link #setHoverEvent(ChatHoverEvent)}
|
||||
* and new text element can also be appended {@link #append(ColoredText)}.
|
||||
* @deprecated Use {@link Component}
|
||||
*/
|
||||
@Deprecated
|
||||
public class RichMessage extends JsonMessage {
|
||||
|
@ -1,10 +1,12 @@
|
||||
package net.minestom.server.chat;
|
||||
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a translatable component which can be used in {@link ColoredText}.
|
||||
* @deprecated Use {@link TranslatableComponent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class TranslatableText {
|
||||
|
@ -18,21 +18,17 @@ public interface CommandSender extends PermissionHandler, Audience {
|
||||
* Sends a raw string message.
|
||||
*
|
||||
* @param message the message to send
|
||||
*
|
||||
* @deprecated Use {@link #sendMessage(Component)}
|
||||
*/
|
||||
@Deprecated
|
||||
default void sendMessage(@NotNull String message) { this.sendMessage(Component.text(message)); }
|
||||
default void sendMessage(@NotNull String message) {
|
||||
this.sendMessage(Component.text(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends multiple raw string messages.
|
||||
*
|
||||
* @param messages the messages to send
|
||||
*
|
||||
* @deprecated Use {@link #sendMessage(Component)}
|
||||
*/
|
||||
@Deprecated
|
||||
default void sendMessage(@NotNull String[] messages) {
|
||||
default void sendMessage(@NotNull String @NotNull[] messages) {
|
||||
for (String message : messages) {
|
||||
sendMessage(message);
|
||||
}
|
||||
@ -57,7 +53,7 @@ public interface CommandSender extends PermissionHandler, Audience {
|
||||
* @return true if 'this' is a player, false otherwise
|
||||
*/
|
||||
default boolean isPlayer() {
|
||||
return this instanceof Player;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +62,7 @@ public interface CommandSender extends PermissionHandler, Audience {
|
||||
* @return true if 'this' is the console, false otherwise
|
||||
*/
|
||||
default boolean isConsole() {
|
||||
return this instanceof ConsoleSender;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,7 +73,7 @@ public interface CommandSender extends PermissionHandler, Audience {
|
||||
* @see #isPlayer()
|
||||
*/
|
||||
default Player asPlayer() {
|
||||
return (Player) this;
|
||||
throw new ClassCastException("CommandSender is not a Player");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,6 +84,6 @@ public interface CommandSender extends PermissionHandler, Audience {
|
||||
* @see #isConsole()
|
||||
*/
|
||||
default ConsoleSender asConsole() {
|
||||
return (ConsoleSender) this;
|
||||
throw new ClassCastException("CommandSender is not the ConsoleSender");
|
||||
}
|
||||
}
|
||||
|
@ -16,15 +16,20 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
* Represents the console when sending a command to the server.
|
||||
*/
|
||||
public class ConsoleSender implements CommandSender {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(ConsoleSender.class);
|
||||
private static final PlainComponentSerializer PLAIN_SERIALIZER = PlainComponentSerializer.plain();
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ConsoleSender.class);
|
||||
|
||||
private final Set<Permission> permissions = new CopyOnWriteArraySet<>();
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull String message) {
|
||||
LOGGER.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type) {
|
||||
// we don't use the serializer here as we just need the plain text of the message
|
||||
LOGGER.info(PlainComponentSerializer.plain().serialize(message));
|
||||
this.sendMessage(PLAIN_SERIALIZER.serialize(message));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@ -32,4 +37,14 @@ public class ConsoleSender implements CommandSender {
|
||||
public Set<Permission> getAllPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsoleSender asConsole() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent.ShowEntity;
|
||||
import net.kyori.adventure.text.event.HoverEventSource;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.advancements.AdvancementTab;
|
||||
@ -803,7 +804,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
*/
|
||||
@Deprecated
|
||||
public void sendJsonMessage(@NotNull String json) {
|
||||
this.sendMessage(json);
|
||||
this.sendMessage(GsonComponentSerializer.gson().deserialize(json));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2666,6 +2667,16 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
this.identity = Identity.identity(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player asPlayer() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the main or off hand of the player.
|
||||
*/
|
||||
|
@ -9,6 +9,7 @@ import net.minestom.server.entity.type.projectile.EntityProjectile;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.time.Cooldown;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -19,6 +20,8 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class CombinedAttackGoal extends GoalSelector {
|
||||
|
||||
private final Cooldown cooldown = new Cooldown(new UpdateOption(5, TimeUnit.TICK));
|
||||
|
||||
private final int meleeRangeSquared;
|
||||
private final int meleeDelay;
|
||||
private final TimeUnit meleeTimeUnit;
|
||||
@ -90,6 +93,10 @@ public class CombinedAttackGoal extends GoalSelector {
|
||||
Check.argCondition(desirableRange > rangedRange, "Desirable range can not exceed ranged range!");
|
||||
}
|
||||
|
||||
public Cooldown getCooldown() {
|
||||
return this.cooldown;
|
||||
}
|
||||
|
||||
public void setProjectileGenerator(Function<Entity, EntityProjectile> projectileGenerator) {
|
||||
this.projectileGenerator = projectileGenerator;
|
||||
}
|
||||
@ -159,7 +166,10 @@ public class CombinedAttackGoal extends GoalSelector {
|
||||
// Otherwise going to the target.
|
||||
Position targetPosition = target.getPosition();
|
||||
if (pathPosition == null || !pathPosition.isSimilar(targetPosition)) {
|
||||
navigator.setPathTo(targetPosition);
|
||||
if (this.cooldown.isReady(time)) {
|
||||
this.cooldown.refreshLastUpdate(time);
|
||||
navigator.setPathTo(targetPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import net.minestom.server.entity.pathfinding.Navigator;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.time.Cooldown;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -16,6 +17,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class MeleeAttackGoal extends GoalSelector {
|
||||
|
||||
private final Cooldown cooldown = new Cooldown(new UpdateOption(5, TimeUnit.TICK));
|
||||
|
||||
private long lastHit;
|
||||
private final int delay;
|
||||
private final TimeUnit timeUnit;
|
||||
@ -37,6 +40,10 @@ public class MeleeAttackGoal extends GoalSelector {
|
||||
this.timeUnit = timeUnit;
|
||||
}
|
||||
|
||||
public Cooldown getCooldown() {
|
||||
return this.cooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldStart() {
|
||||
this.cachedTarget = findTarget();
|
||||
@ -77,7 +84,10 @@ public class MeleeAttackGoal extends GoalSelector {
|
||||
final Position pathPosition = navigator.getPathPosition();
|
||||
final Position targetPosition = target.getPosition();
|
||||
if (pathPosition == null || !pathPosition.isSimilar(targetPosition)) {
|
||||
navigator.setPathTo(targetPosition);
|
||||
if (this.cooldown.isReady(time)) {
|
||||
this.cooldown.refreshLastUpdate(time);
|
||||
navigator.setPathTo(targetPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import net.minestom.server.entity.type.projectile.EntityProjectile;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.time.Cooldown;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -16,6 +17,8 @@ import java.util.function.Function;
|
||||
|
||||
public class RangedAttackGoal extends GoalSelector {
|
||||
|
||||
private final Cooldown cooldown = new Cooldown(new UpdateOption(5, TimeUnit.TICK));
|
||||
|
||||
private long lastShot;
|
||||
private final int delay;
|
||||
private final TimeUnit timeUnit;
|
||||
@ -52,6 +55,10 @@ public class RangedAttackGoal extends GoalSelector {
|
||||
Check.argCondition(desirableRange > attackRange, "Desirable range can not exceed attack range!");
|
||||
}
|
||||
|
||||
public Cooldown getCooldown() {
|
||||
return this.cooldown;
|
||||
}
|
||||
|
||||
public void setProjectileGenerator(Function<Entity, EntityProjectile> projectileGenerator) {
|
||||
this.projectileGenerator = projectileGenerator;
|
||||
}
|
||||
@ -111,7 +118,10 @@ public class RangedAttackGoal extends GoalSelector {
|
||||
}
|
||||
Position targetPosition = target.getPosition();
|
||||
if (pathPosition == null || !pathPosition.isSimilar(targetPosition)) {
|
||||
navigator.setPathTo(targetPosition);
|
||||
if (this.cooldown.isReady(time)) {
|
||||
this.cooldown.refreshLastUpdate(time);
|
||||
navigator.setPathTo(targetPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class ExtensionManager {
|
||||
/**
|
||||
* Loads all extensions in the extension folder into this server.
|
||||
* <br><br>
|
||||
*
|
||||
* <p>
|
||||
* Pipeline:
|
||||
* <br>
|
||||
* Finds all .jar files in the extensions folder.
|
||||
@ -88,32 +88,32 @@ public class ExtensionManager {
|
||||
* <br>
|
||||
* Verifies that all properties of extension.json are correctly set.
|
||||
* <br><br>
|
||||
*
|
||||
* <p>
|
||||
* It then sorts all those jars by their load order (making sure that an extension's dependencies load before it)
|
||||
* <br>
|
||||
* Note: Cyclic dependencies will stop both extensions from being loaded.
|
||||
* <br><br>
|
||||
*
|
||||
* <p>
|
||||
* Afterwards, it loads all external dependencies and adds them to the extension's files
|
||||
* <br><br>
|
||||
*
|
||||
* <p>
|
||||
* Then removes any invalid extensions (Invalid being its Load Status isn't SUCCESS)
|
||||
* <br><br>
|
||||
*
|
||||
* <p>
|
||||
* After that, it set its classloaders so each extension is self-contained,
|
||||
* <br><br>
|
||||
*
|
||||
* <p>
|
||||
* Removes invalid extensions again,
|
||||
* <br><br>
|
||||
*
|
||||
* <p>
|
||||
* and loads all of those extensions into Minestom
|
||||
* <br>
|
||||
* (Extension fields are set via reflection after each extension is verified, then loaded.)
|
||||
* <br><br>
|
||||
*
|
||||
* <p>
|
||||
* If the extension successfully loads, add it to the global extension Map (Name to Extension)
|
||||
* <br><br>
|
||||
*
|
||||
* <p>
|
||||
* And finally make a scheduler to clean observers per extension.
|
||||
*/
|
||||
public void loadExtensions() {
|
||||
@ -193,7 +193,6 @@ public class ExtensionManager {
|
||||
* Loads an extension into Minestom.
|
||||
*
|
||||
* @param discoveredExtension The extension. Make sure to verify its integrity, set its class loader, and its files.
|
||||
*
|
||||
* @return An extension object made from this DiscoveredExtension
|
||||
*/
|
||||
@Nullable
|
||||
@ -213,7 +212,8 @@ public class ExtensionManager {
|
||||
try {
|
||||
jarClass = Class.forName(mainClass, true, loader);
|
||||
} catch (ClassNotFoundException e) {
|
||||
LOGGER.error("Could not find main class '{}' in extension '{}'.", mainClass, extensionName, e);
|
||||
LOGGER.error("Could not find main class '{}' in extension '{}'. If it is, be sure to run your server using Bootstrap#bootstrap",
|
||||
mainClass, extensionName, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ public class ExtensionManager {
|
||||
|
||||
/**
|
||||
* Get all extensions from the extensions folder and make them discovered.
|
||||
*
|
||||
* <p>
|
||||
* It skims the extension folder, discovers and verifies each extension, and returns those created DiscoveredExtensions.
|
||||
*
|
||||
* @return A list of discovered extensions from this folder.
|
||||
@ -354,7 +354,6 @@ public class ExtensionManager {
|
||||
* Grabs a discovered extension from a jar.
|
||||
*
|
||||
* @param file The jar to grab it from (a .jar is a formatted .zip file)
|
||||
*
|
||||
* @return The created DiscoveredExtension.
|
||||
*/
|
||||
@Nullable
|
||||
@ -391,7 +390,8 @@ public class ExtensionManager {
|
||||
extensionMap.put(discoveredExtension.getName().toLowerCase(), discoveredExtension);
|
||||
}
|
||||
|
||||
allExtensions: // go through all the discovered extensions and get their dependencies as extensions
|
||||
allExtensions:
|
||||
// go through all the discovered extensions and get their dependencies as extensions
|
||||
for (DiscoveredExtension discoveredExtension : discoveredExtensions) {
|
||||
|
||||
List<DiscoveredExtension> dependencies = new ArrayList<>(discoveredExtension.getDependencies().length);
|
||||
@ -481,6 +481,7 @@ public class ExtensionManager {
|
||||
|
||||
/**
|
||||
* Checks if this list of extensions are loaded
|
||||
*
|
||||
* @param extensions The list of extensions to check against.
|
||||
* @return If all of these extensions are loaded.
|
||||
*/
|
||||
@ -603,7 +604,7 @@ public class ExtensionManager {
|
||||
try {
|
||||
for (String codeModifierClass : extension.getCodeModifiers()) {
|
||||
boolean loaded = modifiableClassLoader.loadModifier(extension.files.toArray(new URL[0]), codeModifierClass);
|
||||
if(!loaded) {
|
||||
if (!loaded) {
|
||||
extension.addMissingCodeModifier(codeModifierClass);
|
||||
}
|
||||
}
|
||||
@ -613,17 +614,17 @@ public class ExtensionManager {
|
||||
Mixins.addConfiguration(mixinConfigFile);
|
||||
LOGGER.info("Found mixin in extension {}: {}", extension.getName(), mixinConfigFile);
|
||||
} catch (ServiceNotAvailableError | MixinError | MixinException e) {
|
||||
if(MinecraftServer.getExceptionManager() != null) {
|
||||
if (MinecraftServer.getExceptionManager() != null) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LOGGER.error("Could not load Mixin configuration: "+mixinConfigFile);
|
||||
LOGGER.error("Could not load Mixin configuration: " + mixinConfigFile);
|
||||
extension.setFailedToLoadMixinFlag();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if(MinecraftServer.getExceptionManager() != null) {
|
||||
if (MinecraftServer.getExceptionManager() != null) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
|
@ -35,8 +35,8 @@ public class ClientPlayPacketsHandler extends ClientPacketsHandler {
|
||||
register(0x1B, ClientPlayerDiggingPacket::new);
|
||||
register(0x1C, ClientEntityActionPacket::new);
|
||||
register(0x1D, ClientSteerVehiclePacket::new);
|
||||
register(0x1E, ClientRecipeBookData::new);
|
||||
register(0x1F, ClientRecipeBookData::new);
|
||||
register(0x1E, ClientSetRecipeBookStatePacket::new);
|
||||
register(0x1F, ClientSetDisplayedRecipePacket::new);
|
||||
|
||||
|
||||
register(0x20, ClientNameItemPacket::new);
|
||||
|
@ -1,67 +0,0 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
import net.minestom.server.network.packet.client.ClientPlayPacket;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClientRecipeBookData extends ClientPlayPacket {
|
||||
|
||||
public int type;
|
||||
|
||||
public String recipeId = "";
|
||||
|
||||
public boolean craftingRecipeBookOpen;
|
||||
public boolean craftingRecipeFilterActive;
|
||||
public boolean smeltingRecipeBookOpen;
|
||||
public boolean smeltingRecipeFilterActive;
|
||||
public boolean blastingRecipeBookOpen;
|
||||
public boolean blastingRecipeFilterActive;
|
||||
public boolean smokingRecipeBookOpen;
|
||||
public boolean smokingRecipeFilterActive;
|
||||
|
||||
@Override
|
||||
public void read(@NotNull BinaryReader reader) {
|
||||
this.type = reader.readVarInt();
|
||||
|
||||
switch (type) {
|
||||
case 0:
|
||||
this.recipeId = reader.readSizedString(256);
|
||||
break;
|
||||
case 1:
|
||||
this.craftingRecipeBookOpen = reader.readBoolean();
|
||||
this.craftingRecipeFilterActive = reader.readBoolean();
|
||||
this.smeltingRecipeBookOpen = reader.readBoolean();
|
||||
this.smeltingRecipeFilterActive = reader.readBoolean();
|
||||
this.blastingRecipeBookOpen = reader.readBoolean();
|
||||
this.blastingRecipeFilterActive = reader.readBoolean();
|
||||
this.smokingRecipeBookOpen = reader.readBoolean();
|
||||
this.smokingRecipeFilterActive = reader.readBoolean();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(type);
|
||||
|
||||
switch (type) {
|
||||
case 0:
|
||||
if(recipeId.length() > 256)
|
||||
throw new IllegalArgumentException("recipeId must be less than 256 bytes");
|
||||
writer.writeSizedString(recipeId);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
writer.writeBoolean(this.craftingRecipeBookOpen);
|
||||
writer.writeBoolean(this.craftingRecipeFilterActive);
|
||||
writer.writeBoolean(this.smeltingRecipeBookOpen);
|
||||
writer.writeBoolean(this.smeltingRecipeFilterActive);
|
||||
writer.writeBoolean(this.blastingRecipeBookOpen);
|
||||
writer.writeBoolean(this.blastingRecipeFilterActive);
|
||||
writer.writeBoolean(this.smokingRecipeBookOpen);
|
||||
writer.writeBoolean(this.smokingRecipeFilterActive);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
import net.minestom.server.network.packet.client.ClientPlayPacket;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClientSetDisplayedRecipePacket extends ClientPlayPacket {
|
||||
|
||||
public String recipeId = "";
|
||||
|
||||
@Override
|
||||
public void read(@NotNull BinaryReader reader) {
|
||||
this.recipeId = reader.readSizedString(256);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeSizedString(recipeId);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.minestom.server.network.packet.client.play;
|
||||
|
||||
import net.minestom.server.network.packet.client.ClientPlayPacket;
|
||||
import net.minestom.server.utils.binary.BinaryReader;
|
||||
import net.minestom.server.utils.binary.BinaryWriter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClientSetRecipeBookStatePacket extends ClientPlayPacket {
|
||||
|
||||
public BookType type = BookType.CRAFTING;
|
||||
public boolean bookOpen;
|
||||
public boolean filterActive;
|
||||
|
||||
@Override
|
||||
public void read(@NotNull BinaryReader reader) {
|
||||
this.type = BookType.values()[reader.readVarInt()];
|
||||
this.bookOpen = reader.readBoolean();
|
||||
this.filterActive = reader.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull BinaryWriter writer) {
|
||||
writer.writeVarInt(type.ordinal());
|
||||
writer.writeBoolean(bookOpen);
|
||||
writer.writeBoolean(filterActive);
|
||||
}
|
||||
|
||||
public enum BookType {
|
||||
CRAFTING, FURNACE, BLAST_FURNACE, SMOKER
|
||||
}
|
||||
}
|
@ -12,6 +12,10 @@ public final class Cooldown {
|
||||
this.lastUpdate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public UpdateOption getUpdateOption() {
|
||||
return this.updateOption;
|
||||
}
|
||||
|
||||
public void refreshLastUpdate(long lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user