use of com.builtbroken.mc.testing.junit.testers.DummyCommandSender in project ICBM-Classic by BuiltBrokenModding.
the class CommandUtilsTest method getNumber_playerTilde_offset.
@Test
void getNumber_playerTilde_offset() throws WrongUsageException {
final DummyCommandSender dummyCommandSender = new DummyCommandSender(testManager);
double result = CommandUtils.getNumber(dummyCommandSender, "~3", 100);
Assertions.assertEquals(103.0, result);
}
use of com.builtbroken.mc.testing.junit.testers.DummyCommandSender in project ICBM-Classic by BuiltBrokenModding.
the class CommandEntryPointTest method getTabCompletions_nothing.
@Test
void getTabCompletions_nothing() {
final DummyCommandSender dummyCommandSender = new DummyCommandSender(testManager);
List<String> output = commandHandler.getTabCompletions(testManager.getServer(), dummyCommandSender, new String[] { "a" }, null);
Assertions.assertEquals(0, output.size());
}
use of com.builtbroken.mc.testing.junit.testers.DummyCommandSender in project ICBM-Classic by BuiltBrokenModding.
the class CommandLagTest method command_removeMissiles.
@Test
void command_removeMissiles() {
dummyCommandSender.position = new Vec3d(100, 20, 100);
// Spawn some sheep to act as decoys
TestUtils.sheep(testManager.getWorld(), 100, 20, 100);
TestUtils.sheep(testManager.getWorld(), 100, 30, 100);
TestUtils.sheep(testManager.getWorld(), 100, 40, 100);
TestUtils.missile(testManager.getWorld(), 100, 10, 100);
TestUtils.missile(testManager.getWorld(), -100, 10, -100);
// Validate start condition
Assertions.assertEquals(3, testManager.getWorld().loadedEntityList.stream().filter(e -> e instanceof EntitySheep).count(), "Should start with 3 sheep");
Assertions.assertEquals(2, testManager.getWorld().loadedEntityList.stream().filter(e -> e instanceof EntityMissile).count(), "Should start with 2 missiles");
// Trigger command
Assertions.assertDoesNotThrow(() -> command.handleCommand(testManager.getServer(), dummyCommandSender, new String[0]));
// Validate output
Assertions.assertEquals(1, dummyCommandSender.messages.size(), "Should have 1 chat message");
Assertions.assertEquals(CommandLag.TRANSLATION_LAG_REMOVE, dummyCommandSender.pollLastMessage(), "Should get translation");
// Should still have 3 sheep
Assertions.assertEquals(3, testManager.getWorld().loadedEntityList.stream().filter(e -> e instanceof EntitySheep).count(), "Should end with 3 sheep");
Assertions.assertEquals(0, testManager.getWorld().loadedEntityList.stream().filter(e -> e instanceof EntityMissile).filter(Entity::isEntityAlive).count(), "Should end with 0 missiles");
}
use of com.builtbroken.mc.testing.junit.testers.DummyCommandSender in project ICBM-Classic by BuiltBrokenModding.
the class CommandBlastListTest method listBlasts.
@Test
void listBlasts() throws CommandException {
// Setup blast registry
ICBMClassicAPI.EXPLOSIVE_REGISTRY = new ExplosiveRegistry();
ICBMClassicAPI.EXPLOSIVE_REGISTRY.register(new ResourceLocation("tree", "bat"), EnumTier.FOUR, () -> null);
ICBMClassicAPI.EXPLOSIVE_REGISTRY.register(new ResourceLocation("tree", "cat"), EnumTier.FOUR, () -> null);
ICBMClassicAPI.EXPLOSIVE_REGISTRY.register(new ResourceLocation("bo", "fat"), EnumTier.FOUR, () -> null);
((ExplosiveRegistry) ICBMClassicAPI.EXPLOSIVE_REGISTRY).lockNewExplosives();
final DummyCommandSender dummyCommandSender = new DummyCommandSender(testManager);
// Trigger
commandBlastList.handleCommand(testManager.getServer(), dummyCommandSender, new String[0]);
// Should only have 1 message to sender
Assertions.assertEquals(1, dummyCommandSender.messages.size());
Assertions.assertEquals("Explosive Types: bo:fat, tree:bat, tree:cat", dummyCommandSender.messages.poll().getUnformattedText());
// Cleanup
ICBMClassicAPI.EXPLOSIVE_REGISTRY = null;
}
Aggregations