-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add PigZombieMock * fix paper implementation && added descriptive names * update unit tests * remove field unused
- Loading branch information
Showing
4 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/be/seeseemelk/mockbukkit/entity/PigZombieMock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package be.seeseemelk.mockbukkit.entity; | ||
|
||
import be.seeseemelk.mockbukkit.ServerMock; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.PigZombie; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.UUID; | ||
|
||
public class PigZombieMock extends ZombieMock implements PigZombie | ||
{ | ||
|
||
private int anger = 0; | ||
|
||
/** | ||
* Constructs a new {@link PigZombieMock} on the provided {@link ServerMock} with a specified {@link UUID}. | ||
* | ||
* @param server The server to create the entity on. | ||
* @param uuid The UUID of the entity. | ||
*/ | ||
public PigZombieMock(@NotNull ServerMock server, @NotNull UUID uuid) | ||
{ | ||
super(server, uuid); | ||
} | ||
|
||
@Override | ||
public int getAnger() | ||
{ | ||
return this.anger; | ||
} | ||
|
||
@Override | ||
public void setAnger(int level) | ||
{ | ||
this.anger = level; | ||
} | ||
|
||
@Override | ||
public void setAngry(boolean angry) | ||
{ | ||
this.setAnger(angry ? 400 : 0); | ||
} | ||
|
||
@Override | ||
public boolean isAngry() | ||
{ | ||
return this.getAnger() > 0; | ||
} | ||
|
||
@Override | ||
public boolean isConverting() | ||
{ | ||
return false; | ||
} | ||
|
||
@Override | ||
public int getConversionTime() | ||
{ | ||
throw new UnsupportedOperationException("Not supported by this Entity."); | ||
} | ||
|
||
@Override | ||
public void setConversionTime(int conversionTime) | ||
{ | ||
throw new UnsupportedOperationException("Not supported by this Entity."); | ||
} | ||
|
||
@Override | ||
public @NotNull EntityType getType() | ||
{ | ||
return EntityType.ZOMBIFIED_PIGLIN; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/test/java/be/seeseemelk/mockbukkit/entity/PigZombieMockTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package be.seeseemelk.mockbukkit.entity; | ||
|
||
import be.seeseemelk.mockbukkit.MockBukkit; | ||
import be.seeseemelk.mockbukkit.ServerMock; | ||
import org.bukkit.entity.EntityType; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.UUID; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class PigZombieMockTest | ||
{ | ||
private PigZombieMock pigZombie; | ||
|
||
@BeforeEach | ||
void setUp() | ||
{ | ||
ServerMock server = MockBukkit.mock(); | ||
pigZombie = new PigZombieMock(server, UUID.randomUUID()); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() | ||
{ | ||
MockBukkit.unmock(); | ||
} | ||
|
||
@Test | ||
void testAngerDefault() | ||
{ | ||
assertEquals(0, pigZombie.getAnger()); | ||
} | ||
|
||
@Test | ||
void testSetAnger() | ||
{ | ||
pigZombie.setAnger(100); | ||
assertEquals(100, pigZombie.getAnger()); | ||
assertTrue(pigZombie.isAngry()); | ||
} | ||
|
||
@Test | ||
void testAngryDefault() | ||
{ | ||
assertFalse(pigZombie.isAngry()); | ||
} | ||
|
||
@Test | ||
void testSetAngry() | ||
{ | ||
pigZombie.setAngry(true); | ||
assertTrue(pigZombie.isAngry()); | ||
} | ||
|
||
@Test | ||
void testIsConverting() | ||
{ | ||
assertFalse(pigZombie.isConverting()); | ||
} | ||
|
||
@Test | ||
void testGetConversionTime() | ||
{ | ||
assertThrows(UnsupportedOperationException.class, pigZombie::getConversionTime); | ||
} | ||
|
||
@Test | ||
void testSetConversionTime() | ||
{ | ||
assertThrows(UnsupportedOperationException.class, () -> pigZombie.setConversionTime(100)); | ||
} | ||
|
||
@Test | ||
void testType() | ||
{ | ||
assertEquals(EntityType.ZOMBIFIED_PIGLIN, pigZombie.getType()); | ||
} | ||
|
||
} |