Skip to content

Commit

Permalink
Fix velocity skinsrestorer optional issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Jun 7, 2024
1 parent fbff654 commit 6391b91
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.xinecraft.minetrax.common.interfaces.MinetraxPlugin;
import com.xinecraft.minetrax.common.enums.PlatformType;
import com.xinecraft.minetrax.common.webquery.WebQueryServer;
import lombok.AccessLevel;
import lombok.Getter;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
Expand Down
4 changes: 2 additions & 2 deletions velocity/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dependencies {
implementation project(":common")
implementation 'org.bstats:bstats-velocity:3.0.0'
compileOnly "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT"
annotationProcessor "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT"
compileOnly "com.velocitypowered:velocity-api:3.0.0-SNAPSHOT"
annotationProcessor "com.velocitypowered:velocity-api:3.0.0-SNAPSHOT"
implementation "dev.dejvokep:boosted-yaml:1.3"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
import lombok.Getter;
import net.skinsrestorer.api.SkinsRestorer;
import net.skinsrestorer.api.SkinsRestorerProvider;
import net.skinsrestorer.api.VersionProvider;
import net.skinsrestorer.api.event.SkinApplyEvent;
Expand Down Expand Up @@ -93,11 +92,11 @@ public class MinetraxVelocity implements MinetraxPlugin {
public HashMap<String, String> joinAddressCache = new HashMap<>();
public Boolean hasSkinsRestorer = false;
public Boolean isSkinsRestorerHookEnabled;
public SkinsRestorer skinsRestorerApi;
public static final MinecraftChannelIdentifier PLUGIN_MESSAGE_CHANNEL = MinecraftChannelIdentifier.from(MinetraxCommon.PLUGIN_MESSAGE_CHANNEL);

@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
System.out.println("Minetrax plugin is starting...");
// GSON builder
gson = new GsonBuilder()
.serializeNulls()
Expand Down Expand Up @@ -136,6 +135,7 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
// Start web query server
startWebQueryServer();

System.out.println("Checking skinsrestoareraasdf" + PluginUtil.checkIfPluginEnabled("skinsrestorer"));
// Hook into plugins
if (PluginUtil.checkIfPluginEnabled("skinsrestorer")) {
hasSkinsRestorer = setupSkinsRestorer();
Expand Down Expand Up @@ -209,8 +209,7 @@ private Boolean setupSkinsRestorer() {

// Add SkinsRestorerHook
try {
skinsRestorerApi = SkinsRestorerProvider.get();
skinsRestorerApi.getEventBus().subscribe(pluginContainer, SkinApplyEvent.class, new SkinsRestorerHook());
SkinsRestorerProvider.get().getEventBus().subscribe(pluginContainer, SkinApplyEvent.class, new SkinsRestorerHook());

// Warn if SkinsRestorer is not compatible with v15
if (!VersionProvider.isCompatibleWith("15")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.xinecraft.minetrax.common.utils.LoggingUtil;
import com.xinecraft.minetrax.velocity.MinetraxVelocity;
import net.skinsrestorer.api.SkinsRestorer;
import net.skinsrestorer.api.SkinsRestorerProvider;
import net.skinsrestorer.api.exception.DataRequestException;
import net.skinsrestorer.api.exception.MineSkinException;
import net.skinsrestorer.api.property.InputDataResult;
Expand All @@ -16,7 +17,7 @@

public class SkinUtil {
public static void setPlayerSkinUsingUrlOrName(String playerUuid, String value) throws MineSkinException, DataRequestException {
SkinsRestorer skinsRestorerApi = MinetraxVelocity.getPlugin().getSkinsRestorerApi();
SkinsRestorer skinsRestorerApi = SkinsRestorerProvider.get();
SkinStorage skinStorage = skinsRestorerApi.getSkinStorage();
PlayerStorage playerStorage = skinsRestorerApi.getPlayerStorage();
Optional<InputDataResult> result = skinStorage.findOrCreateSkinData(value);
Expand All @@ -35,7 +36,7 @@ public static void setPlayerSkinUsingUrlOrName(String playerUuid, String value)
}

public static void setPlayerSkinUsingCustom(String playerUuid, String value) throws DataRequestException {
SkinsRestorer skinsRestorerApi = MinetraxVelocity.getPlugin().getSkinsRestorerApi();
SkinsRestorer skinsRestorerApi = SkinsRestorerProvider.get();
SkinStorage skinStorage = skinsRestorerApi.getSkinStorage();
PlayerStorage playerStorage = skinsRestorerApi.getPlayerStorage();

Expand All @@ -61,7 +62,7 @@ public static void setPlayerSkinUsingCustom(String playerUuid, String value) thr
}

public static void clearPlayerSkin(String playerUuid) throws DataRequestException {
SkinsRestorer skinsRestorerApi = MinetraxVelocity.getPlugin().getSkinsRestorerApi();
SkinsRestorer skinsRestorerApi = SkinsRestorerProvider.get();
PlayerStorage playerStorage = skinsRestorerApi.getPlayerStorage();
playerStorage.removeSkinIdOfPlayer(UUID.fromString(playerUuid));

Expand All @@ -73,7 +74,7 @@ public static void clearPlayerSkin(String playerUuid) throws DataRequestExceptio
}

public static SkinProperty getSkinForPlayer(UUID playerUuid, String playerName) {
SkinsRestorer skinsRestorerAPI = MinetraxVelocity.getPlugin().getSkinsRestorerApi();
SkinsRestorer skinsRestorerAPI = SkinsRestorerProvider.get();
PlayerStorage playerStorage = skinsRestorerAPI.getPlayerStorage();
try {
Optional<SkinProperty> skin = playerStorage.getSkinForPlayer(playerUuid, playerName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.kyori.adventure.text.Component;
import net.skinsrestorer.api.PropertyUtils;
import net.skinsrestorer.api.SkinsRestorer;
import net.skinsrestorer.api.SkinsRestorerProvider;
import net.skinsrestorer.api.property.SkinProperty;
import net.skinsrestorer.api.storage.PlayerStorage;

Expand Down Expand Up @@ -45,7 +46,7 @@ public String handleStatus() throws Exception {
playerJsonObject.addProperty("ip_address", Objects.requireNonNull(player.getRemoteAddress()).getHostString());

if (this.plugin.getHasSkinsRestorer()) {
SkinsRestorer skinsRestorerApi = this.plugin.getSkinsRestorerApi();
SkinsRestorer skinsRestorerApi = SkinsRestorerProvider.get();
PlayerStorage playerStorage = skinsRestorerApi.getPlayerStorage();
try {
Optional<SkinProperty> skin = playerStorage.getSkinForPlayer(player.getUniqueId(), player.getUsername());
Expand Down

0 comments on commit 6391b91

Please sign in to comment.