Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...rc/main/java/com/denizenscript/depenizen/bukkit/commands/bungee/BungeeExecuteCommand.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,63 @@ | ||
package com.denizenscript.depenizen.bukkit.commands.bungee; | ||
|
||
import com.denizenscript.depenizen.bukkit.support.bungee.BungeeSupport; | ||
import com.denizenscript.depenizen.common.socket.client.packet.ClientPacketOutExecute; | ||
import net.aufdemrand.denizencore.exceptions.CommandExecutionException; | ||
import net.aufdemrand.denizencore.exceptions.InvalidArgumentsException; | ||
import net.aufdemrand.denizencore.objects.Element; | ||
import net.aufdemrand.denizencore.objects.aH; | ||
import net.aufdemrand.denizencore.scripts.ScriptEntry; | ||
import net.aufdemrand.denizencore.scripts.commands.AbstractCommand; | ||
import net.aufdemrand.denizencore.utilities.debugging.dB; | ||
|
||
public class BungeeExecuteCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Name BungeeExecute | ||
// @Syntax bungeeexecute [<command>] | ||
// @Group Depenizen | ||
// @Plugin DepenizenBukkit, DepenizenBungee | ||
// @Required 1 | ||
// @Stable stable | ||
// @Short Executes a command on the BungeeCord proxy server. | ||
// @Author Morphan1 | ||
|
||
// @Description | ||
// This command allows you to execute a BungeeCord command, as if it | ||
// was typed into the proxy server's console. | ||
|
||
// @Tags | ||
// None | ||
|
||
// @Usage | ||
// Send an alert message through BungeeCord. | ||
// - bungeeexecute "alert Hey! Listen!" | ||
|
||
// --> | ||
|
||
@Override | ||
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException { | ||
|
||
for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) { | ||
|
||
if (!scriptEntry.hasObject("command")) { | ||
scriptEntry.addObject("command", arg.asElement()); | ||
} | ||
|
||
} | ||
|
||
if (!scriptEntry.hasObject("command")) { | ||
throw new InvalidArgumentsException("Must specify a command to execute!"); | ||
} | ||
} | ||
|
||
@Override | ||
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { | ||
|
||
Element command = scriptEntry.getElement("command"); | ||
|
||
dB.report(scriptEntry, getName(), command.debug()); | ||
|
||
BungeeSupport.getSocketClient().trySend(new ClientPacketOutExecute(command.asString())); | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
.../java/com/denizenscript/depenizen/common/socket/client/packet/ClientPacketOutExecute.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,19 @@ | ||
package com.denizenscript.depenizen.common.socket.client.packet; | ||
|
||
import com.denizenscript.depenizen.common.socket.DataSerializer; | ||
import com.denizenscript.depenizen.common.socket.Packet; | ||
|
||
public class ClientPacketOutExecute extends Packet { | ||
|
||
private String command; | ||
|
||
public ClientPacketOutExecute(String command) { | ||
this.command = command; | ||
} | ||
|
||
@Override | ||
public void serialize(DataSerializer serializer) { | ||
serializer.writeUnsignedByte(Packet.ServerBound.EXECUTE.getId()); | ||
serializer.writeString(command); | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
...n/java/com/denizenscript/depenizen/common/socket/server/packet/ServerPacketInExecute.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,18 @@ | ||
package com.denizenscript.depenizen.common.socket.server.packet; | ||
|
||
import com.denizenscript.depenizen.common.socket.DataDeserializer; | ||
import com.denizenscript.depenizen.common.socket.Packet; | ||
|
||
public class ServerPacketInExecute extends Packet { | ||
|
||
private String command; | ||
|
||
@Override | ||
public void deserialize(DataDeserializer deserializer) { | ||
command = deserializer.readString(); | ||
} | ||
|
||
public String getCommand() { | ||
return command; | ||
} | ||
} |