Archived
0
This repository has been archived on 2024-08-27. You can view files and clone it, but cannot push or open issues or pull requests.
ChatAPI/net/nemez/chatapi/click/ClickCallback.java

47 lines
971 B
Java

package net.nemez.chatapi.click;
import org.bukkit.command.CommandSender;
import net.nemez.chatapi.ChatAPI;
public abstract class ClickCallback {
private boolean repeatable, async;
private String expiredMessage;
private boolean expired;
public ClickCallback(boolean repeatable, boolean async, String expiredMessage) {
this.repeatable = repeatable;
this.async = async;
this.expiredMessage = expiredMessage;
this.expired = false;
}
public abstract void run(CommandSender sender);
public final void execute(CommandSender sender) {
if (!expired) {
run(sender);
}else{
if (sender != null) {
sender.sendMessage(ChatAPI.colorify(null, expiredMessage));
}
}
if (!repeatable) {
expired = true;
}
}
public boolean isRepeatable() {
return repeatable;
}
public boolean isAsynchronous() {
return async;
}
public String getExpiredMessage() {
return expiredMessage;
}
}