Search in sources :

Example 1 with Location

use of org.bukkit.Location in project HawkEye by oliverwoodings.

the class MonitorPlayerListener method onPlayerQuit.

@HawkEvent(dataType = DataType.QUIT)
public void onPlayerQuit(PlayerQuitEvent event) {
    Player player = event.getPlayer();
    Location loc = player.getLocation();
    //Check for inventory close
    HawkEye.containerManager.checkInventoryClose(player);
    //Hackish workaround for random NPE given off by the address system
    String ip = "";
    try {
        ip = player.getAddress().getAddress().getHostAddress().toString();
    } catch (Exception e) {
    }
    DataManager.addEntry(new DataEntry(player, DataType.QUIT, loc, Config.LogIpAddresses ? ip : ""));
}
Also used : DataEntry(uk.co.oliwali.HawkEye.entry.DataEntry) Player(org.bukkit.entity.Player) Location(org.bukkit.Location) HawkEvent(uk.co.oliwali.HawkEye.HawkEvent)

Example 2 with Location

use of org.bukkit.Location in project HawkEye by oliverwoodings.

the class MonitorPlayerListener method onPlayerTeleport.

@HawkEvent(dataType = DataType.TELEPORT)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    //Check for inventory close
    HawkEye.containerManager.checkInventoryClose(event.getPlayer());
    Location from = event.getFrom();
    Location to = event.getTo();
    if (Util.distance(from, to) > 5)
        DataManager.addEntry(new DataEntry(event.getPlayer(), DataType.TELEPORT, from, to.getWorld().getName() + ": " + to.getX() + ", " + to.getY() + ", " + to.getZ()));
}
Also used : DataEntry(uk.co.oliwali.HawkEye.entry.DataEntry) Location(org.bukkit.Location) HawkEvent(uk.co.oliwali.HawkEye.HawkEvent)

Example 3 with Location

use of org.bukkit.Location in project HawkEye by oliverwoodings.

the class TptoCommand method execute.

@Override
public boolean execute() {
    if (!Util.isInteger(args.get(0))) {
        Util.sendMessage(sender, "&cPlease supply a entry id!");
        return true;
    }
    DataEntry entry = DataManager.getEntry(Integer.parseInt(args.get(0)));
    if (entry == null) {
        Util.sendMessage(sender, "&cEntry not found");
        return true;
    }
    World world = HawkEye.server.getWorld(entry.getWorld());
    if (world == null) {
        Util.sendMessage(sender, "&cWorld &7" + entry.getWorld() + "&c does not exist!");
        return true;
    }
    Location loc = new Location(world, entry.getX(), entry.getY(), entry.getZ());
    player.teleport(loc);
    Util.sendMessage(sender, "&7Teleported to location of data entry &c" + args.get(0));
    return true;
}
Also used : DataEntry(uk.co.oliwali.HawkEye.entry.DataEntry) World(org.bukkit.World) Location(org.bukkit.Location)

Example 4 with Location

use of org.bukkit.Location in project HawkEye by oliverwoodings.

the class Rebuild method run.

/**
	 * Run the rollback.
	 * Contains appropriate methods of catching errors and notifying the player
	 */
public void run() {
    //Start rollback process
    int i = 0;
    while (i < 200 && rebuildQueue.hasNext()) {
        i++;
        DataEntry entry = rebuildQueue.next();
        //If the action can't be rolled back, skip this entry
        if (entry.getType() == null || !entry.getType().canRollback())
            continue;
        //If the world doesn't exist, skip this entry
        World world = HawkEye.server.getWorld(entry.getWorld());
        if (world == null)
            continue;
        //Get some data from the entry
        Location loc = new Location(world, entry.getX(), entry.getY(), entry.getZ());
        Block block = world.getBlockAt(loc);
        //Rebuild it
        entry.rebuild(block);
        counter++;
    }
    //Check if rollback is finished
    if (!rebuildQueue.hasNext()) {
        //End timer
        Bukkit.getServer().getScheduler().cancelTask(timerID);
        session.setDoingRollback(false);
        session.setRollbackResults(undo);
        Util.sendMessage(session.getSender(), "&cRebuild complete, &7" + counter + "&c edits performed");
        Util.sendMessage(session.getSender(), "&cUndo this rebuild using &7/hawk undo");
        Util.debug("Rebuild complete, " + counter + " edits performed");
    }
}
Also used : DataEntry(uk.co.oliwali.HawkEye.entry.DataEntry) Block(org.bukkit.block.Block) World(org.bukkit.World) Location(org.bukkit.Location)

Example 5 with Location

use of org.bukkit.Location in project Prism-Bukkit by prism.

the class EntityAction method applyRollback.

/**
	 * 
	 */
@Override
public ChangeResult applyRollback(Player player, QueryParameters parameters, boolean is_preview) {
    if (getEntityType() == null) {
        return new ChangeResult(ChangeResultType.SKIPPED, null);
    }
    if (Prism.getIllegalEntities().contains(getEntityType().name().toLowerCase())) {
        return new ChangeResult(ChangeResultType.SKIPPED, null);
    }
    if (!is_preview) {
        final Location loc = getLoc();
        loc.setX(loc.getX() + 0.5);
        loc.setZ(loc.getZ() + 0.5);
        final Entity entity = loc.getWorld().spawnEntity(loc, getEntityType());
        // Get custom name
        if (entity instanceof LivingEntity && getCustomName() != null) {
            final LivingEntity namedEntity = (LivingEntity) entity;
            namedEntity.setCustomName(getCustomName());
        }
        // Get animal age
        if (entity instanceof Ageable) {
            final Ageable age = (Ageable) entity;
            if (!isAdult()) {
                age.setBaby();
            } else {
                age.setAdult();
            }
        }
        // Set sheep color
        if (entity.getType().equals(EntityType.SHEEP) && getColor() != null) {
            final Sheep sheep = ((Sheep) entity);
            sheep.setColor(getColor());
        }
        // Set villager profession
        if (entity instanceof Villager && getProfession() != null) {
            final Villager v = (Villager) entity;
            v.setProfession(getProfession());
        }
        // Set wolf details
        if (entity instanceof Wolf) {
            // Owner
            final Wolf wolf = (Wolf) entity;
            final String tamingOwner = getTamingOwner();
            if (tamingOwner != null) {
                Player owner = plugin.getServer().getPlayer(tamingOwner);
                if (owner == null) {
                    final OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(tamingOwner);
                    if (offlinePlayer.hasPlayedBefore()) {
                        owner = offlinePlayer.getPlayer();
                    }
                }
                if (owner != null)
                    wolf.setOwner(owner);
            }
            // Collar color
            if (getColor() != null) {
                wolf.setCollarColor(getColor());
            }
            if (isSitting()) {
                wolf.setSitting(true);
            }
        }
        // Set ocelot details
        if (entity instanceof Ocelot) {
            // Owner
            final Ocelot ocelot = (Ocelot) entity;
            final String tamingOwner = getTamingOwner();
            if (tamingOwner != null) {
                Player owner = plugin.getServer().getPlayer(tamingOwner);
                if (owner == null) {
                    final OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(tamingOwner);
                    if (offlinePlayer.hasPlayedBefore()) {
                        owner = offlinePlayer.getPlayer();
                    }
                }
                if (owner != null) {
                    ocelot.setOwner(owner);
                }
            }
            // Cat type
            if (getCatType() != null) {
                ocelot.setCatType(getCatType());
            }
            // Sitting
            if (isSitting()) {
                ocelot.setSitting(true);
            }
        }
        // Set horse details
        if (entity instanceof Horse) {
            final Horse h = (Horse) entity;
            if (getVariant() != null) {
                h.setVariant(getVariant());
            }
            if (getHorseColor() != null) {
                h.setColor(getHorseColor());
            }
            if (getStyle() != null) {
                h.setStyle(getStyle());
            }
            h.setCarryingChest(this.actionData.chest);
            h.setDomestication(this.actionData.dom);
            h.setMaxDomestication(this.actionData.maxDom);
            h.setJumpStrength(this.actionData.jump);
            h.setMaxHealth(this.actionData.maxHealth);
            // Stuff
            h.getInventory().setSaddle(getSaddle());
            h.getInventory().setArmor(getArmor());
            // Owner
            final String tamingOwner = getTamingOwner();
            if (tamingOwner != null) {
                Player owner = plugin.getServer().getPlayer(tamingOwner);
                if (owner == null) {
                    final OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(tamingOwner);
                    if (offlinePlayer.hasPlayedBefore()) {
                        owner = offlinePlayer.getPlayer();
                    }
                }
                if (owner != null)
                    h.setOwner(owner);
            }
        }
        return new ChangeResult(ChangeResultType.APPLIED, null);
    }
    return new ChangeResult(ChangeResultType.PLANNED, null);
}
Also used : OfflinePlayer(org.bukkit.OfflinePlayer) ChangeResult(me.botsko.prism.appliers.ChangeResult) OfflinePlayer(org.bukkit.OfflinePlayer) Location(org.bukkit.Location)

Aggregations

Location (org.bukkit.Location)351 Player (org.bukkit.entity.Player)90 World (org.bukkit.World)56 EventHandler (org.bukkit.event.EventHandler)43 Test (org.junit.Test)43 Vector (org.bukkit.util.Vector)38 ArrayList (java.util.ArrayList)29 Block (org.bukkit.block.Block)18 Entity (org.bukkit.entity.Entity)17 User (com.earth2me.essentials.User)16 ItemStack (org.bukkit.inventory.ItemStack)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 List (java.util.List)12 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)11 BlockState (org.bukkit.block.BlockState)11 UUID (java.util.UUID)10 LivingEntity (org.bukkit.entity.LivingEntity)10 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)9