Skip to content

Commit

Permalink
Add commands & config for HubCommandBack
Browse files Browse the repository at this point in the history
  • Loading branch information
udu3324 committed Dec 29, 2023
1 parent dd34091 commit dd46b3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/udu3324/poinpow/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public static void create() {
BlockMinehutAds.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockMinehutAds.name)));
BlockFreeCredits.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockFreeCredits.name)));
BlockLobbyMapAds.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockLobbyMapAds.name)));
HubCommandBack.toggled.set(Boolean.parseBoolean(getValueFromConfig(HubCommandBack.name)));
}
}
} catch (IOException e) {
Expand All @@ -243,6 +244,7 @@ private static void writeDefaultConfig() throws IOException {
w.write(BlockMinehutAds.name + ": true" + System.lineSeparator());
w.write(BlockFreeCredits.name + ": true" + System.lineSeparator());
w.write(BlockLobbyMapAds.name + ": true" + System.lineSeparator());
w.write(HubCommandBack.name + ": true" + System.lineSeparator());
w.write(System.lineSeparator());
w.write("# Each line below is regex for ChatPhraseFilter to use." + System.lineSeparator());
w.write("/join");
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/udu3324/poinpow/commands/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
.executes(ctx -> description(ctx.getSource(), BlockLobbyMapAds.name, BlockLobbyMapAds.description, BlockLobbyMapAds.toggled))
.then(literal("true").executes(ctx -> toggle(ctx.getSource(), BlockLobbyMapAds.name, BlockLobbyMapAds.toggled, true)))
.then(literal("false").executes(ctx -> toggle(ctx.getSource(), BlockLobbyMapAds.name, BlockLobbyMapAds.toggled, false))))

.then(literal(HubCommandBack.name)
.executes(ctx -> description(ctx.getSource(), HubCommandBack.name, HubCommandBack.description, HubCommandBack.toggled))
.then(literal("true").executes(ctx -> toggle(ctx.getSource(), HubCommandBack.name, HubCommandBack.toggled, true)))
.then(literal("false").executes(ctx -> toggle(ctx.getSource(), HubCommandBack.name, HubCommandBack.toggled, false))))
);
}

Expand Down Expand Up @@ -165,6 +170,13 @@ private static int help(FabricClientCommandSource source) {
.withColor(Formatting.DARK_GRAY)
));

//hub command back
source.sendFeedback(Text.literal("[toggled|" + HubCommandBack.toggled + "] " + HubCommandBack.name).styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(HubCommandBack.description + "\n\nClick to Toggle")))
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/poinpow " + HubCommandBack.name + " " + !HubCommandBack.toggled.get()))
.withColor(Formatting.DARK_GRAY)
));

//lookup server
source.sendFeedback(Text.literal("/" + ServerLookup.name + " <serverName>").styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(ServerLookup.description + "\n\nClick to lookup a server!")))
Expand Down

0 comments on commit dd46b3d

Please sign in to comment.