Search in sources :

Example 16 with ServerPlayerEntity

use of net.minecraft.server.network.ServerPlayerEntity in project dynmap by webbukkit.

the class FabricServer method getOnlinePlayers.

@Override
public DynmapPlayer[] getOnlinePlayers() {
    if (server.getPlayerManager() == null)
        return new DynmapPlayer[0];
    List<ServerPlayerEntity> players = server.getPlayerManager().getPlayerList();
    int playerCount = players.size();
    DynmapPlayer[] dplay = new DynmapPlayer[players.size()];
    for (int i = 0; i < playerCount; i++) {
        ServerPlayerEntity player = players.get(i);
        dplay[i] = plugin.getOrAddPlayer(player);
    }
    return dplay;
}
Also used : ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) DynmapPlayer(org.dynmap.common.DynmapPlayer)

Example 17 with ServerPlayerEntity

use of net.minecraft.server.network.ServerPlayerEntity in project dynmap by webbukkit.

the class FabricPlayer method sendTitleText.

/**
 * Send title and subtitle text (called from server thread)
 */
@Override
public void sendTitleText(String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
    if (player != null) {
        ServerPlayerEntity player = this.player;
        TitleFadeS2CPacket times = new TitleFadeS2CPacket(fadeInTicks, stayTicks, fadeOutTicks);
        player.networkHandler.sendPacket(times);
        if (title != null) {
            TitleS2CPacket titlepkt = new TitleS2CPacket(new LiteralText(title));
            player.networkHandler.sendPacket(titlepkt);
        }
        if (subtitle != null) {
            SubtitleS2CPacket subtitlepkt = new SubtitleS2CPacket(new LiteralText(subtitle));
            player.networkHandler.sendPacket(subtitlepkt);
        }
    }
}
Also used : TitleFadeS2CPacket(net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket) SubtitleS2CPacket(net.minecraft.network.packet.s2c.play.SubtitleS2CPacket) TitleS2CPacket(net.minecraft.network.packet.s2c.play.TitleS2CPacket) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LiteralText(net.minecraft.text.LiteralText)

Example 18 with ServerPlayerEntity

use of net.minecraft.server.network.ServerPlayerEntity in project dynmap by webbukkit.

the class DynmapPlugin method handleCommand.

// TODO: Clean a bit
public void handleCommand(ServerCommandSource commandSource, String cmd, String[] args) throws CommandSyntaxException {
    DynmapCommandSender dsender;
    ServerPlayerEntity psender = null;
    // getPlayer throws a CommandSyntaxException, so getEntity and instanceof for safety
    if (commandSource.getEntity() instanceof ServerPlayerEntity) {
        psender = commandSource.getPlayer();
    }
    if (psender != null) {
        // FIXME: New Player? Why not query the current player list.
        dsender = new FabricPlayer(this, psender);
    } else {
        dsender = new FabricCommandSender(commandSource);
    }
    core.processCommand(dsender, cmd, cmd, args);
}
Also used : DynmapCommandSender(org.dynmap.common.DynmapCommandSender) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 19 with ServerPlayerEntity

use of net.minecraft.server.network.ServerPlayerEntity in project dynmap by webbukkit.

the class DynmapPlugin method handleCommand.

// TODO: Clean a bit
public void handleCommand(ServerCommandSource commandSource, String cmd, String[] args) throws CommandSyntaxException {
    DynmapCommandSender dsender;
    ServerPlayerEntity psender = null;
    // getPlayer throws a CommandSyntaxException, so getEntity and instanceof for safety
    if (commandSource.getEntity() instanceof ServerPlayerEntity) {
        psender = commandSource.getPlayer();
    }
    if (psender != null) {
        // FIXME: New Player? Why not query the current player list.
        dsender = new FabricPlayer(this, psender);
    } else {
        dsender = new FabricCommandSender(commandSource);
    }
    core.processCommand(dsender, cmd, cmd, args);
}
Also used : DynmapCommandSender(org.dynmap.common.DynmapCommandSender) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 20 with ServerPlayerEntity

use of net.minecraft.server.network.ServerPlayerEntity in project dynmap by webbukkit.

the class FabricPlayer method sendTitleText.

/**
 * Send title and subtitle text (called from server thread)
 */
@Override
public void sendTitleText(String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
    if (player != null) {
        ServerPlayerEntity player = this.player;
        TitleFadeS2CPacket times = new TitleFadeS2CPacket(fadeInTicks, stayTicks, fadeOutTicks);
        player.networkHandler.sendPacket(times);
        if (title != null) {
            TitleS2CPacket titlepkt = new TitleS2CPacket(new LiteralText(title));
            player.networkHandler.sendPacket(titlepkt);
        }
        if (subtitle != null) {
            SubtitleS2CPacket subtitlepkt = new SubtitleS2CPacket(new LiteralText(subtitle));
            player.networkHandler.sendPacket(subtitlepkt);
        }
    }
}
Also used : TitleFadeS2CPacket(net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket) SubtitleS2CPacket(net.minecraft.network.packet.s2c.play.SubtitleS2CPacket) TitleS2CPacket(net.minecraft.network.packet.s2c.play.TitleS2CPacket) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LiteralText(net.minecraft.text.LiteralText)

Aggregations

ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)297 ServerCommandSource (net.minecraft.server.command.ServerCommandSource)75 LiteralText (net.minecraft.text.LiteralText)75 ItemStack (net.minecraft.item.ItemStack)44 PlayerEntity (net.minecraft.entity.player.PlayerEntity)32 Message (io.icker.factions.util.Message)28 Entity (net.minecraft.entity.Entity)28 BlockPos (net.minecraft.util.math.BlockPos)28 ServerWorld (net.minecraft.server.world.ServerWorld)24 MinecraftServer (net.minecraft.server.MinecraftServer)23 TranslatableText (net.minecraft.text.TranslatableText)22 Inject (org.spongepowered.asm.mixin.injection.Inject)22 Faction (io.icker.factions.database.Faction)21 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)20 LivingEntity (net.minecraft.entity.LivingEntity)20 UUID (java.util.UUID)17 Formatting (net.minecraft.util.Formatting)17 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)16 World (net.minecraft.world.World)15 ArrayList (java.util.ArrayList)13