SamsTheNerd / ducky-periphs

A peripheral addon mod for ComputerCraft Restitched
9 stars 3 forks source link

Command computers can be interacted with via keyboards #28

Open SquidDev opened 10 months ago

SquidDev commented 10 months ago

Versions

Steps to reproduce

I'm not really sure there's a good way to guard against this, at least within the confines of CC's API. Really the best solution would be to not queue events on command computers, but IComputerAccess doesn't expose any methods for that.

Entirely unrelated, but didn't feel worth opening a separate bug for this, KeyboardPeripheral's handling of the computer list isn't thread-safe - attach and detach can be called from both the computer and main thread. The easiest thing to do is swap out the ArrayList with a Collections.newSetFromMap(new ConcurrentHashMap<>()).

SamsTheNerd commented 10 months ago

is getId() on IComputerAccess the same ID that ServerComputerRegistry.get() takes ? if so could use that to get whether or not it's a command computer ?

Then just check if the player using the keyboard has the right perms (which is OP and creative ? ) and only sending events on the command computers if they have the perms.

SquidDev commented 10 months ago

is getId() on IComputerAccess the same ID that ServerComputerRegistry.get() takes ? if so could use that to get whether or not it's a command computer ?

https://github.com/SamsTheNerd/ducky-periphs/blob/bbf6aaa583fe1f8133ffad946ce9d1b3ac61d340/common/src/main/java/com/samsthenerd/duckyperiphs/peripherals/keyboards/KeyboardPeripheral.java#L92-L94

Wait, what!? I see you were using IComputerAccess.queueEvent pre 1.20 - what was the motivation for this switch?

SamsTheNerd commented 10 months ago

it still has those on 1.20, i think the non IComputerAccess stuff is just for rebooting and shutdown commands, which I don't think worked with the way i was doing it before ?