-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into latest
- Loading branch information
Showing
44 changed files
with
499 additions
and
727 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
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
58 changes: 58 additions & 0 deletions
58
common/src/main/java/dev/boxadactle/coordinatesdisplay/command/ConfigSubcommand.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,58 @@ | ||
package dev.boxadactle.coordinatesdisplay.command; | ||
|
||
import com.mojang.brigadier.builder.ArgumentBuilder; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import dev.boxadactle.boxlib.command.BCommandManager; | ||
import dev.boxadactle.boxlib.command.BCommandSourceStack; | ||
import dev.boxadactle.boxlib.command.api.BClientSubcommand; | ||
import dev.boxadactle.boxlib.util.GuiUtils; | ||
import dev.boxadactle.coordinatesdisplay.CoordinatesDisplay; | ||
import dev.boxadactle.coordinatesdisplay.ModUtil; | ||
|
||
public class ConfigSubcommand implements BClientSubcommand { | ||
@Override | ||
public ArgumentBuilder<BCommandSourceStack, ?> getSubcommand() { | ||
return BCommandManager.literal("config") | ||
.executes(this::openConfigGui); | ||
} | ||
|
||
@Override | ||
public void build(ArgumentBuilder<BCommandSourceStack, ?> builder) { | ||
builder.then(BCommandManager.literal("file") | ||
.executes(this::openConfigFile) | ||
); | ||
|
||
builder.then(BCommandManager.literal("reload") | ||
.executes(this::reloadConfig) | ||
); | ||
|
||
builder.then(BCommandManager.literal("gui") | ||
.executes(this::openConfigGui) | ||
); | ||
} | ||
|
||
private int openConfigGui(CommandContext<BCommandSourceStack> ignored) { | ||
CoordinatesDisplay.shouldConfigGuiOpen = true; | ||
CoordinatesDisplay.LOGGER.info("Opening Config GUI"); | ||
|
||
return 0; | ||
} | ||
|
||
private int openConfigFile(CommandContext<BCommandSourceStack> ignored) { | ||
if (ModUtil.openConfigFile()) { | ||
CoordinatesDisplay.LOGGER.player.info(GuiUtils.getTranslatable("command.coordinatesdisplay.config.open.success")); | ||
return 0; | ||
} else { | ||
CoordinatesDisplay.LOGGER.info(GuiUtils.getTranslatable("command.coordinatesdisplay.config.open.fail")); | ||
return 1; | ||
} | ||
} | ||
|
||
private int reloadConfig(CommandContext<BCommandSourceStack> ignored) { | ||
CoordinatesDisplay.CONFIG.reload(); | ||
CoordinatesDisplay.LOGGER.player.info(GuiUtils.getTranslatable("command.coordinatesdisplay.config.reload")); | ||
CoordinatesDisplay.LOGGER.info("Reloaded all config"); | ||
|
||
return 0; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
common/src/main/java/dev/boxadactle/coordinatesdisplay/command/CoordinatesCommand.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,58 @@ | ||
package dev.boxadactle.coordinatesdisplay.command; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import dev.boxadactle.boxlib.command.BCommandSourceStack; | ||
import dev.boxadactle.boxlib.command.api.BClientCommand; | ||
import dev.boxadactle.boxlib.util.GuiUtils; | ||
import dev.boxadactle.coordinatesdisplay.CoordinatesDisplay; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.util.List; | ||
|
||
public class CoordinatesCommand { | ||
|
||
public static BClientCommand create() { | ||
return BClientCommand.create("coordinates", CoordinatesCommand::openCoordinatesScreen) | ||
.registerSubcommand(new ConfigSubcommand()) | ||
.registerSubcommand(new CornerSubcommand()) | ||
.registerSubcommand("help", CoordinatesCommand::showHelpMessage) | ||
.registerSubcommand(new ModeSubcommand()) | ||
.registerSubcommand("movehud", CoordinatesCommand::moveHud) | ||
.registerSubcommand(new PositionSubcommand()); | ||
} | ||
|
||
private static int openCoordinatesScreen(CommandContext<BCommandSourceStack> ignored) { | ||
|
||
CoordinatesDisplay.shouldCoordinatesGuiOpen = true; | ||
|
||
return 0; | ||
|
||
} | ||
|
||
private static int showHelpMessage(CommandContext<BCommandSourceStack> ignored) { | ||
List<Component> components = ImmutableList.of( | ||
GuiUtils.colorize(Component.translatable("command.coordinatesdisplay.helpmenu"), GuiUtils.AQUA), | ||
Component.translatable("command.coordinatesdisplay.config"), | ||
Component.translatable("command.coordinatesdisplay.gui"), | ||
Component.translatable("command.coordinatesdisplay.help"), | ||
Component.translatable("command.coordinatesdisplay.mode"), | ||
Component.translatable("command.coordinatesdisplay.movehud"), | ||
Component.translatable("command.coordinatesdisplay.position"), | ||
Component.translatable("command.coordinatesdisplay.visibility") | ||
); | ||
|
||
components.forEach(c -> { | ||
CoordinatesDisplay.LOGGER.player.chat(c); | ||
}); | ||
|
||
return 0; | ||
} | ||
|
||
private static int moveHud(CommandContext<BCommandSourceStack> ignored) { | ||
CoordinatesDisplay.shouldHudPositionGuiOpen = true; | ||
|
||
return 0; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
common/src/main/java/dev/boxadactle/coordinatesdisplay/command/CornerSubcommand.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,30 @@ | ||
package dev.boxadactle.coordinatesdisplay.command; | ||
|
||
import com.mojang.brigadier.builder.ArgumentBuilder; | ||
import dev.boxadactle.boxlib.command.BCommandManager; | ||
import dev.boxadactle.boxlib.command.BCommandSourceStack; | ||
import dev.boxadactle.boxlib.command.api.BClientSubcommand; | ||
import dev.boxadactle.coordinatesdisplay.CoordinatesDisplay; | ||
import dev.boxadactle.coordinatesdisplay.config.ModConfig; | ||
|
||
public class CornerSubcommand implements BClientSubcommand { | ||
@Override | ||
public ArgumentBuilder<BCommandSourceStack, ?> getSubcommand() { | ||
return BCommandManager.literal("corner"); | ||
} | ||
|
||
@Override | ||
public void build(ArgumentBuilder<BCommandSourceStack, ?> builder) { | ||
ModConfig.StartCorner[] corners = ModConfig.StartCorner.values(); | ||
|
||
for (ModConfig.StartCorner corner : corners) { | ||
builder.then(BCommandManager.literal(corner.name().toLowerCase()) | ||
.executes(c -> { | ||
CoordinatesDisplay.getConfig().startCorner = corner; | ||
CoordinatesDisplay.CONFIG.save(); | ||
return 0; | ||
}) | ||
); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
common/src/main/java/dev/boxadactle/coordinatesdisplay/command/ModeSubcommand.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,30 @@ | ||
package dev.boxadactle.coordinatesdisplay.command; | ||
|
||
import com.mojang.brigadier.builder.ArgumentBuilder; | ||
import dev.boxadactle.boxlib.command.BCommandManager; | ||
import dev.boxadactle.boxlib.command.BCommandSourceStack; | ||
import dev.boxadactle.boxlib.command.api.BClientSubcommand; | ||
import dev.boxadactle.coordinatesdisplay.CoordinatesDisplay; | ||
import dev.boxadactle.coordinatesdisplay.hud.CoordinatesHuds; | ||
|
||
public class ModeSubcommand implements BClientSubcommand { | ||
@Override | ||
public ArgumentBuilder<BCommandSourceStack, ?> getSubcommand() { | ||
return BCommandManager.literal("mode"); | ||
} | ||
|
||
@Override | ||
public void build(ArgumentBuilder<BCommandSourceStack, ?> builder) { | ||
String[] modes = CoordinatesHuds.registeredOverlays.keySet().toArray(new String[0]); | ||
|
||
for (String mode : modes) { | ||
builder.then(BCommandManager.literal(mode.toLowerCase()) | ||
.executes(c -> { | ||
CoordinatesDisplay.getConfig().renderMode = mode; | ||
CoordinatesDisplay.CONFIG.save(); | ||
return 0; | ||
}) | ||
); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.