Search in sources :

Example 1 with World

use of org.bukkit.World 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 2 with World

use of org.bukkit.World 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 3 with World

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

the class BlockUtils method removeMaterialsFromRadius.

/**
     * 
     * @param materials
     * @param loc
     * @param radius
     */
public static ArrayList<BlockStateChange> removeMaterialsFromRadius(Material[] materials, Location loc, int radius) {
    final ArrayList<BlockStateChange> blockStateChanges = new ArrayList<BlockStateChange>();
    if (loc != null && radius > 0 && materials != null && materials.length > 0) {
        final int x1 = loc.getBlockX();
        final int y1 = loc.getBlockY();
        final int z1 = loc.getBlockZ();
        final World world = loc.getWorld();
        for (int x = x1 - radius; x <= x1 + radius; x++) {
            for (int y = y1 - radius; y <= y1 + radius; y++) {
                for (int z = z1 - radius; z <= z1 + radius; z++) {
                    loc = new Location(world, x, y, z);
                    final Block b = loc.getBlock();
                    if (b.getType().equals(Material.AIR))
                        continue;
                    if (Arrays.asList(materials).contains(loc.getBlock().getType())) {
                        final BlockState originalBlock = loc.getBlock().getState();
                        loc.getBlock().setType(Material.AIR);
                        final BlockState newBlock = loc.getBlock().getState();
                        blockStateChanges.add(new BlockStateChange(originalBlock, newBlock));
                    }
                }
            }
        }
    }
    return blockStateChanges;
}
Also used : BlockStateChange(me.botsko.prism.events.BlockStateChange) BlockState(org.bukkit.block.BlockState) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) World(org.bukkit.World) Location(org.bukkit.Location)

Example 4 with World

use of org.bukkit.World in project AuthMeReloaded by AuthMe.

the class EmailRegisterExecutorProviderTest method shouldCreatePlayerAuth.

@Test
public void shouldCreatePlayerAuth() {
    // given
    given(commonService.getProperty(EmailSettings.RECOVERY_PASSWORD_LENGTH)).willReturn(12);
    given(passwordSecurity.computeHash(anyString(), anyString())).willAnswer(invocation -> new HashedPassword(invocation.getArgument(0)));
    Player player = mock(Player.class);
    TestHelper.mockPlayerIp(player, "123.45.67.89");
    given(player.getName()).willReturn("Veronica");
    World world = mock(World.class);
    given(world.getName()).willReturn("someWorld");
    given(player.getLocation()).willReturn(new Location(world, 48, 96, 144));
    EmailRegisterParams params = EmailRegisterParams.of(player, "test@example.com");
    // when
    PlayerAuth auth = executor.buildPlayerAuth(params);
    // then
    assertThat(auth, hasAuthBasicData("veronica", "Veronica", "test@example.com", "123.45.67.89"));
    assertThat(auth, hasAuthLocation(48, 96, 144, "someWorld", 0, 0));
    assertThat(auth.getPassword().getHash(), stringWithLength(12));
}
Also used : Player(org.bukkit.entity.Player) World(org.bukkit.World) PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) HashedPassword(fr.xephi.authme.security.crypts.HashedPassword) AuthMeMatchers.hasAuthLocation(fr.xephi.authme.AuthMeMatchers.hasAuthLocation) Location(org.bukkit.Location) Test(org.junit.Test)

Example 5 with World

use of org.bukkit.World in project AuthMeReloaded by AuthMe.

the class PasswordRegisterExecutorTest method shouldCreatePlayerAuth.

@Test
public void shouldCreatePlayerAuth() {
    // given
    given(passwordSecurity.computeHash(anyString(), anyString())).willAnswer(invocation -> new HashedPassword(invocation.getArgument(0)));
    Player player = mockPlayerWithName("S1m0N");
    TestHelper.mockPlayerIp(player, "123.45.67.89");
    World world = mock(World.class);
    given(world.getName()).willReturn("someWorld");
    given(player.getLocation()).willReturn(new Location(world, 48, 96, 144, 1.1f, 0.28f));
    PasswordRegisterParams params = PasswordRegisterParams.of(player, "pass", "mail@example.org");
    // when
    PlayerAuth auth = executor.buildPlayerAuth(params);
    // then
    assertThat(auth, hasAuthBasicData("s1m0n", "S1m0N", "mail@example.org", "123.45.67.89"));
    assertThat(auth, hasAuthLocation(48, 96, 144, "someWorld", 1.1f, 0.28f));
    assertThat(auth.getPassword(), equalToHash("pass"));
}
Also used : Player(org.bukkit.entity.Player) World(org.bukkit.World) PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) HashedPassword(fr.xephi.authme.security.crypts.HashedPassword) AuthMeMatchers.hasAuthLocation(fr.xephi.authme.AuthMeMatchers.hasAuthLocation) Location(org.bukkit.Location) Test(org.junit.Test)

Aggregations

World (org.bukkit.World)124 Location (org.bukkit.Location)56 Player (org.bukkit.entity.Player)37 Test (org.junit.Test)20 Block (org.bukkit.block.Block)11 User (com.earth2me.essentials.User)9 IOException (java.io.IOException)9 File (java.io.File)8 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)7 TownBlock (com.palmergames.bukkit.towny.object.TownBlock)7 PlayerAuth (fr.xephi.authme.data.auth.PlayerAuth)7 ArrayList (java.util.ArrayList)6 BlockState (org.bukkit.block.BlockState)5 PluginManager (org.bukkit.plugin.PluginManager)5 AlreadyRegisteredException (com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException)4 TownyException (com.palmergames.bukkit.towny.exceptions.TownyException)4 TownyWorld (com.palmergames.bukkit.towny.object.TownyWorld)4 LimboPlayer (fr.xephi.authme.data.limbo.LimboPlayer)4 Entity (org.bukkit.entity.Entity)4 LivingEntity (org.bukkit.entity.LivingEntity)4