mirror of
https://github.com/aikar/commands.git
synced 2026-06-03 07:42:17 +00:00
move sneaky into command util
This commit is contained in:
@@ -97,7 +97,7 @@ public abstract class BaseCommand extends Command {
|
||||
registerSubcommand(method, "__default");
|
||||
foundDefault = true;
|
||||
} else {
|
||||
SneakyThrow.sneaky(new InvalidConfigurationException("Multiple @Default commands"));
|
||||
CommandUtil.sneaky(new InvalidConfigurationException("Multiple @Default commands"));
|
||||
}
|
||||
}
|
||||
if (sub != null) {
|
||||
|
||||
@@ -852,4 +852,14 @@ public final class CommandUtil {
|
||||
public static boolean isValidName(String name) {
|
||||
return name != null && !name.isEmpty() && CommandPatterns.VALID_NAME_PATTERN.matcher(name).matches();
|
||||
}
|
||||
|
||||
public static void sneaky(Throwable t)
|
||||
{
|
||||
throw CommandUtil.<RuntimeException>superSneaky( t );
|
||||
}
|
||||
|
||||
private static <T extends Throwable> T superSneaky(Throwable t) throws T
|
||||
{
|
||||
throw (T) t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class RegisteredCommand {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SneakyThrow.sneaky(new InvalidConfigurationException(
|
||||
CommandUtil.sneaky(new InvalidConfigurationException(
|
||||
"Parameter " + type.getSimpleName() + " of " + this.command + " has no resolver"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Daniel Ennis (Aikar) - MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package co.aikar.commands;
|
||||
|
||||
public class SneakyThrow
|
||||
{
|
||||
|
||||
public static void sneaky(Throwable t)
|
||||
{
|
||||
throw SneakyThrow.<RuntimeException>superSneaky( t );
|
||||
}
|
||||
|
||||
private static <T extends Throwable> T superSneaky(Throwable t) throws T
|
||||
{
|
||||
throw (T) t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import co.aikar.commands.annotation.Optional;
|
||||
import co.aikar.commands.annotation.Values;
|
||||
import co.aikar.commands.CommandLog;
|
||||
import co.aikar.commands.CommandPatterns;
|
||||
import co.aikar.commands.SneakyThrow;
|
||||
import co.aikar.commands.CommandUtil;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -112,7 +111,7 @@ public final class CommandContexts {
|
||||
}
|
||||
return CommandPatterns.getPattern(split.value()).split(val);
|
||||
} else if (!c.isLastArg()) {
|
||||
SneakyThrow.sneaky(new InvalidConfigurationException("Weird Command signature... String[] should be last or @Split"));
|
||||
CommandUtil.sneaky(new InvalidConfigurationException("Weird Command signature... String[] should be last or @Split"));
|
||||
}
|
||||
|
||||
String[] result = c.getArgs().toArray(new String[c.getArgs().size()]);
|
||||
|
||||
Reference in New Issue
Block a user