Use Consumers instead of Callbacks

This commit is contained in:
Sam 2017-02-16 14:15:56 +00:00
parent a879a1dc80
commit cf36c83f4b
1 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,7 @@
package mineplex.gemhunters.util; package mineplex.gemhunters.util;
import java.util.function.Consumer;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -18,15 +20,15 @@ public class SimpleNPC implements Listener
{ {
protected final LivingEntity _entity; protected final LivingEntity _entity;
private final Callback<Player> _clickEvent; private final Consumer<Player> _clickEvent;
private final boolean _vegetated; private final boolean _vegetated;
public SimpleNPC(JavaPlugin plugin, Location spawn, Class<? extends LivingEntity> type, String name, Callback<Player> clickEvent) public SimpleNPC(JavaPlugin plugin, Location spawn, Class<? extends LivingEntity> type, String name, Consumer<Player> clickEvent)
{ {
this(plugin, spawn, type, name, clickEvent, true); this(plugin, spawn, type, name, clickEvent, true);
} }
public SimpleNPC(JavaPlugin plugin, Location spawn, Class<? extends LivingEntity> type, String name, Callback<Player> clickEvent, boolean vegetated) public SimpleNPC(JavaPlugin plugin, Location spawn, Class<? extends LivingEntity> type, String name, Consumer<Player> clickEvent, boolean vegetated)
{ {
spawn.getWorld().loadChunk(spawn.getChunk()); spawn.getWorld().loadChunk(spawn.getChunk());
_entity = spawn.getWorld().spawn(spawn, type); _entity = spawn.getWorld().spawn(spawn, type);
@ -57,7 +59,7 @@ public class SimpleNPC implements Listener
if (_clickEvent != null) if (_clickEvent != null)
{ {
_clickEvent.run(event.getPlayer()); _clickEvent.accept(event.getPlayer());
} }
} }