Adds new perm for bypassing delayed commands.

Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1136
This commit is contained in:
tastybento 2020-02-07 18:42:39 -08:00
parent 332967950f
commit 05a4b2d2c7
2 changed files with 14 additions and 3 deletions

View File

@ -74,7 +74,8 @@ public abstract class DelayedTeleportCommand extends CompositeCommand implements
* @param confirmed Runnable to be executed if successfully delayed.
*/
public void delayCommand(User user, String message, Runnable confirmed) {
if (getSettings().getDelayTime() < 1 || user.isOp() || user.hasPermission(getPermissionPrefix() + "mod.bypasscooldowns")) {
if (getSettings().getDelayTime() < 1 || user.isOp() || user.hasPermission(getPermissionPrefix() + "mod.bypasscooldowns")
|| user.hasPermission(getPermissionPrefix() + "mod.bypassdelays")) {
Bukkit.getScheduler().runTask(getPlugin(), confirmed);
return;
}

View File

@ -220,8 +220,18 @@ public class DelayedTeleportCommandTest {
* Test method for {@link world.bentobox.bentobox.api.commands.DelayedTeleportCommand#delayCommand(world.bentobox.bentobox.api.user.User, java.lang.String, java.lang.Runnable)}.
*/
@Test
public void testDelayCommandUserStringRunnablePerm() {
when(user.hasPermission(anyString())).thenReturn(true);
public void testDelayCommandUserStringRunnablePermBypassCooldowns() {
when(user.hasPermission(eq("nullmod.bypasscooldowns"))).thenReturn(true);
dtc.delayCommand(user, HELLO, command);
verify(sch).runTask(eq(plugin), eq(command));
}
/**
* Test method for {@link world.bentobox.bentobox.api.commands.DelayedTeleportCommand#delayCommand(world.bentobox.bentobox.api.user.User, java.lang.String, java.lang.Runnable)}.
*/
@Test
public void testDelayCommandUserStringRunnablePermBypassDelay() {
when(user.hasPermission(eq("nullmod.bypassdelays"))).thenReturn(true);
dtc.delayCommand(user, HELLO, command);
verify(sch).runTask(eq(plugin), eq(command));
}