Improved catchers
This commit is contained in:
parent
a880637c40
commit
f6da4781e7
@ -4,9 +4,9 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import io.izzel.taboolib.TabooLib;
|
||||
import io.izzel.taboolib.module.compat.PlaceholderHook;
|
||||
import io.izzel.taboolib.module.locale.TLocale;
|
||||
import io.izzel.taboolib.module.locale.TLocaleSerialize;
|
||||
import io.izzel.taboolib.module.compat.PlaceholderHook;
|
||||
import io.izzel.taboolib.module.tellraw.TellrawJson;
|
||||
import io.izzel.taboolib.util.Strings;
|
||||
import io.izzel.taboolib.util.Variables;
|
||||
|
@ -39,13 +39,13 @@ public class Catchers implements Listener {
|
||||
e.setCancelled(true);
|
||||
// 1.14 supported.
|
||||
Bukkit.getScheduler().runTask(TabooLib.getPlugin(), () -> {
|
||||
Catcher catcher = playerdata.get(e.getPlayer().getName()).getFirst();
|
||||
// 退出
|
||||
if (e.getMessage().equalsIgnoreCase("quit()")) {
|
||||
if (e.getMessage().split(" ")[0].matches(catcher.quit())) {
|
||||
playerdata.get(e.getPlayer().getName()).removeFirst().cancel();
|
||||
}
|
||||
// 默认
|
||||
else {
|
||||
Catcher catcher = playerdata.get(e.getPlayer().getName()).getFirst();
|
||||
// 如果终止引导
|
||||
if (!catcher.after(e.getMessage())) {
|
||||
playerdata.get(e.getPlayer().getName()).removeFirst();
|
||||
@ -59,6 +59,10 @@ public class Catchers implements Listener {
|
||||
|
||||
public interface Catcher {
|
||||
|
||||
default String quit() {
|
||||
return "(?i)quit|cancel|exit";
|
||||
}
|
||||
|
||||
default Catcher before() {
|
||||
return this;
|
||||
}
|
||||
@ -67,5 +71,6 @@ public class Catchers implements Listener {
|
||||
|
||||
default void cancel() {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user