Skip to content

Commit bd4698c

Browse files
committed
feat: add some checkpoints for TutorialManager, refactor classes, add clickable text when added card
1 parent bca3402 commit bd4698c

10 files changed

Lines changed: 152 additions & 43 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ yarn_mappings=1.21+build.9
88
loader_version=0.16.14
99
loom_version=1.10-SNAPSHOT
1010
# Mod Properties
11-
mod_version=0.6.0
11+
mod_version=0.7.0
1212
maven_group=zadudoder.spmhelper
1313
archives_base_name=spmhelper
1414
mod_menu_version=11.0.3

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,43 @@
55
import net.fabricmc.loader.api.FabricLoader;
66
import net.minecraft.client.MinecraftClient;
77
import net.minecraft.text.ClickEvent;
8+
import net.minecraft.text.HoverEvent;
89
import net.minecraft.text.Text;
910
import net.minecraft.util.Formatting;
1011
import zadudoder.spmhelper.SPmHelper;
1112
import zadudoder.spmhelper.Screen.Pays.AddCardScreen;
13+
import zadudoder.spmhelper.tutorial.TutorialManager;
1214
import zadudoder.spmhelper.utils.Misc;
1315
import zadudoder.spmhelper.utils.SPmHelperApi;
1416

1517
public class ChatEventHandler {
1618

1719
public static void registerChatEventHandler() {
1820
ClientReceiveMessageEvents.GAME.register((message, overlay) -> {
19-
if (message.getString().contains("Управление картой [Копир. токен] [Копир. айди]") && message.getSiblings().get(0).getSiblings().get(0).getStyle().getClickEvent().getAction() == ClickEvent.Action.COPY_TO_CLIPBOARD) {
21+
if (message.getString().contains("Управление картой [Копир. токен] [Копир. айди]") &&
22+
message.getSiblings().get(0).getSiblings().get(0).getStyle().getClickEvent().getAction() == ClickEvent.Action.COPY_TO_CLIPBOARD) {
23+
2024
String token = message.getSiblings().get(0).getSiblings().get(0).getStyle().getClickEvent().getValue();
2125
String id = message.getSiblings().get(0).getSiblings().get(1).getStyle().getClickEvent().getValue();
2226
String name = message.getString().substring(1);
2327
name = name.substring(0, name.indexOf(']'));
2428
String finalName = name;
29+
2530
MinecraftClient.getInstance().
2631
execute(() -> MinecraftClient.getInstance().setScreen(new AddCardScreen(id, token, finalName)));
32+
33+
Text addCard = Text.translatable("text.spmhelper.addCardOpenScreen", finalName)
34+
.styled(style -> style
35+
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
36+
String.format("/spmhelper addcard %s %s %s", id, token, finalName)))
37+
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
38+
Text.translatable("text.spmhelper.addCardOpenScreen.hover_tip", finalName)))
39+
);
40+
41+
MinecraftClient.getInstance().player.sendMessage(
42+
Text.translatable("", addCard),
43+
false
44+
);
2745
}
2846
});
2947

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
import net.minecraft.client.MinecraftClient;
1010
import net.minecraft.text.Text;
1111
import zadudoder.spmhelper.Screen.Calls.ServiceAcceptScreen;
12+
import zadudoder.spmhelper.Screen.Pays.AddCardScreen;
1213
import zadudoder.spmhelper.Screen.Pays.PayScreen;
1314
import zadudoder.spmhelper.config.SPmHelperConfig;
15+
import zadudoder.spmhelper.tutorial.TutorialManager;
1416
import zadudoder.spmhelper.utils.SPmHelperApi;
1517
import zadudoder.spmhelper.utils.types.Service;
1618

@@ -46,6 +48,20 @@ public static void registerCommands() {
4648
});
4749
return 1;
4850
})
51+
).then(ClientCommandManager.literal("addcard")
52+
.then(ClientCommandManager.argument("id", StringArgumentType.string())
53+
.then(ClientCommandManager.argument("token", StringArgumentType.string())
54+
.then(ClientCommandManager.argument("name", StringArgumentType.string())
55+
.executes(context -> {
56+
String id = StringArgumentType.getString(context, "id");
57+
String token = StringArgumentType.getString(context, "token");
58+
String name = StringArgumentType.getString(context, "name");
59+
60+
MinecraftClient.getInstance().send(() -> {
61+
MinecraftClient.getInstance().setScreen(new AddCardScreen(id, token, name));
62+
});
63+
return 1;
64+
}))))
4965
);
5066

5167
var aliasMainCommand = ClientCommandManager.literal("spmh")
@@ -123,4 +139,4 @@ private static LiteralArgumentBuilder<FabricClientCommandSource> createCallComma
123139
});
124140
return callCommand;
125141
}
126-
}
142+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package zadudoder.spmhelper.events;
22

3+
import com.google.common.base.Function;
34
import net.fabricmc.api.EnvType;
45
import net.fabricmc.api.Environment;
6+
import net.minecraft.text.ClickEvent;
7+
import zadudoder.spmhelper.tutorial.ParticleManager;
58

69
@Environment(EnvType.CLIENT)
710
public class ModEvents {

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

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/main/java/zadudoder/spmhelper/events/ParticleManager.java renamed to src/main/java/zadudoder/spmhelper/tutorial/ParticleManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package zadudoder.spmhelper.events;
1+
package zadudoder.spmhelper.tutorial;
22

33
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
44
import net.minecraft.entity.player.PlayerEntity;
@@ -23,13 +23,13 @@ public static void registerParticleManager() {
2323
BlockPos deletePos = null;
2424
for (int index = 0; index < TutorialManager.checkpoints.size(); index++) {
2525
BlockPos checkpointPosition = TutorialManager.checkpoints.get(index).pos;
26-
ParticleEffect particleEffect = ParticleTypes.CRIT;
27-
if (TutorialManager.checkpoints.get(index).action != null) {
26+
ParticleEffect particleEffect = ParticleTypes.END_ROD;
27+
if (TutorialManager.checkpoints.get(index).last) {
2828
particleEffect = ParticleTypes.FLAME;
2929
}
3030
world.addParticle(
3131
particleEffect,
32-
checkpointPosition.getX(), checkpointPosition.getY(), checkpointPosition.getZ(),
32+
checkpointPosition.getX() + 0.5, checkpointPosition.getY(), checkpointPosition.getZ() + 0.5,
3333
0, 0.1, 0
3434
);
3535
if (Misc.getDistance(player.getBlockPos(), checkpointPosition) <= 1) {
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package zadudoder.spmhelper.tutorial;
2+
3+
import net.minecraft.client.MinecraftClient;
4+
import net.minecraft.text.Text;
5+
6+
import java.util.ArrayList;
7+
8+
public class TutorialManager {
9+
public static boolean isEnabled;
10+
11+
public static ArrayList<TutorialPoint> checkpoints;
12+
13+
public static void startTutorial() {
14+
isEnabled = true;
15+
checkpoints = new ArrayList<>();
16+
StartTutorial();
17+
pullText("Включите частицы в настройках и направляйтесь в путь по ним.");
18+
}
19+
20+
public static void stopTutorial() {
21+
isEnabled = false;
22+
}
23+
24+
private static void pullText(String text) {
25+
MinecraftClient.getInstance().player.sendMessage(Text.literal(text));
26+
}
27+
28+
private static void StartTutorial(){
29+
checkpoints.add(new TutorialPoint(18, 81, 16,null, false));
30+
checkpoints.add(new TutorialPoint(14, 81, 22,null, false));
31+
checkpoints.add(new TutorialPoint(11, 81, 28,null, false));
32+
checkpoints.add(new TutorialPoint((int) 7.5, 81, 33, TutorialManager::PNAction, true));
33+
}
34+
35+
private static void PNAction() {
36+
pullText("Вы пришли в палатку новичков");
37+
startBankTutorial();
38+
}
39+
40+
private static void startBankTutorial() {
41+
checkpoints.add(new TutorialPoint(10, 81, 30, null, false));
42+
checkpoints.add(new TutorialPoint(6, 81, 23, null, false));
43+
checkpoints.add(new TutorialPoint(0, 81, 19, null, false));
44+
checkpoints.add(new TutorialPoint(-7, 81, 16, null, false));
45+
checkpoints.add(new TutorialPoint(-16, 79, 16, null, false));
46+
checkpoints.add(new TutorialPoint(-24, 79, 12, null, false));
47+
checkpoints.add(new TutorialPoint(-32, 78, 8, null, false));
48+
checkpoints.add(new TutorialPoint(-36, 79, 14, TutorialManager::BankAction, true));
49+
}
50+
51+
private static void BankAction() {
52+
pullText("Вы пришли в банк");
53+
startCIKTutorial();
54+
}
55+
56+
private static void startCIKTutorial() {
57+
checkpoints.add(new TutorialPoint(-33, 79, 9, null, false));
58+
checkpoints.add(new TutorialPoint(-32, 78, 2, null, false));
59+
checkpoints.add(new TutorialPoint(-31, 78, -8, TutorialManager::CIKAction, true));
60+
}
61+
62+
private static void CIKAction() {
63+
pullText("Вы пришли в Центр Избирательной Комиссии (ЦИК)");
64+
startGalleryTutorial();
65+
}
66+
67+
private static void startGalleryTutorial() {
68+
checkpoints.add(new TutorialPoint(-31, 78, -17,null, false));
69+
checkpoints.add(new TutorialPoint(-30, 78, -26,null, false));
70+
checkpoints.add(new TutorialPoint(-29, 75, -34,null, false));
71+
checkpoints.add(new TutorialPoint(-24, 73, -41,null, false));
72+
checkpoints.add(new TutorialPoint(-17, 72, -48,null, false));
73+
checkpoints.add(new TutorialPoint(-10, 72, -56,null, false));
74+
checkpoints.add(new TutorialPoint(-6, 71, -63,null, false));
75+
checkpoints.add(new TutorialPoint(-3, 71, -75,null, false));
76+
checkpoints.add(new TutorialPoint(2, 70, -81,null, false));
77+
checkpoints.add(new TutorialPoint(11, 70, -88,null, false));
78+
checkpoints.add(new TutorialPoint(20, 68, -93,null, false));
79+
checkpoints.add(new TutorialPoint(29, 64, -97,null, false));
80+
checkpoints.add(new TutorialPoint(37, 66, -104,null, false));
81+
checkpoints.add(new TutorialPoint(44, 65, -111,null, false));
82+
checkpoints.add(new TutorialPoint(54, 63, -119,null, false));
83+
checkpoints.add(new TutorialPoint(59, 63, -126,null, false));
84+
checkpoints.add(new TutorialPoint(59, 64, -139,null, false));
85+
checkpoints.add(new TutorialPoint(59, 64, -147,null, false));
86+
checkpoints.add(new TutorialPoint(59, 50, -154,null, false));
87+
checkpoints.add(new TutorialPoint(59, 50, -166, TutorialManager::GalleryAction, true));
88+
}
89+
90+
private static void GalleryAction() {
91+
pullText("Вы пришли в галерею.");
92+
startLawCourtTutorial();
93+
}
94+
95+
private static void startLawCourtTutorial() {
96+
checkpoints.add(new TutorialPoint(-31, 78, -17, null, false));
97+
}
98+
99+
}

src/main/java/zadudoder/spmhelper/utils/types/TutorialPoint.java renamed to src/main/java/zadudoder/spmhelper/tutorial/TutorialPoint.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
package zadudoder.spmhelper.utils.types;
1+
package zadudoder.spmhelper.tutorial;
22

33
import net.minecraft.util.math.BlockPos;
44

55
public class TutorialPoint {
66
public BlockPos pos;
77
public Runnable action;
8+
public boolean last;
89

9-
public TutorialPoint(int x, int y, int z, Runnable action) {
10+
public TutorialPoint(int x, int y, int z, Runnable action, Boolean last) {
1011
this.pos = new BlockPos(x, y, z);
1112
this.action = action;
13+
this.last = last;
1214
}
1315
}

src/main/java/zadudoder/spmhelper/utils/Misc.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
public class Misc {
1515
public static List<String> ALLOWED_SERVERS = Arrays.asList(
1616
"spm.spworlds.org",
17-
"spm.spworlds.ru"
17+
"spm.spworlds.ru",
18+
"sp.spworlds.ru" // Убрать в конечной версии, для теста, пока у Zadudoderr есть проходка
1819
);
1920

2021
public static boolean isNumeric(String str) {

src/main/resources/assets/spmhelper/lang/ru_ru.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@
139139
"text.spmhelper.updateMod_message_betweenPart": ". Доступна новая: ",
140140
"text.spmhelper.updateMod_message_lastPart": ". Нажмите на текст, чтобы перейти на Modrinth. ",
141141

142+
"text.spmhelper.addCardOpenScreen": "§a[SPmHelper]: Нажмите на текст, чтобы добавить карту %s",
143+
"text.spmhelper.addCardOpenScreen.hover_tip": "Нажмите, чтобы перейти к добавлению карты %s",
144+
142145
"text.spmhelper.auth_FeedBackMessage": "§a[SPmHelper]: Токен активен! Новая авторизация не нужна.",
143146
"text.spmhelper.status_FeedBackMessageCase200": "§a[SPmHelper]: Токен работает",
144147
"text.spmhelper.status_FeedBackMessageCase400": "§c[SPmHelper]: Токен недействителен или отсутсвует",

0 commit comments

Comments
 (0)