Fix a few things, getting back into the flow

This commit is contained in:
Bradley Hilton 2019-04-15 15:41:33 -05:00
parent abc561ded8
commit f0a816513b
3 changed files with 21 additions and 5 deletions

View File

@ -199,6 +199,22 @@ public class JailManager {
return null;
}
/**
* Gets whether the location is inside of a Jail.
*
* @param l to determine if is in a jail
* @return whether it is inside a jail or not
*/
public boolean isLocationAJail(Location l) {
for(Jail j : jails.values()) {
if(Util.isInsideAB(l.toVector(), j.getMinPoint().toVector(), j.getMaxPoint().toVector())) {
return true;
}
}
return false;
}
/**
* Checks to see if the given name for a {@link Jail} is valid, returns true if it is a valid jail.
*

View File

@ -25,7 +25,7 @@ public class EntityListener implements Listener {
for(Block b : event.blockList()) {
//Check the current block and if it is inside a jail,
//then let's do something else
if(pl.getJailManager().getJailFromLocation(b.getLocation()) != null) {
if(pl.getJailManager().isLocationAJail(b.getLocation())) {
//Clear the blocklist, this way the explosion effect still happens
event.blockList().clear();
return;
@ -39,7 +39,7 @@ public class EntityListener implements Listener {
//If we are protecting the jails from endermen protection
if(pl.getConfig().getBoolean(Settings.ENDERMENPROTECTION.getPath())) {
//Check if there are any jails where the block's location is
if(pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) != null) {
if(pl.getJailManager().isLocationAJail(event.getBlock().getLocation())) {
//Let's cancel the event so it doesn't happen
event.setCancelled(true);
}

View File

@ -107,8 +107,8 @@ public class TestJailDefaultConfig {
// interaction blocks protection section
List<String> interactionBlocks = main.getConfig().getStringList(Settings.PREVENTINTERACTIONBLOCKS.getPath());
assertTrue("Default interaction blocks whitelist doesn't contain wooden_door.", interactionBlocks.contains("wooden_door"));
assertTrue("Default interaction blocks whitelist doesn't contain iron_door_block.", interactionBlocks.contains("iron_door_block"));
assertTrue("Default interaction blocks whitelist doesn't contain wooden_door.", interactionBlocks.contains("oak_door"));
assertTrue("Default interaction blocks whitelist doesn't contain iron_door_block.", interactionBlocks.contains("iron_door"));
assertEquals("Default setting for preventing interaction blocks penalty is not 5m.", "5m", main.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
// interaction items protection section
@ -116,7 +116,7 @@ public class TestJailDefaultConfig {
assertEquals("Default setting for preventing interaction blocks penalty is not 5m.", "5m", main.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
assertTrue("Default setting for recieving messages is false.", main.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath()));
assertFalse("Default setting for scoreboard being enabled is true.", main.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath()));
assertTrue("Default setting for scoreboard being enabled is false.", main.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath()));
assertEquals("Default setting for the scoreboard title is not Jail Info.", "Jail Info", main.getConfig().getString(Settings.SCOREBOARDTITLE.getPath()));
assertEquals("Default setting for the scoreboard time language is not &aTime:", "&aTime:", main.getConfig().getString(Settings.SCOREBOARDTIME.getPath()));
}