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