Skip to content

Commit 3502bc3

Browse files
committed
let playerdetector use luaconverter
1 parent 68d6c36 commit 3502bc3

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/PlayerDetectorPeripheral.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ public final Map<String, Object> getOwner() throws LuaException {
169169
private Map<String, Object> getPlayerInfo(ServerPlayer player, boolean isOwner) {
170170
boolean showAbsCoords = true;
171171

172-
Map<String, Object> info = new HashMap<>();
172+
Map<String, Object> info = APConfig.PERIPHERALS_CONFIG.morePlayerInformation.get()
173+
? LuaConverter.entityToLua(player)
174+
: new HashMap<>();
173175

174176
Vec3 selfPos = this.getPhysicsPos();
175177
Vec3 playerPos = player.position();
@@ -213,19 +215,12 @@ private Map<String, Object> getPlayerInfo(ServerPlayer player, boolean isOwner)
213215
CoordUtil.putFRUCoords(info, x - selfPos.x, y - selfPos.y, z - selfPos.z, owner.getOrientation());
214216

215217
if (APConfig.PERIPHERALS_CONFIG.morePlayerInformation.get()) {
216-
info.put("uuid", player.getUUID().toString());
217-
info.put("name", player.getGameProfile().getName());
218-
info.put("yaw", player.getYRot());
219-
info.put("pitch", player.getXRot());
220-
info.put("dimension", player.level().dimension().location().toString());
221-
info.put("eyeHeight", player.getEyeHeight());
222-
info.put("health", player.getHealth());
223-
info.put("maxHealth", player.getMaxHealth());
224-
info.put("airSupply", player.getAirSupply());
218+
// TODO: should we put those into lua converter as well?
225219
info.put("respawnPosition", LuaConverter.posToLua(player.getRespawnPosition()));
226220
info.put("respawnDimension", player.getRespawnDimension().location().toString());
227221
info.put("respawnAngle", player.getRespawnAngle());
228222
}
223+
229224
WeakReference<ServerPlayer> playerRef = new WeakReference<>(player);
230225
if (APConfig.PERIPHERALS_CONFIG.playerSpyStatistics.get()) {
231226
info.put("getStat", (ILuaFunction) (args) -> this.getPlayerStat(playerRef, args.getString(0)));

0 commit comments

Comments
 (0)