mirror of
https://github.com/CarmJos/EasyListener.git
synced 2026-06-04 19:30:57 +08:00
feat(api): 修改接口的实现方式。
将关键方法置顶,并采用接口与实现类的方式分离关键代码,便于学习使用。
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
public class DemoPlugin extends JavaPlugin {
|
||||
|
||||
protected final EasyListener listeners = new EasyListener(this);
|
||||
protected final EasyListener listeners = EasyListener.create(this);
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@@ -37,7 +37,7 @@ public class DemoPlugin extends JavaPlugin {
|
||||
EntityDamageEvent.class, EventPriority.HIGHEST,
|
||||
(event) -> event.getCause() != EntityDamageEvent.DamageCause.ENTITY_ATTACK
|
||||
); // 有条件的取消一个事件
|
||||
|
||||
|
||||
listeners // 额外提供的快捷方法
|
||||
.cancelDeath(null) // 所有玩家取消死亡
|
||||
.cancelBreak(player -> !player.isOp()) // 禁止非OP玩家破坏方块/接水或岩浆
|
||||
|
||||
Reference in New Issue
Block a user