G-Earth/Extensions/AdminOnConnect/src/main/java/extensions/adminonconnect/AdminOnConnect.java

52 lines
1.3 KiB
Java
Raw Normal View History

2018-10-13 22:54:52 +02:00
package extensions.adminonconnect;
2018-06-26 21:20:10 +02:00
2018-10-13 22:54:52 +02:00
import gearth.extensions.Extension;
import gearth.extensions.ExtensionInfo;
import gearth.protocol.HMessage;
import gearth.protocol.HPacket;
2018-06-26 21:20:10 +02:00
/**
* Created by Jonas on 26/06/18.
*/
@ExtensionInfo(
Title = "Always admin!",
Description = "Gives you admin permission on connect",
Version = "1.0",
Author = "sirjonasxx"
)
public class AdminOnConnect extends Extension {
2018-06-26 21:20:10 +02:00
public static void main(String[] args) {
2018-09-27 15:05:38 +02:00
new AdminOnConnect(args).run();
2018-06-26 21:20:10 +02:00
}
public AdminOnConnect(String[] args) {
super(args);
}
private boolean done = true;
protected void init() {
intercept(HMessage.Side.TOCLIENT, message -> {
2018-06-26 21:20:10 +02:00
if (!done) {
HPacket packet = message.getPacket();
if (packet.length() == 11) {
if (packet.readByte(14) == 0 || packet.readByte(14) == 1) {
packet.replaceInt(6, 7);
packet.replaceInt(10, 7);
packet.replaceBoolean(14, true);
done = true;
}
}
}
});
intercept(HMessage.Side.TOSERVER, 4000, message -> done = false);
2018-07-19 18:35:48 +02:00
}
// protected void onStartConnection() {
// done = false;
// }
2018-06-26 21:20:10 +02:00
}