2021-12-05 15:04:03 -06:00
|
|
|
package noppes.npcs.scripted.entity;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2021-12-14 21:41:57 -06:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
2021-12-05 15:04:03 -06:00
|
|
|
import noppes.npcs.scripted.CustomNPCsException;
|
2021-12-14 21:41:57 -06:00
|
|
|
import noppes.npcs.scripted.NpcAPI;
|
|
|
|
|
import noppes.npcs.scripted.ScriptItemStack;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2021-12-15 05:43:07 -06:00
|
|
|
import java.util.Locale;
|
2021-12-05 15:04:03 -06:00
|
|
|
|
|
|
|
|
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
|
|
|
|
|
public T player;
|
|
|
|
|
|
|
|
|
|
public ScriptDBCPlayer(T player){
|
|
|
|
|
super(player);
|
|
|
|
|
this.player = player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStat(String stat, int value) {
|
|
|
|
|
stat = stat.toLowerCase().trim();
|
|
|
|
|
switch (stat) {
|
|
|
|
|
case "str":
|
|
|
|
|
case "strength":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStrI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "dex":
|
|
|
|
|
case "dexterity":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcDexI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "con":
|
|
|
|
|
case "constitution":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcCnsI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "wil":
|
|
|
|
|
case "willpower":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcWilI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "mnd":
|
|
|
|
|
case "mind":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcIntI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
case "spi":
|
|
|
|
|
case "spirit":
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcCncI", value);
|
2021-12-05 15:04:03 -06:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getStat(String stat) {
|
|
|
|
|
stat = stat.toLowerCase().trim();
|
|
|
|
|
switch (stat) {
|
|
|
|
|
case "str":
|
|
|
|
|
case "strength":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcStrI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "dex":
|
|
|
|
|
case "dexterity":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcDexI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "con":
|
|
|
|
|
case "constitution":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcCnsI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "wil":
|
|
|
|
|
case "willpower":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcWilI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "mnd":
|
|
|
|
|
case "mind":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcIntI");
|
2021-12-05 15:04:03 -06:00
|
|
|
case "spi":
|
|
|
|
|
case "spirit":
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcCncI");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" +
|
|
|
|
|
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 05:43:07 -06:00
|
|
|
private double applyOperator(String method, double n1, double n2) {
|
|
|
|
|
if (method.equals("+")) {
|
|
|
|
|
n1 += n2;
|
|
|
|
|
} else if (method.equals("-")) {
|
|
|
|
|
n1 -= n2;
|
|
|
|
|
} else if (method.equals("*")) {
|
|
|
|
|
n1 *= n2;
|
|
|
|
|
} else if (method.equals("/")) {
|
|
|
|
|
n1 /= n2;
|
|
|
|
|
} else if (method.equals("%")) {
|
|
|
|
|
n1 %= n2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return n1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 06:19:16 -06:00
|
|
|
public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue){
|
|
|
|
|
addBonusAttribute(stat,bonusID,operation,attributeValue,true);
|
|
|
|
|
}
|
|
|
|
|
public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList){
|
|
|
|
|
bonusAttribute("add",stat,bonusID,operation,attributeValue,endOfTheList);
|
|
|
|
|
}
|
|
|
|
|
public void addToBonusAttribute(String stat, String bonusID, String operation, double attributeValue){
|
|
|
|
|
bonusAttribute("addto",stat,bonusID,operation,attributeValue,true);
|
|
|
|
|
}
|
|
|
|
|
public void setBonusAttribute(String stat, String bonusID, String operation, double attributeValue){
|
|
|
|
|
bonusAttribute("set",stat,bonusID,operation,attributeValue,true);
|
|
|
|
|
}
|
|
|
|
|
public void getBonusAttribute(String stat, String bonusID){
|
|
|
|
|
bonusAttribute("get",stat,bonusID,"*",1.0,true);
|
|
|
|
|
}
|
|
|
|
|
public void removeBonusAttribute(String stat, String bonusID){
|
|
|
|
|
bonusAttribute("remove",stat,bonusID,"*",1.0,true);
|
|
|
|
|
}
|
|
|
|
|
public void clearBonusAttribute(String stat){
|
|
|
|
|
bonusAttribute("clear",stat,"","*",1.0,true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String bonusAttribute(String action, String stat, String bonusID) {
|
|
|
|
|
String[] actions = new String[]{"get", "remove", "clear"};
|
|
|
|
|
boolean valid = false;
|
|
|
|
|
for(String s : actions){
|
|
|
|
|
if(s.equals(action.toLowerCase())){
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!valid) {
|
|
|
|
|
throw new CustomNPCsException("Action can be: get/remove/clear", new Object[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bonusAttribute(action,stat,bonusID,"*",1.0,false);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 05:43:07 -06:00
|
|
|
public String bonusAttribute(String action, String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList) {
|
|
|
|
|
String[] actions = new String[]{"add", "addto", "set", "get", "remove", "clear"};
|
|
|
|
|
String[] operations = new String[]{"+", "-", "*", "/", "%"};
|
|
|
|
|
|
|
|
|
|
boolean valid = false;
|
|
|
|
|
for(String s : actions){
|
|
|
|
|
if(s.equals(action.toLowerCase())){
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!valid) {
|
|
|
|
|
throw new CustomNPCsException("Action can be: add/addTo/set/get/remove/clear", new Object[0]);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 06:19:16 -06:00
|
|
|
if(!action.equals("remove") && !action.equals("get") && !action.equals("clear")) {
|
|
|
|
|
valid = false;
|
|
|
|
|
for (String s : operations) {
|
|
|
|
|
if (s.equals(operation)) {
|
|
|
|
|
valid = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!valid) {
|
|
|
|
|
throw new CustomNPCsException("Operation can be: + - * / %", new Object[0]);
|
2021-12-15 05:43:07 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stat = stat.toLowerCase().trim();
|
|
|
|
|
switch (stat) {
|
|
|
|
|
case "strength":
|
|
|
|
|
stat = "str";
|
2021-12-15 06:46:27 -06:00
|
|
|
break;
|
2021-12-15 05:43:07 -06:00
|
|
|
case "dexterity":
|
|
|
|
|
stat = "dex";
|
2021-12-15 06:46:27 -06:00
|
|
|
break;
|
2021-12-15 05:43:07 -06:00
|
|
|
case "constitution":
|
|
|
|
|
stat = "con";
|
2021-12-15 06:46:27 -06:00
|
|
|
break;
|
2021-12-15 05:43:07 -06:00
|
|
|
case "willpower":
|
|
|
|
|
stat = "wil";
|
2021-12-15 06:46:27 -06:00
|
|
|
break;
|
2021-12-15 05:43:07 -06:00
|
|
|
case "mind":
|
|
|
|
|
stat = "mnd";
|
2021-12-15 06:46:27 -06:00
|
|
|
break;
|
2021-12-15 05:43:07 -06:00
|
|
|
case "spirit":
|
|
|
|
|
stat = "spi";
|
2021-12-15 06:46:27 -06:00
|
|
|
break;
|
2021-12-15 05:43:07 -06:00
|
|
|
}
|
|
|
|
|
if(!(stat.equals("str") || stat.equals("dex") || stat.equals("con") || stat.equals("wil") || stat.equals("mnd") || stat.equals("spi")))
|
|
|
|
|
throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" +
|
|
|
|
|
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]);
|
|
|
|
|
|
|
|
|
|
String bonusValueString = operation + attributeValue;
|
|
|
|
|
String bonus = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcAttrBonus"+stat);
|
|
|
|
|
String bonuses[] = bonus.split("\\|");
|
|
|
|
|
String[][] bonusValues = new String[bonuses.length][2];
|
|
|
|
|
if (bonuses.length > 0 && bonuses[0].length() > 0) {
|
|
|
|
|
for(int i = 0; i < bonuses.length; ++i) {
|
|
|
|
|
String[] bonusValue = bonuses[i].split("\\;");
|
|
|
|
|
bonusValues[i][0] = bonusValue[0];
|
|
|
|
|
bonusValues[i][1] = bonusValue[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (action) {
|
|
|
|
|
case "get":
|
|
|
|
|
if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat)) {
|
|
|
|
|
for (String[] s : bonusValues) {
|
|
|
|
|
if (s[0].equals(bonusID))
|
|
|
|
|
return s[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
case "clear":
|
|
|
|
|
if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat))
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, "");
|
|
|
|
|
break;
|
|
|
|
|
case "remove":
|
|
|
|
|
String newBonusString = "";
|
2021-12-15 06:46:27 -06:00
|
|
|
if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat)) {
|
|
|
|
|
int num = -1;
|
|
|
|
|
boolean number;
|
|
|
|
|
boolean run = false;
|
|
|
|
|
String[] bonusValue;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
num = Integer.parseInt(bonusID);
|
|
|
|
|
number = true;
|
|
|
|
|
} catch (Exception var33) {
|
|
|
|
|
number = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < bonuses.length; ++i) {
|
|
|
|
|
bonusValue = bonuses[i].split("\\;");
|
|
|
|
|
bonusValues[i][0] = bonusValue[0];
|
|
|
|
|
if (number && i == num || !number && bonusValues[i][0].equals(bonusID)) {
|
|
|
|
|
bonuses[i] = "";
|
|
|
|
|
run = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (run) {
|
|
|
|
|
String startString = "";
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < bonuses.length; ++i) {
|
|
|
|
|
if (bonuses[i] != null && bonuses[i].length() > 0) {
|
|
|
|
|
startString = startString + bonuses[i] + (bonuses.length - 1 == i ? "" : "|");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString);
|
|
|
|
|
}
|
2021-12-15 05:43:07 -06:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "add":
|
|
|
|
|
boolean nbtFail = false;
|
|
|
|
|
|
|
|
|
|
for (int id = 0; id < bonuses.length; ++id) {
|
|
|
|
|
String[] bonusValue = bonuses[id].split("\\;");
|
|
|
|
|
bonusValues[id][0] = bonusValue[0];
|
|
|
|
|
if (bonusValues[id][0].equals(bonusID)) {
|
|
|
|
|
nbtFail = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!nbtFail) {
|
|
|
|
|
if (endOfTheList) {
|
|
|
|
|
if (bonus.length() == 0) {
|
|
|
|
|
bonus = bonusID + ";" + bonusValueString;
|
|
|
|
|
} else {
|
|
|
|
|
bonus = bonus + "|" + bonusID + ";" + bonusValueString;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (bonus.length() == 0) {
|
|
|
|
|
bonus = bonusID + ";" + bonusValueString;
|
|
|
|
|
} else {
|
|
|
|
|
bonus = bonusID + ";" + bonusValueString + "|" + bonus;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, bonus);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "set": {
|
|
|
|
|
String noNBTText;
|
|
|
|
|
int startIndex = -1;
|
|
|
|
|
boolean number = false;
|
|
|
|
|
boolean run = false;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
startIndex = Integer.parseInt(bonusID);
|
|
|
|
|
number = true;
|
|
|
|
|
} catch (Exception var34) {
|
|
|
|
|
number = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (startIndex = 0; startIndex < bonuses.length; ++startIndex) {
|
|
|
|
|
String[] bonusValue = bonuses[startIndex].split("\\;");
|
|
|
|
|
bonusValues[startIndex][0] = bonusValue[0];
|
|
|
|
|
if (number && startIndex == startIndex || !number && bonusValues[startIndex][0].equals(bonusID)) {
|
|
|
|
|
noNBTText = bonusValues[startIndex][0] + ";" + bonusValueString;
|
|
|
|
|
bonuses[startIndex] = "";
|
|
|
|
|
run = true;
|
|
|
|
|
bonuses[startIndex] = noNBTText;
|
|
|
|
|
bonusValue = bonuses[startIndex].split("\\;");
|
|
|
|
|
bonusValues[startIndex][0] = bonusValue[0];
|
|
|
|
|
bonusValues[startIndex][1] = bonusValue[1];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (run) {
|
|
|
|
|
String startString = "";
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < bonuses.length; ++i) {
|
|
|
|
|
if (bonuses[i] != null && bonuses[i].length() > 0) {
|
|
|
|
|
startString = startString + bonuses[i] + (bonuses.length - 1 == i ? "" : "|");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case "addto": {
|
|
|
|
|
boolean number;
|
|
|
|
|
boolean run = false;
|
|
|
|
|
int id = -1;
|
|
|
|
|
try {
|
|
|
|
|
id = Integer.parseInt(bonusID);
|
|
|
|
|
number = true;
|
|
|
|
|
} catch (Exception var35) {
|
|
|
|
|
number = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < bonuses.length; ++i) {
|
|
|
|
|
String[] bonusValue = bonuses[i].split("\\;");
|
|
|
|
|
bonusValues[i][0] = bonusValue[0];
|
|
|
|
|
if (number && i == id || !number && bonusValues[i][0].equals(bonusID)) {
|
|
|
|
|
if (!bonusValues[i][1].contains("nbt_") && !bonusValues[i][1].contains("NBT_") && !bonusValueString.contains("nbt_") && !bonusValueString.contains("NBT_")) {
|
|
|
|
|
double value = Double.parseDouble(bonusValues[i][1].substring(1));
|
|
|
|
|
double resultValue = applyOperator(operation, value, attributeValue);
|
|
|
|
|
String result = bonusValues[i][1].substring(0, 1) + resultValue;
|
|
|
|
|
String data = bonusValues[i][0] + ";" + result;
|
|
|
|
|
bonuses[i] = data;
|
|
|
|
|
bonusValue = bonuses[i].split("\\;");
|
|
|
|
|
bonusValues[i][0] = bonusValue[0];
|
|
|
|
|
bonusValues[i][1] = bonusValue[1];
|
|
|
|
|
run = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (run) {
|
|
|
|
|
String startString = "";
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < bonuses.length; ++i) {
|
|
|
|
|
if (bonuses[i] != null && bonuses[i].length() > 0) {
|
|
|
|
|
startString = startString + bonuses[i] + (bonuses.length - 1 == i ? "" : "|");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 15:04:03 -06:00
|
|
|
public void setRelease(byte release){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRelease",release);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public byte getRelease(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRelease");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBody(int body){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcBdy",body);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getBody(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcBdy");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStamina(int stamina){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStamina",stamina);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getStamina(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcStamina");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setKi(int ki){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcEnrgy",ki);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getKi(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcEnrgy");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTP(int tp){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcTpint",tp);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getTP(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcTpint");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setGravity(float gravity){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setFloat("jrmcGravForce",gravity);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public float getGravity(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getFloat("jrmcGravForce");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
2021-12-14 21:41:57 -06:00
|
|
|
public boolean isBlocking(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
return compound.getCompoundTag("JRMCEP").getInteger("blocking") == 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setHairCode(String hairCode){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
compound.getCompoundTag("JRMCEP").setString("haircode",hairCode);
|
|
|
|
|
}
|
|
|
|
|
public String getHairCode(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
return compound.getCompoundTag("JRMCEP").getString("haircode");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setExtraCode(String extraCode){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
compound.getCompoundTag("JRMCEP").setString("extracode",extraCode);
|
|
|
|
|
}
|
|
|
|
|
public String getExtraCode(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
return compound.getCompoundTag("JRMCEP").getString("extracode");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ScriptItemStack[] getInventory(){
|
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
|
|
|
|
this.player.writeToNBT(compound);
|
|
|
|
|
|
|
|
|
|
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10);
|
|
|
|
|
ScriptItemStack[] itemList = new ScriptItemStack[list.tagCount()];
|
|
|
|
|
for (int i = 0; i < list.tagCount(); i++) {
|
|
|
|
|
ItemStack itemStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
|
|
|
|
|
itemList[i] = new ScriptItemStack(itemStack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return itemList;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 15:04:03 -06:00
|
|
|
public void setForm(byte form){
|
2022-02-21 20:16:42 -06:00
|
|
|
if(form < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch(getRace()){
|
|
|
|
|
case 0:
|
|
|
|
|
case 3:
|
|
|
|
|
if(form > 3)
|
|
|
|
|
return;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
case 2:
|
|
|
|
|
if(form > 15)
|
|
|
|
|
return;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
if(form > 7)
|
|
|
|
|
return;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public byte getForm(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public void setForm2(byte form2){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState2",form2);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public byte getForm2(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState2");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPowerPoints(int points){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv",points);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getPowerPoints(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcArcRsrv");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAuraColor(int color){
|
2021-12-13 18:33:20 -06:00
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcAuraColor",color);
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getAuraColor(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcAuraColor");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
|
2021-12-15 03:14:48 -06:00
|
|
|
public void setFormLevel(int level){
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSltX","TR"+level);
|
|
|
|
|
}
|
|
|
|
|
public int getFormLevel(){
|
2022-01-04 00:06:48 -06:00
|
|
|
String formString = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSltX");
|
|
|
|
|
if(formString.length() < 1)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
StringBuilder digitString = new StringBuilder();
|
|
|
|
|
for(char c : formString.toCharArray()){
|
|
|
|
|
if(Character.isDigit(c))
|
|
|
|
|
digitString.append(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(digitString.length() < 1)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return Integer.parseInt(digitString.toString());
|
2021-12-15 03:14:48 -06:00
|
|
|
}
|
|
|
|
|
|
2021-12-15 03:19:34 -06:00
|
|
|
public void setSkills(String skills){
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSlts",skills);
|
|
|
|
|
}
|
|
|
|
|
public String getSkills(){
|
|
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSlts");
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 05:43:07 -06:00
|
|
|
public void setJRMCSE(String statusEffects){
|
|
|
|
|
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcStatusEff",statusEffects);
|
|
|
|
|
}
|
|
|
|
|
public String getJRMCSE(){
|
|
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcStatusEff");
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 15:04:03 -06:00
|
|
|
public byte getDBCClass(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcClass");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getRace(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRace");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getPowerType(){
|
2021-12-13 18:33:20 -06:00
|
|
|
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcPwrtyp");
|
2021-12-05 15:04:03 -06:00
|
|
|
}
|
|
|
|
|
public int getKillCount(String type){
|
|
|
|
|
type = type.toLowerCase().trim();
|
|
|
|
|
|
2021-12-13 18:33:20 -06:00
|
|
|
int evilKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountEvil");
|
|
|
|
|
int goodKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountGood");
|
|
|
|
|
int neutKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountNeut");
|
2021-12-05 15:04:03 -06:00
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
case "evil":
|
|
|
|
|
return evilKills;
|
|
|
|
|
case "good":
|
|
|
|
|
return goodKills;
|
|
|
|
|
case "neutral":
|
|
|
|
|
return neutKills;
|
|
|
|
|
case "all":
|
|
|
|
|
return evilKills + goodKills + neutKills;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new CustomNPCsException("Invalid kill type: " + type + "\nValid kill types are: evil, good, neutral, all", new Object[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|