Search in sources :

Example 6 with World

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

the class TeleportationServiceTest method mockLocation.

// We check that the World in Location is set, this method creates a mock World in Location for us
private static Location mockLocation() {
    Location location = mock(Location.class);
    given(location.getWorld()).willReturn(mock(World.class));
    return location;
}
Also used : World(org.bukkit.World) Location(org.bukkit.Location)

Example 7 with World

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

the class TeleportationServiceTest method shouldTeleportBackToPlayerAuthLocation.

@Test
public void shouldTeleportBackToPlayerAuthLocation() {
    // given
    given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(true);
    given(settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)).willReturn(true);
    PlayerAuth auth = createAuthWithLocation();
    auth.setWorld("myWorld");
    World world = mock(World.class);
    given(bukkitService.getWorld("myWorld")).willReturn(world);
    Player player = mock(Player.class);
    given(player.isOnline()).willReturn(true);
    LimboPlayer limbo = mock(LimboPlayer.class);
    Location limboLocation = mockLocation();
    given(limbo.getLocation()).willReturn(limboLocation);
    // when
    teleportationService.teleportOnLogin(player, auth, limbo);
    runSyncDelayedTask(bukkitService);
    // then
    ArgumentCaptor<Location> locationCaptor = ArgumentCaptor.forClass(Location.class);
    verify(player).teleport(locationCaptor.capture());
    assertCorrectLocation(locationCaptor.getValue(), auth, world);
}
Also used : Player(org.bukkit.entity.Player) LimboPlayer(fr.xephi.authme.data.limbo.LimboPlayer) PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) World(org.bukkit.World) LimboPlayer(fr.xephi.authme.data.limbo.LimboPlayer) Location(org.bukkit.Location) Test(org.junit.Test)

Example 8 with World

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

the class AuthMeApiTest method shouldGetLastLocation.

@Test
public void shouldGetLastLocation() {
    // given
    String name = "Gary";
    Player player = mockPlayerWithName(name);
    PlayerAuth auth = PlayerAuth.builder().name(name).locWorld("world").locX(12.4).locY(24.6).locZ(-438.2).locYaw(3.41f).locPitch(0.29f).build();
    given(playerCache.getAuth(name)).willReturn(auth);
    Server server = mock(Server.class);
    ReflectionTestUtils.setField(Bukkit.class, null, "server", server);
    World world = mock(World.class);
    given(server.getWorld(auth.getWorld())).willReturn(world);
    // when
    Location result = api.getLastLocation(player);
    // then
    assertThat(result, not(nullValue()));
    assertThat(result.getX(), equalTo(auth.getQuitLocX()));
    assertThat(result.getY(), equalTo(auth.getQuitLocY()));
    assertThat(result.getZ(), equalTo(auth.getQuitLocZ()));
    assertThat(result.getWorld(), equalTo(world));
    assertThat(result.getYaw(), equalTo(auth.getYaw()));
    assertThat(result.getPitch(), equalTo(auth.getPitch()));
}
Also used : Player(org.bukkit.entity.Player) Server(org.bukkit.Server) PlayerAuth(fr.xephi.authme.data.auth.PlayerAuth) World(org.bukkit.World) Location(org.bukkit.Location) Test(org.junit.Test)

Example 9 with World

use of org.bukkit.World in project TotalFreedomMod by TotalFreedom.

the class Command_smite method smite.

public static void smite(Player player, String reason) {
    FUtil.bcastMsg(player.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
    if (reason != null) {
        FUtil.bcastMsg("  Reason: " + reason, ChatColor.RED);
    }
    // Deop
    player.setOp(false);
    // Set gamemode to survival
    player.setGameMode(GameMode.SURVIVAL);
    // Clear inventory
    player.getInventory().clear();
    // Strike with lightning effect
    final Location targetPos = player.getLocation();
    final World world = player.getWorld();
    for (int x = -1; x <= 1; x++) {
        for (int z = -1; z <= 1; z++) {
            final Location strike_pos = new Location(world, targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
            world.strikeLightning(strike_pos);
        }
    }
    // Kill
    player.setHealth(0.0);
    if (reason != null) {
        player.sendMessage(ChatColor.RED + "You've been smitten. Reason: " + reason);
    }
}
Also used : World(org.bukkit.World) Location(org.bukkit.Location)

Example 10 with World

use of org.bukkit.World in project TotalFreedomMod by TotalFreedom.

the class Command_unloadchunks method run.

@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
    FUtil.adminAction(sender.getName(), "Unloading unused chunks", false);
    int numChunks = 0;
    for (World world : server.getWorlds()) {
        numChunks += unloadUnusedChunks(world);
    }
    FUtil.playerMsg(sender, numChunks + " chunks unloaded.");
    return true;
}
Also used : World(org.bukkit.World)

Aggregations

World (org.bukkit.World)139 Location (org.bukkit.Location)63 Player (org.bukkit.entity.Player)41 Test (org.junit.Test)20 Block (org.bukkit.block.Block)14 IOException (java.io.IOException)10 Entity (org.bukkit.entity.Entity)10 User (com.earth2me.essentials.User)9 File (java.io.File)9 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)7 Material (org.bukkit.Material)6 LivingEntity (org.bukkit.entity.LivingEntity)6 EventHandler (org.bukkit.event.EventHandler)6 UUID (java.util.UUID)5 PluginManager (org.bukkit.plugin.PluginManager)5 AlreadyRegisteredException (com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException)4 TownyException (com.palmergames.bukkit.towny.exceptions.TownyException)4