1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
package de.hype.bbsentials.client.Commands;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import de.hype.bbsentials.chat.Chat;
import de.hype.bbsentials.client.BBsentials;
import de.hype.bbsentials.constants.enviromentShared.ChChestItems;
import de.hype.bbsentials.constants.enviromentShared.Islands;
import de.hype.bbsentials.constants.enviromentShared.MiningEvents;
import de.hype.bbsentials.packets.AbstractPacket;
import de.hype.bbsentials.packets.packets.*;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.fabric.api.event.Event;
import net.minecraft.command.CommandSource;
import java.util.ArrayList;
import java.util.List;
import static de.hype.bbsentials.client.BBsentials.*;
public class CommandsOLD {
public CommandsOLD() {
Event<ClientCommandRegistrationCallback> event = ClientCommandRegistrationCallback.EVENT;
// event.register((dispatcher, registryAccess) -> {
// dispatcher.register(ClientCommandManager.literal("warp").then(ClientCommandManager.argument("destination", StringArgumentType.string()).suggests((context, builder) -> {
// // Provide tab-completion options for menu subfolder
// return CommandSource.suggestMatching(new String[]{"desert", "hub", "dhub", "nether", "isle", "wizard", "portal", "mines", "forge", "ch", "crystals", "nucleus", "end", "drag", "void", "castle", "howl", "park", "jungle", "nest", "arachne", "spider", "deep", "barn", "home", "kuurda", "wasteland", "dragontail", "scarleton", "smold", "garden", "da", "crypt", "museum", "trapper", "dungeon_hub"}, builder);
// }).executes((context) -> {
// // Handle "variableName" and "variableValue" logic here
// String destination = StringArgumentType.getString(context, "destination");
// getConfig().sender.addSendTask("/warp " + destination, 0);
// return 1;
// })));
// }); //warp test
event.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("creport")
.then(ClientCommandManager.argument("Player_Name", StringArgumentType.string())
.executes((context) -> {
String playerName = StringArgumentType.getString(context, "Player_Name");
getConfig().sender.addSendTask("/creport " + playerName, 0);
getConfig().addReported(playerName);
return 1;
})));
});//creport helper → no double report during same launch
// event.register((dispatcher, registryAccess) -> {
// dispatcher.register(ClientCommandManager.literal("hp").then(ClientCommandManager.literal("accept").then(ClientCommandManager.argument("player", StringArgumentType.string()).executes((context) -> {
// String player = StringArgumentType.getString(context, "player");
// getConfig().sender.addImmediateSendTask("/party accept " + player);
// return 1;
// }))).then(ClientCommandManager.literal("chat").executes((context) -> {
// getConfig().sender.addImmediateSendTask("/party chat");
// return 1;
// })).then(ClientCommandManager.literal("demote").then(ClientCommandManager.argument("player", StringArgumentType.string()).suggests((context, builder) -> {
// // Provide tab-completion options for menu subfolder
// return CommandSource.suggestMatching(getConfig().getPlayersInParty(), builder);
// }).executes((context) -> {
// String player = StringArgumentType.getString(context, "player");
// getConfig().sender.addImmediateSendTask("/party demote " + player);
// return 1;
// }))).then(ClientCommandManager.literal("disband").executes((context) -> {
// getConfig().sender.addImmediateSendTask("/party disband");
// return 1;
// })).then(ClientCommandManager.literal("kick").then(ClientCommandManager.argument("player", StringArgumentType.string()).suggests((context, builder) -> {
// // Provide tab-completion options for menu subfolder
// return CommandSource.suggestMatching(getConfig().getPlayersInParty(), builder);
// }).executes((context) -> {
// String player = StringArgumentType.getString(context, "player");
// getConfig().sender.addImmediateSendTask("/party kick " + player);
// return 1;
// }))).then(ClientCommandManager.literal("kickoffline").executes((context) -> {
// getConfig().sender.addImmediateSendTask("/party kickoffline");
// return 1;
// })).then(ClientCommandManager.literal("leave").executes((context) -> {
// getConfig().sender.addImmediateSendTask("/party leave");
// return 1;
// })).then(ClientCommandManager.literal("list").executes((context) -> {
// getConfig().sender.addImmediateSendTask("/party list");
// return 1;
// })).then(ClientCommandManager.literal("mute").executes((context) -> {
// getConfig().sender.addImmediateSendTask("/party mute");
// return 1;
// })).then(ClientCommandManager.literal("poll").then(ClientCommandManager.argument("question/answer/answer/answer", StringArgumentType.greedyString()).executes((context) -> {
// String questionAndAnswers = StringArgumentType.getString(context, "question answer answer (answer)");
// getConfig().sender.addImmediateSendTask("/party poll " + questionAndAnswers);
// return 1;
// }))).then(ClientCommandManager.literal("private").executes((context) -> {
// getConfig().sender.addImmediateSendTask("/party private");
// return 1;
// })).then(ClientCommandManager.literal("promote").then(ClientCommandManager.argument("player", StringArgumentType.string()).suggests((context, builder) -> {
// // Provide tab-completion options for menu subfolder
// return CommandSource.suggestMatching(getConfig().getPlayersInParty(), builder);
// }).executes((context) -> {
// String player = StringArgumentType.getString(context, "player");
// getConfig().sender.addImmediateSendTask("/party promote " + player);
// return 1;
// }))).then(ClientCommandManager.literal("setting").then(ClientCommandManager.literal("allinvite")).executes((context) -> {
// String setting = StringArgumentType.getString(context, "setting");
// getConfig().sender.addImmediateSendTask("/party setting " + setting);
// return 1;
// })
//
// ).then(ClientCommandManager.literal("transfer").then(ClientCommandManager.argument("player", StringArgumentType.string()).suggests((context, builder) -> {
// // Provide tab-completion options for menu subfolder
// return CommandSource.suggestMatching(getConfig().getPlayersInParty(), builder);
// }).executes((context) -> {
// String player = StringArgumentType.getString(context, "player");
// getConfig().sender.addImmediateSendTask("/party transfer " + player);
// return 1;
// }))).then(ClientCommandManager.literal("warp").executes((context) -> {
// getConfig().sender.addImmediateSendTask("/party warp");
// return 1;
// })).executes(context -> {
// getConfig().sender.addImmediateSendTask("/p");
// return 1;
// }));
// }); //party test
event.register((dispatcher, registryAccess) -> {
miningEvent(dispatcher, "goblinraid", MiningEvents.GOBLIN_RAID);
});/*goblinraid*/
event.register((dispatcher, registryAccess) -> {
miningEvent(dispatcher, "2xpowder", MiningEvents.DOUBLE_POWDER);
});/*2xpowder*/
event.register((dispatcher, registryAccess) -> {
miningEvent(dispatcher, "bettertogether", MiningEvents.BETTER_TOGETHER);
});/*b2g*/
event.register((dispatcher, registryAccess) -> {
miningEvent(dispatcher, "raffle", MiningEvents.RAFFLE);
});/*raffle*/
event.register((dispatcher, registryAccess) -> {
miningEvent(dispatcher, "gonewiththewind", MiningEvents.GONE_WITH_THE_WIND);
});/*gonewiththewind*/
event.register((dispatcher, registryAccess) -> {
miningEvent(dispatcher, "mithrilgourmand", MiningEvents.MITHRIL_GOURMAND);
});/*gonewiththewind*/
event.register((dispatcher, registryAccess) -> {
dispatcher.register(ClientCommandManager.literal("chchest")
.then(ClientCommandManager.argument("Item", StringArgumentType.string())
.suggests((context, builder) -> {
String[] items = new String[]{"PrehistoricEgg", "Pickonimbus2000", "ElectronTransmitter", "FTX3070", "RobotronReflector", "ControlSwitch", "SyntheticHeart", "SuperliteMotor", "BlueGoblinEgg", "YellowGoblinEgg", "FlawlessAmberGemstone", "FlawlessJadeGemstone", "FlawlessSapphireGemstone", "FlawlessRubyGemstone", "FlawlessAmethystGemstone", "JungleHeart", "FlawlessTopazGemstone", "FlawlessJasperGemstone"};
String input = builder.getRemaining().toLowerCase();
int lastSemicolonIndex = input.lastIndexOf(";");
List<String> suggestions = new ArrayList<>();
if (lastSemicolonIndex >= 0) {
String inputBeforeSemicolon = input.substring(0, lastSemicolonIndex + 1); // Include the semicolon
for (String item : items) {
suggestions.add(inputBeforeSemicolon + item);
}
}
return CommandSource.suggestMatching(suggestions, builder);
})
.then(ClientCommandManager.argument("X", IntegerArgumentType.integer())
.then(ClientCommandManager.argument("Y", IntegerArgumentType.integer())
.then(ClientCommandManager.argument("Z", IntegerArgumentType.integer())
.then(ClientCommandManager.argument("ContactWay", StringArgumentType.string())
.suggests(((context, builder) -> {
return CommandSource.suggestMatching(new String[]{"/msg " + getConfig().getUsername() + " bb:party me", "/p join " + config.getUsername()}, builder);
}))
.executes((context) -> {
String item = StringArgumentType.getString(context, "Item");
int x = IntegerArgumentType.getInteger(context, "X");
int y = IntegerArgumentType.getInteger(context, "Y");
int z = IntegerArgumentType.getInteger(context, "Z");
String contactWay = StringArgumentType.getString(context, "ContactWay");
bbserver.sendPacket(new ChChestPackage("", ChChestItems.getItem(item.split(";")), x + "" + y + "" + z, contactWay, ""));
return 1;
}
)
)
)
)
)
)
);
}); /*chchest*/
event.register((dispatcher, registryAccess) -> {
dispatcher.register(
ClientCommandManager.literal("bbserver")
.then(ClientCommandManager.argument("Message", StringArgumentType.greedyString())
.executes((context) -> {
String message = StringArgumentType.getString(context, "Message");
if (message.equals("bb:reconnect")) {
BBsentials.connectToBBserver();
}
else {
BBsentials.bbserver.sendMessage(message);
}
return 1;
})
)
);
});/*BBserver*/
event.register((dispatcher, registryAccess) -> {
dispatcher.register(
ClientCommandManager.literal("bc")
.then(ClientCommandManager.argument("Message to Bingo Chat", StringArgumentType.greedyString())
.executes((context) -> {
String message = StringArgumentType.getString(context, "Message to Bingo Chat");
sendPacket(new BingoChatMessagePacket("", "", message, 0));
return 1;
})
)
);
});/*BincoChatShort*/
event.register((dispatcher, registryAccess) -> {
dispatcher.register(
ClientCommandManager.literal("bingochat")
.then(ClientCommandManager.argument("Message to Bingo Chat", StringArgumentType.greedyString())
.executes((context) -> {
String message = StringArgumentType.getString(context, "Message to Bingo Chat");
sendPacket(new BingoChatMessagePacket("", "", message, 0));
return 1;
})
)
);
});/*BingoChatLong*/
if (getConfig().bbsentialsRoles != null) {
if (getConfig().hasBBRoles("mod")) {
event.register((dispatcher, registryAccess) -> {
dispatcher.register(
ClientCommandManager.literal("bannounce")
.then(ClientCommandManager.argument("message", StringArgumentType.greedyString())
.executes((context) -> {
String message = StringArgumentType.getString(context, "message");
sendCommand("?announce " + message);
return 1;
})
)
);
});/*bAnnounce*/
event.register((dispatcher, registryAccess) -> {
dispatcher.register(
ClientCommandManager.literal("bmute")
.then(ClientCommandManager.argument("message", StringArgumentType.greedyString())
.executes((context) -> {
String message = StringArgumentType.getString(context, "message");
sendCommand("?mute " + message);
return 1;
})
)
);
});/*bmute*/
event.register((dispatcher, registryAccess) -> {
dispatcher.register(
ClientCommandManager.literal("bban")
.then(ClientCommandManager.argument("message", StringArgumentType.greedyString())
.executes((context) -> {
String message = StringArgumentType.getString(context, "message");
sendCommand("?bban " + message);
return 1;
})
)
);
});/*bmute*/
}
if (getConfig().hasBBRoles("splasher")) {
event.register((dispatcher, registryAccess) -> {
dispatcher.register(
ClientCommandManager.literal("splashAnnounce")
.then(ClientCommandManager.argument("Hub", IntegerArgumentType.integer(1, 28))
.then(ClientCommandManager.argument("location", StringArgumentType.string())
.suggests((context, builder) -> {
return CommandSource.suggestMatching(new String[]{"kat", "bea", "guild-house"}, builder);
})
.then(ClientCommandManager.argument("lasswaste", StringArgumentType.string())
.suggests((context, builder) -> {
return CommandSource.suggestMatching(new String[]{"true", "false"}, builder);
})
.then(ClientCommandManager.argument("extramessage", StringArgumentType.greedyString())
.executes((context) -> {
int hub = IntegerArgumentType.getInteger(context, "Hub");
String extramessage = StringArgumentType.getString(context, "extramessage");
String location = StringArgumentType.getString(context, "location");
boolean lessWaste = Boolean.parseBoolean(StringArgumentType.getString(context, "lasswaste"));
sendPacket(new SplashNotifyPacket(hub, config.getUsername(), location, Islands.HUB, extramessage, lessWaste));
return 1;
})
)
.executes((context) -> {
int hub = IntegerArgumentType.getInteger(context, "Hub");
String location = "bea";
boolean lessWaste = Boolean.parseBoolean(StringArgumentType.getString(context, "lasswaste"));
sendPacket(new SplashNotifyPacket(hub, config.getUsername(), location, Islands.HUB, "", lessWaste));
return 1;
})
))
.executes((context) -> {
int hub = IntegerArgumentType.getInteger(context, "Hub");
String location = StringArgumentType.getString(context, "location");
sendPacket(new SplashNotifyPacket(hub, config.getUsername(), location, Islands.HUB, "", true));
return 1;
})
)
);
});/*SplashAnnounce*/
}
else {
}
}
}
private static void simpleCommand(CommandDispatcher<FabricClientCommandSource> dispatcher, String commandName, String[] parameters) {
dispatcher.register(
ClientCommandManager.literal(commandName)
.executes((context) -> {
BBsentials.bbserver.sendPacket(new InternalCommandPacket(commandName, parameters));
return 1;
})
);
}
private static void miningEvent(CommandDispatcher<FabricClientCommandSource> dispatcher, String commandName, MiningEvents event) {
dispatcher.register(
ClientCommandManager.literal(commandName)
.executes((context) -> {
try {
BBsentials.bbserver.sendPacket(new MiningEventPacket(event,//TODO get the island
config.getUsername(), Islands.HUB));
} catch (Exception e) {
Chat.sendPrivateMessageToSelf("§c" + e.getMessage());
}
return 1;
})
);
}
public void sendCommand(String message) {
BBsentials.bbserver.sendCommand(message);
}
public <E extends AbstractPacket> void sendPacket(E packet) {
BBsentials.bbserver.sendPacket(packet);
}
}
|