Search in sources :

Example 1 with DynmapPlayer

use of org.dynmap.common.DynmapPlayer in project InteractiveChat by LOOHP.

the class DynmapCoreChatListener method chatEvent.

@Override
public void chatEvent(DynmapPlayer p, String msg) {
    if (core.disable_chat_to_web) {
        return;
    }
    if (core.mapManager != null) {
        Player bukkitplayer = Bukkit.getPlayer(p.getUUID());
        if (bukkitplayer == null) {
            msg = msg.replaceAll(Registry.ID_PATTERN.pattern(), "");
            core.mapManager.pushUpdate(new Client.ChatMessage("player", "", p.getDisplayName(), msg, p.getName()));
        } else {
            try {
                String component = InteractiveChatComponentSerializer.gson().serialize(LegacyComponentSerializer.legacySection().deserialize(msg));
                String processed = PlainTextComponentSerializer.plainText().serialize(InteractiveChatComponentSerializer.gson().deserialize(ProcessExternalMessage.processAndRespond(bukkitplayer, component)));
                core.mapManager.pushUpdate(new Client.ChatMessage("player", "", p.getDisplayName(), processed, p.getName()));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : DynmapPlayer(org.dynmap.common.DynmapPlayer) Player(org.bukkit.entity.Player) Client(org.dynmap.Client)

Example 2 with DynmapPlayer

use of org.dynmap.common.DynmapPlayer 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 3 with DynmapPlayer

use of org.dynmap.common.DynmapPlayer in project dynmap by webbukkit.

the class FabricServer method tickEvent.

public void tickEvent(MinecraftServer server) {
    cur_tick_starttime = System.nanoTime();
    long elapsed = cur_tick_starttime - plugin.lasttick;
    plugin.lasttick = cur_tick_starttime;
    plugin.avgticklen = ((plugin.avgticklen * 99) / 100) + (elapsed / 100);
    plugin.tps = (double) 1E9 / (double) plugin.avgticklen;
    // Tick core
    if (plugin.core != null) {
        plugin.core.serverTick(plugin.tps);
    }
    boolean done = false;
    TaskRecord tr = null;
    while (!plugin.blockupdatequeue.isEmpty()) {
        DynmapPlugin.BlockUpdateRec r = plugin.blockupdatequeue.remove();
        BlockState bs = r.w.getBlockState(new BlockPos(r.x, r.y, r.z));
        int idx = Block.STATE_IDS.getRawId(bs);
        if (!org.dynmap.hdmap.HDBlockModels.isChangeIgnoredBlock(DynmapPlugin.stateByID[idx])) {
            if (plugin.onblockchange_with_id)
                plugin.mapManager.touch(r.wid, r.x, r.y, r.z, "blockchange[" + idx + "]");
            else
                plugin.mapManager.touch(r.wid, r.x, r.y, r.z, "blockchange");
        }
    }
    long now;
    synchronized (schedlock) {
        cur_tick++;
        now = System.nanoTime();
        tr = runqueue.peek();
        /* Nothing due to run */
        if ((tr == null) || (tr.getTickToRun() > cur_tick) || ((now - cur_tick_starttime) > plugin.perTickLimit)) {
            done = true;
        } else {
            tr = runqueue.poll();
        }
    }
    while (!done) {
        tr.run();
        synchronized (schedlock) {
            tr = runqueue.peek();
            now = System.nanoTime();
            /* Nothing due to run */
            if ((tr == null) || (tr.getTickToRun() > cur_tick) || ((now - cur_tick_starttime) > plugin.perTickLimit)) {
                done = true;
            } else {
                tr = runqueue.poll();
            }
        }
    }
    while (!plugin.msgqueue.isEmpty()) {
        DynmapPlugin.ChatMessage cm = plugin.msgqueue.poll();
        DynmapPlayer dp = null;
        if (cm.sender != null)
            dp = plugin.getOrAddPlayer(cm.sender);
        else
            dp = new FabricPlayer(plugin, null);
        plugin.core.listenerManager.processChatEvent(DynmapListenerManager.EventType.PLAYER_CHAT, dp, cm.message);
    }
    // Check for generated chunks
    if ((cur_tick % 20) == 0) {
    }
}
Also used : BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) DynmapPlayer(org.dynmap.common.DynmapPlayer)

Example 4 with DynmapPlayer

use of org.dynmap.common.DynmapPlayer in project dynmap by webbukkit.

the class FabricServer method tickEvent.

public void tickEvent(MinecraftServer server) {
    cur_tick_starttime = System.nanoTime();
    long elapsed = cur_tick_starttime - plugin.lasttick;
    plugin.lasttick = cur_tick_starttime;
    plugin.avgticklen = ((plugin.avgticklen * 99) / 100) + (elapsed / 100);
    plugin.tps = (double) 1E9 / (double) plugin.avgticklen;
    // Tick core
    if (plugin.core != null) {
        plugin.core.serverTick(plugin.tps);
    }
    boolean done = false;
    TaskRecord tr = null;
    while (!plugin.blockupdatequeue.isEmpty()) {
        DynmapPlugin.BlockUpdateRec r = plugin.blockupdatequeue.remove();
        BlockState bs = r.w.getBlockState(new BlockPos(r.x, r.y, r.z));
        int idx = Block.STATE_IDS.getRawId(bs);
        if (!org.dynmap.hdmap.HDBlockModels.isChangeIgnoredBlock(DynmapPlugin.stateByID[idx])) {
            if (plugin.onblockchange_with_id)
                plugin.mapManager.touch(r.wid, r.x, r.y, r.z, "blockchange[" + idx + "]");
            else
                plugin.mapManager.touch(r.wid, r.x, r.y, r.z, "blockchange");
        }
    }
    long now;
    synchronized (schedlock) {
        cur_tick++;
        now = System.nanoTime();
        tr = runqueue.peek();
        /* Nothing due to run */
        if ((tr == null) || (tr.getTickToRun() > cur_tick) || ((now - cur_tick_starttime) > plugin.perTickLimit)) {
            done = true;
        } else {
            tr = runqueue.poll();
        }
    }
    while (!done) {
        tr.run();
        synchronized (schedlock) {
            tr = runqueue.peek();
            now = System.nanoTime();
            /* Nothing due to run */
            if ((tr == null) || (tr.getTickToRun() > cur_tick) || ((now - cur_tick_starttime) > plugin.perTickLimit)) {
                done = true;
            } else {
                tr = runqueue.poll();
            }
        }
    }
    while (!plugin.msgqueue.isEmpty()) {
        DynmapPlugin.ChatMessage cm = plugin.msgqueue.poll();
        DynmapPlayer dp = null;
        if (cm.sender != null)
            dp = plugin.getOrAddPlayer(cm.sender);
        else
            dp = new FabricPlayer(plugin, null);
        plugin.core.listenerManager.processChatEvent(DynmapListenerManager.EventType.PLAYER_CHAT, dp, cm.message);
    }
    // Check for generated chunks
    if ((cur_tick % 20) == 0) {
    }
}
Also used : BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) DynmapPlayer(org.dynmap.common.DynmapPlayer)

Example 5 with DynmapPlayer

use of org.dynmap.common.DynmapPlayer 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)

Aggregations

DynmapPlayer (org.dynmap.common.DynmapPlayer)27 BlockState (net.minecraft.block.BlockState)7 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)7 BlockPos (net.minecraft.util.math.BlockPos)7 ArrayList (java.util.ArrayList)4 File (java.io.File)2 InetAddress (java.net.InetAddress)2 UnknownHostException (java.net.UnknownHostException)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ZipFile (java.util.zip.ZipFile)2 DynmapListenerManager (org.dynmap.common.DynmapListenerManager)2 DynmapBlockState (org.dynmap.renderer.DynmapBlockState)2 BufferedReader (java.io.BufferedReader)1 FileOutputStream (java.io.FileOutputStream)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1