|
|
@ -69,7 +69,7 @@ public class FabricEventListener extends EventListener implements LockedHandler
|
|
|
|
WorldSaveCallback.EVENT.register(this::handleWorldSave);
|
|
|
|
WorldSaveCallback.EVENT.register(this::handleWorldSave);
|
|
|
|
PlayerDeathDropsCallback.EVENT.register(this::handlePlayerDeathDrops);
|
|
|
|
PlayerDeathDropsCallback.EVENT.register(this::handlePlayerDeathDrops);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Events of extra things to cancel if the player has not been set yet
|
|
|
|
// Locked events handling
|
|
|
|
ItemPickupCallback.EVENT.register(this::handleItemPickup);
|
|
|
|
ItemPickupCallback.EVENT.register(this::handleItemPickup);
|
|
|
|
ItemDropCallback.EVENT.register(this::handleItemDrop);
|
|
|
|
ItemDropCallback.EVENT.register(this::handleItemDrop);
|
|
|
|
UseBlockCallback.EVENT.register(this::handleBlockInteract);
|
|
|
|
UseBlockCallback.EVENT.register(this::handleBlockInteract);
|
|
|
@ -94,14 +94,15 @@ public class FabricEventListener extends EventListener implements LockedHandler
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handleWorldSave(@NotNull ServerWorld world) {
|
|
|
|
private void handleWorldSave(@NotNull ServerWorld world) {
|
|
|
|
saveOnWorldSave(world.getPlayers().stream()
|
|
|
|
this.saveOnWorldSave(
|
|
|
|
.map(player -> (OnlineUser) FabricUser.adapt(player, plugin)).collect(Collectors.toList()));
|
|
|
|
world.getPlayers().stream().map(player -> (OnlineUser) FabricUser.adapt(player, plugin)).toList()
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void handlePlayerDeathDrops(@NotNull ServerPlayerEntity player, @Nullable ItemStack @NotNull [] toKeep,
|
|
|
|
private void handlePlayerDeathDrops(@NotNull ServerPlayerEntity player, @Nullable ItemStack @NotNull [] toKeep,
|
|
|
|
@Nullable ItemStack @NotNull [] toDrop) {
|
|
|
|
@Nullable ItemStack @NotNull [] toDrop) {
|
|
|
|
final SaveOnDeathSettings settings = plugin.getSettings().getSynchronization().getSaveOnDeath();
|
|
|
|
final SaveOnDeathSettings settings = plugin.getSettings().getSynchronization().getSaveOnDeath();
|
|
|
|
saveOnPlayerDeath(
|
|
|
|
this.saveOnPlayerDeath(
|
|
|
|
FabricUser.adapt(player, plugin),
|
|
|
|
FabricUser.adapt(player, plugin),
|
|
|
|
FabricData.Items.ItemArray.adapt(
|
|
|
|
FabricData.Items.ItemArray.adapt(
|
|
|
|
settings.getItemsToSave() == SaveOnDeathSettings.DeathItemsMode.DROPS ? toDrop : toKeep
|
|
|
|
settings.getItemsToSave() == SaveOnDeathSettings.DeathItemsMode.DROPS ? toDrop : toKeep
|
|
|
|