๐
pasted-code-1767467263351.txt
txt
3 lines
โถ
OutplayNPC is a visual enhancement plugin designed for Minecraft 1.21-1.21.10 lobby servers using the Paper platform. Its primary purpose is to add interactivity to specific NPCs created by the FancyNPCs plugin. When a player aligns their crosshair precisely with a configured NPC, the plugin smoothly scales the NPC to a larger size and generates a random cloud of DUST particles with a configurable HEX color around it. This creates an engaging and responsive environment for players navigating the lobby, highlighting specific quest givers or important characters based on server configuration.
The target audience includes server owners and lobby designers who wish to improve the user experience through visual feedback without requiring complex resource packs or client-side mods. The plugin is lightweight, relying on the Paper API for entity manipulation and particle effects. It integrates seamlessly with existing FancyNPCs setups by targeting specific NPC IDs. Configuration options allow server administrators to define a maximum trigger distance, specific HEX colors for individual NPCs, and specific scale multipliers for each NPC to create visual variety.
Iโll create the OutplayNPC plugin for visual NPC enhancements with FancyNPCs integration.
Implementation Plan:
Core plugin class with FancyNPCs integration
Raytrace system to detect player crosshair alignment with NPCs
Smooth NPC scaling with configurable multipliers
DUST particle cloud generation with HEX color support
Per-NPC configuration (ID, color, scale, distance)
Async task to check player lookups efficiently
Plugin created successfully! OutplayNPC features:
โ
Raytrace-based NPC detection - Precise crosshair alignment with NPCs
โ
Smooth scaling effects - Configurable per-NPC multipliers
โ
Random DUST particle clouds - HEX color customization per NPC
โ
Efficient multi-player support - Tracks individual player lookups
โ
Automatic cleanup - Removes effects when players look away
โ
FancyNPCs integration - Uses NPC IDs from FancyNPCs plugin
Configuration allows you to set different colors, scales, and distances for each NPC. The detection system runs every 2 ticks (configurable) and handles multiple players looking at different NPCs simultaneously.
The compilation failed with this error:
Validation failed for compilation: Compilation failed with 33 error(s):
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 36: cannot find symbol
UUID npcUuid = npc.getData().getUniqueId();
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 53: cannot find symbol
UUID npcUuid = npc.getData().getUniqueId();
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 63: incompatible types: Vector3f cannot be converted to float
npc.getData().setScale(new Vector3f((float) multiplier, (float) multiplier, (float) multiplier));
^
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 68: incompatible types: Vector3f cannot be converted to float
npc.getData().setScale(new Vector3f(1.0f, 1.0f, 1.0f));
^
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 93: cannot find symbol
.withData(dustOptions)
^
symbol: method withData(DustOptions)
location: class XParticle
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 44: cannot find symbol
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().getNpc(settings.getNpcId());
^
symbol: method getNpc(String)
location: interface Function<NpcData,Npc>
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 46: cannot find symbol
if (npc == null || !npc.getData().isEnabled()) {
^
symbol: method isEnabled()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 51: cannot find symbol
lookingAtNPCs.add(npc.getData().getUniqueId());
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 69: cannot find symbol
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().getNpc(settings.getNpcId());
^
symbol: method getNpc(String)
location: interface Function<NpcData,Npc>
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 130: cannot find symbol
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().getNpc(settings.getNpcId());
^
symbol: method getNpc(String)
location: interface Function<NpcData,Npc>
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 131: cannot find symbol
if (npc != null && npc.getData().getUniqueId().equals(npcUuid)) {
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 63: incompatible types: Vector3f cannot be converted to float
npc.getData().setScale(new Vector3f((float) multiplier, (float) multiplier, (float) multiplier));
^
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 68: incompatible types: Vector3f cannot be converted to float
npc.getData().setScale(new Vector3f(1.0f, 1.0f, 1.0f));
^
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 36: cannot find symbol
UUID npcUuid = npc.getData().getUniqueId();
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 53: cannot find symbol
UUID npcUuid = npc.getData().getUniqueId();
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 93: cannot find symbol
.withData(dustOptions)
^
symbol: method withData(DustOptions)
location: class XParticle
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 44: cannot find symbol
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().getNpc(settings.getNpcId());
^
symbol: method getNpc(String)
location: interface Function<NpcData,Npc>
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 46: cannot find symbol
if (npc == null || !npc.getData().isEnabled()) {
^
symbol: method isEnabled()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 51: cannot find symbol
lookingAtNPCs.add(npc.getData().getUniqueId());
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 69: cannot find symbol
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().getNpc(settings.getNpcId());
^
symbol: method getNpc(String)
location: interface Function<NpcData,Npc>
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 130: cannot find symbol
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().getNpc(settings.getNpcId());
^
symbol: method getNpc(String)
location: interface Function<NpcData,Npc>
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 131: cannot find symbol
if (npc != null && npc.getData().getUniqueId().equals(npcUuid)) {
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 63: incompatible types: Vector3f cannot be converted to float
npc.getData().setScale(new Vector3f((float) multiplier, (float) multiplier, (float) multiplier));
^
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 68: incompatible types: Vector3f cannot be converted to float
npc.getData().setScale(new Vector3f(1.0f, 1.0f, 1.0f));
^
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 36: cannot find symbol
UUID npcUuid = npc.getData().getUniqueId();
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 53: cannot find symbol
UUID npcUuid = npc.getData().getUniqueId();
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/manager/NPCEffectManager.java at line 93: cannot find symbol
.withData(dustOptions)
^
symbol: method withData(DustOptions)
location: class XParticle
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 44: cannot find symbol
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().getNpc(settings.getNpcId());
^
symbol: method getNpc(String)
location: interface Function<NpcData,Npc>
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 46: cannot find symbol
if (npc == null || !npc.getData().isEnabled()) {
^
symbol: method isEnabled()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 51: cannot find symbol
lookingAtNPCs.add(npc.getData().getUniqueId());
^
symbol: method getUniqueId()
location: class NpcData
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 69: cannot find symbol
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().getNpc(settings.getNpcId());
^
symbol: method getNpc(String)
location: interface Function<NpcData,Npc>
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 130: cannot find symbol
Npc npc = FancyNpcsPlugin.get().getNpcAdapter().getNpc(settings.getNpcId());
^
symbol: method getNpc(String)
location: interface Function<NpcData,Npc>
ERROR in src/main/java/com/outplay/npc/task/LookDetectionTask.java at line 131: cannot find symbol
if (npc != null && npc.getData().getUniqueId().equals(npcUuid)) {
^
symbol: method getUniqueId()
location: class NpcData
=== COMPILATION ERROR ANALYSIS ===
MISSING METHODS:
- getUniqueId()
- withData(DustOptions)
- getNpc(String)
- isEnabled()
ACTION: Check method names and signatures
TYPE MISMATCHES:
- incompatible types: Vector3f cannot be converted to float
- incompatible types: Vector3f cannot be converted to float
- incompatible types: Vector3f cannot be converted to float
- incompatible types: Vector3f cannot be converted to float
- incompatible types: Vector3f cannot be converted to float
- incompatible types: Vector3f cannot be converted to float
ACTION: Fix variable types or casting
FILES TO INVESTIGATE:
- src/main/java/com/outplay/npc/manager/NPCEffectManager.java
- src/main/java/com/outplay/npc/task/LookDetectionTask.java
- src/main/java/com/outplay/npc/manager/NPCEffectManager.java
- src/main/java/com/outplay/npc/task/LookDetectionTask.java
exceeds maximum
Please fix this error by creating a new artifact with the corrected code.
I need to read the failing files and the FancyNPCs API documentation to understand the correct method signatures.
Now I can see the issues clearly from the FancyNPCs API documentation:
NpcDatadoesnโt havegetUniqueId()- NPCs are identified by their ID (String)NpcData.setScale()takes afloat, notVector3fgetNpcAdapter()returnsFunction<NpcData, Npc>, not a manager - need to usegetNpcManager().getNpc(String)NpcDatadoesnโt haveisEnabled()- need to checkisSpawnEntity()XParticle doesnโt have
withData()- need to use different approach for dust particles
Let me fix these issues:
Fixed all compilation errors:
Changed NPC identification from UUID to String (using
getId()instead of non-existentgetUniqueId())Fixed
setScale()to acceptfloatinstead ofVector3fChanged
getNpcAdapter().getNpc()togetNpcManager().getNpc()Replaced
isEnabled()withisSpawnEntity()Removed XParticleโs non-existent
withData()method and used directplayer.spawnParticle()instead
Make it so that its smooth and when im not looking anymore it returns back to its original size and when im looking at it the particles spawn repeatedly
Iโll read the relevant files to understand the current implementation and then make it smooth with gradual scaling and repeated particle spawning.
Iโll make the scaling smooth with gradual transitions and ensure particles spawn repeatedly while looking at the NPC, then smoothly return to original size when not looking.
Done! The plugin now features:
Smooth scaling: NPCs gradually grow when looked at and smoothly shrink back to original size when not looking (controlled by
scale-speed: 0.05)Repeated particles: Particles spawn continuously while looking at the NPC (every
particle-interval-ticks: 10ticks)Gradual transitions: The animation task runs every tick to smoothly interpolate the scale
Automatic cleanup: When you stop looking, the NPC smoothly returns to scale 1.0
Adjust scale-speed for faster/slower transitions (higher = faster) and particle-interval-ticks for more/less frequent particle spawns.
add reload command when i add new npcs
Iโll add a reload command to reload NPCs when you add new ones to the config.
Now Iโll create a reload command that reloads the config and restarts the NPC effects:
Added reload command! Use /outplaynpc reload or /onpc reload to reload the config when you add new NPCs. Requires outplaynpc.reload permission.
it gets smaller when i move closer to it and i dont like that it doesnt turn bigger when im close to it and it only scales when i look at its legs, fix these
Iโll read the relevant files to understand the scaling behavior and fix these issues.
I found the issues:
Gets smaller when moving closer - The scale is inversely proportional to distance (closer = smaller)
Doesnโt turn bigger when close - The target scale is fixed, not distance-based
Only scales when looking at legs - The raycast is checking the NPCโs base location instead of the full hitbox
Fixes:
Remove distance-based scaling entirely (use fixed scale when looking)
Improve raycast to detect the entire NPC body (head to feet)
Add proper hitbox detection
Fixed all three issues:
Removed distance-based scaling - NPC now grows to configured scale when looked at, regardless of distance
Fixed hitbox detection - Created proper bounding box (0.8 blocks wide, 2 blocks tall) covering entire NPC body
Improved raycast - Now detects looking at any part of NPC (head, body, legs) instead of just the base location
the problem is when the npc gets bigger, the plugin doesnt count with it, so when im looking at the already bigger npc and i look at its head it gets smaller and its not satisfying
I need to read the code to understand how the looking detection works and why it doesnโt account for the scaled NPC size.
I found the issue! In LookDetectionTask.java, the bounding box for raytrace detection is hardcoded to a fixed size (lines 95-101). When the NPC scales up, the hitbox doesnโt scale with it, so you need to look at the original smaller hitbox position to trigger the effect.
The fix is to scale the bounding box based on the NPCโs current scale from the effect state.
The bounding box now scales dynamically with the NPCโs current scale. When the NPC is at 1.3x size, the hitbox is also 1.3x larger, so looking at the scaled NPCโs head will properly detect it.
make an option to each npc when looking at it to create a subtitle that is shown when looking at it and when you click from whatever distance the click action gets triggered
Iโll add subtitle display when looking at NPCs and click action triggering from any distance.
Let me first read the existing files to understand the structure:
Now Iโll implement subtitle display when looking at NPCs and click action triggering from any distance:
Add subtitle configuration to NPCSettings
Add click action configuration to NPCSettings
Create click listener for NPCs
Update LookDetectionTask to show/hide subtitles
Update config to include subtitle and click action options
Implementation complete! Added:
Subtitle display - Shows when looking at NPC, hides when looking away
Click actions - Triggers from any distance with three action types:
[console]- Executes as console[player]- Executes as player[message]- Sends colored messageDefault (no prefix) - Executes as console
%player% placeholder - Replaced with player name in all actions
make an action for moving the player to another server
Iโll add a server transfer action for moving players to another server via BungeeCord/Velocity. Let me first read the relevant files to understand the current action system.
Now Iโll add the server transfer action to the NPCClickListener. This will support both BungeeCord and Velocity proxy systems.
Done! Iโve added the [server] action that transfers players to another server via BungeeCord/Velocity proxy.
Usage:
click-actions:
- "[server] lobby"
- "[server] survival"
- "[server] minigames"
The action works on both BungeeCord and Velocity networks using the standard plugin messaging channel. The server name must match the exact name configured in your proxyโs config.
The scale feature doesnt work, default scale is always returned to 1 and its pretty not intuitive with the naming in the yml file
Iโll read the relevant files to identify the scale bug and improve the naming.
Found the bug! In NPCEffectState, the currentScale is initialized to 1.0f but it doesnโt check the NPCโs actual current scale. When the plugin reloads or an NPC is first detected, it always starts from 1.0 even if the NPC already has a different scale set.
Also, the naming is confusing:
scale-multipliershould bescale-when-lookingortarget-scaledefault-scale-multiplieris unclear
Fixing both issues:
Fixed both issues:
Bug Fix: NPCEffectState now initializes currentScale from the NPCโs actual current scale (npc.getData().getScale()) instead of hardcoding 1.0
Improved Naming:
scale-multiplierโscale-when-looking(clearer purpose)default-scale-multiplierโdefault-scale-when-looking(consistent naming)scale-speedโscale-animation-speed(more descriptive)
now repair the reload option
Iโll check the reload command and related files to identify and fix the issue.
The reload command needs to restart the detection task with potentially new settings. Currently it only reloads config and cleans up effects, but doesnโt restart the detection task with new intervals.
Fixed the reload functionality:
Added
reload()method to OutplayNPC that properly restarts all systemsCancels detection task, cleans up effects, reloads config, recreates effect manager, and restarts detection task with new settings
Added color code translation to reload command messages
Extracted detection task startup to separate method for reuse
package com.outplay.npc;
import com.outplay.npc.command.ReloadCommand;
import com.outplay.npc.config.NPCConfig;
import com.outplay.npc.listener.NPCClickListener;
import com.outplay.npc.manager.NPCEffectManager;
import com.outplay.npc.task.LookDetectionTask;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class OutplayNPC extends JavaPlugin {
private NPCConfig npcConfig;
private NPCEffectManager effectManager;
private LookDetectionTask detectionTask;
@Override
public void onEnable() {
saveDefaultConfig();
if (!Bukkit.getPluginManager().isPluginEnabled("FancyNpcs")) {
getLogger().severe("FancyNpcs plugin not found! Disabling...");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
this.npcConfig = new NPCConfig(this);
this.effectManager = new NPCEffectManager(this);
startDetectionTask();
getServer().getPluginManager().registerEvents(new NPCClickListener(this), this);
getCommand("outplaynpc").setExecutor(new ReloadCommand(this));
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
getLogger().info("OutplayNPC enabled successfully!");
}
@Override
public void onDisable() {
if (this.detectionTask != null) {
this.detectionTask.cancel();
}
if (this.effectManager != null) {
this.effectManager.cleanupAll();
}
getServer().getMessenger().unregisterOutgoingPluginChannel(this, "BungeeCord");
getLogger().info("OutplayNPC disabled successfully!");
}
private void startDetectionTask() {
int checkInterval = getConfig().getInt("settings.check-interval-ticks", 2);
this.detectionTask = new LookDetectionTask(this, effectManager, npcConfig);
this.detectionTask.runTaskTimer(this, 0L, checkInterval);
}
public void reload() {
if (this.detectionTask != null) {
this.detectionTask.cancel();
}
this.effectManager.cleanupAll();
reloadConfig();
this.npcConfig.reload();
this.effectManager = new NPCEffectManager(this);
startDetectionTask();
}
public NPCConfig getNpcConfig() {
return this.npcConfig;
}
public NPCEffectManager getEffectManager() {
return this.effectManager;
}
}