Search in sources :

Example 6 with Player

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);
    }
}
Also used : Player(io.xol.chunkstories.api.player.Player) ServerPlayer(io.xol.chunkstories.server.player.ServerPlayer)

Example 7 with Player

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;
        }
    };
}
Also used : Player(io.xol.chunkstories.api.player.Player) ServerPlayer(io.xol.chunkstories.server.player.ServerPlayer) Iterator(java.util.Iterator) IterableIterator(io.xol.chunkstories.api.util.IterableIterator) IterableIterator(io.xol.chunkstories.api.util.IterableIterator)

Example 8 with 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;
}
Also used : EntityDefinition(io.xol.chunkstories.api.entity.EntityDefinition) Entity(io.xol.chunkstories.api.entity.Entity) Player(io.xol.chunkstories.api.player.Player) Location(io.xol.chunkstories.api.Location)

Example 9 with Player

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;
}
Also used : Player(io.xol.chunkstories.api.player.Player)

Example 10 with Player

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);
}
Also used : Player(io.xol.chunkstories.api.player.Player) ServerPlayer(io.xol.chunkstories.server.player.ServerPlayer) ServerPlayer(io.xol.chunkstories.server.player.ServerPlayer) PlayerLoginEvent(io.xol.chunkstories.api.events.player.PlayerLoginEvent)

Aggregations

Player (io.xol.chunkstories.api.player.Player)33 Location (io.xol.chunkstories.api.Location)12 Entity (io.xol.chunkstories.api.entity.Entity)9 WorldMaster (io.xol.chunkstories.api.world.WorldMaster)8 EntityControllable (io.xol.chunkstories.api.entity.interfaces.EntityControllable)7 ServerPlayer (io.xol.chunkstories.server.player.ServerPlayer)5 LocalPlayer (io.xol.chunkstories.api.client.LocalPlayer)4 Controller (io.xol.chunkstories.api.entity.Controller)4 World (io.xol.chunkstories.api.world.World)4 EntityCreative (io.xol.chunkstories.api.entity.interfaces.EntityCreative)3 PlayerVoxelModificationEvent (io.xol.chunkstories.api.events.player.voxel.PlayerVoxelModificationEvent)3 WorldException (io.xol.chunkstories.api.exceptions.world.WorldException)3 ItemPile (io.xol.chunkstories.api.item.inventory.ItemPile)3 FutureCell (io.xol.chunkstories.api.world.cell.FutureCell)3 HeightmapImplementation (io.xol.chunkstories.world.summary.HeightmapImplementation)3 ByteBuffer (java.nio.ByteBuffer)3 ClientInterface (io.xol.chunkstories.api.client.ClientInterface)2 EntityWorldModifier (io.xol.chunkstories.api.entity.interfaces.EntityWorldModifier)2 EventItemDroppedToWorld (io.xol.chunkstories.api.events.item.EventItemDroppedToWorld)2 PlayerMoveItemEvent (io.xol.chunkstories.api.events.player.PlayerMoveItemEvent)2