use of io.xol.chunkstories.api.player.Player in project chunkstories by Hugobros3.
the class VirtualServerDecalsManager method drawDecal.
@Override
public void drawDecal(Vector3dc position, Vector3dc orientation, Vector3dc size, String decalName) {
Iterator<Player> i = worldServer.getPlayers();
while (i.hasNext()) {
Player player = i.next();
tellPlayer(player, position, orientation, size, decalName);
}
}
use of io.xol.chunkstories.api.player.Player in project chunkstories by Hugobros3.
the class WorldServer method getPlayers.
public IterableIterator<Player> getPlayers() {
return new IterableIterator<Player>() {
Iterator<Player> players = server.getConnectedPlayers();
Player next = null;
@Override
public boolean hasNext() {
while (next == null && players.hasNext()) {
next = players.next();
if (// Require the player to be spawned within this world.
next.getWorld() != null && next.getWorld().equals(WorldServer.this))
break;
else
next = null;
}
return next != null;
}
@Override
public Player next() {
Player player = next;
next = null;
return player;
}
};
}
use of io.xol.chunkstories.api.player.Player in project chunkstories by Hugobros3.
the class SpawnEntityCommand method handleCommand.
@Override
public boolean handleCommand(CommandEmitter emitter, Command command, String[] arguments) {
if (!(emitter instanceof Player)) {
emitter.sendMessage("You need to be a player to use this command.");
return true;
}
Player player = (Player) emitter;
if (!emitter.hasPermission("world.spawnEntity")) {
emitter.sendMessage("You don't have the permission.");
return true;
}
if (arguments.length == 0) {
emitter.sendMessage("Syntax: /spawnEntity <entityId> [x y z]");
return false;
}
Location loc = player.getLocation();
if (arguments.length >= 4) {
loc = new Location(player.getWorld(), Double.parseDouble(arguments[1]), Double.parseDouble(arguments[2]), Double.parseDouble(arguments[3]));
}
EntityDefinition entityType;
String entityName = arguments[0];
entityType = server.getContent().entities().getEntityDefinition(entityName);
if (entityType == null) {
emitter.sendMessage("Entity type : " + arguments[0] + " not found in loaded content.");
return true;
}
Entity entity = entityType.create(loc);
entity.setLocation(loc);
loc.getWorld().addEntity(entity);
emitter.sendMessage("#00FFD0" + "Spawned " + entity.getClass().getSimpleName() + " at " + (arguments.length >= 4 ? loc.toString() : player.getName()));
return true;
}
use of io.xol.chunkstories.api.player.Player in project chunkstories by Hugobros3.
the class WeatherCommand method handleCommand.
@Override
public boolean handleCommand(CommandEmitter emitter, Command command, String[] arguments) {
if (!emitter.hasPermission("world.weather")) {
emitter.sendMessage("You don't have the permission.");
return true;
}
if (!(emitter instanceof Player)) {
emitter.sendMessage("You need to be a player to use this command.");
return true;
}
Player player = (Player) emitter;
if (arguments.length == 1) {
float overcastFactor = Float.parseFloat(arguments[0]);
player.getLocation().getWorld().setWeather(overcastFactor);
} else
emitter.sendMessage("#82FFDBSyntax : /weather [0.0 - 1.0]");
return true;
}
use of io.xol.chunkstories.api.player.Player in project chunkstories by Hugobros3.
the class PlayerLoginHelper method afterLoginValidation.
/**
* Called after the login token has been validated, or in the case of an
* offline-mode server, after the client requested to login.
*/
private void afterLoginValidation() {
// Disallow users from logging in from two places
Player contender = connection.clientsManager.getPlayerByName(name);
if (contender != null) {
connection.disconnect("You are already logged in. (" + contender + "). ");
return;
}
// Creates a player based on the thrusted login information
ServerPlayer player = new ServerPlayer(connection, name);
// Fire the login event
PlayerLoginEvent playerConnectionEvent = new PlayerLoginEvent(player);
connection.clientsManager.getServer().getPluginManager().fireEvent(playerConnectionEvent);
if (playerConnectionEvent.isCancelled()) {
connection.disconnect(playerConnectionEvent.getRefusedConnectionMessage());
return;
}
// Announce player login
connection.clientsManager.getServer().broadcastMessage(playerConnectionEvent.getConnectionMessage());
// Aknowledge the login
logged_in = true;
connection.sendTextMessage("login/ok");
connection.flush();
connection.setPlayer(player);
}
Aggregations