Advertisement
MEMEDGOD

Untitled

Apr 26th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. package nl._deurklink_.kingdombuild;
  2.  
  3. import com.sk89q.worldedit.Vector;
  4. import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
  5. import java.util.ArrayList;
  6. import java.util.Date;
  7. import java.util.HashMap;
  8. import org.bukkit.Bukkit;
  9. import org.bukkit.ChatColor;
  10. import org.bukkit.Location;
  11. import org.bukkit.Material;
  12. import org.bukkit.Server;
  13. import org.bukkit.World;
  14. import org.bukkit.configuration.file.FileConfiguration;
  15. import org.bukkit.entity.Player;
  16. import org.bukkit.inventory.ItemStack;
  17. import org.bukkit.inventory.PlayerInventory;
  18. import org.bukkit.inventory.meta.ItemMeta;
  19. import org.bukkit.scheduler.BukkitScheduler;
  20.  
  21. public class Koth
  22. {
  23. private String name;
  24. private Player capper;
  25. private int timer;
  26. private Date startTime;
  27.  
  28. public Koth() {}
  29.  
  30. public Koth(String n)
  31. {
  32. this.name = n;
  33. this.timer = Integer.parseInt(Main.r.c.getString("koth." + this.name + ".time"));
  34. this.startTime = null;
  35. Main.r.Koths.put(this.name, this);
  36. }
  37.  
  38. public void claim(Player p)
  39. {
  40. this.startTime = new Date();
  41. this.capper = p;
  42. Main.r.Koths.put(this.name, this);
  43. p.sendMessage(ChatColor.GREEN + "Blijf in de koth, je bent hem aan het cappen.");
  44. }
  45.  
  46. public void reset()
  47. {
  48. this.capper.sendMessage(ChatColor.RED + "Je bent gestopt met het cappen van " + this.name + ".");
  49. this.capper = null;
  50. this.startTime = null;
  51. Main.r.Koths.put(this.name, this);
  52. }
  53.  
  54. public String getName()
  55. {
  56. return this.name;
  57. }
  58.  
  59. public Player getCapper()
  60. {
  61. return this.capper;
  62. }
  63.  
  64. public int getTimer()
  65. {
  66. int timePassed = this.startTime != null ? (int)((new Date().getTime() - this.startTime.getTime()) / 1000L) : 0;
  67. if (this.timer - timePassed > 0) {
  68. return this.timer - timePassed;
  69. }
  70. ItemStack reward = new ItemStack(Material.getMaterial(Main.r.c.getString("kothreward.item").toUpperCase()), Main.r.c.getInt("kothreward.amount"), (byte)Main.r.c.getInt("kothreward.itemData"));
  71. ItemMeta m = reward.getItemMeta();
  72. m.setDisplayName(ChatColor.translateAlternateColorCodes('&', Main.r.c.getString("kothreward.name")));
  73. ArrayList<String> lore = new ArrayList();
  74. for (String str : Main.r.c.getStringList("kothreward.lore")) {
  75. lore.add(ChatColor.translateAlternateColorCodes('&', str));
  76. }
  77. m.setLore(lore);
  78. reward.setItemMeta(m);
  79. Main.r.getServer().getScheduler().runTaskLater(Main.r, new Runnable()
  80. {
  81. public void run()
  82. {
  83. Main.r.Koths.remove(Koth.this.name);
  84. }
  85. }, 1L);
  86.  
  87. this.capper.getInventory().addItem(new ItemStack[] { reward });
  88. return 0;
  89. }
  90.  
  91. public boolean isInKoth(Player p)
  92. {
  93. World w = Bukkit.getWorld(Main.r.c.getString("koth." + this.name + ".world"));
  94. Location locA = new Location(w, Main.r.c.getInt("koth." + this.name + ".x1"), Main.r.c.getInt("koth." + this.name + ".y1"), Main.r.c.getInt("koth." + this.name + ".z1"));
  95. Location locB = new Location(w, Main.r.c.getInt("koth." + this.name + ".x2"), Main.r.c.getInt("koth." + this.name + ".y2"), Main.r.c.getInt("koth." + this.name + ".z2"));
  96. CuboidSelection s = new CuboidSelection(w, locA, locB);
  97.  
  98. Vector min = s.getNativeMinimumPoint();
  99. Vector max = s.getNativeMaximumPoint();
  100. if (p.getWorld() == w) {
  101. if ((min.getBlockX() <= p.getLocation().getBlockX()) && (max.getBlockX() >= p.getLocation().getBlockX())) {
  102. if ((min.getBlockY() <= p.getLocation().getBlockY()) && (max.getBlockY() >= p.getLocation().getBlockY())) {
  103. if ((min.getBlockZ() <= p.getLocation().getBlockZ()) && (max.getBlockZ() >= p.getLocation().getBlockZ())) {
  104. return true;
  105. }
  106. }
  107. }
  108. }
  109. return false;
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement