Skip to content

Commit

Permalink
Merge pull request #820 from TonytheMacaroni/main
Browse files Browse the repository at this point in the history
Add more block-related conditions
  • Loading branch information
Chronoken authored Dec 15, 2023
2 parents 8db69b7 + efb3d0f commit 4aeb4b9
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nisovin.magicspells.castmodifiers.conditions;

import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;

import com.nisovin.magicspells.castmodifiers.Condition;

public class BuildableCondition extends Condition {

@Override
public boolean initialize(String var) {
return true;
}

@Override
public boolean check(LivingEntity livingEntity) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, LivingEntity target) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, Location location) {
return location.getBlock().isBuildable();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nisovin.magicspells.castmodifiers.conditions;

import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;

import com.nisovin.magicspells.castmodifiers.Condition;

public class BurnableCondition extends Condition {

@Override
public boolean initialize(String var) {
return true;
}

@Override
public boolean check(LivingEntity livingEntity) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, LivingEntity target) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, Location location) {
return location.getBlock().isBurnable();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nisovin.magicspells.castmodifiers.conditions;

import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;

import com.nisovin.magicspells.castmodifiers.Condition;

public class CollidableCondition extends Condition {

@Override
public boolean initialize(String var) {
return true;
}

@Override
public boolean check(LivingEntity livingEntity) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, LivingEntity target) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, Location location) {
return location.getBlock().isCollidable();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nisovin.magicspells.castmodifiers.conditions;

import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;

import com.nisovin.magicspells.castmodifiers.Condition;

public class PassableCondition extends Condition {

@Override
public boolean initialize(String var) {
return true;
}

@Override
public boolean check(LivingEntity livingEntity) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, LivingEntity target) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, Location location) {
return location.getBlock().isPassable();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nisovin.magicspells.castmodifiers.conditions;

import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;

import com.nisovin.magicspells.castmodifiers.Condition;

public class ReplaceableCondition extends Condition {

@Override
public boolean initialize(String var) {
return true;
}

@Override
public boolean check(LivingEntity livingEntity) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, LivingEntity target) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, Location location) {
return location.getBlock().isReplaceable();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nisovin.magicspells.castmodifiers.conditions;

import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;

import com.nisovin.magicspells.castmodifiers.Condition;

public class SolidCondition extends Condition {

@Override
public boolean initialize(String var) {
return true;
}

@Override
public boolean check(LivingEntity livingEntity) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, LivingEntity target) {
return false;
}

@Override
public boolean check(LivingEntity livingEntity, Location location) {
return location.getBlock().isSolid();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ private void initialize() {
addCondition("ownedloopactive", OwnedLoopActiveCondition.class);
addCondition("always", AlwaysCondition.class);
addCondition("velocityactive", VelocityActiveCondition.class);
addCondition("buildable", BuildableCondition.class);
addCondition("burnable", BurnableCondition.class);
addCondition("collidable", CollidableCondition.class);
addCondition("passable", PassableCondition.class);
addCondition("replaceable", ReplaceableCondition.class);
addCondition("solid", SolidCondition.class);
}

}

0 comments on commit 4aeb4b9

Please sign in to comment.