forked from chipmunkmc/chipmunkbot
add prefix self care and make the self cares configurable
more spam ngl,.,.,.,. well i increased the delay a bit but its still spammy,.,.
This commit is contained in:
parent
372cdce2fa
commit
801ce9cbd2
4 changed files with 47 additions and 4 deletions
|
@ -36,7 +36,7 @@ public class ChipmunkBot extends Client {
|
||||||
this.playerCommandHandler = new PlayerCommandHandler(this, options);
|
this.playerCommandHandler = new PlayerCommandHandler(this, options);
|
||||||
this.position = new PositionManager(this);
|
this.position = new PositionManager(this);
|
||||||
this.core = new CommandCore(this, options);
|
this.core = new CommandCore(this, options);
|
||||||
this.selfCare = new SelfCarePlugin(this);
|
this.selfCare = new SelfCarePlugin(this, options);
|
||||||
this.songPlayer = new SongPlayer(this);
|
this.songPlayer = new SongPlayer(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,18 @@ public class Configuration {
|
||||||
|
|
||||||
public Core core = new Core();
|
public Core core = new Core();
|
||||||
|
|
||||||
|
public SelfCares selfCares = new SelfCares();
|
||||||
|
|
||||||
|
public static class SelfCares {
|
||||||
|
public boolean cspy = true;
|
||||||
|
public PrefixSelfCare prefix = new PrefixSelfCare();
|
||||||
|
|
||||||
|
public static class PrefixSelfCare {
|
||||||
|
public boolean enabled = true;
|
||||||
|
public String prefix = "&x&c&9&5&3&6&7[&x&f&f&c&0&c&bPrefix: s'&x&c&9&5&3&6&7]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class Commands {
|
public static class Commands {
|
||||||
public String prefix = "default.";
|
public String prefix = "default.";
|
||||||
public String cspyPrefix = "default.";
|
public String cspyPrefix = "default.";
|
||||||
|
|
|
@ -18,23 +18,45 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLo
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||||
|
import land.chipmunk.chipmunkbot.Configuration;
|
||||||
|
import land.chipmunk.chipmunkbot.util.ComponentUtilities;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class SelfCarePlugin extends SessionAdapter {
|
public class SelfCarePlugin extends SessionAdapter {
|
||||||
private final ChipmunkBot client;
|
private final ChipmunkBot client;
|
||||||
|
private final Configuration.Bot options;
|
||||||
|
|
||||||
@Getter @Setter private GameMode gamemode;
|
@Getter @Setter private GameMode gamemode;
|
||||||
@Getter @Setter private int permissionLevel;
|
@Getter @Setter private int permissionLevel;
|
||||||
|
|
||||||
|
private boolean prefix = false;
|
||||||
|
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private int entityId; // TODO: Move entity id handling somewhere else
|
private int entityId; // TODO: Move entity id handling somewhere else
|
||||||
|
|
||||||
public SelfCarePlugin (ChipmunkBot client) {
|
public SelfCarePlugin (ChipmunkBot client, Configuration.Bot options) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
this.options = options;
|
||||||
client.addListener((SessionListener) this);
|
client.addListener((SessionListener) this);
|
||||||
|
|
||||||
|
client.chat().addListener(new ChatPlugin.Listener() {
|
||||||
|
@Override
|
||||||
|
public void systemMessageReceived(Component component, boolean overlay) {
|
||||||
|
// mabe parse using components? too lazy
|
||||||
|
final String stringifiedMessage = ComponentUtilities.stringify(component);
|
||||||
|
|
||||||
|
if (stringifiedMessage.equals("You now have the tag: " + options.selfCares.prefix.prefix)) prefix = true;
|
||||||
|
else if (stringifiedMessage.equals("You no longer have a tag")) prefix = false;
|
||||||
|
else if (stringifiedMessage.startsWith("You now have the tag: ")) prefix = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
final TimerTask task = new TimerTask() {
|
final TimerTask task = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run () {
|
public void run () {
|
||||||
|
@ -48,13 +70,14 @@ public class SelfCarePlugin extends SessionAdapter {
|
||||||
};
|
};
|
||||||
|
|
||||||
timer = new Timer();
|
timer = new Timer();
|
||||||
timer.schedule(task, 75, 75);
|
timer.schedule(task, 125, 125);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tick () {
|
public void tick () {
|
||||||
if (permissionLevel < 2) client.chat().command("minecraft:op @s[type=player]");
|
if (permissionLevel < 2) client.chat().command("minecraft:op @s[type=player]");
|
||||||
else if (gamemode != GameMode.CREATIVE) client.chat().command("minecraft:gamemode creative");
|
else if (gamemode != GameMode.CREATIVE) client.chat().command("minecraft:gamemode creative");
|
||||||
else if (!client.commandSpy().enabled()) client.chat().command("c on");
|
else if (!client.commandSpy().enabled() && options.selfCares.cspy) client.chat().command("c on");
|
||||||
|
else if (!prefix && options.selfCares.prefix.enabled) client.chat().command("prefix " + options.selfCares.prefix.prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,6 +15,14 @@
|
||||||
"cspyPrefix": "default."
|
"cspyPrefix": "default."
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"selfCares": {
|
||||||
|
"cspy": true,
|
||||||
|
"prefix": {
|
||||||
|
"enabled": true,
|
||||||
|
"prefix": "&x&c&9&5&3&6&7[&x&f&f&c&0&c&bPrefix: s'&x&c&9&5&3&6&7]"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
"core": {
|
"core": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue