More Core Class Conversion

This commit is contained in:
Kam committed 2026-03-13 16:59:00 -04:00
1 parent 27a9e4c808
commit 79b63efa19
36 files changed
+420 -102

No files matched your search

@@ -1,9 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
public enum AbilityPhase {
IDLE, // Not executing
WINDUP, // Charging up (telegraph visible)
ACTIVE, // Executing (damage happens)
DAZED, // Stunned after interrupt during WINDUP (cannot attack)
BURST_DELAY // Waiting between burst repetitions (free movement/rotation)
}
@@ -1,71 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines anchor points for ability charging effects.
* Determines where the charging visual (orb, disc, etc.) appears relative to the entity.
*/
public enum AnchorPoint {
FRONT("Front"), // In front of entity face (default)
CENTER("Center"), // Entity center
RIGHT_HAND("Right Hand"), // Right arm/hand position
LEFT_HAND("Left Hand"), // Left arm/hand position
ABOVE_HEAD("Above Head"), // Above the entity
CHEST("Chest"), // Chest level, centered
EYE("Eye"); // Eye level, centered
private final String displayName;
AnchorPoint(String displayName) {
this.displayName = displayName;
}
public String getDisplayName() {
return displayName;
}
/**
* Get AnchorPoint from ordinal value.
* Returns FRONT if ordinal is out of bounds.
*/
public static AnchorPoint fromOrdinal(int ordinal) {
AnchorPoint[] vals = values();
if (ordinal < 0 || ordinal >= vals.length) {
return FRONT;
}
return vals[ordinal];
}
/**
* Get all display names for GUI dropdowns.
*/
public static String[] getDisplayNames() {
AnchorPoint[] values = values();
String[] names = new String[values.length];
for (int i = 0; i < values.length; i++) {
names[i] = values[i].displayName;
}
return names;
}
@Override
public String toString() {
switch (this) {
case FRONT:
return "ability.anchor.front";
case CENTER:
return "ability.anchor.center";
case RIGHT_HAND:
return "ability.anchor.rightHand";
case LEFT_HAND:
return "ability.anchor.leftHand";
case ABOVE_HEAD:
return "ability.anchor.aboveHead";
case CHEST:
return "ability.anchor.chest";
case EYE:
return "ability.anchor.eye";
default:
return name();
}
}
}
@@ -1,32 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Shared hit behavior for energy projectiles.
*/
public enum HitType {
SINGLE,
PIERCE,
MULTI;
public static HitType fromOrdinal(int ordinal) {
HitType[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return SINGLE;
}
@Override
public String toString() {
switch (this) {
case SINGLE:
return "ability.hitType.single";
case PIERCE:
return "ability.hitType.pierce";
case MULTI:
return "ability.hitType.multi";
default:
return name();
}
}
}
@@ -1,66 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines when a caster is invulnerable while an ability is executing.
*/
public enum InvulnerableMode {
NONE,
WINDUP,
ACTIVE,
BOTH;
public boolean invulnerableDuringWindup() {
return this == WINDUP || this == BOTH;
}
public boolean invulnerableDuringActive() {
return this == ACTIVE || this == BOTH;
}
/**
* Treat BURST_DELAY as windup-like for interruption/damage immunity checks.
*/
public boolean isInvulnerableInPhase(AbilityPhase phase) {
if (phase == null) return false;
switch (phase) {
case WINDUP:
case BURST_DELAY:
return invulnerableDuringWindup();
case ACTIVE:
return invulnerableDuringActive();
default:
return false;
}
}
public String getDisplayKey() {
switch (this) {
case WINDUP:
return "ability.invulnerable.windup";
case ACTIVE:
return "ability.invulnerable.active";
case BOTH:
return "ability.invulnerable.both";
case NONE:
default:
return "ability.invulnerable.none";
}
}
public static String[] getDisplayKeys() {
return new String[]{
"ability.invulnerable.none",
"ability.invulnerable.windup",
"ability.invulnerable.active",
"ability.invulnerable.both"
};
}
public static InvulnerableMode fromOrdinal(int ordinal) {
InvulnerableMode[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return NONE;
}
}
@@ -1,83 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines when an ability locks NPC movement and rotation.
*/
public enum LockMode {
/**
* No movement lock - NPC can move freely during both phases.
*/
NO,
/**
* Lock movement during WINDUP phase only.
* NPC can move during ACTIVE phase.
*/
WINDUP,
/**
* Lock movement during ACTIVE phase only.
* NPC can move during WINDUP phase.
*/
ACTIVE,
/**
* Lock movement during both WINDUP and ACTIVE phases.
*/
WINDUP_AND_ACTIVE;
/**
* Check if movement should be locked during WINDUP phase.
*/
public boolean locksWindup() {
return this == WINDUP || this == WINDUP_AND_ACTIVE;
}
/**
* Check if movement should be locked during ACTIVE phase.
*/
public boolean locksActive() {
return this == ACTIVE || this == WINDUP_AND_ACTIVE;
}
/**
* Get display name for GUI.
*/
public String getDisplayKey() {
switch (this) {
case NO:
return "gui.no";
case WINDUP:
return "ability.lockMove.windup";
case ACTIVE:
return "ability.lockMove.active";
case WINDUP_AND_ACTIVE:
return "ability.lockMove.both";
default:
return "gui.no";
}
}
/**
* Get all display keys for GUI dropdown.
*/
public static String[] getDisplayKeys() {
return new String[]{
"gui.no",
"ability.lockMove.windup",
"ability.lockMove.active",
"ability.lockMove.both"
};
}
/**
* Get LockMode from ordinal, with fallback to WINDUP.
*/
public static LockMode fromOrdinal(int ordinal) {
LockMode[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return WINDUP;
}
}
@@ -1,53 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines what happens to NPC rotation during ability phases.
* Used with a LockMode to control WHEN it applies.
*/
public enum RotationMode {
/**
* NPC rotates normally via AI look helper.
*/
FREE,
/**
* Freeze rotation at the moment the phase starts.
* NPC stays facing the direction it was looking when the phase began.
*/
LOCKED,
/**
* Force NPC to continuously face its target (hit scan).
* Overrides AI look helper every tick for precise aiming.
*/
TRACK;
public String getDisplayKey() {
switch (this) {
case FREE:
return "ability.rotation.free";
case LOCKED:
return "ability.rotation.locked";
case TRACK:
return "ability.rotation.track";
default:
return "ability.rotation.free";
}
}
public static String[] getDisplayKeys() {
return new String[]{
"ability.rotation.free",
"ability.rotation.locked",
"ability.rotation.track"
};
}
public static RotationMode fromOrdinal(int ordinal) {
RotationMode[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return FREE;
}
}
@@ -1,32 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Filter for determining which entities an ability should affect in AOE mode.
*/
public enum TargetFilter {
ALLIES,
ENEMIES,
ALL;
@Override
public String toString() {
switch (this) {
case ALLIES:
return "ability.targetFilter.allies";
case ENEMIES:
return "ability.targetFilter.enemies";
case ALL:
return "ability.targetFilter.all";
default:
return name();
}
}
public static TargetFilter fromString(String name) {
try {
return valueOf(name);
} catch (Exception e) {
return ALLIES;
}
}
}
@@ -1,42 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines how an ability selects its target(s).
*/
public enum TargetingMode {
/**
* Target the current aggro target
*/
AGGRO_TARGET,
/**
* Target self (for buffs, heals, guards)
*/
SELF,
/**
* AOE centered on self
*/
AOE_SELF,
/**
* AOE centered on target
*/
AOE_TARGET;
@Override
public String toString() {
switch (this) {
case AGGRO_TARGET:
return "ability.target.aggro_target";
case SELF:
return "ability.target.self";
case AOE_SELF:
return "ability.target.aoe_self";
case AOE_TARGET:
return "ability.target.aoe_target";
default:
return name();
}
}
}
@@ -1,27 +0,0 @@
package kamkeel.npcs.controllers.data.ability.enums;
/**
* Defines which entity types can use an ability.
*/
public enum UserType {
NPC_ONLY,
PLAYER_ONLY,
BOTH,
NONE;
public boolean allowsNpc() {
return this == NPC_ONLY || this == BOTH;
}
public boolean allowsPlayer() {
return this == PLAYER_ONLY || this == BOTH;
}
public static UserType fromOrdinal(int ordinal) {
UserType[] values = values();
if (ordinal >= 0 && ordinal < values.length) {
return values[ordinal];
}
return BOTH;
}
}
@@ -1,57 +0,0 @@
package kamkeel.npcs.controllers.data.attribute;
import noppes.npcs.api.handler.data.IAttributeDefinition;
public class AttributeDefinition implements IAttributeDefinition {
private final String key;
private String translationKey;// e.g., "main_attack_flat"
private final String displayName; // Human‑readable name
private final char colorCode;
private final AttributeValueType attributeValueType;
private final AttributeSection section;
public AttributeDefinition(String key, String displayName, char colorCode, AttributeValueType attributeValueType, AttributeSection section) {
this.key = key;
this.translationKey = "rpgcore:attribute." + key;
this.displayName = displayName;
this.attributeValueType = attributeValueType;
this.section = section;
this.colorCode = colorCode;
}
public String getKey() {
return key;
}
public String getDisplayName() {
return displayName;
}
public String getTranslationKey() {
return translationKey;
}
public void setTranslationKey(String translationKey) {
this.translationKey = translationKey;
}
public AttributeValueType getValueType() {
return attributeValueType;
}
public AttributeSection getSection() {
return section;
}
public char getColorCode() {
return colorCode;
}
public enum AttributeSection {
BASE,
MODIFIER,
STATS,
INFO,
EXTRA
}
}
@@ -1,7 +0,0 @@
package kamkeel.npcs.controllers.data.attribute;
public enum AttributeValueType {
FLAT, // e.g., +10 Health or +3 Damage
PERCENT, // e.g., +0.25 means +25% bonus
MAGIC // Represents a container of magic–based values (summed up as a float)
}
@@ -1,24 +0,0 @@
package kamkeel.npcs.controllers.data.attribute;
import noppes.npcs.api.handler.data.ICustomAttribute;
public class PlayerAttribute implements ICustomAttribute {
private final AttributeDefinition attribute;
public float value;
public PlayerAttribute(AttributeDefinition attribute, float value) {
this.attribute = attribute;
this.value = value;
}
@Override
public AttributeDefinition getAttribute() {
return attribute;
}
@Override
public float getValue() {
return value;
}
}
@@ -1,24 +0,0 @@
package kamkeel.npcs.controllers.data.attribute;
import java.util.HashMap;
import java.util.Map;
/**
* CustomAttributeMap holds a set of attribute instances for an entity (or item).
*/
public class PlayerAttributeMap {
public final Map<AttributeDefinition, PlayerAttribute> map = new HashMap<>();
public PlayerAttribute registerAttribute(AttributeDefinition attribute, float baseValue) {
if (map.containsKey(attribute)) {
throw new IllegalArgumentException("Attribute already registered: " + attribute.getKey());
}
PlayerAttribute instance = new PlayerAttribute(attribute, baseValue);
map.put(attribute, instance);
return instance;
}
public PlayerAttribute getAttributeInstance(AttributeDefinition attribute) {
return map.get(attribute);
}
}
@@ -1,7 +0,0 @@
package kamkeel.npcs.controllers.data.profile;
public enum EnumProfileOperation {
SUCCESS,
ERROR,
LOCKED
}
@@ -1,62 +0,0 @@
package kamkeel.npcs.controllers.data.profile;
import net.minecraft.nbt.NBTTagCompound;
public class ProfileInfoEntry {
private String label;
private String result;
private int labelColor;
private int resultColor;
public ProfileInfoEntry() {
}
public ProfileInfoEntry(String label, int labelColor, String result, int resultColor) {
this.label = label;
this.result = result;
this.labelColor = labelColor;
this.resultColor = resultColor;
}
public ProfileInfoEntry(String label, int labelColor, int result, int resultColor) {
this(label, labelColor, String.valueOf(result), resultColor);
}
public ProfileInfoEntry(String label, String result) {
this(label, 0xFFFFFF, result, 0xFFFFFF);
}
public NBTTagCompound writeToNBT() {
NBTTagCompound tag = new NBTTagCompound();
tag.setString("Label", label);
tag.setInteger("LabelColor", labelColor);
tag.setString("Result", result);
tag.setInteger("ResultColor", resultColor);
return tag;
}
public static ProfileInfoEntry readFromNBT(NBTTagCompound tag) {
return new ProfileInfoEntry(
tag.getString("Label"),
tag.getInteger("LabelColor"),
tag.getString("Result"),
tag.getInteger("ResultColor")
);
}
public String getLabel() {
return label;
}
public String getResult() {
return result;
}
public int getLabelColor() {
return labelColor;
}
public int getResultColor() {
return resultColor;
}
}
@@ -1,41 +0,0 @@
package kamkeel.npcs.controllers.data.telegraph;
/**
* Types of telegraph shapes for visual attack warnings.
*/
public enum TelegraphType {
/**
* Filled circle (uses radius)
*/
CIRCLE,
/**
* Donut shape (uses radius and innerRadius)
*/
RING,
/**
* Rectangle (uses length, width)
*/
LINE,
/**
* Fan/wedge shape (uses length, angle)
*/
CONE,
/**
* Single point indicator
*/
POINT,
/**
* Filled square (uses radius as half-size)
*/
SQUARE,
/**
* No telegraph
*/
NONE
}
@@ -7,6 +7,7 @@ import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.profile.Profile;
import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry;
import kamkeel.npcs.network.AbstractPacket;
import noppes.npcs.wrapper.nbt.MC1710NBTCompound;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumPlayerPacket;
@@ -72,7 +73,7 @@ public final class ProfileGetInfoPacket extends AbstractPacket {
slotCompound.setInteger("ID", slot.getId());
List<ProfileInfoEntry> profileInfo = ProfileController.Instance.getProfileInfo(player, slot.getId());
for (ProfileInfoEntry profileInfoEntry : profileInfo) {
infoList.appendTag(profileInfoEntry.writeToNBT());
infoList.appendTag(((MC1710NBTCompound) profileInfoEntry.writeToNBT()).getMCTag());
}
slotCompound.setTag("INFO", infoList);
slotList.appendTag(slotCompound);
@@ -98,7 +99,7 @@ public final class ProfileGetInfoPacket extends AbstractPacket {
List<ProfileInfoEntry> infoEntries = new ArrayList<>();
for (int j = 0; j < infoList.tagCount(); j++) {
NBTTagCompound infoTag = infoList.getCompoundTagAt(j);
infoEntries.add(ProfileInfoEntry.readFromNBT(infoTag)); // Convert back to InfoEntry
infoEntries.add(ProfileInfoEntry.readFromNBT(new MC1710NBTCompound(infoTag))); // Convert back to InfoEntry
}
slotInfoMap.put(slotId, infoEntries);
@@ -1,97 +0,0 @@
package kamkeel.npcs.util;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* Utility helpers for filename-safe ability/chained names.
* Allowed characters are letters, digits, underscore, and dash.
*/
public final class FileNameHelper {
private static final Set<String> WINDOWS_RESERVED_NAMES = new HashSet<String>(Arrays.asList(
"CON", "PRN", "AUX", "NUL",
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
"LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"
));
private FileNameHelper() {
}
/**
* Sanitize a name to a filename-safe identifier.
* Whitespace becomes underscores; unsupported chars are removed.
*/
public static String sanitizeName(String input, String fallback) {
String sanitized = sanitizeInternal(input);
if (sanitized.isEmpty()) {
sanitized = sanitizeInternal(fallback);
}
if (sanitized.isEmpty()) {
sanitized = "Ability";
}
if (isReservedWindowsName(sanitized)) {
sanitized = "_" + sanitized;
}
return sanitized;
}
/**
* Sanitize textfield input without forcing a fallback.
*/
public static String sanitizeTextInput(String input) {
return sanitizeInternal(input);
}
/**
* Quick check for compatibility with sanitized identifier rules.
*/
public static boolean isFileNameCompatible(String value) {
if (value == null || value.isEmpty()) return false;
if (isReservedWindowsName(value)) return false;
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (!Character.isLetterOrDigit(c) && c != '_' && c != '-') {
return false;
}
}
return true;
}
/**
* Human-readable fallback display text for sanitized names.
*/
public static String toDisplayName(String value) {
if (value == null || value.isEmpty()) return "";
return value.replace('_', ' ');
}
private static String sanitizeInternal(String raw) {
if (raw == null) return "";
String trimmed = raw.trim();
if (trimmed.isEmpty()) return "";
StringBuilder out = new StringBuilder(trimmed.length());
for (int i = 0; i < trimmed.length(); i++) {
char c = trimmed.charAt(i);
if (Character.isLetterOrDigit(c)) {
out.append(c);
} else if (c == '_' || c == '-') {
out.append(c);
} else if (Character.isWhitespace(c)) {
if (out.length() == 0) continue;
char last = out.charAt(out.length() - 1);
if (last == '_') continue;
out.append('_');
}
}
return out.toString();
}
private static boolean isReservedWindowsName(String value) {
return WINDOWS_RESERVED_NAMES.contains(value.toUpperCase());
}
}
@@ -1,40 +0,0 @@
package kamkeel.npcs.util;
import java.util.ArrayList;
import java.util.List;
public class TextSplitter {
public static List<String> splitText(String input, int maxSegmentLength) {
List<String> result = new ArrayList<>();
while (input.length() > maxSegmentLength) {
int spaceIndex = input.lastIndexOf(" ", maxSegmentLength);
if (spaceIndex == -1) {
// No space found within the maxSegmentLength, so split at the exact length.
result.add(input.substring(0, maxSegmentLength));
input = input.substring(maxSegmentLength);
} else {
// Split at the last space within maxSegmentLength.
result.add(input.substring(0, spaceIndex));
input = input.substring(spaceIndex + 1); // Skip the space.
}
}
if (!input.isEmpty()) {
result.add(input);
}
return result;
}
public static void main(String[] args) {
String longText = "This is a very long string that needs to be split into multiple lines based on a maximum line length of 30 characters.";
int maxLineLength = 30;
List<String> lines = splitText(longText, maxLineLength);
for (String line : lines) {
System.out.println(line);
}
}
}