Skip to content

Commit a77b5f0

Browse files
Updating Nitro to JDA (#1)
* Update JDA remove Ban function Why was ban a thing * Refactor * Refactor + Update README * Update config.yml * Update README.md * Update README.md * Catching null error * Removed debug shit * Update NitroRemover.java oopsie * clean up * Incorrect Option Name * Update information about main channel use Might change config name at a later date cant think of a viable replacement that makes sense * Update README.md * Incorrect getRoles method * Update README.md * Minecraft username check * Resolve Bot missing MemberCaching * Change command detection to updated name * Use Mojang API instead of Electroid's API * Gang use java 21 * Remove unnecessary CompletableFuture * final clean up * Remove needing nitro role to run remove Unnecessary check in case for whatever reason someone has in game Nitro perks somehow and needs to get rid of them for whatever reason * Update to Spotless A hired a certain fruit to take care of this stuff and he is NOT doing his job. --------- Co-authored-by: Pear <20259871+TheRealPear@users.noreply.github.com>
1 parent 41e5ef0 commit a77b5f0

20 files changed

+437
-804
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,27 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
10-
- uses: actions/setup-java@v1
9+
- name: Checkout code
10+
uses: actions/checkout@v6
11+
12+
- name: Set up Java
13+
uses: actions/setup-java@v5
1114
with:
12-
java-version: '8'
15+
java-version: 21
16+
distribution: temurin
17+
1318
- name: Build jar
1419
run: mvn package
15-
- name: artifact
16-
uses: actions/upload-artifact@v1
20+
21+
- name: Upload artifact
22+
uses: actions/upload-artifact@v6
1723
with:
1824
name: NitroCloudy-1.0.0-SNAPSHOT.jar
1925
path: target/NitroCloudy-1.0.0-SNAPSHOT.jar
26+
2027
- name: Move generated jar file
2128
run: mv target/NitroCloudy-1.0.0-SNAPSHOT.jar NitroCloudy-1.0.0-SNAPSHOT.jar
29+
2230
- name: Create Release
2331
id: create_release
2432
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main')
@@ -30,6 +38,7 @@ jobs:
3038
release_name: Release NitroCloudy-${{github.sha}}
3139
draft: false
3240
prerelease: false
41+
3342
- name: Upload Release Asset
3443
id: upload-release-asset
3544
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main')
@@ -40,4 +49,4 @@ jobs:
4049
upload_url: ${{ steps.create_release.outputs.upload_url }}
4150
asset_path: ./NitroCloudy-1.0.0-SNAPSHOT.jar
4251
asset_name: NitroCloudy-1.0.0-SNAPSHOT.jar
43-
asset_content_type: application/java-archive
52+
asset_content_type: application/java-archive

README.md

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Nitro
2-
This project is a fork of applenick's [Nitro](https://github.com/applenick/Nitro), a Discord -> Minecraft bot which allows for Nitro users to claim an in-game rank or perks.
2+
This project is a fork of applenick's [Nitro](https://github.com/applenick/Nitro), a Discord to Minecraft bot which allows Nitro users to claim an in-game rank or perks.
33

44
This plugin was originally created for use on [Overcast Community](https://oc.tc), while this specific fork has some changes to benefit [Warzone](https://github.com/Warzone). For OCC, its functionality has likely been adapted and implemented into Cloudy, a (sadly) closed source all-in-one bot with a variety of features (also developed by [applenick](https://github.com/applenick)).
55

66
**Disclaimer:** The changes present in this fork were implemented with beginner-level Java experience. I am almost sure that there are cleaner, more efficient ways of accomplishing what has been done. I apologize to those more knowledgeable in that regard. However, I am very open to receive constructive criticism and accept pull requests with better code from other developers.
77

88
## Features and functionality
99

10-
- Using `!nitro help` will show the user a list of available commands.
10+
- Using `/help` will show the user a list of available commands.
1111

12-
- Nitro Boosting privileges can be claimed or redeemed by users to the Minecraft account/player of their choice. To do this, simply instruct the user to enter `!nitro-redeem <minecraft username>` into the designated redemption channel (specified in `config.yml` through `channel-main`).
12+
- Nitro Boosting privileges can be claimed or redeemed by users to the Minecraft account/player of their choice. To do this, simply instruct the user to enter `/redeem <minecraft username>` into the designated redemption channel (specified in `config.yml` through `channel-main`).
1313

14-
- Users may also remove their own privileges by using `!nitro-remove`.
14+
- Users may also remove their own privileges by using `/remove`.
1515

1616
- When the user does redeem Nitro privileges, the plugin will execute, through the console, the commands present in `redemption-commands`. A similar process will take place once the user stops boosting the server or loses the "boosting" role (meaning the removal commands will be executed).
1717

@@ -35,11 +35,11 @@ removal-commands:
3535
- Active Nitro Boosters will be stored in `config.yml` under `nitro-boosters`.
3636
```yml
3737
38-
# List of nitro boosters
38+
# List of Nitro boosters
3939
# Format
40-
# Discord username with discriminator : Discord User ID : Minecraft username : Minecraft UUID
40+
# Discord username : Discord User ID : Minecraft username : Minecraft UUID
4141
nitro-boosters:
42-
- Notch#0001:000000000123456789:Notch:069a79f4-44e9-4726-a5be-fca90e38aaf5
42+
- Notch:000000000123456789:Notch:069a79f4-44e9-4726-a5be-fca90e38aaf5
4343
```
4444

4545
- Messages detailing the Discord user that has claimed Nitro perks and their target Minecraft username will be logged to both the server's console and the designated alerts channel (`channel-alerts`).
@@ -52,65 +52,60 @@ nitro-boosters:
5252

5353
A number of commands are only available to staff in the configured staff channel of the configuration (`channel-staff`).
5454

55-
- `!nitro-list <boosters|bans|commands>`
55+
- `/list <boosters|commands>`
5656
- `boosters`: Lists all Nitro boosters that have redeemed Nitro privileges.
57-
- `bans`: Lists all users that have been banned from redeemed Nitro privileges.
5857
- `commands`: Lists the redemption and removal commands present in the configuration.
59-
- `!nitro-force-remove`: Forcefully removes an active Nitro booster from the `nitro-boosters` list in the configuration. This command will execute the available removal commands for the targeted user.
60-
- `!nitro-ban <discriminated username> <discord id>`: Bans a user from redeeming Nitro privileges.
61-
- Banning a user will prevent them from using `!nitro-redeem` or `!nitro-remove` again until they are unbanned.
62-
- If the user was present in the `nitro-boosters` list, they will also be removed from it and removal commands will be executed.
63-
- `!nitro-unban <discriminated username> <discord id>`: Unbans a user from redeeming Nitro privileges.
64-
- Unbanning a user will allow them to use `!nitro-redeem` or `!nitro-remove` again.
65-
- `!nitro-reload`: Reloads the configuration file.
58+
- `/revoke`: Forcefully removes an active Nitro booster from the `nitro-boosters` list in the configuration. This command will execute the available removal commands for the targeted user.
59+
- `/config-reload`: Reloads the configuration file.
60+
6661
## Building
6762

6863
1. First, [clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) or download the project's source code.
6964
2. Optionally, make your desired changes.
70-
3. Run the code formatter, following Google's [code style.](https://google.github.io/styleguide/javaguide.html)
71-
```bash
72-
mvn com.coveo:fmt-maven-plugin:format
73-
```
65+
3. Run the code formatter, following [Google's code style](https://google.github.io/styleguide/javaguide.html).
66+
```bash
67+
mvn com.coveo:fmt-maven-plugin:format
68+
```
7469
5. Compile the project.
75-
```bash
76-
mvn package
77-
```
70+
```bash
71+
mvn package
72+
```
7873

7974
You'll find the bot's `.jar` file inside the `target` folder of the project's root directory.
8075

81-
You may also find a pre-built `.jar` [here](https://github.com/TBG1000/Nitro/actions/workflows/main.yml).
76+
You may also find a [pre-built `.jar` here](https://github.com/TBG1000/Nitro/actions/workflows/main.yml).
8277

8378
## Installing
84-
When creating the bot that will be linked to Nitro's plugin `.jar`, be sure to toggle on the "Server Members Intent" (`GUILD_MEMBERS`) option. If this setting is left off, the bot will not be able to properly function. It will fail to remove privileges from users that were previously Nitro Boosters but have since stopped boosting the server.
79+
When creating the bot that will be linked to Nitro's plugin `.jar`, be sure to toggle on the "Server Members Intent" (`GUILD_MEMBERS`) option. If this setting is left off, the bot will not be able to properly function. It will fail to remove privileges from users that were previously Nitro Boosters but have since stopped boosting the server. In addition, the (`applications.commands`) scope is required for the slash commands to function.
8580

8681
1. Drop the plugin's `.jar` in your server's `plugins` folder.
87-
2. Restart the server to automatically generate the bot's required files (`config.yml`, `plugin.yml`).
82+
2. Restart the server to automatically generate the bot's required files (`config.yml`).
8883
3. Fill in the blanks of the configuration file (`config.yml`). To do this, you'll need the following:
8984
- A token for your Discord bot which you can get at the [Discord Developer Portal](https://discord.com/developers/docs)
9085
- The ID of the server in which the bot will be functioning.
9186
- The ID of the Nitro Booster role.
9287
- This role can be any role, not necessarily the legitimate "Nitro Booster" role.
9388
- The ID of the channel in which logs will be sent.
94-
- The ID of the channel in which users can redeem/remove Nitro Boosting privileges.
89+
- The ID of the channel in which the bot will alert new Nitro users to redeem their perks.
9590
- The ID of the channel in which staff members can use the management commands.
9691
- The command(s) to be executed on the Minecraft server once a user redeems privileges.
9792
- The command(s) to be executed on the Minecraft server once a user stops boosting the Discord server.
9893
4. Restart the server once again for the changes to take place. Once your bot goes online, users may start redeeming their privileges in the designated channel.
9994

100-
You may look at a sample of the configuration file [below](https://github.com/TBG1000/Nitro/#config).
101-
You can also find out how to get server, role or channel IDs [here](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID).
95+
You may look at a [sample configuration file below](https://github.com/TBG1000/Nitro/#config).
96+
You can also find out [how to get server, role or channel IDs](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID).
10297

10398
## Config
10499
```yml
105-
# Discord Config stuff
100+
# Nitro configuration
106101
enabled: true # Enable discord bot?
107102
108103
token: "" # ID of Discord bot token
109104
server: "" # ID of discord server
110105
nitro-role: "" # ID of the nitro role
111106
112107
channel-alerts: "" # ID of channel where logs from bot are sent
113-
channel-main: "" # ID of channel where command can be used
108+
channel-main: "" # ID of channel where bot alerts new Nitro users to redeem perks
114109
channel-staff: "" # ID of channel where staff can use management commands
115110
116111
# List of redemption commands, executed when the user boosts the server
@@ -122,13 +117,7 @@ removal-commands:
122117
123118
# List of nitro boosters
124119
# Format
125-
# Discriminated Discord username : User Discord ID : Minecraft username : Minecraft username
120+
# Discord username : User Discord ID : Minecraft username : Minecraft username
126121
nitro-boosters:
127122
- ""
128-
129-
# List of users banned from redemption privileges
130-
# Format
131-
# Discriminated Discord username : User Discord ID
132-
banned-boosters:
133-
- ""
134123
```

pom.xml

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<artifactId>NitroCloudy</artifactId>
55
<version>1.0.0-SNAPSHOT</version>
66
<name>NitroCloudy</name>
7+
<description>A Minecraft-to-Discord bot to handle Nitro perks.</description>
78

89
<!-- Repository Locations -->
910
<repositories>
@@ -34,12 +35,17 @@
3435
<artifactId>acf-bukkit</artifactId>
3536
<version>0.5.0-SNAPSHOT</version>
3637
</dependency>
37-
<dependency>
38-
<groupId>org.javacord</groupId>
39-
<artifactId>javacord</artifactId>
40-
<version>3.1.2</version>
41-
<type>pom</type>
42-
</dependency>
38+
<dependency>
39+
<groupId>net.dv8tion</groupId>
40+
<artifactId>JDA</artifactId>
41+
<version>6.2.1</version>
42+
<exclusions>
43+
<exclusion>
44+
<groupId>club.minnced</groupId>
45+
<artifactId>opus-java</artifactId>
46+
</exclusion>
47+
</exclusions>
48+
</dependency>
4349
</dependencies>
4450
<build>
4551
<resources>
@@ -56,8 +62,8 @@
5662
<artifactId>maven-compiler-plugin</artifactId>
5763
<version>3.8.1</version>
5864
<configuration>
59-
<source>1.8</source>
60-
<target>1.8</target>
65+
<source>21</source>
66+
<target>21</target>
6167
<compilerArgs>
6268
<arg>-parameters</arg> <!-- Required for aikar/commands to auto generate syntax -->
6369
</compilerArgs>
@@ -66,7 +72,7 @@
6672
<plugin>
6773
<groupId>org.apache.maven.plugins</groupId>
6874
<artifactId>maven-shade-plugin</artifactId>
69-
<version>3.2.3</version>
75+
<version>3.6.1</version>
7076
<configuration>
7177
<createDependencyReducedPom>false</createDependencyReducedPom>
7278
<minimizeJar>true</minimizeJar>
@@ -119,21 +125,29 @@
119125
</plugin>
120126

121127
<!-- Validates that code is properly formatted with Google's code style -->
122-
<plugin>
123-
<groupId>com.coveo</groupId>
124-
<artifactId>fmt-maven-plugin</artifactId>
125-
<version>2.9</version>
126-
<configuration>
127-
<style>google</style>
128-
</configuration>
129-
<executions>
130-
<execution>
131-
<goals>
132-
<goal>check</goal>
133-
</goals>
134-
</execution>
135-
</executions>
136-
</plugin>
128+
<plugin>
129+
<groupId>com.diffplug.spotless</groupId>
130+
<artifactId>spotless-maven-plugin</artifactId>
131+
<version>3.1.0</version>
132+
<configuration>
133+
<ratchetFrom>origin/main</ratchetFrom>
134+
<java>
135+
<removeUnusedImports/>
136+
<palantirJavaFormat>
137+
<version>2.47.0</version>
138+
<style>GOOGLE</style>
139+
<formatJavadoc>true</formatJavadoc>
140+
</palantirJavaFormat>
141+
</java>
142+
</configuration>
143+
<executions>
144+
<execution>
145+
<goals>
146+
<goal>check</goal>
147+
</goals>
148+
</execution>
149+
</executions>
150+
</plugin>
137151
</plugins>
138152
</build>
139153

@@ -142,6 +156,4 @@
142156
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
143157
<skipTests>true</skipTests>
144158
</properties>
145-
146-
147159
</project>

src/main/java/tc/oc/occ/nitro/NitroConfig.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package tc.oc.occ.nitro;
22

3+
import org.bukkit.configuration.Configuration;
4+
import tc.oc.occ.nitro.data.NitroUser;
5+
36
import java.util.List;
47
import java.util.Optional;
58
import java.util.UUID;
69
import java.util.stream.Collectors;
7-
import org.bukkit.configuration.Configuration;
8-
import tc.oc.occ.nitro.data.BannedNitroUser;
9-
import tc.oc.occ.nitro.data.NitroUser;
1010

1111
public class NitroConfig {
1212

@@ -17,7 +17,6 @@ public class NitroConfig {
1717
private String nitroRole;
1818

1919
private List<NitroUser> nitroUsers;
20-
private List<BannedNitroUser> bannedUsers;
2120

2221
private String alertChannel;
2322
private String mainChannel;
@@ -47,13 +46,6 @@ public void reload(Configuration config) {
4746
.filter(str -> str != null && !str.isEmpty())
4847
.map(NitroUser::of)
4948
.collect(Collectors.toList());
50-
51-
List<String> bannedData = config.getStringList("banned-boosters");
52-
this.bannedUsers =
53-
bannedData.stream()
54-
.filter(str -> str != null && !str.isEmpty())
55-
.map(BannedNitroUser::of)
56-
.collect(Collectors.toList());
5749
}
5850

5951
public boolean isEnabled() {
@@ -88,10 +80,6 @@ public List<NitroUser> getUsers() {
8880
return nitroUsers;
8981
}
9082

91-
public List<BannedNitroUser> getBannedUsers() {
92-
return bannedUsers;
93-
}
94-
9583
public List<String> getRedemptionCommands() {
9684
return redemptionCommands;
9785
}
@@ -101,8 +89,8 @@ public List<String> getRemovalCommands() {
10189
}
10290

10391
public NitroUser addNitro(
104-
String discriminatedUsername, String discordId, String minecraftUsername, UUID playerId) {
105-
NitroUser user = new NitroUser(discriminatedUsername, discordId, minecraftUsername, playerId);
92+
String discordUsername, String discordId, String minecraftUsername, UUID playerId) {
93+
NitroUser user = new NitroUser(discordUsername, discordId, minecraftUsername, playerId);
10694
this.nitroUsers.add(user);
10795
return user;
10896
}

src/main/java/tc/oc/occ/nitro/NitroListener.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void onNitroAdd(NitroUserAddEvent event) {
3333
// Announce in console that the user has redeemed nitro privileges
3434
Bukkit.getConsoleSender()
3535
.sendMessage(
36-
"[Nitro] Nitro Booster "
36+
"[NitroBot] Nitro Booster "
3737
+ parts[0]
3838
+ " ("
3939
+ parts[1]
@@ -46,7 +46,7 @@ public void onNitroAdd(NitroUserAddEvent event) {
4646
for (String redemptionCommand : api.getConfig().getRedemptionCommands()) {
4747
// Print the redemption command(s) in console
4848
Bukkit.getConsoleSender()
49-
.sendMessage("[Nitro] Executing redemption command: " + redemptionCommand);
49+
.sendMessage("[NitroBot] Executing redemption command: " + redemptionCommand);
5050
// Execute the command
5151
if (redemptionCommand.contains("%s")) {
5252
Bukkit.getServer()
@@ -71,11 +71,11 @@ public void onNitroRemove(NitroUserRemoveEvent event) {
7171
+ parts[0]
7272
+ "` (`"
7373
+ parts[1]
74-
+ "`) is no longer boosting the server.");
74+
+ "`) is no longer receiving Nitro perks.");
7575
// Announce in console that the user has lost nitro
7676
Bukkit.getConsoleSender()
7777
.sendMessage(
78-
"[Nitro] Removing Nitro Boosting privileges from "
78+
"[NitroBot] Removing Nitro Boosting privileges from "
7979
+ parts[2]
8080
+ " ("
8181
+ parts[3]
@@ -87,7 +87,7 @@ public void onNitroRemove(NitroUserRemoveEvent event) {
8787
// Iterate through the list of strings from removal-commands in the config
8888
for (String removalCommand : api.getConfig().getRemovalCommands()) {
8989
// Print the removal command(s) in console
90-
Bukkit.getConsoleSender().sendMessage("[Nitro] Executing removal command: " + removalCommand);
90+
Bukkit.getConsoleSender().sendMessage("[NitroBot] Executing removal command: " + removalCommand);
9191
// Execute the command
9292
if (removalCommand.contains("%s")) {
9393
Bukkit.getServer()

0 commit comments

Comments
 (0)