Search in sources :

Example 1 with ChunkNotification

use of com.palmergames.bukkit.towny.ChunkNotification in project Towny by ElgarL.

the class TownyCustomListener method onPlayerChangePlotEvent.

@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerChangePlotEvent(PlayerChangePlotEvent event) {
    Player player = event.getPlayer();
    WorldCoord from = event.getFrom();
    WorldCoord to = event.getTo();
    // TODO: Player mode
    if (plugin.hasPlayerMode(player, "townclaim"))
        TownCommand.parseTownClaimCommand(player, new String[] {});
    if (plugin.hasPlayerMode(player, "townunclaim"))
        TownCommand.parseTownUnclaimCommand(player, new String[] {});
    if (plugin.hasPlayerMode(player, "map"))
        TownyCommand.showMap(player);
    // Check if player has entered a new town/wilderness
    try {
        if (to.getTownyWorld().isUsingTowny() && TownySettings.getShowTownNotifications()) {
            ChunkNotification chunkNotifier = new ChunkNotification(from, to);
            String msg = chunkNotifier.getNotificationString();
            if (msg != null)
                player.sendMessage(msg);
        }
    } catch (NotRegisteredException e) {
        e.printStackTrace();
    }
    if (plugin.hasPlayerMode(player, "plotborder")) {
        CellBorder cellBorder = BorderUtil.getPlotBorder(to);
        cellBorder.runBorderedOnSurface(1, 2, DrawSmokeTaskFactory.sendToPlayer(player));
    }
}
Also used : Player(org.bukkit.entity.Player) WorldCoord(com.palmergames.bukkit.towny.object.WorldCoord) NotRegisteredException(com.palmergames.bukkit.towny.exceptions.NotRegisteredException) CellBorder(com.palmergames.bukkit.towny.object.CellBorder) ChunkNotification(com.palmergames.bukkit.towny.ChunkNotification) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ChunkNotification (com.palmergames.bukkit.towny.ChunkNotification)1 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)1 CellBorder (com.palmergames.bukkit.towny.object.CellBorder)1 WorldCoord (com.palmergames.bukkit.towny.object.WorldCoord)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1