This commit is contained in:
Camotoy 2022-07-09 18:39:02 -04:00
parent f9fd7cb831
commit 897c4dcfec
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
30 changed files with 144 additions and 528 deletions

View file

@ -35,7 +35,6 @@ import org.geysermc.geyser.api.event.EventBus;
import org.geysermc.geyser.api.extension.ExtensionManager;
import org.geysermc.geyser.api.network.BedrockListener;
import org.geysermc.geyser.api.network.RemoteServer;
import org.geysermc.geyser.api.provider.ProviderManager;
import java.util.List;
import java.util.UUID;
@ -44,24 +43,6 @@ import java.util.UUID;
* Represents the API used in Geyser.
*/
public interface GeyserApi extends GeyserApiBase {
/**
* Shuts down the current Geyser instance.
*/
void shutdown();
/**
* Reloads the current Geyser instance.
*/
void reload();
/**
* Gets if this Geyser instance is running in an IDE. This only needs to be used in cases where files
* expected to be in a jarfile are not present.
*
* @return if we are in a production environment
*/
boolean isProductionEnvironment();
/**
* {@inheritDoc}
*/
@ -101,11 +82,15 @@ public interface GeyserApi extends GeyserApiBase {
CommandManager commandManager();
/**
* Gets the {@link ProviderManager}.
* Provides an implementation for the specified API type.
*
* @return the provider manager
* @param apiClass the builder class
* @param <R> the implementation type
* @param <T> the API type
* @return the builder instance
*/
ProviderManager providerManager();
@NonNull
<R extends T, T> R provider(@NonNull Class<T> apiClass, @Nullable Object... args);
/**
* Gets the {@link EventBus} for handling
@ -131,15 +116,6 @@ public interface GeyserApi extends GeyserApiBase {
*/
BedrockListener bedrockListener();
/**
* Gets the maximum number of players that
* can join this Geyser instance.
*
* @return the maximum number of players that
* can join this Geyser instance
*/
int maxPlayers();
/**
* Gets the current {@link GeyserApiBase} instance.
*

View file

@ -105,7 +105,7 @@ public interface Command {
}
static <T extends CommandSource> Command.Builder<T> builder(Class<T> sourceType) {
return GeyserApi.api().providerManager().builderProvider().provideBuilder(Builder.class, sourceType);
return GeyserApi.api().provider(Builder.class, sourceType);
}
interface Builder<T extends CommandSource> {

View file

@ -45,9 +45,10 @@ public class ServerDefineCommandsEvent extends ConnectionEvent implements Cancel
}
/**
* A mutable collection of the commands sent over.
* A collection of commands sent from the server. Any element in this collection can be removed, but no element can
* be added.
*
* @return a mutable collection of the commands sent over
* @return a collection of the commands sent over
*/
@NonNull
public Set<? extends CommandInfo> commands() {
@ -65,7 +66,6 @@ public class ServerDefineCommandsEvent extends ConnectionEvent implements Cancel
}
public interface CommandInfo {
/**
* Gets the name of the command.
*

View file

@ -83,7 +83,7 @@ public interface CustomItemData {
@Nullable CustomRenderOffsets renderOffsets();
static CustomItemData.Builder builder() {
return GeyserApi.api().providerManager().builderProvider().provideBuilder(CustomItemData.Builder.class);
return GeyserApi.api().provider(CustomItemData.Builder.class);
}
interface Builder {

View file

@ -68,7 +68,7 @@ public interface CustomItemOptions {
}
static CustomItemOptions.Builder builder() {
return GeyserApi.api().providerManager().builderProvider().provideBuilder(CustomItemOptions.Builder.class);
return GeyserApi.api().provider(CustomItemOptions.Builder.class);
}
interface Builder {

View file

@ -137,7 +137,7 @@ public interface NonVanillaCustomItemData extends CustomItemData {
boolean isTool();
static NonVanillaCustomItemData.Builder builder() {
return GeyserApi.api().providerManager().builderProvider().provideBuilder(NonVanillaCustomItemData.Builder.class);
return GeyserApi.api().provider(NonVanillaCustomItemData.Builder.class);
}
interface Builder extends CustomItemData.Builder {

View file

@ -25,16 +25,22 @@
package org.geysermc.geyser.api.network;
import java.util.Locale;
/**
* The authentication types that a Java server can be on connection.
*/
public enum AuthType {
OFFLINE,
ONLINE,
/**
* The internal name for connecting to an online mode server without needing a Java account. The presence of this
* authentication type does not necessarily mean the Floodgate plugin is installed; it only means that this
* authentication type will be attempted.
*/
FLOODGATE;
public static final AuthType[] VALUES = values();
public static AuthType getById(int id) {
return id < VALUES.length ? VALUES[id] : OFFLINE;
}
private static final AuthType[] VALUES = values();
/**
* Convert the AuthType string (from config) to the enum, ONLINE on fail
@ -44,7 +50,7 @@ public enum AuthType {
* @return The converted AuthType
*/
public static AuthType getByName(String name) {
String upperCase = name.toUpperCase();
String upperCase = name.toUpperCase(Locale.ROOT);
for (AuthType type : VALUES) {
if (type.name().equals(upperCase)) {
return type;

View file

@ -48,7 +48,7 @@ public interface BedrockListener {
int port();
/**
* Gets the primary MOTD shown to Bedrock players.
* Gets the primary MOTD shown to Bedrock players if a ping passthrough setting is not enabled.
* <p>
* This is the first line that will be displayed.
*
@ -57,7 +57,7 @@ public interface BedrockListener {
String primaryMotd();
/**
* Gets the secondary MOTD shown to Bedrock players.
* Gets the secondary MOTD shown to Bedrock players if a ping passthrough setting is not enabled.
* <p>
* This is the second line that will be displayed.
*

View file

@ -1,47 +0,0 @@
/*
* 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.api.provider;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Allows for obtaining instances of a builder that are
* used for constructing various data.
*/
public interface BuilderProvider extends Provider {
/**
* Provides a builder for the specified builder type.
*
* @param builderClass the builder class
* @param <B> the resulting type
* @param <T> the builder type
* @return the builder instance
*/
@NonNull
<B extends T, T> B provideBuilder(@NonNull Class<T> builderClass, @Nullable Object... args);
}

View file

@ -1,29 +0,0 @@
/*
* 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.api.provider;
public interface Provider {
}

View file

@ -1,41 +0,0 @@
/*
* 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.api.provider;
/**
* Holds a record of every {@link Provider} available
* that allows for accessing various information throughout
* the API.
*/
public interface ProviderManager {
/**
* Returns the {@link BuilderProvider}.
*
* @return the builder provider
*/
BuilderProvider builderProvider();
}