Skip to content

Commit

Permalink
Resolvido problema com sugestão de comandos
Browse files Browse the repository at this point in the history
  • Loading branch information
SrBedrock committed Feb 18, 2024
1 parent 18300aa commit c111f7d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,11 @@ public void build() {

String commandOrder = "/" + command + " " + subCommand + " ";

String correctUsage = null;
String correctUsage = getCorrectUsage(command, subCommand, commandOrder);

switch (command) {
case "crates" -> correctUsage = getContext(subCommand, commandOrder);
case "keys" -> {
if (subCommand.equals("view")) correctUsage = "/keys " + subCommand;
}
if (!correctUsage.isEmpty()) {
send(sender, Messages.correct_usage.getMessage("%usage%", correctUsage).toString());
}

if (correctUsage != null) send(sender, Messages.correct_usage.getMessage("%usage%", correctUsage).toString());
});

getBukkitCommandManager().registerMessage(MessageKey.NOT_ENOUGH_ARGUMENTS, (sender, context) -> {
Expand All @@ -53,21 +48,34 @@ public void build() {

String commandOrder = "/" + command + " " + subCommand + " ";

String correctUsage = null;
String correctUsage = getCorrectUsage(command, subCommand, commandOrder);

switch (command) {
case "crates" -> correctUsage = getContext(subCommand, commandOrder);
case "keys" -> {
if (subCommand.equals("view")) correctUsage = "/keys " + subCommand + " <player-name>";
}
if (!correctUsage.isEmpty()) {
send(sender, Messages.correct_usage.getMessage("%usage%", correctUsage).toString());
}

if (correctUsage != null) send(sender, Messages.correct_usage.getMessage("%usage%", correctUsage).toString());
});

getBukkitCommandManager().registerMessage(MessageKey.UNKNOWN_COMMAND, (sender, context) -> send(sender, Messages.unknown_command.getString()));
}

private String getCorrectUsage(@NotNull String command, String subCommand, String commandOrder) {
String correctUsage = "";

switch (command) {
case "crates" -> correctUsage = getContext(subCommand, commandOrder);
case "chave" -> {
if (subCommand.equals("ver")) {
correctUsage = commandOrder + " [jogador]";
}
if (subCommand.equals("transferir")) {
correctUsage = commandOrder + " <caixa> <jogador> <quantidade>";
}
}
}

return correctUsage;
}

@Override
public void send(@NotNull CommandSender sender, @NotNull String component) {
sender.sendMessage(parse(component));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.HashMap;
import java.util.List;

@Command(value = "chaves", alias = {"chave"})
@Command(value = "chave", alias = {"chaves"})
@Description("Views the amount of keys you/others have.")
public class BaseKeyCommand extends BaseCommand {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.badbones69.crazycrates.support;

import com.badbones69.crazycrates.CrazyCrates;
import com.google.common.collect.Lists;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
Expand Down Expand Up @@ -49,9 +48,7 @@ public void pasteStructure(Location location) {
try {
getBlocks(location);

getStructureManager()
.loadStructure(this.file)
.place(location.subtract(2, 0.0, 2), false, StructureRotation.NONE, Mirror.NONE, 0, 1F, new Random());
getStructureManager().loadStructure(this.file).place(location.subtract(2, 0.0, 2), false, StructureRotation.NONE, Mirror.NONE, 0, 1F, new Random());

getStructureBlocks(location);
} catch (Exception exception) {
Expand Down
11 changes: 1 addition & 10 deletions paper/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,4 @@ api-version: "${apiVersion}"
description: "${description}"
website: "${website}"

softdepend:
[
CMI,
DecentHolograms,
HolographicDisplays,
PlaceholderAPI,
ItemsAdder,
Oraxen,
ItemEdit,
]
softdepend: [ CMI, DecentHolograms, HolographicDisplays, PlaceholderAPI, ItemsAdder, Oraxen, ItemEdit ]

0 comments on commit c111f7d

Please sign in to comment.