improve the stuff
This commit is contained in:
parent
e521c6b671
commit
8a8d6cc102
5 changed files with 37 additions and 40 deletions
|
@ -54,7 +54,6 @@ public class Bot {
|
||||||
public CommandSpyPlugin commandSpy;
|
public CommandSpyPlugin commandSpy;
|
||||||
public PositionPlugin position;
|
public PositionPlugin position;
|
||||||
public ServerPluginsManagerPlugin serverPluginsManager;
|
public ServerPluginsManagerPlugin serverPluginsManager;
|
||||||
public PluginCheckerPlugin pluginChecker;
|
|
||||||
public SelfCarePlugin selfCare;
|
public SelfCarePlugin selfCare;
|
||||||
public CorePlugin core;
|
public CorePlugin core;
|
||||||
public TeamPlugin team;
|
public TeamPlugin team;
|
||||||
|
@ -103,7 +102,6 @@ public class Bot {
|
||||||
this.commandSpy = new CommandSpyPlugin(this);
|
this.commandSpy = new CommandSpyPlugin(this);
|
||||||
this.position = new PositionPlugin(this);
|
this.position = new PositionPlugin(this);
|
||||||
this.serverPluginsManager = new ServerPluginsManagerPlugin(this);
|
this.serverPluginsManager = new ServerPluginsManagerPlugin(this);
|
||||||
this.pluginChecker = new PluginCheckerPlugin(this);
|
|
||||||
this.selfCare = new SelfCarePlugin(this);
|
this.selfCare = new SelfCarePlugin(this);
|
||||||
this.core = new CorePlugin(this);
|
this.core = new CorePlugin(this);
|
||||||
this.team = new TeamPlugin(this);
|
this.team = new TeamPlugin(this);
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void forceRun (String command) {
|
private void forceRun (String command) {
|
||||||
if (bot.pluginChecker.hasExtras) {
|
if (bot.serverPluginsManager.hasPlugin(ServerPluginsManagerPlugin.EXTRAS)) {
|
||||||
bot.session.send(new ServerboundSetCommandBlockPacket(
|
bot.session.send(new ServerboundSetCommandBlockPacket(
|
||||||
block,
|
block,
|
||||||
command,
|
command,
|
||||||
|
@ -205,7 +205,18 @@ public class CorePlugin extends PositionPlugin.Listener {
|
||||||
);
|
);
|
||||||
|
|
||||||
final Session session = bot.session;
|
final Session session = bot.session;
|
||||||
session.send(new ServerboundSetCreativeModeSlotPacket(36, new ItemStack(bot.pluginChecker.hasExtras ? 492 /* repeating command block id */ : 373 /* command block id */, 64, tag)));
|
session.send(
|
||||||
|
new ServerboundSetCreativeModeSlotPacket(
|
||||||
|
36,
|
||||||
|
new ItemStack(
|
||||||
|
bot.serverPluginsManager.hasPlugin(ServerPluginsManagerPlugin.EXTRAS) ?
|
||||||
|
492 /* repeating command block id */ :
|
||||||
|
373 /* command block id */,
|
||||||
|
64,
|
||||||
|
tag
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
session.send(new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, temporaryBlockPosition, Direction.NORTH, 0));
|
session.send(new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, temporaryBlockPosition, Direction.NORTH, 0));
|
||||||
session.send(new ServerboundUseItemOnPacket(temporaryBlockPosition, Direction.UP, Hand.MAIN_HAND, 0.5f, 0.5f, 0.5f, false, 1));
|
session.send(new ServerboundUseItemOnPacket(temporaryBlockPosition, Direction.UP, Hand.MAIN_HAND, 0.5f, 0.5f, 0.5f, false, 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package land.chipmunk.chayapak.chomens_bot.plugins;
|
|
||||||
|
|
||||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class PluginCheckerPlugin extends Bot.Listener {
|
|
||||||
public boolean hasExtras;
|
|
||||||
public boolean hasEssentials;
|
|
||||||
|
|
||||||
public PluginCheckerPlugin(Bot bot) {
|
|
||||||
// dumb
|
|
||||||
bot.executor.scheduleAtFixedRate(() -> {
|
|
||||||
hasExtras = bot.serverPluginsManager.plugins.contains("Extras");
|
|
||||||
hasEssentials = bot.serverPluginsManager.plugins.contains("Essentials");
|
|
||||||
}, 0, 5, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -86,7 +86,8 @@ public class SelfCarePlugin extends Bot.Listener {
|
||||||
public void check () {
|
public void check () {
|
||||||
final Configuration.SelfCare selfCares = bot.config.selfCare;
|
final Configuration.SelfCare selfCares = bot.config.selfCare;
|
||||||
|
|
||||||
final boolean kaboom = bot.pluginChecker.hasExtras;
|
final boolean kaboom = bot.serverPluginsManager.hasPlugin(ServerPluginsManagerPlugin.EXTRAS);
|
||||||
|
final boolean hasEssentials = bot.serverPluginsManager.hasPlugin(ServerPluginsManagerPlugin.ESSENTIALS);
|
||||||
|
|
||||||
// chat only
|
// chat only
|
||||||
if (selfCares.op && permissionLevel < 2) bot.chat.send("/minecraft:op @s[type=player]");
|
if (selfCares.op && permissionLevel < 2) bot.chat.send("/minecraft:op @s[type=player]");
|
||||||
|
@ -96,25 +97,25 @@ public class SelfCarePlugin extends Bot.Listener {
|
||||||
else if (selfCares.username && !username && kaboom) bot.chat.send("/extras:username " + bot.username);
|
else if (selfCares.username && !username && kaboom) bot.chat.send("/extras:username " + bot.username);
|
||||||
|
|
||||||
// core
|
// core
|
||||||
// TODO: improve lol, this is ohio
|
|
||||||
else if (selfCares.icu.enabled && positionPacketsPerSecond > selfCares.icu.positionPacketsPerSecond) bot.core.run("essentials:sudo * icu stop");
|
else if (selfCares.icu.enabled && positionPacketsPerSecond > selfCares.icu.positionPacketsPerSecond) bot.core.run("essentials:sudo * icu stop");
|
||||||
else if (selfCares.vanish && !vanish && !visibility && bot.pluginChecker.hasEssentials) {
|
else if (hasEssentials) {
|
||||||
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:vanish enable");
|
// TODO: improve lol, this is ohio
|
||||||
else bot.core.run("essentials:vanish " + bot.username + " enable");
|
|
||||||
}
|
|
||||||
else if (selfCares.nickname && !nickname && bot.pluginChecker.hasEssentials) {
|
|
||||||
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:nick off");
|
|
||||||
else bot.core.run("essentials:nickname " + bot.username + " off");
|
|
||||||
}
|
|
||||||
else if (selfCares.socialspy && !socialspy && bot.pluginChecker.hasEssentials) {
|
|
||||||
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:socialspy enable");
|
|
||||||
else bot.core.run("essentials:socialspy " + bot.username + " enable");
|
|
||||||
}
|
|
||||||
else if (selfCares.mute && muted && bot.pluginChecker.hasEssentials) {
|
|
||||||
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:mute " + bot.profile.getIdAsString());
|
|
||||||
else bot.core.run("essentials:mute " + bot.profile.getIdAsString());
|
|
||||||
|
|
||||||
muted = false; // too lazy fix and probably the worst fix?
|
if (selfCares.vanish && !vanish && !visibility) {
|
||||||
|
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:vanish enable");
|
||||||
|
else bot.core.run("essentials:vanish " + bot.username + " enable");
|
||||||
|
} else if (selfCares.nickname && !nickname) {
|
||||||
|
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:nick off");
|
||||||
|
else bot.core.run("essentials:nickname " + bot.username + " off");
|
||||||
|
} else if (selfCares.socialspy && !socialspy) {
|
||||||
|
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:socialspy enable");
|
||||||
|
else bot.core.run("essentials:socialspy " + bot.username + " enable");
|
||||||
|
} else if (selfCares.mute && muted) {
|
||||||
|
if (bot.options.useChat) bot.chat.sendCommandInstantly("essentials:mute " + bot.profile.getIdAsString());
|
||||||
|
else bot.core.run("essentials:mute " + bot.profile.getIdAsString());
|
||||||
|
|
||||||
|
muted = false; // too lazy fix
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@ import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class ServerPluginsManagerPlugin extends Bot.Listener {
|
public class ServerPluginsManagerPlugin extends Bot.Listener {
|
||||||
|
public static final String EXTRAS = "Extras";
|
||||||
|
public static final String ESSENTIALS = "Essentials";
|
||||||
|
|
||||||
private final Bot bot;
|
private final Bot bot;
|
||||||
|
|
||||||
public List<String> plugins = new ArrayList<>();
|
public List<String> plugins = new ArrayList<>();
|
||||||
|
@ -33,4 +36,6 @@ public class ServerPluginsManagerPlugin extends Bot.Listener {
|
||||||
return packet;
|
return packet;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasPlugin (String plugin) { return plugins.contains(plugin); }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue