Skip to content

Commit

Permalink
fix: advancement messages being improperly canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed May 6, 2024
1 parent e9ab090 commit a3b50a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerAdvancementDoneEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.MapInitializeEvent;
import org.bukkit.event.world.WorldSaveEvent;
Expand Down Expand Up @@ -103,10 +102,6 @@ public void handlePlayerDeath(@NotNull PlayerDeathEvent event) {
super.saveOnPlayerDeath(user, BukkitData.Items.ItemArray.adapt(event.getDrops()));
}

// Handle advancement grant events (empty on Spigot due to missing message API)
protected void handleLockedAdvancementGrant(@NotNull @SuppressWarnings("unused") PlayerAdvancementDoneEvent event) {
}

@EventHandler(ignoreCancelled = true)
public void onWorldSave(@NotNull WorldSaveEvent event) {
if (!plugin.getSettings().getSynchronization().isSaveOnWorldSave()) {
Expand All @@ -126,13 +121,6 @@ public void onMapInitialize(@NotNull MapInitializeEvent event) {
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerAdvancementDone(@NotNull PlayerAdvancementDoneEvent event) {
if (lockedHandler.cancelPlayerEvent(event.getPlayer().getUniqueId())) {
handleLockedAdvancementGrant(event);
}
}

// We handle commands here to allow specific command handling on ProtocolLib servers
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onCommandProcessed(@NotNull PlayerCommandPreprocessEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import net.william278.husksync.data.BukkitData;
import net.william278.husksync.user.BukkitUser;
import net.william278.husksync.user.OnlineUser;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerAdvancementDoneEvent;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -69,10 +71,11 @@ public void handlePlayerDeath(@NotNull PlayerDeathEvent event) {
super.saveOnPlayerDeath(user, BukkitData.Items.ItemArray.adapt(itemsToSave));
}

@Override
protected void handleLockedAdvancementGrant(@NotNull PlayerAdvancementDoneEvent event) {
// Disable advancement chat messages
event.message(null);
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerAdvancementDone(@NotNull PlayerAdvancementDoneEvent event) {
if (lockedHandler.cancelPlayerEvent(event.getPlayer().getUniqueId())) {
event.message(null);
}
}

@NotNull
Expand Down

0 comments on commit a3b50a0

Please sign in to comment.