Skip to content

Commit

Permalink
connect module: added username field for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
benfiratkaya committed Nov 20, 2023
1 parent 15f516b commit 7a179bf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public void onEnable() {
/**
* Executes console command
* @param command command to execute
* @param username username of player
*/
@Override
public void executeCommands(String command) {
public void executeCommands(String command, String username) {
org.bukkit.Bukkit.getScheduler().runTask(Bukkit.getInstance(), () -> {
org.bukkit.Bukkit.dispatchCommand(org.bukkit.Bukkit.getConsoleSender(), command);
String msg = ChatUtil.replacePlaceholders(Bukkit.getInstance().getLangFile().getMessages().getConnect().getConnectExecutedCommand(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ public void onEnable() {
/**
* Executes console command
* @param command command to execute
* @param username username of player
*/
@Override
public void executeCommands(String command) {
public void executeCommands(String command, String username) {
Bungee.getInstance().getProxy().getPluginManager().dispatchCommand(
Bungee.getInstance().getProxy().getConsole(), command);
String msg = ChatUtil.replacePlaceholders(Bungee.getInstance().getLangFile().getMessages().getConnect().getConnectExecutedCommand(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ public SocketClient(String apiKey, String serverToken) throws URISyntaxException
// Get the command
String command = jsonItem.getString("command");

// Get the username
String username = jsonItem.getString("username");

// Execute the command
executeCommands(command);
executeCommands(command, username);
}
}

Expand All @@ -110,8 +113,9 @@ public SocketClient(String apiKey, String serverToken) throws URISyntaxException
/**
* Executes commands on proxy and server modules
* @param command command to execute
* @param username of player
*/
public abstract void executeCommands(String command);
public abstract void executeCommands(String command, String username);

/**
* Joined room abstracted method for debug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ public void onEnable() {
/**
* Executes console command
* @param command command to execute
* @param username username of player
*/
@Override
public void executeCommands(String command) {
public void executeCommands(String command, String username) {
Velocity.getInstance().getCommandManager()
.executeImmediatelyAsync(Velocity.getInstance().getServer().getConsoleCommandSource(), command);
Component msg = ChatUtil.replacePlaceholders(Velocity.getInstance().getLangFile().getMessages().getConnect().getConnectExecutedCommand(),
Expand Down

0 comments on commit 7a179bf

Please sign in to comment.