Compare commits
2 commits
1a792112cc
...
63f2e7f699
Author | SHA1 | Date | |
---|---|---|---|
63f2e7f699 | |||
d30f433527 |
13 changed files with 202 additions and 15 deletions
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
|
@ -5,7 +5,6 @@
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="22" />
|
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -4,7 +4,7 @@
|
||||||
<component name="PWA">
|
<component name="PWA">
|
||||||
<option name="wasEnabledAtLeastOnce" value="true" />
|
<option name="wasEnabledAtLeastOnce" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="azul-17.0.10" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" project-jdk-name="graal-22" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,15 +1,6 @@
|
||||||
1.3.0-RC1: Update n°13 (XX/XX/25)
|
1.3.0-RC1: Update n°13 (XX/XX/25)
|
||||||
[FEATURES]
|
[FEATURES]
|
||||||
- Players are now able to mark disguises as favorites.
|
- Players are now able to mark disguises as favorites.
|
||||||
- Modernized the messages and added various sound effects upon interacting with the plugin.
|
|
||||||
- Made GUIs names cleaner.
|
|
||||||
|
|
||||||
[FIXES]
|
|
||||||
- Fixed an oversight preventing the configuration from properly being migrated.
|
|
||||||
- Fixed the placeholder item in the skin cache invalidation not being translated.
|
|
||||||
|
|
||||||
[LANGUAGE]
|
|
||||||
- Moved the prefix to the language file.
|
|
||||||
|
|
||||||
1.2.0-RC1: Update n°12 (XX/XX/25)
|
1.2.0-RC1: Update n°12 (XX/XX/25)
|
||||||
[FEATURES]
|
[FEATURES]
|
||||||
|
|
|
@ -29,7 +29,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT")
|
paperweight.paperDevBundle("1.21.5-R0.1-SNAPSHOT")
|
||||||
|
|
||||||
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")
|
||||||
|
@ -100,6 +100,6 @@ tasks {
|
||||||
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
|
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraftVersion("1.21.4")
|
minecraftVersion("1.21.5")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@ import xyz.ineanto.nicko.config.Configuration;
|
||||||
import xyz.ineanto.nicko.config.ConfigurationManager;
|
import xyz.ineanto.nicko.config.ConfigurationManager;
|
||||||
import xyz.ineanto.nicko.event.PlayerJoinListener;
|
import xyz.ineanto.nicko.event.PlayerJoinListener;
|
||||||
import xyz.ineanto.nicko.event.PlayerQuitListener;
|
import xyz.ineanto.nicko.event.PlayerQuitListener;
|
||||||
|
import xyz.ineanto.nicko.event.PromptCloseListener;
|
||||||
import xyz.ineanto.nicko.language.CustomLanguage;
|
import xyz.ineanto.nicko.language.CustomLanguage;
|
||||||
import xyz.ineanto.nicko.language.Language;
|
import xyz.ineanto.nicko.language.Language;
|
||||||
import xyz.ineanto.nicko.migration.ConfigurationMigrator;
|
import xyz.ineanto.nicko.migration.ConfigurationMigrator;
|
||||||
|
@ -111,6 +112,7 @@ 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);
|
||||||
|
getServer().getPluginManager().registerEvents(new PromptCloseListener(), this);
|
||||||
|
|
||||||
getLogger().info("Nicko has been enabled.");
|
getLogger().info("Nicko has been enabled.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package xyz.ineanto.nicko.event;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import xyz.ineanto.nicko.event.custom.PromptCloseEvent;
|
||||||
|
|
||||||
|
public class PromptCloseListener implements Listener {
|
||||||
|
@EventHandler
|
||||||
|
public void onPromptClose(PromptCloseEvent event) {
|
||||||
|
String playerName = event.getPlayer().getName();
|
||||||
|
String skin = event.getSkin().orElse("No skin selected");
|
||||||
|
String name = event.getName().orElse("No name selected");
|
||||||
|
|
||||||
|
System.out.println("Player " + playerName + " closed the prompt with skin: " + skin + " and name: " + name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package xyz.ineanto.nicko.event.custom;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class PromptCloseEvent extends Event implements Cancellable {
|
||||||
|
private static final HandlerList HANDLERS_LIST = new HandlerList();
|
||||||
|
|
||||||
|
private boolean isCancelled;
|
||||||
|
private final Player player;
|
||||||
|
private final String skin, name;
|
||||||
|
|
||||||
|
public PromptCloseEvent(Player player, String skin, String name) {
|
||||||
|
this.player = player;
|
||||||
|
this.skin = skin;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return isCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean isCancelled) {
|
||||||
|
this.isCancelled = isCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() { return HANDLERS_LIST; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers() {
|
||||||
|
return HANDLERS_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<String> getSkin() {
|
||||||
|
return Optional.ofNullable(skin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<String> getName() {
|
||||||
|
return Optional.ofNullable(name);
|
||||||
|
}
|
||||||
|
}
|
102
src/main/java/xyz/ineanto/nicko/gui/prompt/ChatPrompt.java
Normal file
102
src/main/java/xyz/ineanto/nicko/gui/prompt/ChatPrompt.java
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
package xyz.ineanto.nicko.gui.prompt;
|
||||||
|
|
||||||
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import xyz.ineanto.nicko.Nicko;
|
||||||
|
import xyz.ineanto.nicko.event.custom.PromptCloseEvent;
|
||||||
|
import xyz.ineanto.nicko.language.LanguageKey;
|
||||||
|
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ChatPrompt implements Prompt {
|
||||||
|
private final Player player;
|
||||||
|
private final PlayerLanguage playerLanguage;
|
||||||
|
|
||||||
|
private String name = null;
|
||||||
|
private String skin = null;
|
||||||
|
private final List<UUID> inPrompt = new ArrayList<>();
|
||||||
|
|
||||||
|
public ChatPrompt(Player player, PlayerLanguage playerLanguage) {
|
||||||
|
this.player = player;
|
||||||
|
this.playerLanguage = playerLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<String[]> displayNameThenSkinPrompt() {
|
||||||
|
promptInChat(false, false);
|
||||||
|
|
||||||
|
if (skin == null || name == null) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.of(new String[]{name, skin});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<String> displaySkinPrompt() {
|
||||||
|
promptInChat(true, true);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<String> displayNamePrompt() {
|
||||||
|
promptInChat(false, true);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void promptInChat(boolean isSkin, boolean last) {
|
||||||
|
// what the HELL did I wrote (Ineanto)
|
||||||
|
// TODO (Ineanto, 11/05/2025): Doesn't work, the event is registered multiple times and thus is breaking the logic.
|
||||||
|
if (!inPrompt.contains(player.getUniqueId())) {
|
||||||
|
Bukkit.broadcast(Component.text("WAS NOT IN"));
|
||||||
|
inPrompt.add(player.getUniqueId());
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(Nicko.getInstance(), () -> inPrompt.remove(player.getUniqueId()), 20 * 15L);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSkin) {
|
||||||
|
player.sendMessage(playerLanguage.translate(LanguageKey.Event.Appearance.Set.CHAT_PROMPT, true, "skin"));
|
||||||
|
} else {
|
||||||
|
player.sendMessage(playerLanguage.translate(LanguageKey.Event.Appearance.Set.CHAT_PROMPT, true, "name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Nicko.getInstance().getServer().getPluginManager().registerEvents(new Listener() {
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerChat(AsyncChatEvent event) {
|
||||||
|
if (!inPrompt.contains(event.getPlayer().getUniqueId())) {
|
||||||
|
Bukkit.broadcast(Component.text("IS NOT IN (chat)"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
final String plain = PlainTextComponentSerializer.plainText().serialize(event.originalMessage());
|
||||||
|
|
||||||
|
if (isSkin) {
|
||||||
|
skin = plain;
|
||||||
|
} else {
|
||||||
|
name = plain;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last) {
|
||||||
|
Bukkit.broadcast(Component.text("WAS LAST"));
|
||||||
|
inPrompt.remove(event.getPlayer().getUniqueId());
|
||||||
|
Bukkit.getScheduler().runTask(Nicko.getInstance(), () -> Bukkit
|
||||||
|
.getPluginManager()
|
||||||
|
.callEvent(new PromptCloseEvent(event.getPlayer(), skin, name))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Bukkit.broadcast(Component.text("PROMPTING FOR SKIN NOW"));
|
||||||
|
promptInChat(true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, Nicko.getInstance());
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,7 +27,7 @@ public class PromptManager {
|
||||||
final Optional<NickoProfile> optionalProfile = dataStore.getData(player.getUniqueId());
|
final Optional<NickoProfile> optionalProfile = dataStore.getData(player.getUniqueId());
|
||||||
this.profile = optionalProfile.orElse(NickoProfile.EMPTY_PROFILE.clone());
|
this.profile = optionalProfile.orElse(NickoProfile.EMPTY_PROFILE.clone());
|
||||||
this.appearanceManager = new AppearanceManager(player);
|
this.appearanceManager = new AppearanceManager(player);
|
||||||
this.prompt = new SignPrompt(player, playerLanguage);
|
this.prompt = new ChatPrompt(player, playerLanguage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayNameThenSkinPrompt() {
|
public void displayNameThenSkinPrompt() {
|
||||||
|
|
|
@ -13,8 +13,12 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
public class SignPrompt implements Prompt {
|
public class SignPrompt implements Prompt {
|
||||||
|
private final CompletableFuture<Void> future = new CompletableFuture<>();
|
||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final PlayerLanguage playerLanguage;
|
private final PlayerLanguage playerLanguage;
|
||||||
private final ArrayList<String> lines = new ArrayList<>(
|
private final ArrayList<String> lines = new ArrayList<>(
|
||||||
|
@ -51,6 +55,14 @@ public class SignPrompt implements Prompt {
|
||||||
this.lines.set(1, playerLanguage.translate(LanguageKey.GUI.NEW_SKIN, false));
|
this.lines.set(1, playerLanguage.translate(LanguageKey.GUI.NEW_SKIN, false));
|
||||||
displaySign(true);
|
displaySign(true);
|
||||||
|
|
||||||
|
synchronized (future) {
|
||||||
|
try {
|
||||||
|
future.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (skin == null) {
|
if (skin == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -63,6 +75,14 @@ public class SignPrompt implements Prompt {
|
||||||
this.lines.set(1, playerLanguage.translate(LanguageKey.GUI.NEW_NAME, false));
|
this.lines.set(1, playerLanguage.translate(LanguageKey.GUI.NEW_NAME, false));
|
||||||
displaySign(false);
|
displaySign(false);
|
||||||
|
|
||||||
|
synchronized (future) {
|
||||||
|
try {
|
||||||
|
future.get();
|
||||||
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -89,9 +109,11 @@ public class SignPrompt implements Prompt {
|
||||||
name = internalLine1;
|
name = internalLine1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
future.complete(null);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
gui.open(player);
|
gui.open(player);
|
||||||
} catch (SignGUIVersionException _) { }
|
} catch (SignGUIVersionException _) { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class LanguageKey {
|
||||||
|
|
||||||
public static final String OK = SET_KEY + "ok";
|
public static final String OK = SET_KEY + "ok";
|
||||||
public static final String ERROR = SET_KEY + "error";
|
public static final String ERROR = SET_KEY + "error";
|
||||||
|
|
||||||
|
public static final String CHAT_PROMPT = SET_KEY + "chat_prompt";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Remove {
|
public static class Remove {
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class NickoPluginLoader implements PluginLoader {
|
||||||
final MavenLibraryResolver resolver = new MavenLibraryResolver();
|
final MavenLibraryResolver resolver = new MavenLibraryResolver();
|
||||||
|
|
||||||
resolver.addRepository(new RemoteRepository.Builder("xenondevs", "default", "https://repo.xenondevs.xyz/releases/").build());
|
resolver.addRepository(new RemoteRepository.Builder("xenondevs", "default", "https://repo.xenondevs.xyz/releases/").build());
|
||||||
resolver.addDependency(new Dependency(new DefaultArtifact("xyz.xenondevs.invui:invui:pom:1.44"), null));
|
resolver.addDependency(new Dependency(new DefaultArtifact("xyz.xenondevs.invui:invui:pom:1.45"), null));
|
||||||
|
|
||||||
pluginClasspathBuilder.addLibrary(resolver);
|
pluginClasspathBuilder.addLibrary(resolver);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ event:
|
||||||
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>"
|
||||||
|
chat_prompt: "<gray>Please enter your new {0} in chat.</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>Previous disguise restored.</gray>"
|
ok: "<gray>Previous disguise restored.</gray>"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue