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();
}
}
}
}
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;
}
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) {
}
}
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) {
}
}
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;
}
Aggregations