Skip to content

Commit 010c1a4

Browse files
committed
Cleanup, ready for release
1 parent 65db09d commit 010c1a4

14 files changed

Lines changed: 46 additions & 89 deletions

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>nu.nerd</groupId>
55
<artifactId>ModReq</artifactId>
6-
<version>3.0</version>
6+
<version>3.0.0</version>
77
<packaging>jar</packaging>
88
<name>ModReq</name>
99
<description>Moderator Request System</description>
@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>io.papermc.paper</groupId>
3030
<artifactId>paper-api</artifactId>
31-
<version>1.21.4-R0.1-SNAPSHOT</version>
31+
<version>1.20-R0.1-SNAPSHOT</version>
3232
<scope>provided</scope>
3333
</dependency>
3434
<!--

src/nu/nerd/modreq/ModReq.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ public void onEnable() {
132132
tpIdCommand = new TPIdCommand(this);
133133
unclaimCommand = new UnclaimCommand(this);
134134
elevateCommand = new ElevateCommand(this, unclaimCommand);
135-
tpInfoCommand = new TPInfoCommand(this, tpIdCommand, checkCommand);
136-
tpClaimCommand = new TPClaimCommand(this, claimCommand, tpIdCommand, checkCommand);
135+
tpInfoCommand = new TPInfoCommand(tpIdCommand, checkCommand);
136+
tpClaimCommand = new TPClaimCommand(claimCommand, tpIdCommand, checkCommand);
137137

138138
// Command Registration
139139
registry.register("check", checkCommand);
@@ -253,8 +253,6 @@ public String getDatabaseUrl() {
253253
return DATABASE_URL;
254254
}
255255

256-
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
257-
258256
@Override
259257
public boolean onCommand(CommandSender sender, Command command, String name, String[] args) {
260258
if(!(sender instanceof Player)) {

src/nu/nerd/modreq/commands/CheckCommand.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ public boolean execute(Player player, String name, String[] args) {
6464

6565
// If the player wants to specify a page (shorthand)
6666
} else if (arg.startsWith("p:")) {
67-
page = Integer.parseInt(arg.substring(2));
67+
try {
68+
page = Integer.parseInt(arg.substring(2));
69+
} catch (NumberFormatException exception) {
70+
sendMessage(player, configuration.GENERAL__PAGE_ERROR, environment, configuration);
71+
return true;
72+
}
6873

6974
// If the player wants to specify a page
7075
} else if (arg.equalsIgnoreCase("--page") || arg.equalsIgnoreCase("-p")) {
@@ -119,14 +124,12 @@ public boolean execute(Player player, String name, String[] args) {
119124
final UUID finalLimitUUID = limitUUID;
120125
final boolean finalShowNotes = showNotes;
121126
final int finalPage = page;
122-
final int finalRequestId = requestId;
123127
final boolean finalIncludeElevated = includeElevated;
124128
final String finalSearchTerm = searchTerm;
125-
CompletableFuture<Void> future;
126129

127130
if (page > 0) {
128131
if (limitUUID != null) {
129-
future = reqTable.getUserRequests(limitUUID).thenAccept(requests -> {
132+
reqTable.getUserRequests(limitUUID).thenAccept(requests -> {
130133
bukkitScheduler.runTask(plugin, () -> {
131134
if (requests.isEmpty()) {
132135
sendMessage(player, configuration.GENERAL__NO_REQUESTS, environment, configuration);
@@ -154,7 +157,7 @@ public boolean execute(Player player, String name, String[] args) {
154157
Request.RequestStatus.CLAIMED
155158
);
156159

157-
future = CompletableFuture.allOf(requestsFuture, countFuture).thenAccept(ignore -> {
160+
CompletableFuture.allOf(requestsFuture, countFuture).thenAccept(ignore -> {
158161
List<Request> requests = requestsFuture.join();
159162
int totalCount = countFuture.join();
160163

@@ -173,23 +176,20 @@ public boolean execute(Player player, String name, String[] args) {
173176

174177
}
175178
} else if (requestId > 0) {
176-
future = reqTable.getRequest(requestId).thenAccept(request -> {
177-
bukkitScheduler.runTask(plugin, () -> {
178-
if (request == null) {
179-
// Request doesn't exist
180-
sendMessage(player, configuration.GENERAL__REQUEST_ERROR, environment, configuration);
181-
} else if (finalLimitUUID != null && !request.getPlayerUUID().equals(finalLimitUUID)) {
182-
// Request exists but player doesn't have permission to view it
183-
sendMessage(player, configuration.GENERAL__REQUEST_ERROR, environment, configuration);
184-
} else {
185-
// Show the request details
186-
messageRequestToPlayer(player, request, finalShowNotes, environment,
187-
configuration, plugin, plugin.getNoteTable());
188-
}
189-
});
190-
});
179+
reqTable.getRequest(requestId).thenAccept(request -> bukkitScheduler.runTask(plugin, () -> {
180+
if (request == null) {
181+
// Request doesn't exist
182+
sendMessage(player, configuration.GENERAL__REQUEST_ERROR, environment, configuration);
183+
} else if (finalLimitUUID != null && !request.getPlayerUUID().equals(finalLimitUUID)) {
184+
// Request exists but player doesn't have permission to view it
185+
sendMessage(player, configuration.GENERAL__REQUEST_ERROR, environment, configuration);
186+
} else {
187+
// Show the request details
188+
messageRequestToPlayer(player, request, finalShowNotes, environment,
189+
configuration, plugin, plugin.getNoteTable());
190+
}
191+
}));
191192
} else {
192-
future = CompletableFuture.completedFuture(null);
193193

194194
bukkitScheduler.runTask(plugin, () ->
195195
sendMessage(player, configuration.GENERAL__NO_REQUESTS, environment, configuration));

src/nu/nerd/modreq/commands/ElevateCommand.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ public class ElevateCommand implements CommandHandler {
2828
private RequestTable reqTable;
2929
private Map<String, String> environment;
3030
private Configuration configuration;
31-
private CompletableFuture<Void> future;
3231
private UnclaimCommand unclaimCommand;
3332
private Map<UUID, Integer> claimedIds;
34-
private BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
3533

3634
/**
3735
* Creates a new {@code ElevateCommand} instance.
@@ -44,7 +42,6 @@ public ElevateCommand(ModReq plugin, UnclaimCommand unclaimCommand) {
4442
this.reqTable = plugin.getReqTable();
4543
this.environment = plugin.getEnvironment();
4644
this.configuration = plugin.getConfiguration();
47-
this.future = plugin.getCompleteableFuture();
4845
this.claimedIds = plugin.getClaimedIds();
4946
this.unclaimCommand = unclaimCommand;
5047
}

src/nu/nerd/modreq/commands/MRNoteCommand.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class MRNoteCommand implements CommandHandler {
3030
private NoteTable noteTable;
3131
private Map<String, String> environment;
3232
private Configuration configuration;
33-
private CompletableFuture<Void> future;
3433
private Map<UUID, Integer> claimedIds;
3534
private BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
3635

@@ -46,7 +45,6 @@ public MRNoteCommand(ModReq plugin) {
4645
this.noteTable = plugin.getNoteTable();
4746
this.environment = plugin.getEnvironment();
4847
this.configuration = plugin.getConfiguration();
49-
this.future = plugin.getCompleteableFuture();
5048
this.claimedIds = plugin.getClaimedIds();
5149
}
5250

src/nu/nerd/modreq/commands/MRResetCommand.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
public class MRResetCommand implements CommandHandler {
3030

3131
private final ModReq plugin;
32-
private RequestTable reqTable;
33-
private Map<String, String> environment;
34-
private Configuration configuration;
35-
private CompletableFuture<Void> future;
3632
ComponentLogger logger;
3733
String DATABASE_URL;
3834

@@ -44,10 +40,6 @@ public class MRResetCommand implements CommandHandler {
4440
*/
4541
public MRResetCommand(ModReq plugin) {
4642
this.plugin = plugin;
47-
this.reqTable = plugin.getReqTable();
48-
this.environment = plugin.getEnvironment();
49-
this.configuration = plugin.getConfiguration();
50-
this.future = plugin.getCompleteableFuture();
5143
logger = plugin.getComponentLogger();
5244
this.DATABASE_URL = plugin.getDatabaseUrl();
5345
}

src/nu/nerd/modreq/commands/ModreqCommand.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public ModreqCommand(ModReq plugin) {
4444
@Override
4545
public boolean execute(Player player, String name, String[] args) {
4646

47-
reqTable.getNumRequestFromUser(player.getUniqueId()).thenAccept(numRequests -> {
47+
if(args.length > 0) {
48+
reqTable.getNumRequestFromUser(player.getUniqueId()).thenAccept(numRequests -> {
4849
if (numRequests < configuration.MAX_REQUESTS) {
4950
Request req = new Request();
5051
req.setPlayerUUID(player.getUniqueId());
@@ -63,20 +64,21 @@ public boolean execute(Player player, String name, String[] args) {
6364
req.setRequestLocation(location);
6465
req.setStatus(Request.RequestStatus.OPEN);
6566

66-
reqTable.saveAndGetId(req).thenAccept(savedReq -> {
67-
bukkitScheduler.runTask(plugin, () -> {
68-
environment.put("request_id", String.valueOf(req.getId()));
69-
messageMods(configuration.MOD__NEW_REQUEST, environment, configuration);
70-
sendMessage(player, configuration.GENERAL__REQUEST_FILED, environment, configuration);
71-
});
72-
});
67+
reqTable.saveAndGetId(req).thenAccept(savedReq -> bukkitScheduler.runTask(plugin, () -> {
68+
environment.put("request_id", String.valueOf(req.getId()));
69+
messageMods(configuration.MOD__NEW_REQUEST, environment, configuration);
70+
sendMessage(player, configuration.GENERAL__REQUEST_FILED, environment, configuration);
71+
}));
7372
} else {
7473
bukkitScheduler.runTask(plugin, () -> {
7574
environment.put("max_requests", Integer.toString(configuration.MAX_REQUESTS));
7675
sendMessage(player, configuration.GENERAL__MAX_REQUESTS, environment, configuration);
7776
});
7877
}
79-
});
80-
return true;
78+
});
79+
return true;
80+
} else {
81+
return false;
82+
}
8183
}
8284
}

src/nu/nerd/modreq/commands/ReopenCommand.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class ReopenCommand implements CommandHandler {
2727
private RequestTable reqTable;
2828
private Map<String, String> environment;
2929
private Configuration configuration;
30-
private CompletableFuture<Void> future;
3130
private Map<UUID, Integer> claimedIds;
3231
private BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
3332

@@ -42,7 +41,6 @@ public ReopenCommand(ModReq plugin) {
4241
this.reqTable = plugin.getReqTable();
4342
this.environment = plugin.getEnvironment();
4443
this.configuration = plugin.getConfiguration();
45-
this.future = plugin.getCompleteableFuture();
4644
this.claimedIds = plugin.getClaimedIds();
4745
}
4846

src/nu/nerd/modreq/commands/TPClaimCommand.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,14 @@
1616
*/
1717
public class TPClaimCommand implements CommandHandler {
1818

19-
private final ModReq plugin;
20-
private RequestTable reqTable;
21-
private Map<String, String> environment;
22-
private Configuration configuration;
23-
private CompletableFuture<Void> future;
2419
private ClaimCommand claimCommand;
2520
private TPIdCommand tpIdCommand;
2621
private CheckCommand checkCommand;
2722

2823
/**
2924
* Creates a new {@code TPClaimCommand} instance.
30-
*
31-
* @param plugin The main plugin instance, used for scheduling, environment variables, database access,
32-
* and asynchronous operations.
3325
*/
34-
public TPClaimCommand(ModReq plugin, ClaimCommand claimCommand, TPIdCommand tpIdCommand, CheckCommand checkCommand) {
35-
this.plugin = plugin;
36-
this.reqTable = plugin.getReqTable();
37-
this.environment = plugin.getEnvironment();
38-
this.configuration = plugin.getConfiguration();
39-
this.future = plugin.getCompleteableFuture();
26+
public TPClaimCommand(ClaimCommand claimCommand, TPIdCommand tpIdCommand, CheckCommand checkCommand) {
4027
this.claimCommand = claimCommand;
4128
this.tpIdCommand = tpIdCommand;
4229
this.checkCommand = checkCommand;

src/nu/nerd/modreq/commands/TPIdCommand.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class TPIdCommand implements CommandHandler {
3030
private RequestTable reqTable;
3131
private Map<String, String> environment;
3232
private Configuration configuration;
33-
private CompletableFuture<Void> future;
3433
private Map<UUID, Integer> claimedIds;
3534
private BukkitScheduler bukkitScheduler = Bukkit.getScheduler();
3635

@@ -45,7 +44,6 @@ public TPIdCommand(ModReq plugin) {
4544
this.reqTable = plugin.getReqTable();
4645
this.environment = plugin.getEnvironment();
4746
this.configuration = plugin.getConfiguration();
48-
this.future = plugin.getCompleteableFuture();
4947
this.claimedIds = plugin.getClaimedIds();
5048
}
5149

0 commit comments

Comments
 (0)