Skip to content

Commit dd49b78

Browse files
committed
Add pearlkb command
1 parent 917e286 commit dd49b78

File tree

1 file changed

+102
-9
lines changed

1 file changed

+102
-9
lines changed

src/main/java/capitalistspz/test/commands/Commands.java

Lines changed: 102 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public class Commands {
2323

2424
public static void register(CommandDispatcher<ServerCommandSource> dispatcher){
2525
// Argbuilder init
26-
LiteralArgumentBuilder<ServerCommandSource> knockbackCommand = literal("snowkb")
26+
LiteralArgumentBuilder<ServerCommandSource> snowKbCommand = literal("snowkb")
2727
.requires(executor -> executor.hasPermissionLevel(2));
2828

29-
knockbackCommand.then(literal("knockback")
29+
snowKbCommand.then(literal("knockback")
3030
.then(literal("set")
3131
.then(argument("mult", FloatArgumentType.floatArg())
3232
.executes(cmd -> {
@@ -92,7 +92,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher){
9292
)
9393
)
9494
);
95-
knockbackCommand.then(literal("traditional")
95+
snowKbCommand.then(literal("traditional")
9696
.then(literal("set")
9797
.then(argument("enable", BoolArgumentType.bool())
9898
.executes(cmd -> {
@@ -113,12 +113,12 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher){
113113
}))
114114
);
115115

116-
dispatcher.register(knockbackCommand);
116+
dispatcher.register(snowKbCommand);
117117

118-
LiteralArgumentBuilder<ServerCommandSource> eggKnockbackCommand = literal("eggkb")
118+
LiteralArgumentBuilder<ServerCommandSource> eggKbCommand = literal("eggkb")
119119
.requires(executor -> executor.hasPermissionLevel(2));
120120

121-
eggKnockbackCommand.then(literal("knockback")
121+
eggKbCommand.then(literal("knockback")
122122
.then(literal("set")
123123
.then(argument("mult", FloatArgumentType.floatArg())
124124
.executes(cmd -> {
@@ -184,7 +184,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher){
184184
)
185185
)
186186
);
187-
eggKnockbackCommand.then(literal("traditional")
187+
eggKbCommand.then(literal("traditional")
188188
.then(literal("set")
189189
.then(argument("enable", BoolArgumentType.bool())
190190
.executes(cmd -> {
@@ -204,8 +204,101 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher){
204204
return SnowballKB.config.eggTraditionalKb ? 1 : 0;
205205
}))
206206
);
207-
dispatcher.register(eggKnockbackCommand);
208-
207+
dispatcher.register(eggKbCommand);
208+
209+
LiteralArgumentBuilder<ServerCommandSource> pearlKbCommand = literal("pearlkb")
210+
.requires(executor -> executor.hasPermissionLevel(2));
211+
212+
pearlKbCommand.then(literal("knockback")
213+
.then(literal("set")
214+
.then(argument("mult", FloatArgumentType.floatArg())
215+
.executes(cmd -> {
216+
SnowballKB.config.pearlKbMultiplier = FloatArgumentType.getFloat(cmd, "mult");
217+
SendValueFeedback(cmd, kbSetFeedback, SnowballKB.config.pearlKbMultiplier);
218+
return Command.SINGLE_SUCCESS;
219+
})
220+
)
221+
)
222+
// Gets the current global knockback multiplier
223+
.then(literal("get")
224+
.executes(cmd -> {
225+
SendValueFeedback(cmd, kbGetFeedback, SnowballKB.config.pearlKbMultiplier);
226+
return (int)SnowballKB.config.pearlKbMultiplier;
227+
}).then(argument("scale", DoubleArgumentType.doubleArg())
228+
.executes(cmd -> {
229+
double scaledValue = DoubleArgumentType.getDouble(cmd, "scale") * SnowballKB.config.pearlKbMultiplier;
230+
SendValueFeedback(cmd, kbGetFeedback, scaledValue);
231+
return (int) scaledValue;
232+
}))
233+
)
234+
// Adds a value onto the current multiplier
235+
.then(literal("add")
236+
.then(argument("added_mult", FloatArgumentType.floatArg())
237+
.executes(cmd -> {
238+
SnowballKB.config.pearlKbMultiplier += FloatArgumentType.getFloat(cmd, "added_mult");
239+
SendValueFeedback(cmd, kbSetFeedback, SnowballKB.config.pearlKbMultiplier);
240+
return Command.SINGLE_SUCCESS;
241+
})
242+
)
243+
)
244+
)
245+
.then(literal("damage")
246+
.then(literal("set")
247+
.then(argument("damage", FloatArgumentType.floatArg())
248+
.executes(cmd -> {
249+
SnowballKB.config.pearlDamage = FloatArgumentType.getFloat(cmd, "damage");
250+
SendValueFeedback(cmd, dmgSetFeedback, SnowballKB.config.pearlDamage);
251+
return Command.SINGLE_SUCCESS;
252+
})
253+
)
254+
)
255+
// Gets the current global damage amount
256+
.then(literal("get")
257+
.executes(cmd -> {
258+
SendValueFeedback(cmd, dmgGetFeedback, SnowballKB.config.pearlDamage);
259+
return (int)SnowballKB.config.pearlDamage;
260+
}).then(argument("scale", DoubleArgumentType.doubleArg())
261+
.executes(cmd -> {
262+
double scaledValue = DoubleArgumentType.getDouble(cmd, "scale") * SnowballKB.config.pearlDamage;
263+
SendValueFeedback(cmd, dmgGetFeedback, scaledValue);
264+
return (int) scaledValue;
265+
}))
266+
)
267+
// Adds a value onto the current amount
268+
.then(literal("add")
269+
.then(argument("damage", FloatArgumentType.floatArg())
270+
.executes(cmd -> {
271+
SnowballKB.config.pearlDamage += FloatArgumentType.getFloat(cmd, "damage");
272+
SendValueFeedback(cmd, dmgSetFeedback, SnowballKB.config.pearlDamage);
273+
return Command.SINGLE_SUCCESS;
274+
})
275+
)
276+
)
277+
);
278+
pearlKbCommand.then(literal("traditional")
279+
.then(literal("set")
280+
.then(argument("enable", BoolArgumentType.bool())
281+
.executes(cmd -> {
282+
var enable = BoolArgumentType.getBool(cmd, "enable");
283+
if (enable){
284+
cmd.getSource().sendFeedback(() -> Text.literal("Enabled traditional knockback for ender pearls"), false);
285+
}
286+
else {
287+
cmd.getSource().sendFeedback(() -> Text.literal("Disabled traditional knockback for ender pearls"), false);
288+
}
289+
SnowballKB.config.pearlTraditionalKb = enable;
290+
return Command.SINGLE_SUCCESS;
291+
})))
292+
.then(literal("get")
293+
.executes(cmd -> {
294+
cmd.getSource().sendFeedback(() -> Text.literal("Traditional knockback for ender pearls is " + (SnowballKB.config.pearlTraditionalKb ? "enabled" : "disabled")), false);
295+
return SnowballKB.config.pearlTraditionalKb ? 1 : 0;
296+
}))
297+
);
298+
299+
dispatcher.register(pearlKbCommand);
300+
301+
209302
LiteralArgumentBuilder<ServerCommandSource> bobber = literal("bobberpull").requires(executor -> executor.hasPermissionLevel(2));
210303

211304
bobber.then(literal("set").then(argument("value", FloatArgumentType.floatArg()).executes(cmd -> {

0 commit comments

Comments
 (0)