mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 09:55:11 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -14,96 +14,95 @@ import noppes.npcs.scripted.event.FactionEvent;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PlayerFactionData implements IPlayerFactionData {
|
||||
private final PlayerData parent;
|
||||
public HashMap<Integer,Integer> factionData = new HashMap<Integer,Integer>();
|
||||
private final PlayerData parent;
|
||||
public HashMap<Integer, Integer> factionData = new HashMap<Integer, Integer>();
|
||||
|
||||
public PlayerFactionData() {
|
||||
parent = null;
|
||||
}
|
||||
public PlayerFactionData() {
|
||||
parent = null;
|
||||
}
|
||||
|
||||
public PlayerFactionData(PlayerData parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
public PlayerFactionData(PlayerData parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
HashMap<Integer,Integer> factionData = new HashMap<Integer,Integer>();
|
||||
if(compound == null)
|
||||
return;
|
||||
public void loadNBTData(NBTTagCompound compound) {
|
||||
HashMap<Integer, Integer> factionData = new HashMap<Integer, Integer>();
|
||||
if (compound == null)
|
||||
return;
|
||||
NBTTagList list = compound.getTagList("FactionData", 10);
|
||||
if(list == null){
|
||||
return;
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
|
||||
factionData.put(nbttagcompound.getInteger("Faction"),nbttagcompound.getInteger("Points"));
|
||||
factionData.put(nbttagcompound.getInteger("Faction"), nbttagcompound.getInteger("Points"));
|
||||
}
|
||||
this.factionData = factionData;
|
||||
}
|
||||
}
|
||||
|
||||
public void saveNBTData(NBTTagCompound compound) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(int faction : factionData.keySet()){
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("Faction", faction);
|
||||
nbttagcompound.setInteger("Points", factionData.get(faction));
|
||||
list.appendTag(nbttagcompound);
|
||||
}
|
||||
|
||||
compound.setTag("FactionData", list);
|
||||
}
|
||||
public void saveNBTData(NBTTagCompound compound) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (int faction : factionData.keySet()) {
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
nbttagcompound.setInteger("Faction", faction);
|
||||
nbttagcompound.setInteger("Points", factionData.get(faction));
|
||||
list.appendTag(nbttagcompound);
|
||||
}
|
||||
|
||||
public int getFactionPoints(int id) {
|
||||
if(!factionData.containsKey(id)){
|
||||
Faction faction = FactionController.getInstance().get(id);
|
||||
factionData.put(id, faction == null? -1 : faction.defaultPoints);
|
||||
}
|
||||
return factionData.get(id);
|
||||
}
|
||||
compound.setTag("FactionData", list);
|
||||
}
|
||||
|
||||
public void increasePoints(int factionId, int points, EntityPlayer player) {
|
||||
if (EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points)))
|
||||
return;
|
||||
public int getFactionPoints(int id) {
|
||||
if (!factionData.containsKey(id)) {
|
||||
Faction faction = FactionController.getInstance().get(id);
|
||||
factionData.put(id, faction == null ? -1 : faction.defaultPoints);
|
||||
}
|
||||
return factionData.get(id);
|
||||
}
|
||||
|
||||
if(!factionData.containsKey(factionId)){
|
||||
Faction faction = FactionController.getInstance().get(factionId);
|
||||
factionData.put(factionId, faction == null? -1 : faction.defaultPoints);
|
||||
}
|
||||
factionData.put(factionId, factionData.get(factionId) + points);
|
||||
}
|
||||
|
||||
public NBTTagCompound getPlayerGuiData(){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
saveNBTData(compound);
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(int id : factionData.keySet()){
|
||||
Faction faction = FactionController.getInstance().get(id);
|
||||
if(faction == null || faction.hideFaction)
|
||||
continue;
|
||||
NBTTagCompound com = new NBTTagCompound();
|
||||
faction.writeNBT(com);
|
||||
list.appendTag(com);
|
||||
}
|
||||
compound.setTag("FactionList", list);
|
||||
|
||||
return compound;
|
||||
}
|
||||
public void increasePoints(int factionId, int points, EntityPlayer player) {
|
||||
if (EventHooks.onFactionPoints(new FactionEvent.FactionPoints((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), FactionController.getInstance().get(factionId), points < 0, points)))
|
||||
return;
|
||||
|
||||
public int getPoints(int id) {
|
||||
return this.getFactionPoints(id);
|
||||
}
|
||||
if (!factionData.containsKey(factionId)) {
|
||||
Faction faction = FactionController.getInstance().get(factionId);
|
||||
factionData.put(factionId, faction == null ? -1 : faction.defaultPoints);
|
||||
}
|
||||
factionData.put(factionId, factionData.get(factionId) + points);
|
||||
}
|
||||
|
||||
public void addPoints(int id, int points) {
|
||||
if (parent != null) {
|
||||
this.increasePoints(id, points, parent.player);
|
||||
}
|
||||
}
|
||||
public NBTTagCompound getPlayerGuiData() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
saveNBTData(compound);
|
||||
|
||||
public void setPoints(int id, int points) {
|
||||
if (parent != null) {
|
||||
increasePoints(id, points-getFactionPoints(id), parent.player);
|
||||
}
|
||||
}
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (int id : factionData.keySet()) {
|
||||
Faction faction = FactionController.getInstance().get(id);
|
||||
if (faction == null || faction.hideFaction)
|
||||
continue;
|
||||
NBTTagCompound com = new NBTTagCompound();
|
||||
faction.writeNBT(com);
|
||||
list.appendTag(com);
|
||||
}
|
||||
compound.setTag("FactionList", list);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
||||
public int getPoints(int id) {
|
||||
return this.getFactionPoints(id);
|
||||
}
|
||||
|
||||
public void addPoints(int id, int points) {
|
||||
if (parent != null) {
|
||||
this.increasePoints(id, points, parent.player);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPoints(int id, int points) {
|
||||
if (parent != null) {
|
||||
increasePoints(id, points - getFactionPoints(id), parent.player);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user