mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 18:49:39 +00:00
Full Imports and Code Format Optimization
This commit is contained in:
1 parent
250edf099c
commit
6815f579a7
1192 files changed
+60344
-62167
No files matched your search
@@ -15,292 +15,275 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PlayerMail implements IInventory, IPlayerMail {
|
||||
public String subject = "";
|
||||
public String sender = "";
|
||||
public NBTTagCompound message = new NBTTagCompound();
|
||||
public long time = 0;
|
||||
public boolean beenRead = false;
|
||||
public int questId = -1;
|
||||
public String questTitle = "";
|
||||
public ItemStack[] items = new ItemStack[4];
|
||||
public String subject = "";
|
||||
public String sender = "";
|
||||
public NBTTagCompound message = new NBTTagCompound();
|
||||
public long time = 0;
|
||||
public boolean beenRead = false;
|
||||
public int questId = -1;
|
||||
public String questTitle = "";
|
||||
public ItemStack[] items = new ItemStack[4];
|
||||
|
||||
public long timePast;
|
||||
public long timePast;
|
||||
|
||||
public void readNBT(NBTTagCompound compound) {
|
||||
subject = compound.getString("Subject");
|
||||
sender = compound.getString("Sender");
|
||||
time = compound.getLong("Time");
|
||||
beenRead = compound.getBoolean("BeenRead");
|
||||
message = compound.getCompoundTag("Message");
|
||||
timePast = compound.getLong("TimePast");
|
||||
if(compound.hasKey("MailQuest"))
|
||||
questId = compound.getInteger("MailQuest");
|
||||
questTitle = compound.getString("MailQuestTitle");
|
||||
public void readNBT(NBTTagCompound compound) {
|
||||
subject = compound.getString("Subject");
|
||||
sender = compound.getString("Sender");
|
||||
time = compound.getLong("Time");
|
||||
beenRead = compound.getBoolean("BeenRead");
|
||||
message = compound.getCompoundTag("Message");
|
||||
timePast = compound.getLong("TimePast");
|
||||
if (compound.hasKey("MailQuest"))
|
||||
questId = compound.getInteger("MailQuest");
|
||||
questTitle = compound.getString("MailQuestTitle");
|
||||
|
||||
this.items = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
NBTTagList nbttaglist = compound.getTagList("MailItems", 10);
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
int j = nbttagcompound1.getByte("Slot") & 255;
|
||||
|
||||
if (j >= 0 && j < this.items.length)
|
||||
{
|
||||
if (j >= 0 && j < this.items.length) {
|
||||
this.items[j] = NoppesUtilServer.readItem(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("Subject", subject);
|
||||
compound.setString("Sender", sender);
|
||||
compound.setLong("Time", time);
|
||||
compound.setBoolean("BeenRead", beenRead);
|
||||
compound.setTag("Message", message);
|
||||
compound.setLong("TimePast", System.currentTimeMillis() - time);
|
||||
compound.setInteger("MailQuest", questId);
|
||||
public NBTTagCompound writeNBT() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("Subject", subject);
|
||||
compound.setString("Sender", sender);
|
||||
compound.setLong("Time", time);
|
||||
compound.setBoolean("BeenRead", beenRead);
|
||||
compound.setTag("Message", message);
|
||||
compound.setLong("TimePast", System.currentTimeMillis() - time);
|
||||
compound.setInteger("MailQuest", questId);
|
||||
|
||||
if(hasQuest())
|
||||
compound.setString("MailQuestTitle", getQuest().title);
|
||||
if (hasQuest())
|
||||
compound.setString("MailQuestTitle", getQuest().title);
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < this.items.length; ++i)
|
||||
{
|
||||
if (this.items[i] != null)
|
||||
{
|
||||
for (int i = 0; i < this.items.length; ++i) {
|
||||
if (this.items[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte)i);
|
||||
NoppesUtilServer.writeItem(this.items[i], nbttagcompound1);
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
NoppesUtilServer.writeItem(this.items[i], nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
compound.setTag("MailItems", nbttaglist);
|
||||
return compound;
|
||||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
public boolean isValid(){
|
||||
return !subject.isEmpty() && !message.hasNoTags() && !sender.isEmpty();
|
||||
}
|
||||
public boolean isValid() {
|
||||
return !subject.isEmpty() && !message.hasNoTags() && !sender.isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasQuest() {
|
||||
return getQuest() != null;
|
||||
}
|
||||
public Quest getQuest() {
|
||||
return QuestController.Instance != null?QuestController.Instance.quests.get(questId):null;
|
||||
}
|
||||
public boolean hasQuest() {
|
||||
return getQuest() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 4;
|
||||
}
|
||||
public Quest getQuest() {
|
||||
return QuestController.Instance != null ? QuestController.Instance.quests.get(questId) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int var1) {
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int var1) {
|
||||
return this.items[var1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2) {
|
||||
if (this.items[par1] != null)
|
||||
{
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2) {
|
||||
if (this.items[par1] != null) {
|
||||
ItemStack itemstack;
|
||||
|
||||
if (this.items[par1].stackSize <= par2)
|
||||
{
|
||||
if (this.items[par1].stackSize <= par2) {
|
||||
itemstack = this.items[par1];
|
||||
this.items[par1] = null;
|
||||
this.markDirty();
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
itemstack = this.items[par1].splitStack(par2);
|
||||
|
||||
if (this.items[par1].stackSize == 0)
|
||||
{
|
||||
if (this.items[par1].stackSize == 0) {
|
||||
this.items[par1] = null;
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1) {
|
||||
if (this.items[var1] != null)
|
||||
{
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1) {
|
||||
if (this.items[var1] != null) {
|
||||
ItemStack itemstack = this.items[var1];
|
||||
this.items[var1] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
|
||||
@Override
|
||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
|
||||
this.items[par1] = par2ItemStack;
|
||||
|
||||
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
|
||||
{
|
||||
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) {
|
||||
par2ItemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
@Override
|
||||
public void markDirty() {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
@Override
|
||||
public void openInventory() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int var1, ItemStack var2) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int var1, ItemStack var2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public PlayerMail copy() {
|
||||
PlayerMail mail = new PlayerMail();
|
||||
mail.readNBT(writeNBT());
|
||||
return mail;
|
||||
}
|
||||
public PlayerMail copy() {
|
||||
PlayerMail mail = new PlayerMail();
|
||||
mail.readNBT(writeNBT());
|
||||
return mail;
|
||||
}
|
||||
|
||||
public void setPageText(String[] pages) {
|
||||
NBTTagList bookPages = new NBTTagList();
|
||||
for (String text : pages) {
|
||||
bookPages.appendTag(new NBTTagString(text));
|
||||
}
|
||||
public void setPageText(String[] pages) {
|
||||
NBTTagList bookPages = new NBTTagList();
|
||||
for (String text : pages) {
|
||||
bookPages.appendTag(new NBTTagString(text));
|
||||
}
|
||||
|
||||
message.setTag("pages", bookPages);
|
||||
}
|
||||
message.setTag("pages", bookPages);
|
||||
}
|
||||
|
||||
public String[] getPageText() {
|
||||
NBTTagList bookPages = new NBTTagList();
|
||||
public String[] getPageText() {
|
||||
NBTTagList bookPages = new NBTTagList();
|
||||
|
||||
if(message.hasKey("pages"))
|
||||
bookPages = message.getTagList("pages", 8);
|
||||
if (message.hasKey("pages"))
|
||||
bookPages = message.getTagList("pages", 8);
|
||||
|
||||
if (bookPages != null)
|
||||
{
|
||||
bookPages = (NBTTagList)bookPages.copy();
|
||||
ArrayList<String> pageStrings = new ArrayList<>();
|
||||
if (bookPages != null) {
|
||||
bookPages = (NBTTagList) bookPages.copy();
|
||||
ArrayList<String> pageStrings = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < bookPages.tagCount(); i++) {
|
||||
pageStrings.add(bookPages.getStringTagAt(i));
|
||||
}
|
||||
for (int i = 0; i < bookPages.tagCount(); i++) {
|
||||
pageStrings.add(bookPages.getStringTagAt(i));
|
||||
}
|
||||
|
||||
return pageStrings.toArray(new String[0]);
|
||||
} else {
|
||||
return new String[]{""};
|
||||
}
|
||||
}
|
||||
return pageStrings.toArray(new String[0]);
|
||||
} else {
|
||||
return new String[]{""};
|
||||
}
|
||||
}
|
||||
|
||||
public int getPageCount() {
|
||||
NBTTagList bookPages = new NBTTagList();
|
||||
public int getPageCount() {
|
||||
NBTTagList bookPages = new NBTTagList();
|
||||
|
||||
if(message.hasKey("pages"))
|
||||
bookPages = message.getTagList("pages", 8);
|
||||
if (message.hasKey("pages"))
|
||||
bookPages = message.getTagList("pages", 8);
|
||||
|
||||
int bookTotalPages = 0;
|
||||
if (bookPages != null)
|
||||
{
|
||||
bookPages = (NBTTagList)bookPages.copy();
|
||||
bookTotalPages = bookPages.tagCount();
|
||||
int bookTotalPages = 0;
|
||||
if (bookPages != null) {
|
||||
bookPages = (NBTTagList) bookPages.copy();
|
||||
bookTotalPages = bookPages.tagCount();
|
||||
|
||||
if (bookTotalPages < 1)
|
||||
{
|
||||
bookTotalPages = 1;
|
||||
}
|
||||
if (bookTotalPages < 1) {
|
||||
bookTotalPages = 1;
|
||||
}
|
||||
|
||||
return bookTotalPages;
|
||||
}
|
||||
return bookTotalPages;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setSender(String sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
public void setSender(String sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public long getTimePast() {
|
||||
return timePast;
|
||||
}
|
||||
public long getTimePast() {
|
||||
return timePast;
|
||||
}
|
||||
|
||||
public long getTimeSent() {
|
||||
return time;
|
||||
}
|
||||
public long getTimeSent() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public IItemStack[] getItems() {
|
||||
ArrayList<IItemStack> list = new ArrayList<>();
|
||||
for (ItemStack itemStack : items) {
|
||||
list.add(NpcAPI.Instance().getIItemStack(itemStack));
|
||||
}
|
||||
public IItemStack[] getItems() {
|
||||
ArrayList<IItemStack> list = new ArrayList<>();
|
||||
for (ItemStack itemStack : items) {
|
||||
list.add(NpcAPI.Instance().getIItemStack(itemStack));
|
||||
}
|
||||
|
||||
return list.toArray(new IItemStack[0]);
|
||||
}
|
||||
return list.toArray(new IItemStack[0]);
|
||||
}
|
||||
|
||||
public void setItems(IItemStack[] items) {
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
for (IItemStack itemStack : items) {
|
||||
list.add(itemStack.getMCItemStack());
|
||||
}
|
||||
public void setItems(IItemStack[] items) {
|
||||
ArrayList<ItemStack> list = new ArrayList<>();
|
||||
for (IItemStack itemStack : items) {
|
||||
list.add(itemStack.getMCItemStack());
|
||||
}
|
||||
|
||||
this.items = list.toArray(new ItemStack[0]);
|
||||
}
|
||||
this.items = list.toArray(new ItemStack[0]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user