Search in sources :

Example 11 with SimpleLocation

use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.

the class LocationBasedTriggerManager method showTriggerInfo.

@Override
protected void showTriggerInfo(ICommandSender sender, SimpleLocation sloc) {
    Trigger trigger = getTriggerForLocation(sloc);
    if (trigger == null) {
        return;
    }
    Location loc = LocationUtil.convertToBukkitLocation(sloc);
    Block clicked = loc.getBlock();
    sender.sendMessage("- - - - - - - - - - - - - -");
    sender.sendMessage("Trigger: " + getTriggerTypeName());
    sender.sendMessage("Block Type: " + clicked.getType().name());
    sender.sendMessage("Location: " + clicked.getWorld().getName() + "@" + clicked.getLocation().getBlockX() + "," + clicked.getLocation().getBlockY() + "," + clicked.getLocation().getBlockZ());
    sender.sendMessage("");
    sender.sendMessage("Script:");
    sender.sendMessage(trigger.getScript());
    sender.sendMessage("- - - - - - - - - - - - - -");
}
Also used : Trigger(io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager.Trigger) Block(org.bukkit.block.Block) Location(org.bukkit.Location) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) SimpleChunkLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleChunkLocation)

Example 12 with SimpleLocation

use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.

the class WalkTriggerManager method handleWalk.

private void handleWalk(PlayerBlockLocationEvent e, SimpleLocation to) {
    Player player = e.getPlayer();
    SimpleLocation bottomLoc = to.clone();
    bottomLoc.add(0, -1, 0);
    WalkTrigger trigger = getTriggerForLocation(bottomLoc);
    if (trigger == null)
        return;
    Map<String, Object> varMap = new HashMap<>();
    varMap.put("player", player);
    varMap.put("from", e.getFrom());
    varMap.put("to", e.getTo());
    trigger.activate(e, varMap);
    return;
}
Also used : Player(org.bukkit.entity.Player) HashMap(java.util.HashMap) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation)

Example 13 with SimpleLocation

use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.

the class PlayerLocationManager method onTeleport.

@EventHandler
public void onTeleport(PlayerChangedWorldEvent e) {
    Player player = e.getPlayer();
    Location loc = player.getLocation();
    SimpleLocation sloc = LocationUtil.convertToSimpleLocation(loc);
    setCurrentBlockLocation(player.getUniqueId(), sloc);
}
Also used : Player(org.bukkit.entity.Player) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 14 with SimpleLocation

use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.

the class PlayerLocationManager method onMove.

@EventHandler(priority = EventPriority.HIGHEST)
public void onMove(PlayerMoveEvent e) {
    if (e.getTo() == e.getFrom())
        return;
    Player player = e.getPlayer();
    SimpleLocation from = getCurrentBlockLocation(player.getUniqueId());
    SimpleLocation to = LocationUtil.convertToSimpleLocation(e.getTo());
    PlayerBlockLocationEvent pble = new PlayerBlockLocationEvent(player, from, to);
    onMove(new BukkitPlayerBlockLocationEvent(pble));
    if (pble.isCancelled()) {
        Location loc = LocationUtil.convertToBukkitLocation(from);
        loc.setPitch(e.getPlayer().getLocation().getPitch());
        loc.setYaw(e.getPlayer().getLocation().getPitch());
        e.setFrom(loc);
        e.setTo(loc);
    }
}
Also used : BukkitPlayerBlockLocationEvent(io.github.wysohn.triggerreactor.bukkit.bridge.event.BukkitPlayerBlockLocationEvent) PlayerBlockLocationEvent(io.github.wysohn.triggerreactor.bukkit.manager.event.PlayerBlockLocationEvent) BukkitPlayerBlockLocationEvent(io.github.wysohn.triggerreactor.bukkit.bridge.event.BukkitPlayerBlockLocationEvent) Player(org.bukkit.entity.Player) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 15 with SimpleLocation

use of io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation in project TriggerReactor by wysohn.

the class PlayerLocationManager method onJoin.

@EventHandler(priority = EventPriority.LOW)
public void onJoin(PlayerJoinEvent e) {
    Player player = e.getPlayer();
    Location loc = player.getLocation();
    SimpleLocation sloc = LocationUtil.convertToSimpleLocation(loc);
    setCurrentBlockLocation(player.getUniqueId(), sloc);
}
Also used : Player(org.bukkit.entity.Player) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

SimpleLocation (io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation)20 Location (org.bukkit.Location)8 Player (org.bukkit.entity.Player)8 SimpleChunkLocation (io.github.wysohn.triggerreactor.core.manager.location.SimpleChunkLocation)7 EventHandler (org.bukkit.event.EventHandler)5 IOException (java.io.IOException)4 Trigger (io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager.Trigger)3 File (java.io.File)3 Area (io.github.wysohn.triggerreactor.core.manager.location.Area)2 HashMap (java.util.HashMap)2 BukkitPlayerBlockLocationEvent (io.github.wysohn.triggerreactor.bukkit.bridge.event.BukkitPlayerBlockLocationEvent)1 BukkitPlayer (io.github.wysohn.triggerreactor.bukkit.bridge.player.BukkitPlayer)1 PlayerBlockLocationEvent (io.github.wysohn.triggerreactor.bukkit.manager.event.PlayerBlockLocationEvent)1 DelegatedPlayer (io.github.wysohn.triggerreactor.bukkit.tools.DelegatedPlayer)1 IPlayer (io.github.wysohn.triggerreactor.core.bridge.player.IPlayer)1 InventoryTrigger (io.github.wysohn.triggerreactor.core.manager.trigger.AbstractInventoryTriggerManager.InventoryTrigger)1 FileFilter (java.io.FileFilter)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 UUID (java.util.UUID)1