Remove the use of legacy materials to specify the api version
Fixes #34
This commit is contained in:
parent
64ad990db8
commit
00d80cfbd6
|
@ -2,6 +2,7 @@ name: ActionHealth
|
||||||
main: com.zeshanaslam.actionhealth.Main
|
main: com.zeshanaslam.actionhealth.Main
|
||||||
version: 3.5.4
|
version: 3.5.4
|
||||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, WorldGuard, mcMMO, MythicMobs, LangUtils]
|
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, WorldGuard, mcMMO, MythicMobs, LangUtils]
|
||||||
|
api-version: 1.13
|
||||||
commands:
|
commands:
|
||||||
Actionhealth:
|
Actionhealth:
|
||||||
description: Actionhealth main commands.
|
description: Actionhealth main commands.
|
||||||
|
|
|
@ -7,27 +7,15 @@ import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
public class LookThread extends BukkitRunnable {
|
public class LookThread extends BukkitRunnable {
|
||||||
|
|
||||||
private Main plugin;
|
private Main plugin;
|
||||||
private Set<Byte> transparentTypeIds;
|
|
||||||
private TargetHelper targetHelper;
|
private TargetHelper targetHelper;
|
||||||
|
|
||||||
public LookThread(Main plugin) {
|
public LookThread(Main plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.targetHelper = new TargetHelper(plugin);
|
this.targetHelper = new TargetHelper(plugin);
|
||||||
this.transparentTypeIds = new TreeSet<>();
|
|
||||||
|
|
||||||
transparentTypeIds.add((byte) 0);
|
|
||||||
transparentTypeIds.add((byte) 20);
|
|
||||||
transparentTypeIds.add((byte) 95);
|
|
||||||
transparentTypeIds.add((byte) 102);
|
|
||||||
transparentTypeIds.add((byte) 160);
|
|
||||||
transparentTypeIds.add((byte) 8);
|
|
||||||
transparentTypeIds.add((byte) 9);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,7 +35,7 @@ public class LookThread extends BukkitRunnable {
|
||||||
|
|
||||||
String name = plugin.healthUtil.getName(livingEntity, player);
|
String name = plugin.healthUtil.getName(livingEntity, player);
|
||||||
|
|
||||||
if (targetHelper.canSee(player, livingEntity.getLocation(), transparentTypeIds) && !plugin.healthUtil.isBlacklisted(livingEntity, name)) {
|
if (targetHelper.canSee(player, livingEntity.getLocation()) && !plugin.healthUtil.isBlacklisted(livingEntity, name)) {
|
||||||
if (plugin.configStore.isUsingWhiteList()) {
|
if (plugin.configStore.isUsingWhiteList()) {
|
||||||
if (!plugin.healthUtil.isWhiteListed(livingEntity, name)) {
|
if (!plugin.healthUtil.isWhiteListed(livingEntity, name)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -9,9 +9,7 @@ import org.bukkit.util.BlockIterator;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Helper class for getting targets using various methods</p>
|
* <p>Helper class for getting targets using various methods</p>
|
||||||
|
@ -302,24 +300,11 @@ public class TargetHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getTarget(Location from, int distance, byte... transparentTypeIds) {
|
public Block getTarget(Location from, int distance) {
|
||||||
if (transparentTypeIds.length == 0) {
|
|
||||||
return getTarget(from, distance, (Set<Byte>) null);
|
|
||||||
} else {
|
|
||||||
Set<Byte> types = new HashSet<>(transparentTypeIds.length);
|
|
||||||
for (byte b : transparentTypeIds) types.add(b);
|
|
||||||
return getTarget(from, distance, types);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getTarget(Location from, int distance, Set<Byte> transparentTypeIds) {
|
|
||||||
BlockIterator itr = new BlockIterator(from, 0, distance);
|
BlockIterator itr = new BlockIterator(from, 0, distance);
|
||||||
while (itr.hasNext()) {
|
while (itr.hasNext()) {
|
||||||
Block block = itr.next();
|
Block block = itr.next();
|
||||||
int id = block.getType().getId();
|
if (!block.getType().isOccluding()) {
|
||||||
if (transparentTypeIds == null) {
|
|
||||||
if (id == 0) continue;
|
|
||||||
} else if (transparentTypeIds.contains((byte) id)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return block;
|
return block;
|
||||||
|
@ -327,19 +312,7 @@ public class TargetHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block getTarget(LivingEntity from, int distance, Set<Byte> transparentTypeIds) {
|
public boolean canSee(LivingEntity from, Location to) {
|
||||||
return getTarget(from.getEyeLocation(), distance, transparentTypeIds);
|
return getTarget(from.getEyeLocation(), (int) Math.ceil(from.getLocation().distance(to))) == null;
|
||||||
}
|
|
||||||
|
|
||||||
public Block getTarget(LivingEntity from, int distance, byte... transparentTypeIds) {
|
|
||||||
return getTarget(from.getEyeLocation(), distance, transparentTypeIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canSee(LivingEntity from, Location to, Set<Byte> transparentTypeIds) {
|
|
||||||
return getTarget(from, (int) Math.ceil(from.getLocation().distance(to)), transparentTypeIds) == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canSee(LivingEntity from, Location to, byte... transparentTypeIds) {
|
|
||||||
return getTarget(from, (int) Math.ceil(from.getLocation().distance(to)), transparentTypeIds) == null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue