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

fix: /discoveries discover not calling RegionsDiscoverEvent

This commit is contained in:
SamB440
2022-01-14 19:58:36 +00:00
parent 6410ee874b
commit 0c039b0637

View File

@@ -7,9 +7,11 @@ import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.Subcommand;
import net.islandearth.rpgregions.RPGRegions;
import net.islandearth.rpgregions.api.events.RegionDiscoverEvent;
import net.islandearth.rpgregions.gui.DiscoveryGUI;
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
import net.islandearth.rpgregions.managers.data.region.WorldDiscovery;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
@@ -42,12 +44,15 @@ public class DiscoveriesCommand extends BaseCommand {
DateTimeFormatter format = DateTimeFormatter.ofPattern(plugin.getConfig().getString("settings.server.discoveries.date.format"));
String formattedDate = date.format(format);
account.addDiscovery(new WorldDiscovery(formattedDate, configuredRegion.getId()));
final WorldDiscovery worldDiscovery = new WorldDiscovery(formattedDate, configuredRegion.getId());
account.addDiscovery(worldDiscovery);
if (target.getPlayer() != null) {
Player player = target.getPlayer();
player.sendMessage(ChatColor.GREEN + "An administrator added a discovery to your account.");
Bukkit.getPluginManager().callEvent(new RegionDiscoverEvent(player, configuredRegion.getId(), worldDiscovery));
}
plugin.getManagers().getStorageManager().removeCachedAccount(target.getUniqueId());
sender.sendMessage(ChatColor.GREEN + "The player " + target.getName() + " has had the discovery added.");
});
}