-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgraded to latest ToberoCore version
- Loading branch information
Showing
11 changed files
with
417 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/io/github/toberocat/guiengine/arguments/GuiEngineApiArgument.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.github.toberocat.guiengine.arguments; | ||
|
||
import io.github.toberocat.guiengine.GuiEngineApi; | ||
import io.github.toberocat.guiengine.GuiEngineApiPlugin; | ||
import io.github.toberocat.toberocore.command.arguments.Argument; | ||
import io.github.toberocat.toberocore.command.exceptions.CommandException; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
public class GuiEngineApiArgument implements Argument<GuiEngineApi> { | ||
private final GuiEngineApi defaultApi; | ||
|
||
public GuiEngineApiArgument() { | ||
this(GuiEngineApiPlugin.getPlugin().getGuiApi()); | ||
} | ||
|
||
public GuiEngineApiArgument(GuiEngineApi defaultApi) { | ||
this.defaultApi = defaultApi; | ||
} | ||
|
||
@Override | ||
public GuiEngineApi parse(@NotNull Player player, @NotNull String s) throws CommandException { | ||
GuiEngineApi api = GuiEngineApi.APIS.get(s); | ||
if (api == null) | ||
throw new CommandException("§cNo API found with ID" + s, new HashMap<>()); | ||
return api; | ||
} | ||
|
||
@Override | ||
public GuiEngineApi defaultValue(@NotNull Player player) { | ||
return defaultApi; | ||
} | ||
|
||
@Override | ||
public @Nullable List<String> tab(@NotNull Player player) throws CommandException { | ||
return GuiEngineApi.APIS.keySet().stream().toList(); | ||
} | ||
|
||
@Override | ||
public @NotNull String descriptionKey() { | ||
return "base.gui-engine.args.api"; | ||
} | ||
|
||
@Override | ||
public @NotNull String usage() { | ||
return "<api>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/io/github/toberocat/guiengine/commands/ReloadCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.github.toberocat.guiengine.commands; | ||
|
||
import io.github.toberocat.guiengine.GuiEngineApi; | ||
import io.github.toberocat.guiengine.GuiEngineApiPlugin; | ||
import io.github.toberocat.guiengine.exception.GuiIORuntimeException; | ||
import io.github.toberocat.toberocore.command.SubCommand; | ||
import io.github.toberocat.toberocore.command.arguments.Argument; | ||
import io.github.toberocat.toberocore.command.exceptions.CommandException; | ||
import io.github.toberocat.toberocore.command.options.Options; | ||
import org.bukkit.command.CommandSender; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ReloadCommand extends SubCommand { | ||
public ReloadCommand() { | ||
super("reload"); | ||
} | ||
|
||
@Override | ||
protected @NotNull Options options() { | ||
return new Options(); | ||
} | ||
|
||
@Override | ||
protected @NotNull Argument<?>[] arguments() { | ||
return new Argument[0]; | ||
} | ||
|
||
@Override | ||
protected boolean handleCommand(@NotNull CommandSender sender, @NotNull String[] strings) throws CommandException { | ||
try { | ||
GuiEngineApiPlugin.getPlugin().reloadConfig(); | ||
|
||
for (GuiEngineApi api : GuiEngineApi.APIS.values()) | ||
api.reload(); | ||
sender.sendMessage("§aReloaded GUI APIs."); | ||
} catch (GuiIORuntimeException e) { | ||
sender.sendMessage(e.getMessage()); | ||
} | ||
return true; | ||
} | ||
} |
Oops, something went wrong.