Search in sources :

Example 61 with Location

use of org.bukkit.Location in project Minigames by AddstarMC.

the class SetFloorDegeneratorCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
    if (args != null) {
        Player player = (Player) sender;
        if (args[0].equals("1")) {
            Location loc = player.getLocation().clone();
            loc.setY(loc.getY() - 1);
            minigame.setFloorDegen1(loc);
            sender.sendMessage(ChatColor.GRAY + "Floor degenerator corner 1 has been set for " + minigame);
        } else if (args[0].equals("2")) {
            Location loc = player.getLocation().clone();
            loc.setY(loc.getY() - 1);
            minigame.setFloorDegen2(loc);
            sender.sendMessage(ChatColor.GRAY + "Floor degenerator corner 2 has been set for " + minigame);
        } else if (args[0].equalsIgnoreCase("clear")) {
            minigame.setFloorDegen1(null);
            minigame.setFloorDegen2(null);
            sender.sendMessage(ChatColor.GRAY + "Floor degenerator corners have been removed for " + minigame);
        } else if (args[0].equalsIgnoreCase("type") && args.length >= 2) {
            if (args[1].equalsIgnoreCase("random") || args[1].equalsIgnoreCase("inward") || args[1].equalsIgnoreCase("circle")) {
                minigame.setDegenType(args[1].toLowerCase());
                if (args.length > 2 && args[2].matches("[0-9]+")) {
                    minigame.setDegenRandomChance(Integer.parseInt(args[2]));
                }
                sender.sendMessage(ChatColor.GRAY + "Floor degenerator type has been set to " + args[1] + " in " + minigame);
            } else {
                sender.sendMessage(ChatColor.RED + "Invalid floor degenerator type!");
                sender.sendMessage(ChatColor.GRAY + "Possible types: \"inward\", \"circle\" and \"random\".");
            }
        } else if (args[0].equalsIgnoreCase("time") && args.length >= 2) {
            if (args[1].matches("[0-9]+")) {
                int time = Integer.parseInt(args[1]);
                minigame.setFloorDegenTime(time);
                sender.sendMessage(ChatColor.GRAY + "Floor degeneration time has been set to " + MinigameUtils.convertTime(time));
            }
        } else {
            sender.sendMessage(ChatColor.RED + "Error: Invalid floor degenerator command!");
        }
        return true;
    }
    return false;
}
Also used : Player(org.bukkit.entity.Player) Location(org.bukkit.Location)

Example 62 with Location

use of org.bukkit.Location in project Minigames by AddstarMC.

the class LocationFlag method loadValue.

@Override
public void loadValue(String path, FileConfiguration config) {
    double x = config.getDouble(path + "." + getName() + ".x");
    double y = config.getDouble(path + "." + getName() + ".y");
    double z = config.getDouble(path + "." + getName() + ".z");
    float yaw = ((Double) config.getDouble(path + "." + getName() + ".yaw")).floatValue();
    float pitch = ((Double) config.getDouble(path + "." + getName() + ".pitch")).floatValue();
    String world = config.getString(path + "." + getName() + ".world");
    setFlag(new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch));
}
Also used : Location(org.bukkit.Location)

Example 63 with Location

use of org.bukkit.Location in project Minigames by AddstarMC.

the class SimpleLocationFlag method loadValue.

@Override
public void loadValue(String path, FileConfiguration config) {
    double x = config.getDouble(path + "." + getName() + ".x");
    double y = config.getDouble(path + "." + getName() + ".y");
    double z = config.getDouble(path + "." + getName() + ".z");
    String world = config.getString(path + "." + getName() + ".world");
    setFlag(new Location(Bukkit.getWorld(world), x, y, z));
}
Also used : Location(org.bukkit.Location)

Example 64 with Location

use of org.bukkit.Location in project Minigames by AddstarMC.

the class RegionModule method load.

@Override
public void load(FileConfiguration config) {
    if (config.contains(getMinigame() + ".regions")) {
        Set<String> rs = config.getConfigurationSection(getMinigame() + ".regions").getKeys(false);
        for (String name : rs) {
            String cloc1 = getMinigame() + ".regions." + name + ".point1.";
            String cloc2 = getMinigame() + ".regions." + name + ".point2.";
            World w1 = Minigames.plugin.getServer().getWorld(config.getString(cloc1 + "world"));
            World w2 = Minigames.plugin.getServer().getWorld(config.getString(cloc2 + "world"));
            double x1 = config.getDouble(cloc1 + "x");
            double x2 = config.getDouble(cloc2 + "x");
            double y1 = config.getDouble(cloc1 + "y");
            double y2 = config.getDouble(cloc2 + "y");
            double z1 = config.getDouble(cloc1 + "z");
            double z2 = config.getDouble(cloc2 + "z");
            Location loc1 = new Location(w1, x1, y1, z1);
            Location loc2 = new Location(w2, x2, y2, z2);
            regions.put(name, new Region(name, loc1, loc2));
            Region r = regions.get(name);
            if (config.contains(getMinigame() + ".regions." + name + ".tickDelay")) {
                r.changeTickDelay(config.getLong(getMinigame() + ".regions." + name + ".tickDelay"));
            }
            if (config.contains(getMinigame() + ".regions." + name + ".executors")) {
                Set<String> ex = config.getConfigurationSection(getMinigame() + ".regions." + name + ".executors").getKeys(false);
                for (String i : ex) {
                    String path = getMinigame() + ".regions." + name + ".executors." + i;
                    RegionExecutor rex = new RegionExecutor(Triggers.getTrigger(config.getString(path + ".trigger")));
                    if (config.contains(path + ".actions")) {
                        for (String a : config.getConfigurationSection(path + ".actions").getKeys(false)) {
                            ActionInterface ai = Actions.getActionByName(config.getString(path + ".actions." + a + ".type"));
                            ai.loadArguments(config, path + ".actions." + a + ".arguments");
                            rex.addAction(ai);
                        }
                    }
                    if (config.contains(path + ".conditions")) {
                        for (String c : config.getConfigurationSection(path + ".conditions").getKeys(false)) {
                            ConditionInterface ci = Conditions.getConditionByName(config.getString(path + ".conditions." + c + ".type"));
                            ci.loadArguments(config, path + ".conditions." + c + ".arguments");
                            rex.addCondition(ci);
                        }
                    }
                    if (config.contains(path + ".isTriggeredPerPlayer"))
                        rex.setTriggerPerPlayer(config.getBoolean(path + ".isTriggeredPerPlayer"));
                    if (config.contains(path + ".triggerCount"))
                        rex.setTriggerCount(config.getInt(path + ".triggerCount"));
                    r.addExecutor(rex);
                }
            }
        }
    }
    if (config.contains(getMinigame() + ".nodes")) {
        Set<String> rs = config.getConfigurationSection(getMinigame() + ".nodes").getKeys(false);
        for (String name : rs) {
            String cloc1 = getMinigame() + ".nodes." + name + ".point.";
            World w1 = Minigames.plugin.getServer().getWorld(config.getString(cloc1 + "world"));
            double x1 = config.getDouble(cloc1 + "x");
            double y1 = config.getDouble(cloc1 + "y");
            double z1 = config.getDouble(cloc1 + "z");
            float yaw = 0f;
            float pitch = 0f;
            if (config.contains(cloc1 + "yaw")) {
                //TODO: Remove check after next dev build
                yaw = ((Double) config.getDouble(cloc1 + "yaw")).floatValue();
                pitch = ((Double) config.getDouble(cloc1 + "pitch")).floatValue();
            }
            Location loc1 = new Location(w1, x1, y1, z1, yaw, pitch);
            nodes.put(name, new Node(name, loc1));
            Node n = nodes.get(name);
            if (config.contains(getMinigame() + ".nodes." + name + ".executors")) {
                Set<String> ex = config.getConfigurationSection(getMinigame() + ".nodes." + name + ".executors").getKeys(false);
                for (String i : ex) {
                    String path = getMinigame() + ".nodes." + name + ".executors." + i;
                    NodeExecutor rex = new NodeExecutor(Triggers.getTrigger(config.getString(path + ".trigger")));
                    if (config.contains(path + ".actions")) {
                        for (String a : config.getConfigurationSection(path + ".actions").getKeys(false)) {
                            ActionInterface ai = Actions.getActionByName(config.getString(path + ".actions." + a + ".type"));
                            ai.loadArguments(config, path + ".actions." + a + ".arguments");
                            rex.addAction(ai);
                        }
                    }
                    if (config.contains(path + ".conditions")) {
                        for (String c : config.getConfigurationSection(path + ".conditions").getKeys(false)) {
                            ConditionInterface ci = Conditions.getConditionByName(config.getString(path + ".conditions." + c + ".type"));
                            ci.loadArguments(config, path + ".conditions." + c + ".arguments");
                            rex.addCondition(ci);
                        }
                    }
                    if (config.contains(path + ".isTriggeredPerPlayer"))
                        rex.setTriggerPerPlayer(config.getBoolean(path + ".isTriggeredPerPlayer"));
                    if (config.contains(path + ".triggerCount"))
                        rex.setTriggerCount(config.getInt(path + ".triggerCount"));
                    n.addExecutor(rex);
                }
            }
        }
    }
}
Also used : RegionExecutor(au.com.mineauz.minigamesregions.executors.RegionExecutor) ActionInterface(au.com.mineauz.minigamesregions.actions.ActionInterface) ConditionInterface(au.com.mineauz.minigamesregions.conditions.ConditionInterface) MenuItemNode(au.com.mineauz.minigamesregions.menuitems.MenuItemNode) MenuItemRegion(au.com.mineauz.minigamesregions.menuitems.MenuItemRegion) World(org.bukkit.World) Location(org.bukkit.Location) NodeExecutor(au.com.mineauz.minigamesregions.executors.NodeExecutor)

Example 65 with Location

use of org.bukkit.Location in project Denizen-For-Bukkit by DenizenScript.

the class WalkCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
    // Fetch required objects
    dLocation loc = (dLocation) scriptEntry.getObject("location");
    Element speed = scriptEntry.getElement("speed");
    Element auto_range = scriptEntry.getElement("auto_range");
    Element radius = scriptEntry.getElement("radius");
    Element stop = scriptEntry.getElement("stop");
    List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
    final dLocation lookat = scriptEntry.getdObject("lookat");
    // Debug the execution
    dB.report(scriptEntry, getName(), (loc != null ? loc.debug() : "") + (speed != null ? speed.debug() : "") + (auto_range != null ? auto_range.debug() : "") + (radius != null ? radius.debug() : "") + (lookat != null ? lookat.debug() : "") + stop.debug() + (aH.debugObj("entities", entities)));
    // Do the execution
    boolean shouldStop = stop.asBoolean();
    List<dNPC> npcs = new ArrayList<dNPC>();
    final List<dEntity> waitForEntities = new ArrayList<dEntity>();
    for (final dEntity entity : entities) {
        if (entity.isCitizensNPC()) {
            dNPC npc = entity.getDenizenNPC();
            npcs.add(npc);
            if (!npc.isSpawned()) {
                dB.echoError(scriptEntry.getResidingQueue(), "NPC " + npc.identify() + " is not spawned!");
                continue;
            }
            if (shouldStop) {
                npc.getNavigator().cancelNavigation();
                continue;
            }
            if (auto_range != null && auto_range == Element.TRUE) {
                double distance = npc.getLocation().distance(loc);
                if (npc.getNavigator().getLocalParameters().range() < distance + 10) {
                    npc.getNavigator().getLocalParameters().range((float) distance + 10);
                }
            }
            npc.getNavigator().setTarget(loc);
            if (lookat != null) {
                npc.getNavigator().getLocalParameters().lookAtFunction(new Function<Navigator, Location>() {

                    @Override
                    public Location apply(Navigator nav) {
                        return lookat;
                    }
                });
            }
            if (speed != null) {
                npc.getNavigator().getLocalParameters().speedModifier(speed.asFloat());
            }
            if (radius != null) {
                npc.getNavigator().getLocalParameters().addRunCallback(WalkCommandCitizensEvents.generateNewFlocker(npc.getCitizen(), radius.asDouble()));
            }
        } else if (shouldStop) {
            NMSHandler.getInstance().getEntityHelper().stopWalking(entity.getBukkitEntity());
        } else {
            waitForEntities.add(entity);
            NMSHandler.getInstance().getEntityHelper().walkTo(entity.getBukkitEntity(), loc, speed != null ? speed.asDouble() : 0.2, new Runnable() {

                @Override
                public void run() {
                    checkHeld(entity);
                }
            });
        }
    }
    if (scriptEntry.shouldWaitFor()) {
        held.add(scriptEntry);
        if (!npcs.isEmpty()) {
            scriptEntry.addObject("tally", npcs);
        }
        if (!waitForEntities.isEmpty()) {
            scriptEntry.addObject("entities", waitForEntities);
        }
    }
}
Also used : Navigator(net.citizensnpcs.api.ai.Navigator) Element(net.aufdemrand.denizencore.objects.Element) ArrayList(java.util.ArrayList) net.aufdemrand.denizen.objects.dNPC(net.aufdemrand.denizen.objects.dNPC) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) ArrayList(java.util.ArrayList) List(java.util.List) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) Location(org.bukkit.Location) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation)

Aggregations

Location (org.bukkit.Location)470 Player (org.bukkit.entity.Player)120 World (org.bukkit.World)63 EventHandler (org.bukkit.event.EventHandler)54 Vector (org.bukkit.util.Vector)45 Test (org.junit.Test)43 ArrayList (java.util.ArrayList)36 Block (org.bukkit.block.Block)31 Entity (org.bukkit.entity.Entity)28 UUID (java.util.UUID)27 ItemStack (org.bukkit.inventory.ItemStack)22 LivingEntity (org.bukkit.entity.LivingEntity)20 PotionEffect (org.bukkit.potion.PotionEffect)17 User (com.earth2me.essentials.User)16 List (java.util.List)16 IOException (java.io.IOException)15 PlayerAuth (fr.xephi.authme.data.auth.PlayerAuth)14 LimboPlayer (fr.xephi.authme.data.limbo.LimboPlayer)14 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)14 Island (com.wasteofplastic.acidisland.Island)12