forked from upstream/ProAntiTab
Attempt to add Skript support
This commit is contained in:
1 parent
f6e77c04fa
commit
6e5f7cc980
6 files changed
+180
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public abstract class ExecuteCommandEvent extends Event implements Cancellable {
|
||||
|
||||
private final String command;
|
||||
private boolean blocked;
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
this.blocked = false;
|
||||
this.command = null;
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(Player player, String command, boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.blocked = cancel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredSuggestionEvent extends Event {
|
||||
|
||||
private List<String> suggestions;
|
||||
|
||||
public FilteredSuggestionEvent() {
|
||||
this.suggestions = null;
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(Player player, List<String> suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
public List<String> getSuggestions() {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public void setSuggestions(List<String> suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredTabCompletionEvent extends Event {
|
||||
|
||||
private String cursor;
|
||||
private List<String> completion;
|
||||
|
||||
public FilteredTabCompletionEvent() {
|
||||
this.cursor = null;
|
||||
this.completion = null;
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(Player player, String cursor, List<String> completion) {
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
}
|
||||
|
||||
public abstract void handle(FilteredTabCompletionEvent event);
|
||||
|
||||
public String getCursor() {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public List<String> getCompletion() {
|
||||
return completion;
|
||||
}
|
||||
|
||||
public void setCompletion(List<String> completion) {
|
||||
this.completion = completion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package de.rayzs.pat.plugin.skript;
|
||||
|
||||
import ch.njol.skript.*;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import de.rayzs.pat.api.event.events.bukkit.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.skript.impl.events.ExecuteCommandSkriptEvent;
|
||||
|
||||
public class PATSkriptAddon {
|
||||
|
||||
public static SkriptAddon ADDON;
|
||||
|
||||
public static void initialize(JavaPlugin javaPlugin) {
|
||||
ADDON = Skript.getAddon(javaPlugin);
|
||||
|
||||
Skript.registerEvent("PAT Command Execution", ExecuteCommandSkriptEvent.class, ExecuteCommandEvent.class, "if [command] is (blocked|cancelled|not blocked|not cancelled)");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.rayzs.pat.plugin.skript.impl.events;
|
||||
|
||||
import ch.njol.skript.Skript;
|
||||
import ch.njol.skript.doc.Description;
|
||||
import ch.njol.skript.doc.Name;
|
||||
import ch.njol.skript.lang.Literal;
|
||||
import ch.njol.skript.lang.SkriptEvent;
|
||||
import ch.njol.skript.lang.SkriptParser;
|
||||
import de.rayzs.pat.api.event.events.bukkit.ExecuteCommandEvent;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
@Name("PAT Command Execution")
|
||||
@Description("Fires after a command has been checked by PAT.")
|
||||
public class ExecuteCommandSkriptEvent extends SkriptEvent {
|
||||
|
||||
static {
|
||||
Skript.registerEvent("PAT Command Execution",
|
||||
ExecuteCommandSkriptEvent.class, ExecuteCommandEvent.class,
|
||||
"[if] (blocked|cancelled|not blocked|not cancelled)");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Literal<?>[] literals, int i, SkriptParser.ParseResult parseResult) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Event event, boolean b) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(Event event) {
|
||||
|
||||
if (event instanceof ExecuteCommandEvent) {
|
||||
ExecuteCommandEvent executeCommandEvent = (ExecuteCommandEvent) event;
|
||||
return executeCommandEvent.isBlocked();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user