-
-
Notifications
You must be signed in to change notification settings - Fork 3
Handling screen interactions
maps 3.3.0 comes with support for handling screen interactions / screen clicks. This feature requires the maps plugin to be installed and enable-click-listener to be set to true in plugins/maps/maps_config.yml.
maps will inject a custom packet listener into each player connection. When the player sends certain interact packets, maps will intercept them and check if the player interacted with a screen. If maps detects a screen interaction it will fire a PlayerClickScreenEvent and wait for the result. If the event is cancelled, maps will drop the packet and prevent the server from ever knowing that the player sent this packet.
Listing for screen interactions is very simple: All you have to do is to listen to the PlayerClickScreenEvent.
Warning: This event is asynchronous. Most of Bukkits API can not be used asynchronously, such as modifying blocks or teleporting players.
public class MyListener implements Listener {
@EventHandler
public void onScreenClick(PlayerClickScreenEvent event) {
Player player = event.getPlayer();
MapScreen screen = event.getClickedScreen();
Vec2 clickPos = event.getClickPos();
int x = clickPos.x;
int y = clickPos.y;
player.sendMessage(String.format("You have clicked screen #%d @ %d, %d", screen.getId(), x, y));
event.setCancelled(true);
}
}- Getting started
- Core classes
- Other
- Examples
- Javadocs
- Concepts
- (Outdated)
"Dirty" maps - (Outdated)
The Advanced Content Change Algorithm
- (Outdated)
- Other
- (Outdated)
Memory usage
- (Outdated)