-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # src/main/java/com/zenith/network/registry/ZenithHandlerCodec.java # src/main/java/com/zenith/network/server/ServerSession.java
- Loading branch information
Showing
8 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/main/java/com/zenith/command/impl/RotateCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package com.zenith.command.impl; | ||
|
||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import com.zenith.Proxy; | ||
import com.zenith.command.Command; | ||
import com.zenith.command.CommandUsage; | ||
import com.zenith.command.brigadier.CommandCategory; | ||
import com.zenith.command.brigadier.CommandContext; | ||
|
||
import static com.mojang.brigadier.arguments.FloatArgumentType.floatArg; | ||
import static com.mojang.brigadier.arguments.FloatArgumentType.getFloat; | ||
import static com.zenith.Shared.CACHE; | ||
import static com.zenith.Shared.PATHING; | ||
import static java.util.Arrays.asList; | ||
|
||
public class RotateCommand extends Command { | ||
private static final int MOVE_PRIORITY = 1000000; | ||
|
||
@Override | ||
public CommandUsage commandUsage() { | ||
return CommandUsage.args( | ||
"rotate", | ||
CommandCategory.MODULE, | ||
""" | ||
Rotates the bot in-game. | ||
Note that many other modules can change the player's rotation after this command is executed. | ||
""", | ||
asList( | ||
"<yaw> <pitch>", | ||
"yaw <yaw>", | ||
"pitch <pitch>" | ||
) | ||
); | ||
} | ||
|
||
@Override | ||
public LiteralArgumentBuilder<CommandContext> register() { | ||
return command("rotate") | ||
.then(argument("yaw", floatArg(-180, 180)).then(argument("pitch", floatArg(-90, 90)).executes(c -> { | ||
float yaw = getFloat(c, "yaw"); | ||
float pitch = getFloat(c, "pitch"); | ||
if (!Proxy.getInstance().isConnected()) { | ||
c.getSource().getEmbed() | ||
.title("Error") | ||
.errorColor() | ||
.description("Not connected to a server"); | ||
return OK; | ||
} | ||
if (Proxy.getInstance().hasActivePlayer()) { | ||
c.getSource().getEmbed() | ||
.title("Error") | ||
.errorColor() | ||
.description("Cannot rotate while player is controlling"); | ||
return OK; | ||
} | ||
PATHING.rotate(yaw, pitch, MOVE_PRIORITY); | ||
c.getSource().getEmbed() | ||
.title("Rotated") | ||
.successColor(); | ||
return OK; | ||
}))) | ||
.then(literal("yaw").then(argument("yaw", floatArg(-180, 180)).executes(c -> { | ||
float yaw = getFloat(c, "yaw"); | ||
if (!Proxy.getInstance().isConnected()) { | ||
c.getSource().getEmbed() | ||
.title("Error") | ||
.errorColor() | ||
.description("Not connected to a server"); | ||
return OK; | ||
} | ||
if (Proxy.getInstance().hasActivePlayer()) { | ||
c.getSource().getEmbed() | ||
.title("Error") | ||
.errorColor() | ||
.description("Cannot rotate while player is controlling"); | ||
return OK; | ||
} | ||
PATHING.rotate(yaw, CACHE.getPlayerCache().getPitch(), MOVE_PRIORITY); | ||
c.getSource().getEmbed() | ||
.title("Rotated") | ||
.successColor(); | ||
return OK; | ||
}))) | ||
.then(literal("pitch").then(argument("pitch", floatArg(-90, 90)).executes(c -> { | ||
float pitch = getFloat(c, "pitch"); | ||
if (!Proxy.getInstance().isConnected()) { | ||
c.getSource().getEmbed() | ||
.title("Error") | ||
.errorColor() | ||
.description("Not connected to a server"); | ||
return OK; | ||
} | ||
if (Proxy.getInstance().hasActivePlayer()) { | ||
c.getSource().getEmbed() | ||
.title("Error") | ||
.errorColor() | ||
.description("Cannot rotate while player is controlling"); | ||
return OK; | ||
} | ||
PATHING.rotate(CACHE.getPlayerCache().getYaw(), pitch, MOVE_PRIORITY); | ||
c.getSource().getEmbed() | ||
.title("Rotated") | ||
.successColor(); | ||
return OK; | ||
}))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...ith/network/server/handler/spectator/outgoing/OpenSignEditorSpectatorOutgoingHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.zenith.network.server.handler.spectator.outgoing; | ||
|
||
import com.zenith.network.registry.PacketHandler; | ||
import com.zenith.network.server.ServerSession; | ||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundOpenSignEditorPacket; | ||
|
||
public class OpenSignEditorSpectatorOutgoingHandler implements PacketHandler<ClientboundOpenSignEditorPacket, ServerSession> { | ||
@Override | ||
public ClientboundOpenSignEditorPacket apply(final ClientboundOpenSignEditorPacket packet, final ServerSession session) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters