Tag Info

Hot answers tagged

4

You could try to accomplish it by looping through player's inventor and checking if Nth slot in his inventory is empty, if it isn't -- the function returns false. private boolean hasItems(ItemStack item) { for (int i=0; i<=thePlayer.inventory.getSizeInventory()-5; i++) { if (thePlayer.inventory.mainInventory[i].itemId != NULL) { ...


4

The objects in collections in Java are usually indexed starting with zero. Also, the method .size() returns the numbers of elements inside the collection. So, if the size is 1, you can only access the element 0. Not 0 and 1 like you're doing, because the element 1 do not exist. Try this: for(int i = 0; i < staffOnline.size(); i++) { // changed here ...


2

Vanilla Minecraft implemented seamless relative teleports recently (link), you might be able to get away with just having the server execute a command: Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tp player 0 0 0");


2

I have seen this before and I am pretty sure that its because you are getting every item in inventory including the empty ones which return null. inv.getContents() gets everything. Add an if statement inside your for loop to check that they arent null before doing anything with the item.


1

There is an open source plugin called VoxelPort that does this, see here: https://github.com/TVPT/VoxelPort/tree/master/src/main/java/com/thevoxelbox/voxelport It uses Zones as you suggested, and each "Port" calculates whether a player is inside the region & if they are holding the appropriate key. To prevent tons of lag, it has 2 types of ports. ...



Only top voted, non community-wiki answers of a minimum length are eligible