9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-19 14:59:19 +00:00

Fix events being called async in discovery commands

This commit is contained in:
SamB440
2025-12-03 14:17:23 +00:00
parent 67c71ef1f0
commit 84f2383483
3 changed files with 26 additions and 23 deletions

View File

@@ -55,7 +55,6 @@ public class RPGRegionsAccount {
}
public TimeEntry addTimeEntryInRegion(String region, long time) {
System.out.println("added time entry: " + region + ", " + time);
final TimeEntry timeEntry = new TimeEntry(time);
secondsInRegion.put(region, timeEntry);
return timeEntry;

View File

@@ -60,7 +60,7 @@ repositories {
}
project.group = "net.islandearth.rpgregions"
project.version = "1.4.94"
project.version = "1.4.95"
group = project.group
version = project.version

View File

@@ -115,6 +115,7 @@ public class DiscoveriesCommand {
@Argument("region") ConfiguredRegion configuredRegion,
@Argument("player") OfflinePlayer target) {
plugin.getManagers().getStorageManager().getAccount(target.getUniqueId()).thenAcceptAsync(account -> {
plugin.getScheduler().executeOnMain(() -> {
LocalDateTime date = LocalDateTime.now();
final WorldDiscovery worldDiscovery = new WorldDiscovery(date, configuredRegion.getId());
account.addDiscovery(worldDiscovery);
@@ -126,6 +127,7 @@ public class DiscoveriesCommand {
plugin.getManagers().getStorageManager().removeCachedAccount(target.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "The player " + target.getName() + " has had the discovery added.");
});
}).exceptionally((err) -> {
err.printStackTrace();
sender.sendMessage(ChatColor.RED + "An error occurred, please check console and report this to the developer.");
@@ -140,6 +142,7 @@ public class DiscoveriesCommand {
@Argument("fauna") FaunaInstance<?> fauna,
@Argument("player") OfflinePlayer target) {
plugin.getManagers().getStorageManager().getAccount(target.getUniqueId()).thenAccept(account -> {
plugin.getScheduler().executeOnMain(() -> {
LocalDateTime date = LocalDateTime.now();
final WorldDiscovery worldDiscovery = new WorldDiscovery(date, fauna.getIdentifier());
account.addDiscovery(worldDiscovery);
@@ -152,6 +155,7 @@ public class DiscoveriesCommand {
plugin.getManagers().getStorageManager().removeCachedAccount(target.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "The player " + target.getName() + " has had the discovery added.");
});
}).exceptionally((err) -> {
err.printStackTrace();
sender.sendMessage(ChatColor.RED + "An error occurred, please check console and report this to the developer.");