Search in sources :

Example 41 with Location

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

the class CheckpointSign method signUse.

@Override
public boolean signUse(Sign sign, MinigamePlayer player) {
    if ((player.isInMinigame() || (!player.isInMinigame() && sign.getLine(2).equals(ChatColor.BLUE + "Global"))) && player.getPlayer().getInventory().getItemInMainHand().getType() == Material.AIR) {
        if (player.isInMinigame() && player.getMinigame().isSpectator(player)) {
            return false;
        }
        if (player.getPlayer().isOnGround()) {
            Location newloc = player.getPlayer().getLocation();
            if (!sign.getLine(2).equals(ChatColor.BLUE + "Global")) {
                player.setCheckpoint(newloc);
            } else {
                player.getStoredPlayerCheckpoints().setGlobalCheckpoint(newloc);
            }
            player.sendMessage(ChatColor.AQUA + "[Minigames] " + ChatColor.WHITE + MinigameUtils.getLang("sign.checkpoint.set"));
            return true;
        } else {
            player.sendMessage(ChatColor.RED + "[Minigames] " + ChatColor.WHITE + MinigameUtils.getLang("sign.checkpoint.fail"));
        }
    } else
        player.sendMessage(ChatColor.AQUA + "[Minigames] " + ChatColor.WHITE + MinigameUtils.getLang("sign.emptyHand"));
    return false;
}
Also used : Location(org.bukkit.Location)

Example 42 with Location

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

the class StartPositionMode method onLeftClick.

@Override
public void onLeftClick(MinigamePlayer player, Minigame minigame, Team team, PlayerInteractEvent event) {
    if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
        int x = event.getClickedBlock().getLocation().getBlockX();
        int y = event.getClickedBlock().getLocation().getBlockY();
        int z = event.getClickedBlock().getLocation().getBlockZ();
        String world = event.getClickedBlock().getLocation().getWorld().getName();
        int nx;
        int ny;
        int nz;
        String nworld;
        Location delLoc = null;
        if (team != null) {
            if (team.hasStartLocations()) {
                for (Location loc : team.getStartLocations()) {
                    nx = loc.getBlockX();
                    ny = loc.getBlockY();
                    nz = loc.getBlockZ();
                    nworld = loc.getWorld().getName();
                    if (x == nx && y == ny && z == nz && world.equals(nworld)) {
                        delLoc = loc;
                        break;
                    }
                }
            }
            if (delLoc != null) {
                team.getStartLocations().remove(delLoc);
                player.sendMessage("Removed selected " + team.getChatColor() + team.getDisplayName() + ChatColor.WHITE + " start location.", null);
            } else {
                player.sendMessage("Could not find a " + team.getChatColor() + team.getDisplayName() + ChatColor.WHITE + " start location at that point.", "error");
            }
        } else {
            for (Location loc : minigame.getStartLocations()) {
                nx = loc.getBlockX();
                ny = loc.getBlockY();
                nz = loc.getBlockZ();
                nworld = loc.getWorld().getName();
                if (x == nx && y == ny && z == nz && world.equals(nworld)) {
                    delLoc = loc;
                    break;
                }
            }
            if (delLoc != null) {
                minigame.getStartLocations().remove(delLoc);
                player.sendMessage("Removed selected start location.", null);
            } else
                player.sendMessage("Could not find a start location at that point.", "error");
        }
    }
}
Also used : Location(org.bukkit.Location)

Example 43 with Location

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

the class MinigameUtils method loadShortLocation.

/**
	 * Loads a short location (x, y, z, world) from a configuration section
	 * @param section The section that contains the fields
	 * @return A location with the the contents of that section, or null if the world is invalid
	 */
public static Location loadShortLocation(ConfigurationSection section) {
    double x = section.getDouble("x");
    double y = section.getDouble("y");
    double z = section.getDouble("z");
    String worldName = section.getString("world");
    World world = Bukkit.getWorld(worldName);
    if (world != null) {
        return new Location(world, x, y, z);
    } else {
        return null;
    }
}
Also used : World(org.bukkit.World) Location(org.bukkit.Location)

Example 44 with Location

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

the class RecorderData method cartkMoveItem.

@EventHandler(ignoreCancelled = true)
private void cartkMoveItem(InventoryMoveItemEvent event) {
    if (!hasRegenArea() || !minigame.hasPlayers())
        return;
    Location loc = null;
    if (event.getInitiator().getHolder() instanceof HopperMinecart) {
        loc = ((HopperMinecart) event.getInitiator().getHolder()).getLocation().clone();
        if (blockInRegenArea(loc))
            addEntity((Entity) event.getInitiator().getHolder(), null, false);
    }
    loc = null;
    if (event.getDestination().getHolder() instanceof HopperMinecart) {
        loc = ((HopperMinecart) event.getDestination().getHolder()).getLocation().clone();
        if (blockInRegenArea(loc))
            addEntity((Entity) event.getInitiator().getHolder(), null, false);
    }
}
Also used : Entity(org.bukkit.entity.Entity) HopperMinecart(org.bukkit.entity.minecart.HopperMinecart) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 45 with Location

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

the class BasicRecorder method bucketEmpty.

@EventHandler(ignoreCancelled = true)
private void bucketEmpty(PlayerBucketEmptyEvent event) {
    MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
    if (ply == null)
        return;
    if (ply.isInMinigame()) {
        Minigame mgm = ply.getMinigame();
        RecorderData d = mgm.getBlockRecorder();
        if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlockClicked().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlockClicked().getType()))) && mgm.canBlockPlace()) {
            Location loc = new Location(event.getBlockClicked().getWorld(), event.getBlockFace().getModX() + event.getBlockClicked().getX(), event.getBlockFace().getModY() + event.getBlockClicked().getY(), event.getBlockFace().getModZ() + event.getBlockClicked().getZ());
            d.addBlock(loc.getBlock(), pdata.getMinigamePlayer(event.getPlayer()));
        } else {
            event.setCancelled(true);
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

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