Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/BentoBoxWorld/Parkour.git
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
tastybento committed Nov 10, 2024
2 parents 88c6df3 + aa00b82 commit 638bbc9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.managers.RanksManager;
import world.bentobox.parkour.Parkour;
import world.bentobox.parkour.ParkourManager;

Expand Down Expand Up @@ -39,7 +40,7 @@ public boolean canExecute(User user, String label, List<String> args) {
// Check rank to use command
int rank = Objects.requireNonNull(island).getRank(user);
if (rank < island.getRankCommand(getUsage())) {
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(getPlugin().getRanksManager().getRank(rank)));
user.sendMessage("general.errors.insufficient-rank", TextVariables.RANK, user.getTranslation(RanksManager.getInstance().getRank(rank)));
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
*
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, Config.class, DatabaseSetup.class, Util.class,
RanksManager.class })
@PrepareForTest({ Bukkit.class, BentoBox.class, User.class, Config.class, DatabaseSetup.class, Util.class })
public abstract class AbstractParkourTest {

@Mock
Expand Down Expand Up @@ -172,9 +171,6 @@ public void setUp() throws Exception {
when(plugin.getFlagsManager()).thenReturn(fm);
when(fm.getFlags()).thenReturn(Collections.emptyList());

// RanksManager
Whitebox.setInternalState(RanksManager.class, "instance", rm);
when(rm.getRank(any())).thenReturn("ranks.member");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;

import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
Expand Down Expand Up @@ -116,10 +115,6 @@ public void setUp() throws Exception {
Settings settings = new Settings();
when(addon.getSettings()).thenReturn(settings);

// RanksManager
Whitebox.setInternalState(RanksManager.class, "instance", rm);
when(rm.getRank(any())).thenReturn("ranks.member");

// DUT
cmd = new SetWarpCommand(ac);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.damage.DamageSource;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
Expand Down Expand Up @@ -283,8 +281,7 @@ public void testOnVisitorLeaveNotRuning() {
*/
@Test
public void testOnPlayerDeath() {
PlayerDeathEvent e = new PlayerDeathEvent(player, DamageSource.builder(DamageType.ARROW).build(),
new ArrayList<>(), 0, 0, 0, 0, null);
PlayerDeathEvent e = new PlayerDeathEvent(player, null, null, 0, 0, 0, 0, null);
crl.onPlayerDeath(e);
assertFalse(prm.timers().containsKey(uuid));
assertFalse(prm.checkpoints().containsKey(uuid));
Expand All @@ -311,7 +308,7 @@ public void testOnVisitorFall() {
PowerMockito.mockStatic(Util.class, RETURNS_MOCKS);
prm.timers().put(uuid, System.currentTimeMillis() - 20000); // ~ 20 seconds ago
prm.checkpoints().put(uuid, location);
EntityDamageEvent e = new EntityDamageEvent(player, null, null, null);
EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, null, 0);
crl.onVisitorFall(e);
verify(player).playEffect(EntityEffect.ENTITY_POOF);
verify(player).setVelocity(new Vector(0, 0, 0));
Expand All @@ -328,7 +325,7 @@ public void testOnVisitorFall() {
public void testOnVisitorFallNotVoid() {
prm.timers().put(uuid, System.currentTimeMillis() - 20000); // ~ 20 seconds ago
prm.checkpoints().put(uuid, location);
EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.BLOCK_EXPLOSION, 1D);
EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.BLOCK_EXPLOSION, null, 0);
crl.onVisitorFall(e);
verify(player, never()).playEffect(EntityEffect.ENTITY_POOF);
verify(player, never()).setVelocity(new Vector(0, 0, 0));
Expand All @@ -342,7 +339,7 @@ public void testOnVisitorFallNotVoid() {
*/
@Test
public void testOnVisitorFallNotRunning() {
EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, 1D);
EntityDamageEvent e = new EntityDamageEvent(player, DamageCause.VOID, null, 1D);
crl.onVisitorFall(e);
verify(player, never()).playEffect(EntityEffect.ENTITY_POOF);
verify(player, never()).setVelocity(new Vector(0, 0, 0));
Expand All @@ -357,7 +354,7 @@ public void testOnVisitorFallNotRunning() {
@Test
public void testOnVisitorFallNotPlayer() {
Creeper creeper = mock(Creeper.class);
EntityDamageEvent e = new EntityDamageEvent(creeper, DamageCause.VOID, 1D);
EntityDamageEvent e = new EntityDamageEvent(creeper, DamageCause.VOID, null, 1D);
crl.onVisitorFall(e);
verify(creeper, never()).playEffect(EntityEffect.ENTITY_POOF);
}
Expand Down

0 comments on commit 638bbc9

Please sign in to comment.