Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nuriofernandez/grechworldareas

Spigot Minecraft server plugin that allows other plugins to work with world areas. Detecting player joins/leaves block breaks, etc.
https://github.com/nuriofernandez/grechworldareas

areas bukkit bukkit-plugin bukkitdev events minecraft-plugin permissions spigot world-protection

Last synced: 2 days ago
JSON representation

Spigot Minecraft server plugin that allows other plugins to work with world areas. Detecting player joins/leaves block breaks, etc.

Awesome Lists containing this project

README

        

# GrechWorldAreas
Spigot Minecraft server plugin that allows other plugins to work with world areas. Detecting player joins/leaves block breaks, etc.

# Area definition

```yml
name: "Redo"
uuid: "63b4809c-b73e-4a26-a106-4e722fe9c454"
areas:
1:
end:
w: "world"
x: 1
y: 100
z: 1
yaw: 0
pitch: 0
start:
w: "world"
x: 3
y: 100
z: 3
yaw: 0
pitch: 0
```

# Checking areas for location

```java
@EventHandler
public void onBlockClick(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;

Player player = event.getPlayer();
Location clickedBlock = event.getClickedBlock().getLocation();

List areas = worldAreaFactory.fromLocation(clickedBlock);
String areasNames = areas.stream().map(WorldArea::getName).collect(Collectors.joining(","));

player.sendMessage(ChatColor.translateAlternateColorCodes(
'&', "&cYou have clicked at a block inside: &a"+areasNames
));
}
```

# Listening to an area movement event

```java
@EventHandler
public void onJoin(PlayerJoinAreaEvent event) {
Player player = event.getPlayer();
WorldArea area = event.getWorldArea();

String message = ChatColor.translateAlternateColorCodes(
'&', "&aYou joined to &e" + area.getName()
);
player.sendTitle("World Areas", message, 1, 20, 1);
}

@EventHandler
public void onLeave(PlayerLeaveAreaEvent event) {
Player player = event.getPlayer();
WorldArea area = event.getWorldArea();

String message = ChatColor.translateAlternateColorCodes(
'&', "&cYou left to &e" + area.getName()
);
player.sendTitle("World Areas", message, 1, 20, 1);
}
```

## Demonstration of results:

Player joining and leaving from a world area