mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-06-29 05:41:45 +00:00
45 lines
1.2 KiB
Java
45 lines
1.2 KiB
Java
package com.boydti.fawe.object;
|
|
|
|
import com.boydti.fawe.config.BBC;
|
|
import com.boydti.fawe.util.TaskManager;
|
|
|
|
public abstract class FaweCommand<T> {
|
|
public final String perm;
|
|
public final boolean safe;
|
|
|
|
public FaweCommand(String perm) {
|
|
this(perm, true);
|
|
}
|
|
|
|
public FaweCommand(final String perm, final boolean safe) {
|
|
this.perm = perm;
|
|
this.safe = safe;
|
|
}
|
|
|
|
public String getPerm() {
|
|
return this.perm;
|
|
}
|
|
|
|
public boolean executeSafe(final FawePlayer<T> player, final String... args) {
|
|
try {
|
|
if (!safe) {
|
|
execute(player, args);
|
|
return true;
|
|
} else if (player == null) {
|
|
TaskManager.IMP.async(() -> execute(player, args));
|
|
} else {
|
|
if (!player.runAction(() -> execute(player, args), true, true)) {
|
|
BBC.WORLDEDIT_COMMAND_LIMIT.send(player);
|
|
return true;
|
|
}
|
|
}
|
|
return true;
|
|
} catch (Throwable e) {
|
|
e.printStackTrace();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public abstract boolean execute(final FawePlayer<T> player, final String... args);
|
|
}
|