mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 06:29:41 +00:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
b4f733f637
66 files changed
+1836
-481
No files matched your search
@@ -51,6 +51,7 @@ public class CmdDialog extends ChMcLogger {
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.add(diagid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -77,6 +78,7 @@ public class CmdDialog extends ChMcLogger {
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -85,7 +87,7 @@ public class CmdDialog extends ChMcLogger {
|
||||
permissions={OpOnly.class}
|
||||
)
|
||||
public boolean reload(String args[]){
|
||||
new DialogController();
|
||||
new DialogController().load();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ public class CmdFaction extends ChMcLogger {
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -65,6 +66,7 @@ public class CmdFaction extends ChMcLogger {
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -77,6 +79,7 @@ public class CmdFaction extends ChMcLogger {
|
||||
public Boolean reset(String[] args) {
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -97,6 +100,7 @@ public class CmdFaction extends ChMcLogger {
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.factionData.put(this.selectedFaction.id,points);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -109,6 +113,7 @@ public class CmdFaction extends ChMcLogger {
|
||||
public Boolean drop(String[] args){
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public class CmdQuest extends ChMcLogger{
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
}
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -94,6 +95,7 @@ public class CmdQuest extends ChMcLogger{
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.finishedQuests.put(questid, System.currentTimeMillis());
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -125,6 +127,7 @@ public class CmdQuest extends ChMcLogger{
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -157,6 +160,7 @@ public class CmdQuest extends ChMcLogger{
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.questData.finishedQuests.remove(questid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -165,7 +169,7 @@ public class CmdQuest extends ChMcLogger{
|
||||
permissions={OpOnly.class}
|
||||
)
|
||||
public boolean reload(String args[]){
|
||||
new DialogController();
|
||||
new QuestController().load();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ public class DialogCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Read Dialog Cat \u00A7c'%s' \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", dialogCategory.getName(), dialogCatId, playerdata.playername));
|
||||
sendResult(sender, String.format("Read a total of \u00A7b%d \u00A77dialogs", count));
|
||||
}
|
||||
@@ -124,6 +125,7 @@ public class DialogCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Unread Dialog Cat \u00A7c'%s' \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", dialogCategory.getName(), dialogCatId, playerdata.playername));
|
||||
sendResult(sender, String.format("Unread a total of \u00A7b%d \u00A77dialogs", count));
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.client.EntityUtil;
|
||||
import noppes.npcs.constants.EnumAvailabilityDialog;
|
||||
import noppes.npcs.constants.EnumAvailabilityQuest;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.SyncController;
|
||||
import noppes.npcs.controllers.data.Availability;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.DialogOption;
|
||||
@@ -52,6 +54,7 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.add(diagid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Forced Read for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -77,6 +80,7 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.dialogData.dialogsRead.remove(diagid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Forced Unread for Dialog \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", diagid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -85,7 +89,8 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
permission = 4
|
||||
)
|
||||
public void reload(ICommandSender sender, String args[]){
|
||||
new DialogController();
|
||||
new DialogController().load();
|
||||
SyncController.syncAllDialogs();
|
||||
sendResult(sender, "Dialogs Reloaded");
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +86,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, points, playerdata.player);
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Added Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -105,6 +107,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.increasePoints(factionid, -points, playerdata.player);
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Subtracted Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -113,6 +116,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
public void reset(ICommandSender sender, String[] args) {
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.factionData.factionData.put(this.selectedFaction.id, this.selectedFaction.defaultPoints);
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Reset Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -132,6 +136,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
for(PlayerData playerdata : data){
|
||||
PlayerFactionData playerfactiondata = playerdata.factionData;
|
||||
playerfactiondata.factionData.put(this.selectedFaction.id, points);
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Set Points \u00A7a%d\u00A77, Faction \u00A7e%s (%d)\u00A77 for Player \u00A7b%s\u00A77", points, this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -140,6 +145,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
public void drop(ICommandSender sender, String[] args){
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.factionData.factionData.remove(this.selectedFaction.id);
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Dropped Faction \u00A7e%s (%d)\u00A77 from Player \u00A7b%s\u00A77", this.selectedFaction.getName(), this.selectedFaction.id, playerdata.playername));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Completed Quest Cat \u00A7c'%s' \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questCategory.getName(), questcatid, playerdata.playername));
|
||||
sendResult(sender, String.format("Completed a total of \u00A7b%d \u00A77quests", count));
|
||||
}
|
||||
@@ -142,6 +143,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Stopped Quest Cat \u00A7c'%s' \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questCategory.getName(), questcatid, playerdata.playername));
|
||||
sendResult(sender, String.format("Stopped a total of \u00A7b%d \u00A77quests", count));
|
||||
}
|
||||
@@ -190,6 +192,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Started Quest Cat \u00A7c'%s' \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questCategory.getName(), questcatid, playerdata.playername));
|
||||
sendResult(sender, String.format("Started a total of \u00A7b%d \u00A77quests", count));
|
||||
}
|
||||
@@ -232,6 +235,7 @@ public class QuestCategoryCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Cleared Quest Cat \u00A7c'%s' \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questCategory.getName(), questcatid, playerdata.playername));
|
||||
sendResult(sender, String.format("Cleared a total of \u00A7b%d \u00A77quests", count));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import noppes.npcs.constants.EnumQuestCompletion;
|
||||
import noppes.npcs.constants.EnumQuestRepeat;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.SyncController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.controllers.data.QuestData;
|
||||
@@ -63,6 +64,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
}
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Started Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -108,6 +110,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.MESSAGE, "quest.completed", quest.title);
|
||||
Server.sendData((EntityPlayerMP)playerdata.player, EnumPacketClient.CHAT, "quest.completed", ": ", quest.title);
|
||||
}
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Finished Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -138,6 +141,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
for(PlayerData playerdata : data){
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Stopped Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -172,6 +176,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
playerdata.questData.activeQuests.remove(questid);
|
||||
playerdata.questData.finishedQuests.remove(questid);
|
||||
playerdata.save();
|
||||
playerdata.updateClient = true;
|
||||
sendResult(sender, String.format("Removed Quest \u00A7e%d\u00A77 for Player '\u00A7b%s\u00A77'", questid, playerdata.playername));
|
||||
}
|
||||
}
|
||||
@@ -284,8 +289,8 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
permission = 4
|
||||
)
|
||||
public void reload(ICommandSender sender, String args[]){
|
||||
new QuestController();
|
||||
QuestController.Instance.load();
|
||||
new QuestController().load();
|
||||
SyncController.syncAllQuests();
|
||||
sendResult(sender, "Quests Reloaded");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ public class CustomNpcs {
|
||||
|
||||
public static LegacyConfig legacyConfig;
|
||||
|
||||
public static MinecraftServer Server;
|
||||
|
||||
public CustomNpcs() {
|
||||
instance = this;
|
||||
}
|
||||
@@ -192,10 +194,11 @@ public class CustomNpcs {
|
||||
|
||||
@EventHandler
|
||||
public void setAboutToStart(FMLServerAboutToStartEvent event) {
|
||||
Server = event.getServer();
|
||||
ChunkController.Instance.clear();
|
||||
new QuestController();
|
||||
FactionController.getInstance().load();
|
||||
// VisibilityController.instance = new VisibilityController();
|
||||
new PlayerDataController();
|
||||
new FactionController();
|
||||
new TagController();
|
||||
new TransportController();
|
||||
new GlobalDataController();
|
||||
@@ -229,8 +232,8 @@ public class CustomNpcs {
|
||||
@EventHandler
|
||||
public void started(FMLServerStartedEvent event) {
|
||||
RecipeController.Instance.load();
|
||||
new DialogController();
|
||||
new BankController();
|
||||
DialogController.Instance.load();
|
||||
QuestController.Instance.load();
|
||||
ScriptController.HasStart = true;
|
||||
ServerCloneController.Instance = new ServerCloneController();
|
||||
|
||||
@@ -72,6 +72,7 @@ public class CustomNpcsPermissions{
|
||||
public static final Permission SOULSTONE_ALL = new Permission("customnpcs.soulstone.all");
|
||||
|
||||
// Modify / Save Scripts
|
||||
public static final Permission SCRIPT = new Permission("customnpcs.script");
|
||||
public static final Permission SCRIPT_NPC = new Permission("customnpcs.script.npc");
|
||||
public static final Permission SCRIPT_FORGE = new Permission("customnpcs.script.forge");
|
||||
public static final Permission SCRIPT_PLAYER = new Permission("customnpcs.script.player");
|
||||
|
||||
@@ -12,6 +12,7 @@ import noppes.npcs.controllers.data.Line;
|
||||
import noppes.npcs.controllers.data.Lines;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.*;
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -24,7 +25,7 @@ public class DataAdvanced {
|
||||
public Lines attackLines = new Lines();
|
||||
public Lines killedLines = new Lines();
|
||||
public Lines killLines = new Lines();
|
||||
|
||||
|
||||
public boolean orderedLines = false;
|
||||
|
||||
public String idleSound = "";
|
||||
@@ -43,7 +44,7 @@ public class DataAdvanced {
|
||||
public boolean attackOtherFactions = false;
|
||||
public boolean defendFaction = false;
|
||||
public boolean disablePitch = false;
|
||||
|
||||
|
||||
public String soulStonePlayerName = "";
|
||||
public boolean refuseSoulStone = false;
|
||||
public boolean soulStoneInit = false;
|
||||
@@ -78,7 +79,7 @@ public class DataAdvanced {
|
||||
compound.setTag("FactionPoints", factions.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
compound.setTag("NPCDialogOptions", nbtDialogs(npc.dialogs));
|
||||
|
||||
|
||||
compound.setBoolean("RefuseSoulStone", refuseSoulStone);
|
||||
compound.setString("SoulStonePlayerName", soulStonePlayerName);
|
||||
compound.setInteger("MinFactionPointsToSoulStone", minFactionPointsToSoulStone);
|
||||
@@ -90,7 +91,7 @@ public class DataAdvanced {
|
||||
}
|
||||
compound.setTag("TagUUIDs", nbtTagList);
|
||||
}
|
||||
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -120,8 +121,8 @@ public class DataAdvanced {
|
||||
|
||||
factions.readFromNBT(compound.getCompoundTag("FactionPoints"));
|
||||
|
||||
npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10));
|
||||
|
||||
npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10));
|
||||
|
||||
refuseSoulStone = compound.getBoolean("RefuseSoulStone");
|
||||
soulStonePlayerName = compound.getString("SoulStonePlayerName");
|
||||
minFactionPointsToSoulStone = compound.getInteger("MinFactionPointsToSoulStone");
|
||||
@@ -204,40 +205,23 @@ public class DataAdvanced {
|
||||
public void setJob(int i) {
|
||||
if(npc.jobInterface != null && !npc.worldObj.isRemote)
|
||||
npc.jobInterface.reset();
|
||||
|
||||
|
||||
job = EnumJobType.values()[i % EnumJobType.values().length];
|
||||
if (job == EnumJobType.None)
|
||||
npc.jobInterface = null;
|
||||
else if (job == EnumJobType.Bard && !(npc.jobInterface instanceof JobBard))
|
||||
else if (job == EnumJobType.Bard && !(npc.jobInterface instanceof JobBard))
|
||||
npc.jobInterface = new JobBard(npc);
|
||||
else if (job == EnumJobType.Healer && !(npc.jobInterface instanceof JobHealer))
|
||||
else if (job == EnumJobType.Healer && !(npc.jobInterface instanceof JobHealer))
|
||||
npc.jobInterface = new JobHealer(npc);
|
||||
else if (job == EnumJobType.Guard && !(npc.jobInterface instanceof JobGuard))
|
||||
else if (job == EnumJobType.Guard && !(npc.jobInterface instanceof JobGuard))
|
||||
npc.jobInterface = new JobGuard(npc);
|
||||
else if (job == EnumJobType.ItemGiver && !(npc.jobInterface instanceof JobItemGiver)) {
|
||||
if (!npc.isRemote()) {
|
||||
if (npc.itemGiverId > 0 && GlobalDataController.Instance.itemGivers.containsKey(npc.itemGiverId)) {
|
||||
GlobalDataController.Instance.itemGivers.get(npc.itemGiverId).npc = npc;
|
||||
npc.jobInterface = GlobalDataController.Instance.itemGivers.get(npc.itemGiverId);
|
||||
} else {
|
||||
npc.jobInterface = new JobItemGiver(npc);
|
||||
if (npc.itemGiverId == -1) {
|
||||
((JobItemGiver) npc.jobInterface).itemGiverId = GlobalDataController.Instance.incrementItemGiverId();
|
||||
} else {
|
||||
((JobItemGiver) npc.jobInterface).itemGiverId = npc.itemGiverId;
|
||||
}
|
||||
GlobalDataController.Instance.itemGivers.put(((JobItemGiver) npc.jobInterface).itemGiverId, (JobItemGiver) npc.jobInterface);
|
||||
npc.itemGiverId = ((JobItemGiver) npc.jobInterface).itemGiverId;
|
||||
}
|
||||
} else {
|
||||
npc.jobInterface = new JobItemGiver(npc);
|
||||
}
|
||||
}
|
||||
else if (job == EnumJobType.Follower && !(npc.jobInterface instanceof JobFollower))
|
||||
else if (job == EnumJobType.ItemGiver && !(npc.jobInterface instanceof JobItemGiver))
|
||||
npc.jobInterface = new JobItemGiver(npc);
|
||||
else if (job == EnumJobType.Follower && !(npc.jobInterface instanceof JobFollower))
|
||||
npc.jobInterface = new JobFollower(npc);
|
||||
else if (job == EnumJobType.Spawner && !(npc.jobInterface instanceof JobSpawner))
|
||||
else if (job == EnumJobType.Spawner && !(npc.jobInterface instanceof JobSpawner))
|
||||
npc.jobInterface = new JobSpawner(npc);
|
||||
else if (job == EnumJobType.Conversation && !(npc.jobInterface instanceof JobConversation))
|
||||
else if (job == EnumJobType.Conversation && !(npc.jobInterface instanceof JobConversation))
|
||||
npc.jobInterface = new JobConversation(npc);
|
||||
else if (job == EnumJobType.ChunkLoader && !(npc.jobInterface instanceof JobChunkLoader))
|
||||
npc.jobInterface = new JobChunkLoader(npc);
|
||||
|
||||
@@ -23,6 +23,7 @@ import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.entity.IProjectile;
|
||||
import noppes.npcs.api.event.IPartyEvent;
|
||||
import noppes.npcs.api.gui.ICustomGui;
|
||||
import noppes.npcs.api.gui.IItemSlot;
|
||||
import noppes.npcs.api.item.IItemCustom;
|
||||
@@ -765,4 +766,47 @@ public class EventHooks {
|
||||
handler.callScript(EnumScriptType.TIMER, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPartyFinished(Party party, Quest quest){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
PartyEvent.PartyQuestCompletedEvent event = new PartyEvent.PartyQuestCompletedEvent(party, quest);
|
||||
handler.callScript(EnumScriptType.PARTY_QUEST_COMPLETED, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPartyQuestSet(PartyEvent.PartyQuestSetEvent event){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
handler.callScript(EnumScriptType.PARTY_QUEST_SET, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPartyTurnIn(PartyEvent.PartyQuestTurnedInEvent event){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
handler.callScript(EnumScriptType.PARTY_QUEST_TURNED_IN, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPartyInvite(PartyEvent.PartyInviteEvent event){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
handler.callScript(EnumScriptType.PARTY_INVITE, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPartyKick(PartyEvent.PartyKickEvent event){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
handler.callScript(EnumScriptType.PARTY_KICK, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPartyLeave(PartyEvent.PartyLeaveEvent event){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
handler.callScript(EnumScriptType.PARTY_LEAVE, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
|
||||
public static void onPartyDisband(PartyEvent.PartyDisbandEvent event){
|
||||
PlayerDataScript handler = ScriptController.Instance.playerScripts;
|
||||
handler.callScript(EnumScriptType.PARTY_DISBAND, event);
|
||||
NpcAPI.EVENT_BUS.post(event);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import noppes.npcs.roles.RoleFollower;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.ScriptSound;
|
||||
import noppes.npcs.scripted.event.DialogEvent;
|
||||
import noppes.npcs.scripted.event.PartyEvent;
|
||||
import noppes.npcs.scripted.event.QuestEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -468,6 +469,14 @@ public class NoppesUtilPlayer {
|
||||
if(quest == null)
|
||||
return false;
|
||||
|
||||
if (data.quest.completion == EnumQuestCompletion.Instant)
|
||||
EventHooks.onPartyFinished(party, data.quest);
|
||||
|
||||
PartyEvent.PartyQuestTurnedInEvent partyEv = new PartyEvent.PartyQuestTurnedInEvent(party, data.quest);
|
||||
EventHooks.onPartyTurnIn(partyEv);
|
||||
if (partyEv.isCancelled())
|
||||
return false;
|
||||
|
||||
PartyOptions partyOptions = quest.partyOptions;
|
||||
EnumPartyExchange complete = partyOptions.completeFor;
|
||||
EnumPartyExchange reward = partyOptions.rewardControl;
|
||||
@@ -481,7 +490,6 @@ public class NoppesUtilPlayer {
|
||||
if(playerData == null)
|
||||
continue;
|
||||
|
||||
|
||||
boolean isLeader = party.getLeaderUUID().equals(player.getUniqueID());
|
||||
boolean hasActiveQuest = playerData.questData.hasActiveQuest(quest.getId());
|
||||
boolean hasFinishedQuest = playerData.questData.hasFinishedQuest(quest.getId());
|
||||
@@ -521,7 +529,7 @@ public class NoppesUtilPlayer {
|
||||
|
||||
EventHooks.onQuestTurnedIn(event);
|
||||
if (event.isCancelled())
|
||||
return false;
|
||||
continue;
|
||||
|
||||
IItemStack[] var12 = event.itemRewards;
|
||||
int var14 = var12.length;
|
||||
@@ -566,12 +574,17 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
|
||||
playerData.save();
|
||||
|
||||
if(meetsComplete){
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
if(data.quest.completion == EnumQuestCompletion.Npc){
|
||||
party.setQuest(null);
|
||||
PartyController.Instance().sendQuestChat(party, "party.completeChat");
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,7 @@ public class NoppesUtilServer {
|
||||
|
||||
public static void openDialog(EntityPlayer player, EntityNPCInterface npc, Dialog dia, int optionId){
|
||||
Dialog dialog = dia.copy(player);
|
||||
PlayerData playerdata = PlayerData.get(player);
|
||||
|
||||
if (!npc.isRemote()) {
|
||||
if (EventHooks.onNPCDialog(npc, player, dialog.id, optionId, dialog)) {
|
||||
@@ -197,8 +198,10 @@ public class NoppesUtilServer {
|
||||
if(dialog.mail.isValid())
|
||||
PlayerDataController.Instance.addPlayerMessage(player.getCommandSenderName(), dialog.mail);
|
||||
PlayerDialogData data = PlayerDataController.Instance.getPlayerData(player).dialogData;
|
||||
if(!data.dialogsRead.contains(dialog.id))
|
||||
data.dialogsRead.add(dialog.id);
|
||||
if(!data.dialogsRead.contains(dialog.id) && dialog.id >= 0){
|
||||
data.dialogsRead.add(dialog.id);
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
setEditingNpc(player, npc);
|
||||
}
|
||||
public static void runCommand(EntityPlayer player, String name, String command){
|
||||
@@ -550,6 +553,9 @@ public class NoppesUtilServer {
|
||||
data.factionData.remove(buffer.readInt());
|
||||
playerdata.save();
|
||||
}
|
||||
if(pl != null) {
|
||||
SyncController.syncPlayer((EntityPlayerMP) pl);
|
||||
}
|
||||
sendPlayerData(type, player, name);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.roles.RoleTrader;
|
||||
import noppes.npcs.roles.RoleTransporter;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.event.PartyEvent;
|
||||
import noppes.npcs.scripted.event.QuestEvent;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||
|
||||
@@ -124,26 +126,46 @@ public class PacketHandlerServer{
|
||||
if (playerData.partyUUID != null) {
|
||||
PartyController.Instance().disbandParty(playerData.partyUUID);
|
||||
}
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("Disband", true);
|
||||
Server.sendData(player, EnumPacketClient.PARTY_DATA, compound);
|
||||
} else if (type == EnumPacketServer.KickPlayer) {
|
||||
EntityPlayer kickPlayer = NoppesUtilServer.getPlayerByName(Server.readString(buffer));
|
||||
String kickPlayerName = Server.readString(buffer);
|
||||
EntityPlayer kickPlayer = NoppesUtilServer.getPlayerByName(kickPlayerName);
|
||||
PlayerData playerData = null;
|
||||
UUID playerUUID = null;
|
||||
if (kickPlayer != null) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
} else {
|
||||
String uuid = PlayerDataController.Instance.getPlayerUUIDFromName(kickPlayerName);
|
||||
if(!uuid.isEmpty()){
|
||||
playerData = PlayerDataController.Instance.getPlayerDataCache(uuid);
|
||||
playerUUID = UUID.fromString(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
if(playerData != null){
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
if (!party.getIsLocked()) {
|
||||
boolean successful = party.removePlayer(kickPlayer);
|
||||
if(successful){
|
||||
sendInviteData((EntityPlayerMP) kickPlayer);
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
PartyController.Instance().sendKickMessages(party, kickPlayer);
|
||||
PartyEvent.PartyKickEvent partyEvent = new PartyEvent.PartyKickEvent(party, party.getQuest(), (IPlayer) NpcAPI.Instance().getIEntity(kickPlayer));
|
||||
EventHooks.onPartyKick(partyEvent);
|
||||
if (!partyEvent.isCancelled()){
|
||||
boolean successful = party.removePlayer(kickPlayer);
|
||||
if(!successful)
|
||||
successful = party.removePlayer(playerUUID);
|
||||
|
||||
if(successful){
|
||||
if(kickPlayer != null){
|
||||
sendInviteData((EntityPlayerMP) kickPlayer);
|
||||
}
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
PartyController.Instance().sendKickMessages(party, kickPlayer, kickPlayerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (type == EnumPacketServer.LeavePlayer) {
|
||||
EntityPlayer leavingPlayer = NoppesUtilServer.getPlayerByName(Server.readString(buffer));
|
||||
if (leavingPlayer != null) {
|
||||
@@ -152,6 +174,8 @@ public class PacketHandlerServer{
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
boolean successful = party.removePlayer(leavingPlayer);
|
||||
if(successful){
|
||||
PartyEvent.PartyLeaveEvent partyEvent = new PartyEvent.PartyLeaveEvent(party, party.getQuest(), (IPlayer) NpcAPI.Instance().getIEntity(leavingPlayer));
|
||||
EventHooks.onPartyLeave(partyEvent);
|
||||
sendInviteData((EntityPlayerMP) leavingPlayer);
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
PartyController.Instance().sendLeavingMessages(party, leavingPlayer);
|
||||
@@ -181,8 +205,12 @@ public class PacketHandlerServer{
|
||||
if (senderData.partyUUID != null && invitedData.partyUUID == null) {//only send invite if player is not in a party
|
||||
Party party = PartyController.Instance().getParty(senderData.partyUUID);
|
||||
if (!party.getIsLocked()) {
|
||||
invitedData.inviteToParty(party);
|
||||
sendInviteData((EntityPlayerMP) invitedPlayer);
|
||||
PartyEvent.PartyInviteEvent partyEvent = new PartyEvent.PartyInviteEvent(party, party.getQuest(), (IPlayer) NpcAPI.Instance().getIEntity(invitedPlayer));
|
||||
EventHooks.onPartyInvite(partyEvent);
|
||||
if (!partyEvent.isCancelled()){
|
||||
invitedData.inviteToParty(party);
|
||||
sendInviteData((EntityPlayerMP) invitedPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,27 +235,30 @@ public class PacketHandlerServer{
|
||||
if(playerData.partyUUID != null){
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
if (party != null) {
|
||||
if (party.getPartyLeader() != player) {
|
||||
return;
|
||||
}
|
||||
|
||||
int questID = buffer.readInt();
|
||||
party.setQuest(null);
|
||||
if(questID != -1){
|
||||
Quest foundQuest = QuestController.Instance.quests.get(questID);
|
||||
if(foundQuest != null){
|
||||
if (foundQuest.partyOptions.allowParty) {
|
||||
if(party.validateQuest(questID)){
|
||||
if(playerData.questData.hasActiveQuest(questID)){
|
||||
QuestData questdata = new QuestData(foundQuest);
|
||||
playerData.questData.activeQuests.put(questID, questdata);
|
||||
if (party.getLeaderUUID().equals(player.getUniqueID())) {
|
||||
int questID = buffer.readInt();
|
||||
party.setQuest(null);
|
||||
if(questID != -1){
|
||||
Quest foundQuest = QuestController.Instance.quests.get(questID);
|
||||
if(foundQuest != null){
|
||||
if (foundQuest.partyOptions.allowParty) {
|
||||
if(party.validateQuest(questID, true)){
|
||||
PartyEvent.PartyQuestSetEvent partyEvent = new PartyEvent.PartyQuestSetEvent(party, foundQuest);
|
||||
EventHooks.onPartyQuestSet(partyEvent);
|
||||
if (!partyEvent.isCancelled()){
|
||||
if(playerData.questData.hasActiveQuest(questID)){
|
||||
QuestData questdata = new QuestData(foundQuest);
|
||||
playerData.questData.activeQuests.put(questID, questdata);
|
||||
}
|
||||
party.setQuest(foundQuest);
|
||||
PartyController.Instance().sendQuestChat(party, "party.setChat", " ", foundQuest.title);
|
||||
}
|
||||
}
|
||||
party.setQuest(foundQuest);
|
||||
}
|
||||
}
|
||||
}
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
}
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,7 +285,7 @@ public class PacketHandlerServer{
|
||||
featherPackets(type, buffer, player);
|
||||
else if (item.getItem() == Item.getItemFromBlock(CustomItems.waypoint) || item.getItem() == Item.getItemFromBlock(CustomItems.border) || item.getItem() == Item.getItemFromBlock(CustomItems.redstoneBlock))
|
||||
blockPackets(type, buffer, player);
|
||||
else if (ConfigScript.isScriptDev(player)) {
|
||||
else if (ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT)) {
|
||||
if (type == EnumPacketServer.EventScriptDataGet || type == EnumPacketServer.EventScriptDataSave)
|
||||
npcEventScriptPackets(type, buffer, player, npc);
|
||||
else if (type == EnumPacketServer.ScriptPlayerGet || type == EnumPacketServer.ScriptPlayerSave)
|
||||
|
||||
@@ -22,6 +22,7 @@ public class QuestLogData {
|
||||
public HashMap<String,Vector<String>> questStatus = new HashMap<>();
|
||||
public HashMap<String,String> finish = new HashMap<>();
|
||||
public HashMap<String, Integer> partyQuests = new HashMap<>();
|
||||
public HashMap<String,Vector<String>> partyOptions = new HashMap<>();
|
||||
|
||||
public NBTTagCompound writeNBT(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
@@ -32,6 +33,7 @@ public class QuestLogData {
|
||||
compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish));
|
||||
compound.setString("TrackedQuestID", trackedQuestKey);
|
||||
compound.setTag("PartyQuests", NBTTags.nbtStringIntegerMap(partyQuests));
|
||||
compound.setTag("PartyOptions", NBTTags.nbtVectorMap(partyOptions));
|
||||
return compound;
|
||||
}
|
||||
|
||||
@@ -43,6 +45,7 @@ public class QuestLogData {
|
||||
finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10));
|
||||
trackedQuestKey = compound.getString("TrackedQuestID");
|
||||
partyQuests = NBTTags.getStringIntegerMap(compound.getTagList("PartyQuests", 10));
|
||||
partyOptions = NBTTags.getVectorMap(compound.getTagList("PartyOptions", 10));
|
||||
}
|
||||
public void setData(EntityPlayer player){
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
@@ -70,6 +73,7 @@ public class QuestLogData {
|
||||
|
||||
if (quest.partyOptions.allowParty) {
|
||||
partyQuests.put(key, quest.id);
|
||||
partyOptions.put(key, quest.partyOptions.getPartyOptionsList());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,4 +101,8 @@ public class QuestLogData {
|
||||
public String getComplete() {
|
||||
return finish.get(selectedCategory + ":" + selectedQuest);
|
||||
}
|
||||
|
||||
public Vector<String> getPartyOptions() {
|
||||
return partyOptions.get(selectedCategory + ":" + selectedQuest);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,9 @@ import net.minecraftforge.event.entity.living.*;
|
||||
import net.minecraftforge.event.entity.player.*;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
@@ -66,6 +68,12 @@ public class ScriptPlayerEventHandler {
|
||||
if (PlayerDataController.Instance != null) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
if(playerData.updateClient) {
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.SYNC_END, SyncType.PLAYER_DATA, playerData.getSyncNBT());
|
||||
// VisibilityController.instance.onUpdate((EntityPlayerMP) player);
|
||||
playerData.updateClient = false;
|
||||
}
|
||||
|
||||
if (playerData.timers.size() > 0) {
|
||||
playerData.timers.update();
|
||||
}
|
||||
@@ -517,4 +525,4 @@ public class ScriptPlayerEventHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,13 +143,15 @@ public class ServerEventsHandler {
|
||||
if(!(event.source != null && event.source.getEntity() instanceof EntityPlayer) || !(event.entityLiving instanceof EntityPlayer) || FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
return;
|
||||
|
||||
EntityPlayer sourcePlayer = (EntityPlayer) event.source.getEntity();
|
||||
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(sourcePlayer);
|
||||
PlayerData targetData = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entityLiving);
|
||||
if (playerData.partyUUID != null && playerData.partyUUID.equals(targetData.partyUUID)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
// Check for Friendly Fire
|
||||
EntityPlayer sourcePlayer = (EntityPlayer) event.source.getEntity();
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(sourcePlayer);
|
||||
PlayerData targetData = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entityLiving);
|
||||
if (playerData.partyUUID != null && playerData.partyUUID.equals(targetData.partyUUID)) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
if(party != null && !party.friendlyFire())
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -318,7 +320,7 @@ public class ServerEventsHandler {
|
||||
}
|
||||
|
||||
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
boolean checkCompletion = false;
|
||||
String entityName = EntityList.getEntityString(entity);
|
||||
@@ -385,6 +387,7 @@ public class ServerEventsHandler {
|
||||
killed.put(name, amount + 1);
|
||||
}
|
||||
quest.setKilled(data, killed);
|
||||
playerData.updateClient = true;
|
||||
}
|
||||
if(!checkCompletion)
|
||||
return;
|
||||
@@ -393,10 +396,14 @@ public class ServerEventsHandler {
|
||||
}
|
||||
|
||||
private void doPartyQuest(EntityPlayer player, Party party, EntityLivingBase entity){
|
||||
PlayerData pdata = PlayerData.get(player);
|
||||
QuestData data = party.getQuestData();
|
||||
if(data == null)
|
||||
return;
|
||||
|
||||
if(pdata == null)
|
||||
return;
|
||||
|
||||
if (data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
|
||||
return;
|
||||
|
||||
@@ -441,8 +448,10 @@ public class ServerEventsHandler {
|
||||
killed.put(name, amount + 1);
|
||||
}
|
||||
quest.setKilled(data, killed);
|
||||
pdata.updateClient = true;
|
||||
}
|
||||
|
||||
PartyController.Instance().pingPartyQuestObjectiveUpdate(party);
|
||||
PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Kill);
|
||||
}
|
||||
|
||||
@@ -455,8 +464,11 @@ public class ServerEventsHandler {
|
||||
QuestItem.pickedUp = event.item.getEntityItem();
|
||||
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null)
|
||||
if(playerParty != null){
|
||||
QuestItem.pickedUpParty = event.item.getEntityItem();
|
||||
QuestItem.pickedUpPlayer = event.entityPlayer;
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.client.AnalyticsTracking;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.SyncController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
|
||||
import java.net.InetAddress;
|
||||
@@ -20,11 +22,12 @@ public class ServerTickHandler {
|
||||
NPCSpawning.findChunksForSpawning((WorldServer) event.world);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String serverName = null;
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event){
|
||||
EntityPlayerMP player = (EntityPlayerMP) event.player;
|
||||
if(serverName == null){
|
||||
String e = "local";
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
@@ -47,6 +50,8 @@ public class ServerTickHandler {
|
||||
if (playerData != null) {
|
||||
playerData.onLogin();
|
||||
}
|
||||
|
||||
SyncController.syncPlayer(player);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
@@ -172,7 +172,10 @@ public class BlockScripted extends BlockContainer {
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return ((TileScripted) world.getTileEntity(x, y, z)).activePowering;
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
if (tile == null)
|
||||
return 0;
|
||||
return tile.activePowering;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,7 +190,10 @@ public class BlockScripted extends BlockContainer {
|
||||
|
||||
@Override
|
||||
public float getBlockHardness(World world, int x, int y, int z) {
|
||||
return ((TileScripted) world.getTileEntity(x, y, z)).blockHardness;
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
if (tile == null)
|
||||
return 0;
|
||||
return tile.blockHardness;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,7 +206,10 @@ public class BlockScripted extends BlockContainer {
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) {
|
||||
return ((TileScripted) world.getTileEntity(x, y, z)).blockResistance;
|
||||
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
|
||||
if (tile == null)
|
||||
return 0;
|
||||
return tile.blockResistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,6 +54,7 @@ public class TileWaypoint extends TileEntity {
|
||||
boolean isPartyLeader = player.getUniqueID().equals(party.getLeaderUUID());
|
||||
if(partyQuestLocation.setFoundParty(party, player, name, isPartyLeader)){
|
||||
player.addChatMessage(new ChatComponentTranslation(name + " " + StatCollector.translateToLocal("quest.found")));
|
||||
PartyController.Instance().pingPartyQuestObjectiveUpdate(party);
|
||||
PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,7 @@ import noppes.npcs.client.renderer.MarkRenderer;
|
||||
import noppes.npcs.client.renderer.RenderCNPCPlayer;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.constants.MarkType;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.FramePart;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -99,13 +96,14 @@ public class ClientEventHandler {
|
||||
|
||||
MarkData markData = MarkData.get((EntityNPCInterface) event.entity);
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
for(MarkData.Mark m : markData.marks){
|
||||
if(m.getType() != MarkType.NONE && m.availability.isAvailable(player)){
|
||||
MarkRenderer.render(event.entity, event.x, event.y, event.z, m);
|
||||
break;
|
||||
if(PlayerData.get(player) != null){
|
||||
for(MarkData.Mark m : markData.marks){
|
||||
if(m.getType() != MarkType.NONE && m.availability.isAvailable(player)){
|
||||
MarkRenderer.render(event.entity, event.x, event.y, event.z, m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.entity instanceof EntityPlayer) {
|
||||
if (ClientCacheHandler.playerAnimations.containsKey(event.entity.getUniqueID())) {
|
||||
data = ClientCacheHandler.playerAnimations.get(event.entity.getUniqueID());
|
||||
|
||||
@@ -12,6 +12,9 @@ import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.client.controllers.MusicController;
|
||||
import noppes.npcs.client.controllers.ScriptSoundController;
|
||||
import noppes.npcs.client.gui.player.inventory.GuiCNPCInventory;
|
||||
import noppes.npcs.client.gui.player.inventory.GuiFaction;
|
||||
import noppes.npcs.client.gui.player.inventory.GuiParty;
|
||||
import noppes.npcs.client.gui.player.inventory.GuiQuestLog;
|
||||
import noppes.npcs.client.renderer.RenderNPCInterface;
|
||||
import noppes.npcs.constants.EnumPlayerPacket;
|
||||
@@ -28,7 +31,7 @@ public class ClientTickHandler{
|
||||
private int buttonPressed = -1;
|
||||
private long buttonTime = 0L;
|
||||
private final int[] ignoreKeys = new int[]{157, 29, 54, 42, 184, 56, 220, 219};
|
||||
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onClientTick(TickEvent.ClientTickEvent event){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
@@ -91,8 +94,19 @@ public class ClientTickHandler{
|
||||
public void onKey(InputEvent.KeyInputEvent event){
|
||||
if(ClientProxy.QuestLog.isPressed()){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if(mc.currentScreen == null)
|
||||
NoppesUtil.openGUI(mc.thePlayer, new GuiQuestLog(mc.thePlayer));
|
||||
if(mc.currentScreen == null){
|
||||
switch (GuiCNPCInventory.activeTab){
|
||||
case 0:
|
||||
NoppesUtil.openGUI(mc.thePlayer, new GuiQuestLog(mc.thePlayer));
|
||||
break;
|
||||
case 1:
|
||||
NoppesUtil.openGUI(mc.thePlayer, new GuiParty(mc.thePlayer));
|
||||
break;
|
||||
case 2:
|
||||
NoppesUtil.openGUI(mc.thePlayer, new GuiFaction());
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(mc.currentScreen instanceof GuiQuestLog)
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class NoppesUtil {
|
||||
float height = buffer.readFloat();
|
||||
float width = buffer.readFloat();
|
||||
float yOffset = buffer.readFloat();
|
||||
|
||||
|
||||
String particle = Server.readString(buffer);
|
||||
World worldObj = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
@@ -121,7 +121,7 @@ public class NoppesUtil {
|
||||
}
|
||||
|
||||
public static void clickSound() {
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
|
||||
private static EntityNPCInterface lastNpc;
|
||||
@@ -135,7 +135,7 @@ public class NoppesUtil {
|
||||
public static void openGUI(EntityPlayer player, Object guiscreen) {
|
||||
CustomNpcs.proxy.openGui(player, guiscreen);
|
||||
}
|
||||
|
||||
|
||||
public static void openFolder(File dir){
|
||||
String s = dir.getAbsolutePath();
|
||||
|
||||
@@ -196,19 +196,19 @@ public class NoppesUtil {
|
||||
return;
|
||||
Vector<String> data = new Vector<String>();
|
||||
String line;
|
||||
|
||||
|
||||
try {
|
||||
int size = buffer.readInt();
|
||||
for(int i = 0; i < size; i++){
|
||||
data.add(Server.readString(buffer));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
((IScrollData)gui).setData(data,null);
|
||||
}
|
||||
|
||||
|
||||
private static HashMap<String,Integer> data = new HashMap<String,Integer>();
|
||||
private static HashMap<String,Integer> group = new HashMap<String,Integer>();
|
||||
|
||||
@@ -259,7 +259,7 @@ public class NoppesUtil {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void setScrollData(ByteBuf buffer) {
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
if(gui == null)
|
||||
@@ -291,10 +291,8 @@ public class NoppesUtil {
|
||||
NoppesUtil.openGUI(player, new GuiQuestCompletion(quest));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void openDialog(NBTTagCompound compound, EntityNPCInterface npc, EntityPlayer player){
|
||||
if(DialogController.Instance == null)
|
||||
DialogController.Instance = new DialogController();
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.readNBT(compound);
|
||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
||||
@@ -309,20 +307,20 @@ public class NoppesUtil {
|
||||
int x = compound.getInteger("x");
|
||||
int y = compound.getInteger("y");
|
||||
int z = compound.getInteger("z");
|
||||
|
||||
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
tile.readFromNBT(compound);
|
||||
|
||||
|
||||
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.RedstoneBlock, player);
|
||||
}
|
||||
public static void saveWayPointBlock(EntityPlayer player, NBTTagCompound compound){
|
||||
int x = compound.getInteger("x");
|
||||
int y = compound.getInteger("y");
|
||||
int z = compound.getInteger("z");
|
||||
|
||||
|
||||
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||
tile.readFromNBT(compound);
|
||||
|
||||
|
||||
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Waypoint, player);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,16 +33,20 @@ import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.SyncController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.MarkData;
|
||||
import noppes.npcs.controllers.data.RecipeCarpentry;
|
||||
import noppes.npcs.entity.EntityDialogNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PacketHandlerClient extends PacketHandlerServer{
|
||||
|
||||
@@ -105,6 +109,27 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
RecipeController.Instance.anvilRecipes = RecipeController.syncRecipes;
|
||||
RecipeController.syncRecipes = new HashMap<Integer, RecipeCarpentry>();
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNC_ADD || type == EnumPacketClient.SYNC_END){
|
||||
int synctype = buffer.readInt();
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
|
||||
SyncController.clientSync(synctype, compound, type == EnumPacketClient.SYNC_END);
|
||||
|
||||
if(synctype == SyncType.PLAYER_DATA){
|
||||
ClientProxy.playerData.setNBT(compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNC_UPDATE){
|
||||
int synctype = buffer.readInt();
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
SyncController.clientSyncUpdate(synctype, compound, buffer);
|
||||
}
|
||||
else if(type == EnumPacketClient.SYNC_REMOVE){
|
||||
int synctype = buffer.readInt();
|
||||
int id = buffer.readInt();
|
||||
|
||||
SyncController.clientSyncRemove(synctype, id);
|
||||
}
|
||||
else if(type == EnumPacketClient.MARK_DATA){
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(buffer.readInt());
|
||||
if(!(entity instanceof EntityNPCInterface))
|
||||
|
||||
@@ -367,11 +367,11 @@ public class GuiNPCEditAnimation extends GuiModelInterface implements ITextfield
|
||||
float[] pivots = part.getPivots();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
this.rotationSliders[i].sliderValue = ValueUtil.clamp((((rotations[i] / 360.0F) + 1) / 2.0F), 0.0F, 1.0F);
|
||||
int label = (int) (360.0F * 2.0F * ((((rotations[i] / 360.0F) + 1) / 2.0F) - 0.5F));
|
||||
int label = Math.round(rotations[i]);
|
||||
this.rotationSliders[i].setString(label + "");
|
||||
|
||||
this.pivotSliders[i].sliderValue = ValueUtil.clamp(((((ValueUtil.clamp(pivots[i], -100, 100)) / 100.0F) + 1) / 2.0F), 0.0F, 1.0F);
|
||||
int pivotVal = (int)(100.0F * (((((ValueUtil.clamp(pivots[i], -100, 100)) / 100.0F) + 1) / 2.0F) - 0.5F));
|
||||
int pivotVal = Math.round(pivots[i]);
|
||||
this.pivotSliders[i].setString(pivotVal + "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData{
|
||||
ySize = 180;
|
||||
this.drawDefaultBackground = false;
|
||||
title = "";
|
||||
activeTab = 2;
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.FactionsGet);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
xSize = 280;
|
||||
ySize = 180;
|
||||
drawDefaultBackground = false;
|
||||
activeTab = 1;
|
||||
Client.sendData(EnumPacketServer.GetPartyData);
|
||||
}
|
||||
|
||||
@@ -177,6 +176,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
GuiNpcButton trackButton = new GuiNpcButton(340, guiLeft + 5, guiTop + ySize - 8 - 23, "party.track");
|
||||
trackButton.width = 135;
|
||||
this.addButton(trackButton);
|
||||
getButton(340).enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -383,7 +383,21 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
@Override
|
||||
public void setPartyData(NBTTagCompound compound) {
|
||||
this.receivedData = true;
|
||||
ClientCacheHandler.party = null;
|
||||
if (compound.hasKey("QuestPing")) {
|
||||
this.questLogStatus.clear();
|
||||
this.questCompleteWith = "";
|
||||
if (compound.hasKey("QuestProgress")) {
|
||||
NBTTagList tagList = compound.getTagList("QuestProgress", 8);
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
this.questLogStatus.add(tagList.getStringTagAt(i));
|
||||
}
|
||||
}
|
||||
if (compound.hasKey("QuestCompleteWith")) {
|
||||
this.questCompleteWith = compound.getString("QuestCompleteWith");
|
||||
}
|
||||
} else {
|
||||
ClientCacheHandler.party = null;
|
||||
}
|
||||
|
||||
if (compound.hasKey("PartyUUID")) {
|
||||
UUID uuid = UUID.fromString(compound.getString("PartyUUID"));
|
||||
|
||||
@@ -33,7 +33,8 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
private HashMap<Integer,GuiNpcButton> otherButtons = new HashMap<Integer,GuiNpcButton>();
|
||||
private QuestLogData data = new QuestLogData();
|
||||
private boolean noQuests = false;
|
||||
private boolean questDetails = true;
|
||||
private byte questPages = 1;
|
||||
private static long lastClicked = System.currentTimeMillis();
|
||||
|
||||
private HashMap<String,String> questAlertsOnOpen;
|
||||
private String trackedQuestKeyOnOpen;
|
||||
@@ -50,7 +51,6 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
ySize = 180;
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.QuestLog);
|
||||
drawDefaultBackground = false;
|
||||
activeTab = 0;
|
||||
}
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
@@ -73,7 +73,6 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
if(data.selectedCategory.isEmpty())
|
||||
data.selectedCategory = category;
|
||||
sideButtons.put(i, new GuiMenuSideButton(i,guiLeft - 69, this.guiTop +2 + i*21, 70,22, category));
|
||||
otherButtons.put(i, new GuiNpcButton(i,guiLeft - 69, this.guiTop +2 + i*21, 70,22, category));
|
||||
i++;
|
||||
}
|
||||
sideButtons.get(categories.indexOf(data.selectedCategory)).active = true;
|
||||
@@ -87,10 +86,32 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
scroll.guiTop = guiTop + 15;
|
||||
addScroll(scroll);
|
||||
|
||||
// Text Forward--
|
||||
addButton(new GuiButtonNextPage(1, guiLeft + 286, guiTop + 176, true));
|
||||
|
||||
// Objectives Back--
|
||||
addButton(new GuiButtonNextPage(2, guiLeft + 144, guiTop + 176, false));
|
||||
|
||||
if (data.partyQuests.containsKey(data.selectedCategory + ":" + data.selectedQuest)) {
|
||||
boolean showParty = false;
|
||||
boolean showTrackAlerts = true;
|
||||
if(data.partyQuests.containsKey(data.selectedCategory + ":" + data.selectedQuest)){
|
||||
showParty = true;
|
||||
if(data.partyOptions.containsKey(data.selectedCategory + ":" + data.selectedQuest)){
|
||||
if(data.partyOptions.get(data.selectedCategory + ":" + data.selectedQuest).get(0).contains("only")){
|
||||
showTrackAlerts = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (showParty) {
|
||||
// Objectives Forward--
|
||||
addButton(new GuiButtonNextPage(11, guiLeft + 286, guiTop + 176, true));
|
||||
|
||||
// Party Back--
|
||||
addButton(new GuiButtonNextPage(10, guiLeft + 144, guiTop + 176, false));
|
||||
|
||||
String questName = ClientCacheHandler.party != null ? ClientCacheHandler.party.getCurrentQuestName() : null;
|
||||
GuiNpcButton partyButton = new GuiNpcButton(3, guiLeft + 150, guiTop + 151, 50, 20, new String[]{"party.party", "party.partying"}, Objects.equals(questName, data.selectedQuest) ? 1 : 0);
|
||||
addButton(partyButton);
|
||||
@@ -100,6 +121,9 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
if (partyButton.enabled && Objects.equals(questName, data.selectedQuest)) {
|
||||
partyButton.packedFGColour = 0x32CD32;
|
||||
}
|
||||
|
||||
getButton(11).visible = questPages == 0 && data.hasSelectedQuest();
|
||||
getButton(10).visible = questPages == 1 && data.hasSelectedQuest();
|
||||
}
|
||||
|
||||
GuiNpcButton trackingButton = new GuiNpcButton(4, guiLeft + 260, guiTop + 151, 50, 20, new String[]{"quest.track", "quest.tracking"}, data.trackedQuestKey.equals(data.selectedCategory + ":" + data.selectedQuest) ? 1 : 0);
|
||||
@@ -111,13 +135,16 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
GuiNpcButton alertButton = new GuiNpcButton(5, guiLeft + 205, guiTop + 151, 50, 20, new String[]{"quest.alerts", "quest.noAlerts"}, data.getQuestAlerts() ? 0 : 1);
|
||||
addButton(alertButton);
|
||||
|
||||
getButton(1).visible = questDetails && data.hasSelectedQuest();
|
||||
getButton(2).visible = !questDetails && data.hasSelectedQuest();
|
||||
getButton(1).visible = questPages == 1 && data.hasSelectedQuest();
|
||||
getButton(2).visible = questPages == 2 && data.hasSelectedQuest();
|
||||
getButton(4).visible = !data.selectedQuest.isEmpty() && getButton(1).visible;
|
||||
getButton(5).visible = getButton(4).visible;
|
||||
if (getButton(3) != null) {
|
||||
getButton(3).visible = getButton(4).visible;
|
||||
}
|
||||
|
||||
getButton(4).enabled = showTrackAlerts;
|
||||
getButton(5).enabled = showTrackAlerts;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,12 +164,25 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guibutton){
|
||||
if(guibutton.id == 1){
|
||||
questDetails = false;
|
||||
if(lastClicked > System.currentTimeMillis() - 10){
|
||||
return;
|
||||
}
|
||||
|
||||
if(guibutton.id == 11){
|
||||
questPages = 1;
|
||||
lastClicked = System.currentTimeMillis();
|
||||
}
|
||||
else if(guibutton.id == 10){
|
||||
questPages = 0;
|
||||
}
|
||||
else if(guibutton.id == 1){
|
||||
questPages = 2;
|
||||
}
|
||||
if(guibutton.id == 2){
|
||||
questDetails = true;
|
||||
else if(guibutton.id == 2){
|
||||
questPages = 1;
|
||||
lastClicked = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (guibutton.id == 3)
|
||||
{
|
||||
if (Objects.equals(ClientCacheHandler.party.getCurrentQuestName(), data.selectedQuest)) {
|
||||
@@ -192,32 +232,54 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
return;
|
||||
}
|
||||
|
||||
int maxScroll = Math.max(0, this.sideButtons.size() - 10) * 22;
|
||||
this.destSideButtonScroll = ValueUtil.clamp(this.destSideButtonScroll - Math.signum(this.mouseWheel) * 22, -maxScroll, 0);
|
||||
this.sideButtonScroll = this.sideButtonScroll * (1.0F - 0.2F) + (this.destSideButtonScroll * 0.2F);
|
||||
// Define constants for smoothing the scroll
|
||||
final float SMOOTHING_FACTOR = 0.1F; // Adjust this value for smoother or faster scrolling
|
||||
|
||||
for(Map.Entry<Integer,GuiMenuSideButton> entry : this.sideButtons.entrySet()){
|
||||
int maxScroll = Math.max(0, this.sideButtons.size() - 9) * 22;
|
||||
// Adjust scrolling only if the mouse is in the scroll zone
|
||||
if (isMouseInScrollZone(i, j)) {
|
||||
this.destSideButtonScroll = ValueUtil.clamp(this.destSideButtonScroll - Math.signum(this.mouseWheel) * 22, -maxScroll, 0);
|
||||
}
|
||||
// Apply smoothing to the scroll transition
|
||||
this.sideButtonScroll += (this.destSideButtonScroll - this.sideButtonScroll) * SMOOTHING_FACTOR;
|
||||
|
||||
// Loop through the side buttons and render them
|
||||
for (Map.Entry<Integer, GuiMenuSideButton> entry : this.sideButtons.entrySet()) {
|
||||
int buttonNumber = entry.getKey();
|
||||
GuiMenuSideButton button = entry.getValue();
|
||||
|
||||
button.yPosition = (int) (this.guiTop +2 + buttonNumber*21 + this.sideButtonScroll);
|
||||
if (button.yPosition >= this.guiTop && button.yPosition < this.guiTop + 22 * 8) {
|
||||
float rawYPosition = (this.guiTop + 2 + buttonNumber * 21 + this.sideButtonScroll);
|
||||
int smoothedYPosition = Math.round(rawYPosition);
|
||||
|
||||
// Render the button if it's within the visible area
|
||||
if (smoothedYPosition >= this.guiTop && smoothedYPosition < this.guiTop + 22 * 8) {
|
||||
button.yPosition = smoothedYPosition;
|
||||
button.drawButton(mc, i, j);
|
||||
}
|
||||
}
|
||||
fontRendererObj.drawString(data.selectedCategory,guiLeft + 5,guiTop + 5, CustomNpcResourceListener.DefaultTextColor);
|
||||
|
||||
fontRendererObj.drawString(data.selectedCategory,guiLeft + 5,guiTop + 5, CustomNpcResourceListener.DefaultTextColor);
|
||||
|
||||
if(!data.hasSelectedQuest())
|
||||
return;
|
||||
|
||||
if (questDetails) {
|
||||
if (questPages == 1) {
|
||||
drawProgress();
|
||||
String title = StatCollector.translateToLocal("gui.text");
|
||||
fontRendererObj.drawString(title, guiLeft + 284 - fontRendererObj.getStringWidth(title), guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
|
||||
|
||||
if(data.partyQuests.containsKey(data.selectedCategory + ":" + data.selectedQuest)){
|
||||
title = StatCollector.translateToLocal("party.party");
|
||||
fontRendererObj.drawString(title, guiLeft + 170, guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
|
||||
}
|
||||
} else if (questPages == 0) {
|
||||
drawPartyOptions();
|
||||
String title = StatCollector.translateToLocal("quest.objectives");
|
||||
fontRendererObj.drawString(title, guiLeft + 284 - fontRendererObj.getStringWidth(title), guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
|
||||
} else {
|
||||
drawQuestText();
|
||||
String title = StatCollector.translateToLocal("quest.objectives");
|
||||
fontRendererObj.drawString(title, guiLeft + 168, guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
|
||||
fontRendererObj.drawString(title, guiLeft + 170, guiTop + 179, CustomNpcResourceListener.DefaultTextColor);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@@ -261,6 +323,16 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
}
|
||||
}
|
||||
|
||||
private void drawPartyOptions() {
|
||||
int yoffset = guiTop + 22;
|
||||
for(String process : data.getPartyOptions()){
|
||||
List<String> parts = Arrays.asList(process.split(":"));
|
||||
String drawString = StatCollector.translateToLocal(parts.get(0)) + ": " + StatCollector.translateToLocal(parts.get(1));
|
||||
fontRendererObj.drawString("- " + drawString, guiLeft + 144, yoffset , CustomNpcResourceListener.DefaultTextColor);
|
||||
yoffset += 10;
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
|
||||
{
|
||||
}
|
||||
@@ -284,6 +356,8 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
NoppesUtil.clickSound();
|
||||
data.selectedCategory = button.displayString;
|
||||
data.selectedQuest = "";
|
||||
if(scroll != null)
|
||||
scroll.selected = -1;
|
||||
this.initGui();
|
||||
}
|
||||
@Override
|
||||
@@ -346,4 +420,13 @@ public class GuiQuestLog extends GuiCNPCInventory implements ITopButtonListener,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isMouseInScrollZone(int x, int y) {
|
||||
int scrollZoneLeft = guiLeft - 69; // Left boundary of the scroll zone
|
||||
int scrollZoneRight = guiLeft - 69 + 70; // Right boundary of the scroll zone
|
||||
int scrollZoneTop = guiTop + 2; // Top boundary of the scroll zone
|
||||
int scrollZoneBottom = guiTop + 2 + 8 * 21; // Bottom boundary of the scroll zone
|
||||
|
||||
return x >= scrollZoneLeft && x <= scrollZoneRight && y >= scrollZoneTop && y <= scrollZoneBottom;
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,13 @@ public class GuiScriptPlayers extends GuiScriptInterface {
|
||||
hookList.add("customGuiSlotClicked");
|
||||
hookList.add("customGuiScroll");
|
||||
hookList.add("customGuiTextfield");
|
||||
hookList.add("partyQuestCompleted");
|
||||
hookList.add("partyQuestSet");
|
||||
hookList.add("partyQuestTurnedIn");
|
||||
hookList.add("partyInvite");
|
||||
hookList.add("partyKick");
|
||||
hookList.add("partyLeave");
|
||||
hookList.add("partyDisband");
|
||||
|
||||
this.handler = this.script;
|
||||
Client.sendData(EnumPacketServer.ScriptPlayerGet);
|
||||
|
||||
@@ -82,6 +82,7 @@ public class GuiCustomScroll extends GuiScreen
|
||||
public void drawScreen(int i, int j, float f, int mouseScrolled){
|
||||
if(!visible)
|
||||
return;
|
||||
|
||||
drawGradientRect(guiLeft, guiTop, xSize+guiLeft ,ySize+guiTop, 0xc0101010, 0xd0101010);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(resource);
|
||||
@@ -96,6 +97,8 @@ public class GuiCustomScroll extends GuiScreen
|
||||
GL11.glTranslatef(guiLeft, guiTop, 0.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
boolean isMouseOverComponent = isMouseOver(i, j);
|
||||
|
||||
if(selectable)
|
||||
hover = getMouseOver(i,j);
|
||||
|
||||
@@ -140,7 +143,7 @@ public class GuiCustomScroll extends GuiScreen
|
||||
}
|
||||
}
|
||||
|
||||
if(mouseScrolled != 0){
|
||||
if(mouseScrolled != 0 && isMouseOverComponent){
|
||||
scrollY += mouseScrolled > 0?-14:14;
|
||||
if(scrollY > maxScrollY)
|
||||
scrollY = maxScrollY;
|
||||
|
||||
@@ -585,13 +585,13 @@ public class RenderNPCInterface extends RenderLiving{
|
||||
}
|
||||
LastTextureTick = 0;
|
||||
} else if (npc.display.skinType == 2 || npc.display.skinType == 3) {
|
||||
ResourceLocation location = new ResourceLocation("skins/" + (npc.display.modelType + npc.display.url).hashCode());
|
||||
ResourceLocation location = new ResourceLocation("skins/" + (npc.display.modelType + npc.display.skinType + npc.display.url).hashCode());
|
||||
// If URL Empty Steve
|
||||
if(npc.display.url.isEmpty()){ return AbstractClientPlayer.locationStevePng; }
|
||||
// If URL Cached then grab it
|
||||
else if(ClientCacheHandler.isCachedNPC(location)){
|
||||
try {
|
||||
npc.textureLocation = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.modelType > 0, location).getLocation();
|
||||
npc.textureLocation = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.modelType > 0 || npc.display.skinType == 3, location).getLocation();
|
||||
} catch(Exception ignored){}
|
||||
}
|
||||
// For New URL Requests do not spam it
|
||||
@@ -600,7 +600,7 @@ public class RenderNPCInterface extends RenderLiving{
|
||||
}
|
||||
else {
|
||||
try {
|
||||
npc.textureLocation = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.modelType > 0, location).getLocation();
|
||||
npc.textureLocation = ClientCacheHandler.getNPCTexture(npc.display.url, npc.display.modelType > 0 || npc.display.skinType == 3, location).getLocation();
|
||||
LastTextureTick = 0;
|
||||
} catch(Exception ignored){}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.config.legacy.LegacyConfig;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
@@ -168,8 +169,16 @@ public class ConfigScript
|
||||
}
|
||||
|
||||
public static boolean isScriptDev(EntityPlayer player) {
|
||||
return ScriptOpsOnly && MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
|
||||
Developer.ScriptUser.contains(player.getUniqueID()) ||
|
||||
Developer.Universal.contains(player.getUniqueID());
|
||||
}
|
||||
|
||||
public static boolean canScript(EntityPlayer player, CustomNpcsPermissions.Permission perm) {
|
||||
if(ScriptOpsOnly){
|
||||
return isScriptDev(player);
|
||||
}
|
||||
|
||||
return CustomNpcsPermissions.hasPermission(player, perm);
|
||||
}
|
||||
}
|
||||
@@ -55,5 +55,6 @@ public enum EnumPacketClient {
|
||||
STOP_SOUNDS,
|
||||
SYNC_WEAPON,
|
||||
MARK_DATA,
|
||||
SYNC_ADD, SYNC_END, SYNC_UPDATE, SYNC_REMOVE,
|
||||
PARTY_DATA
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public enum EnumPartyExchange {
|
||||
Enrolled("party.enrolled"),
|
||||
Valid("party.valid");
|
||||
|
||||
final String name;
|
||||
public final String name;
|
||||
|
||||
EnumPartyExchange(String name){
|
||||
this.name = name;
|
||||
|
||||
@@ -7,7 +7,7 @@ public enum EnumPartyObjectives {
|
||||
All("party.all"),
|
||||
Leader("party.leader");
|
||||
|
||||
final String name;
|
||||
public final String name;
|
||||
|
||||
EnumPartyObjectives(String name){
|
||||
this.name = name;
|
||||
|
||||
@@ -7,7 +7,7 @@ public enum EnumPartyRequirements {
|
||||
All("party.all"),
|
||||
Valid("party.valid");
|
||||
|
||||
String name;
|
||||
public final String name;
|
||||
|
||||
EnumPartyRequirements(String name){
|
||||
this.name = name;
|
||||
|
||||
@@ -90,7 +90,16 @@ public enum EnumScriptType {
|
||||
FORGE_ENTITY("forgeEntity"),
|
||||
FORGE_WORLD("forgeWorld"),
|
||||
CNPC_NATURAL_SPAWN("onCNPCNaturalSpawn"),
|
||||
CUSTOM_ITEM_EVENT("customItemEvent");
|
||||
CUSTOM_ITEM_EVENT("customItemEvent"),
|
||||
|
||||
PARTY_EVENT("partyEvent"),
|
||||
PARTY_QUEST_COMPLETED("partyQuestCompleted"),
|
||||
PARTY_QUEST_SET("partyQuestSet"),
|
||||
PARTY_QUEST_TURNED_IN("partyQuestTurnedIn"),
|
||||
PARTY_INVITE("partyInvite"),
|
||||
PARTY_KICK("partyKick"),
|
||||
PARTY_LEAVE("partyLeave"),
|
||||
PARTY_DISBAND("partyDisband");
|
||||
|
||||
public String function;
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package noppes.npcs.constants;
|
||||
|
||||
public class SyncType {
|
||||
public static final int FACTION = 1;
|
||||
public static final int QUEST = 2;
|
||||
public static final int QUEST_CATEGORY = 3;
|
||||
public static final int DIALOG = 4;
|
||||
public static final int DIALOG_CATEGORY = 5;
|
||||
public static final int RECIPE_NORMAL = 6;
|
||||
public static final int RECIPE_CARPENTRY = 7;
|
||||
public static final int PLAYER_DATA = 8;
|
||||
}
|
||||
@@ -6,10 +6,13 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.handler.IDialogHandler;
|
||||
import noppes.npcs.api.handler.data.IDialog;
|
||||
import noppes.npcs.api.handler.data.IDialogCategory;
|
||||
import noppes.npcs.constants.EnumOptionType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.DialogCategory;
|
||||
import noppes.npcs.controllers.data.DialogOption;
|
||||
@@ -20,31 +23,31 @@ import java.io.FileInputStream;
|
||||
import java.util.*;
|
||||
|
||||
public class DialogController implements IDialogHandler {
|
||||
public HashMap<Integer,DialogCategory> categoriesSync = new HashMap<Integer, DialogCategory>();
|
||||
public HashMap<Integer,DialogCategory> categories = new HashMap<Integer, DialogCategory>();
|
||||
public HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>();
|
||||
public static DialogController Instance;
|
||||
public static DialogController Instance = new DialogController();;
|
||||
|
||||
private int lastUsedDialogID = 0;
|
||||
private int lastUsedCatID = 0;
|
||||
|
||||
|
||||
public DialogController(){
|
||||
Instance = this;
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
public void load(){
|
||||
LogWriter.info("Loading Dialogs");
|
||||
loadCategories();
|
||||
LogWriter.info("Done loading Dialogs");
|
||||
}
|
||||
|
||||
|
||||
private void loadCategories(){
|
||||
categories.clear();
|
||||
dialogs.clear();
|
||||
|
||||
lastUsedCatID = 0;
|
||||
lastUsedDialogID = 0;
|
||||
|
||||
|
||||
try {
|
||||
File file = new File(CustomNpcs.getWorldSaveDirectory(), "dialog.dat");
|
||||
if(file.exists()){
|
||||
@@ -118,7 +121,7 @@ public class DialogController implements IDialogHandler {
|
||||
NBTTagList list = nbttagcompound1.getTagList("Data", 10);
|
||||
if(list == null)
|
||||
return;
|
||||
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readNBT(list.getCompoundTagAt(i));
|
||||
@@ -135,7 +138,7 @@ public class DialogController implements IDialogHandler {
|
||||
saveDialog(category.id, dialog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,35 +146,35 @@ public class DialogController implements IDialogHandler {
|
||||
DialogCategory cat = new DialogCategory();
|
||||
cat.id = lastUsedCatID++;
|
||||
cat.title = "Villager";
|
||||
|
||||
|
||||
Dialog dia1 = new Dialog();
|
||||
dia1.id = 1;
|
||||
dia1.category = cat;
|
||||
dia1.title = "Start";
|
||||
dia1.text = "Hello {player}, "+'\n'+'\n'+"Welcome to our village. I hope you enjoy your stay";
|
||||
|
||||
|
||||
Dialog dia2 = new Dialog();
|
||||
dia2.id = 2;
|
||||
dia2.category = cat;
|
||||
dia2.title = "Ask about village";
|
||||
dia2.text = "This village has been around for ages. Enjoy your stay here.";
|
||||
|
||||
|
||||
Dialog dia3 = new Dialog();
|
||||
dia3.id = 3;
|
||||
dia3.category = cat;
|
||||
dia3.title = "Who are you";
|
||||
dia3.text = "I'm a villager here. I have lived in this village my whole life.";
|
||||
|
||||
|
||||
cat.dialogs.put(dia1.id, dia1);
|
||||
cat.dialogs.put(dia2.id, dia2);
|
||||
cat.dialogs.put(dia3.id, dia3);
|
||||
|
||||
|
||||
|
||||
DialogOption option = new DialogOption();
|
||||
option.title = "Tell me something about this village";
|
||||
option.dialogId = 2;
|
||||
option.optionType = EnumOptionType.DialogOption;
|
||||
|
||||
|
||||
DialogOption option2 = new DialogOption();
|
||||
option2.title = "Who are you?";
|
||||
option2.dialogId = 3;
|
||||
@@ -180,11 +183,11 @@ public class DialogController implements IDialogHandler {
|
||||
DialogOption option3 = new DialogOption();
|
||||
option3.title = "Goodbye";
|
||||
option3.optionType = EnumOptionType.QuitOption;
|
||||
|
||||
|
||||
dia1.options.put(0, option2);
|
||||
dia1.options.put(1, option);
|
||||
dia1.options.put(2, option3);
|
||||
|
||||
|
||||
|
||||
DialogOption option4 = new DialogOption();
|
||||
option4.title = "Back";
|
||||
@@ -198,7 +201,7 @@ public class DialogController implements IDialogHandler {
|
||||
saveDialog(cat.id, dia2);
|
||||
saveDialog(cat.id, dia3);
|
||||
}
|
||||
|
||||
|
||||
public void saveCategory(DialogCategory category){
|
||||
category.title = NoppesStringUtils.cleanFileName(category.title);
|
||||
if(categories.containsKey(category.id)){
|
||||
@@ -227,8 +230,9 @@ public class DialogController implements IDialogHandler {
|
||||
dir.mkdirs();
|
||||
}
|
||||
categories.put(category.id, category);
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
|
||||
public void removeCategory(int category){
|
||||
DialogCategory cat = categories.get(category);
|
||||
if(cat == null)
|
||||
@@ -239,8 +243,9 @@ public class DialogController implements IDialogHandler {
|
||||
for(int dia : cat.dialogs.keySet())
|
||||
dialogs.remove(dia);
|
||||
categories.remove(category);
|
||||
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.DIALOG_CATEGORY, category);
|
||||
}
|
||||
|
||||
|
||||
private boolean containsCategoryName(String name) {
|
||||
name = name.toLowerCase();
|
||||
for(DialogCategory cat : categories.values()){
|
||||
@@ -269,28 +274,30 @@ public class DialogController implements IDialogHandler {
|
||||
lastUsedDialogID++;
|
||||
dialog.id = lastUsedDialogID;
|
||||
}
|
||||
|
||||
|
||||
dialogs.put(dialog.id, dialog);
|
||||
category.dialogs.put(dialog.id, dialog);
|
||||
|
||||
|
||||
File dir = new File(getDir(), category.title);
|
||||
if(!dir.exists())
|
||||
dir.mkdirs();
|
||||
|
||||
File file = new File(dir, dialog.id + ".json_new");
|
||||
File file2 = new File(dir, dialog.id + ".json");
|
||||
|
||||
|
||||
try {
|
||||
NBTJsonUtil.SaveFile(file, dialog.writeToNBTPartial(new NBTTagCompound()));
|
||||
NBTTagCompound compound = dialog.writeToNBT(new NBTTagCompound());
|
||||
NBTJsonUtil.SaveFile(file, compound);
|
||||
if(file2.exists())
|
||||
file2.delete();
|
||||
file.renameTo(file2);
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.DIALOG, compound, category.id);
|
||||
} catch (Exception e) {
|
||||
LogWriter.except(e);
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
public void removeDialog(Dialog dialog) {
|
||||
DialogCategory category = dialog.category;
|
||||
File file = new File(new File(getDir(), category.title), dialog.id + ".json");
|
||||
@@ -298,9 +305,9 @@ public class DialogController implements IDialogHandler {
|
||||
return;
|
||||
category.dialogs.remove(dialog.id);
|
||||
dialogs.remove(dialog.id);
|
||||
|
||||
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.DIALOG, dialog.id);
|
||||
}
|
||||
|
||||
|
||||
private File getDir(){
|
||||
return new File(CustomNpcs.getWorldSaveDirectory(), "dialogs");
|
||||
}
|
||||
|
||||
@@ -5,8 +5,11 @@ 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.api.handler.IFactionHandler;
|
||||
import noppes.npcs.api.handler.data.IFaction;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.data.Faction;
|
||||
|
||||
import java.io.*;
|
||||
@@ -17,22 +20,16 @@ import java.util.Map;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class FactionController implements IFactionHandler {
|
||||
public HashMap<Integer,Faction> factionsSync = new HashMap<Integer,Faction>();
|
||||
public HashMap<Integer,Faction> factions;
|
||||
|
||||
private static FactionController instance;
|
||||
private static FactionController instance = new FactionController();
|
||||
|
||||
private int lastUsedID = 0;
|
||||
|
||||
public FactionController(){
|
||||
instance = this;
|
||||
factions = new HashMap<Integer, Faction>();
|
||||
loadFactions();
|
||||
if(factions.isEmpty()){
|
||||
factions.put(0,new Faction(0,"Friendly", 0x00DD00, 2000));
|
||||
factions.put(1,new Faction(1,"Neutral", 0xF2DD00, 1000));
|
||||
factions.put(2,new Faction(2,"Aggressive", 0xDD0000, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static FactionController getInstance(){
|
||||
@@ -43,7 +40,7 @@ public class FactionController implements IFactionHandler {
|
||||
return factions.get(faction);
|
||||
}
|
||||
|
||||
private void loadFactions(){
|
||||
public void load(){
|
||||
|
||||
File saveDir = CustomNpcs.getWorldSaveDirectory();
|
||||
if(saveDir == null){
|
||||
@@ -64,6 +61,12 @@ public class FactionController implements IFactionHandler {
|
||||
} catch (Exception ee) {
|
||||
}
|
||||
}
|
||||
|
||||
if(factions.isEmpty()){
|
||||
factions.put(0,new Faction(0,"Friendly", 0x00DD00, 2000));
|
||||
factions.put(1,new Faction(1,"Neutral", 0xF2DD00, 1000));
|
||||
factions.put(2,new Faction(2,"Aggressive", 0xDD0000, 0));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFactionsFile(File file) throws IOException{
|
||||
@@ -151,6 +154,10 @@ public class FactionController implements IFactionHandler {
|
||||
}
|
||||
factions.remove(faction.id);
|
||||
factions.put(faction.id, faction);
|
||||
|
||||
NBTTagCompound facCompound = new NBTTagCompound();
|
||||
faction.writeNBT(facCompound);
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.FACTION, facCompound);
|
||||
saveFactions();
|
||||
}
|
||||
|
||||
@@ -185,6 +192,7 @@ public class FactionController implements IFactionHandler {
|
||||
} else {
|
||||
this.saveFactions();
|
||||
faction.id = -1;
|
||||
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.FACTION, id);
|
||||
return faction;
|
||||
}
|
||||
} else {
|
||||
@@ -206,7 +214,7 @@ public class FactionController implements IFactionHandler {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public Faction getFactionFromName(String factioname){
|
||||
for (Map.Entry<Integer,Faction>entryfaction:FactionController.getInstance().factions.entrySet()){
|
||||
if (entryfaction.getValue().name.equalsIgnoreCase(factioname)){
|
||||
|
||||
@@ -4,24 +4,26 @@ import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.roles.JobItemGiver;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static noppes.npcs.util.CustomNPCsThreader.customNPCThread;
|
||||
|
||||
public class GlobalDataController {
|
||||
public static GlobalDataController Instance;
|
||||
|
||||
private int itemGiverId = 0;
|
||||
public HashMap<Integer, JobItemGiver> itemGivers = new HashMap<>();
|
||||
|
||||
|
||||
public GlobalDataController(){
|
||||
Instance = this;
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
private void load(){
|
||||
File saveDir = CustomNpcs.getWorldSaveDirectory();
|
||||
try {
|
||||
@@ -35,7 +37,7 @@ public class GlobalDataController {
|
||||
if(file.exists()){
|
||||
loadData(file);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception ee) {
|
||||
ee.printStackTrace();
|
||||
}
|
||||
@@ -44,54 +46,41 @@ public class GlobalDataController {
|
||||
private void loadData(File file) throws Exception {
|
||||
NBTTagCompound nbttagcompound1 = CompressedStreamTools.readCompressed(new FileInputStream(file));
|
||||
itemGiverId = nbttagcompound1.getInteger("itemGiverId");
|
||||
|
||||
NBTTagList jobList = nbttagcompound1.getTagList("ItemGivers", 10);
|
||||
for (int i = 0; i < jobList.tagCount(); i++) {
|
||||
NBTTagCompound compound = jobList.getCompoundTagAt(i);
|
||||
JobItemGiver jobItemGiver = new JobItemGiver();
|
||||
jobItemGiver.readFromNBT(compound);
|
||||
itemGivers.put(jobItemGiver.itemGiverId, jobItemGiver);
|
||||
}
|
||||
}
|
||||
public void saveData(){
|
||||
try {
|
||||
File saveDir = CustomNpcs.getWorldSaveDirectory();
|
||||
customNPCThread.execute(() -> {
|
||||
try {
|
||||
File saveDir = CustomNpcs.getWorldSaveDirectory();
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("itemGiverId", itemGiverId);
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("itemGiverId", itemGiverId);
|
||||
|
||||
NBTTagList jobList = new NBTTagList();
|
||||
for (JobItemGiver jobItemGiver : itemGivers.values()) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
jobItemGiver.writeToNBT(compound);
|
||||
jobList.appendTag(compound);
|
||||
}
|
||||
nbttagcompound.setTag("ItemGivers", jobList);
|
||||
|
||||
File file = new File(saveDir, "global.dat_new");
|
||||
File file1 = new File(saveDir, "global.dat_old");
|
||||
File file2 = new File(saveDir, "global.dat");
|
||||
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file));
|
||||
if(file1.exists())
|
||||
{
|
||||
file1.delete();
|
||||
File file = new File(saveDir, "global.dat_new");
|
||||
File file1 = new File(saveDir, "global.dat_old");
|
||||
File file2 = new File(saveDir, "global.dat");
|
||||
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file));
|
||||
if(file1.exists())
|
||||
{
|
||||
file1.delete();
|
||||
}
|
||||
file2.renameTo(file1);
|
||||
if(file2.exists())
|
||||
{
|
||||
file2.delete();
|
||||
}
|
||||
file.renameTo(file2);
|
||||
if(file.exists())
|
||||
{
|
||||
file.delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
file2.renameTo(file1);
|
||||
if(file2.exists())
|
||||
{
|
||||
file2.delete();
|
||||
}
|
||||
file.renameTo(file2);
|
||||
if(file.exists())
|
||||
{
|
||||
file.delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
public int incrementItemGiverId(){
|
||||
itemGiverId++;
|
||||
saveData();
|
||||
return itemGiverId;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,10 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumQuestCompletion;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
@@ -16,6 +18,8 @@ import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.controllers.data.QuestData;
|
||||
import noppes.npcs.quests.QuestInterface;
|
||||
import noppes.npcs.quests.QuestItem;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.event.PartyEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
@@ -50,6 +54,8 @@ public class PartyController {
|
||||
public void disbandParty(UUID partyUUID) {
|
||||
Party party = this.parties.get(partyUUID);
|
||||
if (party != null) {
|
||||
PartyEvent.PartyDisbandEvent partyEvent = new PartyEvent.PartyDisbandEvent(party, party.getQuest());
|
||||
EventHooks.onPartyDisband(partyEvent);
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData playerData;
|
||||
@@ -72,19 +78,22 @@ public class PartyController {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendKickMessages(Party party, EntityPlayer kickPlayer){
|
||||
if(kickPlayer == null || party == null)
|
||||
public void sendKickMessages(Party party, EntityPlayer kickPlayer, String kickPlayerName){
|
||||
if(party == null)
|
||||
return;
|
||||
|
||||
for(String name : party.getPlayerNames()){
|
||||
EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name);
|
||||
if(playerMP != null){
|
||||
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.PARTY_MESSAGE, "party.kickOtherAlert", kickPlayer.getCommandSenderName());
|
||||
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.CHAT, "\u00A7e", kickPlayer.getCommandSenderName(), " \u00A74", "party.kickOtherChat", "!");
|
||||
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.PARTY_MESSAGE, "party.kickOtherAlert", kickPlayerName);
|
||||
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.CHAT, "\u00A7e", kickPlayerName, " \u00A74", "party.kickOtherChat", "!");
|
||||
}
|
||||
}
|
||||
Server.sendData((EntityPlayerMP) kickPlayer, EnumPacketClient.PARTY_MESSAGE, "party.kickYouAlert", "");
|
||||
Server.sendData((EntityPlayerMP) kickPlayer, EnumPacketClient.CHAT, "\u00A74", "party.kickYouChat", "!");
|
||||
|
||||
if(kickPlayer != null){
|
||||
Server.sendData((EntityPlayerMP) kickPlayer, EnumPacketClient.PARTY_MESSAGE, "party.kickYouAlert", "");
|
||||
Server.sendData((EntityPlayerMP) kickPlayer, EnumPacketClient.CHAT, "\u00A74", "party.kickYouChat", "!");
|
||||
}
|
||||
}
|
||||
|
||||
public void sendLeavingMessages(Party party, EntityPlayer leavingPlayer){
|
||||
@@ -131,48 +140,84 @@ public class PartyController {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendQuestChat(Party party, String chatAlert){
|
||||
public void pingPartyQuestObjectiveUpdate(Party party){
|
||||
if(party == null)
|
||||
return;
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("QuestPing", 0);
|
||||
if (party.getQuest() != null) {
|
||||
Quest quest = (Quest) party.getQuest();
|
||||
Vector<String> vector = quest.questInterface.getPartyQuestLogStatus(party);
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (String s : vector) {
|
||||
list.appendTag(new NBTTagString(s));
|
||||
}
|
||||
compound.setTag("QuestProgress", list);
|
||||
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isPartyCompleted(party)) {
|
||||
compound.setString("QuestCompleteWith", quest.completerNpc);
|
||||
}
|
||||
}
|
||||
|
||||
for(String name : party.getPlayerNames()){
|
||||
EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name);
|
||||
if(playerMP != null){
|
||||
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.CHAT, "\u00A7a", chatAlert, "!");
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP);
|
||||
if(playerData != null){
|
||||
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.PARTY_DATA, compound);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendQuestChat(Party party, String... chatAlerts) {
|
||||
if (party == null)
|
||||
return;
|
||||
|
||||
for (String name : party.getPlayerNames()) {
|
||||
EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name);
|
||||
if (playerMP != null) {
|
||||
Object[] args = new Object[2 + chatAlerts.length];
|
||||
args[0] = "\u00A7a";
|
||||
|
||||
System.arraycopy(chatAlerts, 0, args, 1, chatAlerts.length);
|
||||
args[args.length - 1] = "!"; // Add "!" at the end
|
||||
|
||||
// Pass args to Server.sendData using spread operator
|
||||
Server.sendData((EntityPlayerMP) playerMP, EnumPacketClient.CHAT, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkQuestCompletion(Party party, EnumQuestType type) {
|
||||
boolean bo = false;
|
||||
QuestData questData = party.getQuestData();
|
||||
if(questData == null)
|
||||
return bo;
|
||||
|
||||
if(questData.quest.type != type && type != null)
|
||||
return bo;
|
||||
|
||||
QuestInterface inter = questData.quest.questInterface;
|
||||
if(inter.isPartyCompleted(party)){
|
||||
if((!questData.isCompleted && questData.quest.completion == EnumQuestCompletion.Npc) || questData.quest.instantPartyComplete(party)){
|
||||
questData.isCompleted = true;
|
||||
if (questData.quest.completion == EnumQuestCompletion.Npc) {
|
||||
// EventHooks.onQuestFinished(player, data.quest);
|
||||
if(questData != null){
|
||||
if(questData.quest.type == type || type == null){
|
||||
QuestInterface inter = questData.quest.questInterface;
|
||||
if(inter.isPartyCompleted(party)){
|
||||
if((!questData.isCompleted && questData.quest.completion == EnumQuestCompletion.Npc) || questData.quest.instantPartyComplete(party)){
|
||||
questData.isCompleted = true;
|
||||
if (questData.quest.completion == EnumQuestCompletion.Npc) {
|
||||
EventHooks.onPartyFinished(party, questData.quest);
|
||||
PartyController.Instance().sendQuestChat(party, "party.turnedInChat");
|
||||
} else {
|
||||
party.setQuest(null);
|
||||
PartyController.Instance().sendQuestChat(party, "party.completeChat");
|
||||
}
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
}
|
||||
} else {
|
||||
questData.isCompleted = false;
|
||||
}
|
||||
bo = true;
|
||||
|
||||
party.setQuest(null);
|
||||
PartyController.Instance().pingPartyUpdate(party);
|
||||
PartyController.Instance().sendQuestChat(party, "party.completeChat");
|
||||
// if (this.trackedQuest != null && questData.quest.getId() == this.trackedQuest.getId()) {
|
||||
// NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player);
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
questData.isCompleted = false;
|
||||
}
|
||||
// if (this.trackedQuest != null && questData.quest.getId() == this.trackedQuest.getId()) {
|
||||
// NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) player);
|
||||
// }
|
||||
QuestItem.pickedUp = null;
|
||||
return bo;
|
||||
|
||||
QuestItem.pickedUpParty = null;
|
||||
QuestItem.pickedUpPlayer = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -332,6 +332,15 @@ public class PlayerDataController {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getPlayerUUIDFromName(String username) {
|
||||
for(String name : nameUUIDs.keySet()){
|
||||
if(name.equalsIgnoreCase(username))
|
||||
return nameUUIDs.get(name);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public PlayerData getDataFromUsername(String username){
|
||||
EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(username);
|
||||
PlayerData data = null;
|
||||
|
||||
@@ -18,22 +18,23 @@ import java.util.Vector;
|
||||
public class PlayerQuestController {
|
||||
|
||||
public static boolean hasActiveQuests(EntityPlayer player){
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerData.get(player).questData;
|
||||
return !data.activeQuests.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isQuestActive(EntityPlayer player, int quest){
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerData.get(player).questData;
|
||||
return data.activeQuests.containsKey(quest);
|
||||
}
|
||||
|
||||
public static boolean isQuestFinished(EntityPlayer player, int questid){
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerData.get(player).questData;
|
||||
return data.finishedQuests.containsKey(questid);
|
||||
}
|
||||
|
||||
public static void addActiveQuest(QuestData questData, EntityPlayer player) {
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
PlayerQuestData data = playerData.questData;
|
||||
if(canQuestBeAccepted(questData.quest, player)){
|
||||
if (EventHooks.onQuestStarted(player, questData.quest)) {
|
||||
return;
|
||||
@@ -44,6 +45,7 @@ public class PlayerQuestController {
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.MESSAGE, "quest.newquest", questData.quest.title);
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.CHAT, "quest.newquest", ": ", questData.quest.title);
|
||||
}
|
||||
playerData.updateClient = true;
|
||||
} else {
|
||||
long timeUntilRepeat = questData.quest.getTimeUntilRepeat(player);
|
||||
if (timeUntilRepeat > 0 && questData.quest.getIsRepeatable() && questData.quest.repeat != EnumQuestRepeat.NONE && questData.quest.repeat != EnumQuestRepeat.REPEATABLE) {
|
||||
@@ -55,7 +57,7 @@ public class PlayerQuestController {
|
||||
}
|
||||
|
||||
public static void setQuestFinished(Quest quest, EntityPlayer player){
|
||||
PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerData playerdata = PlayerData.get(player);
|
||||
PlayerQuestData data = playerdata.questData;
|
||||
QuestData questData = data.activeQuests.get(quest.id);
|
||||
data.activeQuests.remove(quest.id);
|
||||
@@ -74,10 +76,11 @@ public class PlayerQuestController {
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.MESSAGE, "quest.completed", questData.quest.title);
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.CHAT, "quest.completed", ": ", questData.quest.title);
|
||||
}
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
|
||||
public static void setQuestPartyFinished(Quest quest, EntityPlayer player, QuestData questData ){
|
||||
PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerData playerdata = PlayerData.get(player);
|
||||
PlayerQuestData data = playerdata.questData;
|
||||
data.activeQuests.remove(quest.id);
|
||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
|
||||
@@ -95,6 +98,7 @@ public class PlayerQuestController {
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.MESSAGE, "quest.completed", questData.quest.title);
|
||||
Server.sendData((EntityPlayerMP) player, EnumPacketClient.CHAT, "quest.completed", ": ", questData.quest.title);
|
||||
}
|
||||
playerdata.updateClient = true;
|
||||
}
|
||||
|
||||
public static boolean canQuestBeAccepted(Quest quest, EntityPlayer player){
|
||||
@@ -129,7 +133,7 @@ public class PlayerQuestController {
|
||||
public static Vector<Quest> getActiveQuests(EntityPlayer player)
|
||||
{
|
||||
Vector<Quest> quests = new Vector<Quest>();
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerData.get(player).questData;
|
||||
for(QuestData questdata: data.activeQuests.values()){
|
||||
if(questdata.quest == null)
|
||||
continue;
|
||||
|
||||
@@ -6,9 +6,12 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.handler.IQuestHandler;
|
||||
import noppes.npcs.api.handler.data.IQuest;
|
||||
import noppes.npcs.api.handler.data.IQuestCategory;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
import noppes.npcs.controllers.data.QuestCategory;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
@@ -18,10 +21,11 @@ import java.io.FileInputStream;
|
||||
import java.util.*;
|
||||
|
||||
public class QuestController implements IQuestHandler {
|
||||
public HashMap<Integer,QuestCategory> categoriesSync = new HashMap<Integer, QuestCategory>();
|
||||
public HashMap<Integer,QuestCategory> categories = new HashMap<Integer, QuestCategory>();
|
||||
public HashMap<Integer,Quest> quests = new HashMap<Integer, Quest>();
|
||||
|
||||
public static QuestController Instance;
|
||||
public static QuestController Instance = new QuestController();;
|
||||
|
||||
private int lastUsedCatID = 0;
|
||||
private int lastUsedQuestID = 0;
|
||||
@@ -142,6 +146,7 @@ public class QuestController implements IQuestHandler {
|
||||
for(int dia : cat.quests.keySet())
|
||||
quests.remove(dia);
|
||||
categories.remove(category);
|
||||
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.QUEST_CATEGORY, category);
|
||||
}
|
||||
|
||||
public void saveCategory(QuestCategory category){
|
||||
@@ -172,6 +177,7 @@ public class QuestController implements IQuestHandler {
|
||||
dir.mkdirs();
|
||||
}
|
||||
categories.put(category.id, category);
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
private boolean containsCategoryName(String name) {
|
||||
name = name.toLowerCase();
|
||||
@@ -215,10 +221,12 @@ public class QuestController implements IQuestHandler {
|
||||
File file2 = new File(dir, quest.id + ".json");
|
||||
|
||||
try {
|
||||
NBTJsonUtil.SaveFile(file, quest.writeToNBTPartial(new NBTTagCompound()));
|
||||
NBTTagCompound questCompound = quest.writeToNBTPartial(new NBTTagCompound());
|
||||
NBTJsonUtil.SaveFile(file, questCompound);
|
||||
if(file2.exists())
|
||||
file2.delete();
|
||||
file.renameTo(file2);
|
||||
Server.sendToAll(EnumPacketClient.SYNC_UPDATE, SyncType.QUEST, questCompound, category.id);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,11 @@ import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.handler.IRecipeHandler;
|
||||
import noppes.npcs.api.handler.data.IRecipe;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.data.RecipeCarpentry;
|
||||
import noppes.npcs.controllers.data.RecipesDefault;
|
||||
|
||||
@@ -26,9 +29,9 @@ public class RecipeController implements IRecipeHandler {
|
||||
|
||||
public static final int version = 1;
|
||||
public int nextId = 1;
|
||||
|
||||
|
||||
public static HashMap<Integer,RecipeCarpentry> syncRecipes = new HashMap<Integer, RecipeCarpentry>();
|
||||
|
||||
|
||||
public RecipeController(){
|
||||
Instance = this;
|
||||
}
|
||||
@@ -41,7 +44,7 @@ public class RecipeController implements IRecipeHandler {
|
||||
if(prevRecipes != null){
|
||||
list.removeAll(prevRecipes);
|
||||
}
|
||||
|
||||
|
||||
prevRecipes = new HashSet<RecipeCarpentry>();
|
||||
for(RecipeCarpentry recipe : globalRecipes.values()){
|
||||
if(recipe.isValid())
|
||||
@@ -49,7 +52,7 @@ public class RecipeController implements IRecipeHandler {
|
||||
}
|
||||
list.addAll(prevRecipes);
|
||||
}
|
||||
|
||||
|
||||
private void loadCategories(){
|
||||
File saveDir = CustomNpcs.getWorldSaveDirectory();
|
||||
try {
|
||||
@@ -139,7 +142,7 @@ public class RecipeController implements IRecipeHandler {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public RecipeCarpentry findMatchingRecipe(InventoryCrafting par1InventoryCrafting){
|
||||
for(RecipeCarpentry recipe : anvilRecipes.values()){
|
||||
if(recipe.isValid() && recipe.matches(par1InventoryCrafting,null))
|
||||
@@ -158,13 +161,13 @@ public class RecipeController implements IRecipeHandler {
|
||||
|
||||
public RecipeCarpentry saveRecipe(NBTTagCompound compound) throws IOException {
|
||||
RecipeCarpentry recipe = RecipeCarpentry.read(compound);
|
||||
|
||||
|
||||
RecipeCarpentry current = getRecipe(recipe.id);
|
||||
if(current != null && !current.name.equals(recipe.name)){
|
||||
while(containsRecipeName(recipe.name))
|
||||
recipe.name += "_";
|
||||
}
|
||||
|
||||
|
||||
if(recipe.id == -1){
|
||||
recipe.id = getUniqueId();
|
||||
while(containsRecipeName(recipe.name))
|
||||
@@ -201,8 +204,14 @@ public class RecipeController implements IRecipeHandler {
|
||||
|
||||
public RecipeCarpentry delete(int id) {
|
||||
RecipeCarpentry recipe = getRecipe(id);
|
||||
if(recipe == null)
|
||||
return null;
|
||||
globalRecipes.remove(recipe.id);
|
||||
anvilRecipes.remove(recipe.id);
|
||||
if(recipe.isGlobal)
|
||||
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.RECIPE_NORMAL, id);
|
||||
else
|
||||
Server.sendToAll(EnumPacketClient.SYNC_REMOVE, SyncType.RECIPE_CARPENTRY, id);
|
||||
saveCategories();
|
||||
reloadGlobalRecipes(globalRecipes);
|
||||
return recipe;
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package noppes.npcs.controllers;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.SyncType;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.items.ItemScripted;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SyncController {
|
||||
|
||||
public static void syncPlayer(EntityPlayerMP player){
|
||||
NBTTagList list = new NBTTagList();
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
for(Faction faction : FactionController.getInstance().factions.values()){
|
||||
NBTTagCompound factioNBT = new NBTTagCompound();
|
||||
faction.writeNBT(factioNBT);
|
||||
list.appendTag(factioNBT);
|
||||
if(list.tagCount() > 20){
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.FACTION, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.FACTION, compound);
|
||||
|
||||
for(QuestCategory category : QuestController.Instance.categories.values()){
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound());
|
||||
|
||||
for(DialogCategory category : DialogController.Instance.categories.values()){
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound());
|
||||
|
||||
list = new NBTTagList();
|
||||
for(RecipeCarpentry category : RecipeController.Instance.globalRecipes.values()){
|
||||
list.appendTag(category.writeNBT());
|
||||
if(list.tagCount() > 10){
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.RECIPE_NORMAL, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.RECIPE_NORMAL, compound);
|
||||
|
||||
list = new NBTTagList();
|
||||
for(RecipeCarpentry category : RecipeController.Instance.anvilRecipes.values()){
|
||||
list.appendTag(category.writeNBT());
|
||||
if(list.tagCount() > 10){
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_ADD, SyncType.RECIPE_CARPENTRY, compound);
|
||||
list = new NBTTagList();
|
||||
}
|
||||
}
|
||||
compound = new NBTTagCompound();
|
||||
compound.setTag("Data", list);
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.RECIPE_CARPENTRY, compound);
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
if(data != null)
|
||||
Server.sendData(player, EnumPacketClient.SYNC_END, SyncType.PLAYER_DATA, data.getNBT());
|
||||
}
|
||||
|
||||
public static void syncAllDialogs() {
|
||||
for(DialogCategory category : DialogController.Instance.categories.values()){
|
||||
Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.DIALOG_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.DIALOG_CATEGORY, new NBTTagCompound());
|
||||
}
|
||||
|
||||
public static void syncAllQuests() {
|
||||
for(QuestCategory category : QuestController.Instance.categories.values()){
|
||||
Server.sendToAll(EnumPacketClient.SYNC_ADD, SyncType.QUEST_CATEGORY, category.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
Server.sendToAll(EnumPacketClient.SYNC_END, SyncType.QUEST_CATEGORY, new NBTTagCompound());
|
||||
}
|
||||
|
||||
public static void clientSync(int synctype, NBTTagCompound compound, boolean syncEnd) {
|
||||
if(synctype == SyncType.FACTION){
|
||||
NBTTagList list = compound.getTagList("Data", 10);
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
Faction faction = new Faction();
|
||||
faction.readNBT(list.getCompoundTagAt(i));
|
||||
FactionController.getInstance().factionsSync.put(faction.id, faction);
|
||||
}
|
||||
if(syncEnd){
|
||||
FactionController.getInstance().factions = FactionController.getInstance().factionsSync;
|
||||
FactionController.getInstance().factionsSync = new HashMap<Integer, Faction>();
|
||||
}
|
||||
}
|
||||
else if(synctype == SyncType.QUEST_CATEGORY){
|
||||
if(!compound.hasNoTags()){
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.readNBT(compound);
|
||||
QuestController.Instance.categoriesSync.put(category.id, category);
|
||||
}
|
||||
if(syncEnd){
|
||||
HashMap<Integer,Quest> quests = new HashMap<Integer, Quest>();
|
||||
for(QuestCategory category : QuestController.Instance.categoriesSync.values()){
|
||||
for(Quest quest : category.quests.values()){
|
||||
quests.put(quest.id, quest);
|
||||
}
|
||||
}
|
||||
QuestController.Instance.categories = QuestController.Instance.categoriesSync;
|
||||
QuestController.Instance.quests = quests;
|
||||
QuestController.Instance.categoriesSync = new HashMap<Integer, QuestCategory>();
|
||||
}
|
||||
}
|
||||
else if(synctype == SyncType.DIALOG_CATEGORY){
|
||||
if(!compound.hasNoTags()){
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readNBT(compound);
|
||||
DialogController.Instance.categoriesSync.put(category.id, category);
|
||||
}
|
||||
if(syncEnd){
|
||||
HashMap<Integer,Dialog> dialogs = new HashMap<Integer, Dialog>();
|
||||
for(DialogCategory category : DialogController.Instance.categoriesSync.values()){
|
||||
for(Dialog dialog : category.dialogs.values()){
|
||||
dialogs.put(dialog.id, dialog);
|
||||
}
|
||||
}
|
||||
DialogController.Instance.categories = DialogController.Instance.categoriesSync;
|
||||
DialogController.Instance.dialogs = dialogs;
|
||||
DialogController.Instance.categoriesSync = new HashMap<Integer, DialogCategory>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clientSyncUpdate(int synctype, NBTTagCompound compound, ByteBuf buffer) {
|
||||
if(synctype == SyncType.FACTION){
|
||||
Faction faction = new Faction();
|
||||
faction.readNBT(compound);
|
||||
FactionController.getInstance().factions.put(faction.id, faction);
|
||||
}
|
||||
else if(synctype == SyncType.DIALOG){
|
||||
DialogCategory category = DialogController.Instance.categories.get(buffer.readInt());
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.category = category;
|
||||
dialog.readNBT(compound);
|
||||
DialogController.Instance.dialogs.put(dialog.id, dialog);
|
||||
category.dialogs.put(dialog.id, dialog);
|
||||
}
|
||||
else if(synctype == SyncType.DIALOG_CATEGORY){
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readNBT(compound);
|
||||
DialogController.Instance.categories.put(category.id, category);
|
||||
}
|
||||
else if(synctype == SyncType.QUEST){
|
||||
QuestCategory category = QuestController.Instance.categories.get(buffer.readInt());
|
||||
Quest quest = new Quest();
|
||||
quest.category = category;
|
||||
quest.readNBT(compound);
|
||||
QuestController.Instance.quests.put(quest.id, quest);
|
||||
category.quests.put(quest.id, quest);
|
||||
}
|
||||
else if(synctype == SyncType.QUEST_CATEGORY){
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.readNBT(compound);
|
||||
QuestController.Instance.categories.put(category.id, category);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clientSyncRemove(int synctype, int id) {
|
||||
if(synctype == SyncType.FACTION){
|
||||
FactionController.getInstance().factions.remove(id);
|
||||
}
|
||||
else if(synctype == SyncType.DIALOG){
|
||||
Dialog dialog = DialogController.Instance.dialogs.remove(id);
|
||||
if(dialog != null) {
|
||||
dialog.category.dialogs.remove(id);
|
||||
}
|
||||
}
|
||||
else if(synctype == SyncType.DIALOG_CATEGORY){
|
||||
DialogCategory category = DialogController.Instance.categories.remove(id);
|
||||
if(category != null) {
|
||||
DialogController.Instance.dialogs.keySet().removeAll(category.dialogs.keySet());
|
||||
}
|
||||
}
|
||||
else if(synctype == SyncType.QUEST){
|
||||
Quest quest = QuestController.Instance.quests.remove(id);
|
||||
if(quest != null) {
|
||||
quest.category.quests.remove(id);
|
||||
}
|
||||
}
|
||||
else if(synctype == SyncType.QUEST_CATEGORY){
|
||||
QuestCategory category = QuestController.Instance.categories.remove(id);
|
||||
if(category != null) {
|
||||
QuestController.Instance.quests.keySet().removeAll(category.quests.keySet());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.handler.data.IAvailability;
|
||||
import noppes.npcs.constants.*;
|
||||
import noppes.npcs.controllers.FactionController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.PlayerQuestController;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
|
||||
@@ -24,7 +23,7 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
public int dialog2Id = -1;
|
||||
public int dialog3Id = -1;
|
||||
public int dialog4Id = -1;
|
||||
|
||||
|
||||
public EnumAvailabilityQuest questAvailable = EnumAvailabilityQuest.Always;
|
||||
public EnumAvailabilityQuest quest2Available = EnumAvailabilityQuest.Always;
|
||||
public EnumAvailabilityQuest quest3Available = EnumAvailabilityQuest.Always;
|
||||
@@ -35,10 +34,10 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
public int quest4Id = -1;
|
||||
|
||||
public EnumDayTime daytime = EnumDayTime.Always;
|
||||
|
||||
|
||||
public int factionId = -1;
|
||||
public int faction2Id = -1;
|
||||
|
||||
|
||||
public EnumAvailabilityFactionType factionAvailable = EnumAvailabilityFactionType.Always;
|
||||
public EnumAvailabilityFactionType faction2Available = EnumAvailabilityFactionType.Always;
|
||||
|
||||
@@ -46,8 +45,8 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
public EnumAvailabilityFaction faction2Stance = EnumAvailabilityFaction.Friendly;
|
||||
|
||||
public int minPlayerLevel = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
version = compound.getInteger("ModRev");
|
||||
@@ -57,22 +56,22 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
dialog2Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog2")];
|
||||
dialog3Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog3")];
|
||||
dialog4Available = EnumAvailabilityDialog.values()[compound.getInteger("AvailabilityDialog4")];
|
||||
|
||||
|
||||
dialogId = compound.getInteger("AvailabilityDialogId");
|
||||
dialog2Id = compound.getInteger("AvailabilityDialog2Id");
|
||||
dialog3Id = compound.getInteger("AvailabilityDialog3Id");
|
||||
dialog4Id = compound.getInteger("AvailabilityDialog4Id");
|
||||
|
||||
|
||||
questAvailable = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest")];
|
||||
quest2Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest2")];
|
||||
quest3Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest3")];
|
||||
quest4Available = EnumAvailabilityQuest.values()[compound.getInteger("AvailabilityQuest4")];
|
||||
|
||||
|
||||
questId = compound.getInteger("AvailabilityQuestId");
|
||||
quest2Id = compound.getInteger("AvailabilityQuest2Id");
|
||||
quest3Id = compound.getInteger("AvailabilityQuest3Id");
|
||||
quest4Id = compound.getInteger("AvailabilityQuest4Id");
|
||||
|
||||
|
||||
setFactionAvailability(compound.getInteger("AvailabilityFaction"));
|
||||
setFactionAvailabilityStance(compound.getInteger("AvailabilityFactionStance"));
|
||||
|
||||
@@ -81,43 +80,43 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
|
||||
factionId = compound.getInteger("AvailabilityFactionId");
|
||||
faction2Id = compound.getInteger("AvailabilityFaction2Id");
|
||||
|
||||
|
||||
daytime = EnumDayTime.values()[compound.getInteger("AvailabilityDayTime")];
|
||||
|
||||
minPlayerLevel = compound.getInteger("AvailabilityMinPlayerLevel");
|
||||
}
|
||||
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound){
|
||||
compound.setInteger("ModRev", version);
|
||||
|
||||
|
||||
compound.setInteger("AvailabilityDialog", dialogAvailable.ordinal());
|
||||
compound.setInteger("AvailabilityDialog2", dialog2Available.ordinal());
|
||||
compound.setInteger("AvailabilityDialog3", dialog3Available.ordinal());
|
||||
compound.setInteger("AvailabilityDialog4", dialog4Available.ordinal());
|
||||
|
||||
|
||||
compound.setInteger("AvailabilityDialogId", dialogId);
|
||||
compound.setInteger("AvailabilityDialog2Id", dialog2Id);
|
||||
compound.setInteger("AvailabilityDialog3Id", dialog3Id);
|
||||
compound.setInteger("AvailabilityDialog4Id", dialog4Id);
|
||||
|
||||
|
||||
compound.setInteger("AvailabilityQuest", questAvailable.ordinal());
|
||||
compound.setInteger("AvailabilityQuest2", quest2Available.ordinal());
|
||||
compound.setInteger("AvailabilityQuest3", quest3Available.ordinal());
|
||||
compound.setInteger("AvailabilityQuest4", quest4Available.ordinal());
|
||||
|
||||
|
||||
compound.setInteger("AvailabilityQuestId", questId);
|
||||
compound.setInteger("AvailabilityQuest2Id", quest2Id);
|
||||
compound.setInteger("AvailabilityQuest3Id", quest3Id);
|
||||
compound.setInteger("AvailabilityQuest4Id", quest4Id);
|
||||
|
||||
|
||||
compound.setInteger("AvailabilityFaction", factionAvailable.ordinal());
|
||||
compound.setInteger("AvailabilityFactionStance", factionStance.ordinal());
|
||||
|
||||
|
||||
compound.setInteger("AvailabilityFactionId", factionId);
|
||||
|
||||
compound.setInteger("AvailabilityFaction2", faction2Available.ordinal());
|
||||
compound.setInteger("AvailabilityFaction2Stance", faction2Stance.ordinal());
|
||||
|
||||
|
||||
compound.setInteger("AvailabilityFaction2Id", faction2Id);
|
||||
|
||||
compound.setInteger("AvailabilityDayTime", daytime.ordinal());
|
||||
@@ -147,7 +146,7 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
if(time < 12000)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!dialogAvailable(dialogId, dialogAvailable, player))
|
||||
return false;
|
||||
if(!dialogAvailable(dialog2Id, dialog2Available, player))
|
||||
@@ -170,24 +169,24 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
return false;
|
||||
if(!factionAvailable(faction2Id, faction2Stance, faction2Available, player))
|
||||
return false;
|
||||
|
||||
|
||||
if(player.experienceLevel < minPlayerLevel)
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean factionAvailable(int id, EnumAvailabilityFaction stance, EnumAvailabilityFactionType available, EntityPlayer player) {
|
||||
if(available == EnumAvailabilityFactionType.Always)
|
||||
return true;
|
||||
|
||||
|
||||
Faction faction = FactionController.getInstance().get(id);
|
||||
if(faction == null)
|
||||
return true;
|
||||
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
|
||||
PlayerFactionData data = PlayerData.get(player).factionData;
|
||||
int points = data.getFactionPoints(id);
|
||||
|
||||
|
||||
EnumAvailabilityFaction current = EnumAvailabilityFaction.Neutral;
|
||||
if(faction.neutralPoints >= points)
|
||||
current = EnumAvailabilityFaction.Hostile;
|
||||
@@ -200,21 +199,26 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
if(available == EnumAvailabilityFactionType.IsNot && stance != current){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean dialogAvailable(int id, EnumAvailabilityDialog en, EntityPlayer player){
|
||||
if(player == null)
|
||||
return false;
|
||||
if(en == EnumAvailabilityDialog.Always)
|
||||
return true;
|
||||
boolean hasRead = PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.contains(id);
|
||||
PlayerData data = PlayerData.get(player);
|
||||
if(data == null)
|
||||
return false;
|
||||
boolean hasRead = data.dialogData.dialogsRead.contains(id);
|
||||
if(hasRead && en == EnumAvailabilityDialog.After)
|
||||
return true;
|
||||
else if(!hasRead && en == EnumAvailabilityDialog.Before)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean questAvailable(int id, EnumAvailabilityQuest en, EntityPlayer player){
|
||||
if(en == EnumAvailabilityQuest.Always)
|
||||
return true;
|
||||
|
||||
@@ -9,29 +9,23 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.handler.IPlayerQuestData;
|
||||
import noppes.npcs.api.handler.data.IParty;
|
||||
import noppes.npcs.api.handler.data.IQuest;
|
||||
import noppes.npcs.constants.EnumPartyObjectives;
|
||||
import noppes.npcs.constants.EnumPartyRequirements;
|
||||
import noppes.npcs.constants.EnumQuestCompletion;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.quests.QuestInterface;
|
||||
import noppes.npcs.quests.QuestItem;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
public class Party {
|
||||
public class Party implements IParty {
|
||||
private final UUID partyUUID;
|
||||
private UUID partyLeader;
|
||||
private QuestData questData;
|
||||
@@ -61,10 +55,17 @@ public class Party {
|
||||
return this.partyUUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPartyUUIDString() {
|
||||
return this.partyUUID.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsLocked() {
|
||||
return this.partyLocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuest(IQuest quest) {
|
||||
if (quest != null) {
|
||||
this.currentQuestID = quest.getId();
|
||||
@@ -78,6 +79,7 @@ public class Party {
|
||||
this.partyLocked = quest != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IQuest getQuest() {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
return QuestController.Instance.get(this.currentQuestID);
|
||||
@@ -90,15 +92,28 @@ public class Party {
|
||||
return questData;
|
||||
}
|
||||
|
||||
public EnumPartyObjectives getObjectiveRequirement() {
|
||||
if(getQuestData() != null){
|
||||
if(getQuestData().quest != null){
|
||||
return getQuestData().quest.partyOptions.objectiveRequirement;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentQuestID() {
|
||||
return currentQuestID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentQuestName() {
|
||||
return this.currentQuestName;
|
||||
}
|
||||
|
||||
public boolean addPlayer(EntityPlayer player) {
|
||||
if (player == null) return false;
|
||||
|
||||
if(partyMembers.containsKey(player.getUniqueID())){
|
||||
return false;
|
||||
}
|
||||
@@ -134,18 +149,57 @@ public class Party {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removePlayer(UUID uuid) {
|
||||
if (uuid == null) return false;
|
||||
if(partyMembers.containsKey(uuid)){
|
||||
partyMembers.remove(uuid);
|
||||
partyOrder.remove(uuid);
|
||||
if(uuid.equals(partyLeader)){
|
||||
if(!partyMembers.isEmpty()){
|
||||
partyLeader = partyOrder.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
playerData.partyUUID = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPlayer(String playerName) {
|
||||
return playerName != null && this.addPlayer(NoppesUtilServer.getPlayerByName(playerName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePlayer(String playerName) {
|
||||
return playerName != null && this.removePlayer(NoppesUtilServer.getPlayerByName(playerName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPlayer(IPlayer player) {
|
||||
return player != null && this.addPlayer((EntityPlayerMP)player.getMCEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removePlayer(IPlayer player) {
|
||||
return player != null && this.removePlayer((EntityPlayerMP)player.getMCEntity());
|
||||
}
|
||||
|
||||
public boolean hasPlayer(EntityPlayer player) {
|
||||
return partyMembers.containsKey(player.getUniqueID());
|
||||
}
|
||||
|
||||
public boolean hasPlayer(UUID uuid) {
|
||||
return partyMembers.containsKey(uuid);
|
||||
@Override
|
||||
public boolean hasPlayer(IPlayer player) {
|
||||
if(player == null)
|
||||
return false;
|
||||
EntityPlayer entityPlayer = (EntityPlayer)player.getMCEntity();
|
||||
return partyMembers.containsKey(entityPlayer.getUniqueID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlayer(String playerName) {
|
||||
UUID uuid = getUUID(playerName);
|
||||
if (uuid == null){
|
||||
@@ -158,6 +212,7 @@ public class Party {
|
||||
return NoppesUtilServer.getPlayer(this.partyLeader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPartyLeaderName() {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
|
||||
return this.partyLeaderName;
|
||||
@@ -195,6 +250,11 @@ public class Party {
|
||||
return this.getPlayerNames(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPlayerNamesList() {
|
||||
return new ArrayList<>(this.getPlayerNames(false));
|
||||
}
|
||||
|
||||
public Collection<String> getPlayerNames(boolean lowercase) {
|
||||
Collection<String> names = this.partyMembers.values();
|
||||
if (!lowercase) {
|
||||
@@ -212,8 +272,9 @@ public class Party {
|
||||
return this.partyMembers.keySet();
|
||||
}
|
||||
|
||||
// To Be Called during Set Quest or Quest Switch
|
||||
public boolean validateQuest(int questID) {
|
||||
// Called when Set Quest is Called
|
||||
@Override
|
||||
public boolean validateQuest(int questID, boolean sendLeaderMessages){
|
||||
IQuest quest = QuestController.Instance.get(questID);
|
||||
if (quest == null) {
|
||||
return false;
|
||||
@@ -226,17 +287,17 @@ public class Party {
|
||||
|
||||
int partyReq = quest.getPartyOptions().getPartyRequirements();
|
||||
if (partyReq < 0 || partyReq >= EnumPartyRequirements.values().length) {
|
||||
sendInfoMessage(leader, "Error in quest party requirements");
|
||||
sendInfoMessage(leader, "Error in quest party requirements", sendLeaderMessages);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (partyMembers.size() < quest.getPartyOptions().getMinPartySize()) {
|
||||
sendInfoMessage(leader, String.format("Party too small. Min %d members", quest.getPartyOptions().getMaxPartySize()));
|
||||
sendInfoMessage(leader, String.format("Party too small. Min %d members", quest.getPartyOptions().getMinPartySize()), sendLeaderMessages);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (partyMembers.size() > quest.getPartyOptions().getMaxPartySize()) {
|
||||
sendInfoMessage(leader, String.format("Party too large. Max %d members", quest.getPartyOptions().getMaxPartySize()));
|
||||
sendInfoMessage(leader, String.format("Party too large. Max %d members", quest.getPartyOptions().getMaxPartySize()), sendLeaderMessages);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -244,12 +305,12 @@ public class Party {
|
||||
if (partyRequirements == EnumPartyRequirements.Leader) {
|
||||
boolean leaderBool = isValidLeaderQuest(leader, questID);
|
||||
if(!leaderBool){
|
||||
sendInfoMessage(leader, "\u00A7cYou are invalid for this quest");
|
||||
sendInfoMessage(leader, "\u00A7cYou are invalid for this quest", sendLeaderMessages);
|
||||
}
|
||||
return leaderBool;
|
||||
}
|
||||
|
||||
return arePlayersValid(leader, partyRequirements, quest);
|
||||
return arePlayersValid(leader, partyRequirements, quest, sendLeaderMessages);
|
||||
}
|
||||
|
||||
private boolean isValidLeaderQuest(EntityPlayer leader, int questID) {
|
||||
@@ -257,7 +318,7 @@ public class Party {
|
||||
return questData != null && questData.hasActiveQuest(questID);
|
||||
}
|
||||
|
||||
private boolean arePlayersValid(EntityPlayer leader, EnumPartyRequirements requirements, IQuest quest) {
|
||||
private boolean arePlayersValid(EntityPlayer leader, EnumPartyRequirements requirements, IQuest quest, boolean sendLeaderMessages) {
|
||||
boolean allowQuest = true;
|
||||
for (UUID playerUUID : partyMembers.keySet()) {
|
||||
EntityPlayer player = PlayerDataController.getPlayerFromUUID(playerUUID);
|
||||
@@ -271,36 +332,41 @@ public class Party {
|
||||
|
||||
if (requirements == EnumPartyRequirements.All && !hasActive) {
|
||||
allowQuest = false;
|
||||
sendInfoMessage(leader, String.format("%s does not have quest active", player.getCommandSenderName()));
|
||||
sendInfoMessage(leader, String.format("%s does not have quest active", player.getCommandSenderName()), sendLeaderMessages);
|
||||
} else if (requirements == EnumPartyRequirements.Valid && !hasActive && !hasFinished) {
|
||||
allowQuest = false;
|
||||
sendInfoMessage(leader, String.format("%s does not have the quest active or finished", player.getCommandSenderName()));
|
||||
sendInfoMessage(leader, String.format("%s does not have the quest active or finished", player.getCommandSenderName()), sendLeaderMessages);
|
||||
}
|
||||
} else {
|
||||
allowQuest = false;
|
||||
sendInfoMessage(leader, String.format("%s has no quest data", player.getCommandSenderName()));
|
||||
sendInfoMessage(leader, String.format("%s has no quest data", player.getCommandSenderName()), sendLeaderMessages);
|
||||
}
|
||||
} else {
|
||||
allowQuest = false;
|
||||
sendInfoMessage(leader, String.format("%s has no player data", player.getCommandSenderName()));
|
||||
sendInfoMessage(leader, String.format("%s has no player data", player.getCommandSenderName()), sendLeaderMessages);
|
||||
}
|
||||
} else {
|
||||
allowQuest = false;
|
||||
String playerName = partyMembers.get(playerUUID);
|
||||
sendInfoMessage(leader, String.format("%s was not found", playerName));
|
||||
sendInfoMessage(leader, String.format("%s was not found", playerName), sendLeaderMessages);
|
||||
}
|
||||
}
|
||||
return allowQuest;
|
||||
}
|
||||
|
||||
private void sendInfoMessage(EntityPlayer player, String message) {
|
||||
private void sendInfoMessage(EntityPlayer player, String message, boolean send) {
|
||||
if(!send)
|
||||
return;
|
||||
|
||||
player.addChatMessage(new ChatComponentText(String.format("\u00A7c%s", message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleFriendlyFire() {
|
||||
this.friendlyFire = !this.friendlyFire;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean friendlyFire() {
|
||||
return this.friendlyFire;
|
||||
}
|
||||
@@ -374,6 +440,20 @@ public class Party {
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateQuestObjectiveData(){
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
PartyController.Instance().pingPartyQuestObjectiveUpdate(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePartyData(){
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
PartyController.Instance().pingPartyUpdate(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void readClientNBT(NBTTagCompound compound) {
|
||||
this.currentQuestID = compound.getInteger("PartyQuestID");
|
||||
this.currentQuestName = compound.getString("PartyQuestName");
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.api.handler.data.IPartyOptions;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumPartyExchange;
|
||||
import noppes.npcs.constants.EnumPartyObjectives;
|
||||
import noppes.npcs.constants.EnumPartyRequirements;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class PartyOptions implements IPartyOptions {
|
||||
public boolean allowParty = false;
|
||||
@@ -229,4 +235,18 @@ public class PartyOptions implements IPartyOptions {
|
||||
|
||||
maxPartySize = newSize;
|
||||
}
|
||||
|
||||
public Vector<String> getPartyOptionsList() {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
if(onlyParty){
|
||||
vec.add("party.only" + ":" + "gui.yes");
|
||||
}
|
||||
vec.add("party.partyRequirements" + ":" + partyRequirements.name);
|
||||
vec.add("quest.objectives" + ":" + objectiveRequirement.name);
|
||||
vec.add("party.completeFor" + ":" + completeFor.name);
|
||||
vec.add("quest.reward" + ":" + rewardControl.name);
|
||||
vec.add("party.minPartySize" + ":" + minPartySize);
|
||||
vec.add("party.maxPartySize" + ":" + maxPartySize);
|
||||
return vec;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.PacketHandlerServer;
|
||||
import noppes.npcs.Server;
|
||||
@@ -62,6 +63,8 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
public boolean isGUIOpen = false;
|
||||
public boolean hadInteract = true;
|
||||
|
||||
public boolean updateClient = false;
|
||||
|
||||
public ScreenSize screenSize = new ScreenSize(-1,-1);
|
||||
|
||||
public void onLogin() {
|
||||
@@ -69,7 +72,6 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
}
|
||||
|
||||
public void onLogout() {
|
||||
this.partyUUID = null;
|
||||
this.partyInvites.clear();
|
||||
}
|
||||
|
||||
@@ -144,6 +146,15 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
return compound;
|
||||
}
|
||||
|
||||
public NBTTagCompound getSyncNBT(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
dialogData.saveNBTData(compound);
|
||||
questData.saveNBTData(compound);
|
||||
factionData.saveNBTData(compound);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Entity entity, World world) {
|
||||
|
||||
@@ -314,4 +325,11 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
}
|
||||
setNBT(data);
|
||||
}
|
||||
|
||||
public static PlayerData get(EntityPlayer player) {
|
||||
if(player.worldObj.isRemote)
|
||||
return CustomNpcs.proxy.getPlayerData(player);
|
||||
|
||||
return PlayerDataController.Instance.getPlayerData(player);
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class PlayerItemGiverData implements IPlayerItemGiverData {
|
||||
public boolean hasInteractedBefore(JobItemGiver jobItemGiver) {
|
||||
return itemgivers.containsKey(jobItemGiver.itemGiverId);
|
||||
}
|
||||
|
||||
|
||||
public long getTime(JobItemGiver jobItemGiver){
|
||||
return itemgivers.get(jobItemGiver.itemGiverId);
|
||||
}
|
||||
@@ -59,17 +59,4 @@ public class PlayerItemGiverData implements IPlayerItemGiverData {
|
||||
public boolean hasInteractedBefore(IJobItemGiver jobItemGiver) {
|
||||
return itemgivers.containsKey(((JobItemGiver) jobItemGiver).itemGiverId);
|
||||
}
|
||||
|
||||
public IJobItemGiver[] getItemGivers() {
|
||||
ArrayList<IJobItemGiver> list = new ArrayList<>();
|
||||
for (JobItemGiver jobItemGiver : GlobalDataController.Instance.itemGivers.values()) {
|
||||
if (jobItemGiver.npc != null) {
|
||||
list.add(new ScriptJobItemGiver(jobItemGiver.npc));
|
||||
} else {
|
||||
list.add(new ScriptJobItemGiver(jobItemGiver));
|
||||
}
|
||||
}
|
||||
|
||||
return list.toArray(new IJobItemGiver[0]);
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,23 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Party getPartyQuestCompletion(EntityPlayer player,EntityNPCInterface npc) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if(playerData != null){
|
||||
Party party = playerData.getPlayerParty();
|
||||
if(party != null){
|
||||
QuestData data = party.getQuestData();
|
||||
if(data != null){
|
||||
Quest quest = data.quest;
|
||||
if(quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isPartyCompleted(party)){
|
||||
return party;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean checkQuestCompletion(PlayerData playerData,EnumQuestType type) {
|
||||
boolean bo = false;
|
||||
EntityPlayer player = playerData.player;
|
||||
@@ -135,6 +152,9 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty)
|
||||
continue;
|
||||
|
||||
QuestInterface inter = data.quest.questInterface;
|
||||
if(inter.isCompleted(playerData)){
|
||||
if((!data.isCompleted && data.quest.completion == EnumQuestCompletion.Npc) || data.quest.instantComplete(player,data)){
|
||||
@@ -184,6 +204,8 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
activeQuests.put(id, questdata);
|
||||
Server.sendData((EntityPlayerMP)parent.player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)parent.player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
|
||||
parent.updateClient = true;
|
||||
}
|
||||
|
||||
public void finishQuest(int id) {
|
||||
@@ -195,6 +217,8 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
finishedQuests.put(quest.id, System.currentTimeMillis());
|
||||
else
|
||||
finishedQuests.put(quest.id, parent.player.worldObj.getTotalWorldTime());
|
||||
|
||||
parent.updateClient = true;
|
||||
}
|
||||
|
||||
public void stopQuest(int id) {
|
||||
@@ -202,6 +226,7 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
if (quest == null)
|
||||
return;
|
||||
activeQuests.remove(id);
|
||||
parent.updateClient = true;
|
||||
}
|
||||
|
||||
public void removeQuest(int id) {
|
||||
@@ -210,6 +235,7 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
return;
|
||||
activeQuests.remove(id);
|
||||
finishedQuests.remove(id);
|
||||
parent.updateClient = true;
|
||||
}
|
||||
|
||||
public boolean hasFinishedQuest(int id){
|
||||
|
||||
@@ -99,7 +99,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
public long totalTicksAlive = 0;
|
||||
private int taskCount = 1;
|
||||
public int lastInteract = 0;
|
||||
public int itemGiverId = 0;
|
||||
public boolean isDrawn = false;
|
||||
|
||||
public Faction faction; //should only be used server side
|
||||
@@ -425,7 +424,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
Dialog dialog = getDialog(player);
|
||||
PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
QuestData data = playerdata.getQuestCompletion(player, this);
|
||||
if (data != null){
|
||||
Party partyCompleted = playerdata.getPartyQuestCompletion(player, this);
|
||||
if(partyCompleted != null){
|
||||
NoppesUtilPlayer.questPartyCompletion(partyCompleted);
|
||||
}
|
||||
else if (data != null){
|
||||
NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.QUEST_COMPLETION, data.quest.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
@@ -1016,11 +1019,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
script.readFromNBT(compound);
|
||||
script.readEventsFromNBT(compound);
|
||||
timers.readFromNBT(compound);
|
||||
if (compound.hasKey("ItemGiverId")) {
|
||||
itemGiverId = compound.getInteger("ItemGiverId");
|
||||
} else {
|
||||
itemGiverId = -1;
|
||||
}
|
||||
advanced.readToNBT(compound);
|
||||
if (advanced.role != EnumRoleType.None && roleInterface != null)
|
||||
roleInterface.readFromNBT(compound);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ItemNpcScripter extends Item{
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player){
|
||||
if(!world.isRemote)
|
||||
return itemStack;
|
||||
if(!ConfigScript.isScriptDev(player) && !CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.TOOL_SCRIPTER)){
|
||||
if(!ConfigScript.canScript(player, CustomNpcsPermissions.TOOL_SCRIPTER)){
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
} else {
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptEvent, player);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ItemScripted extends Item implements ItemRenderInterface {
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if(player.isSneaking() && player.capabilities.isCreativeMode) {
|
||||
if(!ConfigScript.isScriptDev(player) && !CustomNpcsPermissions.Instance.hasPermission(player, CustomNpcsPermissions.TOOL_SCRIPTED_ITEM)){
|
||||
if(!ConfigScript.canScript(player, CustomNpcsPermissions.TOOL_SCRIPTED_ITEM)){
|
||||
player.addChatMessage(new ChatComponentTranslation("availability.permission"));
|
||||
} else {
|
||||
CustomNpcs.proxy.openGui(0, 0, 0, EnumGuiType.ScriptItem, player);
|
||||
|
||||
@@ -9,8 +9,10 @@ import noppes.npcs.Server;
|
||||
import noppes.npcs.api.handler.data.IQuestDialog;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPartyObjectives;
|
||||
import noppes.npcs.constants.EnumQuestType;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
@@ -66,6 +68,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
return vec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IQuestObjective[] getObjectives(EntityPlayer player) {
|
||||
List<IQuestObjective> list = new ArrayList();
|
||||
|
||||
@@ -100,12 +103,172 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
for(int dialogId : dialogs.values()){
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(dialogId);
|
||||
if(dialog == null)
|
||||
continue;
|
||||
if(party == null)
|
||||
return vec;
|
||||
|
||||
ArrayList<String> unread = new ArrayList<>();
|
||||
if(party.getQuestData() == null)
|
||||
return vec;
|
||||
|
||||
if(party.getQuestData().quest == null)
|
||||
return vec;
|
||||
|
||||
EnumPartyObjectives objectives = party.getQuestData().quest.partyOptions.objectiveRequirement;
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
for(int dialogId : dialogs.values()){
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(dialogId);
|
||||
if(dialog == null)
|
||||
continue;
|
||||
|
||||
ArrayList<String> unread = new ArrayList<>();
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData playerData;
|
||||
if(player != null){
|
||||
playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
}
|
||||
else {
|
||||
playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
}
|
||||
if(playerData != null){
|
||||
if(!playerData.dialogData.dialogsRead.contains(dialogId))
|
||||
unread.add(playerData.playername);
|
||||
}
|
||||
}
|
||||
|
||||
String title = dialog.title;
|
||||
if(!unread.isEmpty()){
|
||||
title += " (unread)";
|
||||
}
|
||||
else {
|
||||
title += " (read)";
|
||||
}
|
||||
vec.add(title);
|
||||
|
||||
if (!unread.isEmpty()) {
|
||||
StringBuilder unreaders = new StringBuilder();
|
||||
for (String name : unread) {
|
||||
if (unreaders.length() > 0) {
|
||||
unreaders.append(", ");
|
||||
}
|
||||
unreaders.append(name);
|
||||
}
|
||||
vec.add(unreaders.toString());
|
||||
}
|
||||
}
|
||||
return vec;
|
||||
} else if(objectives == EnumPartyObjectives.Leader){
|
||||
EntityPlayer leader = NoppesUtilServer.getPlayer(party.getLeaderUUID());
|
||||
PlayerData playerData;
|
||||
if(leader != null){
|
||||
playerData = PlayerDataController.Instance.getPlayerData(leader);
|
||||
}
|
||||
else {
|
||||
playerData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString());
|
||||
}
|
||||
if(playerData == null)
|
||||
return vec;
|
||||
for(int dialogId : dialogs.values()){
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(dialogId);
|
||||
if(dialog == null)
|
||||
continue;
|
||||
String title = dialog.title;
|
||||
if(playerData.dialogData.dialogsRead.contains(dialogId))
|
||||
title += " (read)";
|
||||
else
|
||||
title += " (unread)";
|
||||
vec.add(title);
|
||||
}
|
||||
return vec;
|
||||
} else {
|
||||
Set<Integer> readValues = new HashSet<>();
|
||||
for(int dialogId : dialogs.values()){
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(dialogId);
|
||||
if(dialog == null)
|
||||
continue;
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData sharedData;
|
||||
if(player != null){
|
||||
sharedData = PlayerDataController.Instance.getPlayerData(player);
|
||||
}
|
||||
else {
|
||||
sharedData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
}
|
||||
if(sharedData != null){
|
||||
if(sharedData.dialogData.dialogsRead.contains(dialogId))
|
||||
readValues.add(dialogId);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int dialogId : dialogs.values()){
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(dialogId);
|
||||
if(dialog == null)
|
||||
continue;
|
||||
String title = dialog.title;
|
||||
if(readValues.contains(dialogId))
|
||||
title += " (read)";
|
||||
else
|
||||
title += " (unread)";
|
||||
vec.add(title);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPartyCompleted(Party party) {
|
||||
if(party == null)
|
||||
return false;
|
||||
|
||||
if(party.getQuestData() == null)
|
||||
return false;
|
||||
|
||||
if(party.getQuestData().quest == null)
|
||||
return false;
|
||||
|
||||
EnumPartyObjectives objectives = party.getQuestData().quest.partyOptions.objectiveRequirement;
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
List<String> incomplete = new ArrayList<>();
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer individual = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData individualData;
|
||||
if(individual != null){
|
||||
individualData = PlayerDataController.Instance.getPlayerData(individual);
|
||||
}
|
||||
else {
|
||||
individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
}
|
||||
if(individualData != null){
|
||||
for(int dialogId : dialogs.values()){
|
||||
if(!individualData.dialogData.dialogsRead.contains(dialogId)){
|
||||
incomplete.add(individualData.playername);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return incomplete.isEmpty();
|
||||
} else if(objectives == EnumPartyObjectives.Leader){
|
||||
EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID());
|
||||
PlayerData leaderData;
|
||||
if(leaderPlayer != null){
|
||||
leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer);
|
||||
}
|
||||
else {
|
||||
leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString());
|
||||
}
|
||||
if(leaderData != null){
|
||||
for(int dialogId : dialogs.values()){
|
||||
if(!leaderData.dialogData.dialogsRead.contains(dialogId)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
HashMap<Integer, Boolean> readValues = new HashMap<>();
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData playerData;
|
||||
@@ -116,57 +279,19 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
}
|
||||
if(playerData != null){
|
||||
if(!playerData.dialogData.dialogsRead.contains(dialogId))
|
||||
unread.add(playerData.playername);
|
||||
}
|
||||
}
|
||||
|
||||
String title = dialog.title;
|
||||
if(!unread.isEmpty()){
|
||||
title += " (unread)";
|
||||
}
|
||||
else {
|
||||
title += " (read)";
|
||||
}
|
||||
vec.add(title);
|
||||
|
||||
if(!unread.isEmpty()){
|
||||
StringBuilder unreaders = new StringBuilder("> ");
|
||||
for(String name : unread){
|
||||
unreaders.append(" ").append(name);
|
||||
}
|
||||
vec.add(unreaders.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPartyCompleted(Party party) {
|
||||
if(party == null)
|
||||
return false;
|
||||
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData playerData;
|
||||
if(player != null){
|
||||
playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
}
|
||||
else {
|
||||
playerData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
}
|
||||
if(playerData != null){
|
||||
for(int dialogId : dialogs.values()){
|
||||
if(!playerData.dialogData.dialogsRead.contains(dialogId)){
|
||||
return false;
|
||||
for(int dialogId : dialogs.values()){
|
||||
if(playerData.dialogData.dialogsRead.contains(dialogId)){
|
||||
readValues.put(dialogId, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
for(boolean result : readValues.values()){
|
||||
if(!result)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class QuestDialogObjective implements IQuestObjective {
|
||||
@@ -195,20 +320,78 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
|
||||
public void setProgress(int progress) {
|
||||
if (progress >= 0 && progress <= 1) {
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
if (progress == 0 && completed) {
|
||||
data.dialogData.dialogsRead.remove(this.dialog.id);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
||||
data.save();
|
||||
}
|
||||
if(player != null){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
boolean completed = data.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
if (progress == 0 && completed) {
|
||||
data.dialogData.dialogsRead.remove(this.dialog.id);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
||||
data.updateClient = true;
|
||||
data.save();
|
||||
}
|
||||
|
||||
if (progress == 1 && !completed) {
|
||||
data.dialogData.dialogsRead.add(this.dialog.id);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
||||
data.save();
|
||||
}
|
||||
if (progress == 1 && !completed) {
|
||||
data.dialogData.dialogsRead.add(this.dialog.id);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[1]);
|
||||
data.updateClient = true;
|
||||
data.save();
|
||||
}
|
||||
} else if (party != null){
|
||||
if(party.getObjectiveRequirement() != null){
|
||||
EnumPartyObjectives objectives = party.getObjectiveRequirement();
|
||||
if(objectives == EnumPartyObjectives.Leader){
|
||||
EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID());
|
||||
PlayerData leaderData;
|
||||
if(leaderPlayer != null){
|
||||
leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer);
|
||||
}
|
||||
else {
|
||||
leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString());
|
||||
}
|
||||
if(leaderData == null)
|
||||
return;
|
||||
|
||||
boolean completed = leaderData.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
if (progress == 0 && completed) {
|
||||
leaderData.dialogData.dialogsRead.remove(this.dialog.id);
|
||||
PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[1]);
|
||||
leaderData.updateClient = true;
|
||||
leaderData.save();
|
||||
}
|
||||
if (progress == 1 && !completed) {
|
||||
leaderData.dialogData.dialogsRead.add(this.dialog.id);
|
||||
PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[1]);
|
||||
leaderData.updateClient = true;
|
||||
leaderData.save();
|
||||
}
|
||||
} else {
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer individual = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData individualData;
|
||||
if(individual != null){
|
||||
individualData = PlayerDataController.Instance.getPlayerData(individual);
|
||||
}
|
||||
else {
|
||||
individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
}
|
||||
if(individualData != null){
|
||||
boolean completed = individualData.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
if (progress == 0 && completed) {
|
||||
individualData.dialogData.dialogsRead.remove(this.dialog.id);
|
||||
individualData.save();
|
||||
individualData.updateClient = true;
|
||||
}
|
||||
if (progress == 1 && !completed) {
|
||||
individualData.dialogData.dialogsRead.add(this.dialog.id);
|
||||
individualData.save();
|
||||
individualData.updateClient = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
PartyController.Instance().checkQuestCompletion(party, EnumQuestType.values()[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new CustomNPCsException("Progress has to be 0 or 1", new Object[0]);
|
||||
}
|
||||
@@ -219,8 +402,50 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
return data.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
if(player != null){
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
return data.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
}
|
||||
else if (party != null){
|
||||
if(party.getObjectiveRequirement() != null){
|
||||
EnumPartyObjectives objectives = party.getObjectiveRequirement();
|
||||
if(objectives == EnumPartyObjectives.Leader){
|
||||
EntityPlayer leaderPlayer = NoppesUtilServer.getPlayer(party.getLeaderUUID());
|
||||
PlayerData leaderData;
|
||||
if(leaderPlayer != null){
|
||||
leaderData = PlayerDataController.Instance.getPlayerData(leaderPlayer);
|
||||
}
|
||||
else {
|
||||
leaderData = PlayerDataController.Instance.getPlayerDataCache(party.getLeaderUUID().toString());
|
||||
}
|
||||
if(leaderData == null)
|
||||
return false;
|
||||
return leaderData.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
} else {
|
||||
boolean requiresOneRead = objectives == EnumPartyObjectives.Shared;
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer individual = NoppesUtilServer.getPlayer(uuid);
|
||||
PlayerData individualData;
|
||||
if(individual != null){
|
||||
individualData = PlayerDataController.Instance.getPlayerData(individual);
|
||||
}
|
||||
else {
|
||||
individualData = PlayerDataController.Instance.getPlayerDataCache(uuid.toString());
|
||||
}
|
||||
if(individualData != null){
|
||||
boolean read = individualData.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
if(requiresOneRead && read){
|
||||
return true;
|
||||
} else if(!requiresOneRead && !read){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !requiresOneRead;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
|
||||
@@ -8,6 +8,8 @@ import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.NpcMiscInventory;
|
||||
import noppes.npcs.api.handler.data.IQuestItem;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.constants.EnumPartyObjectives;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.scripted.CustomNPCsException;
|
||||
@@ -18,6 +20,10 @@ import java.util.*;
|
||||
public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
public NpcMiscInventory items = new NpcMiscInventory(3);
|
||||
public static ItemStack pickedUp;
|
||||
|
||||
public static ItemStack pickedUpParty;
|
||||
public static EntityPlayer pickedUpPlayer;
|
||||
|
||||
public boolean leaveItems = false;
|
||||
public boolean ignoreDamage = false;
|
||||
public boolean ignoreNBT = false;
|
||||
@@ -162,48 +168,211 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
@Override
|
||||
public Vector<String> getPartyQuestLogStatus(Party party) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
HashMap<Integer,ItemStack> map = getProcessSetParty(party);
|
||||
for(int slot : map.keySet()){
|
||||
ItemStack item = map.get(slot);
|
||||
ItemStack quest = items.items.get(slot);
|
||||
if(item == null)
|
||||
continue;
|
||||
String process = item.stackSize + "";
|
||||
if(item.stackSize > quest.stackSize)
|
||||
process = quest.stackSize + "";
|
||||
process += "/" + quest.stackSize + "";
|
||||
if(item.hasDisplayName())
|
||||
vec.add(item.getDisplayName() + ": " + process);
|
||||
else
|
||||
vec.add(item.getUnlocalizedName() + ".name" + ": " + process);
|
||||
if(party == null || party.getObjectiveRequirement() == null)
|
||||
return vec;
|
||||
|
||||
EnumPartyObjectives objectives = party.getObjectiveRequirement();
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
// Slot, QuestItem Vector
|
||||
HashMap<Integer, String> questVector = new HashMap<>();
|
||||
HashMap<Integer, List<String>> playerVector = new HashMap<>();
|
||||
for(int slot : items.items.keySet()){
|
||||
ItemStack questItem = items.items.get(slot);
|
||||
if(questItem != null){
|
||||
if(questItem.hasDisplayName())
|
||||
questVector.put(slot, questItem.getDisplayName() + ": " + questItem.stackSize);
|
||||
else
|
||||
questVector.put(slot, questItem.getUnlocalizedName() + ".name" + ": " + questItem.stackSize);
|
||||
|
||||
playerVector.put(slot, new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
// Slot, List of Players and Their Item Counts
|
||||
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
if(player != null){
|
||||
HashMap<Integer,ItemStack> perPlayerMap = getProcessSetParty(player);
|
||||
for(int slot : perPlayerMap.keySet()){
|
||||
List<String> slotCurrent = playerVector.get(slot);
|
||||
ItemStack item = perPlayerMap.get(slot);
|
||||
ItemStack quest = items.items.get(slot);
|
||||
if(item == null)
|
||||
continue;
|
||||
if(quest == null)
|
||||
continue;
|
||||
if(item.stackSize > quest.stackSize)
|
||||
continue;
|
||||
slotCurrent.add(player.getCommandSenderName() + ": " + item.stackSize);
|
||||
playerVector.put(slot, slotCurrent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add entries to the vec vector
|
||||
for (int slot : questVector.keySet()) {
|
||||
String questEntry = questVector.get(slot);
|
||||
vec.add(questEntry);
|
||||
List<String> playerItems = playerVector.get(slot);
|
||||
if (playerItems != null && !playerItems.isEmpty()) {
|
||||
StringBuilder playerNamesBuilder = new StringBuilder();
|
||||
for (String playerName : playerItems) {
|
||||
if (playerNamesBuilder.length() > 0) {
|
||||
playerNamesBuilder.append(", ");
|
||||
}
|
||||
playerNamesBuilder.append(playerName);
|
||||
}
|
||||
vec.add("[" + playerNamesBuilder.toString() + "]");
|
||||
}
|
||||
}
|
||||
} else if (objectives == EnumPartyObjectives.Shared || objectives == EnumPartyObjectives.Leader){
|
||||
HashMap<Integer, Integer> totals = new HashMap<Integer, Integer>();
|
||||
for (int slot : items.items.keySet()) {
|
||||
ItemStack item = items.items.get(slot);
|
||||
if (item != null) {
|
||||
totals.put(slot, 0);
|
||||
}
|
||||
}
|
||||
// Iterate over each player in the party
|
||||
for (UUID uuid : party.getPlayerUUIDs()) {
|
||||
if(uuid == null)
|
||||
continue;
|
||||
|
||||
if(objectives == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(uuid))
|
||||
continue;
|
||||
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
HashMap<Integer, ItemStack> perPlayerMap = getProcessSetParty(player);
|
||||
for (Map.Entry<Integer, ItemStack> entry : items.items.entrySet()) {
|
||||
int slot = entry.getKey();
|
||||
ItemStack reqItem = entry.getValue();
|
||||
for(ItemStack item : perPlayerMap.values()){
|
||||
if(NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT)){
|
||||
int count = totals.get(slot);
|
||||
count += item.stackSize;
|
||||
totals.put(slot, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the total count of required items collected by the party exceeds the required amount for each slot
|
||||
for (int slot : items.items.keySet()) {
|
||||
ItemStack reqItem = items.items.get(slot);
|
||||
if(reqItem == null)
|
||||
continue;
|
||||
|
||||
int totalCount = totals.get(slot);
|
||||
if (totalCount > reqItem.stackSize) {
|
||||
totalCount = reqItem.stackSize;
|
||||
}
|
||||
String process = totalCount + "/" + reqItem.stackSize;
|
||||
if(reqItem.hasDisplayName())
|
||||
vec.add(reqItem.getDisplayName() + ": " + process);
|
||||
else
|
||||
vec.add(reqItem.getUnlocalizedName() + ".name" + ": " + process);
|
||||
}
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPartyCompleted(Party party) {
|
||||
if(party == null)
|
||||
if(party == null || party.getObjectiveRequirement() == null)
|
||||
return false;
|
||||
|
||||
HashMap<Integer,ItemStack> map = getProcessSetParty(party);
|
||||
for(ItemStack reqItem : items.items.values()){
|
||||
boolean done = false;
|
||||
for(ItemStack item : map.values()){
|
||||
if(NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT) && item.stackSize >= reqItem.stackSize){
|
||||
done = true;
|
||||
break;
|
||||
EnumPartyObjectives objectives = party.getObjectiveRequirement();
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
for (UUID uuid: party.getPlayerUUIDs()) {
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
if(player != null){
|
||||
HashMap<Integer,ItemStack> perPlayerMap = getProcessSetParty(player);
|
||||
for(ItemStack reqItem : items.items.values()){
|
||||
boolean done = false;
|
||||
for(ItemStack item : perPlayerMap.values()){
|
||||
if(NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT) && item.stackSize >= reqItem.stackSize){
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!done)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (objectives == EnumPartyObjectives.Shared || objectives == EnumPartyObjectives.Leader){
|
||||
HashMap<Integer, Integer> totals = new HashMap<Integer, Integer>();
|
||||
for (int slot : items.items.keySet()) {
|
||||
ItemStack item = items.items.get(slot);
|
||||
if (item != null) {
|
||||
totals.put(slot, 0);
|
||||
}
|
||||
}
|
||||
if(!done)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Iterate over each player in the party
|
||||
for (UUID uuid : party.getPlayerUUIDs()) {
|
||||
if(uuid == null)
|
||||
continue;
|
||||
|
||||
if(objectives == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(uuid))
|
||||
continue;
|
||||
|
||||
EntityPlayer player = NoppesUtilServer.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
HashMap<Integer, ItemStack> perPlayerMap = getProcessSetParty(player);
|
||||
for (Map.Entry<Integer, ItemStack> entry : items.items.entrySet()) {
|
||||
int slot = entry.getKey();
|
||||
ItemStack reqItem = entry.getValue();
|
||||
for(ItemStack item : perPlayerMap.values()){
|
||||
if(NoppesUtilPlayer.compareItems(reqItem, item, ignoreDamage, ignoreNBT)){
|
||||
int count = totals.get(slot);
|
||||
count += item.stackSize;
|
||||
totals.put(slot, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the total count of required items collected by the party exceeds the required amount for each slot
|
||||
for (int slot : items.items.keySet()) {
|
||||
ItemStack reqItem = items.items.get(slot);
|
||||
int totalCount = totals.get(slot);
|
||||
if (totalCount < reqItem.stackSize) {
|
||||
return false; // Party has not completed the objective
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public HashMap<Integer,ItemStack> getProcessSetParty(Party party){
|
||||
public HashMap<Integer,ItemStack> getProcessSetParty(EntityPlayer player){
|
||||
HashMap<Integer,ItemStack> map = new HashMap<Integer,ItemStack>();
|
||||
for(int slot : items.items.keySet()){
|
||||
ItemStack item = items.items.get(slot);
|
||||
if(item == null)
|
||||
continue;
|
||||
ItemStack is = item.copy();
|
||||
is.stackSize = 0;
|
||||
map.put(slot,is);
|
||||
}
|
||||
|
||||
ArrayList<ItemStack> list = new ArrayList<>(Arrays.asList(player.inventory.mainInventory));
|
||||
if(pickedUpPlayer != null && player.getCommandSenderName().equals(pickedUpPlayer.getCommandSenderName()))
|
||||
list.add(pickedUpParty);
|
||||
|
||||
for(ItemStack item : list){
|
||||
if(item == null)
|
||||
continue;
|
||||
for(ItemStack questItem : map.values()){
|
||||
if(NoppesUtilPlayer.compareItems(questItem, item, ignoreDamage, ignoreNBT)){
|
||||
questItem.stackSize += item.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -249,31 +418,46 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
|
||||
public int getProgress() {
|
||||
int count = 0;
|
||||
|
||||
ItemStack item = QuestItem.pickedUp;
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
}
|
||||
|
||||
if(player != null){
|
||||
ItemStack item = QuestItem.pickedUp;
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
}
|
||||
|
||||
for(int i = 0; i < this.player.inventory.getSizeInventory(); ++i) {
|
||||
item = this.player.inventory.getStackInSlot(i);
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
}
|
||||
}
|
||||
} else if (party != null){
|
||||
} else if (party != null && party.getObjectiveRequirement() != null){
|
||||
ItemStack item;
|
||||
EnumPartyObjectives objectives = party.getObjectiveRequirement();
|
||||
for(String name : party.getPlayerNames()){
|
||||
EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name);
|
||||
if(playerMP == null)
|
||||
continue;
|
||||
|
||||
if(!playerMP.getUniqueID().equals(party.getLeaderUUID()) && objectives == EnumPartyObjectives.Leader)
|
||||
continue;
|
||||
|
||||
int amount = 0;
|
||||
for(int i = 0; i < playerMP.inventory.getSizeInventory(); ++i) {
|
||||
item = playerMP.inventory.getStackInSlot(i);
|
||||
if (!NoppesUtilServer.IsItemStackNull(item) && NoppesUtilPlayer.compareItems(this.questItem, item, this.parent.ignoreDamage, this.parent.ignoreNBT)) {
|
||||
count += item.stackSize;
|
||||
amount += item.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
count += ValueUtil.clamp(amount, 0, this.questItem.stackSize);
|
||||
} else {
|
||||
count += amount;
|
||||
}
|
||||
}
|
||||
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
return ValueUtil.clamp(count, 0, this.questItem.stackSize * party.getPlayerNames().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,6 +469,13 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
}
|
||||
|
||||
public int getMaxProgress() {
|
||||
if(party != null && party.getObjectiveRequirement() != null){
|
||||
EnumPartyObjectives objectives = party.getObjectiveRequirement();
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
return this.questItem.stackSize * party.getPlayerNames().size();
|
||||
}
|
||||
}
|
||||
|
||||
return this.questItem.stackSize;
|
||||
}
|
||||
|
||||
@@ -299,15 +490,35 @@ public class QuestItem extends QuestInterface implements IQuestItem {
|
||||
|
||||
public boolean comparePartyItems(Party party, ItemStack item, boolean ignoreDamage, boolean ignoreNBT){
|
||||
int size = 0;
|
||||
if(party.getObjectiveRequirement() == null)
|
||||
return false;
|
||||
|
||||
EnumPartyObjectives objectives = party.getObjectiveRequirement();
|
||||
for(String name : party.getPlayerNames()){
|
||||
EntityPlayer playerMP = NoppesUtilServer.getPlayerByName(name);
|
||||
if(playerMP == null)
|
||||
continue;
|
||||
|
||||
if(objectives == EnumPartyObjectives.Leader && !playerMP.getUniqueID().equals(party.getLeaderUUID()))
|
||||
continue;
|
||||
|
||||
int amount = 0;
|
||||
for(ItemStack is : playerMP.inventory.mainInventory){
|
||||
if(is != null && NoppesUtilPlayer.compareItems(item, is, ignoreDamage, ignoreNBT))
|
||||
size += is.stackSize;
|
||||
if(NoppesUtilPlayer.compareItems(item, is, ignoreDamage, ignoreNBT))
|
||||
amount += is.stackSize;
|
||||
}
|
||||
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
size += ValueUtil.clamp(amount, 0, this.questItem.stackSize);
|
||||
} else {
|
||||
size += amount;
|
||||
}
|
||||
}
|
||||
|
||||
if(objectives == EnumPartyObjectives.All){
|
||||
return size >= item.stackSize * party.getPlayerNames().size();
|
||||
}
|
||||
|
||||
return size >= item.stackSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -305,6 +305,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
this.parent.setKilled(questdata, killed);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[2]);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[4]);
|
||||
data.updateClient = true;
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,6 +332,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
questData.extraData.setBoolean(this.nbtName, progress == 1);
|
||||
data.questData.checkQuestCompletion(data, EnumQuestType.values()[3]);
|
||||
data.save();
|
||||
data.updateClient = true;
|
||||
}
|
||||
} else if (party != null){
|
||||
QuestData questData = party.getQuestData();
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.NBTTags;
|
||||
import noppes.npcs.NpcMiscInventory;
|
||||
import noppes.npcs.controllers.GlobalDataController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Availability;
|
||||
import noppes.npcs.controllers.data.Line;
|
||||
@@ -25,11 +26,11 @@ public class JobItemGiver extends JobInterface{
|
||||
public int cooldown = 10;
|
||||
public NpcMiscInventory inventory;
|
||||
public int itemGiverId = 0;
|
||||
|
||||
|
||||
public List<String> lines = new ArrayList<String>();
|
||||
|
||||
|
||||
private int ticks = 10;
|
||||
|
||||
|
||||
private List<EntityPlayer> recentlyChecked = new ArrayList<EntityPlayer>();
|
||||
private List<EntityPlayer> toCheck;
|
||||
public Availability availability = new Availability();
|
||||
@@ -65,6 +66,10 @@ public class JobItemGiver extends JobInterface{
|
||||
cooldown = nbttagcompound.getInteger("igCooldown");
|
||||
lines = NBTTags.getStringList(nbttagcompound.getTagList("igLines", 10));
|
||||
inventory.setFromNBT(nbttagcompound.getCompoundTag("igJobInventory"));
|
||||
|
||||
if(itemGiverId == 0 && GlobalDataController.Instance != null)
|
||||
itemGiverId = GlobalDataController.Instance.incrementItemGiverId();
|
||||
|
||||
availability.readFromNBT(nbttagcompound.getCompoundTag("igAvailability"));
|
||||
}
|
||||
|
||||
@@ -91,16 +96,16 @@ public class JobItemGiver extends JobInterface{
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public boolean giveItems(EntityPlayer player){
|
||||
PlayerItemGiverData data = PlayerDataController.Instance.getPlayerData(player).itemgiverData;
|
||||
if(!canPlayerInteract(data)){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Vector<ItemStack> items = new Vector<ItemStack>();
|
||||
Vector<ItemStack> toGive = new Vector<ItemStack>();
|
||||
|
||||
|
||||
for(ItemStack is : inventory.items.values())
|
||||
if(is != null)
|
||||
items.add(is.copy());
|
||||
@@ -234,7 +239,7 @@ public class JobItemGiver extends JobInterface{
|
||||
private boolean isDaily(){
|
||||
return cooldownType == 2;
|
||||
}
|
||||
|
||||
|
||||
public boolean aiShouldExecute() {
|
||||
if(npc.isAttacking())
|
||||
return false;
|
||||
@@ -242,7 +247,7 @@ public class JobItemGiver extends JobInterface{
|
||||
if(ticks > 0)
|
||||
return false;
|
||||
ticks = 10;
|
||||
|
||||
|
||||
toCheck = npc.worldObj.getEntitiesWithinAABB(EntityPlayer.class, npc.boundingBox.expand(3, 3, 3));
|
||||
toCheck.removeAll(recentlyChecked);
|
||||
|
||||
@@ -260,11 +265,11 @@ public class JobItemGiver extends JobInterface{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void killed() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
private boolean interact(EntityPlayer player) {
|
||||
@@ -276,6 +281,6 @@ public class JobItemGiver extends JobInterface{
|
||||
@Override
|
||||
public void delete() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -193,11 +193,15 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
}
|
||||
|
||||
public void readDialog(int id) {
|
||||
PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.add(id);
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
playerData.dialogData.dialogsRead.add(id);
|
||||
playerData.updateClient = true;
|
||||
}
|
||||
|
||||
public void unreadDialog(int id) {
|
||||
PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.remove(id);
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
playerData.dialogData.dialogsRead.remove(id);
|
||||
playerData.updateClient = true;
|
||||
}
|
||||
|
||||
public boolean hasFinishedQuest(IQuest quest) {
|
||||
@@ -261,6 +265,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
data.questData.activeQuests.put(id, questdata);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
|
||||
Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
|
||||
data.updateClient = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,12 +276,12 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
Quest quest = QuestController.Instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
PlayerData data = PlayerData.get(player);
|
||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
|
||||
data.questData.finishedQuests.put(quest.id, System.currentTimeMillis());
|
||||
else
|
||||
data.questData.finishedQuests.put(quest.id, player.worldObj.getTotalWorldTime());
|
||||
data.updateClient = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -289,6 +294,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return;
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
data.questData.activeQuests.remove(id);
|
||||
data.updateClient = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,9 +305,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
Quest quest = QuestController.Instance.quests.get(id);
|
||||
if (quest == null)
|
||||
return;
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerData data = PlayerData.get(player);
|
||||
data.questData.activeQuests.remove(id);
|
||||
data.questData.finishedQuests.remove(id);
|
||||
data.updateClient = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package noppes.npcs.scripted.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.event.IPartyEvent;
|
||||
import noppes.npcs.api.event.IQuestEvent;
|
||||
import noppes.npcs.api.handler.data.IParty;
|
||||
import noppes.npcs.api.handler.data.IQuest;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.constants.EnumScriptType;
|
||||
|
||||
public class PartyEvent extends CustomNPCsEvent implements IPartyEvent {
|
||||
public final IQuest quest;
|
||||
public final IParty party;
|
||||
|
||||
public PartyEvent(IParty party, IQuest quest) {
|
||||
this.quest = quest;
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
public IParty getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
public IQuest getQuest() {
|
||||
return quest;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PARTY_EVENT.function;
|
||||
}
|
||||
|
||||
public static class PartyQuestCompletedEvent extends PartyEvent implements IPartyEvent.PartyQuestCompletedEvent {
|
||||
public PartyQuestCompletedEvent(IParty party, IQuest quest) {
|
||||
super(party, quest);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PARTY_QUEST_COMPLETED.function;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class PartyQuestSetEvent extends PartyEvent implements IPartyEvent.PartyQuestSetEvent {
|
||||
public PartyQuestSetEvent(IParty party, IQuest quest) {
|
||||
super(party, quest);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PARTY_QUEST_SET.function;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class PartyQuestTurnedInEvent extends PartyEvent implements IPartyEvent.PartyQuestTurnedInEvent {
|
||||
public PartyQuestTurnedInEvent(IParty party, IQuest quest) {
|
||||
super(party, quest);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PARTY_QUEST_TURNED_IN.function;
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class PartyInviteEvent extends PartyEvent implements IPartyEvent.PartyInviteEvent {
|
||||
public IPlayer player;
|
||||
|
||||
public PartyInviteEvent(IParty party, IQuest quest, IPlayer player) {
|
||||
super(party, quest);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PARTY_INVITE.function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerName() {
|
||||
return player.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@Cancelable
|
||||
public static class PartyKickEvent extends PartyEvent implements IPartyEvent.PartyKickEvent {
|
||||
public IPlayer player;
|
||||
|
||||
public PartyKickEvent(IParty party, IQuest quest, IPlayer player) {
|
||||
super(party, quest);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PARTY_KICK.function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerName() {
|
||||
return player.getName();
|
||||
}
|
||||
}
|
||||
|
||||
public static class PartyLeaveEvent extends PartyEvent implements IPartyEvent.PartyLeaveEvent {
|
||||
public IPlayer player;
|
||||
|
||||
public PartyLeaveEvent(IParty party, IQuest quest, IPlayer player) {
|
||||
super(party, quest);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PARTY_LEAVE.function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerName() {
|
||||
return player.getName();
|
||||
}
|
||||
}
|
||||
|
||||
public static class PartyDisbandEvent extends PartyEvent implements IPartyEvent.PartyDisbandEvent {
|
||||
public PartyDisbandEvent(IParty party, IQuest quest) {
|
||||
super(party, quest);
|
||||
}
|
||||
|
||||
public String getHookName() {
|
||||
return EnumScriptType.PARTY_DISBAND.function;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user