mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 11:05:12 +00:00
Added handler support to NPC API.
This commit is contained in:
1 parent
69f96519dc
commit
d50f51e208
40 files changed
+1471
-56
No files matched your search
@@ -33,7 +33,6 @@ import foxz.commandhelper.annotations.SubCommand;
|
||||
import foxz.commandhelper.permissions.OpOnly;
|
||||
import foxz.commandhelper.permissions.ParamCheck;
|
||||
import foxz.commandhelper.permissions.PlayerOnly;
|
||||
import foxz.utils.Utils;
|
||||
|
||||
@Command(
|
||||
name = "noppes",
|
||||
@@ -89,7 +88,7 @@ public class CmdNoppes extends ChMcLogger {
|
||||
return false;
|
||||
}
|
||||
try{
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().getFaction(Integer.parseInt(factionname));
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().get(Integer.parseInt(factionname));
|
||||
}
|
||||
catch(NumberFormatException e){
|
||||
cmdfaction.selectedFaction = FactionController.getInstance().getFactionFromName(factionname); // get faction data
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.netty.buffer.Unpooled;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -400,4 +401,31 @@ public class NoppesUtilPlayer {
|
||||
public static void isGUIOpen(EntityPlayerMP player){
|
||||
Server.sendData(player, EnumPacketClient.ISGUIOPEN);
|
||||
}
|
||||
|
||||
public static List<ItemStack> countStacks(IInventory inv, boolean ignoreDamage, boolean ignoreNBT) {
|
||||
List<ItemStack> list = new ArrayList();
|
||||
|
||||
for(int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
ItemStack item = inv.getStackInSlot(i);
|
||||
if (!NoppesUtilServer.IsItemStackNull(item)) {
|
||||
boolean found = false;
|
||||
Iterator var7 = list.iterator();
|
||||
|
||||
while(var7.hasNext()) {
|
||||
ItemStack is = (ItemStack)var7.next();
|
||||
if (compareItems(item, is, ignoreDamage, ignoreNBT)) {
|
||||
is.stackSize = is.stackSize + item.stackSize;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
list.add(item.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -711,4 +711,8 @@ public class NoppesUtilServer {
|
||||
boolean isGUIOpen = buffer.readBoolean();
|
||||
playerdata.setGUIOpen(isGUIOpen);
|
||||
}
|
||||
|
||||
public static boolean IsItemStackNull(ItemStack is) {
|
||||
return is == null || is.stackSize == 0 || is.getItem() == null;
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class PacketHandlerServer{
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionGet){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
Faction faction = FactionController.getInstance().getFaction(buffer.readInt());
|
||||
Faction faction = FactionController.getInstance().get(buffer.readInt());
|
||||
faction.writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
@@ -380,7 +380,7 @@ public class PacketHandlerServer{
|
||||
NoppesUtilServer.setRecipeGui(player,recipe);
|
||||
}
|
||||
else if(type == EnumPacketServer.RecipeRemove){
|
||||
RecipeCarpentry recipe = RecipeController.instance.removeRecipe(buffer.readInt());
|
||||
RecipeCarpentry recipe = RecipeController.instance.delete(buffer.readInt());
|
||||
NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4);
|
||||
NoppesUtilServer.setRecipeGui(player,new RecipeCarpentry(""));
|
||||
}
|
||||
@@ -555,14 +555,14 @@ public class PacketHandlerServer{
|
||||
else if(type == EnumPacketServer.FactionSave){
|
||||
Faction faction = new Faction();
|
||||
faction.readNBT(Server.readNBT(buffer));
|
||||
FactionController.getInstance().saveFaction(faction);
|
||||
FactionController.getInstance().create(faction);
|
||||
NoppesUtilServer.sendFactionDataAll(player);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
faction.writeNBT(compound);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.FactionRemove){
|
||||
FactionController.getInstance().removeFaction(buffer.readInt());
|
||||
FactionController.getInstance().delete(buffer.readInt());
|
||||
NoppesUtilServer.sendFactionDataAll(player);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
(new Faction()).writeNBT(compound);
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.controllers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import noppes.npcs.ICompatibilty;
|
||||
import noppes.npcs.VersionCompatibility;
|
||||
import noppes.npcs.constants.EnumAvailabilityDialog;
|
||||
@@ -9,8 +10,11 @@ import noppes.npcs.constants.EnumAvailabilityFaction;
|
||||
import noppes.npcs.constants.EnumAvailabilityFactionType;
|
||||
import noppes.npcs.constants.EnumAvailabilityQuest;
|
||||
import noppes.npcs.constants.EnumDayTime;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.handler.data.IAvailability;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
|
||||
public class Availability implements ICompatibilty {
|
||||
public class Availability implements ICompatibilty, IAvailability {
|
||||
public int version = VersionCompatibility.ModRev;
|
||||
|
||||
public EnumAvailabilityDialog dialogAvailable = EnumAvailabilityDialog.Always;
|
||||
@@ -178,7 +182,7 @@ public class Availability implements ICompatibilty {
|
||||
if(available == EnumAvailabilityFactionType.Always)
|
||||
return true;
|
||||
|
||||
Faction faction = FactionController.getInstance().getFaction(id);
|
||||
Faction faction = FactionController.getInstance().get(id);
|
||||
if(faction == null)
|
||||
return true;
|
||||
|
||||
@@ -233,4 +237,170 @@ public class Availability implements ICompatibilty {
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public boolean isAvailable(IPlayer player) {
|
||||
return this.isAvailable((EntityPlayer)player.getMCEntity());
|
||||
}
|
||||
|
||||
public int getDaytime() {
|
||||
return this.daytime.ordinal();
|
||||
}
|
||||
|
||||
public void setDaytime(int type) {
|
||||
this.daytime = EnumDayTime.values()[MathHelper.clamp_int(type, 0, 2)];
|
||||
}
|
||||
|
||||
public int getMinPlayerLevel() {
|
||||
return this.minPlayerLevel;
|
||||
}
|
||||
|
||||
public void setMinPlayerLevel(int level) {
|
||||
this.minPlayerLevel = level;
|
||||
}
|
||||
|
||||
public int getDialog(int i) {
|
||||
if (i < 0 && i > 3) {
|
||||
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||
} else if (i == 0) {
|
||||
return this.dialogId;
|
||||
} else if (i == 1) {
|
||||
return this.dialog2Id;
|
||||
} else {
|
||||
return i == 2 ? this.dialog3Id : this.dialog4Id;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDialog(int i, int id, int type) {
|
||||
if (i < 0 && i > 3) {
|
||||
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||
} else {
|
||||
EnumAvailabilityDialog e = EnumAvailabilityDialog.values()[MathHelper.clamp_int(type, 0, 2)];
|
||||
if (i == 0) {
|
||||
this.dialogId = id;
|
||||
this.dialogAvailable = e;
|
||||
} else if (i == 1) {
|
||||
this.dialog2Id = id;
|
||||
this.dialog2Available = e;
|
||||
} else if (i == 2) {
|
||||
this.dialog3Id = id;
|
||||
this.dialog3Available = e;
|
||||
} else if (i == 3) {
|
||||
this.dialog4Id = id;
|
||||
this.dialog4Available = e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void removeDialog(int i) {
|
||||
if (i < 0 && i > 3) {
|
||||
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||
} else {
|
||||
if (i == 0) {
|
||||
this.dialogId = -1;
|
||||
this.dialogAvailable = EnumAvailabilityDialog.Always;
|
||||
} else if (i == 1) {
|
||||
this.dialog2Id = -1;
|
||||
this.dialog2Available = EnumAvailabilityDialog.Always;
|
||||
} else if (i == 2) {
|
||||
this.dialog3Id = -1;
|
||||
this.dialog3Available = EnumAvailabilityDialog.Always;
|
||||
} else if (i == 3) {
|
||||
this.dialog4Id = -1;
|
||||
this.dialog4Available = EnumAvailabilityDialog.Always;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int getQuest(int i) {
|
||||
if (i < 0 && i > 3) {
|
||||
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||
} else if (i == 0) {
|
||||
return this.questId;
|
||||
} else if (i == 1) {
|
||||
return this.quest2Id;
|
||||
} else {
|
||||
return i == 2 ? this.quest3Id : this.quest4Id;
|
||||
}
|
||||
}
|
||||
|
||||
public void setQuest(int i, int id, int type) {
|
||||
if (i < 0 && i > 3) {
|
||||
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||
} else {
|
||||
EnumAvailabilityQuest e = EnumAvailabilityQuest.values()[MathHelper.clamp_int(type, 0, 5)];
|
||||
if (i == 0) {
|
||||
this.questId = id;
|
||||
this.questAvailable = e;
|
||||
} else if (i == 1) {
|
||||
this.quest2Id = id;
|
||||
this.quest2Available = e;
|
||||
} else if (i == 2) {
|
||||
this.quest3Id = id;
|
||||
this.quest3Available = e;
|
||||
} else if (i == 3) {
|
||||
this.quest4Id = id;
|
||||
this.quest4Available = e;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void removeQuest(int i) {
|
||||
if (i < 0 && i > 3) {
|
||||
throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]);
|
||||
} else {
|
||||
if (i == 0) {
|
||||
this.questId = -1;
|
||||
this.questAvailable = EnumAvailabilityQuest.Always;
|
||||
} else if (i == 1) {
|
||||
this.quest2Id = -1;
|
||||
this.quest2Available = EnumAvailabilityQuest.Always;
|
||||
} else if (i == 2) {
|
||||
this.quest3Id = -1;
|
||||
this.quest3Available = EnumAvailabilityQuest.Always;
|
||||
} else if (i == 3) {
|
||||
this.quest4Id = -1;
|
||||
this.quest4Available = EnumAvailabilityQuest.Always;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void setFaction(int i, int id, int type, int stance) {
|
||||
if (i < 0 && i > 1) {
|
||||
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
|
||||
} else {
|
||||
EnumAvailabilityFactionType e = EnumAvailabilityFactionType.values()[MathHelper.clamp_int(type, 0, 2)];
|
||||
EnumAvailabilityFaction ee = EnumAvailabilityFaction.values()[MathHelper.clamp_int(stance, 0, 2)];
|
||||
if (i == 0) {
|
||||
this.factionId = id;
|
||||
this.factionAvailable = e;
|
||||
this.factionStance = ee;
|
||||
} else if (i == 1) {
|
||||
this.faction2Id = id;
|
||||
this.faction2Available = e;
|
||||
this.faction2Stance = ee;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFaction(int i) {
|
||||
if (i < 0 && i > 1) {
|
||||
throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]);
|
||||
} else {
|
||||
if (i == 0) {
|
||||
this.factionId = -1;
|
||||
this.factionAvailable = EnumAvailabilityFactionType.Always;
|
||||
this.factionStance = EnumAvailabilityFaction.Friendly;
|
||||
} else if (i == 1) {
|
||||
this.faction2Id = -1;
|
||||
this.faction2Available = EnumAvailabilityFactionType.Always;
|
||||
this.faction2Stance = EnumAvailabilityFaction.Friendly;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -8,8 +10,10 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.ICompatibilty;
|
||||
import noppes.npcs.VersionCompatibility;
|
||||
import noppes.npcs.constants.EnumOptionType;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.handler.data.*;
|
||||
|
||||
public class Dialog implements ICompatibilty {
|
||||
public class Dialog implements ICompatibilty, IDialog {
|
||||
public int version = VersionCompatibility.ModRev;
|
||||
public int id = -1;
|
||||
public String title = "";
|
||||
@@ -108,9 +112,7 @@ public class Dialog implements ICompatibilty {
|
||||
public boolean hasQuest() {
|
||||
return getQuest() != null;
|
||||
}
|
||||
public Quest getQuest() {
|
||||
return QuestController.instance.quests.get(quest);
|
||||
}
|
||||
|
||||
public boolean hasOtherOptions() {
|
||||
for(DialogOption option: options.values())
|
||||
if(option != null && option.optionType != EnumOptionType.Disabled)
|
||||
@@ -148,5 +150,74 @@ public class Dialog implements ICompatibilty {
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public List<IDialogOption> getOptions() {
|
||||
return new ArrayList(this.options.values());
|
||||
}
|
||||
|
||||
public IDialogOption getOption(int slot) {
|
||||
IDialogOption option = (IDialogOption)this.options.get(slot);
|
||||
if (option == null) {
|
||||
throw new CustomNPCsException("There is no DialogOption for slot: " + slot, new Object[0]);
|
||||
} else {
|
||||
return option;
|
||||
}
|
||||
}
|
||||
|
||||
public IAvailability getAvailability() {
|
||||
return this.availability;
|
||||
}
|
||||
|
||||
public IDialogCategory getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
DialogController.instance.saveDialog(this.category.id, this);
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.title = name;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public void setQuest(IQuest quest) {
|
||||
if (quest == null) {
|
||||
this.quest = -1;
|
||||
} else {
|
||||
if (quest.getId() < 0) {
|
||||
throw new CustomNPCsException("Quest id is lower than 0", new Object[0]);
|
||||
}
|
||||
|
||||
this.quest = quest.getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Quest getQuest() {
|
||||
return QuestController.instance == null ? null : (Quest)QuestController.instance.quests.get(this.quest);
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public void setCommand(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.scripted.handler.data.IDialog;
|
||||
import noppes.npcs.scripted.handler.data.IDialogCategory;
|
||||
|
||||
public class DialogCategory {
|
||||
public class DialogCategory implements IDialogCategory {
|
||||
|
||||
public int id = -1;
|
||||
public String title = "";
|
||||
@@ -43,4 +47,18 @@ public class DialogCategory {
|
||||
nbtfactions.setTag("Dialogs", dialogs);
|
||||
return nbtfactions;
|
||||
}
|
||||
|
||||
public List<IDialog> dialogs() {
|
||||
return new ArrayList(this.dialogs.values());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public IDialog create() {
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.category = this;
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package noppes.npcs.controllers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -13,9 +11,12 @@ import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.constants.EnumOptionType;
|
||||
import noppes.npcs.scripted.handler.IDialogHandler;
|
||||
import noppes.npcs.scripted.handler.data.IDialog;
|
||||
import noppes.npcs.scripted.handler.data.IDialogCategory;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
public class DialogController {
|
||||
public class DialogController implements IDialogHandler {
|
||||
public HashMap<Integer,DialogCategory> categories = new HashMap<Integer, DialogCategory>();
|
||||
public HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>();
|
||||
public static DialogController instance;
|
||||
@@ -312,4 +313,12 @@ public class DialogController {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public List<IDialogCategory> categories() {
|
||||
return new ArrayList(this.categories.values());
|
||||
}
|
||||
|
||||
public IDialog get(int id) {
|
||||
return (IDialog)this.dialogs.get(id);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,18 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.handler.data.IFaction;
|
||||
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
|
||||
public class Faction {
|
||||
public class Faction implements IFaction {
|
||||
public String name = "";
|
||||
public int color = Integer.parseInt("FF00", 16);
|
||||
|
||||
@@ -85,4 +90,90 @@ public class Faction {
|
||||
public boolean isAggressiveToNpc(EntityNPCInterface entity) {
|
||||
return attackFactions.contains(entity.faction.id);
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getDefaultPoints() {
|
||||
return this.defaultPoints;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public int playerStatus(IPlayer player) {
|
||||
PlayerFactionData data = PlayerData.get((EntityPlayer) player.getMCEntity()).factionData;
|
||||
int points = data.getFactionPoints(this.id);
|
||||
if (points >= this.friendlyPoints) {
|
||||
return 1;
|
||||
} else {
|
||||
return points < this.neutralPoints ? -1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hostileToNpc(ICustomNpc npc) {
|
||||
return this.attackFactions.contains(npc.getFaction().getId());
|
||||
}
|
||||
|
||||
public void setDefaultPoints(int points) {
|
||||
this.defaultPoints = points;
|
||||
}
|
||||
|
||||
public boolean hostileToFaction(int factionId) {
|
||||
return this.attackFactions.contains(factionId);
|
||||
}
|
||||
|
||||
public int[] getHostileList() {
|
||||
int[] a = new int[this.attackFactions.size()];
|
||||
int i = 0;
|
||||
|
||||
Integer val;
|
||||
for(Iterator var3 = this.attackFactions.iterator(); var3.hasNext(); a[i++] = val) {
|
||||
val = (Integer)var3.next();
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
public void addHostile(int id) {
|
||||
if (this.attackFactions.contains(id)) {
|
||||
throw new CustomNPCsException("Faction " + this.id + " is already hostile to " + id, new Object[0]);
|
||||
} else {
|
||||
this.attackFactions.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeHostile(int id) {
|
||||
this.attackFactions.remove(id);
|
||||
}
|
||||
|
||||
public boolean hasHostile(int id) {
|
||||
return this.attackFactions.contains(id);
|
||||
}
|
||||
|
||||
public boolean getIsHidden() {
|
||||
return this.hideFaction;
|
||||
}
|
||||
|
||||
public void setIsHidden(boolean bo) {
|
||||
this.hideFaction = bo;
|
||||
}
|
||||
|
||||
public boolean getAttackedByMobs() {
|
||||
return this.getsAttacked;
|
||||
}
|
||||
|
||||
public void setAttackedByMobs(boolean bo) {
|
||||
this.getsAttacked = bo;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
FactionController.getInstance().saveFaction(this);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,9 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
@@ -15,8 +17,12 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.scripted.handler.IFactionHandler;
|
||||
import noppes.npcs.scripted.handler.data.IFaction;
|
||||
|
||||
public class FactionController {
|
||||
public class FactionController implements IFactionHandler {
|
||||
public HashMap<Integer,Faction> factions;
|
||||
|
||||
private static FactionController instance;
|
||||
@@ -124,10 +130,14 @@ public class FactionController {
|
||||
}
|
||||
}
|
||||
|
||||
public Faction getFaction(int faction) {
|
||||
public Faction get(int faction) {
|
||||
return factions.get(faction);
|
||||
}
|
||||
|
||||
public List<IFaction> list() {
|
||||
return new ArrayList(this.factions.values());
|
||||
}
|
||||
|
||||
public void saveFaction(Faction faction) {
|
||||
|
||||
if(faction.id < 0){
|
||||
@@ -145,6 +155,30 @@ public class FactionController {
|
||||
factions.put(faction.id, faction);
|
||||
saveFactions();
|
||||
}
|
||||
|
||||
public Faction create(Faction faction) {
|
||||
String name = faction.getName();
|
||||
int color = faction.getColor();
|
||||
|
||||
for(faction = new Faction(); this.hasName(name); name = name + "_") {
|
||||
}
|
||||
|
||||
faction.name = name;
|
||||
faction.color = color;
|
||||
this.saveFaction(faction);
|
||||
return faction;
|
||||
}
|
||||
|
||||
public Faction create(String name, int color) {
|
||||
Faction faction;
|
||||
for(faction = new Faction(); this.hasName(name); name = name + "_") {
|
||||
}
|
||||
|
||||
faction.name = name;
|
||||
faction.color = color;
|
||||
this.saveFaction(faction);
|
||||
return faction;
|
||||
}
|
||||
|
||||
public int getUnusedId(){
|
||||
if(lastUsedID == 0){
|
||||
@@ -155,11 +189,20 @@ public class FactionController {
|
||||
lastUsedID++;
|
||||
return lastUsedID;
|
||||
}
|
||||
public void removeFaction(int id) {
|
||||
if(id < 0 || factions.size() <= 1)
|
||||
return;
|
||||
factions.remove(id);
|
||||
saveFactions();
|
||||
public IFaction delete(int id) {
|
||||
if (id >= 0 && this.factions.size() > 1) {
|
||||
Faction faction = (Faction)this.factions.remove(id);
|
||||
saveFactions();
|
||||
if (faction == null) {
|
||||
return null;
|
||||
} else {
|
||||
this.saveFactions();
|
||||
faction.id = -1;
|
||||
return faction;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getFirstFactionId() {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FactionOptions {
|
||||
addPoints(player, data, faction2Id, decreaseFaction2Points, faction2Points);
|
||||
}
|
||||
private void addPoints(EntityPlayer player, PlayerFactionData data, int factionId, boolean decrease, int points) {
|
||||
Faction faction = FactionController.getInstance().getFaction(factionId);
|
||||
Faction faction = FactionController.getInstance().get(factionId);
|
||||
if(faction == null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PlayerFactionData {
|
||||
|
||||
public int getFactionPoints(int id) {
|
||||
if(!factionData.containsKey(id)){
|
||||
Faction faction = FactionController.getInstance().getFaction(id);
|
||||
Faction faction = FactionController.getInstance().get(id);
|
||||
factionData.put(id, faction == null? -1 : faction.defaultPoints);
|
||||
}
|
||||
return factionData.get(id);
|
||||
@@ -47,7 +47,7 @@ public class PlayerFactionData {
|
||||
|
||||
public void increasePoints(int factionId, int points) {
|
||||
if(!factionData.containsKey(factionId)){
|
||||
Faction faction = FactionController.getInstance().getFaction(factionId);
|
||||
Faction faction = FactionController.getInstance().get(factionId);
|
||||
factionData.put(factionId, faction == null? -1 : faction.defaultPoints);
|
||||
}
|
||||
factionData.put(factionId, factionData.get(factionId) + points);
|
||||
@@ -59,7 +59,7 @@ public class PlayerFactionData {
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(int id : factionData.keySet()){
|
||||
Faction faction = FactionController.getInstance().getFaction(id);
|
||||
Faction faction = FactionController.getInstance().get(id);
|
||||
if(faction == null || faction.hideFaction)
|
||||
continue;
|
||||
NBTTagCompound com = new NBTTagCompound();
|
||||
|
||||
@@ -16,8 +16,15 @@ import noppes.npcs.quests.QuestInterface;
|
||||
import noppes.npcs.quests.QuestItem;
|
||||
import noppes.npcs.quests.QuestKill;
|
||||
import noppes.npcs.quests.QuestLocation;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.handler.data.IQuestCategory;
|
||||
import noppes.npcs.scripted.handler.data.IQuestObjective;
|
||||
import noppes.npcs.scripted.interfaces.IContainer;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
|
||||
public class Quest implements ICompatibilty {
|
||||
public class Quest implements ICompatibilty, IQuest {
|
||||
public int version = VersionCompatibility.ModRev;
|
||||
public int id = -1;
|
||||
public EnumQuestType type = EnumQuestType.Item;
|
||||
@@ -148,4 +155,91 @@ public class Quest implements ICompatibilty {
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type.ordinal();
|
||||
}
|
||||
|
||||
public void setType(int questType) {
|
||||
if(questType < 0 || questType >= EnumQuestType.values().length)
|
||||
return;
|
||||
|
||||
EnumQuestType type = EnumQuestType.values()[questType];
|
||||
setType(type);
|
||||
}
|
||||
|
||||
public IQuestCategory getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
QuestController.instance.saveQuest(this.category.id, this);
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.title = name;
|
||||
}
|
||||
|
||||
public String getLogText() {
|
||||
return this.logText;
|
||||
}
|
||||
|
||||
public void setLogText(String text) {
|
||||
this.logText = text;
|
||||
}
|
||||
|
||||
public String getCompleteText() {
|
||||
return this.completeText;
|
||||
}
|
||||
|
||||
public void setCompleteText(String text) {
|
||||
this.completeText = text;
|
||||
}
|
||||
|
||||
public void setNextQuest(IQuest quest) {
|
||||
if (quest == null) {
|
||||
this.nextQuestid = -1;
|
||||
this.nextQuestTitle = "";
|
||||
} else {
|
||||
if (quest.getId() < 0) {
|
||||
throw new CustomNPCsException("Quest id is lower than 0", new Object[0]);
|
||||
}
|
||||
|
||||
this.nextQuestid = quest.getId();
|
||||
this.nextQuestTitle = quest.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getNpcName() {
|
||||
return this.completerNpc;
|
||||
}
|
||||
|
||||
public void setNpcName(String name) {
|
||||
this.completerNpc = name;
|
||||
}
|
||||
|
||||
public IQuestObjective[] getObjectives(IPlayer player) {
|
||||
if (!player.hasActiveQuest(this.id)) {
|
||||
throw new CustomNPCsException("Player doesnt have this quest active.", new Object[0]);
|
||||
} else {
|
||||
return this.questInterface.getObjectives((EntityPlayer) player.getMCEntity());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getIsRepeatable() {
|
||||
return this.repeat != EnumQuestRepeat.NONE;
|
||||
}
|
||||
|
||||
public IContainer getRewards() {
|
||||
return NpcAPI.Instance().getIContainer(this.rewardItems);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,15 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.scripted.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.handler.data.IQuestCategory;
|
||||
|
||||
public class QuestCategory {
|
||||
public class QuestCategory implements IQuestCategory {
|
||||
public HashMap<Integer,Quest> quests;
|
||||
public int id = -1;
|
||||
public String title = "";
|
||||
@@ -43,4 +47,18 @@ public class QuestCategory {
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
public List<IQuest> quests() {
|
||||
return new ArrayList(this.quests.values());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public IQuest create() {
|
||||
Quest quest = new Quest();
|
||||
quest.category = this;
|
||||
return quest;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package noppes.npcs.controllers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -12,9 +10,12 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.scripted.handler.IQuestHandler;
|
||||
import noppes.npcs.scripted.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.handler.data.IQuestCategory;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
public class QuestController {
|
||||
public class QuestController implements IQuestHandler {
|
||||
public HashMap<Integer,QuestCategory> categories = new HashMap<Integer, QuestCategory>();
|
||||
public HashMap<Integer,Quest> quests = new HashMap<Integer, Quest>();
|
||||
|
||||
@@ -232,5 +233,12 @@ public class QuestController {
|
||||
private File getDir(){
|
||||
return new File(CustomNpcs.getWorldSaveDirectory(), "quests");
|
||||
}
|
||||
|
||||
|
||||
public List<IQuestCategory> categories() {
|
||||
return new ArrayList(this.categories.values());
|
||||
}
|
||||
|
||||
public IQuest get(int id) {
|
||||
return (IQuest)this.quests.get(id);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,24 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.scripted.handler.data.IRecipe;
|
||||
|
||||
public class RecipeCarpentry extends ShapedRecipes{
|
||||
public class RecipeCarpentry extends ShapedRecipes implements IRecipe {
|
||||
public int id = -1;
|
||||
public String name = "";
|
||||
public Availability availability = new Availability();
|
||||
@@ -222,4 +226,64 @@ public class RecipeCarpentry extends ShapedRecipes{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public ItemStack getResult() {
|
||||
return this.getRecipeOutput();
|
||||
}
|
||||
|
||||
public boolean isGlobal() {
|
||||
return this.isGlobal;
|
||||
}
|
||||
|
||||
public void setIsGlobal(boolean bo) {
|
||||
this.isGlobal = bo;
|
||||
}
|
||||
|
||||
public boolean getIgnoreNBT() {
|
||||
return this.ignoreNBT;
|
||||
}
|
||||
|
||||
public void setIgnoreNBT(boolean bo) {
|
||||
this.ignoreNBT = bo;
|
||||
}
|
||||
|
||||
public boolean getIgnoreDamage() {
|
||||
return this.ignoreDamage;
|
||||
}
|
||||
|
||||
public void setIgnoreDamage(boolean bo) {
|
||||
this.ignoreDamage = bo;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.recipeWidth;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.recipeHeight;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
RecipeController.instance.saveRecipe(this.writeNBT());
|
||||
} catch (IOException var2) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
RecipeController.instance.delete(this.id);
|
||||
}
|
||||
|
||||
public ItemStack[] getRecipe() {
|
||||
return this.recipeItems;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,7 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -16,8 +13,10 @@ import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.scripted.handler.IRecipeHandler;
|
||||
import noppes.npcs.scripted.handler.data.IRecipe;
|
||||
|
||||
public class RecipeController {
|
||||
public class RecipeController implements IRecipeHandler {
|
||||
private static Collection<RecipeCarpentry> prevRecipes;
|
||||
public HashMap<Integer,RecipeCarpentry> globalRecipes = new HashMap<Integer, RecipeCarpentry>();
|
||||
public HashMap<Integer,RecipeCarpentry> anvilRecipes = new HashMap<Integer, RecipeCarpentry>();
|
||||
@@ -198,7 +197,7 @@ public class RecipeController {
|
||||
return false;
|
||||
}
|
||||
|
||||
public RecipeCarpentry removeRecipe(int id) {
|
||||
public RecipeCarpentry delete(int id) {
|
||||
RecipeCarpentry recipe = getRecipe(id);
|
||||
globalRecipes.remove(recipe.id);
|
||||
anvilRecipes.remove(recipe.id);
|
||||
@@ -214,4 +213,46 @@ public class RecipeController {
|
||||
RecipeController.instance.globalRecipes.put(recipeAnvil.id, recipeAnvil);
|
||||
}
|
||||
}
|
||||
|
||||
public List<IRecipe> getGlobalList() {
|
||||
return new ArrayList(this.globalRecipes.values());
|
||||
}
|
||||
|
||||
public List<IRecipe> getCarpentryList() {
|
||||
return new ArrayList(this.anvilRecipes.values());
|
||||
}
|
||||
|
||||
public void addRecipe(String name, boolean global, ItemStack result, Object... objects) {
|
||||
RecipeCarpentry recipe = new RecipeCarpentry(name);
|
||||
recipe.isGlobal = global;
|
||||
recipe = RecipeCarpentry.saveRecipe(recipe, result, objects);
|
||||
|
||||
try {
|
||||
this.saveRecipe(recipe.writeNBT());
|
||||
} catch (Exception var7) {
|
||||
var7.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addRecipe(String name, boolean global, ItemStack result, int width, int height, ItemStack... objects) {
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
int var9 = objects.length;
|
||||
|
||||
for(int var10 = 0; var10 < var9; ++var10) {
|
||||
ItemStack item = objects[var10];
|
||||
if (item.stackSize > 0) {
|
||||
list.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
RecipeCarpentry recipe = new RecipeCarpentry(width, height, list.toArray(new ItemStack[0]), result);
|
||||
recipe.isGlobal = global;
|
||||
recipe.name = name;
|
||||
|
||||
try {
|
||||
this.saveRecipe(recipe.writeNBT());
|
||||
} catch (IOException var12) {
|
||||
var12.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import java.util.Map;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -20,11 +21,17 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.LinkedNpcController.LinkedData;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.handler.ICloneHandler;
|
||||
import noppes.npcs.scripted.interfaces.IEntity;
|
||||
import noppes.npcs.scripted.interfaces.IWorld;
|
||||
import noppes.npcs.util.JsonException;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
public class ServerCloneController {
|
||||
public class ServerCloneController implements ICloneHandler {
|
||||
public static ServerCloneController Instance;
|
||||
|
||||
public ServerCloneController(){
|
||||
@@ -193,4 +200,39 @@ public class ServerCloneController {
|
||||
nbttagcompound.setTag("TransformAI", adv);
|
||||
}
|
||||
}
|
||||
|
||||
public IEntity spawn(double x, double y, double z, int tab, String name, IWorld world) {
|
||||
NBTTagCompound compound = this.getCloneData((ICommandSender)null, name, tab);
|
||||
if (compound == null) {
|
||||
throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]);
|
||||
} else {
|
||||
Entity entity = NoppesUtilServer.spawnClone(compound, (int)x, (int)y, (int)z, world.getMCWorld());
|
||||
return entity == null ? null : NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public IEntity get(int tab, String name, IWorld world) {
|
||||
NBTTagCompound compound = this.getCloneData((ICommandSender)null, name, tab);
|
||||
if (compound == null) {
|
||||
throw new CustomNPCsException("Unknown clone tab:" + tab + " name:" + name, new Object[0]);
|
||||
} else {
|
||||
Instance.cleanTags(compound);
|
||||
Entity entity = EntityList.createEntityFromNBT(compound, world.getMCWorld());
|
||||
return entity == null ? null : NpcAPI.Instance().getIEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public void set(int tab, String name, IEntity entity) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if (!entity.getMCEntity().isEntityAlive()) {
|
||||
throw new CustomNPCsException("Cannot save dead entities", new Object[0]);
|
||||
} else {
|
||||
this.cleanTags(compound);
|
||||
this.saveClone(tab, name, compound);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(int tab, String name) {
|
||||
this.removeClone(name, tab);
|
||||
}
|
||||
}
|
||||
@@ -1422,10 +1422,10 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
return fac;
|
||||
}
|
||||
else{
|
||||
Faction fac = FactionController.getInstance().getFaction(faction);
|
||||
Faction fac = FactionController.getInstance().get(faction);
|
||||
if (fac == null) {
|
||||
faction = FactionController.getInstance().getFirstFactionId();
|
||||
fac = FactionController.getInstance().getFaction(faction);
|
||||
fac = FactionController.getInstance().get(faction);
|
||||
}
|
||||
return fac;
|
||||
}
|
||||
@@ -1436,7 +1436,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
public void setFaction(int integer) {
|
||||
if(integer < 0|| isRemote())
|
||||
return;
|
||||
Faction faction = FactionController.getInstance().getFaction(integer);
|
||||
Faction faction = FactionController.getInstance().get(integer);
|
||||
if(faction == null)
|
||||
return;
|
||||
String str = faction.id + ":" + faction.color + ":" + faction.name;
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package noppes.npcs.quests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.Dialog;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.handler.data.IQuestObjective;
|
||||
|
||||
public class QuestDialog extends QuestInterface{
|
||||
|
||||
@@ -55,4 +61,69 @@ public class QuestDialog extends QuestInterface{
|
||||
return vec;
|
||||
}
|
||||
|
||||
public IQuestObjective[] getObjectives(EntityPlayer player) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
|
||||
for(int i = 0; i < 3; ++i) {
|
||||
if (this.dialogs.containsKey(i)) {
|
||||
Dialog dialog = (Dialog)DialogController.instance.dialogs.get(this.dialogs.get(i));
|
||||
if (dialog != null) {
|
||||
list.add(new noppes.npcs.quests.QuestDialog.QuestDialogObjective(this, player, dialog));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
class QuestDialogObjective implements IQuestObjective {
|
||||
private final QuestDialog parent;
|
||||
private final EntityPlayer player;
|
||||
private final Dialog dialog;
|
||||
|
||||
public QuestDialogObjective(QuestDialog this$0, EntityPlayer player, Dialog dialog) {
|
||||
this.parent = this$0;
|
||||
this.player = player;
|
||||
this.dialog = dialog;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return this.isCompleted() ? 1 : 0;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
if (progress >= 0 && progress <= 1) {
|
||||
PlayerData data = PlayerData.get(this.player);
|
||||
boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
if (progress == 0 && completed) {
|
||||
data.dialogData.dialogsRead.remove(this.dialog.id);
|
||||
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[1]);
|
||||
data.saveNBTData(data.getNBT());
|
||||
}
|
||||
|
||||
if (progress == 1 && !completed) {
|
||||
data.dialogData.dialogsRead.add(this.dialog.id);
|
||||
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[1]);
|
||||
data.saveNBTData(data.getNBT());
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxProgress() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
PlayerData data = PlayerData.get(this.player);
|
||||
return data.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.dialog.title + (this.isCompleted() ? " (read)" : " (unread)");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.util.Vector;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.scripted.handler.data.IQuestObjective;
|
||||
|
||||
public abstract class QuestInterface {
|
||||
public int questId;
|
||||
@@ -12,4 +13,5 @@ public abstract class QuestInterface {
|
||||
public abstract boolean isCompleted(EntityPlayer player);
|
||||
public abstract void handleComplete(EntityPlayer player);
|
||||
public abstract Vector<String> getQuestLogStatus(EntityPlayer player);
|
||||
public abstract IQuestObjective[] getObjectives(EntityPlayer var1);
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
package noppes.npcs.quests;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.NpcMiscInventory;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.handler.data.IQuestObjective;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
public class QuestItem extends QuestInterface{
|
||||
public NpcMiscInventory items = new NpcMiscInventory(3);
|
||||
@@ -119,5 +122,59 @@ public class QuestItem extends QuestInterface{
|
||||
return vec;
|
||||
}
|
||||
|
||||
public IQuestObjective[] getObjectives(EntityPlayer player) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
List<ItemStack> questItems = NoppesUtilPlayer.countStacks(this.items, this.ignoreDamage, this.ignoreNBT);
|
||||
Iterator var4 = questItems.iterator();
|
||||
|
||||
while(var4.hasNext()) {
|
||||
ItemStack stack = (ItemStack)var4.next();
|
||||
if (stack.stackSize > 0) {
|
||||
list.add(new noppes.npcs.quests.QuestItem.QuestItemObjective(this, player, stack));
|
||||
}
|
||||
}
|
||||
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
class QuestItemObjective implements IQuestObjective {
|
||||
private final QuestItem parent;
|
||||
private final EntityPlayer player;
|
||||
private final ItemStack questItem;
|
||||
|
||||
public QuestItemObjective(QuestItem this$0, EntityPlayer player, ItemStack item) {
|
||||
this.parent = this$0;
|
||||
this.player = player;
|
||||
this.questItem = item;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
int count = 0;
|
||||
|
||||
for(int i = 0; i < this.player.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack item = this.player.inventory.getStackInSlot(i);
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
return ValueUtil.CorrectInt(count, 0, this.questItem.stackSize);
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
throw new CustomNPCsException("Cant set the progress of ItemQuests", new Object[0]);
|
||||
}
|
||||
|
||||
public int getMaxProgress() {
|
||||
return this.questItem.stackSize;
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
return NoppesUtilPlayer.compareItems(this.player, this.questItem, this.parent.ignoreDamage, this.parent.ignoreNBT);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.questItem.getDisplayName() + ": " + this.getProgress() + "/" + this.getMaxProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,20 @@
|
||||
package noppes.npcs.quests;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Vector;
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerQuestData;
|
||||
import noppes.npcs.controllers.QuestData;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.handler.data.IQuestObjective;
|
||||
|
||||
public class QuestKill extends QuestInterface{
|
||||
public HashMap<String,Integer> targets = new HashMap<String,Integer>();
|
||||
@@ -74,4 +78,67 @@ public class QuestKill extends QuestInterface{
|
||||
data.extraData.setTag("Killed", NBTTags.nbtStringIntegerMap(killed));
|
||||
}
|
||||
|
||||
public IQuestObjective[] getObjectives(EntityPlayer player) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
Iterator var3 = this.targets.entrySet().iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
Map.Entry<String, Integer> entry = (Map.Entry)var3.next();
|
||||
list.add(new noppes.npcs.quests.QuestKill.QuestKillObjective(this, player, (String)entry.getKey(), (Integer)entry.getValue()));
|
||||
}
|
||||
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
class QuestKillObjective implements IQuestObjective {
|
||||
private final QuestKill parent;
|
||||
private final EntityPlayer player;
|
||||
private final String entity;
|
||||
private final int amount;
|
||||
|
||||
public QuestKillObjective(QuestKill parent, EntityPlayer player, String entity, int amount) {
|
||||
this.parent = parent;
|
||||
this.player = player;
|
||||
this.entity = entity;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
PlayerData data = PlayerData.get(this.player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
return !killed.containsKey(this.entity) ? 0 : (Integer)killed.get(this.entity);
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
if (progress >= 0 && progress <= this.amount) {
|
||||
PlayerData data = PlayerData.get(this.player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
HashMap<String, Integer> killed = this.parent.getKilled(questdata);
|
||||
if (!killed.containsKey(this.entity) || (Integer)killed.get(this.entity) != progress) {
|
||||
killed.put(this.entity, progress);
|
||||
this.parent.setKilled(questdata, killed);
|
||||
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[2]);
|
||||
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[4]);
|
||||
data.saveNBTData(data.getNBT());
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Progress has to be between 0 and " + this.amount, new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxProgress() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
return this.getProgress() >= this.amount;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.entity + ": " + this.getProgress() + "/" + this.getMaxProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
package noppes.npcs.quests;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PlayerData;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerQuestData;
|
||||
import noppes.npcs.controllers.QuestData;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
import noppes.npcs.scripted.handler.data.IQuestObjective;
|
||||
|
||||
public class QuestLocation extends QuestInterface{
|
||||
public String location = "";
|
||||
@@ -95,4 +101,67 @@ public class QuestLocation extends QuestInterface{
|
||||
return false;
|
||||
}
|
||||
|
||||
public IQuestObjective[] getObjectives(EntityPlayer player) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
if (!this.location.isEmpty()) {
|
||||
list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, player, this.location, "LocationFound"));
|
||||
}
|
||||
|
||||
if (!this.location2.isEmpty()) {
|
||||
list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, player, this.location2, "Location2Found"));
|
||||
}
|
||||
|
||||
if (!this.location3.isEmpty()) {
|
||||
list.add(new noppes.npcs.quests.QuestLocation.QuestLocationObjective(this, player, this.location3, "Location3Found"));
|
||||
}
|
||||
|
||||
return (IQuestObjective[])list.toArray(new IQuestObjective[list.size()]);
|
||||
}
|
||||
|
||||
class QuestLocationObjective implements IQuestObjective {
|
||||
private final QuestLocation parent;
|
||||
private final EntityPlayer player;
|
||||
private final String location;
|
||||
private final String nbtName;
|
||||
|
||||
public QuestLocationObjective(QuestLocation this$0, EntityPlayer player, String location, String nbtName) {
|
||||
this.parent = this$0;
|
||||
this.player = player;
|
||||
this.location = location;
|
||||
this.nbtName = nbtName;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return this.isCompleted() ? 1 : 0;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
if (progress >= 0 && progress <= 1) {
|
||||
PlayerData data = PlayerData.get(this.player);
|
||||
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
|
||||
boolean completed = questData.extraData.getBoolean (this.nbtName);
|
||||
if ((!completed || progress != 1) && (completed || progress != 0)) {
|
||||
questData.extraData.setBoolean(this.nbtName, progress == 1);
|
||||
data.questData.checkQuestCompletion(this.player, EnumQuestType.values()[3]);
|
||||
data.saveNBTData(data.getNBT());
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMaxProgress() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
PlayerData data = PlayerData.get(this.player);
|
||||
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
|
||||
return questData.extraData.getBoolean(this.nbtName);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.location + ": " + (this.isCompleted() ? "Found" : "Not Found");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,15 +29,20 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptItemStack;
|
||||
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.ITimers;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T> implements IPlayer {
|
||||
public T player;
|
||||
private PlayerData data;
|
||||
|
||||
public ScriptPlayer(T player){
|
||||
super(player);
|
||||
this.player = player;
|
||||
@@ -388,6 +393,12 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return data.getGUIOpen();
|
||||
}
|
||||
|
||||
public void checkQuestCompleted() {
|
||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
for(EnumQuestType e : EnumQuestType.values())
|
||||
playerdata.checkQuestCompletion((EntityPlayer)this.entity, e);
|
||||
}
|
||||
|
||||
public ScriptDBCPlayer<T> getDBCPlayer() {
|
||||
Set keySet = player.getEntityData().getCompoundTag("PlayerPersisted").func_150296_c();
|
||||
Iterator iterator = keySet.iterator();
|
||||
@@ -404,4 +415,44 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
public boolean blocking() {
|
||||
return player.isBlocking();
|
||||
}
|
||||
|
||||
private PlayerData getData() {
|
||||
if (this.data == null) {
|
||||
this.data = PlayerDataController.instance.getPlayerData(player);
|
||||
}
|
||||
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public IQuest[] getActiveQuests() {
|
||||
PlayerQuestData data = this.getData().questData;
|
||||
List<IQuest> quests = new ArrayList();
|
||||
Iterator var3 = data.activeQuests.keySet().iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
int id = (Integer)var3.next();
|
||||
IQuest quest = (IQuest)QuestController.instance.quests.get(id);
|
||||
if (quest != null) {
|
||||
quests.add(quest);
|
||||
}
|
||||
}
|
||||
|
||||
return (IQuest[])quests.toArray(new IQuest[quests.size()]);
|
||||
}
|
||||
|
||||
public IQuest[] getFinishedQuests() {
|
||||
PlayerQuestData data = this.getData().questData;
|
||||
List<IQuest> quests = new ArrayList();
|
||||
Iterator var3 = data.finishedQuests.keySet().iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
int id = (Integer)var3.next();
|
||||
IQuest quest = (IQuest)QuestController.instance.quests.get(id);
|
||||
if (quest != null) {
|
||||
quests.add(quest);
|
||||
}
|
||||
}
|
||||
|
||||
return (IQuest[])quests.toArray(new IQuest[quests.size()]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.IWorld;
|
||||
import noppes.npcs.scripted.interfaces.IEntity;
|
||||
|
||||
public interface ICloneHandler {
|
||||
IEntity spawn(double var1, double var3, double var5, int var7, String var8, IWorld var9);
|
||||
|
||||
IEntity get(int var1, String var2, IWorld var3);
|
||||
|
||||
void set(int var1, String var2, IEntity var3);
|
||||
|
||||
void remove(int var1, String var2);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler;
|
||||
|
||||
import noppes.npcs.scripted.handler.data.IDialog;
|
||||
import noppes.npcs.scripted.handler.data.IDialogCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDialogHandler {
|
||||
List<IDialogCategory> categories();
|
||||
|
||||
IDialog get(int var1);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler;
|
||||
|
||||
import noppes.npcs.scripted.handler.data.IFaction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IFactionHandler {
|
||||
List<IFaction> list();
|
||||
|
||||
IFaction delete(int var1);
|
||||
|
||||
IFaction create(String var1, int var2);
|
||||
|
||||
IFaction get(int var1);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler;
|
||||
|
||||
import noppes.npcs.scripted.handler.data.IQuest;
|
||||
import noppes.npcs.scripted.handler.data.IQuestCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IQuestHandler {
|
||||
List<IQuestCategory> categories();
|
||||
|
||||
IQuest get(int var1);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.scripted.handler.data.IRecipe;
|
||||
|
||||
public interface IRecipeHandler {
|
||||
List<IRecipe> getGlobalList();
|
||||
|
||||
List<IRecipe> getCarpentryList();
|
||||
|
||||
void addRecipe(String var1, boolean var2, ItemStack var3, Object... var4);
|
||||
|
||||
void addRecipe(String var1, boolean var2, ItemStack var3, int var4, int var5, ItemStack... var6);
|
||||
|
||||
IRecipe delete(int var1);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
|
||||
public interface IAvailability {
|
||||
boolean isAvailable(IPlayer var1);
|
||||
|
||||
int getDaytime();
|
||||
|
||||
void setDaytime(int var1);
|
||||
|
||||
int getMinPlayerLevel();
|
||||
|
||||
void setMinPlayerLevel(int var1);
|
||||
|
||||
int getDialog(int var1);
|
||||
|
||||
void setDialog(int var1, int var2, int var3);
|
||||
|
||||
void removeDialog(int var1);
|
||||
|
||||
int getQuest(int var1);
|
||||
|
||||
void setQuest(int var1, int var2, int var3);
|
||||
|
||||
void removeQuest(int var1);
|
||||
|
||||
void setFaction(int var1, int var2, int var3, int var4);
|
||||
|
||||
void removeFaction(int var1);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDialog {
|
||||
int getId();
|
||||
|
||||
String getName();
|
||||
|
||||
void setName(String var1);
|
||||
|
||||
String getText();
|
||||
|
||||
void setText(String var1);
|
||||
|
||||
IQuest getQuest();
|
||||
|
||||
void setQuest(IQuest var1);
|
||||
|
||||
String getCommand();
|
||||
|
||||
void setCommand(String var1);
|
||||
|
||||
List<IDialogOption> getOptions();
|
||||
|
||||
IDialogOption getOption(int var1);
|
||||
|
||||
IAvailability getAvailability();
|
||||
|
||||
IDialogCategory getCategory();
|
||||
|
||||
void save();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDialogCategory {
|
||||
List<IDialog> dialogs();
|
||||
|
||||
String getName();
|
||||
|
||||
IDialog create();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
public interface IDialogOption {
|
||||
int getSlot();
|
||||
|
||||
String getName();
|
||||
|
||||
int getType();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
|
||||
public interface IFaction {
|
||||
int getId();
|
||||
|
||||
String getName();
|
||||
|
||||
int getDefaultPoints();
|
||||
|
||||
void setDefaultPoints(int var1);
|
||||
|
||||
int getColor();
|
||||
|
||||
int playerStatus(IPlayer var1);
|
||||
|
||||
boolean hostileToNpc(ICustomNpc var1);
|
||||
|
||||
boolean hostileToFaction(int var1);
|
||||
|
||||
int[] getHostileList();
|
||||
|
||||
void addHostile(int var1);
|
||||
|
||||
void removeHostile(int var1);
|
||||
|
||||
boolean hasHostile(int var1);
|
||||
|
||||
boolean getIsHidden();
|
||||
|
||||
void setIsHidden(boolean var1);
|
||||
|
||||
boolean getAttackedByMobs();
|
||||
|
||||
void setAttackedByMobs(boolean var1);
|
||||
|
||||
void save();
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
import noppes.npcs.scripted.interfaces.IContainer;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
|
||||
public interface IQuest {
|
||||
int getId();
|
||||
|
||||
String getName();
|
||||
|
||||
void setName(String var1);
|
||||
|
||||
int getType();
|
||||
|
||||
void setType(int var1);
|
||||
|
||||
String getLogText();
|
||||
|
||||
void setLogText(String var1);
|
||||
|
||||
String getCompleteText();
|
||||
|
||||
void setCompleteText(String var1);
|
||||
|
||||
IQuest getNextQuest();
|
||||
|
||||
void setNextQuest(IQuest var1);
|
||||
|
||||
IQuestObjective[] getObjectives(IPlayer var1);
|
||||
|
||||
IQuestCategory getCategory();
|
||||
|
||||
IContainer getRewards();
|
||||
|
||||
String getNpcName();
|
||||
|
||||
void setNpcName(String var1);
|
||||
|
||||
void save();
|
||||
|
||||
boolean getIsRepeatable();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IQuestCategory {
|
||||
List<IQuest> quests();
|
||||
|
||||
String getName();
|
||||
|
||||
IQuest create();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
public interface IQuestObjective {
|
||||
int getProgress();
|
||||
|
||||
void setProgress(int var1);
|
||||
|
||||
int getMaxProgress();
|
||||
|
||||
boolean isCompleted();
|
||||
|
||||
String getText();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.handler.data;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IRecipe {
|
||||
String getName();
|
||||
|
||||
boolean isGlobal();
|
||||
|
||||
void setIsGlobal(boolean var1);
|
||||
|
||||
boolean getIgnoreNBT();
|
||||
|
||||
void setIgnoreNBT(boolean var1);
|
||||
|
||||
boolean getIgnoreDamage();
|
||||
|
||||
void setIgnoreDamage(boolean var1);
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
|
||||
ItemStack getResult();
|
||||
|
||||
ItemStack[] getRecipe();
|
||||
|
||||
void delete();
|
||||
|
||||
int getId();
|
||||
}
|
||||
@@ -35,16 +35,18 @@ import net.minecraftforge.common.util.FakePlayer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.client.EntityUtil;
|
||||
import noppes.npcs.controllers.PixelmonHelper;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.ScriptEntityData;
|
||||
import noppes.npcs.controllers.*;
|
||||
import noppes.npcs.scripted.*;
|
||||
import noppes.npcs.containers.ContainerNpcInterface;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.ScriptContainer;
|
||||
import noppes.npcs.scripted.entity.*;
|
||||
import noppes.npcs.scripted.handler.*;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.util.JsonException;
|
||||
import noppes.npcs.util.LRUHashMap;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
public class WrapperNpcAPI extends NpcAPI {
|
||||
private static final Map<Integer, ScriptWorld> worldCache = new LRUHashMap(10);
|
||||
@@ -58,6 +60,29 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
worldCache.clear();
|
||||
}
|
||||
|
||||
public IFactionHandler getFactions() {
|
||||
this.checkWorld();
|
||||
return FactionController.getInstance();
|
||||
}
|
||||
|
||||
public IRecipeHandler getRecipes() {
|
||||
this.checkWorld();
|
||||
return RecipeController.instance;
|
||||
}
|
||||
|
||||
public IQuestHandler getQuests() {
|
||||
this.checkWorld();
|
||||
return QuestController.instance;
|
||||
}
|
||||
|
||||
public IDialogHandler getDialogs() {
|
||||
return DialogController.instance;
|
||||
}
|
||||
|
||||
public ICloneHandler getClones() {
|
||||
return ServerCloneController.Instance;
|
||||
}
|
||||
|
||||
public IEntity getIEntity(Entity entity) {
|
||||
if(entity == null)
|
||||
return null;
|
||||
@@ -98,6 +123,18 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
return compound == null?new ScriptNbt(new NBTTagCompound()):new ScriptNbt(compound);
|
||||
}
|
||||
|
||||
public INbt stringToNbt(String str) {
|
||||
if (str != null && !str.isEmpty()) {
|
||||
try {
|
||||
return this.getINbt(NBTJsonUtil.Convert(str));
|
||||
} catch (JsonException var3) {
|
||||
throw new CustomNPCsException(var3, "Failed converting " + str, new Object[0]);
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Cant cast empty string to nbt", new Object[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public ICustomNpc createNPC(World world) {
|
||||
if (world.isRemote) {
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user