Players can take items from SkyBlock to any other map.

Discussion in 'Plugin Development' started by stefydubstep, Mar 31, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    stefydubstep

    Hi guys,can someone of you help me? On my server i have lots of maps and i want to make it so players can't take items form the skyblock map (Im using the UlitmateSkyBlock plugin).
     
  2. Offline

    sara4012

    stefydubstep I know that this isn't really plugin developing related, but Multiverse-inventories is very easy to set up and does that, along with stats and other stuff like that! Hope this helped!
     
  3. Offline

    _Belknap_

    stefydubstep
    You could try making hashmaps that store the player's name and then their inventory. Basically, you could do this for the HashMaps,
    Code:java
    1. HashMap<String,PlayerInventory> skyblock = new HashMap<String,PlayerInventory>();
    2. HashMap<String,PlayerInventory> othermaps = new HashMap<String,PlayerInventory>();
    3.  

    and then when they join skyblock, it saves their inventory in the othermaps HashMap, then clears that inventory,and sets their inventory to the one saved in the skyblock hashmap
     
  4. Offline

    stefydubstep

    can you tell me what HashMap is ? :D
     
  5. Offline

    _Belknap_

    stefydubstep
    This is what I use them for:
    Ok, so imagine a hashmap it a huge storage area. The first variable in the hashmap is a section in the storage area. So in this case, the player's name, or string is the section of the storage area, and you are putting the player's inventory, or playerinventory, in that section. Unfortunately though, you can only store 1 piece of data per storage section, so every time you add a new piece of data to that particular section, that data that you put in will become the new piece of data. But it works towards your advantage with this, so dont worry about that. Anways, every time a player switches maps, if they go away from skyblock, store their inventory with their name so:
    Code:java
    1. skyblock.put(player.getName(),player.getInventory());

    and then, after you save their inventory as shown above, you would clear it, then set their inventory to their inventory stored in the othermaps with something like this:
    Code:java
    1. //I dont know how to set their inventory, but I'm sure there is a thread in plugin development
    2. p.setInventory(othermaps.get(player.getName()));
    3. //Theres no such thing as setinventory, but I'm using that to show you what to do generally
     
    Norbu10 likes this.
  6. Offline

    Norbu10

    Doesnt this belong to Bukkit Help?
     
  7. Offline

    _Belknap_

    Norbu10 No but this is what I use them for and also what they can be used for in this situation
     
  8. Offline

    stefydubstep

    im new to java dev,i dont know shit,except that i need eclipse and i know a few variables thats all i know...can you help me with that?
     
  9. Offline

    stefydubstep

    well...i cant learn java in a few minutes....so yea,can you help me with that?
     
  10. Offline

    _Belknap_

  11. Offline

    stefydubstep

    anyone ._.
     
  12. Offline

    _Belknap_

  13. stefydubstep Well you can't really do much before you know the basics of Java.
     
  14. Offline

    idontcare1025

    stefydubstep
    Buy a book on Java. However, if you just want to program and aren't set on Bukkit, I think starting with C# would be better.
     
  15. Offline

    JBoss925

    You store the player's name and then their inventory. Now when you go and get the player's name, the hash map returns their inventory. It's like a function table. You put in the x and get out the y. A chart w/ two columns. You find the player name in the left column then go over to the right column and get their inventory. Like that.
     
  16. Offline

    stefydubstep

    @idontcare1025 i already have a book of java,but im too lazy to read it lol but seems that im gonna read it....
     
Thread Status:
Not open for further replies.

Share This Page