Reformat CoordLogger code
This commit is contained in:
@@ -29,6 +29,9 @@ public class CoordLogger extends Module {
|
|||||||
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
||||||
private final SettingGroup sgTeleports = settings.createGroup("Teleports");
|
private final SettingGroup sgTeleports = settings.createGroup("Teleports");
|
||||||
private final SettingGroup sgWorldEvents = settings.createGroup("World Events");
|
private final SettingGroup sgWorldEvents = settings.createGroup("World Events");
|
||||||
|
private final SettingGroup sgSounds = settings.createGroup("Sounds");
|
||||||
|
|
||||||
|
// General
|
||||||
|
|
||||||
private final Setting<Double> minDistance = sgGeneral.add(new DoubleSetting.Builder()
|
private final Setting<Double> minDistance = sgGeneral.add(new DoubleSetting.Builder()
|
||||||
.name("minimum-distance")
|
.name("minimum-distance")
|
||||||
@@ -41,6 +44,8 @@ public class CoordLogger extends Module {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Teleports
|
||||||
|
|
||||||
private final Setting<Boolean> players = sgTeleports.add(new BoolSetting.Builder()
|
private final Setting<Boolean> players = sgTeleports.add(new BoolSetting.Builder()
|
||||||
.name("players")
|
.name("players")
|
||||||
.description("Logs player teleports.")
|
.description("Logs player teleports.")
|
||||||
@@ -55,6 +60,7 @@ public class CoordLogger extends Module {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// World events
|
||||||
|
|
||||||
private final Setting<Boolean> enderDragons = sgWorldEvents.add(new BoolSetting.Builder()
|
private final Setting<Boolean> enderDragons = sgWorldEvents.add(new BoolSetting.Builder()
|
||||||
.name("ender-dragons")
|
.name("ender-dragons")
|
||||||
@@ -77,12 +83,6 @@ public class CoordLogger extends Module {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<Boolean> thunder = sgWorldEvents.add(new BoolSetting.Builder()
|
|
||||||
.name("thunder")
|
|
||||||
.description("Logs thunder sounds.")
|
|
||||||
.defaultValue(false)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
private final Setting<Boolean> otherEvents = sgWorldEvents.add(new BoolSetting.Builder()
|
private final Setting<Boolean> otherEvents = sgWorldEvents.add(new BoolSetting.Builder()
|
||||||
.name("other-global-events")
|
.name("other-global-events")
|
||||||
@@ -91,40 +91,59 @@ public class CoordLogger extends Module {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Sounds
|
||||||
|
|
||||||
|
private final Setting<Boolean> thunder = sgSounds.add(new BoolSetting.Builder()
|
||||||
|
.name("thunder")
|
||||||
|
.description("Logs thunder sounds.")
|
||||||
|
.defaultValue(false)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
public CoordLogger() {
|
public CoordLogger() {
|
||||||
super(MeteorRejectsAddon.CATEGORY,"coord-logger", "Logs coordinates of various events. Might not work on Spigot/Paper servers.");
|
super(MeteorRejectsAddon.CATEGORY,"coord-logger", "Logs coordinates of various events. Might not work on Spigot/Paper servers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onPacketReceive(PacketEvent.Receive event) {
|
private void onPacketReceive(PacketEvent.Receive event) {
|
||||||
|
// Teleports
|
||||||
if (event.packet instanceof EntityPositionS2CPacket) {
|
if (event.packet instanceof EntityPositionS2CPacket) {
|
||||||
EntityPositionS2CPacket packet = (EntityPositionS2CPacket) event.packet;
|
EntityPositionS2CPacket packet = (EntityPositionS2CPacket) event.packet;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Entity entity = mc.world.getEntityById(packet.getId());
|
Entity entity = mc.world.getEntityById(packet.getId());
|
||||||
|
|
||||||
|
// Player teleport
|
||||||
if (entity.getType().equals(EntityType.PLAYER) && players.get()) {
|
if (entity.getType().equals(EntityType.PLAYER) && players.get()) {
|
||||||
Vec3d packetPosition = new Vec3d(packet.getX(), packet.getY(), packet.getZ());
|
Vec3d packetPosition = new Vec3d(packet.getX(), packet.getY(), packet.getZ());
|
||||||
Vec3d playerPosition = entity.getPos();
|
Vec3d playerPosition = entity.getPos();
|
||||||
|
|
||||||
if (playerPosition.distanceTo(packetPosition) >= minDistance.get()) {
|
if (playerPosition.distanceTo(packetPosition) >= minDistance.get()) {
|
||||||
info(formatMessage("Player '" + entity.getEntityName() + "' has teleported to ", packetPosition));
|
info(formatMessage("Player '" + entity.getEntityName() + "' has teleported to ", packetPosition));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.getType().equals(EntityType.WOLF) && wolves.get()) {
|
// World teleport
|
||||||
|
else if (entity.getType().equals(EntityType.WOLF) && wolves.get()) {
|
||||||
Vec3d packetPosition = new Vec3d(packet.getX(), packet.getY(), packet.getZ());
|
Vec3d packetPosition = new Vec3d(packet.getX(), packet.getY(), packet.getZ());
|
||||||
Vec3d wolfPosition = entity.getPos();
|
Vec3d wolfPosition = entity.getPos();
|
||||||
|
|
||||||
UUID ownerUuid = ((TameableEntity) entity).getOwnerUuid();
|
UUID ownerUuid = ((TameableEntity) entity).getOwnerUuid();
|
||||||
|
|
||||||
if (ownerUuid != null && wolfPosition.distanceTo(packetPosition) >= minDistance.get()) {
|
if (ownerUuid != null && wolfPosition.distanceTo(packetPosition) >= minDistance.get()) {
|
||||||
info(formatMessage("Wolf has teleported to ", packetPosition));
|
info(formatMessage("Wolf has teleported to ", packetPosition));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(NullPointerException e) {}
|
} catch(NullPointerException ignored) {}
|
||||||
|
|
||||||
|
// World events
|
||||||
} else if (event.packet instanceof WorldEventS2CPacket) {
|
} else if (event.packet instanceof WorldEventS2CPacket) {
|
||||||
WorldEventS2CPacket worldEventS2CPacket = (WorldEventS2CPacket) event.packet;
|
WorldEventS2CPacket worldEventS2CPacket = (WorldEventS2CPacket) event.packet;
|
||||||
|
|
||||||
if (worldEventS2CPacket.isGlobal()) {
|
if (worldEventS2CPacket.isGlobal()) {
|
||||||
System.out.println(worldEventS2CPacket.getEventId());
|
// Min distance
|
||||||
if (PlayerUtils.distanceTo(worldEventS2CPacket.getPos()) <= minDistance.get()) return;
|
if (PlayerUtils.distanceTo(worldEventS2CPacket.getPos()) <= minDistance.get()) return;
|
||||||
|
|
||||||
switch (worldEventS2CPacket.getEventId()) {
|
switch (worldEventS2CPacket.getEventId()) {
|
||||||
case 1023:
|
case 1023:
|
||||||
if (withers.get()) info(formatMessage("Wither spawned at ", worldEventS2CPacket.getPos()));
|
if (withers.get()) info(formatMessage("Wither spawned at ", worldEventS2CPacket.getPos()));
|
||||||
@@ -139,6 +158,8 @@ public class CoordLogger extends Module {
|
|||||||
if (otherEvents.get()) info(formatMessage("Unknown global event at ", worldEventS2CPacket.getPos()));
|
if (otherEvents.get()) info(formatMessage("Unknown global event at ", worldEventS2CPacket.getPos()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sounds
|
||||||
} else if (thunder.get() && event.packet instanceof PlaySoundS2CPacket playSoundS2CPacket) {
|
} else if (thunder.get() && event.packet instanceof PlaySoundS2CPacket playSoundS2CPacket) {
|
||||||
// Check for thunder sound
|
// Check for thunder sound
|
||||||
if (playSoundS2CPacket.getSound() != SoundEvents.ENTITY_LIGHTNING_BOLT_IMPACT) return;
|
if (playSoundS2CPacket.getSound() != SoundEvents.ENTITY_LIGHTNING_BOLT_IMPACT) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user