Skip to content

Commit d2a51a6

Browse files
#948 Better ChunkyBorder checker
1 parent 52b53c1 commit d2a51a6

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/main/java/me/eccentric_nz/TARDIS/utility/protection/TARDISChunkyChecker.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717
package me.eccentric_nz.TARDIS.utility.protection;
1818

1919
import me.eccentric_nz.TARDIS.TARDIS;
20+
import org.bukkit.entity.Player;
2021
import org.popcraft.chunky.platform.BukkitPlayer;
2122
import org.popcraft.chunky.platform.BukkitWorld;
2223
import org.popcraft.chunky.platform.util.Location;
24+
import org.popcraft.chunky.shape.Shape;
25+
import org.popcraft.chunkyborder.BorderData;
2326
import org.popcraft.chunkyborder.ChunkyBorder;
2427
import org.popcraft.chunkyborder.event.server.BlockPlaceEvent;
28+
29+
import java.util.Optional;
30+
2531
/**
2632
* The TARDIS grants its passengers the ability to understand and speak other languages. This is due to the TARDIS's
2733
* telepathic field.
@@ -43,16 +49,20 @@ public TARDISChunkyChecker(TARDIS plugin) {
4349
* @param l the location to check.
4450
* @return true or false depending on whether the location is outside the border
4551
*/
46-
public boolean isOutsideBorder(org.bukkit.entity.Player p, org.bukkit.Location l) {
52+
public boolean isOutsideBorder(Player p, org.bukkit.Location l) {
4753
boolean bool = false;
4854
if (chunky != null) {
49-
final BukkitWorld world = new BukkitWorld(l.getWorld());
50-
final Location location = new Location(world, l.getX(), l.getY(), l.getZ());
51-
final BukkitPlayer player = new BukkitPlayer(p);
52-
final BlockPlaceEvent blockPlaceEvent = new BlockPlaceEvent(player, location);
53-
chunky.getChunky().getEventBus().call(blockPlaceEvent);
54-
if (blockPlaceEvent.isCancelled()) {
55-
return true;
55+
Optional<BorderData> borderData = chunky.getBorder(l.getWorld().getName());
56+
if (borderData.isPresent()) {
57+
Shape border = borderData.get().getBorder();
58+
bool = !border.isBounding(l.getX(), l.getZ());
59+
} else {
60+
final BukkitWorld world = new BukkitWorld(l.getWorld());
61+
final Location location = new Location(world, l.getX(), l.getY(), l.getZ());
62+
final BukkitPlayer player = new BukkitPlayer(p);
63+
final BlockPlaceEvent blockPlaceEvent = new BlockPlaceEvent(player, location);
64+
chunky.getChunky().getEventBus().call(blockPlaceEvent);
65+
bool = blockPlaceEvent.isCancelled();
5666
}
5767
}
5868
return bool;

todo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
| Priority | Feature | Link |
44
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------|
5-
| ![Static Badge](https://img.shields.io/badge/WIP-f90?style=flat-square) | **Update to 1.21.10**<br/>- Update resource pack - fix sonic generator buttons<br/>- Use new Mannequin api?<br/>- Add new blocks to appropriate rooms e.g. firefly bush to Mangrove, dry grass to Iistabul?<br/>- Related to above - [#902](https://github.com/eccentricdevotion/TARDIS/issues/902) Room updates | [#902](https://github.com/eccentricdevotion/TARDIS/issues/902) |
5+
| ![Static Badge](https://img.shields.io/badge/WIP-f90?style=flat-square) | **Update to 1.21.10**<br/>- Use new Mannequin api?<br/>- Add new blocks to appropriate rooms e.g. firefly bush to Mangrove, dry grass to Iistabul?<br/>- Related to above - [#902](https://github.com/eccentricdevotion/TARDIS/issues/902) Room updates | [#902](https://github.com/eccentricdevotion/TARDIS/issues/902) |
66
| ![Static Badge](https://img.shields.io/badge/WIP-f90?style=flat-square) | **Fix bugs**<br/>! | - |
77
| ![Static Badge](https://img.shields.io/badge/1-f00?style=flat-square) | **Time Rotors and 3D Console Improvements**<br/>- Implement custom modelled consoles<br/>- Rotor/Console menu GUI<br/>- Change rotor placement in item frames<br/>- Additional models for cloister and off states | [#916](https://github.com/eccentricdevotion/TARDIS/issues/916) |
88
| ![Static Badge](https://img.shields.io/badge/1-f00?style=flat-square) | **Modelled controls**<br/>- Console lamp done | [#836](https://github.com/eccentricdevotion/TARDIS/issues/836) |

0 commit comments

Comments
 (0)