Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //From Tile Entity
- @Override
- public void updateEntity() {
- if (cardStack!=null){
- NBTTagCompound tag = cardStack.stackTagCompound;
- if (tag == null) tag = new NBTTagCompound();
- boolean isCardLinked = tag.getBoolean(NBTTags.Card.IS_LINKED_TAG);
- if (!isCardLinked&&player!=null){
- GameProfile profile = player.getGameProfile();
- if (profile!=null) {
- UUID id = profile.getId();
- if (!id.equals(new UUID(0L,0L))) {
- BankAccount account = new BankAccount(this, id);
- //if (account!=null) {
- tag.setTag(NBTTags.Card.ACCOUNTS_TAG, BankAccount.toNBT(account, true));
- tag.setBoolean(NBTTags.Card.IS_LINKED_TAG, true);
- //tag.setString(NBTTags.Card.NAME_TAG,player.getDisplayName());
- cardStack.stackTagCompound = tag;
- this.addAccount(account);
- markForUpDate();
- //}
- }
- }
- }
- if (currencyStack!=null){
- if (tick >= time){
- long ownerIDLeast, ownerIDMost;
- NBTTagCompound ownerTag = tag.getCompoundTag(NBTTags.Card.ACCOUNTS_TAG).getCompoundTag(NBTTags.Card.UUID_OWNER_TAG);
- ownerIDLeast = ownerTag.getLong(NBTTags.Card.UUID_LEAST_TAG);
- ownerIDMost = ownerTag.getLong(NBTTags.Card.UUID_MOST_TAG);
- UUID id = new UUID(ownerIDMost,ownerIDLeast);
- BankAccount account = getAccount(id);
- if (account!=null) {
- account.addCredit(getValue(currencyStack.getItem()));
- decrStackSize(1, 1);
- }
- markForUpDate();
- tick = 0;
- } else tick++;
- }else tick = 0;
- }else tick = 0;
- }
- // From Item
- @Override
- public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) {
- NBTTagCompound tag = stack.stackTagCompound;
- if (tag != null) {
- if (tag.hasKey(NBTTags.Card.ACCOUNTS_TAG)) {
- NBTTagCompound accountTag = tag.getCompoundTag(NBTTags.Card.ACCOUNTS_TAG);
- BankAccount account = BankAccount.fromNBT(accountTag, null);
- if (account!=null) {
- if (account.getPlayer() != null) list.add("Owner: " + ((account.getPlayer()==player) ? EnumChatFormatting.GREEN : EnumChatFormatting.DARK_RED) + account.getPlayer().getDisplayName());
- else{
- CompletableFuture<String> playerName;
- long ownerIDLeast, ownerIDMost;
- NBTTagCompound ownerTag = tag.getCompoundTag(NBTTags.Card.UUID_OWNER_TAG);
- ownerIDLeast = ownerTag.getLong(NBTTags.Card.UUID_LEAST_TAG);
- ownerIDMost = ownerTag.getLong(NBTTags.Card.UUID_MOST_TAG);
- UUID id = new UUID(ownerIDMost,ownerIDLeast);
- playerName = UsernameCache.get(id);
- String name;
- if (playerName.isDone()) {
- try {name = playerName.get();}
- catch (InterruptedException |
- ExecutionException e) {name = "<"+id+">";e.printStackTrace();}
- } else name = "<"+id+">";
- list.add("Owner: " + EnumChatFormatting.DARK_RED + name);
- }
- if (account.getBank()!=null) list.add("Bank: " + EnumChatFormatting.GREEN + account.getBank().getName());
- else list.add("Bank: " + EnumChatFormatting.DARK_RED + "Bankrupt");
- list.add(String.format("Credit: %s\u20a9%.3f",
- ((account.getCredit() > 0) ? EnumChatFormatting.GREEN :
- ((account.getCredit() < 0) ? EnumChatFormatting.DARK_RED :
- EnumChatFormatting.YELLOW)),
- account.getCredit()));
- } else {
- LogHelper.warn("Account not found.");
- NBTTagCompound ownerTag = accountTag.getCompoundTag(NBTTags.Card.UUID_OWNER_TAG);
- long ownerIDLeast = ownerTag.getLong(NBTTags.Card.UUID_LEAST_TAG);
- long ownerIDMost = ownerTag.getLong(NBTTags.Card.UUID_MOST_TAG);
- UUID id = new UUID(ownerIDMost, ownerIDLeast);
- list.add("Owner: " + EnumChatFormatting.DARK_RED + id);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment