use of com.voxelgameslib.voxelgameslib.internal.math.Vector3D in project VoxelGamesLibv2 by VoxelGamesLib.
the class WorldModifyCommands method center.
@Subcommand("center")
@CommandPermission("%admin")
public void center(@Nonnull User user, @Nullable @co.aikar.commands.annotation.Optional String set) {
if (!check(user))
return;
// view
if (set == null) {
Lang.msg(user, LangKey.WORLD_MODIFY_CENTER_VIEW, map.getCenter());
} else // edit
{
map.setCenter(new Vector3D(user.getPlayer().getLocation().getX(), user.getPlayer().getLocation().getY(), user.getPlayer().getLocation().getZ()));
Lang.msg(user, LangKey.WORLD_MODIFY_CENTER_EDIT, map.getCenter());
}
}
use of com.voxelgameslib.voxelgameslib.internal.math.Vector3D in project VoxelGamesLibv2 by VoxelGamesLib.
the class WorldCreator method center.
@Subcommand("center")
@CommandPermission("%admin")
public void center(@Nonnull User sender) {
if (step != 2) {
Lang.msg(sender, LangKey.WORLD_CREATOR_WRONG_STEP, step, 2);
return;
}
center = new Vector3D(sender.getPlayer().getLocation().getX(), sender.getPlayer().getLocation().getY(), sender.getPlayer().getLocation().getZ());
Lang.msg(sender, LangKey.WORLD_CREATOR_ENTER_RADIUS, "/worldcreator radius ");
step = 3;
}
use of com.voxelgameslib.voxelgameslib.internal.math.Vector3D in project VoxelGamesLibv2 by VoxelGamesLib.
the class WorldCreator method world.
@Subcommand("world")
@CommandPermission("%admin")
public void world(@Nonnull User sender, @Nonnull String worldName) {
if (step != 1) {
Lang.msg(sender, LangKey.WORLD_CREATOR_WRONG_STEP, step, 1);
return;
}
gameHandler.getGames(sender.getUuid(), true).forEach(game -> game.leave(sender, false));
this.worldName = worldName;
worldHandler.loadLocalWorld(worldName);
Location spawnLoc = Bukkit.getWorld(worldName).getSpawnLocation();
Vector3D spawn = new Vector3D(spawnLoc.getX(), spawnLoc.getY(), spawnLoc.getZ());
sender.getPlayer().teleportAsync(spawnLoc);
game = gameHandler.startGame(EditModeGame.GAMEMODE);
game.getActivePhase().getNextPhase().getFeature(SpawnFeature.class).addSpawn(spawn);
Map map = new Map(null, worldName, spawn, 100);
map.load(game.getUuid(), worldName);
game.getActivePhase().getNextPhase().getFeature(MapFeature.class).setMap(map);
game.join(editor);
game.endPhase();
Lang.msg(sender, LangKey.WORLD_CREATOR_ENTER_CENTER, "/worldcreator center");
step = 2;
}
use of com.voxelgameslib.voxelgameslib.internal.math.Vector3D in project VoxelGamesLibv2 by VoxelGamesLib.
the class MapScanner method searchForMarkers.
/**
* Searches the map for "markers". Most of the time these are implemented as tile entities (skulls)
*
* @param map the map to scan
* @param center the center location
* @param range the range in where to scan
*/
public void searchForMarkers(@Nonnull Map map, @Nonnull Vector3D center, int range, @Nonnull UUID gameid) {
World world = Bukkit.getWorld(map.getLoadedName(gameid));
if (world == null) {
throw new MapException("Could not find world " + map.getLoadedName(gameid) + "(" + map.getInfo().getDisplayName() + ")" + ". Is it loaded?");
}
List<Marker> markers = new ArrayList<>();
List<ChestMarker> chestMarkers = new ArrayList<>();
int startX = (int) center.getX();
int startY = (int) center.getZ();
int minX = Math.min(startX - range, startX + range);
int minZ = Math.min(startY - range, startY + range);
int maxX = Math.max(startX - range, startX + range);
int maxZ = Math.max(startY - range, startY + range);
for (int x = minX; x <= maxX; x += 16) {
for (int z = minZ; z <= maxZ; z += 16) {
Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
for (BlockState te : chunk.getTileEntities()) {
if (te.getType() == Material.PLAYER_HEAD) {
Skull skull = (Skull) te;
String markerData = getMarkerData(skull);
if (markerData == null)
continue;
MarkerDefinition markerDefinition = mapHandler.createMarkerDefinition(markerData);
markers.add(new Marker(new Vector3D(skull.getX(), skull.getY(), skull.getZ()), DirectionUtil.directionToYaw(skull.getRotation()), markerData, markerDefinition));
} else if (te.getType() == Material.CHEST) {
Chest chest = (Chest) te;
String name = chest.getBlockInventory().getName();
ItemStack[] items = new ItemStack[chest.getBlockInventory().getStorageContents().length];
for (int i = 0; i < items.length; i++) {
ItemStack is = chest.getBlockInventory().getItem(i);
if (is == null) {
items[i] = new ItemStack(Material.AIR);
} else {
items[i] = is;
}
}
chestMarkers.add(new ChestMarker(new Vector3D(chest.getX(), chest.getY(), chest.getZ()), name, items));
}
}
}
}
map.setMarkers(markers);
map.setChestMarkers(chestMarkers);
}
Aggregations