add stuff and remove stuff about core and self care
This commit is contained in:
parent
9cdcbe3026
commit
b7bd19699d
4 changed files with 107 additions and 11 deletions
|
@ -7,8 +7,32 @@ import java.util.Map;
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
@Getter public int reconnectDelay = 7000;
|
@Getter public int reconnectDelay = 7000;
|
||||||
@Getter public Map<String, String> keys;
|
@Getter public Map<String, String> keys;
|
||||||
|
@Getter public Core core = new Core();
|
||||||
|
@Getter public SelfCare selfCare = new SelfCare();
|
||||||
@Getter public Bots[] bots = new Bots[]{};
|
@Getter public Bots[] bots = new Bots[]{};
|
||||||
|
|
||||||
|
public static class Core {
|
||||||
|
@Getter public int layers = 3;
|
||||||
|
@Getter public int refillInterval = 60 * 1000;
|
||||||
|
@Getter public String customName = "[{\"text\":\"ChomeNS \",\"color\":\"yellow\"},{\"text\":\"Core\",\"color\":\"green\"},{\"text\":\"™\",\"color\":\"gold\"}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SelfCare {
|
||||||
|
@Getter public int checkInterval;
|
||||||
|
|
||||||
|
@Getter public boolean op = true;
|
||||||
|
@Getter public boolean gamemode = true;
|
||||||
|
@Getter public boolean endCredits = true;
|
||||||
|
|
||||||
|
@Getter public boolean cspy = true;
|
||||||
|
@Getter public boolean vanish = true;
|
||||||
|
@Getter public boolean nickname = true;
|
||||||
|
@Getter public boolean socialspy = true;
|
||||||
|
@Getter public boolean mute = true;
|
||||||
|
|
||||||
|
@Getter public boolean prefix = true;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Bots {
|
public static class Bots {
|
||||||
@Getter public String host;
|
@Getter public String host;
|
||||||
@Getter public int port;
|
@Getter public int port;
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
package me.chayapak1.chomensbot_mabe.plugins;
|
package me.chayapak1.chomensbot_mabe.plugins;
|
||||||
|
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||||
import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode;
|
import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCommandBlockPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCommandBlockPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerActionPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundUseItemOnPacket;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||||
|
import com.github.steveice10.packetlib.Session;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.chayapak1.chomensbot_mabe.Bot;
|
import me.chayapak1.chomensbot_mabe.Bot;
|
||||||
|
@ -97,7 +108,7 @@ public class CorePlugin extends PositionPlugin.PositionListener {
|
||||||
|
|
||||||
public void refill () {
|
public void refill () {
|
||||||
final String command = String.format(
|
final String command = String.format(
|
||||||
"/minecraft:fill %s %s %s %s %s %s minecraft:command_block",
|
"/minecraft:fill %s %s %s %s %s %s minecraft:command_block{CustomName:'%s'}",
|
||||||
|
|
||||||
coreStart.getX() + origin.getX(),
|
coreStart.getX() + origin.getX(),
|
||||||
coreStart.getY(),
|
coreStart.getY(),
|
||||||
|
@ -105,9 +116,31 @@ public class CorePlugin extends PositionPlugin.PositionListener {
|
||||||
|
|
||||||
coreEnd.getX() + origin.getX(),
|
coreEnd.getX() + origin.getX(),
|
||||||
coreEnd.getY(),
|
coreEnd.getY(),
|
||||||
coreEnd.getZ() + origin.getZ()
|
coreEnd.getZ() + origin.getZ(),
|
||||||
|
|
||||||
|
bot.config().core().customName()
|
||||||
);
|
);
|
||||||
|
|
||||||
bot.chat().send(command);
|
bot.chat().send(command);
|
||||||
|
|
||||||
|
// no work :(
|
||||||
|
// CompoundTag tag = new CompoundTag("tag");
|
||||||
|
// CompoundTag blockEntityTag = new CompoundTag("BlockEntityTag");
|
||||||
|
// blockEntityTag.getValue().put("Command", new StringTag("Command", command));
|
||||||
|
// blockEntityTag.getValue().put("auto", new ByteTag("auto", (byte) 1));
|
||||||
|
// blockEntityTag.getValue().put("TrackOutput", new ByteTag("TrackOutput", (byte) 1));
|
||||||
|
// tag.getValue().put("BlockEntityTag", blockEntityTag);
|
||||||
|
//
|
||||||
|
// final Vector3i temporaryBlockPosition = Vector3i.from(
|
||||||
|
// bot.position().position().getX(),
|
||||||
|
// bot.position().position().getX() - 1,
|
||||||
|
// bot.position().position().getZ()
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// final Session session = bot.session();
|
||||||
|
// session.send(new ServerboundSetCreativeModeSlotPacket(45, new ItemStack(347 /* command block id */, 64, tag)));
|
||||||
|
// session.send(new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, temporaryBlockPosition, Direction.NORTH, 0));
|
||||||
|
// session.send(new ServerboundUseItemOnPacket(temporaryBlockPosition, Direction.NORTH, Hand.OFF_HAND, 0.5f, 0.5f, 0.5f, false, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Listener {
|
public static class Listener {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package me.chayapak1.chomensbot_mabe.plugins;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||||
import com.github.steveice10.mc.protocol.data.ProtocolState;
|
import com.github.steveice10.mc.protocol.data.ProtocolState;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.EntityEvent;
|
import com.github.steveice10.mc.protocol.data.game.entity.EntityEvent;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||||
import com.github.steveice10.mc.protocol.data.game.level.notify.GameEvent;
|
import com.github.steveice10.mc.protocol.data.game.level.notify.GameEvent;
|
||||||
|
@ -9,12 +10,14 @@ import com.github.steveice10.mc.protocol.data.game.level.notify.GameEventValue;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||||
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.clientbound.level.ClientboundGameEventPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
|
||||||
|
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||||
import com.github.steveice10.packetlib.Session;
|
import com.github.steveice10.packetlib.Session;
|
||||||
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
||||||
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
||||||
import com.github.steveice10.packetlib.packet.Packet;
|
import com.github.steveice10.packetlib.packet.Packet;
|
||||||
import com.github.steveice10.packetlib.packet.PacketProtocol;
|
import com.github.steveice10.packetlib.packet.PacketProtocol;
|
||||||
import me.chayapak1.chomensbot_mabe.Bot;
|
import me.chayapak1.chomensbot_mabe.Bot;
|
||||||
|
import me.chayapak1.chomensbot_mabe.Configuration;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
@ -30,6 +33,7 @@ public class SelfCarePlugin extends SessionAdapter {
|
||||||
private int permissionLevel;
|
private int permissionLevel;
|
||||||
private boolean cspy = false;
|
private boolean cspy = false;
|
||||||
private boolean vanish = false;
|
private boolean vanish = false;
|
||||||
|
private boolean nickname = false;
|
||||||
private boolean socialspy = false;
|
private boolean socialspy = false;
|
||||||
private boolean muted = false;
|
private boolean muted = false;
|
||||||
private boolean prefix = false;
|
private boolean prefix = false;
|
||||||
|
@ -48,6 +52,9 @@ public class SelfCarePlugin extends SessionAdapter {
|
||||||
else if (message.equals("Vanish for " + bot.username() + ": enabled")) vanish = true;
|
else if (message.equals("Vanish for " + bot.username() + ": enabled")) vanish = true;
|
||||||
else if (message.equals("Vanish for " + bot.username() + ": disabled")) vanish = false;
|
else if (message.equals("Vanish for " + bot.username() + ": disabled")) vanish = false;
|
||||||
|
|
||||||
|
else if (message.equals("You no longer have a nickname.")) nickname = true;
|
||||||
|
else if (message.startsWith("Your nickname is now ")) nickname = false;
|
||||||
|
|
||||||
else if (message.equals("SocialSpy for " + bot.username() + ": enabled")) socialspy = true;
|
else if (message.equals("SocialSpy for " + bot.username() + ": enabled")) socialspy = true;
|
||||||
else if (message.equals("SocialSpy for " + bot.username() + ": disabled")) socialspy = false;
|
else if (message.equals("SocialSpy for " + bot.username() + ": disabled")) socialspy = false;
|
||||||
|
|
||||||
|
@ -67,13 +74,16 @@ public class SelfCarePlugin extends SessionAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void check () {
|
public void check () {
|
||||||
if (gamemode != GameMode.CREATIVE) bot.chat().send("/minecraft:gamemode creative @s[type=player]");
|
final Configuration.SelfCare selfCares = bot.config().selfCare();
|
||||||
else if (permissionLevel < 2) bot.chat().send("/minecraft:op @s[type=player]");
|
|
||||||
else if (!cspy) bot.chat().send("/commandspy:commandspy on");
|
if (selfCares.gamemode() && gamemode != GameMode.CREATIVE) bot.chat().send("/minecraft:gamemode creative @s[type=player]");
|
||||||
else if (!vanish) bot.chat().send("/essentials:vanish enable");
|
else if (selfCares.op() && permissionLevel < 2) bot.chat().send("/minecraft:op @s[type=player]");
|
||||||
else if (!socialspy) bot.chat().send("/essentials:socialspy enable");
|
else if (selfCares.cspy() && !cspy) bot.chat().send("/commandspy:commandspy on");
|
||||||
else if (muted) bot.chat().send("/essentials:mute " + bot.username());
|
else if (selfCares.vanish() && !vanish) bot.chat().send("/essentials:vanish enable");
|
||||||
else if (!prefix) bot.chat().send("/extras:prefix &8[&eChomeNS Bot&8]");
|
else if (selfCares.nickname() && !nickname) bot.chat().send("/essentials:nickname off");
|
||||||
|
else if (selfCares.socialspy() && !socialspy) bot.chat().send("/essentials:socialspy enable");
|
||||||
|
else if (selfCares.mute() && muted) bot.chat().send("/essentials:mute " + bot.username());
|
||||||
|
else if (selfCares.prefix() && !prefix) bot.chat().send("/extras:prefix &8[&eChomeNS Bot&8]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,6 +99,7 @@ public class SelfCarePlugin extends SessionAdapter {
|
||||||
|
|
||||||
cspy = false;
|
cspy = false;
|
||||||
vanish = false;
|
vanish = false;
|
||||||
|
nickname = false;
|
||||||
socialspy = false;
|
socialspy = false;
|
||||||
muted = false;
|
muted = false;
|
||||||
prefix = false;
|
prefix = false;
|
||||||
|
@ -107,13 +118,18 @@ public class SelfCarePlugin extends SessionAdapter {
|
||||||
check();
|
check();
|
||||||
};
|
};
|
||||||
|
|
||||||
futureTask = bot.executor().scheduleAtFixedRate(task, 50, 500, TimeUnit.MILLISECONDS);
|
futureTask = bot.executor().scheduleAtFixedRate(task, bot.config().selfCare().checkInterval(), 500, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetReceived (ClientboundGameEventPacket packet) {
|
public void packetReceived (ClientboundGameEventPacket packet) {
|
||||||
final GameEvent notification = packet.getNotification();
|
final GameEvent notification = packet.getNotification();
|
||||||
final GameEventValue value = packet.getValue();
|
final GameEventValue value = packet.getValue();
|
||||||
|
|
||||||
|
if (notification == GameEvent.ENTER_CREDITS) {
|
||||||
|
bot.session().send(new ServerboundClientCommandPacket(ClientCommand.RESPAWN));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (notification == GameEvent.CHANGE_GAMEMODE) gamemode = (GameMode) value;
|
if (notification == GameEvent.CHANGE_GAMEMODE) gamemode = (GameMode) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,31 @@ reconnectDelay: 7000
|
||||||
keys:
|
keys:
|
||||||
normalKey: 'normal hash key here'
|
normalKey: 'normal hash key here'
|
||||||
ownerKey: 'OwnerHash™ key here'
|
ownerKey: 'OwnerHash™ key here'
|
||||||
|
core:
|
||||||
|
layers: 3
|
||||||
|
# will add refill interval later after the bot can place command blocks to refill core
|
||||||
|
# refillInterval: 60000
|
||||||
|
# PLEASE give valid JSON component here else the core don't refill at all
|
||||||
|
customName: '[{"text":"ChomeNS ","color":"yellow"},{"text":"Core","color":"green"},{"text":"™","color":"gold"}]'
|
||||||
|
selfCare:
|
||||||
|
checkInterval: 1000,
|
||||||
|
|
||||||
|
# vanilla
|
||||||
|
op: true,
|
||||||
|
gamemode: true,
|
||||||
|
endCredits: true,
|
||||||
|
|
||||||
|
# essentials
|
||||||
|
cspy: true,
|
||||||
|
vanish: true,
|
||||||
|
nickname: true,
|
||||||
|
socialspy: true,
|
||||||
|
mute: true,
|
||||||
|
|
||||||
|
# extras
|
||||||
|
prefix: true
|
||||||
bots:
|
bots:
|
||||||
# username is optional, if doesn't exist it will default to random username
|
# username is optional, if it doesn't exist it will default to random username
|
||||||
- host: 'localhost'
|
- host: 'localhost'
|
||||||
port: 25565
|
port: 25565
|
||||||
username: 'ChomeNS_Bot'
|
username: 'ChomeNS_Bot'
|
Loading…
Reference in a new issue