Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.jonahseguin.drink.parametric.CommandParameter;
import com.jonahseguin.drink.parametric.DrinkProvider;

import dev.lrxh.neptune.configs.impl.MessagesLocale;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -60,7 +62,8 @@ public List<String> combineMultiWordArguments(List<String> args) {
}

@Nonnull
public Object[] parseArguments(@Nonnull CommandExecution execution, @Nonnull DrinkCommand command, @Nonnull CommandArgs args) throws CommandExitMessage, CommandArgumentException {
public Object[] parseArguments(@Nonnull CommandExecution execution, @Nonnull DrinkCommand command,
@Nonnull CommandArgs args) throws CommandExitMessage, CommandArgumentException {

Preconditions.checkNotNull(command, "DrinkCommand cannot be null");
Preconditions.checkNotNull(args, "CommandArgs cannot be null");
Expand Down Expand Up @@ -88,7 +91,8 @@ public Object[] parseArguments(@Nonnull CommandExecution execution, @Nonnull Dri
continue;
}

Object o = provider.provide(new CommandArg(args.getSender(), value, args), parameter.getAllAnnotations());
Object o = provider.provide(new CommandArg(args.getSender(), value, args),
parameter.getAllAnnotations());
o = commandService.getModifierService().executeModifiers(execution, parameter, o);
arguments[i] = o;
continue;
Expand All @@ -104,23 +108,26 @@ public Object[] parseArguments(@Nonnull CommandExecution execution, @Nonnull Dri

value = parameter.getDefaultOptionalValue();

Object o = provider.provide(new CommandArg(args.getSender(), value, args), parameter.getAllAnnotations());
Object o = provider.provide(new CommandArg(args.getSender(), value, args),
parameter.getAllAnnotations());
o = commandService.getModifierService().executeModifiers(execution, parameter, o);
arguments[i] = o;
continue;
}

try {

Object o = provider.provide(new CommandArg(args.getSender(), value, args), parameter.getAllAnnotations());
Object o = provider.provide(new CommandArg(args.getSender(), value, args),
parameter.getAllAnnotations());
o = commandService.getModifierService().executeModifiers(execution, parameter, o);
arguments[i] = o;

} catch (CommandExitMessage ex) {

value = parameter.getDefaultOptionalValue();

Object o = provider.provide(new CommandArg(args.getSender(), value, args), parameter.getAllAnnotations());
Object o = provider.provide(new CommandArg(args.getSender(), value, args),
parameter.getAllAnnotations());
o = commandService.getModifierService().executeModifiers(execution, parameter, o);
arguments[i] = o;

Expand All @@ -133,13 +140,15 @@ public Object[] parseArguments(@Nonnull CommandExecution execution, @Nonnull Dri
if (provider.doesConsumeArgument()) {

if (!args.hasNext()) {
throw new CommandArgumentException("Missing argument for: " + provider.argumentDescription());
throw new CommandArgumentException(MessagesLocale.MISSING_ARGUMENT.getString()
.replaceAll("<command>", provider.argumentDescription()));
}

value = args.next();

if (value == null && !provider.allowNullArgument()) {
throw new CommandArgumentException("Argument already consumed for next argument: " + provider.argumentDescription() + " (this is a provider error!)");
throw new CommandArgumentException("Argument already consumed for next argument: "
+ provider.argumentDescription() + " (this is a provider error!)");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

import lombok.Getter;
import lombok.Setter;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;

import dev.lrxh.neptune.configs.impl.MessagesLocale;
import dev.lrxh.neptune.utils.CC;

import javax.annotation.Nonnull;

@Getter
@Setter
public class DrinkAuthorizer {

private String noPermissionMessage = ChatColor.RED + "You do not have permission to perform this command.";

public boolean isAuthorized(@Nonnull CommandSender sender, @Nonnull DrinkCommand command) {
if (command.getPermission() != null && command.getPermission().length() > 0) {
if (!sender.hasPermission(command.getPermission())) {
sender.sendMessage(noPermissionMessage);
sender.sendMessage(CC.color(MessagesLocale.NO_PERMISSION.getString()));
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ConfigService {
private ConfigFile divisionsConfig;
private ConfigFile cosmeticsConfig;
private ConfigFile killMessagesConfig;
private ConfigFile soundsConfig;

public static ConfigService get() {
if (instance == null) instance = new ConfigService();
Expand All @@ -36,6 +37,7 @@ public void load() {
divisionsConfig = new ConfigFile("divisions");
cosmeticsConfig = new ConfigFile("cosmetics");
killMessagesConfig = new ConfigFile("kill-messages");
soundsConfig = new ConfigFile("sounds");

initialize();
}
Expand All @@ -47,5 +49,6 @@ public void initialize() {
MenusLocale.FILTER_NAME.load();
ScoreboardLocale.TITLE.load();
CosmeticsLocale.LIGHTNING_DISPLAY_NAME.load();
SoundsLocale.MATCH_START.load();
}
}
Loading