mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
Even simpler detection
This commit is contained in:
parent
938aee4f0f
commit
54bc1ca479
@ -1,6 +1,5 @@
|
||||
package net.Indyuce.mmoitems.listener;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -8,9 +7,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* mmoitems
|
||||
* 19/03/2023
|
||||
@ -19,7 +15,6 @@ import java.util.UUID;
|
||||
*/
|
||||
public class BiomeChangeListener implements Listener {
|
||||
|
||||
private final Map<UUID, Biome> biomeMap = Maps.newHashMap();
|
||||
|
||||
/**
|
||||
* This listener goal is to update the player inventory when he changes biome.
|
||||
@ -30,11 +25,9 @@ public class BiomeChangeListener implements Listener {
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
if (e.isCancelled() || !PlayerData.has(e.getPlayer()) || (e.getFrom().getBlockX() == e.getTo().getBlockX() && e.getFrom().getBlockZ() == e.getTo().getBlockZ()))
|
||||
return;
|
||||
final UUID uuid = e.getPlayer().getUniqueId();
|
||||
final Biome lastBiome = e.getFrom().getBlock().getBiome();
|
||||
final Biome biome = e.getTo().getBlock().getBiome();
|
||||
final Biome lastBiome = biomeMap.computeIfAbsent(uuid, u1 -> biome);
|
||||
if (biome != lastBiome)
|
||||
PlayerData.get(e.getPlayer()).getInventory().scheduleUpdate();
|
||||
biomeMap.put(uuid, biome);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user