Skip to content

Commit

Permalink
fix: support SR 15.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
hank9999 committed Dec 30, 2023
1 parent da592b2 commit 80206c6
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.hank9999</groupId>
<artifactId>UseBlessingSkin</artifactId>
<version>1.1.1</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<name>UseBlessingSkin</name>
Expand Down Expand Up @@ -78,7 +78,7 @@
<dependency>
<groupId>net.skinsrestorer</groupId>
<artifactId>skinsrestorer-api</artifactId>
<version>14.2.2-SNAPSHOT</version>
<version>15.0.4-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import static com.github.hank9999.useblessingskin.bukkit.UseBlessingSkin.skinsRestorerAPI;
import static com.github.hank9999.useblessingskin.shared.utils.*;

import net.skinsrestorer.api.property.IProperty;
import net.skinsrestorer.api.property.InputDataResult;
import net.skinsrestorer.api.property.SkinProperty;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;

import net.skinsrestorer.api.PlayerWrapper;
import org.jetbrains.annotations.NotNull;

import java.net.URLEncoder;
Expand Down Expand Up @@ -156,12 +155,26 @@ public void run() {

commandSender.sendMessage(ChatColor.AQUA + "[UBS] " + ChatColor.BLUE + getConfig.str("message.UploadTextureSuccess"));

IProperty iProperty = skinsRestorerAPI.createPlatformProperty("textures", value, signature);
skinsRestorerAPI.setSkinData(" " + commandSender.getName(), iProperty, 9223243187835955807L);

skinsRestorerAPI.setSkin(commandSender.getName(), " " + commandSender.getName());
UseBlessingSkin.skinStorage.setCustomSkinData(" " + commandSender.getName(), SkinProperty.of(value, signature));

Optional<InputDataResult> result = UseBlessingSkin.skinStorage.findOrCreateSkinData(" " + commandSender.getName());

if (!result.isPresent()) {
commandSender.sendMessage(ChatColor.AQUA + "[UBS] " + ChatColor.RED + getConfig.str("message.UnknownError"));
return;
}

Player player = UseBlessingSkin.plugin.getServer().getPlayer(commandSender.getName());

if (player == null) {
commandSender.sendMessage(ChatColor.AQUA + "[UBS] " + ChatColor.RED + getConfig.str("message.UnknownError"));
return;
}

UseBlessingSkin.playerStorage.setSkinIdOfPlayer(player.getUniqueId(), result.get().getIdentifier());

skinsRestorerAPI.applySkin(new PlayerWrapper(commandSender));
skinsRestorerAPI.getSkinApplier(Player.class).applySkin(player);

commandSender.sendMessage(ChatColor.AQUA + "[UBS] " + ChatColor.BLUE + getConfig.str("message.SetSkinSuccess"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import com.github.hank9999.useblessingskin.bukkit.bStats.MetricsLite;

import com.github.hank9999.useblessingskin.bukkit.Update.Updater;
import net.skinsrestorer.api.SkinsRestorerAPI;
import net.skinsrestorer.api.SkinsRestorer;
import net.skinsrestorer.api.SkinsRestorerProvider;
import net.skinsrestorer.api.storage.PlayerStorage;
import net.skinsrestorer.api.storage.SkinStorage;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;

Expand All @@ -13,7 +16,9 @@
public final class UseBlessingSkin extends JavaPlugin {

public static UseBlessingSkin plugin;
public static SkinsRestorerAPI skinsRestorerAPI;
public static SkinsRestorer skinsRestorerAPI;
public static SkinStorage skinStorage;
public static PlayerStorage playerStorage;

@Override
public void onLoad() {
Expand All @@ -23,7 +28,9 @@ public void onLoad() {
@Override
public void onEnable() {
plugin = this;
skinsRestorerAPI = SkinsRestorerAPI.getApi();
skinsRestorerAPI = SkinsRestorerProvider.get();
skinStorage = skinsRestorerAPI.getSkinStorage();
playerStorage = skinsRestorerAPI.getPlayerStorage();
if (!getDataFolder().exists()) {
getDataFolder().mkdir();
}
Expand Down Expand Up @@ -53,6 +60,8 @@ public void onEnable() {
public void onDisable() {
plugin = null;
skinsRestorerAPI = null;
skinStorage = null;
playerStorage = null;
getLogger().info(ChatColor.BLUE + "UseBlessingSkin插件已禁用");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;
import net.skinsrestorer.api.PlayerWrapper;
import net.skinsrestorer.api.property.IProperty;
import net.skinsrestorer.api.property.InputDataResult;
import net.skinsrestorer.api.property.SkinProperty;

import java.net.URLEncoder;

import java.util.*;
import java.util.stream.Collectors;

import static com.github.hank9999.useblessingskin.bungee.UseBlessingSkin.skinsRestorerAPI;
import static com.github.hank9999.useblessingskin.bungee.UseBlessingSkin.*;
import static com.github.hank9999.useblessingskin.shared.utils.*;


Expand Down Expand Up @@ -169,12 +170,20 @@ public void execute(CommandSender commandSender, String[] strings) {

commandSender.sendMessage(new TextComponent(ChatColor.AQUA + "[UBS] " + ChatColor.BLUE + getConfig.str("message.UploadTextureSuccess")));

IProperty iProperty = skinsRestorerAPI.createPlatformProperty("textures", value, signature);
skinsRestorerAPI.setSkinData(" " + commandSender.getName(), iProperty, 9223243187835955807L);

skinsRestorerAPI.setSkin(commandSender.getName(), " " + commandSender.getName());
skinStorage.setCustomSkinData(" " + commandSender.getName(), SkinProperty.of(value, signature));

skinsRestorerAPI.applySkin(new PlayerWrapper(commandSender));
Optional<InputDataResult> result = skinStorage.findOrCreateSkinData(" " + commandSender.getName());

if (!result.isPresent()) {
commandSender.sendMessage(new TextComponent(ChatColor.AQUA + "[UBS] " + getConfig.str("message.UnknownError")));
return;
}

ProxiedPlayer player = instance.getProxy().getPlayer(commandSender.getName());
playerStorage.setSkinIdOfPlayer(player.getUniqueId(), result.get().getIdentifier());

skinsRestorerAPI.getSkinApplier(ProxiedPlayer.class).applySkin(player);

commandSender.sendMessage(new TextComponent(ChatColor.AQUA + "[UBS] " + ChatColor.BLUE + getConfig.str("message.SetSkinSuccess")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import net.skinsrestorer.api.SkinsRestorerAPI;
import net.skinsrestorer.api.SkinsRestorer;
import net.skinsrestorer.api.SkinsRestorerProvider;
import net.skinsrestorer.api.storage.PlayerStorage;
import net.skinsrestorer.api.storage.SkinStorage;

import java.io.*;
import java.nio.file.Files;
Expand All @@ -19,7 +22,9 @@ public final class UseBlessingSkin extends Plugin {

public static UseBlessingSkin instance;
public static Configuration configuration;
public static SkinsRestorerAPI skinsRestorerAPI;
public static SkinsRestorer skinsRestorerAPI;
public static SkinStorage skinStorage;
public static PlayerStorage playerStorage;

@Override
public void onLoad() {
Expand All @@ -29,7 +34,11 @@ public void onLoad() {
@Override
public void onEnable() {
instance = this;
skinsRestorerAPI = SkinsRestorerAPI.getApi();

skinsRestorerAPI = SkinsRestorerProvider.get();
skinStorage = skinsRestorerAPI.getSkinStorage();
playerStorage = skinsRestorerAPI.getPlayerStorage();

if (!getDataFolder().exists()) {
getDataFolder().mkdir();
}
Expand Down Expand Up @@ -71,6 +80,8 @@ public void onEnable() {
public void onDisable() {
instance = null;
skinsRestorerAPI = null;
skinStorage = null;
playerStorage = null;
getLogger().info(ChatColor.BLUE + "UseBlessingSkin Disable");
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: UseBlessingSkin
version: ${project.version}
main: com.github.hank9999.useblessingskin.bungee.UseBlessingSkin
depend: [SkinsRestorer]
author: [hank9999]
softDepends: [ "SkinsRestorer" ]
author: "hank9999"
description: 让SkinsRestorer使用Blessing Skin Server搭建的皮肤站上的皮肤!

permissions:
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: UseBlessingSkin
version: ${project.version}
main: com.github.hank9999.useblessingskin.bukkit.UseBlessingSkin
depend: [SkinsRestorer]
authors: [hank9999]
softdepend: [ "SkinsRestorer" ]
authors: ["hank9999"]
description: 让SkinsRestorer使用Blessing Skin Server搭建的皮肤站上的皮肤!
api-version: 1.13

Expand Down

0 comments on commit 80206c6

Please sign in to comment.