mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-21 11:46:46 +01:00
Fixed npcs can be shown to other players using external mods
This commit is contained in:
parent
1992f03b0e
commit
2750455435
@ -1,6 +1,7 @@
|
||||
package com.bgsoftware.wildloaders.api.npc;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -25,4 +26,9 @@ public interface ChunkLoaderNPC {
|
||||
*/
|
||||
Location getLocation();
|
||||
|
||||
/**
|
||||
* Get the player object of this npc.
|
||||
*/
|
||||
Player getPlayer();
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,11 @@ package com.bgsoftware.wildloaders.listeners;
|
||||
|
||||
import com.bgsoftware.wildloaders.Updater;
|
||||
import com.bgsoftware.wildloaders.WildLoadersPlugin;
|
||||
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.utils.threads.Executor;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
@ -17,6 +19,13 @@ public final class PlayersListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerJoinMonitor(PlayerJoinEvent event) {
|
||||
for (ChunkLoaderNPC npc : plugin.getNPCs().getNPCs().values()) {
|
||||
event.getPlayer().hidePlayer(npc.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Just notifies me if the server is using WildBuster
|
||||
*/
|
||||
|
@ -27,6 +27,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
@ -77,6 +78,11 @@ public final class ChunkLoaderNPC_v1_12_R1 extends EntityPlayer implements Chunk
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean damageEntity0(DamageSource damagesource, float f) {
|
||||
return false;
|
||||
|
@ -26,6 +26,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
@ -83,6 +84,11 @@ public final class ChunkLoaderNPC_v1_16_R3 extends EntityPlayer implements Chunk
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
private static Field channelField;
|
||||
|
@ -25,6 +25,7 @@ import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -83,6 +84,11 @@ public final class ChunkLoaderNPC_v1_17_R1 extends EntityPlayer implements Chunk
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer){
|
||||
worldServer.a(entityPlayer, RemovalReason.d);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -73,8 +74,7 @@ public final class ChunkLoaderNPC_v1_18_R1 extends EntityPlayer implements Chunk
|
||||
dieCall = true;
|
||||
removePlayer(getWorldServer(this), this);
|
||||
dieCall = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
super.a(removalReason);
|
||||
}
|
||||
}
|
||||
@ -84,6 +84,11 @@ public final class ChunkLoaderNPC_v1_18_R1 extends EntityPlayer implements Chunk
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer) {
|
||||
worldServer.a(entityPlayer, RemovalReason.d);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -73,8 +74,7 @@ public final class ChunkLoaderNPC_v1_18_R2 extends EntityPlayer implements Chunk
|
||||
dieCall = true;
|
||||
removePlayer(getLevel(this), this);
|
||||
dieCall = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
super.a(removalReason);
|
||||
}
|
||||
}
|
||||
@ -84,6 +84,11 @@ public final class ChunkLoaderNPC_v1_18_R2 extends EntityPlayer implements Chunk
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer) {
|
||||
worldServer.a(entityPlayer, RemovalReason.d);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -83,6 +84,11 @@ public final class ChunkLoaderNPC_v1_19_R1 extends EntityPlayer implements Chunk
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer) {
|
||||
worldServer.a(entityPlayer, RemovalReason.d);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
@ -74,6 +75,11 @@ public final class ChunkLoaderNPC_v1_7_R4 extends EntityPlayer implements ChunkL
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
private static Field channelField;
|
||||
|
@ -27,6 +27,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
@ -90,6 +91,11 @@ public final class ChunkLoaderNPC_v1_8_R3 extends EntityPlayer implements ChunkL
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
private static Field channelField;
|
||||
|
Loading…
Reference in New Issue
Block a user