mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-06 02:29:42 +01:00
Merge branch 'development'
This commit is contained in:
commit
b9ad5cbd76
@ -0,0 +1,24 @@
|
|||||||
|
package com.songoda.epichoppers.api.events;
|
||||||
|
|
||||||
|
import com.songoda.epichoppers.hopper.Hopper;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class HopperBreakEvent extends HopperEvent {
|
||||||
|
|
||||||
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
||||||
|
public HopperBreakEvent(Player player, Hopper hopper) {
|
||||||
|
super(player, hopper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.songoda.epichoppers.api.events;
|
||||||
|
|
||||||
|
import com.songoda.epichoppers.hopper.Hopper;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class HopperPlaceEvent extends HopperEvent {
|
||||||
|
|
||||||
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
||||||
|
public HopperPlaceEvent(Player player, Hopper hopper) {
|
||||||
|
super(player, hopper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,13 @@
|
|||||||
package com.songoda.epichoppers.listeners;
|
package com.songoda.epichoppers.listeners;
|
||||||
|
|
||||||
import com.songoda.epichoppers.EpicHoppers;
|
import com.songoda.epichoppers.EpicHoppers;
|
||||||
|
import com.songoda.epichoppers.api.events.HopperBreakEvent;
|
||||||
|
import com.songoda.epichoppers.api.events.HopperPlaceEvent;
|
||||||
import com.songoda.epichoppers.hopper.Hopper;
|
import com.songoda.epichoppers.hopper.Hopper;
|
||||||
import com.songoda.epichoppers.hopper.HopperBuilder;
|
import com.songoda.epichoppers.hopper.HopperBuilder;
|
||||||
import com.songoda.epichoppers.hopper.levels.Level;
|
import com.songoda.epichoppers.hopper.levels.Level;
|
||||||
import com.songoda.epichoppers.settings.Settings;
|
import com.songoda.epichoppers.settings.Settings;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -64,6 +67,10 @@ public class BlockListeners implements Listener {
|
|||||||
.setLevel(plugin.getLevelManager().getLevel(item))
|
.setLevel(plugin.getLevelManager().getLevel(item))
|
||||||
.setPlacedBy(player)
|
.setPlacedBy(player)
|
||||||
.setLastPlayerOpened(player).build());
|
.setLastPlayerOpened(player).build());
|
||||||
|
|
||||||
|
HopperPlaceEvent hopperPlaceEvent = new HopperPlaceEvent(player, hopper);
|
||||||
|
Bukkit.getPluginManager().callEvent(hopperPlaceEvent);
|
||||||
|
|
||||||
EpicHoppers.getInstance().getDataManager().createHopper(hopper);
|
EpicHoppers.getInstance().getDataManager().createHopper(hopper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +119,9 @@ public class BlockListeners implements Listener {
|
|||||||
Level level = hopper.getLevel();
|
Level level = hopper.getLevel();
|
||||||
|
|
||||||
if (level.getLevel() > 1 || Settings.ALLOW_NORMAL_HOPPERS.getBoolean()) {
|
if (level.getLevel() > 1 || Settings.ALLOW_NORMAL_HOPPERS.getBoolean()) {
|
||||||
|
HopperBreakEvent hopperBreakEvent = new HopperBreakEvent(player, hopper);
|
||||||
|
Bukkit.getPluginManager().callEvent(hopperBreakEvent);
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
ItemStack item = plugin.newHopperItem(level);
|
ItemStack item = plugin.newHopperItem(level);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user