From ac48fd15b13aafdc5796cb7959884550dece0e12 Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 29 Dec 2024 19:02:49 -0500 Subject: [PATCH 01/25] Fix building issues --- build.gradle.kts | 2 +- core/build.gradle.kts | 4 ++-- v1_20_R1/build.gradle.kts | 2 +- v1_20_R2/build.gradle.kts | 2 +- v1_20_R3/build.gradle.kts | 2 +- v1_20_R4/build.gradle.kts | 2 +- v1_21_R0/build.gradle.kts | 2 +- v1_21_R1/build.gradle.kts | 2 +- v1_21_R2/build.gradle.kts | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2cf2ba12..d4c48c5e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,7 +25,7 @@ plugins { `maven-publish` id("xyz.jpenilla.run-paper") version "2.3.1" id("io.github.goooler.shadow") version "8.1.8" - id("io.papermc.paperweight.userdev") version "1.7.7" apply false + id("io.papermc.paperweight.userdev") version "2.0.0-beta.8" apply false } repositories { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index cf348831..4bbcd092 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -40,8 +40,8 @@ dependencies { implementation("org.mineskin:java-client:1.2.4-SNAPSHOT") compileOnly("org.projectlombok:lombok:1.18.36") annotationProcessor("org.projectlombok:lombok:1.18.36") - implementation("dev.velix:imperat-core:1.3.2") - implementation("dev.velix:imperat-bukkit:1.3.2") + implementation("dev.velix:imperat-core:1.5") + implementation("dev.velix:imperat-bukkit:1.5") } tasks { diff --git a/v1_20_R1/build.gradle.kts b/v1_20_R1/build.gradle.kts index 18b44cab..4f7a3ae2 100644 --- a/v1_20_R1/build.gradle.kts +++ b/v1_20_R1/build.gradle.kts @@ -22,7 +22,7 @@ plugins { id("java") - id("io.papermc.paperweight.userdev") version "1.7.7" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.8" } repositories { diff --git a/v1_20_R2/build.gradle.kts b/v1_20_R2/build.gradle.kts index d82b3e53..9233c366 100644 --- a/v1_20_R2/build.gradle.kts +++ b/v1_20_R2/build.gradle.kts @@ -22,7 +22,7 @@ plugins { id("java") - id("io.papermc.paperweight.userdev") version "1.7.7" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.8" } repositories { diff --git a/v1_20_R3/build.gradle.kts b/v1_20_R3/build.gradle.kts index 81a6f76c..3e905694 100644 --- a/v1_20_R3/build.gradle.kts +++ b/v1_20_R3/build.gradle.kts @@ -22,7 +22,7 @@ plugins { id("java") - id("io.papermc.paperweight.userdev") version "1.7.7" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.8" } repositories { diff --git a/v1_20_R4/build.gradle.kts b/v1_20_R4/build.gradle.kts index a8f2353f..89cad842 100644 --- a/v1_20_R4/build.gradle.kts +++ b/v1_20_R4/build.gradle.kts @@ -22,7 +22,7 @@ plugins { id("java") - id("io.papermc.paperweight.userdev") version "1.7.7" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.8" } repositories { diff --git a/v1_21_R0/build.gradle.kts b/v1_21_R0/build.gradle.kts index 2751bcfe..01a22c34 100644 --- a/v1_21_R0/build.gradle.kts +++ b/v1_21_R0/build.gradle.kts @@ -22,7 +22,7 @@ plugins { id("java") - id("io.papermc.paperweight.userdev") version "1.7.7" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.8" } repositories { diff --git a/v1_21_R1/build.gradle.kts b/v1_21_R1/build.gradle.kts index 134dbd06..6b86bb26 100644 --- a/v1_21_R1/build.gradle.kts +++ b/v1_21_R1/build.gradle.kts @@ -22,7 +22,7 @@ plugins { id("java") - id("io.papermc.paperweight.userdev") version "1.7.7" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.8" } repositories { diff --git a/v1_21_R2/build.gradle.kts b/v1_21_R2/build.gradle.kts index bf015ea1..bef38bf5 100644 --- a/v1_21_R2/build.gradle.kts +++ b/v1_21_R2/build.gradle.kts @@ -22,7 +22,7 @@ plugins { id("java") - id("io.papermc.paperweight.userdev") version "1.7.7" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.8" } repositories { From 19bd07215980ed0ce0382751e0509c7f04ef563e Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 29 Dec 2024 19:26:10 -0500 Subject: [PATCH 02/25] Cleaning up deprecated methods scheduled for removal in 1.8.0 --- core/build.gradle.kts | 4 +- .../actions/conditions/Conditional.java | 302 ------------------ .../conditions/LogicalConditional.java | 182 ----------- .../conditions/NumericConditional.java | 188 ----------- .../java/dev/foxikle/customnpcs/api/NPC.java | 21 +- .../dev/foxikle/customnpcs/api/NPCApi.java | 11 - .../dev/foxikle/customnpcs/data/Settings.java | 10 +- .../customnpcs/internal/FileManager.java | 1 - .../internal/commands/CloneCommand.java | 1 - .../internal/commands/MoveCommand.java | 1 - .../internal/listeners/Listeners.java | 3 +- .../customnpcs/internal/menu/MenuItems.java | 4 +- .../customnpcs/internal/utils/Utils.java | 2 +- .../customnpcs/versions/NPC_v1_20_R1.java | 6 +- .../customnpcs/versions/NPC_v1_20_R2.java | 2 +- .../customnpcs/versions/NPC_v1_20_R3.java | 4 +- .../customnpcs/versions/NPC_v1_20_R4.java | 4 +- .../customnpcs/versions/NPC_v1_21_R0.java | 6 +- .../customnpcs/versions/NPC_v1_21_R1.java | 6 +- .../customnpcs/versions/NPC_v1_21_R2.java | 6 +- 20 files changed, 27 insertions(+), 737 deletions(-) delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 4bbcd092..611ffcff 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -40,8 +40,8 @@ dependencies { implementation("org.mineskin:java-client:1.2.4-SNAPSHOT") compileOnly("org.projectlombok:lombok:1.18.36") annotationProcessor("org.projectlombok:lombok:1.18.36") - implementation("dev.velix:imperat-core:1.5") - implementation("dev.velix:imperat-bukkit:1.5") + implementation("dev.velix:imperat-core:1.5.0") + implementation("dev.velix:imperat-bukkit:1.5.0") } tasks { diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java b/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java deleted file mode 100644 index d51146d1..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2024. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.actions.conditions; - -import dev.foxikle.customnpcs.internal.CustomNPCs; -import lombok.Getter; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; - -/** - * The interface to represent a comparison - * @deprecated See {@link Condition} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.8.0") -public interface Conditional { - - /** - * Computes the condition to determine if the action should be executed - * @param player The player to fetch data from - * @return if the action should be executed - */ - boolean compute(Player player); - - /** - * Serializes the condition to json using Gson - * @return the serialized condition - */ - String toJson(); - - /** - * - * @param data the serialized condition - * @return the condition from the json - */ - static Conditional of(String data) { - return CustomNPCs.getGson().fromJson(data, Conditional.class); - } - - /** - * Gets the value the condition is comparing - * @see Value - * @return the value the condition is comparing - */ - Value getValue(); - - /** - * Gets the comparator the condition uses to compare the value and target value. - * @return the comparator - * @see Comparator - */ - Comparator getComparator(); - - /** - * Gets the type of condition - * @return the condition type - * @see Type - */ - Type getType(); - - /** - * Sets the comparator of this condition - * @param comparator the comparator to compare the value and target value - * @see Comparator - */ - void setComparator(Comparator comparator); - - /** - * Sets the value of this condition - * @param value the value to compare - * @see Value - */ - void setValue(Value value); - - /** - * Sets the target value of this condition - * @param targetValue the target value - */ - void setTargetValue(String targetValue); - - /** - * Gets the target of the condition - * @return returns the target value - */ - String getTarget(); - - /** - * Clones this conditional object - * @return the cloned object - */ - Conditional clone(); - - /** - * A list of comparators used to compare the values and target values of conditions - */ - @Getter - enum Comparator { - /** - * Represents the value being equal to the target value - */ - EQUAL_TO(true), - - /** - * Represents the value being unequal to the target value - */ - NOT_EQUAL_TO(true), - - /** - * Represents the value being less than the target value - */ - LESS_THAN(false), - - /** - * Represents the value being greater than the target value - */ - GREATER_THAN(false), - - /** - * Represents the value being less than or equal to the target value - */ - LESS_THAN_OR_EQUAL_TO(false), - - /** - * Represents the value being greater than or equal to the target value - */ - GREATER_THAN_OR_EQUAL_TO(false); - - private final boolean strictlyLogical; - - /** - * Constructor for the Comparator - * @param strictlyLogical if the comparator is to only be used on logical parameters - */ - Comparator(boolean strictlyLogical) { - this.strictlyLogical = strictlyLogical; - } - - } - - /** - * A list of comparator types - */ - enum Type { - /** - * Represents a comparison between a Value and a target value that can be any numeric value. - * @see Value - */ - NUMERIC, - - /** - * Represents a comparison between a Value and a target value with a finite number of possibilities - * @see Value - */ - LOGICAL - } - - /** - * A list of values the plugin can compare - */ - enum Value { - // numeric - /** - * Represents the player's experience levels - */ - EXP_LEVELS(false), - - /** - * Represents the player's experience points - */ - EXP_POINTS(false), - - /** - * Represents the player's health - */ - HEALTH(false), - - /** - * Represents the player's absorption - * @deprecated - Misspelled, see {@link Conditional.Value#ABSORPTION} - */ - @ApiStatus.ScheduledForRemoval(inVersion = "1.7") - @Deprecated - ABSORBTION(false), - - /** - * Represents the player's absorption - */ - ABSORPTION(false), - - /** - * Represents the player's Y coordinate - */ - Y_COORD(false), - - /** - * Represents the player's X coordinate - */ - X_COORD(false), - - /** - * Represents the player's Z coordinate - */ - Z_COORD(false), - - - // logical - /** - * Represents if the player has an effect - */ - HAS_EFFECT(true), - - /** - * Represents if the player has a permission node - */ - HAS_PERMISSION(true), - - /** - * Represents if the player is in the gamemode - */ - GAMEMODE(true), - - /** - * Represents if the player is flying - */ - IS_FLYING(true), - - /** - * Represents if the player is sprinting - */ - IS_SPRINTING(true), - - /** - * Represents if the player is sneaking - */ - IS_SNEAKING(true), - - /** - * Represents if the player is frozen - */ - IS_FROZEN(true), - - /** - * Represents if the player is gliding - */ - IS_GLIDING(true); - - - - private final boolean isLogical; - - /** - * The constructor for the Value - * @param isLogical if the value is considered 'logical' - */ - Value(boolean isLogical) { - this.isLogical = isLogical; - } - - /** - * Determines if the value is considered 'logical' - * @return if the value is logical - */ - public boolean isLogical() { - return isLogical; - } - } - - /** - * Represents if how the conditions should be computed - */ - enum SelectionMode { - /** - * If ALL the conditions must be true for the action to be executed - */ - ALL, - - /** - * if at least ONE of the conditions must be met for the action to be executed - */ - ONE - } -} diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java b/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java deleted file mode 100644 index dd1c72ac..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2024. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.actions.conditions; - -import dev.foxikle.customnpcs.internal.CustomNPCs; -import org.bukkit.GameMode; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.ApiStatus; - -import java.util.Objects; - -/** - * The object representing two non-numeric values - * @deprecated See {@link LogicalCondition} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.8.0") -public class LogicalConditional implements Condition { - private final Type type = Type.LOGICAL; - private Comparator comparator; - private Value value; - private String target; - - /** - * - * @param comparator the comparator to use - * @param value the value to compare - * @param target the target to compare to - * @see Value - * @see Comparator - */ - public LogicalConditional(Comparator comparator, Value value, String target) { - this.comparator = comparator; - this.value = value; - this.target = target; - } - - /** - * Computes the condition to determine if the action should be executed - * @param player The player to fetch data from - * @return if the action should be executed - */ - @Override - public boolean compute(Player player) { - boolean value = false; - switch (this.value) { - case HAS_PERMISSION -> value = player.hasPermission(target); - case HAS_EFFECT -> value = player.hasPotionEffect(Objects.requireNonNull(PotionEffectType.getByName(target))); - case GAMEMODE -> value = player.getGameMode().equals(GameMode.valueOf(target)); - case IS_FLYING -> value = player.isFlying(); - case IS_SPRINTING -> value = player.isSprinting(); - case IS_SNEAKING -> value = player.isSneaking(); - case IS_FROZEN -> value = player.isFrozen(); - case IS_GLIDING -> value = player.isGliding(); - } - switch (comparator) { - case EQUAL_TO -> { - return value; - } - case NOT_EQUAL_TO -> { - return !value; - } - } - return false; - } - - /** - * Serializes the condition to json using Gson - * @return the serialized condition - */ - @Override - public String toJson(){ - return CustomNPCs.getGson().toJson(this); - } - - /** - * - * @param data the serialized condition - * @return the condition from the json - */ - public static LogicalConditional of(String data) { - return CustomNPCs.getGson().fromJson(data, LogicalConditional.class); - } - - /** - * Gets the type of condition - * @return the condition type - * @see Type - */ - @Override - public Type getType() { - return type; - } - - /** - * Sets the comparator of this condition - * @param comparator the comparator to compare the value and target value - * @see Comparator - */ - @Override - public void setComparator(Comparator comparator) { - this.comparator = comparator; - } - - /** - * Sets the value of this condition - * @param value the value to compare - * @see Value - */ - @Override - public void setValue(Value value) { - this.value = value; - } - - /** - * Sets the target value of this condition - * @param targetValue the target value - */ - @Override - public void setTargetValue(String targetValue) { - this.target = targetValue; - } - - /** - * Gets the value the condition is comparing - * @see Value - * @return the value the condition is comparing - */ - @Override - public Value getValue() { - return this.value; - } - - /** - * Gets the target of the condition - * @return returns the target value - */ - @Override - public String getTarget() { - return target; - } - - @Override - public Condition clone() { - try { - return (LogicalConditional) super.clone(); - } catch (CloneNotSupportedException e) { - return new LogicalConditional(comparator, value, target); - } - } - - /** - * Gets the comparator the condition uses to compare the value and target value. - * @return the comparator - * @see Comparator - */ - @Override - public Comparator getComparator() { - return this.comparator; - } -} diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java b/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java deleted file mode 100644 index 3e1c157c..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2024. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.actions.conditions; - -import dev.foxikle.customnpcs.internal.CustomNPCs; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; - -/** - * The object representing a comparison of two numeric values - * @deprecated See {@link NumericCondition} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.8.0") -public class NumericConditional implements Condition { - - private final Type type = Type.NUMERIC; - private Comparator comparator; - private Value value; - private double target; - - /** - * - * @param comparator the comparator to use - * @param value the value to compare - * @param target the target to compare to - * @see Value - * @see Comparator - */ - public NumericConditional(Comparator comparator, Value value, double target) { - this.comparator = comparator; - this.value = value; - this.target = target; - } - - /** - * Computes the condition to determine if the action should be executed - * @param player The player to fetch data from - * @return if the action should be executed - */ - @Override - public boolean compute(Player player) { - double value = 0; - switch (this.value) { - case X_COORD -> value = player.getLocation().x(); - case Y_COORD -> value = player.getLocation().y(); - case Z_COORD -> value = player.getLocation().z(); - case EXP_LEVELS -> value = player.getLevel(); - case EXP_POINTS -> value = player.getExp(); - } - switch (comparator) { - case EQUAL_TO -> { - return value == target; - } - case NOT_EQUAL_TO -> { - return value != target; - } - case LESS_THAN -> { - return value < target; - } - case LESS_THAN_OR_EQUAL_TO -> { - return value <= target; - } - case GREATER_THAN -> { - return value > target; - } - case GREATER_THAN_OR_EQUAL_TO -> { - return value >= target; - } - } - return false; - } - - /** - * Serializes the condition to json using Gson - * @return the serialized condition - */ - @Override - public String toJson(){ - return CustomNPCs.getGson().toJson(this); - } - - /** - * - * @param data the serialized condition - * @return the condition from the json - */ - public static NumericConditional of(String data) { - return CustomNPCs.getGson().fromJson(data, NumericConditional.class); - } - - /** - * Gets the type of condition - * @return the condition type - * @see Type - */ - @Override - public Type getType() { - return type; - } - - /** - * Sets the comparator of this condition - * @param comparator the comparator to compare the value and target value - * @see Comparator - */ - @Override - public void setComparator(Comparator comparator) { - this.comparator = comparator; - } - - /** - * Sets the value of this condition - * @param value the value to compare - * @see Value - */ - @Override - public void setValue(Value value) { - this.value = value; - } - - /** - * Sets the target value of this condition - * @param targetValue the target value - */ - @Override - public void setTargetValue(String targetValue) { - this.target = Double.parseDouble(targetValue); - } - - /** - * Gets the value the condition is comparing - * @see Value - * @return the value the condition is comparing - */ - @Override - public Value getValue() { - return this.value; - } - - /** - * Gets the target of the condition - * @return returns the target value - */ - @Override - public String getTarget() { - return String.valueOf(target); - } - - /** - * Gets the comparator the condition uses to compare the value and target value. - * @return the comparator - * @see Comparator - */ - @Override - public Comparator getComparator() { - return this.comparator; - } - - @Override - public Condition clone() { - try { - return (NumericConditional) super.clone(); - } catch (CloneNotSupportedException e) { - return new NumericConditional(comparator, value, target); - } - } -} diff --git a/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java b/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java index 8c99af5f..c88c13b7 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java +++ b/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java @@ -90,22 +90,6 @@ public NPC(InternalNpc npc) { this.npc = npc; } - - /** - *

Sets the location of the NPC - *

- * - * @param loc the new location for the NPC - * @return the NPC with the modified location - * @since 1.5.2-pre3 - * @deprecated see {@link #setPosition(Location)} (typo ;|) - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.8") - public NPC setPostion(@NotNull Location loc) { - return setPosition(loc); - } - /** *

Sets the location of the NPC *

@@ -117,7 +101,6 @@ public NPC setPostion(@NotNull Location loc) { public NPC setPosition(@NotNull Location loc) { Preconditions.checkArgument(loc != null, "loc cannot be null."); npc.setSpawnLoc(loc); - npc.getSettings().setDirection(loc.getYaw()); return this; } @@ -178,10 +161,10 @@ public NPC addAction(@NotNull Action action) { * @return the NPC with the modified set of actions * @see Action * @since 1.5.2-pre3 - * @deprecated Use {@link #setActions(Collection)} + * @deprecated Use {@link #setActions(Collection)}, to be removed in 1.9 with the removal of legacy actions. */ @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.8") + @ApiStatus.ScheduledForRemoval(inVersion = "1.9") public NPC setLegacyActions(Collection actionImpls) { List actionList = new ArrayList<>(); for (LegacyAction legacyAction : actionImpls) { diff --git a/core/src/main/java/dev/foxikle/customnpcs/api/NPCApi.java b/core/src/main/java/dev/foxikle/customnpcs/api/NPCApi.java index c99565d6..124b1512 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/api/NPCApi.java +++ b/core/src/main/java/dev/foxikle/customnpcs/api/NPCApi.java @@ -25,7 +25,6 @@ import dev.foxikle.customnpcs.internal.CustomNPCs; import lombok.experimental.UtilityClass; import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.ApiStatus; import java.util.UUID; @@ -39,16 +38,6 @@ public class NPCApi { */ static final CustomNPCs plugin = JavaPlugin.getPlugin(CustomNPCs.class); - /** - * Initiailizes the API - * - * @deprecated since it's no longer necessary - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.8") - public static void initialize() { - } - /** * Gets the NPC object by ID. * diff --git a/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java b/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java index 6dd8986d..adb71896 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java +++ b/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java @@ -27,7 +27,6 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Color; -import org.jetbrains.annotations.ApiStatus; /** * A class holding the data for an NPC's settings @@ -38,9 +37,6 @@ public class Settings { @Getter boolean interactable = false; @Getter boolean tunnelvision = false; @Getter boolean resilient = true; - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.8") - @Getter double direction = 180; @Getter String value = ""; @Getter String signature = ""; String name = "not set"; @@ -59,7 +55,6 @@ public class Settings { * @param interactable If the npc has actions to execute * @param tunnelvision If the npc will look at players * @param resilient If the npc will persist on restarts - * @param direction The direction to look * @param value The value of the npc's skin * @param signature The signature of the npc's skin * @param skinName The name of the skin as it is referenced in the Menu @@ -67,11 +62,10 @@ public class Settings { * @param customInteractableHologram The custom hologram * @param hideClickableHologram If the NPC's Clickable hologram should be hidden */ - public Settings(boolean interactable, boolean tunnelvision, boolean resilient, double direction, String value, String signature, String skinName, String name, String customInteractableHologram, boolean hideClickableHologram) { + public Settings(boolean interactable, boolean tunnelvision, boolean resilient, String value, String signature, String skinName, String name, String customInteractableHologram, boolean hideClickableHologram) { this.interactable = interactable; this.tunnelvision = tunnelvision; this.resilient = resilient; - this.direction = direction; this.value = value; this.signature = signature; this.skinName = skinName; @@ -125,6 +119,6 @@ public void setSkinData(String signature, String value, String skinName) { @SuppressWarnings("all") public Settings clone(){ - return new Settings(interactable, tunnelvision, resilient, direction, value, signature, skinName, name, customInteractableHologram, hideClickableHologram); + return new Settings(interactable, tunnelvision, resilient, value, signature, skinName, name, customInteractableHologram, hideClickableHologram); } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java index 89808a32..b704f867 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java @@ -561,7 +561,6 @@ public void loadNPC(UUID uuid) { section.getBoolean("clickable"), section.getBoolean("tunnelvision"), true, - location.getYaw(), section.getString("value"), section.getString("signature"), section.getString("skin"), diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CloneCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CloneCommand.java index bdda359c..0a2b12ae 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CloneCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CloneCommand.java @@ -58,7 +58,6 @@ public void usage( assert finalNpc != null; InternalNpc newNpc = finalNpc.clone(); newNpc.setSpawnLoc(p.getLocation()); - newNpc.getSettings().setDirection(p.getLocation().getYaw()); newNpc.createNPC(); p.sendMessage(Msg.translate(p.locale(), "customnpcs.commands.clone.success")); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java index 8bbc9b45..5acd7f57 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java @@ -59,7 +59,6 @@ public void usage( assert finalNpc != null; finalNpc.remove(); finalNpc.setSpawnLoc(p.getLocation()); - finalNpc.getSettings().setDirection(p.getLocation().getYaw()); finalNpc.createNPC(); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java b/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java index 8f0545ed..4750e4b8 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java @@ -167,7 +167,7 @@ private void processPlayerMovement(final Player player, final InternalNpc npc, f return; } } - npc.setYRotation((float) npc.getSettings().getDirection()); + npc.setYRotation(npc.getSpawnLoc().getYaw()); }); } } @@ -468,7 +468,6 @@ public void onChat(AsyncPlayerChatEvent e) { return; } if (message.equalsIgnoreCase("confirm")) { - npc.getSettings().setDirection(player.getLocation().getYaw()); npc.getSpawnLoc().setPitch(player.getLocation().getPitch()); npc.getSpawnLoc().setYaw(player.getLocation().getYaw()); player.sendMessage(Msg.translate(player.locale(), "customnpcs.set.facing_direction")); diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java index 528cbfef..ef4ebb03 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java @@ -71,7 +71,7 @@ public class MenuItems { } public static Button rotation(InternalNpc npc, Player player) { - double dir = npc.getSettings().getDirection(); + double dir = npc.getSpawnLoc().getYaw(); List lore = new ArrayList<>(); Map highlightIndexMap = Map.of(180, 0, -135, 1, -90, 2, -45, 3, 0, 4, 45, 5, 90, 6, 135, 7); @@ -124,7 +124,7 @@ public static Button rotation(InternalNpc npc, Player player) { } } - npc.getSettings().setDirection(newDir); + npc.getSpawnLoc().setYaw((float) newDir); menuView.replaceButton(10, rotation(npc, p)); })); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java index df030413..a039147a 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java @@ -133,7 +133,7 @@ public static void setTotalExperience(Player player, int amount) { public static Location calcLocation(InternalNpc npc) { Location loc = npc.getCurrentLocation(); double pitch = Math.toRadians(npc.getSpawnLoc().getPitch()); - double yaw = Math.toRadians(npc.getSettings().getDirection()); + double yaw = Math.toRadians(npc.getSpawnLoc().getYaw()); // trig to calculate the position diff --git a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java index 21bee11f..c45c540b 100644 --- a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java +++ b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java @@ -403,7 +403,7 @@ public void injectPlayer(Player p) { ClientboundAddPlayerPacket namedEntitySpawn = new ClientboundAddPlayerPacket(this); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSettings().getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); super.detectEquipmentUpdates(); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -437,7 +437,7 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } private void updateHolograms(Player p) { @@ -624,7 +624,7 @@ public void reloadSettings() { super.getBukkitEntity().getEquipment().setItem(EquipmentSlot.LEGS, equipment.getLegs(), true); super.getBukkitEntity().getEquipment().setItem(EquipmentSlot.FEET, equipment.getBoots(), true); super.getBukkitEntity().setItemInHand(equipment.getHand()); - setYRotation((float) getSettings().getDirection()); + setYRotation(getSpawnLoc().getYaw()); } @Override diff --git a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java index 383d6f86..47427519 100644 --- a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java +++ b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java @@ -391,7 +391,7 @@ public void injectPlayer(Player p) { ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(this); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; connection.send(playerInfoAdd); diff --git a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java index e22bb030..2a446108 100644 --- a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java +++ b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java @@ -387,7 +387,7 @@ public void injectPlayer(Player p) { ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(this); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; connection.send(playerInfoAdd); @@ -418,7 +418,7 @@ public void run() { } }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } private void injectHolograms(Player p) { diff --git a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java index e4542111..76a3b5a1 100644 --- a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java +++ b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java @@ -404,7 +404,7 @@ public void injectPlayer(Player p) { ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(this); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -437,7 +437,7 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } diff --git a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java index c6028cb9..fc3ad32b 100644 --- a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java +++ b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java @@ -402,10 +402,10 @@ public void injectPlayer(Player p) { ClientboundPlayerInfoUpdatePacket playerInfoAdd = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this); ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uuid, spawnLoc.x(), spawnLoc.y(), spawnLoc.z(), - spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), settings.getDirection()); + spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getSpawnLoc().getYaw()); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -441,7 +441,7 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } diff --git a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java index 07b0b494..70cb4984 100644 --- a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java +++ b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java @@ -404,10 +404,10 @@ public void injectPlayer(Player p) { ClientboundPlayerInfoUpdatePacket playerInfoAdd = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this); ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uuid, spawnLoc.x(), spawnLoc.y(), spawnLoc.z(), - spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), settings.getDirection()); + spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getSpawnLoc().getYaw()); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -441,7 +441,7 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } diff --git a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java index 1d69331c..b01d5e6a 100644 --- a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java +++ b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java @@ -404,10 +404,10 @@ public void injectPlayer(Player p) { ClientboundPlayerInfoUpdatePacket playerInfoAdd = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this); ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uuid, spawnLoc.x(), spawnLoc.y(), spawnLoc.z(), - spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), settings.getDirection()); + spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getSpawnLoc().getYaw()); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -441,7 +441,7 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } From 020200cf572981c7a061f3e878fd975880186bcf Mon Sep 17 00:00:00 2001 From: foxikle Date: Mon, 30 Dec 2024 09:26:39 -0500 Subject: [PATCH 03/25] Protobuf is cool --- .gitignore | 3 + build.gradle.kts | 2 +- core/build.gradle.kts | 3 +- .../customnpcs/internal/CustomNPCs.java | 39 +- .../customnpcs/internal/menu/SkinCatalog.java | 17 +- .../internal/proto/ActionOuterClass.java | 629 ++++++ .../internal/proto/EquipmentOuterClass.java | 1873 +++++++++++++++++ .../internal/proto/ItemOuterClass.java | 564 +++++ .../internal/proto/LocationOuterClass.java | 1119 ++++++++++ .../internal/proto/NpcListOuterClass.java | 870 ++++++++ .../internal/proto/NpcOuterClass.java | 1822 ++++++++++++++++ .../internal/proto/ProtoWrapper.java | 198 ++ .../internal/proto/SettingsOuterClass.java | 1711 +++++++++++++++ .../internal/storage/StorageProvider.java | 36 + proto/action.proto | 7 + proto/equipment.proto | 14 + proto/item.proto | 8 + proto/location.proto | 15 + proto/npc.proto | 19 + proto/npc_list.proto | 9 + proto/settings.proto | 17 + 21 files changed, 8952 insertions(+), 23 deletions(-) create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/ActionOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/EquipmentOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/ItemOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/LocationOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcListOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/SettingsOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java create mode 100644 proto/action.proto create mode 100644 proto/equipment.proto create mode 100644 proto/item.proto create mode 100644 proto/location.proto create mode 100644 proto/npc.proto create mode 100644 proto/npc_list.proto create mode 100644 proto/settings.proto diff --git a/.gitignore b/.gitignore index a8a6a665..7fc1007e 100644 --- a/.gitignore +++ b/.gitignore @@ -115,3 +115,6 @@ build # Common working directory run/ + +# Proto +compile_proto.sh \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index d4c48c5e..8a181fd5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -47,7 +47,7 @@ dependencies { implementation(project(":v1_20_R1", "reobf")) } -var pluginVersion = "1.7.1" +var pluginVersion = "1.8-pre1" allprojects { group = "dev.foxikle" diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 611ffcff..8b1ad5bf 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -33,7 +33,7 @@ repositories { } dependencies { - implementation("com.github.Mqzn:Lotus:1.1.7") + implementation("com.github.Mqzn:Lotus:1.4") implementation("org.bstats:bstats-bukkit:3.1.0") compileOnly("me.clip:placeholderapi:2.11.6") compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT") @@ -42,6 +42,7 @@ dependencies { annotationProcessor("org.projectlombok:lombok:1.18.36") implementation("dev.velix:imperat-core:1.5.0") implementation("dev.velix:imperat-bukkit:1.5.0") + implementation("com.google.protobuf:protobuf-java:4.29.2") } tasks { diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java index f0b9a006..f2fbe1b7 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java @@ -32,12 +32,9 @@ import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.actions.conditions.ConditionalTypeAdapter; import dev.foxikle.customnpcs.actions.defaultImpl.*; +import dev.foxikle.customnpcs.api.NPC; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; -import dev.foxikle.customnpcs.internal.commands.NpcCommand; -import dev.foxikle.customnpcs.internal.commands.suggestion.NpcSuggester; -import dev.foxikle.customnpcs.internal.commands.suggestion.SoundSuggester; -import dev.foxikle.customnpcs.internal.commands.suggestion.WorldSuggester; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.listeners.Listeners; import dev.foxikle.customnpcs.internal.menu.*; @@ -45,10 +42,10 @@ import dev.foxikle.customnpcs.internal.utils.ActionRegistry; import dev.foxikle.customnpcs.internal.utils.AutoUpdater; import dev.foxikle.customnpcs.internal.utils.Utils; -import dev.velix.imperat.BukkitImperat; import dev.velix.imperat.BukkitSource; import dev.velix.imperat.Imperat; import io.github.mqzen.menus.Lotus; +import io.github.mqzen.menus.adventure.CastingAdventure; import io.github.mqzen.menus.base.pagination.Pagination; import lombok.Getter; import lombok.Setter; @@ -62,7 +59,6 @@ import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.entity.TextDisplay; -import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.messaging.PluginMessageListener; @@ -358,7 +354,7 @@ public void onEnable() { getLogger().info("Loading menus!"); - lotus = Lotus.load(this, EventPriority.HIGHEST); + lotus = Lotus.load(this, new CastingAdventure<>()); lotus.registerMenu(new ActionMenu()); lotus.registerMenu(new ActionCustomizerMenu()); lotus.registerMenu(new MainNPCMenu()); @@ -376,18 +372,29 @@ public void onEnable() { if (!System.getProperties().containsKey("CUSTOMNPCS_LOADED")) { getLogger().info("Loading commands!"); - imperat = BukkitImperat.builder(this).applyBrigadier(true) - .namedSuggestionResolver("sound", new SoundSuggester()) - .namedSuggestionResolver("current_npc", new NpcSuggester()) - .namedSuggestionResolver("broken_npc", new NpcSuggester()) - .namedSuggestionResolver("worlds", new WorldSuggester()) - .build(); - - // only one command, the rest are sub commands - imperat.registerCommand(new NpcCommand()); +// imperat = BukkitImperat.builder(this).applyBrigadier(true) +// .namedSuggestionResolver("sound", new SoundSuggester()) +// .namedSuggestionResolver("current_npc", new NpcSuggester()) +// .namedSuggestionResolver("broken_npc", new NpcSuggester()) +// .namedSuggestionResolver("worlds", new WorldSuggester()) +// .build(); +// +// // only one command, the rest are sub commands +// imperat.registerCommand(new NpcCommand()); } System.setProperty("CUSTOMNPCS_LOADED", "true"); + + NPC npc = new NPC(Bukkit.getWorld("world")); + npc.setPosition(new Location(Bukkit.getWorld("world"), 0, 100, 0)); + Settings settings = npc.getSettings(); + settings.setName("CustomNPCs"); + settings.setResilient(false); + settings.setInteractable(true); +// settings.setHologramBackground(Color.BLUE); + npc.setSettings(settings); + npc.create(); + } private void registerNpcTeam() { diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/SkinCatalog.java b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/SkinCatalog.java index d8bc0870..a443621e 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/SkinCatalog.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/SkinCatalog.java @@ -25,12 +25,13 @@ import dev.foxikle.customnpcs.internal.utils.Msg; import io.github.mqzen.menus.base.Content; import io.github.mqzen.menus.base.MenuView; +import io.github.mqzen.menus.base.pagination.FillRange; import io.github.mqzen.menus.base.pagination.Page; -import io.github.mqzen.menus.base.pagination.PageView; import io.github.mqzen.menus.base.style.TextLayout; import io.github.mqzen.menus.base.style.TextLayoutPane; import io.github.mqzen.menus.misc.Capacity; import io.github.mqzen.menus.misc.DataRegistry; +import io.github.mqzen.menus.misc.Slot; import io.github.mqzen.menus.misc.itembuilder.ItemBuilder; import io.github.mqzen.menus.titles.MenuTitle; import io.github.mqzen.menus.titles.MenuTitles; @@ -41,12 +42,17 @@ import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class SkinCatalog extends Page { + + /** + * @param capacity + * @param player + * @return + */ @Override - public int getPageButtonsCount(@Nullable PageView pageView, Player player) { - return 28; + public FillRange getFillRange(Capacity capacity, Player player) { + return FillRange.start(capacity, Slot.of(10)).end(Slot.of(43)); } @Override @@ -63,6 +69,7 @@ public ItemStack previousPageItem(Player player) { .build(); } + /** * Handles the click sounds on page change * @@ -70,7 +77,7 @@ public ItemStack previousPageItem(Player player) { * @param event the click event */ @Override - public void onClick(MenuView playerMenuView, InventoryClickEvent event) { + public void onPostClick(MenuView playerMenuView, InventoryClickEvent event) { if ((event.getSlot() == 45 || event.getSlot() == 53) && event.getCurrentItem().getType() == Material.ARROW) { event.getWhoClicked().playSound(Sound.sound(builder -> builder.type(Key.key("minecraft", "ui.button.click")).pitch(1).volume(1).source(Sound.Source.MASTER))); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ActionOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ActionOuterClass.java new file mode 100644 index 00000000..e16db86a --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ActionOuterClass.java @@ -0,0 +1,629 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: action.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class ActionOuterClass { + private ActionOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + ActionOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface ActionOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Action) + com.google.protobuf.MessageOrBuilder { + + /** + * string serialized_data = 1; + * + * @return The serializedData. + */ + java.lang.String getSerializedData(); + + /** + * string serialized_data = 1; + * + * @return The bytes for serializedData. + */ + com.google.protobuf.ByteString + getSerializedDataBytes(); + } + + /** + *
+     * action doesn't need migration versions as thats handled by each individual action
+     * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Action} + */ + public static final class Action extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Action) + ActionOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Action.class.getName()); + } + + // Use Action.newBuilder() to construct. + private Action(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Action() { + serializedData_ = ""; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.class, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder.class); + } + + public static final int SERIALIZED_DATA_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object serializedData_ = ""; + + /** + * string serialized_data = 1; + * + * @return The serializedData. + */ + @java.lang.Override + public java.lang.String getSerializedData() { + java.lang.Object ref = serializedData_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + serializedData_ = s; + return s; + } + } + + /** + * string serialized_data = 1; + * + * @return The bytes for serializedData. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSerializedDataBytes() { + java.lang.Object ref = serializedData_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + serializedData_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(serializedData_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, serializedData_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(serializedData_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, serializedData_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Action other)) { + return super.equals(obj); + } + + if (!getSerializedData() + .equals(other.getSerializedData())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SERIALIZED_DATA_FIELD_NUMBER; + hash = (53 * hash) + getSerializedData().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + *

+         * action doesn't need migration versions as thats handled by each individual action
+         * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Action} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Action) + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.class, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + serializedData_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action build() { + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action buildPartial() { + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action result = new dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.serializedData_ = serializedData_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action other) { + if (other == dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.getDefaultInstance()) + return this; + if (!other.getSerializedData().isEmpty()) { + serializedData_ = other.serializedData_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + serializedData_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object serializedData_ = ""; + + /** + * string serialized_data = 1; + * + * @return The serializedData. + */ + public java.lang.String getSerializedData() { + java.lang.Object ref = serializedData_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + serializedData_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string serialized_data = 1; + * + * @return The bytes for serializedData. + */ + public com.google.protobuf.ByteString + getSerializedDataBytes() { + java.lang.Object ref = serializedData_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + serializedData_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string serialized_data = 1; + * + * @param value The serializedData to set. + * @return This builder for chaining. + */ + public Builder setSerializedData( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + serializedData_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * string serialized_data = 1; + * + * @return This builder for chaining. + */ + public Builder clearSerializedData() { + serializedData_ = getDefaultInstance().getSerializedData(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * string serialized_data = 1; + * + * @param value The bytes for serializedData to set. + * @return This builder for chaining. + */ + public Builder setSerializedDataBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + serializedData_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Action) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Action) + private static final dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action(); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Action parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Action_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\014action.proto\022%dev.foxikle.customnpcs.i" + + "nternal.proto\"!\n\006Action\022\027\n\017serialized_da" + + "ta\030\001 \001(\tb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Action_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor, + new java.lang.String[]{"SerializedData",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/EquipmentOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/EquipmentOuterClass.java new file mode 100644 index 00000000..ffae48ef --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/EquipmentOuterClass.java @@ -0,0 +1,1873 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: equipment.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class EquipmentOuterClass { + private EquipmentOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + EquipmentOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface EquipmentOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Equipment) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + int getSchemaVersion(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return Whether the mainHand field is set. + */ + boolean hasMainHand(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return The mainHand. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getMainHand(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getMainHandOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return Whether the offHand field is set. + */ + boolean hasOffHand(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return The offHand. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getOffHand(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getOffHandOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return Whether the head field is set. + */ + boolean hasHead(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return The head. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getHead(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getHeadOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return Whether the chest field is set. + */ + boolean hasChest(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return The chest. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getChest(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getChestOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return Whether the legs field is set. + */ + boolean hasLegs(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return The legs. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getLegs(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getLegsOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return Whether the feet field is set. + */ + boolean hasFeet(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return The feet. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getFeet(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getFeetOrBuilder(); + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Equipment} + */ + public static final class Equipment extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Equipment) + EquipmentOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Equipment.class.getName()); + } + + // Use Equipment.newBuilder() to construct. + private Equipment(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Equipment() { + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.class, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder.class); + } + + private int bitField0_; + public static final int SCHEMA_VERSION_FIELD_NUMBER = 1; + private int schemaVersion_ = 0; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + public static final int MAIN_HAND_FIELD_NUMBER = 2; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item mainHand_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return Whether the mainHand field is set. + */ + @java.lang.Override + public boolean hasMainHand() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return The mainHand. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getMainHand() { + return mainHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : mainHand_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getMainHandOrBuilder() { + return mainHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : mainHand_; + } + + public static final int OFF_HAND_FIELD_NUMBER = 3; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item offHand_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return Whether the offHand field is set. + */ + @java.lang.Override + public boolean hasOffHand() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return The offHand. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getOffHand() { + return offHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : offHand_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getOffHandOrBuilder() { + return offHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : offHand_; + } + + public static final int HEAD_FIELD_NUMBER = 4; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item head_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return Whether the head field is set. + */ + @java.lang.Override + public boolean hasHead() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return The head. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getHead() { + return head_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : head_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getHeadOrBuilder() { + return head_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : head_; + } + + public static final int CHEST_FIELD_NUMBER = 5; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item chest_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return Whether the chest field is set. + */ + @java.lang.Override + public boolean hasChest() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return The chest. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getChest() { + return chest_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : chest_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getChestOrBuilder() { + return chest_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : chest_; + } + + public static final int LEGS_FIELD_NUMBER = 6; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item legs_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return Whether the legs field is set. + */ + @java.lang.Override + public boolean hasLegs() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return The legs. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getLegs() { + return legs_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : legs_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getLegsOrBuilder() { + return legs_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : legs_; + } + + public static final int FEET_FIELD_NUMBER = 7; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item feet_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return Whether the feet field is set. + */ + @java.lang.Override + public boolean hasFeet() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return The feet. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getFeet() { + return feet_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : feet_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getFeetOrBuilder() { + return feet_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : feet_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (schemaVersion_ != 0) { + output.writeInt32(1, schemaVersion_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getMainHand()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getOffHand()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getHead()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(5, getChest()); + } + if (((bitField0_ & 0x00000010) != 0)) { + output.writeMessage(6, getLegs()); + } + if (((bitField0_ & 0x00000020) != 0)) { + output.writeMessage(7, getFeet()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (schemaVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, schemaVersion_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getMainHand()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getOffHand()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getHead()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getChest()); + } + if (((bitField0_ & 0x00000010) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getLegs()); + } + if (((bitField0_ & 0x00000020) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, getFeet()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Equipment other)) { + return super.equals(obj); + } + + if (getSchemaVersion() + != other.getSchemaVersion()) return false; + if (hasMainHand() != other.hasMainHand()) return false; + if (hasMainHand()) { + if (!getMainHand() + .equals(other.getMainHand())) return false; + } + if (hasOffHand() != other.hasOffHand()) return false; + if (hasOffHand()) { + if (!getOffHand() + .equals(other.getOffHand())) return false; + } + if (hasHead() != other.hasHead()) return false; + if (hasHead()) { + if (!getHead() + .equals(other.getHead())) return false; + } + if (hasChest() != other.hasChest()) return false; + if (hasChest()) { + if (!getChest() + .equals(other.getChest())) return false; + } + if (hasLegs() != other.hasLegs()) return false; + if (hasLegs()) { + if (!getLegs() + .equals(other.getLegs())) return false; + } + if (hasFeet() != other.hasFeet()) return false; + if (hasFeet()) { + if (!getFeet() + .equals(other.getFeet())) return false; + } + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SCHEMA_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getSchemaVersion(); + if (hasMainHand()) { + hash = (37 * hash) + MAIN_HAND_FIELD_NUMBER; + hash = (53 * hash) + getMainHand().hashCode(); + } + if (hasOffHand()) { + hash = (37 * hash) + OFF_HAND_FIELD_NUMBER; + hash = (53 * hash) + getOffHand().hashCode(); + } + if (hasHead()) { + hash = (37 * hash) + HEAD_FIELD_NUMBER; + hash = (53 * hash) + getHead().hashCode(); + } + if (hasChest()) { + hash = (37 * hash) + CHEST_FIELD_NUMBER; + hash = (53 * hash) + getChest().hashCode(); + } + if (hasLegs()) { + hash = (37 * hash) + LEGS_FIELD_NUMBER; + hash = (53 * hash) + getLegs().hashCode(); + } + if (hasFeet()) { + hash = (37 * hash) + FEET_FIELD_NUMBER; + hash = (53 * hash) + getFeet().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Equipment} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Equipment) + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.class, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage + .alwaysUseFieldBuilders) { + getMainHandFieldBuilder(); + getOffHandFieldBuilder(); + getHeadFieldBuilder(); + getChestFieldBuilder(); + getLegsFieldBuilder(); + getFeetFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + schemaVersion_ = 0; + mainHand_ = null; + if (mainHandBuilder_ != null) { + mainHandBuilder_.dispose(); + mainHandBuilder_ = null; + } + offHand_ = null; + if (offHandBuilder_ != null) { + offHandBuilder_.dispose(); + offHandBuilder_ = null; + } + head_ = null; + if (headBuilder_ != null) { + headBuilder_.dispose(); + headBuilder_ = null; + } + chest_ = null; + if (chestBuilder_ != null) { + chestBuilder_.dispose(); + chestBuilder_ = null; + } + legs_ = null; + if (legsBuilder_ != null) { + legsBuilder_.dispose(); + legsBuilder_ = null; + } + feet_ = null; + if (feetBuilder_ != null) { + feetBuilder_.dispose(); + feetBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment build() { + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment buildPartial() { + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment result = new dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.schemaVersion_ = schemaVersion_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.mainHand_ = mainHandBuilder_ == null + ? mainHand_ + : mainHandBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.offHand_ = offHandBuilder_ == null + ? offHand_ + : offHandBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.head_ = headBuilder_ == null + ? head_ + : headBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.chest_ = chestBuilder_ == null + ? chest_ + : chestBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.legs_ = legsBuilder_ == null + ? legs_ + : legsBuilder_.build(); + to_bitField0_ |= 0x00000010; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.feet_ = feetBuilder_ == null + ? feet_ + : feetBuilder_.build(); + to_bitField0_ |= 0x00000020; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment other) { + if (other == dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance()) + return this; + if (other.getSchemaVersion() != 0) { + setSchemaVersion(other.getSchemaVersion()); + } + if (other.hasMainHand()) { + mergeMainHand(other.getMainHand()); + } + if (other.hasOffHand()) { + mergeOffHand(other.getOffHand()); + } + if (other.hasHead()) { + mergeHead(other.getHead()); + } + if (other.hasChest()) { + mergeChest(other.getChest()); + } + if (other.hasLegs()) { + mergeLegs(other.getLegs()); + } + if (other.hasFeet()) { + mergeFeet(other.getFeet()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + schemaVersion_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + input.readMessage( + getMainHandFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: { + input.readMessage( + getOffHandFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: { + input.readMessage( + getHeadFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: { + input.readMessage( + getChestFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: { + input.readMessage( + getLegsFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 50 + case 58: { + input.readMessage( + getFeetFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000040; + break; + } // case 58 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int schemaVersion_; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + /** + * int32 schema_version = 1; + * + * @param value The schemaVersion to set. + * @return This builder for chaining. + */ + public Builder setSchemaVersion(int value) { + + schemaVersion_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * int32 schema_version = 1; + * + * @return This builder for chaining. + */ + public Builder clearSchemaVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + schemaVersion_ = 0; + onChanged(); + return this; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item mainHand_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> mainHandBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return Whether the mainHand field is set. + */ + public boolean hasMainHand() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return The mainHand. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getMainHand() { + if (mainHandBuilder_ == null) { + return mainHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : mainHand_; + } else { + return mainHandBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public Builder setMainHand(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (mainHandBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mainHand_ = value; + } else { + mainHandBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public Builder setMainHand( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (mainHandBuilder_ == null) { + mainHand_ = builderForValue.build(); + } else { + mainHandBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public Builder mergeMainHand(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (mainHandBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) && + mainHand_ != null && + mainHand_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getMainHandBuilder().mergeFrom(value); + } else { + mainHand_ = value; + } + } else { + mainHandBuilder_.mergeFrom(value); + } + if (mainHand_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public Builder clearMainHand() { + bitField0_ = (bitField0_ & ~0x00000002); + mainHand_ = null; + if (mainHandBuilder_ != null) { + mainHandBuilder_.dispose(); + mainHandBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getMainHandBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getMainHandFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getMainHandOrBuilder() { + if (mainHandBuilder_ != null) { + return mainHandBuilder_.getMessageOrBuilder(); + } else { + return mainHand_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : mainHand_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getMainHandFieldBuilder() { + if (mainHandBuilder_ == null) { + mainHandBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getMainHand(), + getParentForChildren(), + isClean()); + mainHand_ = null; + } + return mainHandBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item offHand_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> offHandBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return Whether the offHand field is set. + */ + public boolean hasOffHand() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return The offHand. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getOffHand() { + if (offHandBuilder_ == null) { + return offHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : offHand_; + } else { + return offHandBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public Builder setOffHand(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (offHandBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + offHand_ = value; + } else { + offHandBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public Builder setOffHand( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (offHandBuilder_ == null) { + offHand_ = builderForValue.build(); + } else { + offHandBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public Builder mergeOffHand(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (offHandBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) && + offHand_ != null && + offHand_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getOffHandBuilder().mergeFrom(value); + } else { + offHand_ = value; + } + } else { + offHandBuilder_.mergeFrom(value); + } + if (offHand_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public Builder clearOffHand() { + bitField0_ = (bitField0_ & ~0x00000004); + offHand_ = null; + if (offHandBuilder_ != null) { + offHandBuilder_.dispose(); + offHandBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getOffHandBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getOffHandFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getOffHandOrBuilder() { + if (offHandBuilder_ != null) { + return offHandBuilder_.getMessageOrBuilder(); + } else { + return offHand_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : offHand_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getOffHandFieldBuilder() { + if (offHandBuilder_ == null) { + offHandBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getOffHand(), + getParentForChildren(), + isClean()); + offHand_ = null; + } + return offHandBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item head_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> headBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return Whether the head field is set. + */ + public boolean hasHead() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return The head. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getHead() { + if (headBuilder_ == null) { + return head_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : head_; + } else { + return headBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public Builder setHead(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (headBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + head_ = value; + } else { + headBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public Builder setHead( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (headBuilder_ == null) { + head_ = builderForValue.build(); + } else { + headBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public Builder mergeHead(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (headBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) && + head_ != null && + head_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getHeadBuilder().mergeFrom(value); + } else { + head_ = value; + } + } else { + headBuilder_.mergeFrom(value); + } + if (head_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public Builder clearHead() { + bitField0_ = (bitField0_ & ~0x00000008); + head_ = null; + if (headBuilder_ != null) { + headBuilder_.dispose(); + headBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getHeadBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getHeadFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getHeadOrBuilder() { + if (headBuilder_ != null) { + return headBuilder_.getMessageOrBuilder(); + } else { + return head_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : head_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getHeadFieldBuilder() { + if (headBuilder_ == null) { + headBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getHead(), + getParentForChildren(), + isClean()); + head_ = null; + } + return headBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item chest_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> chestBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return Whether the chest field is set. + */ + public boolean hasChest() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return The chest. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getChest() { + if (chestBuilder_ == null) { + return chest_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : chest_; + } else { + return chestBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public Builder setChest(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (chestBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + chest_ = value; + } else { + chestBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public Builder setChest( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (chestBuilder_ == null) { + chest_ = builderForValue.build(); + } else { + chestBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public Builder mergeChest(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (chestBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) && + chest_ != null && + chest_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getChestBuilder().mergeFrom(value); + } else { + chest_ = value; + } + } else { + chestBuilder_.mergeFrom(value); + } + if (chest_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public Builder clearChest() { + bitField0_ = (bitField0_ & ~0x00000010); + chest_ = null; + if (chestBuilder_ != null) { + chestBuilder_.dispose(); + chestBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getChestBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getChestFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getChestOrBuilder() { + if (chestBuilder_ != null) { + return chestBuilder_.getMessageOrBuilder(); + } else { + return chest_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : chest_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getChestFieldBuilder() { + if (chestBuilder_ == null) { + chestBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getChest(), + getParentForChildren(), + isClean()); + chest_ = null; + } + return chestBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item legs_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> legsBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return Whether the legs field is set. + */ + public boolean hasLegs() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return The legs. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getLegs() { + if (legsBuilder_ == null) { + return legs_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : legs_; + } else { + return legsBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public Builder setLegs(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (legsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + legs_ = value; + } else { + legsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public Builder setLegs( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (legsBuilder_ == null) { + legs_ = builderForValue.build(); + } else { + legsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public Builder mergeLegs(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (legsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) && + legs_ != null && + legs_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getLegsBuilder().mergeFrom(value); + } else { + legs_ = value; + } + } else { + legsBuilder_.mergeFrom(value); + } + if (legs_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public Builder clearLegs() { + bitField0_ = (bitField0_ & ~0x00000020); + legs_ = null; + if (legsBuilder_ != null) { + legsBuilder_.dispose(); + legsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getLegsBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return getLegsFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getLegsOrBuilder() { + if (legsBuilder_ != null) { + return legsBuilder_.getMessageOrBuilder(); + } else { + return legs_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : legs_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getLegsFieldBuilder() { + if (legsBuilder_ == null) { + legsBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getLegs(), + getParentForChildren(), + isClean()); + legs_ = null; + } + return legsBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item feet_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> feetBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return Whether the feet field is set. + */ + public boolean hasFeet() { + return ((bitField0_ & 0x00000040) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return The feet. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getFeet() { + if (feetBuilder_ == null) { + return feet_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : feet_; + } else { + return feetBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public Builder setFeet(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (feetBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + feet_ = value; + } else { + feetBuilder_.setMessage(value); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public Builder setFeet( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (feetBuilder_ == null) { + feet_ = builderForValue.build(); + } else { + feetBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public Builder mergeFeet(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (feetBuilder_ == null) { + if (((bitField0_ & 0x00000040) != 0) && + feet_ != null && + feet_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getFeetBuilder().mergeFrom(value); + } else { + feet_ = value; + } + } else { + feetBuilder_.mergeFrom(value); + } + if (feet_ != null) { + bitField0_ |= 0x00000040; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public Builder clearFeet() { + bitField0_ = (bitField0_ & ~0x00000040); + feet_ = null; + if (feetBuilder_ != null) { + feetBuilder_.dispose(); + feetBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getFeetBuilder() { + bitField0_ |= 0x00000040; + onChanged(); + return getFeetFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getFeetOrBuilder() { + if (feetBuilder_ != null) { + return feetBuilder_.getMessageOrBuilder(); + } else { + return feet_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : feet_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getFeetFieldBuilder() { + if (feetBuilder_ == null) { + feetBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getFeet(), + getParentForChildren(), + isClean()); + feet_ = null; + } + return feetBuilder_; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Equipment) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Equipment) + private static final dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment(); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Equipment parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\017equipment.proto\022%dev.foxikle.customnpc" + + "s.internal.proto\032\nitem.proto\"\217\003\n\tEquipme" + + "nt\022\026\n\016schema_version\030\001 \001(\005\022>\n\tmain_hand\030" + + "\002 \001(\0132+.dev.foxikle.customnpcs.internal." + + "proto.Item\022=\n\010off_hand\030\003 \001(\0132+.dev.foxik" + + "le.customnpcs.internal.proto.Item\0229\n\004hea" + + "d\030\004 \001(\0132+.dev.foxikle.customnpcs.interna" + + "l.proto.Item\022:\n\005chest\030\005 \001(\0132+.dev.foxikl" + + "e.customnpcs.internal.proto.Item\0229\n\004legs" + + "\030\006 \001(\0132+.dev.foxikle.customnpcs.internal" + + ".proto.Item\0229\n\004feet\030\007 \001(\0132+.dev.foxikle." + + "customnpcs.internal.proto.Itemb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.getDescriptor(), + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor, + new java.lang.String[]{"SchemaVersion", "MainHand", "OffHand", "Head", "Chest", "Legs", "Feet",}); + descriptor.resolveAllFeaturesImmutable(); + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ItemOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ItemOuterClass.java new file mode 100644 index 00000000..e65a9b82 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ItemOuterClass.java @@ -0,0 +1,564 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: item.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class ItemOuterClass { + private ItemOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + ItemOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface ItemOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Item) + com.google.protobuf.MessageOrBuilder { + + /** + *

+         * byte array
+         * 
+ * + * bytes serialized = 1; + * + * @return The serialized. + */ + com.google.protobuf.ByteString getSerialized(); + } + + /** + *
+     * doesn't need a migrations field as that is already handled by Paper's itemstack serialization
+     * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Item} + */ + public static final class Item extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Item) + ItemOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Item.class.getName()); + } + + // Use Item.newBuilder() to construct. + private Item(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Item() { + serialized_ = com.google.protobuf.ByteString.EMPTY; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.class, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder.class); + } + + public static final int SERIALIZED_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString serialized_ = com.google.protobuf.ByteString.EMPTY; + + /** + *

+         * byte array
+         * 
+ * + * bytes serialized = 1; + * + * @return The serialized. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSerialized() { + return serialized_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!serialized_.isEmpty()) { + output.writeBytes(1, serialized_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!serialized_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, serialized_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Item other)) { + return super.equals(obj); + } + + if (!getSerialized() + .equals(other.getSerialized())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SERIALIZED_FIELD_NUMBER; + hash = (53 * hash) + getSerialized().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + *
+         * doesn't need a migrations field as that is already handled by Paper's itemstack serialization
+         * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Item} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Item) + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.class, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + serialized_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item build() { + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item buildPartial() { + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item result = new dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.serialized_ = serialized_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item other) { + if (other == dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) + return this; + if (other.getSerialized() != com.google.protobuf.ByteString.EMPTY) { + setSerialized(other.getSerialized()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + serialized_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.ByteString serialized_ = com.google.protobuf.ByteString.EMPTY; + + /** + *

+             * byte array
+             * 
+ * + * bytes serialized = 1; + * + * @return The serialized. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSerialized() { + return serialized_; + } + + /** + *
+             * byte array
+             * 
+ * + * bytes serialized = 1; + * + * @param value The serialized to set. + * @return This builder for chaining. + */ + public Builder setSerialized(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + serialized_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + *
+             * byte array
+             * 
+ * + * bytes serialized = 1; + * + * @return This builder for chaining. + */ + public Builder clearSerialized() { + bitField0_ = (bitField0_ & ~0x00000001); + serialized_ = getDefaultInstance().getSerialized(); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Item) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Item) + private static final dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item(); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Item parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Item_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\nitem.proto\022%dev.foxikle.customnpcs.int" + + "ernal.proto\"\032\n\004Item\022\022\n\nserialized\030\001 \001(\014b" + + "\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Item_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor, + new java.lang.String[]{"Serialized",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/LocationOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/LocationOuterClass.java new file mode 100644 index 00000000..310f9263 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/LocationOuterClass.java @@ -0,0 +1,1119 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: location.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class LocationOuterClass { + private LocationOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + LocationOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface LocationOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Location) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + int getSchemaVersion(); + + /** + * string world = 2; + * + * @return The world. + */ + java.lang.String getWorld(); + + /** + * string world = 2; + * + * @return The bytes for world. + */ + com.google.protobuf.ByteString + getWorldBytes(); + + /** + * double x = 3; + * + * @return The x. + */ + double getX(); + + /** + * double y = 4; + * + * @return The y. + */ + double getY(); + + /** + * double z = 5; + * + * @return The z. + */ + double getZ(); + + /** + * float pitch = 6; + * + * @return The pitch. + */ + float getPitch(); + + /** + * float yaw = 7; + * + * @return The yaw. + */ + float getYaw(); + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Location} + */ + public static final class Location extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Location) + LocationOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Location.class.getName()); + } + + // Use Location.newBuilder() to construct. + private Location(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Location() { + world_ = ""; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.class, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder.class); + } + + public static final int SCHEMA_VERSION_FIELD_NUMBER = 1; + private int schemaVersion_ = 0; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + public static final int WORLD_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private volatile java.lang.Object world_ = ""; + + /** + * string world = 2; + * + * @return The world. + */ + @java.lang.Override + public java.lang.String getWorld() { + java.lang.Object ref = world_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + world_ = s; + return s; + } + } + + /** + * string world = 2; + * + * @return The bytes for world. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getWorldBytes() { + java.lang.Object ref = world_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + world_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int X_FIELD_NUMBER = 3; + private double x_ = 0D; + + /** + * double x = 3; + * + * @return The x. + */ + @java.lang.Override + public double getX() { + return x_; + } + + public static final int Y_FIELD_NUMBER = 4; + private double y_ = 0D; + + /** + * double y = 4; + * + * @return The y. + */ + @java.lang.Override + public double getY() { + return y_; + } + + public static final int Z_FIELD_NUMBER = 5; + private double z_ = 0D; + + /** + * double z = 5; + * + * @return The z. + */ + @java.lang.Override + public double getZ() { + return z_; + } + + public static final int PITCH_FIELD_NUMBER = 6; + private float pitch_ = 0F; + + /** + * float pitch = 6; + * + * @return The pitch. + */ + @java.lang.Override + public float getPitch() { + return pitch_; + } + + public static final int YAW_FIELD_NUMBER = 7; + private float yaw_ = 0F; + + /** + * float yaw = 7; + * + * @return The yaw. + */ + @java.lang.Override + public float getYaw() { + return yaw_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (schemaVersion_ != 0) { + output.writeInt32(1, schemaVersion_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(world_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, world_); + } + if (java.lang.Double.doubleToRawLongBits(x_) != 0) { + output.writeDouble(3, x_); + } + if (java.lang.Double.doubleToRawLongBits(y_) != 0) { + output.writeDouble(4, y_); + } + if (java.lang.Double.doubleToRawLongBits(z_) != 0) { + output.writeDouble(5, z_); + } + if (java.lang.Float.floatToRawIntBits(pitch_) != 0) { + output.writeFloat(6, pitch_); + } + if (java.lang.Float.floatToRawIntBits(yaw_) != 0) { + output.writeFloat(7, yaw_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (schemaVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, schemaVersion_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(world_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, world_); + } + if (java.lang.Double.doubleToRawLongBits(x_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(3, x_); + } + if (java.lang.Double.doubleToRawLongBits(y_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(4, y_); + } + if (java.lang.Double.doubleToRawLongBits(z_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(5, z_); + } + if (java.lang.Float.floatToRawIntBits(pitch_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(6, pitch_); + } + if (java.lang.Float.floatToRawIntBits(yaw_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(7, yaw_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Location other)) { + return super.equals(obj); + } + + if (getSchemaVersion() + != other.getSchemaVersion()) return false; + if (!getWorld() + .equals(other.getWorld())) return false; + if (java.lang.Double.doubleToLongBits(getX()) + != java.lang.Double.doubleToLongBits( + other.getX())) return false; + if (java.lang.Double.doubleToLongBits(getY()) + != java.lang.Double.doubleToLongBits( + other.getY())) return false; + if (java.lang.Double.doubleToLongBits(getZ()) + != java.lang.Double.doubleToLongBits( + other.getZ())) return false; + if (java.lang.Float.floatToIntBits(getPitch()) + != java.lang.Float.floatToIntBits( + other.getPitch())) return false; + if (java.lang.Float.floatToIntBits(getYaw()) + != java.lang.Float.floatToIntBits( + other.getYaw())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SCHEMA_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getSchemaVersion(); + hash = (37 * hash) + WORLD_FIELD_NUMBER; + hash = (53 * hash) + getWorld().hashCode(); + hash = (37 * hash) + X_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getX())); + hash = (37 * hash) + Y_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getY())); + hash = (37 * hash) + Z_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getZ())); + hash = (37 * hash) + PITCH_FIELD_NUMBER; + hash = (53 * hash) + java.lang.Float.floatToIntBits( + getPitch()); + hash = (37 * hash) + YAW_FIELD_NUMBER; + hash = (53 * hash) + java.lang.Float.floatToIntBits( + getYaw()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Location} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Location) + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.class, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + schemaVersion_ = 0; + world_ = ""; + x_ = 0D; + y_ = 0D; + z_ = 0D; + pitch_ = 0F; + yaw_ = 0F; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location build() { + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location buildPartial() { + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location result = new dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.schemaVersion_ = schemaVersion_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.world_ = world_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.x_ = x_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.y_ = y_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.z_ = z_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.pitch_ = pitch_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.yaw_ = yaw_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location other) { + if (other == dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance()) + return this; + if (other.getSchemaVersion() != 0) { + setSchemaVersion(other.getSchemaVersion()); + } + if (!other.getWorld().isEmpty()) { + world_ = other.world_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.getX() != 0D) { + setX(other.getX()); + } + if (other.getY() != 0D) { + setY(other.getY()); + } + if (other.getZ() != 0D) { + setZ(other.getZ()); + } + if (other.getPitch() != 0F) { + setPitch(other.getPitch()); + } + if (other.getYaw() != 0F) { + setYaw(other.getYaw()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + schemaVersion_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + world_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 25: { + x_ = input.readDouble(); + bitField0_ |= 0x00000004; + break; + } // case 25 + case 33: { + y_ = input.readDouble(); + bitField0_ |= 0x00000008; + break; + } // case 33 + case 41: { + z_ = input.readDouble(); + bitField0_ |= 0x00000010; + break; + } // case 41 + case 53: { + pitch_ = input.readFloat(); + bitField0_ |= 0x00000020; + break; + } // case 53 + case 61: { + yaw_ = input.readFloat(); + bitField0_ |= 0x00000040; + break; + } // case 61 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int schemaVersion_; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + /** + * int32 schema_version = 1; + * + * @param value The schemaVersion to set. + * @return This builder for chaining. + */ + public Builder setSchemaVersion(int value) { + + schemaVersion_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * int32 schema_version = 1; + * + * @return This builder for chaining. + */ + public Builder clearSchemaVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + schemaVersion_ = 0; + onChanged(); + return this; + } + + private java.lang.Object world_ = ""; + + /** + * string world = 2; + * + * @return The world. + */ + public java.lang.String getWorld() { + java.lang.Object ref = world_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + world_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string world = 2; + * + * @return The bytes for world. + */ + public com.google.protobuf.ByteString + getWorldBytes() { + java.lang.Object ref = world_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + world_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string world = 2; + * + * @param value The world to set. + * @return This builder for chaining. + */ + public Builder setWorld( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + world_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * string world = 2; + * + * @return This builder for chaining. + */ + public Builder clearWorld() { + world_ = getDefaultInstance().getWorld(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * string world = 2; + * + * @param value The bytes for world to set. + * @return This builder for chaining. + */ + public Builder setWorldBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + world_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private double x_; + + /** + * double x = 3; + * + * @return The x. + */ + @java.lang.Override + public double getX() { + return x_; + } + + /** + * double x = 3; + * + * @param value The x to set. + * @return This builder for chaining. + */ + public Builder setX(double value) { + + x_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * double x = 3; + * + * @return This builder for chaining. + */ + public Builder clearX() { + bitField0_ = (bitField0_ & ~0x00000004); + x_ = 0D; + onChanged(); + return this; + } + + private double y_; + + /** + * double y = 4; + * + * @return The y. + */ + @java.lang.Override + public double getY() { + return y_; + } + + /** + * double y = 4; + * + * @param value The y to set. + * @return This builder for chaining. + */ + public Builder setY(double value) { + + y_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * double y = 4; + * + * @return This builder for chaining. + */ + public Builder clearY() { + bitField0_ = (bitField0_ & ~0x00000008); + y_ = 0D; + onChanged(); + return this; + } + + private double z_; + + /** + * double z = 5; + * + * @return The z. + */ + @java.lang.Override + public double getZ() { + return z_; + } + + /** + * double z = 5; + * + * @param value The z to set. + * @return This builder for chaining. + */ + public Builder setZ(double value) { + + z_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * double z = 5; + * + * @return This builder for chaining. + */ + public Builder clearZ() { + bitField0_ = (bitField0_ & ~0x00000010); + z_ = 0D; + onChanged(); + return this; + } + + private float pitch_; + + /** + * float pitch = 6; + * + * @return The pitch. + */ + @java.lang.Override + public float getPitch() { + return pitch_; + } + + /** + * float pitch = 6; + * + * @param value The pitch to set. + * @return This builder for chaining. + */ + public Builder setPitch(float value) { + + pitch_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * float pitch = 6; + * + * @return This builder for chaining. + */ + public Builder clearPitch() { + bitField0_ = (bitField0_ & ~0x00000020); + pitch_ = 0F; + onChanged(); + return this; + } + + private float yaw_; + + /** + * float yaw = 7; + * + * @return The yaw. + */ + @java.lang.Override + public float getYaw() { + return yaw_; + } + + /** + * float yaw = 7; + * + * @param value The yaw to set. + * @return This builder for chaining. + */ + public Builder setYaw(float value) { + + yaw_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * float yaw = 7; + * + * @return This builder for chaining. + */ + public Builder clearYaw() { + bitField0_ = (bitField0_ & ~0x00000040); + yaw_ = 0F; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Location) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Location) + private static final dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location(); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Location parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Location_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\016location.proto\022%dev.foxikle.customnpcs" + + ".internal.proto\"n\n\010Location\022\026\n\016schema_ve" + + "rsion\030\001 \001(\005\022\r\n\005world\030\002 \001(\t\022\t\n\001x\030\003 \001(\001\022\t\n" + + "\001y\030\004 \001(\001\022\t\n\001z\030\005 \001(\001\022\r\n\005pitch\030\006 \001(\002\022\013\n\003ya" + + "w\030\007 \001(\002b\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Location_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor, + new java.lang.String[]{"SchemaVersion", "World", "X", "Y", "Z", "Pitch", "Yaw",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcListOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcListOuterClass.java new file mode 100644 index 00000000..ad4fca92 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcListOuterClass.java @@ -0,0 +1,870 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: npc_list.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class NpcListOuterClass { + private NpcListOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + NpcListOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface NpcListOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.NpcList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + java.util.List + getNpcsList(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getNpcs(int index); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + int getNpcsCount(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + java.util.List + getNpcsOrBuilderList(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder getNpcsOrBuilder( + int index); + } + + /** + *
+     * This is the data that gets stored in a file or database somewhere,
+     * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.NpcList} + */ + public static final class NpcList extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.NpcList) + NpcListOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + NpcList.class.getName()); + } + + // Use NpcList.newBuilder() to construct. + private NpcList(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private NpcList() { + npcs_ = java.util.Collections.emptyList(); + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.class, dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.Builder.class); + } + + public static final int NPCS_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private java.util.List npcs_; + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public java.util.List getNpcsList() { + return npcs_; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public java.util.List + getNpcsOrBuilderList() { + return npcs_; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public int getNpcsCount() { + return npcs_.size(); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getNpcs(int index) { + return npcs_.get(index); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder getNpcsOrBuilder( + int index) { + return npcs_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < npcs_.size(); i++) { + output.writeMessage(1, npcs_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < npcs_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, npcs_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof NpcList other)) { + return super.equals(obj); + } + + if (!getNpcsList() + .equals(other.getNpcsList())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getNpcsCount() > 0) { + hash = (37 * hash) + NPCS_FIELD_NUMBER; + hash = (53 * hash) + getNpcsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + *

+         * This is the data that gets stored in a file or database somewhere,
+         * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.NpcList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.NpcList) + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcListOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.class, dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (npcsBuilder_ == null) { + npcs_ = java.util.Collections.emptyList(); + } else { + npcs_ = null; + npcsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList build() { + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList buildPartial() { + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList result = new dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList result) { + if (npcsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + npcs_ = java.util.Collections.unmodifiableList(npcs_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.npcs_ = npcs_; + } else { + result.npcs_ = npcsBuilder_.build(); + } + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList other) { + if (other == dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.getDefaultInstance()) + return this; + if (npcsBuilder_ == null) { + if (!other.npcs_.isEmpty()) { + if (npcs_.isEmpty()) { + npcs_ = other.npcs_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureNpcsIsMutable(); + npcs_.addAll(other.npcs_); + } + onChanged(); + } + } else { + if (!other.npcs_.isEmpty()) { + if (npcsBuilder_.isEmpty()) { + npcsBuilder_.dispose(); + npcsBuilder_ = null; + npcs_ = other.npcs_; + bitField0_ = (bitField0_ & ~0x00000001); + npcsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getNpcsFieldBuilder() : null; + } else { + npcsBuilder_.addAllMessages(other.npcs_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc m = + input.readMessage( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.parser(), + extensionRegistry); + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.add(m); + } else { + npcsBuilder_.addMessage(m); + } + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List npcs_ = + java.util.Collections.emptyList(); + + private void ensureNpcsIsMutable() { + if ((bitField0_ & 0x00000001) == 0) { + npcs_ = new java.util.ArrayList(npcs_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder> npcsBuilder_; + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public java.util.List getNpcsList() { + if (npcsBuilder_ == null) { + return java.util.Collections.unmodifiableList(npcs_); + } else { + return npcsBuilder_.getMessageList(); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public int getNpcsCount() { + if (npcsBuilder_ == null) { + return npcs_.size(); + } else { + return npcsBuilder_.getCount(); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getNpcs(int index) { + if (npcsBuilder_ == null) { + return npcs_.get(index); + } else { + return npcsBuilder_.getMessage(index); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder setNpcs( + int index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc value) { + if (npcsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNpcsIsMutable(); + npcs_.set(index, value); + onChanged(); + } else { + npcsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder setNpcs( + int index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder builderForValue) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.set(index, builderForValue.build()); + onChanged(); + } else { + npcsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addNpcs(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc value) { + if (npcsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNpcsIsMutable(); + npcs_.add(value); + onChanged(); + } else { + npcsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addNpcs( + int index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc value) { + if (npcsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNpcsIsMutable(); + npcs_.add(index, value); + onChanged(); + } else { + npcsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addNpcs( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder builderForValue) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.add(builderForValue.build()); + onChanged(); + } else { + npcsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addNpcs( + int index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder builderForValue) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.add(index, builderForValue.build()); + onChanged(); + } else { + npcsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addAllNpcs( + java.lang.Iterable values) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, npcs_); + onChanged(); + } else { + npcsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder clearNpcs() { + if (npcsBuilder_ == null) { + npcs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + npcsBuilder_.clear(); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder removeNpcs(int index) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.remove(index); + onChanged(); + } else { + npcsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder getNpcsBuilder( + int index) { + return getNpcsFieldBuilder().getBuilder(index); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder getNpcsOrBuilder( + int index) { + if (npcsBuilder_ == null) { + return npcs_.get(index); + } else { + return npcsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public java.util.List + getNpcsOrBuilderList() { + if (npcsBuilder_ != null) { + return npcsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(npcs_); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder addNpcsBuilder() { + return getNpcsFieldBuilder().addBuilder( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.getDefaultInstance()); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder addNpcsBuilder( + int index) { + return getNpcsFieldBuilder().addBuilder( + index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.getDefaultInstance()); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public java.util.List + getNpcsBuilderList() { + return getNpcsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder> + getNpcsFieldBuilder() { + if (npcsBuilder_ == null) { + npcsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder>( + npcs_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + npcs_ = null; + } + return npcsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.NpcList) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.NpcList) + private static final dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList(); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public NpcList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\016npc_list.proto\022%dev.foxikle.customnpcs" + + ".internal.proto\032\tnpc.proto\"C\n\007NpcList\0228\n" + + "\004npcs\030\001 \003(\0132*.dev.foxikle.customnpcs.int" + + "ernal.proto.Npcb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.getDescriptor(), + }); + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor, + new java.lang.String[]{"Npcs",}); + descriptor.resolveAllFeaturesImmutable(); + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcOuterClass.java new file mode 100644 index 00000000..0621beff --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcOuterClass.java @@ -0,0 +1,1822 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: npc.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class NpcOuterClass { + private NpcOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + NpcOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface NpcOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Npc) + com.google.protobuf.MessageOrBuilder { + + /** + *

+         * for migrations
+         * 
+ * + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + int getSchemaVersion(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + java.util.List + getActionsList(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getActions(int index); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + int getActionsCount(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + java.util.List + getActionsOrBuilderList(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder getActionsOrBuilder( + int index); + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return Whether the location field is set. + */ + boolean hasLocation(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return The location. + */ + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getLocation(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder getLocationOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return Whether the settings field is set. + */ + boolean hasSettings(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return The settings. + */ + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getSettings(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder getSettingsOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return Whether the equipment field is set. + */ + boolean hasEquipment(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return The equipment. + */ + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getEquipment(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder getEquipmentOrBuilder(); + + /** + * string uuid = 6; + * + * @return The uuid. + */ + java.lang.String getUuid(); + + /** + * string uuid = 6; + * + * @return The bytes for uuid. + */ + com.google.protobuf.ByteString + getUuidBytes(); + } + + /** + *
+     * DO NOT EVER CHANGE THE INDICIES
+     * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Npc} + */ + public static final class Npc extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Npc) + NpcOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Npc.class.getName()); + } + + // Use Npc.newBuilder() to construct. + private Npc(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Npc() { + actions_ = java.util.Collections.emptyList(); + uuid_ = ""; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.class, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder.class); + } + + private int bitField0_; + public static final int SCHEMA_VERSION_FIELD_NUMBER = 1; + private int schemaVersion_ = 0; + + /** + *

+         * for migrations
+         * 
+ * + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + public static final int ACTIONS_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private java.util.List actions_; + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public java.util.List getActionsList() { + return actions_; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public java.util.List + getActionsOrBuilderList() { + return actions_; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public int getActionsCount() { + return actions_.size(); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getActions(int index) { + return actions_.get(index); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder getActionsOrBuilder( + int index) { + return actions_.get(index); + } + + public static final int LOCATION_FIELD_NUMBER = 3; + private dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location location_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return Whether the location field is set. + */ + @java.lang.Override + public boolean hasLocation() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return The location. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getLocation() { + return location_ == null ? dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance() : location_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder getLocationOrBuilder() { + return location_ == null ? dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance() : location_; + } + + public static final int SETTINGS_FIELD_NUMBER = 4; + private dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings settings_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return Whether the settings field is set. + */ + @java.lang.Override + public boolean hasSettings() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return The settings. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getSettings() { + return settings_ == null ? dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance() : settings_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder getSettingsOrBuilder() { + return settings_ == null ? dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance() : settings_; + } + + public static final int EQUIPMENT_FIELD_NUMBER = 5; + private dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment equipment_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return Whether the equipment field is set. + */ + @java.lang.Override + public boolean hasEquipment() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return The equipment. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getEquipment() { + return equipment_ == null ? dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance() : equipment_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder getEquipmentOrBuilder() { + return equipment_ == null ? dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance() : equipment_; + } + + public static final int UUID_FIELD_NUMBER = 6; + @SuppressWarnings("serial") + private volatile java.lang.Object uuid_ = ""; + + /** + * string uuid = 6; + * + * @return The uuid. + */ + @java.lang.Override + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uuid_ = s; + return s; + } + } + + /** + * string uuid = 6; + * + * @return The bytes for uuid. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getUuidBytes() { + java.lang.Object ref = uuid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (schemaVersion_ != 0) { + output.writeInt32(1, schemaVersion_); + } + for (int i = 0; i < actions_.size(); i++) { + output.writeMessage(2, actions_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getLocation()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(4, getSettings()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(5, getEquipment()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(uuid_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 6, uuid_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (schemaVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, schemaVersion_); + } + for (int i = 0; i < actions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, actions_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getLocation()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getSettings()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getEquipment()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(uuid_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(6, uuid_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Npc other)) { + return super.equals(obj); + } + + if (getSchemaVersion() + != other.getSchemaVersion()) return false; + if (!getActionsList() + .equals(other.getActionsList())) return false; + if (hasLocation() != other.hasLocation()) return false; + if (hasLocation()) { + if (!getLocation() + .equals(other.getLocation())) return false; + } + if (hasSettings() != other.hasSettings()) return false; + if (hasSettings()) { + if (!getSettings() + .equals(other.getSettings())) return false; + } + if (hasEquipment() != other.hasEquipment()) return false; + if (hasEquipment()) { + if (!getEquipment() + .equals(other.getEquipment())) return false; + } + if (!getUuid() + .equals(other.getUuid())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SCHEMA_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getSchemaVersion(); + if (getActionsCount() > 0) { + hash = (37 * hash) + ACTIONS_FIELD_NUMBER; + hash = (53 * hash) + getActionsList().hashCode(); + } + if (hasLocation()) { + hash = (37 * hash) + LOCATION_FIELD_NUMBER; + hash = (53 * hash) + getLocation().hashCode(); + } + if (hasSettings()) { + hash = (37 * hash) + SETTINGS_FIELD_NUMBER; + hash = (53 * hash) + getSettings().hashCode(); + } + if (hasEquipment()) { + hash = (37 * hash) + EQUIPMENT_FIELD_NUMBER; + hash = (53 * hash) + getEquipment().hashCode(); + } + hash = (37 * hash) + UUID_FIELD_NUMBER; + hash = (53 * hash) + getUuid().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + *
+         * DO NOT EVER CHANGE THE INDICIES
+         * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Npc} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Npc) + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.class, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage + .alwaysUseFieldBuilders) { + getActionsFieldBuilder(); + getLocationFieldBuilder(); + getSettingsFieldBuilder(); + getEquipmentFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + schemaVersion_ = 0; + if (actionsBuilder_ == null) { + actions_ = java.util.Collections.emptyList(); + } else { + actions_ = null; + actionsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + location_ = null; + if (locationBuilder_ != null) { + locationBuilder_.dispose(); + locationBuilder_ = null; + } + settings_ = null; + if (settingsBuilder_ != null) { + settingsBuilder_.dispose(); + settingsBuilder_ = null; + } + equipment_ = null; + if (equipmentBuilder_ != null) { + equipmentBuilder_.dispose(); + equipmentBuilder_ = null; + } + uuid_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc build() { + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc buildPartial() { + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc result = new dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc result) { + if (actionsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + actions_ = java.util.Collections.unmodifiableList(actions_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.actions_ = actions_; + } else { + result.actions_ = actionsBuilder_.build(); + } + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.schemaVersion_ = schemaVersion_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.location_ = locationBuilder_ == null + ? location_ + : locationBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.settings_ = settingsBuilder_ == null + ? settings_ + : settingsBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.equipment_ = equipmentBuilder_ == null + ? equipment_ + : equipmentBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.uuid_ = uuid_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc other) { + if (other == dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.getDefaultInstance()) return this; + if (other.getSchemaVersion() != 0) { + setSchemaVersion(other.getSchemaVersion()); + } + if (actionsBuilder_ == null) { + if (!other.actions_.isEmpty()) { + if (actions_.isEmpty()) { + actions_ = other.actions_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureActionsIsMutable(); + actions_.addAll(other.actions_); + } + onChanged(); + } + } else { + if (!other.actions_.isEmpty()) { + if (actionsBuilder_.isEmpty()) { + actionsBuilder_.dispose(); + actionsBuilder_ = null; + actions_ = other.actions_; + bitField0_ = (bitField0_ & ~0x00000002); + actionsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getActionsFieldBuilder() : null; + } else { + actionsBuilder_.addAllMessages(other.actions_); + } + } + } + if (other.hasLocation()) { + mergeLocation(other.getLocation()); + } + if (other.hasSettings()) { + mergeSettings(other.getSettings()); + } + if (other.hasEquipment()) { + mergeEquipment(other.getEquipment()); + } + if (!other.getUuid().isEmpty()) { + uuid_ = other.uuid_; + bitField0_ |= 0x00000020; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + schemaVersion_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action m = + input.readMessage( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.parser(), + extensionRegistry); + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.add(m); + } else { + actionsBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: { + input.readMessage( + getLocationFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: { + input.readMessage( + getSettingsFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: { + input.readMessage( + getEquipmentFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: { + uuid_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000020; + break; + } // case 50 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int schemaVersion_; + + /** + *

+             * for migrations
+             * 
+ * + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + /** + *
+             * for migrations
+             * 
+ * + * int32 schema_version = 1; + * + * @param value The schemaVersion to set. + * @return This builder for chaining. + */ + public Builder setSchemaVersion(int value) { + + schemaVersion_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + *
+             * for migrations
+             * 
+ * + * int32 schema_version = 1; + * + * @return This builder for chaining. + */ + public Builder clearSchemaVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + schemaVersion_ = 0; + onChanged(); + return this; + } + + private java.util.List actions_ = + java.util.Collections.emptyList(); + + private void ensureActionsIsMutable() { + if ((bitField0_ & 0x00000002) == 0) { + actions_ = new java.util.ArrayList(actions_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder> actionsBuilder_; + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public java.util.List getActionsList() { + if (actionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(actions_); + } else { + return actionsBuilder_.getMessageList(); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public int getActionsCount() { + if (actionsBuilder_ == null) { + return actions_.size(); + } else { + return actionsBuilder_.getCount(); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getActions(int index) { + if (actionsBuilder_ == null) { + return actions_.get(index); + } else { + return actionsBuilder_.getMessage(index); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder setActions( + int index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action value) { + if (actionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActionsIsMutable(); + actions_.set(index, value); + onChanged(); + } else { + actionsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder setActions( + int index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder builderForValue) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.set(index, builderForValue.build()); + onChanged(); + } else { + actionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addActions(dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action value) { + if (actionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActionsIsMutable(); + actions_.add(value); + onChanged(); + } else { + actionsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addActions( + int index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action value) { + if (actionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActionsIsMutable(); + actions_.add(index, value); + onChanged(); + } else { + actionsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addActions( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder builderForValue) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.add(builderForValue.build()); + onChanged(); + } else { + actionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addActions( + int index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder builderForValue) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.add(index, builderForValue.build()); + onChanged(); + } else { + actionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addAllActions( + java.lang.Iterable values) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, actions_); + onChanged(); + } else { + actionsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder clearActions() { + if (actionsBuilder_ == null) { + actions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + actionsBuilder_.clear(); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder removeActions(int index) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.remove(index); + onChanged(); + } else { + actionsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder getActionsBuilder( + int index) { + return getActionsFieldBuilder().getBuilder(index); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder getActionsOrBuilder( + int index) { + if (actionsBuilder_ == null) { + return actions_.get(index); + } else { + return actionsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public java.util.List + getActionsOrBuilderList() { + if (actionsBuilder_ != null) { + return actionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(actions_); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder addActionsBuilder() { + return getActionsFieldBuilder().addBuilder( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.getDefaultInstance()); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder addActionsBuilder( + int index) { + return getActionsFieldBuilder().addBuilder( + index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.getDefaultInstance()); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public java.util.List + getActionsBuilderList() { + return getActionsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder> + getActionsFieldBuilder() { + if (actionsBuilder_ == null) { + actionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder>( + actions_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + actions_ = null; + } + return actionsBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location location_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder> locationBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return Whether the location field is set. + */ + public boolean hasLocation() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return The location. + */ + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getLocation() { + if (locationBuilder_ == null) { + return location_ == null ? dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance() : location_; + } else { + return locationBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public Builder setLocation(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location value) { + if (locationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + location_ = value; + } else { + locationBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public Builder setLocation( + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder builderForValue) { + if (locationBuilder_ == null) { + location_ = builderForValue.build(); + } else { + locationBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public Builder mergeLocation(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location value) { + if (locationBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) && + location_ != null && + location_ != dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance()) { + getLocationBuilder().mergeFrom(value); + } else { + location_ = value; + } + } else { + locationBuilder_.mergeFrom(value); + } + if (location_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public Builder clearLocation() { + bitField0_ = (bitField0_ & ~0x00000004); + location_ = null; + if (locationBuilder_ != null) { + locationBuilder_.dispose(); + locationBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder getLocationBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getLocationFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder getLocationOrBuilder() { + if (locationBuilder_ != null) { + return locationBuilder_.getMessageOrBuilder(); + } else { + return location_ == null ? + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance() : location_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder> + getLocationFieldBuilder() { + if (locationBuilder_ == null) { + locationBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder>( + getLocation(), + getParentForChildren(), + isClean()); + location_ = null; + } + return locationBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings settings_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder> settingsBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return Whether the settings field is set. + */ + public boolean hasSettings() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return The settings. + */ + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getSettings() { + if (settingsBuilder_ == null) { + return settings_ == null ? dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance() : settings_; + } else { + return settingsBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public Builder setSettings(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings value) { + if (settingsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + settings_ = value; + } else { + settingsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public Builder setSettings( + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder builderForValue) { + if (settingsBuilder_ == null) { + settings_ = builderForValue.build(); + } else { + settingsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public Builder mergeSettings(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings value) { + if (settingsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) && + settings_ != null && + settings_ != dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance()) { + getSettingsBuilder().mergeFrom(value); + } else { + settings_ = value; + } + } else { + settingsBuilder_.mergeFrom(value); + } + if (settings_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public Builder clearSettings() { + bitField0_ = (bitField0_ & ~0x00000008); + settings_ = null; + if (settingsBuilder_ != null) { + settingsBuilder_.dispose(); + settingsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder getSettingsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getSettingsFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder getSettingsOrBuilder() { + if (settingsBuilder_ != null) { + return settingsBuilder_.getMessageOrBuilder(); + } else { + return settings_ == null ? + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance() : settings_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder> + getSettingsFieldBuilder() { + if (settingsBuilder_ == null) { + settingsBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder>( + getSettings(), + getParentForChildren(), + isClean()); + settings_ = null; + } + return settingsBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment equipment_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder> equipmentBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return Whether the equipment field is set. + */ + public boolean hasEquipment() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return The equipment. + */ + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getEquipment() { + if (equipmentBuilder_ == null) { + return equipment_ == null ? dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance() : equipment_; + } else { + return equipmentBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public Builder setEquipment(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment value) { + if (equipmentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + equipment_ = value; + } else { + equipmentBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public Builder setEquipment( + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder builderForValue) { + if (equipmentBuilder_ == null) { + equipment_ = builderForValue.build(); + } else { + equipmentBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public Builder mergeEquipment(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment value) { + if (equipmentBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) && + equipment_ != null && + equipment_ != dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance()) { + getEquipmentBuilder().mergeFrom(value); + } else { + equipment_ = value; + } + } else { + equipmentBuilder_.mergeFrom(value); + } + if (equipment_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public Builder clearEquipment() { + bitField0_ = (bitField0_ & ~0x00000010); + equipment_ = null; + if (equipmentBuilder_ != null) { + equipmentBuilder_.dispose(); + equipmentBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder getEquipmentBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getEquipmentFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder getEquipmentOrBuilder() { + if (equipmentBuilder_ != null) { + return equipmentBuilder_.getMessageOrBuilder(); + } else { + return equipment_ == null ? + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance() : equipment_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder> + getEquipmentFieldBuilder() { + if (equipmentBuilder_ == null) { + equipmentBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder>( + getEquipment(), + getParentForChildren(), + isClean()); + equipment_ = null; + } + return equipmentBuilder_; + } + + private java.lang.Object uuid_ = ""; + + /** + * string uuid = 6; + * + * @return The uuid. + */ + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uuid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string uuid = 6; + * + * @return The bytes for uuid. + */ + public com.google.protobuf.ByteString + getUuidBytes() { + java.lang.Object ref = uuid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string uuid = 6; + * + * @param value The uuid to set. + * @return This builder for chaining. + */ + public Builder setUuid( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + uuid_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * string uuid = 6; + * + * @return This builder for chaining. + */ + public Builder clearUuid() { + uuid_ = getDefaultInstance().getUuid(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + return this; + } + + /** + * string uuid = 6; + * + * @param value The bytes for uuid to set. + * @return This builder for chaining. + */ + public Builder setUuidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + uuid_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Npc) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Npc) + private static final dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc(); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Npc parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\tnpc.proto\022%dev.foxikle.customnpcs.inte" + + "rnal.proto\032\014action.proto\032\016location.proto" + + "\032\017equipment.proto\032\016settings.proto\"\266\002\n\003Np" + + "c\022\026\n\016schema_version\030\001 \001(\005\022>\n\007actions\030\002 \003" + + "(\0132-.dev.foxikle.customnpcs.internal.pro" + + "to.Action\022A\n\010location\030\003 \001(\0132/.dev.foxikl" + + "e.customnpcs.internal.proto.Location\022A\n\010" + + "settings\030\004 \001(\0132/.dev.foxikle.customnpcs." + + "internal.proto.Settings\022C\n\tequipment\030\005 \001" + + "(\01320.dev.foxikle.customnpcs.internal.pro" + + "to.Equipment\022\014\n\004uuid\030\006 \001(\tb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.getDescriptor(), + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.getDescriptor(), + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.getDescriptor(), + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.getDescriptor(), + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor, + new java.lang.String[]{"SchemaVersion", "Actions", "Location", "Settings", "Equipment", "Uuid",}); + descriptor.resolveAllFeaturesImmutable(); + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.getDescriptor(); + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.getDescriptor(); + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.getDescriptor(); + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java new file mode 100644 index 00000000..9d3bba5c --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2024. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.proto; + +import com.google.protobuf.ByteString; +import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.data.Equipment; +import dev.foxikle.customnpcs.data.Settings; +import dev.foxikle.customnpcs.internal.CustomNPCs; +import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; +import lombok.SneakyThrows; +import lombok.experimental.UtilityClass; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +@UtilityClass +@ApiStatus.Internal +public class ProtoWrapper { + + @ApiStatus.Internal + public static byte[] toProto(InternalNpc internalNpc) { + return toProtoNpc(internalNpc).toByteArray(); + } + + @ApiStatus.Internal + public static NpcOuterClass.Npc toProtoNpc(InternalNpc npc) { + return NpcOuterClass.Npc.newBuilder() + .addAllActions(npc.getActions().stream().map(ProtoWrapper::toProtoAction).collect(Collectors.toList())) + .setEquipment(toProtoEquipment(npc.getEquipment())) + .setLocation(toProtoLocation(npc.getSpawnLoc())) + .setSettings(toProtoSettings(npc.getSettings())) + .setUuid(npc.getUniqueID().toString()).build(); + } + + // may throw runtime exception + @ApiStatus.Internal + public static InternalNpc fromProtoNpc(NpcOuterClass.Npc npc) { + Location loc = fromProtoLocation(npc.getLocation()); + return CustomNPCs.getInstance().createNPC( + loc.getWorld(), + loc, + fromProtoEquipment(npc.getEquipment()), + fromProtoSettings(npc.getSettings()), + UUID.fromString(npc.getUuid()), + null, + npc.getActionsList().stream().map(ProtoWrapper::fromProtoAction).toList() + ); + } + + @ApiStatus.Internal + @SneakyThrows + public static InternalNpc fromProto(byte[] bytes) { + return fromProtoNpc(NpcOuterClass.Npc.parseFrom(bytes)); + } + + @ApiStatus.Internal + public static SettingsOuterClass.Settings toProtoSettings(Settings settings) { + return SettingsOuterClass.Settings.newBuilder() + .setClickable(settings.isInteractable()) + .setTunnelVision(settings.isTunnelvision()) + .setResilient(settings.isResilient()) + .setName(settings.getName()) + .setCustomHologram(settings.getCustomInteractableHologram()) + .setHideClickHologram(settings.isHideClickableHologram()) + .setSignature(settings.getSignature()) + .setValue(settings.getValue()) + .setSkinName(settings.getSkinName()) + .build(); + } + + @ApiStatus.Internal + public static Settings fromProtoSettings(SettingsOuterClass.Settings settings) { + return new Settings( + settings.getClickable(), + settings.getTunnelVision(), + settings.getResilient(), + settings.getValue(), + settings.getSignature(), + settings.getSkinName(), + settings.getName(), + settings.getCustomHologram(), + settings.getHideClickHologram() + ); + } + + @ApiStatus.Internal + public static ItemOuterClass.Item toProtoItem(ItemStack item) { + return ItemOuterClass.Item.newBuilder() + .setSerialized(ByteString.copyFrom(item.ensureServerConversions().serializeAsBytes())) + .build(); + } + + @ApiStatus.Internal + public static ItemStack fromProtoItem(ItemOuterClass.Item item) { + return ItemStack.deserializeBytes(item.getSerialized().toByteArray()); + } + + @ApiStatus.Internal + public static EquipmentOuterClass.Equipment toProtoEquipment(Equipment equipment) { + return EquipmentOuterClass.Equipment.newBuilder(). + setMainHand(toProtoItem(equipment.getHand())) + .setOffHand(toProtoItem(equipment.getOffhand())) + .setHead(toProtoItem(equipment.getHead())) + .setChest(toProtoItem(equipment.getChest())) + .setLegs(toProtoItem(equipment.getLegs())) + .setFeet(toProtoItem(equipment.getBoots())) + .build(); + } + + @ApiStatus.Internal + public static Equipment fromProtoEquipment(EquipmentOuterClass.Equipment equipment) { + return new Equipment( + fromProtoItem(equipment.getHead()), + fromProtoItem(equipment.getChest()), + fromProtoItem(equipment.getLegs()), + fromProtoItem(equipment.getFeet()), + fromProtoItem(equipment.getMainHand()), + fromProtoItem(equipment.getOffHand()) + ); + } + + @ApiStatus.Internal + public static ActionOuterClass.Action toProtoAction(Action action) { + return ActionOuterClass.Action.newBuilder() + .setSerializedData(action.serialize()) + .build(); + } + + @ApiStatus.Internal + public static Action fromProtoAction(ActionOuterClass.Action action) { + return Action.parse(action.getSerializedData()); + } + + @ApiStatus.Internal + public static LocationOuterClass.Location toProtoLocation(Location location) { + return LocationOuterClass.Location.newBuilder() + .setWorld(location.getWorld().getName()) + .setX(location.getX()) + .setY(location.getY()) + .setZ(location.getZ()) + .setPitch(location.getPitch()) + .setYaw(location.getYaw()) + .build(); + } + + @ApiStatus.Internal + @SneakyThrows // npe if world doesn't exist. //todo: Do something about this + public static Location fromProtoLocation(LocationOuterClass.Location location) { + return new Location( + Bukkit.getWorld(location.getWorld()), + location.getX(), location.getY(), + location.getZ(), location.getPitch(), + location.getYaw() + ); + } + + @ApiStatus.Internal + public static byte[] serializeList(List list) { + List npcs = list.stream().map(ProtoWrapper::toProtoNpc).toList(); + return NpcListOuterClass.NpcList.newBuilder() + .addAllNpcs(npcs) + .build().toByteArray(); + } + + @ApiStatus.Internal + @SneakyThrows + public static List deserializeList(byte[] bytes) { + NpcListOuterClass.NpcList list = NpcListOuterClass.NpcList.parseFrom(bytes); + List npcs = list.getNpcsList(); + return npcs.stream().map(ProtoWrapper::fromProtoNpc).collect(Collectors.toList()); + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/SettingsOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/SettingsOuterClass.java new file mode 100644 index 00000000..6e2ee5b8 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/SettingsOuterClass.java @@ -0,0 +1,1711 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: settings.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class SettingsOuterClass { + private SettingsOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + SettingsOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface SettingsOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Settings) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + int getSchemaVersion(); + + /** + * string value = 2; + * + * @return The value. + */ + java.lang.String getValue(); + + /** + * string value = 2; + * + * @return The bytes for value. + */ + com.google.protobuf.ByteString + getValueBytes(); + + /** + * string signature = 3; + * + * @return The signature. + */ + java.lang.String getSignature(); + + /** + * string signature = 3; + * + * @return The bytes for signature. + */ + com.google.protobuf.ByteString + getSignatureBytes(); + + /** + * string skin_name = 4; + * + * @return The skinName. + */ + java.lang.String getSkinName(); + + /** + * string skin_name = 4; + * + * @return The bytes for skinName. + */ + com.google.protobuf.ByteString + getSkinNameBytes(); + + /** + * string custom_hologram = 5; + * + * @return The customHologram. + */ + java.lang.String getCustomHologram(); + + /** + * string custom_hologram = 5; + * + * @return The bytes for customHologram. + */ + com.google.protobuf.ByteString + getCustomHologramBytes(); + + /** + * string name = 6; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * string name = 6; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * bool clickable = 7; + * + * @return The clickable. + */ + boolean getClickable(); + + /** + * bool hide_click_hologram = 8; + * + * @return The hideClickHologram. + */ + boolean getHideClickHologram(); + + /** + * bool tunnel_vision = 9; + * + * @return The tunnelVision. + */ + boolean getTunnelVision(); + + /** + * bool resilient = 10; + * + * @return The resilient. + */ + boolean getResilient(); + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Settings} + */ + public static final class Settings extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Settings) + SettingsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Settings.class.getName()); + } + + // Use Settings.newBuilder() to construct. + private Settings(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Settings() { + value_ = ""; + signature_ = ""; + skinName_ = ""; + customHologram_ = ""; + name_ = ""; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.class, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder.class); + } + + public static final int SCHEMA_VERSION_FIELD_NUMBER = 1; + private int schemaVersion_ = 0; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + public static final int VALUE_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private volatile java.lang.Object value_ = ""; + + /** + * string value = 2; + * + * @return The value. + */ + @java.lang.Override + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + value_ = s; + return s; + } + } + + /** + * string value = 2; + * + * @return The bytes for value. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SIGNATURE_FIELD_NUMBER = 3; + @SuppressWarnings("serial") + private volatile java.lang.Object signature_ = ""; + + /** + * string signature = 3; + * + * @return The signature. + */ + @java.lang.Override + public java.lang.String getSignature() { + java.lang.Object ref = signature_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + signature_ = s; + return s; + } + } + + /** + * string signature = 3; + * + * @return The bytes for signature. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSignatureBytes() { + java.lang.Object ref = signature_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + signature_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SKIN_NAME_FIELD_NUMBER = 4; + @SuppressWarnings("serial") + private volatile java.lang.Object skinName_ = ""; + + /** + * string skin_name = 4; + * + * @return The skinName. + */ + @java.lang.Override + public java.lang.String getSkinName() { + java.lang.Object ref = skinName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + skinName_ = s; + return s; + } + } + + /** + * string skin_name = 4; + * + * @return The bytes for skinName. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSkinNameBytes() { + java.lang.Object ref = skinName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + skinName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CUSTOM_HOLOGRAM_FIELD_NUMBER = 5; + @SuppressWarnings("serial") + private volatile java.lang.Object customHologram_ = ""; + + /** + * string custom_hologram = 5; + * + * @return The customHologram. + */ + @java.lang.Override + public java.lang.String getCustomHologram() { + java.lang.Object ref = customHologram_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + customHologram_ = s; + return s; + } + } + + /** + * string custom_hologram = 5; + * + * @return The bytes for customHologram. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getCustomHologramBytes() { + java.lang.Object ref = customHologram_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + customHologram_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAME_FIELD_NUMBER = 6; + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * string name = 6; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * string name = 6; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CLICKABLE_FIELD_NUMBER = 7; + private boolean clickable_ = false; + + /** + * bool clickable = 7; + * + * @return The clickable. + */ + @java.lang.Override + public boolean getClickable() { + return clickable_; + } + + public static final int HIDE_CLICK_HOLOGRAM_FIELD_NUMBER = 8; + private boolean hideClickHologram_ = false; + + /** + * bool hide_click_hologram = 8; + * + * @return The hideClickHologram. + */ + @java.lang.Override + public boolean getHideClickHologram() { + return hideClickHologram_; + } + + public static final int TUNNEL_VISION_FIELD_NUMBER = 9; + private boolean tunnelVision_ = false; + + /** + * bool tunnel_vision = 9; + * + * @return The tunnelVision. + */ + @java.lang.Override + public boolean getTunnelVision() { + return tunnelVision_; + } + + public static final int RESILIENT_FIELD_NUMBER = 10; + private boolean resilient_ = false; + + /** + * bool resilient = 10; + * + * @return The resilient. + */ + @java.lang.Override + public boolean getResilient() { + return resilient_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (schemaVersion_ != 0) { + output.writeInt32(1, schemaVersion_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(value_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, value_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(signature_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, signature_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(skinName_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, skinName_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(customHologram_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 5, customHologram_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 6, name_); + } + if (clickable_) { + output.writeBool(7, clickable_); + } + if (hideClickHologram_) { + output.writeBool(8, hideClickHologram_); + } + if (tunnelVision_) { + output.writeBool(9, tunnelVision_); + } + if (resilient_) { + output.writeBool(10, resilient_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (schemaVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, schemaVersion_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(value_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, value_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(signature_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, signature_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(skinName_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, skinName_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(customHologram_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(5, customHologram_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(6, name_); + } + if (clickable_) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(7, clickable_); + } + if (hideClickHologram_) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(8, hideClickHologram_); + } + if (tunnelVision_) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(9, tunnelVision_); + } + if (resilient_) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(10, resilient_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Settings other)) { + return super.equals(obj); + } + + if (getSchemaVersion() + != other.getSchemaVersion()) return false; + if (!getValue() + .equals(other.getValue())) return false; + if (!getSignature() + .equals(other.getSignature())) return false; + if (!getSkinName() + .equals(other.getSkinName())) return false; + if (!getCustomHologram() + .equals(other.getCustomHologram())) return false; + if (!getName() + .equals(other.getName())) return false; + if (getClickable() + != other.getClickable()) return false; + if (getHideClickHologram() + != other.getHideClickHologram()) return false; + if (getTunnelVision() + != other.getTunnelVision()) return false; + if (getResilient() + != other.getResilient()) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SCHEMA_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getSchemaVersion(); + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + getValue().hashCode(); + hash = (37 * hash) + SIGNATURE_FIELD_NUMBER; + hash = (53 * hash) + getSignature().hashCode(); + hash = (37 * hash) + SKIN_NAME_FIELD_NUMBER; + hash = (53 * hash) + getSkinName().hashCode(); + hash = (37 * hash) + CUSTOM_HOLOGRAM_FIELD_NUMBER; + hash = (53 * hash) + getCustomHologram().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + CLICKABLE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getClickable()); + hash = (37 * hash) + HIDE_CLICK_HOLOGRAM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getHideClickHologram()); + hash = (37 * hash) + TUNNEL_VISION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getTunnelVision()); + hash = (37 * hash) + RESILIENT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getResilient()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Settings} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Settings) + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.class, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + schemaVersion_ = 0; + value_ = ""; + signature_ = ""; + skinName_ = ""; + customHologram_ = ""; + name_ = ""; + clickable_ = false; + hideClickHologram_ = false; + tunnelVision_ = false; + resilient_ = false; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings build() { + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings buildPartial() { + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings result = new dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.schemaVersion_ = schemaVersion_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.value_ = value_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.signature_ = signature_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.skinName_ = skinName_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.customHologram_ = customHologram_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.clickable_ = clickable_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.hideClickHologram_ = hideClickHologram_; + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.tunnelVision_ = tunnelVision_; + } + if (((from_bitField0_ & 0x00000200) != 0)) { + result.resilient_ = resilient_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings other) { + if (other == dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance()) + return this; + if (other.getSchemaVersion() != 0) { + setSchemaVersion(other.getSchemaVersion()); + } + if (!other.getValue().isEmpty()) { + value_ = other.value_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getSignature().isEmpty()) { + signature_ = other.signature_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (!other.getSkinName().isEmpty()) { + skinName_ = other.skinName_; + bitField0_ |= 0x00000008; + onChanged(); + } + if (!other.getCustomHologram().isEmpty()) { + customHologram_ = other.customHologram_; + bitField0_ |= 0x00000010; + onChanged(); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000020; + onChanged(); + } + if (other.getClickable()) { + setClickable(other.getClickable()); + } + if (other.getHideClickHologram()) { + setHideClickHologram(other.getHideClickHologram()); + } + if (other.getTunnelVision()) { + setTunnelVision(other.getTunnelVision()); + } + if (other.getResilient()) { + setResilient(other.getResilient()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + schemaVersion_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + value_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: { + signature_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: { + skinName_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: { + customHologram_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000020; + break; + } // case 50 + case 56: { + clickable_ = input.readBool(); + bitField0_ |= 0x00000040; + break; + } // case 56 + case 64: { + hideClickHologram_ = input.readBool(); + bitField0_ |= 0x00000080; + break; + } // case 64 + case 72: { + tunnelVision_ = input.readBool(); + bitField0_ |= 0x00000100; + break; + } // case 72 + case 80: { + resilient_ = input.readBool(); + bitField0_ |= 0x00000200; + break; + } // case 80 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int schemaVersion_; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + /** + * int32 schema_version = 1; + * + * @param value The schemaVersion to set. + * @return This builder for chaining. + */ + public Builder setSchemaVersion(int value) { + + schemaVersion_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * int32 schema_version = 1; + * + * @return This builder for chaining. + */ + public Builder clearSchemaVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + schemaVersion_ = 0; + onChanged(); + return this; + } + + private java.lang.Object value_ = ""; + + /** + * string value = 2; + * + * @return The value. + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + value_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string value = 2; + * + * @return The bytes for value. + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string value = 2; + * + * @param value The value to set. + * @return This builder for chaining. + */ + public Builder setValue( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + value_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * string value = 2; + * + * @return This builder for chaining. + */ + public Builder clearValue() { + value_ = getDefaultInstance().getValue(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * string value = 2; + * + * @param value The bytes for value to set. + * @return This builder for chaining. + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + value_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object signature_ = ""; + + /** + * string signature = 3; + * + * @return The signature. + */ + public java.lang.String getSignature() { + java.lang.Object ref = signature_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + signature_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string signature = 3; + * + * @return The bytes for signature. + */ + public com.google.protobuf.ByteString + getSignatureBytes() { + java.lang.Object ref = signature_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + signature_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string signature = 3; + * + * @param value The signature to set. + * @return This builder for chaining. + */ + public Builder setSignature( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + signature_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * string signature = 3; + * + * @return This builder for chaining. + */ + public Builder clearSignature() { + signature_ = getDefaultInstance().getSignature(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * string signature = 3; + * + * @param value The bytes for signature to set. + * @return This builder for chaining. + */ + public Builder setSignatureBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + signature_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private java.lang.Object skinName_ = ""; + + /** + * string skin_name = 4; + * + * @return The skinName. + */ + public java.lang.String getSkinName() { + java.lang.Object ref = skinName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + skinName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string skin_name = 4; + * + * @return The bytes for skinName. + */ + public com.google.protobuf.ByteString + getSkinNameBytes() { + java.lang.Object ref = skinName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + skinName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string skin_name = 4; + * + * @param value The skinName to set. + * @return This builder for chaining. + */ + public Builder setSkinName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + skinName_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * string skin_name = 4; + * + * @return This builder for chaining. + */ + public Builder clearSkinName() { + skinName_ = getDefaultInstance().getSkinName(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * string skin_name = 4; + * + * @param value The bytes for skinName to set. + * @return This builder for chaining. + */ + public Builder setSkinNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + skinName_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + private java.lang.Object customHologram_ = ""; + + /** + * string custom_hologram = 5; + * + * @return The customHologram. + */ + public java.lang.String getCustomHologram() { + java.lang.Object ref = customHologram_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + customHologram_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string custom_hologram = 5; + * + * @return The bytes for customHologram. + */ + public com.google.protobuf.ByteString + getCustomHologramBytes() { + java.lang.Object ref = customHologram_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + customHologram_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string custom_hologram = 5; + * + * @param value The customHologram to set. + * @return This builder for chaining. + */ + public Builder setCustomHologram( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + customHologram_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * string custom_hologram = 5; + * + * @return This builder for chaining. + */ + public Builder clearCustomHologram() { + customHologram_ = getDefaultInstance().getCustomHologram(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + /** + * string custom_hologram = 5; + * + * @param value The bytes for customHologram to set. + * @return This builder for chaining. + */ + public Builder setCustomHologramBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + customHologram_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + + /** + * string name = 6; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string name = 6; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string name = 6; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * string name = 6; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + return this; + } + + /** + * string name = 6; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + private boolean clickable_; + + /** + * bool clickable = 7; + * + * @return The clickable. + */ + @java.lang.Override + public boolean getClickable() { + return clickable_; + } + + /** + * bool clickable = 7; + * + * @param value The clickable to set. + * @return This builder for chaining. + */ + public Builder setClickable(boolean value) { + + clickable_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * bool clickable = 7; + * + * @return This builder for chaining. + */ + public Builder clearClickable() { + bitField0_ = (bitField0_ & ~0x00000040); + clickable_ = false; + onChanged(); + return this; + } + + private boolean hideClickHologram_; + + /** + * bool hide_click_hologram = 8; + * + * @return The hideClickHologram. + */ + @java.lang.Override + public boolean getHideClickHologram() { + return hideClickHologram_; + } + + /** + * bool hide_click_hologram = 8; + * + * @param value The hideClickHologram to set. + * @return This builder for chaining. + */ + public Builder setHideClickHologram(boolean value) { + + hideClickHologram_ = value; + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * bool hide_click_hologram = 8; + * + * @return This builder for chaining. + */ + public Builder clearHideClickHologram() { + bitField0_ = (bitField0_ & ~0x00000080); + hideClickHologram_ = false; + onChanged(); + return this; + } + + private boolean tunnelVision_; + + /** + * bool tunnel_vision = 9; + * + * @return The tunnelVision. + */ + @java.lang.Override + public boolean getTunnelVision() { + return tunnelVision_; + } + + /** + * bool tunnel_vision = 9; + * + * @param value The tunnelVision to set. + * @return This builder for chaining. + */ + public Builder setTunnelVision(boolean value) { + + tunnelVision_ = value; + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * bool tunnel_vision = 9; + * + * @return This builder for chaining. + */ + public Builder clearTunnelVision() { + bitField0_ = (bitField0_ & ~0x00000100); + tunnelVision_ = false; + onChanged(); + return this; + } + + private boolean resilient_; + + /** + * bool resilient = 10; + * + * @return The resilient. + */ + @java.lang.Override + public boolean getResilient() { + return resilient_; + } + + /** + * bool resilient = 10; + * + * @param value The resilient to set. + * @return This builder for chaining. + */ + public Builder setResilient(boolean value) { + + resilient_ = value; + bitField0_ |= 0x00000200; + onChanged(); + return this; + } + + /** + * bool resilient = 10; + * + * @return This builder for chaining. + */ + public Builder clearResilient() { + bitField0_ = (bitField0_ & ~0x00000200); + resilient_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Settings) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Settings) + private static final dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings(); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Settings parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\016settings.proto\022%dev.foxikle.customnpcs" + + ".internal.proto\"\330\001\n\010Settings\022\026\n\016schema_v" + + "ersion\030\001 \001(\005\022\r\n\005value\030\002 \001(\t\022\021\n\tsignature" + + "\030\003 \001(\t\022\021\n\tskin_name\030\004 \001(\t\022\027\n\017custom_holo" + + "gram\030\005 \001(\t\022\014\n\004name\030\006 \001(\t\022\021\n\tclickable\030\007 " + + "\001(\010\022\033\n\023hide_click_hologram\030\010 \001(\010\022\025\n\rtunn" + + "el_vision\030\t \001(\010\022\021\n\tresilient\030\n \001(\010b\006prot" + + "o3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor, + new java.lang.String[]{"SchemaVersion", "Value", "Signature", "SkinName", "CustomHologram", "Name", "Clickable", "HideClickHologram", "TunnelVision", "Resilient",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java new file mode 100644 index 00000000..e1a05754 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.storage; + +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +public interface StorageProvider { + void init(); + + boolean save(byte[] data); + + byte[] load(); + + void shutdown(); +} diff --git a/proto/action.proto b/proto/action.proto new file mode 100644 index 00000000..d19f4796 --- /dev/null +++ b/proto/action.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +// action doesn't need migration versions as thats handled by each individual action +message Action { + string serialized_data = 1; +} \ No newline at end of file diff --git a/proto/equipment.proto b/proto/equipment.proto new file mode 100644 index 00000000..43cfc594 --- /dev/null +++ b/proto/equipment.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +import "item.proto"; +message Equipment { + int32 schema_version = 1; + + Item main_hand = 2; + Item off_hand = 3; + Item head = 4; + Item chest = 5; + Item legs = 6; + Item feet = 7; +} \ No newline at end of file diff --git a/proto/item.proto b/proto/item.proto new file mode 100644 index 00000000..ab50eedc --- /dev/null +++ b/proto/item.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +// doesn't need a migrations field as that is already handled by Paper's itemstack serialization +message Item { + // byte array + bytes serialized = 1; +} \ No newline at end of file diff --git a/proto/location.proto b/proto/location.proto new file mode 100644 index 00000000..869b4f0f --- /dev/null +++ b/proto/location.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +message Location { + int32 schema_version = 1; + + string world = 2; + + double x = 3; + double y = 4; + double z = 5; + + float pitch = 6; + float yaw = 7; +} \ No newline at end of file diff --git a/proto/npc.proto b/proto/npc.proto new file mode 100644 index 00000000..9c287527 --- /dev/null +++ b/proto/npc.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package dev.foxikle.customnpcs.internal.proto; + +import "action.proto"; +import "location.proto"; +import "equipment.proto"; +import "settings.proto"; + +// DO NOT EVER CHANGE THE INDICIES +message Npc { + // for migrations + int32 schema_version = 1; + repeated Action actions = 2; + Location location = 3; + Settings settings = 4; + Equipment equipment = 5; + string uuid = 6; +} \ No newline at end of file diff --git a/proto/npc_list.proto b/proto/npc_list.proto new file mode 100644 index 00000000..cee511b9 --- /dev/null +++ b/proto/npc_list.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +import "npc.proto"; + +// This is the data that gets stored in a file or database somewhere, +message NpcList { + repeated Npc npcs = 1; +} \ No newline at end of file diff --git a/proto/settings.proto b/proto/settings.proto new file mode 100644 index 00000000..3f2d556d --- /dev/null +++ b/proto/settings.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +message Settings { + int32 schema_version = 1; + + string value = 2; + string signature = 3; + string skin_name = 4; + string custom_hologram = 5; + string name = 6; + + bool clickable = 7; + bool hide_click_hologram = 8; + bool tunnel_vision = 9; + bool resilient = 10; +} \ No newline at end of file From a9260ad36eb3fda0416af716b4fba5d42b46da24 Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 29 Dec 2024 19:02:49 -0500 Subject: [PATCH 04/25] Update dependencies --- core/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 00ca438b..09269c67 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -40,8 +40,8 @@ dependencies { compileOnly("org.mineskin:java-client:1.2.4-SNAPSHOT") compileOnly("org.projectlombok:lombok:1.18.36") annotationProcessor("org.projectlombok:lombok:1.18.36") - compileOnly("dev.velix:imperat-core:1.3.2") - compileOnly("dev.velix:imperat-bukkit:1.3.2") + compileOnly("dev.velix:imperat-core:1.5.1") + compileOnly("dev.velix:imperat-bukkit:1.5.1") } tasks { From 39474ee4443820eb8d2b0782fbd5d210a6c90fdc Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 29 Dec 2024 19:26:10 -0500 Subject: [PATCH 05/25] Cleaning up deprecated methods scheduled for removal in 1.8.0 --- .../actions/conditions/Conditional.java | 302 ------------------ .../conditions/LogicalConditional.java | 182 ----------- .../conditions/NumericConditional.java | 188 ----------- .../java/dev/foxikle/customnpcs/api/NPC.java | 21 +- .../dev/foxikle/customnpcs/api/NPCApi.java | 11 - .../dev/foxikle/customnpcs/data/Settings.java | 10 +- .../customnpcs/internal/FileManager.java | 1 - .../internal/commands/CloneCommand.java | 1 - .../internal/commands/MoveCommand.java | 1 - .../internal/listeners/Listeners.java | 3 +- .../customnpcs/internal/menu/MenuItems.java | 4 +- .../customnpcs/internal/utils/Utils.java | 2 +- .../customnpcs/versions/NPC_v1_20_R1.java | 6 +- .../customnpcs/versions/NPC_v1_20_R2.java | 2 +- .../customnpcs/versions/NPC_v1_20_R3.java | 4 +- .../customnpcs/versions/NPC_v1_20_R4.java | 5 +- .../customnpcs/versions/NPC_v1_21_R0.java | 6 +- .../customnpcs/versions/NPC_v1_21_R1.java | 6 +- .../customnpcs/versions/NPC_v1_21_R2.java | 6 +- 19 files changed, 26 insertions(+), 735 deletions(-) delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java b/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java deleted file mode 100644 index d51146d1..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2024. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.actions.conditions; - -import dev.foxikle.customnpcs.internal.CustomNPCs; -import lombok.Getter; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; - -/** - * The interface to represent a comparison - * @deprecated See {@link Condition} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.8.0") -public interface Conditional { - - /** - * Computes the condition to determine if the action should be executed - * @param player The player to fetch data from - * @return if the action should be executed - */ - boolean compute(Player player); - - /** - * Serializes the condition to json using Gson - * @return the serialized condition - */ - String toJson(); - - /** - * - * @param data the serialized condition - * @return the condition from the json - */ - static Conditional of(String data) { - return CustomNPCs.getGson().fromJson(data, Conditional.class); - } - - /** - * Gets the value the condition is comparing - * @see Value - * @return the value the condition is comparing - */ - Value getValue(); - - /** - * Gets the comparator the condition uses to compare the value and target value. - * @return the comparator - * @see Comparator - */ - Comparator getComparator(); - - /** - * Gets the type of condition - * @return the condition type - * @see Type - */ - Type getType(); - - /** - * Sets the comparator of this condition - * @param comparator the comparator to compare the value and target value - * @see Comparator - */ - void setComparator(Comparator comparator); - - /** - * Sets the value of this condition - * @param value the value to compare - * @see Value - */ - void setValue(Value value); - - /** - * Sets the target value of this condition - * @param targetValue the target value - */ - void setTargetValue(String targetValue); - - /** - * Gets the target of the condition - * @return returns the target value - */ - String getTarget(); - - /** - * Clones this conditional object - * @return the cloned object - */ - Conditional clone(); - - /** - * A list of comparators used to compare the values and target values of conditions - */ - @Getter - enum Comparator { - /** - * Represents the value being equal to the target value - */ - EQUAL_TO(true), - - /** - * Represents the value being unequal to the target value - */ - NOT_EQUAL_TO(true), - - /** - * Represents the value being less than the target value - */ - LESS_THAN(false), - - /** - * Represents the value being greater than the target value - */ - GREATER_THAN(false), - - /** - * Represents the value being less than or equal to the target value - */ - LESS_THAN_OR_EQUAL_TO(false), - - /** - * Represents the value being greater than or equal to the target value - */ - GREATER_THAN_OR_EQUAL_TO(false); - - private final boolean strictlyLogical; - - /** - * Constructor for the Comparator - * @param strictlyLogical if the comparator is to only be used on logical parameters - */ - Comparator(boolean strictlyLogical) { - this.strictlyLogical = strictlyLogical; - } - - } - - /** - * A list of comparator types - */ - enum Type { - /** - * Represents a comparison between a Value and a target value that can be any numeric value. - * @see Value - */ - NUMERIC, - - /** - * Represents a comparison between a Value and a target value with a finite number of possibilities - * @see Value - */ - LOGICAL - } - - /** - * A list of values the plugin can compare - */ - enum Value { - // numeric - /** - * Represents the player's experience levels - */ - EXP_LEVELS(false), - - /** - * Represents the player's experience points - */ - EXP_POINTS(false), - - /** - * Represents the player's health - */ - HEALTH(false), - - /** - * Represents the player's absorption - * @deprecated - Misspelled, see {@link Conditional.Value#ABSORPTION} - */ - @ApiStatus.ScheduledForRemoval(inVersion = "1.7") - @Deprecated - ABSORBTION(false), - - /** - * Represents the player's absorption - */ - ABSORPTION(false), - - /** - * Represents the player's Y coordinate - */ - Y_COORD(false), - - /** - * Represents the player's X coordinate - */ - X_COORD(false), - - /** - * Represents the player's Z coordinate - */ - Z_COORD(false), - - - // logical - /** - * Represents if the player has an effect - */ - HAS_EFFECT(true), - - /** - * Represents if the player has a permission node - */ - HAS_PERMISSION(true), - - /** - * Represents if the player is in the gamemode - */ - GAMEMODE(true), - - /** - * Represents if the player is flying - */ - IS_FLYING(true), - - /** - * Represents if the player is sprinting - */ - IS_SPRINTING(true), - - /** - * Represents if the player is sneaking - */ - IS_SNEAKING(true), - - /** - * Represents if the player is frozen - */ - IS_FROZEN(true), - - /** - * Represents if the player is gliding - */ - IS_GLIDING(true); - - - - private final boolean isLogical; - - /** - * The constructor for the Value - * @param isLogical if the value is considered 'logical' - */ - Value(boolean isLogical) { - this.isLogical = isLogical; - } - - /** - * Determines if the value is considered 'logical' - * @return if the value is logical - */ - public boolean isLogical() { - return isLogical; - } - } - - /** - * Represents if how the conditions should be computed - */ - enum SelectionMode { - /** - * If ALL the conditions must be true for the action to be executed - */ - ALL, - - /** - * if at least ONE of the conditions must be met for the action to be executed - */ - ONE - } -} diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java b/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java deleted file mode 100644 index dd1c72ac..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2024. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.actions.conditions; - -import dev.foxikle.customnpcs.internal.CustomNPCs; -import org.bukkit.GameMode; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.ApiStatus; - -import java.util.Objects; - -/** - * The object representing two non-numeric values - * @deprecated See {@link LogicalCondition} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.8.0") -public class LogicalConditional implements Condition { - private final Type type = Type.LOGICAL; - private Comparator comparator; - private Value value; - private String target; - - /** - * - * @param comparator the comparator to use - * @param value the value to compare - * @param target the target to compare to - * @see Value - * @see Comparator - */ - public LogicalConditional(Comparator comparator, Value value, String target) { - this.comparator = comparator; - this.value = value; - this.target = target; - } - - /** - * Computes the condition to determine if the action should be executed - * @param player The player to fetch data from - * @return if the action should be executed - */ - @Override - public boolean compute(Player player) { - boolean value = false; - switch (this.value) { - case HAS_PERMISSION -> value = player.hasPermission(target); - case HAS_EFFECT -> value = player.hasPotionEffect(Objects.requireNonNull(PotionEffectType.getByName(target))); - case GAMEMODE -> value = player.getGameMode().equals(GameMode.valueOf(target)); - case IS_FLYING -> value = player.isFlying(); - case IS_SPRINTING -> value = player.isSprinting(); - case IS_SNEAKING -> value = player.isSneaking(); - case IS_FROZEN -> value = player.isFrozen(); - case IS_GLIDING -> value = player.isGliding(); - } - switch (comparator) { - case EQUAL_TO -> { - return value; - } - case NOT_EQUAL_TO -> { - return !value; - } - } - return false; - } - - /** - * Serializes the condition to json using Gson - * @return the serialized condition - */ - @Override - public String toJson(){ - return CustomNPCs.getGson().toJson(this); - } - - /** - * - * @param data the serialized condition - * @return the condition from the json - */ - public static LogicalConditional of(String data) { - return CustomNPCs.getGson().fromJson(data, LogicalConditional.class); - } - - /** - * Gets the type of condition - * @return the condition type - * @see Type - */ - @Override - public Type getType() { - return type; - } - - /** - * Sets the comparator of this condition - * @param comparator the comparator to compare the value and target value - * @see Comparator - */ - @Override - public void setComparator(Comparator comparator) { - this.comparator = comparator; - } - - /** - * Sets the value of this condition - * @param value the value to compare - * @see Value - */ - @Override - public void setValue(Value value) { - this.value = value; - } - - /** - * Sets the target value of this condition - * @param targetValue the target value - */ - @Override - public void setTargetValue(String targetValue) { - this.target = targetValue; - } - - /** - * Gets the value the condition is comparing - * @see Value - * @return the value the condition is comparing - */ - @Override - public Value getValue() { - return this.value; - } - - /** - * Gets the target of the condition - * @return returns the target value - */ - @Override - public String getTarget() { - return target; - } - - @Override - public Condition clone() { - try { - return (LogicalConditional) super.clone(); - } catch (CloneNotSupportedException e) { - return new LogicalConditional(comparator, value, target); - } - } - - /** - * Gets the comparator the condition uses to compare the value and target value. - * @return the comparator - * @see Comparator - */ - @Override - public Comparator getComparator() { - return this.comparator; - } -} diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java b/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java deleted file mode 100644 index 3e1c157c..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2024. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.actions.conditions; - -import dev.foxikle.customnpcs.internal.CustomNPCs; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; - -/** - * The object representing a comparison of two numeric values - * @deprecated See {@link NumericCondition} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.8.0") -public class NumericConditional implements Condition { - - private final Type type = Type.NUMERIC; - private Comparator comparator; - private Value value; - private double target; - - /** - * - * @param comparator the comparator to use - * @param value the value to compare - * @param target the target to compare to - * @see Value - * @see Comparator - */ - public NumericConditional(Comparator comparator, Value value, double target) { - this.comparator = comparator; - this.value = value; - this.target = target; - } - - /** - * Computes the condition to determine if the action should be executed - * @param player The player to fetch data from - * @return if the action should be executed - */ - @Override - public boolean compute(Player player) { - double value = 0; - switch (this.value) { - case X_COORD -> value = player.getLocation().x(); - case Y_COORD -> value = player.getLocation().y(); - case Z_COORD -> value = player.getLocation().z(); - case EXP_LEVELS -> value = player.getLevel(); - case EXP_POINTS -> value = player.getExp(); - } - switch (comparator) { - case EQUAL_TO -> { - return value == target; - } - case NOT_EQUAL_TO -> { - return value != target; - } - case LESS_THAN -> { - return value < target; - } - case LESS_THAN_OR_EQUAL_TO -> { - return value <= target; - } - case GREATER_THAN -> { - return value > target; - } - case GREATER_THAN_OR_EQUAL_TO -> { - return value >= target; - } - } - return false; - } - - /** - * Serializes the condition to json using Gson - * @return the serialized condition - */ - @Override - public String toJson(){ - return CustomNPCs.getGson().toJson(this); - } - - /** - * - * @param data the serialized condition - * @return the condition from the json - */ - public static NumericConditional of(String data) { - return CustomNPCs.getGson().fromJson(data, NumericConditional.class); - } - - /** - * Gets the type of condition - * @return the condition type - * @see Type - */ - @Override - public Type getType() { - return type; - } - - /** - * Sets the comparator of this condition - * @param comparator the comparator to compare the value and target value - * @see Comparator - */ - @Override - public void setComparator(Comparator comparator) { - this.comparator = comparator; - } - - /** - * Sets the value of this condition - * @param value the value to compare - * @see Value - */ - @Override - public void setValue(Value value) { - this.value = value; - } - - /** - * Sets the target value of this condition - * @param targetValue the target value - */ - @Override - public void setTargetValue(String targetValue) { - this.target = Double.parseDouble(targetValue); - } - - /** - * Gets the value the condition is comparing - * @see Value - * @return the value the condition is comparing - */ - @Override - public Value getValue() { - return this.value; - } - - /** - * Gets the target of the condition - * @return returns the target value - */ - @Override - public String getTarget() { - return String.valueOf(target); - } - - /** - * Gets the comparator the condition uses to compare the value and target value. - * @return the comparator - * @see Comparator - */ - @Override - public Comparator getComparator() { - return this.comparator; - } - - @Override - public Condition clone() { - try { - return (NumericConditional) super.clone(); - } catch (CloneNotSupportedException e) { - return new NumericConditional(comparator, value, target); - } - } -} diff --git a/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java b/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java index 8c99af5f..c88c13b7 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java +++ b/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java @@ -90,22 +90,6 @@ public NPC(InternalNpc npc) { this.npc = npc; } - - /** - *

Sets the location of the NPC - *

- * - * @param loc the new location for the NPC - * @return the NPC with the modified location - * @since 1.5.2-pre3 - * @deprecated see {@link #setPosition(Location)} (typo ;|) - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.8") - public NPC setPostion(@NotNull Location loc) { - return setPosition(loc); - } - /** *

Sets the location of the NPC *

@@ -117,7 +101,6 @@ public NPC setPostion(@NotNull Location loc) { public NPC setPosition(@NotNull Location loc) { Preconditions.checkArgument(loc != null, "loc cannot be null."); npc.setSpawnLoc(loc); - npc.getSettings().setDirection(loc.getYaw()); return this; } @@ -178,10 +161,10 @@ public NPC addAction(@NotNull Action action) { * @return the NPC with the modified set of actions * @see Action * @since 1.5.2-pre3 - * @deprecated Use {@link #setActions(Collection)} + * @deprecated Use {@link #setActions(Collection)}, to be removed in 1.9 with the removal of legacy actions. */ @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.8") + @ApiStatus.ScheduledForRemoval(inVersion = "1.9") public NPC setLegacyActions(Collection actionImpls) { List actionList = new ArrayList<>(); for (LegacyAction legacyAction : actionImpls) { diff --git a/core/src/main/java/dev/foxikle/customnpcs/api/NPCApi.java b/core/src/main/java/dev/foxikle/customnpcs/api/NPCApi.java index c99565d6..124b1512 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/api/NPCApi.java +++ b/core/src/main/java/dev/foxikle/customnpcs/api/NPCApi.java @@ -25,7 +25,6 @@ import dev.foxikle.customnpcs.internal.CustomNPCs; import lombok.experimental.UtilityClass; import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.ApiStatus; import java.util.UUID; @@ -39,16 +38,6 @@ public class NPCApi { */ static final CustomNPCs plugin = JavaPlugin.getPlugin(CustomNPCs.class); - /** - * Initiailizes the API - * - * @deprecated since it's no longer necessary - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.8") - public static void initialize() { - } - /** * Gets the NPC object by ID. * diff --git a/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java b/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java index 6dd8986d..adb71896 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java +++ b/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java @@ -27,7 +27,6 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Color; -import org.jetbrains.annotations.ApiStatus; /** * A class holding the data for an NPC's settings @@ -38,9 +37,6 @@ public class Settings { @Getter boolean interactable = false; @Getter boolean tunnelvision = false; @Getter boolean resilient = true; - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.8") - @Getter double direction = 180; @Getter String value = ""; @Getter String signature = ""; String name = "not set"; @@ -59,7 +55,6 @@ public class Settings { * @param interactable If the npc has actions to execute * @param tunnelvision If the npc will look at players * @param resilient If the npc will persist on restarts - * @param direction The direction to look * @param value The value of the npc's skin * @param signature The signature of the npc's skin * @param skinName The name of the skin as it is referenced in the Menu @@ -67,11 +62,10 @@ public class Settings { * @param customInteractableHologram The custom hologram * @param hideClickableHologram If the NPC's Clickable hologram should be hidden */ - public Settings(boolean interactable, boolean tunnelvision, boolean resilient, double direction, String value, String signature, String skinName, String name, String customInteractableHologram, boolean hideClickableHologram) { + public Settings(boolean interactable, boolean tunnelvision, boolean resilient, String value, String signature, String skinName, String name, String customInteractableHologram, boolean hideClickableHologram) { this.interactable = interactable; this.tunnelvision = tunnelvision; this.resilient = resilient; - this.direction = direction; this.value = value; this.signature = signature; this.skinName = skinName; @@ -125,6 +119,6 @@ public void setSkinData(String signature, String value, String skinName) { @SuppressWarnings("all") public Settings clone(){ - return new Settings(interactable, tunnelvision, resilient, direction, value, signature, skinName, name, customInteractableHologram, hideClickableHologram); + return new Settings(interactable, tunnelvision, resilient, value, signature, skinName, name, customInteractableHologram, hideClickableHologram); } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java index 89808a32..b704f867 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java @@ -561,7 +561,6 @@ public void loadNPC(UUID uuid) { section.getBoolean("clickable"), section.getBoolean("tunnelvision"), true, - location.getYaw(), section.getString("value"), section.getString("signature"), section.getString("skin"), diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CloneCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CloneCommand.java index bdda359c..0a2b12ae 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CloneCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CloneCommand.java @@ -58,7 +58,6 @@ public void usage( assert finalNpc != null; InternalNpc newNpc = finalNpc.clone(); newNpc.setSpawnLoc(p.getLocation()); - newNpc.getSettings().setDirection(p.getLocation().getYaw()); newNpc.createNPC(); p.sendMessage(Msg.translate(p.locale(), "customnpcs.commands.clone.success")); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java index 8bbc9b45..5acd7f57 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java @@ -59,7 +59,6 @@ public void usage( assert finalNpc != null; finalNpc.remove(); finalNpc.setSpawnLoc(p.getLocation()); - finalNpc.getSettings().setDirection(p.getLocation().getYaw()); finalNpc.createNPC(); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java b/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java index 8f0545ed..4750e4b8 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java @@ -167,7 +167,7 @@ private void processPlayerMovement(final Player player, final InternalNpc npc, f return; } } - npc.setYRotation((float) npc.getSettings().getDirection()); + npc.setYRotation(npc.getSpawnLoc().getYaw()); }); } } @@ -468,7 +468,6 @@ public void onChat(AsyncPlayerChatEvent e) { return; } if (message.equalsIgnoreCase("confirm")) { - npc.getSettings().setDirection(player.getLocation().getYaw()); npc.getSpawnLoc().setPitch(player.getLocation().getPitch()); npc.getSpawnLoc().setYaw(player.getLocation().getYaw()); player.sendMessage(Msg.translate(player.locale(), "customnpcs.set.facing_direction")); diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java index 528cbfef..ef4ebb03 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java @@ -71,7 +71,7 @@ public class MenuItems { } public static Button rotation(InternalNpc npc, Player player) { - double dir = npc.getSettings().getDirection(); + double dir = npc.getSpawnLoc().getYaw(); List lore = new ArrayList<>(); Map highlightIndexMap = Map.of(180, 0, -135, 1, -90, 2, -45, 3, 0, 4, 45, 5, 90, 6, 135, 7); @@ -124,7 +124,7 @@ public static Button rotation(InternalNpc npc, Player player) { } } - npc.getSettings().setDirection(newDir); + npc.getSpawnLoc().setYaw((float) newDir); menuView.replaceButton(10, rotation(npc, p)); })); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java index df030413..a039147a 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java @@ -133,7 +133,7 @@ public static void setTotalExperience(Player player, int amount) { public static Location calcLocation(InternalNpc npc) { Location loc = npc.getCurrentLocation(); double pitch = Math.toRadians(npc.getSpawnLoc().getPitch()); - double yaw = Math.toRadians(npc.getSettings().getDirection()); + double yaw = Math.toRadians(npc.getSpawnLoc().getYaw()); // trig to calculate the position diff --git a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java index 27964e66..3b62d142 100644 --- a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java +++ b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java @@ -404,7 +404,7 @@ public void injectPlayer(Player p) { ClientboundAddPlayerPacket namedEntitySpawn = new ClientboundAddPlayerPacket(this); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSettings().getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); super.detectEquipmentUpdates(); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -438,7 +438,7 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } private void updateHolograms(Player p) { @@ -625,7 +625,7 @@ public void reloadSettings() { super.getBukkitEntity().getEquipment().setItem(EquipmentSlot.LEGS, equipment.getLegs(), true); super.getBukkitEntity().getEquipment().setItem(EquipmentSlot.FEET, equipment.getBoots(), true); super.getBukkitEntity().setItemInHand(equipment.getHand()); - setYRotation((float) getSettings().getDirection()); + setYRotation(getSpawnLoc().getYaw()); } /** diff --git a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java index 15ea246b..97308a32 100644 --- a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java +++ b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java @@ -392,7 +392,7 @@ public void injectPlayer(Player p) { ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(this); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; connection.send(playerInfoAdd); diff --git a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java index eb3eff15..3fefda9d 100644 --- a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java +++ b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java @@ -388,7 +388,7 @@ public void injectPlayer(Player p) { ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(this); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; connection.send(playerInfoAdd); @@ -420,7 +420,7 @@ public void run() { } }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } private void injectHolograms(Player p) { diff --git a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java index 4f2a033e..e742e8dd 100644 --- a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java +++ b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java @@ -405,7 +405,7 @@ public void injectPlayer(Player p) { ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(this); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -439,7 +439,8 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); + } private void injectHolograms(Player p) { diff --git a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java index f94b87dc..1365642b 100644 --- a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java +++ b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java @@ -403,10 +403,10 @@ public void injectPlayer(Player p) { ClientboundPlayerInfoUpdatePacket playerInfoAdd = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this); ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uuid, spawnLoc.x(), spawnLoc.y(), spawnLoc.z(), - spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), settings.getDirection()); + spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getSpawnLoc().getYaw()); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -440,7 +440,7 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } diff --git a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java index 245131c5..12a415b1 100644 --- a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java +++ b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java @@ -405,10 +405,10 @@ public void injectPlayer(Player p) { ClientboundPlayerInfoUpdatePacket playerInfoAdd = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this); ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uuid, spawnLoc.x(), spawnLoc.y(), spawnLoc.z(), - spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), settings.getDirection()); + spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getSpawnLoc().getYaw()); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -442,7 +442,7 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } diff --git a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java index f59345d4..5c67cfb8 100644 --- a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java +++ b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java @@ -405,10 +405,10 @@ public void injectPlayer(Player p) { ClientboundPlayerInfoUpdatePacket playerInfoAdd = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this); ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uuid, spawnLoc.x(), spawnLoc.y(), spawnLoc.z(), - spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), settings.getDirection()); + spawnLoc.getYaw(), spawnLoc.getPitch(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getSpawnLoc().getYaw()); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); - ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (settings.getDirection() * 256 / 360), (byte) (0 / 360), true); + ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getSpawnLoc().getYaw() * 256 / 360), (byte) (0 / 360), true); setSkin(); ServerGamePacketListenerImpl connection = ((CraftPlayer) p).getHandle().connection; @@ -442,7 +442,7 @@ public void run() { }.runTaskTimerAsynchronously(plugin, 0, plugin.getConfig().getInt("HologramUpdateInterval")).getTaskId()); } - setYRotation((float) settings.getDirection()); + setYRotation(getSpawnLoc().getYaw()); } From 859a12c36ea5a5b65ee3b263c2ce502bc7295e52 Mon Sep 17 00:00:00 2001 From: foxikle Date: Mon, 30 Dec 2024 09:26:39 -0500 Subject: [PATCH 06/25] Protobuf is cool --- .gitignore | 3 + build.gradle.kts | 4 +- core/build.gradle.kts | 1 + .../customnpcs/internal/menu/SkinCatalog.java | 1 + .../internal/proto/ActionOuterClass.java | 629 ++++++ .../internal/proto/EquipmentOuterClass.java | 1873 +++++++++++++++++ .../internal/proto/ItemOuterClass.java | 564 +++++ .../internal/proto/LocationOuterClass.java | 1119 ++++++++++ .../internal/proto/NpcListOuterClass.java | 870 ++++++++ .../internal/proto/NpcOuterClass.java | 1822 ++++++++++++++++ .../internal/proto/ProtoWrapper.java | 198 ++ .../internal/proto/SettingsOuterClass.java | 1711 +++++++++++++++ .../internal/storage/StorageProvider.java | 36 + proto/action.proto | 7 + proto/equipment.proto | 14 + proto/item.proto | 8 + proto/location.proto | 15 + proto/npc.proto | 19 + proto/npc_list.proto | 9 + proto/settings.proto | 17 + 20 files changed, 8918 insertions(+), 2 deletions(-) create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/ActionOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/EquipmentOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/ItemOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/LocationOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcListOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/SettingsOuterClass.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java create mode 100644 proto/action.proto create mode 100644 proto/equipment.proto create mode 100644 proto/item.proto create mode 100644 proto/location.proto create mode 100644 proto/npc.proto create mode 100644 proto/npc_list.proto create mode 100644 proto/settings.proto diff --git a/.gitignore b/.gitignore index a8a6a665..7fc1007e 100644 --- a/.gitignore +++ b/.gitignore @@ -115,3 +115,6 @@ build # Common working directory run/ + +# Proto +compile_proto.sh \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 5ab2fd18..8393c418 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -47,7 +47,7 @@ dependencies { implementation(project(":v1_20_R1", "reobf")) } -var pluginVersion = "1.7.2" +var pluginVersion = "1.8-pre1" allprojects { group = "dev.foxikle" @@ -79,7 +79,7 @@ publishing { } } publications { - create("main") { + create("maven") { groupId = project.group.toString() artifactId = project.name version = project.version.toString() diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 09269c67..990480b8 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -42,6 +42,7 @@ dependencies { annotationProcessor("org.projectlombok:lombok:1.18.36") compileOnly("dev.velix:imperat-core:1.5.1") compileOnly("dev.velix:imperat-bukkit:1.5.1") + compileOnly("com.google.protobuf:protobuf-java:4.29.2") } tasks { diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/SkinCatalog.java b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/SkinCatalog.java index 530dea70..4dabbfe1 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/SkinCatalog.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/SkinCatalog.java @@ -64,6 +64,7 @@ public ItemStack previousPageItem(Player player) { .build(); } + /** * Handles the click sounds on page change * diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ActionOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ActionOuterClass.java new file mode 100644 index 00000000..e16db86a --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ActionOuterClass.java @@ -0,0 +1,629 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: action.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class ActionOuterClass { + private ActionOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + ActionOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface ActionOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Action) + com.google.protobuf.MessageOrBuilder { + + /** + * string serialized_data = 1; + * + * @return The serializedData. + */ + java.lang.String getSerializedData(); + + /** + * string serialized_data = 1; + * + * @return The bytes for serializedData. + */ + com.google.protobuf.ByteString + getSerializedDataBytes(); + } + + /** + *
+     * action doesn't need migration versions as thats handled by each individual action
+     * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Action} + */ + public static final class Action extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Action) + ActionOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Action.class.getName()); + } + + // Use Action.newBuilder() to construct. + private Action(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Action() { + serializedData_ = ""; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.class, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder.class); + } + + public static final int SERIALIZED_DATA_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object serializedData_ = ""; + + /** + * string serialized_data = 1; + * + * @return The serializedData. + */ + @java.lang.Override + public java.lang.String getSerializedData() { + java.lang.Object ref = serializedData_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + serializedData_ = s; + return s; + } + } + + /** + * string serialized_data = 1; + * + * @return The bytes for serializedData. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSerializedDataBytes() { + java.lang.Object ref = serializedData_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + serializedData_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(serializedData_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, serializedData_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(serializedData_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, serializedData_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Action other)) { + return super.equals(obj); + } + + if (!getSerializedData() + .equals(other.getSerializedData())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SERIALIZED_DATA_FIELD_NUMBER; + hash = (53 * hash) + getSerializedData().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + *

+         * action doesn't need migration versions as thats handled by each individual action
+         * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Action} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Action) + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.class, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + serializedData_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action build() { + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action buildPartial() { + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action result = new dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.serializedData_ = serializedData_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action other) { + if (other == dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.getDefaultInstance()) + return this; + if (!other.getSerializedData().isEmpty()) { + serializedData_ = other.serializedData_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + serializedData_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object serializedData_ = ""; + + /** + * string serialized_data = 1; + * + * @return The serializedData. + */ + public java.lang.String getSerializedData() { + java.lang.Object ref = serializedData_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + serializedData_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string serialized_data = 1; + * + * @return The bytes for serializedData. + */ + public com.google.protobuf.ByteString + getSerializedDataBytes() { + java.lang.Object ref = serializedData_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + serializedData_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string serialized_data = 1; + * + * @param value The serializedData to set. + * @return This builder for chaining. + */ + public Builder setSerializedData( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + serializedData_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * string serialized_data = 1; + * + * @return This builder for chaining. + */ + public Builder clearSerializedData() { + serializedData_ = getDefaultInstance().getSerializedData(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * string serialized_data = 1; + * + * @param value The bytes for serializedData to set. + * @return This builder for chaining. + */ + public Builder setSerializedDataBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + serializedData_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Action) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Action) + private static final dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action(); + } + + public static dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Action parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Action_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\014action.proto\022%dev.foxikle.customnpcs.i" + + "nternal.proto\"!\n\006Action\022\027\n\017serialized_da" + + "ta\030\001 \001(\tb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Action_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Action_descriptor, + new java.lang.String[]{"SerializedData",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/EquipmentOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/EquipmentOuterClass.java new file mode 100644 index 00000000..ffae48ef --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/EquipmentOuterClass.java @@ -0,0 +1,1873 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: equipment.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class EquipmentOuterClass { + private EquipmentOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + EquipmentOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface EquipmentOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Equipment) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + int getSchemaVersion(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return Whether the mainHand field is set. + */ + boolean hasMainHand(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return The mainHand. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getMainHand(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getMainHandOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return Whether the offHand field is set. + */ + boolean hasOffHand(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return The offHand. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getOffHand(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getOffHandOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return Whether the head field is set. + */ + boolean hasHead(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return The head. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getHead(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getHeadOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return Whether the chest field is set. + */ + boolean hasChest(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return The chest. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getChest(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getChestOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return Whether the legs field is set. + */ + boolean hasLegs(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return The legs. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getLegs(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getLegsOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return Whether the feet field is set. + */ + boolean hasFeet(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return The feet. + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getFeet(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getFeetOrBuilder(); + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Equipment} + */ + public static final class Equipment extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Equipment) + EquipmentOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Equipment.class.getName()); + } + + // Use Equipment.newBuilder() to construct. + private Equipment(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Equipment() { + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.class, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder.class); + } + + private int bitField0_; + public static final int SCHEMA_VERSION_FIELD_NUMBER = 1; + private int schemaVersion_ = 0; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + public static final int MAIN_HAND_FIELD_NUMBER = 2; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item mainHand_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return Whether the mainHand field is set. + */ + @java.lang.Override + public boolean hasMainHand() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return The mainHand. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getMainHand() { + return mainHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : mainHand_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getMainHandOrBuilder() { + return mainHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : mainHand_; + } + + public static final int OFF_HAND_FIELD_NUMBER = 3; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item offHand_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return Whether the offHand field is set. + */ + @java.lang.Override + public boolean hasOffHand() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return The offHand. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getOffHand() { + return offHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : offHand_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getOffHandOrBuilder() { + return offHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : offHand_; + } + + public static final int HEAD_FIELD_NUMBER = 4; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item head_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return Whether the head field is set. + */ + @java.lang.Override + public boolean hasHead() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return The head. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getHead() { + return head_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : head_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getHeadOrBuilder() { + return head_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : head_; + } + + public static final int CHEST_FIELD_NUMBER = 5; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item chest_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return Whether the chest field is set. + */ + @java.lang.Override + public boolean hasChest() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return The chest. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getChest() { + return chest_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : chest_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getChestOrBuilder() { + return chest_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : chest_; + } + + public static final int LEGS_FIELD_NUMBER = 6; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item legs_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return Whether the legs field is set. + */ + @java.lang.Override + public boolean hasLegs() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return The legs. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getLegs() { + return legs_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : legs_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getLegsOrBuilder() { + return legs_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : legs_; + } + + public static final int FEET_FIELD_NUMBER = 7; + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item feet_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return Whether the feet field is set. + */ + @java.lang.Override + public boolean hasFeet() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return The feet. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getFeet() { + return feet_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : feet_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getFeetOrBuilder() { + return feet_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : feet_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (schemaVersion_ != 0) { + output.writeInt32(1, schemaVersion_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getMainHand()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getOffHand()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getHead()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(5, getChest()); + } + if (((bitField0_ & 0x00000010) != 0)) { + output.writeMessage(6, getLegs()); + } + if (((bitField0_ & 0x00000020) != 0)) { + output.writeMessage(7, getFeet()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (schemaVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, schemaVersion_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getMainHand()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getOffHand()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getHead()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getChest()); + } + if (((bitField0_ & 0x00000010) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getLegs()); + } + if (((bitField0_ & 0x00000020) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(7, getFeet()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Equipment other)) { + return super.equals(obj); + } + + if (getSchemaVersion() + != other.getSchemaVersion()) return false; + if (hasMainHand() != other.hasMainHand()) return false; + if (hasMainHand()) { + if (!getMainHand() + .equals(other.getMainHand())) return false; + } + if (hasOffHand() != other.hasOffHand()) return false; + if (hasOffHand()) { + if (!getOffHand() + .equals(other.getOffHand())) return false; + } + if (hasHead() != other.hasHead()) return false; + if (hasHead()) { + if (!getHead() + .equals(other.getHead())) return false; + } + if (hasChest() != other.hasChest()) return false; + if (hasChest()) { + if (!getChest() + .equals(other.getChest())) return false; + } + if (hasLegs() != other.hasLegs()) return false; + if (hasLegs()) { + if (!getLegs() + .equals(other.getLegs())) return false; + } + if (hasFeet() != other.hasFeet()) return false; + if (hasFeet()) { + if (!getFeet() + .equals(other.getFeet())) return false; + } + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SCHEMA_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getSchemaVersion(); + if (hasMainHand()) { + hash = (37 * hash) + MAIN_HAND_FIELD_NUMBER; + hash = (53 * hash) + getMainHand().hashCode(); + } + if (hasOffHand()) { + hash = (37 * hash) + OFF_HAND_FIELD_NUMBER; + hash = (53 * hash) + getOffHand().hashCode(); + } + if (hasHead()) { + hash = (37 * hash) + HEAD_FIELD_NUMBER; + hash = (53 * hash) + getHead().hashCode(); + } + if (hasChest()) { + hash = (37 * hash) + CHEST_FIELD_NUMBER; + hash = (53 * hash) + getChest().hashCode(); + } + if (hasLegs()) { + hash = (37 * hash) + LEGS_FIELD_NUMBER; + hash = (53 * hash) + getLegs().hashCode(); + } + if (hasFeet()) { + hash = (37 * hash) + FEET_FIELD_NUMBER; + hash = (53 * hash) + getFeet().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Equipment} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Equipment) + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.class, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage + .alwaysUseFieldBuilders) { + getMainHandFieldBuilder(); + getOffHandFieldBuilder(); + getHeadFieldBuilder(); + getChestFieldBuilder(); + getLegsFieldBuilder(); + getFeetFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + schemaVersion_ = 0; + mainHand_ = null; + if (mainHandBuilder_ != null) { + mainHandBuilder_.dispose(); + mainHandBuilder_ = null; + } + offHand_ = null; + if (offHandBuilder_ != null) { + offHandBuilder_.dispose(); + offHandBuilder_ = null; + } + head_ = null; + if (headBuilder_ != null) { + headBuilder_.dispose(); + headBuilder_ = null; + } + chest_ = null; + if (chestBuilder_ != null) { + chestBuilder_.dispose(); + chestBuilder_ = null; + } + legs_ = null; + if (legsBuilder_ != null) { + legsBuilder_.dispose(); + legsBuilder_ = null; + } + feet_ = null; + if (feetBuilder_ != null) { + feetBuilder_.dispose(); + feetBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment build() { + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment buildPartial() { + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment result = new dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.schemaVersion_ = schemaVersion_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.mainHand_ = mainHandBuilder_ == null + ? mainHand_ + : mainHandBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.offHand_ = offHandBuilder_ == null + ? offHand_ + : offHandBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.head_ = headBuilder_ == null + ? head_ + : headBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.chest_ = chestBuilder_ == null + ? chest_ + : chestBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.legs_ = legsBuilder_ == null + ? legs_ + : legsBuilder_.build(); + to_bitField0_ |= 0x00000010; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.feet_ = feetBuilder_ == null + ? feet_ + : feetBuilder_.build(); + to_bitField0_ |= 0x00000020; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment other) { + if (other == dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance()) + return this; + if (other.getSchemaVersion() != 0) { + setSchemaVersion(other.getSchemaVersion()); + } + if (other.hasMainHand()) { + mergeMainHand(other.getMainHand()); + } + if (other.hasOffHand()) { + mergeOffHand(other.getOffHand()); + } + if (other.hasHead()) { + mergeHead(other.getHead()); + } + if (other.hasChest()) { + mergeChest(other.getChest()); + } + if (other.hasLegs()) { + mergeLegs(other.getLegs()); + } + if (other.hasFeet()) { + mergeFeet(other.getFeet()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + schemaVersion_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + input.readMessage( + getMainHandFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: { + input.readMessage( + getOffHandFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: { + input.readMessage( + getHeadFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: { + input.readMessage( + getChestFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: { + input.readMessage( + getLegsFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 50 + case 58: { + input.readMessage( + getFeetFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000040; + break; + } // case 58 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int schemaVersion_; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + /** + * int32 schema_version = 1; + * + * @param value The schemaVersion to set. + * @return This builder for chaining. + */ + public Builder setSchemaVersion(int value) { + + schemaVersion_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * int32 schema_version = 1; + * + * @return This builder for chaining. + */ + public Builder clearSchemaVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + schemaVersion_ = 0; + onChanged(); + return this; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item mainHand_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> mainHandBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return Whether the mainHand field is set. + */ + public boolean hasMainHand() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + * + * @return The mainHand. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getMainHand() { + if (mainHandBuilder_ == null) { + return mainHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : mainHand_; + } else { + return mainHandBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public Builder setMainHand(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (mainHandBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mainHand_ = value; + } else { + mainHandBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public Builder setMainHand( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (mainHandBuilder_ == null) { + mainHand_ = builderForValue.build(); + } else { + mainHandBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public Builder mergeMainHand(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (mainHandBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) && + mainHand_ != null && + mainHand_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getMainHandBuilder().mergeFrom(value); + } else { + mainHand_ = value; + } + } else { + mainHandBuilder_.mergeFrom(value); + } + if (mainHand_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public Builder clearMainHand() { + bitField0_ = (bitField0_ & ~0x00000002); + mainHand_ = null; + if (mainHandBuilder_ != null) { + mainHandBuilder_.dispose(); + mainHandBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getMainHandBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getMainHandFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getMainHandOrBuilder() { + if (mainHandBuilder_ != null) { + return mainHandBuilder_.getMessageOrBuilder(); + } else { + return mainHand_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : mainHand_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item main_hand = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getMainHandFieldBuilder() { + if (mainHandBuilder_ == null) { + mainHandBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getMainHand(), + getParentForChildren(), + isClean()); + mainHand_ = null; + } + return mainHandBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item offHand_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> offHandBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return Whether the offHand field is set. + */ + public boolean hasOffHand() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + * + * @return The offHand. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getOffHand() { + if (offHandBuilder_ == null) { + return offHand_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : offHand_; + } else { + return offHandBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public Builder setOffHand(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (offHandBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + offHand_ = value; + } else { + offHandBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public Builder setOffHand( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (offHandBuilder_ == null) { + offHand_ = builderForValue.build(); + } else { + offHandBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public Builder mergeOffHand(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (offHandBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) && + offHand_ != null && + offHand_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getOffHandBuilder().mergeFrom(value); + } else { + offHand_ = value; + } + } else { + offHandBuilder_.mergeFrom(value); + } + if (offHand_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public Builder clearOffHand() { + bitField0_ = (bitField0_ & ~0x00000004); + offHand_ = null; + if (offHandBuilder_ != null) { + offHandBuilder_.dispose(); + offHandBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getOffHandBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getOffHandFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getOffHandOrBuilder() { + if (offHandBuilder_ != null) { + return offHandBuilder_.getMessageOrBuilder(); + } else { + return offHand_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : offHand_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item off_hand = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getOffHandFieldBuilder() { + if (offHandBuilder_ == null) { + offHandBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getOffHand(), + getParentForChildren(), + isClean()); + offHand_ = null; + } + return offHandBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item head_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> headBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return Whether the head field is set. + */ + public boolean hasHead() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + * + * @return The head. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getHead() { + if (headBuilder_ == null) { + return head_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : head_; + } else { + return headBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public Builder setHead(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (headBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + head_ = value; + } else { + headBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public Builder setHead( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (headBuilder_ == null) { + head_ = builderForValue.build(); + } else { + headBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public Builder mergeHead(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (headBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) && + head_ != null && + head_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getHeadBuilder().mergeFrom(value); + } else { + head_ = value; + } + } else { + headBuilder_.mergeFrom(value); + } + if (head_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public Builder clearHead() { + bitField0_ = (bitField0_ & ~0x00000008); + head_ = null; + if (headBuilder_ != null) { + headBuilder_.dispose(); + headBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getHeadBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getHeadFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getHeadOrBuilder() { + if (headBuilder_ != null) { + return headBuilder_.getMessageOrBuilder(); + } else { + return head_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : head_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item head = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getHeadFieldBuilder() { + if (headBuilder_ == null) { + headBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getHead(), + getParentForChildren(), + isClean()); + head_ = null; + } + return headBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item chest_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> chestBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return Whether the chest field is set. + */ + public boolean hasChest() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + * + * @return The chest. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getChest() { + if (chestBuilder_ == null) { + return chest_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : chest_; + } else { + return chestBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public Builder setChest(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (chestBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + chest_ = value; + } else { + chestBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public Builder setChest( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (chestBuilder_ == null) { + chest_ = builderForValue.build(); + } else { + chestBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public Builder mergeChest(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (chestBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) && + chest_ != null && + chest_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getChestBuilder().mergeFrom(value); + } else { + chest_ = value; + } + } else { + chestBuilder_.mergeFrom(value); + } + if (chest_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public Builder clearChest() { + bitField0_ = (bitField0_ & ~0x00000010); + chest_ = null; + if (chestBuilder_ != null) { + chestBuilder_.dispose(); + chestBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getChestBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getChestFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getChestOrBuilder() { + if (chestBuilder_ != null) { + return chestBuilder_.getMessageOrBuilder(); + } else { + return chest_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : chest_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item chest = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getChestFieldBuilder() { + if (chestBuilder_ == null) { + chestBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getChest(), + getParentForChildren(), + isClean()); + chest_ = null; + } + return chestBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item legs_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> legsBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return Whether the legs field is set. + */ + public boolean hasLegs() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + * + * @return The legs. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getLegs() { + if (legsBuilder_ == null) { + return legs_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : legs_; + } else { + return legsBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public Builder setLegs(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (legsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + legs_ = value; + } else { + legsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public Builder setLegs( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (legsBuilder_ == null) { + legs_ = builderForValue.build(); + } else { + legsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public Builder mergeLegs(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (legsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) && + legs_ != null && + legs_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getLegsBuilder().mergeFrom(value); + } else { + legs_ = value; + } + } else { + legsBuilder_.mergeFrom(value); + } + if (legs_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public Builder clearLegs() { + bitField0_ = (bitField0_ & ~0x00000020); + legs_ = null; + if (legsBuilder_ != null) { + legsBuilder_.dispose(); + legsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getLegsBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return getLegsFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getLegsOrBuilder() { + if (legsBuilder_ != null) { + return legsBuilder_.getMessageOrBuilder(); + } else { + return legs_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : legs_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item legs = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getLegsFieldBuilder() { + if (legsBuilder_ == null) { + legsBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getLegs(), + getParentForChildren(), + isClean()); + legs_ = null; + } + return legsBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item feet_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> feetBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return Whether the feet field is set. + */ + public boolean hasFeet() { + return ((bitField0_ & 0x00000040) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + * + * @return The feet. + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getFeet() { + if (feetBuilder_ == null) { + return feet_ == null ? dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : feet_; + } else { + return feetBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public Builder setFeet(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (feetBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + feet_ = value; + } else { + feetBuilder_.setMessage(value); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public Builder setFeet( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder builderForValue) { + if (feetBuilder_ == null) { + feet_ = builderForValue.build(); + } else { + feetBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public Builder mergeFeet(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item value) { + if (feetBuilder_ == null) { + if (((bitField0_ & 0x00000040) != 0) && + feet_ != null && + feet_ != dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) { + getFeetBuilder().mergeFrom(value); + } else { + feet_ = value; + } + } else { + feetBuilder_.mergeFrom(value); + } + if (feet_ != null) { + bitField0_ |= 0x00000040; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public Builder clearFeet() { + bitField0_ = (bitField0_ & ~0x00000040); + feet_ = null; + if (feetBuilder_ != null) { + feetBuilder_.dispose(); + feetBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder getFeetBuilder() { + bitField0_ |= 0x00000040; + onChanged(); + return getFeetFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder getFeetOrBuilder() { + if (feetBuilder_ != null) { + return feetBuilder_.getMessageOrBuilder(); + } else { + return feet_ == null ? + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance() : feet_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Item feet = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder> + getFeetFieldBuilder() { + if (feetBuilder_ == null) { + feetBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder>( + getFeet(), + getParentForChildren(), + isClean()); + feet_ = null; + } + return feetBuilder_; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Equipment) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Equipment) + private static final dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment(); + } + + public static dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Equipment parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\017equipment.proto\022%dev.foxikle.customnpc" + + "s.internal.proto\032\nitem.proto\"\217\003\n\tEquipme" + + "nt\022\026\n\016schema_version\030\001 \001(\005\022>\n\tmain_hand\030" + + "\002 \001(\0132+.dev.foxikle.customnpcs.internal." + + "proto.Item\022=\n\010off_hand\030\003 \001(\0132+.dev.foxik" + + "le.customnpcs.internal.proto.Item\0229\n\004hea" + + "d\030\004 \001(\0132+.dev.foxikle.customnpcs.interna" + + "l.proto.Item\022:\n\005chest\030\005 \001(\0132+.dev.foxikl" + + "e.customnpcs.internal.proto.Item\0229\n\004legs" + + "\030\006 \001(\0132+.dev.foxikle.customnpcs.internal" + + ".proto.Item\0229\n\004feet\030\007 \001(\0132+.dev.foxikle." + + "customnpcs.internal.proto.Itemb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.getDescriptor(), + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Equipment_descriptor, + new java.lang.String[]{"SchemaVersion", "MainHand", "OffHand", "Head", "Chest", "Legs", "Feet",}); + descriptor.resolveAllFeaturesImmutable(); + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ItemOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ItemOuterClass.java new file mode 100644 index 00000000..e65a9b82 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ItemOuterClass.java @@ -0,0 +1,564 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: item.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class ItemOuterClass { + private ItemOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + ItemOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface ItemOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Item) + com.google.protobuf.MessageOrBuilder { + + /** + *

+         * byte array
+         * 
+ * + * bytes serialized = 1; + * + * @return The serialized. + */ + com.google.protobuf.ByteString getSerialized(); + } + + /** + *
+     * doesn't need a migrations field as that is already handled by Paper's itemstack serialization
+     * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Item} + */ + public static final class Item extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Item) + ItemOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Item.class.getName()); + } + + // Use Item.newBuilder() to construct. + private Item(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Item() { + serialized_ = com.google.protobuf.ByteString.EMPTY; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.class, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder.class); + } + + public static final int SERIALIZED_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString serialized_ = com.google.protobuf.ByteString.EMPTY; + + /** + *

+         * byte array
+         * 
+ * + * bytes serialized = 1; + * + * @return The serialized. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSerialized() { + return serialized_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!serialized_.isEmpty()) { + output.writeBytes(1, serialized_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!serialized_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, serialized_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Item other)) { + return super.equals(obj); + } + + if (!getSerialized() + .equals(other.getSerialized())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SERIALIZED_FIELD_NUMBER; + hash = (53 * hash) + getSerialized().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + *
+         * doesn't need a migrations field as that is already handled by Paper's itemstack serialization
+         * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Item} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Item) + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.ItemOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.class, dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + serialized_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item build() { + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item buildPartial() { + dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item result = new dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.serialized_ = serialized_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item other) { + if (other == dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item.getDefaultInstance()) + return this; + if (other.getSerialized() != com.google.protobuf.ByteString.EMPTY) { + setSerialized(other.getSerialized()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + serialized_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.ByteString serialized_ = com.google.protobuf.ByteString.EMPTY; + + /** + *

+             * byte array
+             * 
+ * + * bytes serialized = 1; + * + * @return The serialized. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSerialized() { + return serialized_; + } + + /** + *
+             * byte array
+             * 
+ * + * bytes serialized = 1; + * + * @param value The serialized to set. + * @return This builder for chaining. + */ + public Builder setSerialized(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + serialized_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + *
+             * byte array
+             * 
+ * + * bytes serialized = 1; + * + * @return This builder for chaining. + */ + public Builder clearSerialized() { + bitField0_ = (bitField0_ & ~0x00000001); + serialized_ = getDefaultInstance().getSerialized(); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Item) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Item) + private static final dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item(); + } + + public static dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Item parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ItemOuterClass.Item getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Item_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\nitem.proto\022%dev.foxikle.customnpcs.int" + + "ernal.proto\"\032\n\004Item\022\022\n\nserialized\030\001 \001(\014b" + + "\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Item_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Item_descriptor, + new java.lang.String[]{"Serialized",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/LocationOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/LocationOuterClass.java new file mode 100644 index 00000000..310f9263 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/LocationOuterClass.java @@ -0,0 +1,1119 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: location.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class LocationOuterClass { + private LocationOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + LocationOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface LocationOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Location) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + int getSchemaVersion(); + + /** + * string world = 2; + * + * @return The world. + */ + java.lang.String getWorld(); + + /** + * string world = 2; + * + * @return The bytes for world. + */ + com.google.protobuf.ByteString + getWorldBytes(); + + /** + * double x = 3; + * + * @return The x. + */ + double getX(); + + /** + * double y = 4; + * + * @return The y. + */ + double getY(); + + /** + * double z = 5; + * + * @return The z. + */ + double getZ(); + + /** + * float pitch = 6; + * + * @return The pitch. + */ + float getPitch(); + + /** + * float yaw = 7; + * + * @return The yaw. + */ + float getYaw(); + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Location} + */ + public static final class Location extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Location) + LocationOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Location.class.getName()); + } + + // Use Location.newBuilder() to construct. + private Location(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Location() { + world_ = ""; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.class, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder.class); + } + + public static final int SCHEMA_VERSION_FIELD_NUMBER = 1; + private int schemaVersion_ = 0; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + public static final int WORLD_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private volatile java.lang.Object world_ = ""; + + /** + * string world = 2; + * + * @return The world. + */ + @java.lang.Override + public java.lang.String getWorld() { + java.lang.Object ref = world_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + world_ = s; + return s; + } + } + + /** + * string world = 2; + * + * @return The bytes for world. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getWorldBytes() { + java.lang.Object ref = world_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + world_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int X_FIELD_NUMBER = 3; + private double x_ = 0D; + + /** + * double x = 3; + * + * @return The x. + */ + @java.lang.Override + public double getX() { + return x_; + } + + public static final int Y_FIELD_NUMBER = 4; + private double y_ = 0D; + + /** + * double y = 4; + * + * @return The y. + */ + @java.lang.Override + public double getY() { + return y_; + } + + public static final int Z_FIELD_NUMBER = 5; + private double z_ = 0D; + + /** + * double z = 5; + * + * @return The z. + */ + @java.lang.Override + public double getZ() { + return z_; + } + + public static final int PITCH_FIELD_NUMBER = 6; + private float pitch_ = 0F; + + /** + * float pitch = 6; + * + * @return The pitch. + */ + @java.lang.Override + public float getPitch() { + return pitch_; + } + + public static final int YAW_FIELD_NUMBER = 7; + private float yaw_ = 0F; + + /** + * float yaw = 7; + * + * @return The yaw. + */ + @java.lang.Override + public float getYaw() { + return yaw_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (schemaVersion_ != 0) { + output.writeInt32(1, schemaVersion_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(world_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, world_); + } + if (java.lang.Double.doubleToRawLongBits(x_) != 0) { + output.writeDouble(3, x_); + } + if (java.lang.Double.doubleToRawLongBits(y_) != 0) { + output.writeDouble(4, y_); + } + if (java.lang.Double.doubleToRawLongBits(z_) != 0) { + output.writeDouble(5, z_); + } + if (java.lang.Float.floatToRawIntBits(pitch_) != 0) { + output.writeFloat(6, pitch_); + } + if (java.lang.Float.floatToRawIntBits(yaw_) != 0) { + output.writeFloat(7, yaw_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (schemaVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, schemaVersion_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(world_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, world_); + } + if (java.lang.Double.doubleToRawLongBits(x_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(3, x_); + } + if (java.lang.Double.doubleToRawLongBits(y_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(4, y_); + } + if (java.lang.Double.doubleToRawLongBits(z_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeDoubleSize(5, z_); + } + if (java.lang.Float.floatToRawIntBits(pitch_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(6, pitch_); + } + if (java.lang.Float.floatToRawIntBits(yaw_) != 0) { + size += com.google.protobuf.CodedOutputStream + .computeFloatSize(7, yaw_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Location other)) { + return super.equals(obj); + } + + if (getSchemaVersion() + != other.getSchemaVersion()) return false; + if (!getWorld() + .equals(other.getWorld())) return false; + if (java.lang.Double.doubleToLongBits(getX()) + != java.lang.Double.doubleToLongBits( + other.getX())) return false; + if (java.lang.Double.doubleToLongBits(getY()) + != java.lang.Double.doubleToLongBits( + other.getY())) return false; + if (java.lang.Double.doubleToLongBits(getZ()) + != java.lang.Double.doubleToLongBits( + other.getZ())) return false; + if (java.lang.Float.floatToIntBits(getPitch()) + != java.lang.Float.floatToIntBits( + other.getPitch())) return false; + if (java.lang.Float.floatToIntBits(getYaw()) + != java.lang.Float.floatToIntBits( + other.getYaw())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SCHEMA_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getSchemaVersion(); + hash = (37 * hash) + WORLD_FIELD_NUMBER; + hash = (53 * hash) + getWorld().hashCode(); + hash = (37 * hash) + X_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getX())); + hash = (37 * hash) + Y_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getY())); + hash = (37 * hash) + Z_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getZ())); + hash = (37 * hash) + PITCH_FIELD_NUMBER; + hash = (53 * hash) + java.lang.Float.floatToIntBits( + getPitch()); + hash = (37 * hash) + YAW_FIELD_NUMBER; + hash = (53 * hash) + java.lang.Float.floatToIntBits( + getYaw()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Location} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Location) + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.class, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + schemaVersion_ = 0; + world_ = ""; + x_ = 0D; + y_ = 0D; + z_ = 0D; + pitch_ = 0F; + yaw_ = 0F; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location build() { + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location buildPartial() { + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location result = new dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.schemaVersion_ = schemaVersion_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.world_ = world_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.x_ = x_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.y_ = y_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.z_ = z_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.pitch_ = pitch_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.yaw_ = yaw_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location other) { + if (other == dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance()) + return this; + if (other.getSchemaVersion() != 0) { + setSchemaVersion(other.getSchemaVersion()); + } + if (!other.getWorld().isEmpty()) { + world_ = other.world_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.getX() != 0D) { + setX(other.getX()); + } + if (other.getY() != 0D) { + setY(other.getY()); + } + if (other.getZ() != 0D) { + setZ(other.getZ()); + } + if (other.getPitch() != 0F) { + setPitch(other.getPitch()); + } + if (other.getYaw() != 0F) { + setYaw(other.getYaw()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + schemaVersion_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + world_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 25: { + x_ = input.readDouble(); + bitField0_ |= 0x00000004; + break; + } // case 25 + case 33: { + y_ = input.readDouble(); + bitField0_ |= 0x00000008; + break; + } // case 33 + case 41: { + z_ = input.readDouble(); + bitField0_ |= 0x00000010; + break; + } // case 41 + case 53: { + pitch_ = input.readFloat(); + bitField0_ |= 0x00000020; + break; + } // case 53 + case 61: { + yaw_ = input.readFloat(); + bitField0_ |= 0x00000040; + break; + } // case 61 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int schemaVersion_; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + /** + * int32 schema_version = 1; + * + * @param value The schemaVersion to set. + * @return This builder for chaining. + */ + public Builder setSchemaVersion(int value) { + + schemaVersion_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * int32 schema_version = 1; + * + * @return This builder for chaining. + */ + public Builder clearSchemaVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + schemaVersion_ = 0; + onChanged(); + return this; + } + + private java.lang.Object world_ = ""; + + /** + * string world = 2; + * + * @return The world. + */ + public java.lang.String getWorld() { + java.lang.Object ref = world_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + world_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string world = 2; + * + * @return The bytes for world. + */ + public com.google.protobuf.ByteString + getWorldBytes() { + java.lang.Object ref = world_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + world_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string world = 2; + * + * @param value The world to set. + * @return This builder for chaining. + */ + public Builder setWorld( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + world_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * string world = 2; + * + * @return This builder for chaining. + */ + public Builder clearWorld() { + world_ = getDefaultInstance().getWorld(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * string world = 2; + * + * @param value The bytes for world to set. + * @return This builder for chaining. + */ + public Builder setWorldBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + world_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private double x_; + + /** + * double x = 3; + * + * @return The x. + */ + @java.lang.Override + public double getX() { + return x_; + } + + /** + * double x = 3; + * + * @param value The x to set. + * @return This builder for chaining. + */ + public Builder setX(double value) { + + x_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * double x = 3; + * + * @return This builder for chaining. + */ + public Builder clearX() { + bitField0_ = (bitField0_ & ~0x00000004); + x_ = 0D; + onChanged(); + return this; + } + + private double y_; + + /** + * double y = 4; + * + * @return The y. + */ + @java.lang.Override + public double getY() { + return y_; + } + + /** + * double y = 4; + * + * @param value The y to set. + * @return This builder for chaining. + */ + public Builder setY(double value) { + + y_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * double y = 4; + * + * @return This builder for chaining. + */ + public Builder clearY() { + bitField0_ = (bitField0_ & ~0x00000008); + y_ = 0D; + onChanged(); + return this; + } + + private double z_; + + /** + * double z = 5; + * + * @return The z. + */ + @java.lang.Override + public double getZ() { + return z_; + } + + /** + * double z = 5; + * + * @param value The z to set. + * @return This builder for chaining. + */ + public Builder setZ(double value) { + + z_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * double z = 5; + * + * @return This builder for chaining. + */ + public Builder clearZ() { + bitField0_ = (bitField0_ & ~0x00000010); + z_ = 0D; + onChanged(); + return this; + } + + private float pitch_; + + /** + * float pitch = 6; + * + * @return The pitch. + */ + @java.lang.Override + public float getPitch() { + return pitch_; + } + + /** + * float pitch = 6; + * + * @param value The pitch to set. + * @return This builder for chaining. + */ + public Builder setPitch(float value) { + + pitch_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * float pitch = 6; + * + * @return This builder for chaining. + */ + public Builder clearPitch() { + bitField0_ = (bitField0_ & ~0x00000020); + pitch_ = 0F; + onChanged(); + return this; + } + + private float yaw_; + + /** + * float yaw = 7; + * + * @return The yaw. + */ + @java.lang.Override + public float getYaw() { + return yaw_; + } + + /** + * float yaw = 7; + * + * @param value The yaw to set. + * @return This builder for chaining. + */ + public Builder setYaw(float value) { + + yaw_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * float yaw = 7; + * + * @return This builder for chaining. + */ + public Builder clearYaw() { + bitField0_ = (bitField0_ & ~0x00000040); + yaw_ = 0F; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Location) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Location) + private static final dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location(); + } + + public static dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Location parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Location_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\016location.proto\022%dev.foxikle.customnpcs" + + ".internal.proto\"n\n\010Location\022\026\n\016schema_ve" + + "rsion\030\001 \001(\005\022\r\n\005world\030\002 \001(\t\022\t\n\001x\030\003 \001(\001\022\t\n" + + "\001y\030\004 \001(\001\022\t\n\001z\030\005 \001(\001\022\r\n\005pitch\030\006 \001(\002\022\013\n\003ya" + + "w\030\007 \001(\002b\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Location_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Location_descriptor, + new java.lang.String[]{"SchemaVersion", "World", "X", "Y", "Z", "Pitch", "Yaw",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcListOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcListOuterClass.java new file mode 100644 index 00000000..ad4fca92 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcListOuterClass.java @@ -0,0 +1,870 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: npc_list.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class NpcListOuterClass { + private NpcListOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + NpcListOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface NpcListOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.NpcList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + java.util.List + getNpcsList(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getNpcs(int index); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + int getNpcsCount(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + java.util.List + getNpcsOrBuilderList(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder getNpcsOrBuilder( + int index); + } + + /** + *
+     * This is the data that gets stored in a file or database somewhere,
+     * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.NpcList} + */ + public static final class NpcList extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.NpcList) + NpcListOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + NpcList.class.getName()); + } + + // Use NpcList.newBuilder() to construct. + private NpcList(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private NpcList() { + npcs_ = java.util.Collections.emptyList(); + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.class, dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.Builder.class); + } + + public static final int NPCS_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private java.util.List npcs_; + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public java.util.List getNpcsList() { + return npcs_; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public java.util.List + getNpcsOrBuilderList() { + return npcs_; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public int getNpcsCount() { + return npcs_.size(); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getNpcs(int index) { + return npcs_.get(index); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder getNpcsOrBuilder( + int index) { + return npcs_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < npcs_.size(); i++) { + output.writeMessage(1, npcs_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < npcs_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, npcs_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof NpcList other)) { + return super.equals(obj); + } + + if (!getNpcsList() + .equals(other.getNpcsList())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getNpcsCount() > 0) { + hash = (37 * hash) + NPCS_FIELD_NUMBER; + hash = (53 * hash) + getNpcsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + *

+         * This is the data that gets stored in a file or database somewhere,
+         * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.NpcList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.NpcList) + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcListOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.class, dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (npcsBuilder_ == null) { + npcs_ = java.util.Collections.emptyList(); + } else { + npcs_ = null; + npcsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList build() { + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList buildPartial() { + dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList result = new dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList result) { + if (npcsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + npcs_ = java.util.Collections.unmodifiableList(npcs_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.npcs_ = npcs_; + } else { + result.npcs_ = npcsBuilder_.build(); + } + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList other) { + if (other == dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList.getDefaultInstance()) + return this; + if (npcsBuilder_ == null) { + if (!other.npcs_.isEmpty()) { + if (npcs_.isEmpty()) { + npcs_ = other.npcs_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureNpcsIsMutable(); + npcs_.addAll(other.npcs_); + } + onChanged(); + } + } else { + if (!other.npcs_.isEmpty()) { + if (npcsBuilder_.isEmpty()) { + npcsBuilder_.dispose(); + npcsBuilder_ = null; + npcs_ = other.npcs_; + bitField0_ = (bitField0_ & ~0x00000001); + npcsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getNpcsFieldBuilder() : null; + } else { + npcsBuilder_.addAllMessages(other.npcs_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc m = + input.readMessage( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.parser(), + extensionRegistry); + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.add(m); + } else { + npcsBuilder_.addMessage(m); + } + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List npcs_ = + java.util.Collections.emptyList(); + + private void ensureNpcsIsMutable() { + if ((bitField0_ & 0x00000001) == 0) { + npcs_ = new java.util.ArrayList(npcs_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder> npcsBuilder_; + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public java.util.List getNpcsList() { + if (npcsBuilder_ == null) { + return java.util.Collections.unmodifiableList(npcs_); + } else { + return npcsBuilder_.getMessageList(); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public int getNpcsCount() { + if (npcsBuilder_ == null) { + return npcs_.size(); + } else { + return npcsBuilder_.getCount(); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getNpcs(int index) { + if (npcsBuilder_ == null) { + return npcs_.get(index); + } else { + return npcsBuilder_.getMessage(index); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder setNpcs( + int index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc value) { + if (npcsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNpcsIsMutable(); + npcs_.set(index, value); + onChanged(); + } else { + npcsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder setNpcs( + int index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder builderForValue) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.set(index, builderForValue.build()); + onChanged(); + } else { + npcsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addNpcs(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc value) { + if (npcsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNpcsIsMutable(); + npcs_.add(value); + onChanged(); + } else { + npcsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addNpcs( + int index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc value) { + if (npcsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureNpcsIsMutable(); + npcs_.add(index, value); + onChanged(); + } else { + npcsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addNpcs( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder builderForValue) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.add(builderForValue.build()); + onChanged(); + } else { + npcsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addNpcs( + int index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder builderForValue) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.add(index, builderForValue.build()); + onChanged(); + } else { + npcsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder addAllNpcs( + java.lang.Iterable values) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, npcs_); + onChanged(); + } else { + npcsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder clearNpcs() { + if (npcsBuilder_ == null) { + npcs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + npcsBuilder_.clear(); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public Builder removeNpcs(int index) { + if (npcsBuilder_ == null) { + ensureNpcsIsMutable(); + npcs_.remove(index); + onChanged(); + } else { + npcsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder getNpcsBuilder( + int index) { + return getNpcsFieldBuilder().getBuilder(index); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder getNpcsOrBuilder( + int index) { + if (npcsBuilder_ == null) { + return npcs_.get(index); + } else { + return npcsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public java.util.List + getNpcsOrBuilderList() { + if (npcsBuilder_ != null) { + return npcsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(npcs_); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder addNpcsBuilder() { + return getNpcsFieldBuilder().addBuilder( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.getDefaultInstance()); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder addNpcsBuilder( + int index) { + return getNpcsFieldBuilder().addBuilder( + index, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.getDefaultInstance()); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Npc npcs = 1; + */ + public java.util.List + getNpcsBuilderList() { + return getNpcsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder> + getNpcsFieldBuilder() { + if (npcsBuilder_ == null) { + npcsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder>( + npcs_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + npcs_ = null; + } + return npcsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.NpcList) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.NpcList) + private static final dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList(); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public NpcList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcListOuterClass.NpcList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\016npc_list.proto\022%dev.foxikle.customnpcs" + + ".internal.proto\032\tnpc.proto\"C\n\007NpcList\0228\n" + + "\004npcs\030\001 \003(\0132*.dev.foxikle.customnpcs.int" + + "ernal.proto.Npcb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.getDescriptor(), + }); + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_NpcList_descriptor, + new java.lang.String[]{"Npcs",}); + descriptor.resolveAllFeaturesImmutable(); + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcOuterClass.java new file mode 100644 index 00000000..0621beff --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcOuterClass.java @@ -0,0 +1,1822 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: npc.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class NpcOuterClass { + private NpcOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + NpcOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface NpcOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Npc) + com.google.protobuf.MessageOrBuilder { + + /** + *

+         * for migrations
+         * 
+ * + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + int getSchemaVersion(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + java.util.List + getActionsList(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getActions(int index); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + int getActionsCount(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + java.util.List + getActionsOrBuilderList(); + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder getActionsOrBuilder( + int index); + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return Whether the location field is set. + */ + boolean hasLocation(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return The location. + */ + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getLocation(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder getLocationOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return Whether the settings field is set. + */ + boolean hasSettings(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return The settings. + */ + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getSettings(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder getSettingsOrBuilder(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return Whether the equipment field is set. + */ + boolean hasEquipment(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return The equipment. + */ + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getEquipment(); + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder getEquipmentOrBuilder(); + + /** + * string uuid = 6; + * + * @return The uuid. + */ + java.lang.String getUuid(); + + /** + * string uuid = 6; + * + * @return The bytes for uuid. + */ + com.google.protobuf.ByteString + getUuidBytes(); + } + + /** + *
+     * DO NOT EVER CHANGE THE INDICIES
+     * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Npc} + */ + public static final class Npc extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Npc) + NpcOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Npc.class.getName()); + } + + // Use Npc.newBuilder() to construct. + private Npc(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Npc() { + actions_ = java.util.Collections.emptyList(); + uuid_ = ""; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.class, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder.class); + } + + private int bitField0_; + public static final int SCHEMA_VERSION_FIELD_NUMBER = 1; + private int schemaVersion_ = 0; + + /** + *

+         * for migrations
+         * 
+ * + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + public static final int ACTIONS_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private java.util.List actions_; + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public java.util.List getActionsList() { + return actions_; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public java.util.List + getActionsOrBuilderList() { + return actions_; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public int getActionsCount() { + return actions_.size(); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getActions(int index) { + return actions_.get(index); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder getActionsOrBuilder( + int index) { + return actions_.get(index); + } + + public static final int LOCATION_FIELD_NUMBER = 3; + private dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location location_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return Whether the location field is set. + */ + @java.lang.Override + public boolean hasLocation() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return The location. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getLocation() { + return location_ == null ? dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance() : location_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder getLocationOrBuilder() { + return location_ == null ? dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance() : location_; + } + + public static final int SETTINGS_FIELD_NUMBER = 4; + private dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings settings_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return Whether the settings field is set. + */ + @java.lang.Override + public boolean hasSettings() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return The settings. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getSettings() { + return settings_ == null ? dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance() : settings_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder getSettingsOrBuilder() { + return settings_ == null ? dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance() : settings_; + } + + public static final int EQUIPMENT_FIELD_NUMBER = 5; + private dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment equipment_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return Whether the equipment field is set. + */ + @java.lang.Override + public boolean hasEquipment() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return The equipment. + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getEquipment() { + return equipment_ == null ? dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance() : equipment_; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder getEquipmentOrBuilder() { + return equipment_ == null ? dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance() : equipment_; + } + + public static final int UUID_FIELD_NUMBER = 6; + @SuppressWarnings("serial") + private volatile java.lang.Object uuid_ = ""; + + /** + * string uuid = 6; + * + * @return The uuid. + */ + @java.lang.Override + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uuid_ = s; + return s; + } + } + + /** + * string uuid = 6; + * + * @return The bytes for uuid. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getUuidBytes() { + java.lang.Object ref = uuid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (schemaVersion_ != 0) { + output.writeInt32(1, schemaVersion_); + } + for (int i = 0; i < actions_.size(); i++) { + output.writeMessage(2, actions_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getLocation()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(4, getSettings()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(5, getEquipment()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(uuid_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 6, uuid_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (schemaVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, schemaVersion_); + } + for (int i = 0; i < actions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, actions_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getLocation()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getSettings()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getEquipment()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(uuid_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(6, uuid_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Npc other)) { + return super.equals(obj); + } + + if (getSchemaVersion() + != other.getSchemaVersion()) return false; + if (!getActionsList() + .equals(other.getActionsList())) return false; + if (hasLocation() != other.hasLocation()) return false; + if (hasLocation()) { + if (!getLocation() + .equals(other.getLocation())) return false; + } + if (hasSettings() != other.hasSettings()) return false; + if (hasSettings()) { + if (!getSettings() + .equals(other.getSettings())) return false; + } + if (hasEquipment() != other.hasEquipment()) return false; + if (hasEquipment()) { + if (!getEquipment() + .equals(other.getEquipment())) return false; + } + if (!getUuid() + .equals(other.getUuid())) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SCHEMA_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getSchemaVersion(); + if (getActionsCount() > 0) { + hash = (37 * hash) + ACTIONS_FIELD_NUMBER; + hash = (53 * hash) + getActionsList().hashCode(); + } + if (hasLocation()) { + hash = (37 * hash) + LOCATION_FIELD_NUMBER; + hash = (53 * hash) + getLocation().hashCode(); + } + if (hasSettings()) { + hash = (37 * hash) + SETTINGS_FIELD_NUMBER; + hash = (53 * hash) + getSettings().hashCode(); + } + if (hasEquipment()) { + hash = (37 * hash) + EQUIPMENT_FIELD_NUMBER; + hash = (53 * hash) + getEquipment().hashCode(); + } + hash = (37 * hash) + UUID_FIELD_NUMBER; + hash = (53 * hash) + getUuid().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + *
+         * DO NOT EVER CHANGE THE INDICIES
+         * 
+ *

+ * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Npc} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Npc) + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.NpcOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.class, dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage + .alwaysUseFieldBuilders) { + getActionsFieldBuilder(); + getLocationFieldBuilder(); + getSettingsFieldBuilder(); + getEquipmentFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + schemaVersion_ = 0; + if (actionsBuilder_ == null) { + actions_ = java.util.Collections.emptyList(); + } else { + actions_ = null; + actionsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + location_ = null; + if (locationBuilder_ != null) { + locationBuilder_.dispose(); + locationBuilder_ = null; + } + settings_ = null; + if (settingsBuilder_ != null) { + settingsBuilder_.dispose(); + settingsBuilder_ = null; + } + equipment_ = null; + if (equipmentBuilder_ != null) { + equipmentBuilder_.dispose(); + equipmentBuilder_ = null; + } + uuid_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc build() { + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc buildPartial() { + dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc result = new dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc result) { + if (actionsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + actions_ = java.util.Collections.unmodifiableList(actions_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.actions_ = actions_; + } else { + result.actions_ = actionsBuilder_.build(); + } + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.schemaVersion_ = schemaVersion_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.location_ = locationBuilder_ == null + ? location_ + : locationBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.settings_ = settingsBuilder_ == null + ? settings_ + : settingsBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.equipment_ = equipmentBuilder_ == null + ? equipment_ + : equipmentBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.uuid_ = uuid_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc other) { + if (other == dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc.getDefaultInstance()) return this; + if (other.getSchemaVersion() != 0) { + setSchemaVersion(other.getSchemaVersion()); + } + if (actionsBuilder_ == null) { + if (!other.actions_.isEmpty()) { + if (actions_.isEmpty()) { + actions_ = other.actions_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureActionsIsMutable(); + actions_.addAll(other.actions_); + } + onChanged(); + } + } else { + if (!other.actions_.isEmpty()) { + if (actionsBuilder_.isEmpty()) { + actionsBuilder_.dispose(); + actionsBuilder_ = null; + actions_ = other.actions_; + bitField0_ = (bitField0_ & ~0x00000002); + actionsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getActionsFieldBuilder() : null; + } else { + actionsBuilder_.addAllMessages(other.actions_); + } + } + } + if (other.hasLocation()) { + mergeLocation(other.getLocation()); + } + if (other.hasSettings()) { + mergeSettings(other.getSettings()); + } + if (other.hasEquipment()) { + mergeEquipment(other.getEquipment()); + } + if (!other.getUuid().isEmpty()) { + uuid_ = other.uuid_; + bitField0_ |= 0x00000020; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + schemaVersion_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action m = + input.readMessage( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.parser(), + extensionRegistry); + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.add(m); + } else { + actionsBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: { + input.readMessage( + getLocationFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: { + input.readMessage( + getSettingsFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: { + input.readMessage( + getEquipmentFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: { + uuid_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000020; + break; + } // case 50 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int schemaVersion_; + + /** + *

+             * for migrations
+             * 
+ * + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + /** + *
+             * for migrations
+             * 
+ * + * int32 schema_version = 1; + * + * @param value The schemaVersion to set. + * @return This builder for chaining. + */ + public Builder setSchemaVersion(int value) { + + schemaVersion_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + *
+             * for migrations
+             * 
+ * + * int32 schema_version = 1; + * + * @return This builder for chaining. + */ + public Builder clearSchemaVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + schemaVersion_ = 0; + onChanged(); + return this; + } + + private java.util.List actions_ = + java.util.Collections.emptyList(); + + private void ensureActionsIsMutable() { + if ((bitField0_ & 0x00000002) == 0) { + actions_ = new java.util.ArrayList(actions_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder> actionsBuilder_; + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public java.util.List getActionsList() { + if (actionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(actions_); + } else { + return actionsBuilder_.getMessageList(); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public int getActionsCount() { + if (actionsBuilder_ == null) { + return actions_.size(); + } else { + return actionsBuilder_.getCount(); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action getActions(int index) { + if (actionsBuilder_ == null) { + return actions_.get(index); + } else { + return actionsBuilder_.getMessage(index); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder setActions( + int index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action value) { + if (actionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActionsIsMutable(); + actions_.set(index, value); + onChanged(); + } else { + actionsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder setActions( + int index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder builderForValue) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.set(index, builderForValue.build()); + onChanged(); + } else { + actionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addActions(dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action value) { + if (actionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActionsIsMutable(); + actions_.add(value); + onChanged(); + } else { + actionsBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addActions( + int index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action value) { + if (actionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureActionsIsMutable(); + actions_.add(index, value); + onChanged(); + } else { + actionsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addActions( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder builderForValue) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.add(builderForValue.build()); + onChanged(); + } else { + actionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addActions( + int index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder builderForValue) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.add(index, builderForValue.build()); + onChanged(); + } else { + actionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder addAllActions( + java.lang.Iterable values) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, actions_); + onChanged(); + } else { + actionsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder clearActions() { + if (actionsBuilder_ == null) { + actions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + actionsBuilder_.clear(); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public Builder removeActions(int index) { + if (actionsBuilder_ == null) { + ensureActionsIsMutable(); + actions_.remove(index); + onChanged(); + } else { + actionsBuilder_.remove(index); + } + return this; + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder getActionsBuilder( + int index) { + return getActionsFieldBuilder().getBuilder(index); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder getActionsOrBuilder( + int index) { + if (actionsBuilder_ == null) { + return actions_.get(index); + } else { + return actionsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public java.util.List + getActionsOrBuilderList() { + if (actionsBuilder_ != null) { + return actionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(actions_); + } + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder addActionsBuilder() { + return getActionsFieldBuilder().addBuilder( + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.getDefaultInstance()); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder addActionsBuilder( + int index) { + return getActionsFieldBuilder().addBuilder( + index, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.getDefaultInstance()); + } + + /** + * repeated .dev.foxikle.customnpcs.internal.proto.Action actions = 2; + */ + public java.util.List + getActionsBuilderList() { + return getActionsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder> + getActionsFieldBuilder() { + if (actionsBuilder_ == null) { + actionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.Action.Builder, dev.foxikle.customnpcs.internal.proto.ActionOuterClass.ActionOrBuilder>( + actions_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + actions_ = null; + } + return actionsBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location location_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder> locationBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return Whether the location field is set. + */ + public boolean hasLocation() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + * + * @return The location. + */ + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location getLocation() { + if (locationBuilder_ == null) { + return location_ == null ? dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance() : location_; + } else { + return locationBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public Builder setLocation(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location value) { + if (locationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + location_ = value; + } else { + locationBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public Builder setLocation( + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder builderForValue) { + if (locationBuilder_ == null) { + location_ = builderForValue.build(); + } else { + locationBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public Builder mergeLocation(dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location value) { + if (locationBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) && + location_ != null && + location_ != dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance()) { + getLocationBuilder().mergeFrom(value); + } else { + location_ = value; + } + } else { + locationBuilder_.mergeFrom(value); + } + if (location_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public Builder clearLocation() { + bitField0_ = (bitField0_ & ~0x00000004); + location_ = null; + if (locationBuilder_ != null) { + locationBuilder_.dispose(); + locationBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder getLocationBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getLocationFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + public dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder getLocationOrBuilder() { + if (locationBuilder_ != null) { + return locationBuilder_.getMessageOrBuilder(); + } else { + return location_ == null ? + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.getDefaultInstance() : location_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Location location = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder> + getLocationFieldBuilder() { + if (locationBuilder_ == null) { + locationBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.Location.Builder, dev.foxikle.customnpcs.internal.proto.LocationOuterClass.LocationOrBuilder>( + getLocation(), + getParentForChildren(), + isClean()); + location_ = null; + } + return locationBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings settings_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder> settingsBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return Whether the settings field is set. + */ + public boolean hasSettings() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + * + * @return The settings. + */ + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getSettings() { + if (settingsBuilder_ == null) { + return settings_ == null ? dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance() : settings_; + } else { + return settingsBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public Builder setSettings(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings value) { + if (settingsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + settings_ = value; + } else { + settingsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public Builder setSettings( + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder builderForValue) { + if (settingsBuilder_ == null) { + settings_ = builderForValue.build(); + } else { + settingsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public Builder mergeSettings(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings value) { + if (settingsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) && + settings_ != null && + settings_ != dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance()) { + getSettingsBuilder().mergeFrom(value); + } else { + settings_ = value; + } + } else { + settingsBuilder_.mergeFrom(value); + } + if (settings_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public Builder clearSettings() { + bitField0_ = (bitField0_ & ~0x00000008); + settings_ = null; + if (settingsBuilder_ != null) { + settingsBuilder_.dispose(); + settingsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder getSettingsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getSettingsFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder getSettingsOrBuilder() { + if (settingsBuilder_ != null) { + return settingsBuilder_.getMessageOrBuilder(); + } else { + return settings_ == null ? + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance() : settings_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Settings settings = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder> + getSettingsFieldBuilder() { + if (settingsBuilder_ == null) { + settingsBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder>( + getSettings(), + getParentForChildren(), + isClean()); + settings_ = null; + } + return settingsBuilder_; + } + + private dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment equipment_; + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder> equipmentBuilder_; + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return Whether the equipment field is set. + */ + public boolean hasEquipment() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + * + * @return The equipment. + */ + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment getEquipment() { + if (equipmentBuilder_ == null) { + return equipment_ == null ? dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance() : equipment_; + } else { + return equipmentBuilder_.getMessage(); + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public Builder setEquipment(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment value) { + if (equipmentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + equipment_ = value; + } else { + equipmentBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public Builder setEquipment( + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder builderForValue) { + if (equipmentBuilder_ == null) { + equipment_ = builderForValue.build(); + } else { + equipmentBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public Builder mergeEquipment(dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment value) { + if (equipmentBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) && + equipment_ != null && + equipment_ != dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance()) { + getEquipmentBuilder().mergeFrom(value); + } else { + equipment_ = value; + } + } else { + equipmentBuilder_.mergeFrom(value); + } + if (equipment_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public Builder clearEquipment() { + bitField0_ = (bitField0_ & ~0x00000010); + equipment_ = null; + if (equipmentBuilder_ != null) { + equipmentBuilder_.dispose(); + equipmentBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder getEquipmentBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getEquipmentFieldBuilder().getBuilder(); + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + public dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder getEquipmentOrBuilder() { + if (equipmentBuilder_ != null) { + return equipmentBuilder_.getMessageOrBuilder(); + } else { + return equipment_ == null ? + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.getDefaultInstance() : equipment_; + } + } + + /** + * .dev.foxikle.customnpcs.internal.proto.Equipment equipment = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder> + getEquipmentFieldBuilder() { + if (equipmentBuilder_ == null) { + equipmentBuilder_ = new com.google.protobuf.SingleFieldBuilder< + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.Equipment.Builder, dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.EquipmentOrBuilder>( + getEquipment(), + getParentForChildren(), + isClean()); + equipment_ = null; + } + return equipmentBuilder_; + } + + private java.lang.Object uuid_ = ""; + + /** + * string uuid = 6; + * + * @return The uuid. + */ + public java.lang.String getUuid() { + java.lang.Object ref = uuid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uuid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string uuid = 6; + * + * @return The bytes for uuid. + */ + public com.google.protobuf.ByteString + getUuidBytes() { + java.lang.Object ref = uuid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + uuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string uuid = 6; + * + * @param value The uuid to set. + * @return This builder for chaining. + */ + public Builder setUuid( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + uuid_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * string uuid = 6; + * + * @return This builder for chaining. + */ + public Builder clearUuid() { + uuid_ = getDefaultInstance().getUuid(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + return this; + } + + /** + * string uuid = 6; + * + * @param value The bytes for uuid to set. + * @return This builder for chaining. + */ + public Builder setUuidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + uuid_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Npc) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Npc) + private static final dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc(); + } + + public static dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Npc parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.NpcOuterClass.Npc getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\tnpc.proto\022%dev.foxikle.customnpcs.inte" + + "rnal.proto\032\014action.proto\032\016location.proto" + + "\032\017equipment.proto\032\016settings.proto\"\266\002\n\003Np" + + "c\022\026\n\016schema_version\030\001 \001(\005\022>\n\007actions\030\002 \003" + + "(\0132-.dev.foxikle.customnpcs.internal.pro" + + "to.Action\022A\n\010location\030\003 \001(\0132/.dev.foxikl" + + "e.customnpcs.internal.proto.Location\022A\n\010" + + "settings\030\004 \001(\0132/.dev.foxikle.customnpcs." + + "internal.proto.Settings\022C\n\tequipment\030\005 \001" + + "(\01320.dev.foxikle.customnpcs.internal.pro" + + "to.Equipment\022\014\n\004uuid\030\006 \001(\tb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.getDescriptor(), + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.getDescriptor(), + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.getDescriptor(), + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.getDescriptor(), + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Npc_descriptor, + new java.lang.String[]{"SchemaVersion", "Actions", "Location", "Settings", "Equipment", "Uuid",}); + descriptor.resolveAllFeaturesImmutable(); + dev.foxikle.customnpcs.internal.proto.ActionOuterClass.getDescriptor(); + dev.foxikle.customnpcs.internal.proto.LocationOuterClass.getDescriptor(); + dev.foxikle.customnpcs.internal.proto.EquipmentOuterClass.getDescriptor(); + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java new file mode 100644 index 00000000..9d3bba5c --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2024. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.proto; + +import com.google.protobuf.ByteString; +import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.data.Equipment; +import dev.foxikle.customnpcs.data.Settings; +import dev.foxikle.customnpcs.internal.CustomNPCs; +import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; +import lombok.SneakyThrows; +import lombok.experimental.UtilityClass; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; + +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +@UtilityClass +@ApiStatus.Internal +public class ProtoWrapper { + + @ApiStatus.Internal + public static byte[] toProto(InternalNpc internalNpc) { + return toProtoNpc(internalNpc).toByteArray(); + } + + @ApiStatus.Internal + public static NpcOuterClass.Npc toProtoNpc(InternalNpc npc) { + return NpcOuterClass.Npc.newBuilder() + .addAllActions(npc.getActions().stream().map(ProtoWrapper::toProtoAction).collect(Collectors.toList())) + .setEquipment(toProtoEquipment(npc.getEquipment())) + .setLocation(toProtoLocation(npc.getSpawnLoc())) + .setSettings(toProtoSettings(npc.getSettings())) + .setUuid(npc.getUniqueID().toString()).build(); + } + + // may throw runtime exception + @ApiStatus.Internal + public static InternalNpc fromProtoNpc(NpcOuterClass.Npc npc) { + Location loc = fromProtoLocation(npc.getLocation()); + return CustomNPCs.getInstance().createNPC( + loc.getWorld(), + loc, + fromProtoEquipment(npc.getEquipment()), + fromProtoSettings(npc.getSettings()), + UUID.fromString(npc.getUuid()), + null, + npc.getActionsList().stream().map(ProtoWrapper::fromProtoAction).toList() + ); + } + + @ApiStatus.Internal + @SneakyThrows + public static InternalNpc fromProto(byte[] bytes) { + return fromProtoNpc(NpcOuterClass.Npc.parseFrom(bytes)); + } + + @ApiStatus.Internal + public static SettingsOuterClass.Settings toProtoSettings(Settings settings) { + return SettingsOuterClass.Settings.newBuilder() + .setClickable(settings.isInteractable()) + .setTunnelVision(settings.isTunnelvision()) + .setResilient(settings.isResilient()) + .setName(settings.getName()) + .setCustomHologram(settings.getCustomInteractableHologram()) + .setHideClickHologram(settings.isHideClickableHologram()) + .setSignature(settings.getSignature()) + .setValue(settings.getValue()) + .setSkinName(settings.getSkinName()) + .build(); + } + + @ApiStatus.Internal + public static Settings fromProtoSettings(SettingsOuterClass.Settings settings) { + return new Settings( + settings.getClickable(), + settings.getTunnelVision(), + settings.getResilient(), + settings.getValue(), + settings.getSignature(), + settings.getSkinName(), + settings.getName(), + settings.getCustomHologram(), + settings.getHideClickHologram() + ); + } + + @ApiStatus.Internal + public static ItemOuterClass.Item toProtoItem(ItemStack item) { + return ItemOuterClass.Item.newBuilder() + .setSerialized(ByteString.copyFrom(item.ensureServerConversions().serializeAsBytes())) + .build(); + } + + @ApiStatus.Internal + public static ItemStack fromProtoItem(ItemOuterClass.Item item) { + return ItemStack.deserializeBytes(item.getSerialized().toByteArray()); + } + + @ApiStatus.Internal + public static EquipmentOuterClass.Equipment toProtoEquipment(Equipment equipment) { + return EquipmentOuterClass.Equipment.newBuilder(). + setMainHand(toProtoItem(equipment.getHand())) + .setOffHand(toProtoItem(equipment.getOffhand())) + .setHead(toProtoItem(equipment.getHead())) + .setChest(toProtoItem(equipment.getChest())) + .setLegs(toProtoItem(equipment.getLegs())) + .setFeet(toProtoItem(equipment.getBoots())) + .build(); + } + + @ApiStatus.Internal + public static Equipment fromProtoEquipment(EquipmentOuterClass.Equipment equipment) { + return new Equipment( + fromProtoItem(equipment.getHead()), + fromProtoItem(equipment.getChest()), + fromProtoItem(equipment.getLegs()), + fromProtoItem(equipment.getFeet()), + fromProtoItem(equipment.getMainHand()), + fromProtoItem(equipment.getOffHand()) + ); + } + + @ApiStatus.Internal + public static ActionOuterClass.Action toProtoAction(Action action) { + return ActionOuterClass.Action.newBuilder() + .setSerializedData(action.serialize()) + .build(); + } + + @ApiStatus.Internal + public static Action fromProtoAction(ActionOuterClass.Action action) { + return Action.parse(action.getSerializedData()); + } + + @ApiStatus.Internal + public static LocationOuterClass.Location toProtoLocation(Location location) { + return LocationOuterClass.Location.newBuilder() + .setWorld(location.getWorld().getName()) + .setX(location.getX()) + .setY(location.getY()) + .setZ(location.getZ()) + .setPitch(location.getPitch()) + .setYaw(location.getYaw()) + .build(); + } + + @ApiStatus.Internal + @SneakyThrows // npe if world doesn't exist. //todo: Do something about this + public static Location fromProtoLocation(LocationOuterClass.Location location) { + return new Location( + Bukkit.getWorld(location.getWorld()), + location.getX(), location.getY(), + location.getZ(), location.getPitch(), + location.getYaw() + ); + } + + @ApiStatus.Internal + public static byte[] serializeList(List list) { + List npcs = list.stream().map(ProtoWrapper::toProtoNpc).toList(); + return NpcListOuterClass.NpcList.newBuilder() + .addAllNpcs(npcs) + .build().toByteArray(); + } + + @ApiStatus.Internal + @SneakyThrows + public static List deserializeList(byte[] bytes) { + NpcListOuterClass.NpcList list = NpcListOuterClass.NpcList.parseFrom(bytes); + List npcs = list.getNpcsList(); + return npcs.stream().map(ProtoWrapper::fromProtoNpc).collect(Collectors.toList()); + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/SettingsOuterClass.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/SettingsOuterClass.java new file mode 100644 index 00000000..6e2ee5b8 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/SettingsOuterClass.java @@ -0,0 +1,1711 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: settings.proto +// Protobuf Java Version: 4.28.3 + +package dev.foxikle.customnpcs.internal.proto; + +public final class SettingsOuterClass { + private SettingsOuterClass() { + } + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + SettingsOuterClass.class.getName()); + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + + public interface SettingsOrBuilder extends + // @@protoc_insertion_point(interface_extends:dev.foxikle.customnpcs.internal.proto.Settings) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + int getSchemaVersion(); + + /** + * string value = 2; + * + * @return The value. + */ + java.lang.String getValue(); + + /** + * string value = 2; + * + * @return The bytes for value. + */ + com.google.protobuf.ByteString + getValueBytes(); + + /** + * string signature = 3; + * + * @return The signature. + */ + java.lang.String getSignature(); + + /** + * string signature = 3; + * + * @return The bytes for signature. + */ + com.google.protobuf.ByteString + getSignatureBytes(); + + /** + * string skin_name = 4; + * + * @return The skinName. + */ + java.lang.String getSkinName(); + + /** + * string skin_name = 4; + * + * @return The bytes for skinName. + */ + com.google.protobuf.ByteString + getSkinNameBytes(); + + /** + * string custom_hologram = 5; + * + * @return The customHologram. + */ + java.lang.String getCustomHologram(); + + /** + * string custom_hologram = 5; + * + * @return The bytes for customHologram. + */ + com.google.protobuf.ByteString + getCustomHologramBytes(); + + /** + * string name = 6; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * string name = 6; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * bool clickable = 7; + * + * @return The clickable. + */ + boolean getClickable(); + + /** + * bool hide_click_hologram = 8; + * + * @return The hideClickHologram. + */ + boolean getHideClickHologram(); + + /** + * bool tunnel_vision = 9; + * + * @return The tunnelVision. + */ + boolean getTunnelVision(); + + /** + * bool resilient = 10; + * + * @return The resilient. + */ + boolean getResilient(); + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Settings} + */ + public static final class Settings extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:dev.foxikle.customnpcs.internal.proto.Settings) + SettingsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 28, + /* patch= */ 3, + /* suffix= */ "", + Settings.class.getName()); + } + + // Use Settings.newBuilder() to construct. + private Settings(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Settings() { + value_ = ""; + signature_ = ""; + skinName_ = ""; + customHologram_ = ""; + name_ = ""; + } + + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.class, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder.class); + } + + public static final int SCHEMA_VERSION_FIELD_NUMBER = 1; + private int schemaVersion_ = 0; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + public static final int VALUE_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private volatile java.lang.Object value_ = ""; + + /** + * string value = 2; + * + * @return The value. + */ + @java.lang.Override + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + value_ = s; + return s; + } + } + + /** + * string value = 2; + * + * @return The bytes for value. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SIGNATURE_FIELD_NUMBER = 3; + @SuppressWarnings("serial") + private volatile java.lang.Object signature_ = ""; + + /** + * string signature = 3; + * + * @return The signature. + */ + @java.lang.Override + public java.lang.String getSignature() { + java.lang.Object ref = signature_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + signature_ = s; + return s; + } + } + + /** + * string signature = 3; + * + * @return The bytes for signature. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSignatureBytes() { + java.lang.Object ref = signature_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + signature_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SKIN_NAME_FIELD_NUMBER = 4; + @SuppressWarnings("serial") + private volatile java.lang.Object skinName_ = ""; + + /** + * string skin_name = 4; + * + * @return The skinName. + */ + @java.lang.Override + public java.lang.String getSkinName() { + java.lang.Object ref = skinName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + skinName_ = s; + return s; + } + } + + /** + * string skin_name = 4; + * + * @return The bytes for skinName. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSkinNameBytes() { + java.lang.Object ref = skinName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + skinName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CUSTOM_HOLOGRAM_FIELD_NUMBER = 5; + @SuppressWarnings("serial") + private volatile java.lang.Object customHologram_ = ""; + + /** + * string custom_hologram = 5; + * + * @return The customHologram. + */ + @java.lang.Override + public java.lang.String getCustomHologram() { + java.lang.Object ref = customHologram_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + customHologram_ = s; + return s; + } + } + + /** + * string custom_hologram = 5; + * + * @return The bytes for customHologram. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getCustomHologramBytes() { + java.lang.Object ref = customHologram_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + customHologram_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAME_FIELD_NUMBER = 6; + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * string name = 6; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * string name = 6; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CLICKABLE_FIELD_NUMBER = 7; + private boolean clickable_ = false; + + /** + * bool clickable = 7; + * + * @return The clickable. + */ + @java.lang.Override + public boolean getClickable() { + return clickable_; + } + + public static final int HIDE_CLICK_HOLOGRAM_FIELD_NUMBER = 8; + private boolean hideClickHologram_ = false; + + /** + * bool hide_click_hologram = 8; + * + * @return The hideClickHologram. + */ + @java.lang.Override + public boolean getHideClickHologram() { + return hideClickHologram_; + } + + public static final int TUNNEL_VISION_FIELD_NUMBER = 9; + private boolean tunnelVision_ = false; + + /** + * bool tunnel_vision = 9; + * + * @return The tunnelVision. + */ + @java.lang.Override + public boolean getTunnelVision() { + return tunnelVision_; + } + + public static final int RESILIENT_FIELD_NUMBER = 10; + private boolean resilient_ = false; + + /** + * bool resilient = 10; + * + * @return The resilient. + */ + @java.lang.Override + public boolean getResilient() { + return resilient_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (schemaVersion_ != 0) { + output.writeInt32(1, schemaVersion_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(value_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, value_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(signature_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, signature_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(skinName_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, skinName_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(customHologram_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 5, customHologram_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 6, name_); + } + if (clickable_) { + output.writeBool(7, clickable_); + } + if (hideClickHologram_) { + output.writeBool(8, hideClickHologram_); + } + if (tunnelVision_) { + output.writeBool(9, tunnelVision_); + } + if (resilient_) { + output.writeBool(10, resilient_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (schemaVersion_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, schemaVersion_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(value_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, value_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(signature_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, signature_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(skinName_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, skinName_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(customHologram_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(5, customHologram_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(6, name_); + } + if (clickable_) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(7, clickable_); + } + if (hideClickHologram_) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(8, hideClickHologram_); + } + if (tunnelVision_) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(9, tunnelVision_); + } + if (resilient_) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(10, resilient_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Settings other)) { + return super.equals(obj); + } + + if (getSchemaVersion() + != other.getSchemaVersion()) return false; + if (!getValue() + .equals(other.getValue())) return false; + if (!getSignature() + .equals(other.getSignature())) return false; + if (!getSkinName() + .equals(other.getSkinName())) return false; + if (!getCustomHologram() + .equals(other.getCustomHologram())) return false; + if (!getName() + .equals(other.getName())) return false; + if (getClickable() + != other.getClickable()) return false; + if (getHideClickHologram() + != other.getHideClickHologram()) return false; + if (getTunnelVision() + != other.getTunnelVision()) return false; + if (getResilient() + != other.getResilient()) return false; + return getUnknownFields().equals(other.getUnknownFields()); + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SCHEMA_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getSchemaVersion(); + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + getValue().hashCode(); + hash = (37 * hash) + SIGNATURE_FIELD_NUMBER; + hash = (53 * hash) + getSignature().hashCode(); + hash = (37 * hash) + SKIN_NAME_FIELD_NUMBER; + hash = (53 * hash) + getSkinName().hashCode(); + hash = (37 * hash) + CUSTOM_HOLOGRAM_FIELD_NUMBER; + hash = (53 * hash) + getCustomHologram().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + CLICKABLE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getClickable()); + hash = (37 * hash) + HIDE_CLICK_HOLOGRAM_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getHideClickHologram()); + hash = (37 * hash) + TUNNEL_VISION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getTunnelVision()); + hash = (37 * hash) + RESILIENT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getResilient()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code dev.foxikle.customnpcs.internal.proto.Settings} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:dev.foxikle.customnpcs.internal.proto.Settings) + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.SettingsOrBuilder { + public static com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_fieldAccessorTable + .ensureFieldAccessorsInitialized( + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.class, dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.Builder.class); + } + + // Construct using dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + schemaVersion_ = 0; + value_ = ""; + signature_ = ""; + skinName_ = ""; + customHologram_ = ""; + name_ = ""; + clickable_ = false; + hideClickHologram_ = false; + tunnelVision_ = false; + resilient_ = false; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getDefaultInstanceForType() { + return dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance(); + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings build() { + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings buildPartial() { + dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings result = new dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.schemaVersion_ = schemaVersion_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.value_ = value_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.signature_ = signature_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.skinName_ = skinName_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.customHologram_ = customHologram_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.clickable_ = clickable_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.hideClickHologram_ = hideClickHologram_; + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.tunnelVision_ = tunnelVision_; + } + if (((from_bitField0_ & 0x00000200) != 0)) { + result.resilient_ = resilient_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings) { + return mergeFrom((dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings other) { + if (other == dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings.getDefaultInstance()) + return this; + if (other.getSchemaVersion() != 0) { + setSchemaVersion(other.getSchemaVersion()); + } + if (!other.getValue().isEmpty()) { + value_ = other.value_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getSignature().isEmpty()) { + signature_ = other.signature_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (!other.getSkinName().isEmpty()) { + skinName_ = other.skinName_; + bitField0_ |= 0x00000008; + onChanged(); + } + if (!other.getCustomHologram().isEmpty()) { + customHologram_ = other.customHologram_; + bitField0_ |= 0x00000010; + onChanged(); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000020; + onChanged(); + } + if (other.getClickable()) { + setClickable(other.getClickable()); + } + if (other.getHideClickHologram()) { + setHideClickHologram(other.getHideClickHologram()); + } + if (other.getTunnelVision()) { + setTunnelVision(other.getTunnelVision()); + } + if (other.getResilient()) { + setResilient(other.getResilient()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + schemaVersion_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + value_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: { + signature_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: { + skinName_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: { + customHologram_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000020; + break; + } // case 50 + case 56: { + clickable_ = input.readBool(); + bitField0_ |= 0x00000040; + break; + } // case 56 + case 64: { + hideClickHologram_ = input.readBool(); + bitField0_ |= 0x00000080; + break; + } // case 64 + case 72: { + tunnelVision_ = input.readBool(); + bitField0_ |= 0x00000100; + break; + } // case 72 + case 80: { + resilient_ = input.readBool(); + bitField0_ |= 0x00000200; + break; + } // case 80 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int schemaVersion_; + + /** + * int32 schema_version = 1; + * + * @return The schemaVersion. + */ + @java.lang.Override + public int getSchemaVersion() { + return schemaVersion_; + } + + /** + * int32 schema_version = 1; + * + * @param value The schemaVersion to set. + * @return This builder for chaining. + */ + public Builder setSchemaVersion(int value) { + + schemaVersion_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * int32 schema_version = 1; + * + * @return This builder for chaining. + */ + public Builder clearSchemaVersion() { + bitField0_ = (bitField0_ & ~0x00000001); + schemaVersion_ = 0; + onChanged(); + return this; + } + + private java.lang.Object value_ = ""; + + /** + * string value = 2; + * + * @return The value. + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + value_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string value = 2; + * + * @return The bytes for value. + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string value = 2; + * + * @param value The value to set. + * @return This builder for chaining. + */ + public Builder setValue( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + value_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * string value = 2; + * + * @return This builder for chaining. + */ + public Builder clearValue() { + value_ = getDefaultInstance().getValue(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * string value = 2; + * + * @param value The bytes for value to set. + * @return This builder for chaining. + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + value_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object signature_ = ""; + + /** + * string signature = 3; + * + * @return The signature. + */ + public java.lang.String getSignature() { + java.lang.Object ref = signature_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + signature_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string signature = 3; + * + * @return The bytes for signature. + */ + public com.google.protobuf.ByteString + getSignatureBytes() { + java.lang.Object ref = signature_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + signature_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string signature = 3; + * + * @param value The signature to set. + * @return This builder for chaining. + */ + public Builder setSignature( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + signature_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * string signature = 3; + * + * @return This builder for chaining. + */ + public Builder clearSignature() { + signature_ = getDefaultInstance().getSignature(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * string signature = 3; + * + * @param value The bytes for signature to set. + * @return This builder for chaining. + */ + public Builder setSignatureBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + signature_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private java.lang.Object skinName_ = ""; + + /** + * string skin_name = 4; + * + * @return The skinName. + */ + public java.lang.String getSkinName() { + java.lang.Object ref = skinName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + skinName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string skin_name = 4; + * + * @return The bytes for skinName. + */ + public com.google.protobuf.ByteString + getSkinNameBytes() { + java.lang.Object ref = skinName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + skinName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string skin_name = 4; + * + * @param value The skinName to set. + * @return This builder for chaining. + */ + public Builder setSkinName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + skinName_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * string skin_name = 4; + * + * @return This builder for chaining. + */ + public Builder clearSkinName() { + skinName_ = getDefaultInstance().getSkinName(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * string skin_name = 4; + * + * @param value The bytes for skinName to set. + * @return This builder for chaining. + */ + public Builder setSkinNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + skinName_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + private java.lang.Object customHologram_ = ""; + + /** + * string custom_hologram = 5; + * + * @return The customHologram. + */ + public java.lang.String getCustomHologram() { + java.lang.Object ref = customHologram_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + customHologram_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string custom_hologram = 5; + * + * @return The bytes for customHologram. + */ + public com.google.protobuf.ByteString + getCustomHologramBytes() { + java.lang.Object ref = customHologram_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + customHologram_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string custom_hologram = 5; + * + * @param value The customHologram to set. + * @return This builder for chaining. + */ + public Builder setCustomHologram( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + customHologram_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * string custom_hologram = 5; + * + * @return This builder for chaining. + */ + public Builder clearCustomHologram() { + customHologram_ = getDefaultInstance().getCustomHologram(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + /** + * string custom_hologram = 5; + * + * @param value The bytes for customHologram to set. + * @return This builder for chaining. + */ + public Builder setCustomHologramBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + customHologram_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + + /** + * string name = 6; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string name = 6; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string name = 6; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * string name = 6; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + return this; + } + + /** + * string name = 6; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + private boolean clickable_; + + /** + * bool clickable = 7; + * + * @return The clickable. + */ + @java.lang.Override + public boolean getClickable() { + return clickable_; + } + + /** + * bool clickable = 7; + * + * @param value The clickable to set. + * @return This builder for chaining. + */ + public Builder setClickable(boolean value) { + + clickable_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * bool clickable = 7; + * + * @return This builder for chaining. + */ + public Builder clearClickable() { + bitField0_ = (bitField0_ & ~0x00000040); + clickable_ = false; + onChanged(); + return this; + } + + private boolean hideClickHologram_; + + /** + * bool hide_click_hologram = 8; + * + * @return The hideClickHologram. + */ + @java.lang.Override + public boolean getHideClickHologram() { + return hideClickHologram_; + } + + /** + * bool hide_click_hologram = 8; + * + * @param value The hideClickHologram to set. + * @return This builder for chaining. + */ + public Builder setHideClickHologram(boolean value) { + + hideClickHologram_ = value; + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * bool hide_click_hologram = 8; + * + * @return This builder for chaining. + */ + public Builder clearHideClickHologram() { + bitField0_ = (bitField0_ & ~0x00000080); + hideClickHologram_ = false; + onChanged(); + return this; + } + + private boolean tunnelVision_; + + /** + * bool tunnel_vision = 9; + * + * @return The tunnelVision. + */ + @java.lang.Override + public boolean getTunnelVision() { + return tunnelVision_; + } + + /** + * bool tunnel_vision = 9; + * + * @param value The tunnelVision to set. + * @return This builder for chaining. + */ + public Builder setTunnelVision(boolean value) { + + tunnelVision_ = value; + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * bool tunnel_vision = 9; + * + * @return This builder for chaining. + */ + public Builder clearTunnelVision() { + bitField0_ = (bitField0_ & ~0x00000100); + tunnelVision_ = false; + onChanged(); + return this; + } + + private boolean resilient_; + + /** + * bool resilient = 10; + * + * @return The resilient. + */ + @java.lang.Override + public boolean getResilient() { + return resilient_; + } + + /** + * bool resilient = 10; + * + * @param value The resilient to set. + * @return This builder for chaining. + */ + public Builder setResilient(boolean value) { + + resilient_ = value; + bitField0_ |= 0x00000200; + onChanged(); + return this; + } + + /** + * bool resilient = 10; + * + * @return This builder for chaining. + */ + public Builder clearResilient() { + bitField0_ = (bitField0_ & ~0x00000200); + resilient_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:dev.foxikle.customnpcs.internal.proto.Settings) + } + + // @@protoc_insertion_point(class_scope:dev.foxikle.customnpcs.internal.proto.Settings) + private static final dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings(); + } + + public static dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Settings parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public dev.foxikle.customnpcs.internal.proto.SettingsOuterClass.Settings getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor; + private static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + + private static final com.google.protobuf.Descriptors.FileDescriptor + descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\016settings.proto\022%dev.foxikle.customnpcs" + + ".internal.proto\"\330\001\n\010Settings\022\026\n\016schema_v" + + "ersion\030\001 \001(\005\022\r\n\005value\030\002 \001(\t\022\021\n\tsignature" + + "\030\003 \001(\t\022\021\n\tskin_name\030\004 \001(\t\022\027\n\017custom_holo" + + "gram\030\005 \001(\t\022\014\n\004name\030\006 \001(\t\022\021\n\tclickable\030\007 " + + "\001(\010\022\033\n\023hide_click_hologram\030\010 \001(\010\022\025\n\rtunn" + + "el_vision\030\t \001(\010\022\021\n\tresilient\030\n \001(\010b\006prot" + + "o3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{ + }); + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_dev_foxikle_customnpcs_internal_proto_Settings_descriptor, + new java.lang.String[]{"SchemaVersion", "Value", "Signature", "SkinName", "CustomHologram", "Name", "Clickable", "HideClickHologram", "TunnelVision", "Resilient",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java new file mode 100644 index 00000000..e1a05754 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.storage; + +import org.jetbrains.annotations.ApiStatus; + +@ApiStatus.Internal +public interface StorageProvider { + void init(); + + boolean save(byte[] data); + + byte[] load(); + + void shutdown(); +} diff --git a/proto/action.proto b/proto/action.proto new file mode 100644 index 00000000..d19f4796 --- /dev/null +++ b/proto/action.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +// action doesn't need migration versions as thats handled by each individual action +message Action { + string serialized_data = 1; +} \ No newline at end of file diff --git a/proto/equipment.proto b/proto/equipment.proto new file mode 100644 index 00000000..43cfc594 --- /dev/null +++ b/proto/equipment.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +import "item.proto"; +message Equipment { + int32 schema_version = 1; + + Item main_hand = 2; + Item off_hand = 3; + Item head = 4; + Item chest = 5; + Item legs = 6; + Item feet = 7; +} \ No newline at end of file diff --git a/proto/item.proto b/proto/item.proto new file mode 100644 index 00000000..ab50eedc --- /dev/null +++ b/proto/item.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +// doesn't need a migrations field as that is already handled by Paper's itemstack serialization +message Item { + // byte array + bytes serialized = 1; +} \ No newline at end of file diff --git a/proto/location.proto b/proto/location.proto new file mode 100644 index 00000000..869b4f0f --- /dev/null +++ b/proto/location.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +message Location { + int32 schema_version = 1; + + string world = 2; + + double x = 3; + double y = 4; + double z = 5; + + float pitch = 6; + float yaw = 7; +} \ No newline at end of file diff --git a/proto/npc.proto b/proto/npc.proto new file mode 100644 index 00000000..9c287527 --- /dev/null +++ b/proto/npc.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package dev.foxikle.customnpcs.internal.proto; + +import "action.proto"; +import "location.proto"; +import "equipment.proto"; +import "settings.proto"; + +// DO NOT EVER CHANGE THE INDICIES +message Npc { + // for migrations + int32 schema_version = 1; + repeated Action actions = 2; + Location location = 3; + Settings settings = 4; + Equipment equipment = 5; + string uuid = 6; +} \ No newline at end of file diff --git a/proto/npc_list.proto b/proto/npc_list.proto new file mode 100644 index 00000000..cee511b9 --- /dev/null +++ b/proto/npc_list.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +import "npc.proto"; + +// This is the data that gets stored in a file or database somewhere, +message NpcList { + repeated Npc npcs = 1; +} \ No newline at end of file diff --git a/proto/settings.proto b/proto/settings.proto new file mode 100644 index 00000000..3f2d556d --- /dev/null +++ b/proto/settings.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package dev.foxikle.customnpcs.internal.proto; + +message Settings { + int32 schema_version = 1; + + string value = 2; + string signature = 3; + string skin_name = 4; + string custom_hologram = 5; + string name = 6; + + bool clickable = 7; + bool hide_click_hologram = 8; + bool tunnel_vision = 9; + bool resilient = 10; +} \ No newline at end of file From 2f86b7cdea67640724490cb50f92febaed09dfe4 Mon Sep 17 00:00:00 2001 From: foxikle Date: Thu, 16 Jan 2025 21:39:36 -0500 Subject: [PATCH 07/25] load protobuf at runtime --- .../main/java/dev/foxikle/customnpcs/internal/NpcLoading.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/NpcLoading.java b/core/src/main/java/dev/foxikle/customnpcs/internal/NpcLoading.java index 0531c4da..3096ab49 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/NpcLoading.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/NpcLoading.java @@ -54,6 +54,7 @@ public void classloader(@NotNull PluginClasspathBuilder classpathBuilder) { resolver.addDependency(new Dependency(new DefaultArtifact("com.github.Mqzn:Lotus:1.4.1"), null)); resolver.addDependency(new Dependency(new DefaultArtifact("dev.velix:imperat-core:1.3.2"), null)); resolver.addDependency(new Dependency(new DefaultArtifact("dev.velix:imperat-bukkit:1.3.2"), null)); + resolver.addDependency(new Dependency(new DefaultArtifact("com.google.protobuf:protobuf-java:4.29.2"), null)); classpathBuilder.addLibrary(resolver); } From 056567bbb5abf053c1d36d8f788d08b23accd71c Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 15:58:33 -0400 Subject: [PATCH 08/25] Import the right chart --- .../main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java index 5336a0d5..53b7dca7 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java @@ -55,7 +55,7 @@ import lombok.extern.slf4j.Slf4j; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bstats.bukkit.Metrics; -import org.bstats.charts.MultiLineChart; +import org.bstats.charts.AdvancedPie; import org.bstats.charts.SimplePie; import org.bukkit.Bukkit; import org.bukkit.Location; From 048297479b8c07407ece91d8431877482d48ed78 Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 20:02:35 -0400 Subject: [PATCH 09/25] Remove old file manager --- .../customnpcs/internal/FileManager.java | 670 ------------------ 1 file changed, 670 deletions(-) delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java deleted file mode 100644 index 2c0d6b05..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java +++ /dev/null @@ -1,670 +0,0 @@ -/* - * Copyright (c) 2024. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.internal; - -import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.ActionType; -import dev.foxikle.customnpcs.actions.LegacyAction; -import dev.foxikle.customnpcs.actions.conditions.Condition; -import dev.foxikle.customnpcs.data.Equipment; -import dev.foxikle.customnpcs.data.Settings; -import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; -import dev.foxikle.customnpcs.internal.utils.Utils; -import lombok.Getter; -import lombok.SneakyThrows; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.YamlConfiguration; -import org.jetbrains.annotations.Nullable; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.time.Instant; -import java.util.*; -import java.util.logging.Level; - -/** - * The class that deals with all file related things - */ -@SuppressWarnings("unused") -public class FileManager { - - /** - * The config file version - */ - public static final int CONFIG_FILE_VERSION = 6; - /** - * The file version of the npcs.yml file - */ - public static final double NPC_FILE_VERSION = 1.6; - public static File PARENT_DIRECTORY = new File("plugins/CustomNPCs/"); - @Getter - private final Map brokenNPCs = new HashMap<>(); - @Getter - private final List validNPCs = new ArrayList<>(); - private final CustomNPCs plugin; - - /** - *

Gets the file manager object. - *

- * - * @param plugin The instance of the Main class - */ - public FileManager(CustomNPCs plugin) { - this.plugin = plugin; - } - - /** - *

Creates the files the plugin needs to run - *

- * - * @return if creating the files was successful - */ - public boolean createFiles() { - if (!new File(PARENT_DIRECTORY, "/npcs.yml").exists()) { - plugin.saveResource("npcs.yml", false); - } - if (!new File(PARENT_DIRECTORY, "config.yml").exists()) { - plugin.saveResource("config.yml", false); - return true; - } - // config - { - File file = new File(PARENT_DIRECTORY, "config.yml"); - YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); - - if (!yml.contains("Skins")) { - BackupResult br = createBackup(file); - if (br.success) { - plugin.getLogger().warning("The config is irreparably damaged! Resetting config. Your old config was saved to the file \"" + br.filePath.toString() + "\""); - plugin.saveResource("config.yml", true); - } - } - int version = yml.getInt("CONFIG_VERSION"); - - if (version < 6) { - BackupResult br = createBackup(file); - if (!br.success()) { - throw new RuntimeException("Failed to create a backup of the config file before updating it!"); - } else { - plugin.getLogger().info("Created backup of config.yml before updating it! A copy of your existing config was saved to " + br.filePath().toString()); - } - } - - if (version == 0) { // doesn't exist? - plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 1)); - yml.set("CONFIG_VERSION", 1); - yml.setComments("CONFIG_VERSION", List.of(" DO NOT, under ANY circumstances modify the 'CONFIG_VERSION' field. Doing so can cause catastrophic data loss.", "")); - yml.set("ClickText", "&e&lCLICK"); - yml.setComments("ClickText", List.of("ClickText -> The hologram displayed above the NPC if it is interactable", " NOTE: Due to Minecraft limitations, this cannot be more than 16 characters INCLUDING color and format codes.", " (But not the &)", "")); - yml.set("DisplayClickText", true); - yml.setComments("DisplayClickText", List.of(" DisplayClickText -> Should the plugin display a hologram above the NPC's head if it is interactable?", "")); - try { - yml.save(file); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - if (version < 2) { // prior to 1.4-pre2 - plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 2)); - yml.set("CONFIG_VERSION", 2); - yml.set("AlertOnUpdate", true); - try { - yml.save(file); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - if (version < 3) { // prior to 1.5.2-pre1 - plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 3)); - yml.set("CONFIG_VERSION", 3); - yml.set("ClickText", plugin.getMiniMessage().serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(Objects.requireNonNull(yml.getString("ClickText"))))); - try { - yml.save(file); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - if (version < 4) { //prior to 1.6-pre2 - plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 4)); - yml.set("CONFIG_VERSION", 4); - yml.set("DisableCollisions", true); - try { - yml.save(file); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - if (version < 5) { - plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 5)); - yml.set("CONFIG_VERSION", 5); - yml.set("NameReferenceMessages", true); - try { - yml.save(file); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - if (version < 6) { - plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 6)); - yml.set("CONFIG_VERSION", 6); - yml.set("InjectionDistance", 48); - yml.set("InjectionInterval", 10); - yml.set("HologramUpdateInterval", 200); - yml.set("LookInterval", 5); - try { - yml.save(file); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - if (version < 7) { - plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 7)); - yml.set("CONFIG_VERSION", 7); - yml.set("DefaultInterpolationDuration", 5); - yml.setComments("DefaultInterpolationDuration", List.of("DefaultInterpolationDuration -> How long should moving NPCs interpolate their Nametags moving?")); - try { - yml.save(file); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - - // npcs - { - boolean changed = false; - File file = new File(PARENT_DIRECTORY, "npcs.yml"); - - YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); - - - String version = yml.getString("version"); - - - if (version == null) { // Config is from before 1.3-pre4 - plugin.getLogger().warning("Old NPC file version found! Bumping version! (unknown version -> 1.3)"); - BackupResult br = createBackup(file); - if (!br.success) { - plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); - return false; - } - yml.set("version", "1.3"); - version = "1.3"; - - plugin.getLogger().warning("Adding delay to old actions."); - for (UUID u : getNPCIds()) { - ConfigurationSection s = yml.getConfigurationSection(u.toString()); - assert s != null; - List strings = s.getStringList("actions"); - List convertedActions = new ArrayList<>(); - for (String string : strings) { - List split = Utils.list(string.split("%::%")); - String sub = split.get(0); - split.remove(0); - int delay = 0; - LegacyAction actionImpl = new LegacyAction(ActionType.valueOf(sub), split, delay, Condition.SelectionMode.ONE, new ArrayList<>()); - convertedActions.add(actionImpl.toJson()); - } - s.set("actions", convertedActions); - } - // save after adding actions - try { - yml.save(file); - } catch (IOException e) { - plugin.getLogger().log(Level.SEVERE, "An error occurred saving the npcs.yml file after saving a list of converted actions. Please report the following stacktrace to Foxikle.", e); - } - } - - if (version.equalsIgnoreCase("1.3")) { - plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.3-> 1.4)"); - BackupResult br = createBackup(file); - if (!br.success) { - plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); - return false; - } - yml.set("version", "1.4"); - version = "1.4"; - - Set npcs = yml.getKeys(false); - for (String npc : npcs) { - if (npc.equals("version")) continue; // it's a key - ConfigurationSection section = yml.getConfigurationSection(npc); - - plugin.getLogger().warning("Old Actions found. Converting to json."); - List legacyActions = section.getStringList("actions"); - List newActions = new ArrayList<>(); - legacyActions.forEach(s -> { - if (s != null) { - LegacyAction a = LegacyAction.of(s); // going to be converted the old way - if (a != null) { - newActions.add(a.toJson()); - } - } - }); - section.set("actions", newActions); - try { - yml.save(file); - } catch (IOException e) { - plugin.getLogger().severe("An error occurred whilst saving the converted actions. Please report the following stacktrace to Foxikle. \n" + Arrays.toString(e.getStackTrace())); - } - } - } - - if (version.equalsIgnoreCase("1.4")) { - plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.4 -> 1.5)"); - BackupResult br = createBackup(file); - if (!br.success) { - plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); - return false; - } - - yml.set("version", "1.5"); - version = "1.5"; - - Set npcs = yml.getKeys(false); - for (String npc : npcs) { - if (npc.equals("version")) continue; // it's a key - ConfigurationSection section = yml.getConfigurationSection(npc); - - section.set("tunnelvision", false); - try { - yml.save(file); - } catch (IOException e) { - plugin.getLogger().severe("An error occurred whilst saving the tunelvision status to the config. Please report the following stacktrace to Foxikle. \n" + Arrays.toString(e.getStackTrace())); - } - } - } - - if (version.equalsIgnoreCase("1.5")) { - plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.5-> 1.6)"); - BackupResult br = createBackup(file); - if (!br.success) { - plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); - return false; - } - - yml.set("version", "1.6"); - version = "1.6"; - Set npcs = yml.getKeys(false); - for (String npc : npcs) { - if (npc.equals("version")) continue; // it's a key - ConfigurationSection section = yml.getConfigurationSection(npc); - - section.set("customHologram", false); - section.set("hideInteractableHologram", ""); - try { - yml.save(file); - } catch (IOException e) { - plugin.getLogger().severe("An error occurred whilst saving the tunelvision status to the config. Please report the following stacktrace to Foxikle. \n" + Arrays.toString(e.getStackTrace())); - } - } - } - - if (version.equals("1.6")) { - plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.6 -> 1.7)"); - BackupResult br = createBackup(file); - if (!br.success) { - plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); - return false; - } - yml.set("version", "1.7"); - version = "1.7"; - - Set npcs = yml.getKeys(false); - for (String npc : npcs) { - if (npc.equals("version")) continue; // its a key - ConfigurationSection section = yml.getConfigurationSection(npc); - - // convert actions to new format - List actionStrs = section.getStringList("actions"); - List list = new ArrayList<>(); - for (String actionStr : actionStrs) { - LegacyAction a = LegacyAction.of(actionStr); - if (a == null) { - plugin.getLogger().warning("Found an invalid action in the config. Please report the following action string to Foxikle. \n" + actionStr); - continue; - } - if (a.getActionType() == ActionType.TOGGLE_FOLLOWING) { - plugin.getLogger().warning("Found an action of the type `TOGGLE_FOLLOWING`. This action has been removed in 1.7."); - continue; - } - - list.add(a.toAction()); - } - - List newActions = new ArrayList<>(); - - for (Action a : list) { - if (a == null) { - plugin.getLogger().warning("Found an invalid action in the config."); - continue; - } - newActions.add(a.serialize()); - } - - section.set("actions", newActions); - } - try { - yml.save(file); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - // After 1.7-pre6 - if (version.equals("1.7")) { - plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.7 -> 1.8)"); - BackupResult br = createBackup(file); - if (!br.success) { - plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); - return false; - } - yml.set("version", "1.8"); - - Set npcs = yml.getKeys(false); - for (String npc : npcs) { - if (npc.equals("version")) continue; // its a key - ConfigurationSection section = yml.getConfigurationSection(npc); - - assert section != null : "Section is null -- Upgrading NPC file from 1.7 to 1.8"; - - double dir = section.getDouble("direction"); - Location loc = section.getLocation("location"); - assert loc != null : "Location is null -- Upgrading NPC file from 1.7 to 1.8"; - loc.setYaw((float) dir); - - section.set("location", loc); // update the location - section.set("direction", null); // remove the direction field - } - try { - yml.save(file); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - - // check for valid NPCs: - boolean found = false; - Set npcs = yml.getKeys(false); - for (String npc : npcs) { - if (npc.equals("version")) continue; // not an NPC uuid - ConfigurationSection section = yml.getConfigurationSection(npc); - boolean err = false; - boolean exists = false; - UUID uuid = UUID.fromString(npc); - - try { - var sec = section.getLocation("location"); - exists = sec != null; - } catch (Exception e) { - err = true; - } - - if (err || !exists) { - found = true; - String rawName = plugin.getMiniMessage().stripTags(section.getString("name")); - brokenNPCs.put(UUID.fromString(npc), rawName); - } else { - validNPCs.add(UUID.fromString(npc)); - } - } - if (found) printInvalidConfig(); - } - - return true; - } - - /** - *

Adds an NPC to the `npcs.yml` file. - *

- * - * @param npc The NPC to store - */ - public void addNPC(InternalNpc npc) { - File file = new File("plugins/CustomNPCs/npcs.yml"); - YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); - yml.createSection(npc.getUniqueID().toString()); - ConfigurationSection section = yml.getConfigurationSection(npc.getUniqueID().toString()); - - List actions = new ArrayList<>(); - npc.getActions().forEach(action -> actions.add(action.serialize())); - assert section != null; - section.addDefault("value", npc.getSettings().getValue()); - section.addDefault("signature", npc.getSettings().getSignature()); - section.addDefault("skin", npc.getSettings().getSkinName()); - section.addDefault("clickable", npc.getSettings().isInteractable()); - section.addDefault("customHologram", npc.getSettings().getCustomInteractableHologram()); - section.addDefault("hideInteractableHologram", npc.getSettings().isHideClickableHologram()); - section.addDefault("location", npc.getSpawnLoc()); - section.addDefault("actions", actions); - section.addDefault("handItem", npc.getEquipment().getHand()); - section.addDefault("offhandItem", npc.getEquipment().getOffhand()); - section.addDefault("headItem", npc.getEquipment().getHead()); - section.addDefault("chestItem", npc.getEquipment().getChest()); - section.addDefault("legsItem", npc.getEquipment().getLegs()); - section.addDefault("feetItem", npc.getEquipment().getBoots()); - section.addDefault("name", npc.getSettings().getName()); - section.addDefault("world", npc.getWorld().getName()); - section.addDefault("tunnelvision", npc.getSettings().isTunnelvision()); - yml.options().copyDefaults(true); - try { - yml.save(file); - } catch (IOException e) { - plugin.getLogger().log(Level.SEVERE, "An error occurred saving the npcs.yml file after creating a new section. Please report the following stacktrace to Foxikle.", e); - } - } - - /** - *

Gets the NPC of the specified UUID - *

- * - * @param uuid The NPC to load from the file - */ - public void loadNPC(UUID uuid) { - File file = new File("plugins/CustomNPCs/npcs.yml"); - YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); - ConfigurationSection section = yml.getConfigurationSection(uuid.toString()); - if (section == null) throw new IllegalArgumentException("NPC uuid cannot be null."); - List actionImpls = new ArrayList<>(); - List actions; - - if (section.getConfigurationSection("actions") == null) { // meaning it does not exist - if (section.getString("command") != null) { // if there is a legacy command - Bukkit.getLogger().info("Converting legacy commands to Actions."); - String command = section.getString("command"); - assert command != null; - LegacyAction actionImpl = new LegacyAction(ActionType.RUN_COMMAND, Utils.list(command.split(" ")), 0, Condition.SelectionMode.ONE, new ArrayList<>()); - actionImpls.add(actionImpl); - section.set("actions", actionImpls); - section.set("command", null); - try { - yml.save(file); - } catch (IOException e) { - plugin.getLogger().log(Level.SEVERE, "An error occurred saving the npcs.yml file after converting legacy commands to actions. Please report the following stacktrace to Foxikle.", e); - } - } - } - if (Objects.requireNonNull(section.getString("name")).contains("§")) { - section.set("name", plugin.getMiniMessage().serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(Objects.requireNonNull(section.getString("name")).replace("§", "&")))); - try { - yml.save(file); - } catch (IOException e) { - plugin.getLogger().log(Level.SEVERE, "An error occurred saving the npcs.yml file after converting legacy names to minimessage. Please report the following stacktrace to Foxikle.", e); - } - } - - String rawName = plugin.getMiniMessage().stripTags(section.getString("name")); - World world; - try { - world = Bukkit.getWorld(Objects.requireNonNull(section.getString("world"))); - } catch (IllegalArgumentException ex) { - printInvalidConfig(); - brokenNPCs.put(uuid, rawName); - return; - } - - Location location; - try { - location = section.getLocation("location"); - } catch (Exception ex) { - brokenNPCs.put(uuid, rawName); - printInvalidConfig(); - return; - } - - if (world == null) { - printInvalidConfig(); - brokenNPCs.put(uuid, rawName); - return; - } - - if (location == null) { - printInvalidConfig(); - brokenNPCs.put(uuid, rawName); - return; - } - - - // use the actions freshly converted - - actions = new ArrayList<>(); - for (String s : section.getStringList("actions")) { - actions.add(Action.parse(s)); - } - - InternalNpc npc = plugin.createNPC( - world, - location, - new Equipment( - section.getItemStack("headItem"), - section.getItemStack("chestItem"), - section.getItemStack("legsItem"), - section.getItemStack("feetItem"), - section.getItemStack("handItem"), - section.getItemStack("offhandItem") - ), new Settings( - section.getBoolean("clickable"), - section.getBoolean("tunnelvision"), - true, - section.getString("value"), - section.getString("signature"), - section.getString("skin"), - section.getString("name"), - section.getString("customHologram"), - section.getBoolean("hideInteractableHologram") - ), uuid, null, actions); - if (npc != null) { - npc.createNPC(); - } else { - plugin.getLogger().severe("The NPC '{name}' could not be created!".replace("{name}", Objects.requireNonNull(section.getString("name")))); - } - } - - @Nullable - public YamlConfiguration getNpcYaml() { - File file = new File(PARENT_DIRECTORY, "npcs.yml"); - return YamlConfiguration.loadConfiguration(file); - } - - @SneakyThrows - public void saveNpcFile(YamlConfiguration section) { - File file = new File(PARENT_DIRECTORY, "npcs.yml"); - section.save(file); - } - - /** - *

Gets the set of stored UUIDs. - *

- * - * @return the set of stored NPC uuids. - */ - public Set getNPCIds() { - File file = new File("plugins/CustomNPCs/npcs.yml"); - YamlConfiguration yml; - try { - yml = YamlConfiguration.loadConfiguration(file); - } catch (Exception ex) { - printInvalidConfig(); - return new HashSet<>(); - } - Set uuids = new HashSet<>(); - for (String str : yml.getKeys(false)) { - if (!str.equalsIgnoreCase("version")) - uuids.add(UUID.fromString(str)); - } - return uuids; - } - - /** - *

Removes the specified NPC from storage - *

- * - * @param uuid The NPC uuid to remove - */ - public void remove(UUID uuid) { - File file = new File("plugins/CustomNPCs/npcs.yml"); - YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); - yml.set(uuid.toString(), null); - try { - yml.save(file); - } catch (IOException e) { - plugin.getLogger().log(Level.SEVERE, "An error occurred saving the npcs.yml file after removing an npc. Please report the following stacktrace to Foxikle.", e); - } - } - - private BackupResult createBackup(File file) { - YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); - File f = new File(PARENT_DIRECTORY, new Date().toString().replace(" ", "_").replace(":", "_") + "_backup_of_" + file.getName() + Instant.now().hashCode()); - try { - if (f.createNewFile()) { - yml.save(f); - } else { - throw new RuntimeException("A duplicate file of file '" + f.getName() + "' exists! This means the plugin attempted to back up the file '" + file.getName() + "' multiple times within this millisecond! This is a serious issue that should be reported to @foxikle on discord!"); - } - } catch (IOException e) { - plugin.getLogger().log(Level.SEVERE, "An error occurred whilst creating a backup of the file '" + file.getName() + "'", e); - return new BackupResult(null, false); - } - return new BackupResult(f.toPath(), true); - } - - private void printInvalidConfig() { - plugin.getLogger().severe(""); - plugin.getLogger().severe("+------------------------------------------------------------------------------+"); - plugin.getLogger().severe("| NPC with an invalid configuration detected! |"); - plugin.getLogger().severe("| ** THIS IS NOT AN ERROR WITH CUSTOMNPCS ** |"); - plugin.getLogger().severe("| This is most likely a configuration error as a result of |"); - plugin.getLogger().severe("| modifying the `npcs.yml` file. |"); - plugin.getLogger().severe("+------------------------------------------------------------------------------+"); - plugin.getLogger().severe(""); - } - - private record BackupResult(Path filePath, boolean success) { - } -} From 0e5cd34c1b3f26f7d6d0cd9865a3b579892dc64a Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 20:02:59 -0400 Subject: [PATCH 10/25] chore: direction & storage manager --- .../java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java | 4 ++-- .../java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java | 4 ++-- .../java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java | 4 ++-- .../java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java | 4 ++-- .../java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java | 4 ++-- .../java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java | 4 ++-- .../java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java index 6502f6eb..7f4955e3 100644 --- a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java +++ b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java @@ -195,7 +195,7 @@ public void createNPC() { ((CraftPlayer) player).getHandle().connection.send(teamPacket); }), 1, 5).getTaskId(); - if (settings.isResilient()) plugin.getFileManager().addNPC(this); + if (settings.isResilient()) plugin.getStorageManager().addNPC(this); plugin.addNPC(this, hologram); injectionManager = new InjectionManager(plugin, this); @@ -530,7 +530,7 @@ public void moveTo(Location v) { */ @Override public void delete() { - plugin.getFileManager().remove(this.uuid); + plugin.getStorageManager().remove(this.uuid); } @Override diff --git a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java index 4c693d54..3c07a069 100644 --- a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java +++ b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java @@ -194,7 +194,7 @@ public void createNPC() { ((CraftPlayer) player).getHandle().connection.send(teamPacket); }), 1, 5).getTaskId(); - if (settings.isResilient()) plugin.getFileManager().addNPC(this); + if (settings.isResilient()) plugin.getStorageManager().addNPC(this); plugin.addNPC(this, hologram); injectionManager = new InjectionManager(plugin, this); @@ -507,7 +507,7 @@ public void moveTo(Location v) { *

*/ public void delete() { - plugin.getFileManager().remove(this.uuid); + plugin.getStorageManager().remove(this.uuid); } @Override diff --git a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java index c200b740..915afb14 100644 --- a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java +++ b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java @@ -198,7 +198,7 @@ public void createNPC() { }); }, 1, 5).getTaskId(); - if (settings.isResilient()) plugin.getFileManager().addNPC(this); + if (settings.isResilient()) plugin.getStorageManager().addNPC(this); plugin.addNPC(this, hologram); injectionManager = new InjectionManager(plugin, this); @@ -512,7 +512,7 @@ public void moveTo(Location v) { *

*/ public void delete() { - plugin.getFileManager().remove(this.uuid); + plugin.getStorageManager().remove(this.uuid); } @Override diff --git a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java index eb308484..da4c9cac 100644 --- a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java +++ b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java @@ -210,7 +210,7 @@ public void createNPC() { ((CraftPlayer) player).getHandle().connection.send(teamPacket); }), 1, 5).getTaskId(); - if (settings.isResilient()) plugin.getFileManager().addNPC(this); + if (settings.isResilient()) plugin.getStorageManager().addNPC(this); plugin.addNPC(this, hologram); injectionManager = new InjectionManager(plugin, this); @@ -533,7 +533,7 @@ public void moveTo(Location v) { *

*/ public void delete() { - plugin.getFileManager().remove(this.uuid); + plugin.getStorageManager().remove(this.uuid); } @Override diff --git a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java index d6b4dabf..9ff534a9 100644 --- a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java +++ b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java @@ -209,7 +209,7 @@ public void createNPC() { ((CraftPlayer) player).getHandle().connection.send(teamPacket); }), 1, 5).getTaskId(); - if (settings.isResilient()) plugin.getFileManager().addNPC(this); + if (settings.isResilient()) plugin.getStorageManager().addNPC(this); plugin.addNPC(this, hologram); injectionManager = new InjectionManager(plugin, this); @@ -532,7 +532,7 @@ public void moveTo(Location v) { *

*/ public void delete() { - plugin.getFileManager().remove(this.uuid); + plugin.getStorageManager().remove(this.uuid); } @Override diff --git a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java index 1a4f8be0..46faff28 100644 --- a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java +++ b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java @@ -211,7 +211,7 @@ public void createNPC() { ((CraftPlayer) player).getHandle().connection.send(teamPacket); }), 1, 5).getTaskId(); - if (settings.isResilient()) plugin.getFileManager().addNPC(this); + if (settings.isResilient()) plugin.getStorageManager().addNPC(this); plugin.addNPC(this, hologram); injectionManager = new InjectionManager(plugin, this); @@ -532,7 +532,7 @@ public void moveTo(Location v) { *

*/ public void delete() { - plugin.getFileManager().remove(this.uuid); + plugin.getStorageManager().remove(this.uuid); } @Override diff --git a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java index bef7c89e..fff45dea 100644 --- a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java +++ b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java @@ -215,7 +215,7 @@ public void createNPC() { }); }, 1, 5).getTaskId(); - if (settings.isResilient()) plugin.getFileManager().addNPC(this); + if (settings.isResilient()) plugin.getStorageManager().addNPC(this); plugin.addNPC(this, hologram); injectionManager = new InjectionManager(plugin, this); @@ -537,7 +537,7 @@ public void moveTo(Location v) { *

*/ public void delete() { - plugin.getFileManager().remove(this.uuid); + plugin.getStorageManager().remove(this.uuid); } @Override From 176ae29b3a07ac8846d8f224a19464684571f6d8 Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 20:09:24 -0400 Subject: [PATCH 11/25] New storage options --- build.gradle.kts | 3 + core/build.gradle.kts | 6 +- .../customnpcs/internal/NpcLoading.java | 9 +- .../internal/proto/ProtoWrapper.java | 34 +- .../internal/storage/FileStorage.java | 91 ++ .../internal/storage/MongoStorage.java | 130 +++ .../internal/storage/MysqlStorage.java | 154 ++++ .../internal/storage/StorageManager.java | 800 ++++++++++++++++++ .../internal/storage/StorageProvider.java | 26 +- 9 files changed, 1242 insertions(+), 11 deletions(-) create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/storage/FileStorage.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/storage/MongoStorage.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/storage/MysqlStorage.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java diff --git a/build.gradle.kts b/build.gradle.kts index 440bacc8..f3b9b07e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -128,6 +128,9 @@ tasks { shadowJar { archiveClassifier.set("") // This is used to place the file into a test server's plugin directory. + +// thanks, paper + relocate("com.google.protobuf", "dev.foxikle.libs.proto") destinationDirectory.set( file( providers.gradleProperty("plugin_dir").orElse(destinationDirectory.get().toString()) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index f1a60970..9405b787 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -22,6 +22,7 @@ plugins { id("java") + id("io.github.goooler.shadow") version "8.1.8" } repositories { @@ -40,9 +41,12 @@ dependencies { compileOnly("org.mineskin:java-client:1.2.4-SNAPSHOT") compileOnly("org.projectlombok:lombok:1.18.36") annotationProcessor("org.projectlombok:lombok:1.18.36") - compileOnly("com.google.protobuf:protobuf-java:4.29.2") compileOnly("dev.velix:imperat-core:1.7.1") compileOnly("dev.velix:imperat-bukkit:1.7.1") + implementation("com.google.protobuf:protobuf-java:4.29.2") + compileOnly("org.mongodb:mongodb-driver-sync:5.3.0") + compileOnly("com.mysql:mysql-connector-j:9.1.0") + compileOnly("com.zaxxer:HikariCP:6.2.1") } tasks { diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/NpcLoading.java b/core/src/main/java/dev/foxikle/customnpcs/internal/NpcLoading.java index 3096ab49..3461ed60 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/NpcLoading.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/NpcLoading.java @@ -52,10 +52,11 @@ public void classloader(@NotNull PluginClasspathBuilder classpathBuilder) { resolver.addDependency(new Dependency(new DefaultArtifact("org.mineskin:java-client:1.2.4-SNAPSHOT"), null)); resolver.addDependency(new Dependency(new DefaultArtifact("org.bstats:bstats-bukkit:3.1.0"), null)); resolver.addDependency(new Dependency(new DefaultArtifact("com.github.Mqzn:Lotus:1.4.1"), null)); - resolver.addDependency(new Dependency(new DefaultArtifact("dev.velix:imperat-core:1.3.2"), null)); - resolver.addDependency(new Dependency(new DefaultArtifact("dev.velix:imperat-bukkit:1.3.2"), null)); - resolver.addDependency(new Dependency(new DefaultArtifact("com.google.protobuf:protobuf-java:4.29.2"), null)); - + resolver.addDependency(new Dependency(new DefaultArtifact("dev.velix:imperat-core:1.7.1"), null)); + resolver.addDependency(new Dependency(new DefaultArtifact("dev.velix:imperat-bukkit:1.7.1"), null)); + resolver.addDependency(new Dependency(new DefaultArtifact("org.mongodb:mongodb-driver-sync:5.3.0"), null)); + resolver.addDependency(new Dependency(new DefaultArtifact("com.zaxxer:HikariCP:6.2.1"), null)); + resolver.addDependency(new Dependency(new DefaultArtifact("com.mysql:mysql-connector-j:9.1.0"), null)); classpathBuilder.addLibrary(resolver); } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java index 9d3bba5c..d8681ca2 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java @@ -28,13 +28,16 @@ import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; +import dev.foxikle.customnpcs.internal.utils.exceptions.IllegalWorldException; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.ApiStatus; +import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; @@ -111,13 +114,22 @@ public static Settings fromProtoSettings(SettingsOuterClass.Settings settings) { @ApiStatus.Internal public static ItemOuterClass.Item toProtoItem(ItemStack item) { + byte[] data; + if (item == null || item.getType() == Material.AIR) { + data = new byte[0]; + } else { + data = item.ensureServerConversions().serializeAsBytes(); + } return ItemOuterClass.Item.newBuilder() - .setSerialized(ByteString.copyFrom(item.ensureServerConversions().serializeAsBytes())) + .setSerialized(ByteString.copyFrom(data)) .build(); } @ApiStatus.Internal public static ItemStack fromProtoItem(ItemOuterClass.Item item) { + if (item.getSerialized().toByteArray().length == 0) { + return new ItemStack(Material.AIR); + } return ItemStack.deserializeBytes(item.getSerialized().toByteArray()); } @@ -170,8 +182,11 @@ public static LocationOuterClass.Location toProtoLocation(Location location) { } @ApiStatus.Internal - @SneakyThrows // npe if world doesn't exist. //todo: Do something about this public static Location fromProtoLocation(LocationOuterClass.Location location) { + //todo: Test this :) + if (Bukkit.getWorld(location.getWorld()) == null) { + throw new IllegalWorldException("Invalid world: " + location.getWorld()); + } return new Location( Bukkit.getWorld(location.getWorld()), location.getX(), location.getY(), @@ -188,11 +203,24 @@ public static byte[] serializeList(List list) { .build().toByteArray(); } + @ApiStatus.Internal + public static byte[] serializeProtoList(List list) { + return NpcListOuterClass.NpcList.newBuilder() + .addAllNpcs(list) + .build().toByteArray(); + } + @ApiStatus.Internal @SneakyThrows public static List deserializeList(byte[] bytes) { + return deserializeProtoList(bytes).stream().map(ProtoWrapper::fromProtoNpc).collect(Collectors.toList()); + } + + @ApiStatus.Internal + @SneakyThrows + public static List deserializeProtoList(byte[] bytes) { NpcListOuterClass.NpcList list = NpcListOuterClass.NpcList.parseFrom(bytes); List npcs = list.getNpcsList(); - return npcs.stream().map(ProtoWrapper::fromProtoNpc).collect(Collectors.toList()); + return new ArrayList<>(npcs); } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/FileStorage.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/FileStorage.java new file mode 100644 index 00000000..809869d5 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/FileStorage.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2025. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.storage; + +import dev.foxikle.customnpcs.internal.CustomNPCs; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.concurrent.CompletableFuture; + +public class FileStorage implements StorageProvider { + + public static final File FILE = new File("plugins/CustomNPCs/npcs.dat"); + + /** + * Creates files + */ + @Override + public CompletableFuture init(CustomNPCs plugin) { + return CompletableFuture.supplyAsync(() -> { + if (!FILE.exists()) { + FILE.getParentFile().mkdirs(); + try { + FILE.createNewFile(); + } catch (IOException e) { + throw new RuntimeException("Failed to create local storage file.", e); + } + } + plugin.getLogger().info("Successfully set up File storage!"); + return null; + }); + } + + /** + * {@inheritDoc} + */ + @Override + public CompletableFuture save(byte[] data) { + return CompletableFuture.supplyAsync(() -> { + try (FileOutputStream fos = new FileOutputStream(FILE)) { + fos.write(data); + } catch (IOException e) { + throw new RuntimeException("Failed to save local storage file.", e); + } + return true; + }); + } + + /** + * {@inheritDoc} + */ + @Override + public CompletableFuture load() { + return CompletableFuture.supplyAsync(() -> { + try (FileInputStream fis = new FileInputStream(FILE)) { + return fis.readAllBytes(); + } catch (Exception e) { + throw new RuntimeException("Failed to load local storage file.", e); + } + }); + } + + /** + * Does nothing. + */ + @Override + public void shutdown() { + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/MongoStorage.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/MongoStorage.java new file mode 100644 index 00000000..f88e4dc2 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/MongoStorage.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2025. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.storage; + +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.ServerApi; +import com.mongodb.ServerApiVersion; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; +import com.mongodb.client.MongoDatabase; +import com.mongodb.client.model.Filters; +import com.mongodb.client.model.ReplaceOptions; +import dev.foxikle.customnpcs.internal.CustomNPCs; +import org.bson.Document; +import org.bson.types.Binary; + +import java.util.Objects; +import java.util.concurrent.CompletableFuture; + + +public class MongoStorage implements StorageProvider { + + private MongoClientSettings settings = null; + private String database = null; + private String document = null; + + /** + * Initializes the storage provider. This could be connecting to a database, creating files, etc. + */ + @Override + public CompletableFuture init(CustomNPCs plugin) { + + return CompletableFuture.supplyAsync(() -> { + ServerApi serverApi = ServerApi.builder() + .version(ServerApiVersion.V1) + .build(); + settings = MongoClientSettings.builder() + .applyConnectionString(new ConnectionString(Objects.requireNonNull(plugin.getConfig().getString("storage.mongo.connectionString")))) + .serverApi(serverApi) + .applyToLoggerSettings(builder -> { + builder.maxDocumentLength(1); + }) + .build(); + database = Objects.requireNonNull(plugin.getConfig().getString("storage.mongo.database")); + document = Objects.requireNonNull(plugin.getConfig().getString("storage.mongo.document")); + plugin.getLogger().info("Successfully set up MongoDB storage!"); + return null; + }); + } + + /** + * Saves the given byte array to the storage provider. It should overwrite the data. + * + * @param data The byte array to save + * @return if the save was successful + */ + @Override + public CompletableFuture save(byte[] data) { + checkState(); + return CompletableFuture.supplyAsync(() -> { + try (MongoClient client = MongoClients.create(settings)) { + MongoDatabase db = client.getDatabase(database); + + Document doc = new Document("_id", document).append("data", new Binary(data)); + // replace it if it exists :) + db.getCollection("customnpcs").replaceOne(Filters.eq("_id", document), doc, new ReplaceOptions().upsert(true)); + return true; + + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + } + + /** + * Loads the saved byte array from the storage provider + * + * @return The array of bytes, or the loaded data. + */ + @Override + public CompletableFuture load() { + checkState(); + return CompletableFuture.supplyAsync(() -> { + try (MongoClient client = MongoClients.create(settings)) { + MongoDatabase db = client.getDatabase(database); + + Document doc = db.getCollection("customnpcs").find(Filters.eq("_id", document)).first(); + if (doc == null) return new byte[0]; // no data saved + return doc.get("data", Binary.class).getData(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + } + + /** + * Shuts down the storage provider. This could close buffers, connections, etc. + */ + @Override + public void shutdown() { + checkState(); + } + + private void checkState() { + if (document == null) throw new IllegalStateException("Document is null"); + if (database == null) throw new IllegalStateException("Database is null"); + if (settings == null) throw new IllegalStateException("Mongo settings is not initialized"); + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/MysqlStorage.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/MysqlStorage.java new file mode 100644 index 00000000..523bda7b --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/MysqlStorage.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2025. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.storage; + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import dev.foxikle.customnpcs.internal.CustomNPCs; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.concurrent.CompletableFuture; +import java.util.logging.Level; + +@SuppressWarnings("SqlNoDataSourceInspection") +public class MysqlStorage implements StorageProvider { + + private HikariConfig config = new HikariConfig(); + private String tableName; + + /** + * Initializes the storage provider. This could be connecting to a database, creating files, etc. + * + * @param plugin the plugin instance for fetching config values + */ + @Override + @SuppressWarnings("SqlSourceToSinkFlow") + public CompletableFuture init(CustomNPCs plugin) { + config = new HikariConfig(); + config.setJdbcUrl("jdbc:mysql://" + plugin.getConfig().getString("storage.mysql.hostname") + ":" + plugin.getConfig().getString("storage.mysql.port") + "/" + plugin.getConfig().getString("storage.mysql.database")); + config.setUsername(plugin.getConfig().getString("storage.mysql.username")); + config.setPassword(plugin.getConfig().getString("storage.mysql.password")); + config.setMaximumPoolSize(10); + config.setMinimumIdle(2); + config.setIdleTimeout(30000); + config.setConnectionTimeout(3000); + config.setDriverClassName("com.mysql.cj.jdbc.Driver"); + + tableName = getSafeTableName(plugin.getConfig().getString("storage.mysql.table")); + + return CompletableFuture.supplyAsync(() -> { + try (HikariDataSource dataSource = new HikariDataSource(config)) { + try (Connection connection = dataSource.getConnection()) { + PreparedStatement statement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS npc_data (id VARCHAR(255) PRIMARY KEY, data MEDIUMBLOB)"); + statement.executeUpdate(); + } catch (Exception e) { + plugin.getLogger().log(Level.SEVERE, "Failed to create table", e); + throw new RuntimeException(e); + } + } catch (Exception e) { + plugin.getLogger().log(Level.SEVERE, "Failed to create database connection", e); + throw new RuntimeException(e); + } + plugin.getLogger().info("Successfully set up MySQL storage!"); + return null; + }); + } + + /** + * Saves the given byte array to the storage provider. It should overwrite the data. + * + * @param data The byte array to save + * @return if the save was successful + */ + @Override + public CompletableFuture save(byte[] data) { + return CompletableFuture.supplyAsync(() -> { + try (HikariDataSource dataSource = new HikariDataSource(config)) { + try (Connection connection = dataSource.getConnection()) { + + // Prepare the SQL INSERT statement + String sql = "INSERT INTO npc_data (id, data) VALUES (?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data)"; + try (PreparedStatement statement = connection.prepareStatement(sql)) { + statement.setString(1, tableName); // Set the id parameter + statement.setBytes(2, data); // Set the data (MEDIUMBLOB) + + // Execute the insert query + statement.executeUpdate(); + return true; + } + } + } catch (Exception e) { + throw new RuntimeException("Database insertion failed", e); + } + }); + } + + /** + * Loads the saved byte array from the storage provider + * + * @return The array of bytes, or the loaded data. + */ + @Override + public CompletableFuture load() { + return CompletableFuture.supplyAsync(() -> { + try (HikariDataSource dataSource = new HikariDataSource(config)) { + try (Connection connection = dataSource.getConnection()) { + + // Prepare the SQL statement + String sql = "SELECT data FROM npc_data WHERE id = ?"; + try (PreparedStatement statement = connection.prepareStatement(sql)) { + statement.setString(1, tableName); // Set the id parameter + + // Execute the query + ResultSet rs = statement.executeQuery(); + byte[] data = new byte[0]; + while (rs.next()) { + // should only run once, as primary keys are unique. + data = rs.getBytes("data"); + } + return data; + } + } + } catch (Exception e) { + throw new RuntimeException("Database insertion failed", e); + } + }); + } + + /** + * Shuts down the storage provider. This could close buffers, connections, etc. + */ + @Override + public void shutdown() { + + } + + private String getSafeTableName(String tableName) { + if (tableName == null || !tableName.matches("^[a-zA-Z0-9_]+$")) { + throw new IllegalArgumentException("Invalid table name: " + tableName + ". Only alphanumeric and underscores are allowed."); + } + return tableName; + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java new file mode 100644 index 00000000..706919df --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java @@ -0,0 +1,800 @@ +/* + * Copyright (c) 2024-2025. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.storage; + +import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.ActionType; +import dev.foxikle.customnpcs.actions.LegacyAction; +import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.data.Equipment; +import dev.foxikle.customnpcs.data.Settings; +import dev.foxikle.customnpcs.internal.CustomNPCs; +import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; +import dev.foxikle.customnpcs.internal.proto.NpcOuterClass; +import dev.foxikle.customnpcs.internal.proto.ProtoWrapper; +import dev.foxikle.customnpcs.internal.utils.Utils; +import dev.foxikle.customnpcs.internal.utils.exceptions.IllegalWorldException; +import dev.foxikle.customnpcs.internal.utils.exceptions.UntrackedNpcException; +import lombok.Getter; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.time.Instant; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; +import java.util.stream.Collectors; + +/** + * The class that deals with all file related things + */ +@SuppressWarnings("unused") +public class StorageManager { + + public static final String[] VALID_PROVIDERS = {"LOCAL", "MONGODB", "MYSQL"}; + + /** + * The config file version + */ + public static final int CONFIG_FILE_VERSION = 6; + /** + * The file version of the npcs.yml file + */ + public static final double NPC_FILE_VERSION = 1.6; + public static File PARENT_DIRECTORY = new File("plugins/CustomNPCs/"); + @Getter + private final Map brokenNPCs = new HashMap<>(); + @Getter + private final List validNPCs = new ArrayList<>(); + private final CustomNPCs plugin; + private final List trackedNpcs = new ArrayList<>(); + + private boolean justMigrated = false; + private StorageProvider storage = null; + + /** + *

Gets the file manager object. + *

+ * + * @param plugin The instance of the Main class + */ + public StorageManager(CustomNPCs plugin) { + this.plugin = plugin; + } + + /** + *

Creates the files the plugin needs to run + *

+ * + * @return if creating the files was successful + */ + public boolean setup() { + if (!new File(PARENT_DIRECTORY, "config.yml").exists()) { + plugin.saveResource("config.yml", false); + return true; + } + // config + { + File file = new File(PARENT_DIRECTORY, "config.yml"); + YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); + + if (!yml.contains("Skins")) { + BackupResult br = createBackup(file); + if (br.success) { + plugin.getLogger().warning("The config is irreparably damaged! Resetting config. Your old config was saved to the file \"" + br.filePath.toString() + "\""); + plugin.saveResource("config.yml", true); + } + } + int version = yml.getInt("CONFIG_VERSION"); + + if (version < 7) { + BackupResult br = createBackup(file); + if (!br.success()) { + throw new RuntimeException("Failed to create a backup of the config file before updating it!"); + } else { + plugin.getLogger().info("Created backup of config.yml before updating it! A copy of your existing config was saved to " + br.filePath().toString()); + } + } + + if (version == 0) { // doesn't exist? + plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 1)); + yml.set("CONFIG_VERSION", 1); + yml.setComments("CONFIG_VERSION", List.of(" DO NOT, under ANY circumstances modify the 'CONFIG_VERSION' field. Doing so can cause catastrophic data loss.", "")); + yml.set("ClickText", "&e&lCLICK"); + yml.setComments("ClickText", List.of("ClickText -> The hologram displayed above the NPC if it is interactable", " NOTE: Due to Minecraft limitations, this cannot be more than 16 characters INCLUDING color and format codes.", " (But not the &)", "")); + yml.set("DisplayClickText", true); + yml.setComments("DisplayClickText", List.of(" DisplayClickText -> Should the plugin display a hologram above the NPC's head if it is interactable?", "")); + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + if (version < 2) { // prior to 1.4-pre2 + plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 2)); + yml.set("CONFIG_VERSION", 2); + yml.set("AlertOnUpdate", true); + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + if (version < 3) { // prior to 1.5.2-pre1 + plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 3)); + yml.set("CONFIG_VERSION", 3); + yml.set("ClickText", plugin.getMiniMessage().serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(Objects.requireNonNull(yml.getString("ClickText"))))); + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + if (version < 4) { //prior to 1.6-pre2 + plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 4)); + yml.set("CONFIG_VERSION", 4); + yml.set("DisableCollisions", true); + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + if (version < 5) { + plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 5)); + yml.set("CONFIG_VERSION", 5); + yml.set("NameReferenceMessages", true); + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + if (version < 6) { + plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 6)); + yml.set("CONFIG_VERSION", 6); + yml.set("InjectionDistance", 48); + yml.set("InjectionInterval", 10); + yml.set("HologramUpdateInterval", 200); + yml.set("LookInterval", 5); + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + if (version < 7) { + plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 7)); + yml.set("CONFIG_VERSION", 7); + yml.set("DefaultInterpolationDuration", 5); + yml.setComments("DefaultInterpolationDuration", List.of("DefaultInterpolationDuration -> How long should moving NPCs interpolate their Nametags moving?")); + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + if (version < 8) { + plugin.getLogger().log(Level.WARNING, String.format("Outdated Config version! Converting config (%d -> %d).", version, 8)); + + yml.set("DebugMode", false); + yml.setComments("DebugMode", List.of("DebugMode -> Should the plugin launch in debug mode? This can be quite spammy, so only use this if you're sure!")); + + yml.set("CONFIG_VERSION", 8); + ConfigurationSection storage = yml.createSection("storage"); + yml.setComments("storage", Utils.list("", + "+---------------------------------------+", + "| NPC Data Storage |", + "+---------------------------------------+" + )); + + storage.set("provider", "LOCAL"); + storage.setComments("provider", Utils.list("", + "+---------------------------------------+", + "| Storage Provider |", + "+---------------------------------------+", + "", + "The storage proivder determines how the plugin stores the NPC data. There are 3 options:", + "", + "\"LOCAL\" is used by default. It stores the data on the same disc the server is running on. It is a good choice if you don't want to deal with setting up a database or don't have one.", + "\"MYSQL\" is a typical relational database. It's not really optimized for this kind of storage, it's a good choice if you already use a MySQL or MariaDB database.", + "\"MONGODB\" is the recommended option for using remote storage. It tends to be more performant and optimized for storing BLOBs." + )); + + ConfigurationSection mysql = storage.createSection("mysql"); + storage.setComments("mysql", Utils.list("", + "+---------------------------------------+", + "| MySQL Configuration |", + "+---------------------------------------+", + "These settings only matter if the provider is set to \"MYSQL\"" + )); + + mysql.set("hostname", "YOUR_HOST"); + mysql.setComments("hostname", Utils.list( + "hostname -> the host name, or ip address of your database server." + )); + + mysql.set("port", 3306); + mysql.setComments("port", Utils.list( + "port -> The port the database runs on. Don't change this unless you know what you're doing" + )); + + mysql.set("username", "YOUR_USERNAME"); + mysql.setComments("username", Utils.list( + "username -> The database username" + )); + + mysql.set("password", "YOUR_PASSWORD"); + mysql.setComments("password", Utils.list( + "password -> The database password" + )); + + mysql.set("database", "YOUR_DATABASE"); + mysql.setComments("database", Utils.list( + "database -> The name of the database to use" + )); + + mysql.set("table", "npcs"); + mysql.setComments("table", Utils.list( + "table -> The name of the table used to store the data in. This can be used to separate your npc configurations across servers. ie: lobby, survival, etc." + )); + + ConfigurationSection mongo = storage.createSection("mongo"); + storage.setComments("mongo", Utils.list("", + "+---------------------------------------+", + "| MongoDB Configuration |", + "+---------------------------------------+", + "These settings only matter if the provider is set to \"MONGODB\"" + )); + + mongo.set("connectionString", "YOUR_CONNECTION_STRING"); + mongo.setComments("connectionString", Utils.list( + "connectionString -> The connection string provided by your mongo server." + )); + + mongo.set("database", "YOUR_DATABASE"); + mongo.setComments("database", Utils.list( + "database -> The name of the database to use" + )); + + mongo.set("document", "npcs"); + mongo.setComments("document", Utils.list( + "document -> The document to use to store the data. This can be used to separate your npc configurations across servers. ie: lobby, survival, etc." + )); + + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + if (Arrays.stream(VALID_PROVIDERS).noneMatch(s -> s.equalsIgnoreCase(yml.getString("storage.provider")))) { + throw new IllegalArgumentException("Invalid config provider " + yml.getString("storage.provider")); + } + plugin.getLogger().info("Successfully loaded " + yml.getString("storage.provider") + " storage provider."); + } + + // npcs (we only care if it exists) + if (new File(PARENT_DIRECTORY, "npcs.yml").exists()) { + // make it colapsable + File file = new File(PARENT_DIRECTORY, "npcs.yml"); + YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); + { + + String version = yml.getString("version"); + + if (version == null) { // Config is from before 1.3-pre4 + plugin.getLogger().warning("Old NPC file version found! Bumping version! (unknown version -> 1.3)"); + BackupResult br = createBackup(file); + if (!br.success) { + plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); + return false; + } + yml.set("version", "1.3"); + version = "1.3"; + + plugin.getLogger().warning("Adding delay to old actions."); + for (UUID u : getNPCIds()) { + ConfigurationSection s = yml.getConfigurationSection(u.toString()); + assert s != null; + List strings = s.getStringList("actions"); + List convertedActions = new ArrayList<>(); + for (String string : strings) { + List split = Utils.list(string.split("%::%")); + String sub = split.get(0); + split.remove(0); + int delay = 0; + LegacyAction actionImpl = new LegacyAction(ActionType.valueOf(sub), split, delay, Condition.SelectionMode.ONE, new ArrayList<>()); + convertedActions.add(actionImpl.toJson()); + } + s.set("actions", convertedActions); + } + // save after adding actions + try { + yml.save(file); + } catch (IOException e) { + plugin.getLogger().log(Level.SEVERE, "An error occurred saving the npcs.yml file after saving a list of converted actions. Please report the following stacktrace to Foxikle.", e); + } + } + + if (version.equalsIgnoreCase("1.3")) { + plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.3-> 1.4)"); + BackupResult br = createBackup(file); + if (!br.success) { + plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); + return false; + } + yml.set("version", "1.4"); + version = "1.4"; + + Set npcs = yml.getKeys(false); + for (String npc : npcs) { + if (npc.equals("version")) continue; // it's a key + ConfigurationSection section = yml.getConfigurationSection(npc); + + plugin.getLogger().warning("Old Actions found. Converting to json."); + List legacyActions = section.getStringList("actions"); + List newActions = new ArrayList<>(); + legacyActions.forEach(s -> { + if (s != null) { + LegacyAction a = LegacyAction.of(s); // going to be converted the old way + if (a != null) { + newActions.add(a.toJson()); + } + } + }); + section.set("actions", newActions); + try { + yml.save(file); + } catch (IOException e) { + plugin.getLogger().severe("An error occurred whilst saving the converted actions. Please report the following stacktrace to Foxikle. \n" + Arrays.toString(e.getStackTrace())); + } + } + } + + if (version.equalsIgnoreCase("1.4")) { + plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.4 -> 1.5)"); + BackupResult br = createBackup(file); + if (!br.success) { + plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); + return false; + } + + yml.set("version", "1.5"); + version = "1.5"; + + Set npcs = yml.getKeys(false); + for (String npc : npcs) { + if (npc.equals("version")) continue; // it's a key + ConfigurationSection section = yml.getConfigurationSection(npc); + + section.set("tunnelvision", false); + try { + yml.save(file); + } catch (IOException e) { + plugin.getLogger().severe("An error occurred whilst saving the tunelvision status to the config. Please report the following stacktrace to Foxikle. \n" + Arrays.toString(e.getStackTrace())); + } + } + } + + if (version.equalsIgnoreCase("1.5")) { + plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.5-> 1.6)"); + BackupResult br = createBackup(file); + if (!br.success) { + plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); + return false; + } + + yml.set("version", "1.6"); + version = "1.6"; + Set npcs = yml.getKeys(false); + for (String npc : npcs) { + if (npc.equals("version")) continue; // it's a key + ConfigurationSection section = yml.getConfigurationSection(npc); + + section.set("customHologram", false); + section.set("hideInteractableHologram", ""); + try { + yml.save(file); + } catch (IOException e) { + plugin.getLogger().severe("An error occurred whilst saving the tunelvision status to the config. Please report the following stacktrace to Foxikle. \n" + Arrays.toString(e.getStackTrace())); + } + } + } + + if (version.equals("1.6")) { + plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.6 -> 1.7)"); + BackupResult br = createBackup(file); + if (!br.success) { + plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); + return false; + } + yml.set("version", "1.7"); + version = "1.7"; + + Set npcs = yml.getKeys(false); + for (String npc : npcs) { + if (npc.equals("version")) continue; // its a key + ConfigurationSection section = yml.getConfigurationSection(npc); + + // convert actions to new format + List actionStrs = section.getStringList("actions"); + List list = new ArrayList<>(); + for (String actionStr : actionStrs) { + LegacyAction a = LegacyAction.of(actionStr); + if (a == null) { + plugin.getLogger().warning("Found an invalid action in the config. Please report the following action string to Foxikle. \n" + actionStr); + continue; + } + if (a.getActionType() == ActionType.TOGGLE_FOLLOWING) { + plugin.getLogger().warning("Found an action of the type `TOGGLE_FOLLOWING`. This action has been removed in 1.7."); + continue; + } + + list.add(a.toAction()); + } + + List newActions = new ArrayList<>(); + + for (Action a : list) { + if (a == null) { + plugin.getLogger().warning("Found an invalid action in the config."); + continue; + } + newActions.add(a.serialize()); + } + + section.set("actions", newActions); + } + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + // After 1.7-pre6 + if (version.equals("1.7")) { + plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.7 -> 1.8)"); + BackupResult br = createBackup(file); + if (!br.success) { + plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); + return false; + } + yml.set("version", "1.8"); + + Set npcs = yml.getKeys(false); + for (String npc : npcs) { + if (npc.equals("version")) continue; // its a key + ConfigurationSection section = yml.getConfigurationSection(npc); + + assert section != null : "Section is null -- Upgrading NPC file from 1.7 to 1.8"; + + double dir = section.getDouble("direction"); + Location loc = section.getLocation("location"); + assert loc != null : "Location is null -- Upgrading NPC file from 1.7 to 1.8"; + loc.setYaw((float) dir); + + section.set("location", loc); // update the location + section.set("direction", null); // remove the direction field + } + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + + // check for valid NPCs: + boolean found = false; + Set npcs = yml.getKeys(false); + for (String npc : npcs) { + if (npc.equals("version")) continue; // not an NPC uuid + ConfigurationSection section = yml.getConfigurationSection(npc); + boolean err = false; + boolean exists = false; + UUID uuid = UUID.fromString(npc); + + try { + var sec = section.getLocation("location"); + exists = sec != null; + } catch (Exception e) { + err = true; + } + + if (err || !exists) { + String rawName = plugin.getMiniMessage().stripTags(section.getString("name")); + throw new IllegalStateException("Detected an NPC (" + rawName + ") with an invalid location! Please revert to 1.7.x and use the /npc fixconfig command to fix this!"); + } else validNPCs.add(uuid); + } + } + // migrate data to the new storage provider! + plugin.getLogger().warning(" -- Migrating NPCs to dataformat 2! -- "); + + List migrated = new ArrayList<>(); + for (String key : yml.getKeys(false)) { + if (key.equals("version")) continue; // version tracking + migrated.add(migrateNPC(UUID.fromString(key))); + } + trackedNpcs.addAll(migrated); + createBackup(file); // create a backup just in case + if (!file.delete()) { + plugin.getLogger().warning("Couldn't delete old NPC file!"); + } + justMigrated = true; + } + + File configFile = new File(PARENT_DIRECTORY, "config.yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); + + switch (config.getString("storage.provider").toUpperCase(Locale.ROOT)) { + case "LOCAL" -> storage = new FileStorage(); + case "MYSQL" -> storage = new MysqlStorage(); + case "MONGODB" -> storage = new MongoStorage(); + default -> throw new IllegalStateException("Unknown provider: " + config.getString("storage.provider")); + } + + storage.init(plugin).whenComplete((unused, throwable) -> { + if (throwable != null) throw new RuntimeException("Couldn't load storage provider!", throwable); + if (justMigrated) saveNpcs(); + + // load the NPCs now (skip if just migrated) + + plugin.getLogger().info("Loading NPCs!"); + AtomicInteger successfullyLoaded = new AtomicInteger(); + if (!justMigrated) { + trackedNpcs.clear(); + getAllNpcs().whenComplete((internalNpcs, t) -> Bukkit.getScheduler().runTask(plugin, () -> { + // this needs to be sync since it adds entities + if (t != null) { + plugin.getLogger().log(Level.SEVERE, "An error occured whilst loading NPCs!", t); + return; + } + + // track the npcs + for (NpcOuterClass.Npc npc : internalNpcs) { + if (plugin.isDebug()) { + plugin.getLogger().info("[DEBUG] Tracking NPC " + npc.getUuid()); + } + track(npc); + if (loadProto(npc)) { + successfullyLoaded.incrementAndGet(); + } else { + plugin.getLogger().log(Level.WARNING, "NPC " + npc.getUuid() + " could not be loaded!"); + } + } + plugin.getLogger().info("Succesfully loaded " + successfullyLoaded + " NPCs, failed to load " + (trackedNpcs.size() - successfullyLoaded.get()) + " NPCs."); + })); + } else { + trackedNpcs.forEach(npc -> { + if (loadProto(npc)) { + successfullyLoaded.incrementAndGet(); + } else { + plugin.getLogger().log(Level.WARNING, "NPC " + npc.getUuid() + " could not be loaded!"); + } + }); + plugin.getLogger().info("Succesfully loaded " + successfullyLoaded + " cached NPCs, failed to load " + (trackedNpcs.size() - successfullyLoaded.get()) + " NPCs."); + } + }); + return true; + } + + private boolean loadProto(NpcOuterClass.Npc npc) { + if (plugin.isDebug()) { + plugin.getLogger().info("[DEBUG] Loading NPC " + npc.getUuid()); + } + try { + if (loadNPC(UUID.fromString(npc.getUuid()))) { + return true; + } else { + plugin.getLogger().warning("Failed to load NPC " + npc.getUuid() + "!"); + } + } catch (IllegalWorldException e) { + plugin.getLogger().log(Level.SEVERE, "Failed to load NPC " + npc.getUuid() + " due to an invalid world."); + } catch (UntrackedNpcException e) { + plugin.getLogger().log(Level.SEVERE, "Failed to load NPC " + npc.getUuid() + " as it was not tracked."); + } catch (Exception e) { + plugin.getLogger().log(Level.SEVERE, "Failed to load NPC " + npc.getUuid() + " due to an unknown error.", e); + } + brokenNPCs.put(UUID.fromString(npc.getUuid()), npc); + return false; + } + + /** + *

Adds an NPC to the `npcs.yml` file. + *

+ * + * @param npc The NPC to store + */ + public void addNPC(InternalNpc npc) { + trackedNpcs.add(ProtoWrapper.toProtoNpc(npc)); + saveNpcs(); + } + + /** + *

Gets the NPC of the specified UUID + *

+ * + * @param uuid The NPC to load from the file + * @return if the load was successful + */ + public boolean loadNPC(UUID uuid) { + if (trackedNpcs.stream().noneMatch(npc -> npc.getUuid().equals(uuid.toString()))) { + throw new IllegalArgumentException("NPC does not exist!"); + } + NpcOuterClass.Npc proto = trackedNpcs.stream().filter(n -> n.getUuid().equals(uuid.toString())).findFirst().orElse(null); + if (proto == null) throw new IllegalArgumentException("NPC does not exist!"); // should never be thrown + + InternalNpc npc = ProtoWrapper.fromProtoNpc(proto); + if (npc.getWorld() == null) { + printInvalidConfig(); + brokenNPCs.put(uuid, proto); + return false; + } + npc.createNPC(); + return true; + } + + public NpcOuterClass.Npc migrateNPC(UUID uuid) { + File file = new File("plugins/CustomNPCs/npcs.yml"); + YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); + ConfigurationSection section = yml.getConfigurationSection(uuid.toString()); + if (section == null) throw new IllegalArgumentException("NPC uuid cannot be null."); + + List actionImpls = new ArrayList<>(); + List actions; + + if (section.getList("actions") == null) { // meaning it does not exist + throw new IllegalStateException("Your NPC file is too old to migrate to 1.8! Please update to 1.7.x first!"); + } + if (Objects.requireNonNull(section.getString("name")).contains("§")) { + throw new IllegalStateException("Your NPC file is too old to migrate to 1.8! Please update to 1.7.x first!"); + } + + String rawName = plugin.getMiniMessage().stripTags(section.getString("name")); + World world; + + try { + world = Bukkit.getWorld(Objects.requireNonNull(section.getString("world"))); + } catch (IllegalArgumentException ex) { + throw new IllegalArgumentException("The NPC '" + rawName + "' has an invalid world. Please downgrade to 1.7.x and use the /npc fixconfig command!"); + } + + Location location; + try { + location = section.getLocation("location"); + } catch (Exception ex) { + throw new IllegalArgumentException("The NPC '" + rawName + "' has an invalid location. Please downgrade to 1.7.x and use the /npc fixconfig command!"); + } + + if (world == null) + throw new IllegalArgumentException("The NPC '" + rawName + "' has an invalid world. Please downgrade to 1.7.x and use the /npc fixconfig command!"); + if (location == null) + throw new IllegalArgumentException("The NPC '" + rawName + "' has an invalid location. Please downgrade to 1.7.x and use the /npc fixconfig command!"); + + + // use the actions freshly converted + + actions = new ArrayList<>(); + for (String s : section.getStringList("actions")) { + actions.add(Action.parse(s)); + } + + InternalNpc npc = plugin.createNPC(world, location, new Equipment(section.getItemStack("headItem"), section.getItemStack("chestItem"), section.getItemStack("legsItem"), section.getItemStack("feetItem"), section.getItemStack("handItem"), section.getItemStack("offhandItem")), new Settings(section.getBoolean("clickable"), section.getBoolean("tunnelvision"), true, section.getString("value"), section.getString("signature"), section.getString("skin"), section.getString("name"), section.getString("customHologram"), section.getBoolean("hideInteractableHologram")), uuid, null, actions); + + return ProtoWrapper.toProtoNpc(npc); + } + + + /** + *

Gets the set of stored UUIDs. + *

+ * + * @return the set of stored NPC uuids. + */ + public Set getNPCIds() { + return trackedNpcs.stream().map(npc -> UUID.fromString(npc.getUuid())).collect(Collectors.toSet()); + } + + /** + *

Removes the specified NPC from storage + *

+ * + * @param uuid The NPC uuid to remove + */ + public void remove(UUID uuid) { + NpcOuterClass.Npc proto = trackedNpcs.stream().filter(npc -> npc.getUuid().equals(uuid.toString())).findFirst().orElse(null); + if (proto == null) throw new IllegalArgumentException("NPC does not exist!"); + trackedNpcs.remove(proto); + saveNpcs(); + } + + private BackupResult createBackup(File file) { + YamlConfiguration yml = YamlConfiguration.loadConfiguration(file); + File f = new File(PARENT_DIRECTORY, new Date().toString().replace(" ", "_").replace(":", "_") + "_backup_of_" + file.getName() + Instant.now().hashCode()); + try { + if (f.createNewFile()) { + yml.save(f); + } else { + throw new RuntimeException("A duplicate file of file '" + f.getName() + "' exists! This means the plugin attempted to back up the file '" + file.getName() + "' multiple times within this millisecond! This is a serious issue that should be reported to @foxikle on discord!"); + } + } catch (IOException e) { + plugin.getLogger().log(Level.SEVERE, "An error occurred whilst creating a backup of the file '" + file.getName() + "'", e); + return new BackupResult(null, false); + } + return new BackupResult(f.toPath(), true); + } + + private void printInvalidConfig() { + plugin.getLogger().severe(""); + plugin.getLogger().severe("+------------------------------------------------------------------------------+"); + plugin.getLogger().severe("| NPC with an invalid configuration detected! |"); + plugin.getLogger().severe("| ** THIS IS NOT AN ERROR WITH CUSTOMNPCS ** |"); + plugin.getLogger().severe("| This is most likely a configuration error as a result of |"); + plugin.getLogger().severe("| modifying the `npcs.yml` file. |"); + plugin.getLogger().severe("+------------------------------------------------------------------------------+"); + plugin.getLogger().severe(""); + } + + private CompletableFuture saveNpcs() { + return storage.save(ProtoWrapper.serializeProtoList(trackedNpcs)); + } + + public void track(NpcOuterClass.Npc proto) { + NpcOuterClass.Npc found = trackedNpcs.stream().filter(npc -> npc.getUuid().equals(proto.getUuid())).findFirst().orElse(null); + if (found != null) trackedNpcs.remove(found); + trackedNpcs.add(proto); + } + + /** + * Gets ALL npcs stored in the storage provider, their configurations are not validated. + */ + public CompletableFuture> getAllNpcs() { + CompletableFuture> future = new CompletableFuture<>(); + storage.load().whenComplete((bytes, throwable) -> { + if (throwable != null) { + future.completeExceptionally(throwable); + return; + } + try { + future.complete(ProtoWrapper.deserializeProtoList(bytes)); + } catch (Exception e) { + future.completeExceptionally(e); + } + }); + return future; + } + + private record BackupResult(Path filePath, boolean success) { + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java index e1a05754..0b92cb2d 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageProvider.java @@ -22,15 +22,35 @@ package dev.foxikle.customnpcs.internal.storage; +import dev.foxikle.customnpcs.internal.CustomNPCs; import org.jetbrains.annotations.ApiStatus; +import java.util.concurrent.CompletableFuture; + @ApiStatus.Internal public interface StorageProvider { - void init(); + /** + * Initializes the storage provider. This could be connecting to a database, creating files, etc. + */ + CompletableFuture init(CustomNPCs plugin); - boolean save(byte[] data); + /** + * Saves the given byte array to the storage provider. It should overwrite the data. + * + * @param data The byte array to save + * @return if the save was successful + */ + CompletableFuture save(byte[] data); - byte[] load(); + /** + * Loads the saved byte array from the storage provider + * + * @return The array of bytes, or the loaded data. + */ + CompletableFuture load(); + /** + * Shuts down the storage provider. This could close buffers, connections, etc. + */ void shutdown(); } From 49557c7dab831c8e2775c9fd5537d464d5969fcc Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 20:09:49 -0400 Subject: [PATCH 12/25] Create custom exceptions --- .../exceptions/IllegalWorldException.java | 29 +++++++++++++++++++ .../exceptions/NpcConfigurationException.java | 29 +++++++++++++++++++ .../exceptions/UntrackedNpcException.java | 29 +++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/IllegalWorldException.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/NpcConfigurationException.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/UntrackedNpcException.java diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/IllegalWorldException.java b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/IllegalWorldException.java new file mode 100644 index 00000000..5be9bc5e --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/IllegalWorldException.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.utils.exceptions; + +public class IllegalWorldException extends NpcConfigurationException { + public IllegalWorldException(String message) { + super(message); + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/NpcConfigurationException.java b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/NpcConfigurationException.java new file mode 100644 index 00000000..4626d5ed --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/NpcConfigurationException.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.utils.exceptions; + +public class NpcConfigurationException extends RuntimeException { + public NpcConfigurationException(String message) { + super(message); + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/UntrackedNpcException.java b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/UntrackedNpcException.java new file mode 100644 index 00000000..b7974c8b --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/exceptions/UntrackedNpcException.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.utils.exceptions; + +public class UntrackedNpcException extends NpcConfigurationException { + public UntrackedNpcException(String message) { + super(message); + } +} From c30b5a783bdb717316bb3b70bc6c99e54e7e0080 Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 20:10:02 -0400 Subject: [PATCH 13/25] close the classloader --- core/src/main/resources/paper-plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/paper-plugin.yml b/core/src/main/resources/paper-plugin.yml index 32d004f0..1e0ea964 100644 --- a/core/src/main/resources/paper-plugin.yml +++ b/core/src/main/resources/paper-plugin.yml @@ -7,7 +7,7 @@ authors: [ Foxikle ] #website: https://foxikle.dev/plugins description: A simple NPC plugin. loader: dev.foxikle.customnpcs.internal.NpcLoading -has-open-classloader: true +has-open-classloader: false contributors: - FlameyosFlow dependencies: From bed2434a2ac9200265aa671a5ef0c7c8e7577130 Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 20:10:25 -0400 Subject: [PATCH 14/25] use the new file manager --- .../internal/commands/suggestion/NpcBrokenSuggester.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/suggestion/NpcBrokenSuggester.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/suggestion/NpcBrokenSuggester.java index ef5f052b..c43cc00e 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/suggestion/NpcBrokenSuggester.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/suggestion/NpcBrokenSuggester.java @@ -1,7 +1,7 @@ package dev.foxikle.customnpcs.internal.commands.suggestion; import dev.foxikle.customnpcs.internal.CustomNPCs; -import dev.foxikle.customnpcs.internal.FileManager; +import dev.foxikle.customnpcs.internal.storage.StorageManager; import dev.velix.imperat.BukkitSource; import dev.velix.imperat.command.parameters.CommandParameter; import dev.velix.imperat.context.SuggestionContext; @@ -17,7 +17,7 @@ public class NpcBrokenSuggester implements SuggestionResolver { @Override public Collection autoComplete(SuggestionContext context, CommandParameter parameter) { final CustomNPCs plugin = CustomNPCs.getInstance(); - FileManager fileManager = plugin.getFileManager(); - return fileManager.getBrokenNPCs().keySet().stream().map(UUID::toString).toList(); + StorageManager storageManager = plugin.getStorageManager(); + return storageManager.getBrokenNPCs().keySet().stream().map(UUID::toString).toList(); } } \ No newline at end of file From a28eff63a4f277eae625a47bb9df7763df60000e Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 20:10:47 -0400 Subject: [PATCH 15/25] Use proto wrapped things --- .../customnpcs/internal/CustomNPCs.java | 22 ++--- .../internal/commands/FixConfigCommand.java | 90 +++++-------------- 2 files changed, 31 insertions(+), 81 deletions(-) diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java index c9150ae7..25b8ff42 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java @@ -41,6 +41,7 @@ import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.listeners.Listeners; import dev.foxikle.customnpcs.internal.menu.*; +import dev.foxikle.customnpcs.internal.storage.StorageManager; import dev.foxikle.customnpcs.internal.translations.Translations; import dev.foxikle.customnpcs.internal.utils.ActionRegistry; import dev.foxikle.customnpcs.internal.utils.AutoUpdater; @@ -82,8 +83,8 @@ @Slf4j public final class CustomNPCs extends JavaPlugin implements PluginMessageListener { - public static int INTERPOLATION_DURATION; public static final ActionRegistry ACTION_REGISTRY = new ActionRegistry(); + public static int INTERPOLATION_DURATION; /** * Singleton for the NPCBuilder */ @@ -203,7 +204,7 @@ public final class CustomNPCs extends JavaPlugin implements PluginMessageListene public MiniMessage miniMessage = MiniMessage.miniMessage(); Listeners listeners; @Getter - private FileManager fileManager; + private StorageManager storageManager; /** * Singleton for menu utilities */ @@ -241,7 +242,7 @@ public void onEnable() { String s = translateVersion(); try { - getLogger().info("Loading class: " + String.format(NPC_CLASS, s)); + getLogger().info("Loading NPC class: " + String.format(NPC_CLASS, s)); getClassLoader().loadClass(String.format(NPC_CLASS, s)); } catch (ClassNotFoundException e) { getLogger().log(Level.SEVERE, "Failed to load NPC class for server version " + s + "!", e); @@ -260,15 +261,11 @@ public void onEnable() { .registerTypeAdapter(Condition.class, new ConditionalTypeAdapter()) .registerTypeAdapter(LegacyAction.class, new ActionAdapter()) .create(); - this.fileManager = new FileManager(this); + this.storageManager = new StorageManager(this); this.mu = new MenuUtils(this); this.updater = new AutoUpdater(this); update = updater.checkForUpdates(); - if (!fileManager.createFiles()) { - throw new RuntimeException("Failed to create files"); - } - getLogger().info("Loading action registry..."); ACTION_REGISTRY.register("ActionBar", ActionBar.class, ActionBar::creationButton); ACTION_REGISTRY.register("DisplayTitle", DisplayTitle.class, DisplayTitle::creationButton); @@ -282,13 +279,8 @@ public void onEnable() { ACTION_REGISTRY.register("SendServer", SendServer.class, SendServer::creationButton, true, false, true); ACTION_REGISTRY.register("Teleport", Teleport.class, Teleport::creationButton); - try { - this.getLogger().info("Loading NPCs!"); - for (UUID uuid : fileManager.getValidNPCs()) { - fileManager.loadNPC(uuid); - } - } catch (Exception e) { - getLogger().log(Level.SEVERE, "Failed to load NPC:", e); + if (!storageManager.setup()) { + throw new RuntimeException("Failed to start storage manager"); } //generate skin menus for the supported locales diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/FixConfigCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/FixConfigCommand.java index 5ad5235c..4e7e70fa 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/FixConfigCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/FixConfigCommand.java @@ -23,17 +23,18 @@ package dev.foxikle.customnpcs.internal.commands; import dev.foxikle.customnpcs.internal.CustomNPCs; -import dev.foxikle.customnpcs.internal.FileManager; import dev.foxikle.customnpcs.internal.commands.enums.FixConfigWorldStrategy; +import dev.foxikle.customnpcs.internal.proto.NpcOuterClass; +import dev.foxikle.customnpcs.internal.proto.ProtoWrapper; +import dev.foxikle.customnpcs.internal.storage.StorageManager; import dev.foxikle.customnpcs.internal.utils.Msg; import dev.velix.imperat.BukkitSource; import dev.velix.imperat.annotations.*; +import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Bukkit; import org.bukkit.FluidCollisionMode; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.util.RayTraceResult; import org.bukkit.util.Vector; @@ -86,44 +87,23 @@ public void execute(BukkitSource source, } CustomNPCs plugin = CustomNPCs.getInstance(); - FileManager fileManager = plugin.getFileManager(); + StorageManager storageManager = plugin.getStorageManager(); if (target.equalsIgnoreCase("all")) { // apply it to all NPCs - for (UUID uuid : fileManager.getBrokenNPCs().keySet()) { - YamlConfiguration yml = fileManager.getNpcYaml(); - ConfigurationSection parent = yml.getConfigurationSection(uuid.toString()); - if (parent == null) { - nonExistentNpcs++; - continue; - } - - ConfigurationSection location = parent.getConfigurationSection("location"); - - Location loc; - String locString; - - //Bukkit's terrible config api didn't wipe the section - if (location != null) { - assert location != null : "Location is null"; + for (NpcOuterClass.Npc npc : storageManager.getBrokenNPCs().values()) { - double x = location.getDouble("x"); - double y = location.getDouble("y"); - double z = location.getDouble("z"); - float pitch = (float) location.getDouble("pitch"); - float yaw = (float) location.getDouble("yaw"); - loc = new Location(w, x, y, z, pitch, yaw); - locString = "(" + x + "," + y + "," + z + ")"; - } else { + Location loc = ProtoWrapper.fromProtoLocation(npc.getLocation()); + if (loc == null) { loc = new Location(w, 0, 0, 0, 0, 0); - locString = "(0, 0, 0)"; plugin.getLogger().warning("Fixed an NPC whose location data was wiped by Bukkit's configuration API. Its location was set to (0,0,0)"); source.reply(Msg.translate(locale, "customnpcs.commands.fix_config.bukkit_wiped_data")); } + String locString = "(" + loc.x() + ", " + loc.y() + ", " + loc.z() + ")"; if (strat == FixConfigWorldStrategy.SAFE_LOCATION) { @@ -135,34 +115,34 @@ public void execute(BukkitSource source, if (traceResult == null) { // The location cannot be safe - plugin.getLogger().warning("Failed to fix npc " + uuid + " at " + locString + " -- Location cannot be made safe."); + plugin.getLogger().warning("Failed to fix npc " + npc.getUuid() + " at " + locString + " -- Location cannot be made safe."); failedToFix++; continue; } loc.setY(traceResult.getHitBlock().getY() + 1); } movedbyStrategy++; - } - parent.set("location", loc); totalFixed++; - fileManager.saveNpcFile(yml); + NpcOuterClass.Npc fixed = npc.toBuilder().setLocation(ProtoWrapper.toProtoLocation(loc)).build(); + storageManager.track(fixed); // retrack the fixed on :) } } else { // find npc by flag try { - - if (!fileManager.getBrokenNPCs().containsValue(target)) { + if (storageManager.getBrokenNPCs().values().stream().noneMatch(npc -> MiniMessage.miniMessage().stripTags(npc.getSettings().getName()).equals(target))) { // it dont exist source.reply(Msg.translate(locale, "customnpcs.commands.invalid_name_or_uuid ")); return; } UUID uuid = null; - for (Map.Entry entry : fileManager.getBrokenNPCs().entrySet()) { - if (entry.getValue().equals(target)) { + NpcOuterClass.Npc npc = null; + for (Map.Entry entry : storageManager.getBrokenNPCs().entrySet()) { + if (MiniMessage.miniMessage().stripTags(entry.getValue().getSettings().getName()).equals(target)) { uuid = entry.getKey(); + npc = entry.getValue(); break; } } @@ -172,38 +152,16 @@ public void execute(BukkitSource source, return; } - YamlConfiguration yml = fileManager.getNpcYaml(); - ConfigurationSection parent = yml.getConfigurationSection(uuid.toString()); - if (parent == null) { - nonExistentNpcs++; - // hacky hacky way to do this - throw new RuntimeException("Catch me!"); - } - ConfigurationSection location = parent.getConfigurationSection("location"); - - Location loc; - String locString; - - //Bukkit's terrible config api didn't wipe the section - if (location != null) { - assert location != null : "Location is null"; - - double x = location.getDouble("x"); - double y = location.getDouble("y"); - double z = location.getDouble("z"); - float pitch = (float) location.getDouble("pitch"); - float yaw = (float) location.getDouble("yaw"); - - loc = new Location(w, x, y, z, pitch, yaw); - locString = "(" + x + "," + y + "," + z + ")"; - } else { + Location loc = ProtoWrapper.fromProtoLocation(npc.getLocation()); + if (loc == null) { loc = new Location(w, 0, 0, 0, 0, 0); - locString = "(0, 0, 0)"; plugin.getLogger().warning("Fixed an NPC whose location data was wiped by Bukkit's configuration API. Its location was set to (0,0,0)"); source.reply(Msg.translate(locale, "customnpcs.commands.fix_config.bukkit_wiped_data")); } + String locString = "(" + loc.x() + ", " + loc.y() + ", " + loc.z() + ")"; + if (strat == FixConfigWorldStrategy.SAFE_LOCATION) { @@ -224,10 +182,10 @@ public void execute(BukkitSource source, } - parent.set("location", loc); - totalFixed++; - fileManager.saveNpcFile(yml); + totalFixed++; + NpcOuterClass.Npc fixed = npc.toBuilder().setLocation(ProtoWrapper.toProtoLocation(loc)).build(); + storageManager.track(fixed); } catch (Exception ignored) { } From 969f37a2b03f5c2e159f4cef7cadfce3ce70276c Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 20:11:02 -0400 Subject: [PATCH 16/25] Add storage options and debug modes --- core/src/main/resources/config.yml | 53 ++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index 532136b0..08974890 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -13,7 +13,7 @@ # will be automatically generated on the next server start. # DO NOT, under ANY circumstances modify the 'CONFIG_VERSION' field. Doing so can cause catastrophic data loss. -CONFIG_VERSION: 7 +CONFIG_VERSION: 8 # InjectionDistance -> How close should a player be to the NPC before the plugin attempts to inject the NPC (Due to minecraft, npcs automatically remove themselves after getting 48 blocks from the player. InjectionDistance: 48 @@ -47,6 +47,9 @@ NameReferenceMessages: true # DefaultInterpolationDuration -> How long should moving NPCs interpolate their Nametags moving? DefaultInterpolationDuration: 5 +# DebugMode -> Should the plugin launch in debug mode? This can be quite spammy, so only use this if you're sure! +DebugMode: false + # Skins -> A list of preset Skins Skins: Sourcerer: @@ -230,7 +233,53 @@ Skins: value: ewogICJ0aW1lc3RhbXAiIDogMTY4Mzk0MDM2NjQ5MSwKICAicHJvZmlsZUlkIiA6ICJiODMyODBlODZhMzU0ZjA4OTUzMDlkMDFmMTk3OGZmOSIsCiAgInByb2ZpbGVOYW1lIiA6ICJPeGlrbGUiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2YwNzYwNGRmZDJiZTFmMzZhZDU5MjdhYmExZjE4ODJjYzRjM2U3ODA4MjFhMjA2M2U0YmJhMDlmZGY2NWQ2YyIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9 signature: iw9jmhcoCch+yWx2Yjy9+Dg2y9MOq9Ef6rOCY2FywOfR6+/T/sGwJtM+HqLHYO+B9uhBqfKxYXVLHQNvT7KzfiYVnbsIUQSWyBR7NxGssbbFixC3SoxTsIg0x2nvidbi/IjeG0UL1ZTb2S7jhjnvVU/bwyTz/i5fQ3lnBbW172FySPewRfVh10pZogAflKXZ22Lz5pHxlR4Ed/2RW75sltmKd3j7H76f+cEm9arixjilX/NhH/1WVFUqb7W6xUd5zrGxVkNIp3a8Fn4DCDItauhqDSjRZQkxpDnky36iuh/sCvJWFcxO9hkdqvMClUS4wtRTO1aKSnQFCMuwAuraIQClYJztI4EReSlB2NF6whEHpsRIBo5zG4J6nynu77VV1p1gn7W4g6LvmP0YoTPqed5uOL/FPBC/etn0Ofj1t3CgnOY8HQBDvkhSgyUuQwzixrGiNxRuu7IU3lDvSYVIewKGSK2Qkkl/Ob1P7BZCJTSkNA3MWfA11MDLFm8AZU6Bau+epO2C7RDwaKO61hSpdcgpORHruzXskvOfoOQ+oSP9VDAeLSfjD8fLQNgUdd/QdZXMgBitS5izHT/L6UCEoM6Tm5DmQz2D+ysvPdPpbNoa39sXL08vm5HgReFTh73qUJQC/qoK2rOk1Igef1oaiH7R1X5MiMvetNYE97vkoXM= - +# +---------------------------------------+ +# | NPC Data Storage | +# +---------------------------------------+ +Storage: + + # +---------------------------------------+ + # | Storage Provider | + # +---------------------------------------+ + + # The storage proivder determines how the plugin stores the NPC data. There are 3 options: + # + # "LOCAL" is used by default. It stores the data on the same disc the server is running on. It is a good choice if you don't want to deal with setting up a database or don't have one. + # "MYSQL" is a typical relational database. It's not really optimized for this kind of storage, it's a good choice if you already use a MySQL or MariaDB database. + # "MONGODB" is the recommended option for using remote storage. It tends to be more performant and optimized for storing BLOBs. + provider: "LOCAL" + + # +---------------------------------------+ + # | MySQL Configuration | + # +---------------------------------------+ + # These settings only matter if the provider is set to "MYSQL" + mysql: + + # hostname -> the host name, or ip address of your database server. + hostname: 'YOUR_HOST' + # port -> The port the database runs on. Don't change this unless you know what you're doing + port: 3306 + # username -> The database username + username: 'YOUR_USERNAME' + # password -> The database password + password: 'YOUR_PASSWORD' + # table -> The name of the table used to store the data in. This can be used to separate your npc configurations across servers. ie: lobby, survival, etc. + table: 'npcs' + # database -> The name of the database to use + database: 'YOUR_DATABASE' + + # +---------------------------------------+ + # | MongoDB Configuration | + # +---------------------------------------+ + # These settings only matter if the provider is set to "MONGODB" + mongodb: + + # connectionString -> The connection string provided by your mongo server. + connectionString: 'YOUR_CONNECTION_STRING' + # database -> The name of the database to use + database: 'YOUR_DATABASE' + # document -> The document to use to store the data. This can be used to separate your npc configurations across servers. ie: lobby, survival, etc. + document: 'npcs' From 4f44cfc7086b11ebd39257e580f3ef66ba17f3f3 Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 20:12:19 -0400 Subject: [PATCH 17/25] Enable debug mode if its true in the config --- .../foxikle/customnpcs/internal/storage/StorageManager.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java index 706919df..aed9d18a 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java @@ -297,6 +297,9 @@ public boolean setup() { } } + // enable debug mode as quickly as possible: + plugin.setDebug(yml.getBoolean("DebugMode")); + if (Arrays.stream(VALID_PROVIDERS).noneMatch(s -> s.equalsIgnoreCase(yml.getString("storage.provider")))) { throw new IllegalArgumentException("Invalid config provider " + yml.getString("storage.provider")); } From aa436fcfa01a94c4e9e4c0b91b5e6a57f7e4cffe Mon Sep 17 00:00:00 2001 From: foxikle Date: Sun, 9 Mar 2025 21:28:38 -0400 Subject: [PATCH 18/25] Create a command to move the NPC data around --- .../internal/commands/CommandUtils.java | 3 + .../internal/commands/FixConfigCommand.java | 2 - .../internal/commands/MoveDataCommand.java | 201 ++++++++++++++++++ .../internal/commands/NpcCommand.java | 9 +- .../internal/storage/StorageManager.java | 14 +- .../localization/English_en_US.properties | 11 +- core/src/main/resources/paper-plugin.yml | 4 + 7 files changed, 232 insertions(+), 12 deletions(-) create mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CommandUtils.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CommandUtils.java index 71be0624..e1f22db1 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CommandUtils.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CommandUtils.java @@ -86,6 +86,9 @@ public static Component getHelpComponent(Locale p) { .append(Msg.translate(p, "customnpcs.commands.help.debug.syntax").color(NamedTextColor.GOLD).appendSpace().hoverEvent(HoverEvent.showText(Msg.translate(p, "customnpcs.commands.help.debug.aliases")))) .append(Msg.translate(p, "customnpcs.commands.help.debug.description").color(NamedTextColor.DARK_AQUA).appendSpace().hoverEvent(HoverEvent.showText(Msg.translate(p, "customnpcs.commands.help.debug.hover")))) .appendNewline() + .append(Msg.translate(p, "customnpcs.commands.help.movedata.syntax").color(NamedTextColor.GOLD).appendSpace().hoverEvent(HoverEvent.showText(Msg.translate(p, "customnpcs.commands.help.movedata.aliases")))) + .append(Msg.translate(p, "customnpcs.commands.help.movedata.description").color(NamedTextColor.DARK_AQUA).appendSpace().hoverEvent(HoverEvent.showText(Msg.translate(p, "customnpcs.commands.help.movedata.hover")))) + .appendNewline() .append(Component.text(" ", NamedTextColor.DARK_GREEN, TextDecoration.STRIKETHROUGH)); return component; } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/FixConfigCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/FixConfigCommand.java index 4e7e70fa..59e81639 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/FixConfigCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/FixConfigCommand.java @@ -42,8 +42,6 @@ import java.util.Map; import java.util.UUID; -@SubCommand(value = "fixconfig", attachDirectly = true) -@Permission("customnpcs.commands.fix_config") public class FixConfigCommand { @Usage diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java new file mode 100644 index 00000000..266e7281 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2025. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.internal.commands; + +import dev.foxikle.customnpcs.internal.CustomNPCs; +import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; +import dev.foxikle.customnpcs.internal.proto.NpcOuterClass; +import dev.foxikle.customnpcs.internal.proto.ProtoWrapper; +import dev.foxikle.customnpcs.internal.storage.FileStorage; +import dev.foxikle.customnpcs.internal.storage.StorageManager; +import dev.foxikle.customnpcs.internal.utils.Msg; +import dev.velix.imperat.BukkitSource; +import dev.velix.imperat.annotations.*; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.io.FileInputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.logging.Level; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@SubCommand(value = "movedata", attachDirectly = true) +@Permission("customnpcs.commands.movedata") +public class MoveDataCommand { + + private static final Map run_already = new HashMap<>(); + private static boolean console_confirmed = false; + + @Usage + public void usage(BukkitSource source, @Named("operation") @Suggest({"MERGE_REMOTE", "MERGE_LOCAL", "OVERWRITE"}) @Default("MERGE_LOCAL") String operation) { + if (!checkValidOperation(operation)) { + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.invalid_operation")); + return; + } + checkValidOperation(operation); + if (source.isConsole()) { + if (!console_confirmed) { + console_confirmed = true; + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.need_confirm")); + return; + } else { + console_confirmed = false; + if (operation.equals("MERGE_LOCAL")) { + merge(source, true); + } else if (operation.equals("MERGE_REMOTE")) { + merge(source, false); + } else { + overwrite(source); + } + } + } + + Player player = source.asPlayer(); + if (!run_already.containsKey(player.getUniqueId())) { + run_already.put(player.getUniqueId(), true); + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.need_confirm")); + return; + } + + run_already.remove(player.getUniqueId()); + + if (operation.equals("MERGE_LOCAL")) { + merge(source, true); + } else if (operation.equals("MERGE_REMOTE")) { + merge(source, false); + } else { + overwrite(source); + } + + } + + private boolean checkValidOperation(String operation) { + return operation.equalsIgnoreCase("MERGE_LOCAL") || operation.equalsIgnoreCase("MERGE_REMOTE") || operation.equalsIgnoreCase("OVERWRITE"); + } + + private boolean start(BukkitSource source) { + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.operation_queued")); + + if ((CustomNPCs.getInstance().getStorageManager().getStorage() instanceof FileStorage)) { + CustomNPCs.getInstance().getLogger().log(Level.WARNING, "The current file provider is already File storage!"); + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.operation_failure")); + return true; + } + + if (!FileStorage.FILE.exists()) { + CustomNPCs.getInstance().getLogger().log(Level.SEVERE, "The local NPC data file does not exist!", new IllegalStateException()); + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.operation_failure")); + return true; + } + return false; + } + + private void merge(BukkitSource source, boolean discardRemote) { + CustomNPCs plugin = CustomNPCs.getInstance(); + if (start(source)) { + return; + } + + StorageManager sm = plugin.getStorageManager(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + byte[] currentData; + try (FileInputStream fis = new FileInputStream(FileStorage.FILE)) { + currentData = fis.readAllBytes(); + } catch (Exception e) { + plugin.getLogger().log(Level.SEVERE, "An error occurred while reading local NPC file", e); + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.operation_failure")); + return; + } + + List local = ProtoWrapper.deserializeProtoList(currentData); + sm.getAllNpcs().whenComplete((remote, throwable) -> { + if (throwable != null) { + plugin.getLogger().log(Level.SEVERE, "An error occurred while fetching remote NPC data!", throwable); + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.operation_failure")); + return; + } + + List merged = Stream.concat(remote.stream(), local.stream()) + .collect(Collectors.toMap( + NpcOuterClass.Npc::getUuid, npc -> npc, (t, t2) -> discardRemote ? t : t2) + ).values().stream().toList(); + finalizeMove(source, plugin, sm, merged); + }); + }); + } + + /** + * Overwrites the currently stored data with whatever is in the local file + * + * @param source the source to reply to + */ + private void overwrite(BukkitSource source) { + CustomNPCs plugin = CustomNPCs.getInstance(); + if (start(source)) { + return; + } + + StorageManager sm = plugin.getStorageManager(); + Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { + byte[] currentData; + try (FileInputStream fis = new FileInputStream(FileStorage.FILE)) { + currentData = fis.readAllBytes(); + } catch (Exception e) { + plugin.getLogger().log(Level.SEVERE, "An error occurred while reading local NPC file", e); + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.operation_failure")); + return; + } + + List toWrite = ProtoWrapper.deserializeProtoList(currentData); + finalizeMove(source, plugin, sm, toWrite); + }); + } + + private void finalizeMove(BukkitSource source, CustomNPCs plugin, StorageManager sm, List toWrite) { + Bukkit.getScheduler().runTask(plugin, () -> { + sm.resetTracked(); + + // remove the npcs + plugin.getNPCs().forEach(InternalNpc::remove); + plugin.npcs.clear(); + + for (NpcOuterClass.Npc npc : toWrite) { + sm.track(npc); + sm.loadProto(npc); + } + + sm.saveNpcs().whenComplete((aBoolean, throwable1) -> { + if (throwable1 != null) { + plugin.getLogger().log(Level.SEVERE, "An error occurred while writing remote NPC data!", throwable1); + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.operation_failure")); + return; + } + source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.operation_success")); + }); + }); + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/NpcCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/NpcCommand.java index 0f666933..b8f56289 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/NpcCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/NpcCommand.java @@ -25,8 +25,6 @@ import dev.velix.imperat.BukkitSource; import dev.velix.imperat.annotations.*; -import java.util.Locale; - @Command("npc") @Description("The main CustomNPCs command") @Permission("customnpcs.commands.help") @@ -35,15 +33,14 @@ CloneCommand.class, CreateCommand.class, DeleteCommand.class, EditCommand.class, FixConfigCommand.class, ListCommand.class, MoveCommand.class, ReloadCommand.class, SetsoundCommand.class, TeleportCommand.class, - WikiCommand.class, HelpCommand.class, ManageCommand.class, DebugCommand.class + WikiCommand.class, HelpCommand.class, ManageCommand.class, DebugCommand.class, + MoveDataCommand.class } ) public class NpcCommand { @Usage public void showHelp(BukkitSource sender) { - Locale locale = Locale.getDefault(); - if (!sender.isConsole()) locale = sender.asPlayer().locale(); - sender.reply(CommandUtils.getHelpComponent(locale)); + sender.reply(CommandUtils.getHelpComponent(CommandUtils.getLocale(sender))); } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java index aed9d18a..480d8eb8 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java @@ -42,6 +42,7 @@ import org.bukkit.World; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; +import org.jetbrains.annotations.ApiStatus; import java.io.File; import java.io.IOException; @@ -64,10 +65,12 @@ public class StorageManager { /** * The config file version */ - public static final int CONFIG_FILE_VERSION = 6; + public static final int CONFIG_FILE_VERSION = 8; /** * The file version of the npcs.yml file */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "1.10") public static final double NPC_FILE_VERSION = 1.6; public static File PARENT_DIRECTORY = new File("plugins/CustomNPCs/"); @Getter @@ -78,6 +81,7 @@ public class StorageManager { private final List trackedNpcs = new ArrayList<>(); private boolean justMigrated = false; + @Getter private StorageProvider storage = null; /** @@ -612,7 +616,7 @@ public boolean setup() { return true; } - private boolean loadProto(NpcOuterClass.Npc npc) { + public boolean loadProto(NpcOuterClass.Npc npc) { if (plugin.isDebug()) { plugin.getLogger().info("[DEBUG] Loading NPC " + npc.getUuid()); } @@ -769,7 +773,7 @@ private void printInvalidConfig() { plugin.getLogger().severe(""); } - private CompletableFuture saveNpcs() { + public CompletableFuture saveNpcs() { return storage.save(ProtoWrapper.serializeProtoList(trackedNpcs)); } @@ -798,6 +802,10 @@ public CompletableFuture> getAllNpcs() { return future; } + public void resetTracked() { + trackedNpcs.clear(); + } + private record BackupResult(Path filePath, boolean success) { } } diff --git a/core/src/main/resources/localization/English_en_US.properties b/core/src/main/resources/localization/English_en_US.properties index af7f7d3f..34991c1c 100644 --- a/core/src/main/resources/localization/English_en_US.properties +++ b/core/src/main/resources/localization/English_en_US.properties @@ -90,10 +90,19 @@ customnpcs.commands.help.wiki.description =Sends a link to t customnpcs.commands.help.wiki.hover =Gives you access to the Wiki! customnpcs.commands.debug.message.enable =Debug mode enabled! customnpcs.commands.debug.message.disable =Debug mode disabled! -customnpcs.commands.help.debug.syntax =\u2022 npc manage +customnpcs.commands.help.debug.syntax =\u2022 npc debug customnpcs.commands.help.debug.aliases =npc debug customnpcs.commands.help.debug.description =Debugs CustomNPCs customnpcs.commands.help.debug.hover =Allows CustomNPCs to broadcast debug messages to the logs and authorized players. +customnpcs.commands.help.movedata.syntax =\u2022 npc movedata +customnpcs.commands.help.movedata.aliases =npc movedata +customnpcs.commands.help.movedata.description =Relocates any local NPC data to the currently configured storage provider +customnpcs.commands.help.movedata.hover =Stores any local NPC data in the storage provider. The three operators, MERGE_LOCAL, MERGE_REMOTE, and OVERWRITE, determine how conflicts are handled. MERGE_REMOTE tries to merge the two lists of NPCs, discarding the local duplicate (by uuid, settings, equipment, etc are not considdered). MERGE_LOCAL tries to merge the two lists, but it discards the remote duplicates. OVERWRITE completley wipes the storage provider and replaces it with the local data. +customnpcs.commands.movedata.invalid_operation =Invalid operator! Use `OVERWRITE` to replace and `MERGE_REMOTE`/`MERGE_LOCAL` to combine. +customnpcs.commands.movedata.need_confirm =WARNING! This operation cannot be undone! Run the command again to confirm. +customnpcs.commands.movedata.operation_queued =QUEUED! The data transfer has been queued, and will be completed shortly! +customnpcs.commands.movedata.operation_success =SUCCESS! The data transfer was successful. +customnpcs.commands.movedata.operation_failure =ERROR! The data transfer was not successful. Check the server logs for details. #=====================================# # Actions Messages # #=====================================# diff --git a/core/src/main/resources/paper-plugin.yml b/core/src/main/resources/paper-plugin.yml index 1e0ea964..1a0870a0 100644 --- a/core/src/main/resources/paper-plugin.yml +++ b/core/src/main/resources/paper-plugin.yml @@ -44,6 +44,7 @@ permissions: - customnpcs.run_command.enable_console - customnpcs.commands.wiki - customnpcs.commands.fix_config + - customnpcs.commands.movedata customnpcs.commands.*: description: A wildcard permission for all command permissions default: op @@ -102,6 +103,9 @@ permissions: customnpcs.alert: description: A permission to alert if there is a new update available. default: op + customnpcs.commands.movedata: + description: A permission required to use the /npc movedata command + default: op # This permission is only a child of the customnpcs.* permission. # It is incredibly important that this permission is tightly regulated From 74c40e4b2d1df32b68cd9347c4922f71e2fc4236 Mon Sep 17 00:00:00 2001 From: foxikle Date: Sat, 5 Apr 2025 06:36:01 -0400 Subject: [PATCH 19/25] Fix async error creating NPCs --- .../foxikle/customnpcs/internal/storage/StorageManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java index 480d8eb8..1e17d28e 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/storage/StorageManager.java @@ -668,7 +668,8 @@ public boolean loadNPC(UUID uuid) { brokenNPCs.put(uuid, proto); return false; } - npc.createNPC(); + // has to be on a sync thread + Bukkit.getScheduler().runTask(plugin, npc::createNPC); return true; } From 75d18cb3dce6d8d6d7c2bd5e061dae478380d8f4 Mon Sep 17 00:00:00 2001 From: Foxikle Date: Sat, 5 Apr 2025 09:11:28 -0400 Subject: [PATCH 20/25] Update core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../foxikle/customnpcs/internal/commands/MoveDataCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java index 266e7281..77a5eb54 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java @@ -56,7 +56,6 @@ public void usage(BukkitSource source, @Named("operation") @Suggest({"MERGE_REMO source.reply(Msg.translate(CommandUtils.getLocale(source), "customnpcs.commands.movedata.invalid_operation")); return; } - checkValidOperation(operation); if (source.isConsole()) { if (!console_confirmed) { console_confirmed = true; From fa48f821fe31601f0175fa31b587d492f385da4c Mon Sep 17 00:00:00 2001 From: Foxikle Date: Wed, 3 Sep 2025 18:12:19 -0400 Subject: [PATCH 21/25] Add conditions for injection --- .../foxikle/customnpcs/actions/Action.java | 2 +- .../java/dev/foxikle/customnpcs/api/NPC.java | 28 +++++- .../customnpcs/api/events/NpcInjectEvent.java | 22 +++++ .../customnpcs/internal/CustomNPCs.java | 8 +- .../customnpcs/internal/FileManager.java | 34 +++++++- .../customnpcs/internal/InjectionManager.java | 10 ++- .../internal/commands/CreateCommand.java | 3 +- .../internal/commands/EditCommand.java | 2 +- .../internal/commands/MoveCommand.java | 4 +- .../internal/interfaces/InternalNpc.java | 46 ++++++++++ .../internal/listeners/Listeners.java | 2 +- .../customnpcs/versions/NPC_v1_20_R1.java | 49 ++++++++--- .../customnpcs/versions/NPC_v1_20_R2.java | 47 +++++++--- .../customnpcs/versions/NPC_v1_20_R3.java | 48 ++++++++--- .../customnpcs/versions/NPC_v1_20_R4.java | 50 ++++++++--- .../customnpcs/versions/NPC_v1_21_R0.java | 49 ++++++++--- .../customnpcs/versions/NPC_v1_21_R1.java | 48 ++++++++--- .../customnpcs/versions/NPC_v1_21_R2.java | 86 +++++++++++-------- .../customnpcs/versions/NPC_v1_21_R3.java | 65 ++++++++------ .../customnpcs/versions/NPC_v1_21_R4.java | 45 +++++++--- 20 files changed, 484 insertions(+), 164 deletions(-) diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/Action.java b/core/src/main/java/dev/foxikle/customnpcs/actions/Action.java index 986b200e..0939a715 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/Action.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/Action.java @@ -53,7 +53,7 @@ public abstract class Action { private int delay = 0; private Condition.SelectionMode mode = Condition.SelectionMode.ONE; private int cooldown = 0; - private Map cooldowns = new ConcurrentHashMap<>(); + private final Map cooldowns = new ConcurrentHashMap<>(); /** * Default constructor diff --git a/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java b/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java index 470bb5d7..b577e508 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java +++ b/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java @@ -25,6 +25,7 @@ import com.google.common.base.Preconditions; import dev.foxikle.customnpcs.actions.Action; import dev.foxikle.customnpcs.actions.LegacyAction; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.events.NpcDeleteEvent; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -79,7 +80,7 @@ public NPC(@NotNull World world) { UUID uuid = UUID.randomUUID(); Settings settings = new Settings(); settings.setResilient(false); - this.npc = NPCApi.plugin.createNPC(world, new Location(world, 0, 0, 0), new Equipment(), settings, uuid, null, new ArrayList<>()); + this.npc = NPCApi.plugin.createNPC(world, new Location(world, 0, 0, 0), new Equipment(), settings, uuid, null, new ArrayList<>(), new ArrayList<>(), Condition.SelectionMode.ONE); } /** @@ -238,6 +239,11 @@ public void swingArm() { /** * Injects the npc into the player's connection. This should be handled by the plugin, but this is here for more control. * + *

+ * This feature bypasses injection conditions! If you would like to have the plugin reevaluate if a player should + * be injected, you can remove this NPC from their client with {@link NPC#withdraw(Player)}, and + *

+ * * @param player the player to inject * @see Player * @since 1.5.2-pre3 @@ -390,4 +396,24 @@ public Location getLocation() { public void reloadSettings() { npc.reloadSettings(); } + + /** + * The inverse operation of injecting this NPC into a player's client. + *

+ * This does **NOT** remove the NPC from the server, and the npc may be reinjected later. + *

+ * @param player the player to remove the NPC from + */ + public void withdraw(Player player) { + npc.withdraw(player); + } + + /** + * Tells this NPC's InjectionManager to inject this player again, on the next injection check. This may cause the + * NPC to twitch and flicker. + * @param player the player to mark for injection. Only this player will be affected + */ + public void markForInjection(Player player){ + npc.getInjectionManager().markForInjection(player.getUniqueId()); + } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/api/events/NpcInjectEvent.java b/core/src/main/java/dev/foxikle/customnpcs/api/events/NpcInjectEvent.java index 0384a49a..0eefc465 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/api/events/NpcInjectEvent.java +++ b/core/src/main/java/dev/foxikle/customnpcs/api/events/NpcInjectEvent.java @@ -22,9 +22,14 @@ package dev.foxikle.customnpcs.api.events; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import lombok.Getter; import org.bukkit.entity.Player; +import org.jetbrains.annotations.ApiStatus; + +import java.util.HashMap; +import java.util.Map; /** * A class representing an event called upon the injection of an NPC. @@ -34,16 +39,33 @@ public class NpcInjectEvent extends NpcEvent { private final double distanceSquared; + private final Map conditions; /** * The constructor for the event * * @param player the player associated with the action * @param npc the npc involved in the event + * @deprecated Use the constructor with the conditions */ + @Deprecated + @ApiStatus.ScheduledForRemoval(inVersion = "1.9.0") public NpcInjectEvent(Player player, InternalNpc npc, double distanceSquared) { super(player, npc, true); this.distanceSquared = distanceSquared; + conditions = new HashMap<>(); + } + + /** + * The constructor for the event + * + * @param player the player associated with the action + * @param npc the npc involved in the event + */ + public NpcInjectEvent(Player player, InternalNpc npc, double distanceSquared, Map conditions) { + super(player, npc, true); + this.distanceSquared = distanceSquared; + this.conditions = conditions; } /** diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java index 4b052645..1320d915 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java @@ -467,16 +467,16 @@ public void onPluginMessageReceived(@NotNull String channel, @NotNull Player pla * @param settings the settings object representing the NPC's settings * @param uuid the NPC's UUID * @param target the NPC's target to follow - * @param actionImpls the NPC's actions + * @param actions the NPC's actions * @return the created NPC * @throws RuntimeException If the reflective creation of the NPC object fails */ - public InternalNpc createNPC(World world, Location location, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actionImpls) { + public InternalNpc createNPC(World world, Location location, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List conditions, Condition.SelectionMode injectionMode) { try { Class clazz = Class.forName(String.format(NPC_CLASS, translateVersion())); return (InternalNpc) clazz - .getConstructor(this.getClass(), World.class, Location.class, Equipment.class, Settings.class, UUID.class, Player.class, List.class) - .newInstance(this, world, location, equipment, settings, uuid, target, actionImpls); + .getConstructor(this.getClass(), World.class, Location.class, Equipment.class, Settings.class, UUID.class, Player.class, List.class, List.class, Condition.SelectionMode.class) + .newInstance(this, world, location, equipment, settings, uuid, target, actions, conditions, injectionMode); } catch (ReflectiveOperationException e) { getLogger().log(Level.SEVERE, "An error occurred whilst creating the NPC '{name}! This is most likely a configuration issue.".replace("{name}", settings.getName()), e); throw new RuntimeException(e); diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java index f6e3d46a..6bf86a68 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java @@ -466,6 +466,33 @@ public boolean createFiles() { } } + if (version.equals("1.9")) { + plugin.getLogger().warning("Old NPC file version found! Bumping version! (1.9 -> 1.10)"); + BackupResult br = createBackup(file); + if (!br.success) { + plugin.getLogger().warning("Could not create backup before updating npcs.yml!"); + return false; + } + yml.set("version", "1.9"); + + Set npcs = yml.getKeys(false); + for (String npc : npcs) { + if (npc.equals("version")) continue; // its a key + ConfigurationSection section = yml.getConfigurationSection(npc); + + assert section != null : "Section is null -- Upgrading NPC file from 1.9 to 1.10"; + + section.set("injectionConditionSelector", Condition.SelectionMode.ONE.name()); + section.set("injectionConditions", CustomNPCs.getGson().toJson(new ArrayList<>(), Utils.CONDITIONS_LIST)); + + } + try { + yml.save(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + // check for valid NPCs: boolean found = false; Set npcs = yml.getKeys(false); @@ -532,6 +559,8 @@ public void addNPC(InternalNpc npc) { section.addDefault("world", npc.getWorld().getName()); section.addDefault("tunnelvision", npc.getSettings().isTunnelvision()); section.addDefault("upsideDown", npc.getSettings().isUpsideDown()); + section.addDefault("injectionConditionSelector", npc.getInjectionSelectionMode()); + section.addDefault("injectionConditions", CustomNPCs.getGson().toJson(npc.getInjectionConditions(), Utils.CONDITIONS_LIST)); yml.options().copyDefaults(true); try { yml.save(file); @@ -624,6 +653,7 @@ public void loadNPC(UUID uuid) { actions.add(Action.parse(s)); } + InternalNpc npc = plugin.createNPC( world, location, @@ -647,7 +677,9 @@ public void loadNPC(UUID uuid) { section.getBoolean("hideInteractableHologram"), parsePose(section.getString("pose")), section.getBoolean("upsideDown") - ), uuid, null, actions); + ), uuid, null, actions, + CustomNPCs.getGson().fromJson(section.getString("injectionConditions"), Utils.CONDITIONS_LIST), + Condition.SelectionMode.valueOf(section.getString("injectionConditionSelector"))); if (npc != null) { npc.createNPC(); } else { diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/InjectionManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/InjectionManager.java index 118a7b17..5ee52cdd 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/InjectionManager.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/InjectionManager.java @@ -45,6 +45,10 @@ public InjectionManager(CustomNPCs plugin, InternalNpc npc) { INJECTION_DISTANCE = (int) Math.pow(plugin.getConfig().getInt("InjectionDistance"), 2); } + public void markForInjection(UUID player) { + isVisible.put(player, false); + } + public void setup() { if (task != -1) shutDown(); task = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this::checkForInjections, 0, plugin.getConfig().getInt("InjectionInterval")).getTaskId(); @@ -79,9 +83,13 @@ private void checkForInjections() { } if (distance <= INJECTION_DISTANCE && !isVisible.getOrDefault(player.getUniqueId(), false)) { - NpcInjectEvent injectEvent = new NpcInjectEvent(player, npc, distance); + + + + NpcInjectEvent injectEvent = new NpcInjectEvent(player, npc, distance, npc.evaluateInjectionConditions(player)); Bukkit.getServer().getPluginManager().callEvent(injectEvent); if (injectEvent.isCancelled()) continue; + if (!npc.passesInectionConditions(player)) continue; npc.injectPlayer(player); isVisible.put(player.getUniqueId(), true); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CreateCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CreateCommand.java index c2a4b515..567c7c44 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CreateCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CreateCommand.java @@ -22,6 +22,7 @@ package dev.foxikle.customnpcs.internal.commands; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -49,7 +50,7 @@ public void usage(BukkitSource source) { final Player p = source.asPlayer(); final UUID uuid = UUID.randomUUID(); final CustomNPCs plugin = CustomNPCs.getInstance(); - InternalNpc npc = plugin.createNPC(p.getWorld(), p.getLocation(), new Equipment(), new Settings(), uuid, null, new ArrayList<>()); + InternalNpc npc = plugin.createNPC(p.getWorld(), p.getLocation(), new Equipment(), new Settings(), uuid, null, new ArrayList<>(), new ArrayList<>(), Condition.SelectionMode.ONE); plugin.getEditingNPCs().put(p.getUniqueId(), npc); plugin.getLotus().openMenu(p, MenuUtils.NPC_MAIN); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/EditCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/EditCommand.java index 86626360..ea758260 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/EditCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/EditCommand.java @@ -59,7 +59,7 @@ public void editNpc( final CustomNPCs plugin = CustomNPCs.getInstance(); final InternalNpc finalNpc = plugin.getNPCByID(uuid); Bukkit.getScheduler().runTaskLater(plugin, () -> { - InternalNpc newNpc = plugin.createNPC(p.getWorld(), finalNpc.getSpawnLoc(), finalNpc.getEquipment(), finalNpc.getSettings(), finalNpc.getUniqueID(), null, finalNpc.getActions()); + InternalNpc newNpc = plugin.createNPC(p.getWorld(), finalNpc.getSpawnLoc(), finalNpc.getEquipment(), finalNpc.getSettings(), finalNpc.getUniqueID(), null, finalNpc.getActions(), finalNpc.getInjectionConditions(), finalNpc.getInjectionSelectionMode()); plugin.getEditingNPCs().put(p.getUniqueId(), newNpc); plugin.getLotus().openMenu(p, MenuUtils.NPC_MAIN); }, 1); diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java index 376d829a..264f7faf 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveCommand.java @@ -62,7 +62,9 @@ public void usage( finalNpc.teleport(p.getLocation()); finalNpc.remove(); finalNpc.createNPC(); - Bukkit.getOnlinePlayers().forEach(finalNpc::injectPlayer); + Bukkit.getOnlinePlayers().forEach(pl -> + finalNpc.getInjectionManager().markForInjection(pl.getUniqueId()) + ); } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/interfaces/InternalNpc.java b/core/src/main/java/dev/foxikle/customnpcs/internal/interfaces/InternalNpc.java index eef23b32..95bf4bf5 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/interfaces/InternalNpc.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/interfaces/InternalNpc.java @@ -23,8 +23,10 @@ package dev.foxikle.customnpcs.internal.interfaces; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; +import dev.foxikle.customnpcs.internal.InjectionManager; import dev.foxikle.customnpcs.internal.LookAtAnchor; import org.bukkit.Location; import org.bukkit.Particle; @@ -37,7 +39,9 @@ import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -55,6 +59,28 @@ public interface InternalNpc { */ void setPosRot(Location location); + /** + * Gets the list of conditions checked upon injection checks + * @return + */ + List getInjectionConditions(); + + /** + * Gets this NPC's InjectionManager to handle marking players for reinjection + * @return + */ + InjectionManager getInjectionManager(); + + /** + * Gets which selection mode should be used when determining if this NPC should be injectioned + * @return return the desired {@link Condition.SelectionMode} + */ + Condition.SelectionMode getInjectionSelectionMode(); + + void setInjectionConditions(List conditions); + + void setInjectionSelectionMode(Condition.SelectionMode mode); + /** *

Creates the NPC and injects it into every player *

@@ -307,4 +333,24 @@ public interface InternalNpc { InternalNpc clone(); void teleport(Location loc); + + /** + * Remove this NPC from this player. + * @param player the player to withdraw + */ + void withdraw(Player player); + + default Map evaluateInjectionConditions(Player player){ + Map map = new HashMap<>(); + for (Condition c : getInjectionConditions()) { + map.put(c, c.compute(player)); + } + return map; + } + + default boolean passesInectionConditions(Player player) { + Map map = evaluateInjectionConditions(player); + if (map.isEmpty()) return true; + return (getInjectionSelectionMode() == Condition.SelectionMode.ALL ? !map.containsValue(false) : map.containsValue(true)); + } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java b/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java index 94c44761..2a12cc2b 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java @@ -608,7 +608,7 @@ public void onRespawn(PlayerRespawnEvent e) { double distanceSquared = location.distanceSquared(spawnLocation); if (distanceSquared <= FIFTY_BLOCKS) { - SCHEDULER.runTaskLater(plugin, () -> npc.injectPlayer(player), 5); + SCHEDULER.runTaskLater(plugin, () -> npc.getInjectionManager().markForInjection(player.getUniqueId()), 5); } if (distanceSquared <= FIVE_BLOCKS && !npc.getSettings().isTunnelvision()) { diff --git a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java index cd1fc194..f4e8aeb5 100644 --- a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java +++ b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java @@ -26,6 +26,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -77,39 +78,35 @@ /** * The object representing the NPC */ +@Getter public class NPC_v1_20_R1 extends ServerPlayer implements InternalNpc { - @Getter private final UUID uniqueID; - @Getter private final Particle spawnParticle = Particle.EXPLOSION_LARGE; private final CustomNPCs plugin; - @Getter private final World world; private final EntityDataAccessor TEXT_DISPLAY_ACCESSOR; private final Map loops = new HashMap<>(); - @Getter @Setter private Equipment equipment; - @Getter @Setter private Settings settings; - @Getter @Setter private Location spawnLoc; private @Nullable ArmorStand seat; - @Getter private TextDisplay clickableHologram; - @Getter private List holograms; - @Getter @Setter private Player target; - @Getter @Setter private List actions; private String clickableName = "ERROR"; private InjectionManager injectionManager; + @Setter + private List injectionConditions; + @Setter + private Condition.SelectionMode injectionSelectionMode; + /** *

Gets a new NPC @@ -124,7 +121,7 @@ public class NPC_v1_20_R1 extends ServerPlayer implements InternalNpc { * @param equipment The NPC's equipment * @param settings The NPC's settings */ - public NPC_v1_20_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions) { + public NPC_v1_20_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID))); this.spawnLoc = spawnLoc; this.equipment = equipment; @@ -135,6 +132,8 @@ public NPC_v1_20_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment this.actions = new ArrayList<>(actions); super.connection = new FakeListener_v1_20_R1(((CraftServer) Bukkit.getServer()).getServer(), new FakeConnection_v1_20_R1(PacketFlow.CLIENTBOUND), this); this.plugin = plugin; + this.injectionConditions = injectionConditions; + this.injectionSelectionMode = injectionSelectionMode; //aL is the text data accessor try { @@ -437,6 +436,32 @@ public void teleport(Location loc) { } + @Override + public void withdraw(Player player) { + loops.remove(player.getUniqueId()); + List> packets = new ArrayList<>(); + + if (holograms != null) { + for (TextDisplay hologram : holograms) { + packets.add(new ClientboundRemoveEntitiesPacket(hologram.getEntityId())); + } + } + + if (clickableHologram != null) { + packets.add(new ClientboundRemoveEntitiesPacket(clickableHologram.getEntityId())); + } + packets.add(new ClientboundRemoveEntitiesPacket(super.getId())); + + ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection; + + + packets.forEach(connection::send); + if (plugin.isEnabled()) { + Bukkit.getScheduler().runTaskLater(plugin, () -> packets.forEach(connection::send), 1); + } + } + + @Override public void delete() { plugin.getFileManager().remove(this.uniqueID); @@ -564,7 +589,7 @@ public double getPoseOffset(Pose pose) { @Override public InternalNpc clone() { - return new NPC_v1_20_R1(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions)); + return new NPC_v1_20_R1(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions), new ArrayList<>(injectionConditions), injectionSelectionMode); } @Override diff --git a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java index bf1e873e..cd8ed435 100644 --- a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java +++ b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java @@ -26,6 +26,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -77,41 +78,36 @@ /** * The object representing the NPC */ +@Getter public class NPC_v1_20_R2 extends ServerPlayer implements InternalNpc { - @Getter private final UUID uniqueID; - @Getter private final Particle spawnParticle = Particle.EXPLOSION_LARGE; private final CustomNPCs plugin; - @Getter private final World world; private final EntityDataAccessor TEXT_DISPLAY_ACCESSOR; private final Map loops = new HashMap<>(); - @Getter @Setter private Settings settings; - @Getter @Setter private Equipment equipment; - @Getter @Setter private Location spawnLoc; private @Nullable ArmorStand seat; - @Getter private TextDisplay clickableHologram; - @Getter private List holograms; - @Getter @Setter private Player target; - @Getter @Setter private List actions; private String clickableName = "ERROR"; + @Getter private InjectionManager injectionManager; + @Setter private List injectionConditions; + @Setter private Condition.SelectionMode injectionSelectionMode; + - public NPC_v1_20_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions) { + public NPC_v1_20_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.settings = settings; @@ -122,6 +118,8 @@ public NPC_v1_20_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment this.actions = new ArrayList<>(actions); super.connection = new FakeListener_v1_20_R2(((CraftServer) Bukkit.getServer()).getServer(), new FakeConnection_v1_20_R2(PacketFlow.CLIENTBOUND), this); this.plugin = plugin; + this.injectionConditions = injectionConditions; + this.injectionSelectionMode = injectionSelectionMode; //aM try { @@ -514,7 +512,7 @@ public double getPoseOffset(Pose pose) { @Override public InternalNpc clone() { - return new NPC_v1_20_R2(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions)); + return new NPC_v1_20_R2(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions), new ArrayList<>(injectionConditions), injectionSelectionMode); } @@ -527,5 +525,30 @@ public float getYaw() { public float getPitch() { return getXRot(); } + + @Override + public void withdraw(Player player) { + loops.remove(player.getUniqueId()); + List> packets = new ArrayList<>(); + + if (holograms != null) { + for (TextDisplay hologram : holograms) { + packets.add(new ClientboundRemoveEntitiesPacket(hologram.getEntityId())); + } + } + + if (clickableHologram != null) { + packets.add(new ClientboundRemoveEntitiesPacket(clickableHologram.getEntityId())); + } + packets.add(new ClientboundRemoveEntitiesPacket(super.getId())); + + ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection; + + + packets.forEach(connection::send); + if (plugin.isEnabled()) { + Bukkit.getScheduler().runTaskLater(plugin, () -> packets.forEach(connection::send), 1); + } + } } diff --git a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java index 134ae629..b1f8bf0d 100644 --- a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java +++ b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java @@ -26,6 +26,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -77,42 +78,36 @@ /** * The object representing the NPC */ +@Getter public class NPC_v1_20_R3 extends ServerPlayer implements InternalNpc { // reflection for data accessors private final EntityDataAccessor TEXT_DISPLAY_ACCESSOR; - @Getter private final Particle spawnParticle = Particle.EXPLOSION_LARGE; - @Getter private final UUID uniqueID; private final CustomNPCs plugin; - @Getter private final World world; private final Map loops = new HashMap<>(); - @Getter @Setter private Settings settings; - @Getter @Setter private Equipment equipment; - @Getter @Setter private Location spawnLoc; private @Nullable ArmorStand seat; - @Getter private TextDisplay clickableHologram; - @Getter private List holograms; - @Getter @Setter private Player target; - @Getter @Setter private List actions; private String clickableName = "ERROR"; private InjectionManager injectionManager; + @Setter private List injectionConditions; + @Setter private Condition.SelectionMode injectionSelectionMode; - public NPC_v1_20_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions) { + + public NPC_v1_20_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; @@ -122,7 +117,9 @@ public NPC_v1_20_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment this.target = target; this.actions = actions; super.connection = new FakeListener_v1_20_R3(((CraftServer) Bukkit.getServer()).getServer(), new FakeConnection_v1_20_R3(PacketFlow.CLIENTBOUND), this); - this.plugin = plugin; + this.plugin = plugin; + this.injectionConditions = injectionConditions; + this.injectionSelectionMode = injectionSelectionMode; // aM try { @@ -520,7 +517,7 @@ public double getPoseOffset(Pose pose) { @Override public InternalNpc clone() { - return new NPC_v1_20_R3(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions)); + return new NPC_v1_20_R3(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions), new ArrayList<>(injectionConditions), injectionSelectionMode); } @@ -533,5 +530,30 @@ public float getYaw() { public float getPitch() { return getXRot(); } + + @Override + public void withdraw(Player player) { + loops.remove(player.getUniqueId()); + List> packets = new ArrayList<>(); + + if (holograms != null) { + for (TextDisplay hologram : holograms) { + packets.add(new ClientboundRemoveEntitiesPacket(hologram.getEntityId())); + } + } + + if (clickableHologram != null) { + packets.add(new ClientboundRemoveEntitiesPacket(clickableHologram.getEntityId())); + } + packets.add(new ClientboundRemoveEntitiesPacket(super.getId())); + + ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection; + + + packets.forEach(connection::send); + if (plugin.isEnabled()) { + Bukkit.getScheduler().runTaskLater(plugin, () -> packets.forEach(connection::send), 1); + } + } } diff --git a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java index dc6a1ce3..f7610a1e 100644 --- a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java +++ b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java @@ -26,6 +26,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -79,6 +80,7 @@ /** * The object representing the NPC */ +@Getter public class NPC_v1_20_R4 extends ServerPlayer implements InternalNpc { private static final EntityDataAccessor TEXT_DISPLAY_ACCESSOR; @@ -95,38 +97,31 @@ public class NPC_v1_20_R4 extends ServerPlayer implements InternalNpc { } - @Getter private final Particle spawnParticle = Particle.EXPLOSION; - @Getter private final UUID uniqueID; private final CustomNPCs plugin; - @Getter private final World world; private final Map loops = new HashMap<>(); - @Getter @Setter private Settings settings; - @Getter @Setter private Equipment equipment; - @Getter @Setter private Location spawnLoc; private @Nullable ArmorStand seat; - @Getter private TextDisplay clickableHologram; - @Getter private List holograms; - @Getter @Setter private Player target; - @Getter @Setter private List actions; private String clickableName = "ERROR"; - private InjectionManager injectionManager; + @Getter private InjectionManager injectionManager; + @Setter private List injectionConditions; + @Setter private Condition.SelectionMode injectionSelectionMode; - public NPC_v1_20_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions) { + + public NPC_v1_20_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uuid, Utils.getNpcName(settings, uuid)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; @@ -136,7 +131,9 @@ public NPC_v1_20_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment this.target = target; this.actions = actions; super.connection = new FakeListener_v1_20_R4(((CraftServer) Bukkit.getServer()).getServer(), new FakeConnection_v1_20_R4(PacketFlow.CLIENTBOUND), this); - this.plugin = plugin; + this.plugin = plugin; + this.injectionConditions = injectionConditions; + this.injectionSelectionMode = injectionSelectionMode; } public void setPosRot(Location location) { @@ -537,7 +534,7 @@ public double getPoseOffset(Pose pose) { @Override public InternalNpc clone() { - return new NPC_v1_20_R4(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions)); + return new NPC_v1_20_R4(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions), new ArrayList<>(injectionConditions), injectionSelectionMode); } @@ -550,5 +547,30 @@ public float getYaw() { public float getPitch() { return getXRot(); } + + @Override + public void withdraw(Player player) { + loops.remove(player.getUniqueId()); + List> packets = new ArrayList<>(); + + if (holograms != null) { + for (TextDisplay hologram : holograms) { + packets.add(new ClientboundRemoveEntitiesPacket(hologram.getEntityId())); + } + } + + if (clickableHologram != null) { + packets.add(new ClientboundRemoveEntitiesPacket(clickableHologram.getEntityId())); + } + packets.add(new ClientboundRemoveEntitiesPacket(super.getId())); + + ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection; + + + packets.forEach(connection::send); + if (plugin.isEnabled()) { + Bukkit.getScheduler().runTaskLater(plugin, () -> packets.forEach(connection::send), 1); + } + } } diff --git a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java index 361b90d0..1f067cca 100644 --- a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java +++ b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java @@ -26,6 +26,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -76,6 +77,7 @@ import java.util.*; import java.util.stream.Stream; +@Getter public class NPC_v1_21_R0 extends ServerPlayer implements InternalNpc { // reflection for data accessors @@ -92,39 +94,33 @@ public class NPC_v1_21_R0 extends ServerPlayer implements InternalNpc { } } - @Getter private final Particle spawnParticle = Particle.EXPLOSION; - @Getter private final UUID uniqueID; private final CustomNPCs plugin; - @Getter private final World world; private final Map loops = new HashMap<>(); - @Getter @Setter private Settings settings; - @Getter @Setter private Equipment equipment; - @Getter @Setter private Location spawnLoc; private @Nullable ArmorStand seat; - @Getter private TextDisplay clickableHologram; - @Getter private List holograms; - @Getter @Setter private Player target; - @Getter @Setter - private List actions; private String clickableName = "ERROR"; private InjectionManager injectionManager; + @Setter + private List injectionConditions; + @Setter + private Condition.SelectionMode injectionSelectionMode; - public NPC_v1_21_R0(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions) { + + public NPC_v1_21_R0(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; @@ -135,6 +131,8 @@ public NPC_v1_21_R0(CustomNPCs plugin, World world, Location spawnLoc, Equipment this.actions = actions; super.connection = new FakeListener_v1_21_R0(((CraftServer) Bukkit.getServer()).getServer(), new FakeConnection_v1_21_R0(PacketFlow.CLIENTBOUND), this); this.plugin = plugin; + this.injectionConditions = injectionConditions; + this.injectionSelectionMode = injectionSelectionMode; } public void setPosRot(Location location) { @@ -526,7 +524,7 @@ public double getPoseOffset(Pose pose) { @Override public InternalNpc clone() { - return new NPC_v1_21_R0(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions)); + return new NPC_v1_21_R0(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions), new ArrayList<>(injectionConditions), injectionSelectionMode); } @@ -539,5 +537,30 @@ public float getYaw() { public float getPitch() { return getXRot(); } + + @Override + public void withdraw(Player player) { + loops.remove(player.getUniqueId()); + List> packets = new ArrayList<>(); + + if (holograms != null) { + for (TextDisplay hologram : holograms) { + packets.add(new ClientboundRemoveEntitiesPacket(hologram.getEntityId())); + } + } + + if (clickableHologram != null) { + packets.add(new ClientboundRemoveEntitiesPacket(clickableHologram.getEntityId())); + } + packets.add(new ClientboundRemoveEntitiesPacket(super.getId())); + + ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection; + + + packets.forEach(connection::send); + if (plugin.isEnabled()) { + Bukkit.getScheduler().runTaskLater(plugin, () -> packets.forEach(connection::send), 1); + } + } } diff --git a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java index 760e7844..cc65ed01 100644 --- a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java +++ b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java @@ -26,6 +26,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -77,6 +78,7 @@ import java.util.*; import java.util.stream.Stream; +@Getter public class NPC_v1_21_R1 extends ServerPlayer implements InternalNpc { // reflection for data accessors @@ -93,38 +95,33 @@ public class NPC_v1_21_R1 extends ServerPlayer implements InternalNpc { } } - @Getter private final Particle spawnParticle = Particle.EXPLOSION; - @Getter private final UUID uniqueID; private final CustomNPCs plugin; - @Getter private final World world; private final Map loops = new HashMap<>(); - @Getter @Setter private Settings settings; - @Getter @Setter private Equipment equipment; @Setter - @Getter private Location spawnLoc; private @Nullable ArmorStand seat; - @Getter private TextDisplay clickableHologram; - @Getter private List holograms; - @Getter @Setter private Player target; @Setter - @Getter private List actions; private String clickableName = "ERROR"; private InjectionManager injectionManager; + @Setter + private List injectionConditions; + @Setter + private Condition.SelectionMode injectionSelectionMode; + - public NPC_v1_21_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions) { + public NPC_v1_21_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uuid, Utils.getNpcName(settings, uuid)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; @@ -135,6 +132,8 @@ public NPC_v1_21_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment this.actions = actions; super.connection = new FakeListener_v1_21_R1(((CraftServer) Bukkit.getServer()).getServer(), new FakeConnection_v1_21_R1(PacketFlow.CLIENTBOUND), this); this.plugin = plugin; + this.injectionConditions = injectionConditions; + this.injectionSelectionMode = injectionSelectionMode; } public void setPosRot(Location location) { @@ -526,7 +525,7 @@ public double getPoseOffset(Pose pose) { @Override public InternalNpc clone() { - return new NPC_v1_21_R1(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions)); + return new NPC_v1_21_R1(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions), new ArrayList<>(injectionConditions), injectionSelectionMode); } @@ -539,5 +538,30 @@ public float getYaw() { public float getPitch() { return getXRot(); } + + @Override + public void withdraw(Player player) { + loops.remove(player.getUniqueId()); + List> packets = new ArrayList<>(); + + if (holograms != null) { + for (TextDisplay hologram : holograms) { + packets.add(new ClientboundRemoveEntitiesPacket(hologram.getEntityId())); + } + } + + if (clickableHologram != null) { + packets.add(new ClientboundRemoveEntitiesPacket(clickableHologram.getEntityId())); + } + packets.add(new ClientboundRemoveEntitiesPacket(super.getId())); + + ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection; + + + packets.forEach(connection::send); + if (plugin.isEnabled()) { + Bukkit.getScheduler().runTaskLater(plugin, () -> packets.forEach(connection::send), 1); + } + } } diff --git a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java index 665f24dc..0801b80f 100644 --- a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java +++ b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java @@ -26,6 +26,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -80,6 +81,7 @@ /** * The object representing the NPC */ +@Getter public class NPC_v1_21_R2 extends ServerPlayer implements InternalNpc { // reflection for data accessors @@ -95,52 +97,45 @@ public class NPC_v1_21_R2 extends ServerPlayer implements InternalNpc { throw new RuntimeException(e); } } - - @Getter + private final UUID uniqueID; private final CustomNPCs plugin; - @Getter private final World world; private final Map loops = new HashMap<>(); - @Getter private final Particle spawnParticle = Particle.EXPLOSION; - @Getter @Setter private Settings settings; - @Getter @Setter private Equipment equipment; - @Getter @Setter private Location spawnLoc; private @Nullable ArmorStand seat; - @Getter private TextDisplay clickableHologram; - @Getter private List holograms; - @Getter @Setter private Player target; - @Getter @Setter private List actions; private String clickableName = "ERROR"; private InjectionManager injectionManager; + @Setter private List injectionConditions; + @Setter private Condition.SelectionMode injectionSelectionMode; + /** *

Gets a new NPC *

* - * @param actions The actions for the NPC to execute on interaction - * @param plugin The instance of the Main class - * @param uniqueID The UUID of the NPC (Should be the same as the gameprofile's uuid) - * @param spawnLoc The location to spawn the NPC - * @param target The Entity the NPC should follow - * @param world The world to create the NPC in - * @param settings The settings for the NPC - * @param equipment The NPC's equipment + * @param actions The actions for the NPC to execute on interaction + * @param plugin The instance of the Main class + * @param uniqueID The UUID of the NPC (Should be the same as the gameprofile's uuid) + * @param spawnLoc The location to spawn the NPC + * @param target The Entity the NPC should follow + * @param world The world to create the NPC in + * @param settings The settings for the NPC + * @param equipment The NPC's equipment */ - public NPC_v1_21_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions) { + public NPC_v1_21_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; @@ -150,7 +145,9 @@ public NPC_v1_21_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment this.target = target; this.actions = actions; super.connection = new FakeListener_v1_21_R2(((CraftServer) Bukkit.getServer()).getServer(), new FakeConnection_v1_21_R2(PacketFlow.CLIENTBOUND), this); - this.plugin = plugin; + this.plugin = plugin; + this.injectionConditions = injectionConditions; + this.injectionSelectionMode = injectionSelectionMode; } /** @@ -233,12 +230,7 @@ public void setupHolograms() { hologram.setBillboard(Display.Billboard.CENTER); hologram.addScoreboardTag("npcHologram"); hologram.setTeleportDuration(settings.getInterpolationDuration()); - hologram.setTransformation(new Transformation( - new Vector3f(0, (float) y, 0), - hologram.getTransformation().getLeftRotation(), - hologram.getTransformation().getScale(), - hologram.getTransformation().getRightRotation() - )); + hologram.setTransformation(new Transformation(new Vector3f(0, (float) y, 0), hologram.getTransformation().getLeftRotation(), hologram.getTransformation().getScale(), hologram.getTransformation().getRightRotation())); holograms.add(hologram); ((CraftTextDisplay) hologram).getHandle().startRiding(this, true); } @@ -254,12 +246,7 @@ public void setupClickableHologram(String name) { clickableHologram.addScoreboardTag("npcHologram"); clickableHologram.setTeleportDuration(settings.getInterpolationDuration()); - clickableHologram.setTransformation(new Transformation( - new Vector3f(0, (float) getPoseOffset(settings.getPose()), 0), - clickableHologram.getTransformation().getLeftRotation(), - clickableHologram.getTransformation().getScale(), - clickableHologram.getTransformation().getRightRotation() - )); + clickableHologram.setTransformation(new Transformation(new Vector3f(0, (float) getPoseOffset(settings.getPose()), 0), clickableHologram.getTransformation().getLeftRotation(), clickableHologram.getTransformation().getScale(), clickableHologram.getTransformation().getRightRotation())); ((CraftTextDisplay) clickableHologram).getHandle().startRiding(this, true); } @@ -293,8 +280,7 @@ public void injectPlayer(Player p) { stuffs.add(new Pair<>(net.minecraft.world.entity.EquipmentSlot.FEET, CraftItemStack.asNMSCopy(equipment.getBoots()))); ClientboundPlayerInfoUpdatePacket playerInfoAdd = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this); - ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uniqueID, getCurrentLocation().x(), getCurrentLocation().y(), getCurrentLocation().z(), - getYRot(), getXRot(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getYRot()); + ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uniqueID, getCurrentLocation().x(), getCurrentLocation().y(), getCurrentLocation().z(), getYRot(), getXRot(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getYRot()); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getYRot() * 256 / 360), (byte) (getXRot() * 256 / 360), true); @@ -471,8 +457,7 @@ public void reloadSettings() { holograms.clear(); } - if (clickableHologram != null) - clickableHologram.remove(); + if (clickableHologram != null) clickableHologram.remove(); setPose(setupPose(settings.getPose())); @@ -552,7 +537,7 @@ public double getPoseOffset(Pose pose) { @Override public InternalNpc clone() { - return new NPC_v1_21_R2(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions)); + return new NPC_v1_21_R2(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions), new ArrayList<>(injectionConditions), injectionSelectionMode); } @@ -565,5 +550,30 @@ public float getYaw() { public float getPitch() { return getXRot(); } + + @Override + public void withdraw(Player player) { + loops.remove(player.getUniqueId()); + List> packets = new ArrayList<>(); + + if (holograms != null) { + for (TextDisplay hologram : holograms) { + packets.add(new ClientboundRemoveEntitiesPacket(hologram.getEntityId())); + } + } + + if (clickableHologram != null) { + packets.add(new ClientboundRemoveEntitiesPacket(clickableHologram.getEntityId())); + } + packets.add(new ClientboundRemoveEntitiesPacket(super.getId())); + + ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection; + + + packets.forEach(connection::send); + if (plugin.isEnabled()) { + Bukkit.getScheduler().runTaskLater(plugin, () -> packets.forEach(connection::send), 1); + } + } } diff --git a/v1_21_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R3.java b/v1_21_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R3.java index fde836bf..e60acdd4 100644 --- a/v1_21_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R3.java +++ b/v1_21_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R3.java @@ -26,6 +26,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -81,6 +82,7 @@ /** * The object representing the NPC */ +@Getter public class NPC_v1_21_R3 extends ServerPlayer implements InternalNpc { // reflection for data accessors @@ -97,36 +99,29 @@ public class NPC_v1_21_R3 extends ServerPlayer implements InternalNpc { } } - @Getter private final UUID uniqueID; private final CustomNPCs plugin; - @Getter private final World world; private final Map loops = new HashMap<>(); - @Getter @Setter private Settings settings; - @Getter @Setter private Equipment equipment; - @Getter @Setter private Location spawnLoc; - @Getter private @Nullable TextDisplay clickableHologram; - @Getter private List holograms; private @Nullable ArmorStand seat; - @Getter @Setter private Player target; - @Getter @Setter private List actions; private String clickableName = "ERROR"; private InjectionManager injectionManager; + @Setter private List injectionConditions; + @Setter private Condition.SelectionMode injectionSelectionMode; - public NPC_v1_21_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions) { + public NPC_v1_21_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uuid, Utils.getNpcName(settings, uuid)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; @@ -137,6 +132,8 @@ public NPC_v1_21_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment this.actions = actions; super.connection = new FakeListener_v1_21_R3(((CraftServer) Bukkit.getServer()).getServer(), new FakeConnection_v1_21_R3(PacketFlow.CLIENTBOUND), this); this.plugin = plugin; + this.injectionConditions = injectionConditions; + this.injectionSelectionMode = injectionSelectionMode; } @Override @@ -212,12 +209,7 @@ public void setupHolograms() { hologram.setBillboard(Display.Billboard.CENTER); hologram.addScoreboardTag("npcHologram"); hologram.setTeleportDuration(settings.getInterpolationDuration()); - hologram.setTransformation(new Transformation( - new Vector3f(0, (float) y, 0), - hologram.getTransformation().getLeftRotation(), - hologram.getTransformation().getScale(), - hologram.getTransformation().getRightRotation() - )); + hologram.setTransformation(new Transformation(new Vector3f(0, (float) y, 0), hologram.getTransformation().getLeftRotation(), hologram.getTransformation().getScale(), hologram.getTransformation().getRightRotation())); holograms.add(hologram); ((CraftTextDisplay) hologram).getHandle().startRiding(this, true); } @@ -233,12 +225,7 @@ public void setupClickableHologram(String name) { clickableHologram.addScoreboardTag("npcHologram"); clickableHologram.setTeleportDuration(settings.getInterpolationDuration()); - clickableHologram.setTransformation(new Transformation( - new Vector3f(0, (float) getPoseOffset(settings.getPose()), 0), - clickableHologram.getTransformation().getLeftRotation(), - clickableHologram.getTransformation().getScale(), - clickableHologram.getTransformation().getRightRotation() - )); + clickableHologram.setTransformation(new Transformation(new Vector3f(0, (float) getPoseOffset(settings.getPose()), 0), clickableHologram.getTransformation().getLeftRotation(), clickableHologram.getTransformation().getScale(), clickableHologram.getTransformation().getRightRotation())); ((CraftTextDisplay) clickableHologram).getHandle().startRiding(this, true); } @@ -272,8 +259,7 @@ public void injectPlayer(Player p) { stuffs.add(new Pair<>(net.minecraft.world.entity.EquipmentSlot.FEET, CraftItemStack.asNMSCopy(equipment.getBoots()))); ClientboundPlayerInfoUpdatePacket playerInfoAdd = new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this); - ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uniqueID, spawnLoc.x(), spawnLoc.y(), spawnLoc.z(), - getYRot(), getXRot(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getYRot()); + ClientboundAddEntityPacket namedEntitySpawn = new ClientboundAddEntityPacket(getId(), uniqueID, spawnLoc.x(), spawnLoc.y(), spawnLoc.z(), getYRot(), getXRot(), net.minecraft.world.entity.EntityType.PLAYER, 0, new Vec3(0, 0, 0), getYRot()); ClientboundPlayerInfoRemovePacket playerInforemove = new ClientboundPlayerInfoRemovePacket(Collections.singletonList(super.getUUID())); ClientboundSetEquipmentPacket equipmentPacket = new ClientboundSetEquipmentPacket(super.getId(), stuffs); ClientboundMoveEntityPacket rotation = new ClientboundMoveEntityPacket.Rot(this.getBukkitEntity().getEntityId(), (byte) (getYRot() * 256 / 360), (byte) (getXRot() * 256 / 360), true); @@ -453,8 +439,7 @@ public void reloadSettings() { holograms.clear(); } - if (clickableHologram != null) - clickableHologram.remove(); + if (clickableHologram != null) clickableHologram.remove(); setPose(setupPose(settings.getPose())); @@ -550,8 +535,34 @@ private double getPoseOffset(Pose pose) { case SLEEPING -> 0.10D; }; } + @Override public InternalNpc clone() { - return new NPC_v1_21_R3(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions)); + return new NPC_v1_21_R3(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions), new ArrayList<>(injectionConditions), injectionSelectionMode); + } + + @Override + public void withdraw(Player player) { + loops.remove(player.getUniqueId()); + List> packets = new ArrayList<>(); + + if (holograms != null) { + for (TextDisplay hologram : holograms) { + packets.add(new ClientboundRemoveEntitiesPacket(hologram.getEntityId())); + } + } + + if (clickableHologram != null) { + packets.add(new ClientboundRemoveEntitiesPacket(clickableHologram.getEntityId())); + } + packets.add(new ClientboundRemoveEntitiesPacket(super.getId())); + + ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection; + + + packets.forEach(connection::send); + if (plugin.isEnabled()) { + Bukkit.getScheduler().runTaskLater(plugin, () -> packets.forEach(connection::send), 1); + } } } diff --git a/v1_21_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R4.java b/v1_21_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R4.java index 24711976..6c309c6b 100644 --- a/v1_21_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R4.java +++ b/v1_21_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R4.java @@ -28,6 +28,7 @@ import com.mojang.datafixers.util.Pair; import com.mojang.serialization.JsonOps; import dev.foxikle.customnpcs.actions.Action; +import dev.foxikle.customnpcs.actions.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; @@ -82,6 +83,7 @@ /** * The object representing the NPC */ +@Getter public class NPC_v1_21_R4 extends ServerPlayer implements InternalNpc { // reflection for data accessors @@ -98,36 +100,30 @@ public class NPC_v1_21_R4 extends ServerPlayer implements InternalNpc { } } - @Getter private final UUID uniqueID; private final CustomNPCs plugin; - @Getter private final World world; private final Map loops = new HashMap<>(); - @Getter @Setter private Settings settings; - @Getter @Setter private Equipment equipment; - @Getter @Setter private Location spawnLoc; - @Getter private @Nullable TextDisplay clickableHologram; - @Getter private List holograms; private @Nullable ArmorStand seat; - @Getter @Setter private Player target; - @Getter @Setter private List actions; private String clickableName = "ERROR"; private InjectionManager injectionManager; + @Setter private List injectionConditions; + @Setter private Condition.SelectionMode injectionSelectionMode; - public NPC_v1_21_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions) { + + public NPC_v1_21_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uuid, Utils.getNpcName(settings, uuid)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; @@ -138,6 +134,8 @@ public NPC_v1_21_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment this.actions = actions; super.connection = new FakeListener_v1_21_R4(((CraftServer) Bukkit.getServer()).getServer(), new FakeConnection_v1_21_R4(PacketFlow.CLIENTBOUND), this); this.plugin = plugin; + this.injectionConditions = injectionConditions; + this.injectionSelectionMode = injectionSelectionMode; } @Override @@ -559,6 +557,31 @@ private double getPoseOffset(Pose pose) { @Override public InternalNpc clone() { - return new NPC_v1_21_R4(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions)); + return new NPC_v1_21_R4(plugin, world, spawnLoc.clone(), equipment.clone(), settings.clone(), UUID.randomUUID(), target, new ArrayList<>(actions), new ArrayList<>(injectionConditions), injectionSelectionMode); + } + + @Override + public void withdraw(Player player) { + loops.remove(player.getUniqueId()); + List> packets = new ArrayList<>(); + + if (holograms != null) { + for (TextDisplay hologram : holograms) { + packets.add(new ClientboundRemoveEntitiesPacket(hologram.getEntityId())); + } + } + + if (clickableHologram != null) { + packets.add(new ClientboundRemoveEntitiesPacket(clickableHologram.getEntityId())); + } + packets.add(new ClientboundRemoveEntitiesPacket(super.getId())); + + ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection; + + + packets.forEach(connection::send); + if (plugin.isEnabled()) { + Bukkit.getScheduler().runTaskLater(plugin, () -> packets.forEach(connection::send), 1); + } } } From 32223a4d873a321b8e4b66b6926eca311cfbf8ea Mon Sep 17 00:00:00 2001 From: Foxikle Date: Wed, 3 Sep 2025 19:46:03 -0400 Subject: [PATCH 22/25] !! Breaking changes !! - removed conditional classes, move nested enums to standalone classes, rename SelectionMode to Selector --- .../foxikle/customnpcs/actions/Action.java | 21 +- .../{conditions => }/ActionAdapter.java | 11 +- .../customnpcs/actions/LegacyAction.java | 11 +- .../actions/conditions/Conditional.java | 302 ------------------ .../conditions/LogicalConditional.java | 182 ----------- .../conditions/NumericConditional.java | 188 ----------- .../actions/defaultImpl/ActionBar.java | 11 +- .../actions/defaultImpl/DisplayTitle.java | 11 +- .../actions/defaultImpl/GiveEffect.java | 11 +- .../actions/defaultImpl/GiveXP.java | 9 +- .../actions/defaultImpl/PlaySound.java | 11 +- .../actions/defaultImpl/RemoveEffect.java | 11 +- .../actions/defaultImpl/RemoveXP.java | 11 +- .../actions/defaultImpl/RunCommand.java | 11 +- .../actions/defaultImpl/SendMessage.java | 11 +- .../actions/defaultImpl/SendServer.java | 11 +- .../actions/defaultImpl/Teleport.java | 11 +- .../java/dev/foxikle/customnpcs/api/NPC.java | 5 +- .../customnpcs/api/events/NpcInjectEvent.java | 2 +- .../customnpcs/conditions/Comparator.java | 53 +++ .../{actions => }/conditions/Condition.java | 83 +---- .../conditions/ConditionalTypeAdapter.java | 7 +- .../conditions/LogicalCondition.java | 2 +- .../conditions/NumericCondition.java | 2 +- .../customnpcs/conditions/Selector.java | 16 + .../customnpcs/internal/CustomNPCs.java | 11 +- .../customnpcs/internal/FileManager.java | 11 +- .../internal/commands/CreateCommand.java | 5 +- .../internal/interfaces/InternalNpc.java | 11 +- .../internal/listeners/Listeners.java | 2 +- .../menu/ConditionCustomizerMenu.java | 2 +- .../customnpcs/internal/menu/MenuItems.java | 18 +- .../customnpcs/internal/utils/Utils.java | 2 +- .../customnpcs/versions/NPC_v1_20_R1.java | 7 +- .../customnpcs/versions/NPC_v1_20_R2.java | 7 +- .../customnpcs/versions/NPC_v1_20_R3.java | 7 +- .../customnpcs/versions/NPC_v1_20_R4.java | 7 +- .../customnpcs/versions/NPC_v1_21_R0.java | 7 +- .../customnpcs/versions/NPC_v1_21_R1.java | 7 +- .../customnpcs/versions/NPC_v1_21_R2.java | 7 +- .../customnpcs/versions/NPC_v1_21_R3.java | 7 +- .../customnpcs/versions/NPC_v1_21_R4.java | 7 +- 42 files changed, 242 insertions(+), 887 deletions(-) rename core/src/main/java/dev/foxikle/customnpcs/actions/{conditions => }/ActionAdapter.java (92%) delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java create mode 100644 core/src/main/java/dev/foxikle/customnpcs/conditions/Comparator.java rename core/src/main/java/dev/foxikle/customnpcs/{actions => }/conditions/Condition.java (74%) rename core/src/main/java/dev/foxikle/customnpcs/{actions => }/conditions/ConditionalTypeAdapter.java (93%) rename core/src/main/java/dev/foxikle/customnpcs/{actions => }/conditions/LogicalCondition.java (99%) rename core/src/main/java/dev/foxikle/customnpcs/{actions => }/conditions/NumericCondition.java (99%) create mode 100644 core/src/main/java/dev/foxikle/customnpcs/conditions/Selector.java diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/Action.java b/core/src/main/java/dev/foxikle/customnpcs/actions/Action.java index 0939a715..fd39b4e1 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/Action.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/Action.java @@ -22,7 +22,8 @@ package dev.foxikle.customnpcs.actions; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.utils.Utils; @@ -51,7 +52,7 @@ public abstract class Action { private List conditions = new ArrayList<>(); private int delay = 0; - private Condition.SelectionMode mode = Condition.SelectionMode.ONE; + private Selector mode = Selector.ONE; private int cooldown = 0; private final Map cooldowns = new ConcurrentHashMap<>(); @@ -62,7 +63,7 @@ public Action() { } - public Action(int delay, Condition.SelectionMode mode, List conditions, int cooldown) { + public Action(int delay, Selector mode, List conditions, int cooldown) { this.delay = delay; this.mode = mode; this.conditions = conditions; @@ -71,11 +72,11 @@ public Action(int delay, Condition.SelectionMode mode, List condition /** - * Deprecated, use {@link Action#Action(int, Condition.SelectionMode, List, int)} Action} + * Deprecated, use {@link Action#Action(int, Selector, List, int)} Action} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public Action(int delay, Condition.SelectionMode mode, List conditions) { + public Action(int delay, Selector mode, List conditions) { this(delay, mode, conditions, 0); } @@ -119,7 +120,7 @@ public static Action parse(@NotNull String s) { protected static ParseResult parseBase(String data) { int cooldown = parseInt(data, "cooldown"); int delay = parseInt(data, "delay"); - Condition.SelectionMode mode = parseEnum(data, "mode", Condition.SelectionMode.class); + Selector mode = parseEnum(data, "mode", Selector.class); List conditions = deserializeConditions(parseString(data, "conditions")); return new ParseResult(delay, mode, conditions, cooldown); } @@ -270,7 +271,7 @@ public boolean processConditions(Player player) { if (conditions == null || conditions.isEmpty()) return true; // no conditions Set results = new HashSet<>(conditions.size()); conditions.forEach(conditional -> results.add(conditional.compute(player))); - return (mode == Condition.SelectionMode.ALL ? !results.contains(false) : results.contains(true)); + return (mode == Selector.ALL ? !results.contains(false) : results.contains(true)); } private String getConditionSerialized() { @@ -333,13 +334,13 @@ protected String generateSerializedString(String id, Map params) public abstract Action clone(); - protected record ParseResult(int delay, Condition.SelectionMode mode, List conditions, int cooldown) { + protected record ParseResult(int delay, Selector mode, List conditions, int cooldown) { /** - * @deprecated Use {@link ParseResult#ParseResult(int, Condition.SelectionMode, List, int)}} + * @deprecated Use {@link ParseResult#ParseResult(int, Selector, List, int)}} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public ParseResult(int delay, Condition.SelectionMode mode, List conditions) { + public ParseResult(int delay, Selector mode, List conditions) { this(delay, mode, conditions, 0); } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/ActionAdapter.java b/core/src/main/java/dev/foxikle/customnpcs/actions/ActionAdapter.java similarity index 92% rename from core/src/main/java/dev/foxikle/customnpcs/actions/conditions/ActionAdapter.java rename to core/src/main/java/dev/foxikle/customnpcs/actions/ActionAdapter.java index d7cdcaa6..3e729dd1 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/ActionAdapter.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/ActionAdapter.java @@ -20,14 +20,15 @@ * SOFTWARE. */ -package dev.foxikle.customnpcs.actions.conditions; +package dev.foxikle.customnpcs.actions; import com.google.gson.JsonSyntaxException; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import dev.foxikle.customnpcs.actions.ActionType; -import dev.foxikle.customnpcs.actions.LegacyAction; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.ConditionalTypeAdapter; +import dev.foxikle.customnpcs.conditions.Selector; import java.io.IOException; import java.util.ArrayList; @@ -83,7 +84,7 @@ public LegacyAction read(JsonReader in) throws IOException { List args = new ArrayList<>(); int delay = 0; List conditions = new ArrayList<>(); - Condition.SelectionMode selectionMode = null; + Selector selectionMode = null; while (in.hasNext()) { @@ -98,7 +99,7 @@ public LegacyAction read(JsonReader in) throws IOException { in.endArray(); } case "delay" -> delay = in.nextInt(); - case "mode" -> selectionMode = Condition.SelectionMode.valueOf(in.nextString()); + case "mode" -> selectionMode = Selector.valueOf(in.nextString()); case "conditionals" -> { in.beginArray(); while(in.hasNext()) { diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/LegacyAction.java b/core/src/main/java/dev/foxikle/customnpcs/actions/LegacyAction.java index cd739d7d..0109f126 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/LegacyAction.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/LegacyAction.java @@ -22,8 +22,9 @@ package dev.foxikle.customnpcs.actions; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.actions.defaultImpl.*; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import lombok.Getter; import lombok.Setter; @@ -51,7 +52,7 @@ public class LegacyAction { @Setter private int delay; @Setter - private Condition.SelectionMode mode; + private Selector mode; /** *

Creates a new Action @@ -63,7 +64,7 @@ public class LegacyAction { * @param matchAll If all the conditions must be met, or one * @param conditionals The conditions to apply to this action */ - public LegacyAction(ActionType actionType, List args, int delay, Condition.SelectionMode matchAll, List conditionals) { + public LegacyAction(ActionType actionType, List args, int delay, Selector matchAll, List conditionals) { this.actionType = actionType; this.args = args; this.delay = delay; @@ -75,7 +76,7 @@ private LegacyAction(String subCommand, ArrayList args, int delay) { this.actionType = ActionType.valueOf(subCommand); this.args = args; this.delay = delay; - this.mode = Condition.SelectionMode.ONE; + this.mode = Selector.ONE; this.conditionals = new ArrayList<>(); } @@ -152,7 +153,7 @@ private boolean processConditions(Player player) { Set results = new HashSet<>(2); conditionals.forEach(conditional -> results.add(conditional.compute(player))); - return (mode == Condition.SelectionMode.ALL ? !results.contains(false) : results.contains(true)); + return (mode == Selector.ALL ? !results.contains(false) : results.contains(true)); } /** diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java b/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java deleted file mode 100644 index 461d3d00..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Conditional.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2024-2025. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.actions.conditions; - -import dev.foxikle.customnpcs.internal.CustomNPCs; -import lombok.Getter; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; - -/** - * The interface to represent a comparison - * @deprecated See {@link Condition} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.8.0") -public interface Conditional { - - /** - * Computes the condition to determine if the action should be executed - * @param player The player to fetch data from - * @return if the action should be executed - */ - boolean compute(Player player); - - /** - * Serializes the condition to json using Gson - * @return the serialized condition - */ - String toJson(); - - /** - * - * @param data the serialized condition - * @return the condition from the json - */ - static Conditional of(String data) { - return CustomNPCs.getGson().fromJson(data, Conditional.class); - } - - /** - * Gets the value the condition is comparing - * @see Value - * @return the value the condition is comparing - */ - Value getValue(); - - /** - * Gets the comparator the condition uses to compare the value and target value. - * @return the comparator - * @see Comparator - */ - Comparator getComparator(); - - /** - * Gets the type of condition - * @return the condition type - * @see Type - */ - Type getType(); - - /** - * Sets the comparator of this condition - * @param comparator the comparator to compare the value and target value - * @see Comparator - */ - void setComparator(Comparator comparator); - - /** - * Sets the value of this condition - * @param value the value to compare - * @see Value - */ - void setValue(Value value); - - /** - * Sets the target value of this condition - * @param targetValue the target value - */ - void setTargetValue(String targetValue); - - /** - * Gets the target of the condition - * @return returns the target value - */ - String getTarget(); - - /** - * Clones this conditional object - * @return the cloned object - */ - Conditional clone(); - - /** - * A list of comparators used to compare the values and target values of conditions - */ - @Getter - enum Comparator { - /** - * Represents the value being equal to the target value - */ - EQUAL_TO(true), - - /** - * Represents the value being unequal to the target value - */ - NOT_EQUAL_TO(true), - - /** - * Represents the value being less than the target value - */ - LESS_THAN(false), - - /** - * Represents the value being greater than the target value - */ - GREATER_THAN(false), - - /** - * Represents the value being less than or equal to the target value - */ - LESS_THAN_OR_EQUAL_TO(false), - - /** - * Represents the value being greater than or equal to the target value - */ - GREATER_THAN_OR_EQUAL_TO(false); - - private final boolean strictlyLogical; - - /** - * Constructor for the Comparator - * @param strictlyLogical if the comparator is to only be used on logical parameters - */ - Comparator(boolean strictlyLogical) { - this.strictlyLogical = strictlyLogical; - } - - } - - /** - * A list of comparator types - */ - enum Type { - /** - * Represents a comparison between a Value and a target value that can be any numeric value. - * @see Value - */ - NUMERIC, - - /** - * Represents a comparison between a Value and a target value with a finite number of possibilities - * @see Value - */ - LOGICAL - } - - /** - * A list of values the plugin can compare - */ - enum Value { - // numeric - /** - * Represents the player's experience levels - */ - EXP_LEVELS(false), - - /** - * Represents the player's experience points - */ - EXP_POINTS(false), - - /** - * Represents the player's health - */ - HEALTH(false), - - /** - * Represents the player's absorption - * @deprecated - Misspelled, see {@link Conditional.Value#ABSORPTION} - */ - @ApiStatus.ScheduledForRemoval(inVersion = "1.7") - @Deprecated - ABSORBTION(false), - - /** - * Represents the player's absorption - */ - ABSORPTION(false), - - /** - * Represents the player's Y coordinate - */ - Y_COORD(false), - - /** - * Represents the player's X coordinate - */ - X_COORD(false), - - /** - * Represents the player's Z coordinate - */ - Z_COORD(false), - - - // logical - /** - * Represents if the player has an effect - */ - HAS_EFFECT(true), - - /** - * Represents if the player has a permission node - */ - HAS_PERMISSION(true), - - /** - * Represents if the player is in the gamemode - */ - GAMEMODE(true), - - /** - * Represents if the player is flying - */ - IS_FLYING(true), - - /** - * Represents if the player is sprinting - */ - IS_SPRINTING(true), - - /** - * Represents if the player is sneaking - */ - IS_SNEAKING(true), - - /** - * Represents if the player is frozen - */ - IS_FROZEN(true), - - /** - * Represents if the player is gliding - */ - IS_GLIDING(true); - - - - private final boolean isLogical; - - /** - * The constructor for the Value - * @param isLogical if the value is considered 'logical' - */ - Value(boolean isLogical) { - this.isLogical = isLogical; - } - - /** - * Determines if the value is considered 'logical' - * @return if the value is logical - */ - public boolean isLogical() { - return isLogical; - } - } - - /** - * Represents if how the conditions should be computed - */ - enum SelectionMode { - /** - * If ALL the conditions must be true for the action to be executed - */ - ALL, - - /** - * if at least ONE of the conditions must be met for the action to be executed - */ - ONE - } -} diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java b/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java deleted file mode 100644 index 69fb58c4..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalConditional.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2024-2025. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.actions.conditions; - -import dev.foxikle.customnpcs.internal.CustomNPCs; -import org.bukkit.GameMode; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.ApiStatus; - -import java.util.Objects; - -/** - * The object representing two non-numeric values - * @deprecated See {@link LogicalCondition} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.8.0") -public class LogicalConditional implements Condition { - private final Type type = Type.LOGICAL; - private Comparator comparator; - private Value value; - private String target; - - /** - * - * @param comparator the comparator to use - * @param value the value to compare - * @param target the target to compare to - * @see Value - * @see Comparator - */ - public LogicalConditional(Comparator comparator, Value value, String target) { - this.comparator = comparator; - this.value = value; - this.target = target; - } - - /** - * Computes the condition to determine if the action should be executed - * @param player The player to fetch data from - * @return if the action should be executed - */ - @Override - public boolean compute(Player player) { - boolean value = false; - switch (this.value) { - case HAS_PERMISSION -> value = player.hasPermission(target); - case HAS_EFFECT -> value = player.hasPotionEffect(Objects.requireNonNull(PotionEffectType.getByName(target))); - case GAMEMODE -> value = player.getGameMode().equals(GameMode.valueOf(target)); - case IS_FLYING -> value = player.isFlying(); - case IS_SPRINTING -> value = player.isSprinting(); - case IS_SNEAKING -> value = player.isSneaking(); - case IS_FROZEN -> value = player.isFrozen(); - case IS_GLIDING -> value = player.isGliding(); - } - switch (comparator) { - case EQUAL_TO -> { - return value; - } - case NOT_EQUAL_TO -> { - return !value; - } - } - return false; - } - - /** - * Serializes the condition to json using Gson - * @return the serialized condition - */ - @Override - public String toJson(){ - return CustomNPCs.getGson().toJson(this); - } - - /** - * - * @param data the serialized condition - * @return the condition from the json - */ - public static LogicalConditional of(String data) { - return CustomNPCs.getGson().fromJson(data, LogicalConditional.class); - } - - /** - * Gets the type of condition - * @return the condition type - * @see Type - */ - @Override - public Type getType() { - return type; - } - - /** - * Sets the comparator of this condition - * @param comparator the comparator to compare the value and target value - * @see Comparator - */ - @Override - public void setComparator(Comparator comparator) { - this.comparator = comparator; - } - - /** - * Sets the value of this condition - * @param value the value to compare - * @see Value - */ - @Override - public void setValue(Value value) { - this.value = value; - } - - /** - * Sets the target value of this condition - * @param targetValue the target value - */ - @Override - public void setTargetValue(String targetValue) { - this.target = targetValue; - } - - /** - * Gets the value the condition is comparing - * @see Value - * @return the value the condition is comparing - */ - @Override - public Value getValue() { - return this.value; - } - - /** - * Gets the target of the condition - * @return returns the target value - */ - @Override - public String getTarget() { - return target; - } - - @Override - public Condition clone() { - try { - return (LogicalConditional) super.clone(); - } catch (CloneNotSupportedException e) { - return new LogicalConditional(comparator, value, target); - } - } - - /** - * Gets the comparator the condition uses to compare the value and target value. - * @return the comparator - * @see Comparator - */ - @Override - public Comparator getComparator() { - return this.comparator; - } -} diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java b/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java deleted file mode 100644 index 2cda6ceb..00000000 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericConditional.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2024-2025. Foxikle - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package dev.foxikle.customnpcs.actions.conditions; - -import dev.foxikle.customnpcs.internal.CustomNPCs; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; - -/** - * The object representing a comparison of two numeric values - * @deprecated See {@link NumericCondition} - */ -@Deprecated -@ApiStatus.ScheduledForRemoval(inVersion = "1.8.0") -public class NumericConditional implements Condition { - - private final Type type = Type.NUMERIC; - private Comparator comparator; - private Value value; - private double target; - - /** - * - * @param comparator the comparator to use - * @param value the value to compare - * @param target the target to compare to - * @see Value - * @see Comparator - */ - public NumericConditional(Comparator comparator, Value value, double target) { - this.comparator = comparator; - this.value = value; - this.target = target; - } - - /** - * Computes the condition to determine if the action should be executed - * @param player The player to fetch data from - * @return if the action should be executed - */ - @Override - public boolean compute(Player player) { - double value = 0; - switch (this.value) { - case X_COORD -> value = player.getLocation().x(); - case Y_COORD -> value = player.getLocation().y(); - case Z_COORD -> value = player.getLocation().z(); - case EXP_LEVELS -> value = player.getLevel(); - case EXP_POINTS -> value = player.getExp(); - } - switch (comparator) { - case EQUAL_TO -> { - return value == target; - } - case NOT_EQUAL_TO -> { - return value != target; - } - case LESS_THAN -> { - return value < target; - } - case LESS_THAN_OR_EQUAL_TO -> { - return value <= target; - } - case GREATER_THAN -> { - return value > target; - } - case GREATER_THAN_OR_EQUAL_TO -> { - return value >= target; - } - } - return false; - } - - /** - * Serializes the condition to json using Gson - * @return the serialized condition - */ - @Override - public String toJson(){ - return CustomNPCs.getGson().toJson(this); - } - - /** - * - * @param data the serialized condition - * @return the condition from the json - */ - public static NumericConditional of(String data) { - return CustomNPCs.getGson().fromJson(data, NumericConditional.class); - } - - /** - * Gets the type of condition - * @return the condition type - * @see Type - */ - @Override - public Type getType() { - return type; - } - - /** - * Sets the comparator of this condition - * @param comparator the comparator to compare the value and target value - * @see Comparator - */ - @Override - public void setComparator(Comparator comparator) { - this.comparator = comparator; - } - - /** - * Sets the value of this condition - * @param value the value to compare - * @see Value - */ - @Override - public void setValue(Value value) { - this.value = value; - } - - /** - * Sets the target value of this condition - * @param targetValue the target value - */ - @Override - public void setTargetValue(String targetValue) { - this.target = Double.parseDouble(targetValue); - } - - /** - * Gets the value the condition is comparing - * @see Value - * @return the value the condition is comparing - */ - @Override - public Value getValue() { - return this.value; - } - - /** - * Gets the target of the condition - * @return returns the target value - */ - @Override - public String getTarget() { - return String.valueOf(target); - } - - /** - * Gets the comparator the condition uses to compare the value and target value. - * @return the comparator - * @see Comparator - */ - @Override - public Comparator getComparator() { - return this.comparator; - } - - @Override - public Condition clone() { - try { - return (NumericConditional) super.clone(); - } catch (CloneNotSupportedException e) { - return new NumericConditional(comparator, value, target); - } - } -} diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/ActionBar.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/ActionBar.java index 6ef3511b..7bf911d0 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/ActionBar.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/ActionBar.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuUtils; @@ -65,11 +66,11 @@ public class ActionBar extends Action { * Creates a new SendMessage with the specified message * * @param rawMessage The raw message - * @deprecated Use {@link ActionBar#ActionBar(String, int, Condition.SelectionMode, List, int)} + * @deprecated Use {@link ActionBar#ActionBar(String, int, Selector, List, int)} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public ActionBar(String rawMessage, int delay, Condition.SelectionMode mode, List conditionals) { + public ActionBar(String rawMessage, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.rawMessage = rawMessage; } @@ -79,7 +80,7 @@ public ActionBar(String rawMessage, int delay, Condition.SelectionMode mode, Lis * * @param rawMessage The raw message */ - public ActionBar(String rawMessage, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public ActionBar(String rawMessage, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.rawMessage = rawMessage; } @@ -92,7 +93,7 @@ public static Button creationButton(Player player) { ButtonClickAction.plain((menuView, event) -> { event.setCancelled(true); Player p = (Player) event.getWhoClicked(); - ActionBar actionImpl = new ActionBar("", 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + ActionBar actionImpl = new ActionBar("", 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/DisplayTitle.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/DisplayTitle.java index 324c088d..a776b282 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/DisplayTitle.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/DisplayTitle.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuItems; @@ -75,7 +76,7 @@ public class DisplayTitle extends Action { * * @param title The raw message */ - public DisplayTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public DisplayTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.title = title; this.subTitle = subTitle; @@ -88,11 +89,11 @@ public DisplayTitle(String title, String subTitle, int fadeIn, int stay, int fad * Creates a new SendMessage with the specified message * * @param title The raw message - * @deprecated Use {@link DisplayTitle#DisplayTitle(String, String, int, int, int, int, Condition.SelectionMode, List, int)}} + * @deprecated Use {@link DisplayTitle#DisplayTitle(String, String, int, int, int, int, Selector, List, int)}} */ @ApiStatus.ScheduledForRemoval(inVersion = "1.9") @Deprecated - public DisplayTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut, int delay, Condition.SelectionMode mode, List conditionals) { + public DisplayTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.title = title; this.subTitle = subTitle; @@ -110,7 +111,7 @@ public static Button creationButton(Player player) { event.setCancelled(true); Player p = (Player) event.getWhoClicked(); p.playSound(p, Sound.UI_BUTTON_CLICK, 1, 1); - DisplayTitle actionImpl = new DisplayTitle("Title", "Subtitle", 10, 10, 10, 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + DisplayTitle actionImpl = new DisplayTitle("Title", "Subtitle", 10, 10, 10, 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/GiveEffect.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/GiveEffect.java index 20eb3205..06359539 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/GiveEffect.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/GiveEffect.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuItems; @@ -72,7 +73,7 @@ public class GiveEffect extends Action { * * @param effect The raw message */ - public GiveEffect(String effect, int duration, int amplifier, boolean particles, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public GiveEffect(String effect, int duration, int amplifier, boolean particles, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.effect = effect; this.duration = duration; @@ -84,11 +85,11 @@ public GiveEffect(String effect, int duration, int amplifier, boolean particles, * Creates a new GiveEffect with the specified parameters * * @param effect The raw message - * @deprecated Use {@link #GiveEffect(String, int, int, boolean, int, Condition.SelectionMode, List, int)} + * @deprecated Use {@link #GiveEffect(String, int, int, boolean, int, Selector, List, int)} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public GiveEffect(String effect, int duration, int amplifier, boolean particles, int delay, Condition.SelectionMode mode, List conditionals) { + public GiveEffect(String effect, int duration, int amplifier, boolean particles, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.effect = effect; this.duration = duration; @@ -105,7 +106,7 @@ public static Button creationButton(Player player) { event.setCancelled(true); Player p = (Player) event.getWhoClicked(); p.playSound(event.getWhoClicked(), Sound.UI_BUTTON_CLICK, 1, 1); - GiveEffect actionImpl = new GiveEffect("SPEED", 100, 0, false, 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + GiveEffect actionImpl = new GiveEffect("SPEED", 100, 0, false, 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/GiveXP.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/GiveXP.java index db1d8130..385e46c6 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/GiveXP.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/GiveXP.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuItems; @@ -67,7 +68,7 @@ public static Button creationButton(Player player) { Player p = (Player) event.getWhoClicked(); p.playSound(event.getWhoClicked(), Sound.UI_BUTTON_CLICK, 1, 1); - GiveXP actionImpl = new GiveXP(1, true, 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + GiveXP actionImpl = new GiveXP(1, true, 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); @@ -82,7 +83,7 @@ public static Button creationButton(Player player) { * @param levels if the xp is in levels * @param amount the number */ - public GiveXP(int amount, boolean levels, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public GiveXP(int amount, boolean levels, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.levels = levels; this.amount = amount; @@ -96,7 +97,7 @@ public GiveXP(int amount, boolean levels, int delay, Condition.SelectionMode mod */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public GiveXP(int amount, boolean levels, int delay, Condition.SelectionMode mode, List conditionals) { + public GiveXP(int amount, boolean levels, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.levels = levels; this.amount = amount; diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/PlaySound.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/PlaySound.java index 4c3b9dd8..99f54fbc 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/PlaySound.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/PlaySound.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuItems; @@ -70,7 +71,7 @@ public static Button creationButton(Player player) { event.setCancelled(true); Player p = (Player) event.getWhoClicked(); p.playSound(Sound.sound(Key.key("minecraft:ui.button.click"), Sound.Source.MASTER, 1, 1)); - PlaySound actionImpl = new PlaySound("minecraft:ui.button.click", 1, 1, 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + PlaySound actionImpl = new PlaySound("minecraft:ui.button.click", 1, 1, 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); @@ -87,7 +88,7 @@ public static Button creationButton(Player player) { * @param pitch The pitch, between 0.0f and 1.0f * @param volume The volume, between 0.0f and 1.0f */ - public PlaySound(String sound, float volume, float pitch, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public PlaySound(String sound, float volume, float pitch, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.sound = sound; this.volume = volume; @@ -100,11 +101,11 @@ public PlaySound(String sound, float volume, float pitch, int delay, Condition.S * @param sound The sound enum constants * @param pitch The pitch, between 0.0f and 1.0f * @param volume The volume, between 0.0f and 1.0f - * @deprecated Use {@link PlaySound#PlaySound(String, float, float, int, Condition.SelectionMode, List, int)} + * @deprecated Use {@link PlaySound#PlaySound(String, float, float, int, Selector, List, int)} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public PlaySound(String sound, float volume, float pitch, int delay, Condition.SelectionMode mode, List conditionals) { + public PlaySound(String sound, float volume, float pitch, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.sound = sound; this.volume = volume; diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RemoveEffect.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RemoveEffect.java index 295d21a5..74735ff1 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RemoveEffect.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RemoveEffect.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuUtils; @@ -71,7 +72,7 @@ public class RemoveEffect extends Action { * * @param effect The raw message */ - public RemoveEffect(String effect, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public RemoveEffect(String effect, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.effect = effect; } @@ -80,11 +81,11 @@ public RemoveEffect(String effect, int delay, Condition.SelectionMode mode, List * Creates a new GiveEffect with the specified parameters * * @param effect The raw message - * @deprecated Use {@link #RemoveEffect(String, int, Condition.SelectionMode, List, int)} + * @deprecated Use {@link #RemoveEffect(String, int, Selector, List, int)} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public RemoveEffect(String effect, int delay, Condition.SelectionMode mode, List conditionals) { + public RemoveEffect(String effect, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.effect = effect; } @@ -99,7 +100,7 @@ public static Button creationButton(Player player) { event.setCancelled(true); Player p = (Player) event.getWhoClicked(); p.playSound(event.getWhoClicked(), Sound.UI_BUTTON_CLICK, 1, 1); - RemoveEffect actionImpl = new RemoveEffect("SPEED", 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + RemoveEffect actionImpl = new RemoveEffect("SPEED", 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(player.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RemoveXP.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RemoveXP.java index df4074f9..ee387cc3 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RemoveXP.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RemoveXP.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuItems; @@ -68,7 +69,7 @@ public static Button creationButton(Player player) { Player p = (Player) event.getWhoClicked(); p.playSound(event.getWhoClicked(), Sound.UI_BUTTON_CLICK, 1, 1); - RemoveXP actionImpl = new RemoveXP(1, true, 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + RemoveXP actionImpl = new RemoveXP(1, true, 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); @@ -83,7 +84,7 @@ public static Button creationButton(Player player) { * @param levels if the xp is in levels * @param amount the number of XP to remove */ - public RemoveXP(int amount, boolean levels, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public RemoveXP(int amount, boolean levels, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.levels = levels; this.amount = amount; @@ -94,11 +95,11 @@ public RemoveXP(int amount, boolean levels, int delay, Condition.SelectionMode m * * @param levels if the xp is in levels * @param amount the number of XP to remove - * @deprecated Use {@link #RemoveXP(int, boolean, int, Condition.SelectionMode, List, int)} + * @deprecated Use {@link #RemoveXP(int, boolean, int, Selector, List, int)} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public RemoveXP(int amount, boolean levels, int delay, Condition.SelectionMode mode, List conditionals) { + public RemoveXP(int amount, boolean levels, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.levels = levels; this.amount = amount; diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RunCommand.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RunCommand.java index 05317a49..f23318af 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RunCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/RunCommand.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuItems; @@ -71,7 +72,7 @@ public static Button creationButton(Player player) { Player p = (Player) event.getWhoClicked(); event.setCancelled(true); p.playSound(event.getWhoClicked(), Sound.UI_BUTTON_CLICK, 1, 1); - RunCommand actionImpl = new RunCommand("say hi", false, 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + RunCommand actionImpl = new RunCommand("say hi", false, 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); @@ -90,7 +91,7 @@ public static Button creationButton(Player player) { * @param mode The mode * @param conditionals The conditionals */ - public RunCommand(String rawCommand, boolean asConsole, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public RunCommand(String rawCommand, boolean asConsole, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.command = rawCommand; this.asConsole = asConsole; @@ -104,11 +105,11 @@ public RunCommand(String rawCommand, boolean asConsole, int delay, Condition.Sel * @param delay The delay * @param mode The mode * @param conditionals The conditionals - * @deprecated Use {@link #RunCommand(String, boolean, int, Condition.SelectionMode, List, int)} + * @deprecated Use {@link #RunCommand(String, boolean, int, Selector, List, int)} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public RunCommand(String rawCommand, boolean asConsole, int delay, Condition.SelectionMode mode, List conditionals) { + public RunCommand(String rawCommand, boolean asConsole, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.command = rawCommand; this.asConsole = asConsole; diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/SendMessage.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/SendMessage.java index 18bb2d4a..a34130b8 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/SendMessage.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/SendMessage.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuUtils; @@ -67,7 +68,7 @@ public class SendMessage extends Action { * * @param rawMessage The raw message */ - public SendMessage(String rawMessage, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public SendMessage(String rawMessage, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.rawMessage = rawMessage; } @@ -76,11 +77,11 @@ public SendMessage(String rawMessage, int delay, Condition.SelectionMode mode, L * Creates a new SendMessage with the specified message * * @param rawMessage The raw message - * @deprecated Use {@link SendMessage#SendMessage(String, int, Condition.SelectionMode, List, int)} + * @deprecated Use {@link SendMessage#SendMessage(String, int, Selector, List, int)} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public SendMessage(String rawMessage, int delay, Condition.SelectionMode mode, List conditionals) { + public SendMessage(String rawMessage, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals); this.rawMessage = rawMessage; } @@ -95,7 +96,7 @@ public static Button creationButton(Player player) { Player p = (Player) event.getWhoClicked(); p.playSound(event.getWhoClicked(), Sound.UI_BUTTON_CLICK, 1, 1); - SendMessage actionImpl = new SendMessage("", 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + SendMessage actionImpl = new SendMessage("", 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/SendServer.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/SendServer.java index 6815c51d..3e96d0d6 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/SendServer.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/SendServer.java @@ -25,7 +25,8 @@ import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuUtils; @@ -69,7 +70,7 @@ public class SendServer extends Action { * * @param server The raw message */ - public SendServer(String server, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public SendServer(String server, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.server = server; } @@ -78,11 +79,11 @@ public SendServer(String server, int delay, Condition.SelectionMode mode, List conditionals) { + public SendServer(String server, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.server = server; } @@ -99,7 +100,7 @@ public static Button creationButton(Player player) { p.playSound(event.getWhoClicked(), Sound.UI_BUTTON_CLICK, 1, 1); //todo: watch out for duplications - SendServer actionImpl = new SendServer("server", 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + SendServer actionImpl = new SendServer("server", 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/Teleport.java b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/Teleport.java index 1bc87b0c..ef8a9038 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/Teleport.java +++ b/core/src/main/java/dev/foxikle/customnpcs/actions/defaultImpl/Teleport.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.actions.defaultImpl; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import dev.foxikle.customnpcs.internal.menu.MenuItems; @@ -76,7 +77,7 @@ public class Teleport extends Action { * @param delay The delay * @param mode The selection mode of the action's conditions */ - public Teleport(double x, double y, double z, float pitch, float yaw, int delay, Condition.SelectionMode mode, List conditionals, int cooldown) { + public Teleport(double x, double y, double z, float pitch, float yaw, int delay, Selector mode, List conditionals, int cooldown) { super(delay, mode, conditionals, cooldown); this.x = x; this.y = y; @@ -96,11 +97,11 @@ public Teleport(double x, double y, double z, float pitch, float yaw, int delay, * @param conditionals The conditionals * @param delay The delay * @param mode The selection mode of the action's conditions - * @deprecated Use {@link Teleport#Teleport(double, double, double, float, float, int, Condition.SelectionMode, List, int)} + * @deprecated Use {@link Teleport#Teleport(double, double, double, float, float, int, Selector, List, int)} */ @Deprecated @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public Teleport(double x, double y, double z, float pitch, float yaw, int delay, Condition.SelectionMode mode, List conditionals) { + public Teleport(double x, double y, double z, float pitch, float yaw, int delay, Selector mode, List conditionals) { super(delay, mode, conditionals, 0); this.x = x; this.y = y; @@ -119,7 +120,7 @@ public static Button creationButton(Player player) { Player p = (Player) event.getWhoClicked(); p.playSound(event.getWhoClicked(), Sound.UI_BUTTON_CLICK, 1, 1); - Teleport actionImpl = new Teleport(0, 0, 0, 0F, 0F, 0, Condition.SelectionMode.ONE, new ArrayList<>(), 0); + Teleport actionImpl = new Teleport(0, 0, 0, 0F, 0F, 0, Selector.ONE, new ArrayList<>(), 0); CustomNPCs.getInstance().editingActions.put(p.getUniqueId(), actionImpl); menuView.getAPI().openMenu(p, actionImpl.getMenu()); })); diff --git a/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java b/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java index b577e508..a230e0d1 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java +++ b/core/src/main/java/dev/foxikle/customnpcs/api/NPC.java @@ -25,8 +25,9 @@ import com.google.common.base.Preconditions; import dev.foxikle.customnpcs.actions.Action; import dev.foxikle.customnpcs.actions.LegacyAction; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.events.NpcDeleteEvent; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.LookAtAnchor; @@ -80,7 +81,7 @@ public NPC(@NotNull World world) { UUID uuid = UUID.randomUUID(); Settings settings = new Settings(); settings.setResilient(false); - this.npc = NPCApi.plugin.createNPC(world, new Location(world, 0, 0, 0), new Equipment(), settings, uuid, null, new ArrayList<>(), new ArrayList<>(), Condition.SelectionMode.ONE); + this.npc = NPCApi.plugin.createNPC(world, new Location(world, 0, 0, 0), new Equipment(), settings, uuid, null, new ArrayList<>(), new ArrayList<>(), Selector.ONE); } /** diff --git a/core/src/main/java/dev/foxikle/customnpcs/api/events/NpcInjectEvent.java b/core/src/main/java/dev/foxikle/customnpcs/api/events/NpcInjectEvent.java index 0eefc465..f89649b0 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/api/events/NpcInjectEvent.java +++ b/core/src/main/java/dev/foxikle/customnpcs/api/events/NpcInjectEvent.java @@ -22,7 +22,7 @@ package dev.foxikle.customnpcs.api.events; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import lombok.Getter; import org.bukkit.entity.Player; diff --git a/core/src/main/java/dev/foxikle/customnpcs/conditions/Comparator.java b/core/src/main/java/dev/foxikle/customnpcs/conditions/Comparator.java new file mode 100644 index 00000000..b03ee3ea --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/conditions/Comparator.java @@ -0,0 +1,53 @@ +package dev.foxikle.customnpcs.conditions; + +import lombok.Getter; + +/** + * A list of comparators used to compare the values and target values of conditions + */ +@Getter +public enum Comparator { + /** + * Represents the value being equal to the target value + */ + EQUAL_TO(true, "customnpcs.conditions.equal_to"), + + /** + * Represents the value being unequal to the target value + */ + NOT_EQUAL_TO(true, "customnpcs.conditions.not_equal_to"), + + /** + * Represents the value being less than the target value + */ + LESS_THAN(false, "customnpcs.conditions.less_than"), + + /** + * Represents the value being greater than the target value + */ + GREATER_THAN(false, "customnpcs.conditions.greater_than"), + + /** + * Represents the value being less than or equal to the target value + */ + LESS_THAN_OR_EQUAL_TO(false, "customnpcs.conditions.less_than_or_equal_to"), + + /** + * Represents the value being greater than or equal to the target value + */ + GREATER_THAN_OR_EQUAL_TO(false, "customnpcs.conditions.greater_than_or_equal_to"); + + private final boolean strictlyLogical; + private final String key; + + /** + * Constructor for the Comparator + * + * @param strictlyLogical if the comparator is to only be used on logical parameters + * @param key the translation key + */ + Comparator(boolean strictlyLogical, String key) { + this.strictlyLogical = strictlyLogical; + this.key = key; + } +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Condition.java b/core/src/main/java/dev/foxikle/customnpcs/conditions/Condition.java similarity index 74% rename from core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Condition.java rename to core/src/main/java/dev/foxikle/customnpcs/conditions/Condition.java index 11d83af1..9f37e0ec 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/Condition.java +++ b/core/src/main/java/dev/foxikle/customnpcs/conditions/Condition.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package dev.foxikle.customnpcs.actions.conditions; +package dev.foxikle.customnpcs.conditions; import dev.foxikle.customnpcs.internal.CustomNPCs; import lombok.Getter; @@ -115,57 +115,6 @@ static Condition of(String data) { */ Condition clone(); - /** - * A list of comparators used to compare the values and target values of conditions - */ - @Getter - enum Comparator { - /** - * Represents the value being equal to the target value - */ - EQUAL_TO(true, "customnpcs.conditions.equal_to"), - - /** - * Represents the value being unequal to the target value - */ - NOT_EQUAL_TO(true, "customnpcs.conditions.not_equal_to"), - - /** - * Represents the value being less than the target value - */ - LESS_THAN(false, "customnpcs.conditions.less_than"), - - /** - * Represents the value being greater than the target value - */ - GREATER_THAN(false, "customnpcs.conditions.greater_than"), - - /** - * Represents the value being less than or equal to the target value - */ - LESS_THAN_OR_EQUAL_TO(false, "customnpcs.conditions.less_than_or_equal_to"), - - /** - * Represents the value being greater than or equal to the target value - */ - GREATER_THAN_OR_EQUAL_TO(false, "customnpcs.conditions.greater_than_or_equal_to"); - - private final boolean strictlyLogical; - private final String key; - - /** - * Constructor for the Comparator - * - * @param strictlyLogical if the comparator is to only be used on logical parameters - * @param key the translation key - */ - Comparator(boolean strictlyLogical, String key) { - this.strictlyLogical = strictlyLogical; - this.key = key; - } - - } - /** * A list of comparator types */ @@ -268,6 +217,13 @@ enum Value { IS_GLIDING(true, "customnpcs.conditions.is_gliding"); + /** + * -- GETTER -- + * Determines if the value is considered 'logical' + * + * @return if the value is logical + */ + @Getter private final boolean isLogical; private final String key; @@ -286,28 +242,5 @@ public String getTranslationKey() { return key; } - /** - * Determines if the value is considered 'logical' - * - * @return if the value is logical - */ - public boolean isLogical() { - return isLogical; - } - } - - /** - * Represents if how the conditions should be computed - */ - enum SelectionMode { - /** - * If ALL the conditions must be true for the action to be executed - */ - ALL, - - /** - * if at least ONE of the conditions must be met for the action to be executed - */ - ONE } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/ConditionalTypeAdapter.java b/core/src/main/java/dev/foxikle/customnpcs/conditions/ConditionalTypeAdapter.java similarity index 93% rename from core/src/main/java/dev/foxikle/customnpcs/actions/conditions/ConditionalTypeAdapter.java rename to core/src/main/java/dev/foxikle/customnpcs/conditions/ConditionalTypeAdapter.java index 89f3d647..7334958d 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/ConditionalTypeAdapter.java +++ b/core/src/main/java/dev/foxikle/customnpcs/conditions/ConditionalTypeAdapter.java @@ -20,14 +20,13 @@ * SOFTWARE. */ -package dev.foxikle.customnpcs.actions.conditions; +package dev.foxikle.customnpcs.conditions; import com.google.gson.TypeAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import dev.foxikle.customnpcs.actions.conditions.Condition.Comparator; -import dev.foxikle.customnpcs.actions.conditions.Condition.Type; -import dev.foxikle.customnpcs.actions.conditions.Condition.Value; +import dev.foxikle.customnpcs.conditions.Condition.Type; +import dev.foxikle.customnpcs.conditions.Condition.Value; import java.io.IOException; diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalCondition.java b/core/src/main/java/dev/foxikle/customnpcs/conditions/LogicalCondition.java similarity index 99% rename from core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalCondition.java rename to core/src/main/java/dev/foxikle/customnpcs/conditions/LogicalCondition.java index c5dd5575..e3223884 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/LogicalCondition.java +++ b/core/src/main/java/dev/foxikle/customnpcs/conditions/LogicalCondition.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package dev.foxikle.customnpcs.actions.conditions; +package dev.foxikle.customnpcs.conditions; import dev.foxikle.customnpcs.internal.CustomNPCs; import org.bukkit.GameMode; diff --git a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericCondition.java b/core/src/main/java/dev/foxikle/customnpcs/conditions/NumericCondition.java similarity index 99% rename from core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericCondition.java rename to core/src/main/java/dev/foxikle/customnpcs/conditions/NumericCondition.java index d982a227..a42bd461 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/actions/conditions/NumericCondition.java +++ b/core/src/main/java/dev/foxikle/customnpcs/conditions/NumericCondition.java @@ -20,7 +20,7 @@ * SOFTWARE. */ -package dev.foxikle.customnpcs.actions.conditions; +package dev.foxikle.customnpcs.conditions; import dev.foxikle.customnpcs.internal.CustomNPCs; import org.bukkit.entity.Player; diff --git a/core/src/main/java/dev/foxikle/customnpcs/conditions/Selector.java b/core/src/main/java/dev/foxikle/customnpcs/conditions/Selector.java new file mode 100644 index 00000000..041a55e6 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/conditions/Selector.java @@ -0,0 +1,16 @@ +package dev.foxikle.customnpcs.conditions; + +/** + * Represents how the conditions should be computed + */ +public enum Selector { + /** + * If ALL the conditions must be true for the action to be executed + */ + ALL, + + /** + * if at least ONE of the conditions must be met for the action to be executed + */ + ONE +} diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java index 1320d915..0f90e13b 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/CustomNPCs.java @@ -28,10 +28,11 @@ import com.google.gson.GsonBuilder; import dev.foxikle.customnpcs.actions.Action; import dev.foxikle.customnpcs.actions.LegacyAction; -import dev.foxikle.customnpcs.actions.conditions.ActionAdapter; -import dev.foxikle.customnpcs.actions.conditions.Condition; -import dev.foxikle.customnpcs.actions.conditions.ConditionalTypeAdapter; +import dev.foxikle.customnpcs.actions.ActionAdapter; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.ConditionalTypeAdapter; import dev.foxikle.customnpcs.actions.defaultImpl.*; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.commands.NpcCommand; @@ -471,11 +472,11 @@ public void onPluginMessageReceived(@NotNull String channel, @NotNull Player pla * @return the created NPC * @throws RuntimeException If the reflective creation of the NPC object fails */ - public InternalNpc createNPC(World world, Location location, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List conditions, Condition.SelectionMode injectionMode) { + public InternalNpc createNPC(World world, Location location, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List conditions, Selector injectionMode) { try { Class clazz = Class.forName(String.format(NPC_CLASS, translateVersion())); return (InternalNpc) clazz - .getConstructor(this.getClass(), World.class, Location.class, Equipment.class, Settings.class, UUID.class, Player.class, List.class, List.class, Condition.SelectionMode.class) + .getConstructor(this.getClass(), World.class, Location.class, Equipment.class, Settings.class, UUID.class, Player.class, List.class, List.class, Selector.class) .newInstance(this, world, location, equipment, settings, uuid, target, actions, conditions, injectionMode); } catch (ReflectiveOperationException e) { getLogger().log(Level.SEVERE, "An error occurred whilst creating the NPC '{name}! This is most likely a configuration issue.".replace("{name}", settings.getName()), e); diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java index 6bf86a68..e1f39b3e 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java @@ -25,8 +25,9 @@ import dev.foxikle.customnpcs.actions.Action; import dev.foxikle.customnpcs.actions.ActionType; import dev.foxikle.customnpcs.actions.LegacyAction; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; @@ -254,7 +255,7 @@ public boolean createFiles() { String sub = split.get(0); split.remove(0); int delay = 0; - LegacyAction actionImpl = new LegacyAction(ActionType.valueOf(sub), split, delay, Condition.SelectionMode.ONE, new ArrayList<>()); + LegacyAction actionImpl = new LegacyAction(ActionType.valueOf(sub), split, delay, Selector.ONE, new ArrayList<>()); convertedActions.add(actionImpl.toJson()); } s.set("actions", convertedActions); @@ -482,7 +483,7 @@ public boolean createFiles() { assert section != null : "Section is null -- Upgrading NPC file from 1.9 to 1.10"; - section.set("injectionConditionSelector", Condition.SelectionMode.ONE.name()); + section.set("injectionConditionSelector", Selector.ONE.name()); section.set("injectionConditions", CustomNPCs.getGson().toJson(new ArrayList<>(), Utils.CONDITIONS_LIST)); } @@ -588,7 +589,7 @@ public void loadNPC(UUID uuid) { Bukkit.getLogger().info("Converting legacy commands to Actions."); String command = section.getString("command"); assert command != null; - LegacyAction actionImpl = new LegacyAction(ActionType.RUN_COMMAND, Utils.list(command.split(" ")), 0, Condition.SelectionMode.ONE, new ArrayList<>()); + LegacyAction actionImpl = new LegacyAction(ActionType.RUN_COMMAND, Utils.list(command.split(" ")), 0, Selector.ONE, new ArrayList<>()); actionImpls.add(actionImpl); section.set("actions", actionImpls); section.set("command", null); @@ -679,7 +680,7 @@ public void loadNPC(UUID uuid) { section.getBoolean("upsideDown") ), uuid, null, actions, CustomNPCs.getGson().fromJson(section.getString("injectionConditions"), Utils.CONDITIONS_LIST), - Condition.SelectionMode.valueOf(section.getString("injectionConditionSelector"))); + Selector.valueOf(section.getString("injectionConditionSelector"))); if (npc != null) { npc.createNPC(); } else { diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CreateCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CreateCommand.java index 567c7c44..ae7d99c6 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CreateCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/CreateCommand.java @@ -22,7 +22,8 @@ package dev.foxikle.customnpcs.internal.commands; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -50,7 +51,7 @@ public void usage(BukkitSource source) { final Player p = source.asPlayer(); final UUID uuid = UUID.randomUUID(); final CustomNPCs plugin = CustomNPCs.getInstance(); - InternalNpc npc = plugin.createNPC(p.getWorld(), p.getLocation(), new Equipment(), new Settings(), uuid, null, new ArrayList<>(), new ArrayList<>(), Condition.SelectionMode.ONE); + InternalNpc npc = plugin.createNPC(p.getWorld(), p.getLocation(), new Equipment(), new Settings(), uuid, null, new ArrayList<>(), new ArrayList<>(), Selector.ONE); plugin.getEditingNPCs().put(p.getUniqueId(), npc); plugin.getLotus().openMenu(p, MenuUtils.NPC_MAIN); } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/interfaces/InternalNpc.java b/core/src/main/java/dev/foxikle/customnpcs/internal/interfaces/InternalNpc.java index 95bf4bf5..0eae9f40 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/interfaces/InternalNpc.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/interfaces/InternalNpc.java @@ -23,7 +23,8 @@ package dev.foxikle.customnpcs.internal.interfaces; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.InjectionManager; @@ -73,13 +74,13 @@ public interface InternalNpc { /** * Gets which selection mode should be used when determining if this NPC should be injectioned - * @return return the desired {@link Condition.SelectionMode} + * @return return the desired {@link Selector} */ - Condition.SelectionMode getInjectionSelectionMode(); + Selector getInjectionSelectionMode(); void setInjectionConditions(List conditions); - void setInjectionSelectionMode(Condition.SelectionMode mode); + void setInjectionSelectionMode(Selector mode); /** *

Creates the NPC and injects it into every player @@ -351,6 +352,6 @@ default Map evaluateInjectionConditions(Player player){ default boolean passesInectionConditions(Player player) { Map map = evaluateInjectionConditions(player); if (map.isEmpty()) return true; - return (getInjectionSelectionMode() == Condition.SelectionMode.ALL ? !map.containsValue(false) : map.containsValue(true)); + return (getInjectionSelectionMode() == Selector.ALL ? !map.containsValue(false) : map.containsValue(true)); } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java b/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java index 2a12cc2b..5fbfedae 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/listeners/Listeners.java @@ -25,7 +25,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.actions.defaultImpl.*; import dev.foxikle.customnpcs.api.events.NpcInteractEvent; import dev.foxikle.customnpcs.internal.CustomNPCs; diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/ConditionCustomizerMenu.java b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/ConditionCustomizerMenu.java index d19a4816..8012bd47 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/ConditionCustomizerMenu.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/ConditionCustomizerMenu.java @@ -22,7 +22,7 @@ package dev.foxikle.customnpcs.internal.menu; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.utils.Msg; import io.github.mqzen.menus.base.Content; diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java index 356996cc..94abf9df 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java @@ -25,9 +25,7 @@ import com.destroystokyo.paper.profile.PlayerProfile; import com.destroystokyo.paper.profile.ProfileProperty; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; -import dev.foxikle.customnpcs.actions.conditions.LogicalCondition; -import dev.foxikle.customnpcs.actions.conditions.NumericCondition; +import dev.foxikle.customnpcs.conditions.*; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; @@ -836,7 +834,7 @@ public static Button saveCondition(Player player) { public static Button comparatorSwitcher(Condition condition, Player player) { List lore = new ArrayList<>(); - for (Condition.Comparator c : Condition.Comparator.values()) { + for (Comparator c : Comparator.values()) { if (condition.getType() == Condition.Type.NUMERIC || (condition.getType() == Condition.Type.LOGICAL && c.isStrictlyLogical())) { if (condition.getComparator() != c) lore.add(Msg.translate(player.locale(), c.getKey()).color(NamedTextColor.GREEN)); @@ -853,8 +851,8 @@ public static Button comparatorSwitcher(Condition condition, Player player) { return Button.clickable(i, ButtonClickAction.plain((menuView, event) -> { event.setCancelled(true); - List comparators = new ArrayList<>(); - for (Condition.Comparator value : Condition.Comparator.values()) { + List comparators = new ArrayList<>(); + for (Comparator value : Comparator.values()) { if (condition.getType() == Condition.Type.LOGICAL && !value.isStrictlyLogical()) { continue; } @@ -1107,7 +1105,7 @@ public static Button newCondition(Action action, Player player) { } public static Button toggleConditionMode(Action action, Player player) { - boolean isAll = action.getMode() == Condition.SelectionMode.ALL; + boolean isAll = action.getMode() == Selector.ALL; ItemStack i = ItemBuilder.modern(isAll ? GREEN_CANDLE : RED_CANDLE) .setDisplay(Msg.translate(player.locale(), "customnpcs.menus.conditions.mode.toggle")) .setLore(isAll ? Msg.translate(player.locale(), "customnpcs.menus.conditions.mode.all") : Msg.translate(player.locale(), "customnpcs.menus.conditions.mode.one")) @@ -1117,7 +1115,7 @@ public static Button toggleConditionMode(Action action, Player player) { Player p = (Player) event.getWhoClicked(); p.playSound(p, Sound.UI_BUTTON_CLICK, 1.0F, 1.0F); event.setCancelled(true); - action.setMode(isAll ? Condition.SelectionMode.ONE : Condition.SelectionMode.ALL); + action.setMode(isAll ? Selector.ONE : Selector.ALL); menuView.replaceButton(35, toggleConditionMode(action, p)); })); } @@ -1158,7 +1156,7 @@ public static Button numeric(Player player) { event.setCancelled(true); Player p = (Player) event.getWhoClicked(); p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F); - Condition conditional = new NumericCondition(Condition.Comparator.EQUAL_TO, Condition.Value.EXP_LEVELS, 0.0); + Condition conditional = new NumericCondition(Comparator.EQUAL_TO, Condition.Value.EXP_LEVELS, 0.0); plugin.originalEditingConditionals.remove(p.getUniqueId()); plugin.editingConditionals.put(p.getUniqueId(), conditional); menuView.getAPI().openMenu(p, MenuUtils.NPC_CONDITION_CUSTOMIZER); @@ -1175,7 +1173,7 @@ public static Button logic(Player player) { event.setCancelled(true); Player p = (Player) event.getWhoClicked(); p.playSound(p.getLocation(), Sound.UI_BUTTON_CLICK, 1.0F, 1.0F); - Condition conditional = new LogicalCondition(Condition.Comparator.EQUAL_TO, Condition.Value.GAMEMODE, "CREATIVE"); + Condition conditional = new LogicalCondition(Comparator.EQUAL_TO, Condition.Value.GAMEMODE, "CREATIVE"); plugin.originalEditingConditionals.remove(p.getUniqueId()); plugin.editingConditionals.put(p.getUniqueId(), conditional); menuView.getAPI().openMenu(p, MenuUtils.NPC_CONDITION_CUSTOMIZER); diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java index 2cbe8d8b..4e67e246 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/utils/Utils.java @@ -23,7 +23,7 @@ package dev.foxikle.customnpcs.internal.utils; import com.google.common.reflect.TypeToken; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; import net.kyori.adventure.text.Component; diff --git a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java index f4e8aeb5..8e42ede5 100644 --- a/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java +++ b/v1_20_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R1.java @@ -26,8 +26,9 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -105,7 +106,7 @@ public class NPC_v1_20_R1 extends ServerPlayer implements InternalNpc { @Setter private List injectionConditions; @Setter - private Condition.SelectionMode injectionSelectionMode; + private Selector injectionSelectionMode; /** @@ -121,7 +122,7 @@ public class NPC_v1_20_R1 extends ServerPlayer implements InternalNpc { * @param equipment The NPC's equipment * @param settings The NPC's settings */ - public NPC_v1_20_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { + public NPC_v1_20_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Selector injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID))); this.spawnLoc = spawnLoc; this.equipment = equipment; diff --git a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java index cd8ed435..9f68fd6f 100644 --- a/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java +++ b/v1_20_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R2.java @@ -26,8 +26,9 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -104,10 +105,10 @@ public class NPC_v1_20_R2 extends ServerPlayer implements InternalNpc { @Getter private InjectionManager injectionManager; @Setter private List injectionConditions; - @Setter private Condition.SelectionMode injectionSelectionMode; + @Setter private Selector injectionSelectionMode; - public NPC_v1_20_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { + public NPC_v1_20_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Selector injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.settings = settings; diff --git a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java index b1f8bf0d..69166179 100644 --- a/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java +++ b/v1_20_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R3.java @@ -26,8 +26,9 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -104,10 +105,10 @@ public class NPC_v1_20_R3 extends ServerPlayer implements InternalNpc { private String clickableName = "ERROR"; private InjectionManager injectionManager; @Setter private List injectionConditions; - @Setter private Condition.SelectionMode injectionSelectionMode; + @Setter private Selector injectionSelectionMode; - public NPC_v1_20_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { + public NPC_v1_20_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Selector injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; diff --git a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java index f7610a1e..7544cad2 100644 --- a/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java +++ b/v1_20_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_20_R4.java @@ -26,8 +26,9 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -118,10 +119,10 @@ public class NPC_v1_20_R4 extends ServerPlayer implements InternalNpc { private String clickableName = "ERROR"; @Getter private InjectionManager injectionManager; @Setter private List injectionConditions; - @Setter private Condition.SelectionMode injectionSelectionMode; + @Setter private Selector injectionSelectionMode; - public NPC_v1_20_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { + public NPC_v1_20_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Selector injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uuid, Utils.getNpcName(settings, uuid)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; diff --git a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java index 1f067cca..8f06ea43 100644 --- a/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java +++ b/v1_21_R0/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R0.java @@ -26,8 +26,9 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -117,10 +118,10 @@ public class NPC_v1_21_R0 extends ServerPlayer implements InternalNpc { @Setter private List injectionConditions; @Setter - private Condition.SelectionMode injectionSelectionMode; + private Selector injectionSelectionMode; - public NPC_v1_21_R0(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { + public NPC_v1_21_R0(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Selector injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; diff --git a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java index cc65ed01..9c553ae0 100644 --- a/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java +++ b/v1_21_R1/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R1.java @@ -26,8 +26,9 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -118,10 +119,10 @@ public class NPC_v1_21_R1 extends ServerPlayer implements InternalNpc { @Setter private List injectionConditions; @Setter - private Condition.SelectionMode injectionSelectionMode; + private Selector injectionSelectionMode; - public NPC_v1_21_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { + public NPC_v1_21_R1(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Selector injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uuid, Utils.getNpcName(settings, uuid)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; diff --git a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java index 0801b80f..aa83f6b4 100644 --- a/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java +++ b/v1_21_R2/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R2.java @@ -26,8 +26,9 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -119,7 +120,7 @@ public class NPC_v1_21_R2 extends ServerPlayer implements InternalNpc { private String clickableName = "ERROR"; private InjectionManager injectionManager; @Setter private List injectionConditions; - @Setter private Condition.SelectionMode injectionSelectionMode; + @Setter private Selector injectionSelectionMode; /** @@ -135,7 +136,7 @@ public class NPC_v1_21_R2 extends ServerPlayer implements InternalNpc { * @param settings The settings for the NPC * @param equipment The NPC's equipment */ - public NPC_v1_21_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { + public NPC_v1_21_R2(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uniqueID, @Nullable Player target, List actions, List injectionConditions, Selector injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uniqueID, Utils.getNpcName(settings, uniqueID)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; diff --git a/v1_21_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R3.java b/v1_21_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R3.java index e60acdd4..566445cd 100644 --- a/v1_21_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R3.java +++ b/v1_21_R3/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R3.java @@ -26,8 +26,9 @@ import com.mojang.authlib.properties.Property; import com.mojang.datafixers.util.Pair; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -119,9 +120,9 @@ public class NPC_v1_21_R3 extends ServerPlayer implements InternalNpc { private String clickableName = "ERROR"; private InjectionManager injectionManager; @Setter private List injectionConditions; - @Setter private Condition.SelectionMode injectionSelectionMode; + @Setter private Selector injectionSelectionMode; - public NPC_v1_21_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { + public NPC_v1_21_R3(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Selector injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uuid, Utils.getNpcName(settings, uuid)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; diff --git a/v1_21_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R4.java b/v1_21_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R4.java index 6c309c6b..738df06c 100644 --- a/v1_21_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R4.java +++ b/v1_21_R4/src/main/java/dev/foxikle/customnpcs/versions/NPC_v1_21_R4.java @@ -28,8 +28,9 @@ import com.mojang.datafixers.util.Pair; import com.mojang.serialization.JsonOps; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; +import dev.foxikle.customnpcs.conditions.Condition; import dev.foxikle.customnpcs.api.Pose; +import dev.foxikle.customnpcs.conditions.Selector; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.data.Settings; import dev.foxikle.customnpcs.internal.CustomNPCs; @@ -120,10 +121,10 @@ public class NPC_v1_21_R4 extends ServerPlayer implements InternalNpc { private String clickableName = "ERROR"; private InjectionManager injectionManager; @Setter private List injectionConditions; - @Setter private Condition.SelectionMode injectionSelectionMode; + @Setter private Selector injectionSelectionMode; - public NPC_v1_21_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Condition.SelectionMode injectionSelectionMode) { + public NPC_v1_21_R4(CustomNPCs plugin, World world, Location spawnLoc, Equipment equipment, Settings settings, UUID uuid, @Nullable Player target, List actions, List injectionConditions, Selector injectionSelectionMode) { super(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) world).getHandle(), new GameProfile(uuid, Utils.getNpcName(settings, uuid)), ClientInformation.createDefault()); this.spawnLoc = spawnLoc; this.equipment = equipment; From 8991f0c996504ff19a3fee8d0ebdb3aa1a7d82d2 Mon Sep 17 00:00:00 2001 From: Foxikle Date: Wed, 3 Sep 2025 20:37:15 -0400 Subject: [PATCH 23/25] Fix merge issues --- .../conditions/NumericCondition.java | 191 ++ .../dev/foxikle/customnpcs/data/Settings.java | 107 +- .../customnpcs/internal/FileManager.java | 1 - .../internal/commands/MoveDataCommand.java | 3 +- .../customnpcs/internal/menu/MenuItems.java | 241 ++- .../internal/proto/ActionOuterClass.java | 629 ------ .../internal/proto/EquipmentOuterClass.java | 1873 ----------------- .../internal/proto/ItemOuterClass.java | 564 ----- .../internal/proto/LocationOuterClass.java | 1119 ---------- .../internal/proto/NpcListOuterClass.java | 870 -------- .../internal/proto/NpcOuterClass.java | 1822 ---------------- .../internal/proto/ProtoWrapper.java | 226 -- .../internal/proto/SettingsOuterClass.java | 1711 --------------- .../internal/storage/StorageManager.java | 86 +- proto/action.proto | 7 - proto/equipment.proto | 14 - proto/item.proto | 8 - proto/location.proto | 15 - proto/npc.proto | 19 - proto/npc_list.proto | 9 - proto/settings.proto | 17 - 21 files changed, 441 insertions(+), 9091 deletions(-) create mode 100644 core/src/main/java/dev/foxikle/customnpcs/conditions/NumericCondition.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/ActionOuterClass.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/EquipmentOuterClass.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/ItemOuterClass.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/LocationOuterClass.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcListOuterClass.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/NpcOuterClass.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/ProtoWrapper.java delete mode 100644 core/src/main/java/dev/foxikle/customnpcs/internal/proto/SettingsOuterClass.java delete mode 100644 proto/action.proto delete mode 100644 proto/equipment.proto delete mode 100644 proto/item.proto delete mode 100644 proto/location.proto delete mode 100644 proto/npc.proto delete mode 100644 proto/npc_list.proto delete mode 100644 proto/settings.proto diff --git a/core/src/main/java/dev/foxikle/customnpcs/conditions/NumericCondition.java b/core/src/main/java/dev/foxikle/customnpcs/conditions/NumericCondition.java new file mode 100644 index 00000000..8a8e5205 --- /dev/null +++ b/core/src/main/java/dev/foxikle/customnpcs/conditions/NumericCondition.java @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2024-2025. Foxikle + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.foxikle.customnpcs.conditions; + +import dev.foxikle.customnpcs.internal.CustomNPCs; +import org.bukkit.entity.Player; + +/** + * The object representing a comparison of two numeric values + */ +public class NumericCondition implements Condition { + + private final Type type = Type.NUMERIC; + private Comparator comparator; + private Value value; + private double target; + + /** + * @param comparator the comparator to use + * @param value the value to compare + * @param target the target to compare to + * @see Condition.Value + * @see Comparator + */ + public NumericCondition(Comparator comparator, Value value, double target) { + this.comparator = comparator; + this.value = value; + this.target = target; + } + + /** + * Computes the condition to determine if the action should be executed + * + * @param player The player to fetch data from + * @return if the action should be executed + */ + @Override + public boolean compute(Player player) { + double value = 0; + switch (this.value) { + case X_COORD -> value = player.getLocation().x(); + case Y_COORD -> value = player.getLocation().y(); + case Z_COORD -> value = player.getLocation().z(); + case EXP_LEVELS -> value = player.getLevel(); + case EXP_POINTS -> value = player.getExp(); + } + switch (comparator) { + case EQUAL_TO -> { + return value == target; + } + case NOT_EQUAL_TO -> { + return value != target; + } + case LESS_THAN -> { + return value < target; + } + case LESS_THAN_OR_EQUAL_TO -> { + return value <= target; + } + case GREATER_THAN -> { + return value > target; + } + case GREATER_THAN_OR_EQUAL_TO -> { + return value >= target; + } + } + return false; + } + + /** + * Serializes the condition to json using Gson + * + * @return the serialized condition + */ + @Override + public String toJson() { + return CustomNPCs.getGson().toJson(this); + } + + /** + * @param data the serialized condition + * @return the condition from the json + */ + public static NumericCondition of(String data) { + return CustomNPCs.getGson().fromJson(data, NumericCondition.class); + } + + /** + * Gets the type of condition + * + * @return the condition type + * @see Condition.Type + */ + @Override + public Type getType() { + return type; + } + + /** + * Sets the comparator of this condition + * + * @param comparator the comparator to compare the value and target value + * @see Comparator + */ + @Override + public void setComparator(Comparator comparator) { + this.comparator = comparator; + } + + /** + * Sets the value of this condition + * + * @param value the value to compare + * @see Condition.Value + */ + @Override + public void setValue(Value value) { + this.value = value; + } + + /** + * Sets the target value of this condition + * + * @param targetValue the target value + */ + @Override + public void setTargetValue(String targetValue) { + this.target = Double.parseDouble(targetValue); + } + + /** + * Gets the value the condition is comparing + * + * @return the value the condition is comparing + * @see Condition.Value + */ + @Override + public Value getValue() { + return this.value; + } + + /** + * Gets the target of the condition + * + * @return returns the target value + */ + @Override + public String getTarget() { + return String.valueOf(target); + } + + /** + * Gets the comparator the condition uses to compare the value and target value. + * + * @return the comparator + * @see Comparator + */ + @Override + public Comparator getComparator() { + return this.comparator; + } + + @Override + public Condition clone() { + try { + return (NumericCondition) super.clone(); + } catch (CloneNotSupportedException e) { + return new NumericCondition(comparator, value, target); + } + } +} \ No newline at end of file diff --git a/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java b/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java index f965432f..2611382b 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java +++ b/core/src/main/java/dev/foxikle/customnpcs/data/Settings.java @@ -68,92 +68,6 @@ public class Settings { @Getter boolean upsideDown = false; - /** - * Creates a settings object with the specified settings - * @param interactable If the npc has actions to execute - * @param tunnelvision If the npc will look at players - * @param resilient If the npc will persist on restarts - * @param direction The direction to look - * @param value The value of the npc's skin - * @param signature The signature of the npc's skin - * @param skinName The name of the skin as it is referenced in the Menu - * @param name The name of NPC formatted in SERIALIZED minimessage format - * @param customInteractableHologram The custom hologram - * @param hideClickableHologram If the NPC's Clickable hologram should be hidden - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public Settings(boolean interactable, boolean tunnelvision, boolean resilient, String value, String signature, String skinName, String name, String customInteractableHologram, boolean hideClickableHologram) { - this.interactable = interactable; - this.tunnelvision = tunnelvision; - this.resilient = resilient; - this.value = value; - this.signature = signature; - this.skinName = skinName; - this.holograms = new String[]{name}; - this.hideClickableHologram = hideClickableHologram; - this.customInteractableHologram = customInteractableHologram; - } - - /** - * Creates a settings object with the specified settings - * - * @param interactable If the npc has actions to execute - * @param tunnelvision If the npc will look at players - * @param resilient If the npc will persist on restarts - * @param value The value of the npc's skin - * @param signature The signature of the npc's skin - * @param skinName The name of the skin as it is referenced in the Menu - * @param name The name of NPC formatted in SERIALIZED minimessage format - * @param customInteractableHologram The custom hologram - * @param hideClickableHologram If the NPC's Clickable hologram should be hidden - * @param interpolationDuration How long to interpolate the teleportation of the NPC and its nametags - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public Settings(boolean interactable, boolean tunnelvision, boolean resilient, String value, String signature, String skinName, String name, String customInteractableHologram, boolean hideClickableHologram, int interpolationDuration) { - this.interactable = interactable; - this.tunnelvision = tunnelvision; - this.resilient = resilient; - this.value = value; - this.signature = signature; - this.skinName = skinName; - this.holograms = new String[]{name}; - this.hideClickableHologram = hideClickableHologram; - this.customInteractableHologram = customInteractableHologram; - this.interpolationDuration = interpolationDuration; - } - - /** - * Creates a settings object with the specified settings - * - * @param interactable If the npc has actions to execute - * @param tunnelvision If the npc will look at players - * @param resilient If the npc will persist on restarts - * @param direction The direction to look - * @param value The value of the npc's skin - * @param signature The signature of the npc's skin - * @param skinName The name of the skin as it is referenced in the Menu - * @param holograms The lines of the NPC's hologram, formatted in SERIALIZED minimessage format. Index 0 corresponds to the top (first) line. - * @param customInteractableHologram The custom hologram - * @param hideClickableHologram If the NPC's Clickable hologram should be hidden - * @param pose The Pose of the NPC - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.9") - public Settings(boolean interactable, boolean tunnelvision, boolean resilient, double direction, String value, String signature, String skinName, String[] holograms, String customInteractableHologram, boolean hideClickableHologram, Pose pose) { - this.interactable = interactable; - this.tunnelvision = tunnelvision; - this.resilient = resilient; - this.direction = direction; - this.value = value; - this.signature = signature; - this.skinName = skinName; - this.holograms = holograms; - this.hideClickableHologram = hideClickableHologram; - this.customInteractableHologram = customInteractableHologram; - this.pose = pose; - } /** * Creates a settings object with the specified settings @@ -161,7 +75,6 @@ public Settings(boolean interactable, boolean tunnelvision, boolean resilient, d * @param interactable If the npc has actions to execute * @param tunnelvision If the npc will look at players * @param resilient If the npc will persist on restarts - * @param direction The direction to look * @param value The value of the npc's skin * @param signature The signature of the npc's skin * @param skinName The name of the skin as it is referenced in the Menu @@ -170,11 +83,10 @@ public Settings(boolean interactable, boolean tunnelvision, boolean resilient, d * @param hideClickableHologram If the NPC's Clickable hologram should be hidden * @param pose The Pose of the NPC */ - public Settings(boolean interactable, boolean tunnelvision, boolean resilient, double direction, String value, String signature, String skinName, String[] holograms, String customInteractableHologram, boolean hideClickableHologram, Pose pose, boolean upsideDown) { + public Settings(boolean interactable, boolean tunnelvision, boolean resilient, String value, String signature, String skinName, String[] holograms, String customInteractableHologram, boolean hideClickableHologram, Pose pose, boolean upsideDown) { this.interactable = interactable; this.tunnelvision = tunnelvision; this.resilient = resilient; - this.direction = direction; this.value = value; this.signature = signature; this.skinName = skinName; @@ -191,7 +103,6 @@ public Settings(boolean interactable, boolean tunnelvision, boolean resilient, d * @param interactable If the npc has actions to execute * @param tunnelvision If the npc will look at players * @param resilient If the npc will persist on restarts - * @param direction The direction to look * @param value The value of the npc's skin * @param signature The signature of the npc's skin * @param skinName The name of the skin as it is referenced in the Menu @@ -200,11 +111,10 @@ public Settings(boolean interactable, boolean tunnelvision, boolean resilient, d * @param hideClickableHologram If the NPC's Clickable hologram should be hidden * @param interpolationDuration How long to interpolate the teleportation of the NPC and its nametags */ - public Settings(boolean interactable, boolean tunnelvision, boolean resilient, double direction, String value, String signature, String skinName, String[] holograms, String customInteractableHologram, boolean hideClickableHologram, int interpolationDuration) { + public Settings(boolean interactable, boolean tunnelvision, boolean resilient, String value, String signature, String skinName, String[] holograms, String customInteractableHologram, boolean hideClickableHologram, int interpolationDuration) { this.interactable = interactable; this.tunnelvision = tunnelvision; this.resilient = resilient; - this.direction = direction; this.value = value; this.signature = signature; this.skinName = skinName; @@ -264,17 +174,6 @@ public Settings setResilient(boolean resilient) { return this; } - /** - * Deprecated: - use {@link NPC#setFacing(float, float)}, {@link NPC#lookAt(Entity, boolean)}, or - * {@link NPC#lookAt(Location)} instead. - */ - @Deprecated - @ApiStatus.ScheduledForRemoval(inVersion = "1.8") - public Settings setDirection(double direction) { - this.direction = direction; - return this; - } - /** * Sets the ticks this NPC should be interpolated for on move. This defaults to the value defined in the config, * but can be overridden for this NPC directly. The interpolation makes the nametags move more smoothly with the @@ -486,6 +385,6 @@ public Settings setSkin(Player player) { @SuppressWarnings("all") public Settings clone(){ - return new Settings(interactable, tunnelvision, resilient, value, signature, skinName, name, customInteractableHologram, hideClickableHologram, pose); + return new Settings(interactable, tunnelvision, resilient, value, signature, skinName, holograms, customInteractableHologram, hideClickableHologram, pose, upsideDown); } } diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java index e1f39b3e..3655262c 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/FileManager.java @@ -669,7 +669,6 @@ public void loadNPC(UUID uuid) { section.getBoolean("clickable"), section.getBoolean("tunnelvision"), true, - location.getYaw(), section.getString("value"), section.getString("signature"), section.getString("skin"), diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java index 77a5eb54..065c7e36 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/commands/MoveDataCommand.java @@ -31,6 +31,7 @@ import dev.foxikle.customnpcs.internal.utils.Msg; import dev.velix.imperat.BukkitSource; import dev.velix.imperat.annotations.*; +import dev.velix.imperat.command.AttachmentMode; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -43,7 +44,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -@SubCommand(value = "movedata", attachDirectly = true) +@SubCommand(value = "movedata", attachment = AttachmentMode.MAIN) @Permission("customnpcs.commands.movedata") public class MoveDataCommand { diff --git a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java index ef4ebb03..03b6a038 100644 --- a/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java +++ b/core/src/main/java/dev/foxikle/customnpcs/internal/menu/MenuItems.java @@ -25,19 +25,16 @@ import com.destroystokyo.paper.profile.PlayerProfile; import com.destroystokyo.paper.profile.ProfileProperty; import dev.foxikle.customnpcs.actions.Action; -import dev.foxikle.customnpcs.actions.conditions.Condition; -import dev.foxikle.customnpcs.actions.conditions.LogicalCondition; -import dev.foxikle.customnpcs.actions.conditions.NumericCondition; +import dev.foxikle.customnpcs.conditions.*; +import dev.foxikle.customnpcs.conditions.Comparator; import dev.foxikle.customnpcs.data.Equipment; import dev.foxikle.customnpcs.internal.CustomNPCs; import dev.foxikle.customnpcs.internal.interfaces.InternalNpc; -import dev.foxikle.customnpcs.internal.runnables.InteractableHologramRunnable; -import dev.foxikle.customnpcs.internal.runnables.PlayerNameRunnable; -import dev.foxikle.customnpcs.internal.runnables.TargetInputRunnable; -import dev.foxikle.customnpcs.internal.runnables.UrlRunnable; +import dev.foxikle.customnpcs.internal.runnables.*; import dev.foxikle.customnpcs.internal.utils.Msg; import dev.foxikle.customnpcs.internal.utils.OpenButtonAction; import dev.foxikle.customnpcs.internal.utils.Utils; +import dev.foxikle.customnpcs.internal.utils.WaitingType; import io.github.mqzen.menus.base.pagination.exception.InvalidPageException; import io.github.mqzen.menus.misc.button.Button; import io.github.mqzen.menus.misc.button.actions.ButtonClickAction; @@ -48,14 +45,12 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import java.util.logging.Level; import static org.bukkit.Material.*; @@ -70,6 +65,23 @@ public class MenuItems { ButtonClickAction.plain((menuView, event) -> event.setCancelled(true))); } + public static Button changeLines(InternalNpc npc, Player player) { + + Component lines = Component.empty(); + + for (int i = 0; i < npc.getSettings().getHolograms().length; i++) { + Component holo = npc.getSettings().getHolograms()[i]; + lines = lines.append(Msg.format(" " + (i + 1) + ". ").append(holo)).append(Component.newline()); + } + + Component[] lore = Msg.vlore(player.locale(), "customnpcs.menus.main.items.name.current_name", 100, lines); + + return Button.clickable(ItemBuilder.modern(Material.NAME_TAG) + .setDisplay(Msg.translate(player.locale(), "customnpcs.menus.main.items.name.name")) + .setLore(lore) + .build(), new OpenButtonAction(MenuUtils.NPC_HOLOGRAMS)); + } + public static Button rotation(InternalNpc npc, Player player) { double dir = npc.getSpawnLoc().getYaw(); @@ -561,6 +573,11 @@ public static Button offhandSlot(InternalNpc npc, Player player) { } } + public static Button toPose(Player player) { + return Button.clickable(ItemBuilder.modern(SNIFFER_EGG).setDisplay(Msg.translate(player.locale(), "customnpcs.pose.pose_editor")).build(), + new OpenButtonAction(MenuUtils.NPC_POSE)); + } + public static Button toMain(Player player) { return Button.clickable(ItemBuilder.modern(BARRIER).setDisplay(Msg.translate(player.locale(), "customnpcs.items.go_back")).build(), new OpenButtonAction(MenuUtils.NPC_MAIN)); @@ -625,6 +642,114 @@ public static List