feat: integrate Beta 1.0.2.0 Pillager update with paid raid recovery
All checks were successful
DuneRealms Plugin CI / plugins (push) Successful in 3m8s
All checks were successful
DuneRealms Plugin CI / plugins (push) Successful in 3m8s
This commit is contained in:
parent
3485eec4a1
commit
c599b2b708
1 changed files with 4107 additions and 23 deletions
|
|
@ -0,0 +1,49 @@
|
|||
package com.example.duneterrain;
|
||||
import java.util.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.generator.*;
|
||||
import org.bukkit.persistence.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class SpiceDepositProvenanceTest {
|
||||
@Test void onlyRecordedGeneratorCoordinatesAreMarkedAndPopulationConsumesPendingState(){
|
||||
var provenance=new SpiceDepositProvenance();WorldInfo world=mock(WorldInfo.class);when(world.getUID()).thenReturn(UUID.randomUUID());
|
||||
var data=mock(ChunkGenerator.ChunkData.class);when(data.getType(1,70,2)).thenReturn(Material.SUSPICIOUS_SAND);when(data.getType(3,70,4)).thenReturn(Material.SAND);
|
||||
provenance.capture(world,-1,2,List.of(new SpiceDepositProvenance.Position(1,70,2),new SpiceDepositProvenance.Position(3,70,4)),data);
|
||||
LimitedRegion region=mock(LimitedRegion.class);when(region.isInRegion(-15,70,34)).thenReturn(true);when(region.getType(-15,70,34)).thenReturn(Material.SUSPICIOUS_SAND);
|
||||
BrushableBlock tile=mock(BrushableBlock.class);when(tile.getType()).thenReturn(Material.SUSPICIOUS_SAND);var pdc=mock(PersistentDataContainer.class);when(tile.getPersistentDataContainer()).thenReturn(pdc);
|
||||
when(region.getBlockState(-15,70,34)).thenReturn(tile);
|
||||
provenance.populate(world,new Random(1),-1,2,region);provenance.populate(world,new Random(1),-1,2,region);
|
||||
verify(pdc,times(1)).set(SpiceDepositProvenance.KEY,PersistentDataType.BYTE,(byte)1);verify(tile).update(true,false);
|
||||
verify(region,never()).getBlockState(-13,70,36);verify(region,times(1)).getBlockState(anyInt(),anyInt(),anyInt());
|
||||
}
|
||||
@Test void playerPlacedOrOldUnmarkedSandAndCompressedDisksAreNotAuthentic(){
|
||||
Block block=mock(Block.class);when(block.getType()).thenReturn(Material.SUSPICIOUS_SAND);BrushableBlock tile=mock(BrushableBlock.class);when(block.getState()).thenReturn(tile);
|
||||
var pdc=mock(PersistentDataContainer.class);when(tile.getPersistentDataContainer()).thenReturn(pdc);
|
||||
assertFalse(SpiceDepositProvenance.authentic(block));
|
||||
when(pdc.get(SpiceDepositProvenance.KEY,PersistentDataType.BYTE)).thenReturn((byte)1);assertTrue(SpiceDepositProvenance.authentic(block));
|
||||
when(block.getType()).thenReturn(Material.DRIED_KELP_BLOCK);assertFalse(SpiceDepositProvenance.authentic(block));
|
||||
SpiceDepositProvenance.forget(block);verify(pdc).remove(SpiceDepositProvenance.KEY);
|
||||
}
|
||||
@Test void changedOrMissingBlockEntityFailsClosed(){
|
||||
assertFalse(SpiceDepositProvenance.mark(mock(BlockState.class)));
|
||||
BrushableBlock tile=mock(BrushableBlock.class);when(tile.getType()).thenReturn(Material.SAND);assertFalse(SpiceDepositProvenance.mark(tile));
|
||||
verify(tile,never()).getPersistentDataContainer();
|
||||
}
|
||||
@Test void onlyGeneratedBloomOriginCanAuthenticateItsOutputAndItIsSingleUse(){
|
||||
var provenance=new SpiceDepositProvenance();World world=mock(World.class);UUID id=UUID.randomUUID();when(world.getUID()).thenReturn(id);
|
||||
Chunk chunk=mock(Chunk.class);when(chunk.getWorld()).thenReturn(world);when(chunk.getX()).thenReturn(2);when(chunk.getZ()).thenReturn(3);
|
||||
Block center=mock(Block.class);when(center.getChunk()).thenReturn(chunk);when(center.getX()).thenReturn(34);when(center.getY()).thenReturn(71);when(center.getZ()).thenReturn(50);when(center.getType()).thenReturn(Material.MAGMA_BLOCK);when(chunk.getBlock(2,71,2)).thenReturn(center);
|
||||
var pdc=mock(PersistentDataContainer.class);when(chunk.getPersistentDataContainer()).thenReturn(pdc);Map<NamespacedKey,Byte> values=new HashMap<>();
|
||||
doAnswer(c->{values.put(c.getArgument(0),c.getArgument(2));return null;}).when(pdc).set(any(NamespacedKey.class),eq(PersistentDataType.BYTE),anyByte());
|
||||
when(pdc.get(any(NamespacedKey.class),eq(PersistentDataType.BYTE))).thenAnswer(c->values.get(c.getArgument(0)));
|
||||
doAnswer(c->{values.remove(c.getArgument(0));return null;}).when(pdc).remove(any(NamespacedKey.class));
|
||||
assertFalse(SpiceDepositProvenance.takeBloom(center)); // A player-built magma pattern has no producer record.
|
||||
provenance.bloom(world,2,3,new SpiceDepositProvenance.Position(34,71,50));provenance.commitBloom(chunk);
|
||||
assertTrue(SpiceDepositProvenance.takeBloom(center));assertFalse(SpiceDepositProvenance.takeBloom(center));
|
||||
provenance.commitBloom(chunk);assertFalse(SpiceDepositProvenance.takeBloom(center));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue

Staff