Best MockBukkit code snippet using be.seeseemelk.mockbukkit.WorldBorderMock.getCenter
Source:WorldBorderMockTest.java
...44 assertEquals(0.2, worldBorderMock.getDamageAmount());45 assertEquals(5.0, worldBorderMock.getDamageBuffer());46 assertEquals(5, worldBorderMock.getWarningDistance());47 assertEquals(15, worldBorderMock.getWarningTime());48 assertEquals(new Location(world, 0, 0, 0), worldBorderMock.getCenter());49 }50 @Test51 void setSize()52 {53 worldBorderMock.setSize(10);54 assertEquals(10, worldBorderMock.getSize());55 }56 @Test57 void setSize_OverTimeGoingDown_CompleteAtFullTime()58 {59 worldBorderMock.setSize(100);60 worldBorderMock.setSize(50, 10);61 server.getScheduler().performTicks(10 * 20);62 assertEquals(50, worldBorderMock.getSize());63 }64 @Test65 void setSize_OverTimeGoingUp_CompleteAtFullTime()66 {67 worldBorderMock.setSize(50);68 worldBorderMock.setSize(100, 10);69 server.getScheduler().performTicks(10 * 20);70 assertEquals(100, worldBorderMock.getSize());71 }72 @Test73 void setSize_OverTime_HalfwayAtHalfTime()74 {75 worldBorderMock.setSize(100);76 worldBorderMock.setSize(50, 10);77 server.getScheduler().performTicks(5 * 20);78 assertEquals(75, worldBorderMock.getSize());79 }80 @Test81 void setSize_LessThanOne_ClampedAtOne()82 {83 worldBorderMock.setSize(0);84 assertEquals(1, worldBorderMock.getSize());85 }86 @Test87 void setSize_GreaterThanMax_ClampedAtMax()88 {89 worldBorderMock.setSize(6.0000001E7);90 assertEquals(6.0E7, worldBorderMock.getSize());91 }92 @Test93 void setSize_Instant_CallsEvent()94 {95 worldBorderMock.setSize(100);96 server.getPluginManager().assertEventFired(WorldBorderBoundsChangeEvent.class, (e) -> e.getType() == WorldBorderBoundsChangeEvent.Type.INSTANT_MOVE && e.getNewSize() == 100);97 }98 @Test99 void setSize_Duration_CallsEvent()100 {101 worldBorderMock.setSize(100, 5);102 server.getPluginManager().assertEventFired(WorldBorderBoundsChangeEvent.class, (e) -> e.getType() == WorldBorderBoundsChangeEvent.Type.STARTED_MOVE && e.getNewSize() == 100 && e.getDuration() == 5000);103 }104 @Test105 void setSize_Event_AppliesSize()106 {107 server.getPluginManager().registerEvents(new Listener()108 {109 @EventHandler110 public void onBorderChange(@NotNull WorldBorderBoundsChangeEvent e)111 {112 e.setNewSize(50);113 }114 }, MockBukkit.createMockPlugin());115 worldBorderMock.setSize(100);116 assertEquals(50, worldBorderMock.getSize());117 }118 @Test119 void setSize_Event_AppliesDuration()120 {121 server.getPluginManager().registerEvents(new Listener()122 {123 @EventHandler124 public void onBorderChange(@NotNull WorldBorderBoundsChangeEvent e)125 {126 e.setDuration(5000);127 }128 }, MockBukkit.createMockPlugin());129 worldBorderMock.setSize(100, 10);130 server.getScheduler().performTicks(5 * 20);131 assertEquals(100, worldBorderMock.getSize());132 }133 @Test134 void setSize_CanceledEvent_DoesntApply()135 {136 server.getPluginManager().registerEvents(new Listener()137 {138 @EventHandler139 public void onBorderChange(@NotNull WorldBorderBoundsChangeEvent e)140 {141 e.setCancelled(true);142 }143 }, MockBukkit.createMockPlugin());144 worldBorderMock.setSize(100);145 assertEquals(6.0E7, worldBorderMock.getSize());146 }147 @Test148 void setCenterLocation()149 {150 worldBorderMock.setCenter(new Location(null, 10, 0, 10));151 assertEquals(new Location(world, 10, 0, 10), worldBorderMock.getCenter());152 }153 @Test154 void setCenterXZ()155 {156 worldBorderMock.setCenter(10, 10);157 assertEquals(new Location(world, 10, 0, 10), worldBorderMock.getCenter());158 }159 @Test160 void setCenter_CallsEvent()161 {162 worldBorderMock.setCenter(10, 12);163 server.getPluginManager().assertEventFired(WorldBorderCenterChangeEvent.class, (e) -> e.getNewCenter().getX() == 10 && e.getNewCenter().getZ() == 12);164 }165 @Test166 void setCenter_CanceledEvent_DoesntApply()167 {168 server.getPluginManager().registerEvents(new Listener()169 {170 @EventHandler171 public void onBorderChange(@NotNull WorldBorderCenterChangeEvent e)172 {173 e.setCancelled(true);174 }175 }, MockBukkit.createMockPlugin());176 worldBorderMock.setCenter(10, 10);177 assertEquals(0, worldBorderMock.getCenter().getBlockX());178 assertEquals(0, worldBorderMock.getCenter().getBlockZ());179 }180 @Test181 void setDamageBuffer()182 {183 worldBorderMock.setDamageBuffer(10.0);184 assertEquals(10.0, worldBorderMock.getDamageBuffer());185 }186 @Test187 void setDamageAmount()188 {189 worldBorderMock.setDamageAmount(1);190 assertEquals(1, worldBorderMock.getDamageAmount());191 }192 @Test...
Source:WorldBorderMock.java
...119 }120 }.runTaskTimer(null, 1, 1);121 }122 @Override123 public @NotNull Location getCenter()124 {125 return new Location(this.world, this.centerX, 0, this.centerZ);126 }127 @Override128 public void setCenter(@NotNull Location location)129 {130 Preconditions.checkNotNull(location, "Location cannot be null");131 setCenter(location.getX(), location.getZ());132 }133 @Override134 public void setCenter(double x, double z)135 {136 x = Math.min(MAX_CENTER_VALUE, Math.max(-MAX_CENTER_VALUE, x));137 z = Math.min(MAX_CENTER_VALUE, Math.max(-MAX_CENTER_VALUE, z));...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!