deps(chore): bump deps and update accordingly

This commit is contained in:
ineanto 2023-11-23 23:12:08 +01:00
parent 2a326232ca
commit 2aa37a10a6
10 changed files with 93 additions and 69 deletions

View file

@ -45,7 +45,7 @@
<dependency> <dependency>
<groupId>io.papermc.paper</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version> <version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -63,13 +63,13 @@
<dependency> <dependency>
<groupId>me.clip</groupId> <groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId> <artifactId>placeholderapi</artifactId>
<version>2.11.2</version> <version>2.11.4</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>xyz.xenondevs.invui</groupId> <groupId>xyz.xenondevs.invui</groupId>
<artifactId>invui</artifactId> <artifactId>invui</artifactId>
<version>1.20</version> <version>1.23</version>
<type>pom</type> <type>pom</type>
</dependency> </dependency>
<dependency> <dependency>
@ -80,7 +80,7 @@
<dependency> <dependency>
<groupId>com.github.seeseemelk</groupId> <groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.20</artifactId> <artifactId>MockBukkit-v1.20</artifactId>
<version>3.31.0</version> <version>3.47.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View file

@ -84,9 +84,8 @@ public class AppearanceManager {
private ActionResult updateGameProfileSkin(WrappedGameProfile gameProfile, boolean skinChange, boolean reset) { private ActionResult updateGameProfileSkin(WrappedGameProfile gameProfile, boolean skinChange, boolean reset) {
final NickoProfile profile = getNickoProfile(); final NickoProfile profile = getNickoProfile();
final boolean changeOnlyName = profile.getSkin() != null && profile.getSkin().equals(player.getName());
if (skinChange || !changeOnlyName) { if (skinChange) {
Optional<MojangSkin> skin; Optional<MojangSkin> skin;
try { try {
final MojangAPI mojangAPI = NickoBukkit.getInstance().getMojangAPI(); final MojangAPI mojangAPI = NickoBukkit.getInstance().getMojangAPI();

View file

@ -37,7 +37,7 @@ public class InvalidateSkinGUI {
.collect(Collectors.toList()); .collect(Collectors.toList());
final List<Item> items = loadedSkins.stream() final List<Item> items = loadedSkins.stream()
.map(CacheEntryItem::new) .map(uuid -> new CacheEntryItem(i18n, uuid))
.collect(Collectors.toList()); .collect(Collectors.toList());
final CacheManagementGUI parent = new CacheManagementGUI(player); final CacheManagementGUI parent = new CacheManagementGUI(player);

View file

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import xyz.atnrch.nicko.NickoBukkit;
import xyz.atnrch.nicko.gui.CacheManagementGUI; import xyz.atnrch.nicko.gui.CacheManagementGUI;
import xyz.atnrch.nicko.i18n.I18N; import xyz.atnrch.nicko.i18n.I18N;
import xyz.atnrch.nicko.i18n.I18NDict; import xyz.atnrch.nicko.i18n.I18NDict;
@ -13,6 +14,9 @@ import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.builder.SkullBuilder; import xyz.xenondevs.invui.item.builder.SkullBuilder;
import xyz.xenondevs.invui.item.impl.AsyncItem; import xyz.xenondevs.invui.item.impl.AsyncItem;
import xyz.xenondevs.invui.item.impl.SuppliedItem; import xyz.xenondevs.invui.item.impl.SuppliedItem;
import xyz.xenondevs.invui.util.MojangApiUtils;
import java.io.IOException;
public class ManageCacheItem extends AsyncItem { public class ManageCacheItem extends AsyncItem {
public ManageCacheItem(I18N i18n) { public ManageCacheItem(I18N i18n) {
@ -24,11 +28,20 @@ public class ManageCacheItem extends AsyncItem {
return builder; return builder;
}, (click -> true)).getItemProvider(), }, (click -> true)).getItemProvider(),
() -> { () -> {
final SkullBuilder builder = new SkullBuilder("Notch"); try {
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Admin.MANAGE_CACHE); final SkullBuilder builder = new SkullBuilder("Notch");
builder.setDisplayName(translation.getName()); final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Admin.MANAGE_CACHE);
translation.getLore().forEach(builder::addLoreLines); builder.setDisplayName(translation.getName());
return builder; translation.getLore().forEach(builder::addLoreLines);
return builder;
} catch (MojangApiUtils.MojangApiException | IOException e) {
final ItemBuilder builder = new ItemBuilder(Material.TNT);
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.ERROR);
builder.setDisplayName(translation.getName());
translation.getLore().forEach(builder::addLoreLines);
NickoBukkit.getInstance().getLogger().warning("Unable to get Head texture for Notch! (GUI/ManageCache)");
return builder;
}
}); });
} }

View file

@ -11,11 +11,14 @@ import xyz.atnrch.nicko.gui.InvalidateSkinGUI;
import xyz.atnrch.nicko.gui.items.common.choice.ChoiceCallback; import xyz.atnrch.nicko.gui.items.common.choice.ChoiceCallback;
import xyz.atnrch.nicko.i18n.I18N; import xyz.atnrch.nicko.i18n.I18N;
import xyz.atnrch.nicko.i18n.I18NDict; import xyz.atnrch.nicko.i18n.I18NDict;
import xyz.atnrch.nicko.i18n.ItemTranslation;
import xyz.atnrch.nicko.mojang.MojangAPI; import xyz.atnrch.nicko.mojang.MojangAPI;
import xyz.xenondevs.invui.item.builder.ItemBuilder; import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.builder.SkullBuilder; import xyz.xenondevs.invui.item.builder.SkullBuilder;
import xyz.xenondevs.invui.item.impl.AsyncItem; import xyz.xenondevs.invui.item.impl.AsyncItem;
import xyz.xenondevs.invui.util.MojangApiUtils;
import java.io.IOException;
import java.util.UUID; import java.util.UUID;
public class CacheEntryItem extends AsyncItem { public class CacheEntryItem extends AsyncItem {
@ -23,14 +26,23 @@ public class CacheEntryItem extends AsyncItem {
private final String uuid; private final String uuid;
private final MojangAPI mojangAPI = NickoBukkit.getInstance().getMojangAPI(); private final MojangAPI mojangAPI = NickoBukkit.getInstance().getMojangAPI();
public CacheEntryItem(String uuid) { public CacheEntryItem(I18N i18n, String uuid) {
super(new ItemBuilder(Material.PAINTING).setDisplayName("§7§oLoading..."), () -> { super(new ItemBuilder(Material.PAINTING).setDisplayName("§7§oLoading..."), () -> {
final String dashedUuid = uuid.replaceAll("(.{8})(.{4})(.{4})(.{4})(.+)", "$1-$2-$3-$4-$5"); final String dashedUuid = uuid.replaceAll("(.{8})(.{4})(.{4})(.{4})(.+)", "$1-$2-$3-$4-$5");
final UUID uuidObject = UUID.fromString(dashedUuid); final UUID uuidObject = UUID.fromString(dashedUuid);
final SkullBuilder skull = new SkullBuilder(uuidObject); try {
skull.setDisplayName("§6" + NickoBukkit.getInstance().getMojangAPI().getUUIDName(uuid)); final SkullBuilder skull = new SkullBuilder(uuidObject);
skull.addLoreLines("§7Click to invalidate skin"); skull.setDisplayName("§6" + NickoBukkit.getInstance().getMojangAPI().getUUIDName(uuid));
return skull; skull.addLoreLines("§7Click to invalidate skin");
return skull;
} catch (MojangApiUtils.MojangApiException | IOException e) {
final ItemBuilder builder = new ItemBuilder(Material.TNT);
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.ERROR);
builder.setDisplayName(translation.getName());
translation.getLore().forEach(builder::addLoreLines);
NickoBukkit.getInstance().getLogger().warning("Unable to get Head texture for Notch! (GUI/ManageCache)");
return builder;
}
}); });
this.uuid = uuid; this.uuid = uuid;
this.name = mojangAPI.getUUIDName(uuid); this.name = mojangAPI.getUUIDName(uuid);

View file

@ -13,7 +13,9 @@ import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.builder.SkullBuilder; import xyz.xenondevs.invui.item.builder.SkullBuilder;
import xyz.xenondevs.invui.item.impl.AsyncItem; import xyz.xenondevs.invui.item.impl.AsyncItem;
import xyz.xenondevs.invui.item.impl.SuppliedItem; import xyz.xenondevs.invui.item.impl.SuppliedItem;
import xyz.xenondevs.invui.util.MojangApiUtils;
import java.io.IOException;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@ -27,26 +29,35 @@ public class PlayerInformationItem extends AsyncItem {
return builder; return builder;
}, (click -> true)).getItemProvider(), () -> { }, (click -> true)).getItemProvider(), () -> {
final Player player = Bukkit.getPlayer(uuid); final Player player = Bukkit.getPlayer(uuid);
final SkullBuilder skull = new SkullBuilder(uuid); try {
final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore(); final SkullBuilder skull = new SkullBuilder(uuid);
final Optional<NickoProfile> optionalProfile = dataStore.getData(uuid); final PlayerDataStore dataStore = NickoBukkit.getInstance().getDataStore();
final Optional<NickoProfile> optionalProfile = dataStore.getData(uuid);
if (optionalProfile.isPresent()) {
final NickoProfile profile = optionalProfile.get();
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Admin.CHECK, player.getName(), (profile.hasData() ? "§a✔" : "§c❌"), profile.getName(), profile.getSkin());
skull.setDisplayName("§6" + translation.getName());
translation.getLore().forEach(skull::addLoreLines);
} else {
// Default item name in case the profile is not found
skull.setDisplayName("§6§lYou should not see this!");
skull.addLoreLines(
"§cPlease file a bug report",
"§cat https://ineanto.xyz/git/ineanto/nicko!"
);
}
if (optionalProfile.isPresent()) { return skull;
final NickoProfile profile = optionalProfile.get(); } catch (MojangApiUtils.MojangApiException | IOException e) {
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Admin.CHECK, player.getName(), (profile.hasData() ? "§a✔" : "§c❌"), profile.getName(), profile.getSkin()); NickoBukkit.getInstance().getLogger().severe("Unable to get head for specified UUID ( " + uuid + ")! (GUI/PlayerCheck)");
skull.setDisplayName("§6" + translation.getName());
translation.getLore().forEach(skull::addLoreLines);
} else {
// Default item name in case the profile is not found
skull.setDisplayName("§6§lYou should not see this!");
skull.addLoreLines(
"§cPlease file a bug report",
"§cat https://ineanto.xyz/git/ineanto/nicko!"
);
} }
return skull; final ItemBuilder builder = new ItemBuilder(Material.TNT);
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.ERROR);
builder.setDisplayName(translation.getName());
translation.getLore().forEach(builder::addLoreLines);
return builder;
}); });
} }
} }

View file

@ -1,13 +1,19 @@
package xyz.atnrch.nicko.gui.items.appearance; package xyz.atnrch.nicko.gui.items.appearance;
import org.bukkit.Material;
import xyz.atnrch.nicko.NickoBukkit;
import xyz.atnrch.nicko.anvil.AnvilManager; import xyz.atnrch.nicko.anvil.AnvilManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import xyz.atnrch.nicko.i18n.I18N; import xyz.atnrch.nicko.i18n.I18N;
import xyz.atnrch.nicko.i18n.I18NDict; import xyz.atnrch.nicko.i18n.I18NDict;
import xyz.atnrch.nicko.i18n.ItemTranslation; import xyz.atnrch.nicko.i18n.ItemTranslation;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.builder.SkullBuilder; import xyz.xenondevs.invui.item.builder.SkullBuilder;
import xyz.xenondevs.invui.item.impl.SuppliedItem; import xyz.xenondevs.invui.item.impl.SuppliedItem;
import xyz.xenondevs.invui.util.MojangApiUtils;
import java.io.IOException;
public class ChangeSkinItem { public class ChangeSkinItem {
private final I18N i18n; private final I18N i18n;
@ -20,11 +26,20 @@ public class ChangeSkinItem {
public SuppliedItem get() { public SuppliedItem get() {
return new SuppliedItem(() -> { return new SuppliedItem(() -> {
final SkullBuilder builder = new SkullBuilder(player.getName()); try {
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Home.CHANGE_SKIN); final SkullBuilder builder = new SkullBuilder(player.getName());
builder.setDisplayName(translation.getName()); final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.Home.CHANGE_SKIN);
translation.getLore().forEach(builder::addLoreLines); builder.setDisplayName(translation.getName());
return builder; translation.getLore().forEach(builder::addLoreLines);
return builder;
} catch (MojangApiUtils.MojangApiException | IOException e) {
final ItemBuilder builder = new ItemBuilder(Material.TNT);
final ItemTranslation translation = i18n.translateItem(I18NDict.GUI.ERROR);
builder.setDisplayName(translation.getName());
translation.getLore().forEach(builder::addLoreLines);
NickoBukkit.getInstance().getLogger().warning("Unable to get Head texture for specified player (" + player.getName() + ")! (GUI/Home)");
return builder;
}
}, click -> { }, click -> {
final ClickType clickType = click.getClickType(); final ClickType clickType = click.getClickType();
if (clickType.isLeftClick() || clickType.isRightClick()) { if (clickType.isLeftClick() || clickType.isRightClick()) {

View file

@ -70,6 +70,7 @@ public class I18NDict {
public static final String GO_BACK = GUI_KEY + "go_back"; public static final String GO_BACK = GUI_KEY + "go_back";
public static final String UNAVAILABLE = GUI_KEY + "unavailable"; public static final String UNAVAILABLE = GUI_KEY + "unavailable";
public static final String LOADING = GUI_KEY + "loading"; public static final String LOADING = GUI_KEY + "loading";
public static final String ERROR = GUI_KEY + "error";
public static final String SCROLL_UP = GUI_KEY + "scroll_up"; public static final String SCROLL_UP = GUI_KEY + "scroll_up";
public static final String SCROLL_DOWN = GUI_KEY + "scroll_down"; public static final String SCROLL_DOWN = GUI_KEY + "scroll_down";

View file

@ -1,31 +0,0 @@
package xyz.atnrch.nicko.profile;
public class AppearanceData {
private String name;
private String skin;
public AppearanceData(String name, String skin) {
this.name = name;
this.skin = skin;
}
public boolean isEmpty() {
return name == null && skin == null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSkin() {
return skin;
}
public void setSkin(String skin) {
this.skin = skin;
}
}

View file

@ -44,6 +44,10 @@ gui:
name: "Unavailable" name: "Unavailable"
lore: lore:
- "§7§oThis button is disabled." - "§7§oThis button is disabled."
error:
name: "Error!"
lore:
- "§7§oAn error occurred."
loading: loading:
name: "§7§oLoading..." name: "§7§oLoading..."
choice: choice: