HUGE CORE COMMIT

This commit is contained in:
Kam committed 2026-03-13 15:18:13 -04:00
1 parent 57e6934fe5
commit 43a52ad407
125 files changed
+1801 -413

No files matched your search

@@ -0,0 +1,7 @@
package noppes.npcs.constants;
public class AiMutex {
public static byte PASSIVE = 1; //Usually ai which runs ones
public static byte LOOK = 2; //Used for ai which affect rotation
public static byte PATHING = 4; //Used for ai which runs during pathing
}
@@ -0,0 +1,21 @@
package noppes.npcs.constants;
public enum EnumAnimation {
NONE, SITTING, LYING, SNEAKING, DANCING, AIMING, CRAWLING, HUG, CRY, WAVING, BOW;
public int getWalkingAnimation() {
if (this == SNEAKING)
return 1;
if (this == AIMING)
return 2;
if (this == DANCING)
return 3;
if (this == CRAWLING)
return 4;
if (this == HUG)
return 5;
return 0;
}
}
@@ -0,0 +1,11 @@
package noppes.npcs.constants;
public enum EnumAnimationPart {
HEAD,
BODY,
RIGHT_ARM,
LEFT_ARM,
RIGHT_LEG,
LEFT_LEG,
FULL_MODEL;
}
@@ -0,0 +1,28 @@
package noppes.npcs.constants;
/**
* Enum for auction GUI page navigation.
* Maps page indices to GUI types for packet-based navigation.
*/
public enum EnumAuctionPage {
LISTINGS(EnumGuiType.PlayerAuction),
SELL(EnumGuiType.PlayerAuctionSell),
TRADES(EnumGuiType.PlayerAuctionTrades);
private final EnumGuiType guiType;
EnumAuctionPage(EnumGuiType guiType) {
this.guiType = guiType;
}
public EnumGuiType getGuiType() {
return guiType;
}
public static EnumAuctionPage fromOrdinal(int ordinal) {
if (ordinal >= 0 && ordinal < values().length) {
return values()[ordinal];
}
return LISTINGS;
}
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumAvailabilityDialog {
Always, After, Before
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumAvailabilityFaction {
Friendly, Neutral, Hostile
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumAvailabilityFactionType {
Always, Is, IsNot
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumAvailabilityQuest {
Always, After, Before, Active, NotActive, Acceptable, NotAcceptable
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumBannerVariant {
Normal, Curved, Pointy, Triangle, Torn
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumBardInstrument {
None, Banjo, Violin, Guitar, Harp, FrenchHorn
}
@@ -0,0 +1,13 @@
package noppes.npcs.constants;
/**
* Identifies which controller a category operation targets.
* Used by category packets to route to the correct CategoryManager.
*/
public class EnumCategoryType {
public static final int EFFECT = 1;
public static final int ANIMATION = 2;
public static final int LINKED_ITEM = 3;
public static final int ABILITY = 4;
public static final int CHAINED_ABILITY = 5;
}
@@ -0,0 +1,24 @@
package noppes.npcs.constants;
import java.util.ArrayList;
public enum EnumCombatPolicy {
Flip("aicombat.flip"),
Brute("aicombat.brute"),
Stubborn("aicombat.stubborn"),
Tactical("aicombat.tactical");
public final String name;
EnumCombatPolicy(String name) {
this.name = name;
}
public static String[] names() {
ArrayList<String> list = new ArrayList<String>();
for (EnumCombatPolicy e : values())
list.add(e.name);
return list.toArray(new String[list.size()]);
}
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumCompanionJobs {
NONE, SOLDIER, GUARD, FARMER, MINER, SHOP, ROBOT
}
@@ -0,0 +1,19 @@
package noppes.npcs.constants;
public enum EnumCompanionStage {
BABY(0, EnumAnimation.CRAWLING, "companion.baby"),
CHILD(72000, EnumAnimation.NONE, "companion.child"),
TEEN(180000, EnumAnimation.NONE, "companion.teenager"),
ADULT(324000, EnumAnimation.NONE, "companion.adult"),
FULLGROWN(450000, EnumAnimation.NONE, "companion.fullgrown");
public int matureAge;
public EnumAnimation animation;
public String name;
EnumCompanionStage(int age, EnumAnimation animation, String name) {
this.matureAge = age;
this.animation = animation;
this.name = name;
}
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumDayTime {
Always, Night, Day
}
@@ -0,0 +1,37 @@
package noppes.npcs.constants;
import java.util.ArrayList;
public enum EnumDiagramLayout {
CIRCULAR("diagram.circular"),
SQUARE("diagram.square"),
TREE("diagram.tree"),
GENERATED("diagram.generated"),
CIRCULAR_MANUAL("diagram.circular_manual"),
SQUARE_MANUAL("diagram.square_manual"),
TREE_MANUAL("diagram.tree_manual"),
CHART("diagram.chart"),
MANUAL("diagram.manual");
private String lang;
EnumDiagramLayout(String langName) {
this.lang = langName;
}
public String getLang() {
return lang;
}
public static String[] names() {
ArrayList<String> list = new ArrayList<String>();
for (EnumDiagramLayout e : values())
list.add(e.lang);
return list.toArray(new String[list.size()]);
}
public boolean isManual() {
return this == CIRCULAR_MANUAL || this == SQUARE_MANUAL || this == TREE_MANUAL;
}
}
@@ -0,0 +1,73 @@
package noppes.npcs.constants;
public enum EnumGuiType {
MainMenuDisplay,
MainMenuInv,
MainMenuStats,
ManageFactions,
ManageTags,
ManageCustomForms,
ManageCustomAuras,
ManageAnimations,
MainMenuAdvanced,
MainMenuGlobal,
PlayerBankSmall,
PlayerFollowerHire,
PlayerFollower,
SetupItemGiver,
SetupTrader,
SetupFollower,
PlayerTrader,
PlayerTransporter,
RedstoneBlock,
SetupTransporter,
ManageTransport,
ManageBanks,
Cloner,
SetupBank,
ManageDialogs,
ManageQuests,
PlayerCarpentryBench,
PlayerAnvil,
QuestReward,
ManageRecipes,
ManageEffects,
QuestItem,
NpcRemote,
GlobalRemote,
ScriptEvent,
MoneyBag,
MainMenuAI,
MovingPath,
PlayerBankUnlock,
PlayerBankUprade,
PlayerBankLarge,
MobSpawnerAdd,
PlayerMailbox,
PlayerMailman,
Waypoint,
MerchantAdd,
MobSpawnerMounter,
Crate,
NpcDimensions,
Border,
BigSign,
Script,
Companion,
CompanionInv,
CompanionTalent,
CompanionTrader,
ManageLinked,
ManageMagic,
CustomGui,
ScriptItem,
ScriptBlock,
Paintbrush,
MagicBook,
ManageAbilities,
PlayerAuction,
PlayerAuctionSell,
PlayerAuctionTrades,
PlayerAuctionBidding,
ManageAuction;
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumJobType {
None, Bard, Healer, Guard, ItemGiver, Follower, Spawner, Conversation, ChunkLoader
}
@@ -0,0 +1,23 @@
package noppes.npcs.constants;
import java.util.ArrayList;
public enum EnumMovingType {
Standing("ai.standing"),
Wandering("ai.wandering"),
MovingPath("ai.movingpath");
String name;
EnumMovingType(String name) {
this.name = name;
}
public static String[] names() {
ArrayList<String> list = new ArrayList<String>();
for (EnumMovingType e : values())
list.add(e.name);
return list.toArray(new String[list.size()]);
}
}
@@ -0,0 +1,27 @@
package noppes.npcs.constants;
import java.util.ArrayList;
public enum EnumNavType {
Default("aitactics.rush"),
Dodge("aitactics.stagger"),
Surround("aitactics.orbit"),
HitNRun("aitactics.hitandrun"),
Ambush("aitactics.ambush"),
Stalk("aitactics.stalk"),
None("gui.none");
String name;
EnumNavType(String name) {
this.name = name;
}
public static String[] names() {
ArrayList<String> list = new ArrayList<String>();
for (EnumNavType e : values())
list.add(e.name);
return list.toArray(new String[list.size()]);
}
}
@@ -0,0 +1,82 @@
package noppes.npcs.constants;
public enum EnumNpcToolMaterial {
WOOD(0, 59, 2.0F, 0, 15),
STONE(1, 131, 4.0F, 1, 5),
BRONZE(2, 170, 5.0F, 2, 15),
IRON(2, 250, 6.0F, 2, 14),
DIA(3, 1561, 8.0F, 3, 10),
GOLD(0, 32, 12.0F, 1, 22),
EMERALD(3, 1000, 8.0F, 4, 10),
DEMONIC(3, 100, 8.0F, 6, 10),
FROST(2, 59, 6.0F, 3, 5),
MITHRIL(3, 3000, 8.0F, 3, 10);
/**
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD)
*/
private final int harvestLevel;
/**
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
*/
private final int maxUses;
/**
* The strength of this tool material against blocks which it is effective against.
*/
private final float efficiencyOnProperMaterial;
/**
* Damage versus entities.
*/
private final int damageVsEntity;
/**
* Defines the natural enchantability factor of the material.
*/
private final int enchantability;
private EnumNpcToolMaterial(int par3, int par4, float par5, int par6, int par7) {
this.harvestLevel = par3;
this.maxUses = par4;
this.efficiencyOnProperMaterial = par5;
this.damageVsEntity = par6;
this.enchantability = par7;
}
/**
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
*/
public int getMaxUses() {
return this.maxUses;
}
/**
* The strength of this tool material against blocks which it is effective against.
*/
public float getEfficiencyOnProperMaterial() {
return this.efficiencyOnProperMaterial;
}
/**
* Damage versus entities.
*/
public int getDamageVsEntity() {
return this.damageVsEntity;
}
/**
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD)
*/
public int getHarvestLevel() {
return this.harvestLevel;
}
/**
* Return the natural enchantability factor of the material.
*/
public int getEnchantability() {
return this.enchantability;
}
}
@@ -0,0 +1,6 @@
package noppes.npcs.constants;
public enum EnumOptionType {
QuitOption, DialogOption, Disabled, RoleOption, CommandBlock;
}
@@ -0,0 +1,29 @@
package noppes.npcs.constants;
public enum EnumParticleType {
None(""),
Smoke("smoke"),
Portal("portal"),
Redstone("reddust"),
Lightning("magicCrit"),
LargeSmoke("largesmoke"),
Magic("witchMagic"),
Enchant("enchantmenttable"),
Crit("crit"),
Explode("explode"),
Music("note"),
Flame("flame"),
Lava("lava"),
Splash("splash"),
Slime("slime"),
Heart("heart"),
AngryVillager("angryVillager"),
HappyVillager("happyVillager"),
Custom("custom");
public String particleName;
EnumParticleType(String name) {
this.particleName = name;
}
}
@@ -0,0 +1,24 @@
package noppes.npcs.constants;
import java.util.ArrayList;
public enum EnumPartyExchange {
Leader("party.leader"),
All("party.all"),
Enrolled("party.enrolled"),
Valid("party.valid");
public final String name;
EnumPartyExchange(String name) {
this.name = name;
}
public static String[] names() {
ArrayList<String> list = new ArrayList<String>();
for (EnumPartyExchange e : values())
list.add(e.name);
return list.toArray(new String[list.size()]);
}
}
@@ -0,0 +1,23 @@
package noppes.npcs.constants;
import java.util.ArrayList;
public enum EnumPartyObjectives {
Shared("party.shared"),
All("party.all"),
Leader("party.leader");
public final String name;
EnumPartyObjectives(String name) {
this.name = name;
}
public static String[] names() {
ArrayList<String> list = new ArrayList<String>();
for (EnumPartyObjectives e : values())
list.add(e.name);
return list.toArray(new String[list.size()]);
}
}
@@ -0,0 +1,23 @@
package noppes.npcs.constants;
import java.util.ArrayList;
public enum EnumPartyRequirements {
Leader("party.leader"),
All("party.all"),
Valid("party.valid");
public final String name;
EnumPartyRequirements(String name) {
this.name = name;
}
public static String[] names() {
ArrayList<String> list = new ArrayList<String>();
for (EnumPartyRequirements e : values())
list.add(e.name);
return list.toArray(new String[list.size()]);
}
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumPlayerData {
Players, Quest, Dialog, Transport, Bank, Factions, Magic
}
@@ -0,0 +1,29 @@
package noppes.npcs.constants;
public enum EnumPlayerPacket {
// FollowerHire, // Finished
// FollowerExtend,
// FollowerState,
// Transport,
// BankUnlock,
// BankUpgrade,
// Dialog,
// QuestLog,
// TrackedQuest,
// CheckQuestCompletion,
// BankSlotOpen,
// FactionsGet,
// MailGet,
// MailDelete,
// MailSend,
// MailRead,
// MailboxOpenMail,
// SignSave,
// SaveBook,
// CompanionOpenInv,
// RoleGet,
// KeyPressed,
// MouseClicked,
// CompanionTalentExp,
// ScreenSize
}
@@ -0,0 +1,22 @@
package noppes.npcs.constants;
import java.util.ArrayList;
public enum EnumProfileSync {
Individual("profile.individual"),
Shared("party.shared");
public final String name;
EnumProfileSync(String name) {
this.name = name;
}
public static String[] names() {
ArrayList<String> list = new ArrayList<String>();
for (EnumProfileSync e : values())
list.add(e.name);
return list.toArray(new String[list.size()]);
}
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumQuestCompletion {
Npc, Instant;
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumQuestRepeat {
NONE, REPEATABLE, MCDAILY, MCWEEKLY, RLDAILY, RLWEEKLY, MCCUSTOM, RLCUSTOM;
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumQuestType {
Item, Dialog, Kill, Location, AreaKill, Manual;
}
@@ -0,0 +1,6 @@
package noppes.npcs.constants;
public enum EnumRoleType {
None, Trader, Follower, Bank, Transporter, Postman, Companion, Mount, Auctioneer
}
@@ -0,0 +1,178 @@
package noppes.npcs.constants;
public enum EnumScriptType {
INIT("init"),
TICK("tick"),
INTERACT("interact"),
DIALOG("dialog"),
DAMAGED("damaged"),
KILLED("killed"),
ATTACK("attack"),
TARGET("target"),
COLLIDE("collide"),
KILLS("kills"),
DIALOG_CLOSE("dialogClose"),
TIMER("timer"),
TARGET_LOST("targetLost"),
PROJECTILE_TICK("projectileTick"),
PROJECTILE_IMPACT("projectileImpact"),
ATTACKED("attacked"),
ATTACK_MELEE("meleeAttack"),
ATTACK_SWING("meleeSwing"),
RIGHT_CLICK("rightClick"),
ROLE("role"),
RANGED_CHARGE("rangedCharge"),
RANGED_LAUNCHED("rangedLaunched"),
CLICKED("clicked"),
FALLEN_UPON("fallenUpon"),
RAIN_FILLED("rainFilled"),
BROKEN("broken"),
HARVESTED("harvested"),
EXPLODED("exploded"),
NEIGHBOR_CHANGED("neighborChanged"),
REDSTONE("redstone"),
DOOR_TOGGLE("doorToggle"),
TOSS("toss"),
DROP("drop"),
CONTAINER_OPEN("containerOpen"),
CONTAINER_CLOSED("containerClosed"),
LOGIN("login"),
LOGOUT("logout"),
CHAT("chat"),
DAMAGED_ENTITY("damagedEntity"),
SPAWN("spawn"),
TOSSED("tossed"),
PICKEDUP("pickedUp"),
PICKUP("pickUp"),
LEVEL_UP("levelUp"),
KEY_PRESSED("keyPressed"),
QUEST_EVENT("questEvent"),
QUEST_START("questStart"),
QUEST_COMPLETED("questCompleted"),
QUEST_TURNIN("questTurnIn"),
FACTION_EVENT("factionEvent"),
FACTION_POINTS("factionPoints"),
DIALOG_EVENT("dialogEvent"),
DIALOG_OPEN("dialogOpen"),
DIALOG_OPTION("dialogOption"),
CUSTOM_CHEST_CLOSED("customChestClosed"),
CUSTOM_CHEST_CLICKED("customChestClicked"),
SCRIPT_COMMAND("scriptCommand"),
CUSTOM_GUI_EVENT("customGuiEvent"),
CUSTOM_GUI_CLOSED("customGuiClosed"),
CUSTOM_GUI_BUTTON("customGuiButton"),
CUSTOM_GUI_SLOT("customGuiSlot"),
CUSTOM_GUI_SLOT_CLICKED("customGuiSlotClicked"),
CUSTOM_GUI_SCROLL("customGuiScroll"),
CUSTOM_GUI_TEXTFIELD("customGuiTextfield"),
PICKUP_XP("pickupXP"),
MOUSE_CLICKED("mouseClicked"),
START_USING_ITEM("startItem"),
USING_ITEM("usingItem"),
STOP_USING_ITEM("stopItem"),
FINISH_USING_ITEM("finishItem"),
REPAIR_ITEM("repairItem"),
BREAK_ITEM("breakItem"),
USE_HOE("useHoe"),
SLEEP("sleep"),
WAKE_UP("wakeUp"),
FILL_BUCKET("fillBucket"),
BONEMEAL("bonemeal"),
ACHIEVEMENT("achievement"),
FALL("fall"),
JUMP("jump"),
LIGHTNING("lightning"),
PLAYSOUND("playSound"),
RESPAWN("respawn"),
CHANGED_DIM("changedDim"),
BREAK_BLOCK("breakBlock"),
FORGE_EVENT("forgeEvent"),
FORGE_INIT("forgeInit"),
FORGE_ENTITY("forgeEntity"),
FORGE_WORLD("forgeWorld"),
CNPC_NATURAL_SPAWN("onCNPCNaturalSpawn"),
CUSTOM_ITEM_EVENT("customItemEvent"),
PARTY_EVENT("partyEvent"),
PARTY_QUEST_COMPLETED("partyQuestCompleted"),
PARTY_QUEST_SET("partyQuestSet"),
PARTY_QUEST_TURNED_IN("partyQuestTurnedIn"),
PARTY_INVITE("partyInvite"),
PARTY_KICK("partyKick"),
PARTY_LEAVE("partyLeave"),
PARTY_DISBAND("partyDisband"),
ANIMATION_START("animationStart"),
ANIMATION_END("animationEnd"),
ANIMATION_FRAME_ENTER("frameEnter"),
ANIMATION_FRAME_EXIT("frameExit"),
LINKED_ITEM_VERSION("versionChanged"),
LINKED_ITEM_BUILD("buildingItem"),
PROFILE("profile"),
PROFILE_CHANGE("profileChange"),
PROFILE_REMOVE("profileRemove"),
PROFILE_CREATE("profileCreate"),
ON_EFFECT_ADD("onEffectAdd"),
ON_EFFECT_TICK("onEffectTick"),
ON_EFFECT_REMOVE("onEffectRemove"),
ABILITY_START("abilityStart"),
ABILITY_EXECUTE("abilityExecute"),
ABILITY_INTERRUPT("abilityInterrupt"),
ABILITY_COMPLETE("abilityComplete"),
ABILITY_HIT("abilityHit"),
ABILITY_TICK("abilityTick"),
ABILITY_TOGGLE("abilityToggle"),
ABILITY_TOGGLE_TICK("abilityToggleTick"),
CHAIN_START("chainStart"),
CHAIN_NEXT("chainNext"),
CHAIN_COMPLETE("chainComplete"),
CHAIN_INTERRUPT("chainInterrupt"),
ENERGY_PROJECTILE_FIRED("energyProjectileFired"),
ENERGY_PROJECTILE_TICK("energyProjectileTick"),
ENERGY_PROJECTILE_ENTITY_IMPACT("energyProjectileEntityImpact"),
ENERGY_PROJECTILE_BLOCK_IMPACT("energyProjectileBlockImpact"),
ENERGY_PROJECTILE_EXPIRED("energyProjectileExpired"),
// Energy Barrier Events
ENERGY_BARRIER_SPAWNED("energyBarrierSpawned"),
ENERGY_BARRIER_TICK("energyBarrierTick"),
ENERGY_BARRIER_HIT("energyBarrierHit"),
ENERGY_BARRIER_DESTROYED("energyBarrierDestroyed"),
// Auction Events
AUCTION_CREATE("auctionCreate"),
AUCTION_BID("auctionBid"),
AUCTION_BUYOUT("auctionBuyout"),
AUCTION_CANCEL("auctionCancel"),
AUCTION_CLAIM("auctionClaim");
public String function;
private static final java.util.Map<String, EnumScriptType> BY_FUNCTION = new java.util.HashMap<>();
static {
for (EnumScriptType type : values()) {
BY_FUNCTION.put(type.function, type);
}
}
public static EnumScriptType valueOfIgnoreCase(String channelName) {
// First try by function name (e.g. "abilityStart")
EnumScriptType type = BY_FUNCTION.get(channelName);
if (type != null) {
return type;
}
// Fallback to enum constant name (e.g. "ABILITY_START")
return valueOf(channelName.toUpperCase());
}
private EnumScriptType(String function) {
this.function = function;
}
}
@@ -0,0 +1,17 @@
package noppes.npcs.constants;
public enum EnumScrollData {
OPTIONAL,
MAGIC,
MAGIC_CYCLES,
DIALOG_GROUP,
QUEST_GROUP,
ABILITY_TYPES,
CUSTOM_ABILITIES,
BUILTIN_ABILITIES,
ANIMATIONS,
BUILTIN_ANIMATIONS,
CHAINED_ABILITIES,
CATEGORY_GROUP,
CATEGORY_LIST
}
@@ -0,0 +1,5 @@
package noppes.npcs.constants;
public enum EnumStandingType {
RotateBody, NoRotation, Stalking, HeadRotation
}
@@ -0,0 +1,81 @@
package noppes.npcs.constants;
/**
* Stock reset types for Trader NPCs.
* Mirrors EnumQuestRepeat pattern for consistency.
*/
public enum EnumStockReset {
NONE("stock.reset.never"),
MCDAILY("stock.reset.mcdaily"),
MCWEEKLY("stock.reset.mcweekly"),
MCCUSTOM("stock.reset.mccustom"),
RLDAILY("stock.reset.rldaily"),
RLWEEKLY("stock.reset.rlweekly"),
RLCUSTOM("stock.reset.rlcustom");
private final String langKey;
EnumStockReset(String langKey) {
this.langKey = langKey;
}
/**
* Get the language key for localization.
*/
public String getLangKey() {
return langKey;
}
/**
* Get reset interval in milliseconds for real-time types
* or ticks for MC-time types
*/
public long getDefaultInterval() {
switch (this) {
case MCDAILY:
return 24000; // MC ticks
case MCWEEKLY:
return 168000; // MC ticks (7 days)
case RLDAILY:
return 86400000L; // 24 hours in ms
case RLWEEKLY:
return 604800000L; // 7 days in ms
default:
return 0;
}
}
/**
* Check if this reset type uses real-world time
*/
public boolean isRealTime() {
return this == RLDAILY || this == RLWEEKLY || this == RLCUSTOM;
}
/**
* Check if this reset type uses Minecraft time
*/
public boolean isMinecraftTime() {
return this == MCDAILY || this == MCWEEKLY || this == MCCUSTOM;
}
/**
* Get display name - returns the lang key for platform-specific translation.
*/
public String getDisplayName() {
return langKey;
}
/**
* Get all lang keys for dropdown menus.
* Platform code should translate these via the version-specific localization system.
*/
public static String[] getDisplayNames() {
EnumStockReset[] values = values();
String[] names = new String[values.length];
for (int i = 0; i < values.length; i++) {
names[i] = values[i].langKey;
}
return names;
}
}
@@ -0,0 +1,26 @@
package noppes.npcs.constants;
import java.util.ArrayList;
public enum EnumTextureType {
BASE("texture.base"),
ITEM("texture.item");
private String lang;
EnumTextureType(String langName) {
this.lang = langName;
}
public String getLang() {
return lang;
}
public static String[] names() {
ArrayList<String> list = new ArrayList<String>();
for (EnumTextureType e : values())
list.add(e.lang);
return list.toArray(new String[list.size()]);
}
}
@@ -0,0 +1,35 @@
package noppes.npcs.constants;
/**
* Enum for trade slot types in the player's auction trades view.
* Used by ContainerAuctionTrades to identify what each slot contains.
*/
public enum EnumTradeSlotType {
EMPTY,
SELLING,
BIDDING,
CLAIM;
public boolean isSelling() {
return this == SELLING;
}
public boolean isBidding() {
return this == BIDDING;
}
public boolean isClaim() {
return this == CLAIM;
}
public boolean isEmpty() {
return this == EMPTY;
}
public static EnumTradeSlotType fromOrdinal(int ordinal) {
if (ordinal >= 0 && ordinal < values().length) {
return values()[ordinal];
}
return EMPTY;
}
}
@@ -0,0 +1,11 @@
package noppes.npcs.constants;
public class MarkType {
public static final int NONE = 0;
public static final int QUESTION = 1;
public static final int EXCLAMATION = 2;
public static final int POINTER = 3;
public static final int SKULL = 4;
public static final int CROSS = 5;
public static final int STAR = 6;
}
@@ -0,0 +1,26 @@
package noppes.npcs.constants;
/**
* NBT type ID constants, matching Minecraft's internal NBT type numbering.
* These are stable across all MC versions.
*
* Use these instead of magic numbers when calling INBTCompound.hasKey(key, type)
* or INBTCompound.getList(key, type).
*/
public final class NBTTypes {
public static final int TAG_END = 0;
public static final int TAG_BYTE = 1;
public static final int TAG_SHORT = 2;
public static final int TAG_INT = 3;
public static final int TAG_LONG = 4;
public static final int TAG_FLOAT = 5;
public static final int TAG_DOUBLE = 6;
public static final int TAG_BYTE_ARRAY = 7;
public static final int TAG_STRING = 8;
public static final int TAG_LIST = 9;
public static final int TAG_COMPOUND = 10;
public static final int TAG_INT_ARRAY = 11;
private NBTTypes() {}
}
@@ -0,0 +1,48 @@
package noppes.npcs.controllers.data;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.core.NBT;
public class AbilityHotbarData {
public static final String CHAIN_PREFIX = "chain:";
public static final int TOTAL_SLOTS = 12;
public int slot = -1;
public String abilityKey = "";
public AbilityHotbarData() {
}
public AbilityHotbarData(int slot) {
this.slot = slot;
}
public boolean isChainKey() {
return abilityKey != null && abilityKey.startsWith(CHAIN_PREFIX);
}
public String getResolveKey() {
if (isChainKey()) return abilityKey.substring(CHAIN_PREFIX.length());
return abilityKey;
}
public INBTCompound writeToNBT(INBTCompound compound) {
INBTCompound tag = NBT.compound();
tag.setInteger("slot", slot);
tag.setString("abilityKey", abilityKey != null ? abilityKey : "");
compound.setCompound("AbilityHotbar" + slot, tag);
return compound;
}
public void readFromNBT(INBTCompound compound) {
abilityKey = compound.getString("abilityKey");
}
public void reset() {
abilityKey = "";
}
public boolean isEmpty() {
return abilityKey == null || abilityKey.isEmpty();
}
}
@@ -0,0 +1,32 @@
package noppes.npcs.controllers.data;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.core.NBT;
/**
* Simple category data class for the generic category system.
* Used by CategoryManager to organize items into named groups.
*/
public class Category {
public int id = -1;
public String title = "";
public Category() {
}
public Category(int id, String title) {
this.id = id;
this.title = title;
}
public void readNBT(INBTCompound compound) {
id = compound.getInteger("CatID");
title = compound.getString("CatTitle");
}
public INBTCompound writeNBT(INBTCompound compound) {
compound.setInteger("CatID", id);
compound.setString("CatTitle", title);
return compound;
}
}
@@ -0,0 +1,62 @@
package noppes.npcs.controllers.data;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.core.NBT;
public class CloneFolder {
public String name;
public long createdDate;
public CloneFolder() {
this.name = "";
this.createdDate = System.currentTimeMillis();
}
public CloneFolder(String name) {
this.name = name;
this.createdDate = System.currentTimeMillis();
}
public void readNBT(INBTCompound compound) {
name = compound.getString("Name");
createdDate = compound.getLong("Created");
}
public INBTCompound writeNBT(INBTCompound compound) {
compound.setString("Name", name);
compound.setLong("Created", createdDate);
return compound;
}
public static boolean isValidName(String name) {
if (name == null || name.isEmpty()) {
return false;
}
if (name.length() > 32) {
return false;
}
if (!name.equals(name.trim())) {
return false;
}
if (name.equals(".") || name.equals("..")) {
return false;
}
if (name.startsWith("___")) {
return false;
}
try {
Integer.parseInt(name);
return false;
} catch (NumberFormatException ignored) {
}
for (char c : name.toCharArray()) {
if (c == '/' || c == '\\' || c == ':' || c == '*' || c == '?' || c == '"' || c == '<' || c == '>' || c == '|') {
return false;
}
if (c < 32) {
return false;
}
}
return true;
}
}
@@ -0,0 +1,95 @@
package noppes.npcs.controllers.data;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.core.NBT;
public class DialogColorData {
private boolean enableColorSettings = false;
private int lineColor1 = 0xff8d3800;
private int lineColor2 = 0xfffea53b;
private int lineColor3 = 0xff8d3800;
private int slotColor = 0xfff96605;
private int buttonAcceptColor = 0xfff96605;
private int buttonRejectColor = 0xfff96605;
public INBTCompound writeToNBT(INBTCompound compound) {
compound.setBoolean("ColorSettings", enableColorSettings);
if (enableColorSettings) {
compound.setInteger("LineColor1", lineColor1);
compound.setInteger("LineColor2", lineColor2);
compound.setInteger("LineColor3", lineColor3);
compound.setInteger("SlotColor", slotColor);
compound.setInteger("ButtonAcceptColor", buttonAcceptColor);
compound.setInteger("ButtonRejectColor", buttonRejectColor);
}
return compound;
}
public void readFromNBT(INBTCompound compound) {
this.enableColorSettings = compound.getBoolean("ColorSettings");
if (enableColorSettings) {
lineColor1 = compound.getInteger("LineColor1");
lineColor2 = compound.getInteger("LineColor2");
lineColor3 = compound.getInteger("LineColor3");
slotColor = compound.getInteger("SlotColor");
buttonAcceptColor = compound.getInteger("ButtonAcceptColor");
buttonRejectColor = compound.getInteger("ButtonRejectColor");
}
}
public boolean getEnableColorSettings() {
return enableColorSettings;
}
public void setEnableColorSettings(boolean enableColorSettings) {
this.enableColorSettings = enableColorSettings;
}
public int getLineColor1() {
return lineColor1;
}
public void setLineColor1(int lineColour1) {
this.lineColor1 = lineColour1;
}
public int getLineColor2() {
return lineColor2;
}
public void setLineColor2(int lineColour2) {
this.lineColor2 = lineColour2;
}
public int getLineColor3() {
return lineColor3;
}
public void setLineColor3(int lineColour3) {
this.lineColor3 = lineColour3;
}
public int getSlotColor() {
return slotColor;
}
public void setSlotColor(int slotColour) {
this.slotColor = slotColour;
}
public int getButtonAcceptColor() {
return buttonAcceptColor;
}
public void setButtonAcceptColor(int buttonAcceptColour) {
this.buttonAcceptColor = buttonAcceptColour;
}
public int getButtonRejectColor() {
return buttonRejectColor;
}
public void setButtonRejectColor(int buttonRejectColour) {
this.buttonRejectColor = buttonRejectColour;
}
}
@@ -0,0 +1,176 @@
package noppes.npcs.controllers.data;
import noppes.npcs.api.handler.data.IDialogImage;
import noppes.npcs.platform.nbt.INBTCompound;
public class DialogImage implements IDialogImage {
public int id;
public String texture = "";
public int x = 0;
public int y = 0;
public int width = 0;
public int height = 0;
public int textureX = 0;
public int textureY = 0;
public float scale = 1.0F;
public int color = 0xFFFFFF;
public int selectedColor = 0xFFFFFF;
public float alpha = 1.0F;
public float rotation = 0;
public int imageType = 1; //0 - Default, 1 - Text, 2 - Option
public int alignment = 0;
public DialogImage() {
}
public DialogImage(int id) {
this.id = id;
}
public INBTCompound writeToNBT(INBTCompound compound) {
compound.setInteger("ID", id);
compound.setString("Texture", texture);
compound.setInteger("PosX", x);
compound.setInteger("PosY", y);
compound.setInteger("Width", width);
compound.setInteger("Height", height);
compound.setInteger("TextureX", textureX);
compound.setInteger("TextureY", textureY);
compound.setFloat("Scale", scale);
compound.setInteger("Color", color);
compound.setInteger("SelectedColor", selectedColor);
compound.setFloat("Alpha", alpha);
compound.setFloat("Rotation", rotation);
compound.setInteger("ImageType", imageType);
compound.setInteger("Alignment", alignment);
return compound;
}
public void readNBT(INBTCompound compound) {
id = compound.getInteger("ID");
texture = compound.getString("Texture");
x = compound.getInteger("PosX");
y = compound.getInteger("PosY");
width = compound.getInteger("Width");
height = compound.getInteger("Height");
textureX = compound.getInteger("TextureX");
textureY = compound.getInteger("TextureY");
scale = compound.getFloat("Scale");
color = compound.getInteger("Color");
selectedColor = compound.getInteger("SelectedColor");
alpha = compound.getFloat("Alpha");
rotation = compound.getFloat("Rotation");
imageType = compound.getInteger("ImageType");
alignment = compound.getInteger("Alignment");
}
public int getId() {
return id;
}
public void setTexture(String texture) {
this.texture = texture;
}
public String getTexture() {
return texture;
}
public void setPosition(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public void setWidthHeight(int width, int height) {
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void setTextureOffset(int offsetX, int offsetY) {
this.textureX = offsetX;
this.textureY = offsetY;
}
public int getTextureX() {
return textureX;
}
public int getTextureY() {
return textureY;
}
public void setColor(int color) {
this.color = color;
}
public int getColor() {
return color;
}
public void setSelectedColor(int color) {
this.selectedColor = color;
}
public int getSelectedColor() {
return selectedColor;
}
public void setScale(float scale) {
this.scale = scale;
}
public float getScale() {
return scale;
}
public void setAlpha(float alpha) {
this.alpha = alpha;
}
public float getAlpha() {
return alpha;
}
public void setRotation(float rotation) {
this.rotation = rotation;
}
public float getRotation() {
return rotation;
}
public void setImageType(int imageType) {
this.imageType = imageType;
}
public int getImageType() {
return imageType;
}
public void setAlignment(int alignment) {
this.alignment = alignment;
}
public int getAlignment() {
return alignment;
}
}
@@ -0,0 +1,37 @@
package noppes.npcs.controllers.data;
public class EffectKey {
private final int id;
private final int index;
public EffectKey(int key1, int key2) {
this.id = key1;
this.index = key2;
}
public int getId() {
return id;
}
public int getIndex() {
return index;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof EffectKey)) return false;
EffectKey that = (EffectKey) o;
return id == that.id && index == that.index;
}
@Override
public int hashCode() {
return 31 * id + index;
}
@Override
public String toString() {
return "EffectKey{" + "key1=" + id + ", key2=" + index + '}';
}
}
@@ -0,0 +1,7 @@
package noppes.npcs.controllers.data;
public class InnDoorData {
public int x = 0;
public int y = 0;
public int z = 0;
}
@@ -0,0 +1,139 @@
package noppes.npcs.controllers.data;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.core.NBT;
public class ItemDisplayData {
public String texture = "minecraft:textures/items/iron_pickaxe.png";
public Float translateX = 0F, translateY = 0F, translateZ = 0F;
public Integer itemColor = 0x8B4513;
public Float scaleX = 1.0F, scaleY = 1.0F, scaleZ = 1.0F;
public Float rotationX = 0F, rotationY = 0F, rotationZ = 0F;
public Float rotationXRate = 0F, rotationYRate = 0F, rotationZRate = 0F;
public Boolean durabilityShow = false;
public Integer durabilityColor = -1;
// Animation
public Boolean animated = false;
public Integer frameCount = 1;
public Integer frametime = 2;
public INBTCompound writeToNBT() {
INBTCompound compound = NBT.compound();
this.writeToNBT(compound);
return compound;
}
public INBTCompound writeToNBT(INBTCompound compound) {
this.setBoolean(compound, "DurabilityShow", this.durabilityShow);
this.setInteger(compound, "DurabilityColor", this.durabilityColor);
this.setInteger(compound, "ItemColor", this.itemColor);
if (this.texture != null) {
compound.setString("ItemTexture", this.texture);
}
this.setFloat(compound, "RotationX", this.rotationX);
this.setFloat(compound, "RotationY", this.rotationY);
this.setFloat(compound, "RotationZ", this.rotationZ);
this.setFloat(compound, "RotationXRate", this.rotationXRate);
this.setFloat(compound, "RotationYRate", this.rotationYRate);
this.setFloat(compound, "RotationZRate", this.rotationZRate);
this.setFloat(compound, "ScaleX", this.scaleX);
this.setFloat(compound, "ScaleY", this.scaleY);
this.setFloat(compound, "ScaleZ", this.scaleZ);
this.setFloat(compound, "TranslateX", this.translateX);
this.setFloat(compound, "TranslateY", this.translateY);
this.setFloat(compound, "TranslateZ", this.translateZ);
this.setBoolean(compound, "Animated", this.animated);
this.setInteger(compound, "FrameCount", this.frameCount);
this.setInteger(compound, "FrameTime", this.frametime);
return compound;
}
public void readFromNBT(INBTCompound compound) {
if (compound.hasKey("DurabilityShow")) {
this.durabilityShow = compound.getBoolean("DurabilityShow");
}
if (compound.hasKey("DurabilityColor")) {
this.durabilityColor = compound.getInteger("DurabilityColor");
}
if (compound.hasKey("ItemColor")) {
this.itemColor = compound.getInteger("ItemColor");
}
if (compound.hasKey("ItemTexture")) {
this.texture = compound.getString("ItemTexture");
}
if (compound.hasKey("RotationX")) {
this.rotationX = compound.getFloat("RotationX");
}
if (compound.hasKey("RotationY")) {
this.rotationY = compound.getFloat("RotationY");
}
if (compound.hasKey("RotationZ")) {
this.rotationZ = compound.getFloat("RotationZ");
}
if (compound.hasKey("RotationXRate")) {
this.rotationXRate = compound.getFloat("RotationXRate");
}
if (compound.hasKey("RotationYRate")) {
this.rotationYRate = compound.getFloat("RotationYRate");
}
if (compound.hasKey("RotationZRate")) {
this.rotationZRate = compound.getFloat("RotationZRate");
}
if (compound.hasKey("ScaleX")) {
this.scaleX = compound.getFloat("ScaleX");
}
if (compound.hasKey("ScaleY")) {
this.scaleY = compound.getFloat("ScaleY");
}
if (compound.hasKey("ScaleZ")) {
this.scaleZ = compound.getFloat("ScaleZ");
}
if (compound.hasKey("TranslateX")) {
this.translateX = compound.getFloat("TranslateX");
}
if (compound.hasKey("TranslateY")) {
this.translateY = compound.getFloat("TranslateY");
}
if (compound.hasKey("TranslateZ")) {
this.translateZ = compound.getFloat("TranslateZ");
}
if (compound.hasKey("Animated")) {
this.animated = compound.getBoolean("Animated");
}
if (compound.hasKey("FrameCount")) {
this.frameCount = Math.max(1, compound.getInteger("FrameCount"));
}
if (compound.hasKey("FrameTime")) {
this.frametime = Math.max(1, compound.getInteger("FrameTime"));
}
}
private void setBoolean(INBTCompound compound, String key, Boolean value) {
if (value != null) {
compound.setBoolean(key, value);
}
}
private void setInteger(INBTCompound compound, String key, Integer value) {
if (value != null) {
compound.setInteger(key, value);
}
}
private void setFloat(INBTCompound compound, String key, Float value) {
if (value != null) {
compound.setFloat(key, value);
}
}
}
@@ -0,0 +1,11 @@
package noppes.npcs.controllers.data;
/**
* A helper class that represents the relationship between a Magic and a Category.
* It holds per-category ordering data.
*/
public class MagicAssociation {
public int magicId;
public int index;
public int priority;
}
@@ -0,0 +1,103 @@
package noppes.npcs.controllers.data;
import noppes.npcs.api.handler.data.IMagicCycle;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.platform.nbt.INBTList;
import noppes.npcs.core.NBT;
import noppes.npcs.constants.EnumDiagramLayout;
import java.util.HashMap;
/**
* Holds category information for magic.
* Each category can have many magic associations.
*/
public class MagicCycle implements IMagicCycle {
public int id = -1;
public String name = "";
public String displayName = "";
public EnumDiagramLayout layout = EnumDiagramLayout.CIRCULAR;
public HashMap<Integer, MagicAssociation> associations = new HashMap<>();
public MagicCycle() {
}
public void readNBT(INBTCompound compound) {
id = compound.getInteger("ID");
name = compound.getString("Name");
displayName = compound.getString("DisplayName");
layout = EnumDiagramLayout.values()[compound.getInteger("Layout")];
associations.clear();
INBTList list = compound.getList("Associations", 10); // compound tags
for (int i = 0; i < list.size(); i++) {
INBTCompound assocTag = list.getCompound(i);
MagicAssociation assoc = new MagicAssociation();
assoc.magicId = assocTag.getInteger("MagicID");
assoc.index = assocTag.getInteger("Index");
assoc.priority = assocTag.getInteger("Priority");
associations.put(assoc.magicId, assoc);
}
}
public void writeNBT(INBTCompound compound) {
compound.setInteger("ID", id);
compound.setString("Name", name);
compound.setString("DisplayName", displayName);
compound.setInteger("Layout", layout.ordinal());
INBTList list = NBT.list();
for (MagicAssociation assoc : associations.values()) {
INBTCompound assocTag = NBT.compound();
assocTag.setInteger("MagicID", assoc.magicId);
assocTag.setInteger("Index", assoc.index);
assocTag.setInteger("Priority", assoc.priority);
list.addCompound(assocTag);
}
compound.setList("Associations", list);
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public EnumDiagramLayout getLayout() {
return layout;
}
public int getLayoutType() {
return layout.ordinal();
}
public void setLayout(EnumDiagramLayout layout) {
this.layout = layout;
}
public void setLayoutType(int layout) {
if (layout < 0 || layout > EnumDiagramLayout.values().length - 1)
return;
this.layout = EnumDiagramLayout.values()[layout];
}
public HashMap<Integer, MagicAssociation> getAssociations() {
return associations;
}
public void setAssociations(HashMap<Integer, MagicAssociation> associations) {
this.associations = associations;
}
}
@@ -0,0 +1,84 @@
package noppes.npcs.controllers.data;
import noppes.npcs.api.handler.data.IMagicData;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.core.NBT;
import java.util.HashMap;
public class MagicData implements IMagicData {
private final HashMap<Integer, MagicEntry> magics = new HashMap<>();
public void writeToNBT(INBTCompound compound) {
INBTCompound magicData = NBT.compound();
for (int key : magics.keySet()) {
magicData.setCompound(String.valueOf(key), magics.get(key).writeToNBT());
}
compound.setCompound("MagicData", magicData);
}
public void readToNBT(INBTCompound compound) {
INBTCompound magicData = compound.getCompound("MagicData");
magics.clear();
if (magicData == null)
return;
for (String key : magicData.getKeySet()) {
int i = Integer.parseInt(key);
MagicEntry entry = new MagicEntry();
entry.readToNBT(magicData.getCompound(key));
magics.put(i, entry);
}
}
public MagicEntry getMagic(int id) {
return magics.get(id);
}
public void removeMagic(int id) {
magics.remove(id);
}
public boolean hasMagic(int id) {
return magics.containsKey(id);
}
public HashMap<Integer, MagicEntry> getMagics() {
return magics;
}
public void clear() {
magics.clear();
}
public boolean isEmpty() {
return magics.isEmpty();
}
public void addMagic(int id, float damage, float split) {
MagicEntry entry = new MagicEntry();
entry.damage = damage;
entry.split = split;
magics.put(id, entry);
}
public float getMagicDamage(int id) {
MagicEntry entry = magics.get(id);
return entry == null ? 0 : entry.damage;
}
public float getMagicSplit(int id) {
MagicEntry entry = magics.get(id);
return entry == null ? 0 : entry.split;
}
public MagicData copy() {
MagicData copy = new MagicData();
for (java.util.Map.Entry<Integer, MagicEntry> e : magics.entrySet()) {
MagicEntry entryCopy = new MagicEntry();
entryCopy.damage = e.getValue().damage;
entryCopy.split = e.getValue().split;
copy.magics.put(e.getKey(), entryCopy);
}
return copy;
}
}
@@ -0,0 +1,21 @@
package noppes.npcs.controllers.data;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.core.NBT;
public class MagicEntry {
public float damage;
public float split;
public INBTCompound writeToNBT() {
INBTCompound compound = NBT.compound();
compound.setFloat("Dmg", damage);
compound.setFloat("Split", split);
return compound;
}
public void readToNBT(INBTCompound compound) {
damage = compound.getFloat("Dmg");
split = compound.getFloat("Split");
}
}
@@ -0,0 +1,80 @@
package noppes.npcs.controllers.data;
import noppes.npcs.api.handler.data.IProfileOptions;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.core.NBT;
import noppes.npcs.constants.EnumProfileSync;
public class ProfileOptions implements IProfileOptions {
public boolean enableOptions = false;
public EnumProfileSync cooldownControl = EnumProfileSync.Individual;
public EnumProfileSync completeControl = EnumProfileSync.Individual;
public void readFromNBT(INBTCompound compound) {
// Party Management
enableOptions = compound.getBoolean("EnableProfiles");
if (enableOptions) {
cooldownControl = EnumProfileSync.values()[compound.getInteger("CooldownControl")];
completeControl = EnumProfileSync.values()[compound.getInteger("CompleteControl")];
} else {
if (compound.hasKey("CooldownControl")) {
compound.removeTag("CooldownControl");
}
if (compound.hasKey("CompleteControl")) {
compound.removeTag("CompleteControl");
}
cooldownControl = EnumProfileSync.Individual;
completeControl = EnumProfileSync.Individual;
}
}
public INBTCompound writeToNBT() {
INBTCompound compound = NBT.compound();
compound.setBoolean("EnableProfiles", enableOptions);
if (enableOptions) {
compound.setInteger("CooldownControl", cooldownControl.ordinal());
compound.setInteger("CompleteControl", completeControl.ordinal());
} else {
if (compound.hasKey("CooldownControl")) {
compound.removeTag("CooldownControl");
}
if (compound.hasKey("CompleteControl")) {
compound.removeTag("CompleteControl");
}
}
return compound;
}
public boolean hasProfileOptions() {
return enableOptions;
}
public void setProfileOptions(boolean enable) {
this.enableOptions = enable;
}
public void setCooldownControl(int profileType) {
if (profileType < 0 || profileType >= EnumProfileSync.values().length) {
return;
}
this.cooldownControl = EnumProfileSync.values()[profileType];
}
public int getCooldownControl() {
return this.cooldownControl.ordinal();
}
public void setCompleteControl(int profileType) {
if (profileType < 0 || profileType >= EnumProfileSync.values().length) {
return;
}
this.completeControl = EnumProfileSync.values()[profileType];
}
public int getCompleteControl() {
return this.completeControl.ordinal();
}
}
@@ -0,0 +1,122 @@
package noppes.npcs.controllers.data;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.platform.nbt.INBTList;
import noppes.npcs.core.NBT;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
public class TagMap {
public int cloneTab;
public String cloneFolder;
public HashMap<String, HashSet<UUID>> tagMap;
public TagMap(int tab) {
this.cloneTab = tab;
this.cloneFolder = null;
this.tagMap = new HashMap<String, HashSet<UUID>>();
}
public TagMap(String folder) {
this.cloneTab = -1;
this.cloneFolder = folder;
this.tagMap = new HashMap<String, HashSet<UUID>>();
}
public void readNBT(INBTCompound compound) {
this.tagMap = new HashMap<String, HashSet<UUID>>();
INBTList list = compound.getList("TagMap", 10);
if (list != null) {
for (int i = 0; i < list.size(); i++) {
INBTCompound nbttagcompound = list.getCompound(i);
String cloneName = nbttagcompound.getString("Clone");
HashSet<UUID> uuids = new HashSet<UUID>();
INBTList nbtTagList = nbttagcompound.getList("TagUUIDs", 8);
for (int j = 0; j < nbtTagList.size(); j++) {
String uuid = nbtTagList.getString(j);
if (!uuid.isEmpty()) {
uuids.add(UUID.fromString(uuid));
}
}
tagMap.put(cloneName, uuids);
}
}
}
public INBTCompound writeNBT() {
INBTCompound nbt = NBT.compound();
INBTList cloneList = NBT.list();
for (String key : tagMap.keySet()) {
HashSet<UUID> uuidSet = tagMap.get(key);
if (uuidSet.size() > 0) {
INBTCompound cloneCompound = NBT.compound();
cloneCompound.setString("Clone", key);
INBTList nbtTagList = NBT.list();
for (UUID uuid : uuidSet) {
nbtTagList.addString(uuid.toString());
}
cloneCompound.setList("TagUUIDs", nbtTagList);
cloneList.addCompound(cloneCompound);
}
}
nbt.setList("TagMap", cloneList);
return nbt;
}
public int getCloneTab() {
return this.cloneTab;
}
public boolean hasClone(String cloneName) {
return tagMap.containsKey(cloneName);
}
public HashSet<UUID> getUUIDs(String cloneName) {
if (hasClone(cloneName)) {
return tagMap.get(cloneName);
}
return null;
}
public List<UUID> getUUIDsList(String cloneName) {
HashSet<UUID> uuids = getUUIDs(cloneName);
if (uuids != null) {
List<UUID> tagUUIDS = new ArrayList<>(uuids);
Collections.sort(tagUUIDS);
return tagUUIDS;
}
return null;
}
public boolean removeClone(String cloneName) {
return tagMap.remove(cloneName) != null;
}
public void putClone(String cloneName, HashSet<UUID> uuids) {
tagMap.put(cloneName, uuids);
}
public boolean hasTag(String cloneName, UUID tag) {
HashSet<UUID> uuids = getUUIDs(cloneName);
if (uuids == null) {
return false;
}
return uuids.contains(tag);
}
public HashSet<UUID> getAllUUIDs() {
HashSet<UUID> uuids = new HashSet<UUID>();
for (HashSet<UUID> uuids1 : tagMap.values()) {
uuids.addAll(uuids1);
}
return uuids;
}
}
@@ -0,0 +1,92 @@
package noppes.npcs.controllers.data;
import noppes.npcs.api.entity.data.ITintData;
import noppes.npcs.platform.nbt.INBTCompound;
public class TintData implements ITintData {
private boolean tintEnabled = false;
private boolean hurtTintEnabled = true;
private boolean generalTintEnabled = false;
private int hurtTint = 0xff0000;
private int generalTint = 0x000000;
private int generalAlpha = 40;
public INBTCompound writeToNBT(INBTCompound nbttagcompound) {
nbttagcompound.setBoolean("TintEnabled", tintEnabled);
if (tintEnabled) {
nbttagcompound.setBoolean("HurtTintEnabled", hurtTintEnabled);
nbttagcompound.setBoolean("GeneralTintEnabled", generalTintEnabled);
nbttagcompound.setInteger("HurtTint", hurtTint);
nbttagcompound.setInteger("GeneralTint", generalTint);
nbttagcompound.setInteger("GeneralAlpha", generalAlpha);
}
return nbttagcompound;
}
public void readFromNBT(INBTCompound nbttagcompound) {
tintEnabled = nbttagcompound.getBoolean("TintEnabled");
if (tintEnabled) {
hurtTintEnabled = nbttagcompound.getBoolean("HurtTintEnabled");
generalTintEnabled = nbttagcompound.getBoolean("GeneralTintEnabled");
hurtTint = nbttagcompound.getInteger("HurtTint");
generalTint = nbttagcompound.getInteger("GeneralTint");
generalAlpha = nbttagcompound.getInteger("GeneralAlpha");
}
}
public boolean isHurtTintEnabled() {
return hurtTintEnabled;
}
public void setHurtTintEnabled(boolean hurtTintEnabled) {
this.hurtTintEnabled = hurtTintEnabled;
}
public int getHurtTint() {
return hurtTint;
}
public void setHurtTint(int colorHurtTint) {
this.hurtTint = colorHurtTint;
}
public int getGeneralTint() {
return generalTint;
}
public void setGeneralTint(int generalTint) {
this.generalTint = generalTint;
}
public boolean isTintEnabled() {
return tintEnabled;
}
public void setTintEnabled(boolean tintEnabled) {
this.tintEnabled = tintEnabled;
}
public boolean isGeneralTintEnabled() {
return generalTintEnabled;
}
public void setGeneralTintEnabled(boolean generalTintEnabled) {
this.generalTintEnabled = generalTintEnabled;
}
public int getGeneralAlpha() {
return generalAlpha;
}
public void setGeneralAlpha(int generalAlpha) {
this.generalAlpha = generalAlpha;
}
public boolean processColor(boolean isHurt) {
if (isHurt) {
return (isTintEnabled() && (!isHurtTintEnabled() && !isGeneralTintEnabled()));
} else {
return !(isTintEnabled() && isGeneralTintEnabled());
}
}
}
@@ -0,0 +1,362 @@
package noppes.npcs.controllers.data;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.platform.nbt.INBTList;
import noppes.npcs.core.NBT;
import noppes.npcs.constants.EnumStockReset;
import java.util.HashMap;
import java.util.Map;
/**
* Manages trader stock system including:
* - Per-slot stock limits
* - Per-player vs per-server stock tracking
* - Automatic stock reset timers
*/
public class TraderStock {
// Stock configuration
public boolean enableStock = false;
public boolean perPlayer = false; // false = per-server, true = per-player
// Reset configuration (mirrors Quest cooldown system)
public EnumStockReset resetType = EnumStockReset.NONE;
public long customResetTime = 0; // For MCCUSTOM/RLCUSTOM types (in ticks or ms)
// Stock quantities per slot (max stock, -1 = unlimited)
public int[] maxStock = new int[18];
// Current stock (per-server mode)
public int[] currentStock = new int[18];
public long lastResetTime = 0;
// Per-player stock tracking
public HashMap<String, PlayerTraderStock> playerStock = new HashMap<>();
public TraderStock() {
for (int i = 0; i < 18; i++) {
maxStock[i] = -1; // -1 = unlimited
currentStock[i] = -1;
}
}
/**
* Get available stock for a slot
*
* @param slot The slot index
* @param playerName The player name (for per-player mode)
* @return Available stock count, or Integer.MAX_VALUE if unlimited
*/
public synchronized int getAvailableStock(int slot, String playerName) {
if (!enableStock || slot < 0 || slot >= 18 || maxStock[slot] < 0) {
return Integer.MAX_VALUE; // Unlimited
}
if (perPlayer) {
PlayerTraderStock pStock = playerStock.get(playerName);
if (pStock == null) {
return maxStock[slot]; // Not purchased yet
}
return pStock.getStock(slot, maxStock[slot]);
}
if (currentStock[slot] < 0) {
return maxStock[slot];
}
return Math.max(0, currentStock[slot]);
}
/**
* Check if stock is available for purchase
*/
public boolean hasStock(int slot, String playerName, int amount) {
return getAvailableStock(slot, playerName) >= amount;
}
/**
* Consume stock when purchase is made
*
* @return true if successful, false if insufficient stock
*/
public synchronized boolean consumeStock(int slot, String playerName, int amount) {
if (!enableStock || slot < 0 || slot >= 18 || maxStock[slot] < 0) {
return true; // Unlimited, always succeeds
}
if (perPlayer) {
PlayerTraderStock pStock = playerStock.computeIfAbsent(
playerName, k -> new PlayerTraderStock());
return pStock.consumeStock(slot, maxStock[slot], amount);
}
if (currentStock[slot] < 0) {
currentStock[slot] = maxStock[slot];
}
if (currentStock[slot] >= amount) {
currentStock[slot] -= amount;
return true;
}
return false;
}
/**
* 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) {
if (resetType == EnumStockReset.NONE) {
return false;
}
long elapsed = currentTime - lastResetTime;
long resetInterval = getResetInterval();
return elapsed >= resetInterval;
}
/**
* Reset all stock to max values
*
* @param currentTime Current time to record as reset time
*/
public synchronized void resetStock(long currentTime) {
lastResetTime = currentTime;
// Reset per-server stock
for (int i = 0; i < 18; i++) {
currentStock[i] = maxStock[i];
}
// Clear per-player stock (cleanup per-player data on reset)
playerStock.clear();
}
/**
* Get reset interval based on reset type
*
* @return Interval in ticks (MC time) or milliseconds (real time)
*/
public long getResetInterval() {
switch (resetType) {
case MCDAILY:
return 24000; // 1 MC day in ticks
case MCWEEKLY:
return 168000; // 7 MC days in ticks
case MCCUSTOM:
return customResetTime; // Custom ticks
case RLDAILY:
return 86400000L; // 24 hours in ms
case RLWEEKLY:
return 604800000L; // 7 days in ms
case RLCUSTOM:
return customResetTime; // Custom ms
default:
return Long.MAX_VALUE;
}
}
/**
* Get time until next reset
*
* @param currentTime Current time
* @return Time remaining until reset, or -1 if no reset scheduled
*/
public long getTimeUntilReset(long currentTime) {
if (resetType == EnumStockReset.NONE) {
return -1;
}
long elapsed = currentTime - lastResetTime;
long interval = getResetInterval();
return Math.max(0, interval - elapsed);
}
/**
* Format time until reset for display
*
* @param currentTime Current time
* @return Formatted string like "2 hours" or "1 day, 5 hours"
*/
public String getTimeUntilResetFormatted(long currentTime) {
long remaining = getTimeUntilReset(currentTime);
if (remaining < 0) {
return "";
}
if (resetType.isRealTime()) {
// Convert ms to readable format
long hours = remaining / 3600000L;
long days = hours / 24;
hours = hours % 24;
if (days > 0) {
return days + " day" + (days != 1 ? "s" : "") +
(hours > 0 ? ", " + hours + " hour" + (hours != 1 ? "s" : "") : "");
} else if (hours > 0) {
return hours + " hour" + (hours != 1 ? "s" : "");
} else {
long minutes = remaining / 60000L;
return minutes + " minute" + (minutes != 1 ? "s" : "");
}
} else {
// Convert ticks to MC time format
long mcHours = remaining / 1000; // 1000 ticks = 1 MC hour
long mcDays = mcHours / 24;
mcHours = mcHours % 24;
if (mcDays > 0) {
return mcDays + " MC day" + (mcDays != 1 ? "s" : "") +
(mcHours > 0 ? ", " + mcHours + " MC hour" + (mcHours != 1 ? "s" : "") : "");
} else {
return mcHours + " MC hour" + (mcHours != 1 ? "s" : "");
}
}
}
/**
* Set stock for a specific slot
*/
public void setMaxStock(int slot, int amount) {
if (slot >= 0 && slot < 18) {
maxStock[slot] = amount;
if (currentStock[slot] < 0 || currentStock[slot] > amount) {
currentStock[slot] = amount;
}
}
}
/**
* 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() {
boolean changed = false;
for (int i = 0; i < 18; i++) {
if (maxStock[i] >= 0) {
// Has a max limit
if (currentStock[i] < 0) {
// Not initialized, set to max
currentStock[i] = maxStock[i];
changed = true;
} else if (currentStock[i] > maxStock[i]) {
// Exceeds max, clamp down
currentStock[i] = maxStock[i];
changed = true;
}
}
}
// Also validate per-player stock
for (PlayerTraderStock pStock : playerStock.values()) {
for (int i = 0; i < 18; i++) {
if (maxStock[i] >= 0) {
int available = pStock.getStock(i, maxStock[i]);
if (available < 0) {
// Over-purchased somehow, reset
pStock.purchasedAmounts[i] = maxStock[i];
changed = true;
}
}
}
}
return changed;
}
// ==================== NBT Serialization ====================
public INBTCompound writeToNBT(INBTCompound compound) {
compound.setBoolean("EnableStock", enableStock);
compound.setBoolean("PerPlayer", perPlayer);
compound.setInteger("ResetType", resetType.ordinal());
compound.setLong("CustomResetTime", customResetTime);
compound.setIntArray("MaxStock", maxStock);
compound.setIntArray("CurrentStock", currentStock);
compound.setLong("LastResetTime", lastResetTime);
// Save per-player stock
INBTList playerList = NBT.list();
for (Map.Entry<String, PlayerTraderStock> entry : playerStock.entrySet()) {
INBTCompound playerTag = NBT.compound();
playerTag.setString("Player", entry.getKey());
entry.getValue().writeToNBT(playerTag);
playerList.addCompound(playerTag);
}
compound.setList("PlayerStock", playerList);
return compound;
}
public void readFromNBT(INBTCompound compound) {
enableStock = compound.getBoolean("EnableStock");
perPlayer = compound.getBoolean("PerPlayer");
int resetOrdinal = compound.getInteger("ResetType");
if (resetOrdinal >= 0 && resetOrdinal < EnumStockReset.values().length) {
resetType = EnumStockReset.values()[resetOrdinal];
}
customResetTime = compound.getLong("CustomResetTime");
int[] loadedMax = compound.getIntArray("MaxStock");
int[] loadedCurrent = compound.getIntArray("CurrentStock");
if (loadedMax != null && loadedMax.length == 18) {
maxStock = loadedMax;
}
if (loadedCurrent != null && loadedCurrent.length == 18) {
currentStock = loadedCurrent;
}
lastResetTime = compound.getLong("LastResetTime");
// Load per-player stock
playerStock.clear();
INBTList playerList = compound.getList("PlayerStock", 10);
for (int i = 0; i < playerList.size(); i++) {
INBTCompound playerTag = playerList.getCompound(i);
String playerName = playerTag.getString("Player");
PlayerTraderStock pStock = new PlayerTraderStock();
pStock.readFromNBT(playerTag);
playerStock.put(playerName, pStock);
}
}
// ==================== Inner Class for Per-Player Stock ====================
public static class PlayerTraderStock {
public int[] purchasedAmounts = new int[18];
public PlayerTraderStock() {
for (int i = 0; i < 18; i++) {
purchasedAmounts[i] = 0;
}
}
public int getStock(int slot, int maxStock) {
if (slot < 0 || slot >= 18) return 0;
return Math.max(0, maxStock - purchasedAmounts[slot]);
}
public boolean consumeStock(int slot, int maxStock, int amount) {
if (slot < 0 || slot >= 18) return false;
if (getStock(slot, maxStock) >= amount) {
purchasedAmounts[slot] += amount;
return true;
}
return false;
}
public void writeToNBT(INBTCompound compound) {
compound.setIntArray("Purchased", purchasedAmounts);
}
public void readFromNBT(INBTCompound compound) {
int[] loaded = compound.getIntArray("Purchased");
if (loaded != null && loaded.length == 18) {
purchasedAmounts = loaded;
}
}
}
}
@@ -0,0 +1,28 @@
package noppes.npcs.core;
import noppes.npcs.platform.PlatformServiceHolder;
import noppes.npcs.platform.nbt.INBTCompound;
import noppes.npcs.platform.nbt.INBTList;
/**
* Convenience factory for creating NBT objects in CORE code.
* Shorthand for PlatformServiceHolder.get().nbt().createCompound(), etc.
*/
public final class NBT {
private NBT() {}
/**
* Creates a new, empty NBT compound.
*/
public static INBTCompound compound() {
return PlatformServiceHolder.get().nbt().createCompound();
}
/**
* Creates a new, empty NBT list.
*/
public static INBTList list() {
return PlatformServiceHolder.get().nbt().createList();
}
}
@@ -0,0 +1,12 @@
/**
* CustomNPC+ Core Module.
*
* This package contains version-independent game logic that is shared across
* all Minecraft versions (1.7.10, 1.12, 1.16, 1.20.1).
*
* Rules:
* - NO imports from net.minecraft.*, cpw.mods.*, net.minecraftforge.*, org.spongepowered.*
* - Only java.*, javax.*, noppes.npcs.core.*, noppes.npcs.platform.*, kamkeel.npcs.core.*
* - All MC-specific behavior is accessed through noppes.npcs.platform.PlatformServiceHolder
*/
package noppes.npcs.core;