Added quest start, complete, and turnin events, and a faction points event to scripted player events.

This commit is contained in:
luisc committed 2022-01-12 20:12:16 -06:00
1 parent 8919a182c5
commit b024f800ae
9 files changed
+152 -20

No files matched your search

@@ -1,8 +1,12 @@
package noppes.npcs.controllers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import noppes.npcs.EventHooks;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.FactionEvent;
public class FactionOptions {
@@ -55,7 +59,9 @@ public class FactionOptions {
Faction faction = FactionController.getInstance().get(factionId);
if(faction == null)
return;
EventHooks.onFactionPoints(new FactionEvent.FactionPoints(new ScriptPlayer((EntityPlayerMP) player), faction, decrease, points));
if(!faction.hideFaction){
String message = decrease?"faction.decreasepoints":"faction.increasepoints";
player.addChatMessage(new ChatComponentTranslation(message, faction.name, points));
@@ -4,6 +4,7 @@ import java.util.Vector;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import noppes.npcs.EventHooks;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestRepeat;
@@ -30,6 +31,10 @@ public class PlayerQuestController {
public static void addActiveQuest(Quest quest, EntityPlayer player) {
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
if(canQuestBeAccepted(quest, player)){
if (EventHooks.onQuestStarted(player, quest)) {
return;
}
data.activeQuests.put(quest.id,new QuestData(quest));
Server.sendData((EntityPlayerMP)player, EnumPacketClient.MESSAGE, "quest.newquest", quest.title);
Server.sendData((EntityPlayerMP)player, EnumPacketClient.CHAT, "quest.newquest", ": ", quest.title);
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.EventHooks;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestCompletion;
@@ -103,6 +104,7 @@ public class PlayerQuestData {
}
data.isCompleted = true;
bo = true;
EventHooks.onQuestFinished(player,data.quest);
}
}
else