Compare commits
No commits in common. "5f327206173147ea9b0a7a855b3bda25fa288b9b" and "d7663ab463dabc4e7a53dcc9964bf8801ea19be5" have entirely different histories.
5f32720617
...
d7663ab463
5 changed files with 22 additions and 52 deletions
|
@ -12,7 +12,10 @@ https://www.spigotmc.org/resources/nicko.113868/
|
||||||
|
|
||||||
## Known bugs:
|
## Known bugs:
|
||||||
|
|
||||||
N/A
|
- Players who have operator (OP) status lose access to the Operator Items tab in creative mode
|
||||||
|
after disguising **(1.20 and up)**.
|
||||||
|
- When disguising and only changing their display name, players will have the new default
|
||||||
|
skins **(1.20 and up)**.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -22,5 +25,5 @@ N/A
|
||||||
|---------------|----------------------------------------------------------------------------|
|
|---------------|----------------------------------------------------------------------------|
|
||||||
| 1.7 and lower | Unsupported |
|
| 1.7 and lower | Unsupported |
|
||||||
| 1.8 - 1.12.2 | Use [NickReloaded](https://www.spigotmc.org/resources/nickreloaded.46335/) |
|
| 1.8 - 1.12.2 | Use [NickReloaded](https://www.spigotmc.org/resources/nickreloaded.46335/) |
|
||||||
| 1.13 to 1.19 | Use Nicko (without support) |
|
| 1.13 to 1.19 | Unsupported |
|
||||||
| 1.20 - 1.21 | Use Nicko (with support) |
|
| 1.20 - 1.21 | Use Nicko |
|
||||||
|
|
|
@ -5,7 +5,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.ineanto"
|
group = "xyz.ineanto"
|
||||||
version = "1.3.0"
|
version = "1.2.0"
|
||||||
|
|
||||||
val invuiVersion: String = "1.44"
|
val invuiVersion: String = "1.44"
|
||||||
|
|
||||||
|
|
|
@ -2,78 +2,45 @@ package xyz.ineanto.nicko.gui.items.favorites;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
|
||||||
import xyz.ineanto.nicko.Nicko;
|
import xyz.ineanto.nicko.Nicko;
|
||||||
import xyz.ineanto.nicko.appearance.ActionResult;
|
|
||||||
import xyz.ineanto.nicko.appearance.Appearance;
|
import xyz.ineanto.nicko.appearance.Appearance;
|
||||||
import xyz.ineanto.nicko.appearance.AppearanceManager;
|
import xyz.ineanto.nicko.appearance.AppearanceManager;
|
||||||
import xyz.ineanto.nicko.gui.items.ItemDefaults;
|
import xyz.ineanto.nicko.gui.items.ItemDefaults;
|
||||||
import xyz.ineanto.nicko.language.LanguageKey;
|
import xyz.ineanto.nicko.language.LanguageKey;
|
||||||
import xyz.ineanto.nicko.language.PlayerLanguage;
|
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||||
import xyz.ineanto.nicko.profile.NickoProfile;
|
|
||||||
import xyz.ineanto.nicko.storage.PlayerDataStore;
|
|
||||||
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.item.impl.SuppliedItem;
|
import xyz.xenondevs.invui.util.MojangApiUtils;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class FavoriteAppearanceEntryItem {
|
public class FavoriteAppearanceEntryItem {
|
||||||
private final PlayerDataStore dataStore = Nicko.getInstance().getDataStore();
|
|
||||||
|
|
||||||
private final AppearanceManager appearanceManager;
|
private final AppearanceManager appearanceManager;
|
||||||
private final PlayerLanguage playerLanguage;
|
private final PlayerLanguage playerLanguage;
|
||||||
private final Appearance appearance;
|
private final Appearance appearance;
|
||||||
private final Player player;
|
|
||||||
|
|
||||||
public FavoriteAppearanceEntryItem(Player player, Appearance appearance) {
|
public FavoriteAppearanceEntryItem(Player player, Appearance appearance) {
|
||||||
this.player = player;
|
|
||||||
this.appearanceManager = new AppearanceManager(player);
|
this.appearanceManager = new AppearanceManager(player);
|
||||||
this.playerLanguage = new PlayerLanguage(player);
|
this.playerLanguage = new PlayerLanguage(player);
|
||||||
this.appearance = appearance;
|
this.appearance = appearance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AsyncItem get() {
|
public AsyncItem get() {
|
||||||
// what the f is this entanglement of suppliers
|
// TODO (Ineanto, 26/06/2025): handle click
|
||||||
return new AsyncItem(playerLanguage.translateItem(new ItemBuilder(Material.PAINTING), LanguageKey.GUI.LOADING),
|
final ItemBuilder temporaryItemBuilder = new ItemBuilder(Material.PAINTING);
|
||||||
() -> new SuppliedItem(() -> {
|
return new AsyncItem(playerLanguage.translateItem(temporaryItemBuilder, LanguageKey.GUI.LOADING),
|
||||||
|
() -> {
|
||||||
try {
|
try {
|
||||||
// TODO (Ineanto, 08/06/2025): set a default skin if the entry contains only a name
|
// TODO (Ineanto, 08/06/2025): set a default skin if the entry contains only a name
|
||||||
final String name = (appearance.name() == null ? "N/A" : appearance.name());
|
final String name = (appearance.name() == null ? "N/A" : appearance.name());
|
||||||
final String skin = (appearance.skin() == null ? "N/A" : appearance.skin());
|
final String skin = (appearance.skin() == null ? "N/A" : appearance.skin());
|
||||||
final SkullBuilder skull = new SkullBuilder(skin);
|
final SkullBuilder skull = new SkullBuilder(skin);
|
||||||
return playerLanguage.translateItem(skull, LanguageKey.GUI.Favorites.ENTRY, name, skin);
|
return playerLanguage.translateItem(skull, LanguageKey.GUI.Favorites.ENTRY, name, skin);
|
||||||
} catch (Exception e) {
|
} catch (MojangApiUtils.MojangApiException | IOException e) {
|
||||||
Nicko.getInstance().getLogger().warning("Unable to get Head texture for specified UUID (" + appearance.skin() + ")! (GUI/Favorites/Entry)");
|
Nicko.getInstance().getLogger().warning("Unable to get Head texture for specified UUID (" + appearance.skin() + ")! (GUI/Favorites/Entry)");
|
||||||
return ItemDefaults.getErrorSkullItem(playerLanguage, LanguageKey.GUI.Favorites.ENTRY, "N/A", "N/A");
|
return ItemDefaults.getErrorSkullItem(playerLanguage, LanguageKey.GUI.Favorites.ENTRY, "N/A", "N/A");
|
||||||
}
|
}
|
||||||
}, (click) -> {
|
});
|
||||||
System.out.println("there's a click folks!");
|
|
||||||
final ClickType clickType = click.getClickType();
|
|
||||||
|
|
||||||
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
|
||||||
click.getEvent().getView().close();
|
|
||||||
final NickoProfile profile = dataStore.getData(player.getUniqueId()).orElse(NickoProfile.EMPTY_PROFILE);
|
|
||||||
|
|
||||||
profile.setName(appearance.name());
|
|
||||||
profile.setSkin(appearance.skin());
|
|
||||||
dataStore.updateCache(player.getUniqueId(), profile);
|
|
||||||
|
|
||||||
final ActionResult result = appearanceManager.update(true);
|
|
||||||
if (!result.isError()) {
|
|
||||||
player.sendMessage(playerLanguage.translateWithWhoosh(LanguageKey.Event.Appearance.Set.OK));
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
player.sendMessage(playerLanguage.translateWithOops(
|
|
||||||
LanguageKey.Event.Appearance.Set.ERROR,
|
|
||||||
result.getErrorKey()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
appearanceManager.reset();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}).getItemProvider()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ gui:
|
||||||
- "<grey>Clicking on any disguise as this mode is</grey>"
|
- "<grey>Clicking on any disguise as this mode is</grey>"
|
||||||
- "<grey>active will remove it from your favorites.</grey>"
|
- "<grey>active will remove it from your favorites.</grey>"
|
||||||
entry:
|
entry:
|
||||||
name: "<gold>Favorite</gold>"
|
name: "Favorite"
|
||||||
lore:
|
lore:
|
||||||
- "<gray>Name:</gray> <yellow>{0}</yellow>"
|
- "<gray>Name:</gray> <green>{0}</green>"
|
||||||
- "<gray>Skin:</gray> <yellow>{1}</yellow>"
|
- "<gray>Skin:</gray> <green>{1}</green>"
|
|
@ -171,7 +171,7 @@ gui:
|
||||||
- "<grey>Cliquer sur un déguisement lorsque le mode est</grey>"
|
- "<grey>Cliquer sur un déguisement lorsque le mode est</grey>"
|
||||||
- "<grey>actif le supprimera de vos favoris.</grey>"
|
- "<grey>actif le supprimera de vos favoris.</grey>"
|
||||||
entry:
|
entry:
|
||||||
name: "<gold>Favori</gold>"
|
name: "Favori"
|
||||||
lore:
|
lore:
|
||||||
- "<gray>Nom:</gray> <yellow>{0}</yellow>"
|
- "<gray>Nom:</gray> <green>{0}</green>"
|
||||||
- "<gray>Skin:</gray> <yellow>{1}</yellow>"
|
- "<gray>Skin:</gray> <green>{1}</green>"
|
Loading…
Add table
Add a link
Reference in a new issue