mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 01:05:12 +00:00
fixed crash when hovering over a trader item slot
HashMap.put doesn't work the way I thought it did
This commit is contained in:
1 parent
8c687e7ef5
commit
17fa6328c9
3 files changed
+10
-12
No files matched your search
@@ -68,12 +68,12 @@ public class ContainerNPCTrader extends ContainerNpcInterface{
|
||||
NoppesUtilPlayer.consumeItem(entityplayer, role.inventoryCurrency.getStackInSlot(i + 18), role.ignoreDamage, role.ignoreNBT);
|
||||
ItemStack soldItem = item.copy();
|
||||
givePlayer(soldItem, entityplayer);
|
||||
role.addPurchase(i, entityplayer);
|
||||
role.addPurchase(i, entityplayer.getDisplayName());
|
||||
return soldItem;
|
||||
|
||||
}
|
||||
public boolean isSlotEnabled(int slot, EntityPlayer player) {
|
||||
return role.isSlotEnabled(slot, player);
|
||||
return role.isSlotEnabled(slot, player.getDisplayName());
|
||||
}
|
||||
public boolean canBuy(int slot, EntityPlayer player) {
|
||||
ItemStack currency = role.inventoryCurrency.getStackInSlot(slot);
|
||||
|
||||
@@ -118,23 +118,22 @@ public class RoleTrader extends RoleInterface{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addPurchase(int slot, EntityPlayer player) {
|
||||
public void addPurchase(int slot, String playerName) {
|
||||
if(slot >= 18 || slot < 0) return;
|
||||
++purchases[slot];
|
||||
++getArrayByName(player.getDisplayName(), playerPurchases)[slot];
|
||||
++getArrayByName(playerName, playerPurchases)[slot];
|
||||
}
|
||||
|
||||
public boolean isSlotEnabled(int slot, EntityPlayer player) {
|
||||
public boolean isSlotEnabled(int slot, String playerName) {
|
||||
if(slot >= 18 || slot < 0) return false;
|
||||
if (disableSlot[slot] > 0) return false;
|
||||
if (getArrayByName(player.getDisplayName(), playerDisableSlot)[slot] > 0) return false;
|
||||
if (getArrayByName(playerName, playerDisableSlot)[slot] > 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int[] getArrayByName(String name, HashMap<String, int[]> map) {
|
||||
int[] a = map.get(name);
|
||||
if (a == null) a = map.put(name, new int[18]);
|
||||
return a;
|
||||
if (map.get(name) == null) map.put(name, new int[18]);
|
||||
return map.get(name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import foxz.utils.Market;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.roles.RoleTrader;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.entity.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
||||
|
||||
public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
private RoleTrader role;
|
||||
@@ -160,7 +159,7 @@ public class ScriptRoleTrader extends ScriptRoleInterface{
|
||||
*/
|
||||
public boolean isSlotEnabled(int slot, IPlayer player) {
|
||||
if(slot >= 18 || slot < 0) return false;
|
||||
return role.isSlotEnabled(slot, (EntityPlayer)player.getMCEntity());
|
||||
return role.isSlotEnabled(slot, player.getDisplayName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user