Advertisement
amitay12123

Untitled

Jun 26th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. package me.amitay.MW;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Location;
  9. import org.bukkit.World;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.inventory.ClickType;
  13. import org.bukkit.event.inventory.InventoryClickEvent;
  14.  
  15. public class Inv implements Listener {
  16. private Main plugin;
  17.  
  18. @SuppressWarnings("static-access")
  19. public Inv (Main plugin) {
  20. this.plugin = plugin;
  21. }
  22.  
  23.  
  24. @EventHandler
  25. public void onPlayerClickedBlock (InventoryClickEvent e) {
  26.  
  27.  
  28.  
  29.  
  30. int slot = e.getSlot();
  31. String localWarp="";
  32. List<String> list = plugin.getConfig().getStringList("warpnames");
  33. if (list == null) {
  34. list = new ArrayList<>();
  35. }
  36. if ((slot>=0) && (slot<list.size())) {
  37. localWarp=list.get(slot);
  38. e.getWhoClicked().sendMessage(localWarp);
  39.  
  40. if (e.getClick() == ClickType.LEFT) {
  41. if (e.getClickedInventory() != null) {
  42. if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.BOLD + plugin.getConfig().getString("warps." + localWarp + ".Name"))){
  43. e.setCancelled(true);
  44.  
  45. World world = Bukkit.getWorld(plugin.getConfig().getString("warps." + localWarp + ".world"));
  46. double x = plugin.getConfig().getDouble("warps." + localWarp + ".x");
  47. double y = plugin.getConfig().getDouble("warps." + localWarp + ".y");
  48. double z = plugin.getConfig().getDouble("warps." + localWarp + ".z");
  49. float yaw = (float) plugin.getConfig().getDouble("warps." + localWarp + ".yaw");
  50. float pitch = (float) plugin.getConfig().getDouble("warps." + localWarp + ".pitch");
  51.  
  52. e.getWhoClicked().teleport(new Location(world, x, y, z, yaw, pitch));
  53.  
  54. }
  55.  
  56. }
  57.  
  58. }
  59.  
  60. }
  61.  
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement