Added "ShowInTabList" configuration option to allow server owners to optionally make the Herobrine tab list entry persistent
This commit is contained in:
parent
b6a0fd92e5
commit
8730c32b13
@ -81,6 +81,7 @@ public class ConfigDB {
|
|||||||
public String HerobrineUUID = "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2";
|
public String HerobrineUUID = "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2";
|
||||||
public String HerobrineName = "Herobrine";
|
public String HerobrineName = "Herobrine";
|
||||||
public String HerobrineWorldName = "world_herobrine_graveyard";
|
public String HerobrineWorldName = "world_herobrine_graveyard";
|
||||||
|
public boolean ShowInTabList = false;
|
||||||
|
|
||||||
private boolean isStartupDone = false;
|
private boolean isStartupDone = false;
|
||||||
|
|
||||||
@ -238,6 +239,7 @@ public class ConfigDB {
|
|||||||
config.set("config.HerobrineUUID", "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2");
|
config.set("config.HerobrineUUID", "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2");
|
||||||
config.set("config.HerobrineName", "Herobrine");
|
config.set("config.HerobrineName", "Herobrine");
|
||||||
config.set("config.HerobrineWorldName", "world_herobrine_graveyard");
|
config.set("config.HerobrineWorldName", "world_herobrine_graveyard");
|
||||||
|
config.set("config.ShowInTabList", false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.save(configF);
|
config.save(configF);
|
||||||
@ -328,6 +330,7 @@ public class ConfigDB {
|
|||||||
HerobrineUUID = config.getString("config.HerobrineUUID");
|
HerobrineUUID = config.getString("config.HerobrineUUID");
|
||||||
HerobrineName = config.getString("config.HerobrineName");
|
HerobrineName = config.getString("config.HerobrineName");
|
||||||
HerobrineWorldName = config.getString("config.HerobrineWorldName");
|
HerobrineWorldName = config.getString("config.HerobrineWorldName");
|
||||||
|
ShowInTabList = config.getBoolean("config.ShowInTabList");
|
||||||
|
|
||||||
Herobrine.HerobrineMaxHP = HerobrineHP;
|
Herobrine.HerobrineMaxHP = HerobrineHP;
|
||||||
Herobrine.getPluginCore().getAICore().Stop_MAIN();
|
Herobrine.getPluginCore().getAICore().Stop_MAIN();
|
||||||
|
@ -71,12 +71,14 @@ public class HumanNPC {
|
|||||||
public void Teleport(Location loc) {
|
public void Teleport(Location loc) {
|
||||||
getEntity().getBukkitEntity().teleport(loc);
|
getEntity().getBukkitEntity().teleport(loc);
|
||||||
|
|
||||||
// After Herobrine moves, check if any players are in Herobrine's line of sight.
|
// After Herobrine moves, check if any players are in Herobrine's line of sight if the persistent tab list entry is disabled.
|
||||||
boolean doActivationTeleport = false;
|
if(!Herobrine.getPluginCore().getConfigDB().ShowInTabList) {
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
boolean doActivationTeleport = false;
|
||||||
doActivationTeleport = doActivationTeleport || Herobrine.getPluginCore().getAICore().toggleHerobrinePlayerVisibilityNoTeleport(p);
|
for(Player p : Bukkit.getOnlinePlayers())
|
||||||
if(doActivationTeleport)
|
doActivationTeleport = doActivationTeleport || Herobrine.getPluginCore().getAICore().toggleHerobrinePlayerVisibilityNoTeleport(p);
|
||||||
Herobrine.getPluginCore().getAICore().visibilityActivationTeleport();
|
if(doActivationTeleport)
|
||||||
|
Herobrine.getPluginCore().getAICore().visibilityActivationTeleport();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerInventory getInventory() {
|
public PlayerInventory getInventory() {
|
||||||
|
@ -12,6 +12,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Jukebox;
|
import org.bukkit.block.Jukebox;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -28,6 +29,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_15_R1.PacketPlayOutPlayerInfo;
|
||||||
|
import net.minecraft.server.v1_15_R1.PacketPlayOutPlayerInfo.EnumPlayerInfoAction;
|
||||||
import net.theprogrammersworld.herobrine.Herobrine;
|
import net.theprogrammersworld.herobrine.Herobrine;
|
||||||
import net.theprogrammersworld.herobrine.Utils;
|
import net.theprogrammersworld.herobrine.Utils;
|
||||||
import net.theprogrammersworld.herobrine.AI.AICore;
|
import net.theprogrammersworld.herobrine.AI.AICore;
|
||||||
@ -55,6 +58,11 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent event) {
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
|
// If the persistent tab list entry for Herobrine is enabled, send an "add player" packet to the user on login.
|
||||||
|
if(Herobrine.getPluginCore().getConfigDB().ShowInTabList)
|
||||||
|
((CraftPlayer) event.getPlayer()).getHandle().playerConnection.sendPacket(
|
||||||
|
new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, Herobrine.getPluginCore().HerobrineNPC.getEntity()));
|
||||||
|
|
||||||
// Check if the user has a Graveyard cache. If they do, this means they are stuck in the Graveyard and
|
// Check if the user has a Graveyard cache. If they do, this means they are stuck in the Graveyard and
|
||||||
// need teleported out.
|
// need teleported out.
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(PluginCore, new Runnable() {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(PluginCore, new Runnable() {
|
||||||
@ -276,8 +284,9 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMoveEvent(PlayerMoveEvent event) {
|
public void onPlayerMoveEvent(PlayerMoveEvent event) {
|
||||||
// Dynamically toggle Herobrine's visibility to players as a workaround to the persistent tab list entry.
|
// Dynamically toggle Herobrine's visibility to players as a workaround to the persistent tab list entry if the persistent entry is disabled.
|
||||||
PluginCore.getAICore().toggleHerobrinePlayerVisibility(event.getPlayer());
|
if(!Herobrine.getPluginCore().getConfigDB().ShowInTabList)
|
||||||
|
PluginCore.getAICore().toggleHerobrinePlayerVisibility(event.getPlayer());
|
||||||
|
|
||||||
// Prevent player from moving when in Herobrine's Graveyard.
|
// Prevent player from moving when in Herobrine's Graveyard.
|
||||||
if (event.getPlayer().getEntityId() != PluginCore.HerobrineEntityID) {
|
if (event.getPlayer().getEntityId() != PluginCore.HerobrineEntityID) {
|
||||||
|
Loading…
Reference in New Issue
Block a user