feat: removed Metrics, updated loc files, enabled skulls again in GUI

This commit is contained in:
ineanto 2024-11-16 18:10:57 +01:00
parent 3440f1fad1
commit a1919caa2a
Signed by: ineanto
GPG key ID: E511F9CAA2F9CE84
7 changed files with 79 additions and 28 deletions

View file

@ -1,7 +1,6 @@
package xyz.ineanto.nicko;
import com.comphenix.protocol.utility.MinecraftVersion;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.PluginCommand;
@ -40,7 +39,6 @@ public class Nicko extends JavaPlugin {
private CustomLanguage customLanguage;
private PlayerNameStore nameStore;
private RandomNameFetcher nameFetcher;
private Metrics metrics;
public Nicko() {
this.unitTesting = false;
@ -66,7 +64,7 @@ public class Nicko extends JavaPlugin {
if (!MinecraftVersion.TRAILS_AND_TAILS.atOrAbove()) {
getLogger().severe("This version (" + MinecraftVersion.getCurrentVersion().getVersion() + ") is not supported by Nicko!");
getLogger().severe("As of version 1.2.0, Nicko only supports the latest Minecraft versions. (Currently 1.21.3)");
getLogger().severe("As of version 1.2.0, Nicko only supports the latest Minecraft version. (Currently 1.21.3)");
dataStore.getStorage().setError(true);
Bukkit.getPluginManager().disablePlugin(this);
}
@ -131,7 +129,6 @@ public class Nicko extends JavaPlugin {
getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);
getServer().getPluginManager().registerEvents(new PlayerQuitListener(), this);
metrics = new Metrics(this, 20483);
}
getLogger().info("Nicko has been enabled.");
@ -150,7 +147,6 @@ public class Nicko extends JavaPlugin {
if (!unitTesting) {
nameStore.clearStoredNames();
metrics.shutdown();
}
getLogger().info("Nicko (Bukkit) has been disabled.");
}

View file

@ -27,16 +27,17 @@ public class AppearanceManager {
public ActionResult reset() {
final NickoProfile profile = getNickoProfile();
final String defaultName = nameStore.getStoredName(player);
profile.setName(defaultName);
profile.setSkin(defaultName);
dataStore.getCache().cache(player.getUniqueId(), profile);
final ActionResult result = update(true, true);
if (!result.isError()) {
profile.setName(null);
profile.setSkin(null);
dataStore.getCache().cache(player.getUniqueId(), profile);
}
profile.setName(null);
profile.setSkin(null);
dataStore.getCache().cache(player.getUniqueId(), profile);
return result;
}

View file

@ -8,9 +8,14 @@ import org.jetbrains.annotations.NotNull;
import xyz.ineanto.nicko.gui.CacheManagementGUI;
import xyz.ineanto.nicko.language.LanguageKey;
import xyz.ineanto.nicko.language.PlayerLanguage;
import xyz.xenondevs.invui.item.builder.AbstractItemBuilder;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.builder.SkullBuilder;
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 ManageCacheItem extends AsyncItem {
public ManageCacheItem(PlayerLanguage playerLanguage) {
@ -19,7 +24,14 @@ public class ManageCacheItem extends AsyncItem {
return playerLanguage.translateItem(builder, LanguageKey.GUI.LOADING);
}, (click -> true)).getItemProvider(),
() -> {
final ItemBuilder builder = new ItemBuilder(Material.PLAYER_HEAD);
AbstractItemBuilder<?> builder;
try {
builder = new SkullBuilder("Notch");
} catch (MojangApiUtils.MojangApiException | IOException e) {
builder = new ItemBuilder(Material.PLAYER_HEAD);
}
return playerLanguage.translateItem(builder, LanguageKey.GUI.Admin.MANAGE_CACHE);
});
}

View file

@ -6,19 +6,33 @@ import org.bukkit.event.inventory.ClickType;
import xyz.ineanto.nicko.anvil.AnvilManager;
import xyz.ineanto.nicko.language.LanguageKey;
import xyz.ineanto.nicko.language.PlayerLanguage;
import xyz.xenondevs.invui.item.builder.AbstractItemBuilder;
import xyz.xenondevs.invui.item.builder.ItemBuilder;
import xyz.xenondevs.invui.item.builder.SkullBuilder;
import xyz.xenondevs.invui.item.impl.SuppliedItem;
import xyz.xenondevs.invui.util.MojangApiUtils;
import java.io.IOException;
public class ChangeSkinItem {
private final PlayerLanguage playerLanguage;
private final Player player;
public ChangeSkinItem(Player player) {
this.playerLanguage = new PlayerLanguage(player);
this.player = player;
}
public SuppliedItem get() {
return new SuppliedItem(() -> {
final ItemBuilder builder = new ItemBuilder(Material.PLAYER_HEAD);
AbstractItemBuilder<?> builder;
try {
builder = new SkullBuilder(player.getName());
} catch (MojangApiUtils.MojangApiException | IOException e) {
builder = new ItemBuilder(Material.PLAYER_HEAD);
}
return playerLanguage.translateItem(builder, LanguageKey.GUI.Home.CHANGE_SKIN);
}, click -> {
final ClickType clickType = click.getClickType();

View file

@ -20,10 +20,10 @@ event:
appearance:
set:
error: "<gray>Wasn''t able to apply your disguise! ({0})</gray>"
ok: "<gray>You're now disguised.</gray>"
ok: "<gray>You''re now disguised.</gray>"
restore:
error: "<gray>Wasn''t able to apply the previous disguise! ({0})</gray>"
ok: "<gray>Disguise restored from last time.</gray>"
ok: "<gray>Previous disguise restored.</gray>"
remove:
error: "<gray>Wasn''t able to remove your disguise!.</gray>"
missing: "<gray>You''re not currently disguised.</gray>"

View file

@ -3,7 +3,7 @@ main: xyz.ineanto.nicko.Nicko
version: ${version}
author: Ineanto
description: "The feature packed, next generation disguise plugin for Minecraft."
api-version: 1.20
api-version: 1.21
softdepend: [ PlaceholderAPI ]
depend:
- ProtocolLib