Skip to content

Commit

Permalink
fix aura modules in legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 9, 2025
1 parent 2609868 commit bdde47d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,9 @@ private void onPlayerInteract(PlayerInteractEvent event) {
if (event.getItem() == null || event.getItem().getType() != XMaterial.GLOWSTONE.get()) return;
if (WorldUtil.isRespawnAnchorWorks(event.getPlayer().getWorld())) return;

if (
breakCooldowns.containsKey(event.getPlayer().getUniqueId())
&& breakCooldowns.get(event.getPlayer().getUniqueId()) > System.nanoTime()
) {
if (isOnCooldown(event.getPlayer().getUniqueId(), breakCooldowns, breakDelayNanos)) {
event.setCancelled(true);
if (updateInventory) event.getPlayer().updateInventory();
} else {
breakCooldowns.put(event.getPlayer().getUniqueId(), System.nanoTime() + breakDelayNanos);
}
}

Expand All @@ -39,14 +34,9 @@ private void onBlockPlace(BlockPlaceEvent event) {
if (event.getBlock().getType() != XMaterial.RESPAWN_ANCHOR.get()) return;
if (WorldUtil.isRespawnAnchorWorks(event.getPlayer().getWorld())) return;

if (
placeCooldowns.containsKey(event.getPlayer().getUniqueId())
&& placeCooldowns.get(event.getPlayer().getUniqueId()) > System.nanoTime()
) {
if (isOnCooldown(event.getPlayer().getUniqueId(), placeCooldowns, placeDelayNanos)) {
event.setCancelled(true);
if (updateInventory) event.getPlayer().updateInventory();
} else {
placeCooldowns.put(event.getPlayer().getUniqueId(), System.nanoTime() + placeDelayNanos);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public AuraDelayModule(String configPath, boolean defEnabled, long defPlaceDelay
this.updateInventory = config.getBoolean(configPath + ".update-inventory-on-cancel", false,
"Can help with desync but recommended to leave off unless you have issues.");
placeDelayNanos = TimeUnit.MILLISECONDS.toNanos(
config.getLong(".place-delay-millis", defPlaceDelayMillis, "1 tick = 50 ms"));
config.getLong(configPath + ".place-delay-millis", defPlaceDelayMillis, "1 tick = 50 ms"));
breakDelayNanos = TimeUnit.MILLISECONDS.toNanos(
config.getLong(".break-delay-millis", defBreakDelayMillis));
config.getLong(configPath + ".break-delay-millis", defBreakDelayMillis));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ private void onPlayerInteract(PlayerInteractEvent event) {
if (!MaterialUtil.BEDS.contains(event.getClickedBlock().getType())) return;
if (WorldUtil.isBedWorks(event.getClickedBlock().getWorld())) return;

if (
breakCooldowns.containsKey(event.getPlayer().getUniqueId())
&& breakCooldowns.get(event.getPlayer().getUniqueId()) > System.nanoTime()
) {
if (isOnCooldown(event.getPlayer().getUniqueId(), breakCooldowns, breakDelayNanos)) {
event.setCancelled(true);
if (updateInventory) event.getPlayer().updateInventory();
} else {
breakCooldowns.put(event.getPlayer().getUniqueId(), System.nanoTime() + breakDelayNanos);
}
}

Expand All @@ -38,14 +33,9 @@ private void onBlockPlace(BlockPlaceEvent event) {
if (!MaterialUtil.BEDS.contains(event.getBlockPlaced().getType())) return;
if (WorldUtil.isBedWorks(event.getBlockPlaced().getWorld())) return;

if (
placeCooldowns.containsKey(event.getPlayer().getUniqueId())
&& placeCooldowns.get(event.getPlayer().getUniqueId()) > System.nanoTime()
) {
if (isOnCooldown(event.getPlayer().getUniqueId(), placeCooldowns, placeDelayNanos)) {
event.setCancelled(true);
if (updateInventory) event.getPlayer().updateInventory();
} else {
placeCooldowns.put(event.getPlayer().getUniqueId(), System.nanoTime() + placeDelayNanos);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ private void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event.getEntityType() != XEntityType.END_CRYSTAL.get()) return;
if (event.getDamager().getType() != XEntityType.PLAYER.get()) return;

if (
breakCooldowns.containsKey(event.getDamager().getUniqueId())
&& breakCooldowns.get(event.getDamager().getUniqueId()) > System.nanoTime()
) {
if (isOnCooldown(event.getDamager().getUniqueId(), breakCooldowns, placeDelayNanos)) {
event.setCancelled(true);
if (updateInventory) ((Player) event.getDamager()).updateInventory();
} else {
breakCooldowns.put(event.getDamager().getUniqueId(), System.nanoTime() + breakDelayNanos);
}
}

Expand All @@ -38,14 +33,9 @@ private void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; // Need to right-click a block to place a crystal
if (event.getItem() == null || event.getItem().getType() != XMaterial.END_CRYSTAL.get()) return;

if (
placeCooldowns.containsKey(event.getPlayer().getUniqueId())
&& placeCooldowns.get(event.getPlayer().getUniqueId()) > System.nanoTime()
) {
if (isOnCooldown(event.getPlayer().getUniqueId(), placeCooldowns, placeDelayNanos)) {
event.setCancelled(true);
if (updateInventory) event.getPlayer().updateInventory();
} else {
placeCooldowns.put(event.getPlayer().getUniqueId(), System.nanoTime() + placeDelayNanos);
}
}
}

0 comments on commit bdde47d

Please sign in to comment.