mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 05:15:11 +00:00
-Parties: Kicking, inviting players, setting a leader, friendly fire toggle, and leaving a party are all functional over packets
-Created a new type of achievement that uses the bag icon, used for party messages
This commit is contained in:
1 parent
32d9869d43
commit
4abbb62e69
11 files changed
+224
-73
No files matched your search
@@ -851,6 +851,10 @@ public class NoppesUtilServer {
|
||||
return null;
|
||||
}
|
||||
|
||||
static public EntityPlayer getPlayerByName(String playername){
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152612_a(playername);
|
||||
}
|
||||
|
||||
public static Entity GetDamageSourcee(DamageSource damagesource) {
|
||||
Object entity = damagesource.getEntity();
|
||||
if(entity == null) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import foxz.utils.Market;
|
||||
@@ -123,12 +124,6 @@ public class PacketHandlerServer{
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
compound = party.writeToNBT();
|
||||
|
||||
Quest quest = (Quest) QuestController.Instance.get(party.getCurrentQuestID());
|
||||
if (quest != null) {
|
||||
compound.setString("QuestName", quest.getName());
|
||||
compound.setString("QuestCategory", quest.getCategory().getName());
|
||||
}
|
||||
}
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
} else if (type == EnumPacketServer.DisbandParty) {
|
||||
@@ -140,6 +135,38 @@ public class PacketHandlerServer{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("Disband", true);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, compound);
|
||||
} else if (type == EnumPacketServer.KickPlayer) {
|
||||
EntityPlayer kickPlayer = NoppesUtilServer.getPlayerByName(Server.readString(buffer));
|
||||
if (kickPlayer != null) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
party.removePlayer(kickPlayer);
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, party.writeToNBT());
|
||||
}
|
||||
}
|
||||
} else if (type == EnumPacketServer.SavePartyData) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
party.readClientNBT(Server.readNBT(buffer));
|
||||
}
|
||||
} else if (type == EnumPacketServer.SetPartyLeader) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
if (playerData.partyUUID != null) {
|
||||
Party party = PartyController.Instance().getParty(playerData.partyUUID);
|
||||
party.setLeader(NoppesUtilServer.getPlayerByName(Server.readString(buffer)));
|
||||
Server.sendData(player, EnumPacketClient.GUI_DATA, party.writeToNBT());
|
||||
}
|
||||
} else if (type == EnumPacketServer.PartyInvite) {
|
||||
EntityPlayer invitedPlayer = NoppesUtilServer.getPlayerByName(Server.readString(buffer));
|
||||
if (invitedPlayer != null) {
|
||||
PlayerData senderData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerData invitedData = PlayerDataController.Instance.getPlayerData(invitedPlayer);
|
||||
if (senderData.partyUUID != null && invitedData.partyUUID == null) {//only send invite if player is not in a party
|
||||
invitedData.inviteToParty(PartyController.Instance().getParty(senderData.partyUUID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(type.needsNpc && npc == null){
|
||||
|
||||
@@ -7,6 +7,8 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import noppes.npcs.client.AnalyticsTracking;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
@@ -40,5 +42,18 @@ public class ServerTickHandler {
|
||||
serverName = e;
|
||||
}
|
||||
AnalyticsTracking.sendData(event.player, "join", serverName);
|
||||
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
|
||||
if (playerData != null) {
|
||||
playerData.onLogin();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
|
||||
if (playerData != null) {
|
||||
playerData.onLogout();
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -1,20 +1,27 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import noppes.npcs.CustomItems;
|
||||
|
||||
public class QuestAchievement extends Achievement{
|
||||
public class MessageAchievement extends Achievement{
|
||||
|
||||
private String description;
|
||||
private String message;
|
||||
public QuestAchievement(String message, String description) {
|
||||
super("",message, 0, 0, CustomItems.letter==null?Items.paper:CustomItems.letter, null);
|
||||
|
||||
public MessageAchievement(Item item, String message, String description) {
|
||||
super("",message, 0, 0, item, null);
|
||||
this.description = description;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public MessageAchievement(String message, String description) {
|
||||
this(CustomItems.letter==null ? Items.paper : CustomItems.letter, message, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent func_150951_e()
|
||||
{
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.achievement.GuiAchievement;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -76,10 +77,10 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
|
||||
player.addChatMessage(new ChatComponentTranslation(message));
|
||||
}
|
||||
else if(type == EnumPacketClient.MESSAGE){
|
||||
else if(type == EnumPacketClient.MESSAGE || type == EnumPacketClient.PARTY_MESSAGE){
|
||||
String description = StatCollector.translateToLocal(Server.readString(buffer));
|
||||
String message = Server.readString(buffer);
|
||||
Achievement ach = new QuestAchievement(message, description);
|
||||
Achievement ach = type == EnumPacketClient.MESSAGE ? new MessageAchievement(message, description) : new MessageAchievement(CustomItems.bag == null ? Items.paper : CustomItems.bag, message, description);
|
||||
Minecraft.getMinecraft().guiAchievement.func_146256_a(ach);
|
||||
ObfuscationReflectionHelper.setPrivateValue(GuiAchievement.class, Minecraft.getMinecraft().guiAchievement, ach.getDescription(), 4);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.Client;
|
||||
import noppes.npcs.client.ClientCacheHandler;
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import noppes.npcs.client.gui.SubGuiNpcTextArea;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
@@ -30,6 +29,10 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
|
||||
private boolean receivedData;
|
||||
private long renderTicks;
|
||||
private String selectedPlayer;
|
||||
|
||||
private boolean partyChanged = false;
|
||||
private boolean isLeader;
|
||||
|
||||
public GuiParty(EntityPlayer player) {
|
||||
super();
|
||||
@@ -97,41 +100,49 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
playerScroll.setList(arrayList);
|
||||
this.addScroll(playerScroll);
|
||||
|
||||
//set leader button
|
||||
//
|
||||
GuiNpcButton leaderButton = new GuiNpcButton(305, guiLeft + 5, guiTop + ySize - 12, "party.makeLeader");
|
||||
leaderButton.width = 70;
|
||||
this.addButton(leaderButton);
|
||||
if (this.isLeader) {
|
||||
//set leader button
|
||||
//
|
||||
GuiNpcButton leaderButton = new GuiNpcButton(305, guiLeft + 5, guiTop + ySize - 12, "party.makeLeader");
|
||||
leaderButton.width = 70;
|
||||
this.addButton(leaderButton);
|
||||
|
||||
//kick player button
|
||||
//
|
||||
GuiNpcButton kickButton = new GuiNpcButton(315, guiLeft + 85, guiTop + ySize - 12, "party.kick");
|
||||
kickButton.width = 70;
|
||||
this.addButton(kickButton);
|
||||
//kick player button
|
||||
//
|
||||
GuiNpcButton kickButton = new GuiNpcButton(310, guiLeft + 85, guiTop + ySize - 12, "party.kick");
|
||||
kickButton.width = 70;
|
||||
this.addButton(kickButton);
|
||||
|
||||
//toggle friendly fire
|
||||
//
|
||||
GuiNpcButton friendlyFireButton = new GuiNpcButton(320, guiLeft + xSize/2 + 95, guiTop + ySize/2, new String[] {"gui.on", "gui.off"}, party.friendlyFire() ? 0 : 1);
|
||||
friendlyFireButton.width = 40;
|
||||
this.addButton(friendlyFireButton);
|
||||
//toggle friendly fire
|
||||
//
|
||||
GuiNpcButton friendlyFireButton = new GuiNpcButton(320, guiLeft + xSize / 2 + 95, guiTop + ySize / 2, new String[]{"gui.on", "gui.off"}, party.friendlyFire() ? 0 : 1);
|
||||
friendlyFireButton.width = 40;
|
||||
this.addButton(friendlyFireButton);
|
||||
|
||||
GuiNpcLabel friendlyFireLabel = new GuiNpcLabel(321, StatCollector.translateToLocal("party.friendlyFire") + ":", guiLeft + xSize/2 + 20, guiTop + ySize/2 + 5);
|
||||
this.addLabel(friendlyFireLabel);
|
||||
GuiNpcLabel friendlyFireLabel = new GuiNpcLabel(321, StatCollector.translateToLocal("party.friendlyFire") + ":", guiLeft + xSize / 2 + 20, guiTop + ySize / 2 + 5);
|
||||
this.addLabel(friendlyFireLabel);
|
||||
|
||||
//send invite button (opens subgui)
|
||||
//
|
||||
GuiNpcTextField playerTextField = new GuiNpcTextField(325, this, guiLeft + xSize/2 + 20, guiTop + ySize/2 + 40,100, 20, "");
|
||||
this.addTextField(playerTextField);
|
||||
//send invite button (opens subgui)
|
||||
//
|
||||
GuiNpcTextField playerTextField = new GuiNpcTextField(325, this, guiLeft + xSize / 2 + 20, guiTop + ySize / 2 + 40, 100, 20, "");
|
||||
this.addTextField(playerTextField);
|
||||
|
||||
GuiNpcButton inviteButton = new GuiNpcButton(330, guiLeft + xSize/2 + 125, guiTop + ySize/2 + 40, "party.invite");
|
||||
inviteButton.width = 50;
|
||||
this.addButton(inviteButton);
|
||||
GuiNpcButton inviteButton = new GuiNpcButton(330, guiLeft + xSize / 2 + 125, guiTop + ySize / 2 + 40, "party.invite");
|
||||
inviteButton.width = 50;
|
||||
this.addButton(inviteButton);
|
||||
|
||||
//disband party
|
||||
//
|
||||
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "party.disbandParty");
|
||||
disbandButton.width = 100;
|
||||
this.addButton(disbandButton);
|
||||
//disband party
|
||||
//
|
||||
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "party.leaveParty");
|
||||
disbandButton.width = 100;
|
||||
this.addButton(disbandButton);
|
||||
} else {
|
||||
//leave party
|
||||
//
|
||||
GuiNpcButton disbandButton = new GuiNpcButton(335, guiLeft + xSize/2 + 45, guiTop + ySize/2 + 70, "party.disbandParty");
|
||||
disbandButton.width = 100;
|
||||
this.addButton(disbandButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,11 +152,20 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
if (flag) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
Client.sendData(EnumPacketServer.SetPartyLeader, this.selectedPlayer);
|
||||
break;
|
||||
case 1:
|
||||
Client.sendData(EnumPacketServer.KickPlayer, this.selectedPlayer);
|
||||
break;
|
||||
case 2:
|
||||
Client.sendData(EnumPacketServer.DisbandParty);
|
||||
receivedData = false;
|
||||
initGui();
|
||||
break;
|
||||
case 3:
|
||||
Client.sendData(EnumPacketServer.KickPlayer, this.player.getCommandSenderName());
|
||||
break;
|
||||
}
|
||||
receivedData = false;
|
||||
initGui();
|
||||
}
|
||||
displayGuiScreen(this);
|
||||
}
|
||||
@@ -159,12 +179,37 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
Client.sendData(EnumPacketServer.CreateParty);
|
||||
receivedData = false;
|
||||
break;
|
||||
case 305:
|
||||
if (!party.getPartyLeaderName().equals(this.selectedPlayer)) {
|
||||
GuiYesNo yesnoLeader = new GuiYesNo(this, StatCollector.translateToLocal("party.leaderConfirm"), this.selectedPlayer, 0);
|
||||
displayGuiScreen(yesnoLeader);
|
||||
}
|
||||
break;
|
||||
case 310:
|
||||
if (!party.getPartyLeaderName().equals(this.selectedPlayer)) {
|
||||
GuiYesNo yesnoKick = new GuiYesNo(this, StatCollector.translateToLocal("party.kickConfirm"), this.selectedPlayer, 1);
|
||||
displayGuiScreen(yesnoKick);
|
||||
}
|
||||
break;
|
||||
case 320:
|
||||
party.toggleFriendlyFire();
|
||||
this.partyChanged = true;
|
||||
break;
|
||||
case 330:
|
||||
String inviteName = this.getTextField(325).getText();
|
||||
if (!inviteName.isEmpty() && !party.getPlayerNames(true).contains(inviteName.toLowerCase())) {
|
||||
Client.sendData(EnumPacketServer.PartyInvite, inviteName);
|
||||
this.getTextField(325).setText("");
|
||||
}
|
||||
break;
|
||||
case 335:
|
||||
GuiYesNo guiyesno = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("party.disbandConfirm"), 0);
|
||||
displayGuiScreen(guiyesno);
|
||||
if (this.isLeader) {
|
||||
GuiYesNo yesnoDisband = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("party.disbandConfirm"), 2);
|
||||
displayGuiScreen(yesnoDisband);
|
||||
} else {
|
||||
GuiYesNo yesnoLeave = new GuiYesNo(this, "Confirm", StatCollector.translateToLocal("party.leaveConfirm"), 3);
|
||||
displayGuiScreen(yesnoLeave);
|
||||
}
|
||||
break;
|
||||
}
|
||||
initGui();
|
||||
@@ -233,8 +278,10 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
party = ClientCacheHandler.party;
|
||||
}
|
||||
party.readFromNBT(compound);
|
||||
this.isLeader = ClientCacheHandler.party.getPartyLeaderName().equals(this.player.getCommandSenderName());
|
||||
} else if (compound.hasKey("Disband")) {
|
||||
ClientCacheHandler.party = null;
|
||||
this.isLeader = false;
|
||||
}
|
||||
|
||||
initGui();
|
||||
@@ -248,12 +295,14 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener, IT
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
if (this.partyChanged) {
|
||||
Client.sendData(EnumPacketServer.SavePartyData, ClientCacheHandler.party.writeClientNBT());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int j, int k, GuiCustomScroll guiCustomScroll) {
|
||||
|
||||
this.selectedPlayer = guiCustomScroll.getSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ noppes.npcs.constants;
|
||||
public enum EnumPacketClient {
|
||||
CHAT,
|
||||
MESSAGE,
|
||||
PARTY_MESSAGE,
|
||||
SYNCRECIPES_ADD,
|
||||
SYNCRECIPES_WORKBENCH,
|
||||
DIALOG,
|
||||
|
||||
@@ -95,7 +95,7 @@ public enum EnumPacketServer {
|
||||
|
||||
CustomGuiButton,CustomGuiScrollClick,CustomGuiClose,CustomGuiUnfocused,
|
||||
|
||||
CreateParty, GetPartyData, DisbandParty,
|
||||
SavePartyData, CreateParty, GetPartyData, DisbandParty, KickPlayer, PartyInvite, SetPartyLeader,
|
||||
|
||||
ServerUpdateSkinOverlays;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -27,7 +28,6 @@ public class Party {
|
||||
private final ArrayList<UUID> partyOrder = new ArrayList<>();
|
||||
|
||||
private int currentQuestID = -1;
|
||||
|
||||
private boolean friendlyFire;
|
||||
|
||||
//Client-sided
|
||||
@@ -66,12 +66,10 @@ public class Party {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removePlayer(String playerName) {
|
||||
UUID uuid = getUUID(playerName);
|
||||
if (uuid == null){
|
||||
return false;
|
||||
}
|
||||
public boolean removePlayer(EntityPlayer player) {
|
||||
if (player == null) return false;
|
||||
|
||||
UUID uuid = player.getUniqueID();
|
||||
if(partyMembers.containsKey(uuid)){
|
||||
partyMembers.remove(uuid);
|
||||
partyOrder.remove(uuid);
|
||||
@@ -88,22 +86,8 @@ public class Party {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removePlayer(EntityPlayer player) {
|
||||
UUID uuid = player.getUniqueID();
|
||||
if(partyMembers.containsKey(uuid)){
|
||||
partyMembers.remove(uuid);
|
||||
partyOrder.remove(uuid);
|
||||
|
||||
if(uuid.equals(partyLeader)){
|
||||
if(partyMembers.size() > 0){
|
||||
partyLeader = partyOrder.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
public boolean removePlayer(String playerName) {
|
||||
return playerName != null && this.removePlayer(NoppesUtilServer.getPlayerByName(playerName));
|
||||
}
|
||||
|
||||
public boolean hasPlayer(EntityPlayer player) {
|
||||
@@ -149,7 +133,20 @@ public class Party {
|
||||
}
|
||||
|
||||
public Collection<String> getPlayerNames() {
|
||||
return this.partyMembers.values();
|
||||
return this.getPlayerNames(false);
|
||||
}
|
||||
|
||||
public Collection<String> getPlayerNames(boolean lowercase) {
|
||||
Collection<String> names = this.partyMembers.values();
|
||||
if (!lowercase) {
|
||||
return names;
|
||||
}
|
||||
|
||||
ArrayList<String> lowerNames = new ArrayList<>();
|
||||
for (String s : names) {
|
||||
lowerNames.add(s.toLowerCase());
|
||||
}
|
||||
return lowerNames;
|
||||
}
|
||||
|
||||
public Collection<UUID> getPlayerUUIDs() {
|
||||
@@ -215,6 +212,7 @@ public class Party {
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
this.partyLeaderName = compound.getString("PartyLeader");
|
||||
this.currentQuestID = compound.getInteger("PartyQuestID");
|
||||
this.friendlyFire = compound.getBoolean("FriendlyFire");
|
||||
|
||||
NBTTagList list = compound.getTagList("PartyMembers", 10);
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
@@ -231,7 +229,8 @@ public class Party {
|
||||
|
||||
compound.setString("PartyUUID", this.partyUUID.toString());
|
||||
compound.setInteger("PartyQuestID", this.currentQuestID);
|
||||
compound.setString("PartyLeader", getPartyLeader().getCommandSenderName());
|
||||
compound.setBoolean("FriendlyFire", this.friendlyFire);
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (UUID uuid : this.partyOrder) {
|
||||
NBTTagCompound uuidCompound = new NBTTagCompound();
|
||||
@@ -241,6 +240,25 @@ public class Party {
|
||||
}
|
||||
compound.setTag("PartyMembers", list);
|
||||
|
||||
compound.setString("PartyLeader", getPartyLeader().getCommandSenderName());
|
||||
Quest quest = (Quest) QuestController.Instance.get(this.getCurrentQuestID());
|
||||
if (quest != null) {
|
||||
compound.setString("QuestName", quest.getName());
|
||||
compound.setString("QuestCategory", quest.getCategory().getName());
|
||||
}
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readClientNBT(NBTTagCompound compound) {
|
||||
this.currentQuestID = compound.getInteger("PartyQuestID");
|
||||
this.friendlyFire = compound.getBoolean("FriendlyFire");
|
||||
}
|
||||
|
||||
public NBTTagCompound writeClientNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("PartyQuestID", this.currentQuestID);
|
||||
compound.setBoolean("FriendlyFire", this.friendlyFire);
|
||||
return compound;
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,17 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IExtendedEntityProperties;
|
||||
import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.entity.ICustomNpc;
|
||||
import noppes.npcs.api.handler.*;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
@@ -24,6 +27,7 @@ import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
@@ -41,7 +45,9 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
|
||||
public EntityNPCInterface editingNpc;
|
||||
public NBTTagCompound cloned;
|
||||
|
||||
public UUID partyUUID = null;
|
||||
private final HashSet<UUID> partyInvites = new HashSet<>();
|
||||
|
||||
public EntityPlayer player;
|
||||
|
||||
@@ -55,6 +61,15 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
|
||||
public ScreenSize screenSize = new ScreenSize(-1,-1);
|
||||
|
||||
public void onLogin() {
|
||||
|
||||
}
|
||||
|
||||
public void onLogout() {
|
||||
this.partyUUID = null;
|
||||
this.partyInvites.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveNBTData(NBTTagCompound nbtTagCompound) {
|
||||
}
|
||||
@@ -128,7 +143,7 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
|
||||
@Override
|
||||
public void init(Entity entity, World world) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setGUIOpen(boolean bool) {
|
||||
@@ -180,6 +195,14 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
|
||||
world.spawnEntityInWorld(npc);
|
||||
}
|
||||
|
||||
public void inviteToParty(Party party) {
|
||||
if (party != null && this.partyUUID == null && !this.partyInvites.contains(party.getPartyUUID())) {
|
||||
this.partyInvites.add(party.getPartyUUID());
|
||||
Server.sendData((EntityPlayerMP)this.player, EnumPacketClient.PARTY_MESSAGE, "party.inviteAlert", party.getPartyLeader().getCommandSenderName());
|
||||
Server.sendData((EntityPlayerMP)this.player, EnumPacketClient.CHAT, "party.inviteChat", " ", party.getPartyLeader().getCommandSenderName(), "!");
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompanion(ICustomNpc npc) {
|
||||
this.setCompanion((EntityNPCInterface) npc.getMCEntity());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user