Skip to content

Commit

Permalink
feat: add bungeecord support
Browse files Browse the repository at this point in the history
  • Loading branch information
titivermeesch committed Oct 27, 2024
1 parent 0f2f2fb commit 152d279
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 23 deletions.
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ java {


group = 'me.playbosswar.com'
version = '8.9.1'
version = '8.10.0'
description = 'CommandTimer'

repositories {
Expand All @@ -27,6 +27,9 @@ repositories {
maven {
url = 'https://repo.codemc.io/repository/maven-snapshots/'
}
maven {
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
}

shadowJar {
Expand Down Expand Up @@ -54,7 +57,8 @@ dependencies {
implementation 'io.sentry:sentry:7.0.0'
implementation 'com.j256.ormlite:ormlite-jdbc:6.1'
implementation 'org.apache.commons:commons-pool2:2.12.0'
compileOnly 'io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT'
implementation 'org.apache.commons:commons-lang3:3.17.0'
compileOnly 'org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT'
compileOnly 'me.clip:placeholderapi:2.11.6'
compileOnly 'org.jetbrains:annotations:23.1.0'
}
Expand All @@ -64,8 +68,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java21'
version = '8.9.1'

version = '8.10.0'
from components.java
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/docs/configuration/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Genders define for whom the command will be executed.
the [conditions engine](conditions.md) to check if the player has the permission before executing it.
- `CONSOLE_PER_USER_OFFLINE`: Same as `CONSOLE_PER_USER` but also executed for all offline players that every joined. *
*Please note that the conditions engine is currently not compatible with this gender**
- `CONSOLE_PROXY`: Execute commands on your proxy. You need the [CommandTimer Proxy Extension](https://www.spigotmc.org/resources/commandtimer-proxy-extension.120439/) for this. Depending on which version of the extension you use the commands may only be executed when a player is connected to the proxy network

## Command iteration interval

Expand Down
4 changes: 2 additions & 2 deletions java17-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ java {


group = 'me.playbosswar.com'
version = '8.9.1'
version = '8.10.0'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -63,7 +63,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java17'
version = '8.9.1'
version = '8.10.0'

from components.java
}
Expand Down
4 changes: 2 additions & 2 deletions java8-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java {
}

group = 'me.playbosswar.com'
version = '8.9.1'
version = '8.10.0'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -70,7 +70,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java8'
version = '8.9.1'
version = '8.10.0'

from components.java
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/playbosswar/com/CommandTimerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public void onEnable() {
options.setTracesSampleRate(0.3);
options.setRelease(getDescription().getVersion());
});

Sentry.configureScope(scope -> {
scope.setExtra("bukkit_version", getServer().getBukkitVersion());
scope.setExtra("server_name", getServer().getName());
Expand Down Expand Up @@ -97,6 +96,7 @@ public void onEnable() {
conditionEngineManager = new ConditionEngineManager();
eventsManager = new EventsManager(tasksManager);
inventoryManager.init();
getServer().getMessenger().registerOutgoingPluginChannel(plugin, "commandtimer:main");
loadMetrics();

if(getConfig().getBoolean("timeonload")) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/me/playbosswar/com/enums/Gender.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ public enum Gender {
/**
* Commands are executed for each player that ever joined
*/
CONSOLE_PER_USER_OFFLINE;
CONSOLE_PER_USER_OFFLINE,
/**
* Commands are executed in the linked proxy server
*/
CONSOLE_PROXY,
}
5 changes: 5 additions & 0 deletions src/main/java/me/playbosswar/com/tasks/TaskCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public void toggleGender() {
}

if(gender.equals(Gender.CONSOLE_PER_USER_OFFLINE)) {
setGender(Gender.CONSOLE_PROXY);
return;
}

if(gender.equals(Gender.CONSOLE_PROXY)) {
setGender(Gender.OPERATOR);
}
}
Expand Down
62 changes: 51 additions & 11 deletions src/main/java/me/playbosswar/com/tasks/TasksManager.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
package me.playbosswar.com.tasks;

import me.playbosswar.com.CommandTimerPlugin;
import me.playbosswar.com.enums.CommandExecutionMode;
import me.playbosswar.com.enums.Gender;
import me.playbosswar.com.hooks.PAPIHook;
import me.playbosswar.com.utils.*;
import org.apache.commons.lang.RandomStringUtils;
import java.io.IOException;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

import org.apache.commons.lang3.RandomStringUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandException;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.*;
import java.util.stream.Collectors;
import me.playbosswar.com.CommandTimerPlugin;
import me.playbosswar.com.enums.CommandExecutionMode;
import me.playbosswar.com.enums.Gender;
import me.playbosswar.com.hooks.PAPIHook;
import me.playbosswar.com.utils.DatabaseUtils;
import me.playbosswar.com.utils.Files;
import me.playbosswar.com.utils.Messages;
import me.playbosswar.com.utils.StringEnhancer;
import me.playbosswar.com.utils.Tools;


public class TasksManager {
Expand Down Expand Up @@ -288,6 +302,30 @@ private boolean runOperatorCommand(Task task, TaskCommand taskCommand) {
return runOperatorCommand(task, taskCommand, new ArrayList<>());
}

private boolean runConsoleProxyCommand(Task task, TaskCommand taskCommand) {
if(task.hasCondition()) {
boolean valid = TaskValidationHelpers.processCondition(task.getCondition(), null);
if(!valid) {
Messages.sendDebugConsole(CONDITION_NO_MATCH);
return false;
}
}

String command = taskCommand.getCommand();
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("executeConsoleCommand");
out.writeUTF(command);
} catch (IOException e) {
e.printStackTrace();
}

Bukkit.getServer().sendPluginMessage(CommandTimerPlugin.getPlugin(), "commandtimer:main", b.toByteArray());
executionsSinceLastSync++;
return true;
}

public void processCommandExecution(Task task, TaskCommand taskCommand) {
if(!task.isActive()) {
return;
Expand All @@ -306,6 +344,8 @@ public void processCommandExecution(Task task, TaskCommand taskCommand) {
executed = runConsolePerUserCommand(task, taskCommand);
} else if(gender.equals(Gender.CONSOLE_PER_USER_OFFLINE)) {
executed = runConsolePerUserOfflineCommand(taskCommand);
} else if(gender.equals(Gender.CONSOLE_PROXY)) {
executed = runConsoleProxyCommand(task, taskCommand);
}

if(executed) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"gender_item": "&bGender",
"gender": "&7Gender: &e$1",
"gender_lore": "\n&7The commands don't need to be executed all\n&7at once. You can decide between one of the\n&7following selection modes:\n\n&7 - &eALL: &7Execute all commands at once\n\n&7 - &eORDERED: &7Execute the commands one by one.\n&7 This works best if you specify seconds. It will\n&7 execute command 1 the first time the task is executed,\n&7 then it will pick command 2 on next execution and so on.\n\n&7 - &eRANDOM: &7Same as above, but will pick a random\n&7 command at each execution.\n\n&7 - &eINTERVAL: &7Execute each command in order with\n&7 an interval in between.\n&7 See ORDERED for more information\n\n",
"gender_selector_lore": "\n&7Genders are one of the core concepts of\n&7CommandTimer. They allow you to specify\n&7how your task is executed.\n\n&7Current: &e$1\n\n&bAvailable genders:\n\n&7 - &eOPERATOR: &7All the commands in the task\n&7 will be executed for each individual player,\n&7 by the player. This means that CommandTimer will\n&7 force the player to execute the commands but ignore\n&7 the permissions linked to them.\n\n&7 - &ePLAYER: &7Same as above. CommandTimer will force\n&7 the player to execute the commands, but will take\n&7 into account the possible permissions the player\n&7 has or is lacking.\n\n&7 - &eCONSOLE: &7Execute the command in the console only\n\n&7 - &eCONSOLE PER USER: &7Execute the command in the console\n&7 for each individual player. This works very well with\n&7 placeholders\n\n&7 - &eCONSOLE_PER_USER_OFFLINE: &7Same as above but also takes into account offline players",
"gender_selector_lore": "\n&7Genders are one of the core concepts of\n&7CommandTimer. They allow you to specify\n&7how your task is executed.\n\n&7Current: &e$1\n\n&bAvailable genders:\n\n&7 - &eOPERATOR: &7All the commands in the task\n&7 will be executed for each individual player,\n&7 by the player. This means that CommandTimer will\n&7 force the player to execute the commands but ignore\n&7 the permissions linked to them.\n\n&7 - &ePLAYER: &7Same as above. CommandTimer will force\n&7 the player to execute the commands, but will take\n&7 into account the possible permissions the player\n&7 has or is lacking.\n\n&7 - &eCONSOLE: &7Execute the command in the console only\n\n&7 - &eCONSOLE PER USER: &7Execute the command in the console\n&7 for each individual player. This works very well with\n&7 placeholders\n\n&7 - &eCONSOLE_PER_USER_OFFLINE: &7Same as above but also takes into account offline players\n\n&7 - &eCONSOLE_PROXY: &7Execute commands on proxy (requires proxy extension",
"add_command": "&bAdd command",
"add_command_lore": "\n&7Add a new command that will be\n&7executed on your specified schedule\n",
"command_interval_lore": "\n&7Define the delay between each player command execution.\n&7This only works when you have a gender that runs\n&7for all the players.\n\n&7Current: &e$1",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"gender_item": "&bGender",
"gender": "&7Gender: &e$1",
"gender_lore": "\n&7The commands don't need to be executed all\n&7at once. You can decide between one of the\n&7following selection modes:\n\n&7 - &eALL: &7Execute all commands at once\n\n&7 - &eORDERED: &7Execute the commands one by one.\n&7 This works best if you specify seconds. It will\n&7 execute command 1 the first time the task is executed,\n&7 then it will pick command 2 on next execution and so on.\n\n&7 - &eRANDOM: &7Same as above, but will pick a random\n&7 command at each execution.\n\n&7 - &eINTERVAL: &7Execute each command in order with\n&7 an interval in between.\n&7 See ORDERED for more information\n\n",
"gender_selector_lore": "\n&7Genders are one of the core concepts of\n&7CommandTimer. They allow you to specify\n&7how your task is executed.\n\n&7Current: &e$1\n\n&bAvailable genders:\n\n&7 - &eOPERATOR: &7All the commands in the task\n&7 will be executed for each individual player,\n&7 by the player. This means that CommandTimer will\n&7 force the player to execute the commands but ignore\n&7 the permissions linked to them.\n\n&7 - &ePLAYER: &7Same as above. CommandTimer will force\n&7 the player to execute the commands, but will take\n&7 into account the possible permissions the player\n&7 has or is lacking.\n\n&7 - &eCONSOLE: &7Execute the command in the console only\n\n&7 - &eCONSOLE PER USER: &7Execute the command in the console\n&7 for each individual player. This works very well with\n&7 placeholders\n\n&7 - &eCONSOLE_PER_USER_OFFLINE: &7Same as above but also takes into account offline players",
"gender_selector_lore": "\n&7Genders are one of the core concepts of\n&7CommandTimer. They allow you to specify\n&7how your task is executed.\n\n&7Current: &e$1\n\n&bAvailable genders:\n\n&7 - &eOPERATOR: &7All the commands in the task\n&7 will be executed for each individual player,\n&7 by the player. This means that CommandTimer will\n&7 force the player to execute the commands but ignore\n&7 the permissions linked to them.\n\n&7 - &ePLAYER: &7Same as above. CommandTimer will force\n&7 the player to execute the commands, but will take\n&7 into account the possible permissions the player\n&7 has or is lacking.\n\n&7 - &eCONSOLE: &7Execute the command in the console only\n\n&7 - &eCONSOLE PER USER: &7Execute the command in the console\n&7 for each individual player. This works very well with\n&7 placeholders\n\n&7 - &eCONSOLE_PER_USER_OFFLINE: &7Same as above but also takes into account offline players\n\n&7 - &eCONSOLE_PROXY: &7Execute commands on proxy (requires proxy extension",
"add_command": "&bAdd command",
"add_command_lore": "\n&7Add a new command that will be\n&7executed on your specified schedule\n",
"command_interval_lore": "\n&7Define the delay between each player command execution.\n&7This only works when you have a gender that runs\n&7for all the players.\n\n&7Current: &e$1",
Expand Down

0 comments on commit 152d279

Please sign in to comment.