diff --git a/src/api b/src/api
index 64fe8794e..a6b4a131c 160000
--- a/src/api
+++ b/src/api
@@ -1 +1 @@
-Subproject commit 64fe8794e71d82f09449e6c916c7902fe890cab7
+Subproject commit a6b4a131c843f27bbd3c561168f18498cb9d59ec
diff --git a/src/main/java/kamkeel/npcs/controllers/ProfileController.java b/src/main/java/kamkeel/npcs/controllers/ProfileController.java
index 73f16ebf6..f7ac06bb1 100644
--- a/src/main/java/kamkeel/npcs/controllers/ProfileController.java
+++ b/src/main/java/kamkeel/npcs/controllers/ProfileController.java
@@ -1,6 +1,5 @@
package kamkeel.npcs.controllers;
-import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.data.profile.CNPCData;
import kamkeel.npcs.controllers.data.profile.EnumProfileOperation;
import kamkeel.npcs.controllers.data.profile.IProfileData;
diff --git a/src/main/java/kamkeel/npcs/controllers/SyncController.java b/src/main/java/kamkeel/npcs/controllers/SyncController.java
index 9617f4d12..3247498b5 100644
--- a/src/main/java/kamkeel/npcs/controllers/SyncController.java
+++ b/src/main/java/kamkeel/npcs/controllers/SyncController.java
@@ -2,9 +2,9 @@ package kamkeel.npcs.controllers;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import kamkeel.npcs.addon.DBCAddon;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import kamkeel.npcs.addon.DBCAddon;
import kamkeel.npcs.network.LargeAbstractPacket;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumSyncAction;
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java b/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java
index 4d62a934f..48cf46cb3 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/Ability.java
@@ -15,8 +15,8 @@ import noppes.npcs.DataAbilities;
import noppes.npcs.NpcDamageSource;
import noppes.npcs.api.INbt;
import noppes.npcs.api.ability.IAbility;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.AbilityEvent;
@@ -89,33 +89,46 @@ public abstract class Ability implements IAbility {
// ABSTRACT METHODS
// ═══════════════════════════════════════════════════════════════════
- /** Called first tick of ACTIVE phase */
+ /**
+ * Called first tick of ACTIVE phase
+ */
public abstract void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world);
- /** Called every tick of ACTIVE phase */
+ /**
+ * Called every tick of ACTIVE phase
+ */
public abstract void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick);
- /** Write type-specific config to NBT */
+ /**
+ * Write type-specific config to NBT
+ */
public abstract void writeTypeNBT(NBTTagCompound nbt);
- /** Read type-specific config from NBT */
+ /**
+ * Read type-specific config from NBT
+ */
public abstract void readTypeNBT(NBTTagCompound nbt);
// ═══════════════════════════════════════════════════════════════════
// OPTIONAL OVERRIDES
// ═══════════════════════════════════════════════════════════════════
- public void onWindUpTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {}
- public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) {}
- public void onComplete(EntityNPCInterface npc, EntityLivingBase target) {}
+ public void onWindUpTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
+ }
+
+ public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) {
+ }
+
+ public void onComplete(EntityNPCInterface npc, EntityLivingBase target) {
+ }
/**
* Apply damage to an entity with ability hit event support.
* Fires the abilityHit script event, allowing scripts to modify or cancel the damage.
*
- * @param npc The NPC executing the ability
+ * @param npc The NPC executing the ability
* @param hitEntity The entity being hit
- * @param damage The damage amount
+ * @param damage The damage amount
* @param knockback The horizontal knockback
* @return true if damage was applied (not cancelled), false if cancelled
*/
@@ -160,17 +173,17 @@ public abstract class Ability implements IAbility {
* Apply damage to an entity with ability hit event support and custom knockback direction.
* Fires the abilityHit script event, allowing scripts to modify or cancel the damage.
*
- * @param npc The NPC executing the ability
- * @param hitEntity The entity being hit
- * @param damage The damage amount
- * @param knockback The horizontal knockback
+ * @param npc The NPC executing the ability
+ * @param hitEntity The entity being hit
+ * @param damage The damage amount
+ * @param knockback The horizontal knockback
* @param knockbackDirX The X component of knockback direction (normalized)
* @param knockbackDirZ The Z component of knockback direction (normalized)
* @return true if damage was applied (not cancelled), false if cancelled
*/
protected boolean applyAbilityDamageWithDirection(EntityNPCInterface npc, EntityLivingBase hitEntity,
- float damage, float knockback,
- double knockbackDirX, double knockbackDirZ) {
+ float damage, float knockback,
+ double knockbackDirX, double knockbackDirZ) {
DataAbilities dataAbilities = npc.abilities;
AbilityEvent.HitEvent event = dataAbilities.fireHitEvent(
this, currentTarget, hitEntity, damage, knockback, 0.0f);
@@ -206,53 +219,77 @@ public abstract class Ability implements IAbility {
hitEntity.addVelocity(x, 0.1D, z);
hitEntity.velocityChanged = true;
}
- public float getTelegraphRadius() { return 5.0f; }
- public float getTelegraphLength() { return 5.0f; }
- public float getTelegraphWidth() { return 2.0f; }
- public float getTelegraphAngle() { return 45.0f; }
+
+ public float getTelegraphRadius() {
+ return 5.0f;
+ }
+
+ public float getTelegraphLength() {
+ return 5.0f;
+ }
+
+ public float getTelegraphWidth() {
+ return 2.0f;
+ }
+
+ public float getTelegraphAngle() {
+ return 45.0f;
+ }
/**
* Returns true if this ability controls NPC movement during ACTIVE phase.
* When true, AI pathfinding will be blocked during ability execution.
* Override in abilities that move the NPC (Charge, Dash, Slam, etc.)
*/
- public boolean hasAbilityMovement() { return false; }
+ public boolean hasAbilityMovement() {
+ return false;
+ }
/**
* Returns true if the targeting mode for this ability type is locked and cannot be changed.
* Most abilities have fixed targeting (e.g., Heal is always SELF, Charge is always AGGRO_TARGET).
* Override and return false for abilities with flexible targeting.
*/
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
/**
* Returns the allowed targeting modes for this ability, or null if all modes are allowed.
* Override in abilities that only support specific targeting modes.
*/
- public TargetingMode[] getAllowedTargetingModes() { return null; }
+ public TargetingMode[] getAllowedTargetingModes() {
+ return null;
+ }
/**
* Returns true if the telegraph type for this ability is locked and cannot be changed.
* Telegraph type is inherent to how the ability works (e.g., Charge uses LINE, Slam uses CIRCLE).
*/
- public boolean isTelegraphTypeLocked() { return true; }
+ public boolean isTelegraphTypeLocked() {
+ return true;
+ }
/**
* Returns true if this ability type has custom settings that need a Type-specific tab.
* Override to return true if the ability has settings beyond the base Ability fields.
*/
- public boolean hasTypeSettings() { return false; }
+ public boolean hasTypeSettings() {
+ return false;
+ }
/**
* Get the number of rows needed for type-specific settings in the GUI.
* Each row is approximately 24 pixels. Used for GUI layout.
*/
- public int getTypeSettingsRowCount() { return 0; }
+ public int getTypeSettingsRowCount() {
+ return 0;
+ }
/**
* Creates the GUI for configuring this ability.
* Override this method to provide a custom GUI subclass for type-specific settings.
- *
+ *
* Third-party mods can extend SubGuiAbilityConfig and override initTypeTab(),
* handleTypeButton(), and handleTypeTextField() to provide custom type settings.
*
@@ -268,7 +305,7 @@ public abstract class Ability implements IAbility {
* Create a telegraph instance for this ability.
* Override for custom telegraph shapes.
*
- * @param npc The caster
+ * @param npc The caster
* @param target The target (for position calculation)
* @return The telegraph instance, or null if no telegraph
*/
@@ -283,9 +320,9 @@ public abstract class Ability implements IAbility {
// Determine position based on targeting mode
boolean positionAtNpc = targetingMode == TargetingMode.AOE_SELF ||
- targetingMode == TargetingMode.SELF ||
- telegraphType == TelegraphType.LINE ||
- telegraphType == TelegraphType.CONE;
+ targetingMode == TargetingMode.SELF ||
+ telegraphType == TelegraphType.LINE ||
+ telegraphType == TelegraphType.CONE;
if (positionAtNpc) {
x = npc.posX;
@@ -347,10 +384,10 @@ public abstract class Ability implements IAbility {
* Find the ground level at a given position.
* Searches downward from the given Y to find a solid block.
*
- * @param world The world
- * @param x X coordinate
+ * @param world The world
+ * @param x X coordinate
* @param startY Starting Y coordinate (entity feet position)
- * @param z Z coordinate
+ * @param z Z coordinate
* @return The Y coordinate of the ground surface
*/
protected double findGroundLevel(World world, double x, double startY, double z) {
@@ -391,7 +428,9 @@ public abstract class Ability implements IAbility {
// EXECUTION LOGIC (called by CombatHandler)
// ═══════════════════════════════════════════════════════════════════
- /** Start executing this ability */
+ /**
+ * Start executing this ability
+ */
public void start(EntityLivingBase target) {
this.phase = AbilityPhase.WINDUP;
this.currentTick = 0;
@@ -399,7 +438,9 @@ public abstract class Ability implements IAbility {
this.executionStartTime = System.currentTimeMillis();
}
- /** Tick the ability. Returns true if phase changed. */
+ /**
+ * Tick the ability. Returns true if phase changed.
+ */
public boolean tick() {
if (phase == AbilityPhase.IDLE) return false;
@@ -432,7 +473,9 @@ public abstract class Ability implements IAbility {
return false;
}
- /** Interrupt this ability */
+ /**
+ * Interrupt this ability
+ */
public void interrupt() {
phase = AbilityPhase.IDLE;
currentTick = 0;
@@ -440,17 +483,23 @@ public abstract class Ability implements IAbility {
telegraphInstance = null;
}
- /** Start cooldown timer */
+ /**
+ * Start cooldown timer
+ */
public void startCooldown() {
cooldownEndTime = System.currentTimeMillis() + (cooldownTicks * 50L);
}
- /** Check if on cooldown */
+ /**
+ * Check if on cooldown
+ */
public boolean isOnCooldown() {
return System.currentTimeMillis() < cooldownEndTime;
}
- /** Check if executing */
+ /**
+ * Check if executing
+ */
public boolean isExecuting() {
return phase != AbilityPhase.IDLE;
}
@@ -487,7 +536,9 @@ public abstract class Ability implements IAbility {
return true;
}
- /** Reset all execution state (called on combat end) */
+ /**
+ * Reset all execution state (called on combat end)
+ */
public void reset() {
phase = AbilityPhase.IDLE;
currentTick = 0;
@@ -507,7 +558,9 @@ public abstract class Ability implements IAbility {
return true;
}
- /** Full eligibility check */
+ /**
+ * Full eligibility check
+ */
public boolean canUse(EntityNPCInterface npc, EntityLivingBase target) {
if (!enabled) return false;
if (isOnCooldown()) return false;
@@ -634,110 +687,266 @@ public abstract class Ability implements IAbility {
// GETTERS & SETTERS
// ═══════════════════════════════════════════════════════════════════
- public String getId() { return id; }
- public void setId(String id) { this.id = id; }
+ public String getId() {
+ return id;
+ }
- public String getName() { return name; }
- public void setName(String name) { this.name = name; }
+ public void setId(String id) {
+ this.id = id;
+ }
- public String getTypeId() { return typeId; }
+ public String getName() {
+ return name;
+ }
- public int getWeight() { return weight; }
- public void setWeight(int weight) { this.weight = weight; }
+ public void setName(String name) {
+ this.name = name;
+ }
- public boolean isEnabled() { return enabled; }
- public void setEnabled(boolean enabled) { this.enabled = enabled; }
+ public String getTypeId() {
+ return typeId;
+ }
- public TargetingMode getTargetingMode() { return targetingMode; }
- public void setTargetingMode(TargetingMode targetingMode) { this.targetingMode = targetingMode; }
+ public int getWeight() {
+ return weight;
+ }
- public float getMinRange() { return minRange; }
- public void setMinRange(float minRange) { this.minRange = minRange; }
+ public void setWeight(int weight) {
+ this.weight = weight;
+ }
- public float getMaxRange() { return maxRange; }
- public void setMaxRange(float maxRange) { this.maxRange = maxRange; }
+ public boolean isEnabled() {
+ return enabled;
+ }
- public int getCooldownTicks() { return cooldownTicks; }
- public void setCooldownTicks(int cooldownTicks) { this.cooldownTicks = cooldownTicks; }
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
- public int getWindUpTicks() { return windUpTicks; }
- public void setWindUpTicks(int windUpTicks) { this.windUpTicks = windUpTicks; }
+ public TargetingMode getTargetingMode() {
+ return targetingMode;
+ }
- public int getActiveTicks() { return activeTicks; }
- public void setActiveTicks(int activeTicks) { this.activeTicks = activeTicks; }
+ public void setTargetingMode(TargetingMode targetingMode) {
+ this.targetingMode = targetingMode;
+ }
- public int getRecoveryTicks() { return recoveryTicks; }
- public void setRecoveryTicks(int recoveryTicks) { this.recoveryTicks = recoveryTicks; }
+ public float getMinRange() {
+ return minRange;
+ }
- public boolean isInterruptible() { return interruptible; }
- public void setInterruptible(boolean interruptible) { this.interruptible = interruptible; }
+ public void setMinRange(float minRange) {
+ this.minRange = minRange;
+ }
- public boolean isLockMovement() { return lockMovement; }
- public void setLockMovement(boolean lockMovement) { this.lockMovement = lockMovement; }
+ public float getMaxRange() {
+ return maxRange;
+ }
- public int getWindUpColor() { return windUpColor; }
- public void setWindUpColor(int windUpColor) { this.windUpColor = windUpColor; }
+ public void setMaxRange(float maxRange) {
+ this.maxRange = maxRange;
+ }
- public int getActiveColor() { return activeColor; }
- public void setActiveColor(int activeColor) { this.activeColor = activeColor; }
+ public int getCooldownTicks() {
+ return cooldownTicks;
+ }
- /** @deprecated Use getWindUpColor() instead */
+ public void setCooldownTicks(int cooldownTicks) {
+ this.cooldownTicks = cooldownTicks;
+ }
+
+ public int getWindUpTicks() {
+ return windUpTicks;
+ }
+
+ public void setWindUpTicks(int windUpTicks) {
+ this.windUpTicks = windUpTicks;
+ }
+
+ public int getActiveTicks() {
+ return activeTicks;
+ }
+
+ public void setActiveTicks(int activeTicks) {
+ this.activeTicks = activeTicks;
+ }
+
+ public int getRecoveryTicks() {
+ return recoveryTicks;
+ }
+
+ public void setRecoveryTicks(int recoveryTicks) {
+ this.recoveryTicks = recoveryTicks;
+ }
+
+ public boolean isInterruptible() {
+ return interruptible;
+ }
+
+ public void setInterruptible(boolean interruptible) {
+ this.interruptible = interruptible;
+ }
+
+ public boolean isLockMovement() {
+ return lockMovement;
+ }
+
+ public void setLockMovement(boolean lockMovement) {
+ this.lockMovement = lockMovement;
+ }
+
+ public int getWindUpColor() {
+ return windUpColor;
+ }
+
+ public void setWindUpColor(int windUpColor) {
+ this.windUpColor = windUpColor;
+ }
+
+ public int getActiveColor() {
+ return activeColor;
+ }
+
+ public void setActiveColor(int activeColor) {
+ this.activeColor = activeColor;
+ }
+
+ /**
+ * @deprecated Use getWindUpColor() instead
+ */
@Deprecated
- public int getTelegraphColor() { return windUpColor; }
- /** @deprecated Use setWindUpColor() instead */
+ public int getTelegraphColor() {
+ return windUpColor;
+ }
+
+ /**
+ * @deprecated Use setWindUpColor() instead
+ */
@Deprecated
- public void setTelegraphColor(int telegraphColor) { this.windUpColor = telegraphColor; }
+ public void setTelegraphColor(int telegraphColor) {
+ this.windUpColor = telegraphColor;
+ }
- public String getWindUpSound() { return windUpSound; }
- public void setWindUpSound(String windUpSound) { this.windUpSound = windUpSound; }
+ public String getWindUpSound() {
+ return windUpSound;
+ }
- public String getActiveSound() { return activeSound; }
- public void setActiveSound(String activeSound) { this.activeSound = activeSound; }
+ public void setWindUpSound(String windUpSound) {
+ this.windUpSound = windUpSound;
+ }
- public int getWindUpAnimationId() { return windUpAnimationId; }
- public void setWindUpAnimationId(int windUpAnimationId) { this.windUpAnimationId = windUpAnimationId; }
+ public String getActiveSound() {
+ return activeSound;
+ }
- public int getActiveAnimationId() { return activeAnimationId; }
- public void setActiveAnimationId(int activeAnimationId) { this.activeAnimationId = activeAnimationId; }
+ public void setActiveSound(String activeSound) {
+ this.activeSound = activeSound;
+ }
- /** @deprecated Use getWindUpSound() instead */
+ public int getWindUpAnimationId() {
+ return windUpAnimationId;
+ }
+
+ public void setWindUpAnimationId(int windUpAnimationId) {
+ this.windUpAnimationId = windUpAnimationId;
+ }
+
+ public int getActiveAnimationId() {
+ return activeAnimationId;
+ }
+
+ public void setActiveAnimationId(int activeAnimationId) {
+ this.activeAnimationId = activeAnimationId;
+ }
+
+ /**
+ * @deprecated Use getWindUpSound() instead
+ */
@Deprecated
- public String getCastSound() { return windUpSound; }
- /** @deprecated Use setWindUpSound() instead */
+ public String getCastSound() {
+ return windUpSound;
+ }
+
+ /**
+ * @deprecated Use setWindUpSound() instead
+ */
@Deprecated
- public void setCastSound(String castSound) { this.windUpSound = castSound; }
+ public void setCastSound(String castSound) {
+ this.windUpSound = castSound;
+ }
- /** @deprecated Use getWindUpAnimationId() instead */
+ /**
+ * @deprecated Use getWindUpAnimationId() instead
+ */
@Deprecated
- public int getAnimationId() { return windUpAnimationId; }
- /** @deprecated Use setWindUpAnimationId() instead */
+ public int getAnimationId() {
+ return windUpAnimationId;
+ }
+
+ /**
+ * @deprecated Use setWindUpAnimationId() instead
+ */
@Deprecated
- public void setAnimationId(int animationId) { this.windUpAnimationId = animationId; }
+ public void setAnimationId(int animationId) {
+ this.windUpAnimationId = animationId;
+ }
- public boolean isShowTelegraph() { return showTelegraph; }
- public void setShowTelegraph(boolean showTelegraph) { this.showTelegraph = showTelegraph; }
+ public boolean isShowTelegraph() {
+ return showTelegraph;
+ }
- public TelegraphType getTelegraphType() { return telegraphType; }
- public void setTelegraphType(TelegraphType telegraphType) { this.telegraphType = telegraphType; }
+ public void setShowTelegraph(boolean showTelegraph) {
+ this.showTelegraph = showTelegraph;
+ }
- public float getTelegraphHeightOffset() { return telegraphHeightOffset; }
- public void setTelegraphHeightOffset(float telegraphHeightOffset) { this.telegraphHeightOffset = telegraphHeightOffset; }
+ public TelegraphType getTelegraphType() {
+ return telegraphType;
+ }
- public AbilityPhase getPhase() { return phase; }
+ public void setTelegraphType(TelegraphType telegraphType) {
+ this.telegraphType = telegraphType;
+ }
+
+ public float getTelegraphHeightOffset() {
+ return telegraphHeightOffset;
+ }
+
+ public void setTelegraphHeightOffset(float telegraphHeightOffset) {
+ this.telegraphHeightOffset = telegraphHeightOffset;
+ }
+
+ public AbilityPhase getPhase() {
+ return phase;
+ }
/**
* Get the current execution phase as int (0=IDLE, 1=WINDUP, 2=ACTIVE, 3=RECOVERY).
* Required for IAbility interface.
*/
@Override
- public int getPhaseInt() { return phase.ordinal(); }
+ public int getPhaseInt() {
+ return phase.ordinal();
+ }
- public int getCurrentTick() { return currentTick; }
- public EntityLivingBase getCurrentTarget() { return currentTarget; }
- public NBTTagCompound getCustomData() { return customData; }
+ public int getCurrentTick() {
+ return currentTick;
+ }
- public List getConditions() { return conditions; }
- public void addCondition(Condition c) { conditions.add(c); }
+ public EntityLivingBase getCurrentTarget() {
+ return currentTarget;
+ }
+
+ public NBTTagCompound getCustomData() {
+ return customData;
+ }
+
+ public List getConditions() {
+ return conditions;
+ }
+
+ public void addCondition(Condition c) {
+ conditions.add(c);
+ }
// ═══════════════════════════════════════════════════════════════════
// IAbility API METHODS
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityController.java b/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityController.java
index 685e5403d..1a9bbd522 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityController.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/AbilityController.java
@@ -1,6 +1,20 @@
package kamkeel.npcs.controllers.data.ability;
-import kamkeel.npcs.controllers.data.ability.type.*;
+import kamkeel.npcs.controllers.data.ability.type.AbilityBeam;
+import kamkeel.npcs.controllers.data.ability.type.AbilityCharge;
+import kamkeel.npcs.controllers.data.ability.type.AbilityCutter;
+import kamkeel.npcs.controllers.data.ability.type.AbilityDash;
+import kamkeel.npcs.controllers.data.ability.type.AbilityGuard;
+import kamkeel.npcs.controllers.data.ability.type.AbilityHazard;
+import kamkeel.npcs.controllers.data.ability.type.AbilityHeal;
+import kamkeel.npcs.controllers.data.ability.type.AbilityHeavyHit;
+import kamkeel.npcs.controllers.data.ability.type.AbilityOrb;
+import kamkeel.npcs.controllers.data.ability.type.AbilityProjectile;
+import kamkeel.npcs.controllers.data.ability.type.AbilityShockwave;
+import kamkeel.npcs.controllers.data.ability.type.AbilitySlam;
+import kamkeel.npcs.controllers.data.ability.type.AbilityTeleport;
+import kamkeel.npcs.controllers.data.ability.type.AbilityTrap;
+import kamkeel.npcs.controllers.data.ability.type.AbilityVortex;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
@@ -8,13 +22,17 @@ import noppes.npcs.api.handler.IAbilityHandler;
import noppes.npcs.util.NBTJsonUtil;
import java.io.File;
-import java.util.*;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
import java.util.function.Supplier;
/**
* Controller for ability types. Allows external mods to register custom ability types.
* Initialize during FMLInitializationEvent.
- *
+ *
* Also manages saved ability presets that can be reused across NPCs.
*/
public class AbilityController implements IAbilityHandler {
@@ -211,7 +229,7 @@ public class AbilityController implements IAbilityHandler {
* Call during FMLInitializationEvent.
*
* @param factoryKey The factory key (e.g., "cnpc:slam", "mymod:custom_ability")
- * @param factory Factory lambda that creates a new instance
+ * @param factory Factory lambda that creates a new instance
*/
public void registerType(String factoryKey, Supplier factory) {
if (factories.containsKey(factoryKey)) {
@@ -252,6 +270,7 @@ public class AbilityController implements IAbilityHandler {
/**
* Create a new empty ability of the given type.
+ *
* @param factoryKey The factory key (e.g., "cnpc:slam") or the ability typeId (e.g., "ability.cnpc.slam")
*/
public Ability create(String factoryKey) {
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/Condition.java b/src/main/java/kamkeel/npcs/controllers/data/ability/Condition.java
index 70b3b290f..8d078421a 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/Condition.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/Condition.java
@@ -13,7 +13,7 @@ public interface Condition {
/**
* Check if this condition is met.
*
- * @param npc The NPC that would use the ability
+ * @param npc The NPC that would use the ability
* @param target The current target (may be null for self-targeting abilities)
* @return true if the condition is satisfied
*/
@@ -80,7 +80,8 @@ public interface Condition {
class ConditionHPAbove implements Condition {
private float threshold = 0.5f; // 50%
- public ConditionHPAbove() {}
+ public ConditionHPAbove() {
+ }
public ConditionHPAbove(float threshold) {
this.threshold = threshold;
@@ -92,7 +93,9 @@ public interface Condition {
}
@Override
- public String getTypeId() { return "hp_above"; }
+ public String getTypeId() {
+ return "hp_above";
+ }
@Override
public NBTTagCompound writeNBT() {
@@ -114,7 +117,8 @@ public interface Condition {
class ConditionHPBelow implements Condition {
private float threshold = 0.5f;
- public ConditionHPBelow() {}
+ public ConditionHPBelow() {
+ }
public ConditionHPBelow(float threshold) {
this.threshold = threshold;
@@ -126,7 +130,9 @@ public interface Condition {
}
@Override
- public String getTypeId() { return "hp_below"; }
+ public String getTypeId() {
+ return "hp_below";
+ }
@Override
public NBTTagCompound writeNBT() {
@@ -148,7 +154,8 @@ public interface Condition {
class ConditionTargetHPAbove implements Condition {
private float threshold = 0.5f;
- public ConditionTargetHPAbove() {}
+ public ConditionTargetHPAbove() {
+ }
public ConditionTargetHPAbove(float threshold) {
this.threshold = threshold;
@@ -161,7 +168,9 @@ public interface Condition {
}
@Override
- public String getTypeId() { return "target_hp_above"; }
+ public String getTypeId() {
+ return "target_hp_above";
+ }
@Override
public NBTTagCompound writeNBT() {
@@ -183,7 +192,8 @@ public interface Condition {
class ConditionTargetHPBelow implements Condition {
private float threshold = 0.5f;
- public ConditionTargetHPBelow() {}
+ public ConditionTargetHPBelow() {
+ }
public ConditionTargetHPBelow(float threshold) {
this.threshold = threshold;
@@ -196,7 +206,9 @@ public interface Condition {
}
@Override
- public String getTypeId() { return "target_hp_below"; }
+ public String getTypeId() {
+ return "target_hp_below";
+ }
@Override
public NBTTagCompound writeNBT() {
@@ -220,7 +232,8 @@ public interface Condition {
private int requiredHits = 3;
private int withinTicks = 60;
- public ConditionHitCount() {}
+ public ConditionHitCount() {
+ }
public ConditionHitCount(int requiredHits, int withinTicks) {
this.requiredHits = requiredHits;
@@ -237,7 +250,9 @@ public interface Condition {
}
@Override
- public String getTypeId() { return "hit_count"; }
+ public String getTypeId() {
+ return "hit_count";
+ }
@Override
public NBTTagCompound writeNBT() {
@@ -254,10 +269,20 @@ public interface Condition {
withinTicks = nbt.getInteger("withinTicks");
}
- public int getRequiredHits() { return requiredHits; }
- public void setRequiredHits(int hits) { this.requiredHits = hits; }
+ public int getRequiredHits() {
+ return requiredHits;
+ }
- public int getWithinTicks() { return withinTicks; }
- public void setWithinTicks(int ticks) { this.withinTicks = ticks; }
+ public void setRequiredHits(int hits) {
+ this.requiredHits = hits;
+ }
+
+ public int getWithinTicks() {
+ return withinTicks;
+ }
+
+ public void setWithinTicks(int ticks) {
+ this.withinTicks = ticks;
+ }
}
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/TargetingMode.java b/src/main/java/kamkeel/npcs/controllers/data/ability/TargetingMode.java
index a639702e1..7a2e43b64 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/TargetingMode.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/TargetingMode.java
@@ -4,24 +4,38 @@ package kamkeel.npcs.controllers.data.ability;
* Defines how an ability selects its target(s).
*/
public enum TargetingMode {
- /** Target the current aggro target */
+ /**
+ * Target the current aggro target
+ */
AGGRO_TARGET,
- /** Target self (for buffs, heals, guards) */
+ /**
+ * Target self (for buffs, heals, guards)
+ */
SELF,
- /** AOE centered on self */
+ /**
+ * AOE centered on self
+ */
AOE_SELF,
- /** AOE centered on target */
+ /**
+ * AOE centered on target
+ */
AOE_TARGET,
- /** Random nearby enemy */
+ /**
+ * Random nearby enemy
+ */
RANDOM_ENEMY,
- /** Lowest HP enemy in range */
+ /**
+ * Lowest HP enemy in range
+ */
LOWEST_HP,
- /** Highest threat enemy */
+ /**
+ * Highest threat enemy
+ */
HIGHEST_THREAT
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/Telegraph.java b/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/Telegraph.java
index 1b42b55e1..b8f92de17 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/Telegraph.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/Telegraph.java
@@ -35,7 +35,8 @@ public class Telegraph {
private boolean followsCaster = false;
private float offsetForward = 0.0f;
- public Telegraph() {}
+ public Telegraph() {
+ }
public Telegraph(String id, TelegraphType type) {
this.id = id;
@@ -149,54 +150,139 @@ public class Telegraph {
// GETTERS & SETTERS
// ═══════════════════════════════════════════════════════════════════
- public String getId() { return id; }
- public void setId(String id) { this.id = id; }
+ public String getId() {
+ return id;
+ }
- public TelegraphType getType() { return type; }
- public void setType(TelegraphType type) { this.type = type; }
+ public void setId(String id) {
+ this.id = id;
+ }
- public float getRadius() { return radius; }
- public void setRadius(float radius) { this.radius = radius; }
+ public TelegraphType getType() {
+ return type;
+ }
- public float getInnerRadius() { return innerRadius; }
- public void setInnerRadius(float innerRadius) { this.innerRadius = innerRadius; }
+ public void setType(TelegraphType type) {
+ this.type = type;
+ }
- public float getLength() { return length; }
- public void setLength(float length) { this.length = length; }
+ public float getRadius() {
+ return radius;
+ }
- public float getWidth() { return width; }
- public void setWidth(float width) { this.width = width; }
+ public void setRadius(float radius) {
+ this.radius = radius;
+ }
- public float getAngle() { return angle; }
- public void setAngle(float angle) { this.angle = angle; }
+ public float getInnerRadius() {
+ return innerRadius;
+ }
- public int getDurationTicks() { return durationTicks; }
- public void setDurationTicks(int durationTicks) { this.durationTicks = durationTicks; }
+ public void setInnerRadius(float innerRadius) {
+ this.innerRadius = innerRadius;
+ }
- public int getColor() { return color; }
- public void setColor(int color) { this.color = color; }
+ public float getLength() {
+ return length;
+ }
- public int getWarningColor() { return warningColor; }
- public void setWarningColor(int warningColor) { this.warningColor = warningColor; }
+ public void setLength(float length) {
+ this.length = length;
+ }
- public int getWarningStartTick() { return warningStartTick; }
- public void setWarningStartTick(int warningStartTick) { this.warningStartTick = warningStartTick; }
+ public float getWidth() {
+ return width;
+ }
- public boolean isAnimated() { return animated; }
- public void setAnimated(boolean animated) { this.animated = animated; }
+ public void setWidth(float width) {
+ this.width = width;
+ }
- public float getHeightOffset() { return heightOffset; }
- public void setHeightOffset(float heightOffset) { this.heightOffset = heightOffset; }
+ public float getAngle() {
+ return angle;
+ }
- public boolean isAtTarget() { return atTarget; }
- public void setAtTarget(boolean atTarget) { this.atTarget = atTarget; }
+ public void setAngle(float angle) {
+ this.angle = angle;
+ }
- public boolean isFollowsTarget() { return followsTarget; }
- public void setFollowsTarget(boolean followsTarget) { this.followsTarget = followsTarget; }
+ public int getDurationTicks() {
+ return durationTicks;
+ }
- public boolean isFollowsCaster() { return followsCaster; }
- public void setFollowsCaster(boolean followsCaster) { this.followsCaster = followsCaster; }
+ public void setDurationTicks(int durationTicks) {
+ this.durationTicks = durationTicks;
+ }
- public float getOffsetForward() { return offsetForward; }
- public void setOffsetForward(float offsetForward) { this.offsetForward = offsetForward; }
+ public int getColor() {
+ return color;
+ }
+
+ public void setColor(int color) {
+ this.color = color;
+ }
+
+ public int getWarningColor() {
+ return warningColor;
+ }
+
+ public void setWarningColor(int warningColor) {
+ this.warningColor = warningColor;
+ }
+
+ public int getWarningStartTick() {
+ return warningStartTick;
+ }
+
+ public void setWarningStartTick(int warningStartTick) {
+ this.warningStartTick = warningStartTick;
+ }
+
+ public boolean isAnimated() {
+ return animated;
+ }
+
+ public void setAnimated(boolean animated) {
+ this.animated = animated;
+ }
+
+ public float getHeightOffset() {
+ return heightOffset;
+ }
+
+ public void setHeightOffset(float heightOffset) {
+ this.heightOffset = heightOffset;
+ }
+
+ public boolean isAtTarget() {
+ return atTarget;
+ }
+
+ public void setAtTarget(boolean atTarget) {
+ this.atTarget = atTarget;
+ }
+
+ public boolean isFollowsTarget() {
+ return followsTarget;
+ }
+
+ public void setFollowsTarget(boolean followsTarget) {
+ this.followsTarget = followsTarget;
+ }
+
+ public boolean isFollowsCaster() {
+ return followsCaster;
+ }
+
+ public void setFollowsCaster(boolean followsCaster) {
+ this.followsCaster = followsCaster;
+ }
+
+ public float getOffsetForward() {
+ return offsetForward;
+ }
+
+ public void setOffsetForward(float offsetForward) {
+ this.offsetForward = offsetForward;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphInstance.java b/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphInstance.java
index b16a9f0f2..2d705fb15 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphInstance.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphInstance.java
@@ -55,6 +55,7 @@ public class TelegraphInstance {
/**
* Called every tick to update telegraph state.
+ *
* @param world The world (for entity lookup)
* @return false if telegraph should be removed
*/
@@ -90,10 +91,10 @@ public class TelegraphInstance {
* Find the ground level at a given position.
* Searches downward from the given Y to find a solid block.
*
- * @param world The world
- * @param x X coordinate
+ * @param world The world
+ * @param x X coordinate
* @param startY Starting Y coordinate (entity feet position)
- * @param z Z coordinate
+ * @param z Z coordinate
* @return The Y coordinate of the ground surface
*/
private double findGroundLevel(World world, double x, double startY, double z) {
@@ -207,42 +208,99 @@ public class TelegraphInstance {
// GETTERS & SETTERS
// ═══════════════════════════════════════════════════════════════════
- public String getInstanceId() { return instanceId; }
- public void setInstanceId(String instanceId) { this.instanceId = instanceId; }
+ public String getInstanceId() {
+ return instanceId;
+ }
- public Telegraph getTelegraph() { return telegraph; }
- public void setTelegraph(Telegraph telegraph) { this.telegraph = telegraph; }
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
- public double getX() { return x; }
- public void setX(double x) { this.x = x; }
+ public Telegraph getTelegraph() {
+ return telegraph;
+ }
- public double getY() { return y; }
- public void setY(double y) { this.y = y; }
+ public void setTelegraph(Telegraph telegraph) {
+ this.telegraph = telegraph;
+ }
- public double getZ() { return z; }
- public void setZ(double z) { this.z = z; }
+ public double getX() {
+ return x;
+ }
- public float getYaw() { return yaw; }
- public void setYaw(float yaw) { this.yaw = yaw; }
+ public void setX(double x) {
+ this.x = x;
+ }
- public int getEntityIdToFollow() { return entityIdToFollow; }
- public void setEntityIdToFollow(int entityIdToFollow) { this.entityIdToFollow = entityIdToFollow; }
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getZ() {
+ return z;
+ }
+
+ public void setZ(double z) {
+ this.z = z;
+ }
+
+ public float getYaw() {
+ return yaw;
+ }
+
+ public void setYaw(float yaw) {
+ this.yaw = yaw;
+ }
+
+ public int getEntityIdToFollow() {
+ return entityIdToFollow;
+ }
+
+ public void setEntityIdToFollow(int entityIdToFollow) {
+ this.entityIdToFollow = entityIdToFollow;
+ }
/**
* Locks the telegraph at its current position.
* Stops following any entity - used when ability commits to action.
*/
- public void lockPosition() { this.entityIdToFollow = -1; }
+ public void lockPosition() {
+ this.entityIdToFollow = -1;
+ }
- public int getCasterEntityId() { return casterEntityId; }
- public void setCasterEntityId(int casterEntityId) { this.casterEntityId = casterEntityId; }
+ public int getCasterEntityId() {
+ return casterEntityId;
+ }
- public int getRemainingTicks() { return remainingTicks; }
- public void setRemainingTicks(int remainingTicks) { this.remainingTicks = remainingTicks; }
+ public void setCasterEntityId(int casterEntityId) {
+ this.casterEntityId = casterEntityId;
+ }
- public int getTotalTicks() { return totalTicks; }
- public void setTotalTicks(int totalTicks) { this.totalTicks = totalTicks; }
+ public int getRemainingTicks() {
+ return remainingTicks;
+ }
- public boolean isWarning() { return isWarning; }
- public void setWarning(boolean warning) { isWarning = warning; }
+ public void setRemainingTicks(int remainingTicks) {
+ this.remainingTicks = remainingTicks;
+ }
+
+ public int getTotalTicks() {
+ return totalTicks;
+ }
+
+ public void setTotalTicks(int totalTicks) {
+ this.totalTicks = totalTicks;
+ }
+
+ public boolean isWarning() {
+ return isWarning;
+ }
+
+ public void setWarning(boolean warning) {
+ isWarning = warning;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphManager.java b/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphManager.java
index b82afffd2..3dc4f9e0f 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphManager.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphManager.java
@@ -12,12 +12,15 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class TelegraphManager {
- /** Client-side instance for rendering */
+ /**
+ * Client-side instance for rendering
+ */
public static TelegraphManager ClientInstance;
private final ConcurrentHashMap telegraphs = new ConcurrentHashMap<>();
- public TelegraphManager() {}
+ public TelegraphManager() {
+ }
/**
* Initialize the client-side manager.
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphType.java b/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphType.java
index dee9a249a..c7e4978b6 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphType.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/telegraph/TelegraphType.java
@@ -4,21 +4,33 @@ package kamkeel.npcs.controllers.data.ability.telegraph;
* Types of telegraph shapes for visual attack warnings.
*/
public enum TelegraphType {
- /** Filled circle (uses radius) */
+ /**
+ * Filled circle (uses radius)
+ */
CIRCLE,
- /** Donut shape (uses radius and innerRadius) */
+ /**
+ * Donut shape (uses radius and innerRadius)
+ */
RING,
- /** Rectangle (uses length, width) */
+ /**
+ * Rectangle (uses length, width)
+ */
LINE,
- /** Fan/wedge shape (uses length, angle) */
+ /**
+ * Fan/wedge shape (uses length, angle)
+ */
CONE,
- /** Single point indicator */
+ /**
+ * Single point indicator
+ */
POINT,
- /** No telegraph */
+ /**
+ * No telegraph
+ */
NONE
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityBeam.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityBeam.java
index f094a4f0d..a071fcb30 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityBeam.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityBeam.java
@@ -2,19 +2,17 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-
import kamkeel.npcs.controllers.data.ability.Ability;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
-import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityBeam;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
+import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
+import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityBeam;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -61,21 +59,25 @@ public class AbilityBeam extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
- IAbilityConfigCallback callback) {
+ IAbilityConfigCallback callback) {
return new SubGuiAbilityBeam(this, callback);
}
@Override
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
+ return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -184,7 +186,7 @@ public class AbilityBeam extends Ability {
}
private boolean isInBeamPath(EntityLivingBase entity, double startX, double startY, double startZ,
- double dirX, double dirZ) {
+ double dirX, double dirZ) {
// Project entity position onto beam line
double entityX = entity.posX - startX;
double entityZ = entity.posZ - startZ;
@@ -209,7 +211,7 @@ public class AbilityBeam extends Ability {
}
private void spawnBeamParticles(World world, double startX, double startY, double startZ,
- double dirX, double dirZ) {
+ double dirX, double dirZ) {
// Spawn particles along beam line
for (int i = 0; i < beamLength; i++) {
double px = startX + dirX * i;
@@ -259,30 +261,75 @@ public class AbilityBeam extends Ability {
}
// Getters & Setters
- public float getBeamLength() { return beamLength; }
- public void setBeamLength(float beamLength) { this.beamLength = beamLength; }
+ public float getBeamLength() {
+ return beamLength;
+ }
- public float getBeamWidth() { return beamWidth; }
- public void setBeamWidth(float beamWidth) { this.beamWidth = beamWidth; }
+ public void setBeamLength(float beamLength) {
+ this.beamLength = beamLength;
+ }
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public float getBeamWidth() {
+ return beamWidth;
+ }
- public int getDamageInterval() { return damageInterval; }
- public void setDamageInterval(int damageInterval) { this.damageInterval = damageInterval; }
+ public void setBeamWidth(float beamWidth) {
+ this.beamWidth = beamWidth;
+ }
- public boolean isPiercing() { return piercing; }
- public void setPiercing(boolean piercing) { this.piercing = piercing; }
+ public float getDamage() {
+ return damage;
+ }
- public float getSweepAngle() { return sweepAngle; }
- public void setSweepAngle(float sweepAngle) { this.sweepAngle = sweepAngle; }
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
- public float getSweepSpeed() { return sweepSpeed; }
- public void setSweepSpeed(float sweepSpeed) { this.sweepSpeed = sweepSpeed; }
+ public int getDamageInterval() {
+ return damageInterval;
+ }
- public boolean isSweepBackAndForth() { return sweepBackAndForth; }
- public void setSweepBackAndForth(boolean sweepBackAndForth) { this.sweepBackAndForth = sweepBackAndForth; }
+ public void setDamageInterval(int damageInterval) {
+ this.damageInterval = damageInterval;
+ }
- public boolean isLockOnTarget() { return lockOnTarget; }
- public void setLockOnTarget(boolean lockOnTarget) { this.lockOnTarget = lockOnTarget; }
+ public boolean isPiercing() {
+ return piercing;
+ }
+
+ public void setPiercing(boolean piercing) {
+ this.piercing = piercing;
+ }
+
+ public float getSweepAngle() {
+ return sweepAngle;
+ }
+
+ public void setSweepAngle(float sweepAngle) {
+ this.sweepAngle = sweepAngle;
+ }
+
+ public float getSweepSpeed() {
+ return sweepSpeed;
+ }
+
+ public void setSweepSpeed(float sweepSpeed) {
+ this.sweepSpeed = sweepSpeed;
+ }
+
+ public boolean isSweepBackAndForth() {
+ return sweepBackAndForth;
+ }
+
+ public void setSweepBackAndForth(boolean sweepBackAndForth) {
+ this.sweepBackAndForth = sweepBackAndForth;
+ }
+
+ public boolean isLockOnTarget() {
+ return lockOnTarget;
+ }
+
+ public void setLockOnTarget(boolean lockOnTarget) {
+ this.lockOnTarget = lockOnTarget;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCharge.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCharge.java
index 41e288c5b..abe05c643 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCharge.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCharge.java
@@ -11,12 +11,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.DamageSource;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityCharge;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -59,7 +58,9 @@ public class AbilityCharge extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
@@ -68,11 +69,13 @@ public class AbilityCharge extends Ability {
}
@Override
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
+ return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -150,7 +153,7 @@ public class AbilityCharge extends Ability {
// Calculate distance traveled
double distanceTraveled = Math.sqrt(
Math.pow(npc.posX - startX, 2) +
- Math.pow(npc.posZ - startZ, 2)
+ Math.pow(npc.posZ - startZ, 2)
);
// Check if reached max distance
@@ -305,15 +308,35 @@ public class AbilityCharge extends Ability {
}
// Getters & Setters
- public float getChargeSpeed() { return chargeSpeed; }
- public void setChargeSpeed(float chargeSpeed) { this.chargeSpeed = chargeSpeed; }
+ public float getChargeSpeed() {
+ return chargeSpeed;
+ }
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public void setChargeSpeed(float chargeSpeed) {
+ this.chargeSpeed = chargeSpeed;
+ }
- public float getKnockback() { return knockback; }
- public void setKnockback(float knockback) { this.knockback = knockback; }
+ public float getDamage() {
+ return damage;
+ }
- public float getHitWidth() { return hitWidth; }
- public void setHitWidth(float hitWidth) { this.hitWidth = hitWidth; }
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
+
+ public float getKnockback() {
+ return knockback;
+ }
+
+ public void setKnockback(float knockback) {
+ this.knockback = knockback;
+ }
+
+ public float getHitWidth() {
+ return hitWidth;
+ }
+
+ public void setHitWidth(float hitWidth) {
+ this.hitWidth = hitWidth;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCutter.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCutter.java
index b258e6127..89ff0e3f0 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCutter.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityCutter.java
@@ -12,9 +12,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityCutter;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -67,7 +67,9 @@ public class AbilityCutter extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
@@ -76,21 +78,29 @@ public class AbilityCutter extends Ability {
}
@Override
- public boolean isTargetingModeLocked() { return true; }
-
- @Override
- public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AOE_SELF };
+ public boolean isTargetingModeLocked() {
+ return true;
}
@Override
- public float getTelegraphRadius() { return range; }
+ public TargetingMode[] getAllowedTargetingModes() {
+ return new TargetingMode[]{TargetingMode.AOE_SELF};
+ }
@Override
- public float getTelegraphLength() { return range; }
+ public float getTelegraphRadius() {
+ return range;
+ }
@Override
- public float getTelegraphAngle() { return arcAngle; }
+ public float getTelegraphLength() {
+ return range;
+ }
+
+ @Override
+ public float getTelegraphAngle() {
+ return arcAngle;
+ }
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
@@ -145,7 +155,7 @@ public class AbilityCutter extends Ability {
hitEntities.add(entity.getEntityId());
- float distFactor = 1.0f - ((float)dist / maxDist) * 0.3f;
+ float distFactor = 1.0f - ((float) dist / maxDist) * 0.3f;
float actualDamage = damage * distFactor;
// Apply damage with scripted event support
@@ -223,38 +233,95 @@ public class AbilityCutter extends Ability {
}
// Getters & Setters
- public float getArcAngle() { return arcAngle; }
- public void setArcAngle(float arcAngle) { this.arcAngle = arcAngle; }
+ public float getArcAngle() {
+ return arcAngle;
+ }
- public float getRange() { return range; }
- public void setRange(float range) { this.range = range; }
+ public void setArcAngle(float arcAngle) {
+ this.arcAngle = arcAngle;
+ }
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public float getRange() {
+ return range;
+ }
- public float getKnockback() { return knockback; }
- public void setKnockback(float knockback) { this.knockback = knockback; }
+ public void setRange(float range) {
+ this.range = range;
+ }
- public SweepMode getSweepMode() { return sweepMode; }
- public void setSweepMode(SweepMode sweepMode) { this.sweepMode = sweepMode; }
+ public float getDamage() {
+ return damage;
+ }
- public float getSweepSpeed() { return sweepSpeed; }
- public void setSweepSpeed(float sweepSpeed) { this.sweepSpeed = sweepSpeed; }
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
- public int getStunDuration() { return stunDuration; }
- public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
+ public float getKnockback() {
+ return knockback;
+ }
- public int getPoisonDurationSeconds() { return poisonDurationSeconds; }
- public void setPoisonDurationSeconds(int poisonDurationSeconds) { this.poisonDurationSeconds = poisonDurationSeconds; }
+ public void setKnockback(float knockback) {
+ this.knockback = knockback;
+ }
- public int getPoisonLevel() { return poisonLevel; }
- public void setPoisonLevel(int poisonLevel) { this.poisonLevel = poisonLevel; }
+ public SweepMode getSweepMode() {
+ return sweepMode;
+ }
- public boolean isPiercing() { return piercing; }
- public void setPiercing(boolean piercing) { this.piercing = piercing; }
+ public void setSweepMode(SweepMode sweepMode) {
+ this.sweepMode = sweepMode;
+ }
- public float getInnerRadius() { return innerRadius; }
- public void setInnerRadius(float innerRadius) { this.innerRadius = innerRadius; }
+ public float getSweepSpeed() {
+ return sweepSpeed;
+ }
- public float getCurrentRotation() { return currentRotation; }
+ public void setSweepSpeed(float sweepSpeed) {
+ this.sweepSpeed = sweepSpeed;
+ }
+
+ public int getStunDuration() {
+ return stunDuration;
+ }
+
+ public void setStunDuration(int stunDuration) {
+ this.stunDuration = stunDuration;
+ }
+
+ public int getPoisonDurationSeconds() {
+ return poisonDurationSeconds;
+ }
+
+ public void setPoisonDurationSeconds(int poisonDurationSeconds) {
+ this.poisonDurationSeconds = poisonDurationSeconds;
+ }
+
+ public int getPoisonLevel() {
+ return poisonLevel;
+ }
+
+ public void setPoisonLevel(int poisonLevel) {
+ this.poisonLevel = poisonLevel;
+ }
+
+ public boolean isPiercing() {
+ return piercing;
+ }
+
+ public void setPiercing(boolean piercing) {
+ this.piercing = piercing;
+ }
+
+ public float getInnerRadius() {
+ return innerRadius;
+ }
+
+ public void setInnerRadius(float innerRadius) {
+ this.innerRadius = innerRadius;
+ }
+
+ public float getCurrentRotation() {
+ return currentRotation;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java
index db34b0bb8..0c0f9cf2c 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityDash.java
@@ -2,17 +2,16 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-
import kamkeel.npcs.controllers.data.ability.Ability;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
-import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityDash;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
+import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
+import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityDash;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.Random;
@@ -100,21 +99,25 @@ public class AbilityDash extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
- IAbilityConfigCallback callback) {
+ IAbilityConfigCallback callback) {
return new SubGuiAbilityDash(this, callback);
}
@Override
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
+ return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -163,7 +166,7 @@ public class AbilityDash extends Ability {
// Calculate distance traveled
double distanceTraveled = Math.sqrt(
Math.pow(npc.posX - startX, 2) +
- Math.pow(npc.posZ - startZ, 2)
+ Math.pow(npc.posZ - startZ, 2)
);
// Check if reached max distance
@@ -246,14 +249,31 @@ public class AbilityDash extends Ability {
}
// Getters & Setters
- public DashMode getDashMode() { return dashMode; }
- public void setDashMode(DashMode dashMode) { this.dashMode = dashMode; }
+ public DashMode getDashMode() {
+ return dashMode;
+ }
- public float getDashDistance() { return dashDistance; }
- public void setDashDistance(float dashDistance) { this.dashDistance = dashDistance; }
+ public void setDashMode(DashMode dashMode) {
+ this.dashMode = dashMode;
+ }
- public float getDashSpeed() { return dashSpeed; }
- public void setDashSpeed(float dashSpeed) { this.dashSpeed = dashSpeed; }
+ public float getDashDistance() {
+ return dashDistance;
+ }
- public DashDirection getChosenDirection() { return chosenDirection; }
+ public void setDashDistance(float dashDistance) {
+ this.dashDistance = dashDistance;
+ }
+
+ public float getDashSpeed() {
+ return dashSpeed;
+ }
+
+ public void setDashSpeed(float dashSpeed) {
+ this.dashSpeed = dashSpeed;
+ }
+
+ public DashDirection getChosenDirection() {
+ return chosenDirection;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java
index 2ef0a446c..2427255fe 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityGuard.java
@@ -2,17 +2,16 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-
import kamkeel.npcs.controllers.data.ability.Ability;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
-import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityGuard;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
+import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
+import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityGuard;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.Random;
@@ -62,21 +61,25 @@ public class AbilityGuard extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
- IAbilityConfigCallback callback) {
+ IAbilityConfigCallback callback) {
return new SubGuiAbilityGuard(this, callback);
}
@Override
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.SELF };
+ return new TargetingMode[]{TargetingMode.SELF};
}
@Override
@@ -99,7 +102,7 @@ public class AbilityGuard extends Ability {
* This should be called from the damage handling code.
*
* @param attacker The entity that attacked
- * @param damage The damage amount (after reduction)
+ * @param damage The damage amount (after reduction)
*/
public void onDamageTaken(EntityNPCInterface npc, EntityLivingBase attacker, DamageSource source, float damage) {
if (!canCounter || attacker == null) return;
@@ -212,24 +215,59 @@ public class AbilityGuard extends Ability {
}
// Getters & Setters
- public float getDamageReduction() { return damageReduction; }
- public void setDamageReduction(float damageReduction) { this.damageReduction = damageReduction; }
+ public float getDamageReduction() {
+ return damageReduction;
+ }
- public boolean isCanCounter() { return canCounter; }
- public void setCanCounter(boolean canCounter) { this.canCounter = canCounter; }
+ public void setDamageReduction(float damageReduction) {
+ this.damageReduction = damageReduction;
+ }
- public CounterType getCounterType() { return counterType; }
- public void setCounterType(CounterType counterType) { this.counterType = counterType; }
+ public boolean isCanCounter() {
+ return canCounter;
+ }
- public float getCounterValue() { return counterValue; }
- public void setCounterValue(float counterValue) { this.counterValue = counterValue; }
+ public void setCanCounter(boolean canCounter) {
+ this.canCounter = canCounter;
+ }
- public float getCounterChance() { return counterChance; }
- public void setCounterChance(float counterChance) { this.counterChance = counterChance; }
+ public CounterType getCounterType() {
+ return counterType;
+ }
- public String getCounterSound() { return counterSound; }
- public void setCounterSound(String counterSound) { this.counterSound = counterSound; }
+ public void setCounterType(CounterType counterType) {
+ this.counterType = counterType;
+ }
- public int getCounterAnimationId() { return counterAnimationId; }
- public void setCounterAnimationId(int counterAnimationId) { this.counterAnimationId = counterAnimationId; }
+ public float getCounterValue() {
+ return counterValue;
+ }
+
+ public void setCounterValue(float counterValue) {
+ this.counterValue = counterValue;
+ }
+
+ public float getCounterChance() {
+ return counterChance;
+ }
+
+ public void setCounterChance(float counterChance) {
+ this.counterChance = counterChance;
+ }
+
+ public String getCounterSound() {
+ return counterSound;
+ }
+
+ public void setCounterSound(String counterSound) {
+ this.counterSound = counterSound;
+ }
+
+ public int getCounterAnimationId() {
+ return counterAnimationId;
+ }
+
+ public void setCounterAnimationId(int counterAnimationId) {
+ this.counterAnimationId = counterAnimationId;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHazard.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHazard.java
index d211e7516..b8ce70929 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHazard.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHazard.java
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-
import kamkeel.npcs.controllers.data.ability.Ability;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
-import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHazard;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
@@ -17,6 +13,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
+import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
+import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHazard;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -90,25 +89,31 @@ public class AbilityHazard extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
- IAbilityConfigCallback callback) {
+ IAbilityConfigCallback callback) {
return new SubGuiAbilityHazard(this, callback);
}
@Override
- public boolean isTargetingModeLocked() { return true; }
-
- @Override
- public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
+ public boolean isTargetingModeLocked() {
+ return true;
}
@Override
- public float getTelegraphRadius() { return radius; }
+ public TargetingMode[] getAllowedTargetingModes() {
+ return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
+ }
+
+ @Override
+ public float getTelegraphRadius() {
+ return radius;
+ }
@Override
public TelegraphInstance createTelegraph(EntityNPCInterface npc, EntityLivingBase target) {
@@ -414,68 +419,176 @@ public class AbilityHazard extends Ability {
}
// Getters & Setters
- public float getRadius() { return radius; }
- public void setRadius(float radius) { this.radius = radius; }
+ public float getRadius() {
+ return radius;
+ }
- public float getInnerRadius() { return innerRadius; }
- public void setInnerRadius(float innerRadius) { this.innerRadius = innerRadius; }
+ public void setRadius(float radius) {
+ this.radius = radius;
+ }
- public float getConeAngle() { return coneAngle; }
- public void setConeAngle(float coneAngle) { this.coneAngle = coneAngle; }
+ public float getInnerRadius() {
+ return innerRadius;
+ }
- public HazardShape getShape() { return shape; }
- public void setShape(HazardShape shape) { this.shape = shape; }
+ public void setInnerRadius(float innerRadius) {
+ this.innerRadius = innerRadius;
+ }
- public PlacementMode getPlacement() { return placement; }
- public void setPlacement(PlacementMode placement) { this.placement = placement; }
+ public float getConeAngle() {
+ return coneAngle;
+ }
- public float getDamagePerTick() { return damagePerTick; }
- public void setDamagePerTick(float damagePerTick) { this.damagePerTick = damagePerTick; }
+ public void setConeAngle(float coneAngle) {
+ this.coneAngle = coneAngle;
+ }
- public int getDamageInterval() { return damageInterval; }
- public void setDamageInterval(int damageInterval) { this.damageInterval = damageInterval; }
+ public HazardShape getShape() {
+ return shape;
+ }
- public boolean isIgnoreInvulnFrames() { return ignoreInvulnFrames; }
- public void setIgnoreInvulnFrames(boolean ignoreInvulnFrames) { this.ignoreInvulnFrames = ignoreInvulnFrames; }
+ public void setShape(HazardShape shape) {
+ this.shape = shape;
+ }
- public int getSlownessLevel() { return slownessLevel; }
- public void setSlownessLevel(int slownessLevel) { this.slownessLevel = slownessLevel; }
+ public PlacementMode getPlacement() {
+ return placement;
+ }
- public int getWeaknessLevel() { return weaknessLevel; }
- public void setWeaknessLevel(int weaknessLevel) { this.weaknessLevel = weaknessLevel; }
+ public void setPlacement(PlacementMode placement) {
+ this.placement = placement;
+ }
- public int getPoisonLevel() { return poisonLevel; }
- public void setPoisonLevel(int poisonLevel) { this.poisonLevel = poisonLevel; }
+ public float getDamagePerTick() {
+ return damagePerTick;
+ }
- public int getWitherLevel() { return witherLevel; }
- public void setWitherLevel(int witherLevel) { this.witherLevel = witherLevel; }
+ public void setDamagePerTick(float damagePerTick) {
+ this.damagePerTick = damagePerTick;
+ }
- public int getBlindnessLevel() { return blindnessLevel; }
- public void setBlindnessLevel(int blindnessLevel) { this.blindnessLevel = blindnessLevel; }
+ public int getDamageInterval() {
+ return damageInterval;
+ }
- public int getDebuffDuration() { return debuffDuration; }
- public void setDebuffDuration(int debuffDuration) { this.debuffDuration = debuffDuration; }
+ public void setDamageInterval(int damageInterval) {
+ this.damageInterval = damageInterval;
+ }
- public boolean isAffectsCaster() { return affectsCaster; }
- public void setAffectsCaster(boolean affectsCaster) { this.affectsCaster = affectsCaster; }
+ public boolean isIgnoreInvulnFrames() {
+ return ignoreInvulnFrames;
+ }
- public float getHeightAbove() { return heightAbove; }
- public void setHeightAbove(float heightAbove) { this.heightAbove = heightAbove; }
+ public void setIgnoreInvulnFrames(boolean ignoreInvulnFrames) {
+ this.ignoreInvulnFrames = ignoreInvulnFrames;
+ }
- public float getHeightBelow() { return heightBelow; }
- public void setHeightBelow(float heightBelow) { this.heightBelow = heightBelow; }
+ public int getSlownessLevel() {
+ return slownessLevel;
+ }
- public float getMinOffset() { return minOffset; }
- public void setMinOffset(float minOffset) { this.minOffset = minOffset; }
+ public void setSlownessLevel(int slownessLevel) {
+ this.slownessLevel = slownessLevel;
+ }
- public float getMaxOffset() { return maxOffset; }
- public void setMaxOffset(float maxOffset) { this.maxOffset = maxOffset; }
+ public int getWeaknessLevel() {
+ return weaknessLevel;
+ }
- public boolean isRandomOffset() { return randomOffset; }
- public void setRandomOffset(boolean randomOffset) { this.randomOffset = randomOffset; }
+ public void setWeaknessLevel(int weaknessLevel) {
+ this.weaknessLevel = weaknessLevel;
+ }
+
+ public int getPoisonLevel() {
+ return poisonLevel;
+ }
+
+ public void setPoisonLevel(int poisonLevel) {
+ this.poisonLevel = poisonLevel;
+ }
+
+ public int getWitherLevel() {
+ return witherLevel;
+ }
+
+ public void setWitherLevel(int witherLevel) {
+ this.witherLevel = witherLevel;
+ }
+
+ public int getBlindnessLevel() {
+ return blindnessLevel;
+ }
+
+ public void setBlindnessLevel(int blindnessLevel) {
+ this.blindnessLevel = blindnessLevel;
+ }
+
+ public int getDebuffDuration() {
+ return debuffDuration;
+ }
+
+ public void setDebuffDuration(int debuffDuration) {
+ this.debuffDuration = debuffDuration;
+ }
+
+ public boolean isAffectsCaster() {
+ return affectsCaster;
+ }
+
+ public void setAffectsCaster(boolean affectsCaster) {
+ this.affectsCaster = affectsCaster;
+ }
+
+ public float getHeightAbove() {
+ return heightAbove;
+ }
+
+ public void setHeightAbove(float heightAbove) {
+ this.heightAbove = heightAbove;
+ }
+
+ public float getHeightBelow() {
+ return heightBelow;
+ }
+
+ public void setHeightBelow(float heightBelow) {
+ this.heightBelow = heightBelow;
+ }
+
+ public float getMinOffset() {
+ return minOffset;
+ }
+
+ public void setMinOffset(float minOffset) {
+ this.minOffset = minOffset;
+ }
+
+ public float getMaxOffset() {
+ return maxOffset;
+ }
+
+ public void setMaxOffset(float maxOffset) {
+ this.maxOffset = maxOffset;
+ }
+
+ public boolean isRandomOffset() {
+ return randomOffset;
+ }
+
+ public void setRandomOffset(boolean randomOffset) {
+ this.randomOffset = randomOffset;
+ }
// Runtime getters
- public double getZoneX() { return zoneX; }
- public double getZoneY() { return zoneY; }
- public double getZoneZ() { return zoneZ; }
+ public double getZoneX() {
+ return zoneX;
+ }
+
+ public double getZoneY() {
+ return zoneY;
+ }
+
+ public double getZoneZ() {
+ return zoneZ;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java
index 4a393682b..cae5f6815 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeal.java
@@ -10,9 +10,9 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeal;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
@@ -50,7 +50,9 @@ public class AbilityHeal extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
@@ -59,11 +61,13 @@ public class AbilityHeal extends Ability {
}
@Override
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.SELF };
+ return new TargetingMode[]{TargetingMode.SELF};
}
@Override
@@ -197,21 +201,51 @@ public class AbilityHeal extends Ability {
}
// Getters & Setters
- public float getHealAmount() { return healAmount; }
- public void setHealAmount(float healAmount) { this.healAmount = healAmount; }
+ public float getHealAmount() {
+ return healAmount;
+ }
- public float getHealPercent() { return healPercent; }
- public void setHealPercent(float healPercent) { this.healPercent = healPercent; }
+ public void setHealAmount(float healAmount) {
+ this.healAmount = healAmount;
+ }
- public boolean isHealSelf() { return healSelf; }
- public void setHealSelf(boolean healSelf) { this.healSelf = healSelf; }
+ public float getHealPercent() {
+ return healPercent;
+ }
- public boolean isHealAllies() { return healAllies; }
- public void setHealAllies(boolean healAllies) { this.healAllies = healAllies; }
+ public void setHealPercent(float healPercent) {
+ this.healPercent = healPercent;
+ }
- public float getHealRadius() { return healRadius; }
- public void setHealRadius(float healRadius) { this.healRadius = healRadius; }
+ public boolean isHealSelf() {
+ return healSelf;
+ }
- public boolean isInstantHeal() { return instantHeal; }
- public void setInstantHeal(boolean instantHeal) { this.instantHeal = instantHeal; }
+ public void setHealSelf(boolean healSelf) {
+ this.healSelf = healSelf;
+ }
+
+ public boolean isHealAllies() {
+ return healAllies;
+ }
+
+ public void setHealAllies(boolean healAllies) {
+ this.healAllies = healAllies;
+ }
+
+ public float getHealRadius() {
+ return healRadius;
+ }
+
+ public void setHealRadius(float healRadius) {
+ this.healRadius = healRadius;
+ }
+
+ public boolean isInstantHeal() {
+ return instantHeal;
+ }
+
+ public void setInstantHeal(boolean instantHeal) {
+ this.instantHeal = instantHeal;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeavyHit.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeavyHit.java
index 288af63d7..caafc9d5d 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeavyHit.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityHeavyHit.java
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-
import kamkeel.npcs.controllers.data.ability.Ability;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
-import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeavyHit;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
@@ -14,6 +10,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
+import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
+import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeavyHit;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
/**
@@ -46,21 +45,25 @@ public class AbilityHeavyHit extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
- IAbilityConfigCallback callback) {
+ IAbilityConfigCallback callback) {
return new SubGuiAbilityHeavyHit(this, callback);
}
@Override
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
+ return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -105,18 +108,43 @@ public class AbilityHeavyHit extends Ability {
}
// Getters & Setters
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public float getDamage() {
+ return damage;
+ }
- public float getKnockback() { return knockback; }
- public void setKnockback(float knockback) { this.knockback = knockback; }
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
- public int getSlownessLevel() { return slownessLevel; }
- public void setSlownessLevel(int slownessLevel) { this.slownessLevel = slownessLevel; }
+ public float getKnockback() {
+ return knockback;
+ }
- public int getWeaknessLevel() { return weaknessLevel; }
- public void setWeaknessLevel(int weaknessLevel) { this.weaknessLevel = weaknessLevel; }
+ public void setKnockback(float knockback) {
+ this.knockback = knockback;
+ }
- public int getPotionDurationSeconds() { return potionDurationSeconds; }
- public void setPotionDurationSeconds(int potionDurationSeconds) { this.potionDurationSeconds = potionDurationSeconds; }
+ public int getSlownessLevel() {
+ return slownessLevel;
+ }
+
+ public void setSlownessLevel(int slownessLevel) {
+ this.slownessLevel = slownessLevel;
+ }
+
+ public int getWeaknessLevel() {
+ return weaknessLevel;
+ }
+
+ public void setWeaknessLevel(int weaknessLevel) {
+ this.weaknessLevel = weaknessLevel;
+ }
+
+ public int getPotionDurationSeconds() {
+ return potionDurationSeconds;
+ }
+
+ public void setPotionDurationSeconds(int potionDurationSeconds) {
+ this.potionDurationSeconds = potionDurationSeconds;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrb.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrb.java
index cf1555898..a3677a9db 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrb.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityOrb.java
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-
import kamkeel.npcs.controllers.data.ability.Ability;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
-import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityOrb;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
@@ -16,6 +12,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
+import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
+import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityOrb;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
@@ -67,21 +66,25 @@ public class AbilityOrb extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
- IAbilityConfigCallback callback) {
+ IAbilityConfigCallback callback) {
return new SubGuiAbilityOrb(this, callback);
}
@Override
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
+ return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -124,8 +127,8 @@ public class AbilityOrb extends Ability {
double distTraveled = Math.sqrt(
Math.pow(orbX - startX, 2) +
- Math.pow(orbY - startY, 2) +
- Math.pow(orbZ - startZ, 2)
+ Math.pow(orbY - startY, 2) +
+ Math.pow(orbZ - startZ, 2)
);
if (distTraveled >= maxDistance) {
hasHit = true;
@@ -139,8 +142,8 @@ public class AbilityOrb extends Ability {
double distToTarget = Math.sqrt(
Math.pow(targetX - orbX, 2) +
- Math.pow(targetY - orbY, 2) +
- Math.pow(targetZ - orbZ, 2)
+ Math.pow(targetY - orbY, 2) +
+ Math.pow(targetZ - orbZ, 2)
);
if (distToTarget <= homingRange) {
@@ -202,7 +205,7 @@ public class AbilityOrb extends Ability {
break;
}
- if (!hasHit && world.getBlock((int)orbX, (int)orbY, (int)orbZ).getMaterial().isSolid()) {
+ if (!hasHit && world.getBlock((int) orbX, (int) orbY, (int) orbZ).getMaterial().isSolid()) {
hasHit = true;
if (explosive) {
doExplosion(npc, world);
@@ -224,12 +227,12 @@ public class AbilityOrb extends Ability {
double dist = Math.sqrt(
Math.pow(blastTarget.posX - orbX, 2) +
- Math.pow(blastTarget.posY - orbY, 2) +
- Math.pow(blastTarget.posZ - orbZ, 2)
+ Math.pow(blastTarget.posY - orbY, 2) +
+ Math.pow(blastTarget.posZ - orbZ, 2)
);
if (dist <= explosionRadius) {
- float falloff = 1.0f - (float)(dist / explosionRadius) * explosionDamageFalloff;
+ float falloff = 1.0f - (float) (dist / explosionRadius) * explosionDamageFalloff;
// Apply damage with scripted event support
boolean wasHit = applyAbilityDamage(npc, blastTarget, damage * falloff, knockback * falloff);
if (wasHit) {
@@ -314,54 +317,140 @@ public class AbilityOrb extends Ability {
}
// Getters & Setters
- public float getOrbSpeed() { return orbSpeed; }
- public void setOrbSpeed(float orbSpeed) { this.orbSpeed = orbSpeed; }
+ public float getOrbSpeed() {
+ return orbSpeed;
+ }
- public float getOrbSize() { return orbSize; }
- public void setOrbSize(float orbSize) { this.orbSize = orbSize; }
+ public void setOrbSpeed(float orbSpeed) {
+ this.orbSpeed = orbSpeed;
+ }
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public float getOrbSize() {
+ return orbSize;
+ }
- public float getKnockback() { return knockback; }
- public void setKnockback(float knockback) { this.knockback = knockback; }
+ public void setOrbSize(float orbSize) {
+ this.orbSize = orbSize;
+ }
- public float getMaxDistance() { return maxDistance; }
- public void setMaxDistance(float maxDistance) { this.maxDistance = maxDistance; }
+ public float getDamage() {
+ return damage;
+ }
- public int getMaxLifetime() { return maxLifetime; }
- public void setMaxLifetime(int maxLifetime) { this.maxLifetime = maxLifetime; }
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
- public boolean isHoming() { return homing; }
- public void setHoming(boolean homing) { this.homing = homing; }
+ public float getKnockback() {
+ return knockback;
+ }
- public float getHomingStrength() { return homingStrength; }
- public void setHomingStrength(float homingStrength) { this.homingStrength = homingStrength; }
+ public void setKnockback(float knockback) {
+ this.knockback = knockback;
+ }
- public float getHomingRange() { return homingRange; }
- public void setHomingRange(float homingRange) { this.homingRange = homingRange; }
+ public float getMaxDistance() {
+ return maxDistance;
+ }
- public boolean isExplosive() { return explosive; }
- public void setExplosive(boolean explosive) { this.explosive = explosive; }
+ public void setMaxDistance(float maxDistance) {
+ this.maxDistance = maxDistance;
+ }
- public float getExplosionRadius() { return explosionRadius; }
- public void setExplosionRadius(float explosionRadius) { this.explosionRadius = explosionRadius; }
+ public int getMaxLifetime() {
+ return maxLifetime;
+ }
- public float getExplosionDamageFalloff() { return explosionDamageFalloff; }
- public void setExplosionDamageFalloff(float explosionDamageFalloff) { this.explosionDamageFalloff = explosionDamageFalloff; }
+ public void setMaxLifetime(int maxLifetime) {
+ this.maxLifetime = maxLifetime;
+ }
- public int getStunDuration() { return stunDuration; }
- public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
+ public boolean isHoming() {
+ return homing;
+ }
- public int getSlowDuration() { return slowDuration; }
- public void setSlowDuration(int slowDuration) { this.slowDuration = slowDuration; }
+ public void setHoming(boolean homing) {
+ this.homing = homing;
+ }
- public int getSlowLevel() { return slowLevel; }
- public void setSlowLevel(int slowLevel) { this.slowLevel = slowLevel; }
+ public float getHomingStrength() {
+ return homingStrength;
+ }
+
+ public void setHomingStrength(float homingStrength) {
+ this.homingStrength = homingStrength;
+ }
+
+ public float getHomingRange() {
+ return homingRange;
+ }
+
+ public void setHomingRange(float homingRange) {
+ this.homingRange = homingRange;
+ }
+
+ public boolean isExplosive() {
+ return explosive;
+ }
+
+ public void setExplosive(boolean explosive) {
+ this.explosive = explosive;
+ }
+
+ public float getExplosionRadius() {
+ return explosionRadius;
+ }
+
+ public void setExplosionRadius(float explosionRadius) {
+ this.explosionRadius = explosionRadius;
+ }
+
+ public float getExplosionDamageFalloff() {
+ return explosionDamageFalloff;
+ }
+
+ public void setExplosionDamageFalloff(float explosionDamageFalloff) {
+ this.explosionDamageFalloff = explosionDamageFalloff;
+ }
+
+ public int getStunDuration() {
+ return stunDuration;
+ }
+
+ public void setStunDuration(int stunDuration) {
+ this.stunDuration = stunDuration;
+ }
+
+ public int getSlowDuration() {
+ return slowDuration;
+ }
+
+ public void setSlowDuration(int slowDuration) {
+ this.slowDuration = slowDuration;
+ }
+
+ public int getSlowLevel() {
+ return slowLevel;
+ }
+
+ public void setSlowLevel(int slowLevel) {
+ this.slowLevel = slowLevel;
+ }
// Runtime getters for rendering
- public double getOrbX() { return orbX; }
- public double getOrbY() { return orbY; }
- public double getOrbZ() { return orbZ; }
- public boolean hasHit() { return hasHit; }
+ public double getOrbX() {
+ return orbX;
+ }
+
+ public double getOrbY() {
+ return orbY;
+ }
+
+ public double getOrbZ() {
+ return orbZ;
+ }
+
+ public boolean hasHit() {
+ return hasHit;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityProjectile.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityProjectile.java
index 4d2143b36..b47cd244a 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityProjectile.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityProjectile.java
@@ -8,11 +8,10 @@ import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityProjectile;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
@@ -49,7 +48,9 @@ public class AbilityProjectile extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
@@ -58,11 +59,13 @@ public class AbilityProjectile extends Ability {
}
@Override
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
+ return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -187,27 +190,67 @@ public class AbilityProjectile extends Ability {
}
// Getters & Setters
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public float getDamage() {
+ return damage;
+ }
- public float getSpeed() { return speed; }
- public void setSpeed(float speed) { this.speed = speed; }
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
- public float getKnockback() { return knockback; }
- public void setKnockback(float knockback) { this.knockback = knockback; }
+ public float getSpeed() {
+ return speed;
+ }
- public String getProjectileType() { return projectileType; }
- public void setProjectileType(String projectileType) { this.projectileType = projectileType; }
+ public void setSpeed(float speed) {
+ this.speed = speed;
+ }
- public boolean isExplosive() { return explosive; }
- public void setExplosive(boolean explosive) { this.explosive = explosive; }
+ public float getKnockback() {
+ return knockback;
+ }
- public float getExplosionRadius() { return explosionRadius; }
- public void setExplosionRadius(float explosionRadius) { this.explosionRadius = explosionRadius; }
+ public void setKnockback(float knockback) {
+ this.knockback = knockback;
+ }
- public boolean isHoming() { return homing; }
- public void setHoming(boolean homing) { this.homing = homing; }
+ public String getProjectileType() {
+ return projectileType;
+ }
- public float getHomingStrength() { return homingStrength; }
- public void setHomingStrength(float homingStrength) { this.homingStrength = homingStrength; }
+ public void setProjectileType(String projectileType) {
+ this.projectileType = projectileType;
+ }
+
+ public boolean isExplosive() {
+ return explosive;
+ }
+
+ public void setExplosive(boolean explosive) {
+ this.explosive = explosive;
+ }
+
+ public float getExplosionRadius() {
+ return explosionRadius;
+ }
+
+ public void setExplosionRadius(float explosionRadius) {
+ this.explosionRadius = explosionRadius;
+ }
+
+ public boolean isHoming() {
+ return homing;
+ }
+
+ public void setHoming(boolean homing) {
+ this.homing = homing;
+ }
+
+ public float getHomingStrength() {
+ return homingStrength;
+ }
+
+ public void setHomingStrength(float homingStrength) {
+ this.homingStrength = homingStrength;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityShockwave.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityShockwave.java
index 340b92826..e15cf683a 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityShockwave.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityShockwave.java
@@ -12,9 +12,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityShockwave;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
@@ -50,7 +50,9 @@ public class AbilityShockwave extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
@@ -59,15 +61,19 @@ public class AbilityShockwave extends Ability {
}
@Override
- public boolean isTargetingModeLocked() { return true; }
-
- @Override
- public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AOE_SELF };
+ public boolean isTargetingModeLocked() {
+ return true;
}
@Override
- public float getTelegraphRadius() { return pushRadius; }
+ public TargetingMode[] getAllowedTargetingModes() {
+ return new TargetingMode[]{TargetingMode.AOE_SELF};
+ }
+
+ @Override
+ public float getTelegraphRadius() {
+ return pushRadius;
+ }
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
@@ -111,7 +117,7 @@ public class AbilityShockwave extends Ability {
}
// Scale knockback by distance (closer = stronger)
- float distFactor = 1.0f - (float)(dist / pushRadius) * 0.5f;
+ float distFactor = 1.0f - (float) (dist / pushRadius) * 0.5f;
float finalPush = pushStrength * distFactor;
// Apply damage with custom knockback direction
boolean wasHit = applyAbilityDamageWithDirection(npc, entity, damage * distFactor, finalPush, dx, dz);
@@ -153,19 +159,44 @@ public class AbilityShockwave extends Ability {
}
// Getters & Setters
- public float getPushRadius() { return pushRadius; }
- public void setPushRadius(float pushRadius) { this.pushRadius = pushRadius; }
+ public float getPushRadius() {
+ return pushRadius;
+ }
- public float getPushStrength() { return pushStrength; }
- public void setPushStrength(float pushStrength) { this.pushStrength = pushStrength; }
+ public void setPushRadius(float pushRadius) {
+ this.pushRadius = pushRadius;
+ }
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public float getPushStrength() {
+ return pushStrength;
+ }
- public int getStunDuration() { return stunDuration; }
- public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
+ public void setPushStrength(float pushStrength) {
+ this.pushStrength = pushStrength;
+ }
- public int getMaxTargets() { return maxTargets; }
- public void setMaxTargets(int maxTargets) { this.maxTargets = maxTargets; }
+ public float getDamage() {
+ return damage;
+ }
+
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
+
+ public int getStunDuration() {
+ return stunDuration;
+ }
+
+ public void setStunDuration(int stunDuration) {
+ this.stunDuration = stunDuration;
+ }
+
+ public int getMaxTargets() {
+ return maxTargets;
+ }
+
+ public void setMaxTargets(int maxTargets) {
+ this.maxTargets = maxTargets;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySlam.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySlam.java
index 321b9058f..1b0eb246f 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySlam.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilitySlam.java
@@ -11,18 +11,17 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
-import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilitySlam;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
/**
* Slam ability: NPC leaps toward target in an arc and slams down, dealing AOE damage on landing.
- *
+ *
* Phases:
* - WINDUP: NPC prepares to leap, telegraph shows landing zone
* - ACTIVE: NPC is in the air, traveling in arc toward destination
@@ -62,7 +61,9 @@ public class AbilitySlam extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
@@ -80,7 +81,7 @@ public class AbilitySlam extends Ability {
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AOE_SELF, TargetingMode.AOE_TARGET };
+ return new TargetingMode[]{TargetingMode.AOE_SELF, TargetingMode.AOE_TARGET};
}
@Override
@@ -317,7 +318,7 @@ public class AbilitySlam extends Ability {
}
// Ground crack particles - check if block is valid
- net.minecraft.block.Block groundBlock = world.getBlock((int)x, (int)y - 1, (int)z);
+ net.minecraft.block.Block groundBlock = world.getBlock((int) x, (int) y - 1, (int) z);
if (groundBlock != null && groundBlock.getMaterial().isSolid()) {
int blockId = net.minecraft.block.Block.getIdFromBlock(groundBlock);
if (blockId > 0) {
@@ -427,18 +428,43 @@ public class AbilitySlam extends Ability {
}
// Getters & Setters
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public float getDamage() {
+ return damage;
+ }
- public float getRadius() { return radius; }
- public void setRadius(float radius) { this.radius = radius; }
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
- public float getKnockbackStrength() { return knockbackStrength; }
- public void setKnockbackStrength(float knockbackStrength) { this.knockbackStrength = knockbackStrength; }
+ public float getRadius() {
+ return radius;
+ }
- public float getLeapSpeed() { return leapSpeed; }
- public void setLeapSpeed(float leapSpeed) { this.leapSpeed = leapSpeed; }
+ public void setRadius(float radius) {
+ this.radius = radius;
+ }
- public float getLeapHeight() { return leapHeight; }
- public void setLeapHeight(float leapHeight) { this.leapHeight = leapHeight; }
+ public float getKnockbackStrength() {
+ return knockbackStrength;
+ }
+
+ public void setKnockbackStrength(float knockbackStrength) {
+ this.knockbackStrength = knockbackStrength;
+ }
+
+ public float getLeapSpeed() {
+ return leapSpeed;
+ }
+
+ public void setLeapSpeed(float leapSpeed) {
+ this.leapSpeed = leapSpeed;
+ }
+
+ public float getLeapHeight() {
+ return leapHeight;
+ }
+
+ public void setLeapHeight(float leapHeight) {
+ this.leapHeight = leapHeight;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java
index 72971c572..50d59e729 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTeleport.java
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-
import kamkeel.npcs.controllers.data.ability.Ability;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
-import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityTeleport;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.block.Block;
@@ -14,10 +10,12 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
+import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
+import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityTeleport;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
@@ -73,21 +71,25 @@ public class AbilityTeleport extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
- IAbilityConfigCallback callback) {
+ IAbilityConfigCallback callback) {
return new SubGuiAbilityTeleport(this, callback);
}
@Override
- public boolean isTargetingModeLocked() { return true; }
+ public boolean isTargetingModeLocked() {
+ return true;
+ }
@Override
public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
+ return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -202,7 +204,7 @@ public class AbilityTeleport extends Ability {
}
private Vec3 findSafeDestination(World world, double oldX, double oldY, double oldZ,
- double destX, double destY, double destZ) {
+ double destX, double destY, double destZ) {
int oldBlockX = (int) Math.floor(oldX);
int oldBlockY = (int) Math.floor(oldY);
int oldBlockZ = (int) Math.floor(oldZ);
@@ -291,7 +293,7 @@ public class AbilityTeleport extends Ability {
double checkZ = z1 + dz * d;
if (hasLineOfSight(world, x1, y1 + npc.getEyeHeight(), z1,
- checkX, checkY + npc.getEyeHeight(), checkZ)) {
+ checkX, checkY + npc.getEyeHeight(), checkZ)) {
int blockX = MathHelper.floor_double(checkX);
int blockY = MathHelper.floor_double(checkY);
int blockZ = MathHelper.floor_double(checkZ);
@@ -330,8 +332,8 @@ public class AbilityTeleport extends Ability {
Block headBlock = world.getBlock(x, y + 1, z);
return groundBlock.getMaterial().isSolid() &&
- !feetBlock.getMaterial().isSolid() &&
- !headBlock.getMaterial().isSolid();
+ !feetBlock.getMaterial().isSolid() &&
+ !headBlock.getMaterial().isSolid();
}
private void dealDamageAt(EntityNPCInterface npc, World world, double x, double y, double z) {
@@ -414,33 +416,83 @@ public class AbilityTeleport extends Ability {
}
// Getters & Setters
- public TeleportMode getMode() { return mode; }
- public void setMode(TeleportMode mode) { this.mode = mode; }
+ public TeleportMode getMode() {
+ return mode;
+ }
- public int getBlinkCount() { return blinkCount; }
- public void setBlinkCount(int blinkCount) { this.blinkCount = blinkCount; }
+ public void setMode(TeleportMode mode) {
+ this.mode = mode;
+ }
- public int getBlinkDelayTicks() { return blinkDelayTicks; }
- public void setBlinkDelayTicks(int blinkDelayTicks) { this.blinkDelayTicks = blinkDelayTicks; }
+ public int getBlinkCount() {
+ return blinkCount;
+ }
- public float getBlinkRadius() { return blinkRadius; }
- public void setBlinkRadius(float blinkRadius) { this.blinkRadius = blinkRadius; }
+ public void setBlinkCount(int blinkCount) {
+ this.blinkCount = blinkCount;
+ }
- public float getBehindDistance() { return behindDistance; }
- public void setBehindDistance(float behindDistance) { this.behindDistance = behindDistance; }
+ public int getBlinkDelayTicks() {
+ return blinkDelayTicks;
+ }
- public boolean isRequireLineOfSight() { return requireLineOfSight; }
- public void setRequireLineOfSight(boolean requireLineOfSight) { this.requireLineOfSight = requireLineOfSight; }
+ public void setBlinkDelayTicks(int blinkDelayTicks) {
+ this.blinkDelayTicks = blinkDelayTicks;
+ }
- public boolean isDamageAtStart() { return damageAtStart; }
- public void setDamageAtStart(boolean damageAtStart) { this.damageAtStart = damageAtStart; }
+ public float getBlinkRadius() {
+ return blinkRadius;
+ }
- public boolean isDamageAtEnd() { return damageAtEnd; }
- public void setDamageAtEnd(boolean damageAtEnd) { this.damageAtEnd = damageAtEnd; }
+ public void setBlinkRadius(float blinkRadius) {
+ this.blinkRadius = blinkRadius;
+ }
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public float getBehindDistance() {
+ return behindDistance;
+ }
- public float getDamageRadius() { return damageRadius; }
- public void setDamageRadius(float damageRadius) { this.damageRadius = damageRadius; }
+ public void setBehindDistance(float behindDistance) {
+ this.behindDistance = behindDistance;
+ }
+
+ public boolean isRequireLineOfSight() {
+ return requireLineOfSight;
+ }
+
+ public void setRequireLineOfSight(boolean requireLineOfSight) {
+ this.requireLineOfSight = requireLineOfSight;
+ }
+
+ public boolean isDamageAtStart() {
+ return damageAtStart;
+ }
+
+ public void setDamageAtStart(boolean damageAtStart) {
+ this.damageAtStart = damageAtStart;
+ }
+
+ public boolean isDamageAtEnd() {
+ return damageAtEnd;
+ }
+
+ public void setDamageAtEnd(boolean damageAtEnd) {
+ this.damageAtEnd = damageAtEnd;
+ }
+
+ public float getDamage() {
+ return damage;
+ }
+
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
+
+ public float getDamageRadius() {
+ return damageRadius;
+ }
+
+ public void setDamageRadius(float damageRadius) {
+ this.damageRadius = damageRadius;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTrap.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTrap.java
index 9d1090da6..021b1f7d6 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTrap.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityTrap.java
@@ -13,9 +13,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityTrap;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -80,7 +80,9 @@ public class AbilityTrap extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
@@ -89,15 +91,19 @@ public class AbilityTrap extends Ability {
}
@Override
- public boolean isTargetingModeLocked() { return true; }
-
- @Override
- public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
+ public boolean isTargetingModeLocked() {
+ return true;
}
@Override
- public float getTelegraphRadius() { return triggerRadius; }
+ public TargetingMode[] getAllowedTargetingModes() {
+ return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
+ }
+
+ @Override
+ public float getTelegraphRadius() {
+ return triggerRadius;
+ }
@Override
public TelegraphInstance createTelegraph(EntityNPCInterface npc, EntityLivingBase target) {
@@ -362,66 +368,172 @@ public class AbilityTrap extends Ability {
}
// Getters & Setters
- public TrapPlacement getPlacement() { return placement; }
- public void setPlacement(TrapPlacement placement) { this.placement = placement; }
+ public TrapPlacement getPlacement() {
+ return placement;
+ }
- public float getPlacementDistance() { return placementDistance; }
- public void setPlacementDistance(float placementDistance) { this.placementDistance = placementDistance; }
+ public void setPlacement(TrapPlacement placement) {
+ this.placement = placement;
+ }
- public float getTriggerRadius() { return triggerRadius; }
- public void setTriggerRadius(float triggerRadius) { this.triggerRadius = triggerRadius; }
+ public float getPlacementDistance() {
+ return placementDistance;
+ }
- public int getArmTime() { return armTime; }
- public void setArmTime(int armTime) { this.armTime = armTime; }
+ public void setPlacementDistance(float placementDistance) {
+ this.placementDistance = placementDistance;
+ }
- public int getMaxTriggers() { return maxTriggers; }
- public void setMaxTriggers(int maxTriggers) { this.maxTriggers = maxTriggers; }
+ public float getTriggerRadius() {
+ return triggerRadius;
+ }
- public int getTriggerCooldown() { return triggerCooldown; }
- public void setTriggerCooldown(int triggerCooldown) { this.triggerCooldown = triggerCooldown; }
+ public void setTriggerRadius(float triggerRadius) {
+ this.triggerRadius = triggerRadius;
+ }
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public int getArmTime() {
+ return armTime;
+ }
- public float getDamageRadius() { return damageRadius; }
- public void setDamageRadius(float damageRadius) { this.damageRadius = damageRadius; }
+ public void setArmTime(int armTime) {
+ this.armTime = armTime;
+ }
- public float getKnockback() { return knockback; }
- public void setKnockback(float knockback) { this.knockback = knockback; }
+ public int getMaxTriggers() {
+ return maxTriggers;
+ }
- public int getStunDuration() { return stunDuration; }
- public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
+ public void setMaxTriggers(int maxTriggers) {
+ this.maxTriggers = maxTriggers;
+ }
- public int getRootDuration() { return rootDuration; }
- public void setRootDuration(int rootDuration) { this.rootDuration = rootDuration; }
+ public int getTriggerCooldown() {
+ return triggerCooldown;
+ }
- public int getSlowDuration() { return slowDuration; }
- public void setSlowDuration(int slowDuration) { this.slowDuration = slowDuration; }
+ public void setTriggerCooldown(int triggerCooldown) {
+ this.triggerCooldown = triggerCooldown;
+ }
- public int getSlowLevel() { return slowLevel; }
- public void setSlowLevel(int slowLevel) { this.slowLevel = slowLevel; }
+ public float getDamage() {
+ return damage;
+ }
- public int getPoisonDuration() { return poisonDuration; }
- public void setPoisonDuration(int poisonDuration) { this.poisonDuration = poisonDuration; }
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
- public int getPoisonLevel() { return poisonLevel; }
- public void setPoisonLevel(int poisonLevel) { this.poisonLevel = poisonLevel; }
+ public float getDamageRadius() {
+ return damageRadius;
+ }
- public boolean isVisible() { return visible; }
- public void setVisible(boolean visible) { this.visible = visible; }
+ public void setDamageRadius(float damageRadius) {
+ this.damageRadius = damageRadius;
+ }
- public float getMinOffset() { return minOffset; }
- public void setMinOffset(float minOffset) { this.minOffset = minOffset; }
+ public float getKnockback() {
+ return knockback;
+ }
- public float getMaxOffset() { return maxOffset; }
- public void setMaxOffset(float maxOffset) { this.maxOffset = maxOffset; }
+ public void setKnockback(float knockback) {
+ this.knockback = knockback;
+ }
- public boolean isRandomOffset() { return randomOffset; }
- public void setRandomOffset(boolean randomOffset) { this.randomOffset = randomOffset; }
+ public int getStunDuration() {
+ return stunDuration;
+ }
+
+ public void setStunDuration(int stunDuration) {
+ this.stunDuration = stunDuration;
+ }
+
+ public int getRootDuration() {
+ return rootDuration;
+ }
+
+ public void setRootDuration(int rootDuration) {
+ this.rootDuration = rootDuration;
+ }
+
+ public int getSlowDuration() {
+ return slowDuration;
+ }
+
+ public void setSlowDuration(int slowDuration) {
+ this.slowDuration = slowDuration;
+ }
+
+ public int getSlowLevel() {
+ return slowLevel;
+ }
+
+ public void setSlowLevel(int slowLevel) {
+ this.slowLevel = slowLevel;
+ }
+
+ public int getPoisonDuration() {
+ return poisonDuration;
+ }
+
+ public void setPoisonDuration(int poisonDuration) {
+ this.poisonDuration = poisonDuration;
+ }
+
+ public int getPoisonLevel() {
+ return poisonLevel;
+ }
+
+ public void setPoisonLevel(int poisonLevel) {
+ this.poisonLevel = poisonLevel;
+ }
+
+ public boolean isVisible() {
+ return visible;
+ }
+
+ public void setVisible(boolean visible) {
+ this.visible = visible;
+ }
+
+ public float getMinOffset() {
+ return minOffset;
+ }
+
+ public void setMinOffset(float minOffset) {
+ this.minOffset = minOffset;
+ }
+
+ public float getMaxOffset() {
+ return maxOffset;
+ }
+
+ public void setMaxOffset(float maxOffset) {
+ this.maxOffset = maxOffset;
+ }
+
+ public boolean isRandomOffset() {
+ return randomOffset;
+ }
+
+ public void setRandomOffset(boolean randomOffset) {
+ this.randomOffset = randomOffset;
+ }
// Runtime getters
- public double getTrapX() { return trapX; }
- public double getTrapY() { return trapY; }
- public double getTrapZ() { return trapZ; }
- public boolean isArmed() { return armed; }
+ public double getTrapX() {
+ return trapX;
+ }
+
+ public double getTrapY() {
+ return trapY;
+ }
+
+ public double getTrapZ() {
+ return trapZ;
+ }
+
+ public boolean isArmed() {
+ return armed;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java
index ccd8d4a19..ab7171461 100644
--- a/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java
+++ b/src/main/java/kamkeel/npcs/controllers/data/ability/type/AbilityVortex.java
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-
import kamkeel.npcs.controllers.data.ability.Ability;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
-import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityVortex;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
@@ -16,6 +12,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
+import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
+import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityVortex;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -61,25 +60,31 @@ public class AbilityVortex extends Ability {
}
@Override
- public boolean hasTypeSettings() { return true; }
+ public boolean hasTypeSettings() {
+ return true;
+ }
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
- IAbilityConfigCallback callback) {
+ IAbilityConfigCallback callback) {
return new SubGuiAbilityVortex(this, callback);
}
@Override
- public boolean isTargetingModeLocked() { return true; }
-
- @Override
- public TargetingMode[] getAllowedTargetingModes() {
- return new TargetingMode[] { TargetingMode.AOE_SELF };
+ public boolean isTargetingModeLocked() {
+ return true;
}
@Override
- public float getTelegraphRadius() { return pullRadius; }
+ public TargetingMode[] getAllowedTargetingModes() {
+ return new TargetingMode[]{TargetingMode.AOE_SELF};
+ }
+
+ @Override
+ public float getTelegraphRadius() {
+ return pullRadius;
+ }
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
@@ -249,33 +254,83 @@ public class AbilityVortex extends Ability {
}
// Getters & Setters
- public float getPullRadius() { return pullRadius; }
- public void setPullRadius(float pullRadius) { this.pullRadius = pullRadius; }
+ public float getPullRadius() {
+ return pullRadius;
+ }
- public float getPullStrength() { return pullStrength; }
- public void setPullStrength(float pullStrength) { this.pullStrength = pullStrength; }
+ public void setPullRadius(float pullRadius) {
+ this.pullRadius = pullRadius;
+ }
- public float getDamage() { return damage; }
- public void setDamage(float damage) { this.damage = damage; }
+ public float getPullStrength() {
+ return pullStrength;
+ }
- public float getKnockback() { return knockback; }
- public void setKnockback(float knockback) { this.knockback = knockback; }
+ public void setPullStrength(float pullStrength) {
+ this.pullStrength = pullStrength;
+ }
- public int getStunDuration() { return stunDuration; }
- public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
+ public float getDamage() {
+ return damage;
+ }
- public int getRootDuration() { return rootDuration; }
- public void setRootDuration(int rootDuration) { this.rootDuration = rootDuration; }
+ public void setDamage(float damage) {
+ this.damage = damage;
+ }
- public boolean isAoe() { return aoe; }
- public void setAoe(boolean aoe) { this.aoe = aoe; }
+ public float getKnockback() {
+ return knockback;
+ }
- public int getMaxTargets() { return maxTargets; }
- public void setMaxTargets(int maxTargets) { this.maxTargets = maxTargets; }
+ public void setKnockback(float knockback) {
+ this.knockback = knockback;
+ }
- public boolean isDamageOnPull() { return damageOnPull; }
- public void setDamageOnPull(boolean damageOnPull) { this.damageOnPull = damageOnPull; }
+ public int getStunDuration() {
+ return stunDuration;
+ }
- public float getPullDamage() { return pullDamage; }
- public void setPullDamage(float pullDamage) { this.pullDamage = pullDamage; }
+ public void setStunDuration(int stunDuration) {
+ this.stunDuration = stunDuration;
+ }
+
+ public int getRootDuration() {
+ return rootDuration;
+ }
+
+ public void setRootDuration(int rootDuration) {
+ this.rootDuration = rootDuration;
+ }
+
+ public boolean isAoe() {
+ return aoe;
+ }
+
+ public void setAoe(boolean aoe) {
+ this.aoe = aoe;
+ }
+
+ public int getMaxTargets() {
+ return maxTargets;
+ }
+
+ public void setMaxTargets(int maxTargets) {
+ this.maxTargets = maxTargets;
+ }
+
+ public boolean isDamageOnPull() {
+ return damageOnPull;
+ }
+
+ public void setDamageOnPull(boolean damageOnPull) {
+ this.damageOnPull = damageOnPull;
+ }
+
+ public float getPullDamage() {
+ return pullDamage;
+ }
+
+ public void setPullDamage(float pullDamage) {
+ this.pullDamage = pullDamage;
+ }
}
diff --git a/src/main/java/kamkeel/npcs/network/PacketHandler.java b/src/main/java/kamkeel/npcs/network/PacketHandler.java
index c87a5aa2d..1405b44c9 100644
--- a/src/main/java/kamkeel/npcs/network/PacketHandler.java
+++ b/src/main/java/kamkeel/npcs/network/PacketHandler.java
@@ -26,6 +26,8 @@ import kamkeel.npcs.network.packets.data.SoundManagementPacket;
import kamkeel.npcs.network.packets.data.SwingPlayerArmPacket;
import kamkeel.npcs.network.packets.data.UpdateAnimationsPacket;
import kamkeel.npcs.network.packets.data.VillagerListPacket;
+import kamkeel.npcs.network.packets.data.ability.TelegraphRemovePacket;
+import kamkeel.npcs.network.packets.data.ability.TelegraphSpawnPacket;
import kamkeel.npcs.network.packets.data.gui.GuiClosePacket;
import kamkeel.npcs.network.packets.data.gui.GuiErrorPacket;
import kamkeel.npcs.network.packets.data.gui.GuiOpenBookPacket;
@@ -49,8 +51,6 @@ import kamkeel.npcs.network.packets.data.npc.WeaponNpcPacket;
import kamkeel.npcs.network.packets.data.script.ScriptOverlayClosePacket;
import kamkeel.npcs.network.packets.data.script.ScriptOverlayDataPacket;
import kamkeel.npcs.network.packets.data.script.ScriptedParticlePacket;
-import kamkeel.npcs.network.packets.data.ability.TelegraphSpawnPacket;
-import kamkeel.npcs.network.packets.data.ability.TelegraphRemovePacket;
import kamkeel.npcs.network.packets.player.BankActionPacket;
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
import kamkeel.npcs.network.packets.player.CompanionActionPacket;
@@ -64,6 +64,7 @@ import kamkeel.npcs.network.packets.player.SaveBookPacket;
import kamkeel.npcs.network.packets.player.SaveSignPacket;
import kamkeel.npcs.network.packets.player.ScreenSizePacket;
import kamkeel.npcs.network.packets.player.SpecialKeyStatePacket;
+import kamkeel.npcs.network.packets.player.SyncRevisionInfoPacket;
import kamkeel.npcs.network.packets.player.TransportPacket;
import kamkeel.npcs.network.packets.player.customgui.CustomGuiButtonPacket;
import kamkeel.npcs.network.packets.player.customgui.CustomGuiClosePacket;
@@ -75,7 +76,6 @@ import kamkeel.npcs.network.packets.player.item.MagicCyclesPacket;
import kamkeel.npcs.network.packets.player.profile.ProfileChangePacket;
import kamkeel.npcs.network.packets.player.profile.ProfileCreatePacket;
import kamkeel.npcs.network.packets.player.profile.ProfileGetInfoPacket;
-import kamkeel.npcs.network.packets.player.SyncRevisionInfoPacket;
import kamkeel.npcs.network.packets.player.profile.ProfileGetPacket;
import kamkeel.npcs.network.packets.player.profile.ProfileRemovePacket;
import kamkeel.npcs.network.packets.player.profile.ProfileRenamePacket;
@@ -88,6 +88,9 @@ import kamkeel.npcs.network.packets.request.MountPacket;
import kamkeel.npcs.network.packets.request.TileEntityGetPacket;
import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
import kamkeel.npcs.network.packets.request.TraderMarketSavePacket;
+import kamkeel.npcs.network.packets.request.ability.AbilitiesGetAllPacket;
+import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcGetPacket;
+import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcSavePacket;
import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket;
import kamkeel.npcs.network.packets.request.animation.AnimationRemovePacket;
import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket;
@@ -141,9 +144,6 @@ import kamkeel.npcs.network.packets.request.linked.LinkedItemSavePacket;
import kamkeel.npcs.network.packets.request.linked.LinkedNPCAddPacket;
import kamkeel.npcs.network.packets.request.linked.LinkedNPCRemovePacket;
import kamkeel.npcs.network.packets.request.linked.LinkedSetPacket;
-import kamkeel.npcs.network.packets.request.ability.AbilitiesGetAllPacket;
-import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcGetPacket;
-import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcSavePacket;
import kamkeel.npcs.network.packets.request.magic.MagicCycleRemovePacket;
import kamkeel.npcs.network.packets.request.magic.MagicCycleSavePacket;
import kamkeel.npcs.network.packets.request.magic.MagicGetAllPacket;
@@ -216,7 +216,16 @@ import kamkeel.npcs.network.packets.request.recipe.RecipesGetPacket;
import kamkeel.npcs.network.packets.request.role.RoleCompanionUpdatePacket;
import kamkeel.npcs.network.packets.request.role.RoleGetPacket;
import kamkeel.npcs.network.packets.request.role.RoleSavePacket;
-import kamkeel.npcs.network.packets.request.script.*;
+import kamkeel.npcs.network.packets.request.script.BlockScriptPacket;
+import kamkeel.npcs.network.packets.request.script.EffectScriptPacket;
+import kamkeel.npcs.network.packets.request.script.EventScriptPacket;
+import kamkeel.npcs.network.packets.request.script.ForgeScriptPacket;
+import kamkeel.npcs.network.packets.request.script.GlobalNPCScriptPacket;
+import kamkeel.npcs.network.packets.request.script.NPCScriptPacket;
+import kamkeel.npcs.network.packets.request.script.PlayerScriptPacket;
+import kamkeel.npcs.network.packets.request.script.RecipeScriptPacket;
+import kamkeel.npcs.network.packets.request.script.ScriptFilesPacket;
+import kamkeel.npcs.network.packets.request.script.ScriptInfoPacket;
import kamkeel.npcs.network.packets.request.script.item.ItemScriptErrorPacket;
import kamkeel.npcs.network.packets.request.script.item.ItemScriptPacket;
import kamkeel.npcs.network.packets.request.script.item.LinkedItemScriptPacket;
diff --git a/src/main/java/kamkeel/npcs/network/packets/data/ability/TelegraphSpawnPacket.java b/src/main/java/kamkeel/npcs/network/packets/data/ability/TelegraphSpawnPacket.java
index bbf342ade..e9c846764 100644
--- a/src/main/java/kamkeel/npcs/network/packets/data/ability/TelegraphSpawnPacket.java
+++ b/src/main/java/kamkeel/npcs/network/packets/data/ability/TelegraphSpawnPacket.java
@@ -3,7 +3,6 @@ package kamkeel.npcs.network.packets.data.ability;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
-import kamkeel.npcs.controllers.data.ability.telegraph.Telegraph;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import kamkeel.npcs.network.AbstractPacket;
diff --git a/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptFilesPacket.java b/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptFilesPacket.java
index 74bf8bd5e..37383ea6c 100644
--- a/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptFilesPacket.java
+++ b/src/main/java/kamkeel/npcs/network/packets/request/script/ScriptFilesPacket.java
@@ -3,7 +3,9 @@ package kamkeel.npcs.network.packets.request.script;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
-import kamkeel.npcs.network.*;
+import kamkeel.npcs.network.AbstractPacket;
+import kamkeel.npcs.network.PacketChannel;
+import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
diff --git a/src/main/java/kamkeel/npcs/util/BukkitUtil.java b/src/main/java/kamkeel/npcs/util/BukkitUtil.java
index 78cd49c82..bc35cae6c 100644
--- a/src/main/java/kamkeel/npcs/util/BukkitUtil.java
+++ b/src/main/java/kamkeel/npcs/util/BukkitUtil.java
@@ -95,6 +95,7 @@ public class BukkitUtil {
/**
* Checks if a specific Bukkit plugin is enabled.
+ *
* @param pluginName the plugin name to check
* @return true if the plugin is enabled
*/
@@ -112,6 +113,7 @@ public class BukkitUtil {
/**
* Gets a Bukkit OfflinePlayer by name.
+ *
* @param playerName the player name
* @return the OfflinePlayer object, or null if not available
*/
@@ -128,6 +130,7 @@ public class BukkitUtil {
/**
* Gets a Bukkit Player by name (online players only).
+ *
* @param playerName the player name
* @return the Player object, or null if not online or not available
*/
@@ -144,6 +147,7 @@ public class BukkitUtil {
/**
* Gets a service provider from Bukkit's ServicesManager.
+ *
* @param serviceClass the service class to get
* @return the service provider, or null if not available
*/
diff --git a/src/main/java/kamkeel/npcs/util/VaultUtil.java b/src/main/java/kamkeel/npcs/util/VaultUtil.java
index c7ef92e97..64743ffba 100644
--- a/src/main/java/kamkeel/npcs/util/VaultUtil.java
+++ b/src/main/java/kamkeel/npcs/util/VaultUtil.java
@@ -174,6 +174,7 @@ public class VaultUtil {
/**
* Checks if a player has an account in the economy system.
+ *
* @param player the player to check
* @return true if the player has an account
*/
@@ -183,6 +184,7 @@ public class VaultUtil {
/**
* Checks if a player has an account in the economy system.
+ *
* @param playerName the player name to check
* @return true if the player has an account
*/
@@ -203,6 +205,7 @@ public class VaultUtil {
/**
* Gets the balance of a player.
+ *
* @param player the player
* @return the player's balance, or 0 if not available
*/
@@ -212,6 +215,7 @@ public class VaultUtil {
/**
* Gets the balance of a player by name.
+ *
* @param playerName the player name
* @return the player's balance, or 0 if not available
*/
@@ -232,6 +236,7 @@ public class VaultUtil {
/**
* Checks if a player has at least the specified amount.
+ *
* @param player the player
* @param amount the amount to check
* @return true if the player has at least the specified amount
@@ -242,8 +247,9 @@ public class VaultUtil {
/**
* Checks if a player has at least the specified amount.
+ *
* @param playerName the player name
- * @param amount the amount to check
+ * @param amount the amount to check
* @return true if the player has at least the specified amount
*/
public static boolean has(String playerName, double amount) {
@@ -263,6 +269,7 @@ public class VaultUtil {
/**
* Withdraws money from a player's account.
+ *
* @param player the player
* @param amount the amount to withdraw
* @return true if the transaction was successful
@@ -273,8 +280,9 @@ public class VaultUtil {
/**
* Withdraws money from a player's account.
+ *
* @param playerName the player name
- * @param amount the amount to withdraw
+ * @param amount the amount to withdraw
* @return true if the transaction was successful
*/
public static boolean withdrawMoney(String playerName, double amount) {
@@ -297,6 +305,7 @@ public class VaultUtil {
/**
* Adds money to a player's account (deposit).
+ *
* @param player the player
* @param amount the amount to add
* @return true if the transaction was successful
@@ -307,8 +316,9 @@ public class VaultUtil {
/**
* Adds money to a player's account (deposit).
+ *
* @param playerName the player name
- * @param amount the amount to add
+ * @param amount the amount to add
* @return true if the transaction was successful
*/
public static boolean addMoney(String playerName, double amount) {
@@ -332,6 +342,7 @@ public class VaultUtil {
/**
* Sets a player's balance to the specified amount.
* This withdraws all money first, then deposits the new amount.
+ *
* @param player the player
* @param amount the new balance
* @return true if the transaction was successful
@@ -343,8 +354,9 @@ public class VaultUtil {
/**
* Sets a player's balance to the specified amount.
* This withdraws all money first, then deposits the new amount.
+ *
* @param playerName the player name
- * @param amount the new balance
+ * @param amount the new balance
* @return true if the transaction was successful
*/
public static boolean setBalance(String playerName, double amount) {
@@ -364,6 +376,7 @@ public class VaultUtil {
/**
* Formats an amount according to the economy plugin's settings.
+ *
* @param amount the amount to format
* @return the formatted string, or the raw number as string if not available
*/
@@ -380,6 +393,7 @@ public class VaultUtil {
/**
* Gets the plural currency name (e.g., "Dollars").
+ *
* @return the plural currency name, or "coins" if not available
*/
public static String getCurrencyNamePlural() {
@@ -395,6 +409,7 @@ public class VaultUtil {
/**
* Gets the singular currency name (e.g., "Dollar").
+ *
* @return the singular currency name, or "coin" if not available
*/
public static String getCurrencyNameSingular() {
@@ -410,6 +425,7 @@ public class VaultUtil {
/**
* Creates an account for the player if one doesn't exist.
+ *
* @param player the player
* @return true if the account was created or already exists
*/
@@ -419,6 +435,7 @@ public class VaultUtil {
/**
* Creates an account for the player if one doesn't exist.
+ *
* @param playerName the player name
* @return true if the account was created or already exists
*/
@@ -455,6 +472,7 @@ public class VaultUtil {
/**
* Gets a list of all bank names.
+ *
* @return list of bank names, or empty list if not available
*/
@SuppressWarnings("unchecked")
@@ -471,6 +489,7 @@ public class VaultUtil {
/**
* Gets the balance of a bank.
+ *
* @param bankName the bank name
* @return the bank balance, or 0 if not available
*/
@@ -488,8 +507,9 @@ public class VaultUtil {
/**
* Checks if a bank has at least the specified amount.
+ *
* @param bankName the bank name
- * @param amount the amount to check
+ * @param amount the amount to check
* @return true if the bank has at least the specified amount
*/
public static boolean bankHas(String bankName, double amount) {
@@ -506,8 +526,9 @@ public class VaultUtil {
/**
* Withdraws money from a bank.
+ *
* @param bankName the bank name
- * @param amount the amount to withdraw
+ * @param amount the amount to withdraw
* @return true if the transaction was successful
*/
public static boolean bankWithdraw(String bankName, double amount) {
@@ -524,8 +545,9 @@ public class VaultUtil {
/**
* Deposits money into a bank.
+ *
* @param bankName the bank name
- * @param amount the amount to deposit
+ * @param amount the amount to deposit
* @return true if the transaction was successful
*/
public static boolean bankDeposit(String bankName, double amount) {
@@ -542,8 +564,9 @@ public class VaultUtil {
/**
* Transfers money from one player to another.
- * @param from the player to take money from
- * @param to the player to give money to
+ *
+ * @param from the player to take money from
+ * @param to the player to give money to
* @param amount the amount to transfer
* @return true if the transfer was successful
*/
@@ -553,9 +576,10 @@ public class VaultUtil {
/**
* Transfers money from one player to another.
+ *
* @param fromPlayerName the player name to take money from
- * @param toPlayerName the player name to give money to
- * @param amount the amount to transfer
+ * @param toPlayerName the player name to give money to
+ * @param amount the amount to transfer
* @return true if the transfer was successful
*/
public static boolean transfer(String fromPlayerName, String toPlayerName, double amount) {
diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java
index 604ba26a0..c5b82d72a 100644
--- a/src/main/java/noppes/npcs/CustomNpcs.java
+++ b/src/main/java/noppes/npcs/CustomNpcs.java
@@ -4,7 +4,13 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
-import cpw.mods.fml.common.event.*;
+import cpw.mods.fml.common.event.FMLInitializationEvent;
+import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
+import cpw.mods.fml.common.event.FMLServerStartedEvent;
+import cpw.mods.fml.common.event.FMLServerStartingEvent;
+import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -18,6 +24,7 @@ import kamkeel.npcs.command.profile.CommandProfile;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.SyncController;
+import kamkeel.npcs.controllers.data.ability.AbilityController;
import kamkeel.npcs.controllers.data.profile.CNPCData;
import kamkeel.npcs.developer.Developer;
import kamkeel.npcs.network.PacketHandler;
@@ -68,7 +75,6 @@ import noppes.npcs.controllers.SpawnController;
import noppes.npcs.controllers.TagController;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.enchants.EnchantInterface;
-import kamkeel.npcs.controllers.data.ability.AbilityController;
import noppes.npcs.entity.EntityChairMount;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityMagicProjectile;
diff --git a/src/main/java/noppes/npcs/DataAbilities.java b/src/main/java/noppes/npcs/DataAbilities.java
index d9655b20a..3bed6075f 100644
--- a/src/main/java/noppes/npcs/DataAbilities.java
+++ b/src/main/java/noppes/npcs/DataAbilities.java
@@ -1,8 +1,8 @@
package noppes.npcs;
import kamkeel.npcs.controllers.data.ability.Ability;
-import kamkeel.npcs.controllers.data.ability.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.AbilityController;
+import kamkeel.npcs.controllers.data.ability.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
import kamkeel.npcs.network.packets.data.ability.TelegraphRemovePacket;
import kamkeel.npcs.network.packets.data.ability.TelegraphSpawnPacket;
@@ -35,32 +35,48 @@ public class DataAbilities {
// CONFIGURATION (saved to NBT)
// ═══════════════════════════════════════════════════════════════════
- /** List of abilities this NPC can use */
+ /**
+ * List of abilities this NPC can use
+ */
private List abilities = new ArrayList<>();
- /** Whether the ability system is enabled for this NPC */
+ /**
+ * Whether the ability system is enabled for this NPC
+ */
public boolean enabled = false;
- /** Minimum ticks between ability selections (global cooldown) */
+ /**
+ * Minimum ticks between ability selections (global cooldown)
+ */
public int globalCooldown = 20;
// ═══════════════════════════════════════════════════════════════════
// RUNTIME STATE (not saved)
// ═══════════════════════════════════════════════════════════════════
- /** Currently executing ability (null if none) */
+ /**
+ * Currently executing ability (null if none)
+ */
private transient Ability currentAbility;
- /** Per-ability cooldown timers (ability ID -> world time when cooldown ends) */
+ /**
+ * Per-ability cooldown timers (ability ID -> world time when cooldown ends)
+ */
private transient Map cooldowns = new HashMap<>();
- /** Ticks until next ability can be selected (global cooldown timer) */
+ /**
+ * Ticks until next ability can be selected (global cooldown timer)
+ */
private transient int globalCooldownTimer = 0;
- /** Last target used for ability execution */
+ /**
+ * Last target used for ability execution
+ */
private transient EntityLivingBase lastTarget;
- /** Recent hit timestamps for hit count condition */
+ /**
+ * Recent hit timestamps for hit count condition
+ */
private transient List recentHitTimes = new ArrayList<>();
// ═══════════════════════════════════════════════════════════════════
@@ -532,11 +548,11 @@ public class DataAbilities {
* Fire an ability hit event. Called by abilities when they hit an entity.
* Returns null if the event was cancelled, otherwise returns the (possibly modified) event.
*
- * @param ability The ability doing the hit
- * @param target The original target of the ability
- * @param hitEntity The entity being hit
- * @param damage The damage amount
- * @param knockback The horizontal knockback
+ * @param ability The ability doing the hit
+ * @param target The original target of the ability
+ * @param hitEntity The entity being hit
+ * @param damage The damage amount
+ * @param knockback The horizontal knockback
* @param knockbackUp The vertical knockback (deprecated, ignored)
* @return The event (with possibly modified values), or null if cancelled
*/
@@ -636,7 +652,7 @@ public class DataAbilities {
/**
* Check if ability is controlling NPC movement (AI pathfinding should be blocked).
* Called by AI tasks to determine if they should try to path.
- *
+ *
* Rules:
* - WINDUP phase: Block AI if lockMovement is true
* - ACTIVE phase: Block AI if lockMovement OR hasAbilityMovement is true
@@ -672,6 +688,7 @@ public class DataAbilities {
/**
* Check if NPC movement should be blocked due to ability execution.
+ *
* @deprecated Use isAbilityControllingMovement() instead
*/
@Deprecated
diff --git a/src/main/java/noppes/npcs/EventHooks.java b/src/main/java/noppes/npcs/EventHooks.java
index f72bbdab7..5e086abce 100644
--- a/src/main/java/noppes/npcs/EventHooks.java
+++ b/src/main/java/noppes/npcs/EventHooks.java
@@ -38,7 +38,6 @@ import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.Dialog;
-import noppes.npcs.controllers.data.EffectScript;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.IScriptBlockHandler;
import noppes.npcs.controllers.data.IScriptHandler;
@@ -265,7 +264,7 @@ public class EventHooks {
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INIT, event);
npc.script.callScript(EnumScriptType.INIT, event);
- NpcAPI.EVENT_BUS.post(event);
+ NpcAPI.EVENT_BUS.post(event);
npc.advanced.soulStoneInit = false;
}
@@ -276,7 +275,7 @@ public class EventHooks {
noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TICK, event);
npc.script.callScript(EnumScriptType.TICK, event);
- NpcAPI.EVENT_BUS.post(event);
+ NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
@@ -297,7 +296,7 @@ public class EventHooks {
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog());
- NpcAPI.EVENT_BUS.post(event);
+ NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) {
@@ -307,7 +306,7 @@ public class EventHooks {
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC, player);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INTERACT, event);
boolean result = npc.script.callScript(EnumScriptType.INTERACT, event, "player", player);
- NpcAPI.EVENT_BUS.post(event);
+ NpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -318,7 +317,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
npc.script.callScript(EnumScriptType.ATTACK_MELEE, event, "target", event.target);
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
- return NpcAPI.EVENT_BUS.post(event);
+ return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCMeleeSwing(EntityNPCInterface npc, NpcEvent.SwingEvent event) {
@@ -327,7 +326,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_SWING, event);
npc.script.callScript(EnumScriptType.ATTACK_SWING, event);
- return NpcAPI.EVENT_BUS.post(event);
+ return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCRangedAttack(EntityNPCInterface npc, NpcEvent.RangedLaunchedEvent event) {
@@ -337,7 +336,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
npc.script.callScript(EnumScriptType.RANGED_LAUNCHED, event, "target", event.target);
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
- return NpcAPI.EVENT_BUS.post(event);
+ return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity) {
@@ -347,7 +346,7 @@ public class EventHooks {
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC, entity);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLS, event);
npc.script.callScript(EnumScriptType.KILLS, event, "target", entity);
- NpcAPI.EVENT_BUS.post(event);
+ NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCTarget(EntityNPCInterface npc, NpcEvent.TargetEvent event) {
@@ -356,7 +355,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET, event);
npc.script.callScript(EnumScriptType.TARGET, event);
- return NpcAPI.EVENT_BUS.post(event);
+ return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCTargetLost(EntityNPCInterface npc, EntityLivingBase prevtarget, EntityLivingBase newTarget) {
@@ -366,7 +365,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET_LOST, event);
npc.script.callScript(EnumScriptType.TARGET_LOST, event);
- return NpcAPI.EVENT_BUS.post(event);
+ return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCCollide(EntityNPCInterface npc, Entity entity) {
@@ -376,7 +375,7 @@ public class EventHooks {
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC, entity);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.COLLIDE, event);
npc.script.callScript(EnumScriptType.COLLIDE, event, "entity", entity);
- NpcAPI.EVENT_BUS.post(event);
+ NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCDamaged(EntityNPCInterface npc, NpcEvent.DamagedEvent event) {
@@ -385,7 +384,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DAMAGED, event);
npc.script.callScript(EnumScriptType.DAMAGED, event);
- return NpcAPI.EVENT_BUS.post(event);
+ return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCKilled(EntityNPCInterface npc, NpcEvent.DiedEvent event) {
@@ -394,7 +393,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLED, event);
npc.script.callScript(EnumScriptType.KILLED, event);
- return NpcAPI.EVENT_BUS.post(event);
+ return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCTimer(EntityNPCInterface npc, int id) {
@@ -404,7 +403,7 @@ public class EventHooks {
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TIMER, event);
npc.script.callScript(EnumScriptType.TIMER, event);
- NpcAPI.EVENT_BUS.post(event);
+ NpcAPI.EVENT_BUS.post(event);
}
public static void onProjectileTick(EntityProjectile projectile) {
@@ -422,7 +421,7 @@ public class EventHooks {
EntityNPCInterface npc = (EntityNPCInterface) thrower;
npc.script.callScript(EnumScriptType.PROJECTILE_TICK, event);
- }
+ }
}
NpcAPI.EVENT_BUS.post(event);
@@ -442,7 +441,7 @@ public class EventHooks {
EntityNPCInterface npc = (EntityNPCInterface) thrower;
npc.script.callScript(EnumScriptType.PROJECTILE_IMPACT, event);
- }
+ }
}
NpcAPI.EVENT_BUS.post(event);
diff --git a/src/main/java/noppes/npcs/NBTTags.java b/src/main/java/noppes/npcs/NBTTags.java
index fff8d1c5d..6eec4c14d 100644
--- a/src/main/java/noppes/npcs/NBTTags.java
+++ b/src/main/java/noppes/npcs/NBTTags.java
@@ -6,7 +6,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
-import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.data.IScriptHandler;
import noppes.npcs.controllers.data.IScriptUnit;
diff --git a/src/main/java/noppes/npcs/NoppesStringUtils.java b/src/main/java/noppes/npcs/NoppesStringUtils.java
index cd7031ef0..ddc11d5c6 100644
--- a/src/main/java/noppes/npcs/NoppesStringUtils.java
+++ b/src/main/java/noppes/npcs/NoppesStringUtils.java
@@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.StatCollector;
import noppes.npcs.entity.EntityNPCInterface;
-import java.awt.*;
+import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
diff --git a/src/main/java/noppes/npcs/ScriptForgeEventHandler.java b/src/main/java/noppes/npcs/ScriptForgeEventHandler.java
index 4294a6d9e..abc5a80ee 100644
--- a/src/main/java/noppes/npcs/ScriptForgeEventHandler.java
+++ b/src/main/java/noppes/npcs/ScriptForgeEventHandler.java
@@ -36,7 +36,7 @@ public class ScriptForgeEventHandler {
@SubscribeEvent
public void forgeEntity(Event event) {
if (CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
- if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT){
+ if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
return;
}
diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java
index e9531296a..a37e6ba08 100644
--- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java
+++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java
@@ -62,7 +62,6 @@ import noppes.npcs.items.ItemNpcTool;
import noppes.npcs.quests.QuestItem;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.item.ScriptCustomizableItem;
-import noppes.npcs.scripted.item.ScriptItemStack;
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
@@ -549,7 +548,7 @@ public class ScriptPlayerEventHandler {
if (event.source.getEntity() instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) event.source.getEntity();
- if(playerMP.getHeldItem() != null) {
+ if (playerMP.getHeldItem() != null) {
IItemStack itemStack = NpcAPI.Instance().getIItemStack(playerMP.getHeldItem());
if (itemStack instanceof ScriptCustomizableItem) {
ScriptCustomizableItem sci = (ScriptCustomizableItem) itemStack;
diff --git a/src/main/java/noppes/npcs/ServerEventsHandler.java b/src/main/java/noppes/npcs/ServerEventsHandler.java
index 47a1148df..b6671b72a 100644
--- a/src/main/java/noppes/npcs/ServerEventsHandler.java
+++ b/src/main/java/noppes/npcs/ServerEventsHandler.java
@@ -51,7 +51,6 @@ import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.Line;
-import noppes.npcs.controllers.data.LinkedItem;
import noppes.npcs.controllers.data.MarkData;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.PlayerData;
@@ -60,7 +59,6 @@ import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestData;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemExcalibur;
-import noppes.npcs.items.ItemLinked;
import noppes.npcs.items.ItemShield;
import noppes.npcs.items.ItemSoulstoneEmpty;
import noppes.npcs.quests.QuestKill;
diff --git a/src/main/java/noppes/npcs/ServerTickHandler.java b/src/main/java/noppes/npcs/ServerTickHandler.java
index eb5018871..93acda2ea 100644
--- a/src/main/java/noppes/npcs/ServerTickHandler.java
+++ b/src/main/java/noppes/npcs/ServerTickHandler.java
@@ -10,8 +10,8 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.WorldServer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerData;
-import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.controllers.data.action.ActionManager;
+import noppes.npcs.entity.EntityNPCInterface;
public class ServerTickHandler {
diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java b/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java
index b9558dd93..64dbb767b 100644
--- a/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java
+++ b/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java
@@ -28,8 +28,8 @@ import noppes.npcs.client.renderer.blocks.BlockScriptedRenderer;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptController;
-import noppes.npcs.controllers.data.IScriptHandlerPacket;
import noppes.npcs.controllers.data.IScriptBlockHandler;
+import noppes.npcs.controllers.data.IScriptHandlerPacket;
import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.entity.data.DataTimers;
import noppes.npcs.scripted.BlockScriptedWrapper;
@@ -39,8 +39,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
public class TileScripted extends TileEntity implements IScriptBlockHandler, IScriptHandlerPacket {
public List scripts = new ArrayList<>();
@@ -449,7 +447,7 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler, ISc
public List getScripts() {
return scripts;
}
-
+
@SideOnly(Side.CLIENT)
@Override
diff --git a/src/main/java/noppes/npcs/client/ClientCacheHandler.java b/src/main/java/noppes/npcs/client/ClientCacheHandler.java
index 2c6a368c2..30b14be83 100644
--- a/src/main/java/noppes/npcs/client/ClientCacheHandler.java
+++ b/src/main/java/noppes/npcs/client/ClientCacheHandler.java
@@ -1,5 +1,6 @@
package noppes.npcs.client;
+import kamkeel.npcs.network.enums.EnumSyncType;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.controllers.MusicController;
@@ -15,7 +16,6 @@ import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.SkinOverlay;
-import kamkeel.npcs.network.enums.EnumSyncType;
import noppes.npcs.util.CacheHashMap;
import java.util.EnumMap;
diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java
index 249836b80..656efc97b 100644
--- a/src/main/java/noppes/npcs/client/ClientProxy.java
+++ b/src/main/java/noppes/npcs/client/ClientProxy.java
@@ -6,6 +6,8 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import kamkeel.npcs.addon.client.DBCClient;
+import kamkeel.npcs.client.renderer.TelegraphRenderer;
+import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.model.ModelBiped;
@@ -138,9 +140,6 @@ import noppes.npcs.client.renderer.RenderNpcCrystal;
import noppes.npcs.client.renderer.RenderNpcDragon;
import noppes.npcs.client.renderer.RenderNpcSlime;
import noppes.npcs.client.renderer.RenderProjectile;
-import kamkeel.npcs.client.renderer.TelegraphRenderer;
-import noppes.npcs.scripted.item.ScriptCustomItem;
-import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
import noppes.npcs.client.renderer.blocks.BlockBarrelRenderer;
import noppes.npcs.client.renderer.blocks.BlockBeamRenderer;
@@ -214,6 +213,7 @@ import noppes.npcs.entity.data.ModelPartData;
import noppes.npcs.items.ItemLinked;
import noppes.npcs.items.ItemNpcTool;
import noppes.npcs.items.ItemScripted;
+import noppes.npcs.scripted.item.ScriptCustomItem;
import org.lwjgl.input.Keyboard;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.InventoryTabVanilla;
@@ -635,7 +635,7 @@ public class ClientProxy extends CommonProxy {
return GuiScriptInterface.create(null, (TileScripted) tile);
}
-
+
@Override
public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
diff --git a/src/main/java/noppes/npcs/client/ClientTickHandler.java b/src/main/java/noppes/npcs/client/ClientTickHandler.java
index 7c5ec98f2..78a473f41 100644
--- a/src/main/java/noppes/npcs/client/ClientTickHandler.java
+++ b/src/main/java/noppes/npcs/client/ClientTickHandler.java
@@ -5,11 +5,12 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
+import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
import kamkeel.npcs.network.packets.player.InputDevicePacket;
-import kamkeel.npcs.network.packets.player.SpecialKeyStatePacket;
import kamkeel.npcs.network.packets.player.ScreenSizePacket;
+import kamkeel.npcs.network.packets.player.SpecialKeyStatePacket;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -18,7 +19,6 @@ import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.controllers.ScriptSoundController;
-import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import noppes.npcs.client.gui.hud.ClientHudManager;
import noppes.npcs.client.gui.hud.CompassHudComponent;
import noppes.npcs.client.gui.hud.EnumHudComponent;
diff --git a/src/main/java/noppes/npcs/client/CustomNpcResourceListener.java b/src/main/java/noppes/npcs/client/CustomNpcResourceListener.java
index 132805af1..2f2bc3115 100644
--- a/src/main/java/noppes/npcs/client/CustomNpcResourceListener.java
+++ b/src/main/java/noppes/npcs/client/CustomNpcResourceListener.java
@@ -11,7 +11,7 @@ import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import javax.imageio.ImageIO;
-import java.awt.*;
+import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStream;
diff --git a/src/main/java/noppes/npcs/client/controllers/MusicController.java b/src/main/java/noppes/npcs/client/controllers/MusicController.java
index 98c30f2ac..172152f51 100644
--- a/src/main/java/noppes/npcs/client/controllers/MusicController.java
+++ b/src/main/java/noppes/npcs/client/controllers/MusicController.java
@@ -199,6 +199,7 @@ public class MusicController {
/**
* Stops a specific sound by its resource key.
* This is used to stop dialog sounds without affecting Bard music.
+ *
* @param soundKey The sound resource key to stop
*/
public void stopSound(String soundKey) {
diff --git a/src/main/java/noppes/npcs/client/gui/GuiScript.java b/src/main/java/noppes/npcs/client/gui/GuiScript.java
index 137ccf5a1..8d960e142 100644
--- a/src/main/java/noppes/npcs/client/gui/GuiScript.java
+++ b/src/main/java/noppes/npcs/client/gui/GuiScript.java
@@ -5,34 +5,41 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.script.GuiScriptInterface;
-import noppes.npcs.client.gui.util.*;
+import noppes.npcs.client.gui.util.GuiCustomScroll;
+import noppes.npcs.client.gui.util.GuiMenuTopButton;
+import noppes.npcs.client.gui.util.GuiNpcButton;
+import noppes.npcs.client.gui.util.GuiNpcLabel;
+import noppes.npcs.client.gui.util.GuiNpcTextArea;
+import noppes.npcs.client.gui.util.GuiScriptTextArea;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.DataScript;
import noppes.npcs.entity.EntityNPCInterface;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
/**
* NPC Script GUI - extends GuiScriptInterface but with unique behavior:
* - Uses scroll-based tab selection instead of top buttons
- * - Shows settings/script toggle
+ * - Shows settings/script toggle
* - Uses DataScript with getNPCScript(index) access pattern
* - Has console filtering by hook type
*/
public class GuiScript extends GuiScriptInterface {
public boolean showScript = false;
public DataScript script;
-
+
private static int activeConsole = 0;
-
+
public GuiScript(EntityNPCInterface npc) {
super();
this.npc = npc;
@@ -40,7 +47,7 @@ public class GuiScript extends GuiScriptInterface {
this.handler = script;
this.useScrollTabs = true;
this.useSettingsToggle = true;
-
+
// Initialize hook list for NPC scripts
hookList.add("script.init");
hookList.add("script.update");
@@ -57,20 +64,20 @@ public class GuiScript extends GuiScriptInterface {
hookList.add("script.targetLost");
hookList.add("script.projectileTick");
hookList.add("script.projectileImpact");
-
+
NPCScriptPacket.Get();
}
-
+
@Override
protected ScriptContext getScriptContext() {
return ScriptContext.NPC;
}
-
+
@Override
protected int getActiveScriptIndex() {
return this.activeTab;
}
-
+
@Override
protected ScriptContainer getCurrentContainer() {
return script.getNPCScript(activeTab);
@@ -99,13 +106,13 @@ public class GuiScript extends GuiScriptInterface {
initSettingsView();
}
}
-
+
private void initScriptView() {
ScriptContainer container = getCurrentContainer();
-
+
// ==================== CALCULATE VIEWPORT BOUNDS ====================
int editorX, editorY, editorWidth, editorHeight;
-
+
if (isFullscreen) {
// Fullscreen: viewport fills screen with configured padding
FullscreenConfig.paddingTop = 30;
@@ -123,11 +130,11 @@ public class GuiScript extends GuiScriptInterface {
editorWidth = 239;
editorHeight = 208;
}
-
+
// ==================== HOOKS SCROLL (hidden in fullscreen) ====================
if (!isFullscreen) {
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
-
+
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
hooks.setSize(68, 198);
hooks.guiLeft = guiLeft + 4;
@@ -142,28 +149,28 @@ public class GuiScript extends GuiScriptInterface {
GuiScriptTextArea activeArea = getActiveScriptArea();
if (activeArea == null) {
activeArea = new GuiScriptTextArea(this, 2, editorX, editorY, editorWidth, editorHeight,
- container == null ? "" : container.script);
+ container == null ? "" : container.script);
activeArea.setListener(this);
this.closeOnEsc(activeArea::closeOnEsc);
textAreas.put(idx, activeArea);
} else {
- activeArea.init(editorX, editorY, editorWidth, editorHeight,
- container == null ? "" : container.script);
+ activeArea.init(editorX, editorY, editorWidth, editorHeight,
+ container == null ? "" : container.script);
}
activeArea.setLanguage(script.getLanguage());
activeArea.setScriptContext(getScriptContext());
-
+
// Setup fullscreen key binding
GuiScriptTextArea.KEYS.FULLSCREEN.setTask(e -> {
if (e.isPress()) {
toggleFullscreen();
}
});
-
+
activeArea.enableCodeHighlighting();
addTextField(activeArea);
-
+
// Initialize fullscreen button
int scrollbarOffset = activeArea.hasVerticalScrollbar() ? -8 : -2;
fullscreenButton.initGui(editorX + editorWidth, editorY, scrollbarOffset);
@@ -184,35 +191,35 @@ public class GuiScript extends GuiScriptInterface {
addScroll(scroll);
}
}
-
-
+
+
private void initSettingsView() {
addLabel(new GuiNpcLabel(0, "script.console", guiLeft + 4, guiTop + 16));
if (getTopButton(14) != null)
getTopButton(14).active = true;
-
+
GuiNpcTextArea consoleArea = new GuiNpcTextArea(2, this, guiLeft + 4, guiTop + 26, 226, 186, getConsoleText());
consoleArea.canEdit = false;
addTextField(consoleArea);
-
+
addButton(new GuiNpcButton(100, guiLeft + 232, guiTop + 170, 56, 20, "gui.copy"));
addButton(new GuiNpcButton(102, guiLeft + 232, guiTop + 192, 56, 20, "gui.clear"));
List consoleOptions = new ArrayList<>();
consoleOptions.add("All");
consoleOptions.addAll(hookList);
- addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20,
- consoleOptions.toArray(new String[0]), activeConsole));
+ addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20,
+ consoleOptions.toArray(new String[0]), activeConsole));
addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30));
List languageOptions = getLanguageOptions();
- addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20,
- languageOptions.toArray(new String[0]), getLanguageIndex(languageOptions)));
+ addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20,
+ languageOptions.toArray(new String[0]), getLanguageIndex(languageOptions)));
getButton(103).enabled = languageOptions.size() > 0;
addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53));
- addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20,
- new String[]{"gui.no", "gui.yes"}, script.enabled ? 1 : 0));
+ addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20,
+ new String[]{"gui.no", "gui.yes"}, script.enabled ? 1 : 0));
if (MinecraftServer.getServer() != null)
addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder"));
@@ -280,12 +287,12 @@ public class GuiScript extends GuiScriptInterface {
NoppesStringUtils.setClipboardContents(getTextField(2).getText());
}
if (guibutton.id == 101) {
- displayGuiScreen(new GuiYesNo(this, StatCollector.translateToLocal("gui.paste"),
- StatCollector.translateToLocal("gui.sure"), 101));
+ displayGuiScreen(new GuiYesNo(this, StatCollector.translateToLocal("gui.paste"),
+ StatCollector.translateToLocal("gui.sure"), 101));
}
if (guibutton.id == 102) {
- displayGuiScreen(new GuiYesNo(this, StatCollector.translateToLocal("gui.clear"),
- StatCollector.translateToLocal("gui.sure"), 102));
+ displayGuiScreen(new GuiYesNo(this, StatCollector.translateToLocal("gui.clear"),
+ StatCollector.translateToLocal("gui.sure"), 102));
}
if (guibutton.id == 103) {
script.scriptLanguage = ((GuiNpcButton) guibutton).displayString;
diff --git a/src/main/java/noppes/npcs/client/gui/GuiScriptList.java b/src/main/java/noppes/npcs/client/gui/GuiScriptList.java
index 547f75f83..a13f2a056 100644
--- a/src/main/java/noppes/npcs/client/gui/GuiScriptList.java
+++ b/src/main/java/noppes/npcs/client/gui/GuiScriptList.java
@@ -20,7 +20,7 @@ public class GuiScriptList extends SubGuiInterface {
public GuiScriptList(List scripts, ScriptContainer container) {
this(scripts, (IScriptUnit) container);
}
-
+
public GuiScriptList(List scripts, IScriptUnit scriptUnit) {
this.scriptUnit = scriptUnit;
setBackground("menubg.png");
diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiEffectGeneral.java b/src/main/java/noppes/npcs/client/gui/SubGuiEffectGeneral.java
index db1b516ea..cfde598de 100644
--- a/src/main/java/noppes/npcs/client/gui/SubGuiEffectGeneral.java
+++ b/src/main/java/noppes/npcs/client/gui/SubGuiEffectGeneral.java
@@ -8,7 +8,6 @@ import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.gui.global.GuiNPCManageEffects;
import noppes.npcs.client.gui.script.GuiScriptInterface;
-import noppes.npcs.controllers.data.EffectScript;
import noppes.npcs.client.gui.util.GuiMenuTopButton;
import noppes.npcs.client.gui.util.GuiNpcButtonYesNo;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -18,6 +17,7 @@ import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.controllers.data.CustomEffect;
+import noppes.npcs.controllers.data.EffectScript;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java b/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java
index 9025023b1..c3d85c8ad 100644
--- a/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java
+++ b/src/main/java/noppes/npcs/client/gui/SubGuiPlayerData.java
@@ -36,7 +36,7 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Fields
- ////////////////////////////////////////////////////////////////////////////////
+ /// /////////////////////////////////////////////////////////////////////////////
// Current tab (10=Quest, 11=Dialog, 12=Transport, 13=Bank, 14=Faction, 15=Magic)
private int currentTab = 10;
@@ -99,7 +99,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Constructor
- ////////////////////////////////////////////////////////////////////////////////
+
+ /// /////////////////////////////////////////////////////////////////////////////
public SubGuiPlayerData(String playerName) {
this.playerName = playerName;
xSize = 420;
@@ -112,7 +113,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Layout Helpers
- ////////////////////////////////////////////////////////////////////////////////
+
+ /// /////////////////////////////////////////////////////////////////////////////
private int getPaddedLeft() {
return guiLeft + leftPadding;
}
@@ -135,7 +137,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Component Setup Helpers
- ////////////////////////////////////////////////////////////////////////////////
+
+ /// /////////////////////////////////////////////////////////////////////////////
private void setupTopButtons() {
// Show General Display Information
GuiMenuTopButton playerTab = new GuiMenuTopButton(-10, guiLeft + 4, guiTop - 10, playerName);
@@ -192,7 +195,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// initGui() & Tab Initialization
- ////////////////////////////////////////////////////////////////////////////////
+
+ /// /////////////////////////////////////////////////////////////////////////////
@Override
public void initGui() {
super.initGui();
@@ -489,7 +493,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Drawing Helpers
- ////////////////////////////////////////////////////////////////////////////////
+
+ /// /////////////////////////////////////////////////////////////////////////////
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
@@ -525,7 +530,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Mouse & Resizing Handlers
- ////////////////////////////////////////////////////////////////////////////////
+
+ /// /////////////////////////////////////////////////////////////////////////////
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
int hitMargin = 3;
@@ -672,7 +678,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Key & Search Field Handling
- ////////////////////////////////////////////////////////////////////////////////
+
+ /// /////////////////////////////////////////////////////////////////////////////
@Override
public void keyTyped(char c, int i) {
super.keyTyped(c, i);
@@ -894,7 +901,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Action Handling
- ////////////////////////////////////////////////////////////////////////////////
+
+ /// /////////////////////////////////////////////////////////////////////////////
@Override
public void actionPerformed(GuiButton button) {
if (button.id == -5) {
@@ -1043,7 +1051,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Data Setting Methods (IPlayerDataInfo)
- ////////////////////////////////////////////////////////////////////////////////
+
+ /// /////////////////////////////////////////////////////////////////////////////
@Override
public void setQuestData(Map questCategories, Map questActive, Map questFinished) {
this.questCatData = new HashMap<>(questCategories);
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java
index 584bd8238..0f41347d4 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/GuiNPCAbilities.java
@@ -10,7 +10,18 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
-import noppes.npcs.client.gui.util.*;
+import noppes.npcs.client.gui.util.GuiCustomScroll;
+import noppes.npcs.client.gui.util.GuiNPCInterface2;
+import noppes.npcs.client.gui.util.GuiNpcButton;
+import noppes.npcs.client.gui.util.GuiNpcLabel;
+import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
+import noppes.npcs.client.gui.util.ICustomScrollListener;
+import noppes.npcs.client.gui.util.IGuiData;
+import noppes.npcs.client.gui.util.IScrollData;
+import noppes.npcs.client.gui.util.ISubGuiListener;
+import noppes.npcs.client.gui.util.ITextfieldListener;
+import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumScrollData;
import noppes.npcs.entity.EntityNPCInterface;
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java
index c88c18095..1146ea4ae 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityConfig.java
@@ -10,7 +10,14 @@ import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.select.GuiAnimationSelection;
import noppes.npcs.client.gui.select.GuiSoundSelection;
-import noppes.npcs.client.gui.util.*;
+import noppes.npcs.client.gui.util.GuiMenuTopButton;
+import noppes.npcs.client.gui.util.GuiNpcButton;
+import noppes.npcs.client.gui.util.GuiNpcLabel;
+import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
+import noppes.npcs.client.gui.util.ISubGuiListener;
+import noppes.npcs.client.gui.util.ITextfieldListener;
+import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.ArrayList;
import java.util.List;
@@ -18,13 +25,13 @@ import java.util.List;
/**
* Base SubGui for editing ability configuration with tabbed interface.
* Uses GuiMenuTopButton for navigation tabs.
- *
+ *
* Tabs:
* - General: Name, Weight, Lock Movement, Interruptible, Timing
* - Type: Type-specific settings per Ability (override in subclasses)
* - Target: Min/Max Range, Targeting Mode, Conditions (up to 3)
* - Effects: Sounds, Animations, Telegraph settings, Colors
- *
+ *
* Subclasses should override initTypeTab() and handleTypeButton()/handleTypeTextField()
* to provide type-specific settings UI.
*/
@@ -376,13 +383,13 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
String typeId = cond.getTypeId();
switch (typeId) {
case "hp_above":
- return StatCollector.translateToLocal("condition.hp_above") + " " + (int)(getConditionThreshold(cond) * 100) + "%";
+ return StatCollector.translateToLocal("condition.hp_above") + " " + (int) (getConditionThreshold(cond) * 100) + "%";
case "hp_below":
- return StatCollector.translateToLocal("condition.hp_below") + " " + (int)(getConditionThreshold(cond) * 100) + "%";
+ return StatCollector.translateToLocal("condition.hp_below") + " " + (int) (getConditionThreshold(cond) * 100) + "%";
case "target_hp_above":
- return StatCollector.translateToLocal("condition.target_hp_above") + " " + (int)(getConditionThreshold(cond) * 100) + "%";
+ return StatCollector.translateToLocal("condition.target_hp_above") + " " + (int) (getConditionThreshold(cond) * 100) + "%";
case "target_hp_below":
- return StatCollector.translateToLocal("condition.target_hp_below") + " " + (int)(getConditionThreshold(cond) * 100) + "%";
+ return StatCollector.translateToLocal("condition.target_hp_below") + " " + (int) (getConditionThreshold(cond) * 100) + "%";
case "hit_count":
Condition.ConditionHitCount hitCount = (Condition.ConditionHitCount) cond;
return StatCollector.translateToLocal("condition.hit_count") + ": " + hitCount.getRequiredHits() + "/" + hitCount.getWithinTicks() + "t";
@@ -566,8 +573,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// General tab buttons
else if (id == 14) {
interruptible = ((GuiNpcButton) guibutton).getValue() == 1;
- }
- else if (id == 16) {
+ } else if (id == 16) {
lockMovement = ((GuiNpcButton) guibutton).getValue() == 1;
}
@@ -619,12 +625,10 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
else if (id == 20) {
showTelegraph = ((GuiNpcButton) guibutton).getValue() == 1;
initGui();
- }
- else if (id == 22) {
+ } else if (id == 22) {
editingColorId = 22;
setSubGui(new SubGuiColorSelector(windUpColor));
- }
- else if (id == 24) {
+ } else if (id == 24) {
editingColorId = 24;
setSubGui(new SubGuiColorSelector(activeColor));
}
@@ -633,8 +637,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
else if (id == 30) {
editingSoundId = 30;
setSubGui(new GuiSoundSelection(windUpSound));
- }
- else if (id == 31) {
+ } else if (id == 31) {
editingSoundId = 31;
setSubGui(new GuiSoundSelection(activeSound));
}
@@ -642,8 +645,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
else if (id == 35) {
windUpSound = "";
initGui();
- }
- else if (id == 36) {
+ } else if (id == 36) {
activeSound = "";
initGui();
}
@@ -651,8 +653,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
else if (id == 32) {
editingAnimationId = 32;
setSubGui(new GuiAnimationSelection(windUpAnimationId));
- }
- else if (id == 33) {
+ } else if (id == 33) {
editingAnimationId = 33;
setSubGui(new GuiAnimationSelection(activeAnimationId));
}
@@ -661,8 +662,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
windUpAnimationId = -1;
windUpAnimationName = null;
initGui();
- }
- else if (id == 38) {
+ } else if (id == 38) {
activeAnimationId = -1;
activeAnimationName = null;
initGui();
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityLoad.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityLoad.java
index 069c9f1b4..c48683070 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityLoad.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiAbilityLoad.java
@@ -3,7 +3,11 @@ package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import net.minecraft.client.gui.GuiButton;
-import noppes.npcs.client.gui.util.*;
+import noppes.npcs.client.gui.util.GuiCustomScroll;
+import noppes.npcs.client.gui.util.GuiNpcButton;
+import noppes.npcs.client.gui.util.GuiNpcLabel;
+import noppes.npcs.client.gui.util.ICustomScrollListener;
+import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiConditionEdit.java b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiConditionEdit.java
index f0d4f2734..3d2874dbc 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/SubGuiConditionEdit.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/SubGuiConditionEdit.java
@@ -2,7 +2,11 @@ package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.Condition;
import net.minecraft.client.gui.GuiButton;
-import noppes.npcs.client.gui.util.*;
+import noppes.npcs.client.gui.util.GuiNpcButton;
+import noppes.npcs.client.gui.util.GuiNpcLabel;
+import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.ITextfieldListener;
+import noppes.npcs.client.gui.util.SubGuiInterface;
/**
* SubGui for editing a single ability condition.
@@ -106,7 +110,7 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi
} else {
// HP threshold field (as percentage)
addLabel(new GuiNpcLabel(2, "condition.percent", labelX, y + 5));
- int percent = (int)(threshold * 100);
+ int percent = (int) (threshold * 100);
GuiNpcTextField thresholdField = new GuiNpcTextField(4, this, fontRendererObj, fieldX, y, 40, 20, String.valueOf(percent));
thresholdField.setIntegersOnly();
thresholdField.setMinMaxDefault(1, 99, 50);
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityBeam.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityBeam.java
index fb3e6b074..ce56f809e 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityBeam.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityBeam.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityBeam;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Beam ability type-specific settings.
@@ -72,21 +72,39 @@ public class SubGuiAbilityBeam extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
- case 106: beam.setPiercing(value == 1); break;
- case 107: beam.setLockOnTarget(value == 1); break;
- case 108: beam.setSweepBackAndForth(value == 1); break;
+ case 106:
+ beam.setPiercing(value == 1);
+ break;
+ case 107:
+ beam.setLockOnTarget(value == 1);
+ break;
+ case 108:
+ beam.setSweepBackAndForth(value == 1);
+ break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: beam.setDamage(parseFloat(field, beam.getDamage())); break;
- case 101: beam.setDamageInterval(field.getInteger()); break;
- case 102: beam.setBeamLength(parseFloat(field, beam.getBeamLength())); break;
- case 103: beam.setBeamWidth(parseFloat(field, beam.getBeamWidth())); break;
- case 104: beam.setSweepAngle(parseFloat(field, beam.getSweepAngle())); break;
- case 105: beam.setSweepSpeed(parseFloat(field, beam.getSweepSpeed())); break;
+ case 100:
+ beam.setDamage(parseFloat(field, beam.getDamage()));
+ break;
+ case 101:
+ beam.setDamageInterval(field.getInteger());
+ break;
+ case 102:
+ beam.setBeamLength(parseFloat(field, beam.getBeamLength()));
+ break;
+ case 103:
+ beam.setBeamWidth(parseFloat(field, beam.getBeamWidth()));
+ break;
+ case 104:
+ beam.setSweepAngle(parseFloat(field, beam.getSweepAngle()));
+ break;
+ case 105:
+ beam.setSweepSpeed(parseFloat(field, beam.getSweepSpeed()));
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCharge.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCharge.java
index d3ff5fd81..4d7486c5e 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCharge.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCharge.java
@@ -1,10 +1,10 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityCharge;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Charge ability type-specific settings.
@@ -50,10 +50,18 @@ public class SubGuiAbilityCharge extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: charge.setDamage(parseFloat(field, charge.getDamage())); break;
- case 101: charge.setChargeSpeed(parseFloat(field, charge.getChargeSpeed())); break;
- case 102: charge.setKnockback(parseFloat(field, charge.getKnockback())); break;
- case 104: charge.setHitWidth(parseFloat(field, charge.getHitWidth())); break;
+ case 100:
+ charge.setDamage(parseFloat(field, charge.getDamage()));
+ break;
+ case 101:
+ charge.setChargeSpeed(parseFloat(field, charge.getChargeSpeed()));
+ break;
+ case 102:
+ charge.setKnockback(parseFloat(field, charge.getKnockback()));
+ break;
+ case 104:
+ charge.setHitWidth(parseFloat(field, charge.getHitWidth()));
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCutter.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCutter.java
index d917282f2..514391f8a 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCutter.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityCutter.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityCutter;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Cutter ability type-specific settings.
@@ -82,23 +82,45 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
- case 106: cutter.setSweepMode(AbilityCutter.SweepMode.values()[value]); break;
- case 107: cutter.setPiercing(value == 1); break;
+ case 106:
+ cutter.setSweepMode(AbilityCutter.SweepMode.values()[value]);
+ break;
+ case 107:
+ cutter.setPiercing(value == 1);
+ break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: cutter.setDamage(parseFloat(field, cutter.getDamage())); break;
- case 101: cutter.setRange(parseFloat(field, cutter.getRange())); break;
- case 102: cutter.setArcAngle(parseFloat(field, cutter.getArcAngle())); break;
- case 103: cutter.setInnerRadius(parseFloat(field, cutter.getInnerRadius())); break;
- case 104: cutter.setKnockback(parseFloat(field, cutter.getKnockback())); break;
- case 105: cutter.setSweepSpeed(parseFloat(field, cutter.getSweepSpeed())); break;
- case 108: cutter.setStunDuration(field.getInteger()); break;
- case 109: cutter.setPoisonDurationSeconds(field.getInteger()); break;
- case 110: cutter.setPoisonLevel(field.getInteger()); break;
+ case 100:
+ cutter.setDamage(parseFloat(field, cutter.getDamage()));
+ break;
+ case 101:
+ cutter.setRange(parseFloat(field, cutter.getRange()));
+ break;
+ case 102:
+ cutter.setArcAngle(parseFloat(field, cutter.getArcAngle()));
+ break;
+ case 103:
+ cutter.setInnerRadius(parseFloat(field, cutter.getInnerRadius()));
+ break;
+ case 104:
+ cutter.setKnockback(parseFloat(field, cutter.getKnockback()));
+ break;
+ case 105:
+ cutter.setSweepSpeed(parseFloat(field, cutter.getSweepSpeed()));
+ break;
+ case 108:
+ cutter.setStunDuration(field.getInteger());
+ break;
+ case 109:
+ cutter.setPoisonDurationSeconds(field.getInteger());
+ break;
+ case 110:
+ cutter.setPoisonLevel(field.getInteger());
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDash.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDash.java
index 7ae0ea1f5..26bfd6610 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDash.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityDash.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityDash;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Dash ability type-specific settings.
@@ -52,8 +52,12 @@ public class SubGuiAbilityDash extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 101: dash.setDashDistance(parseFloat(field, dash.getDashDistance())); break;
- case 102: dash.setDashSpeed(parseFloat(field, dash.getDashSpeed())); break;
+ case 101:
+ dash.setDashDistance(parseFloat(field, dash.getDashDistance()));
+ break;
+ case 102:
+ dash.setDashSpeed(parseFloat(field, dash.getDashSpeed()));
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityGuard.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityGuard.java
index 4858445fb..c5240d862 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityGuard.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityGuard.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityGuard;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Guard ability type-specific settings.
@@ -86,11 +86,21 @@ public class SubGuiAbilityGuard extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: guard.setDamageReduction(parseFloat(field, guard.getDamageReduction())); break;
- case 103: guard.setCounterValue(parseFloat(field, guard.getCounterValue())); break;
- case 104: guard.setCounterChance(parseFloat(field, guard.getCounterChance())); break;
- case 105: guard.setCounterSound(field.getText()); break;
- case 106: guard.setCounterAnimationId(field.getInteger()); break;
+ case 100:
+ guard.setDamageReduction(parseFloat(field, guard.getDamageReduction()));
+ break;
+ case 103:
+ guard.setCounterValue(parseFloat(field, guard.getCounterValue()));
+ break;
+ case 104:
+ guard.setCounterChance(parseFloat(field, guard.getCounterChance()));
+ break;
+ case 105:
+ guard.setCounterSound(field.getText());
+ break;
+ case 106:
+ guard.setCounterAnimationId(field.getInteger());
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHazard.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHazard.java
index def67e71d..e44eb6984 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHazard.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHazard.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityHazard;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Hazard ability type-specific settings.
@@ -77,22 +77,42 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
- case 100: hazard.setShape(AbilityHazard.HazardShape.values()[value]); break;
- case 101: hazard.setPlacement(AbilityHazard.PlacementMode.values()[value]); break;
- case 109: hazard.setAffectsCaster(value == 1); break;
+ case 100:
+ hazard.setShape(AbilityHazard.HazardShape.values()[value]);
+ break;
+ case 101:
+ hazard.setPlacement(AbilityHazard.PlacementMode.values()[value]);
+ break;
+ case 109:
+ hazard.setAffectsCaster(value == 1);
+ break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 102: hazard.setRadius(parseFloat(field, hazard.getRadius())); break;
- case 103: hazard.setInnerRadius(parseFloat(field, hazard.getInnerRadius())); break;
- case 104: hazard.setDamagePerTick(parseFloat(field, hazard.getDamagePerTick())); break;
- case 105: hazard.setDamageInterval(field.getInteger()); break;
- case 106: hazard.setSlownessLevel(field.getInteger()); break;
- case 107: hazard.setDebuffDuration(field.getInteger()); break;
- case 108: hazard.setPoisonLevel(field.getInteger()); break;
+ case 102:
+ hazard.setRadius(parseFloat(field, hazard.getRadius()));
+ break;
+ case 103:
+ hazard.setInnerRadius(parseFloat(field, hazard.getInnerRadius()));
+ break;
+ case 104:
+ hazard.setDamagePerTick(parseFloat(field, hazard.getDamagePerTick()));
+ break;
+ case 105:
+ hazard.setDamageInterval(field.getInteger());
+ break;
+ case 106:
+ hazard.setSlownessLevel(field.getInteger());
+ break;
+ case 107:
+ hazard.setDebuffDuration(field.getInteger());
+ break;
+ case 108:
+ hazard.setPoisonLevel(field.getInteger());
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeal.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeal.java
index 30ccb739e..8b679fb25 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeal.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeal.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityHeal;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Heal ability type-specific settings.
@@ -57,18 +57,30 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
- case 103: heal.setInstantHeal(value == 1); break;
- case 104: heal.setHealSelf(value == 1); break;
- case 105: heal.setHealAllies(value == 1); break;
+ case 103:
+ heal.setInstantHeal(value == 1);
+ break;
+ case 104:
+ heal.setHealSelf(value == 1);
+ break;
+ case 105:
+ heal.setHealAllies(value == 1);
+ break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: heal.setHealAmount(parseFloat(field, heal.getHealAmount())); break;
- case 101: heal.setHealPercent(parseFloat(field, heal.getHealPercent())); break;
- case 102: heal.setHealRadius(parseFloat(field, heal.getHealRadius())); break;
+ case 100:
+ heal.setHealAmount(parseFloat(field, heal.getHealAmount()));
+ break;
+ case 101:
+ heal.setHealPercent(parseFloat(field, heal.getHealPercent()));
+ break;
+ case 102:
+ heal.setHealRadius(parseFloat(field, heal.getHealRadius()));
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeavyHit.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeavyHit.java
index 5c0d99c48..ea21127dc 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeavyHit.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityHeavyHit.java
@@ -1,10 +1,10 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityHeavyHit;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Heavy Hit ability type-specific settings.
@@ -52,11 +52,21 @@ public class SubGuiAbilityHeavyHit extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: heavyHit.setDamage(parseFloat(field, heavyHit.getDamage())); break;
- case 101: heavyHit.setPotionDurationSeconds(field.getInteger()); break;
- case 102: heavyHit.setKnockback(parseFloat(field, heavyHit.getKnockback())); break;
- case 103: heavyHit.setSlownessLevel(field.getInteger()); break;
- case 104: heavyHit.setWeaknessLevel(field.getInteger()); break;
+ case 100:
+ heavyHit.setDamage(parseFloat(field, heavyHit.getDamage()));
+ break;
+ case 101:
+ heavyHit.setPotionDurationSeconds(field.getInteger());
+ break;
+ case 102:
+ heavyHit.setKnockback(parseFloat(field, heavyHit.getKnockback()));
+ break;
+ case 103:
+ heavyHit.setSlownessLevel(field.getInteger());
+ break;
+ case 104:
+ heavyHit.setWeaknessLevel(field.getInteger());
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java
index fd75700c0..f94e8d0cf 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityOrb.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityOrb;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Orb ability type-specific settings.
@@ -75,22 +75,42 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
- case 104: orb.setHoming(value == 1); break;
- case 106: orb.setExplosive(value == 1); break;
+ case 104:
+ orb.setHoming(value == 1);
+ break;
+ case 106:
+ orb.setExplosive(value == 1);
+ break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: orb.setDamage(parseFloat(field, orb.getDamage())); break;
- case 101: orb.setOrbSpeed(parseFloat(field, orb.getOrbSpeed())); break;
- case 102: orb.setOrbSize(parseFloat(field, orb.getOrbSize())); break;
- case 103: orb.setMaxDistance(parseFloat(field, orb.getMaxDistance())); break;
- case 105: orb.setHomingStrength(parseFloat(field, orb.getHomingStrength())); break;
- case 107: orb.setExplosionRadius(parseFloat(field, orb.getExplosionRadius())); break;
- case 108: orb.setKnockback(parseFloat(field, orb.getKnockback())); break;
- case 109: orb.setMaxLifetime(field.getInteger()); break;
+ case 100:
+ orb.setDamage(parseFloat(field, orb.getDamage()));
+ break;
+ case 101:
+ orb.setOrbSpeed(parseFloat(field, orb.getOrbSpeed()));
+ break;
+ case 102:
+ orb.setOrbSize(parseFloat(field, orb.getOrbSize()));
+ break;
+ case 103:
+ orb.setMaxDistance(parseFloat(field, orb.getMaxDistance()));
+ break;
+ case 105:
+ orb.setHomingStrength(parseFloat(field, orb.getHomingStrength()));
+ break;
+ case 107:
+ orb.setExplosionRadius(parseFloat(field, orb.getExplosionRadius()));
+ break;
+ case 108:
+ orb.setKnockback(parseFloat(field, orb.getKnockback()));
+ break;
+ case 109:
+ orb.setMaxLifetime(field.getInteger());
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityProjectile.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityProjectile.java
index 88d7bbf00..c9be00e38 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityProjectile.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityProjectile.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityProjectile;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Projectile ability type-specific settings.
@@ -79,19 +79,33 @@ public class SubGuiAbilityProjectile extends SubGuiAbilityConfig {
String[] projTypes = {"fireball", "arrow", "magic"};
projectile.setProjectileType(projTypes[value]);
break;
- case 104: projectile.setExplosive(value == 1); break;
- case 106: projectile.setHoming(value == 1); break;
+ case 104:
+ projectile.setExplosive(value == 1);
+ break;
+ case 106:
+ projectile.setHoming(value == 1);
+ break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: projectile.setDamage(parseFloat(field, projectile.getDamage())); break;
- case 101: projectile.setSpeed(parseFloat(field, projectile.getSpeed())); break;
- case 102: projectile.setKnockback(parseFloat(field, projectile.getKnockback())); break;
- case 105: projectile.setExplosionRadius(parseFloat(field, projectile.getExplosionRadius())); break;
- case 107: projectile.setHomingStrength(parseFloat(field, projectile.getHomingStrength())); break;
+ case 100:
+ projectile.setDamage(parseFloat(field, projectile.getDamage()));
+ break;
+ case 101:
+ projectile.setSpeed(parseFloat(field, projectile.getSpeed()));
+ break;
+ case 102:
+ projectile.setKnockback(parseFloat(field, projectile.getKnockback()));
+ break;
+ case 105:
+ projectile.setExplosionRadius(parseFloat(field, projectile.getExplosionRadius()));
+ break;
+ case 107:
+ projectile.setHomingStrength(parseFloat(field, projectile.getHomingStrength()));
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityShockwave.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityShockwave.java
index 38ab22158..a03a85736 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityShockwave.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityShockwave.java
@@ -1,10 +1,10 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityShockwave;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Shockwave ability type-specific settings.
@@ -55,11 +55,21 @@ public class SubGuiAbilityShockwave extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: shockwave.setDamage(parseFloat(field, shockwave.getDamage())); break;
- case 101: shockwave.setPushRadius(parseFloat(field, shockwave.getPushRadius())); break;
- case 102: shockwave.setPushStrength(parseFloat(field, shockwave.getPushStrength())); break;
- case 103: shockwave.setStunDuration(field.getInteger()); break;
- case 104: shockwave.setMaxTargets(field.getInteger()); break;
+ case 100:
+ shockwave.setDamage(parseFloat(field, shockwave.getDamage()));
+ break;
+ case 101:
+ shockwave.setPushRadius(parseFloat(field, shockwave.getPushRadius()));
+ break;
+ case 102:
+ shockwave.setPushStrength(parseFloat(field, shockwave.getPushStrength()));
+ break;
+ case 103:
+ shockwave.setStunDuration(field.getInteger());
+ break;
+ case 104:
+ shockwave.setMaxTargets(field.getInteger());
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySlam.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySlam.java
index 7f8c7194e..989202037 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySlam.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilitySlam.java
@@ -1,10 +1,10 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilitySlam;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Slam ability type-specific settings.
@@ -52,11 +52,21 @@ public class SubGuiAbilitySlam extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: slam.setDamage(parseFloat(field, slam.getDamage())); break;
- case 101: slam.setRadius(parseFloat(field, slam.getRadius())); break;
- case 102: slam.setKnockbackStrength(parseFloat(field, slam.getKnockbackStrength())); break;
- case 103: slam.setLeapSpeed(parseFloat(field, slam.getLeapSpeed())); break;
- case 104: slam.setLeapHeight(parseFloat(field, slam.getLeapHeight())); break;
+ case 100:
+ slam.setDamage(parseFloat(field, slam.getDamage()));
+ break;
+ case 101:
+ slam.setRadius(parseFloat(field, slam.getRadius()));
+ break;
+ case 102:
+ slam.setKnockbackStrength(parseFloat(field, slam.getKnockbackStrength()));
+ break;
+ case 103:
+ slam.setLeapSpeed(parseFloat(field, slam.getLeapSpeed()));
+ break;
+ case 104:
+ slam.setLeapHeight(parseFloat(field, slam.getLeapHeight()));
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTeleport.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTeleport.java
index 5570d944f..6173f9ded 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTeleport.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTeleport.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityTeleport;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Teleport ability type-specific settings.
@@ -95,21 +95,39 @@ public class SubGuiAbilityTeleport extends SubGuiAbilityConfig {
teleport.setMode(AbilityTeleport.TeleportMode.values()[value]);
initGui();
break;
- case 105: teleport.setRequireLineOfSight(value == 1); break;
- case 108: teleport.setDamageAtStart(value == 1); break;
- case 109: teleport.setDamageAtEnd(value == 1); break;
+ case 105:
+ teleport.setRequireLineOfSight(value == 1);
+ break;
+ case 108:
+ teleport.setDamageAtStart(value == 1);
+ break;
+ case 109:
+ teleport.setDamageAtEnd(value == 1);
+ break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 101: teleport.setBlinkRadius(parseFloat(field, teleport.getBlinkRadius())); break;
- case 102: teleport.setBlinkCount(field.getInteger()); break;
- case 103: teleport.setBlinkDelayTicks(field.getInteger()); break;
- case 104: teleport.setBehindDistance(parseFloat(field, teleport.getBehindDistance())); break;
- case 106: teleport.setDamage(parseFloat(field, teleport.getDamage())); break;
- case 107: teleport.setDamageRadius(parseFloat(field, teleport.getDamageRadius())); break;
+ case 101:
+ teleport.setBlinkRadius(parseFloat(field, teleport.getBlinkRadius()));
+ break;
+ case 102:
+ teleport.setBlinkCount(field.getInteger());
+ break;
+ case 103:
+ teleport.setBlinkDelayTicks(field.getInteger());
+ break;
+ case 104:
+ teleport.setBehindDistance(parseFloat(field, teleport.getBehindDistance()));
+ break;
+ case 106:
+ teleport.setDamage(parseFloat(field, teleport.getDamage()));
+ break;
+ case 107:
+ teleport.setDamageRadius(parseFloat(field, teleport.getDamageRadius()));
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTrap.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTrap.java
index 88529fe68..781d0665a 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTrap.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityTrap.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityTrap;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Trap ability type-specific settings.
@@ -79,14 +79,30 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 101: trap.setTriggerRadius(parseFloat(field, trap.getTriggerRadius())); break;
- case 102: trap.setDamage(parseFloat(field, trap.getDamage())); break;
- case 103: trap.setDamageRadius(parseFloat(field, trap.getDamageRadius())); break;
- case 104: trap.setArmTime(field.getInteger()); break;
- case 105: trap.setMaxTriggers(field.getInteger()); break;
- case 106: trap.setRootDuration(field.getInteger()); break;
- case 107: trap.setStunDuration(field.getInteger()); break;
- case 108: trap.setKnockback(parseFloat(field, trap.getKnockback())); break;
+ case 101:
+ trap.setTriggerRadius(parseFloat(field, trap.getTriggerRadius()));
+ break;
+ case 102:
+ trap.setDamage(parseFloat(field, trap.getDamage()));
+ break;
+ case 103:
+ trap.setDamageRadius(parseFloat(field, trap.getDamageRadius()));
+ break;
+ case 104:
+ trap.setArmTime(field.getInteger());
+ break;
+ case 105:
+ trap.setMaxTriggers(field.getInteger());
+ break;
+ case 106:
+ trap.setRootDuration(field.getInteger());
+ break;
+ case 107:
+ trap.setStunDuration(field.getInteger());
+ break;
+ case 108:
+ trap.setKnockback(parseFloat(field, trap.getKnockback()));
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityVortex.java b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityVortex.java
index a1abbd661..003cef5c6 100644
--- a/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityVortex.java
+++ b/src/main/java/noppes/npcs/client/gui/advanced/ability/SubGuiAbilityVortex.java
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityVortex;
-import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Vortex ability type-specific settings.
@@ -75,22 +75,42 @@ public class SubGuiAbilityVortex extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
- case 104: vortex.setAoe(value == 1); break;
- case 108: vortex.setDamageOnPull(value == 1); break;
+ case 104:
+ vortex.setAoe(value == 1);
+ break;
+ case 108:
+ vortex.setDamageOnPull(value == 1);
+ break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
- case 100: vortex.setPullRadius(parseFloat(field, vortex.getPullRadius())); break;
- case 101: vortex.setPullStrength(parseFloat(field, vortex.getPullStrength())); break;
- case 102: vortex.setDamage(parseFloat(field, vortex.getDamage())); break;
- case 103: vortex.setKnockback(parseFloat(field, vortex.getKnockback())); break;
- case 105: vortex.setMaxTargets(field.getInteger()); break;
- case 106: vortex.setStunDuration(field.getInteger()); break;
- case 107: vortex.setRootDuration(field.getInteger()); break;
- case 109: vortex.setPullDamage(parseFloat(field, vortex.getPullDamage())); break;
+ case 100:
+ vortex.setPullRadius(parseFloat(field, vortex.getPullRadius()));
+ break;
+ case 101:
+ vortex.setPullStrength(parseFloat(field, vortex.getPullStrength()));
+ break;
+ case 102:
+ vortex.setDamage(parseFloat(field, vortex.getDamage()));
+ break;
+ case 103:
+ vortex.setKnockback(parseFloat(field, vortex.getKnockback()));
+ break;
+ case 105:
+ vortex.setMaxTargets(field.getInteger());
+ break;
+ case 106:
+ vortex.setStunDuration(field.getInteger());
+ break;
+ case 107:
+ vortex.setRootDuration(field.getInteger());
+ break;
+ case 109:
+ vortex.setPullDamage(parseFloat(field, vortex.getPullDamage()));
+ break;
}
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java
index e5ae8c436..22d0f3103 100644
--- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java
+++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageAbilities.java
@@ -3,13 +3,21 @@ package noppes.npcs.client.gui.global;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import net.minecraft.client.gui.GuiButton;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.SubGuiAbilityDeleteConfirm;
-import noppes.npcs.client.gui.advanced.SubGuiAbilityLoad;
-import noppes.npcs.client.gui.util.*;
+import noppes.npcs.client.gui.util.GuiCustomScroll;
+import noppes.npcs.client.gui.util.GuiNPCInterface2;
+import noppes.npcs.client.gui.util.GuiNpcButton;
+import noppes.npcs.client.gui.util.GuiNpcLabel;
+import noppes.npcs.client.gui.util.GuiNpcTextField;
+import noppes.npcs.client.gui.util.IAbilityConfigCallback;
+import noppes.npcs.client.gui.util.ICustomScrollListener;
+import noppes.npcs.client.gui.util.ISubGuiListener;
+import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.entity.EntityNPCInterface;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
/**
* Global GUI for managing saved ability presets.
diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java
index f246cb417..40df2d463 100644
--- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java
+++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcManageRecipes.java
@@ -13,7 +13,6 @@ import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiNpcAvailability;
import noppes.npcs.client.gui.script.GuiScriptInterface;
-import noppes.npcs.controllers.data.RecipeScript;
import noppes.npcs.client.gui.util.GuiButtonBiDirectional;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
import noppes.npcs.client.gui.util.GuiCustomScroll;
@@ -32,6 +31,7 @@ import noppes.npcs.constants.EnumScrollData;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.controllers.data.RecipeAnvil;
import noppes.npcs.controllers.data.RecipeCarpentry;
+import noppes.npcs.controllers.data.RecipeScript;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
diff --git a/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java b/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java
index fd57c0171..b71f6642a 100644
--- a/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java
+++ b/src/main/java/noppes/npcs/client/gui/item/SubGuiLinkedItem.java
@@ -13,7 +13,6 @@ import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.global.GuiNPCManageLinked;
import noppes.npcs.client.gui.script.GuiScriptInterface;
-import noppes.npcs.controllers.data.LinkedItemScript;
import noppes.npcs.client.gui.util.GuiButtonBiDirectional;
import noppes.npcs.client.gui.util.GuiMenuTopButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
@@ -26,6 +25,7 @@ import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.controllers.data.LinkedItem;
+import noppes.npcs.controllers.data.LinkedItemScript;
import org.lwjgl.opengl.GL11;
public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListener, GuiYesNoCallback, ISubGuiListener {
@@ -120,8 +120,8 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe
GuiNpcTextField digSpeedField = new GuiNpcTextField(12, this, x + 110, y, 50, 20, "" + linkedItem.digSpeed);
digSpeedField.setIntegersOnly().setMinMaxDefault(0, 20, 1);
addTextField(digSpeedField);
- GuiNpcTextField attackSpeedField = new GuiNpcTextField(14, this, x +165, y, 50, 20, "" +linkedItem.attackSpeed);
- attackSpeedField.setIntegersOnly().setMinMaxDefault(0,999999999,20);
+ GuiNpcTextField attackSpeedField = new GuiNpcTextField(14, this, x + 165, y, 50, 20, "" + linkedItem.attackSpeed);
+ attackSpeedField.setIntegersOnly().setMinMaxDefault(0, 999999999, 20);
addTextField(attackSpeedField);
y += spacing;
diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java
index 885c61d94..26942e57f 100644
--- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java
+++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java
@@ -9,11 +9,11 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
+import noppes.npcs.client.gui.advanced.GuiNPCAbilities;
import noppes.npcs.client.gui.advanced.GuiNPCAdvancedLinkedNpc;
import noppes.npcs.client.gui.advanced.GuiNPCDialogNpcOptions;
import noppes.npcs.client.gui.advanced.GuiNPCFactionSetup;
import noppes.npcs.client.gui.advanced.GuiNPCLinesMenu;
-import noppes.npcs.client.gui.advanced.GuiNPCAbilities;
import noppes.npcs.client.gui.advanced.GuiNPCMagic;
import noppes.npcs.client.gui.advanced.GuiNPCMarks;
import noppes.npcs.client.gui.advanced.GuiNPCNightSetup;
@@ -25,8 +25,8 @@ import noppes.npcs.client.gui.roles.GuiNpcConversation;
import noppes.npcs.client.gui.roles.GuiNpcFollowerJob;
import noppes.npcs.client.gui.roles.GuiNpcGuard;
import noppes.npcs.client.gui.roles.GuiNpcHealer;
-import noppes.npcs.client.gui.roles.GuiNpcSpawner;
import noppes.npcs.client.gui.roles.GuiNpcMount;
+import noppes.npcs.client.gui.roles.GuiNpcSpawner;
import noppes.npcs.client.gui.roles.GuiNpcTransporter;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
diff --git a/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java b/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java
index cd47fed55..fe6daff23 100644
--- a/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java
+++ b/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java
@@ -105,7 +105,7 @@ public class EventGuiScriptList extends SubGuiInterface {
public List getScripts() {
return this.container.getExternalScripts();
}
-
+
public void save() {
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiJaninoScript.java b/src/main/java/noppes/npcs/client/gui/script/GuiJaninoScript.java
index acfac310a..9fb601162 100644
--- a/src/main/java/noppes/npcs/client/gui/script/GuiJaninoScript.java
+++ b/src/main/java/noppes/npcs/client/gui/script/GuiJaninoScript.java
@@ -1,17 +1,38 @@
package noppes.npcs.client.gui.script;
-import noppes.npcs.janino.JaninoScript;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.*;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiConfirmOpenLink;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.GuiYesNo;
+import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesStringUtils;
-import noppes.npcs.client.gui.util.*;
+import noppes.npcs.client.gui.util.GuiCustomScroll;
+import noppes.npcs.client.gui.util.GuiMenuTopButton;
+import noppes.npcs.client.gui.util.GuiNPCInterface;
+import noppes.npcs.client.gui.util.GuiNpcButton;
+import noppes.npcs.client.gui.util.GuiNpcLabel;
+import noppes.npcs.client.gui.util.GuiNpcTextArea;
+import noppes.npcs.client.gui.util.GuiScriptTextArea;
+import noppes.npcs.client.gui.util.ICustomScrollListener;
+import noppes.npcs.client.gui.util.ISubGuiListener;
+import noppes.npcs.client.gui.util.ITextChangeListener;
+import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.ScriptController;
+import noppes.npcs.janino.JaninoScript;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback, ITextChangeListener, ICustomScrollListener, ISubGuiListener {
@@ -21,7 +42,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
public List allExternalScripts = new ArrayList<>();
private final int scriptLimit = 1;
public String previousHookClicked = "";
-
+
// GUI display list
List hooklist = new ArrayList<>();
@@ -83,6 +104,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
}
}
}
+
public void initGui() {
this.ySize = (int) ((double) this.xSize * 0.56);
if ((double) this.ySize > (double) this.height * 0.95) {
@@ -95,7 +117,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
this.guiTop += 10;
int yoffset = (int) ((double) this.ySize * 0.02);
GuiMenuTopButton top;
- addTopButton(new GuiMenuTopButton(-1, guiLeft + xSize-2 , guiTop - 17, "X"));
+ addTopButton(new GuiMenuTopButton(-1, guiLeft + xSize - 2, guiTop - 17, "X"));
this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings"));
int topXoffset = 0;
int topYoffset = 0;
@@ -135,7 +157,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
textArea.setListener(this);
this.closeOnEsc(textArea::closeOnEsc);
this.addTextField(textArea);
-
+
int left1 = this.guiLeft + this.xSize - 104;
this.addButton(new GuiNpcButton(102, left1, this.guiTop + yoffset, 60, 20, "gui.clear"));
this.addButton(new GuiNpcButton(101, left1 + 61, this.guiTop + yoffset, 60, 20, "gui.paste"));
diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiNPCEventScripts.java b/src/main/java/noppes/npcs/client/gui/script/GuiNPCEventScripts.java
index cff2c111e..db1338fff 100644
--- a/src/main/java/noppes/npcs/client/gui/script/GuiNPCEventScripts.java
+++ b/src/main/java/noppes/npcs/client/gui/script/GuiNPCEventScripts.java
@@ -1,7 +1,7 @@
package noppes.npcs.client.gui.script;
-import noppes.npcs.controllers.data.IScriptHandlerPacket;
import noppes.npcs.controllers.data.DataScript;
+import noppes.npcs.controllers.data.IScriptHandlerPacket;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiNPCEventScripts extends GuiScriptInterface {
diff --git a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java
index 15d3e8e76..82012429f 100644
--- a/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java
+++ b/src/main/java/noppes/npcs/client/gui/script/GuiScriptInterface.java
@@ -1,7 +1,11 @@
package noppes.npcs.client.gui.script;
import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.*;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.GuiConfirmOpenLink;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.GuiYesNo;
+import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.StatCollector;
@@ -21,13 +25,13 @@ import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.IJTextAreaListener;
import noppes.npcs.client.gui.util.ITextChangeListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
+import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
-import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.IScriptHandler;
-import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.controllers.data.IScriptHandlerPacket;
+import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.scripted.item.ScriptCustomItem;
import org.lwjgl.opengl.Display;
@@ -50,15 +54,21 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
protected Map textAreas = new HashMap<>();
protected GuiScreen parent;
-
- /** If true, uses scroll-based tab selection instead of top buttons */
+
+ /**
+ * If true, uses scroll-based tab selection instead of top buttons
+ */
protected boolean useScrollTabs = false;
-
- /** If true, shows settings/script toggle instead of numbered tabs */
- protected boolean useSettingsToggle = false;
+
+ /**
+ * If true, shows settings/script toggle instead of numbered tabs
+ */
+ protected boolean useSettingsToggle = false;
// ==================== FULLSCREEN MODE ====================
- /** Whether the editor viewport is currently in fullscreen mode */
+ /**
+ * Whether the editor viewport is currently in fullscreen mode
+ */
public static boolean isFullscreen = false;
/**
@@ -67,19 +77,29 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
* All padding values are in scaled GUI pixels.
*/
public static class FullscreenConfig {
- /** Padding from the top edge of the screen */
+ /**
+ * Padding from the top edge of the screen
+ */
public static int paddingTop = 20;
- /** Padding from the bottom edge of the screen */
+ /**
+ * Padding from the bottom edge of the screen
+ */
public static int paddingBottom = 20;
- /** Padding from the left edge of the screen */
+ /**
+ * Padding from the left edge of the screen
+ */
public static int paddingLeft = 20;
- /** Padding from the right edge of the screen */
+ /**
+ * Padding from the right edge of the screen
+ */
public static int paddingRight = 20;
}
- /** Fullscreen toggle button drawn at top-right of viewport */
+ /**
+ * Fullscreen toggle button drawn at top-right of viewport
+ */
public final FullscreenButton fullscreenButton = new FullscreenButton();
-
+
public GuiScriptInterface() {
this.drawDefaultBackground = true;
this.closeOnEsc = true;
@@ -150,7 +170,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
topXoffset -= top.width + 20 * 22;
}
this.addTopButton(top = new GuiMenuTopButton(ta + 1, top.xPosition + top.width + topXoffset,
- top.yPosition + topYoffset, ta + 1 + ""));
+ top.yPosition + topYoffset, ta + 1 + ""));
topXoffset = 0;
topYoffset = 0;
scriptLimit = ta + 2;
@@ -159,8 +179,8 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
if (isSingle && handler.getSingleScript() != null)
this.addTopButton(
- top = new GuiMenuTopButton(1, top.xPosition + top.width + topXoffset, top.yPosition + topYoffset,
- "Script"));
+ top = new GuiMenuTopButton(1, top.xPosition + top.width + topXoffset, top.yPosition + topYoffset,
+ "Script"));
else if (this.handler.getScripts().size() < 100)
this.addTopButton(new GuiMenuTopButton(scriptLimit, top.xPosition + top.width, top.yPosition, "+"));
@@ -241,15 +261,15 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
GuiScriptTextArea activeArea = getActiveScriptArea();
if (activeArea == null) {
activeArea = new GuiScriptTextArea(this, 2, editorX, editorY, editorWidth, editorHeight,
- container == null ? "" : container.getScript());
+ container == null ? "" : container.getScript());
activeArea.setListener(this);
this.closeOnEsc(activeArea::closeOnEsc);
textAreas.put(idx, activeArea);
} else {
activeArea.init(editorX, editorY, editorWidth, editorHeight,
- container == null ? "" : container.getScript());
+ container == null ? "" : container.getScript());
}
-
+
// Set the scripting language for proper syntax highlighting
// Use the container's language if available, otherwise fall back to handler's language
String language = (container != null) ? container.getLanguage() : this.handler.getLanguage();
@@ -279,12 +299,12 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.addButton(new GuiNpcButton(101, left1 + 61, this.guiTop + yoffset, 60, 20, "gui.paste"));
this.addButton(new GuiNpcButton(100, left1, this.guiTop + 21 + yoffset, 60, 20, "gui.copy"));
this.addButton(new GuiNpcButton(105, left1 + 61, this.guiTop + 21 + yoffset, 60, 20, "gui.remove"));
-
+
// Language toggle button (only if handler supports Janino and there is more than one option)
if (handler.supportsJanino() && getLanguageOptions().size() > 1 && container != null) {
this.addButton(new GuiNpcButton(113, left1, this.guiTop + 42 + yoffset, 121, 20, container.getLanguage()));
}
-
+
this.addButton(new GuiNpcButton(107, left1, this.guiTop + 66 + yoffset, 80, 20, "script.loadscript"));
GuiCustomScroll scroll = (new GuiCustomScroll(this, 0)).setUnselectable();
@@ -303,7 +323,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
*/
private void initSettingsTab(int yoffset) {
GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset,
- this.xSize - 160 - yoffset, (int) ((float) this.ySize * 0.92F) - yoffset * 2, this.getConsoleText());
+ this.xSize - 160 - yoffset, (int) ((float) this.ySize * 0.92F) - yoffset * 2, this.getConsoleText());
var8.canEdit = false;
var8.setFocused(true);
this.addTextField(var8);
@@ -319,7 +339,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.getButton(103).enabled = languageOptions.size() > 0;
this.addLabel(new GuiNpcLabel(2, "gui.enabled", var9, this.guiTop + 36));
this.addButton(new GuiNpcButton(104, var9 + 60, this.guiTop + 31, 50, 20,
- new String[]{"gui.no", "gui.yes"}, this.handler.getEnabled() ? 1 : 0));
+ new String[]{"gui.no", "gui.yes"}, this.handler.getEnabled() ? 1 : 0));
if (this.player.worldObj.isRemote) {
this.addButton(new GuiNpcButton(106, var9, this.guiTop + 55, 150, 20, "script.openfolder"));
@@ -382,11 +402,11 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
IScriptUnit container = getCurrentContainer();
if (container == null)
return;
-
+
String addString = "";
if (!this.getTextField(2).getText().isEmpty())
addString += "\n";
-
+
// Generate the appropriate stub based on language
// hook is already the proper method name from EnumScriptType.function
addString += container.generateHookStub(hook, null);
@@ -525,7 +545,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
return textAreas.get(idx);
return null;
}
-
+
/**
* Get the current script index for text area storage.
* Override in subclasses with different tab logic.
@@ -533,7 +553,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
protected int getActiveScriptIndex() {
return this.activeTab - 1;
}
-
+
/**
* Get the current script container.
* Override in subclasses with different container access patterns.
@@ -642,14 +662,14 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
String language = container != null ? container.getLanguage() : this.handler.getLanguage();
this.setSubGui(new EventGuiScriptList((List) this.languages.get(language), container));
}
-
+
// Language toggle button - switch between ECMAScript and Java
if (guibutton.id == 113) {
int idx = getActiveScriptIndex();
if (idx >= 0 && idx < handler.getScripts().size()) {
IScriptUnit currentUnit = handler.getScripts().get(idx);
IScriptUnit newUnit;
-
+
if (currentUnit.isJanino()) {
// Switch from Java to ECMAScript
newUnit = new ScriptContainer(handler);
@@ -669,7 +689,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
handler.replaceScriptUnit(idx, newUnit);
// Clear the cached text area so it recreates with new language
textAreas.remove(idx);
-
+
// Reinitialize the GUI
initGui();
}
@@ -712,7 +732,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
return;
}
-
+
loadLanguagesData(compound);
}
@@ -759,7 +779,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
return;
this.setScript();
-
+
if (handler instanceof IScriptHandlerPacket)
((IScriptHandlerPacket) handler).sync();
@@ -790,7 +810,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
IScriptUnit current = getCurrentContainer();
if (current != null)
current.ensureCompiled();
-
+
if (parent != null) {
this.save();
parent.setWorldAndResolution(mc, width, height);
@@ -838,14 +858,18 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
public int size = 12;
public boolean hovered = false;
- /** Initialize button position relative to viewport bounds */
+ /**
+ * Initialize button position relative to viewport bounds
+ */
public void initGui(int viewportEndX, int viewportY, int scrollbarOffset) {
// Position at top-right, accounting for scrollbar
this.x = viewportEndX + scrollbarOffset - size - 4;
this.y = viewportY + 4;
}
- /** Draw the fullscreen toggle button */
+ /**
+ * Draw the fullscreen toggle button
+ */
public void draw(int mouseX, int mouseY) {
hovered = isMouseOver(mouseX, mouseY);
int y = this.y + getYOffset();
@@ -877,7 +901,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
drawRect(right, bottom, right + cornerLen, bottom + 1, iconColor);
drawRect(right, bottom, right + 1, bottom + cornerLen, iconColor);
-
+
} else {
// Draw expand icon (corners pointing outward) ⌐¬⌙⌞
// Top-left corner pointing outward
@@ -891,23 +915,27 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
drawRect(x + inset, y + size - inset - 1, x + inset + cornerLen, y + size - inset, iconColor);
// Bottom-right corner pointing outward
drawRect(x + size - inset - 1, y + size - inset - cornerLen, x + size - inset, y + size - inset,
- iconColor);
+ iconColor);
drawRect(x + size - inset - cornerLen, y + size - inset - 1, x + size - inset, y + size - inset,
- iconColor);
+ iconColor);
}
}
-
+
public void drawRect(int x1, int y1, int x2, int y2, int color) {
GuiUtil.drawRectD(x1, y1, x2, y2, color);
}
- /** Check if mouse is over the button */
+ /**
+ * Check if mouse is over the button
+ */
public boolean isMouseOver(int mouseX, int mouseY) {
int y = this.y + getYOffset();
return mouseX >= x && mouseX < x + size && mouseY >= y && mouseY < y + size;
}
- /** Handle click - returns true if click was consumed */
+ /**
+ * Handle click - returns true if click was consumed
+ */
public boolean mouseClicked(int mouseX, int mouseY, int button) {
if (button == 0 && isMouseOver(mouseX, mouseY)) {
toggleFullscreen();
diff --git a/src/main/java/noppes/npcs/client/gui/script/SubGuiSelectList.java b/src/main/java/noppes/npcs/client/gui/script/SubGuiSelectList.java
index e2812ecb2..2e20a6ed5 100644
--- a/src/main/java/noppes/npcs/client/gui/script/SubGuiSelectList.java
+++ b/src/main/java/noppes/npcs/client/gui/script/SubGuiSelectList.java
@@ -42,7 +42,7 @@ public class SubGuiSelectList extends SubGuiInterface {
scroll1.setSize(140, 180);
}
- addTopButton(new GuiMenuTopButton(-1, guiLeft + xSize-22 , guiTop - 17, "X"));
+ addTopButton(new GuiMenuTopButton(-1, guiLeft + xSize - 22, guiTop - 17, "X"));
scroll1.guiLeft = guiLeft + 4;
scroll1.guiTop = guiTop + 14;
diff --git a/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java b/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java
index 4f1bccfaf..3b8fda84d 100644
--- a/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java
+++ b/src/main/java/noppes/npcs/client/gui/select/GuiTextureSelection.java
@@ -371,6 +371,7 @@ public class GuiTextureSelection extends SubGuiInterface implements ICustomScrol
selectedDomain = domain;
this.location = location;
}
+
static class TextureData {
String domain;
String absoluteName;
diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java b/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java
index 07822888c..3624de03c 100644
--- a/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java
+++ b/src/main/java/noppes/npcs/client/gui/util/GuiDiagram.java
@@ -9,7 +9,7 @@ import noppes.npcs.constants.EnumDiagramLayout;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
-import java.awt.*;
+import java.awt.Point;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java
index 585ee8515..8444c5c1d 100644
--- a/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java
+++ b/src/main/java/noppes/npcs/client/gui/util/GuiNPCInterface.java
@@ -109,7 +109,7 @@ public abstract class GuiNPCInterface extends GuiScreen {
//Important for GuiScriptTextArea
for (GuiNpcTextField tf : textfields.values())
- tf.initGui();
+ tf.initGui();
}
@Override
@@ -208,6 +208,7 @@ public abstract class GuiNPCInterface extends GuiScreen {
}
}
}
+
@Override
public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
if (subgui != null) {
@@ -286,7 +287,7 @@ public abstract class GuiNPCInterface extends GuiScreen {
}
public void close() {
- if(GuiNpcTextField.activeTextfield != null)
+ if (GuiNpcTextField.activeTextfield != null)
GuiNpcTextField.unfocus();
Keyboard.enableRepeatEvents(false);
@@ -537,6 +538,7 @@ public abstract class GuiNPCInterface extends GuiScreen {
public void drawNpcWithExtras(EntityLivingBase entity, int mouseX, int mouseY, float partialTicks) {
drawNpc(entity, mouseX, mouseY, partialTicks);
}
+
public void drawNpc(EntityLivingBase entity, int mouseX, int mouseY, float partialTicks) {
if (hasSubGui() && !drawNPConSub)
return;
diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java
index 37ffdb807..c14d0da83 100644
--- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java
+++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcButton.java
@@ -126,6 +126,7 @@ public class GuiNpcButton extends GuiButton {
}
public AtomicBoolean rightClicked = new AtomicBoolean();
+
@Override
public boolean mousePressed(Minecraft minecraft, int i, int j) {
boolean bo = super.mousePressed(minecraft, i, j);
diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java
index 1345a584f..91f3ca142 100644
--- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java
+++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java
@@ -38,10 +38,10 @@ public class GuiNpcTextField extends GuiTextField {
public GuiNpcTextField(int id, GuiScreen parent, int i, int j, int k, int l, String s) {
this(id, parent, Minecraft.getMinecraft().fontRenderer, i, j, k, l, s);
}
-
+
public void initGui() {
}
-
+
protected boolean charAllowed(char c, int i) {
if (!integersOnly || Character.isDigit(c))
return true;
diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java
index c73f2bebf..77be0dd7c 100644
--- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java
+++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java
@@ -8,8 +8,17 @@ import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.ClientProxy;
import noppes.npcs.client.gui.script.GuiScriptInterface;
import noppes.npcs.client.gui.util.key.OverlayKeyPresetViewer;
-import noppes.npcs.client.gui.util.script.*;
+import noppes.npcs.client.gui.util.script.BracketMatcher;
+import noppes.npcs.client.gui.util.script.CommentHandler;
+import noppes.npcs.client.gui.util.script.CursorNavigation;
+import noppes.npcs.client.gui.util.script.GoToLineDialog;
+import noppes.npcs.client.gui.util.script.IndentHelper;
+import noppes.npcs.client.gui.util.script.JavaTextContainer;
import noppes.npcs.client.gui.util.script.JavaTextContainer.LineData;
+import noppes.npcs.client.gui.util.script.RenameRefactorHandler;
+import noppes.npcs.client.gui.util.script.ScrollState;
+import noppes.npcs.client.gui.util.script.SearchReplaceBar;
+import noppes.npcs.client.gui.util.script.SelectionState;
import noppes.npcs.client.key.impl.ScriptEditorKeys;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.util.ValueUtil;
@@ -27,7 +36,7 @@ import static net.minecraft.client.gui.GuiScreen.isCtrlKeyDown;
/**
* Script text editor component with syntax highlighting, bracket matching,
* smooth scrolling, and IDE-like features.
- *
+ *
* Helper classes used:
* - ScrollState: smooth scroll animation and state management
* - SelectionState: cursor position and text selection management
@@ -37,11 +46,11 @@ import static net.minecraft.client.gui.GuiScreen.isCtrlKeyDown;
* - CursorNavigation: cursor movement logic
*/
public class GuiScriptTextArea extends GuiNpcTextField {
-
+
// ==================== DIMENSIONS & POSITION ====================
public int x;
public int y;
-
+
// ==================== STATE FLAGS ====================
public boolean active = false;
public boolean enabled = true;
@@ -51,7 +60,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
public boolean tripleClicked = false;
private int clickCount = 0;
private long lastClicked = 0L;
-
+
// ==================== TEXT & CONTAINER ====================
public String text = null;
public String highlightedWord;
@@ -80,12 +89,12 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// ==================== HELPER CLASS INSTANCES ====================
private final ScrollState scroll = new ScrollState();
private final SelectionState selection = new SelectionState();
-
+
// ==================== UI COMPONENTS ====================
private int cursorCounter;
private ITextChangeListener listener;
private static int LINE_NUMBER_GUTTER_WIDTH = 25;
-
+
// ==================== UNDO/REDO ====================
public List undoList = new ArrayList<>();
public List redoList = new ArrayList<>();
@@ -97,7 +106,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// ==================== SEARCH/REPLACE ====================
public static final SearchReplaceBar searchBar = new SearchReplaceBar();
-
+
// ==================== GO TO LINE ====================
private final GoToLineDialog goToLineDialog = new GoToLineDialog();
@@ -125,11 +134,12 @@ public class GuiScriptTextArea extends GuiNpcTextField {
this.searchBaseHeight = 0;
this.searchAppliedOffset = 0;
this.searchBaseInitialized = false;
-
+
KEYS_OVERLAY.openOnClick = true;
initGui();
initializeKeyBindings();
}
+
public void initGui() {
int endX = x + width, endY = y + height;
int xOffset = hasVerticalScrollbar() ? -8 : -2;
@@ -137,11 +147,11 @@ public class GuiScriptTextArea extends GuiNpcTextField {
KEYS_OVERLAY.borderCol1 = KEYS_OVERLAY.borderCol2 = 0xFF3c3c3c;
int overlayWidth = 160;
KEYS_OVERLAY.initGui(x + (width - overlayWidth) / 2 + 5, y + height / 10, overlayWidth,
- height - height / 5 - 10);
+ height - height / 5 - 10);
KEYS_OVERLAY.viewButton.scale = 0.45f;
KEYS_OVERLAY.viewButton.initGui(endX + xOffset, endY - 26);
-
+
// Initialize search bar (preserves state across initGui calls)
searchBar.initGui(x, y, width);
if (searchBar.isVisible()) { // If open
@@ -150,7 +160,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
if (!active) // Focus search if opening another script tab & bar is open
searchBar.focus(false);
}
-
+
// Initialize Go To Line dialog
goToLineDialog.initGui(x, y, width);
}
@@ -193,7 +203,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
int visibleLines = effectiveHeight / container.lineHeight;
// Calculate how many lines the search bar covers
int linesHiddenBySRB = searchBarOffset > 0 ? (int) Math.ceil(
- (double) searchBarOffset / container.lineHeight) : 0;
+ (double) searchBarOffset / container.lineHeight) : 0;
for (int i = 0; i < container.lines.size(); i++) {
LineData ld = container.lines.get(i);
@@ -457,12 +467,13 @@ public class GuiScriptTextArea extends GuiNpcTextField {
}
}
}
+
// ==================== RENDERING ====================
public void drawTextBox(int xMouse, int yMouse) {
if (!visible)
return;
clampSelectionBounds();
-
+
// Dynamically calculate gutter width based on line count digits
if (container != null && container.linesCount > 0) {
int maxLineNum = container.linesCount;
@@ -473,7 +484,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// Draw outer border around entire area
int offset = fullscreen() ? 2 : 1;
drawRect(x - offset, y - offset - searchBar.getTotalHeight(), x + width + offset, y + height + offset,
- 0xffa0a0a0);
+ 0xffa0a0a0);
int searchHeight = searchBar.getTotalHeight();
@@ -483,7 +494,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// Draw text viewport background (starts after gutter)
drawRect(x + LINE_NUMBER_GUTTER_WIDTH, y, x + width, y + height, 0xff000000);
// Draw separator line between gutter and text area
- drawRect(x + LINE_NUMBER_GUTTER_WIDTH-1, y, x + LINE_NUMBER_GUTTER_WIDTH, y + height, 0xff3c3f41);
+ drawRect(x + LINE_NUMBER_GUTTER_WIDTH - 1, y, x + LINE_NUMBER_GUTTER_WIDTH, y + height, 0xff3c3f41);
// Enable scissor test to clip drawing to the TEXT viewport rectangle (excludes gutter)
GL11.glEnable(GL11.GL_SCISSOR_TEST);
@@ -509,7 +520,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// Handle scrollbar dragging (delegated to ScrollState)
if (scroll.isClickScrolling())
scroll.handleClickScrolling(yMouse, x, y, height, container.visibleLines, getPaddedLineCount(), maxScroll);
-
+
// Update scroll animation
scroll.initializeIfNeeded(scroll.getScrolledLine());
scroll.update(maxScroll);
@@ -535,8 +546,8 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// Calculate braces next to cursor to highlight
int startBracket = 0, endBracket = 0;
if (selection.getStartSelection() >= 0 && text != null && text.length() > 0 &&
- (selection.getEndSelection() - selection.getStartSelection() == 1 || !selection.hasSelection())) {
- int[] span = BracketMatcher.findBracketSpanAt(text,selection.getStartSelection());
+ (selection.getEndSelection() - selection.getStartSelection() == 1 || !selection.hasSelection())) {
+ int[] span = BracketMatcher.findBracketSpanAt(text, selection.getStartSelection());
if (span != null) {
startBracket = span[0];
endBracket = span[1];
@@ -544,12 +555,12 @@ public class GuiScriptTextArea extends GuiNpcTextField {
}
List list = new ArrayList<>(container.lines);
-
+
// Build brace spans: {origDepth, open line, close line, adjustedDepth}
List braceSpans = BracketMatcher.computeBraceSpans(text, list);
// Always highlight unmatched braces (positions in text)
List unmatchedBraces = BracketMatcher.findUnmatchedBracePositions(text);
-
+
// Determine which exact brace span (openLine/closeLine) to highlight indent guides for
int highlightedOpenLine = -1;
int highlightedCloseLine = -1;
@@ -618,19 +629,19 @@ public class GuiScriptTextArea extends GuiNpcTextField {
float fracPixels = (float) (fracOffset * container.lineHeight);
GL11.glPushMatrix();
GL11.glTranslatef(0.0f, -fracPixels, 0.0f);
-
-
+
+
// Expand render range by one line above/below so partially-visible lines are drawn
int renderStart = Math.max(0, scroll.getScrolledLine() - 1);
// Compute the last line index to render, including the last partially-visible line if any.
// Adds the fractional scroll offset (fracOffset * lineHeight) to ensure the bottom line is drawn
// when only part of it is visible in the viewport.
int renderEnd = (int) Math.min(list.size() - 1,
- scroll.getScrolledLine() + container.visibleLines + fracPixels + 1);
+ scroll.getScrolledLine() + container.visibleLines + fracPixels + 1);
// Strings start drawing vertically this much into the line.
int stringYOffset = 2;
-
+
// Render LINE GUTTER numbers
for (int i = renderStart; i <= renderEnd; i++) {
int posY = y + (i - scroll.getScrolledLine()) * container.lineHeight + stringYOffset;
@@ -698,7 +709,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
}
}
}
-
+
// Highlight search matches
if (searchBar.isVisible()) {
List searchMatches = searchBar.getMatches();
@@ -747,8 +758,8 @@ public class GuiScriptTextArea extends GuiNpcTextField {
if (occStart <= occEnd) { // Changed from < to <= to handle empty case
int s = ClientProxy.Font.width(line.substring(0, occStart));
int e = isEmpty ? s + 2 : ClientProxy.Font.width(
- line.substring(0, occEnd)) + 1; // 2px wide for empty
- int occX = x + LINE_NUMBER_GUTTER_WIDTH + s;
+ line.substring(0, occEnd)) + 1; // 2px wide for empty
+ int occX = x + LINE_NUMBER_GUTTER_WIDTH + s;
int occEndX = x + LINE_NUMBER_GUTTER_WIDTH + 2 + e;
boolean isPrimary = renameHandler.isPrimaryOccurrence(occ[0]);
@@ -761,12 +772,12 @@ public class GuiScriptTextArea extends GuiNpcTextField {
int borderColor = 0xDDFFFFFF;
//RED BG
drawRect(occX, posY, occEndX, posY + container.lineHeight, 0x33ff0000);
-
+
// Top border
drawRect(occX, posY, occEndX, posY + 1, borderColor);
- // Bottom border
+ // Bottom border
drawRect(occX, posY + container.lineHeight - 1, occEndX,
- posY + container.lineHeight, borderColor);
+ posY + container.lineHeight, borderColor);
// Left border
drawRect(occX, posY, occX + 1, posY + container.lineHeight, borderColor);
// Right border
@@ -778,7 +789,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
String currentWord = renameHandler.getCurrentWord();
if (currentWord != null && cursorInWord >= 0 && cursorInWord <= currentWord.length()) {
String beforeCursor = currentWord.substring(0,
- Math.min(cursorInWord, currentWord.length()));
+ Math.min(cursorInWord, currentWord.length()));
int cursorX = occX + ClientProxy.Font.width(beforeCursor);
// drawRect(cursorX, posY + 1, cursorX + 1, posY + container.lineHeight - 1,
// 0xFFFFFFFF);
@@ -789,18 +800,18 @@ public class GuiScriptTextArea extends GuiNpcTextField {
}
}
}
-
+
// Highlight the current line (light gray) under any selection
if (active && isEnabled() && (selection.getCursorPosition() >= data.start && selection.getCursorPosition() < data.end || (i == list.size() - 1 && selection.getCursorPosition() == text.length()))) {
- drawRect(x , posY, x + width - 1, posY + container.lineHeight, 0x22e0e0e0);
+ drawRect(x, posY, x + width - 1, posY + container.lineHeight, 0x22e0e0e0);
}
// Highlight selection
if (selection.hasSelection() && selection.getEndSelection() > data.start && selection.getStartSelection() <= data.end) {
if (selection.getStartSelection() < data.end) {
int s = ClientProxy.Font.width(
- line.substring(0, Math.max(selection.getStartSelection() - data.start, 0)));
+ line.substring(0, Math.max(selection.getStartSelection() - data.start, 0)));
int e = ClientProxy.Font.width(
- line.substring(0, Math.min(selection.getEndSelection() - data.start, w))) + 1;
+ line.substring(0, Math.min(selection.getEndSelection() - data.start, w))) + 1;
drawRect(x + LINE_NUMBER_GUTTER_WIDTH + 1 + s, posY, x + LINE_NUMBER_GUTTER_WIDTH + 1 + e, posY + container.lineHeight, 0x992172ff);
}
}
@@ -837,11 +848,11 @@ public class GuiScriptTextArea extends GuiNpcTextField {
boolean highlighted = (openLine == highlightedOpenLine && closeLine == highlightedCloseLine);
int guideColor = highlighted ? 0x9933cc00 : 0x33FFFFFF;
-
+
int topY = y + (drawStart - scroll.getScrolledLine()) * container.lineHeight;
int bottomY = y + (endLine - scroll.getScrolledLine() + 1) * container.lineHeight;
- if(highlighted)
- bottomY-=2;
+ if (highlighted)
+ bottomY -= 2;
drawRect(gx, topY, gx + 1, bottomY, guideColor);
}
}
@@ -852,15 +863,15 @@ public class GuiScriptTextArea extends GuiNpcTextField {
boolean recentInput = selection.hadRecentInput();
if (active && isEnabled() && (recentInput || (cursorCounter / 10) % 2 == 0) && (selection.getCursorPosition() >= data.start && selection.getCursorPosition() < data.end || (i == list.size() - 1 && selection.getCursorPosition() == text.length()))) {
int posX = x + LINE_NUMBER_GUTTER_WIDTH + ClientProxy.Font.width(
- line.substring(0, Math.min(selection.getCursorPosition() - data.start, line.length())));
- drawRect(posX + 1, posY, posX + 2, posY + container.lineHeight, 0xffffffff);
+ line.substring(0, Math.min(selection.getCursorPosition() - data.start, line.length())));
+ drawRect(posX + 1, posY, posX + 2, posY + container.lineHeight, 0xffffffff);
}
}
}
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
-
+
if (hasVerticalScrollbar()) {
Minecraft.getMinecraft().renderEngine.bindTexture(GuiCustomScroll.resource);
int effLines = Math.max(1, getPaddedLineCount());
@@ -875,7 +886,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// Draw search/replace bar (overlays viewport)
searchBar.draw(xMouse, yMouse);
-
+
// Draw go to line dialog (overlays everything)
goToLineDialog.draw(xMouse, yMouse);
KEYS_OVERLAY.draw(xMouse, yMouse, wheelDelta);
@@ -902,13 +913,13 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// visible lines (fractional positions) correctly hit that line.
double fracPixels = scroll.getFractionalOffset() * container.lineHeight;
double yMouseD = yMouse + fracPixels;
-
+
ArrayList list = new ArrayList(this.container.lines);
for (int i = 0; i < list.size(); ++i) {
LineData data = (LineData) list.get(i);
//+1 to account for the fractional line
- if (i >= scroll.getScrolledLine() && i <= scroll.getScrolledLine() + this.container.visibleLines +1) {
+ if (i >= scroll.getScrolledLine() && i <= scroll.getScrolledLine() + this.container.visibleLines + 1) {
double yPos = (i - scroll.getScrolledLine()) * this.container.lineHeight;
if (yMouseD >= yPos && yMouseD < yPos + this.container.lineHeight) {
int lineWidth = 0;
@@ -941,13 +952,13 @@ public class GuiScriptTextArea extends GuiNpcTextField {
private int getCursorLineIndex() {
return selection.getCursorLineIndex(container.lines, text != null ? text.length() : 0);
}
-
-
+
+
// Scroll viewport to keep cursor visible (minimal adjustment, like IntelliJ)
// Only scrolls if cursor is outside the visible area
private void scrollToCursor() {
if (container == null || container.lines == null || container.lines.isEmpty()) return;
-
+
int lineIdx = getCursorLineIndex();
int visible = Math.max(1, container.visibleLines);
int effectiveVisible = Math.max(1, visible - bottomPaddingLines);
@@ -1162,27 +1173,27 @@ public class GuiScriptTextArea extends GuiNpcTextField {
KEYS.SEARCH.setTask(e -> {
if (!e.isPress() || !openBoxes.get())
return;
-
+
unfocusAll();
searchBar.openSearch();
});
-
+
// SEARCH_REPLACE: Open search+replace bar (Ctrl+Shift+R)
// Works in search bar.
KEYS.SEARCH_REPLACE.setTask(e -> {
if (!e.isPress() || !openBoxes.get())
return;
-
+
unfocusAll();
searchBar.openSearchReplace();
});
-
+
// GO_TO_LINE: Open go to line dialog (Ctrl+G)
// Works in search bar.
KEYS.GO_TO_LINE.setTask(e -> {
if (!e.isPress() || !openBoxes.get())
return;
-
+
unfocusAll();
goToLineDialog.toggle();
});
@@ -1221,13 +1232,13 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// Handle rename refactor input first if active
if (renameHandler.isActive() && renameHandler.keyTyped(c, i))
return true;
-
+
// Handle Go To Line dialog input first if it has focus
- if (goToLineDialog.isVisible() &&goToLineDialog.keyTyped(c, i))
- return true;
-
+ if (goToLineDialog.isVisible() && goToLineDialog.keyTyped(c, i))
+ return true;
+
// Handle search bar input first if it has focus
- if (searchBar.isVisible() && searchBar.keyTyped(c, i))
+ if (searchBar.isVisible() && searchBar.keyTyped(c, i))
return true;
if (!active)
@@ -1339,7 +1350,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
int cursorPos = selection.getCursorPosition();
int prevNonWs = cursorPos - 1;
while (prevNonWs >= 0 && prevNonWs < (text != null ? text.length() : 0) && Character.isWhitespace(
- text.charAt(prevNonWs))) {
+ text.charAt(prevNonWs))) {
prevNonWs--;
}
@@ -1473,7 +1484,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
s = s.substring(0, nearestCondition);
// Adjust selection start to match removed characters
selection.setStartSelection(
- selection.getStartSelection() - (selection.getCursorPosition() - nearestCondition));
+ selection.getStartSelection() - (selection.getCursorPosition() - nearestCondition));
}
setText(s + getSelectionAfterText());
selection.reset(selection.getStartSelection());
@@ -1561,9 +1572,9 @@ public class GuiScriptTextArea extends GuiNpcTextField {
char lastChar = before.charAt(before.length() - 1);
char firstChar = content.charAt(0);
// Avoid adding space when punctuation/brackets are adjacent
- if (!Character.isWhitespace(lastChar) &&
+ if (!Character.isWhitespace(lastChar) &&
lastChar != '{' && lastChar != '(' && lastChar != '[' &&
- firstChar != '}' && firstChar != ')' && firstChar != ']' &&
+ firstChar != '}' && firstChar != ')' && firstChar != ']' &&
firstChar != ';' && firstChar != ',' && firstChar != '.' &&
firstChar != '\n') {
spacer = " ";
@@ -1584,14 +1595,14 @@ public class GuiScriptTextArea extends GuiNpcTextField {
if (selection.getStartSelection() > 0 && selection.getStartSelection() < text.length()) {
char prev = text.charAt(selection.getStartSelection() - 1);
char nextc = text.charAt(selection.getStartSelection());
- if ((prev == '(' && nextc == ')') ||
- (prev == '[' && nextc == ']') ||
- (prev == '{' && nextc == '}') ||
- (prev == '\'' && nextc == '\'') ||
+ if ((prev == '(' && nextc == ')') ||
+ (prev == '[' && nextc == ']') ||
+ (prev == '{' && nextc == '}') ||
+ (prev == '\'' && nextc == '\'') ||
(prev == '"' && nextc == '"')) {
String before = text.substring(0, selection.getStartSelection() - 1);
String after = selection.getStartSelection() + 1 < text.length() ? text.substring(
- selection.getStartSelection() + 1) : "";
+ selection.getStartSelection() + 1) : "";
setText(before + after);
selection.setStartSelection(selection.getStartSelection() - 1);
selection.reset(selection.getStartSelection());
@@ -1757,7 +1768,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// already immediately after the caret, move caret past it instead
// of inserting another closer. This prevents duplicate closers
// when the editor auto-inserts pairs.
- if ((c == ')' || c == ']' || c == '"' || c == '\'' ) && after.length() > 0 && after.charAt(0) == c) {
+ if ((c == ')' || c == ']' || c == '"' || c == '\'') && after.length() > 0 && after.charAt(0) == c) {
// Move caret forward by one (skip over existing closer)
selection.reset(before.length() + 1);
scrollToCursor();
@@ -1805,10 +1816,10 @@ public class GuiScriptTextArea extends GuiNpcTextField {
// ==================== COMMENT TOGGLING ====================
// Uses CommentHandler helper for comment operations
-
+
private void toggleCommentSelection() {
CommentHandler.SelectionToggleResult result = CommentHandler.toggleCommentSelection(
- text, container.lines, selection.getStartSelection(), selection.getEndSelection());
+ text, container.lines, selection.getStartSelection(), selection.getEndSelection());
setText(result.newText);
selection.setStartSelection(result.newStartSelection);
selection.setEndSelection(result.newEndSelection);
@@ -1816,15 +1827,15 @@ public class GuiScriptTextArea extends GuiNpcTextField {
private void toggleCommentLineAtCursor() {
CommentHandler.SingleLineToggleResult result = CommentHandler.toggleCommentAtCursor(
- text, container.lines, selection.getCursorPosition());
+ text, container.lines, selection.getCursorPosition());
setText(result.newText);
setCursor(result.newCursorPosition, false);
}
-
- public boolean closeOnEsc(){
- return !KEYS_OVERLAY.isVisible() && !searchBar.isVisible() && !goToLineDialog.isVisible() && !renameHandler.isActive();
+
+ public boolean closeOnEsc() {
+ return !KEYS_OVERLAY.isVisible() && !searchBar.isVisible() && !goToLineDialog.isVisible() && !renameHandler.isActive();
}
-
+
// ==================== KEYBOARD MODIFIERS ====================
private boolean isAltKeyDown() {
@@ -1872,7 +1883,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
return IndentHelper.getAutoIndentForEnter(currentLine.text, selection.getCursorPosition() - currentLine.start);
}
// ==================== TEXT FORMATTING ====================
-
+
private int getTabSize() {
return IndentHelper.TAB_SIZE;
}
@@ -1888,7 +1899,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
setText(result.text);
selection.reset(Math.max(0, Math.min(result.cursorPosition, this.text.length())));
}
-
+
// ==================== TAB HANDLING ====================
private void handleTab() {
@@ -1986,7 +1997,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
}
}
}
-
+
// ==================== CURSOR MANAGEMENT ====================
private void setCursor(int i, boolean select) {
@@ -2014,7 +2025,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
public String getSelectionAfterText() {
return selection.getTextAfter(text);
}
-
+
// ==================== MOUSE HANDLING ====================
public void mouseClicked(int xMouse, int yMouse, int mouseButton) {
@@ -2022,21 +2033,21 @@ public class GuiScriptTextArea extends GuiNpcTextField {
if (goToLineDialog.isVisible() && goToLineDialog.mouseClicked(xMouse, yMouse, mouseButton)) {
return;
}
-
+
// Check search bar clicks first
if (searchBar.isVisible() && searchBar.mouseClicked(xMouse, yMouse, mouseButton)) {
return;
}
-
+
// If search bar is visible but click was outside it, unfocus the search bar
if (searchBar.isVisible()) {
searchBar.unfocus();
}
-
+
// Let the overlay consume clicks (it returns true when it handled the event)
if (KEYS_OVERLAY.mouseClicked(xMouse, yMouse, mouseButton))
return;
-
+
// Determine whether click occurred inside the text area bounds
this.active = xMouse >= this.x && xMouse < this.x + this.width && yMouse >= this.y && yMouse < this.y + this.height;
if (this.active) {
@@ -2067,7 +2078,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
if (this.clicked && getPaddedLineCount() * this.container.lineHeight > this.height && xMouse > this.x + this.width - 8) {
// We consumed the mouse-down as a scrollbar drag start
this.clicked = false;
- scroll.startScrollbarDrag(yMouse,this.y,this.height, getPaddedLineCount());
+ scroll.startScrollbarDrag(yMouse, this.y, this.height, getPaddedLineCount());
} else {
// Handle double/triple click selection counting
if (time - this.lastClicked < 300L) {
@@ -2111,7 +2122,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
renameHandler.updateCursor();
++this.cursorCounter;
}
-
+
// ==================== TEXT MANAGEMENT ====================
public void setText(String text) {
@@ -2140,7 +2151,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
this.container.init(text, this.width, this.height);
- if (this.enableCodeHighlighting)
+ if (this.enableCodeHighlighting)
this.container.formatCodeText();
// Ensure scroll state stays in bounds after text change
@@ -2202,7 +2213,7 @@ public class GuiScriptTextArea extends GuiNpcTextField {
private void clampSelectionBounds() {
selection.clamp(text != null ? text.length() : 0);
}
-
+
// ==================== INNER CLASSES ====================
public static class UndoData {
diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScrollWindow.java b/src/main/java/noppes/npcs/client/gui/util/GuiScrollWindow.java
index 59afbea09..3273f1f6c 100644
--- a/src/main/java/noppes/npcs/client/gui/util/GuiScrollWindow.java
+++ b/src/main/java/noppes/npcs/client/gui/util/GuiScrollWindow.java
@@ -143,6 +143,7 @@ public class GuiScrollWindow extends GuiScreen implements ITextfieldListener, IC
}
}
}
+
public void mouseEvent(int i, int j, int k) {
}
@@ -208,6 +209,7 @@ public class GuiScrollWindow extends GuiScreen implements ITextfieldListener, IC
}
public int backgroundColor = 0x66000000;
+
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
scrollY = (float) lerp(scrollY, nextScrollY, partialTicks);
diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiUtil.java b/src/main/java/noppes/npcs/client/gui/util/GuiUtil.java
index 9a9fc71ca..7350668b8 100644
--- a/src/main/java/noppes/npcs/client/gui/util/GuiUtil.java
+++ b/src/main/java/noppes/npcs/client/gui/util/GuiUtil.java
@@ -112,7 +112,7 @@ public class GuiUtil {
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
-
+
public static void drawGradientRectHorizontal(int left, int top, int right, int bottom, int startColor, int endColor) {
double zLevel = 0;
diff --git a/src/main/java/noppes/npcs/client/gui/util/IAbilityConfigCallback.java b/src/main/java/noppes/npcs/client/gui/util/IAbilityConfigCallback.java
index ec186d066..4012c9f73 100644
--- a/src/main/java/noppes/npcs/client/gui/util/IAbilityConfigCallback.java
+++ b/src/main/java/noppes/npcs/client/gui/util/IAbilityConfigCallback.java
@@ -9,6 +9,7 @@ import kamkeel.npcs.controllers.data.ability.Ability;
public interface IAbilityConfigCallback {
/**
* Called when an ability has been edited and saved.
+ *
* @param ability The edited ability
*/
void onAbilitySaved(Ability ability);
diff --git a/src/main/java/noppes/npcs/client/gui/util/key/OverlayKeyPresetViewer.java b/src/main/java/noppes/npcs/client/gui/util/key/OverlayKeyPresetViewer.java
index e8fefd475..7ebc098be 100644
--- a/src/main/java/noppes/npcs/client/gui/util/key/OverlayKeyPresetViewer.java
+++ b/src/main/java/noppes/npcs/client/gui/util/key/OverlayKeyPresetViewer.java
@@ -79,7 +79,7 @@ public class OverlayKeyPresetViewer {
public void drawOverlay(int wheel) {
scroll.update(wheel);
-
+
if (hasBorder) {
// int borderCol2 = 0xffff00ff,borderCol2 = 0xff00ffff; NEON
@@ -133,7 +133,7 @@ public class OverlayKeyPresetViewer {
showOverlay = false;
return true;
}
-
+
// If overlay is visible but no element consumed the key, consider it handled
return true;
}
@@ -155,7 +155,7 @@ public class OverlayKeyPresetViewer {
// If overlay is not visible, no other clicks matter
if (!showOverlay)
return false;
-
+
boolean isAboveOverlay = isMouseAbove(mouseX, mouseY);
// In click-to-open mode, clicking outside the overlay (and not the button) should close it
if (openOnClick && !isAboveOverlay && !isAboveButton) {
@@ -259,7 +259,7 @@ public class OverlayKeyPresetViewer {
public void drawBar() {
GL11.glPushMatrix();
GL11.glTranslatef(endX - barWidth - 2, startY + yStartSpacing + scrollY * scrollFactor, 1);
- GuiUtil.drawRectD(0, 1, barWidth, scrollbarHeight-1, (isMouseAboveBar(mouseX, mouseY) || isMouseDragging) ? 0xffbababa : 0xff767676);
+ GuiUtil.drawRectD(0, 1, barWidth, scrollbarHeight - 1, (isMouseAboveBar(mouseX, mouseY) || isMouseDragging) ? 0xffbababa : 0xff767676);
GL11.glPopMatrix();
}
@@ -480,7 +480,7 @@ public class OverlayKeyPresetViewer {
int oldMinFilter = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glDisable(GL11.GL_BLEND);
-
+
GL11.glPushMatrix();
float color = aboveButton ? 1f : 0.4f;
GL11.glColor4f(color, color, color, 1);
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/BracketMatcher.java b/src/main/java/noppes/npcs/client/gui/util/script/BracketMatcher.java
index 96fe2a7ba..b7b9ab63a 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/BracketMatcher.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/BracketMatcher.java
@@ -1,6 +1,7 @@
package noppes.npcs.client.gui.util.script;
import noppes.npcs.client.gui.util.script.JavaTextContainer.LineData;
+
import java.util.ArrayList;
import java.util.List;
@@ -8,14 +9,15 @@ import java.util.List;
* Handles bracket matching, brace span computation, and indent guide generation.
*/
public class BracketMatcher {
-
+
/**
* Find matching bracket at cursor position.
+ *
* @return int[2] with {startPos, endPos} or null if no bracket found
*/
public static int[] findBracketSpanAt(String text, int pos) {
if (text == null || text.isEmpty()) return null;
-
+
// Try at current position
if (pos >= 0 && pos < text.length()) {
char c = text.charAt(pos);
@@ -34,7 +36,10 @@ public class BracketMatcher {
int scan = pos - 1;
while (scan >= 0) {
char sc = text.charAt(scan);
- if (sc == ' ' || sc == '\t') { scan--; continue; }
+ if (sc == ' ' || sc == '\t') {
+ scan--;
+ continue;
+ }
if (sc == '\n') break; // Don't cross line boundary
int found2 = 0;
@@ -73,25 +78,43 @@ public class BracketMatcher {
char next = pos + 1 < text.length() ? text.charAt(pos + 1) : 0;
if (inString) {
- if (escape) { escape = false; }
- else if (c == '\\') { escape = true; }
- else if (c == stringDelimiter) { inString = false; }
- else if (c == '\n') { inString = false; }
+ if (escape) {
+ escape = false;
+ } else if (c == '\\') {
+ escape = true;
+ } else if (c == stringDelimiter) {
+ inString = false;
+ } else if (c == '\n') {
+ inString = false;
+ }
continue;
}
if (inBlockComment) {
- if (c == '*' && next == '/') { inBlockComment = false; pos++; }
+ if (c == '*' && next == '/') {
+ inBlockComment = false;
+ pos++;
+ }
continue;
}
if (inLineComment) {
- if (c == '\n') { inLineComment = false; }
+ if (c == '\n') {
+ inLineComment = false;
+ }
continue;
}
- if (c == '/' && next == '/') { inLineComment = true; pos++; continue; }
- if (c == '/' && next == '*') { inBlockComment = true; pos++; continue; }
+ if (c == '/' && next == '/') {
+ inLineComment = true;
+ pos++;
+ continue;
+ }
+ if (c == '/' && next == '*') {
+ inBlockComment = true;
+ pos++;
+ continue;
+ }
if (c == '"' || c == '\'') {
inString = true;
@@ -193,29 +216,47 @@ public class BracketMatcher {
// String handling
if (inString) {
- if (escape) { escape = false; }
- else if (c == '\\') { escape = true; }
- else if (c == stringDelimiter) { inString = false; }
- else if (c == '\n') { inString = false; } // Unterminated string
+ if (escape) {
+ escape = false;
+ } else if (c == '\\') {
+ escape = true;
+ } else if (c == stringDelimiter) {
+ inString = false;
+ } else if (c == '\n') {
+ inString = false;
+ } // Unterminated string
continue;
}
// Block comment handling
if (inBlockComment) {
- if (c == '*' && next == '/') { inBlockComment = false; pos++; }
+ if (c == '*' && next == '/') {
+ inBlockComment = false;
+ pos++;
+ }
continue;
}
// Line comment handling
if (inLineComment) {
- if (c == '\n') { inLineComment = false; }
+ if (c == '\n') {
+ inLineComment = false;
+ }
continue;
}
// Start of comments
- if (c == '/' && next == '/') { inLineComment = true; pos++; continue; }
- if (c == '/' && next == '*') { inBlockComment = true; pos++; continue; }
-
+ if (c == '/' && next == '/') {
+ inLineComment = true;
+ pos++;
+ continue;
+ }
+ if (c == '/' && next == '*') {
+ inBlockComment = true;
+ pos++;
+ continue;
+ }
+
// Start of string
if (c == '"' || c == '\'') {
inString = true;
@@ -256,11 +297,12 @@ public class BracketMatcher {
/**
* Find which brace span should be highlighted based on bracket at position
+ *
* @return int[2] {openLine, closeLine} or null
*/
public static int[] findHighlightedSpan(int bracketPos, List lines, List spans) {
if (bracketPos < 0 || lines == null || spans == null) return null;
-
+
// Find line containing bracket
int bracketLineIdx = -1;
for (int i = 0; i < lines.size(); i++) {
@@ -270,7 +312,7 @@ public class BracketMatcher {
break;
}
}
-
+
if (bracketLineIdx >= 0) {
for (int[] span : spans) {
int openLine = span[1];
@@ -282,13 +324,13 @@ public class BracketMatcher {
}
return null;
}
-
+
/**
* Check if a brace at given position has a matching close with same indent
*/
public static boolean hasMatchingCloseWithSameIndent(String text, int bracePos, List lines, int currentIndent) {
if (text == null || lines == null || bracePos < 0) return false;
-
+
// Find line containing the brace
int openLineIdx = -1;
for (int i = 0; i < lines.size(); i++) {
@@ -298,9 +340,9 @@ public class BracketMatcher {
break;
}
}
-
+
if (openLineIdx < 0) return false;
-
+
List spans = computeBraceSpans(text, lines);
for (int[] span : spans) {
if (span[1] == openLineIdx) {
@@ -314,7 +356,7 @@ public class BracketMatcher {
}
return false;
}
-
+
/**
* Get leading whitespace count of a line
*/
@@ -327,4 +369,4 @@ public class BracketMatcher {
}
return indent;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/ClassPathFinder.java b/src/main/java/noppes/npcs/client/gui/util/script/ClassPathFinder.java
index e54f5d878..844da165b 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/ClassPathFinder.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/ClassPathFinder.java
@@ -1,6 +1,13 @@
package noppes.npcs.client.gui.util.script;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* Helper class for resolving Java classpath imports and determining class types.
@@ -21,14 +28,14 @@ public class ClassPathFinder {
// Common java.lang classes (auto-imported in Java)
public static final Set JAVA_LANG_CLASSES = new HashSet<>(Arrays.asList(
- "Object", "String", "Class", "System", "Math", "Integer", "Double", "Float", "Long", "Short", "Byte",
- "Character", "Boolean", "Number", "Void", "Thread", "Runnable", "Exception", "RuntimeException",
- "Error", "Throwable", "StringBuilder", "StringBuffer", "Enum", "Comparable", "Iterable",
- "CharSequence", "Cloneable", "Process", "ProcessBuilder", "Runtime", "SecurityManager",
- "ClassLoader", "Package", "ArithmeticException", "ArrayIndexOutOfBoundsException",
- "ClassCastException", "IllegalArgumentException", "IllegalStateException",
- "IndexOutOfBoundsException", "NullPointerException", "NumberFormatException",
- "UnsupportedOperationException", "AssertionError", "OutOfMemoryError", "StackOverflowError"
+ "Object", "String", "Class", "System", "Math", "Integer", "Double", "Float", "Long", "Short", "Byte",
+ "Character", "Boolean", "Number", "Void", "Thread", "Runnable", "Exception", "RuntimeException",
+ "Error", "Throwable", "StringBuilder", "StringBuffer", "Enum", "Comparable", "Iterable",
+ "CharSequence", "Cloneable", "Process", "ProcessBuilder", "Runtime", "SecurityManager",
+ "ClassLoader", "Package", "ArithmeticException", "ArrayIndexOutOfBoundsException",
+ "ClassCastException", "IllegalArgumentException", "IllegalStateException",
+ "IndexOutOfBoundsException", "NullPointerException", "NumberFormatException",
+ "UnsupportedOperationException", "AssertionError", "OutOfMemoryError", "StackOverflowError"
));
/**
@@ -193,10 +200,10 @@ public class ClassPathFinder {
// Full resolution successful
List classSegments = buildClassSegments(segments, classStartIdx, n);
- return ResolveResult.found(
- new ClassInfo(info.resolvedName, info.type, packagePortion.length()),
- packagePortion, validClassPortion, classSegments, classStartIdx
- );
+ return ResolveResult.found(
+ new ClassInfo(info.resolvedName, info.type, packagePortion.length()),
+ packagePortion, validClassPortion, classSegments, classStartIdx
+ );
}
}
}
@@ -243,7 +250,7 @@ public class ClassPathFinder {
// Build the typed package path segment by segment and compare with cache
StringBuilder sb = new StringBuilder();
int lastValidIndex = -1;
-
+
for (int i = 0; i < classStartIdx; i++) {
if (i > 0) sb.append(".");
sb.append(segments[i]);
@@ -272,7 +279,7 @@ public class ClassPathFinder {
}
}
}
-
+
// If we found some valid prefix but not all, return where it stopped being valid
if (lastValidIndex > 0 && lastValidIndex < classStartIdx) {
// Check if segment at lastValidIndex diverges from any known path
@@ -282,15 +289,15 @@ public class ClassPathFinder {
// There's a known continuation - check if typed segment matches
String nextTyped = segments[lastValidIndex];
String cachedRemainder = cached.substring(validPrefix.length() + 1);
- String nextCached = cachedRemainder.contains(".") ?
- cachedRemainder.substring(0, cachedRemainder.indexOf('.')) : cachedRemainder;
+ String nextCached = cachedRemainder.contains(".") ?
+ cachedRemainder.substring(0, cachedRemainder.indexOf('.')) : cachedRemainder;
if (!nextTyped.equals(nextCached)) {
return lastValidIndex; // Divergence point
}
}
}
}
-
+
return -1; // No typo detected
}
@@ -312,7 +319,7 @@ public class ClassPathFinder {
registerValidPackage(packagePath);
return true;
}
-
+
// Fallback: try to find any class under this package to validate it
String[] testClasses = getTestClassesForPackage(packagePath);
for (String testClass : testClasses) {
@@ -580,7 +587,7 @@ public class ClassPathFinder {
default:
// For unknown packages, try common class suffixes
return new String[]{
- packagePath + ".package-info", // Won't work but harmless
+ packagePath + ".package-info", // Won't work but harmless
};
}
}
@@ -591,7 +598,7 @@ public class ClassPathFinder {
* Parse generic type content and return type names with their positions.
* Handles arbitrary nesting depth like "Map>>"
*
- * @param genericContent The content inside <...> (without the outer angle brackets)
+ * @param genericContent The content inside <...> (without the outer angle brackets)
* @param importedClasses Map of simple name -> full class name for resolution
* @return List of TypeOccurrence with position and type info
*/
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/CommentHandler.java b/src/main/java/noppes/npcs/client/gui/util/script/CommentHandler.java
index b5c0f2205..ed586e304 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/CommentHandler.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/CommentHandler.java
@@ -1,6 +1,7 @@
package noppes.npcs.client.gui.util.script;
import noppes.npcs.client.gui.util.script.JavaTextContainer.LineData;
+
import java.util.List;
/**
@@ -15,18 +16,18 @@ public class CommentHandler {
public final String text;
public final int delta; // Change in length (negative if comment removed)
public final int nonWsIndex; // Index of first non-whitespace character
-
+
public ToggleResult(String text, int delta, int nonWsIndex) {
this.text = text;
this.delta = delta;
this.nonWsIndex = nonWsIndex;
}
-
+
public boolean wasCommented() {
return delta < 0;
}
}
-
+
/**
* Toggle line comment on a single line
*/
@@ -36,11 +37,11 @@ public class CommentHandler {
while (nonWs < lineText.length() && Character.isWhitespace(lineText.charAt(nonWs))) {
nonWs++;
}
-
+
boolean hasContent = nonWs < lineText.length();
boolean hasComment = hasContent && lineText.startsWith("//", nonWs);
String newText;
-
+
if (hasComment) {
// Remove comment
int cut = Math.min(nonWs + 2, lineText.length());
@@ -52,10 +53,10 @@ public class CommentHandler {
// Empty/whitespace line - no change
newText = lineText;
}
-
+
return new ToggleResult(newText, newText.length() - lineText.length(), nonWs);
}
-
+
/**
* Result of toggling comments on a selection
*/
@@ -63,33 +64,33 @@ public class CommentHandler {
public final String newText;
public final int newStartSelection;
public final int newEndSelection;
-
+
public SelectionToggleResult(String text, int start, int end) {
this.newText = text;
this.newStartSelection = start;
this.newEndSelection = end;
}
}
-
+
/**
* Toggle comments on all lines in a selection
*/
public static SelectionToggleResult toggleCommentSelection(
- String text,
- List lines,
- int startSelection,
- int endSelection) {
-
+ String text,
+ List lines,
+ int startSelection,
+ int endSelection) {
+
StringBuilder newText = new StringBuilder(text.length() + 100);
int prevEnd = 0;
int newStart = -1;
int newEnd = -1;
int newIndex = 0;
-
+
for (LineData line : lines) {
int safeLineStart = Math.max(0, Math.min(line.start, text.length()));
int safeLineEnd = Math.max(0, Math.min(line.end, text.length()));
-
+
// Handle gap between lines (shouldn't happen normally)
if (safeLineStart > prevEnd) {
if (newStart == -1 && startSelection >= prevEnd && startSelection <= safeLineStart) {
@@ -101,7 +102,7 @@ public class CommentHandler {
newText.append(text, prevEnd, safeLineStart);
newIndex += safeLineStart - prevEnd;
}
-
+
// Check if this line is in selection
if (safeLineEnd > startSelection && safeLineStart < endSelection) {
String lineText = text.substring(safeLineStart, safeLineEnd);
@@ -109,7 +110,7 @@ public class CommentHandler {
String newLineText = tr.text;
int nonWs = tr.nonWsIndex;
int delta = tr.delta;
-
+
// Update start selection position
if (newStart == -1 && startSelection >= safeLineStart && startSelection <= safeLineEnd) {
int offsetInOld = startSelection - safeLineStart;
@@ -119,7 +120,7 @@ public class CommentHandler {
}
newStart = newIndex + Math.max(0, newOffset);
}
-
+
// Update end selection position
if (newEnd == -1 && endSelection >= safeLineStart && endSelection <= safeLineEnd) {
int offsetInOld = endSelection - safeLineStart;
@@ -129,7 +130,7 @@ public class CommentHandler {
}
newEnd = newIndex + Math.max(0, newOffset);
}
-
+
newText.append(newLineText);
newIndex += newLineText.length();
} else {
@@ -145,7 +146,7 @@ public class CommentHandler {
}
prevEnd = safeLineEnd;
}
-
+
// Handle remaining text after last line
if (prevEnd < text.length()) {
if (newStart == -1 && startSelection >= prevEnd && startSelection <= text.length()) {
@@ -157,35 +158,35 @@ public class CommentHandler {
newText.append(text, prevEnd, text.length());
newIndex += text.length() - prevEnd;
}
-
+
// Fallback for positions not found
if (newStart == -1) newStart = Math.max(0, Math.min(startSelection, newText.length()));
if (newEnd == -1) newEnd = Math.max(0, Math.min(endSelection, newText.length()));
-
+
return new SelectionToggleResult(newText.toString(), newStart, newEnd);
}
-
+
/**
* Toggle comment on a single line at cursor position
*/
public static SingleLineToggleResult toggleCommentAtCursor(
- String text,
- List lines,
- int cursorPosition) {
-
+ String text,
+ List lines,
+ int cursorPosition) {
+
for (LineData line : lines) {
int lineStart = Math.max(0, Math.min(line.start, text.length()));
int lineEnd = Math.max(0, Math.min(line.end, text.length()));
-
+
if (cursorPosition >= lineStart && cursorPosition <= lineEnd) {
String lineText = text.substring(lineStart, lineEnd);
ToggleResult tr = toggleLine(lineText);
boolean hadComment = tr.delta < 0;
-
+
String before = text.substring(0, lineStart);
String after = lineEnd <= text.length() ? text.substring(lineEnd) : "";
String newText = before + tr.text + after;
-
+
// Calculate new cursor position
int cursorDelta = hadComment ? -2 : 2;
int newCursor = cursorPosition + cursorDelta;
@@ -193,25 +194,25 @@ public class CommentHandler {
newCursor = cursorPosition;
}
newCursor = Math.max(lineStart, newCursor);
-
+
return new SingleLineToggleResult(newText, newCursor);
}
}
-
+
// No line found at cursor - return unchanged
return new SingleLineToggleResult(text, cursorPosition);
}
-
+
/**
* Result of toggling comment on single line
*/
public static class SingleLineToggleResult {
public final String newText;
public final int newCursorPosition;
-
+
public SingleLineToggleResult(String text, int cursor) {
this.newText = text;
this.newCursorPosition = cursor;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/CursorNavigation.java b/src/main/java/noppes/npcs/client/gui/util/script/CursorNavigation.java
index 2a39d5bbb..52faebe0c 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/CursorNavigation.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/CursorNavigation.java
@@ -1,6 +1,7 @@
package noppes.npcs.client.gui.util.script;
import noppes.npcs.client.gui.util.script.JavaTextContainer.LineData;
+
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -9,25 +10,25 @@ import java.util.regex.Pattern;
* Handles cursor navigation logic (up, down, left, right, word movement).
*/
public class CursorNavigation {
-
+
/**
* Move cursor up one line, maintaining column position
*/
public static int cursorUp(int cursorPosition, List lines, String text) {
if (lines == null || lines.isEmpty()) return 0;
-
+
for (int i = 0; i < lines.size(); i++) {
LineData data = lines.get(i);
boolean isLastLine = (i == lines.size() - 1);
- boolean isOnLine = isLastLine
- ? (cursorPosition >= data.start && cursorPosition <= data.end)
- : (cursorPosition >= data.start && cursorPosition < data.end);
-
+ boolean isOnLine = isLastLine
+ ? (cursorPosition >= data.start && cursorPosition <= data.end)
+ : (cursorPosition >= data.start && cursorPosition < data.end);
+
if (isOnLine) {
if (i == 0) {
return 0; // Already on first line
}
-
+
int column = Math.min(cursorPosition - data.start, data.text.length());
LineData target = lines.get(i - 1);
int targetColumn = Math.min(column, target.text.length());
@@ -39,26 +40,26 @@ public class CursorNavigation {
}
return 0;
}
-
+
/**
* Move cursor down one line, maintaining column position
*/
public static int cursorDown(int cursorPosition, List lines, String text) {
if (lines == null || lines.isEmpty()) return text != null ? text.length() : 0;
if (text != null && cursorPosition == text.length()) return cursorPosition;
-
+
for (int i = 0; i < lines.size(); i++) {
LineData data = lines.get(i);
boolean isLastLine = (i == lines.size() - 1);
- boolean isOnLine = isLastLine
- ? (cursorPosition >= data.start && cursorPosition <= data.end)
- : (cursorPosition >= data.start && cursorPosition < data.end);
-
+ boolean isOnLine = isLastLine
+ ? (cursorPosition >= data.start && cursorPosition <= data.end)
+ : (cursorPosition >= data.start && cursorPosition < data.end);
+
if (isOnLine) {
if (i >= lines.size() - 1) {
return cursorPosition; // Already on last line
}
-
+
int column = Math.min(cursorPosition - data.start, data.text.length());
LineData target = lines.get(i + 1);
int targetColumn = Math.min(column, target.text.length());
@@ -70,13 +71,13 @@ public class CursorNavigation {
}
return text != null ? text.length() : 0;
}
-
+
/**
* Move cursor left, optionally by word
*/
public static int cursorLeft(int cursorPosition, String text, Pattern wordPattern, boolean byWord) {
if (text == null || cursorPosition <= 0) return 0;
-
+
int moveAmount = 1;
if (byWord && wordPattern != null) {
Matcher m = wordPattern.matcher(text.substring(0, cursorPosition));
@@ -88,7 +89,7 @@ public class CursorNavigation {
}
return Math.max(cursorPosition - moveAmount, 0);
}
-
+
/**
* Move cursor right, optionally by word
*/
@@ -96,7 +97,7 @@ public class CursorNavigation {
if (text == null) return 0;
int textLen = text.length();
if (cursorPosition >= textLen) return textLen;
-
+
int moveAmount = 1;
if (byWord && wordPattern != null) {
Matcher m = wordPattern.matcher(text.substring(cursorPosition));
@@ -108,45 +109,45 @@ public class CursorNavigation {
}
return Math.min(cursorPosition + moveAmount, textLen);
}
-
+
/**
* Get cursor position from mouse click coordinates
*/
public static int getPositionFromMouse(
- int mouseX, int mouseY,
- int areaX, int areaY,
- int gutterWidth,
- int lineHeight,
- int scrolledLine,
- double scrollFracOffset,
- List lines,
- String text,
- FontWidthProvider fontWidth) {
-
+ int mouseX, int mouseY,
+ int areaX, int areaY,
+ int gutterWidth,
+ int lineHeight,
+ int scrolledLine,
+ double scrollFracOffset,
+ List lines,
+ String text,
+ FontWidthProvider fontWidth) {
+
int xMouse = mouseX - (areaX + gutterWidth + 1);
int yMouse = mouseY - areaY - 1;
-
+
// Account for fractional scroll offset
double fracPixels = scrollFracOffset * lineHeight;
yMouse = (int) Math.round(yMouse + fracPixels);
-
+
if (lines == null || lines.isEmpty()) {
return text != null ? text.length() : 0;
}
-
+
int visibleLines = Math.min(lines.size(), scrolledLine + 50); // Reasonable limit
-
+
for (int i = 0; i < lines.size(); i++) {
LineData data = lines.get(i);
-
+
if (i >= scrolledLine && i <= visibleLines) {
int yPos = (i - scrolledLine) * lineHeight;
-
+
if (yMouse >= yPos && yMouse < yPos + lineHeight) {
// Found the line, now find character position
int lineWidth = 0;
char[] chars = data.text.toCharArray();
-
+
for (int j = 1; j <= chars.length; j++) {
int w = fontWidth.getWidth(data.text.substring(0, j));
if (xMouse < lineWidth + (w - lineWidth) / 2) {
@@ -154,24 +155,24 @@ public class CursorNavigation {
}
lineWidth = w;
}
-
+
// Click past end of line - place cursor at end of text (not on newline)
int posAfterChars = data.start + chars.length;
return Math.min(posAfterChars, text.length());
}
}
}
-
+
return text != null ? text.length() : 0;
}
-
+
/**
* Interface for font width measurement
*/
public interface FontWidthProvider {
int getWidth(String text);
}
-
+
/**
* Get leading whitespace count of a line
*/
@@ -184,26 +185,26 @@ public class CursorNavigation {
}
return indent;
}
-
+
/**
* Find line index containing given position
*/
public static int findLineIndex(int position, List lines) {
if (lines == null || lines.isEmpty()) return 0;
-
+
for (int i = 0; i < lines.size(); i++) {
LineData line = lines.get(i);
boolean isLastLine = (i == lines.size() - 1);
- boolean isOnLine = isLastLine
- ? (position >= line.start && position <= line.end)
- : (position >= line.start && position < line.end);
+ boolean isOnLine = isLastLine
+ ? (position >= line.start && position <= line.end)
+ : (position >= line.start && position < line.end);
if (isOnLine) {
return i;
}
}
return lines.size() - 1;
}
-
+
/**
* Find line data containing given position
*/
@@ -214,4 +215,4 @@ public class CursorNavigation {
}
return null;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/FormatHelper.java b/src/main/java/noppes/npcs/client/gui/util/script/FormatHelper.java
index 5c534cc94..a1eedce0b 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/FormatHelper.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/FormatHelper.java
@@ -6,7 +6,7 @@ import java.util.regex.Pattern;
/**
* Configurable code formatter with IntelliJ-like settings.
- *
+ *
* Features:
* - Operator spacing (a+b → a + b)
* - Whitespace normalization (a b → a b)
@@ -15,9 +15,9 @@ import java.util.regex.Pattern;
* - Preserves string content and comments
*/
public class FormatHelper {
-
+
// ==================== SETTINGS ====================
-
+
/**
* Formatting configuration - similar to IntelliJ Code Style settings
*/
@@ -28,12 +28,12 @@ public class FormatHelper {
public boolean spaceAroundComparison = true; // a == b, a != b, a <= b
public boolean spaceAroundLogical = true; // a && b || c
public boolean spaceAroundBitwise = true; // a & b | c ^ d
-
+
// Spaces within brackets
public boolean spaceWithinParens = false; // (a) vs ( a )
public boolean spaceWithinBrackets = false; // [a] vs [ a ]
public boolean spaceWithinBraces = true; // {a} vs { a } (for initializers)
-
+
// Spaces before/after
public boolean spaceAfterComma = true; // a, b vs a,b
public boolean spaceBeforeComma = false; // a, b vs a , b
@@ -41,48 +41,48 @@ public class FormatHelper {
public boolean spaceBeforeSemicolon = false;
public boolean spaceAfterColon = true; // case a: b vs case a:b
public boolean spaceBeforeColon = false;
-
+
// Method calls
public boolean spaceBeforeMethodParens = false; // foo() vs foo ()
public boolean spaceAfterTypeCast = true; // (int) x vs (int)x
-
+
// Control statements
public boolean spaceBeforeIfParens = true; // if (...) vs if(...)
public boolean spaceBeforeWhileParens = true;
public boolean spaceBeforeForParens = true;
public boolean spaceBeforeSwitchParens = true;
public boolean spaceBeforeCatchParens = true;
-
+
// Braces
public boolean spaceBeforeOpenBrace = true; // if () { vs if (){
-
+
// Line length
public int maxLineLength = 120;
public boolean wrapLongLines = false; // Auto-wrap lines longer than maxLineLength
public int wrapIndentSpaces = 4; // Extra indent for wrapped lines
public boolean wrapComments = true; // Also wrap long comments
-
+
// Wrap break preferences (where to break long lines)
public boolean wrapAfterComma = true; // Prefer breaking after commas
public boolean wrapAfterOperator = true; // Prefer breaking after operators
public boolean wrapBeforeDot = true; // Break before . for chained calls
public boolean wrapMethodArguments = true; // Each arg on new line when wrapping method calls
-
+
// Whitespace normalization
public boolean normalizeWhitespace = true; // Multiple spaces → single space
public boolean trimTrailingWhitespace = true;
-
+
// Unary operators
public boolean spaceAroundUnaryNot = false; // !a vs ! a
public boolean spaceAroundUnaryIncDec = false; // ++i vs ++ i
-
+
/**
* Create default settings (similar to IntelliJ defaults)
*/
public static FormatSettings defaults() {
return new FormatSettings();
}
-
+
/**
* Create compact settings (minimal spacing)
*/
@@ -95,53 +95,53 @@ public class FormatHelper {
return s;
}
}
-
+
private FormatSettings settings;
-
+
public FormatHelper() {
this.settings = FormatSettings.defaults();
}
-
+
public FormatHelper(FormatSettings settings) {
this.settings = settings != null ? settings : FormatSettings.defaults();
}
-
+
public void setSettings(FormatSettings settings) {
this.settings = settings;
}
-
+
public FormatSettings getSettings() {
return settings;
}
-
+
// ==================== MAIN FORMAT METHOD ====================
-
+
/**
* Format the entire text with all configured options
*/
public String format(String text) {
if (text == null || text.isEmpty()) return text;
-
+
// Process line by line to preserve structure
String[] lines = text.split("\n", -1);
StringBuilder result = new StringBuilder();
-
+
for (int i = 0; i < lines.length; i++) {
String line = formatLine(lines[i], text, getLineStartOffset(lines, i));
-
+
if (settings.trimTrailingWhitespace) {
line = trimTrailing(line);
}
-
+
result.append(line);
if (i < lines.length - 1) {
result.append("\n");
}
}
-
+
return result.toString();
}
-
+
/**
* Split multiple statements on one line into separate lines with proper indentation.
* E.g., " this.a = 1; this.b = 2;" becomes two lines
@@ -150,10 +150,10 @@ public class FormatHelper {
private String splitStatementsOntoSeparateLines(String text) {
String[] lines = text.split("\n", -1);
StringBuilder result = new StringBuilder();
-
+
for (int lineIdx = 0; lineIdx < lines.length; lineIdx++) {
String line = lines[lineIdx];
-
+
// Skip empty lines or comment-only lines
String trimmed = line.trim();
if (trimmed.isEmpty() || trimmed.startsWith("//") || trimmed.startsWith("/*") || trimmed.startsWith("*")) {
@@ -161,7 +161,7 @@ public class FormatHelper {
if (lineIdx < lines.length - 1) result.append("\n");
continue;
}
-
+
// Extract leading indentation
int indent = 0;
while (indent < line.length() && (line.charAt(indent) == ' ' || line.charAt(indent) == '\t')) {
@@ -169,14 +169,14 @@ public class FormatHelper {
}
String indentation = line.substring(0, indent);
String content = line.substring(indent);
-
+
// Split by semicolons (but preserve those in strings, for loops, etc.)
List statements = splitBySemicolons(content);
-
+
for (int si = 0; si < statements.size(); si++) {
String stmt = statements.get(si).trim();
if (stmt.isEmpty()) continue;
-
+
// Check if statement opens a scope { and has code after it
int braceIdx = stmt.indexOf('{');
if (braceIdx >= 0 && braceIdx < stmt.length() - 1) {
@@ -191,20 +191,20 @@ public class FormatHelper {
continue;
}
}
-
+
result.append(indentation).append(stmt);
// Add semicolon back if it was removed
if (si < statements.size() - 1) {
result.append("\n");
}
}
-
+
if (lineIdx < lines.length - 1) result.append("\n");
}
-
+
return result.toString();
}
-
+
/**
* Split content by semicolons, preserving those in strings and for-loops
*/
@@ -216,25 +216,25 @@ public class FormatHelper {
boolean inChar = false;
boolean escaped = false;
int forLoopDepth = 0; // Track for(...) depth to preserve semicolons
-
+
for (int i = 0; i < content.length(); i++) {
char c = content.charAt(i);
char prev = i > 0 ? content.charAt(i - 1) : ' ';
-
+
// Track strings
if (c == '\"' && !escaped && !inChar) {
inString = !inString;
} else if (c == '\'' && !escaped && !inString) {
inChar = !inChar;
}
-
+
escaped = (c == '\\' && !escaped);
-
+
if (inString || inChar) {
current.append(c);
continue;
}
-
+
// Track for loops
if (c == '(' && i >= 3 && content.substring(Math.max(0, i - 3), i + 1).matches(".*\\bfor\\s*\\(")) {
forLoopDepth++;
@@ -247,7 +247,7 @@ public class FormatHelper {
forLoopDepth = 0;
}
}
-
+
// Semicolon: split if not in for-loop header
if (c == ';' && forLoopDepth == 0) {
current.append(c);
@@ -255,18 +255,18 @@ public class FormatHelper {
current = new StringBuilder();
continue;
}
-
+
current.append(c);
}
-
+
// Add remaining content
if (current.length() > 0) {
statements.add(current.toString());
}
-
+
return statements;
}
-
+
private int getLineStartOffset(String[] lines, int lineIndex) {
int offset = 0;
for (int i = 0; i < lineIndex; i++) {
@@ -274,13 +274,13 @@ public class FormatHelper {
}
return offset;
}
-
+
/**
* Format a single line of code
*/
private String formatLine(String line, String fullText, int lineOffset) {
if (line.trim().isEmpty()) return line;
-
+
// Preserve leading indentation
int indent = 0;
while (indent < line.length() && (line.charAt(indent) == ' ' || line.charAt(indent) == '\t')) {
@@ -288,27 +288,27 @@ public class FormatHelper {
}
String indentation = line.substring(0, indent);
String content = line.substring(indent);
-
+
if (content.isEmpty()) return line;
-
+
// Skip formatting for lines that are entirely comments
String trimmed = content.trim();
if (trimmed.startsWith("//") || trimmed.startsWith("*") || trimmed.startsWith("/*")) {
return line;
}
-
+
// Skip formatting for continuation lines (lines that start with operators, dots, etc.)
// These are wrapped lines from a previous format and should be preserved as-is
if (isContinuationLine(trimmed)) {
return line;
}
-
+
// Format the content
String formatted = formatContent(content, fullText, lineOffset + indent);
-
+
return indentation + formatted;
}
-
+
/**
* Check if a line appears to be a continuation of a previous line
* (i.e., starts with an operator, dot, or other continuation character)
@@ -317,7 +317,7 @@ public class FormatHelper {
if (trimmedContent.isEmpty()) return false;
char firstChar = trimmedContent.charAt(0);
// Lines starting with these are likely continuations
- if (firstChar == '.' || firstChar == '+' || firstChar == '-' ||
+ if (firstChar == '.' || firstChar == '+' || firstChar == '-' ||
firstChar == '*' || firstChar == '/' || firstChar == '%' ||
firstChar == '&' || firstChar == '|' || firstChar == '^' ||
firstChar == '?' || firstChar == ':' || firstChar == ',') {
@@ -329,53 +329,53 @@ public class FormatHelper {
}
return false;
}
-
+
/**
* Format line content, preserving strings and comments
*/
private String formatContent(String content, String fullText, int offset) {
// Find string/comment regions to preserve
List preserveRegions = findPreserveRegions(content);
-
+
if (preserveRegions.isEmpty()) {
// No strings/comments, format everything
return formatCodeSegment(content);
}
-
+
// Build result by formatting non-preserved regions
StringBuilder result = new StringBuilder();
int lastEnd = 0;
-
+
for (int[] region : preserveRegions) {
// Format code before this preserved region
if (region[0] > lastEnd) {
String codeSegment = content.substring(lastEnd, region[0]);
result.append(formatCodeSegment(codeSegment));
}
-
+
// Append preserved region unchanged
result.append(content.substring(region[0], region[1]));
lastEnd = region[1];
}
-
+
// Format remaining code after last preserved region
if (lastEnd < content.length()) {
result.append(formatCodeSegment(content.substring(lastEnd)));
}
-
+
return result.toString();
}
-
+
/**
* Find string literals and comments that should not be formatted
*/
private List findPreserveRegions(String content) {
List regions = new ArrayList<>();
-
+
int i = 0;
while (i < content.length()) {
char c = content.charAt(i);
-
+
// String literal
if (c == '"') {
int end = findStringEnd(content, i, '"');
@@ -383,7 +383,7 @@ public class FormatHelper {
i = end;
continue;
}
-
+
// Char literal
if (c == '\'') {
int end = findStringEnd(content, i, '\'');
@@ -391,13 +391,13 @@ public class FormatHelper {
i = end;
continue;
}
-
+
// Line comment
if (c == '/' && i + 1 < content.length() && content.charAt(i + 1) == '/') {
regions.add(new int[]{i, content.length()});
break;
}
-
+
// Block comment (could span multiple lines but we process line-by-line)
if (c == '/' && i + 1 < content.length() && content.charAt(i + 1) == '*') {
int end = content.indexOf("*/", i + 2);
@@ -410,13 +410,13 @@ public class FormatHelper {
}
continue;
}
-
+
i++;
}
-
+
return regions;
}
-
+
/**
* Find end of string/char literal
*/
@@ -435,37 +435,37 @@ public class FormatHelper {
}
return content.length();
}
-
+
// ==================== CODE SEGMENT FORMATTING ====================
-
+
/**
* Format a code segment (no strings/comments)
*/
private String formatCodeSegment(String code) {
if (code.isEmpty()) return code;
-
+
String result = code;
-
+
// Normalize whitespace first
if (settings.normalizeWhitespace) {
result = normalizeWhitespace(result);
}
-
+
// Apply operator spacing
result = formatOperators(result);
-
+
// Apply bracket spacing
result = formatBrackets(result);
-
+
// Apply keyword spacing
result = formatKeywords(result);
-
+
// Apply punctuation spacing
result = formatPunctuation(result);
-
+
return result;
}
-
+
/**
* Normalize whitespace (multiple spaces → single space)
*/
@@ -473,13 +473,13 @@ public class FormatHelper {
// Replace multiple spaces with single space, but preserve indentation
return code.replaceAll(" +", " ");
}
-
+
/**
* Format operator spacing
*/
private String formatOperators(String code) {
String result = code;
-
+
// Assignment operators
if (settings.spaceAroundAssignment) {
// Compound assignments first (longer patterns first)
@@ -494,11 +494,11 @@ public class FormatHelper {
result = formatBinaryOp(result, "<<=", " <<= ");
result = formatBinaryOp(result, ">>=", " >>= ");
result = formatBinaryOp(result, ">>>=", " >>>= ");
-
+
// Simple assignment (but not ==, !=, <=, >=)
result = formatSimpleAssignment(result);
}
-
+
// Comparison operators
if (settings.spaceAroundComparison) {
result = formatBinaryOp(result, "==", " == ");
@@ -508,27 +508,27 @@ public class FormatHelper {
// Simple < > (but not generics)
result = formatComparisonOperators(result);
}
-
+
// Logical operators
if (settings.spaceAroundLogical) {
result = formatBinaryOp(result, "&&", " && ");
result = formatBinaryOp(result, "||", " || ");
}
-
+
// Arithmetic operators
if (settings.spaceAroundArithmetic) {
// Handle ++ and -- first to avoid conflicts
result = formatArithmeticOperators(result);
}
-
+
// Bitwise operators (but not in generics)
if (settings.spaceAroundBitwise) {
result = formatBitwiseOperators(result);
}
-
+
return result;
}
-
+
/**
* Format a binary operator with proper spacing
*/
@@ -537,7 +537,7 @@ public class FormatHelper {
String pattern = "\\s*" + Pattern.quote(op) + "\\s*";
return code.replaceAll(pattern, replacement);
}
-
+
/**
* Format simple assignment = (not ==, !=, <=, >=, etc.)
*/
@@ -550,13 +550,13 @@ public class FormatHelper {
// Check it's not part of ==, !=, <=, >=, +=, etc.
char prev = i > 0 ? code.charAt(i - 1) : ' ';
char next = i + 1 < code.length() ? code.charAt(i + 1) : ' ';
-
- boolean isCompound = prev == '!' || prev == '<' || prev == '>' ||
- prev == '+' || prev == '-' || prev == '*' ||
- prev == '/' || prev == '%' || prev == '&' ||
- prev == '|' || prev == '^';
+
+ boolean isCompound = prev == '!' || prev == '<' || prev == '>' ||
+ prev == '+' || prev == '-' || prev == '*' ||
+ prev == '/' || prev == '%' || prev == '&' ||
+ prev == '|' || prev == '^';
boolean isEquality = next == '=';
-
+
if (!isCompound && !isEquality) {
// Ensure space before =
if (result.length() > 0 && result.charAt(result.length() - 1) != ' ') {
@@ -577,7 +577,7 @@ public class FormatHelper {
}
return result.toString();
}
-
+
/**
* Format < and > comparison operators (avoiding generics)
*/
@@ -586,11 +586,11 @@ public class FormatHelper {
int i = 0;
while (i < code.length()) {
char c = code.charAt(i);
-
+
if ((c == '<' || c == '>') && !isLikelyGeneric(code, i, c)) {
char prev = i > 0 ? code.charAt(i - 1) : ' ';
char next = i + 1 < code.length() ? code.charAt(i + 1) : ' ';
-
+
// Skip if part of <<, >>, <=, >=
if ((c == '<' && next == '<') || (c == '>' && next == '>') ||
next == '=' || prev == '<' || prev == '>') {
@@ -612,7 +612,7 @@ public class FormatHelper {
}
return result.toString();
}
-
+
/**
* Check if < or > is likely part of a generic type declaration
*/
@@ -651,7 +651,7 @@ public class FormatHelper {
return depth == 0;
}
}
-
+
/**
* Format arithmetic operators (+, -, *, /, %)
*/
@@ -662,9 +662,9 @@ public class FormatHelper {
char c = code.charAt(i);
char next = i + 1 < code.length() ? code.charAt(i + 1) : ' ';
char prev = i > 0 ? code.charAt(i - 1) : ' ';
-
+
boolean isArithOp = c == '+' || c == '-' || c == '*' || c == '/' || c == '%';
-
+
if (isArithOp) {
// Skip ++, --, +=, -=, *=, /=, %=, and unary +/-
if ((c == '+' && next == '+') || (c == '-' && next == '-') ||
@@ -691,41 +691,41 @@ public class FormatHelper {
}
return result.toString();
}
-
+
/**
* Check if position is in a unary context (operator is unary, not binary)
*/
private boolean isUnaryContext(String code, int pos) {
if (pos == 0) return true;
-
+
// Look back for context
int i = pos - 1;
while (i >= 0 && code.charAt(i) == ' ') {
i--;
}
-
+
if (i < 0) return true;
-
+
char prev = code.charAt(i);
// Unary context after: ( [ { , ; = + - * / % < > & | ^ ? :
- return prev == '(' || prev == '[' || prev == '{' || prev == ',' ||
- prev == ';' || prev == '=' || prev == '+' || prev == '-' ||
- prev == '*' || prev == '/' || prev == '%' || prev == '<' ||
- prev == '>' || prev == '&' || prev == '|' || prev == '^' ||
- prev == '?' || prev == ':' || prev == '!';
+ return prev == '(' || prev == '[' || prev == '{' || prev == ',' ||
+ prev == ';' || prev == '=' || prev == '+' || prev == '-' ||
+ prev == '*' || prev == '/' || prev == '%' || prev == '<' ||
+ prev == '>' || prev == '&' || prev == '|' || prev == '^' ||
+ prev == '?' || prev == ':' || prev == '!';
}
-
+
/**
* Format bitwise operators
*/
private String formatBitwiseOperators(String code) {
String result = code;
-
+
// Shift operators first
result = formatBinaryOp(result, ">>>", " >>> ");
result = formatBinaryOp(result, "<<", " << ");
result = formatBinaryOp(result, ">>", " >> ");
-
+
// Single & | ^ (not && ||)
StringBuilder sb = new StringBuilder();
int i = 0;
@@ -733,7 +733,7 @@ public class FormatHelper {
char c = result.charAt(i);
char next = i + 1 < result.length() ? result.charAt(i + 1) : ' ';
char prev = i > 0 ? result.charAt(i - 1) : ' ';
-
+
if ((c == '&' && next != '&' && prev != '&' && next != '=') ||
(c == '|' && next != '|' && prev != '|' && next != '=') ||
(c == '^' && next != '=')) {
@@ -749,18 +749,18 @@ public class FormatHelper {
}
i++;
}
-
+
return sb.toString();
}
-
+
// ==================== BRACKET FORMATTING ====================
-
+
/**
* Format bracket spacing
*/
private String formatBrackets(String code) {
String result = code;
-
+
// Parentheses
if (settings.spaceWithinParens) {
result = result.replaceAll("\\(\\s*", "( ");
@@ -769,7 +769,7 @@ public class FormatHelper {
result = result.replaceAll("\\(\\s+", "(");
result = result.replaceAll("\\s+\\)", ")");
}
-
+
// Square brackets
if (settings.spaceWithinBrackets) {
result = result.replaceAll("\\[\\s*", "[ ");
@@ -778,69 +778,69 @@ public class FormatHelper {
result = result.replaceAll("\\[\\s+", "[");
result = result.replaceAll("\\s+\\]", "]");
}
-
+
// Curly braces (for array initializers inline)
// Note: standalone braces for blocks are handled by indentation logic
-
+
return result;
}
-
+
// ==================== KEYWORD FORMATTING ====================
-
+
/**
* Format keyword spacing (if, while, for, etc.)
*/
private String formatKeywords(String code) {
String result = code;
-
+
if (settings.spaceBeforeIfParens) {
result = result.replaceAll("\\bif\\s*\\(", "if (");
} else {
result = result.replaceAll("\\bif\\s+\\(", "if(");
}
-
+
if (settings.spaceBeforeWhileParens) {
result = result.replaceAll("\\bwhile\\s*\\(", "while (");
} else {
result = result.replaceAll("\\bwhile\\s+\\(", "while(");
}
-
+
if (settings.spaceBeforeForParens) {
result = result.replaceAll("\\bfor\\s*\\(", "for (");
} else {
result = result.replaceAll("\\bfor\\s+\\(", "for(");
}
-
+
if (settings.spaceBeforeSwitchParens) {
result = result.replaceAll("\\bswitch\\s*\\(", "switch (");
} else {
result = result.replaceAll("\\bswitch\\s+\\(", "switch(");
}
-
+
if (settings.spaceBeforeCatchParens) {
result = result.replaceAll("\\bcatch\\s*\\(", "catch (");
} else {
result = result.replaceAll("\\bcatch\\s+\\(", "catch(");
}
-
+
// Space before opening brace
if (settings.spaceBeforeOpenBrace) {
result = result.replaceAll("\\)\\s*\\{", ") {");
} else {
result = result.replaceAll("\\)\\s+\\{", "){");
}
-
+
return result;
}
-
+
// ==================== PUNCTUATION FORMATTING ====================
-
+
/**
* Format punctuation spacing (commas, semicolons, colons)
*/
private String formatPunctuation(String code) {
String result = code;
-
+
// Commas
if (settings.spaceAfterComma && !settings.spaceBeforeComma) {
result = result.replaceAll("\\s*,\\s*", ", ");
@@ -851,17 +851,17 @@ public class FormatHelper {
} else {
result = result.replaceAll("\\s*,\\s*", ",");
}
-
+
// Semicolons (but not in for loops - handle more carefully)
// This is tricky because for(;;) should be handled differently
// For now, just handle trailing semicolons
if (settings.trimTrailingWhitespace) {
result = result.replaceAll("\\s+;", ";");
}
-
+
return result;
}
-
+
/**
* Trim trailing whitespace from a line
*/
@@ -872,43 +872,43 @@ public class FormatHelper {
}
return line.substring(0, end);
}
-
+
// ==================== STATIC UTILITIES ====================
-
+
/**
* Format code with default settings
*/
public static String formatCode(String code) {
return new FormatHelper().format(code);
}
-
+
/**
* Format code with custom settings
*/
public static String formatCode(String code, FormatSettings settings) {
return new FormatHelper(settings).format(code);
}
-
+
// ==================== LINE WRAPPING ====================
-
+
/**
* Wrap long lines according to settings.
* Call this after format() if wrapLongLines is enabled.
- *
- * @param text The text to wrap
+ *
+ * @param text The text to wrap
* @param maxWidth Maximum line width (use settings.maxLineLength if 0)
* @return Text with wrapped lines
*/
public String wrapLines(String text, int maxWidth) {
if (text == null || text.isEmpty()) return text;
-
+
int width = maxWidth > 0 ? maxWidth : settings.maxLineLength;
String[] lines = text.split("\n", -1);
StringBuilder result = new StringBuilder();
-
+
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
-
+
if (getVisualLength(line) <= width) {
result.append(line);
} else {
@@ -922,15 +922,15 @@ public class FormatHelper {
result.append(wrapCodeLine(line, width));
}
}
-
+
if (i < lines.length - 1) {
result.append("\n");
}
}
-
+
return result.toString();
}
-
+
/**
* Get visual length of a line (tabs count as 4 spaces)
*/
@@ -945,7 +945,7 @@ public class FormatHelper {
}
return len;
}
-
+
/**
* Extract leading indentation from a line
*/
@@ -956,67 +956,67 @@ public class FormatHelper {
}
return line.substring(0, i);
}
-
+
/**
* Wrap a single-line comment (// style)
*/
private String wrapCommentLine(String line, int maxWidth) {
if (!settings.wrapComments) return line;
-
+
String indent = extractIndent(line);
String content = line.substring(indent.length());
-
+
// Must start with //
if (!content.startsWith("//")) return line;
-
+
String commentContent = content.substring(2).trim();
String prefix = indent + "// ";
int prefixLen = getVisualLength(prefix);
int contentWidth = maxWidth - prefixLen;
-
+
if (contentWidth <= 10) return line; // Too narrow to wrap
-
+
StringBuilder result = new StringBuilder();
result.append(indent).append("// ");
-
+
String[] words = commentContent.split("\\s+");
int lineLen = prefixLen;
-
+
for (int i = 0; i < words.length; i++) {
String word = words[i];
int wordLen = word.length();
-
+
if (lineLen + wordLen > maxWidth && lineLen > prefixLen) {
// Start new line
result.append("\n").append(prefix);
lineLen = prefixLen;
}
-
+
if (lineLen > prefixLen) {
result.append(" ");
lineLen++;
}
-
+
result.append(word);
lineLen += wordLen;
}
-
+
return result.toString();
}
-
+
/**
* Wrap a block comment line (* style)
*/
private String wrapBlockCommentLine(String line, int maxWidth) {
if (!settings.wrapComments) return line;
-
+
String indent = extractIndent(line);
String content = line.substring(indent.length()).trim();
-
+
// Determine prefix for wrapped lines
String prefix;
String textContent;
-
+
if (content.startsWith("/**")) {
prefix = indent + " * ";
textContent = content.substring(3).trim();
@@ -1029,20 +1029,20 @@ public class FormatHelper {
} else {
return line;
}
-
+
// Handle closing */
boolean hasClose = textContent.endsWith("*/");
if (hasClose) {
textContent = textContent.substring(0, textContent.length() - 2).trim();
}
-
+
int prefixLen = getVisualLength(prefix);
int contentWidth = maxWidth - prefixLen;
-
+
if (contentWidth <= 10) return line;
-
+
StringBuilder result = new StringBuilder();
-
+
// First line keeps original prefix
if (content.startsWith("/**")) {
result.append(indent).append("/** ");
@@ -1051,72 +1051,72 @@ public class FormatHelper {
} else {
result.append(indent).append(" * ");
}
-
+
String[] words = textContent.split("\\s+");
int lineLen = prefixLen;
-
+
for (int i = 0; i < words.length; i++) {
String word = words[i];
int wordLen = word.length();
-
+
if (lineLen + wordLen > maxWidth && lineLen > prefixLen) {
result.append("\n").append(prefix);
lineLen = prefixLen;
}
-
+
if (lineLen > prefixLen) {
result.append(" ");
lineLen++;
}
-
+
result.append(word);
lineLen += wordLen;
}
-
+
if (hasClose) {
result.append(" */");
}
-
+
return result.toString();
}
-
+
/**
* Wrap a code line at appropriate break points
*/
private String wrapCodeLine(String line, int maxWidth) {
String indent = extractIndent(line);
String content = line.substring(indent.length());
-
+
// Additional indent for wrapped lines
String wrapIndent = indent + spaces(settings.wrapIndentSpaces);
-
+
// Find break points - positions where we can break the line
List breakPoints = findBreakPoints(content);
-
+
if (breakPoints.isEmpty()) {
// No good break points, just return as-is
return line;
}
-
+
StringBuilder result = new StringBuilder();
result.append(indent);
-
+
int currentLen = getVisualLength(indent);
int lastBreak = 0;
boolean isFirstLine = true;
-
+
for (BreakPoint bp : breakPoints) {
int segmentEnd = bp.position;
String segment = content.substring(lastBreak, segmentEnd);
int segmentLen = getVisualLength(segment);
-
+
// Check if adding this segment would exceed max width
if (currentLen + segmentLen > maxWidth && !isFirstLine) {
// Break here
result.append("\n").append(wrapIndent);
currentLen = getVisualLength(wrapIndent);
isFirstLine = false;
-
+
// Trim leading space from continuation if any
segment = trimLeading(segment);
} else if (currentLen + segmentLen > maxWidth && isFirstLine && lastBreak > 0) {
@@ -1125,29 +1125,29 @@ public class FormatHelper {
currentLen = getVisualLength(wrapIndent);
isFirstLine = false;
}
-
+
result.append(segment);
currentLen += getVisualLength(segment);
lastBreak = segmentEnd;
isFirstLine = false;
}
-
+
// Append remaining content
if (lastBreak < content.length()) {
String remaining = content.substring(lastBreak);
int remLen = getVisualLength(remaining);
-
+
if (currentLen + remLen > maxWidth && !isFirstLine) {
result.append("\n").append(wrapIndent);
remaining = trimLeading(remaining);
}
-
+
result.append(remaining);
}
-
+
return result.toString();
}
-
+
/**
* Trim leading whitespace (Java 8 compatible)
*/
@@ -1158,7 +1158,7 @@ public class FormatHelper {
}
return s.substring(start);
}
-
+
/**
* A potential line break point
*/
@@ -1166,29 +1166,29 @@ public class FormatHelper {
int position; // Position in string (after this char)
@SuppressWarnings("unused")
int priority; // Lower = better place to break (for future sorting)
-
+
BreakPoint(int pos, int prio) {
this.position = pos;
this.priority = prio;
}
}
-
+
/**
* Find good positions to break a line
*/
private List findBreakPoints(String content) {
List points = new ArrayList<>();
-
+
int parenDepth = 0;
int bracketDepth = 0;
int braceDepth = 0;
boolean inString = false;
char stringChar = 0;
-
+
for (int i = 0; i < content.length(); i++) {
char c = content.charAt(i);
char prev = i > 0 ? content.charAt(i - 1) : ' ';
-
+
// Track string state
if ((c == '"' || c == '\'') && prev != '\\') {
if (!inString) {
@@ -1198,9 +1198,9 @@ public class FormatHelper {
inString = false;
}
}
-
+
if (inString) continue;
-
+
// Track bracket depth
if (c == '(') parenDepth++;
else if (c == ')') parenDepth--;
@@ -1208,16 +1208,16 @@ public class FormatHelper {
else if (c == ']') bracketDepth--;
else if (c == '{') braceDepth++;
else if (c == '}') braceDepth--;
-
+
// Calculate total nesting depth (prefer breaking at lower depth)
int depth = parenDepth + bracketDepth + braceDepth;
-
+
// Find break points
if (settings.wrapAfterComma && c == ',') {
// After comma is a good break point (better at lower depth)
points.add(new BreakPoint(i + 1, 1 + depth));
}
-
+
if (settings.wrapAfterOperator) {
// After binary operators
if ((c == '+' || c == '-') && i > 0 && i < content.length() - 1) {
@@ -1234,24 +1234,24 @@ public class FormatHelper {
points.add(new BreakPoint(i + 2, 2 + depth));
}
}
-
+
if (settings.wrapBeforeDot && c == '.') {
// Before dot (for method chaining)
points.add(new BreakPoint(i, 2 + depth));
}
-
+
// After opening brace
if (c == '{' && i + 1 < content.length()) {
points.add(new BreakPoint(i + 1, 1));
}
}
-
+
// Sort by position
points.sort((a, b) -> Integer.compare(a.position, b.position));
-
+
return points;
}
-
+
/**
* Create a string of n spaces
*/
@@ -1262,7 +1262,7 @@ public class FormatHelper {
}
return sb.toString();
}
-
+
/**
* Format and wrap code in one step
*/
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/GoToLineDialog.java b/src/main/java/noppes/npcs/client/gui/util/script/GoToLineDialog.java
index 7a8217493..f054f32a7 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/GoToLineDialog.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/GoToLineDialog.java
@@ -5,7 +5,6 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.ResourceLocation;
-import noppes.npcs.client.gui.util.GuiUtil;
import noppes.npcs.client.gui.util.key.OverlayKeyPresetViewer;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@@ -13,7 +12,7 @@ import org.lwjgl.opengl.GL11;
/**
* Go To Line:Column dialog for the script editor.
* Provides IntelliJ-like "Go to Line" functionality (Ctrl+G).
- *
+ *
* Input format: "line" or "line:column"
* Example: "42" goes to line 42, column 1
* Example: "42:15" goes to line 42, column 15
@@ -55,26 +54,35 @@ public class GoToLineDialog {
* Callback interface for go-to-line operations
*/
public interface GoToLineCallback {
- /** Get total line count */
+ /**
+ * Get total line count
+ */
int getLineCount();
- /** Get the column count for a specific line (0-indexed) */
+ /**
+ * Get the column count for a specific line (0-indexed)
+ */
int getColumnCount(int lineIndex);
- /** Navigate to specific line and column (both 1-indexed for user display) */
+ /**
+ * Navigate to specific line and column (both 1-indexed for user display)
+ */
void goToLineColumn(int line, int column);
- /** Called when dialog closes - should restore focus to editor */
+ /**
+ * Called when dialog closes - should restore focus to editor
+ */
void onDialogClose();
void unfocusMainEditor();
-
+
void focusMainEditor();
}
-
+
public void setCallback(GoToLineCallback callback) {
this.callback = callback;
}
+
/**
* Initialize/update position for the dialog
*/
@@ -163,7 +171,7 @@ public class GoToLineDialog {
int fieldY = y + padding + 14 + 5;
textFieldWidth = dialogWidth - padding * 2;
drawTextField(fieldX, fieldY, textFieldWidth, textFieldHeight, inputText, cursor,
- selectionStart, selectionEnd, scrollOffset, focused);
+ selectionStart, selectionEnd, scrollOffset, focused);
if (inputText.isEmpty())
font.drawString("[Line][:Column]", x + padding + 6, y + padding + 23, 0xFF888888);
@@ -228,7 +236,7 @@ public class GoToLineDialog {
int maxSel = Math.max(adjustedSelStart, adjustedSelEnd);
String beforeSel = visibleText.substring(0, Math.min(minSel, visibleText.length()));
String inSel = visibleText.substring(Math.min(minSel, visibleText.length()),
- Math.min(maxSel, visibleText.length()));
+ Math.min(maxSel, visibleText.length()));
int selX = textX + font.getStringWidth(beforeSel);
int selW = font.getStringWidth(inSel);
Gui.drawRect(selX, textY - 1, selX + selW, textY + 9, 0xFF264f78);
@@ -240,7 +248,7 @@ public class GoToLineDialog {
// Draw cursor
if (isFocused && shouldShowCursor()) {
String beforeCursor = adjustedCursor > 0 && adjustedCursor <= visibleText.length()
- ? visibleText.substring(0, adjustedCursor) : "";
+ ? visibleText.substring(0, adjustedCursor) : "";
int cursorX = textX + font.getStringWidth(beforeCursor);
Gui.drawRect(cursorX, textY - 1, cursorX + 1, textY + 9, 0xFFe0e0e0);
}
@@ -258,13 +266,13 @@ public class GoToLineDialog {
int fieldX = x + padding;
int fieldY = y + padding + 14;
if (mouseX >= fieldX && mouseX < fieldX + textFieldWidth &&
- mouseY >= fieldY && mouseY < fieldY + textFieldHeight) {
+ mouseY >= fieldY && mouseY < fieldY + textFieldHeight) {
focused = true;
if (callback != null) callback.unfocusMainEditor();
// Position cursor based on click
int clickX = mouseX - fieldX - 4;
String visibleText = scrollOffset > 0 && scrollOffset < inputText.length()
- ? inputText.substring(scrollOffset) : inputText;
+ ? inputText.substring(scrollOffset) : inputText;
int newCursor = getCharIndexAtX(visibleText, clickX) + scrollOffset;
cursor = Math.max(0, Math.min(newCursor, inputText.length()));
selectionStart = cursor;
@@ -297,7 +305,7 @@ public class GoToLineDialog {
close();
return true;
}
-
+
if (!visible || !focused)
return false;
@@ -617,4 +625,4 @@ public class GoToLineDialog {
public int getTotalHeight() {
return visible ? dialogHeight + 10 : 0;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/IndentHelper.java b/src/main/java/noppes/npcs/client/gui/util/script/IndentHelper.java
index a978dc724..12a5567ad 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/IndentHelper.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/IndentHelper.java
@@ -1,6 +1,7 @@
package noppes.npcs.client.gui.util.script;
import noppes.npcs.client.gui.util.script.JavaTextContainer.LineData;
+
import java.util.Arrays;
import java.util.List;
@@ -8,9 +9,9 @@ import java.util.List;
* Helper class for indentation-related operations.
*/
public class IndentHelper {
-
+
public static final int TAB_SIZE = 4;
-
+
/**
* Get leading whitespace count of a line
*/
@@ -23,7 +24,7 @@ public class IndentHelper {
}
return leading;
}
-
+
/**
* Extract leading whitespace as string
*/
@@ -31,7 +32,7 @@ public class IndentHelper {
int indent = getLineIndent(lineText);
return lineText.substring(0, indent);
}
-
+
/**
* Create a string of n spaces
*/
@@ -41,16 +42,16 @@ public class IndentHelper {
Arrays.fill(arr, ' ');
return new String(arr);
}
-
+
/**
* Calculate expected indent for a line based on context
*/
public static int getExpectedIndent(LineData currentLine, List allLines) {
if (currentLine == null || allLines == null) return 0;
-
+
int idx = allLines.indexOf(currentLine);
if (idx <= 0) return 0;
-
+
// Find previous non-empty line
LineData prevLine = null;
for (int i = idx - 1; i >= 0; i--) {
@@ -60,40 +61,40 @@ public class IndentHelper {
break;
}
}
-
+
if (prevLine == null) return 0;
-
+
int prevIndent = getLineIndent(prevLine.text);
String prevTrimmed = prevLine.text.trim();
String currTrimmed = currentLine.text.trim();
-
+
// If current line starts with }, expected is one level back
if (currTrimmed.startsWith("}")) {
return Math.max(0, prevIndent - TAB_SIZE);
}
-
+
// If previous line ends with {, expected is one level forward
if (prevTrimmed.endsWith("{")) {
return prevIndent + TAB_SIZE;
}
-
+
return prevIndent;
}
-
+
/**
* Calculate auto-indent for Enter key
*/
public static String getAutoIndentForEnter(String lineText, int cursorInLine) {
int leading = 0;
- while (leading < lineText.length() &&
- (lineText.charAt(leading) == ' ' || lineText.charAt(leading) == '\t')) {
+ while (leading < lineText.length() &&
+ (lineText.charAt(leading) == ' ' || lineText.charAt(leading) == '\t')) {
leading++;
}
-
+
String baseIndent = lineText.substring(0, leading);
int relativeCursor = Math.max(0, Math.min(cursorInLine, lineText.length()));
String beforeCursor = lineText.substring(0, relativeCursor);
-
+
// Find last non-whitespace before cursor
int lastNonWs = -1;
for (int i = beforeCursor.length() - 1; i >= 0; i--) {
@@ -102,7 +103,7 @@ public class IndentHelper {
break;
}
}
-
+
// Add extra indent if last char is {
// Only add extra indent if cursor is actually after the opening brace (not just in trailing whitespace)
// Check that the last non-whitespace is at or after the line's indent position
@@ -110,10 +111,10 @@ public class IndentHelper {
if (opensBlock) {
return baseIndent + spaces(TAB_SIZE);
}
-
+
return baseIndent;
}
-
+
/**
* Calculate target indent for Tab key
*/
@@ -136,62 +137,63 @@ public class IndentHelper {
}
}
}
-
+
/**
* Calculate target indent for Shift+Tab
*/
public static int calculateShiftTabTargetIndent(int currentIndent) {
return Math.max(0, ((currentIndent - 1) / TAB_SIZE) * TAB_SIZE);
}
-
+
/**
* Format entire text with proper indentation and operator spacing
*/
public static FormatResult formatText(String text, int cursorPosition) {
return formatText(text, cursorPosition, 0);
}
-
+
/**
* Format entire text with proper indentation, operator spacing, and optional line wrapping
- * @param text The text to format
+ *
+ * @param text The text to format
* @param cursorPosition Current cursor position
- * @param viewportWidth Viewport width for line wrapping (0 = no wrapping)
+ * @param viewportWidth Viewport width for line wrapping (0 = no wrapping)
*/
public static FormatResult formatText(String text, int cursorPosition, int viewportWidth) {
// First pass: fix indentation
String indented = formatIndentation(text, cursorPosition);
-
+
// Second pass: apply operator spacing and whitespace normalization
FormatHelper helper = new FormatHelper();
FormatHelper.FormatSettings settings = helper.getSettings();
-
+
// Enable wrapping if viewport width is provided
if (viewportWidth > 0) {
settings.wrapLongLines = true;
settings.wrapComments = true;
// Use 75% of viewport width as max line length for some margin
int charWidth = 6; // Approximate character width
- settings.maxLineLength = Math.max(60, (int)(viewportWidth * 0.8f / charWidth));
+ settings.maxLineLength = Math.max(60, (int) (viewportWidth * 0.8f / charWidth));
}
-
+
String formatted = helper.format(indented);
-
+
// Apply wrapping if enabled
if (viewportWidth > 0 && settings.wrapLongLines) {
formatted = helper.wrapLines(formatted, settings.maxLineLength);
}
-
+
// Recalculate cursor position (try to maintain relative position)
int newCursorPos = Math.min(cursorPosition, formatted.length());
-
+
// Try to find cursor on same line with same content context
String[] origLines = text.split("\n", -1);
String[] newLines = formatted.split("\n", -1);
-
+
int lineStartPos = 0;
int cursorLine = -1;
int cursorColInLine = 0;
-
+
for (int li = 0; li < origLines.length; li++) {
int lineEndPos = lineStartPos + origLines[li].length();
if (cursorPosition >= lineStartPos && cursorPosition <= lineEndPos) {
@@ -201,7 +203,7 @@ public class IndentHelper {
}
lineStartPos = lineEndPos + 1;
}
-
+
if (cursorLine >= 0 && cursorLine < newLines.length) {
int newLineStart = 0;
for (int li = 0; li < cursorLine; li++) {
@@ -210,51 +212,66 @@ public class IndentHelper {
// Clamp cursor to new line length
newCursorPos = newLineStart + Math.min(cursorColInLine, newLines[cursorLine].length());
}
-
+
return new FormatResult(formatted, newCursorPos);
}
-
+
/**
* Format indentation only (first pass)
*/
private static String formatIndentation(String text, int cursorPosition) {
String[] linesArr = text.split("\n", -1);
StringBuilder out = new StringBuilder(text.length() + 32);
-
+
boolean inString = false;
boolean escape = false;
boolean inBlockComment = false;
int depth = 0;
-
+
for (int li = 0; li < linesArr.length; li++) {
String line = linesArr[li];
String trimmedLeading = line.replaceAll("^[ \\t]+", "");
int originalIndent = getLineIndent(line);
-
+
int opens = 0, closes = 0;
boolean startsWithClose = false;
-
+
// Parse line for braces
for (int idx = 0; idx < line.length(); idx++) {
char c = line.charAt(idx);
char next = idx + 1 < line.length() ? line.charAt(idx + 1) : 0;
-
+
if (inString) {
- if (escape) { escape = false; }
- else if (c == '\\') { escape = true; }
- else if (c == '"') { inString = false; }
+ if (escape) {
+ escape = false;
+ } else if (c == '\\') {
+ escape = true;
+ } else if (c == '"') {
+ inString = false;
+ }
continue;
}
-
+
if (inBlockComment) {
- if (c == '*' && next == '/') { inBlockComment = false; idx++; }
+ if (c == '*' && next == '/') {
+ inBlockComment = false;
+ idx++;
+ }
continue;
}
-
+
if (c == '/' && next == '/') break;
- if (c == '/' && next == '*') { inBlockComment = true; idx++; continue; }
- if (c == '"') { inString = true; escape = false; continue; }
-
+ if (c == '/' && next == '*') {
+ inBlockComment = true;
+ idx++;
+ continue;
+ }
+ if (c == '"') {
+ inString = true;
+ escape = false;
+ continue;
+ }
+
if (c == '{') {
opens++;
} else if (c == '}') {
@@ -264,11 +281,11 @@ public class IndentHelper {
}
}
}
-
+
int indentLevel = depth;
if (startsWithClose) indentLevel = Math.max(0, indentLevel - 1);
int targetIndent = indentLevel * TAB_SIZE;
-
+
// Check if this is a continuation line:
// 1. Line starts with operator/dot (explicit continuation)
// 2. Previous line ends with operator (implicit continuation - this line continues it)
@@ -279,7 +296,7 @@ public class IndentHelper {
String prevLine = linesArr[li - 1].trim();
isContinuation = lineEndsWithContinuationOperator(prevLine);
}
-
+
if (isContinuation && originalIndent > targetIndent) {
// This is a continuation line - preserve its extra indent
out.append(spaces(originalIndent)).append(trimmedLeading);
@@ -287,13 +304,13 @@ public class IndentHelper {
out.append(spaces(targetIndent)).append(trimmedLeading);
}
if (li < linesArr.length - 1) out.append('\n');
-
+
depth = Math.max(0, depth + opens - closes);
}
-
+
return out.toString();
}
-
+
/**
* Check if a line appears to be a continuation of a previous line
* (i.e., starts with an operator, dot, or other continuation character)
@@ -302,7 +319,7 @@ public class IndentHelper {
if (trimmedContent.isEmpty()) return false;
char firstChar = trimmedContent.charAt(0);
// Lines starting with these are likely continuations
- if (firstChar == '.' || firstChar == '+' || firstChar == '-' ||
+ if (firstChar == '.' || firstChar == '+' || firstChar == '-' ||
firstChar == '*' || firstChar == '/' || firstChar == '%' ||
firstChar == '&' || firstChar == '|' || firstChar == '^' ||
firstChar == '?' || firstChar == ':' || firstChar == ',') {
@@ -314,7 +331,7 @@ public class IndentHelper {
}
return false;
}
-
+
/**
* Check if a line ends with an operator that indicates the next line is a continuation
*/
@@ -326,10 +343,10 @@ public class IndentHelper {
trimmedLine = trimmedLine.substring(0, commentIdx).trim();
}
if (trimmedLine.isEmpty()) return false;
-
+
// Check if ends with operator
char lastChar = trimmedLine.charAt(trimmedLine.length() - 1);
- if (lastChar == '+' || lastChar == '-' || lastChar == '*' ||
+ if (lastChar == '+' || lastChar == '-' || lastChar == '*' ||
lastChar == '/' || lastChar == '%' || lastChar == '=' ||
lastChar == '&' || lastChar == '|' || lastChar == '^' ||
lastChar == '?' || lastChar == ':' || lastChar == ',' ||
@@ -343,17 +360,17 @@ public class IndentHelper {
}
return false;
}
-
+
/**
* Result of text formatting
*/
public static class FormatResult {
public final String text;
public final int cursorPosition;
-
+
public FormatResult(String text, int cursorPosition) {
this.text = text;
this.cursorPosition = cursorPosition;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/JavaTextContainer.java b/src/main/java/noppes/npcs/client/gui/util/script/JavaTextContainer.java
index ccdd9cc44..fe09cb81a 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/JavaTextContainer.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/JavaTextContainer.java
@@ -11,37 +11,38 @@ import java.util.regex.Pattern;
public class JavaTextContainer extends TextContainer {
public static final Pattern MODIFIER = Pattern.compile(
- "\\b(public|protected|private|static|final|abstract|synchronized|native|default)\\b");
+ "\\b(public|protected|private|static|final|abstract|synchronized|native|default)\\b");
public static final Pattern KEYWORD = Pattern.compile(
- "\\b(null|boolean|int|float|double|long|char|byte|short|void|if|else|switch|case|for|while|do|try|catch|finally|return|throw|var|let|const|function|continue|break|this|new|typeof|instanceof|import)\\b");
+ "\\b(null|boolean|int|float|double|long|char|byte|short|void|if|else|switch|case|for|while|do|try|catch|finally|return|throw|var|let|const|function|continue|break|this|new|typeof|instanceof|import)\\b");
public static final Pattern CLASS_DECL = Pattern.compile("\\b(class|interface|enum)\\s+([A-Za-z_][a-zA-Z0-9_]*)");
- public static final Pattern NEW_TYPE = Pattern.compile("\\bnew\\s+([A-Za-z_][a-zA-Z0-9_]*)");;
+ public static final Pattern NEW_TYPE = Pattern.compile("\\bnew\\s+([A-Za-z_][a-zA-Z0-9_]*)");
+ ;
public static final Pattern METHOD_DECL = Pattern.compile("\\b([A-Za-z_][a-zA-Z0-9_<>\\[\\]]*)\\s+" + // return type
- "([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(" // method name
+ "([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(" // method name
);
public static final Pattern METHOD_CALL = Pattern.compile("([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(");
// Class-level global fields
public static final Pattern GLOBAL_FIELD_DECL = Pattern.compile(
- "\\b([A-Za-z_][a-zA-Z0-9_<>\\[\\]]*)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*(=|;)");
+ "\\b([A-Za-z_][a-zA-Z0-9_<>\\[\\]]*)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*(=|;)");
// Local fields inside methods (simplified)
public static final Pattern LOCAL_FIELD_DECL = Pattern.compile(
- "\\b([A-Z][a-zA-Z0-9_<>\\[\\]]*|[a-z][a-zA-Z0-9_]*)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*(=|;)");
+ "\\b([A-Z][a-zA-Z0-9_<>\\[\\]]*|[a-z][a-zA-Z0-9_]*)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*(=|;)");
public static final Pattern STRING = Pattern.compile("([\"'])(?:(?=(\\\\?))\\2.)*?\\1");
public static final Pattern COMMENT = Pattern.compile("/\\*[\\s\\S]*?(?:\\*/|$)|//.*|#.*");
public static final Pattern NUMBER = Pattern.compile(
- "\\b-?(?:0[xX][\\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?(?:[fFbBdDlLsS])?|NaN|null|Infinity|true|false)\\b");
+ "\\b-?(?:0[xX][\\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?(?:[fFbBdDlLsS])?|NaN|null|Infinity|true|false)\\b");
- // Import statement: import [static] package.path.ClassName [.*]; (semicolon optional for live typing)
- // Allows optional whitespace (including newlines) around the dots so wrapped imports match.
- // Match imports while allowing optional whitespace/newlines around dots.
- public static final Pattern IMPORT = Pattern.compile(
- "(?m)\\bimport\\s+(?:static\\s+)?([A-Za-z_][A-Za-z0-9_]*(?:\\s*\\.\\s*[A-Za-z_][A-Za-z0-9_]*)*)(?:\\s*\\.\\s*\\*?)?\\s*(?:;|$)");
+ // Import statement: import [static] package.path.ClassName [.*]; (semicolon optional for live typing)
+ // Allows optional whitespace (including newlines) around the dots so wrapped imports match.
+ // Match imports while allowing optional whitespace/newlines around dots.
+ public static final Pattern IMPORT = Pattern.compile(
+ "(?m)\\bimport\\s+(?:static\\s+)?([A-Za-z_][A-Za-z0-9_]*(?:\\s*\\.\\s*[A-Za-z_][A-Za-z0-9_]*)*)(?:\\s*\\.\\s*\\*?)?\\s*(?:;|$)");
// ClassPathFinder for resolving imports and determining class types
private final ClassPathFinder classPathFinder = new ClassPathFinder();
@@ -73,10 +74,10 @@ public class JavaTextContainer extends TextContainer {
return pathStart + orig.length();
}
- public void init(String text,int width, int height) {
+ public void init(String text, int width, int height) {
this.text = text == null ? "" : text.replaceAll("\\r?\\n|\\r", "\n");
lines.clear();
- String[] split = text.split("\n",-1);
+ String[] split = text.split("\n", -1);
int totalChars = 0;
for (String l : split) {
@@ -196,32 +197,38 @@ public class JavaTextContainer extends TextContainer {
}
}
}
-
+
/**
* Parse and highlight generic type parameters using ClassPathFinder.
* Handles arbitrarily nested generics like "Map>>".
*/
private void highlightGenericTypes(String genericContent, int contentStart, List marks, List excluded) {
if (genericContent == null || genericContent.isEmpty()) return;
-
+
List occurrences = classPathFinder.parseGenericTypes(genericContent, importedClasses, importedPackages);
-
+
for (ClassPathFinder.TypeOccurrence occ : occurrences) {
int absStart = contentStart + occ.startOffset;
int absEnd = contentStart + occ.endOffset;
-
+
if (!isInExcludedRange(absStart, excluded)) {
TokenType tokenType;
switch (occ.type) {
- case INTERFACE: tokenType = TokenType.INTERFACE_DECL; break;
- case ENUM: tokenType = TokenType.ENUM_DECL; break;
- default: tokenType = TokenType.IMPORTED_CLASS; break;
+ case INTERFACE:
+ tokenType = TokenType.INTERFACE_DECL;
+ break;
+ case ENUM:
+ tokenType = TokenType.ENUM_DECL;
+ break;
+ default:
+ tokenType = TokenType.IMPORTED_CLASS;
+ break;
}
marks.add(new Mark(absStart, absEnd, tokenType));
}
}
}
-
+
private void collectFields() {
globalFields.clear();
localFields.clear();
@@ -229,7 +236,7 @@ public class JavaTextContainer extends TextContainer {
// Extract method blocks first
methodBlocks = MethodBlock.collectMethodBlocks(text);
-
+
// Get excluded ranges (strings and comments) for the entire text
List excludedRanges = MethodBlock.getExcludedRanges(text);
@@ -238,7 +245,7 @@ public class JavaTextContainer extends TextContainer {
while (mGlobal.find()) {
String varName = mGlobal.group(2);
int varPosition = mGlobal.start(2);
-
+
// Skip if inside a string or comment
if (isInExcludedRange(varPosition, excludedRanges)) {
continue;
@@ -298,7 +305,7 @@ public class JavaTextContainer extends TextContainer {
"String", "Object", "Array", "Math", "System", "Integer", "Double", "Float",
"Boolean", "Long", "Byte", "Short", "Character", "List", "Map", "Set"
));
-
+
// First pass: handle field accesses (this.field and obj.field patterns)
Pattern thisFieldPattern = Pattern.compile("\\bthis\\s*\\.\\s*([a-zA-Z_][a-zA-Z0-9_]*)");
Matcher thisFieldMatcher = thisFieldPattern.matcher(text);
@@ -312,7 +319,7 @@ public class JavaTextContainer extends TextContainer {
marks.add(new Mark(fieldPos, thisFieldMatcher.end(1), TokenType.UNDEFINED_VAR));
}
}
-
+
// Handle identifier.field patterns (e.g., obj.field, global.field)
// The field part should be highlighted as GLOBAL_FIELD (light blue)
// Also, detect chained accesses like `a.b.c` and treat subsequent segments
@@ -378,13 +385,13 @@ public class JavaTextContainer extends TextContainer {
marks.add(new Mark(fieldPos, objFieldMatcher.end(2), TokenType.GLOBAL_FIELD));
}
}
-
+
Pattern identifier = Pattern.compile("\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b");
Matcher m = identifier.matcher(text);
while (m.find()) {
String name = m.group(1);
int position = m.start(1);
-
+
// Skip known keywords
if (knownIdentifiers.contains(name)) continue;
@@ -462,24 +469,24 @@ public class JavaTextContainer extends TextContainer {
}
return false;
}
-
+
/**
* Check if the identifier at this position is a field access (preceded by a dot)
* e.g., in "obj.field", the "field" part is a field access
*/
private boolean isFieldAccess(int position) {
if (position <= 0) return false;
-
+
// Look backwards from position, skipping any whitespace
int i = position - 1;
while (i >= 0 && Character.isWhitespace(text.charAt(i))) {
i--;
}
-
+
// Check if preceded by a dot
return i >= 0 && text.charAt(i) == '.';
}
-
+
/**
* Check if the identifier at this position is a method call (followed by parenthesis)
*/
@@ -497,7 +504,7 @@ public class JavaTextContainer extends TextContainer {
// Check for opening paren
return i < text.length() && text.charAt(i) == '(';
}
-
+
/**
* Check if this looks like a type reference (e.g., part of a declaration or generic)
* But NOT a comparison like "i < container" which uses < as less-than operator
@@ -510,7 +517,7 @@ public class JavaTextContainer extends TextContainer {
return true;
}
}
-
+
// Check if preceded by < but make sure it's a generic, not a comparison
// Generic: Type tokenStarts = new ArrayList<>();
List tokenEnds = new ArrayList<>();
Matcher tokm = Pattern.compile("[A-Za-z_][A-Za-z0-9_]*").matcher(orig);
- while (tokm.find()) { tokens.add(tokm.group()); tokenStarts.add(tokm.start()); tokenEnds.add(tokm.end()); }
+ while (tokm.find()) {
+ tokens.add(tokm.group());
+ tokenStarts.add(tokm.start());
+ tokenEnds.add(tokm.end());
+ }
int tokenCount = tokenStarts.size();
if (tokenCount > 0) {
@@ -713,9 +736,15 @@ public class JavaTextContainer extends TextContainer {
TokenType segType = TokenType.IMPORTED_CLASS;
if (outerInfo != null) {
switch (outerInfo.type) {
- case INTERFACE: segType = TokenType.INTERFACE_DECL; break;
- case ENUM: segType = TokenType.ENUM_DECL; break;
- default: segType = TokenType.IMPORTED_CLASS; break;
+ case INTERFACE:
+ segType = TokenType.INTERFACE_DECL;
+ break;
+ case ENUM:
+ segType = TokenType.ENUM_DECL;
+ break;
+ default:
+ segType = TokenType.IMPORTED_CLASS;
+ break;
}
}
marks.add(new Mark(s, e, segType));
@@ -748,7 +777,6 @@ public class JavaTextContainer extends TextContainer {
}
}
-
private void collectImportedClassUsages(List marks) {
List excluded = MethodBlock.getExcludedRanges(text);
@@ -779,7 +807,7 @@ public class JavaTextContainer extends TextContainer {
boolean isShadowed = globalFields.contains(className) || localFields.contains(className);
if (block != null) {
isShadowed = isShadowed || block.parameters.contains(className) || block.isLocalDeclaredAtPosition(
- className, start);
+ className, start);
}
if (isImported && !isShadowed) {
@@ -788,8 +816,12 @@ public class JavaTextContainer extends TextContainer {
TokenType tokenType = TokenType.IMPORTED_CLASS;
if (info != null) {
switch (info.type) {
- case INTERFACE: tokenType = TokenType.INTERFACE_DECL; break;
- case ENUM: tokenType = TokenType.ENUM_DECL; break;
+ case INTERFACE:
+ tokenType = TokenType.INTERFACE_DECL;
+ break;
+ case ENUM:
+ tokenType = TokenType.ENUM_DECL;
+ break;
}
}
marks.add(new Mark(start, end, tokenType));
@@ -819,7 +851,7 @@ public class JavaTextContainer extends TextContainer {
}
}
}
-
+
public void formatCodeText() {
// Step 1: Tokenize the full text
List marks = new ArrayList<>();
@@ -855,7 +887,7 @@ public class JavaTextContainer extends TextContainer {
// Compute indent guides based on matched braces, ignoring strings/comments
computeIndentGuides(marks);
-
+
// Step 2: Clear existing tokens
for (LineData line : lines) {
line.tokens.clear();
@@ -880,7 +912,7 @@ public class JavaTextContainer extends TextContainer {
if (cursor < tokenStart) {
int end = Math.min(tokenStart, text.length());
line.tokens.add(
- new Token(text.substring(cursor, end), TokenType.DEFAULT, cursor, end));
+ new Token(text.substring(cursor, end), TokenType.DEFAULT, cursor, end));
}
// token text
@@ -910,50 +942,53 @@ public class JavaTextContainer extends TextContainer {
private void collectTypeDeclarations(List marks) {
List excluded = MethodBlock.getExcludedRanges(text);
-
+
// Pattern to find type declarations: Type<...> variableName or Type variableName
// We'll manually parse the generic portion to handle arbitrary nesting
Pattern typeStart = Pattern.compile(
"(?:(?:public|private|protected|static|final|transient|volatile)\\s+)*" +
- "([A-Z][a-zA-Z0-9_]*)\\s*" // Group 1 → type name (must start with uppercase)
+ "([A-Z][a-zA-Z0-9_]*)\\s*" // Group 1 → type name (must start with uppercase)
);
-
+
for (LineData ld : lines) {
int lineStart = ld.start;
int lineEnd = ld.end;
if (lineStart >= lineEnd) continue;
String s = ld.text;
-
+
Matcher m = typeStart.matcher(s);
int searchFrom = 0;
-
+
while (m.find(searchFrom)) {
int typeNameStart = lineStart + m.start(1);
int typeNameEnd = lineStart + m.end(1);
-
+
// Skip if in excluded range
boolean skip = false;
for (int[] r : excluded) {
- if (typeNameStart < r[1] && typeNameEnd > r[0]) { skip = true; break; }
+ if (typeNameStart < r[1] && typeNameEnd > r[0]) {
+ skip = true;
+ break;
+ }
}
if (skip) {
searchFrom = m.end();
continue;
}
-
+
String typeName = m.group(1);
int posAfterType = m.end(1);
-
+
// Skip whitespace after type name
while (posAfterType < s.length() && Character.isWhitespace(s.charAt(posAfterType))) {
posAfterType++;
}
-
+
// Check for generic parameters
String genericContent = null;
int genericStart = -1;
int genericEnd = -1;
-
+
if (posAfterType < s.length() && s.charAt(posAfterType) == '<') {
genericStart = posAfterType;
int depth = 1;
@@ -970,12 +1005,12 @@ public class JavaTextContainer extends TextContainer {
posAfterType = genericEnd;
}
}
-
+
// Skip whitespace after generics
while (posAfterType < s.length() && Character.isWhitespace(s.charAt(posAfterType))) {
posAfterType++;
}
-
+
// Check if this looks like a type declaration:
// 1. Has generic content (e.g., List) - always a type
// 2. Followed by a variable name (lowercase start or underscore)
@@ -983,38 +1018,43 @@ public class JavaTextContainer extends TextContainer {
boolean hasGeneric = genericContent != null && !genericContent.isEmpty();
boolean atEndOfLine = posAfterType >= s.length();
boolean followedByVarName = false;
-
+
if (!atEndOfLine) {
char nextChar = s.charAt(posAfterType);
followedByVarName = Character.isLetter(nextChar) || nextChar == '_';
}
-
+
// Accept as type if: has generics OR followed by variable name
// This handles both `List myList` and wrapped lines like `List`
if (hasGeneric || followedByVarName) {
// This looks like a type declaration
-
+
// Resolve the main type
ClassPathFinder.ClassInfo info = classPathFinder.resolveSimpleName(typeName, importedClasses, importedPackages);
TokenType tokenType = TokenType.UNDEFINED_VAR;
if (info != null) {
switch (info.type) {
- case INTERFACE: tokenType = TokenType.INTERFACE_DECL; break;
- case ENUM: tokenType = TokenType.ENUM_DECL; break;
- default: tokenType = TokenType.TYPE_DECL;
+ case INTERFACE:
+ tokenType = TokenType.INTERFACE_DECL;
+ break;
+ case ENUM:
+ tokenType = TokenType.ENUM_DECL;
+ break;
+ default:
+ tokenType = TokenType.TYPE_DECL;
}
}
marks.add(new Mark(typeNameStart, typeNameEnd, tokenType));
-
+
// Handle generic content
if (hasGeneric && genericStart >= 0) {
int absGenericStart = lineStart + genericStart;
int absGenericEnd = lineStart + genericEnd;
-
+
// Mark < and > as default
marks.add(new Mark(absGenericStart, absGenericStart + 1, TokenType.DEFAULT));
marks.add(new Mark(absGenericEnd - 1, absGenericEnd, TokenType.DEFAULT));
-
+
// Parse and highlight all types in generic content
int contentStart = lineStart + genericStart + 1;
highlightGenericTypes(genericContent, contentStart, marks, excluded);
@@ -1046,7 +1086,7 @@ public class JavaTextContainer extends TextContainer {
}
}
}
-
+
searchFrom = m.end();
}
}
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/MethodBlock.java b/src/main/java/noppes/npcs/client/gui/util/script/MethodBlock.java
index ef9567779..6158c85ed 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/MethodBlock.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/MethodBlock.java
@@ -11,17 +11,17 @@ public class MethodBlock {
// pattern matches returnType + methodName + parentheses
public static final Pattern METHOD_PATTERN = Pattern.compile(
- "\\b([a-zA-Z_][a-zA-Z0-9_<>\\[\\]]*)\\s+" + // return type
- "([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(" // method name
+ "\\b([a-zA-Z_][a-zA-Z0-9_<>\\[\\]]*)\\s+" + // return type
+ "([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\(" // method name
);
// Pattern for variable declarations (same as in JavaTextContainer)
public static final Pattern LOCAL_VAR_DECL = Pattern.compile(
- "\\b([A-Z][a-zA-Z0-9_<>\\[\\]]*|[a-z][a-zA-Z0-9_]*)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*(=|;)");
-
+ "\\b([A-Z][a-zA-Z0-9_<>\\[\\]]*|[a-z][a-zA-Z0-9_]*)\\s+([a-zA-Z_][a-zA-Z0-9_]*)\\s*(=|;)");
+
// Pattern for method parameters: Type name (with optional ... for varargs)
public static final Pattern PARAMETER_PATTERN = Pattern.compile(
- "([a-zA-Z_][a-zA-Z0-9_<>\\[\\]]*(?:\\.{3})?)\\s+([a-zA-Z_][a-zA-Z0-9_]*)");
+ "([a-zA-Z_][a-zA-Z0-9_<>\\[\\]]*(?:\\.{3})?)\\s+([a-zA-Z_][a-zA-Z0-9_]*)");
public int startOffset;
public int endOffset;
@@ -37,22 +37,22 @@ public class MethodBlock {
extractParameters();
extractLocalVariables();
}
-
+
// Extract method parameters from the method signature
private void extractParameters() {
parameters.clear();
-
+
// Find the parameter list between ( and )
int parenStart = text.indexOf('(');
int parenEnd = text.indexOf(')');
-
+
if (parenStart < 0 || parenEnd <= parenStart) return;
-
+
String paramList = text.substring(parenStart + 1, parenEnd);
-
+
// Skip if empty
if (paramList.trim().isEmpty()) return;
-
+
// Split by comma (but be careful of generic types like List)
Matcher m = PARAMETER_PATTERN.matcher(paramList);
while (m.find()) {
@@ -67,20 +67,20 @@ public class MethodBlock {
private void extractLocalVariables() {
localVariables.clear();
localVarPositions.clear();
-
+
// Get excluded ranges (strings and comments) for this method's text
List excludedRanges = getExcludedRanges(text);
-
+
Matcher m = LOCAL_VAR_DECL.matcher(text);
while (m.find()) {
String varName = m.group(2);
int declPosition = m.start();
-
+
// Skip if inside a string or comment
if (isInExcludedRange(declPosition, excludedRanges)) {
continue;
}
-
+
// Check if this is a "this.field" assignment - if so, skip it
// Look backwards from the declaration position to see if preceded by "this."
boolean isThisFieldAssignment = false;
@@ -91,7 +91,7 @@ public class MethodBlock {
isThisFieldAssignment = true;
}
}
-
+
if (!isThisFieldAssignment && !localVariables.contains(varName)) {
localVariables.add(varName);
// Store the absolute position in the full text (startOffset + relative position)
@@ -99,7 +99,7 @@ public class MethodBlock {
}
}
}
-
+
// Check if a reference position comes before the local variable declaration
// This handles cases like: global.field on line 7, then var global = "x" on line 9
// At line 7, the local 'global' doesn't exist yet, so it should refer to the global 'global'
@@ -129,10 +129,10 @@ public class MethodBlock {
// Matches: returnType methodName(...) { (non-greedy capture until first { )
Pattern methodPattern = Pattern.compile(
- "\\b([a-zA-Z_][a-zA-Z0-9_<>\\[\\]]*)\\s+" + // return type
- "([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\([^)]*\\)\\s*" + // method name + parameters
- "\\{", // opening brace
- Pattern.MULTILINE);
+ "\\b([a-zA-Z_][a-zA-Z0-9_<>\\[\\]]*)\\s+" + // return type
+ "([a-zA-Z_][a-zA-Z0-9_]*)\\s*\\([^)]*\\)\\s*" + // method name + parameters
+ "\\{", // opening brace
+ Pattern.MULTILINE);
Matcher m = methodPattern.matcher(text);
while (m.find()) {
@@ -160,14 +160,14 @@ public class MethodBlock {
Pattern stringPattern = Pattern.compile("([\"'])(?:(?=(\\\\?))\\2.)*?\\1");
Matcher stringMatcher = stringPattern.matcher(text);
while (stringMatcher.find()) {
- ranges.add(new int[] { stringMatcher.start(), stringMatcher.end() });
+ ranges.add(new int[]{stringMatcher.start(), stringMatcher.end()});
}
// Find all comments (block and line comments)
Pattern commentPattern = Pattern.compile("/\\*[\\s\\S]*?(?:\\*/|$)|//.*");
Matcher commentMatcher = commentPattern.matcher(text);
while (commentMatcher.find()) {
- ranges.add(new int[] { commentMatcher.start(), commentMatcher.end() });
+ ranges.add(new int[]{commentMatcher.start(), commentMatcher.end()});
}
if (ranges.isEmpty())
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/PackageFinder.java b/src/main/java/noppes/npcs/client/gui/util/script/PackageFinder.java
index 391ea0e14..5dd70e7ce 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/PackageFinder.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/PackageFinder.java
@@ -7,7 +7,6 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/RenameRefactorHandler.java b/src/main/java/noppes/npcs/client/gui/util/script/RenameRefactorHandler.java
index 4f36da54b..3d5c9909d 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/RenameRefactorHandler.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/RenameRefactorHandler.java
@@ -1,7 +1,6 @@
package noppes.npcs.client.gui.util.script;
import net.minecraft.client.gui.GuiScreen;
-import noppes.npcs.client.ClientProxy;
import noppes.npcs.client.gui.util.script.JavaTextContainer.LineData;
import org.lwjgl.input.Keyboard;
@@ -12,7 +11,7 @@ import java.util.regex.Pattern;
/**
* Handles IntelliJ-like rename refactoring with scope-aware renaming.
- *
+ *
* Features:
* - Scope detection: local variables rename only within their block, global fields rename everywhere
* - Visual feedback: primary occurrence has white border, others just highlighted
@@ -33,7 +32,7 @@ public class RenameRefactorHandler {
private int primaryOccurrenceEnd = -1;
private List allOccurrences = new ArrayList<>();
private ScopeInfo scope = null;
-
+
// For global scope, track positions that have local shadowing (to exclude them)
private List localShadowedPositions = new ArrayList<>();
@@ -141,10 +140,10 @@ public class RenameRefactorHandler {
initialWord = text.substring(wordBounds[0], wordBounds[1]); // Remember for undo
originalWord = initialWord;
currentWord = initialWord;
-
+
// Determine scope for this identifier - MUST check if local shadows global
scope = determineScope(text, wordBounds[0], originalWord, callback.getContainer());
-
+
// If global scope, find all positions where local variables shadow this name
localShadowedPositions.clear();
if (scope != null && scope.isGlobal) {
@@ -158,12 +157,12 @@ public class RenameRefactorHandler {
return false;
active = true;
-
+
// Set selection to full word (uses GuiScriptTextArea's selection)
primaryOccurrenceStart = wordBounds[0];
primaryOccurrenceEnd = wordBounds[1];
callback.getSelectionState().setSelection(wordBounds[0], wordBounds[1]);
- // callback.setCursorPosition(wordBounds[1]);
+ // callback.setCursorPosition(wordBounds[1]);
callback.getSelectionState().markActivity();
return true;
@@ -207,7 +206,7 @@ public class RenameRefactorHandler {
// During live editing we used setTextWithoutUndo to avoid creating intermediate
// undo entries; pushing the original snapshot here gives a single predictable
// undo step back to the pre-rename state.
- if (originalText != null && !originalText.isEmpty())
+ if (originalText != null && !originalText.isEmpty())
callback.pushUndoState(originalText, originalCursorPos);
// Calculate cursor position relative to primary occurrence
@@ -237,6 +236,7 @@ public class RenameRefactorHandler {
/**
* Handle keyboard input during rename
+ *
* @return true if input was consumed
*/
public boolean keyTyped(char c, int keyCode) {
@@ -264,7 +264,7 @@ public class RenameRefactorHandler {
// Get selection state
SelectionState sel = callback.getSelectionState();
boolean hasSelection = sel.hasSelection();
-
+
// Calculate cursor position within the word
int cursorInWord = callback.getCursorPosition() - primaryOccurrenceStart;
cursorInWord = Math.max(0, Math.min(cursorInWord, currentWord.length()));
@@ -315,7 +315,7 @@ public class RenameRefactorHandler {
sel.setSelection(primaryOccurrenceStart, primaryOccurrenceStart);
callback.setCursorPosition(primaryOccurrenceStart);
}
-
+
// Left arrow
if (keyCode == Keyboard.KEY_LEFT) {
if (cursorInWord > 0) {
@@ -354,7 +354,7 @@ public class RenameRefactorHandler {
// Ctrl+A - select all (select the whole word)
if (keyCode == Keyboard.KEY_A &&
- Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
+ Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
sel.setSelection(primaryOccurrenceStart, primaryOccurrenceStart + currentWord.length());
callback.setCursorPosition(primaryOccurrenceStart + currentWord.length());
sel.markActivity();
@@ -537,22 +537,22 @@ public class RenameRefactorHandler {
}
}
}
-
+
/**
* Find all positions where local variables with the same name shadow the global variable.
* This populates localShadowedPositions with ranges where local declarations exist.
*/
private void findLocalShadowedPositions(String text, String varName) {
localShadowedPositions.clear();
-
+
List methods = MethodBlock.collectMethodBlocks(text);
List excluded = MethodBlock.getExcludedRanges(text);
-
+
for (MethodBlock method : methods) {
// Check if this method has a local variable or parameter with the same name
boolean hasLocalDecl = method.localVariables.contains(varName);
boolean hasParamDecl = isParameterInMethod(text, varName, method);
-
+
if (hasLocalDecl || hasParamDecl) {
// Find where the local/param scope starts
int scopeStart;
@@ -564,18 +564,18 @@ public class RenameRefactorHandler {
scopeStart = findLocalDeclarationPosition(text, varName, method);
if (scopeStart < 0) scopeStart = method.startOffset;
}
-
+
// Find all occurrences of varName within this method's shadowed range
Pattern pattern = Pattern.compile("\\b" + Pattern.quote(varName) + "\\b");
Matcher m = pattern.matcher(text);
-
+
while (m.find()) {
int pos = m.start();
-
+
// Skip if in string or comment
if (isInExcludedRange(pos, excluded))
continue;
-
+
// Check if within the shadowed scope of this method
if (pos >= scopeStart && pos < method.endOffset) {
localShadowedPositions.add(new int[]{m.start(), m.end()});
@@ -584,7 +584,7 @@ public class RenameRefactorHandler {
}
}
}
-
+
/**
* Check if a position is within a locally shadowed range
*/
@@ -595,13 +595,13 @@ public class RenameRefactorHandler {
}
return false;
}
-
+
/**
* Check if varName is a parameter in the method
*/
private boolean isParameterInMethod(String text, String varName, MethodBlock method) {
String methodHeader = text.substring(method.startOffset,
- Math.min(method.startOffset + 500, method.endOffset));
+ Math.min(method.startOffset + 500, method.endOffset));
int parenStart = methodHeader.indexOf('(');
int parenEnd = methodHeader.indexOf(')');
if (parenStart >= 0 && parenEnd > parenStart) {
@@ -687,7 +687,7 @@ public class RenameRefactorHandler {
// Cursor is inside a method
// Check if it's a method parameter first
String methodHeader = text.substring(containingMethod.startOffset,
- Math.min(containingMethod.startOffset + 500, containingMethod.endOffset));
+ Math.min(containingMethod.startOffset + 500, containingMethod.endOffset));
int parenStart = methodHeader.indexOf('(');
int parenEnd = methodHeader.indexOf(')');
if (parenStart >= 0 && parenEnd > parenStart) {
@@ -861,9 +861,9 @@ public class RenameRefactorHandler {
public boolean isWordFullySelected() {
if (callback == null) return false;
SelectionState selection = callback.getSelectionState();
- return selection.hasSelection() &&
- selection.getStartSelection() == primaryOccurrenceStart &&
- selection.getEndSelection() == primaryOccurrenceEnd;
+ return selection.hasSelection() &&
+ selection.getStartSelection() == primaryOccurrenceStart &&
+ selection.getEndSelection() == primaryOccurrenceEnd;
}
/**
@@ -884,7 +884,7 @@ public class RenameRefactorHandler {
public boolean handleClick(int clickPosInText) {
if (!active || callback == null)
return false;
-
+
return false;
}
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/ScrollState.java b/src/main/java/noppes/npcs/client/gui/util/script/ScrollState.java
index 2649563ff..4d71a6b62 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/ScrollState.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/ScrollState.java
@@ -21,12 +21,12 @@ public class ScrollState {
private int scrollbarDragOffset = 0;
// Whether currently dragging the scrollbar
private boolean clickScrolling = false;
-
+
// Animation parameters
private static final double TAU = 0.1; // Time constant (~55ms feels snappy)
private static final double SNAP_THRESHOLD = 0.01; // Snap to target when this close
private static final double MAX_DT = 0.05; // Max delta time for stability
-
+
/**
* Reset scroll state to initial values
*/
@@ -37,7 +37,7 @@ public class ScrollState {
scrolledLine = 0;
lastScrollTime = System.currentTimeMillis();
}
-
+
/**
* Initialize scroll position if not already initialized
*/
@@ -47,18 +47,19 @@ public class ScrollState {
lastScrollTime = System.currentTimeMillis();
}
}
-
+
/**
* Update scroll animation. Call once per frame.
+ *
* @param maxScroll Maximum valid scroll position
*/
public void update(int maxScroll) {
long nowMs = System.currentTimeMillis();
double dt = Math.min(MAX_DT, (nowMs - lastScrollTime) / 1000.0);
lastScrollTime = nowMs;
-
+
double dist = targetScroll - scrollPos;
-
+
// Snap to target if close enough
if (Math.abs(dist) < SNAP_THRESHOLD) {
scrollPos = targetScroll;
@@ -69,21 +70,21 @@ public class ScrollState {
double prev = scrollPos;
scrollPos += dist * alpha;
scrollVelocity = (scrollPos - prev) / (dt > 0 ? dt : 1e-6);
-
+
// Clamp overshoot
if ((dist > 0 && scrollPos > targetScroll) || (dist < 0 && scrollPos < targetScroll)) {
scrollPos = targetScroll;
scrollVelocity = 0.0;
}
}
-
+
// Keep in bounds
clampToBounds(maxScroll);
-
+
// Update integer line for rendering
scrolledLine = Math.max(0, Math.min((int) Math.floor(scrollPos), maxScroll));
}
-
+
/**
* Clamp scroll position to valid bounds
*/
@@ -94,35 +95,37 @@ public class ScrollState {
if (targetScroll > maxScroll) targetScroll = maxScroll;
scrolledLine = Math.max(0, Math.min(scrolledLine, maxScroll));
}
-
+
/**
* Apply mouse wheel scroll
+ *
* @param wheelDelta Positive = scroll up, negative = scroll down
- * @param maxScroll Maximum valid scroll position
+ * @param maxScroll Maximum valid scroll position
*/
public void applyWheelScroll(int wheelDelta, int maxScroll) {
double sign = Math.copySign(1, wheelDelta);
targetScroll -= sign * 2.0; // 2 lines per wheel tick
clampToBounds(maxScroll);
}
-
+
/**
* Set target scroll directly (for scrollbar dragging)
*/
public void setTargetScroll(double target, int maxScroll) {
targetScroll = Math.max(0, Math.min(target, maxScroll));
}
-
+
/**
* Scroll to make a specific line visible
- * @param lineIdx Line index to make visible
+ *
+ * @param lineIdx Line index to make visible
* @param visibleLines Number of visible lines in viewport
- * @param maxScroll Maximum scroll position
+ * @param maxScroll Maximum scroll position
*/
public void scrollToLine(int lineIdx, int visibleLines, int maxScroll) {
int firstVisible = scrolledLine;
int lastFullyVisible = scrolledLine + visibleLines;
-
+
if (lineIdx < firstVisible) {
// Line is above viewport - scroll up
targetScroll = lineIdx;
@@ -132,41 +135,66 @@ public class ScrollState {
}
// If line is visible, don't change scroll
}
-
- // Getters
- public double getScrollPos() { return scrollPos; }
- public double getTargetScroll() { return targetScroll; }
- /** @return First visible line **/
+ // Getters
+ public double getScrollPos() {
+ return scrollPos;
+ }
+
+ public double getTargetScroll() {
+ return targetScroll;
+ }
+
+ /**
+ * @return First visible line
+ **/
public int getScrolledLine() {
return scrolledLine;
}
- public double getScrollVelocity() { return scrollVelocity; }
- public boolean isClickScrolling() { return clickScrolling; }
- public int getScrollbarDragOffset() { return scrollbarDragOffset; }
-
+
+ public double getScrollVelocity() {
+ return scrollVelocity;
+ }
+
+ public boolean isClickScrolling() {
+ return clickScrolling;
+ }
+
+ public int getScrollbarDragOffset() {
+ return scrollbarDragOffset;
+ }
+
/**
* Get fractional offset for sub-pixel rendering
*/
public double getFractionalOffset() {
return scrollPos - scrolledLine;
}
-
+
// Setters for scrollbar interaction
- public void setClickScrolling(boolean scrolling) { this.clickScrolling = scrolling; }
- public void setScrollbarDragOffset(int offset) { this.scrollbarDragOffset = offset; }
- public void setScrolledLine(int line) { this.scrolledLine = line; }
+ public void setClickScrolling(boolean scrolling) {
+ this.clickScrolling = scrolling;
+ }
+
+ public void setScrollbarDragOffset(int offset) {
+ this.scrollbarDragOffset = offset;
+ }
+
+ public void setScrolledLine(int line) {
+ this.scrolledLine = line;
+ }
/**
* Handle scrollbar dragging interaction. This encapsulates the logic that was
* previously in the GUI class for handling thumb clicks/drags.
- * @param yMouse current mouse Y coordinate
- * @param areaX GUI area X (unused but kept for parity)
- * @param areaY GUI area Y (top of text area)
- * @param areaHeight height of the scroll track area
+ *
+ * @param yMouse current mouse Y coordinate
+ * @param areaX GUI area X (unused but kept for parity)
+ * @param areaY GUI area Y (top of text area)
+ * @param areaHeight height of the scroll track area
* @param visibleLines number of visible lines in viewport
- * @param linesCount total number of lines
- * @param maxScroll maximum allowed scroll value
+ * @param linesCount total number of lines
+ * @param maxScroll maximum allowed scroll value
*/
public void handleClickScrolling(int yMouse, int areaX, int areaY, int areaHeight, int visibleLines, int linesCount, int maxScroll) {
// Keep dragging while mouse button is down
@@ -210,4 +238,4 @@ public class ScrollState {
int thumbTop = (int) (areaY + 1f * getScrollPos() / linesCountD * (areaHeight - 4)) + 1;
setScrollbarDragOffset(yMouse - thumbTop);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/SearchReplaceBar.java b/src/main/java/noppes/npcs/client/gui/util/script/SearchReplaceBar.java
index ef20e816a..32e835aaf 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/SearchReplaceBar.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/SearchReplaceBar.java
@@ -5,6 +5,7 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.ResourceLocation;
+import noppes.npcs.client.gui.util.GuiScriptTextArea.UndoData;
import noppes.npcs.client.gui.util.GuiUtil;
import noppes.npcs.client.gui.util.key.OverlayKeyPresetViewer;
import noppes.npcs.util.ValueUtil;
@@ -16,8 +17,6 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import noppes.npcs.client.gui.util.GuiScriptTextArea.UndoData;
-
/**
* Search and Replace bar component for the script editor.
* Provides IntelliJ-like search functionality with:
@@ -30,10 +29,10 @@ import noppes.npcs.client.gui.util.GuiScriptTextArea.UndoData;
* - All matches highlighting
*/
public class SearchReplaceBar {
-
+
// ==================== TEXTURE ====================
public static final ResourceLocation TEXTURE = OverlayKeyPresetViewer.TEXTURE;
-
+
// ==================== DIMENSIONS ====================
private int x, y, width;
private int barHeight = 24;
@@ -43,17 +42,17 @@ public class SearchReplaceBar {
private int buttonSize = 16;
private int buttonSpacing = 2;
private int padding = 4;
-
+
// ==================== STATE ====================
private boolean visible = false;
private boolean showReplace = false;
private boolean searchFieldFocused = true;
private boolean replaceFieldFocused = false;
-
+
// ==================== SEARCH OPTIONS ====================
private boolean matchCase = false;
private boolean wholeWord = false;
-
+
// ==================== TEXT FIELDS ====================
private String searchText = "";
private String replaceText = "";
@@ -66,18 +65,18 @@ public class SearchReplaceBar {
// Text scroll offsets for when text exceeds field width
private int searchScrollOffset = 0;
private int replaceScrollOffset = 0;
-
+
// ==================== UNDO/REDO ====================
private List searchUndoList = new ArrayList<>();
private List searchRedoList = new ArrayList<>();
private List replaceUndoList = new ArrayList<>();
private List replaceRedoList = new ArrayList<>();
-
+
// ==================== MATCHES ====================
private List matches = new ArrayList<>();
private int currentMatchIndex = -1;
private List excludedMatches = new ArrayList<>();
-
+
// ==================== HOVER STATE ====================
private boolean hoverClose = false;
private boolean hoverSearchUnwind = false;
@@ -88,21 +87,21 @@ public class SearchReplaceBar {
private boolean hoverReplace = false;
private boolean hoverReplaceAll = false;
private boolean hoverExclude = false;
-
+
// ==================== CURSOR BLINK ====================
private int cursorCounter = 0;
private long lastInputTime = 0; // For cursor blink pause on activity
-
+
// ==================== DOUBLE/TRIPLE CLICK ====================
private long lastClickTime = 0;
private int clickCount = 0;
private boolean lastClickWasSearch = true;
-
+
// ==================== CALLBACK ====================
public SearchCallback callback;
-
+
private final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
-
+
/**
* Callback interface for search/replace operations
*/
@@ -115,24 +114,31 @@ public class SearchReplaceBar {
int getSelectionStart();
int getSelectionEnd();
+
void setText(String text);
+
void scrollToPosition(int position);
+
void setSelection(int start, int end);
+
int getGutterWidth();
+
void unfocusMainEditor();
+
void focusMainEditor();
+
void onMatchesUpdated(); // Called when matches change (for undo/redo sync)
void resizeEditor(boolean open, int barHeight);
}
-
+
public SearchReplaceBar() {
}
-
+
public void setCallback(SearchCallback callback) {
this.callback = callback;
}
-
+
/**
* Initialize bar position based on text area bounds.
* Preserves existing state (search text, matches, etc.) across initGui calls.
@@ -149,8 +155,8 @@ public class SearchReplaceBar {
boolean matchHighlight = false;
visible = true;
if (callback != null) {
- // Always notify callback that the search UI is open and provide its current height.
- callback.resizeEditor(true, getTotalHeight());
+ // Always notify callback that the search UI is open and provide its current height.
+ callback.resizeEditor(true, getTotalHeight());
callback.unfocusMainEditor();
String highlight = callback.getHighlightedWord();
@@ -179,9 +185,9 @@ public class SearchReplaceBar {
searchFieldFocused = true;
replaceFieldFocused = false;
open();
-
+
}
-
+
/**
* Open search+replace bar (Ctrl+Shift+R)
*/
@@ -191,7 +197,7 @@ public class SearchReplaceBar {
replaceFieldFocused = true;
open();
}
-
+
/**
* Close the search bar and restore focus to main editor
*/
@@ -212,6 +218,7 @@ public class SearchReplaceBar {
else
searchFieldFocused = true;
}
+
/**
* Unfocus the search bar (when clicking main editor)
*/
@@ -219,7 +226,7 @@ public class SearchReplaceBar {
searchFieldFocused = false;
replaceFieldFocused = false;
}
-
+
/**
* Save current state to undo list before making changes
*/
@@ -232,7 +239,7 @@ public class SearchReplaceBar {
replaceRedoList.clear();
}
}
-
+
/**
* Undo last change in focused field
*/
@@ -256,7 +263,7 @@ public class SearchReplaceBar {
updateScrollOffset(false);
}
}
-
+
/**
* Redo last undone change in focused field
*/
@@ -280,7 +287,7 @@ public class SearchReplaceBar {
updateScrollOffset(false);
}
}
-
+
/**
* Update scroll offset for text field to keep cursor visible
*/
@@ -298,14 +305,14 @@ public class SearchReplaceBar {
} else if (cursor < scrollOffset) {
scrollOffset = cursor;
}
-
+
if (isSearchField) {
searchScrollOffset = scrollOffset;
} else {
replaceScrollOffset = scrollOffset;
}
}
-
+
/**
* Toggle visibility
*/
@@ -316,7 +323,7 @@ public class SearchReplaceBar {
openSearch();
}
}
-
+
/**
* Toggle replace mode
*/
@@ -327,23 +334,23 @@ public class SearchReplaceBar {
openSearchReplace();
}
}
-
+
public boolean isVisible() {
return visible;
}
-
+
public boolean isSearchFocused() {
return visible && searchFieldFocused;
}
-
+
public boolean isReplaceFocused() {
return visible && replaceFieldFocused;
}
-
+
public boolean hasFocus() {
return visible && (searchFieldFocused || replaceFieldFocused);
}
-
+
/**
* Get total height of the bar (for viewport offset)
*/
@@ -351,143 +358,143 @@ public class SearchReplaceBar {
if (!visible) return 0;
return showReplace ? barHeight + replaceBarHeight : barHeight;
}
-
+
/**
* Get all current matches for highlighting
*/
public List getMatches() {
return matches;
}
-
+
/**
* Get current match index
*/
public int getCurrentMatchIndex() {
return currentMatchIndex;
}
-
+
/**
* Check if a match is excluded
*/
public boolean isMatchExcluded(int index) {
return excludedMatches.contains(index);
}
-
+
/**
* Update cursor blink counter
*/
public void updateCursor() {
cursorCounter++;
}
-
+
/**
* Mark activity to pause cursor blinking
*/
private void markActivity() {
lastInputTime = System.currentTimeMillis();
}
-
+
/**
* Check if there was recent input (cursor stays visible during typing)
*/
private boolean hadRecentInput() {
return System.currentTimeMillis() - lastInputTime < 500;
}
-
+
/**
* Check if cursor should be visible (solid during typing, blinking otherwise)
*/
private boolean shouldShowCursor() {
return hadRecentInput() || (cursorCounter / 10) % 2 == 0;
}
-
+
// ==================== DRAWING ====================
-
+
/**
* Draw the search/replace bar
*/
public void draw(int mouseX, int mouseY) {
if (!visible) return;
-
+
updateHoverStates(mouseX, mouseY);
-
+
int totalHeight = getTotalHeight();
Gui.drawRect(x, y, x + width, y + totalHeight, 0xFF2d2d30);
Gui.drawRect(x, y + totalHeight - 1, x + width, y + totalHeight, 0xFF414141);
-
+
drawSearchRow(mouseX, mouseY);
-
+
if (showReplace) {
drawReplaceRow(mouseX, mouseY);
}
}
-
+
private void drawSearchRow(int mouseX, int mouseY) {
int rowY = y + padding;
int currentX = x + padding;
- textFieldWidth=100;
- drawTextField(currentX, rowY, textFieldWidth, textFieldHeight,
- searchText, searchCursor, searchSelectionStart, searchSelectionEnd,
- searchFieldFocused, "Search...", searchScrollOffset, true);
+ textFieldWidth = 100;
+ drawTextField(currentX, rowY, textFieldWidth, textFieldHeight,
+ searchText, searchCursor, searchSelectionStart, searchSelectionEnd,
+ searchFieldFocused, "Search...", searchScrollOffset, true);
currentX += textFieldWidth + buttonSpacing + 4;
-
+
// "0 results" in red, otherwise "X/Y" in normal color
- String matchInfo = matches.isEmpty() ? "0 results" :
- (currentMatchIndex + 1) + "/" + matches.size();
+ String matchInfo = matches.isEmpty() ? "0 results" :
+ (currentMatchIndex + 1) + "/" + matches.size();
int matchInfoWidth = font.getStringWidth(matchInfo);
font.drawString(matchInfo, currentX, rowY + 4,
- matches.isEmpty() && !searchText.isEmpty() ? 0xFFff6666 : 0xFFcccccc);
+ matches.isEmpty() && !searchText.isEmpty() ? 0xFFff6666 : 0xFFcccccc);
currentX += matchInfoWidth + 8;
drawToggleButton(currentX, rowY, "Cc", matchCase, hoverMatchCase, "Match Case");
currentX += buttonSize + buttonSpacing;
-
+
drawToggleButton(currentX, rowY, "W", wholeWord, hoverWholeWord, "Whole Word");
currentX += buttonSize + buttonSpacing + 4;
-
+
boolean prevEnabled = !matches.isEmpty();
drawNavButton(currentX, rowY, "▲", prevEnabled, hoverPrev);
currentX += buttonSize + buttonSpacing;
-
+
boolean nextEnabled = !matches.isEmpty();
drawNavButton(currentX, rowY, "▼", nextEnabled, hoverNext);
currentX += buttonSize + buttonSpacing;
-
+
int closeX = x + width - buttonSize - padding;
drawCloseButton(closeX, rowY, hoverClose);
int replaceUnwindButton = closeX - buttonSize - buttonSpacing;
drawActionButton(replaceUnwindButton, rowY, showReplace ? "▼" : "◀", hoverSearchUnwind, true);
}
-
+
private void drawReplaceRow(int mouseX, int mouseY) {
int rowY = y + barHeight + 2;
int currentX = x + padding;
drawTextField(currentX, rowY, textFieldWidth, textFieldHeight,
- replaceText, replaceCursor, replaceSelectionStart, replaceSelectionEnd,
- replaceFieldFocused, "Replace...", replaceScrollOffset, false);
+ replaceText, replaceCursor, replaceSelectionStart, replaceSelectionEnd,
+ replaceFieldFocused, "Replace...", replaceScrollOffset, false);
currentX += textFieldWidth + buttonSpacing + 4;
-
+
drawActionButton(currentX, rowY, "Replace", hoverReplace, !matches.isEmpty());
currentX += font.getStringWidth("Replace") + 12 + buttonSpacing;
-
+
drawActionButton(currentX, rowY, "Replace All", hoverReplaceAll, !matches.isEmpty());
currentX += font.getStringWidth("Replace All") + 12 + buttonSpacing;
-
+
drawActionButton(currentX, rowY, "Exclude", hoverExclude, currentMatchIndex >= 0);
}
private void drawTextField(int fieldX, int fieldY, int fieldWidth, int fieldHeight,
- String text, int cursor, int selStart, int selEnd,
- boolean focused, String placeholder, int scrollOffset, boolean isSearchField) {
+ String text, int cursor, int selStart, int selEnd,
+ boolean focused, String placeholder, int scrollOffset, boolean isSearchField) {
// Draw text field background
Gui.drawRect(fieldX, fieldY, fieldX + fieldWidth, fieldY + fieldHeight, 0xFF1e1e1e);
Gui.drawRect(fieldX, fieldY, fieldX + fieldWidth, fieldY + 1, focused ? 0xFF007acc : 0xFF3c3c3c);
Gui.drawRect(fieldX, fieldY + fieldHeight - 1, fieldX + fieldWidth, fieldY + fieldHeight,
- focused ? 0xFF007acc : 0xFF3c3c3c);
+ focused ? 0xFF007acc : 0xFF3c3c3c);
Gui.drawRect(fieldX, fieldY, fieldX + 1, fieldY + fieldHeight, focused ? 0xFF007acc : 0xFF3c3c3c);
Gui.drawRect(fieldX + fieldWidth - 1, fieldY, fieldX + fieldWidth, fieldY + fieldHeight,
- focused ? 0xFF007acc : 0xFF3c3c3c);
+ focused ? 0xFF007acc : 0xFF3c3c3c);
// Calculate visible area
int textX = fieldX + 4;
@@ -511,7 +518,7 @@ public class SearchReplaceBar {
int maxSel = Math.max(adjustedSelStart, adjustedSelEnd);
String beforeSel = visibleText.substring(0, Math.min(minSel, visibleText.length()));
String inSel = visibleText.substring(Math.min(minSel, visibleText.length()),
- Math.min(maxSel, visibleText.length()));
+ Math.min(maxSel, visibleText.length()));
int selX = textX + font.getStringWidth(beforeSel);
int selW = font.getStringWidth(inSel);
Gui.drawRect(selX, textY - 1, selX + selW, textY + 9, 0xFF264f78);
@@ -537,7 +544,7 @@ public class SearchReplaceBar {
// Draw selection highlight
if (selStart != selEnd && focused) {
int startX = textX + font.getStringWidth(
- text.substring(0, Math.min(selStart, text.length()))) - scrollOffset;
+ text.substring(0, Math.min(selStart, text.length()))) - scrollOffset;
int endX = textX + font.getStringWidth(text.substring(0, Math.min(selEnd, text.length()))) - scrollOffset;
Gui.drawRect(startX, textY - 1, endX, textY + font.FONT_HEIGHT, 0xFF2d5ca6);
}
@@ -555,21 +562,21 @@ public class SearchReplaceBar {
int cursorDrawX = textX + cursorPosX - scrollOffset;
Gui.drawRect(cursorDrawX, textY - 1, cursorDrawX + 1, textY + font.FONT_HEIGHT, 0xFFffffff);
}
-
+
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
-
+
private void oldDrawTextField(int fieldX, int fieldY, int fieldWidth, int fieldHeight,
- String text, int cursor, int selStart, int selEnd,
- boolean focused, String placeholder, int scrollOffset, boolean isSearchField) {
+ String text, int cursor, int selStart, int selEnd,
+ boolean focused, String placeholder, int scrollOffset, boolean isSearchField) {
Minecraft.getMinecraft().getTextureManager().bindTexture(TEXTURE);
GL11.glPushMatrix();
GL11.glColor4f(1, 1, 1, 1);
float boxScaleX = fieldWidth / 32f, boxScaleY = 1.5f;
GL11.glScalef(boxScaleX, boxScaleY, 1);
-
+
if (focused) {
GL11.glColor4f(0.28f, 0.45f, 0.7f, 1f);
} else {
@@ -577,11 +584,11 @@ public class SearchReplaceBar {
}
GuiUtil.drawTexturedModalRect(fieldX / boxScaleX, (fieldY - 16) / boxScaleY, 32, 20, 0, 492);
GL11.glPopMatrix();
-
+
int textX = fieldX + 4;
int textY = fieldY + (fieldHeight - font.FONT_HEIGHT) / 2;
int visibleWidth = fieldWidth - 8;
-
+
// Calculate scroll offset to keep cursor visible
int cursorPosX = font.getStringWidth(text.substring(0, Math.min(cursor, text.length())));
if (cursorPosX - scrollOffset > visibleWidth - 2) {
@@ -595,7 +602,7 @@ public class SearchReplaceBar {
} else {
replaceScrollOffset = scrollOffset;
}
-
+
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GuiUtil.setScissorClip(fieldX + 2, fieldY, fieldWidth - 4, fieldHeight);
@@ -606,7 +613,7 @@ public class SearchReplaceBar {
int endX = textX + font.getStringWidth(text.substring(0, Math.min(selEnd, text.length()))) - scrollOffset;
Gui.drawRect(startX, textY - 1, endX, textY + font.FONT_HEIGHT, 0xFF2d5ca6);
}
-
+
// Draw text with scroll offset
boolean noMatches = !text.isEmpty() && matches.isEmpty();
int col = text.isEmpty() ? 0xFFa0a0a0 : 0xFFe0e0e0;
@@ -614,28 +621,28 @@ public class SearchReplaceBar {
col = 0xFFff6666; // Red
font.drawString(text.isEmpty() ? placeholder : text, textX - scrollOffset, textY, col);
-
+
// Draw cursor (stays visible during typing)
if (focused && shouldShowCursor()) {
int cursorDrawX = textX + cursorPosX - scrollOffset;
Gui.drawRect(cursorDrawX, textY - 1, cursorDrawX + 1, textY + font.FONT_HEIGHT, 0xFFffffff);
}
}
-
+
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
-
+
private void drawToggleButton(int btnX, int btnY, String label, boolean active, boolean hovered, String tooltip) {
int bgColor = active ? 0xFF4a6da7 : (hovered ? 0xFF505050 : 0xFF3c3c3c);
Gui.drawRect(btnX, btnY, btnX + buttonSize, btnY + buttonSize, bgColor);
Gui.drawRect(btnX, btnY, btnX + buttonSize, btnY + 1, 0xFF606060);
Gui.drawRect(btnX, btnY + buttonSize - 1, btnX + buttonSize, btnY + buttonSize, 0xFF2a2a2a);
-
+
int textColor = active ? 0xFFffffff : (hovered ? 0xFFcccccc : 0xFF999999);
int labelWidth = font.getStringWidth(label);
font.drawString(label, btnX + (buttonSize - labelWidth) / 2, btnY + (buttonSize - font.FONT_HEIGHT) / 2 + 1, textColor);
}
-
+
private void drawNavButton(int btnX, int btnY, String arrow, boolean enabled, boolean hovered) {
int bgColor = !enabled ? 0xFF393939 : (hovered ? 0xFF505050 : 0xFF3c3c3c);
Gui.drawRect(btnX, btnY, btnX + buttonSize, btnY + buttonSize, bgColor);
@@ -646,57 +653,57 @@ public class SearchReplaceBar {
int arrowWidth = font.getStringWidth(arrow);
font.drawString(arrow, btnX + (buttonSize - arrowWidth) / 2, btnY + (buttonSize - font.FONT_HEIGHT) / 2, textColor);
}
-
+
private void drawCloseButton(int btnX, int btnY, boolean hovered) {
int bgColor = hovered ? 0xFFc75050 : 0xFF3c3c3c;
Gui.drawRect(btnX, btnY, btnX + buttonSize, btnY + buttonSize, bgColor);
-
+
int textColor = hovered ? 0xFFffffff : 0xFFaaaaaa;
String xChar = "X";
int xWidth = font.getStringWidth(xChar);
font.drawString(xChar, btnX + (buttonSize - xWidth) / 2, btnY + (buttonSize - font.FONT_HEIGHT) / 2 + 1, textColor);
}
-
+
private void drawActionButton(int btnX, int btnY, String label, boolean hovered, boolean enabled) {
int btnWidth = font.getStringWidth(label) + 10;
int btnHeight = 14;
-
+
int bgColor = !enabled ? 0xFF393939 : (hovered ? 0xFF505050 : 0xFF3c3c3c);
Gui.drawRect(btnX, btnY + 1, btnX + btnWidth, btnY + btnHeight + 1, bgColor);
Gui.drawRect(btnX, btnY + 1, btnX + btnWidth, btnY + 2, 0xFF555555);
Gui.drawRect(btnX, btnY + btnHeight, btnX + btnWidth, btnY + btnHeight + 1, 0xFF2a2a2a);
-
+
int textColor = !enabled ? 0xFF555555 : (hovered ? 0xFFffffff : 0xFFaaaaaa);
font.drawString(label, btnX + 5, btnY + (btnHeight - font.FONT_HEIGHT) / 2 + 2, textColor);
}
-
+
// ==================== HOVER DETECTION ====================
-
+
private void updateHoverStates(int mouseX, int mouseY) {
int rowY = y + padding;
int currentX = x + padding;
-
+
int searchFieldEndX = currentX + textFieldWidth;
currentX = searchFieldEndX + buttonSpacing + 4;
-
+
String matchInfo = matches.isEmpty() ? "0 results" : (currentMatchIndex + 1) + "/" + matches.size();
currentX += font.getStringWidth(matchInfo) + 8;
-
+
int matchCaseX = currentX;
hoverMatchCase = isMouseOver(mouseX, mouseY, matchCaseX, rowY, buttonSize, buttonSize);
currentX += buttonSize + buttonSpacing;
-
+
int wholeWordX = currentX;
hoverWholeWord = isMouseOver(mouseX, mouseY, wholeWordX, rowY, buttonSize, buttonSize);
currentX += buttonSize + buttonSpacing + 4;
-
+
int prevX = currentX;
hoverPrev = isMouseOver(mouseX, mouseY, prevX, rowY, buttonSize, buttonSize);
currentX += buttonSize + buttonSpacing;
-
+
int nextX = currentX;
hoverNext = isMouseOver(mouseX, mouseY, nextX, rowY, buttonSize, buttonSize);
-
+
int closeX = x + width - buttonSize - padding;
hoverClose = isMouseOver(mouseX, mouseY, closeX, rowY, buttonSize, buttonSize);
@@ -706,50 +713,51 @@ public class SearchReplaceBar {
if (showReplace) {
int replaceRowY = y + barHeight + 2;
currentX = x + padding + textFieldWidth + buttonSpacing + 4;
-
+
int replaceWidth = font.getStringWidth("Replace") + 12;
hoverReplace = isMouseOver(mouseX, mouseY, currentX, replaceRowY + 1, replaceWidth, 14);
currentX += replaceWidth + buttonSpacing;
-
+
int replaceAllWidth = font.getStringWidth("Replace All") + 12;
hoverReplaceAll = isMouseOver(mouseX, mouseY, currentX, replaceRowY + 1, replaceAllWidth, 14);
currentX += replaceAllWidth + buttonSpacing;
-
+
int excludeWidth = font.getStringWidth("Exclude") + 12;
hoverExclude = isMouseOver(mouseX, mouseY, currentX, replaceRowY + 1, excludeWidth, 14);
} else {
hoverReplace = hoverReplaceAll = hoverExclude = false;
}
}
-
+
private boolean isMouseOver(int mouseX, int mouseY, int bx, int by, int bw, int bh) {
return mouseX >= bx && mouseX < bx + bw && mouseY >= by && mouseY < by + bh;
}
-
+
public void resetSelection() {
searchSelectionStart = searchSelectionEnd = searchCursor;
replaceSelectionStart = replaceSelectionEnd = replaceCursor;
}
// ==================== MOUSE INPUT ====================
-
+
/**
* Handle mouse click - supports double-click for word selection, triple-click for all
+ *
* @return true if click was consumed
*/
public boolean mouseClicked(int mouseX, int mouseY, int button) {
if (!visible) return false;
if (button != 0) return false; // Only handle left clicks
-
+
int totalHeight = getTotalHeight();
// If click is outside the bar, don't consume it (let main editor handle)
if (mouseX < x || mouseX > x + width || mouseY < y || mouseY > y + totalHeight) {
resetSelection();
return false;
}
-
+
int rowY = y + padding;
int currentX = x + padding;
-
+
// Handle click timing for double/triple click
long now = System.currentTimeMillis();
boolean isSearchFieldClick = isMouseOver(mouseX, mouseY, currentX, rowY - 2, textFieldWidth, textFieldHeight + 4);
@@ -766,11 +774,11 @@ public class SearchReplaceBar {
}
lastClickTime = now;
lastClickWasSearch = true;
-
+
searchFieldFocused = true;
replaceFieldFocused = false;
markActivity();
-
+
if (clickCount == 1) {
// Single click - position cursor
int clickX = mouseX - currentX - 4 + searchScrollOffset;
@@ -789,35 +797,35 @@ public class SearchReplaceBar {
return true;
}
currentX += textFieldWidth + buttonSpacing + 4;
-
+
String matchInfo = matches.isEmpty() ? "0 results" : (currentMatchIndex + 1) + "/" + matches.size();
currentX += font.getStringWidth(matchInfo) + 8;
-
+
if (hoverMatchCase) {
matchCase = !matchCase;
updateMatches();
return true;
}
currentX += buttonSize + buttonSpacing;
-
+
if (hoverWholeWord) {
wholeWord = !wholeWord;
updateMatches();
return true;
}
currentX += buttonSize + buttonSpacing + 4;
-
+
if (hoverPrev && !matches.isEmpty()) {
goToPreviousMatch();
return true;
}
currentX += buttonSize + buttonSpacing;
-
+
if (hoverNext && !matches.isEmpty()) {
goToNextMatch();
return true;
}
-
+
if (hoverClose) {
close();
return true;
@@ -830,7 +838,7 @@ public class SearchReplaceBar {
if (showReplace) {
int replaceRowY = y + barHeight + 2;
-
+
if (isReplaceFieldClick || isMouseOver(mouseX, mouseY, x + padding, replaceRowY - 2, textFieldWidth, textFieldHeight + 4)) {
// Handle click timing for replace field
boolean sameField = !lastClickWasSearch;
@@ -841,11 +849,11 @@ public class SearchReplaceBar {
}
lastClickTime = now;
lastClickWasSearch = false;
-
+
searchFieldFocused = false;
replaceFieldFocused = true;
markActivity();
-
+
if (clickCount == 1) {
int clickX = mouseX - x - padding - 4 + replaceScrollOffset;
replaceCursor = getTextCursorPosition(replaceText, clickX);
@@ -860,30 +868,30 @@ public class SearchReplaceBar {
}
return true;
}
-
+
if (hoverReplace && !matches.isEmpty()) {
replaceCurrent();
return true;
}
-
+
if (hoverReplaceAll && !matches.isEmpty()) {
replaceAll();
return true;
}
-
+
if (hoverExclude && currentMatchIndex >= 0) {
excludeCurrentMatch();
return true;
}
}
-
+
// Click was within bar bounds but not on any control - consume it to prevent MTA from getting focus
return true;
}
-
+
private int getTextCursorPosition(String text, int clickX) {
if (text.isEmpty() || clickX <= 0) return 0;
-
+
for (int i = 1; i <= text.length(); i++) {
int w = font.getStringWidth(text.substring(0, i));
if (clickX < w) {
@@ -893,17 +901,17 @@ public class SearchReplaceBar {
}
return text.length();
}
-
+
/**
* Select word at cursor position (for double-click)
*/
private void selectWordAt(String text, int pos, boolean isSearchField) {
if (text.isEmpty()) return;
-
+
// Find word boundaries
int start = pos;
int end = pos;
-
+
// Expand left
while (start > 0 && isWordChar(text.charAt(start - 1))) {
start--;
@@ -912,7 +920,7 @@ public class SearchReplaceBar {
while (end < text.length() && isWordChar(text.charAt(end))) {
end++;
}
-
+
if (isSearchField) {
searchSelectionStart = start;
searchSelectionEnd = end;
@@ -923,15 +931,16 @@ public class SearchReplaceBar {
replaceCursor = end;
}
}
-
+
private boolean isWordChar(char c) {
return Character.isLetterOrDigit(c) || c == '_';
}
-
+
// ==================== KEYBOARD INPUT ====================
-
+
/**
* Handle keyboard input
+ *
* @return true if input was consumed
*/
public boolean keyTyped(char c, int keyCode) {
@@ -941,12 +950,12 @@ public class SearchReplaceBar {
}
if (!visible || (!searchFieldFocused && !replaceFieldFocused)) return false;
-
+
// Check modifier keys - don't let them trigger first-match issue
boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
boolean alt = Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU);
-
+
// Ignore lone modifier key presses
if (keyCode == Keyboard.KEY_LCONTROL || keyCode == Keyboard.KEY_RCONTROL ||
keyCode == Keyboard.KEY_LSHIFT || keyCode == Keyboard.KEY_RSHIFT ||
@@ -965,7 +974,7 @@ public class SearchReplaceBar {
markActivity();
return true;
}
-
+
// Enter/Shift+Enter for next/previous match
if (keyCode == Keyboard.KEY_RETURN) {
if (shift) {
@@ -980,7 +989,7 @@ public class SearchReplaceBar {
}
return true;
}
-
+
// Up/Down arrows cycle through matches when SRB is focused
if (keyCode == Keyboard.KEY_UP && !matches.isEmpty()) {
goToPreviousMatch();
@@ -990,38 +999,36 @@ public class SearchReplaceBar {
goToNextMatch();
return true;
}
-
+
if (searchFieldFocused) {
handleTextFieldInput(c, keyCode, true);
} else if (replaceFieldFocused) {
handleTextFieldInput(c, keyCode, false);
}
-
+
return true;
}
-
+
private void handleTextFieldInput(char c, int keyCode, boolean isSearchField) {
String text = isSearchField ? searchText : replaceText;
int cursor = isSearchField ? searchCursor : replaceCursor;
int selStart = isSearchField ? searchSelectionStart : replaceSelectionStart;
int selEnd = isSearchField ? searchSelectionEnd : replaceSelectionEnd;
-
+
boolean hasSelection = selStart != selEnd;
boolean ctrl = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
boolean shift = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
-
+
if (ctrl && keyCode == Keyboard.KEY_A) {
selStart = 0;
selEnd = text.length();
cursor = text.length();
- }
- else if (ctrl && keyCode == Keyboard.KEY_C) {
+ } else if (ctrl && keyCode == Keyboard.KEY_C) {
if (hasSelection) {
String selected = text.substring(Math.min(selStart, selEnd), Math.max(selStart, selEnd));
setClipboard(selected);
}
- }
- else if (ctrl && keyCode == Keyboard.KEY_X) {
+ } else if (ctrl && keyCode == Keyboard.KEY_X) {
if (hasSelection) {
String selected = text.substring(Math.min(selStart, selEnd), Math.max(selStart, selEnd));
setClipboard(selected);
@@ -1030,8 +1037,7 @@ public class SearchReplaceBar {
cursor = Math.min(selStart, selEnd);
selStart = selEnd = cursor;
}
- }
- else if (ctrl && keyCode == Keyboard.KEY_V) {
+ } else if (ctrl && keyCode == Keyboard.KEY_V) {
String clipboard = getClipboard();
if (clipboard != null) {
clipboard = clipboard.replace("\n", "").replace("\r", "");
@@ -1045,8 +1051,7 @@ public class SearchReplaceBar {
}
selStart = selEnd = cursor;
}
- }
- else if (keyCode == Keyboard.KEY_BACK) {
+ } else if (keyCode == Keyboard.KEY_BACK) {
saveState(isSearchField);
if (hasSelection) {
text = text.substring(0, Math.min(selStart, selEnd)) + text.substring(Math.max(selStart, selEnd));
@@ -1056,8 +1061,7 @@ public class SearchReplaceBar {
cursor--;
}
selStart = selEnd = cursor;
- }
- else if (keyCode == Keyboard.KEY_DELETE) {
+ } else if (keyCode == Keyboard.KEY_DELETE) {
saveState(isSearchField);
if (hasSelection) {
text = text.substring(0, Math.min(selStart, selEnd)) + text.substring(Math.max(selStart, selEnd));
@@ -1066,8 +1070,7 @@ public class SearchReplaceBar {
text = text.substring(0, cursor) + text.substring(cursor + 1);
}
selStart = selEnd = cursor;
- }
- else if (keyCode == Keyboard.KEY_LEFT) {
+ } else if (keyCode == Keyboard.KEY_LEFT) {
if (shift) {
if (cursor > 0) {
cursor--;
@@ -1088,8 +1091,7 @@ public class SearchReplaceBar {
}
selStart = selEnd = cursor;
}
- }
- else if (keyCode == Keyboard.KEY_RIGHT) {
+ } else if (keyCode == Keyboard.KEY_RIGHT) {
if (shift) {
if (cursor < text.length()) {
cursor++;
@@ -1110,8 +1112,7 @@ public class SearchReplaceBar {
}
selStart = selEnd = cursor;
}
- }
- else if (keyCode == Keyboard.KEY_HOME) {
+ } else if (keyCode == Keyboard.KEY_HOME) {
if (shift) {
selEnd = selStart == selEnd ? cursor : selEnd;
selStart = 0;
@@ -1119,8 +1120,7 @@ public class SearchReplaceBar {
selStart = selEnd = 0;
}
cursor = 0;
- }
- else if (keyCode == Keyboard.KEY_END) {
+ } else if (keyCode == Keyboard.KEY_END) {
if (shift) {
selStart = selStart == selEnd ? cursor : selStart;
selEnd = text.length();
@@ -1128,8 +1128,7 @@ public class SearchReplaceBar {
selStart = selEnd = text.length();
}
cursor = text.length();
- }
- else if (ChatAllowedCharacters.isAllowedCharacter(c)) {
+ } else if (ChatAllowedCharacters.isAllowedCharacter(c)) {
saveState(isSearchField);
if (hasSelection) {
text = text.substring(0, Math.min(selStart, selEnd)) + c + text.substring(Math.max(selStart, selEnd));
@@ -1140,16 +1139,16 @@ public class SearchReplaceBar {
}
selStart = selEnd = cursor;
}
-
+
if (selStart > selEnd) {
int temp = selStart;
selStart = selEnd;
selEnd = temp;
}
-
+
// Mark activity on any input to keep cursor visible
markActivity();
-
+
if (isSearchField) {
searchText = text;
searchCursor = cursor;
@@ -1163,14 +1162,15 @@ public class SearchReplaceBar {
replaceSelectionEnd = selEnd;
}
}
-
+
private void setClipboard(String text) {
try {
java.awt.datatransfer.StringSelection selection = new java.awt.datatransfer.StringSelection(text);
java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, null);
- } catch (Exception ignored) {}
+ } catch (Exception ignored) {
+ }
}
-
+
private String getClipboard() {
try {
return (String) java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().getData(java.awt.datatransfer.DataFlavor.stringFlavor);
@@ -1178,53 +1178,53 @@ public class SearchReplaceBar {
return null;
}
}
-
+
// ==================== SEARCH LOGIC ====================
-
+
/**
* Update matches based on current search text and options
*/
public void updateMatches() {
matches.clear();
excludedMatches.clear();
-
+
if (callback == null || searchText.isEmpty()) {
if (callback != null) callback.onMatchesUpdated();
return;
}
-
+
String sourceText = callback.getText();
if (sourceText == null || sourceText.isEmpty()) {
callback.onMatchesUpdated();
return;
}
-
+
String searchPattern = searchText;
-
+
if (wholeWord) {
searchPattern = "\\b" + Pattern.quote(searchPattern) + "\\b";
} else {
searchPattern = Pattern.quote(searchPattern);
}
-
+
int flags = matchCase ? 0 : Pattern.CASE_INSENSITIVE;
-
+
try {
Pattern pattern = Pattern.compile(searchPattern, flags);
Matcher matcher = pattern.matcher(sourceText);
-
+
while (matcher.find()) {
matches.add(new int[]{matcher.start(), matcher.end()});
}
} catch (Exception ignored) {
}
-
+
// No need to navigate right now
if (!matches.isEmpty()) {
// currentMatchIndex = 0;
// navigateToCurrentMatch();
}
-
+
currentMatchIndex = ValueUtil.clamp(currentMatchIndex, 0, matches.size() - 1);
callback.onMatchesUpdated();
}
@@ -1251,7 +1251,7 @@ public class SearchReplaceBar {
} catch (Exception ignored) {
}
}
-
+
/**
* Navigate to next match
*/
@@ -1263,7 +1263,7 @@ public class SearchReplaceBar {
navigateToCurrentMatch();
}
-
+
/**
* Navigate to previous match
*/
@@ -1275,20 +1275,20 @@ public class SearchReplaceBar {
navigateToCurrentMatch();
}
-
+
/**
* Navigate viewport to current match and select it
*/
private void navigateToCurrentMatch() {
if (callback == null || currentMatchIndex < 0 || currentMatchIndex >= matches.size()) return;
-
+
int[] match = matches.get(currentMatchIndex);
callback.scrollToPosition(match[0]);
callback.setSelection(match[0], match[1]);
}
-
+
// ==================== REPLACE LOGIC ====================
-
+
/**
* Replace current match
*/
@@ -1298,15 +1298,15 @@ public class SearchReplaceBar {
goToNextMatch();
return;
}
-
+
String sourceText = callback.getText();
int[] match = matches.get(currentMatchIndex);
-
+
String newText = sourceText.substring(0, match[0]) + replaceText + sourceText.substring(match[1]);
callback.setText(newText);
-
+
updateMatches();
-
+
if (!matches.isEmpty()) {
int replacementEnd = match[0] + replaceText.length();
for (int i = 0; i < matches.size(); i++) {
@@ -1318,17 +1318,17 @@ public class SearchReplaceBar {
navigateToCurrentMatch();
}
}
-
+
/**
* Replace all matches
*/
public void replaceAll() {
if (callback == null || matches.isEmpty()) return;
-
+
String sourceText = callback.getText();
StringBuilder result = new StringBuilder();
int lastEnd = 0;
-
+
for (int i = 0; i < matches.size(); i++) {
if (excludedMatches.contains(i)) {
continue;
@@ -1339,11 +1339,11 @@ public class SearchReplaceBar {
lastEnd = match[1];
}
result.append(sourceText.substring(lastEnd));
-
+
callback.setText(result.toString());
updateMatches();
}
-
+
/**
* Exclude current match from replacement
*/
@@ -1359,16 +1359,16 @@ public class SearchReplaceBar {
goToNextMatch();
}
}
-
+
// ==================== UTILITY ====================
-
+
/**
* Get search text for external highlighting
*/
public String getSearchText() {
return searchText;
}
-
+
/**
* Check if bar consumes click at position
*/
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/SelectionState.java b/src/main/java/noppes/npcs/client/gui/util/script/SelectionState.java
index 242c16a93..89efa34cd 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/SelectionState.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/SelectionState.java
@@ -1,6 +1,7 @@
package noppes.npcs.client.gui.util.script;
import noppes.npcs.client.gui.util.script.JavaTextContainer.LineData;
+
import java.util.List;
import java.util.regex.Pattern;
@@ -12,14 +13,14 @@ public class SelectionState {
private int endSelection = 0;
private int cursorPosition = 0;
private long lastInputTime = 0L;
-
+
/**
* Reset all cursor selections to a single position
*/
public void reset(int position) {
startSelection = endSelection = cursorPosition = position;
}
-
+
/**
* Clamp all selection bounds to valid text range
*/
@@ -32,13 +33,13 @@ public class SelectionState {
endSelection = Math.max(0, Math.min(endSelection, textLength));
cursorPosition = Math.max(0, Math.min(cursorPosition, textLength));
}
-
+
/**
* Set cursor position, optionally extending selection
*/
public void setCursor(int position, int textLength, boolean extendSelection) {
position = Math.max(0, Math.min(position, textLength));
-
+
if (position != cursorPosition) {
if (!extendSelection) {
endSelection = startSelection = cursorPosition = position;
@@ -49,7 +50,7 @@ public class SelectionState {
} else if (cursorPosition == endSelection) {
endSelection -= diff;
}
-
+
// Ensure start <= end
if (startSelection > endSelection) {
int temp = endSelection;
@@ -62,7 +63,7 @@ public class SelectionState {
markActivity();
}
}
-
+
/**
* Select a range of text
*/
@@ -70,7 +71,7 @@ public class SelectionState {
startSelection = Math.min(start, end);
endSelection = Math.max(start, end);
}
-
+
/**
* Select all text
*/
@@ -78,14 +79,14 @@ public class SelectionState {
startSelection = cursorPosition = 0;
endSelection = textLength;
}
-
+
/**
* Check if there's an active selection (not just cursor)
*/
public boolean hasSelection() {
return startSelection != endSelection;
}
-
+
/**
* Get selected text
*/
@@ -95,7 +96,7 @@ public class SelectionState {
int end = Math.max(0, Math.min(endSelection, text.length()));
return text.substring(start, end);
}
-
+
/**
* Get text before selection/cursor
*/
@@ -103,7 +104,7 @@ public class SelectionState {
if (text == null || startSelection <= 0) return "";
return text.substring(0, Math.min(startSelection, text.length()));
}
-
+
/**
* Get text after selection/cursor
*/
@@ -112,37 +113,37 @@ public class SelectionState {
int pos = Math.min(endSelection, text.length());
return text.substring(pos);
}
-
+
/**
* Find which line the cursor is on (0-indexed)
*/
public int getCursorLineIndex(List lines, int textLength) {
if (lines == null || lines.isEmpty()) return 0;
-
+
for (int i = 0; i < lines.size(); i++) {
LineData ld = lines.get(i);
boolean isLastLine = (i == lines.size() - 1);
- boolean isOnLine = isLastLine
- ? (cursorPosition >= ld.start && cursorPosition <= ld.end)
- : (cursorPosition >= ld.start && cursorPosition < ld.end);
+ boolean isOnLine = isLastLine
+ ? (cursorPosition >= ld.start && cursorPosition <= ld.end)
+ : (cursorPosition >= ld.start && cursorPosition < ld.end);
if (isOnLine) {
return i;
}
}
return lines.size() - 1;
}
-
+
/**
- * Check if cursor is on a specific line, handling the last line specially
- * (last line doesn't have trailing newline, so use <= for end boundary)
+ * Check if cursor is on a specific line, handling the last line specially
+ * (last line doesn't have trailing newline, so use <= for end boundary)
*/
public boolean isCursorOnLine(int lineIndex, LineData line, int totalLines) {
boolean isLastLine = (lineIndex == totalLines - 1);
- return isLastLine
- ? (cursorPosition >= line.start && cursorPosition <= line.end)
- : (cursorPosition >= line.start && cursorPosition < line.end);
+ return isLastLine
+ ? (cursorPosition >= line.start && cursorPosition <= line.end)
+ : (cursorPosition >= line.start && cursorPosition < line.end);
}
-
+
/**
* Find line containing the cursor
*/
@@ -156,32 +157,51 @@ public class SelectionState {
}
return null;
}
-
+
/**
* Mark user activity (for cursor blink timing)
*/
public void markActivity() {
lastInputTime = System.currentTimeMillis();
}
-
+
/**
* Check if there was recent input (for cursor blink pause)
*/
public boolean hadRecentInput() {
return System.currentTimeMillis() - lastInputTime < 500;
}
-
+
// Getters
- public int getStartSelection() { return startSelection; }
- public int getEndSelection() { return endSelection; }
- public int getCursorPosition() { return cursorPosition; }
- public long getLastInputTime() { return lastInputTime; }
-
+ public int getStartSelection() {
+ return startSelection;
+ }
+
+ public int getEndSelection() {
+ return endSelection;
+ }
+
+ public int getCursorPosition() {
+ return cursorPosition;
+ }
+
+ public long getLastInputTime() {
+ return lastInputTime;
+ }
+
// Direct setters (use with caution, prefer higher-level methods)
- public void setStartSelection(int pos) { this.startSelection = pos; }
- public void setEndSelection(int pos) { this.endSelection = pos; }
- public void setCursorPositionDirect(int pos) { this.cursorPosition = pos; }
-
+ public void setStartSelection(int pos) {
+ this.startSelection = pos;
+ }
+
+ public void setEndSelection(int pos) {
+ this.endSelection = pos;
+ }
+
+ public void setCursorPositionDirect(int pos) {
+ this.cursorPosition = pos;
+ }
+
/**
* After text modification, update selection to new position
*/
@@ -219,4 +239,4 @@ public class SelectionState {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/noppes/npcs/client/gui/util/script/UndoManager.java b/src/main/java/noppes/npcs/client/gui/util/script/UndoManager.java
index d7cad5295..c5cfd9f77 100644
--- a/src/main/java/noppes/npcs/client/gui/util/script/UndoManager.java
+++ b/src/main/java/noppes/npcs/client/gui/util/script/UndoManager.java
@@ -7,90 +7,92 @@ import java.util.List;
* Manages undo/redo stacks for the text editor.
*/
public class UndoManager {
-
+
/**
* Stores a snapshot of text state for undo/redo
*/
public static class UndoState {
public final String text;
public final int cursorPosition;
-
+
public UndoState(String text, int cursorPosition) {
this.text = text;
this.cursorPosition = cursorPosition;
}
}
-
+
private final List undoStack = new ArrayList<>();
private final List redoStack = new ArrayList<>();
private boolean isUndoing = false;
-
+
// Optional: limit stack size to prevent memory issues
private static final int MAX_STACK_SIZE = 100;
-
+
/**
* Record current state before making a change
*/
public void recordState(String text, int cursorPosition) {
if (isUndoing) return;
-
+
undoStack.add(new UndoState(text, cursorPosition));
redoStack.clear();
-
+
// Trim stack if too large
while (undoStack.size() > MAX_STACK_SIZE) {
undoStack.remove(0);
}
}
-
+
/**
* Undo to previous state
- * @param currentText Current text before undo
+ *
+ * @param currentText Current text before undo
* @param currentCursor Current cursor position
* @return Previous state, or null if nothing to undo
*/
public UndoState undo(String currentText, int currentCursor) {
if (undoStack.isEmpty()) return null;
-
+
isUndoing = true;
redoStack.add(new UndoState(currentText, currentCursor));
UndoState state = undoStack.remove(undoStack.size() - 1);
isUndoing = false;
-
+
return state;
}
-
+
/**
* Redo to next state
- * @param currentText Current text before redo
+ *
+ * @param currentText Current text before redo
* @param currentCursor Current cursor position
* @return Next state, or null if nothing to redo
*/
public UndoState redo(String currentText, int currentCursor) {
if (redoStack.isEmpty()) return null;
-
+
isUndoing = true;
undoStack.add(new UndoState(currentText, currentCursor));
UndoState state = redoStack.remove(redoStack.size() - 1);
isUndoing = false;
-
+
return state;
}
-
+
/**
* Check if undo is available
*/
public boolean canUndo() {
return !undoStack.isEmpty();
}
-
+
/**
* Check if redo is available
*/
public boolean canRedo() {
return !redoStack.isEmpty();
}
-
+
/**
* Clear all history
*/
@@ -98,22 +100,27 @@ public class UndoManager {
undoStack.clear();
redoStack.clear();
}
-
+
/**
* Check if currently performing an undo/redo operation
*/
public boolean isUndoing() {
return isUndoing;
}
-
+
/**
* Set undoing flag (for external control during setText)
*/
public void setUndoing(boolean undoing) {
this.isUndoing = undoing;
}
-
+
// For backward compatibility with existing code
- public List getUndoList() { return undoStack; }
- public List getRedoList() { return redoStack; }
-}
\ No newline at end of file
+ public List getUndoList() {
+ return undoStack;
+ }
+
+ public List getRedoList() {
+ return redoStack;
+ }
+}
diff --git a/src/main/java/noppes/npcs/client/key/KeyEvent.java b/src/main/java/noppes/npcs/client/key/KeyEvent.java
index 53011f2e8..1948e2f78 100644
--- a/src/main/java/noppes/npcs/client/key/KeyEvent.java
+++ b/src/main/java/noppes/npcs/client/key/KeyEvent.java
@@ -15,10 +15,27 @@ public class KeyEvent {
this.timestamp = System.currentTimeMillis();
}
- public boolean is(KeyPreset.PressType t) { return this.type == t; }
- public boolean isPress() { return is(KeyPreset.PressType.PRESS); }
- public boolean isHold() { return is(KeyPreset.PressType.HOLD); }
- public boolean isRelease() { return is(KeyPreset.PressType.RELEASE); }
- public boolean isSinglePress() { return is(KeyPreset.PressType.SINGLE_PRESS); }
- public boolean isPressRelease() { return is(KeyPreset.PressType.PRESS_RELEASE); }
+ public boolean is(KeyPreset.PressType t) {
+ return this.type == t;
+ }
+
+ public boolean isPress() {
+ return is(KeyPreset.PressType.PRESS);
+ }
+
+ public boolean isHold() {
+ return is(KeyPreset.PressType.HOLD);
+ }
+
+ public boolean isRelease() {
+ return is(KeyPreset.PressType.RELEASE);
+ }
+
+ public boolean isSinglePress() {
+ return is(KeyPreset.PressType.SINGLE_PRESS);
+ }
+
+ public boolean isPressRelease() {
+ return is(KeyPreset.PressType.PRESS_RELEASE);
+ }
}
diff --git a/src/main/java/noppes/npcs/client/key/KeyPreset.java b/src/main/java/noppes/npcs/client/key/KeyPreset.java
index 7bae2c58c..e76cf14ff 100644
--- a/src/main/java/noppes/npcs/client/key/KeyPreset.java
+++ b/src/main/java/noppes/npcs/client/key/KeyPreset.java
@@ -13,8 +13,10 @@ public class KeyPreset {
* @field SINGLE_PRESS => on releasing before 5 ticks press time
* @field PRESS_RELEASE => on pressing and releasing
*/
- /** Press types for key events. */
- public enum PressType { PRESS, HOLD, RELEASE, SINGLE_PRESS, PRESS_RELEASE }
+ /**
+ * Press types for key events.
+ */
+ public enum PressType {PRESS, HOLD, RELEASE, SINGLE_PRESS, PRESS_RELEASE}
public KeyState defaultState = new KeyState();
public KeyState currentState = new KeyState();
@@ -81,7 +83,7 @@ public class KeyPreset {
if (throttleInterval <= 0) return false;
long currentTime = System.currentTimeMillis();
long intervalToUse = pressType == PressType.HOLD && isFirstAction && firstThrottleInterval > 0 ?
- firstThrottleInterval : throttleInterval;
+ firstThrottleInterval : throttleInterval;
if (currentTime - lastActionTime < intervalToUse) return true;
lastActionTime = currentTime;
isFirstAction = false;
@@ -108,7 +110,7 @@ public class KeyPreset {
}
if (!down && isDown) { // just released
- if (getPressTime() <= SHORT_PRESS_MS)
+ if (getPressTime() <= SHORT_PRESS_MS)
onAction(PressType.SINGLE_PRESS);
onAction(PressType.RELEASE, PressType.PRESS_RELEASE);
pressStartMs = 0;
@@ -116,10 +118,10 @@ public class KeyPreset {
if (down) // while held
onAction(PressType.HOLD);
-
+
this.isDown = down;
}
-
+
public long getPressTime() {
return pressStartMs > 0 ? (System.currentTimeMillis() - pressStartMs) : 0L;
}
diff --git a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java
index 6f973e2b5..1a978cdc7 100644
--- a/src/main/java/noppes/npcs/client/key/KeyPresetManager.java
+++ b/src/main/java/noppes/npcs/client/key/KeyPresetManager.java
@@ -25,7 +25,7 @@ public class KeyPresetManager {
}
public void tick() {
- for (KeyPreset key : keys)
+ for (KeyPreset key : keys)
key.tick();
}
diff --git a/src/main/java/noppes/npcs/client/key/impl/ScriptEditorKeys.java b/src/main/java/noppes/npcs/client/key/impl/ScriptEditorKeys.java
index f8f262893..4a9e294d0 100644
--- a/src/main/java/noppes/npcs/client/key/impl/ScriptEditorKeys.java
+++ b/src/main/java/noppes/npcs/client/key/impl/ScriptEditorKeys.java
@@ -5,8 +5,8 @@ import noppes.npcs.client.key.KeyPresetManager;
import org.lwjgl.input.Keyboard;
public class ScriptEditorKeys extends KeyPresetManager {
-
- ////////////////////
+
+ /// /////////////////
// Editor shortcuts (mapped from GuiScriptTextArea.handleShortcutKeys)
public final KeyPreset COPY = add("Copy").setDefaultState(Keyboard.KEY_C, true, false, false);
public final KeyPreset PASTE = add("Paste").setDefaultState(Keyboard.KEY_V, true, false, false);
@@ -14,20 +14,20 @@ public class ScriptEditorKeys extends KeyPresetManager {
public final KeyPreset DUPLICATE = add("Duplicate").setDefaultState(Keyboard.KEY_D, true, false, false);
public final KeyPreset UNDO = add("Undo").setDefaultState(Keyboard.KEY_Z, true, false, false);
public final KeyPreset REDO = add("Redo").setDefaultState(Keyboard.KEY_Y, true, false, false);
-
+
public final KeyPreset FORMAT = add("Format Code").setDefaultState(Keyboard.KEY_F, false, true, false);
public final KeyPreset TOGGLE_COMMENT = add("Toggle Comment").setDefaultState(Keyboard.KEY_SLASH, true, false, false);
-
+
// Search/Replace
public final KeyPreset SEARCH = add("Search").setDefaultState(Keyboard.KEY_F, true, false, false);
public final KeyPreset SEARCH_REPLACE = add("Replace").setDefaultState(Keyboard.KEY_F, true, false, true);
-
+
// Navigation
public final KeyPreset GO_TO_LINE = add("Go to Line").setDefaultState(Keyboard.KEY_G, true, false, false);
-
+
// Refactoring
public final KeyPreset RENAME = add("Rename").setDefaultState(Keyboard.KEY_R, true, false, false);
-
+
// View
public final KeyPreset FULLSCREEN = add("Toggle Fullscreen").setDefaultState(Keyboard.KEY_F11, false, false, false);
diff --git a/src/main/java/noppes/npcs/client/model/ModelPony.java b/src/main/java/noppes/npcs/client/model/ModelPony.java
index b0d23b40a..203a1d12b 100644
--- a/src/main/java/noppes/npcs/client/model/ModelPony.java
+++ b/src/main/java/noppes/npcs/client/model/ModelPony.java
@@ -17,7 +17,7 @@ import noppes.npcs.entity.EntityNpcPony;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
-import java.awt.*;
+import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
diff --git a/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java b/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java
index 252f0af65..90172ce6f 100644
--- a/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java
+++ b/src/main/java/noppes/npcs/client/renderer/ImageBufferDownloadAlt.java
@@ -2,7 +2,7 @@ package noppes.npcs.client.renderer;
import net.minecraft.client.renderer.ImageBufferDownload;
-import java.awt.*;
+import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
diff --git a/src/main/java/noppes/npcs/client/renderer/RenderNPCPony.java b/src/main/java/noppes/npcs/client/renderer/RenderNPCPony.java
index a82ba93a8..b018adf60 100644
--- a/src/main/java/noppes/npcs/client/renderer/RenderNPCPony.java
+++ b/src/main/java/noppes/npcs/client/renderer/RenderNPCPony.java
@@ -25,7 +25,7 @@ import noppes.npcs.entity.EntityNpcPony;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
-import java.awt.*;
+import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java
index 9aa8cdcaa..5be3a9492 100644
--- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java
+++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockScriptedRenderer.java
@@ -23,7 +23,7 @@ import noppes.npcs.blocks.tiles.TileScripted.TextPlane;
import noppes.npcs.client.TextBlockClient;
import org.lwjgl.opengl.GL11;
-import java.awt.*;
+import java.awt.Color;
import java.util.Random;
public class BlockScriptedRenderer extends BlockRendererInterface {
diff --git a/src/main/java/noppes/npcs/config/GlyphCache.java b/src/main/java/noppes/npcs/config/GlyphCache.java
index 98474c493..86f34d433 100644
--- a/src/main/java/noppes/npcs/config/GlyphCache.java
+++ b/src/main/java/noppes/npcs/config/GlyphCache.java
@@ -5,7 +5,13 @@ import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
-import java.awt.*;
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.Point2D;
diff --git a/src/main/java/noppes/npcs/config/StringCache.java b/src/main/java/noppes/npcs/config/StringCache.java
index 263b480b9..c40d59f1c 100644
--- a/src/main/java/noppes/npcs/config/StringCache.java
+++ b/src/main/java/noppes/npcs/config/StringCache.java
@@ -5,7 +5,8 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
-import java.awt.*;
+import java.awt.Font;
+import java.awt.Point;
import java.awt.font.GlyphVector;
import java.lang.ref.WeakReference;
import java.text.Bidi;
diff --git a/src/main/java/noppes/npcs/constants/ScriptContext.java b/src/main/java/noppes/npcs/constants/ScriptContext.java
index f2f614a1e..dcc5b5d95 100644
--- a/src/main/java/noppes/npcs/constants/ScriptContext.java
+++ b/src/main/java/noppes/npcs/constants/ScriptContext.java
@@ -1,13 +1,29 @@
package noppes.npcs.constants;
-import noppes.npcs.api.event.*;
+import noppes.npcs.api.event.IAnimationEvent;
+import noppes.npcs.api.event.IBlockEvent;
+import noppes.npcs.api.event.ICustomGuiEvent;
+import noppes.npcs.api.event.IDialogEvent;
+import noppes.npcs.api.event.IFactionEvent;
+import noppes.npcs.api.event.IForgeEvent;
+import noppes.npcs.api.event.IItemEvent;
+import noppes.npcs.api.event.INpcEvent;
+import noppes.npcs.api.event.IPartyEvent;
+import noppes.npcs.api.event.IPlayerEvent;
+import noppes.npcs.api.event.IProjectileEvent;
+import noppes.npcs.api.event.IQuestEvent;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Represents a script context that maps to one or more event interface namespaces.
- *
+ *
* A script context can have multiple namespaces because script editors often
* support hooks from multiple event types. For example, Player scripts support:
* - IPlayerEvent (core player hooks)
@@ -15,17 +31,17 @@ import java.util.concurrent.ConcurrentHashMap;
* - IPartyEvent (party hooks)
* - ICustomGuiEvent (custom GUI hooks)
* - etc.
- *
+ *
* Each context also has a hookContext string used by ScriptHookController for
* hook registration and lookup.
- *
+ *
* This is a registerable system - any mod can register their own contexts:
- *
- * // Register a new context with multiple namespaces:
- * ScriptContext.register("DBC", "dbc", IDBCEvent.class, IDBCPlayerEvent.class);
- *
- * // Or add namespaces to an existing context:
- * ScriptContext.PLAYER.addNamespace("IDBCPlayerEvent");
+ *
+ * // Register a new context with multiple namespaces:
+ * ScriptContext.register("DBC", "dbc", IDBCEvent.class, IDBCPlayerEvent.class);
+ *
+ * // Or add namespaces to an existing context:
+ * ScriptContext.PLAYER.addNamespace("IDBCPlayerEvent");
*/
public class ScriptContext {
@@ -35,42 +51,42 @@ public class ScriptContext {
// ==================== BUILT-IN CONTEXTS ====================
public static final ScriptContext NPC = register("NPC", "npc",
- INpcEvent.class,
- IProjectileEvent.class
+ INpcEvent.class,
+ IProjectileEvent.class
);
public static final ScriptContext PLAYER = register("PLAYER", "player",
- IPlayerEvent.class,
- IAnimationEvent.class,
- IPartyEvent.class,
- IDialogEvent.class,
- IQuestEvent.class,
- IFactionEvent.class,
- ICustomGuiEvent.class
+ IPlayerEvent.class,
+ IAnimationEvent.class,
+ IPartyEvent.class,
+ IDialogEvent.class,
+ IQuestEvent.class,
+ IFactionEvent.class,
+ ICustomGuiEvent.class
);
public static final ScriptContext BLOCK = register("BLOCK", "block",
- IBlockEvent.class
+ IBlockEvent.class
);
public static final ScriptContext ITEM = register("ITEM", "item",
- IItemEvent.class
+ IItemEvent.class
);
public static final ScriptContext FORGE = register("FORGE", "forge",
- IForgeEvent.class
+ IForgeEvent.class
);
public static final ScriptContext LINKED_ITEM = register("LINKED_ITEM", "linked_item",
- IItemEvent.class
+ IItemEvent.class
);
public static final ScriptContext RECIPE = register("RECIPE", "recipe",
- "Recipe"
+ "Recipe"
);
public static final ScriptContext EFFECT = register("EFFECT", "effect",
- "Effect"
+ "Effect"
);
public static final ScriptContext GLOBAL = register("GLOBAL", "",
@@ -79,13 +95,19 @@ public class ScriptContext {
// ==================== INSTANCE FIELDS ====================
- /** Unique identifier for this context (e.g., "NPC", "PLAYER", "DBC") */
+ /**
+ * Unique identifier for this context (e.g., "NPC", "PLAYER", "DBC")
+ */
public final String id;
- /** Hook context identifier used by ScriptHookController (e.g., "npc", "player") */
+ /**
+ * Hook context identifier used by ScriptHookController (e.g., "npc", "player")
+ */
public final String hookContext;
- /** The event interface namespaces this context supports */
+ /**
+ * The event interface namespaces this context supports
+ */
private final List namespaces;
// ==================== CONSTRUCTOR ====================
@@ -144,9 +166,9 @@ public class ScriptContext {
/**
* Register a new script context with a hook context and one or more namespaces.
*
- * @param id Unique identifier (e.g., "DBC", "CUSTOM")
+ * @param id Unique identifier (e.g., "DBC", "CUSTOM")
* @param hookContext The hook context string for ScriptHookController (e.g., "dbc")
- * @param namespaces The event interface names (e.g., "IDBCEvent", "IDBCPlayerEvent")
+ * @param namespaces The event interface names (e.g., "IDBCEvent", "IDBCPlayerEvent")
* @return The registered ScriptContext
*/
public static ScriptContext register(String id, String hookContext, String... namespaces) {
@@ -158,12 +180,12 @@ public class ScriptContext {
/**
* Register a new script context using event interface classes.
* Automatically extracts the simple name from each class.
- *
+ *
* Example:
- * ScriptContext.register("NPC", "npc", INpcEvent.class, IProjectileEvent.class);
+ * ScriptContext.register("NPC", "npc", INpcEvent.class, IProjectileEvent.class);
*
- * @param id Unique identifier (e.g., "DBC", "CUSTOM")
- * @param hookContext The hook context string for ScriptHookController (e.g., "npc")
+ * @param id Unique identifier (e.g., "DBC", "CUSTOM")
+ * @param hookContext The hook context string for ScriptHookController (e.g., "npc")
* @param eventClasses The event interface classes (simple names will be extracted)
* @return The registered ScriptContext
*/
diff --git a/src/main/java/noppes/npcs/controllers/AnimationController.java b/src/main/java/noppes/npcs/controllers/AnimationController.java
index 65adfcd3d..e3caddce5 100644
--- a/src/main/java/noppes/npcs/controllers/AnimationController.java
+++ b/src/main/java/noppes/npcs/controllers/AnimationController.java
@@ -231,10 +231,9 @@ public class AnimationController implements IAnimationHandler {
}
- ////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////
+ /// /////////////////////////////////////////////////////
+ /// /////////////////////////////////////////////////////
// ANIMATION MAP
-
public File getMapDir() {
File dir = CustomNpcs.getWorldSaveDirectory();
if (!dir.exists())
diff --git a/src/main/java/noppes/npcs/controllers/HookDefinition.java b/src/main/java/noppes/npcs/controllers/HookDefinition.java
index 9d8c34fa6..864e37ee3 100644
--- a/src/main/java/noppes/npcs/controllers/HookDefinition.java
+++ b/src/main/java/noppes/npcs/controllers/HookDefinition.java
@@ -97,7 +97,7 @@ public class HookDefinition implements IHookDefinition {
* Create a hook definition from a hook name and event class.
* Automatically derives imports from the event class.
*
- * @param hookName The hook function name
+ * @param hookName The hook function name
* @param eventClass The event class (e.g., INpcEvent.InitEvent.class)
* @return A hook definition with auto-derived imports
*/
@@ -131,7 +131,7 @@ public class HookDefinition implements IHookDefinition {
* This provides backward compatibility with the annotation-based hook definition approach.
*
* @param hookName The hook name (may differ from method name)
- * @param method The method to extract metadata from
+ * @param method The method to extract metadata from
* @return A hook definition with extracted metadata
*/
public static HookDefinition fromMethod(String hookName, Method method) {
@@ -165,7 +165,7 @@ public class HookDefinition implements IHookDefinition {
} else {
// Fallback: use lowercase simple type name
names[i] = Character.toLowerCase(params[i].getType().getSimpleName().charAt(0))
- + params[i].getType().getSimpleName().substring(1);
+ + params[i].getType().getSimpleName().substring(1);
}
}
builder.paramNames(names);
diff --git a/src/main/java/noppes/npcs/controllers/LinkedItemController.java b/src/main/java/noppes/npcs/controllers/LinkedItemController.java
index 48f19958b..78534a82f 100644
--- a/src/main/java/noppes/npcs/controllers/LinkedItemController.java
+++ b/src/main/java/noppes/npcs/controllers/LinkedItemController.java
@@ -94,8 +94,8 @@ public class LinkedItemController {
return this.linkedItemsScripts.get(id);
}
- ////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////
+ /// /////////////////////////////////////////////////////
+ /// /////////////////////////////////////////////////////
public void load() {
lastUsedID = 0;
@@ -247,10 +247,9 @@ public class LinkedItemController {
}
- ////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////
+ /// /////////////////////////////////////////////////////
+ /// /////////////////////////////////////////////////////
// LINKED ITEMS MAP
-
public File getMapDir() {
File dir = CustomNpcs.getWorldSaveDirectory();
if (!dir.exists())
diff --git a/src/main/java/noppes/npcs/controllers/MarketRegistry.java b/src/main/java/noppes/npcs/controllers/MarketRegistry.java
index 1110f9e5f..55de3a0bf 100644
--- a/src/main/java/noppes/npcs/controllers/MarketRegistry.java
+++ b/src/main/java/noppes/npcs/controllers/MarketRegistry.java
@@ -15,7 +15,7 @@ import java.util.concurrent.ConcurrentHashMap;
* Central registry for linked market synchronization.
* Tracks which RoleTrader instances use which markets,
* and which players are viewing each market.
- *
+ *
* This enables immediate sync across all traders sharing
* the same market when a purchase occurs.
*/
diff --git a/src/main/java/noppes/npcs/controllers/ScriptContainer.java b/src/main/java/noppes/npcs/controllers/ScriptContainer.java
index eb0b8b1c4..738819500 100644
--- a/src/main/java/noppes/npcs/controllers/ScriptContainer.java
+++ b/src/main/java/noppes/npcs/controllers/ScriptContainer.java
@@ -270,41 +270,41 @@ public class ScriptContainer implements IScriptUnit {
this.evaluated = false;
}
}
-
+
// ==================== IScriptUnit IMPLEMENTATION ====================
-
+
@Override
public String getScript() {
return this.script;
}
-
+
@Override
public void setScript(String script) {
this.script = script;
this.evaluated = false;
}
-
+
@Override
public List getExternalScripts() {
return this.scripts;
}
-
+
@Override
public void setExternalScripts(List scripts) {
this.scripts = scripts;
this.evaluated = false;
}
-
+
@Override
public TreeMap getConsole() {
return this.console;
}
-
+
@Override
public void clearConsole() {
this.console.clear();
}
-
+
@Override
public String getLanguage() {
// If a specific language is set for this container, use it
@@ -314,7 +314,7 @@ public class ScriptContainer implements IScriptUnit {
}
return handler != null ? handler.getLanguage() : "ECMAScript";
}
-
+
@Override
public void setLanguage(String language) {
if (!Objects.equals(this.currentScriptLanguage, language)) {
@@ -322,7 +322,7 @@ public class ScriptContainer implements IScriptUnit {
this.evaluated = false;
}
}
-
+
@Override
public String generateHookStub(String hookName, Object hookData) {
// ECMAScript function template
@@ -330,13 +330,14 @@ public class ScriptContainer implements IScriptUnit {
}
@Override
- public void ensureCompiled() {}
+ public void ensureCompiled() {
+ }
@Override
public boolean hasErrored() {
return this.errored;
}
-
+
@Override
public void setErrored(boolean errored) {
this.errored = errored;
diff --git a/src/main/java/noppes/npcs/controllers/ScriptHookController.java b/src/main/java/noppes/npcs/controllers/ScriptHookController.java
index f89177c9e..f3bad8e9d 100644
--- a/src/main/java/noppes/npcs/controllers/ScriptHookController.java
+++ b/src/main/java/noppes/npcs/controllers/ScriptHookController.java
@@ -1,16 +1,43 @@
package noppes.npcs.controllers;
-import noppes.npcs.api.event.*;
+import noppes.npcs.api.event.IAbilityEvent;
+import noppes.npcs.api.event.IAnimationEvent;
+import noppes.npcs.api.event.IBlockEvent;
+import noppes.npcs.api.event.ICustomGuiEvent;
+import noppes.npcs.api.event.ICustomNPCsEvent;
+import noppes.npcs.api.event.IDialogEvent;
+import noppes.npcs.api.event.IFactionEvent;
+import noppes.npcs.api.event.IForgeEvent;
+import noppes.npcs.api.event.IItemEvent;
+import noppes.npcs.api.event.ILinkedItemEvent;
+import noppes.npcs.api.event.INpcEvent;
+import noppes.npcs.api.event.IPartyEvent;
+import noppes.npcs.api.event.IPlayerEvent;
+import noppes.npcs.api.event.IProjectileEvent;
+import noppes.npcs.api.event.IQuestEvent;
+import noppes.npcs.api.event.IRecipeEvent;
import noppes.npcs.api.handler.IHookDefinition;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.data.RecipeScript;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import static noppes.npcs.constants.EnumScriptType.*;
-import static noppes.npcs.constants.ScriptContext.*;
+import static noppes.npcs.constants.ScriptContext.BLOCK;
+import static noppes.npcs.constants.ScriptContext.EFFECT;
+import static noppes.npcs.constants.ScriptContext.FORGE;
+import static noppes.npcs.constants.ScriptContext.ITEM;
+import static noppes.npcs.constants.ScriptContext.LINKED_ITEM;
+import static noppes.npcs.constants.ScriptContext.NPC;
+import static noppes.npcs.constants.ScriptContext.PLAYER;
+import static noppes.npcs.constants.ScriptContext.RECIPE;
/**
* Controller for managing script hooks.
@@ -290,8 +317,8 @@ public class ScriptHookController implements IScriptHookHandler {
* Register a hook with event class (auto-derives imports).
* For addon mods to register custom hooks.
*
- * @param context Hook context (e.g., "npc", "player")
- * @param hookName Function name in scripts
+ * @param context Hook context (e.g., "npc", "player")
+ * @param hookName Function name in scripts
* @param eventClass The event class (imports auto-derived from enclosing class)
*/
public void registerHook(String context, String hookName, Class> eventClass) {
diff --git a/src/main/java/noppes/npcs/controllers/data/Animation.java b/src/main/java/noppes/npcs/controllers/data/Animation.java
index c7d006198..8cf9b3827 100644
--- a/src/main/java/noppes/npcs/controllers/data/Animation.java
+++ b/src/main/java/noppes/npcs/controllers/data/Animation.java
@@ -185,16 +185,26 @@ public class Animation implements IAnimation {
}
@Override
- public boolean hasData(String key) {return dataStore.containsKey(key);}
-
- @Override
- public Object getData(String key) {return dataStore.get(key);}
+ public boolean hasData(String key) {
+ return dataStore.containsKey(key);
+ }
@Override
- public IAnimation setData(String key, Object v) {dataStore.put(key, v);return this;}
+ public Object getData(String key) {
+ return dataStore.get(key);
+ }
@Override
- public IAnimation removeData(String key) {dataStore.remove(key);return this;}
+ public IAnimation setData(String key, Object v) {
+ dataStore.put(key, v);
+ return this;
+ }
+
+ @Override
+ public IAnimation removeData(String key) {
+ dataStore.remove(key);
+ return this;
+ }
public void readFromNBT(NBTTagCompound compound) {
if (compound.hasKey("ID")) {
@@ -323,13 +333,13 @@ public class Animation implements IAnimation {
this.onAnimationStart = task;
return this;
}
-
+
@Override
public IAnimation onFrame(BiConsumer task) {
this.onAnimationFrame = task;
return this;
}
-
+
@Override
public IAnimation onEnd(Consumer task) {
this.onAnimationEnd = task;
@@ -355,7 +365,7 @@ public class Animation implements IAnimation {
}
/**
- * Only called on setAnimation, to transfer tasks from
+ * Only called on setAnimation, to transfer tasks from
* this global instance stored in AnimationController
* to the new local instance on entity's AnimationData,
* and clear them from the global instance.
@@ -372,6 +382,6 @@ public class Animation implements IAnimation {
this.dataStore.putAll(animation.dataStore);
animation.dataStore.clear();
}
-
-
+
+
}
diff --git a/src/main/java/noppes/npcs/controllers/data/CustomEffect.java b/src/main/java/noppes/npcs/controllers/data/CustomEffect.java
index 9b621234d..7a5db74de 100644
--- a/src/main/java/noppes/npcs/controllers/data/CustomEffect.java
+++ b/src/main/java/noppes/npcs/controllers/data/CustomEffect.java
@@ -194,7 +194,7 @@ public class CustomEffect implements ICustomEffect {
return;
}
- script.callScript(EnumScriptType.ON_EFFECT_ADD, event);
+ script.callScript(EnumScriptType.ON_EFFECT_ADD, event);
}
EventHooks.onEffectAdded(iPlayer, playerEffect);
@@ -214,7 +214,7 @@ public class CustomEffect implements ICustomEffect {
return;
}
- script.callScript(EnumScriptType.ON_EFFECT_TICK, event);
+ script.callScript(EnumScriptType.ON_EFFECT_TICK, event);
}
EventHooks.onEffectTick(iPlayer, playerEffect);
@@ -235,7 +235,7 @@ public class CustomEffect implements ICustomEffect {
return;
}
- script.callScript(EnumScriptType.ON_EFFECT_REMOVE, event);
+ script.callScript(EnumScriptType.ON_EFFECT_REMOVE, event);
}
EventHooks.onEffectRemove(iPlayer, playerEffect, type);
diff --git a/src/main/java/noppes/npcs/controllers/data/DataScript.java b/src/main/java/noppes/npcs/controllers/data/DataScript.java
index ede4a4c96..74806605f 100644
--- a/src/main/java/noppes/npcs/controllers/data/DataScript.java
+++ b/src/main/java/noppes/npcs/controllers/data/DataScript.java
@@ -312,6 +312,7 @@ public class DataScript implements IScriptHandlerPacket {
public Collection getNPCScripts() {
return this.scripts.values();
}
+
@Override
public IScriptUnit createJaninoScriptUnit() {
return new EventJaninoScript(ScriptContext.NPC);
diff --git a/src/main/java/noppes/npcs/controllers/data/EffectScript.java b/src/main/java/noppes/npcs/controllers/data/EffectScript.java
index 821e542b4..457eb11d6 100644
--- a/src/main/java/noppes/npcs/controllers/data/EffectScript.java
+++ b/src/main/java/noppes/npcs/controllers/data/EffectScript.java
@@ -2,9 +2,7 @@ package noppes.npcs.controllers.data;
import kamkeel.npcs.network.packets.request.script.EffectScriptPacket;
import net.minecraft.nbt.NBTTagCompound;
-import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.constants.ScriptContext;
-import noppes.npcs.scripted.event.player.PlayerEvent;
/**
* Script handler for CustomEffect scripts.
@@ -12,7 +10,9 @@ import noppes.npcs.scripted.event.player.PlayerEvent;
*/
public class EffectScript extends SingleScriptHandler implements IScriptHandlerPacket {
- /** The effect ID for packet communication. -1 if not bound to an effect. */
+ /**
+ * The effect ID for packet communication. -1 if not bound to an effect.
+ */
private int effectId = -1;
/**
@@ -23,6 +23,7 @@ public class EffectScript extends SingleScriptHandler implements IScriptHandlerP
/**
* Create an EffectScript bound to a specific effect (for GUI use).
+ *
* @param effectId The ID of the CustomEffect
*/
public EffectScript(int effectId) {
diff --git a/src/main/java/noppes/npcs/controllers/data/IScriptHandler.java b/src/main/java/noppes/npcs/controllers/data/IScriptHandler.java
index 93892f2a6..812bef6d8 100644
--- a/src/main/java/noppes/npcs/controllers/data/IScriptHandler.java
+++ b/src/main/java/noppes/npcs/controllers/data/IScriptHandler.java
@@ -13,16 +13,16 @@ import java.util.TreeMap;
public interface IScriptHandler {
default void callScript(EnumScriptType type, Event event) {
- if (type != null)
+ if (type != null)
callScript(type.function, event);
-
+
}
void callScript(String hookName, Event event);
/**
* Call a function by name and return its result.
- *
+ *
* Default implementation calls the function on each script unit (in order) and returns
* the first non-null value.
*/
@@ -86,7 +86,7 @@ public interface IScriptHandler {
default Map getConsoleText() {
Map map = new TreeMap<>();
int tab = 0;
-
+
for (IScriptUnit script : getScripts()) {
++tab;
for (Map.Entry entry : script.getConsole().entrySet()) {
@@ -97,24 +97,24 @@ public interface IScriptHandler {
}
default void clearConsole() {
- for (IScriptUnit script : getScripts())
+ for (IScriptUnit script : getScripts())
script.clearConsole();
-
+
}
-
+
/**
* Create a new Janino (Java) script unit for this handler.
* Handlers that don't support Janino scripts should return null.
- *
+ *
* @return A new JaninoScript instance, or null if not supported
*/
default IScriptUnit createJaninoScriptUnit() {
return null; // Default: Janino not supported
}
-
+
/**
* Check if this handler supports Janino (Java) scripts.
- *
+ *
* @return true if createJaninoScriptUnit() can create valid Janino scripts
*/
default boolean supportsJanino() {
@@ -133,7 +133,7 @@ public interface IScriptHandler {
/**
* Get the hook context identifier for this handler.
* Used by ScriptHookController to look up available hooks.
- *
+ *
* By default, derives from getContext().hookContext.
* Override if a different hook context is needed.
*
@@ -152,9 +152,9 @@ public interface IScriptHandler {
*/
default List getHooks() {
String context = getHookContext();
- if (context == null || context.isEmpty())
+ if (context == null || context.isEmpty())
return Collections.emptyList();
-
+
return ScriptHookController.Instance.getAllHooks(context);
}
diff --git a/src/main/java/noppes/npcs/controllers/data/IScriptHandlerPacket.java b/src/main/java/noppes/npcs/controllers/data/IScriptHandlerPacket.java
index c307f508d..88ff5fb94 100644
--- a/src/main/java/noppes/npcs/controllers/data/IScriptHandlerPacket.java
+++ b/src/main/java/noppes/npcs/controllers/data/IScriptHandlerPacket.java
@@ -15,9 +15,9 @@ public interface IScriptHandlerPacket extends IScriptHandler {
/**
* Client-side: send a script container packet to the server.
*
- * @param index {@code >= 0} for a script tab, {@code -1} for handler metadata (language/enabled/console)
+ * @param index {@code >= 0} for a script tab, {@code -1} for handler metadata (language/enabled/console)
* @param totalCount Total number of scripts for this handler
- * @param nbt The script container NBT (tab content or metadata)
+ * @param nbt The script container NBT (tab content or metadata)
*/
void sendSavePacket(int index, int totalCount, NBTTagCompound nbt);
diff --git a/src/main/java/noppes/npcs/controllers/data/IScriptUnit.java b/src/main/java/noppes/npcs/controllers/data/IScriptUnit.java
index 258b584b8..b439d7d0a 100644
--- a/src/main/java/noppes/npcs/controllers/data/IScriptUnit.java
+++ b/src/main/java/noppes/npcs/controllers/data/IScriptUnit.java
@@ -6,7 +6,6 @@ import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.ScriptContainer;
import java.util.List;
-import java.util.Map;
import java.util.TreeMap;
/**
@@ -15,24 +14,24 @@ import java.util.TreeMap;
* This allows GuiScriptInterface to work with both script types uniformly.
*/
public interface IScriptUnit {
-
+
// NBT type identifiers
String NBT_TYPE_KEY = "ScriptUnitType";
String TYPE_ECMASCRIPT = "ECMAScript";
String TYPE_JANINO = "Janino";
-
+
/**
* Create an IScriptUnit from NBT data.
* Uses the "ScriptUnitType" tag to determine which implementation to create.
- *
+ *
* @param compound The NBT data
- * @param handler The script handler (used for ScriptContainer)
+ * @param handler The script handler (used for ScriptContainer)
* @return A ScriptContainer or JaninoScript based on the NBT type
*/
static IScriptUnit createFromNBT(NBTTagCompound compound, IScriptHandler handler) {
String type = compound.getString(NBT_TYPE_KEY);
IScriptUnit unit;
-
+
if (TYPE_JANINO.equals(type)) {
// Create appropriate JaninoScript based on handler
unit = handler.createJaninoScriptUnit();
@@ -44,96 +43,97 @@ public interface IScriptUnit {
// Default to ScriptContainer for ECMAScript or missing type
unit = new ScriptContainer(handler);
}
-
+
unit.readFromNBT(compound);
return unit;
}
-
+
// ==================== SCRIPT CONTENT ====================
-
+
/**
* Get the main script text content.
*/
String getScript();
-
+
/**
* Set the main script text content.
*/
void setScript(String script);
-
+
/**
* Get the list of external script file names loaded for this unit.
*/
List getExternalScripts();
-
+
/**
* Set the list of external script file names to load.
*/
void setExternalScripts(List scripts);
-
+
// ==================== CONSOLE ====================
-
+
/**
* Get the console output map (timestamp -> message).
*/
TreeMap getConsole();
-
+
/**
* Clear all console output.
*/
void clearConsole();
-
+
/**
* Append a message to the console.
*/
void appendConsole(String message);
-
+
// ==================== LANGUAGE ====================
-
+
/**
* Get the scripting language for this unit.
* Returns "ECMAScript", "Java", etc.
*/
String getLanguage();
-
+
/**
* Set the scripting language for this unit.
+ *
* @param language The language name (e.g., "ECMAScript", "Java")
*/
void setLanguage(String language);
-
+
/**
* Check if this script unit uses Janino (Java) compilation.
*/
default boolean isJanino() {
return "Java".equals(getLanguage());
}
-
+
// ==================== HOOK GENERATION ====================
-
+
/**
* Generate a stub/template for the given hook name.
* ECMAScript: function hookName(event) { }
* Janino: full Java method signature with return type
- *
+ *
* @param hookName The hook name to generate a stub for
* @param hookData Optional data (e.g., Method object for Janino)
* @return The generated stub string
*/
String generateHookStub(String hookName, Object hookData);
-
+
// ==================== NBT ====================
-
+
/**
* Write this script unit to NBT.
*/
NBTTagCompound writeToNBT(NBTTagCompound compound);
-
+
/**
* Read this script unit from NBT.
*/
void readFromNBT(NBTTagCompound compound);
-
+
// ==================== STATE ====================
/**
@@ -141,43 +141,43 @@ public interface IScriptUnit {
* No-op for ScriptContainer.
*/
void ensureCompiled();
-
+
/**
* Check if this script unit has any code (script or external scripts).
*/
boolean hasCode();
-
+
/**
* Check if this script unit has encountered an error during execution.
*/
boolean hasErrored();
-
+
/**
* Set the error state of this script unit.
*/
void setErrored(boolean errored);
-
+
// ==================== EXECUTION ====================
-
+
/**
* Execute this script unit for the given hook type and event.
- *
- * @param type The script hook type
+ *
+ * @param type The script hook type
* @param event The event object
*/
void run(EnumScriptType type, Event event);
-
+
/**
* Execute this script unit for the given hook name and event.
*
* @param hookName The hook name (e.g., "init", "interact")
- * @param event The event object
+ * @param event The event object
*/
void run(String hookName, Object event);
/**
* Call a script function by name and return its result.
- *
+ *
* Default implementation returns null (not supported).
*/
default Object callFunction(String hookName, Object... args) {
diff --git a/src/main/java/noppes/npcs/controllers/data/JaninoScriptHandler.java b/src/main/java/noppes/npcs/controllers/data/JaninoScriptHandler.java
index fb354e590..cbe1230e0 100644
--- a/src/main/java/noppes/npcs/controllers/data/JaninoScriptHandler.java
+++ b/src/main/java/noppes/npcs/controllers/data/JaninoScriptHandler.java
@@ -11,13 +11,13 @@ import java.util.function.Supplier;
/**
* Reusable IScriptHandler implementation for objects that own an optional single JaninoScript unit.
- *
+ *
* This is meant for "function provider" scripts (not EnumScriptType driven). Execution is typically
* initiated by the owning system calling script.call(...) directly.
- *
+ *
* NBT storage is kept under the parent compound key "Script" (same convention as JaninoScriptable).
*/
-public class JaninoScriptHandler> extends ScriptHandler {
+public class JaninoScriptHandler> extends ScriptHandler {
protected S script;
@@ -41,9 +41,9 @@ public class JaninoScriptHandler> extends ScriptHandle
}
public JaninoScript createScript() {
- if (script == null)
+ if (script == null)
script = factory.get();
-
+
return script;
}
@@ -96,9 +96,9 @@ public class JaninoScriptHandler> extends ScriptHandle
@Override
public List getScripts() {
- if (script == null)
+ if (script == null)
return Collections.emptyList();
-
+
return Collections.singletonList(script);
}
diff --git a/src/main/java/noppes/npcs/controllers/data/LinkedItem.java b/src/main/java/noppes/npcs/controllers/data/LinkedItem.java
index f1840a625..961c570f9 100644
--- a/src/main/java/noppes/npcs/controllers/data/LinkedItem.java
+++ b/src/main/java/noppes/npcs/controllers/data/LinkedItem.java
@@ -249,8 +249,8 @@ public class LinkedItem implements ILinkedItem {
@Override
public void setAttackSpeed(int time) {
- if(time <= 0) {
- time = 10;
+ if (time <= 0) {
+ time = 10;
}
this.attackSpeed = time;
}
diff --git a/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java b/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java
index 1ee4537fb..a54c20727 100644
--- a/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java
+++ b/src/main/java/noppes/npcs/controllers/data/LinkedItemScript.java
@@ -9,44 +9,47 @@ import noppes.npcs.constants.ScriptContext;
* Manages a single script container for linked item hooks.
*/
public class LinkedItemScript extends SingleScriptHandler implements IScriptHandlerPacket {
-
- /** The linked item ID for packet communication. -1 if not bound. */
+
+ /**
+ * The linked item ID for packet communication. -1 if not bound.
+ */
private int linkedItemId = -1;
-
+
/**
* Create an unbound LinkedItemScript (for server-side use).
*/
public LinkedItemScript() {
}
-
+
/**
* Create a LinkedItemScript bound to a specific linked item (for GUI use).
+ *
* @param linkedItemId The ID of the LinkedItem
*/
public LinkedItemScript(int linkedItemId) {
this.linkedItemId = linkedItemId;
}
-
+
@Override
public ScriptContext getContext() {
return ScriptContext.LINKED_ITEM;
}
-
+
@Override
public String noticeString() {
return "LinkedItem";
}
-
+
@Override
public void requestData() {
- if (linkedItemId >= 0)
+ if (linkedItemId >= 0)
LinkedItemScriptPacket.Get(linkedItemId);
}
-
+
@Override
public void sendSavePacket(int index, int totalCount, NBTTagCompound nbt) {
- if (linkedItemId >= 0)
+ if (linkedItemId >= 0)
LinkedItemScriptPacket.Save(linkedItemId, index, totalCount, nbt);
-
+
}
}
diff --git a/src/main/java/noppes/npcs/controllers/data/MultiScriptHandler.java b/src/main/java/noppes/npcs/controllers/data/MultiScriptHandler.java
index d175eb3b9..d4b4c027b 100644
--- a/src/main/java/noppes/npcs/controllers/data/MultiScriptHandler.java
+++ b/src/main/java/noppes/npcs/controllers/data/MultiScriptHandler.java
@@ -7,13 +7,11 @@ import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import java.util.ArrayList;
-import java.util.Map;
-import java.util.TreeMap;
/**
* Base class for script handlers that manage multiple script containers (tabs).
* Provides shared NBT serialization and common script execution patterns.
- *
+ *
* Subclasses should:
* - Override getContext() to return the appropriate ScriptContext
* - Override getHookContext() if not using ScriptContext's hookContext
@@ -21,7 +19,7 @@ import java.util.TreeMap;
* - Override isEnabled() if custom enable logic is needed
*/
public abstract class MultiScriptHandler extends ScriptHandler implements IScriptHandlerPacket {
-
+
// ==================== NBT SERIALIZATION ====================
/**
diff --git a/src/main/java/noppes/npcs/controllers/data/PlayerCurrencyData.java b/src/main/java/noppes/npcs/controllers/data/PlayerCurrencyData.java
index 1271594ba..b2b8c4b57 100644
--- a/src/main/java/noppes/npcs/controllers/data/PlayerCurrencyData.java
+++ b/src/main/java/noppes/npcs/controllers/data/PlayerCurrencyData.java
@@ -99,6 +99,7 @@ public class PlayerCurrencyData implements IPlayerCurrencyData {
/**
* Add currency to balance (deposit)
+ *
* @param amount Amount to add
* @return true if successful, false if would exceed max balance
*/
@@ -135,6 +136,7 @@ public class PlayerCurrencyData implements IPlayerCurrencyData {
/**
* Remove currency from balance (withdraw)
+ *
* @param amount Amount to remove
* @return true if successful, false if insufficient funds
*/
diff --git a/src/main/java/noppes/npcs/controllers/data/RecipeScript.java b/src/main/java/noppes/npcs/controllers/data/RecipeScript.java
index 803a1b30d..97f81df90 100644
--- a/src/main/java/noppes/npcs/controllers/data/RecipeScript.java
+++ b/src/main/java/noppes/npcs/controllers/data/RecipeScript.java
@@ -9,48 +9,53 @@ import noppes.npcs.constants.ScriptContext;
* Manages a single script container for recipe hooks (pre, post).
*/
public class RecipeScript extends SingleScriptHandler implements IScriptHandlerPacket {
-
- /** The recipe ID for packet communication. -1 if not bound. */
+
+ /**
+ * The recipe ID for packet communication. -1 if not bound.
+ */
private int recipeId = -1;
-
- /** Whether this is an anvil recipe (vs carpentry). */
+
+ /**
+ * Whether this is an anvil recipe (vs carpentry).
+ */
private boolean anvil = false;
-
+
/**
* Create an unbound RecipeScript (for server-side use).
*/
public RecipeScript() {
}
-
+
/**
* Create a RecipeScript bound to a specific recipe (for GUI use).
+ *
* @param recipeId The ID of the recipe
- * @param anvil true for anvil recipe, false for carpentry recipe
+ * @param anvil true for anvil recipe, false for carpentry recipe
*/
public RecipeScript(int recipeId, boolean anvil) {
this.recipeId = recipeId;
this.anvil = anvil;
}
-
+
@Override
public ScriptContext getContext() {
return ScriptContext.RECIPE;
}
-
+
@Override
public String noticeString() {
return "RecipeScript";
}
-
+
@Override
public void requestData() {
- if (recipeId >= 0)
+ if (recipeId >= 0)
RecipeScriptPacket.Get(anvil, recipeId);
}
-
+
@Override
public void sendSavePacket(int index, int totalCount, NBTTagCompound nbt) {
- if (recipeId >= 0)
+ if (recipeId >= 0)
RecipeScriptPacket.Save(anvil, recipeId, index, totalCount, nbt);
}
@@ -63,4 +68,4 @@ public class RecipeScript extends SingleScriptHandler implements IScriptHandlerP
this.function = functionName;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/noppes/npcs/controllers/data/ScriptHandler.java b/src/main/java/noppes/npcs/controllers/data/ScriptHandler.java
index dd57b05bb..684c9a45b 100644
--- a/src/main/java/noppes/npcs/controllers/data/ScriptHandler.java
+++ b/src/main/java/noppes/npcs/controllers/data/ScriptHandler.java
@@ -68,6 +68,7 @@ public abstract class ScriptHandler implements IScriptHandler {
public void clear() {
this.scripts = new ArrayList<>();
}
+
/**
* Reset the lastInited timestamp to force re-initialization on next script call.
*/
diff --git a/src/main/java/noppes/npcs/controllers/data/SingleScriptHandler.java b/src/main/java/noppes/npcs/controllers/data/SingleScriptHandler.java
index a047b41b6..00c273bca 100644
--- a/src/main/java/noppes/npcs/controllers/data/SingleScriptHandler.java
+++ b/src/main/java/noppes/npcs/controllers/data/SingleScriptHandler.java
@@ -16,7 +16,7 @@ import java.util.List;
/**
* Base class for script handlers that manage a single script container.
* Provides shared NBT/ByteBuf serialization and packet handling.
- *
+ *
* Subclasses should:
* - Store their parent object (e.g., CustomEffect, LinkedItem)
* - Override getHookContext() to return the appropriate context string
@@ -57,9 +57,9 @@ public abstract class SingleScriptHandler extends ScriptHandler {
@Override
public List getScripts() {
- if(container == null)
+ if (container == null)
return new ArrayList<>();
-
+
return Collections.singletonList(container);
}
@@ -112,7 +112,7 @@ public abstract class SingleScriptHandler extends ScriptHandler {
/**
* Save script data from a ByteBuf packet.
* Handles the tab/totalScripts protocol used by script packets.
- *
+ *
* Protocol:
* - tab == 0: Script content NBT follows
* - tab != 0 (typically -1): Script metadata (language, enabled) follows
diff --git a/src/main/java/noppes/npcs/controllers/data/TraderStock.java b/src/main/java/noppes/npcs/controllers/data/TraderStock.java
index 68bc96c53..85e76ec02 100644
--- a/src/main/java/noppes/npcs/controllers/data/TraderStock.java
+++ b/src/main/java/noppes/npcs/controllers/data/TraderStock.java
@@ -41,7 +41,8 @@ public class TraderStock {
/**
* Get available stock for a slot
- * @param slot The slot index
+ *
+ * @param slot The slot index
* @param playerName The player name (for per-player mode)
* @return Available stock count, or Integer.MAX_VALUE if unlimited
*/
@@ -73,6 +74,7 @@ public class TraderStock {
/**
* Consume stock when purchase is made
+ *
* @return true if successful, false if insufficient stock
*/
public synchronized boolean consumeStock(int slot, String playerName, int amount) {
@@ -98,6 +100,7 @@ public class TraderStock {
/**
* Check if stock should reset based on current time
+ *
* @param currentTime Current MC world time (ticks) or real time (ms) depending on reset type
*/
public boolean shouldReset(long currentTime) {
@@ -113,6 +116,7 @@ public class TraderStock {
/**
* Reset all stock to max values
+ *
* @param currentTime Current time to record as reset time
*/
public synchronized void resetStock(long currentTime) {
@@ -129,6 +133,7 @@ public class TraderStock {
/**
* Get reset interval based on reset type
+ *
* @return Interval in ticks (MC time) or milliseconds (real time)
*/
public long getResetInterval() {
@@ -152,6 +157,7 @@ public class TraderStock {
/**
* Get time until next reset
+ *
* @param currentTime Current time
* @return Time remaining until reset, or -1 if no reset scheduled
*/
@@ -166,6 +172,7 @@ public class TraderStock {
/**
* Format time until reset for display
+ *
* @param currentTime Current time
* @return Formatted string like "2 hours" or "1 day, 5 hours"
*/
@@ -183,7 +190,7 @@ public class TraderStock {
if (days > 0) {
return days + " day" + (days != 1 ? "s" : "") +
- (hours > 0 ? ", " + hours + " hour" + (hours != 1 ? "s" : "") : "");
+ (hours > 0 ? ", " + hours + " hour" + (hours != 1 ? "s" : "") : "");
} else if (hours > 0) {
return hours + " hour" + (hours != 1 ? "s" : "");
} else {
@@ -198,7 +205,7 @@ public class TraderStock {
if (mcDays > 0) {
return mcDays + " MC day" + (mcDays != 1 ? "s" : "") +
- (mcHours > 0 ? ", " + mcHours + " MC hour" + (mcHours != 1 ? "s" : "") : "");
+ (mcHours > 0 ? ", " + mcHours + " MC hour" + (mcHours != 1 ? "s" : "") : "");
} else {
return mcHours + " MC hour" + (mcHours != 1 ? "s" : "");
}
@@ -220,6 +227,7 @@ public class TraderStock {
/**
* Validate and clamp all current stock values to not exceed max stock.
* Should be called when trader GUI opens to ensure consistency.
+ *
* @return true if any stock was clamped
*/
public boolean validateStock() {
diff --git a/src/main/java/noppes/npcs/controllers/data/action/Action.java b/src/main/java/noppes/npcs/controllers/data/action/Action.java
index 729603019..b7bce1102 100644
--- a/src/main/java/noppes/npcs/controllers/data/action/Action.java
+++ b/src/main/java/noppes/npcs/controllers/data/action/Action.java
@@ -274,10 +274,9 @@ public class Action implements IAction {
// return this;
// }
- ///////////////////////////////////////////////////
- //////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ///////////////////////////////////////////////
// Handling
-
@Override
public IAction start() {
manager.start();
@@ -405,10 +404,10 @@ public class Action implements IAction {
public String toString() {
return String.format("%s [queue='%s', scheduled=%s, done=%s, paused=%s, updateEvery=%s, duration=%d/%d, count=%d/%d, threaded=%s]", getIdentifier(), getQueueName(), isScheduled, done, isPaused(), updateEveryXTick, duration, maxDuration, count, maxCount, isThreaded);
}
- ///////////////////////////////////////////////////
- //////////////////////////////////////////////////
- // Thread
+ /// ////////////////////////////////////////////////
+ /// ///////////////////////////////////////////////
+ // Thread
@Override
public IAction threadify() {
if (!isThreaded) {
@@ -469,10 +468,9 @@ public class Action implements IAction {
return startAfterTicks > 0;
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Sequential
-
@Override
public IAction getNext() {
if (queue == null)
@@ -606,10 +604,9 @@ public class Action implements IAction {
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Parallels
-
@Override
public IAction parallel(IAction act) {
if (unscheduledList != null)
@@ -658,10 +655,9 @@ public class Action implements IAction {
return parallel(manager.create(name, maxDuration, delay, t));
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Conditionals
-
@Override
public IConditionalAction conditional(IConditionalAction after) {
if (unscheduledList != null)
diff --git a/src/main/java/noppes/npcs/controllers/data/action/ActionManager.java b/src/main/java/noppes/npcs/controllers/data/action/ActionManager.java
index c36aa04a9..9cdaf4e57 100644
--- a/src/main/java/noppes/npcs/controllers/data/action/ActionManager.java
+++ b/src/main/java/noppes/npcs/controllers/data/action/ActionManager.java
@@ -117,10 +117,9 @@ public class ActionManager implements IActionManager {
// return false;
// }
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Creators
-
@Override
public IAction create(String name) {
return new Action(this, name);
@@ -186,10 +185,9 @@ public class ActionManager implements IActionManager {
return new ConditionalAction(this, name, condition, task, terminateWhen, onTermination);
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Queues
-
@Override
public IActionQueue createQueue(String name) {
return createQueue(name, false);
@@ -237,10 +235,9 @@ public class ActionManager implements IActionManager {
return true;
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Sequential
-
@Override
public IActionQueue getSequentialQueue() {
return sequentialQueue;
@@ -299,10 +296,9 @@ public class ActionManager implements IActionManager {
return sequentialQueue.scheduleActionAt(index, action);
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Parallels
-
@Override
public IActionQueue getParallelQueue() {
return parallelQueue;
@@ -345,7 +341,7 @@ public class ActionManager implements IActionManager {
@Override
public IAction scheduleParallel(String name, int delay, Consumer task) {
- return parallelQueue.schedule(name,delay, task);
+ return parallelQueue.schedule(name, delay, task);
}
@Override
@@ -353,10 +349,9 @@ public class ActionManager implements IActionManager {
return parallelQueue.schedule(name, maxDuration, delay, task);
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Conditionals
-
@Override
public IActionQueue getConditionalQueue() {
return conditionalQueue;
@@ -403,10 +398,9 @@ public class ActionManager implements IActionManager {
return schedule(new ConditionalAction(this, name, condition, task, terminateWhen, onTermination));
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Handling
-
@Override
public IActionQueue[] getAllQueues() {
ArrayList allQueues = new ArrayList<>();
diff --git a/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java b/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java
index 0b3d0b483..332adab39 100644
--- a/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java
+++ b/src/main/java/noppes/npcs/controllers/data/action/ActionQueue.java
@@ -125,10 +125,9 @@ public class ActionQueue implements IActionQueue {
return this;
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Schedulers
-
@Override
public IAction schedule(IAction action) {
Action act = (Action) action;
@@ -203,10 +202,9 @@ public class ActionQueue implements IActionQueue {
return action;
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Queue Data
-
@Override
public boolean hasActiveTasks() {
return !queue.isEmpty();
@@ -276,10 +274,9 @@ public class ActionQueue implements IActionQueue {
return false;
}
- ///////////////////////////////////////////////////
- ///////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
+ /// ////////////////////////////////////////////////
// Handling
-
public boolean finish(Action a) {
if (a.isDone()) {
if (a.onDone != null)
diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java
index c30f15f57..20d2f6d5c 100644
--- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java
+++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java
@@ -67,14 +67,13 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
-import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.ServerChatEvent;
import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
-import noppes.npcs.DataAbilities;
import noppes.npcs.DataAI;
+import noppes.npcs.DataAbilities;
import noppes.npcs.DataAdvanced;
import noppes.npcs.DataDisplay;
import noppes.npcs.DataInventory;
@@ -96,12 +95,12 @@ import noppes.npcs.ai.EntityAIDodgeShoot;
import noppes.npcs.ai.EntityAIFindShade;
import noppes.npcs.ai.EntityAIFollow;
import noppes.npcs.ai.EntityAIJob;
+import noppes.npcs.ai.EntityAILeapAtTargetNpc;
import noppes.npcs.ai.EntityAILook;
import noppes.npcs.ai.EntityAIMoveIndoors;
import noppes.npcs.ai.EntityAIMovingPath;
import noppes.npcs.ai.EntityAIOrbitTarget;
import noppes.npcs.ai.EntityAIPanic;
-import noppes.npcs.ai.EntityAILeapAtTargetNpc;
import noppes.npcs.ai.EntityAIPounceTarget;
import noppes.npcs.ai.EntityAIRangedAttack;
import noppes.npcs.ai.EntityAIReturn;
@@ -155,8 +154,8 @@ import noppes.npcs.roles.JobFollower;
import noppes.npcs.roles.JobInterface;
import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.roles.RoleFollower;
-import noppes.npcs.roles.RoleMount;
import noppes.npcs.roles.RoleInterface;
+import noppes.npcs.roles.RoleMount;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.event.NpcEvent;
@@ -2150,7 +2149,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
protected boolean handleMountedMovement(float strafe, float forward) {
return NPCMountUtil.handleMountedMovement(this, mountState, strafe, forward);
}
-
+
public void performMountedMovement(float strafe, float forward, float moveSpeed) {
this.moveStrafing = strafe;
this.moveForward = forward;
diff --git a/src/main/java/noppes/npcs/items/ItemElementalStaff.java b/src/main/java/noppes/npcs/items/ItemElementalStaff.java
index 45f45c17f..d786222b1 100644
--- a/src/main/java/noppes/npcs/items/ItemElementalStaff.java
+++ b/src/main/java/noppes/npcs/items/ItemElementalStaff.java
@@ -9,7 +9,7 @@ import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcs;
import noppes.npcs.constants.EnumNpcToolMaterial;
-import java.awt.*;
+import java.awt.Color;
import java.util.List;
public class ItemElementalStaff extends ItemStaff {
diff --git a/src/main/java/noppes/npcs/items/ItemNpcScripter.java b/src/main/java/noppes/npcs/items/ItemNpcScripter.java
index c3a88def0..4d503d97a 100644
--- a/src/main/java/noppes/npcs/items/ItemNpcScripter.java
+++ b/src/main/java/noppes/npcs/items/ItemNpcScripter.java
@@ -41,7 +41,7 @@ public class ItemNpcScripter extends Item {
}
return itemStack;
}
-
+
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptEvent, player);
return itemStack;
}
diff --git a/src/main/java/noppes/npcs/items/ItemOrb.java b/src/main/java/noppes/npcs/items/ItemOrb.java
index 04df0e16c..b43ccaef4 100644
--- a/src/main/java/noppes/npcs/items/ItemOrb.java
+++ b/src/main/java/noppes/npcs/items/ItemOrb.java
@@ -5,7 +5,7 @@ import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import java.awt.*;
+import java.awt.Color;
import java.util.List;
public class ItemOrb extends ItemNpcInterface {
diff --git a/src/main/java/noppes/npcs/janino/JaninoHookResolver.java b/src/main/java/noppes/npcs/janino/JaninoHookResolver.java
index 2ff8b4afb..fc0c63f6d 100644
--- a/src/main/java/noppes/npcs/janino/JaninoHookResolver.java
+++ b/src/main/java/noppes/npcs/janino/JaninoHookResolver.java
@@ -4,7 +4,8 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
/**
* Resolves script hook methods for compiled script classes.
diff --git a/src/main/java/noppes/npcs/janino/JaninoScript.java b/src/main/java/noppes/npcs/janino/JaninoScript.java
index 46d0bf164..1800cc895 100644
--- a/src/main/java/noppes/npcs/janino/JaninoScript.java
+++ b/src/main/java/noppes/npcs/janino/JaninoScript.java
@@ -8,13 +8,12 @@ import noppes.npcs.CustomNpcs;
import noppes.npcs.NBTTags;
import noppes.npcs.api.handler.IHookDefinition;
import noppes.npcs.config.ConfigScript;
-import noppes.npcs.controllers.HookDefinition;
-import noppes.npcs.janino.annotations.ParamName;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.data.IScriptUnit;
+import noppes.npcs.janino.annotations.ParamName;
import org.codehaus.commons.compiler.InternalCompilerException;
import org.codehaus.commons.compiler.Sandbox;
@@ -23,7 +22,14 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.Permissions;
import java.security.PrivilegedAction;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -54,7 +60,7 @@ public abstract class JaninoScript implements IScriptUnit {
this.type = type;
this.defaultImports = defaultImports != null ? defaultImports : new String[0];
this.builder = IScriptBodyBuilder.getBuilder(type,
- isClient ? CustomNpcs.getClientCompiler() : CustomNpcs.getDynamicCompiler())
+ isClient ? CustomNpcs.getClientCompiler() : CustomNpcs.getDynamicCompiler())
.setDefaultImports(this.defaultImports);
Permissions permissions = new Permissions();
@@ -67,7 +73,7 @@ public abstract class JaninoScript implements IScriptUnit {
this(type, defaultImports, false);
}
- protected String getHookContext(){
+ protected String getHookContext() {
return this.context.hookContext;
}
@@ -326,7 +332,7 @@ public abstract class JaninoScript implements IScriptUnit {
public static String generateMethodStub(Method method) {
String mods = Modifier.toString(method.getModifiers());
mods = mods.replace("abstract ", "").replace("abstract", "")
- .replace("default ", "").replace("default", "").trim();
+ .replace("default ", "").replace("default", "").trim();
if (!mods.isEmpty()) mods += " ";
String returnTypeStr = getUsableTypeName(method.getReturnType());
@@ -346,7 +352,7 @@ public abstract class JaninoScript implements IScriptUnit {
} else {
// Fallback to generated name
String baseName = Character.toLowerCase(p.getType().getSimpleName().charAt(0))
- + p.getType().getSimpleName().substring(1);
+ + p.getType().getSimpleName().substring(1);
int count = typeCount.getOrDefault(baseName, 0) + 1;
typeCount.put(baseName, count);
paramName = count == 1 ? baseName : baseName + (count - 1);
@@ -393,7 +399,10 @@ public abstract class JaninoScript implements IScriptUnit {
// ==================== IScriptUnit ====================
- @Override public String getScript() { return script; }
+ @Override
+ public String getScript() {
+ return script;
+ }
@Override
public void setScript(String script) {
@@ -402,7 +411,10 @@ public abstract class JaninoScript implements IScriptUnit {
hookResolver.clearResolutionCaches();
}
- @Override public List getExternalScripts() { return externalScripts; }
+ @Override
+ public List getExternalScripts() {
+ return externalScripts;
+ }
@Override
public void setExternalScripts(List scripts) {
@@ -411,8 +423,15 @@ public abstract class JaninoScript implements IScriptUnit {
hookResolver.clearResolutionCaches();
}
- @Override public TreeMap getConsole() { return console; }
- @Override public void clearConsole() { console.clear(); }
+ @Override
+ public TreeMap getConsole() {
+ return console;
+ }
+
+ @Override
+ public void clearConsole() {
+ console.clear();
+ }
@Override
public void appendConsole(String message) {
@@ -427,16 +446,29 @@ public abstract class JaninoScript implements IScriptUnit {
}
}
- @Override public String getLanguage() { return "Java"; }
- @Override public void setLanguage(String language) { }
+ @Override
+ public String getLanguage() {
+ return "Java";
+ }
+
+ @Override
+ public void setLanguage(String language) {
+ }
@Override
public boolean hasCode() {
return !externalScripts.isEmpty() || (script != null && !script.isEmpty());
}
- @Override public boolean hasErrored() { return errored; }
- @Override public void setErrored(boolean errored) { this.errored = errored; }
+ @Override
+ public boolean hasErrored() {
+ return errored;
+ }
+
+ @Override
+ public void setErrored(boolean errored) {
+ this.errored = errored;
+ }
// ==================== NBT ====================
diff --git a/src/main/java/noppes/npcs/janino/annotations/ParamName.java b/src/main/java/noppes/npcs/janino/annotations/ParamName.java
index 6b1e9ec25..deb8ed85c 100644
--- a/src/main/java/noppes/npcs/janino/annotations/ParamName.java
+++ b/src/main/java/noppes/npcs/janino/annotations/ParamName.java
@@ -12,9 +12,13 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
public @interface ParamName {
- /** The parameter name (e.g., "event") */
+ /**
+ * The parameter name (e.g., "event")
+ */
String value();
-
- /** The fully qualified type name (e.g., "noppes.npcs.api.event.INpcEvent.InitEvent") */
+
+ /**
+ * The fully qualified type name (e.g., "noppes.npcs.api.event.INpcEvent.InitEvent")
+ */
String type() default "";
}
diff --git a/src/main/java/noppes/npcs/roles/RoleTrader.java b/src/main/java/noppes/npcs/roles/RoleTrader.java
index 107076a44..91a116efc 100644
--- a/src/main/java/noppes/npcs/roles/RoleTrader.java
+++ b/src/main/java/noppes/npcs/roles/RoleTrader.java
@@ -238,9 +238,9 @@ public class RoleTrader extends RoleInterface {
* Consume stock after purchase.
* For shared stock, syncs all viewers (market-wide for linked markets, per-NPC otherwise).
*
- * @param slot The slot purchased from
+ * @param slot The slot purchased from
* @param playerName The player making the purchase
- * @param amount Amount to consume
+ * @param amount Amount to consume
* @return true if stock was consumed successfully
*/
public boolean consumeStock(int slot, String playerName, int amount) {
@@ -284,6 +284,7 @@ public class RoleTrader extends RoleInterface {
/**
* Get time until stock reset in real-time milliseconds.
* Converts MC ticks to approximate real-time for client countdown display.
+ *
* @return Remaining time in milliseconds, or -1 if no reset scheduled
*/
public long getResetTimeRemainingMillis() {
diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java
index 3d71e0023..ecf4b8ba0 100644
--- a/src/main/java/noppes/npcs/scripted/NpcAPI.java
+++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.eventhandler.EventBus;
import foxz.command.ScriptedCommand;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.ProfileController;
+import kamkeel.npcs.controllers.data.ability.AbilityController;
import net.minecraft.block.Block;
import net.minecraft.command.CommandHandler;
import net.minecraft.entity.Entity;
@@ -59,7 +60,22 @@ import noppes.npcs.api.entity.ICustomNpc;
import noppes.npcs.api.entity.IEntity;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.gui.ICustomGui;
-import noppes.npcs.api.handler.*;
+import noppes.npcs.api.handler.IAbilityHandler;
+import noppes.npcs.api.handler.IActionManager;
+import noppes.npcs.api.handler.IAnimationHandler;
+import noppes.npcs.api.handler.IAttributeHandler;
+import noppes.npcs.api.handler.ICloneHandler;
+import noppes.npcs.api.handler.ICustomEffectHandler;
+import noppes.npcs.api.handler.IDialogHandler;
+import noppes.npcs.api.handler.IFactionHandler;
+import noppes.npcs.api.handler.IMagicHandler;
+import noppes.npcs.api.handler.INaturalSpawnsHandler;
+import noppes.npcs.api.handler.IPartyHandler;
+import noppes.npcs.api.handler.IProfileHandler;
+import noppes.npcs.api.handler.IQuestHandler;
+import noppes.npcs.api.handler.IRecipeHandler;
+import noppes.npcs.api.handler.IScriptHookHandler;
+import noppes.npcs.api.handler.ITransportHandler;
import noppes.npcs.api.handler.data.IAnimation;
import noppes.npcs.api.handler.data.IFrame;
import noppes.npcs.api.handler.data.IFramePart;
@@ -70,7 +86,6 @@ import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.config.ConfigScript;
import noppes.npcs.constants.EnumAnimationPart;
import noppes.npcs.containers.ContainerNpcInterface;
-import kamkeel.npcs.controllers.data.ability.AbilityController;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.ChunkController;
import noppes.npcs.controllers.CustomEffectController;
@@ -81,8 +96,8 @@ import noppes.npcs.controllers.PartyController;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.RecipeController;
import noppes.npcs.controllers.ScriptController;
-import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.ScriptEntityData;
+import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.SpawnController;
import noppes.npcs.controllers.TransportController;
diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java
index 85a15041e..f2cfc9a34 100644
--- a/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java
+++ b/src/main/java/noppes/npcs/scripted/entity/ScriptPlayer.java
@@ -39,7 +39,6 @@ import noppes.npcs.api.handler.IOverlayHandler;
import noppes.npcs.api.handler.data.IAnimationData;
import noppes.npcs.api.handler.data.IDialog;
import noppes.npcs.api.handler.data.IMagicData;
-import noppes.npcs.api.handler.data.IParty;
import noppes.npcs.api.handler.data.IPlayerAttributes;
import noppes.npcs.api.handler.data.IQuest;
import noppes.npcs.api.handler.data.ISound;
@@ -882,13 +881,13 @@ public class ScriptPlayer extends ScriptLivingBase
@Override
- public IPlayer[] getPartyMembers(){
+ public IPlayer[] getPartyMembers() {
Party party = this.getData().getPlayerParty();
if (party == null) {
throw new CustomNPCsException("Player is not in party");
}
- List list = new ArrayList<>();
- for(int i = 0; i < party.getPlayerNamesList().size();i++){
+ List list = new ArrayList<>();
+ for (int i = 0; i < party.getPlayerNamesList().size(); i++) {
IPlayer player = NpcAPI.Instance().getPlayer(party.getPlayerNamesList().get(i));
if (player == null) continue;
list.add(player);
diff --git a/src/main/java/noppes/npcs/scripted/event/AbilityEvent.java b/src/main/java/noppes/npcs/scripted/event/AbilityEvent.java
index 9baf245a2..9bf7719d5 100644
--- a/src/main/java/noppes/npcs/scripted/event/AbilityEvent.java
+++ b/src/main/java/noppes/npcs/scripted/event/AbilityEvent.java
@@ -125,7 +125,7 @@ public class AbilityEvent extends NpcEvent implements IAbilityEvent {
private float knockbackUp;
public HitEvent(ICustomNpc npc, Ability ability, EntityLivingBase target,
- EntityLivingBase hitEntity, float damage, float knockback, float knockbackUp) {
+ EntityLivingBase hitEntity, float damage, float knockback, float knockbackUp) {
super(npc, ability, target);
this.hitEntity = hitEntity != null ? (IEntityLivingBase) NpcAPI.Instance().getIEntity(hitEntity) : null;
this.damage = damage;
diff --git a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java
index 0ca2fa778..e3641570e 100644
--- a/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java
+++ b/src/main/java/noppes/npcs/scripted/item/ScriptCustomItem.java
@@ -10,10 +10,10 @@ import noppes.npcs.NBTTags;
import noppes.npcs.api.item.IItemCustom;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.constants.ScriptContext;
-import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.IScriptHandler;
import noppes.npcs.controllers.data.IScriptHandlerPacket;
+import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.scripted.CustomNPCsException;
import java.util.ArrayList;
@@ -279,7 +279,7 @@ public class ScriptCustomItem extends ScriptCustomizableItem implements IItemCus
}
public void setAttackSpeed(int speed) {
- if(speed <= 0) {
+ if (speed <= 0) {
speed = 10;
}
this.attackSpeed = speed;
diff --git a/src/main/java/noppes/npcs/util/NPCMountUtil.java b/src/main/java/noppes/npcs/util/NPCMountUtil.java
index 6303f67b9..9c3cce57f 100644
--- a/src/main/java/noppes/npcs/util/NPCMountUtil.java
+++ b/src/main/java/noppes/npcs/util/NPCMountUtil.java
@@ -5,10 +5,10 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import noppes.npcs.CustomNpcs;
+import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityNPCInterface;
-import noppes.npcs.constants.EnumRoleType;
import noppes.npcs.roles.RoleMount;
public final class NPCMountUtil {
diff --git a/src/main/java/noppes/npcs/util/ValueUtil.java b/src/main/java/noppes/npcs/util/ValueUtil.java
index a81fb9fef..71846afcc 100644
--- a/src/main/java/noppes/npcs/util/ValueUtil.java
+++ b/src/main/java/noppes/npcs/util/ValueUtil.java
@@ -9,7 +9,7 @@ public class ValueUtil {
public static double lerp(double start, double end, double delta) {
return start + delta * (end - start);
}
-
+
public static float clamp(float given, float min, float max) {
if (given < min)
return min;
diff --git a/src/main/java/somehussar/janino/AdvancedClassFilter.java b/src/main/java/somehussar/janino/AdvancedClassFilter.java
index b48de2c30..7c2d51834 100644
--- a/src/main/java/somehussar/janino/AdvancedClassFilter.java
+++ b/src/main/java/somehussar/janino/AdvancedClassFilter.java
@@ -24,14 +24,17 @@ public class AdvancedClassFilter implements LoadClassCondition {
allowedWildCards.addAll(Arrays.stream(classRegexes).map(Pattern::compile).collect(Collectors.toList()));
return this;
}
+
public AdvancedClassFilter banRegexes(String... classRegexes) {
bannedWildCards.addAll(Arrays.stream(classRegexes).map(Pattern::compile).collect(Collectors.toList()));
return this;
}
+
public AdvancedClassFilter addClasses(String... classPath) {
allowedClasses.addAll(Arrays.asList(classPath));
return this;
}
+
public AdvancedClassFilter banClasses(String... classPath) {
bannedClasses.addAll(Arrays.asList(classPath));
return this;
diff --git a/src/main/java/somehussar/janino/EntityUnloadListener.java b/src/main/java/somehussar/janino/EntityUnloadListener.java
index 592b0750c..b4777e712 100644
--- a/src/main/java/somehussar/janino/EntityUnloadListener.java
+++ b/src/main/java/somehussar/janino/EntityUnloadListener.java
@@ -47,7 +47,7 @@ public class EntityUnloadListener implements IWorldAccess {
EntityNPCInterface npc = (EntityNPCInterface) entity;
// TODO: REMOVE SCRIPTED OBJECT AND CLASSLOADER FOR IT
}
- }
+ }
@Override
public void playRecord(String p_72702_1_, int p_72702_2_, int p_72702_3_, int p_72702_4_) {