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;
}
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);
}
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()));
}
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);
}
}
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;
}
Aggregations