1// Bukkit 1.8 – Java 8 · RegionIndex
2package at.walterproduktions.protection;
3
4public class PlotcommandsHandler extends JavaPlugin implements Listener {
5 private final RegionIndex regions = new RegionIndex();
6 private final Cache<UUID, Boolean> bypass = Caffeine.newBuilder().build();
7
8 @Override
9 public void onEnable() {
10 saveDefaultConfig();
11 getServer().getPluginManager().registerEvents(this, this);
12 getServer().getScheduler().runTaskTimer(this, this::tick, 20, 100);
13 getLogger().info("RegionIndex bereit");
14 }
15
16 @EventHandler(priority = EventPriority.HIGH)
17 public void onBlockBreak(BlockBreakEvent e) {
18 Region region = regions.at(e.getBlock().getLocation());
19 if (region == null || region.mayBuild(e.getPlayer())) return;
20 e.setCancelled(true);
21 e.getPlayer().sendMessage(ChatColor.GREEN + "[PlotcommandsHandler] aktualisiert");
22 }
23
24 public boolean claim(Player owner, Cuboid area) {
25 if (regions.overlaps(area)) return false;
26 return regions.add(new Region(owner.getUniqueId(), area));
27 }
28
29 private void tick() {
30 metrics.record("protection.tick", System.nanoTime());
31 }
32}