Merge remote-tracking branch 'alexdev03/2.X' into alexdev032.X
# Conflicts: # plugin/src/main/java/lol/pyr/znpcsplus/npc/NpcImpl.java
This commit is contained in:
commit
3ebd0070b8
5 changed files with 46 additions and 3 deletions
|
@ -100,6 +100,28 @@ public interface Npc extends PropertyHolder {
|
|||
*/
|
||||
void respawn(Player player);
|
||||
|
||||
/**
|
||||
* Blacklists a player from sending packets for this NPC
|
||||
* This means that the run task won't send packets to the player
|
||||
*
|
||||
* @param player The player to be blacklisted
|
||||
*/
|
||||
void blacklist(Player player);
|
||||
|
||||
/**
|
||||
* Removes a player from the blacklist, allowing packets to be sent to them for this NPC.
|
||||
*
|
||||
* @param player The player to be removed from the blacklist
|
||||
*/
|
||||
void unblacklist(Player player);
|
||||
|
||||
/**
|
||||
* Gets if a player is blacklisted from sending packets for this NPC
|
||||
* @param player The player to check
|
||||
* @return If the player is blacklisted
|
||||
*/
|
||||
boolean isBlacklisted(Player player);
|
||||
|
||||
/**
|
||||
* Sets the head rotation of this NPC for a player
|
||||
* @param player The {@link Player} to set the head rotation for
|
||||
|
|
|
@ -20,7 +20,7 @@ dependencies {
|
|||
compileOnly "com.google.code.gson:gson:2.10.1" // JSON parsing
|
||||
compileOnly "org.bstats:bstats-bukkit:3.0.2" // Plugin stats
|
||||
compileOnly "me.robertlit:SpigotResourcesAPI:2.0" // Spigot API wrapper for update checker
|
||||
compileOnly "com.github.retrooper.packetevents:spigot:2.1.0" // Packets
|
||||
compileOnly "com.github.retrooper.packetevents:spigot:2.2.0" // Packets
|
||||
compileOnly "space.arim.dazzleconf:dazzleconf-ext-snakeyaml:1.2.1" // Configs
|
||||
compileOnly "lol.pyr:director-adventure:2.1.1" // Commands
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ public class ZNpcsPlusBootstrap extends JavaPlugin {
|
|||
|
||||
loader.loadLibrary("me.robertlit", "SpigotResourcesAPI", "2.0", "https://repo.pyr.lol/releases");
|
||||
|
||||
loader.loadLibrary(decrypt("com..github..retrooper..packetevents"), "api", "2.1.0", "https://repo.codemc.io/repository/maven-releases/");
|
||||
loader.loadLibrary(decrypt("com..github..retrooper..packetevents"), "spigot", "2.1.0", "https://repo.codemc.io/repository/maven-releases/");
|
||||
loader.loadLibrary(decrypt("com..github..retrooper..packetevents"), "api", "2.2.0", "https://repo.codemc.io/repository/maven-releases/");
|
||||
loader.loadLibrary(decrypt("com..github..retrooper..packetevents"), "spigot", "2.2.0", "https://repo.codemc.io/repository/maven-releases/");
|
||||
|
||||
loader.loadLibrary(decrypt("space..arim..dazzleconf"), "dazzleconf-core", "1.2.1");
|
||||
loader.loadLibrary(decrypt("space..arim..dazzleconf"), "dazzleconf-ext-snakeyaml", "1.2.1");
|
||||
|
|
|
@ -47,6 +47,11 @@ public class NpcProcessorTask extends BukkitRunnable {
|
|||
if (npc.isVisibleTo(player)) npc.hide(player);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (npc.isBlacklisted(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double distance = player.getLocation().distanceSquared(npc.getBukkitLocation());
|
||||
|
||||
// visibility
|
||||
|
|
|
@ -22,6 +22,7 @@ public abstract class Viewable {
|
|||
}
|
||||
|
||||
private final Set<Player> viewers = ConcurrentHashMap.newKeySet();
|
||||
private final Set<Player> blacklisted = ConcurrentHashMap.newKeySet();
|
||||
|
||||
public Viewable() {
|
||||
all.add(new WeakReference<>(this));
|
||||
|
@ -30,6 +31,7 @@ public abstract class Viewable {
|
|||
public void delete() {
|
||||
UNSAFE_hideAll();
|
||||
viewers.clear();
|
||||
blacklisted.clear();
|
||||
}
|
||||
|
||||
public void respawn() {
|
||||
|
@ -55,8 +57,22 @@ public abstract class Viewable {
|
|||
UNSAFE_hide(player);
|
||||
}
|
||||
|
||||
public void blacklist(Player player) {
|
||||
blacklisted.add(player);
|
||||
hide(player);
|
||||
}
|
||||
|
||||
public void unblacklist(Player player) {
|
||||
blacklisted.remove(player);
|
||||
}
|
||||
|
||||
public boolean isBlacklisted(Player player) {
|
||||
return blacklisted.contains(player);
|
||||
}
|
||||
|
||||
public void UNSAFE_removeViewer(Player player) {
|
||||
viewers.remove(player);
|
||||
blacklisted.remove(player);
|
||||
}
|
||||
|
||||
protected void UNSAFE_hideAll() {
|
||||
|
|
Loading…
Reference in a new issue