Skip to content

Commit

Permalink
Use Adventure ResourcePackInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed May 18, 2024
1 parent aca1dea commit a6f2cfd
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 202 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/spongepowered/api/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.ForwardingAudience;
import net.kyori.adventure.resource.ResourcePackRequest;
import net.kyori.adventure.text.Component;
import org.spongepowered.api.block.entity.CommandBlock;
import org.spongepowered.api.command.manager.CommandManager;
Expand All @@ -38,7 +39,6 @@
import org.spongepowered.api.map.MapStorage;
import org.spongepowered.api.network.ServerSideConnection;
import org.spongepowered.api.profile.GameProfileManager;
import org.spongepowered.api.resourcepack.ResourcePack;
import org.spongepowered.api.scoreboard.Scoreboard;
import org.spongepowered.api.service.ServiceProvider;
import org.spongepowered.api.user.UserManager;
Expand Down Expand Up @@ -131,11 +131,11 @@ public interface Server extends ForwardingAudience, Engine, LocaleSource {
Component motd();

/**
* Gets the {@link ResourcePack pack} sent to clients when they join.
* Gets the {@link ResourcePackRequest pack} sent to clients when they join.
*
* @return The resource pack
*/
Optional<ResourcePack> resourcePack();
Optional<ResourcePackRequest> resourcePack();

/**
* Gets the player idle timeout, in minutes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.command.exception.CommandException;
import org.spongepowered.api.command.parameter.CommandContext;


/**
* Interface containing the method directing how a certain command will
* be executed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.spongepowered.api.item.inventory.Container;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.api.network.ServerSideConnection;
import org.spongepowered.api.resourcepack.ResourcePack;
import org.spongepowered.api.scoreboard.Scoreboard;
import org.spongepowered.api.service.permission.Subject;
import org.spongepowered.api.statistic.Statistic;
Expand Down Expand Up @@ -186,13 +185,6 @@ default SetValue.Mutable<SkinPart> displayedSkinParts() {
*/
ServerSideConnection connection();

/**
* Sends a given {@link ResourcePack} to this player.
*
* @param pack The ResourcePack to send
*/
void sendResourcePack(ResourcePack pack);

/**
* Gets this player's {@link TabList}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,90 +24,58 @@
*/
package org.spongepowered.api.event.entity.living.player;

import org.checkerframework.checker.nullness.qual.Nullable;
import net.kyori.adventure.resource.ResourcePackInfo;
import net.kyori.adventure.resource.ResourcePackStatus;
import org.spongepowered.api.Server;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
import org.spongepowered.api.event.Event;
import org.spongepowered.api.resourcepack.ResourcePack;
import org.spongepowered.api.network.ServerSideConnection;
import org.spongepowered.api.profile.GameProfile;
import org.spongepowered.api.util.annotation.eventgen.GenerateFactoryMethod;

import java.util.Optional;

/**
* Called when a {@link ServerPlayer player} notifies the {@link Server} of the
* Called when a {@link ServerSideConnection connection} notifies the {@link Server} of the
* status of a resource pack change request.
*/
@GenerateFactoryMethod
public interface ResourcePackStatusEvent extends Event {

/**
* Get the {@link ServerPlayer player}.
* Gets the {@link ServerSideConnection connection}.
*
* @return The player
* @return The connection
*/
ServerPlayer player();
ServerSideConnection connection();

/**
* Gets the {@link GameProfile profile} associated
* with this connection.
*
* @return The profile
*/
GameProfile profile();

/**
* Gets the {@link ServerPlayer player}.
*
* @return The player, or {@link Optional#empty()} if the
* player is in the configuration state.
*/
Optional<ServerPlayer> player();

/**
* Gets the pack that this status corresponds to.
*
* @return The pack that this status corresponds to.
*/
ResourcePack pack();
ResourcePackInfo pack();

/**
* Gets the status of the sent pack.
*
* @return The status of the sent pack.
*/
ResourcePackStatus status();

/**
* The different possible responses the client can have.
*/
enum ResourcePackStatus {

/**
* The client is attempting to download the pack.
*/
ACCEPTED(null),

/**
* The client declined to download the pack.
*/
DECLINED(false),

/**
* The client failed to download the resource pack.
*
* <p>In some client versions, such as 1.8.0, this may only be sent when
* the resource pack URL does not end in {@code .zip}. Otherwise,
* {@link #SUCCESSFULLY_LOADED} will be sent.</p>
*/
FAILED(false),

/**
* The pack URI was successfully loaded. This does not mean that pack
* was loaded, as the vanilla client sends this even when encountering a
* 404 or similar.
*/
SUCCESSFULLY_LOADED(true);

@Nullable private final Boolean success;

ResourcePackStatus(@Nullable Boolean success) {
this.success = success;
}

/**
* Gets if this status indicates that the pack was successfully set.
*
* @return true if it was successful, false if it was not, and
* Optional.empty() if it cannot be determined at this time.
*/
public Optional<Boolean> wasSuccessful() {
return Optional.ofNullable(this.success);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ interface Handshake extends ProfileScoped {
* can be terminated by calling {@link ServerSideConnection#close(Component)}.</p>
*/
interface Configuration extends ProfileScoped {

}

/**
Expand Down
108 changes: 0 additions & 108 deletions src/main/java/org/spongepowered/api/resourcepack/ResourcePack.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/org/spongepowered/api/resourcepack/package-info.java

This file was deleted.

0 comments on commit a6f2cfd

Please sign in to comment.