Advertisement
Guest User

Untitled

a guest
Jul 10th, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. package Mainp;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandExecutor;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.configuration.file.FileConfiguration;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.inventory.ItemStack;
  11.  
  12. public class test implements CommandExecutor{
  13.  
  14. @Override
  15. public boolean onCommand( CommandSender s, Command cmd, String lable, String[] args) {
  16.  
  17. if(s instanceof Player) {
  18.  
  19.  
  20. Player p = (Player)s;
  21.  
  22. FileConfiguration config = Main.GetPlugin().getConfig();
  23.  
  24. @SuppressWarnings("unchecked")
  25. ArrayList<ItemStack> content = (ArrayList<ItemStack>) config.getList("inventar");
  26. ItemStack[] items = new ItemStack[content.size()];
  27. for (int i = 0; i < content.size(); i++) {
  28. ItemStack item = content.get(i);
  29. if (item != null) {
  30. items[i] = item;
  31. } else {
  32. items[i] = null;
  33. }
  34. }
  35.  
  36. p.getInventory().setContents(items);
  37.  
  38. config.set("inventar", p.getInventory().getContents());
  39.  
  40. config.set("World", p.getWorld().getName());
  41.  
  42. Main.GetPlugin().saveConfig();
  43.  
  44.  
  45. } else {
  46. s.sendMessage("stop");
  47. }
  48. return false;
  49. }
  50.  
  51.  
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement