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,3 +1,7 @@
import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
import io.papermc.paperweight.util.path
import xyz.jpenilla.runtask.RunExtension
plugins { plugins {
id("java") id("java")
id("com.gradleup.shadow") version "8.3.2" id("com.gradleup.shadow") version "8.3.2"
@ -45,16 +49,17 @@ dependencies {
compileOnly("me.clip:placeholderapi:2.11.5") compileOnly("me.clip:placeholderapi:2.11.5")
compileOnly("net.kyori:adventure-api:4.17.0") compileOnly("net.kyori:adventure-api:4.17.0")
implementation("xyz.xenondevs.invui:invui:1.39") implementation("xyz.xenondevs.invui:invui-core:1.41")
implementation("net.wesjd:anvilgui:1.10.2-SNAPSHOT") implementation("xyz.xenondevs.invui:inventory-access-r21:1.41")
implementation("net.wesjd:anvilgui:1.10.3-SNAPSHOT")
implementation("com.github.jsixface:yamlconfig:1.2") implementation("com.github.jsixface:yamlconfig:1.2")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.1") implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.18.1")
implementation("com.fasterxml.jackson.core:jackson-core:2.18.1") implementation("com.fasterxml.jackson.core:jackson-core:2.18.1")
implementation("com.mysql:mysql-connector-j:8.2.0") implementation("com.mysql:mysql-connector-j:9.1.0")
implementation("org.mariadb.jdbc:mariadb-java-client:3.3.1") implementation("org.mariadb.jdbc:mariadb-java-client:3.5.0")
implementation("redis.clients:jedis:5.1.2") implementation("redis.clients:jedis:5.2.0")
implementation("com.google.code.gson:gson:2.10.1") implementation("com.google.code.gson:gson:2.10.1")
implementation("org.bstats:bstats-bukkit:3.0.2")
testImplementation("com.github.MockBukkit:MockBukkit:v3.133.2") testImplementation("com.github.MockBukkit:MockBukkit:v3.133.2")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2") testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.2")
@ -62,7 +67,12 @@ dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
} }
paperweight {
reobfArtifactConfiguration = ReobfArtifactConfiguration.REOBF_PRODUCTION
}
tasks { tasks {
processResources { processResources {
from("src/main/resources") from("src/main/resources")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
@ -72,12 +82,6 @@ tasks {
} }
shadowJar { shadowJar {
// NAMING
archiveBaseName.set("nicko")
archiveVersion.set(version.toString())
archiveAppendix.set("")
archiveClassifier.set("")
// RELOCATIONS // RELOCATIONS
relocate("xyz.xenondevs", "xyz.ineanto.nicko.libs.invui") relocate("xyz.xenondevs", "xyz.ineanto.nicko.libs.invui")
relocate("me.clip", "xyz.ineanto.nicko.libs.placeholderapi") relocate("me.clip", "xyz.ineanto.nicko.libs.placeholderapi")
@ -113,10 +117,30 @@ tasks {
exclude(dependency("net.wesjd:.*")) exclude(dependency("net.wesjd:.*"))
exclude(dependency("org.bstats:.*")) exclude(dependency("org.bstats:.*"))
} }
manifest {
attributes["paperweight-mappings-namespace"] = "spigot"
}
} }
runServer { runServer {
dependsOn(shadowJar) dependsOn(reobfJar)
/**
* https://github.com/jpenilla/run-task/issues/56
*
* jpenilla:
* "On 1.20.5+ it makes no sense to waste time obfuscating the jar in development
* just for it to be immediately deobfuscated.
* If you have an edge case setup where this makes sense somehow,
* you can disable plugin jar detection and configure the plugin jars collection yourself."
*
* Well, Nicko is an edge case.
* AnvilGUI and InvUI are still using Spigot Mappings,
* and I'm stuck using them until they push a major, breaking update.
*/
args("-add-plugin=${reobfJar.get().outputJar.path.toAbsolutePath()}")
downloadPlugins { downloadPlugins {
url("https://download.luckperms.net/1554/bukkit/loader/LuckPerms-Bukkit-5.4.139.jar") url("https://download.luckperms.net/1554/bukkit/loader/LuckPerms-Bukkit-5.4.139.jar")
@ -131,3 +155,7 @@ tasks {
minecraftVersion("1.21.3") minecraftVersion("1.21.3")
} }
} }
extensions.configure<RunExtension> {
disablePluginJarDetection()
}

View file

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

View file

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

View file

@ -8,9 +8,14 @@ import org.jetbrains.annotations.NotNull;
import xyz.ineanto.nicko.gui.CacheManagementGUI; import xyz.ineanto.nicko.gui.CacheManagementGUI;
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.xenondevs.invui.item.builder.AbstractItemBuilder;
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.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(PlayerLanguage playerLanguage) { public ManageCacheItem(PlayerLanguage playerLanguage) {
@ -19,7 +24,14 @@ public class ManageCacheItem extends AsyncItem {
return playerLanguage.translateItem(builder, LanguageKey.GUI.LOADING); return playerLanguage.translateItem(builder, LanguageKey.GUI.LOADING);
}, (click -> true)).getItemProvider(), }, (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); 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.anvil.AnvilManager;
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.xenondevs.invui.item.builder.AbstractItemBuilder;
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.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 PlayerLanguage playerLanguage; private final PlayerLanguage playerLanguage;
private final Player player;
public ChangeSkinItem(Player player) { public ChangeSkinItem(Player player) {
this.playerLanguage = new PlayerLanguage(player); this.playerLanguage = new PlayerLanguage(player);
this.player = player;
} }
public SuppliedItem get() { public SuppliedItem get() {
return new SuppliedItem(() -> { 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); return playerLanguage.translateItem(builder, LanguageKey.GUI.Home.CHANGE_SKIN);
}, click -> { }, click -> {
final ClickType clickType = click.getClickType(); final ClickType clickType = click.getClickType();

View file

@ -20,10 +20,10 @@ event:
appearance: appearance:
set: set:
error: "<gray>Wasn''t able to apply your disguise! ({0})</gray>" 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: restore:
error: "<gray>Wasn''t able to apply the previous disguise! ({0})</gray>" 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: remove:
error: "<gray>Wasn''t able to remove your disguise!.</gray>" error: "<gray>Wasn''t able to remove your disguise!.</gray>"
missing: "<gray>You''re not currently disguised.</gray>" missing: "<gray>You''re not currently disguised.</gray>"

View file

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