1.17.x PlayerDeathEvent Trigger

Discussion in 'Spigot Plugin Development' started by Tooni_Warri, Jul 11, 2021.

  1. For creating my new plugin, I'm getting into unit testing all different aspects and events on my plugin. My goal is to trigger/create messages on these events to test them. This way, I started learning MockBukkit. (https://github.com/MockBukkit)

    My goal was to set the player to death, but It seems I can only get the status (which is a boolean) if he is dead or not, but cannot set his status? I already know I can damage him the real case, but I'm interested how to trigger the event. My testing code already looks like this:

    Code (Text):
    @Before
        public void setUp()
        {
            server = MockBukkit.mock();
            plugin = (BetterMonitor) MockBukkit.load(BetterMonitor.class);

        }


        @Test
        public void addPlayerTest()
        {
            server.addPlayer("NewPlayer");
        }

        @Test
        public void onPlayerDeathTest()
        {
            server.addPlayer("DeathPlayer");
            Player player = server.getPlayer("DeathPlayer");
            assert player != null;
            player.damage(100);
        }


        @After
        public void tearDown()
        {
            MockBukkit.unmock();
        }