Skip to content

Command + Permission Data Extraction #6083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
./gradlew build --stacktrace

- name: Publish JUnit report
uses: mikepenz/action-junit-report@v4
uses: mikepenz/action-junit-report@v5
if: success() || failure() # Run even if the previous step fails
with:
report_paths: '**/build/test-results/test*/TEST-*.xml'
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/upload-plugin-data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Command and Permissions Data
on:
push:
branches:
- 2.x

jobs:
data:
name: Generate and Upload
runs-on: ubuntu-latest

steps:
- name: Checkout Git Repo
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Generate Data
run: |
chmod +x gradlew
./gradlew commandData

- name: Upload Data
uses: ryand56/r2-upload-action@v1
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET }}
source-dir: generated
destination-dir: ./


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# Build files
.gradle/
/jars/
generated/
out/
build/
target/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.bukkit.block.data.type.WallHangingSign;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.block.sign.Side;
import org.bukkit.entity.Player;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.util.Vector;

Expand Down Expand Up @@ -49,7 +48,7 @@ protected void run(final Server server, final User user, final String commandLab
throw new TranslatableException("editsignCommandLimit");
}
existingLines[line] = text;
if (callSignEvent(sign, user.getBase(), existingLines)) {
if (callSignEvent(sign, user, existingLines)) {
return;
}

Expand All @@ -61,7 +60,7 @@ protected void run(final Server server, final User user, final String commandLab
existingLines[i] = "";
}

if (callSignEvent(sign, user.getBase(), existingLines)) {
if (callSignEvent(sign, user, existingLines)) {
return;
}

Expand All @@ -71,7 +70,7 @@ protected void run(final Server server, final User user, final String commandLab
final int line = Integer.parseInt(args[1]) - 1;
existingLines[line] = "";

if (callSignEvent(sign, user.getBase(), existingLines)) {
if (callSignEvent(sign, user, existingLines)) {
return;
}

Expand Down Expand Up @@ -100,13 +99,13 @@ protected void run(final Server server, final User user, final String commandLab
for (int i = 0; i < 4; i++) {
existingLines[i] = FormatUtil.formatString(user, "essentials.editsign", user.getSignCopy().get(i));
}
if (callSignEvent(sign, user.getBase(), existingLines)) {
if (callSignEvent(sign, user, existingLines)) {
return;
}
user.sendTl("editsignPaste", commandLabel);
} else {
existingLines[line] = FormatUtil.formatString(user, "essentials.editsign", user.getSignCopy().get(line));
if (callSignEvent(sign, user.getBase(), existingLines)) {
if (callSignEvent(sign, user, existingLines)) {
return;
}
user.sendTl("editsignPasteLine", line + 1, commandLabel);
Expand All @@ -119,22 +118,22 @@ protected void run(final Server server, final User user, final String commandLab
}
}

private boolean callSignEvent(final ModifiableSign sign, final Player player, final String[] lines) {
private boolean callSignEvent(final ModifiableSign sign, final User user, final String[] lines) {
final SignChangeEvent event;
if (VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_20_1_R01)) {
if (sign.isWaxed() && !player.hasPermission("essentials.editsign.waxed.exempt")) {
if (sign.isWaxed() && !user.isAuthorized("essentials.editsign.waxed.exempt")) {
return true;
}
event = new SignChangeEvent(sign.getBlock(), player, lines, sign.isFront() ? Side.FRONT : Side.BACK);
event = new SignChangeEvent(sign.getBlock(), user.getBase(), lines, sign.isFront() ? Side.FRONT : Side.BACK);
} else {
//noinspection deprecation
event = new SignChangeEvent(sign.getBlock(), player, lines);
event = new SignChangeEvent(sign.getBlock(), user.getBase(), lines);
}

Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
if (ess.getSettings().isDebug()) {
ess.getLogger().info("SignChangeEvent canceled for /editsign execution by " + player.getName());
ess.getLogger().info("SignChangeEvent canceled for /editsign execution by " + user.getName());
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void sendMessage(final IMessageRecipient from, final String[] args) thro

final List<IUser> recipients = new ArrayList<>();
for (IUser user : ess.getOnlineUsers()) {
if (user.getBase().hasPermission("essentials.helpop.receive")) {
if (user.isAuthorized("essentials.helpop.receive")) {
recipients.add(user);
}
}
Expand Down
Loading