+ update event api

+ update command api
+ update nbt api
+ update menu api
This commit is contained in:
坏黑
2019-10-22 13:18:18 +08:00
parent 048eb12daf
commit baf2958535
17 changed files with 530 additions and 78 deletions

View File

@@ -1,46 +1,17 @@
package io.izzel.taboolib.common.event;
import org.bukkit.Bukkit;
import io.izzel.taboolib.module.event.EventCancellable;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PlayerJumpEvent extends Event implements Cancellable {
public class PlayerJumpEvent extends EventCancellable<PlayerJumpEvent> {
private static final HandlerList handlers = new HandlerList();
private boolean isCancelled;
private Player player;
public PlayerJumpEvent(Player player) {
this.player = player;
}
public static HandlerList getHandlerList() {
return handlers;
}
public Player getPlayer() {
return this.player;
}
public PlayerJumpEvent call() {
Bukkit.getPluginManager().callEvent(this);
return this;
}
@Override
public boolean isCancelled() {
return this.isCancelled;
}
@Override
public void setCancelled(boolean e) {
this.isCancelled = e;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
}

View File

@@ -28,13 +28,12 @@ public class ListenerPlayerJump implements Listener {
// 不在冷却
&& !cooldown.isCooldown(e.getPlayer().getName())) {
PlayerJumpEvent event = new PlayerJumpEvent(e.getPlayer()).call();
if (event.isCancelled()) {
new PlayerJumpEvent(e.getPlayer()).call().ifCancelled(() -> {
// 返回位置
e.setTo(e.getFrom());
// 重置冷却
cooldown.reset(e.getPlayer().getName());
}
});
}
}
}