Package net.aufdemrand.denizen.objects

Examples of net.aufdemrand.denizen.objects.dLocation


    @Override
    public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
        // Get objects

        final dLocation location = (dLocation) scriptEntry.getObject("location");
        Element power = (Element) scriptEntry.getObject("power");
        Boolean breakblocks = scriptEntry.hasObject("breakblocks");
        Boolean fire = scriptEntry.hasObject("fire");

        // Report to dB
        dB.report(scriptEntry, getName(),
                (aH.debugObj("location", location.toString()) +
                 aH.debugObj("power", power) +
                 aH.debugObj("breakblocks", breakblocks) +
                 aH.debugObj("fire", fire)));

        location.getWorld().createExplosion
                    (location.getX(), location.getY(), location.getZ(),
                     power.asFloat(), fire, breakblocks);
    }
View Full Code Here


    }

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

        dLocation copy_location = (dLocation) scriptEntry.getObject("location");
        dLocation destination = (dLocation) scriptEntry.getObject("destination");
        dCuboid copy_cuboid = (dCuboid) scriptEntry.getObject("cuboid");
        Element remove_original = (Element) scriptEntry.getObject("remove"); // TODO: Implement?


        List<Location> locations = new ArrayList<Location>();

        if (copy_location != null) locations.add(copy_location);
        else if (copy_cuboid != null) locations.addAll(copy_cuboid.getBlockLocations());


        for (Location loc : locations) {

            Block source = copy_location.getBlock();
            BlockState sourceState = source.getState();
            Block update = destination.getBlock();

            update.setTypeIdAndData(source.getTypeId(), source.getData(), false);

            BlockState updateState = update.getState();
View Full Code Here

        Action action = (Action) scriptEntry.getObject("action");
        Type type = scriptEntry.hasObject("type") ? (Type) scriptEntry.getObject("type") : null;
        Display display = scriptEntry.hasObject("display") ? (Display) scriptEntry.getObject("display") : null;
        final String id = scriptEntry.getObject("id").toString();
        if (viewers.containsKey(id)) scriptEntry.setPlayer(dPlayer.valueOf(viewers.get(id).getContent().split("; ")[1]));
        dLocation location = scriptEntry.hasObject("location") ? (dLocation) scriptEntry.getObject("location") : null;
        String content = scriptEntry.hasObject("display") ? display.toString() + "; " + ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().getOfflinePlayer().getUniqueId() : null;

        switch (action) {

            case CREATE:
                if (viewers.containsKey(id)) {
                    dB.echoDebug(scriptEntry, "Viewer ID " + id + " already exists!");
                    return;
                }

                Viewer viewer = new Viewer(id, content, location);
                viewers.put(id, viewer);

                final Block sign = location.getBlock();
                sign.setType(Material.valueOf(type.name()));

                if (direction != null)
                    Utilities.setSignRotation(sign.getState(), direction);
                else
                    Utilities.setSignRotation(sign.getState());

                int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(DenizenAPI.getCurrentInstance(), new Runnable() {
                    public void run() {
                        Player player = Bukkit.getPlayer(UUID.fromString(viewers.get(id).getContent().split("; ")[1]));
                        if (player == null)
                            Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[]{"", viewers.get(id).getContent().split("; ")[1], "is offline.", ""});
                        else
                            Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[]{String.valueOf((int) player.getLocation().getX()), String.valueOf((int) player.getLocation().getY()), String.valueOf((int) player.getLocation().getZ()), player.getWorld().getName()});

                    }
                }, 0, 20);

                viewer.setTask(task);
                viewer.save();

                break;


            case MODIFY:
                if (!viewers.containsKey(id)) {
                    dB.echoDebug(scriptEntry, "Viewer ID " + id + " doesn't exist!");
                    return;
                }
                if (content != null) viewers.get(id).setContent(content);
                if (location != null) {
                    if (type == null) type = Type.valueOf(viewers.get(id).getLocation().getBlock().getType().name());
                    Bukkit.getScheduler().cancelTask(viewers.get(id).getTask());
                    int newTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(DenizenAPI.getCurrentInstance(), new Runnable() {
                        public void run() {
                            Player player = Bukkit.getPlayer(UUID.fromString(viewers.get(id).getContent().split("; ")[1]));
                            if (player == null)
                                Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[]{"", viewers.get(id).getContent().split("; ")[1], "is offline.", ""});
                            else
                                Utilities.setSignLines((Sign) viewers.get(id).getLocation().getBlock().getState(), new String[]{String.valueOf((int) player.getLocation().getX()), String.valueOf((int) player.getLocation().getY()), String.valueOf((int) player.getLocation().getZ()), player.getWorld().getName()});

                        }
                    }, 0, 20);
                    viewers.get(id).getLocation().getBlock().setType(Material.AIR);
                    viewers.get(id).setLocation(location);
                    viewers.get(id).setTask(newTask);
                    location.getBlock().setType(Material.valueOf(type.name()));
                }

                break;

            case REMOVE:
View Full Code Here

            }
    }

    @EventHandler
    public static void blockBreak(BlockBreakEvent event) {
        dLocation location = new dLocation(event.getBlock().getLocation());
        for (Viewer viewer : viewers.values())
            if (Utilities.isBlock(location, viewer.getLocation())) {
                event.getPlayer().sendMessage(ChatColor.RED + "You're not allowed to break that sign.");
                event.setCancelled(true);
            }
View Full Code Here

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

        // Fetch required objects
        Element required_integer = scriptEntry.getElement("required_integer");
        dLocation required_location = scriptEntry.getdObject("required_location");

        // Debug the execution
        dB.report(scriptEntry, getName(), required_integer.debug()
                                          + required_location.debug());

        // Do the execution

        // INSERT
        // YOUR
View Full Code Here

        // Get objects
        String direction = scriptEntry.hasObject("direction") ? ((Element) scriptEntry.getObject("direction")).asString() : null;
        Element typeElement = scriptEntry.getElement("type");
        dList text = (dList) scriptEntry.getObject("text");
        dLocation location = (dLocation) scriptEntry.getObject("location");

        // Report to dB
        dB.report(scriptEntry, getName(), typeElement.debug()
                                          + location.debug()
                                          + text.debug());

        Type type = Type.valueOf(typeElement.asString().toUpperCase());
        Block sign = location.getBlock();
        if (type != Type.AUTOMATIC
                || (sign.getType() != Material.WALL_SIGN
                && sign.getType() != Material.SIGN_POST))
            sign.setType(type == Type.WALL_SIGN ? Material.WALL_SIGN: Material.SIGN_POST);
        BlockState signState = sign.getState();
View Full Code Here

    @Override
    public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {

        // Get objects
        List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
        dLocation location = (dLocation) scriptEntry.getObject("location");
        dEntity target = (dEntity) scriptEntry.getObject("target");
        Element spread = scriptEntry.getElement("spread");
        boolean persistent = scriptEntry.hasObject("persistent");

        // Report to dB
        dB.report(scriptEntry, getName(), aH.debugObj("entities", entities.toString()) +
                              location.debug() +
                             (spread != null  ?spread.debug() : "") +
                             (target != null ? target.debug() : "") +
                             (persistent ? aH.debugObj("persistent", "true") : ""));

        // Keep a dList of entities that can be called using <entry[name].spawned_entities>
        // later in the script queue

        dList entityList = new dList();

        // Go through all the entities and spawn them or teleport them,
        // then set their targets if applicable

        for (dEntity entity : entities) {
            Location loc = location.clone();
            if (spread != null) {
                loc.add(CoreUtilities.getRandom().nextInt(spread.asInt() * 2) - spread.asInt(),
                        0,
                        CoreUtilities.getRandom().nextInt(spread.asInt() * 2) - spread.asInt());
            }
View Full Code Here

    public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {

        // Get objects
        List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
        dEntity holder = null;
        dLocation holderLoc = null;
        Entity Holder = null;
        Object holderObject = scriptEntry.getObject("holder");
        if (holderObject instanceof dEntity) {
            holder = (dEntity) scriptEntry.getObject("holder");
            Holder = holder.getBukkitEntity();
        }
        else if (holderObject instanceof dLocation) {
            holderLoc = ((dLocation)scriptEntry.getObject("holder"));
            if (holderLoc.getBlock().getType() == Material.FENCE || holderLoc.getBlock().getType() == Material.NETHER_FENCE)
                Holder = holderLoc.getWorld().spawn(holderLoc, LeashHitch.class);
            else {
                dB.echoError(scriptEntry.getResidingQueue(), "Bad holder location specified - only fences are permitted!");
                return;
            }
        }
View Full Code Here

    }

    @Override
    public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {

        dLocation location = scriptEntry.getdObject("location");
        Element katch = scriptEntry.getElement("catch");
        Element stop = scriptEntry.getElement("stop");
        Element percent = scriptEntry.getElement("percent");

        dNPC npc = ((BukkitScriptEntryData)scriptEntry.entryData).getNPC();
        FishingTrait trait = npc.getFishingTrait();

        dB.report(scriptEntry, getName(), location.debug() + katch.debug() + percent.debug() + stop.debug());

        if (stop.asBoolean()) {
            trait.stopFishing();
            return;
        }
View Full Code Here

        // Get objects
        TargetType target = (TargetType) scriptEntry.getObject("target");
        dNPC npc = ((BukkitScriptEntryData)scriptEntry.entryData).getNPC();
        Action action = (Action) scriptEntry.getObject("action");
        String id = (String) scriptEntry.getObject("pose_id");
        dLocation pose_loc = (dLocation) scriptEntry.getObject("pose_loc");

        // Report to dB
        dB.report(scriptEntry, getName(),
                aH.debugObj("Target", target.toString())
                        + (target == TargetType.PLAYER ? ((BukkitScriptEntryData)scriptEntry.entryData).getPlayer().debug() : "")
                        + npc.debug()
                        + aH.debugObj("Action", action.toString())
                        + aH.debugObj("Id", id)
                        + (pose_loc != null ? pose_loc.debug() : ""));

        if (!npc.getCitizen().hasTrait(Poses.class))
            npc.getCitizen().addTrait(Poses.class);

        Poses poses = npc.getCitizen().getTrait(Poses.class);
View Full Code Here

TOP

Related Classes of net.aufdemrand.denizen.objects.dLocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.