Skip to content

Commit 15810d5

Browse files
committed
feat: add alias for tutorial, add more tutorial commands, optimize code. config: add voice options
1 parent 7d85f03 commit 15810d5

5 files changed

Lines changed: 146 additions & 30 deletions

File tree

src/main/java/zadudoder/spmhelper/ModMenuIntegration.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import net.minecraft.text.Text;
1616
import zadudoder.spmhelper.config.SPmHelperConfig;
1717
import zadudoder.spmhelper.utils.ScreenType;
18+
import zadudoder.spmhelper.utils.types.VoiceType;
1819

1920
@Environment(EnvType.CLIENT)
2021
public class ModMenuIntegration implements ModMenuApi {
@@ -39,6 +40,7 @@ public ConfigScreenFactory<?> getModConfigScreenFactory() {
3940
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
4041
ConfigCategory mainCategory = builder.getOrCreateCategory(Text.translatable("text.spmhelper.config.mainCategory"));
4142
ConfigCategory navCategory = builder.getOrCreateCategory(Text.translatable("text.spmhelper.config.navCategory"));
43+
ConfigCategory guideCategory = builder.getOrCreateCategory(Text.translatable("text.spmhelper.config.guideCategory"));
4244

4345
// Добавляем настройки
4446
mainCategory.addEntry(entryBuilder.startBooleanToggle(Text.translatable("text.spmhelper.option.enableMenuButton"), config.enableMenuButton)
@@ -76,6 +78,19 @@ public ConfigScreenFactory<?> getModConfigScreenFactory() {
7678
.setSaveConsumer(newValue -> config.SPmNavScale = newValue)
7779
.build());
7880

81+
guideCategory.addEntry(entryBuilder.startBooleanToggle(Text.translatable("text.spmhelper.option.enableVoiceInGuide"), config.EnableVoiceGuide)
82+
.setSaveConsumer(newValue -> config.EnableVoiceGuide = newValue)
83+
.build());
84+
85+
guideCategory.addEntry(entryBuilder.startEnumSelector(Text.translatable("text.spmhelper.option.voiceType"), VoiceType.class, config.voiceType)
86+
.setSaveConsumer(newValue -> config.voiceType = newValue)
87+
.setEnumNameProvider(value -> {
88+
// Локализация значений enum
89+
return Text.translatable("text.spmhelper.voice_type_." + value.name().toLowerCase());
90+
})
91+
.build());
92+
93+
7994
return builder.build();
8095
};
8196
}

src/main/java/zadudoder/spmhelper/config/SPmHelperConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import me.shedaniel.autoconfig.annotation.Config;
66
import zadudoder.spmhelper.utils.ScreenType;
77
import zadudoder.spmhelper.utils.types.Card;
8+
import zadudoder.spmhelper.utils.types.VoiceType;
89

910
import java.util.HashMap;
1011
import java.util.Map;
@@ -18,6 +19,8 @@ public class SPmHelperConfig implements ConfigData {
1819
public Boolean numberOfCardInComment = false; // true - включено, false - выключено в переводе будет указывать карту куда вы переводите
1920
public Boolean enableSPmNav = true;
2021
public Boolean particlesEnabled = true;
22+
public Boolean EnableVoiceGuide = true;
23+
public VoiceType voiceType = VoiceType.MALE;
2124
public Boolean isFirstRun = true;
2225
public int SPmNavX = 50;
2326
public int SPmNavY = 2;

src/main/java/zadudoder/spmhelper/events/Commands.java

Lines changed: 76 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,34 +71,95 @@ public static void registerCommands() {
7171
).then(ClientCommandManager.literal("tutorial")
7272
.then(ClientCommandManager.literal("start")
7373
.executes(context -> {
74-
TutorialManager.startTutorial();
74+
TutorialManager.startFullTutorial();
7575
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startTutorialMessage"));
7676
return 1;
7777
}))
7878
.then(ClientCommandManager.literal("stop")
7979
.executes(context -> {
80-
TutorialManager.stopTutorial();
81-
context.getSource().sendFeedback(Text.translatable("text.spmhelper.stopTutorialMessage"));
80+
if (TutorialManager.isEnabled) {
81+
TutorialManager.stopTutorial();
82+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.stopTutorialMessage"));
83+
} else {
84+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.TutorialIsNotEnabledMessage"));
85+
}
86+
8287
return 1;
8388
}))
8489
.then(ClientCommandManager.literal("skip")
8590
.executes(context -> {
86-
TutorialManager.skipTutorial();
87-
context.getSource().sendFeedback(Text.translatable("text.spmhelper.skipTutorialMessage"));
91+
if (TutorialManager.isEnabled) {
92+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.skipTutorialMessage"));
93+
TutorialManager.skipTutorial();
94+
} else {
95+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.TutorialIsNotEnabledMessage"));
96+
}
97+
98+
return 1;
99+
}))
100+
.then(ClientCommandManager.literal("startPNTutorial")
101+
.executes(context -> {
102+
TutorialManager.startPNTutorial();
103+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startPNTutorialMessage"));
104+
return 1;
105+
}))
106+
.then(ClientCommandManager.literal("startCIKTutorial")
107+
.executes(context -> {
108+
TutorialManager.startCIKTutorial();
109+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startCIKTutorialMessage"));
110+
return 1;
111+
}))
112+
.then(ClientCommandManager.literal("startBankTutorial")
113+
.executes(context -> {
114+
TutorialManager.startBankTutorial();
115+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startBankTutorialMessage"));
116+
return 1;
117+
}))
118+
.then(ClientCommandManager.literal("startGalleryTutorial")
119+
.executes(context -> {
120+
TutorialManager.startGalleryTutorial();
121+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startGalleryTutorialMessage"));
122+
return 1;
123+
}))
124+
.then(ClientCommandManager.literal("startLawCourtTutorial")
125+
.executes(context -> {
126+
TutorialManager.startLawCourtTutorial();
127+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startLawTutorialMessage"));
128+
return 1;
129+
}))
130+
.then(ClientCommandManager.literal("startGoToHell")
131+
.executes(context -> {
132+
TutorialManager.startGoToHell();
133+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startHellTutorialMessage"));
134+
return 1;
135+
}))
136+
.then(ClientCommandManager.literal("startGoToEndAndTalkAboutTrade")
137+
.executes(context -> {
138+
TutorialManager.startGoToEndAndTalkAboutTrade();
139+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startEndTutorialMessage"));
140+
return 1;
141+
}))
142+
.then(ClientCommandManager.literal("goToFSB")
143+
.executes(context -> {
144+
TutorialManager.goToFSB();
145+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startFSBTutorialMessage"));
146+
return 1;
147+
}))
148+
.then(ClientCommandManager.literal("goToBiblioteka")
149+
.executes(context -> {
150+
TutorialManager.goToBiblioteka();
151+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startLibraryTutorialMessage"));
152+
return 1;
153+
}))
154+
.then(ClientCommandManager.literal("goToSpawn")
155+
.executes(context -> {
156+
TutorialManager.goToSpawn();
157+
context.getSource().sendFeedback(Text.translatable("text.spmhelper.startGoToSpawnTutorialMessage"));
88158
return 1;
89159
}))
90160
);
91161

92-
var aliasMainCommand = ClientCommandManager.literal("spmh")
93-
.then(ClientCommandManager.literal("auth")
94-
.executes(context -> dispatcher.execute("spmhelper auth", context.getSource()))
95-
)
96-
.then(ClientCommandManager.literal("status")
97-
.executes(context -> dispatcher.execute("spmhelper status", context.getSource()))
98-
)
99-
.then(ClientCommandManager.literal("tutorial")
100-
.executes(context -> dispatcher.execute("spmhelper tutorial", context.getSource()))
101-
);
162+
var aliasMainCommand = ClientCommandManager.literal("spmh").redirect(mainCommand.build());
102163

103164
var payCommand = ClientCommandManager.literal("pay")
104165
.then(ClientCommandManager.argument(Text.translatable("text.spmhelper.argumentForPayment.NickOrNumCard").getString(), StringArgumentType.string())
@@ -121,7 +182,6 @@ public static void registerCommands() {
121182
});
122183

123184

124-
125185
var deteciveCallCommand = createCallCommand("detective", Service.DETECTIVE);
126186
var fsbCallCommand = createCallCommand("fsb", Service.FSB);
127187
var bankerCallCommand = createCallCommand("banker", Service.BANKER);

src/main/java/zadudoder/spmhelper/tutorial/TutorialManager.java

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import net.minecraft.client.MinecraftClient;
44
import net.minecraft.text.Text;
5-
import net.minecraft.world.World;
65

76
import java.util.ArrayList;
87

@@ -13,11 +12,14 @@ public class TutorialManager {
1312

1413
public static ArrayList<TutorialPoint> checkpoints;
1514

16-
public static void startTutorial() {
15+
public static void preTutorial() {
1716
isEnabled = true;
1817
checkpoints = new ArrayList<>();
19-
StartTutorial();
18+
}
19+
20+
public static void startFullTutorial() {
2021
pullText("Включите частицы в настройках и направляйтесь в путь по ним.");
22+
startPNTutorial();
2123
}
2224

2325
public static void stopTutorial() {
@@ -32,14 +34,16 @@ public static void skipTutorial() {
3234
Runnable action = checkpoints.getLast().action;
3335
checkpoints.clear();
3436
action.run();
35-
pullText("Часть скипнута");
3637
}
3738

3839
private static void pullText(String text) {
3940
MinecraftClient.getInstance().player.sendMessage(Text.literal(text));
4041
}
4142

42-
private static void StartTutorial() {
43+
public static void startPNTutorial() {
44+
if (!isEnabled || checkpoints == null) {
45+
preTutorial();
46+
}
4347
checkpoints.add(new TutorialPoint(18, 81, 16, OVERWORLD, null, false));
4448
checkpoints.add(new TutorialPoint(14, 81, 22, OVERWORLD, null, false));
4549
checkpoints.add(new TutorialPoint(11, 81, 28, OVERWORLD, null, false));
@@ -51,7 +55,10 @@ private static void PNAction() {
5155
startCIKTutorial();
5256
}
5357

54-
private static void startCIKTutorial() {
58+
public static void startCIKTutorial() {
59+
if (!isEnabled || checkpoints == null) {
60+
preTutorial();
61+
}
5562
checkpoints.add(new TutorialPoint(10, 81, 30, OVERWORLD, null, false));
5663
checkpoints.add(new TutorialPoint(6, 81, 23, OVERWORLD, null, false));
5764
checkpoints.add(new TutorialPoint(0, 81, 19, OVERWORLD, null, false));
@@ -68,7 +75,10 @@ private static void CIKAction() {
6875
startBankTutorial();
6976
}
7077

71-
private static void startBankTutorial() {
78+
public static void startBankTutorial() {
79+
if (!isEnabled || checkpoints == null) {
80+
preTutorial();
81+
}
7282
checkpoints.add(new TutorialPoint(-31, 78, -17, OVERWORLD, null, false));
7383
checkpoints.add(new TutorialPoint(-30, 78, -26, OVERWORLD, null, false));
7484
checkpoints.add(new TutorialPoint(-29, 75, -34, OVERWORLD, null, false));
@@ -84,7 +94,10 @@ private static void BankAction() {
8494
startGalleryTutorial();
8595
}
8696

87-
private static void startGalleryTutorial() {
97+
public static void startGalleryTutorial() {
98+
if (!isEnabled || checkpoints == null) {
99+
preTutorial();
100+
}
88101
checkpoints.add(new TutorialPoint(-22, 72, -67, OVERWORLD, null, false));
89102
checkpoints.add(new TutorialPoint(-17, 71, -68, OVERWORLD, null, false));
90103
checkpoints.add(new TutorialPoint(-10, 71, -72, OVERWORLD, null, false));
@@ -108,7 +121,10 @@ private static void GalleryAction() {
108121
startLawCourtTutorial();
109122
}
110123

111-
private static void startLawCourtTutorial() {
124+
public static void startLawCourtTutorial() {
125+
if (!isEnabled || checkpoints == null) {
126+
preTutorial();
127+
}
112128
checkpoints.add(new TutorialPoint(59, 50, -166, OVERWORLD, null, false));
113129
checkpoints.add(new TutorialPoint(59, 50, -154, OVERWORLD, null, false)); // Написать поднимайтесь наверх
114130
checkpoints.add(new TutorialPoint(59, 64, -147, OVERWORLD, null, false));
@@ -129,12 +145,16 @@ private static void startLawCourtTutorial() {
129145
checkpoints.add(new TutorialPoint(16, 79, -27, OVERWORLD, TutorialManager::LawCourtAction, true));
130146

131147
}
148+
132149
private static void LawCourtAction() {
133150
pullText("Вы пришли в суд");
134151
startGoToHell();
135152
}
136153

137-
private static void startGoToHell() {
154+
public static void startGoToHell() {
155+
if (!isEnabled || checkpoints == null) {
156+
preTutorial();
157+
}
138158
checkpoints.add(new TutorialPoint(16, 79, -24, OVERWORLD, null, false));
139159
checkpoints.add(new TutorialPoint(10, 80, -18, OVERWORLD, null, false));
140160
checkpoints.add(new TutorialPoint(8, 81, -12, OVERWORLD, null, false));
@@ -153,7 +173,10 @@ private static void HellAction() {
153173
startGoToEndAndTalkAboutTrade();
154174
}
155175

156-
private static void startGoToEndAndTalkAboutTrade() {
176+
public static void startGoToEndAndTalkAboutTrade() {
177+
if (!isEnabled || checkpoints == null) {
178+
preTutorial();
179+
}
157180
checkpoints.add(new TutorialPoint(-17, 137, 14, NETHER, null, false));
158181
checkpoints.add(new TutorialPoint(-18, 136, 10, NETHER, null, false));
159182
checkpoints.add(new TutorialPoint(-23, 131, 0, NETHER, null, false));
@@ -205,7 +228,10 @@ private static void EndAction() {
205228
goToFSB();
206229
}
207230

208-
private static void goToFSB() {
231+
public static void goToFSB() {
232+
if (!isEnabled || checkpoints == null) {
233+
preTutorial();
234+
}
209235
checkpoints.add(new TutorialPoint(11, 81, 25, OVERWORLD, null, false));
210236
checkpoints.add(new TutorialPoint(12, 81, 32, OVERWORLD, null, false));
211237
checkpoints.add(new TutorialPoint(14, 80, 44, OVERWORLD, null, false));
@@ -226,7 +252,10 @@ private static void FSBAction() {
226252
goToBiblioteka();
227253
}
228254

229-
private static void goToBiblioteka() {
255+
public static void goToBiblioteka() {
256+
if (!isEnabled || checkpoints == null) {
257+
preTutorial();
258+
}
230259
checkpoints.add(new TutorialPoint(-1, 71, 110, OVERWORLD, null, false));
231260
checkpoints.add(new TutorialPoint(-7, 71, 109, OVERWORLD, null, false));
232261
checkpoints.add(new TutorialPoint(11, 71, 106, OVERWORLD, null, false));
@@ -271,7 +300,10 @@ private static void BibliotekaAction() {
271300
goToSpawn();
272301
}
273302

274-
private static void goToSpawn() {
303+
public static void goToSpawn() {
304+
if (!isEnabled || checkpoints == null) {
305+
preTutorial();
306+
}
275307
checkpoints.add(new TutorialPoint(-105, 71, 124, OVERWORLD, null, false));
276308
checkpoints.add(new TutorialPoint(-104, 71, 118, OVERWORLD, null, false));
277309
checkpoints.add(new TutorialPoint(-102, 71, 112, OVERWORLD, null, false));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package zadudoder.spmhelper.utils.types;
2+
3+
public enum VoiceType {
4+
MALE,
5+
FEMALE
6+
}

0 commit comments

Comments
 (0)