mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Reintroduce GeyserDefineCommandsEvent and cleanup a few things
This commit is contained in:
parent
c07c7b9337
commit
e5337b6298
22 changed files with 355 additions and 107 deletions
|
|
@ -547,7 +547,7 @@ public class GeyserImpl implements GeyserApi {
|
|||
|
||||
ResourcePack.PACKS.clear();
|
||||
|
||||
this.eventBus.fire(new GeyserShutdownEvent(this.extensionManager, this.commandManager(), this.eventBus));
|
||||
this.eventBus.fire(new GeyserShutdownEvent(this.extensionManager, this.eventBus));
|
||||
this.extensionManager.disableExtensions();
|
||||
|
||||
bootstrap.getGeyserLogger().info(GeyserLocale.getLocaleStringLog("geyser.core.shutdown.done"));
|
||||
|
|
@ -572,11 +572,12 @@ public class GeyserImpl implements GeyserApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public GeyserExtensionManager extensionManager() {
|
||||
return this.extensionManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public GeyserCommandManager commandManager() {
|
||||
return this.bootstrap.getGeyserCommandManager();
|
||||
}
|
||||
|
|
@ -587,15 +588,18 @@ public class GeyserImpl implements GeyserApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public EventBus eventBus() {
|
||||
return this.eventBus;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public RemoteServer defaultRemoteServer() {
|
||||
return getConfig().getRemote();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public BedrockListener bedrockListener() {
|
||||
return getConfig().getBedrock();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,30 +33,46 @@ import org.geysermc.common.PlatformType;
|
|||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.command.CommandExecutor;
|
||||
import org.geysermc.geyser.api.command.CommandManager;
|
||||
import org.geysermc.geyser.api.command.CommandSource;
|
||||
import org.geysermc.geyser.command.defaults.*;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCommandsEvent;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
import org.geysermc.geyser.command.defaults.AdvancedTooltipsCommand;
|
||||
import org.geysermc.geyser.command.defaults.AdvancementsCommand;
|
||||
import org.geysermc.geyser.command.defaults.ConnectionTestCommand;
|
||||
import org.geysermc.geyser.command.defaults.DumpCommand;
|
||||
import org.geysermc.geyser.command.defaults.ExtensionsCommand;
|
||||
import org.geysermc.geyser.command.defaults.HelpCommand;
|
||||
import org.geysermc.geyser.command.defaults.ListCommand;
|
||||
import org.geysermc.geyser.command.defaults.OffhandCommand;
|
||||
import org.geysermc.geyser.command.defaults.ReloadCommand;
|
||||
import org.geysermc.geyser.command.defaults.SettingsCommand;
|
||||
import org.geysermc.geyser.command.defaults.StatisticsCommand;
|
||||
import org.geysermc.geyser.command.defaults.StopCommand;
|
||||
import org.geysermc.geyser.command.defaults.VersionCommand;
|
||||
import org.geysermc.geyser.event.type.GeyserDefineCommandsEventImpl;
|
||||
import org.geysermc.geyser.extension.command.GeyserExtensionCommand;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.text.GeyserLocale;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class GeyserCommandManager extends CommandManager {
|
||||
public abstract class GeyserCommandManager {
|
||||
|
||||
@Getter
|
||||
private final Map<String, Command> commands = new Object2ObjectOpenHashMap<>(12);
|
||||
private final Map<String, Command> extensionCommands = new Object2ObjectOpenHashMap<>(0);
|
||||
private final Map<Extension, Map<String, Command>> extensionCommands = new Object2ObjectOpenHashMap<>(0);
|
||||
|
||||
private final GeyserImpl geyser;
|
||||
|
||||
public void init() {
|
||||
registerBuiltInCommand(new HelpCommand(geyser, "help", "geyser.commands.help.desc", "geyser.command.help", "geyser", commands));
|
||||
registerBuiltInCommand(new HelpCommand(geyser, "help", "geyser.commands.help.desc", "geyser.command.help", "geyser", this.commands));
|
||||
registerBuiltInCommand(new ListCommand(geyser, "list", "geyser.commands.list.desc", "geyser.command.list"));
|
||||
registerBuiltInCommand(new ReloadCommand(geyser, "reload", "geyser.commands.reload.desc", "geyser.command.reload"));
|
||||
registerBuiltInCommand(new OffhandCommand(geyser, "offhand", "geyser.commands.offhand.desc", "geyser.command.offhand"));
|
||||
|
|
@ -67,11 +83,32 @@ public abstract class GeyserCommandManager extends CommandManager {
|
|||
registerBuiltInCommand(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
|
||||
registerBuiltInCommand(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips"));
|
||||
registerBuiltInCommand(new ConnectionTestCommand(geyser, "connectiontest", "geyser.commands.connectiontest.desc", "geyser.command.connectiontest"));
|
||||
if (GeyserImpl.getInstance().getPlatformType() == PlatformType.STANDALONE) {
|
||||
if (this.geyser.getPlatformType() == PlatformType.STANDALONE) {
|
||||
registerBuiltInCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
|
||||
}
|
||||
|
||||
register(new HelpCommand(geyser, "help", "geyser.commands.exthelp.desc", "geyser.command.exthelp", "geyserext", extensionCommands));
|
||||
if (this.geyser.extensionManager().extensions().size() > 0) {
|
||||
registerBuiltInCommand(new ExtensionsCommand(this.geyser, "extensions", "geyser.commands.extensions.desc", "geyser.command.extensions"));
|
||||
}
|
||||
|
||||
GeyserDefineCommandsEvent defineCommandsEvent = new GeyserDefineCommandsEventImpl(this.commands) {
|
||||
|
||||
@Override
|
||||
public void register(@NonNull Command command) {
|
||||
if (!(command instanceof GeyserExtensionCommand extensionCommand)) {
|
||||
throw new IllegalArgumentException("Expected GeyserExtensionCommand as part of command registration but got " + command + "! Did you use the Command builder properly?");
|
||||
}
|
||||
|
||||
registerExtensionCommand(extensionCommand.extension(), extensionCommand);
|
||||
}
|
||||
};
|
||||
|
||||
this.geyser.eventBus().fire(defineCommandsEvent);
|
||||
|
||||
// Register help commands for all extensions with commands
|
||||
for (Map.Entry<Extension, Map<String, Command>> entry : this.extensionCommands.entrySet()) {
|
||||
registerExtensionCommand(entry.getKey(), new HelpCommand(this.geyser, "help", "geyser.commands.exthelp.desc", "geyser.command.exthelp", entry.getKey().description().id(), entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,9 +118,8 @@ public abstract class GeyserCommandManager extends CommandManager {
|
|||
register(command, this.commands);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(@NonNull Command command) {
|
||||
register(command, this.extensionCommands);
|
||||
public void registerExtensionCommand(@NonNull Extension extension, @NonNull Command command) {
|
||||
register(command, this.extensionCommands.computeIfAbsent(extension, e -> new HashMap<>()));
|
||||
}
|
||||
|
||||
private void register(Command command, Map<String, Command> commands) {
|
||||
|
|
@ -99,32 +135,30 @@ public abstract class GeyserCommandManager extends CommandManager {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister(@NonNull Command command) {
|
||||
this.extensionCommands.remove(command.name(), command);
|
||||
|
||||
if (command.aliases().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String alias : command.aliases()) {
|
||||
this.extensionCommands.remove(alias, command);
|
||||
}
|
||||
@NotNull
|
||||
public Map<String, Command> commands() {
|
||||
return Collections.unmodifiableMap(this.commands);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Map<String, Command> commands() {
|
||||
public Map<Extension, Map<String, Command>> extensionCommands() {
|
||||
return Collections.unmodifiableMap(this.extensionCommands);
|
||||
}
|
||||
|
||||
public boolean runCommand(GeyserCommandSource sender, String command) {
|
||||
boolean extensionCommand = command.startsWith("geyserext ");
|
||||
if (!command.startsWith("geyser ") && !extensionCommand) {
|
||||
Extension extension = null;
|
||||
for (Extension loopedExtension : this.extensionCommands.keySet()) {
|
||||
if (command.startsWith(loopedExtension.description().id() + " ")) {
|
||||
extension = loopedExtension;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!command.startsWith("geyser ") && extension == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = command.trim().replace(extensionCommand ? "geyserext " : "geyser ", "");
|
||||
command = command.trim().replace(extension != null ? extension.description().id() + " " : "geyser ", "");
|
||||
String label;
|
||||
String[] args;
|
||||
|
||||
|
|
@ -137,9 +171,9 @@ public abstract class GeyserCommandManager extends CommandManager {
|
|||
args = argLine.contains(" ") ? argLine.split(" ") : new String[] { argLine };
|
||||
}
|
||||
|
||||
Command cmd = (extensionCommand ? this.extensionCommands : this.commands).get(label);
|
||||
Command cmd = (extension != null ? this.extensionCommands.getOrDefault(extension, Collections.emptyMap()) : this.commands).get(label);
|
||||
if (cmd == null) {
|
||||
geyser.getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.invalid"));
|
||||
sender.sendMessage(GeyserLocale.getLocaleStringLog("geyser.commands.invalid"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +202,8 @@ public abstract class GeyserCommandManager extends CommandManager {
|
|||
|
||||
@RequiredArgsConstructor
|
||||
public static class CommandBuilder<T extends CommandSource> implements Command.Builder<T> {
|
||||
private final Class<T> sourceType;
|
||||
private final Extension extension;
|
||||
private Class<? extends T> sourceType;
|
||||
private String name;
|
||||
private String description = "";
|
||||
private String permission = "";
|
||||
|
|
@ -179,22 +214,28 @@ public abstract class GeyserCommandManager extends CommandManager {
|
|||
private boolean bedrockOnly;
|
||||
private CommandExecutor<T> executor;
|
||||
|
||||
public CommandBuilder<T> name(String name) {
|
||||
@Override
|
||||
public Command.Builder<T> source(@NonNull Class<? extends T> sourceType) {
|
||||
this.sourceType = sourceType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder<T> name(@NonNull String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder<T> description(String description) {
|
||||
public CommandBuilder<T> description(@NonNull String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder<T> permission(String permission) {
|
||||
public CommandBuilder<T> permission(@NonNull String permission) {
|
||||
this.permission = permission;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder<T> aliases(List<String> aliases) {
|
||||
public CommandBuilder<T> aliases(@NonNull List<String> aliases) {
|
||||
this.aliases = aliases;
|
||||
return this;
|
||||
}
|
||||
|
|
@ -210,7 +251,7 @@ public abstract class GeyserCommandManager extends CommandManager {
|
|||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder<T> subCommands(List<String> subCommands) {
|
||||
public CommandBuilder<T> subCommands(@NonNull List<String> subCommands) {
|
||||
this.subCommands = subCommands;
|
||||
return this;
|
||||
}
|
||||
|
|
@ -220,22 +261,27 @@ public abstract class GeyserCommandManager extends CommandManager {
|
|||
return this;
|
||||
}
|
||||
|
||||
public CommandBuilder<T> executor(CommandExecutor<T> executor) {
|
||||
public CommandBuilder<T> executor(@NonNull CommandExecutor<T> executor) {
|
||||
this.executor = executor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GeyserCommand build() {
|
||||
@NonNull
|
||||
public GeyserExtensionCommand build() {
|
||||
if (this.name == null || this.name.isBlank()) {
|
||||
throw new IllegalArgumentException("Command cannot be null or blank!");
|
||||
}
|
||||
|
||||
return new GeyserCommand(this.name, this.description, this.permission) {
|
||||
if (this.sourceType == null) {
|
||||
throw new IllegalArgumentException("Source type was not defined for command " + this.name + " in extension " + this.extension.name());
|
||||
}
|
||||
|
||||
return new GeyserExtensionCommand(this.extension, this.name, this.description, this.permission) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void execute(@Nullable GeyserSession session, GeyserCommandSource sender, String[] args) {
|
||||
Class<T> sourceType = CommandBuilder.this.sourceType;
|
||||
Class<? extends T> sourceType = CommandBuilder.this.sourceType;
|
||||
CommandExecutor<T> executor = CommandBuilder.this.executor;
|
||||
if (sourceType.isInstance(session)) {
|
||||
executor.execute((T) session, this, args);
|
||||
|
|
|
|||
|
|
@ -66,19 +66,19 @@ public class HelpCommand extends GeyserCommand {
|
|||
String header = GeyserLocale.getPlayerLocaleString("geyser.commands.help.header", sender.locale(), page, maxPage);
|
||||
sender.sendMessage(header);
|
||||
|
||||
for (Map.Entry<String, Command> entry : commands.entrySet()) {
|
||||
this.commands.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(entry -> {
|
||||
Command cmd = entry.getValue();
|
||||
|
||||
// Standalone hack-in since it doesn't have a concept of permissions
|
||||
if (geyser.getPlatformType() == PlatformType.STANDALONE || sender.hasPermission(cmd.permission())) {
|
||||
// Only list commands the player can actually run
|
||||
if (cmd.isBedrockOnly() && session == null) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW + "/" + baseCommand + " " + entry.getKey() + ChatColor.WHITE + ": " +
|
||||
GeyserLocale.getPlayerLocaleString(cmd.description(), sender.locale()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.event.type;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCommandsEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class GeyserDefineCommandsEventImpl implements GeyserDefineCommandsEvent {
|
||||
private final Map<String, Command> commands;
|
||||
|
||||
public GeyserDefineCommandsEventImpl(Map<String, Command> commands) {
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Map<String, Command> commands() {
|
||||
return Collections.unmodifiableMap(this.commands);
|
||||
}
|
||||
}
|
||||
|
|
@ -36,11 +36,11 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class DefineCustomItemsEvent implements GeyserDefineCustomItemsEvent {
|
||||
public abstract class GeyserDefineCustomItemsEventImpl implements GeyserDefineCustomItemsEvent {
|
||||
private final Multimap<String, CustomItemData> customItems;
|
||||
private final List<NonVanillaCustomItemData> nonVanillaCustomItems;
|
||||
|
||||
public DefineCustomItemsEvent(Multimap<String, CustomItemData> customItems, List<NonVanillaCustomItemData> nonVanillaCustomItems) {
|
||||
public GeyserDefineCustomItemsEventImpl(Multimap<String, CustomItemData> customItems, List<NonVanillaCustomItemData> nonVanillaCustomItems) {
|
||||
this.customItems = customItems;
|
||||
this.nonVanillaCustomItems = nonVanillaCustomItems;
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ import org.yaml.snakeyaml.Yaml;
|
|||
import java.io.Reader;
|
||||
import java.util.*;
|
||||
|
||||
public record GeyserExtensionDescription(String name, String main, String apiVersion, String version, List<String> authors) implements ExtensionDescription {
|
||||
public record GeyserExtensionDescription(String id, String name, String main, String apiVersion, String version, List<String> authors) implements ExtensionDescription {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static GeyserExtensionDescription fromYaml(Reader reader) throws InvalidDescriptionException {
|
||||
DumperOptions dumperOptions = new DumperOptions();
|
||||
|
|
@ -42,6 +42,11 @@ public record GeyserExtensionDescription(String name, String main, String apiVer
|
|||
Yaml yaml = new Yaml(dumperOptions);
|
||||
Map<String, Object> yamlMap = yaml.loadAs(reader, LinkedHashMap.class);
|
||||
|
||||
String id = ((String) yamlMap.get("id")).replaceAll("[^A-Za-z0-9 _.-]", "");
|
||||
if (id.isBlank()) {
|
||||
throw new InvalidDescriptionException("Invalid extension id, cannot be empty");
|
||||
}
|
||||
|
||||
String name = ((String) yamlMap.get("name")).replaceAll("[^A-Za-z0-9 _.-]", "");
|
||||
if (name.isBlank()) {
|
||||
throw new InvalidDescriptionException("Invalid extension name, cannot be empty");
|
||||
|
|
@ -72,6 +77,6 @@ public record GeyserExtensionDescription(String name, String main, String apiVer
|
|||
}
|
||||
}
|
||||
|
||||
return new GeyserExtensionDescription(name, main, apiVersion, version, authors);
|
||||
return new GeyserExtensionDescription(id, name, main, apiVersion, version, Collections.unmodifiableList(authors));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.extension.command;
|
||||
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
import org.geysermc.geyser.command.GeyserCommand;
|
||||
|
||||
public abstract class GeyserExtensionCommand extends GeyserCommand {
|
||||
private final Extension extension;
|
||||
|
||||
public GeyserExtensionCommand(Extension extension, String name, String description, String permission) {
|
||||
super(name, description, permission);
|
||||
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
public Extension extension() {
|
||||
return this.extension;
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.geyser.registry.loader;
|
||||
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.command.CommandSource;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
import org.geysermc.geyser.api.item.custom.CustomItemData;
|
||||
import org.geysermc.geyser.api.item.custom.CustomItemOptions;
|
||||
import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData;
|
||||
|
|
@ -43,10 +43,9 @@ import java.util.Map;
|
|||
*/
|
||||
public class ProviderRegistryLoader implements RegistryLoader<Map<Class<?>, ProviderSupplier>, Map<Class<?>, ProviderSupplier>> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<Class<?>, ProviderSupplier> load(Map<Class<?>, ProviderSupplier> providers) {
|
||||
providers.put(Command.Builder.class, args -> new GeyserCommandManager.CommandBuilder<>((Class<? extends CommandSource>) args[0]));
|
||||
providers.put(Command.Builder.class, args -> new GeyserCommandManager.CommandBuilder<>((Extension) args[0]));
|
||||
providers.put(CustomItemData.Builder.class, args -> new GeyserCustomItemData.CustomItemDataBuilder());
|
||||
providers.put(CustomItemOptions.Builder.class, args -> new GeyserCustomItemOptions.CustomItemOptionsBuilder());
|
||||
providers.put(NonVanillaCustomItemData.Builder.class, args -> new GeyserNonVanillaCustomItemData.NonVanillaCustomItemDataBuilder());
|
||||
|
|
|
|||
|
|
@ -48,11 +48,10 @@ import it.unimi.dsi.fastutil.objects.*;
|
|||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.GeyserBootstrap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCustomItemsEvent;
|
||||
import org.geysermc.geyser.api.item.custom.CustomItemData;
|
||||
import org.geysermc.geyser.api.item.custom.CustomItemOptions;
|
||||
import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData;
|
||||
import org.geysermc.geyser.event.type.DefineCustomItemsEvent;
|
||||
import org.geysermc.geyser.event.type.GeyserDefineCustomItemsEventImpl;
|
||||
import org.geysermc.geyser.inventory.item.StoredItemMappings;
|
||||
import org.geysermc.geyser.item.GeyserCustomMappingData;
|
||||
import org.geysermc.geyser.item.mappings.MappingsConfigReader;
|
||||
|
|
@ -109,7 +108,7 @@ public class ItemRegistryPopulator {
|
|||
});
|
||||
|
||||
nonVanillaCustomItems = new ObjectArrayList<>();
|
||||
GeyserImpl.getInstance().eventBus().fire(new DefineCustomItemsEvent(customItems, nonVanillaCustomItems) {
|
||||
GeyserImpl.getInstance().eventBus().fire(new GeyserDefineCustomItemsEventImpl(customItems, nonVanillaCustomItems) {
|
||||
@Override
|
||||
public boolean register(@NonNull String identifier, @NonNull CustomItemData customItemData) {
|
||||
if (CustomItemRegistryPopulator.initialCheck(identifier, customItemData, items)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue