mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 23:09:05 +00:00
Merge branch 'temp' into patch
This commit is contained in:
commit
45ba8c5c06
51 files changed
+202
-210
No files matched your search
@@ -220,13 +220,13 @@ public abstract class AbstractCommandHelper extends CommandHelper {
|
||||
ArrayList<PlayerData> list = new ArrayList<PlayerData>();
|
||||
EntityPlayerMP[] players = PlayerSelector.matchPlayers(pcParam, username);
|
||||
if(players == null || players.length == 0){
|
||||
PlayerData data = PlayerDataController.instance.getDataFromUsername(username);
|
||||
PlayerData data = PlayerDataController.Instance.getDataFromUsername(username);
|
||||
if(data != null)
|
||||
list.add(data);
|
||||
}
|
||||
else{
|
||||
for(EntityPlayer player : players){
|
||||
list.add(PlayerDataController.instance.getPlayerData(player));
|
||||
list.add(PlayerDataController.Instance.getPlayerData(player));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class AnimationCommand extends CommandKamkeelBase {
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
String playername = args[0];
|
||||
|
||||
data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
throw new CommandException("Unknown player: " + playername);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class ConfigCommand extends CommandKamkeelBase {
|
||||
}
|
||||
|
||||
sendResult(sender, "Started Conversion Process for PlayerData");
|
||||
PlayerDataController.instance.convertPlayerFiles(send, convertToDat);
|
||||
PlayerDataController.Instance.convertPlayerFiles(send, convertToDat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
@@ -66,7 +66,7 @@ public class DialogCommand extends CommandKamkeelBase {
|
||||
sendError(sender, "DialogID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FactionCommand extends CommandKamkeelBase {
|
||||
String playername = args[0];
|
||||
String factionname = args[1];
|
||||
|
||||
data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
return;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, "Unknown player: " + playername);
|
||||
@@ -80,7 +80,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
return;
|
||||
@@ -123,7 +123,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
sendError(sender, "QuestID must be an integer: " + args[1]);
|
||||
return;
|
||||
}
|
||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
return;
|
||||
@@ -154,7 +154,7 @@ public class QuestCommand extends CommandKamkeelBase {
|
||||
return;
|
||||
}
|
||||
|
||||
List<PlayerData> data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
List<PlayerData> data = PlayerDataController.Instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
sendError(sender, String.format("Unknown player '%s'", playername));
|
||||
return;
|
||||
|
||||
@@ -32,9 +32,7 @@ import noppes.npcs.entity.old.*;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.8.5")
|
||||
public class CustomNpcs {
|
||||
@@ -206,6 +204,7 @@ public class CustomNpcs {
|
||||
ScriptController.Instance.loadPlayerScripts();
|
||||
ScriptController.HasStart = false;
|
||||
NpcAPI.clearCache();
|
||||
PlayerDataController.Instance.clearCache();
|
||||
|
||||
Set<String> names = Block.blockRegistry.getKeys();
|
||||
for(String name : names){
|
||||
@@ -237,7 +236,7 @@ public class CustomNpcs {
|
||||
@EventHandler
|
||||
public void stopped(FMLServerStoppedEvent event){
|
||||
ServerCloneController.Instance = null;
|
||||
GlobalDataController.instance.saveData();
|
||||
GlobalDataController.Instance.saveData();
|
||||
ScriptController.Instance.saveForgeScripts();
|
||||
ScriptController.Instance.savePlayerScripts();
|
||||
ScriptController.Instance.saveGlobalNpcScripts();
|
||||
|
||||
@@ -216,17 +216,17 @@ public class DataAdvanced {
|
||||
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);
|
||||
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();
|
||||
((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);
|
||||
GlobalDataController.Instance.itemGivers.put(((JobItemGiver) npc.jobInterface).itemGiverId, (JobItemGiver) npc.jobInterface);
|
||||
npc.itemGiverId = ((JobItemGiver) npc.jobInterface).itemGiverId;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -71,7 +71,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
public static void transport(EntityPlayerMP player, EntityNPCInterface npc, String location){
|
||||
TransportLocation loc = TransportController.getInstance().getTransport(location);
|
||||
PlayerTransportData playerdata = PlayerDataController.instance.getPlayerData(player).transportData;
|
||||
PlayerTransportData playerdata = PlayerDataController.Instance.getPlayerData(player).transportData;
|
||||
|
||||
if(loc == null || !loc.isDefault() && !playerdata.transports.contains(loc.id))
|
||||
return;
|
||||
@@ -215,7 +215,7 @@ public class NoppesUtilPlayer {
|
||||
else
|
||||
currency = currency.splitStack(price);
|
||||
player.closeContainer();
|
||||
PlayerBankData data = PlayerDataController.instance.getBankData(player,bank.id);
|
||||
PlayerBankData data = PlayerDataController.Instance.getBankData(player,bank.id);
|
||||
BankData bankData = data.getBank(bank.id);
|
||||
bankData.upgradedSlots.put(container.slot, true);
|
||||
|
||||
@@ -243,7 +243,7 @@ public class NoppesUtilPlayer {
|
||||
else
|
||||
currency = currency.splitStack(price);
|
||||
player.closeContainer();
|
||||
PlayerBankData data = PlayerDataController.instance.getBankData(player,bank.id);
|
||||
PlayerBankData data = PlayerDataController.Instance.getBankData(player,bank.id);
|
||||
BankData bankData = data.getBank(bank.id);
|
||||
if(bankData.unlockedSlots + 1 <= bank.maxSlots)
|
||||
bankData.unlockedSlots++;
|
||||
@@ -299,7 +299,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
|
||||
public static void updateQuestLogData(ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
HashMap<String,String> questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
|
||||
@@ -342,7 +342,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
|
||||
public static void sendTrackedQuestData(EntityPlayerMP player) {
|
||||
Quest trackedQuest = (Quest) PlayerDataController.instance.getPlayerData(player).questData.getTrackedQuest();
|
||||
Quest trackedQuest = (Quest) PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest();
|
||||
if(trackedQuest != null){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setTag("Quest",trackedQuest.writeToNBT(new NBTTagCompound()));
|
||||
@@ -370,7 +370,7 @@ public class NoppesUtilPlayer {
|
||||
if(player == null)
|
||||
return false;
|
||||
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
QuestData data = questData.activeQuests.get(questId);
|
||||
|
||||
@@ -426,7 +426,7 @@ public class NoppesUtilPlayer {
|
||||
}
|
||||
data.quest.factionOptions.addPoints(player);
|
||||
if(data.quest.mail.isValid()){
|
||||
PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail);
|
||||
PlayerDataController.Instance.addPlayerMessage(player.getCommandSenderName(), data.quest.mail);
|
||||
}
|
||||
|
||||
if(!data.quest.command.isEmpty()){
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import foxz.utils.Utils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.command.server.CommandBlockLogic;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -53,13 +52,13 @@ public class NoppesUtilServer {
|
||||
private static HashMap<String,Quest> editingQuests = new HashMap<String,Quest>();
|
||||
|
||||
public static void setEditingNpc(EntityPlayer player, EntityNPCInterface npc){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
data.editingNpc = npc;
|
||||
if(npc != null)
|
||||
Server.sendDataChecked((EntityPlayerMP)player, EnumPacketClient.EDIT_NPC, npc.getEntityId());
|
||||
}
|
||||
public static EntityNPCInterface getEditingNpc(EntityPlayer player){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
return data.editingNpc;
|
||||
}
|
||||
|
||||
@@ -186,8 +185,8 @@ public class NoppesUtilServer {
|
||||
runCommand(player, npc.getCommandSenderName(), dialog.command);
|
||||
}
|
||||
if(dialog.mail.isValid())
|
||||
PlayerDataController.instance.addPlayerMessage(player.getCommandSenderName(), dialog.mail);
|
||||
PlayerDialogData data = PlayerDataController.instance.getPlayerData(player).dialogData;
|
||||
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);
|
||||
setEditingNpc(player, npc);
|
||||
@@ -310,7 +309,7 @@ public class NoppesUtilServer {
|
||||
list.add(loc.name);
|
||||
}
|
||||
}
|
||||
PlayerTransportData playerdata = PlayerDataController.instance.getPlayerData(player).transportData;
|
||||
PlayerTransportData playerdata = PlayerDataController.Instance.getPlayerData(player).transportData;
|
||||
for(int i : playerdata.transports){
|
||||
TransportLocation loc = TransportController.getInstance().getTransport(i);
|
||||
if(loc != null && location.category.locations.containsKey(loc.id)){
|
||||
@@ -411,7 +410,7 @@ public class NoppesUtilServer {
|
||||
Map<String,Integer> map = new HashMap<String,Integer>();
|
||||
|
||||
if(type == EnumPlayerData.Players){
|
||||
for(String username : PlayerDataController.instance.nameUUIDs.keySet()){
|
||||
for(String username : PlayerDataController.Instance.nameUUIDs.keySet()){
|
||||
map.put(username, 0);
|
||||
}
|
||||
for(String username : MinecraftServer.getServer().getConfigurationManager().getAllUsernames()){
|
||||
@@ -419,7 +418,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
}
|
||||
else{
|
||||
PlayerData playerdata = PlayerDataController.instance.getDataFromUsername(name);
|
||||
PlayerData playerdata = PlayerDataController.Instance.getDataFromUsername(name);
|
||||
if(type == EnumPlayerData.Dialog){
|
||||
PlayerDialogData data = playerdata.dialogData;
|
||||
|
||||
@@ -489,16 +488,16 @@ public class NoppesUtilServer {
|
||||
EntityPlayer pl = MinecraftServer.getServer().getConfigurationManager().func_152612_a(name);
|
||||
PlayerData playerdata = null;
|
||||
if(pl == null)
|
||||
playerdata = PlayerDataController.instance.getDataFromUsername(name);
|
||||
playerdata = PlayerDataController.Instance.getDataFromUsername(name);
|
||||
else
|
||||
playerdata = PlayerDataController.instance.getPlayerData(pl);
|
||||
playerdata = PlayerDataController.Instance.getPlayerData(pl);
|
||||
|
||||
if(type == EnumPlayerData.Players){
|
||||
String fileType = ".json";
|
||||
if(ConfigMain.DatFormat){
|
||||
fileType = ".dat";
|
||||
}
|
||||
File file = new File(PlayerDataController.instance.getSaveDir(), playerdata.uuid + fileType);
|
||||
File file = new File(PlayerDataController.Instance.getSaveDir(), playerdata.uuid + fileType);
|
||||
if(file.exists())
|
||||
file.delete();
|
||||
if(pl != null){
|
||||
@@ -508,8 +507,8 @@ public class NoppesUtilServer {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
PlayerDataController.instance.nameUUIDs.remove(name);
|
||||
PlayerDataController.instance.savePlayerDataMap();
|
||||
PlayerDataController.Instance.nameUUIDs.remove(name);
|
||||
PlayerDataController.Instance.savePlayerDataMap();
|
||||
}
|
||||
}
|
||||
if(type == EnumPlayerData.Quest){
|
||||
@@ -543,7 +542,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
|
||||
public static void regenPlayerData(EntityPlayerMP player) throws IOException {
|
||||
PlayerDataController.instance.generatePlayerMap(player);
|
||||
PlayerDataController.Instance.generatePlayerMap(player);
|
||||
}
|
||||
|
||||
public static void sendRecipeData(EntityPlayerMP player, int size) {
|
||||
@@ -819,7 +818,7 @@ public class NoppesUtilServer {
|
||||
}
|
||||
|
||||
public static void isGUIOpen(ByteBuf buffer, EntityPlayer player) throws IOException {
|
||||
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player);
|
||||
boolean isGUIOpen = buffer.readBoolean();
|
||||
playerdata.setGUIOpen(isGUIOpen);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public class PacketHandlerPlayer{
|
||||
return;
|
||||
int slot = buffer.readInt();
|
||||
int bankId = buffer.readInt();
|
||||
BankData data = PlayerDataController.instance.getBankData(player,bankId).getBankOrDefault(bankId);
|
||||
BankData data = PlayerDataController.Instance.getBankData(player,bankId).getBankOrDefault(bankId);
|
||||
data.openBankGui(player, npc, bankId, slot);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.Dialog){
|
||||
@@ -183,25 +183,25 @@ public class PacketHandlerPlayer{
|
||||
NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.CheckQuestCompletion){
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerQuestData questData = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
questData.checkQuestCompletion(playerData, null);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.QuestLog){
|
||||
NoppesUtilPlayer.sendQuestLogData(player);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FactionsGet){
|
||||
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.getPlayerGuiData());
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailGet){
|
||||
PlayerMailData data = PlayerDataController.instance.getPlayerData(player).mailData;
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, data.saveNBTData(new NBTTagCompound()));
|
||||
}
|
||||
else if(type == EnumPlayerPacket.MailDelete){
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
PlayerMailData data = PlayerDataController.instance.getPlayerData(player).mailData;
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
@@ -215,7 +215,7 @@ public class PacketHandlerPlayer{
|
||||
else if(type == EnumPlayerPacket.MailSend){
|
||||
if(!(player.openContainer instanceof ContainerMail))
|
||||
return;
|
||||
String username = PlayerDataController.instance.hasPlayer(Server.readString(buffer));
|
||||
String username = PlayerDataController.Instance.hasPlayer(Server.readString(buffer));
|
||||
if(username.isEmpty()){
|
||||
NoppesUtilServer.sendGuiError(player, 0);
|
||||
return;
|
||||
@@ -234,7 +234,7 @@ public class PacketHandlerPlayer{
|
||||
NoppesUtilServer.sendGuiError(player, 1);
|
||||
return;
|
||||
}
|
||||
PlayerDataController.instance.addPlayerMessage(username, mail);
|
||||
PlayerDataController.Instance.addPlayerMessage(username, mail);
|
||||
|
||||
NBTTagCompound comp = new NBTTagCompound();
|
||||
comp.setString("username", username);
|
||||
@@ -244,7 +244,7 @@ public class PacketHandlerPlayer{
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
player.closeContainer();
|
||||
PlayerMailData data = PlayerDataController.instance.getPlayerData(player).mailData;
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
@@ -259,7 +259,7 @@ public class PacketHandlerPlayer{
|
||||
else if(type == EnumPlayerPacket.MailRead){
|
||||
long time = buffer.readLong();
|
||||
String username = Server.readString(buffer);
|
||||
PlayerMailData data = PlayerDataController.instance.getPlayerData(player).mailData;
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
|
||||
@@ -6,7 +6,6 @@ import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import foxz.utils.Market;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
@@ -28,7 +27,6 @@ import net.minecraft.world.WorldProvider;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.handler.data.ITag;
|
||||
import noppes.npcs.config.ConfigDebug;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
@@ -1006,7 +1004,7 @@ public class PacketHandlerServer{
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.CloneSave){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
if(data.cloned == null)
|
||||
return;
|
||||
String name = Server.readString(buffer);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class QuestLogData {
|
||||
trackedQuestKey = compound.getString("TrackedQuestID");
|
||||
}
|
||||
public void setData(EntityPlayer player){
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
for(Quest quest : PlayerQuestController.getActiveQuests(player))
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@ 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.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
@@ -64,19 +63,19 @@ public class ScriptPlayerEventHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerDataController.instance != null) {
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
if (PlayerDataController.Instance != null) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
if (playerData.timers.size() > 0) {
|
||||
playerData.timers.update();
|
||||
}
|
||||
|
||||
if (playerData.questData.getTrackedQuest() != null && !playerData.questData.activeQuests.containsKey(playerData.questData.getTrackedQuest().getId())) {
|
||||
PlayerDataController.instance.getPlayerData(player).questData.untrackQuest();
|
||||
PlayerDataController.Instance.getPlayerData(player).questData.untrackQuest();
|
||||
}
|
||||
|
||||
if (player.ticksExisted % 20 == 0 && !PlayerDataController.instance.getPlayerData(player).skinOverlays.overlayList.isEmpty()) {
|
||||
PlayerDataController.instance.getPlayerData(player).skinOverlays.updateClient();
|
||||
if (player.ticksExisted % 20 == 0 && !PlayerDataController.Instance.getPlayerData(player).skinOverlays.overlayList.isEmpty()) {
|
||||
PlayerDataController.Instance.getPlayerData(player).skinOverlays.updateClient();
|
||||
}
|
||||
|
||||
if (player.ticksExisted % (TrackedQuestUpdateFrequency * 20) == 0) {
|
||||
@@ -476,12 +475,12 @@ public class ScriptPlayerEventHandler {
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
|
||||
EventHooks.onPlayerLogin(handler, scriptPlayer);
|
||||
|
||||
Quest quest = (Quest) PlayerDataController.instance.getPlayerData(event.player).questData.getTrackedQuest();
|
||||
Quest quest = (Quest) PlayerDataController.Instance.getPlayerData(event.player).questData.getTrackedQuest();
|
||||
if (quest != null) {
|
||||
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
|
||||
}
|
||||
|
||||
PlayerDataController.instance.getPlayerData(event.player).skinOverlays.updateClient();
|
||||
PlayerDataController.Instance.getPlayerData(event.player).skinOverlays.updateClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package noppes.npcs;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -21,7 +20,6 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.village.MerchantRecipeList;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
@@ -92,7 +90,7 @@ public class ServerEventsHandler {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(!event.target.writeToNBTOptional(compound))
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(event.entityPlayer);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
ServerCloneController.Instance.cleanTags(compound);
|
||||
if(!Server.sendDataChecked((EntityPlayerMP)event.entityPlayer, EnumPacketClient.CLONE, compound))
|
||||
event.entityPlayer.addChatMessage(new ChatComponentText("Entity too big to clone"));
|
||||
@@ -277,7 +275,7 @@ public class ServerEventsHandler {
|
||||
}
|
||||
}
|
||||
if(event.entityLiving instanceof EntityPlayer){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer)event.entityLiving);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer)event.entityLiving);
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
@@ -295,7 +293,7 @@ public class ServerEventsHandler {
|
||||
}
|
||||
|
||||
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) {
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
boolean checkCompletion = false;
|
||||
String entityName = EntityList.getEntityString(entity);
|
||||
@@ -354,7 +352,7 @@ public class ServerEventsHandler {
|
||||
public void pickUp(EntityItemPickupEvent event){
|
||||
if(event.entityPlayer.worldObj.isRemote)
|
||||
return;
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(event.entityPlayer);
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
QuestItem.pickedUp = event.item.getEntityItem();
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
|
||||
@@ -362,7 +360,7 @@ public class ServerEventsHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void world(PlayerEvent.SaveToFile event){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity);
|
||||
data.save();
|
||||
}
|
||||
|
||||
@@ -370,7 +368,7 @@ public class ServerEventsHandler {
|
||||
public void world(EntityJoinWorldEvent event){
|
||||
if(event.world.isRemote || !(event.entity instanceof EntityPlayer))
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData((EntityPlayer) event.entity);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity);
|
||||
data.updateCompanion(event.world);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class TileWaypoint extends TileEntity {
|
||||
if(toCheck.isEmpty())
|
||||
return;
|
||||
for(EntityPlayer player : toCheck){
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
|
||||
ArrayList<QuestData> activeQuestValues = new ArrayList<>(questData.activeQuests.values());
|
||||
|
||||
@@ -3,23 +3,13 @@ package noppes.npcs.client;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Client {
|
||||
public static OverlayQuestTracking questTrackingOverlay = null;
|
||||
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
|
||||
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
|
||||
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
|
||||
|
||||
public static void sendData(final EnumPacketServer enu, final Object... obs) {
|
||||
ByteBuf buffer = Unpooled.buffer();
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.util.CacheHashMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ClientCacheHandler {
|
||||
private static final CacheHashMap<String, CacheHashMap.CachedObject<ImageData>> imageDataCache = new CacheHashMap<>((long) ConfigClient.CacheLife * 60 * 1000);
|
||||
public static OverlayQuestTracking questTrackingOverlay = null;
|
||||
public static HashMap<Integer, OverlayCustom> customOverlays = new HashMap<>();
|
||||
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
|
||||
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
|
||||
|
||||
public static ImageData getImageData(String directory) {
|
||||
synchronized (imageDataCache) {
|
||||
@@ -25,4 +36,12 @@ public class ClientCacheHandler {
|
||||
return imageDataCache.get(resource.getResourcePath()).getObject();
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearCache() {
|
||||
ClientCacheHandler.imageDataCache.clear();
|
||||
ClientCacheHandler.questTrackingOverlay = null;
|
||||
ClientCacheHandler.customOverlays.clear();
|
||||
ClientCacheHandler.skinOverlays.clear();
|
||||
ClientCacheHandler.playerAnimations.clear();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.client;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
@@ -65,12 +66,12 @@ public class ClientEventHandler {
|
||||
@SubscribeEvent
|
||||
public void onOverlayRender(RenderGameOverlayEvent.Post event){
|
||||
if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
|
||||
for (OverlayCustom overlayCustom : Client.customOverlays.values()) {
|
||||
for (OverlayCustom overlayCustom : ClientCacheHandler.customOverlays.values()) {
|
||||
overlayCustom.renderGameOverlay(event.partialTicks);
|
||||
}
|
||||
|
||||
if (Client.questTrackingOverlay != null) {
|
||||
Client.questTrackingOverlay.renderGameOverlay(event.partialTicks);
|
||||
if (ClientCacheHandler.questTrackingOverlay != null) {
|
||||
ClientCacheHandler.questTrackingOverlay.renderGameOverlay(event.partialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,8 +91,8 @@ public class ClientEventHandler {
|
||||
if (event.entity instanceof EntityNPCInterface) {
|
||||
data = ClientEventHandler.renderingNpc.display.animationData;
|
||||
} else if (event.entity instanceof EntityPlayer) {
|
||||
if (Client.playerAnimations.containsKey(event.entity.getUniqueID())) {
|
||||
data = Client.playerAnimations.get(event.entity.getUniqueID());
|
||||
if (ClientCacheHandler.playerAnimations.containsKey(event.entity.getUniqueID())) {
|
||||
data = ClientCacheHandler.playerAnimations.get(event.entity.getUniqueID());
|
||||
}
|
||||
|
||||
for (Map.Entry<ModelRenderer,FramePart> entry : ClientEventHandler.originalValues.entrySet()) {
|
||||
@@ -123,8 +124,8 @@ public class ClientEventHandler {
|
||||
AnimationData data = null;
|
||||
if (event.entity instanceof EntityNPCInterface) {
|
||||
data = ((EntityNPCInterface) event.entity).display.animationData;
|
||||
} else if (event.entity instanceof EntityPlayer && Client.playerAnimations.containsKey(event.entity.getUniqueID())) {
|
||||
data = Client.playerAnimations.get(event.entity.getUniqueID());
|
||||
} else if (event.entity instanceof EntityPlayer && ClientCacheHandler.playerAnimations.containsKey(event.entity.getUniqueID())) {
|
||||
data = ClientCacheHandler.playerAnimations.get(event.entity.getUniqueID());
|
||||
}
|
||||
|
||||
if (data != null && data.isActive()) {
|
||||
@@ -199,6 +200,6 @@ public class ClientEventHandler {
|
||||
}
|
||||
|
||||
public static boolean hasOverlays(EntityPlayer player) {
|
||||
return Client.skinOverlays.containsKey(player.getUniqueID()) && Client.skinOverlays.get(player.getUniqueID()).values().size() > 0;
|
||||
return ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID()) && ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values().size() > 0;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,11 @@ package noppes.npcs.client;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
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.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ContainerPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
@@ -30,6 +32,10 @@ public class ClientTickHandler{
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onClientTick(TickEvent.ClientTickEvent event){
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if ((this.prevWorld == null || mc.theWorld == null) && this.prevWorld != mc.theWorld) {
|
||||
ClientCacheHandler.clearCache();
|
||||
this.prevWorld = mc.theWorld;
|
||||
}
|
||||
if(event.phase == Phase.END) {
|
||||
if (mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused() && ClientEventHandler.hasOverlays(mc.thePlayer)) {
|
||||
renderCNPCPlayer.itemRenderer.updateEquippedItem();
|
||||
|
||||
@@ -12,7 +12,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.client.fx.CustomFX;
|
||||
@@ -73,8 +72,8 @@ public class NoppesUtil {
|
||||
HashMap<Integer, SkinOverlay> skinOverlays = new HashMap<>();
|
||||
HashMap<Integer, SkinOverlay> oldOverlays = new HashMap<>();
|
||||
NBTTagList skinOverlayList = compound.getTagList("SkinOverlayData",10);
|
||||
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
oldOverlays = Client.skinOverlays.get(player.getUniqueID());
|
||||
if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
oldOverlays = ClientCacheHandler.skinOverlays.get(player.getUniqueID());
|
||||
}
|
||||
|
||||
for (int i = 0; i < skinOverlayList.tagCount(); i++) {
|
||||
@@ -85,7 +84,7 @@ public class NoppesUtil {
|
||||
}
|
||||
skinOverlays.put(tagID,overlay);
|
||||
}
|
||||
Client.skinOverlays.put(player.getUniqueID(), skinOverlays);
|
||||
ClientCacheHandler.skinOverlays.put(player.getUniqueID(), skinOverlays);
|
||||
}
|
||||
|
||||
public static void spawnScriptedParticle(EntityPlayer player, ByteBuf buffer){
|
||||
|
||||
@@ -265,19 +265,19 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
OverlayCustom overlayCustom = new OverlayCustom(Minecraft.getMinecraft());
|
||||
overlayCustom.setOverlayData(Server.readNBT(buffer));
|
||||
|
||||
Client.customOverlays.put(overlayCustom.overlay.getID(),overlayCustom);
|
||||
ClientCacheHandler.customOverlays.put(overlayCustom.overlay.getID(),overlayCustom);
|
||||
}
|
||||
else if(type == EnumPacketClient.SCRIPT_OVERLAY_CLOSE){
|
||||
int id = buffer.readInt();
|
||||
Client.customOverlays.remove(id);
|
||||
ClientCacheHandler.customOverlays.remove(id);
|
||||
}
|
||||
else if(type == EnumPacketClient.OVERLAY_QUEST_TRACKING){
|
||||
try {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
Client.questTrackingOverlay = new OverlayQuestTracking(Minecraft.getMinecraft());
|
||||
Client.questTrackingOverlay.setOverlayData(compound);
|
||||
ClientCacheHandler.questTrackingOverlay = new OverlayQuestTracking(Minecraft.getMinecraft());
|
||||
ClientCacheHandler.questTrackingOverlay.setOverlayData(compound);
|
||||
} catch (IOException e) {
|
||||
Client.questTrackingOverlay = null;
|
||||
ClientCacheHandler.questTrackingOverlay = null;
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.SWING_PLAYER_ARM){
|
||||
@@ -307,7 +307,7 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
data.readFromNBT(compound);
|
||||
data.animation = new Animation();
|
||||
data.animation.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
Client.playerAnimations.put(sendingPlayer.getUniqueID(), data);
|
||||
ClientCacheHandler.playerAnimations.put(sendingPlayer.getUniqueID(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.glu.Project;
|
||||
@@ -106,8 +106,8 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
|
||||
if (!p_77036_1_.isInvisible())
|
||||
{
|
||||
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (overlayData.texture.isEmpty())
|
||||
continue;
|
||||
|
||||
@@ -271,8 +271,8 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
gender = (float) RenderPlayerJBRA.getMethod("genGet").invoke(null);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (overlayData.texture.isEmpty())
|
||||
continue;
|
||||
|
||||
@@ -398,8 +398,8 @@ public class RenderCNPCPlayer extends RenderPlayer {
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
try {
|
||||
if (Client.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : Client.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (ClientCacheHandler.skinOverlays.containsKey(player.getUniqueID())) {
|
||||
for (SkinOverlay overlayData : ClientCacheHandler.skinOverlays.get(player.getUniqueID()).values()) {
|
||||
if (overlayData.texture.isEmpty())
|
||||
continue;
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ContainerMail extends ContainerNpcInterface{
|
||||
public void onContainerClosed(EntityPlayer player){
|
||||
super.onContainerClosed(player);
|
||||
if(!canEdit && !player.worldObj.isRemote){
|
||||
PlayerMailData data = PlayerDataController.instance.getPlayerData(player).mailData;
|
||||
PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
Iterator<PlayerMail> it = data.playermail.iterator();
|
||||
while(it.hasNext()){
|
||||
PlayerMail mail = it.next();
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ContainerNPCBankInterface extends ContainerNpcInterface
|
||||
|
||||
NpcMiscInventory items = new NpcMiscInventory(54);
|
||||
if(!player.worldObj.isRemote){
|
||||
data = PlayerDataController.instance.getBankData(player,bankid);
|
||||
data = PlayerDataController.Instance.getBankData(player,bankid);
|
||||
items = data.getBankOrDefault(bankid).itemSlots.get(slot);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ import java.io.FileOutputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class GlobalDataController {
|
||||
public static GlobalDataController instance;
|
||||
public static GlobalDataController Instance;
|
||||
|
||||
private int itemGiverId = 0;
|
||||
public HashMap<Integer, JobItemGiver> itemGivers = new HashMap<>();
|
||||
|
||||
public GlobalDataController(){
|
||||
instance = this;
|
||||
Instance = this;
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,15 +9,11 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.controllers.data.*;
|
||||
import noppes.npcs.util.CacheHashMap;
|
||||
import noppes.npcs.util.CustomNPCsThreader;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.*;
|
||||
@@ -29,12 +25,12 @@ import java.util.zip.GZIPInputStream;
|
||||
import static noppes.npcs.util.CustomNPCsThreader.playerDataThread;
|
||||
|
||||
public class PlayerDataController {
|
||||
public static PlayerDataController instance;
|
||||
public static HashMap<String, String> nameUUIDs;
|
||||
private static final CacheHashMap<String, CacheHashMap.CachedObject<PlayerData>> playerDataCache = new CacheHashMap<>(60 * 60 * 1000);
|
||||
public static PlayerDataController Instance;
|
||||
public HashMap<String, String> nameUUIDs;
|
||||
private final CacheHashMap<String, CacheHashMap.CachedObject<PlayerData>> playerDataCache = new CacheHashMap<>(60 * 60 * 1000);
|
||||
|
||||
public PlayerDataController(){
|
||||
instance = this;
|
||||
Instance = this;
|
||||
File dir = getSaveDir();
|
||||
|
||||
LogWriter.info("Loading PlayerData...");
|
||||
@@ -249,13 +245,13 @@ public class PlayerDataController {
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
public static void putPlayerDataCache(final String uuid, final PlayerData playerCompound) {
|
||||
public void putPlayerDataCache(final String uuid, final PlayerData playerCompound) {
|
||||
synchronized (playerDataCache) {
|
||||
playerDataCache.put(uuid, new CacheHashMap.CachedObject<>(playerCompound));
|
||||
}
|
||||
}
|
||||
|
||||
public static PlayerData getPlayerDataCache(final String uuid) {
|
||||
public PlayerData getPlayerDataCache(final String uuid) {
|
||||
synchronized (playerDataCache) {
|
||||
if (!playerDataCache.containsKey(uuid)) {
|
||||
return null;
|
||||
@@ -264,6 +260,12 @@ public class PlayerDataController {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
synchronized (playerDataCache) {
|
||||
playerDataCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerBankData getBankData(EntityPlayer player, int bankId) {
|
||||
Bank bank = BankController.getInstance().getBank(bankId);
|
||||
PlayerBankData data = getPlayerData(player).bankData;
|
||||
@@ -305,13 +307,13 @@ public class PlayerDataController {
|
||||
for(String name : nameUUIDs.keySet()){
|
||||
if(name.equalsIgnoreCase(username)){
|
||||
data = new PlayerData();
|
||||
data.setNBT(PlayerDataController.instance.loadPlayerData(nameUUIDs.get(name)));
|
||||
data.setNBT(PlayerDataController.Instance.loadPlayerData(nameUUIDs.get(name)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
data = PlayerDataController.instance.getPlayerData(player);
|
||||
data = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -329,13 +331,13 @@ public class PlayerDataController {
|
||||
ArrayList<PlayerData> list = new ArrayList<PlayerData>();
|
||||
EntityPlayerMP[] players = PlayerSelector.matchPlayers(sender, username);
|
||||
if(players == null || players.length == 0){
|
||||
PlayerData data = PlayerDataController.instance.getDataFromUsername(username);
|
||||
PlayerData data = PlayerDataController.Instance.getDataFromUsername(username);
|
||||
if(data != null)
|
||||
list.add(data);
|
||||
}
|
||||
else{
|
||||
for(EntityPlayer player : players){
|
||||
list.add(PlayerDataController.instance.getPlayerData(player));
|
||||
list.add(PlayerDataController.Instance.getPlayerData(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +470,7 @@ public class PlayerDataController {
|
||||
}
|
||||
int tenPercent = (int) ((double) length * 0.1);
|
||||
int progress = 0;
|
||||
File saveDir = PlayerDataController.instance.getNewSaveDir();
|
||||
File saveDir = PlayerDataController.Instance.getNewSaveDir();
|
||||
if(saveDir == null){
|
||||
if(sender != null){
|
||||
sender.addChatMessage(new ChatComponentText("playerdata_new folder already exists please delete it or rename it"));
|
||||
|
||||
@@ -21,22 +21,22 @@ import java.util.Vector;
|
||||
public class PlayerQuestController {
|
||||
|
||||
public static boolean hasActiveQuests(EntityPlayer player){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
return !data.activeQuests.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isQuestActive(EntityPlayer player, int quest){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
return data.activeQuests.containsKey(quest);
|
||||
}
|
||||
|
||||
public static boolean isQuestFinished(EntityPlayer player, int questid){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
return data.finishedQuests.containsKey(questid);
|
||||
}
|
||||
|
||||
public static void addActiveQuest(QuestData questData, EntityPlayer player) {
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
if(canQuestBeAccepted(questData.quest, player)){
|
||||
if (EventHooks.onQuestStarted(player, questData.quest)) {
|
||||
return;
|
||||
@@ -58,7 +58,7 @@ public class PlayerQuestController {
|
||||
}
|
||||
|
||||
public static void setQuestFinished(Quest quest, EntityPlayer player){
|
||||
PlayerData playerdata = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData playerdata = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData data = playerdata.questData;
|
||||
QuestData questData = data.activeQuests.get(quest.id);
|
||||
data.activeQuests.remove(quest.id);
|
||||
@@ -83,7 +83,7 @@ public class PlayerQuestController {
|
||||
if(quest == null)
|
||||
return false;
|
||||
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
if(data.activeQuests.containsKey(quest.id))
|
||||
return false;
|
||||
|
||||
@@ -111,7 +111,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 = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
for(QuestData questdata: data.activeQuests.values()){
|
||||
if(questdata.quest == null)
|
||||
continue;
|
||||
|
||||
@@ -185,7 +185,7 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
if(faction == null)
|
||||
return true;
|
||||
|
||||
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
int points = data.getFactionPoints(id);
|
||||
|
||||
EnumAvailabilityFaction current = EnumAvailabilityFaction.Neutral;
|
||||
@@ -207,7 +207,7 @@ public class Availability implements ICompatibilty, IAvailability {
|
||||
public boolean dialogAvailable(int id, EnumAvailabilityDialog en, EntityPlayer player){
|
||||
if(en == EnumAvailabilityDialog.Always)
|
||||
return true;
|
||||
boolean hasRead = PlayerDataController.instance.getPlayerData(player).dialogData.dialogsRead.contains(id);
|
||||
boolean hasRead = PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.contains(id);
|
||||
if(hasRead && en == EnumAvailabilityDialog.After)
|
||||
return true;
|
||||
else if(!hasRead && en == EnumAvailabilityDialog.Before)
|
||||
|
||||
@@ -74,17 +74,17 @@ public class Faction implements IFaction {
|
||||
}
|
||||
|
||||
public boolean isFriendlyToPlayer(EntityPlayer player) {
|
||||
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
return data.getFactionPoints(id) >= friendlyPoints;
|
||||
}
|
||||
|
||||
public boolean isAggressiveToPlayer(EntityPlayer player) {
|
||||
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
return data.getFactionPoints(id) < neutralPoints;
|
||||
}
|
||||
|
||||
public boolean isNeutralToPlayer(EntityPlayer player) {
|
||||
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
int points = data.getFactionPoints(id);
|
||||
return points >= neutralPoints && points < friendlyPoints;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class FactionOptions {
|
||||
if(factionId < 0 && faction2Id < 0)
|
||||
return;
|
||||
|
||||
PlayerFactionData data = PlayerDataController.instance.getPlayerData(player).factionData;
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
if(factionId >= 0 && factionPoints > 0)
|
||||
addPoints(player, data, factionId, decreaseFactionPoints, factionPoints);
|
||||
if(faction2Id >= 0 && faction2Points> 0)
|
||||
|
||||
@@ -7,11 +7,9 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.api.entity.ICustomNpc;
|
||||
import noppes.npcs.api.handler.*;
|
||||
import noppes.npcs.client.renderer.ImageData;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
@@ -21,7 +19,6 @@ import noppes.npcs.entity.data.DataSkinOverlays;
|
||||
import noppes.npcs.entity.data.DataTimers;
|
||||
import noppes.npcs.roles.RoleCompanion;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.util.CacheHashMap;
|
||||
import noppes.npcs.util.CustomNPCsThreader;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
@@ -219,11 +216,11 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
} else {
|
||||
filename = uuid + ".json";
|
||||
}
|
||||
PlayerDataController.instance.putPlayerMap(playername, uuid);
|
||||
PlayerDataController.putPlayerDataCache(uuid, this);
|
||||
PlayerDataController.Instance.putPlayerMap(playername, uuid);
|
||||
PlayerDataController.Instance.putPlayerDataCache(uuid, this);
|
||||
CustomNPCsThreader.playerDataThread.execute(() -> {
|
||||
try {
|
||||
File saveDir = PlayerDataController.instance.getSaveDir();
|
||||
File saveDir = PlayerDataController.Instance.getSaveDir();
|
||||
File file = new File(saveDir, filename + "_new");
|
||||
File file1 = new File(saveDir, filename);
|
||||
if(ConfigMain.DatFormat){
|
||||
@@ -242,9 +239,9 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
NBTTagCompound data = PlayerDataController.instance.loadPlayerData(player.getPersistentID().toString());
|
||||
NBTTagCompound data = PlayerDataController.Instance.loadPlayerData(player.getPersistentID().toString());
|
||||
if(data.hasNoTags()){
|
||||
data = PlayerDataController.instance.loadPlayerDataOld(player.getCommandSenderName());
|
||||
data = PlayerDataController.Instance.loadPlayerDataOld(player.getCommandSenderName());
|
||||
}
|
||||
setNBT(data);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class PlayerItemGiverData implements IPlayerItemGiverData {
|
||||
|
||||
public IJobItemGiver[] getItemGivers() {
|
||||
ArrayList<IJobItemGiver> list = new ArrayList<>();
|
||||
for (JobItemGiver jobItemGiver : GlobalDataController.instance.itemGivers.values()) {
|
||||
for (JobItemGiver jobItemGiver : GlobalDataController.Instance.itemGivers.values()) {
|
||||
if (jobItemGiver.npc != null) {
|
||||
list.add(new ScriptJobItemGiver(jobItemGiver.npc));
|
||||
} else {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class PlayerQuestData implements IPlayerQuestData {
|
||||
}
|
||||
|
||||
public QuestData getQuestCompletion(EntityPlayer player,EntityNPCInterface npc) {
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
for(QuestData data : activeQuests.values()){
|
||||
Quest quest = data.quest;
|
||||
if(quest != null && quest.completion == EnumQuestCompletion.Npc && quest.completerNpc.equals(npc.getCommandSenderName()) && quest.questInterface.isCompleted(playerData)){
|
||||
|
||||
@@ -144,7 +144,7 @@ public class Quest implements ICompatibilty, IQuest {
|
||||
}
|
||||
|
||||
public long getTimeUntilRepeat(EntityPlayer player) {
|
||||
long questTime = PlayerDataController.instance.getPlayerData(player).getQuestData().getLastCompletedTime(this.id);
|
||||
long questTime = PlayerDataController.Instance.getPlayerData(player).getQuestData().getLastCompletedTime(this.id);
|
||||
|
||||
switch (repeat) {
|
||||
case MCDAILY:
|
||||
|
||||
@@ -370,7 +370,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
addInteract(player);
|
||||
|
||||
Dialog dialog = getDialog(player);
|
||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
QuestData data = playerdata.getQuestCompletion(player, this);
|
||||
if (data != null){
|
||||
NoppesUtilPlayer.questCompletion((EntityPlayerMP) player, data.quest.id);
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ItemSoulstoneEmpty extends Item {
|
||||
int p = npc.advanced.minFactionPointsToSoulStone;
|
||||
if (p == -1 && npc.getFaction().isFriendlyToPlayer(player)) return true;
|
||||
else if (p != -1) {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
return data.factionData.getFactionPoints(npc.getFaction().getId()) >= p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ItemSoulstoneFilled extends Item {
|
||||
npc.advanced.soulStonePlayerName = player.getDisplayName();
|
||||
npc.advanced.soulStoneInit = true;
|
||||
if(npc.advanced.role == EnumRoleType.Companion && player != null){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
if(data.hasCompanion())
|
||||
return false;
|
||||
((RoleCompanion)npc.roleInterface).setOwner(player);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package noppes.npcs.mixin;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.ClientEventHandler;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
@@ -110,8 +109,8 @@ public abstract class MixinModelRenderer {
|
||||
if (ClientEventHandler.renderingPlayer != null) {
|
||||
ClientEventHandler.playerModel = ((ModelRenderer) (Object) this).baseModel;
|
||||
}
|
||||
if (ClientEventHandler.renderingPlayer != null && Client.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) {
|
||||
animData = Client.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID());
|
||||
if (ClientEventHandler.renderingPlayer != null && ClientCacheHandler.playerAnimations.containsKey(ClientEventHandler.renderingPlayer.getUniqueID())) {
|
||||
animData = ClientCacheHandler.playerAnimations.get(ClientEventHandler.renderingPlayer.getUniqueID());
|
||||
|
||||
EnumAnimationPart mainPartType = null;
|
||||
try{
|
||||
|
||||
@@ -5,8 +5,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.ClientEventHandler;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
import noppes.npcs.controllers.data.FramePart;
|
||||
@@ -23,8 +22,8 @@ public class MixinRenderPlayer {
|
||||
@Inject(method = "renderLivingAt", at = @At(value = "TAIL"))
|
||||
protected void modelDataRotations(AbstractClientPlayer p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_, CallbackInfo callbackInfo)
|
||||
{
|
||||
if (Client.playerAnimations.containsKey(p_77039_1_.getUniqueID())) {
|
||||
AnimationData animData = Client.playerAnimations.get(p_77039_1_.getUniqueID());
|
||||
if (ClientCacheHandler.playerAnimations.containsKey(p_77039_1_.getUniqueID())) {
|
||||
AnimationData animData = ClientCacheHandler.playerAnimations.get(p_77039_1_.getUniqueID());
|
||||
if (animData != null && animData.isActive()) {
|
||||
Frame frame = (Frame) animData.animation.currentFrame();
|
||||
if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL)) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
if(dialog == null)
|
||||
continue;
|
||||
String title = dialog.title;
|
||||
if(PlayerDataController.instance.getPlayerData(player).dialogData.dialogsRead.contains(dialogId))
|
||||
if(PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.contains(dialogId))
|
||||
title += " (read)";
|
||||
else
|
||||
title += " (unread)";
|
||||
@@ -94,7 +94,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
|
||||
public void setProgress(int progress) {
|
||||
if (progress >= 0 && progress <= 1) {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
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);
|
||||
@@ -118,7 +118,7 @@ public class QuestDialog extends QuestInterface implements IQuestDialog {
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
return data.dialogData.dialogsRead.contains(this.dialog.id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
package noppes.npcs.quests;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.handler.data.IQuestInterface;
|
||||
import noppes.npcs.api.handler.data.IQuestObjective;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||
|
||||
@@ -20,10 +16,10 @@ public abstract class QuestInterface implements IQuestInterface {
|
||||
public abstract void readEntityFromNBT(NBTTagCompound compound);
|
||||
public abstract boolean isCompleted(PlayerData player);
|
||||
public void handleComplete(EntityPlayer player) {
|
||||
PlayerQuestData questData = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
if(questData != null && questData.getTrackedQuest() != null){
|
||||
if (this.questId == PlayerDataController.instance.getPlayerData(player).questData.getTrackedQuest().getId()) {
|
||||
PlayerDataController.instance.getPlayerData(player).questData.untrackQuest();
|
||||
if (this.questId == PlayerDataController.Instance.getPlayerData(player).questData.getTrackedQuest().getId()) {
|
||||
PlayerDataController.Instance.getPlayerData(player).questData.untrackQuest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
@Override
|
||||
public Vector<String> getQuestLogStatus(EntityPlayer player) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
QuestData data = playerdata.activeQuests.get(questId);
|
||||
if(data == null)
|
||||
return vec;
|
||||
@@ -143,7 +143,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
if(questdata != null){
|
||||
@@ -155,7 +155,7 @@ public class QuestKill extends QuestInterface implements IQuestKill {
|
||||
|
||||
public void setProgress(int progress) {
|
||||
if (progress >= 0 && progress <= this.amount) {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData playerdata = data.questData;
|
||||
QuestData questdata = (QuestData)playerdata.activeQuests.get(this.parent.questId);
|
||||
if(questdata != null){
|
||||
|
||||
@@ -53,7 +53,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
@Override
|
||||
public Vector<String> getQuestLogStatus(EntityPlayer player) {
|
||||
Vector<String> vec = new Vector<String>();
|
||||
PlayerQuestData playerdata = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData playerdata = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
QuestData data = playerdata.activeQuests.get(questId);
|
||||
if(data == null)
|
||||
return vec;
|
||||
@@ -160,7 +160,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
|
||||
public void setProgress(int progress) {
|
||||
if (progress >= 0 && progress <= 1) {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
|
||||
boolean completed = questData.extraData.getBoolean (this.nbtName);
|
||||
if ((!completed || progress != 1) && (completed || progress != 0)) {
|
||||
@@ -178,7 +178,7 @@ public class QuestLocation extends QuestInterface implements IQuestLocation {
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
QuestData questData = (QuestData)data.questData.activeQuests.get(this.parent.questId);
|
||||
return questData.extraData.getBoolean(this.nbtName);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class JobItemGiver extends JobInterface{
|
||||
}
|
||||
|
||||
public boolean giveItems(EntityPlayer player){
|
||||
PlayerItemGiverData data = PlayerDataController.instance.getPlayerData(player).itemgiverData;
|
||||
PlayerItemGiverData data = PlayerDataController.Instance.getPlayerData(player).itemgiverData;
|
||||
if(!canPlayerInteract(data)){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class RoleBank extends RoleInterface{
|
||||
|
||||
@Override
|
||||
public void interact(EntityPlayer player) {
|
||||
BankData data = PlayerDataController.instance.getBankData(player,bankId).getBankOrDefault(bankId);
|
||||
BankData data = PlayerDataController.Instance.getBankData(player,bankId).getBankOrDefault(bankId);
|
||||
data.openBankGui(player,npc,bankId,0);
|
||||
npc.say(player, npc.advanced.getInteractLine());
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class RoleCompanion extends RoleInterface {
|
||||
}
|
||||
else if(prev != owner && owner != null){
|
||||
ownerName = owner.getDisplayName();
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(owner);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(owner);
|
||||
if(data.companionID != companionID){
|
||||
npc.isDead = true;
|
||||
}
|
||||
@@ -523,7 +523,7 @@ public class RoleCompanion extends RoleInterface {
|
||||
public void setSelfsuficient(boolean bo){
|
||||
if(owner == null || jobInterface != null && bo == jobInterface.isSelfSufficient())
|
||||
return;
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(owner);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(owner);
|
||||
if(!bo && data.hasCompanion())
|
||||
return;
|
||||
data.setCompanion(bo?null:npc);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class RolePostman extends RoleInterface{
|
||||
recentlyChecked.addAll(toCheck);
|
||||
|
||||
for(EntityPlayer player : toCheck){
|
||||
if(PlayerDataController.instance.hasMail(player))
|
||||
if(PlayerDataController.Instance.hasMail(player))
|
||||
player.addChatMessage(new ChatComponentTranslation("You've got mail"));
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -79,7 +79,7 @@ public class RoleTransporter extends RoleInterface{
|
||||
}
|
||||
|
||||
public void unlock(EntityPlayer player, ITransportLocation loc){
|
||||
PlayerTransportData data = PlayerDataController.instance.getPlayerData(player).transportData;
|
||||
PlayerTransportData data = PlayerDataController.Instance.getPlayerData(player).transportData;
|
||||
if(data.transports.contains(transportId))
|
||||
return;
|
||||
data.transports.add(transportId);
|
||||
|
||||
@@ -73,7 +73,6 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
private static final Map<Integer, ScriptWorld> worldCache = new LRUHashMap<>(10);
|
||||
private static final CacheHashMap<ItemStack, CacheHashMap.CachedObject<ScriptItemStack>> scriptItemCache = new CacheHashMap<>(60*1000);
|
||||
public static final HashMap<String,Object> engineObjects = new HashMap<>();
|
||||
public static final HashMap<UUID,ScriptEntityData> scriptPlayerCache = new HashMap<>();
|
||||
public static final EventBus EVENT_BUS = new EventBus();
|
||||
private static AbstractNpcAPI instance = null;
|
||||
|
||||
@@ -196,16 +195,8 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
ScriptEntityData data = (ScriptEntityData) entity.getExtendedProperties("ScriptedObject");
|
||||
if(data != null)
|
||||
return data.base;
|
||||
if(entity instanceof EntityPlayerMP) {
|
||||
if (!scriptPlayerCache.containsKey(entity.getPersistentID())) {
|
||||
scriptPlayerCache.put(entity.getPersistentID(),new ScriptEntityData(new ScriptPlayer<>((EntityPlayerMP) entity)));
|
||||
}
|
||||
data = scriptPlayerCache.get(entity.getPersistentID());
|
||||
if(data == null){
|
||||
scriptPlayerCache.put(entity.getPersistentID(),new ScriptEntityData(new ScriptPlayer<>((EntityPlayerMP) entity)));
|
||||
data = scriptPlayerCache.get(entity.getPersistentID());
|
||||
}
|
||||
}
|
||||
if(entity instanceof EntityPlayerMP)
|
||||
data = new ScriptEntityData(new ScriptPlayer<>((EntityPlayerMP) entity));
|
||||
else if(PixelmonHelper.isPixelmon(entity))
|
||||
return new ScriptPixelmon<EntityTameable>((EntityTameable) entity);
|
||||
else if(entity instanceof EntityAnimal)
|
||||
|
||||
@@ -187,16 +187,16 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
}
|
||||
|
||||
public boolean hasReadDialog(int id){
|
||||
PlayerDialogData data = PlayerDataController.instance.getPlayerData(player).dialogData;
|
||||
PlayerDialogData data = PlayerDataController.Instance.getPlayerData(player).dialogData;
|
||||
return data.dialogsRead.contains(id);
|
||||
}
|
||||
|
||||
public void readDialog(int id) {
|
||||
PlayerDataController.instance.getPlayerData(player).dialogData.dialogsRead.add(id);
|
||||
PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.add(id);
|
||||
}
|
||||
|
||||
public void unreadDialog(int id) {
|
||||
PlayerDataController.instance.getPlayerData(player).dialogData.dialogsRead.remove(id);
|
||||
PlayerDataController.Instance.getPlayerData(player).dialogData.dialogsRead.remove(id);
|
||||
}
|
||||
|
||||
public boolean hasFinishedQuest(IQuest quest) {
|
||||
@@ -236,12 +236,12 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
}
|
||||
|
||||
public boolean hasFinishedQuest(int id){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
return data.finishedQuests.containsKey(id);
|
||||
}
|
||||
|
||||
public boolean hasActiveQuest(int id){
|
||||
PlayerQuestData data = PlayerDataController.instance.getPlayerData(player).questData;
|
||||
PlayerQuestData data = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
return data.activeQuests.containsKey(id);
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ 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 = PlayerDataController.Instance.getPlayerData(player);
|
||||
if(data.questData.activeQuests.containsKey(id))
|
||||
return;
|
||||
QuestData questdata = new QuestData(quest);
|
||||
@@ -270,7 +270,7 @@ 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 = PlayerDataController.Instance.getPlayerData(player);
|
||||
|
||||
if(quest.repeat == EnumQuestRepeat.RLDAILY || quest.repeat == EnumQuestRepeat.RLWEEKLY)
|
||||
data.questData.finishedQuests.put(quest.id, System.currentTimeMillis());
|
||||
@@ -286,7 +286,7 @@ 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 = PlayerDataController.Instance.getPlayerData(player);
|
||||
data.questData.activeQuests.remove(id);
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ 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 = PlayerDataController.Instance.getPlayerData(player);
|
||||
data.questData.activeQuests.remove(id);
|
||||
data.questData.finishedQuests.remove(id);
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
* @param points The points to increase. Use negative values to decrease
|
||||
*/
|
||||
public void addFactionPoints(int faction, int points){
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
data.factionData.increasePoints(faction, points, player);
|
||||
}
|
||||
/**
|
||||
@@ -325,7 +325,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
* @param points The new point value for this faction
|
||||
*/
|
||||
public void setFactionPoints(int faction, int points) {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
data.factionData.increasePoints(faction, points-getFactionPoints(faction), player);
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
* @return points
|
||||
*/
|
||||
public int getFactionPoints(int faction) {
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
return data.factionData.getFactionPoints(faction);
|
||||
}
|
||||
|
||||
@@ -675,12 +675,12 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
}
|
||||
|
||||
public ITimers getTimers() {
|
||||
return PlayerDataController.instance.getPlayerData(player).timers;
|
||||
return PlayerDataController.Instance.getPlayerData(player).timers;
|
||||
}
|
||||
|
||||
public void updatePlayerInventory() {
|
||||
((EntityPlayerMP)this.entity).inventoryContainer.detectAndSendChanges();
|
||||
PlayerData playerData = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = playerData.questData;
|
||||
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
|
||||
}
|
||||
@@ -688,7 +688,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
@Deprecated
|
||||
public boolean checkGUIOpen() {
|
||||
NoppesUtilPlayer.isGUIOpen(player);
|
||||
PlayerData data = PlayerDataController.instance.getPlayerData(player);
|
||||
PlayerData data = PlayerDataController.Instance.getPlayerData(player);
|
||||
return data.getGUIOpen();
|
||||
}
|
||||
|
||||
@@ -711,7 +711,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
|
||||
public PlayerData getData() {
|
||||
if (this.data == null) {
|
||||
this.data = PlayerDataController.instance.getPlayerData(player);
|
||||
this.data = PlayerDataController.Instance.getPlayerData(player);
|
||||
}
|
||||
|
||||
return this.data;
|
||||
|
||||
Reference in new issue
Block a user