Search in sources :

Example 1 with SimpleLocation

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

the class PlayerLocationManager method onSpawn.

@EventHandler
public void onSpawn(PlayerRespawnEvent 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 2 with SimpleLocation

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

the class LocationBasedTriggerManager method setTriggerForLocation.

protected void setTriggerForLocation(Location loc, T trigger) {
    SimpleLocation sloc = LocationUtil.convertToSimpleLocation(loc);
    setTriggerForLocation(sloc, trigger);
}
Also used : SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation)

Example 3 with SimpleLocation

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

the class JavaPluginBridge method showGlowStones.

@Override
@SuppressWarnings("deprecation")
protected void showGlowStones(ICommandSender sender, Set<Entry<SimpleLocation, Trigger>> set) {
    for (Entry<SimpleLocation, Trigger> entry : set) {
        SimpleLocation sloc = entry.getKey();
        Player player = sender.get();
        player.sendBlockChange(new Location(Bukkit.getWorld(sloc.getWorld()), sloc.getX(), sloc.getY(), sloc.getZ()), Material.GLOWSTONE, (byte) 0);
    }
}
Also used : DelegatedPlayer(io.github.wysohn.triggerreactor.bukkit.tools.DelegatedPlayer) IPlayer(io.github.wysohn.triggerreactor.core.bridge.player.IPlayer) Player(org.bukkit.entity.Player) BukkitPlayer(io.github.wysohn.triggerreactor.bukkit.bridge.player.BukkitPlayer) Trigger(io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager.Trigger) InventoryTrigger(io.github.wysohn.triggerreactor.core.manager.trigger.AbstractInventoryTriggerManager.InventoryTrigger) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) Location(org.bukkit.Location) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation)

Example 4 with SimpleLocation

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

the class AreaSelectionManager method onInteract.

@EventHandler
public void onInteract(PlayerInteractEvent e) {
    Player player = e.getPlayer();
    UUID uuid = player.getUniqueId();
    if (!selecting.contains(uuid))
        return;
    e.setCancelled(true);
    if (!BukkitUtil.isLeftHandClick(e))
        return;
    SimpleLocation sloc = LocationUtil.convertToSimpleLocation(e.getClickedBlock().getLocation());
    ClickResult result = null;
    if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
        result = onClick(ClickAction.LEFT_CLICK_BLOCK, uuid, sloc);
    } else if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
        result = onClick(ClickAction.RIGHT_CLICK_BLOCK, uuid, sloc);
    }
    if (result != null) {
        switch(result) {
            case DIFFERENTWORLD:
                player.sendMessage(ChatColor.RED + "Positions have different world name.");
                break;
            case COMPLETE:
                SimpleLocation left = leftPosition.get(uuid);
                SimpleLocation right = rightPosition.get(uuid);
                SimpleLocation smallest = getSmallest(left, right);
                SimpleLocation largest = getLargest(left, right);
                player.sendMessage(ChatColor.LIGHT_PURPLE + "Smallest: " + smallest + " , Largest: " + largest);
                break;
            case LEFTSET:
                player.sendMessage(ChatColor.GREEN + "Left ready");
                break;
            case RIGHTSET:
                player.sendMessage(ChatColor.GREEN + "Right ready");
                break;
        }
    }
}
Also used : Player(org.bukkit.entity.Player) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) UUID(java.util.UUID) EventHandler(org.bukkit.event.EventHandler)

Example 5 with SimpleLocation

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

the class AbstractAreaTriggerManager method reload.

@Override
public void reload() {
    FileFilter filter = new FileFilter() {

        @Override
        public boolean accept(File pathname) {
            return pathname.getName().endsWith(".yml");
        }
    };
    areaTriggers.clear();
    for (File ymlfile : folder.listFiles(filter)) {
        String triggerName = extractName(ymlfile);
        SimpleLocation smallest = null;
        SimpleLocation largest = null;
        boolean isSync = false;
        try {
            smallest = SimpleLocation.valueOf(getData(ymlfile, SMALLEST));
            largest = SimpleLocation.valueOf(getData(ymlfile, LARGEST));
            isSync = getData(ymlfile, SYNC, false);
        } catch (IOException e) {
            e.printStackTrace();
            plugin.getLogger().warning("Could not load Area Trigger " + ymlfile);
            continue;
        }
        if (smallest == null || largest == null) {
            plugin.getLogger().warning("Could not load Area Trigger" + ymlfile);
            plugin.getLogger().warning("Could not find Smallest: or Largest:");
            continue;
        }
        File scriptFolder = new File(folder, triggerName);
        if (!scriptFolder.exists()) {
            scriptFolder.mkdirs();
        }
        String enterScript = null;
        File enterFile = null;
        try {
            enterFile = getTriggerFile(scriptFolder, "Enter.trg");
            enterScript = FileUtil.readFromFile(enterFile);
        } catch (IOException e1) {
            e1.printStackTrace();
            continue;
        }
        String exitScript = null;
        File exitFile = null;
        try {
            exitFile = getTriggerFile(scriptFolder, "Exit.trg");
            exitScript = FileUtil.readFromFile(exitFile);
        } catch (IOException e1) {
            e1.printStackTrace();
            continue;
        }
        Area area = new Area(smallest, largest);
        AreaTrigger trigger = new AreaTrigger(area, scriptFolder, triggerName);
        trigger.setSync(isSync);
        nameMapper.put(triggerName, trigger);
        this.setupArea(trigger);
        try {
            if (enterScript != null) {
                trigger.setEnterTrigger(enterScript);
            }
        } catch (TriggerInitFailedException e) {
            e.printStackTrace();
            continue;
        }
        try {
            if (exitScript != null) {
                trigger.setExitTrigger(exitScript);
            }
        } catch (TriggerInitFailedException e) {
            e.printStackTrace();
            continue;
        }
    }
}
Also used : Area(io.github.wysohn.triggerreactor.core.manager.location.Area) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) IOException(java.io.IOException) FileFilter(java.io.FileFilter) File(java.io.File)

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