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
@@ -0,0 +1,43 @@
package net.fameless.forcebattle.command;

import net.fameless.forcebattle.caption.Caption;
import net.fameless.forcebattle.command.framework.CallerType;
import net.fameless.forcebattle.command.framework.Command;
import net.fameless.forcebattle.command.framework.CommandCaller;
import net.fameless.forcebattle.configuration.SettingsManager;
import net.fameless.forcebattle.player.BattlePlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class MobileCraftingCommand extends Command {

public MobileCraftingCommand() {
super(
"craft",
List.of("crafting"),
CallerType.PLAYER,
"/craft",
"forcebattle.craft",
"Command to open the crafting table GUI"
);
}

@Override
public void executeCommand(@NotNull CommandCaller caller, String[] args) {
if (!SettingsManager.isEnabled(SettingsManager.Setting.MOBILE_CRAFTING)) {
caller.sendMessage(Caption.of("error.mobile_crafting_disabled"));
return;
}
if (caller instanceof BattlePlayer battlePlayer) {
Player player = battlePlayer.getPlayer();
player.openWorkbench(null, true);
}
}

@Override
public List<String> tabComplete(CommandCaller caller, String[] args) {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.fameless.forcebattle.command.HelpCommand;
import net.fameless.forcebattle.command.JokerCommand;
import net.fameless.forcebattle.command.LanguageCommand;
import net.fameless.forcebattle.command.MobileCraftingCommand;
import net.fameless.forcebattle.command.PointsCommand;
import net.fameless.forcebattle.command.RandomTeamsCommand;
import net.fameless.forcebattle.command.RecipeCommand;
Expand Down Expand Up @@ -90,6 +91,7 @@ public static void createInstances() {
new HelpCommand();
new JokerCommand();
new LanguageCommand();
new MobileCraftingCommand();
new PointsCommand();
new RandomTeamsCommand();
new RecipeCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class PermissionManager {
Map.entry("forcebattle.joker", PermissionDefault.OP),
Map.entry("forcebattle.points", PermissionDefault.OP),
Map.entry("forcebattle.help", PermissionDefault.TRUE),
Map.entry("forcebattle.randomteams", PermissionDefault.OP)
Map.entry("forcebattle.randomteams", PermissionDefault.OP),
Map.entry("forcebattle.craft", PermissionDefault.TRUE)
);

public static void registerPermissions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public enum Setting {

NO_HUNGER,
NO_DAMAGE,
MOBILE_CRAFTING,
BACKPACK,
CHAIN_MODE,
HIDE_POINTS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public enum SettingButton {
"gui.no_hunger_name", "gui.no_hunger_lore", "notification.no_hunger_changed"),
NO_DAMAGE(19, Material.IRON_SWORD, SettingsManager.Setting.NO_DAMAGE, false,
"gui.no_damage_name", "gui.no_damage_lore", "notification.no_damage_changed"),
MOBILE_CRAFTING(20, Material.CRAFTING_TABLE, SettingsManager.Setting.MOBILE_CRAFTING, false,
"gui.mobile_crafting_name", "gui.mobile_crafting_lore", "notification.mobile_crafting_changed"),
CHAIN_MODE(27, Material.CHAIN, SettingsManager.Setting.CHAIN_MODE, false,
"gui.chain_mode_name", "gui.chain_mode_lore", "notification.chain_mode_changed"),
BACKPACK(28, Material.CHEST, SettingsManager.Setting.BACKPACK, false,
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"gui.no_hunger_lore" : " <br><gray>Click to toggle no Hunger.<br><br><blue>Current Status<dark_gray>: <state>",
"gui.no_damage_name" : "<blue>No Damage",
"gui.no_damage_lore" : " <br><gray>Click to toggle no Damage.<br><br><blue>Current Status<dark_gray>: <state>",
"gui.mobile_crafting_name" : "<blue>Mobile Crafting",
"gui.mobile_crafting_lore" : " <br><gray>Click to toggle mobile crafting.<br><br><blue>Current Status<dark_gray>: <state>",
"gui.chain_mode_name" : "<blue>Chain Mode",
"gui.chain_mode_lore" : " <br><gray>Click to toggle Chain Mode.<br><br><blue>Current Status<dark_gray>: <state>",
"gui.result_title_all" : "Results | All Players",
Expand Down Expand Up @@ -84,6 +86,7 @@
"notification.force_structure_changed" : "<prefix><blue>ForceStructure <gray>has been set to <blue><state>!",
"notification.no_hunger_changed" : "<prefix><blue>No Hunger <gray>has been set to <blue><state>!",
"notification.no_damage_changed" : "<prefix><blue>No Damage <gray>has been set to <blue><state>!",
"notification.mobile_crafting_changed" : "<prefix><blue>Mobile Crafting <gray>has been set to <blue><state>!",
"notification.chain_mode_changed" : "<prefix><blue>Chain Mode <gray>has been set to <blue><state>!",
"notification.no_duplicate_objectives_changed" : "<prefix><blue>No duplicate objectives <gray>has been set to <blue><state>!",
"notification.simplified_objectives_changed" : "<prefix><blue>Simplified objectives <gray>have been set to <blue><state>!",
Expand Down Expand Up @@ -137,6 +140,7 @@
"command.timer_set" : "<prefix><blue>The timer has been set to <time>.",
"error.no_challenge_selected" : "<prefix><red>You need to select at least 1 Challenge.",
"error.backpacks_disabled" : "<prefix><red>Backpacks are disabled.",
"error.mobile_crafting_disabled" : "<prefix><red>Mobile Crafting is disabled.",
"error.no_caller_type" : "<prefix><red>Report an issue in case you see this message.",
"error.not_same_team" : "<prefix><red>The specified player is not on your team.",
"error.game_not_started" : "<prefix><red>The game hasn't started yet.",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ commands:
joker:
language:
aliases: [ lang ]
craft:
aliases: [ crafting ]
points:
randomteams:
recipe:
Expand Down
Loading