Added "ShowInTabList" configuration option to allow server owners to optionally make the Herobrine tab list entry persistent

This commit is contained in:
David Berdik 2019-12-29 21:47:58 -05:00
parent b6a0fd92e5
commit 8730c32b13
3 changed files with 22 additions and 8 deletions

View File

@ -81,6 +81,7 @@ public class ConfigDB {
public String HerobrineUUID = "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2";
public String HerobrineName = "Herobrine";
public String HerobrineWorldName = "world_herobrine_graveyard";
public boolean ShowInTabList = false;
private boolean isStartupDone = false;
@ -238,6 +239,7 @@ public class ConfigDB {
config.set("config.HerobrineUUID", "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2");
config.set("config.HerobrineName", "Herobrine");
config.set("config.HerobrineWorldName", "world_herobrine_graveyard");
config.set("config.ShowInTabList", false);
try {
config.save(configF);
@ -328,6 +330,7 @@ public class ConfigDB {
HerobrineUUID = config.getString("config.HerobrineUUID");
HerobrineName = config.getString("config.HerobrineName");
HerobrineWorldName = config.getString("config.HerobrineWorldName");
ShowInTabList = config.getBoolean("config.ShowInTabList");
Herobrine.HerobrineMaxHP = HerobrineHP;
Herobrine.getPluginCore().getAICore().Stop_MAIN();

View File

@ -71,13 +71,15 @@ public class HumanNPC {
public void Teleport(Location 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.
if(!Herobrine.getPluginCore().getConfigDB().ShowInTabList) {
boolean doActivationTeleport = false;
for(Player p : Bukkit.getOnlinePlayers())
doActivationTeleport = doActivationTeleport || Herobrine.getPluginCore().getAICore().toggleHerobrinePlayerVisibilityNoTeleport(p);
if(doActivationTeleport)
Herobrine.getPluginCore().getAICore().visibilityActivationTeleport();
}
}
public PlayerInventory getInventory() {
return ((org.bukkit.entity.HumanEntity) getEntity().getBukkitEntity()).getInventory();

View File

@ -12,6 +12,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Jukebox;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
@ -28,6 +29,8 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
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.Utils;
import net.theprogrammersworld.herobrine.AI.AICore;
@ -55,6 +58,11 @@ public class PlayerListener implements Listener {
@EventHandler
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
// need teleported out.
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(PluginCore, new Runnable() {
@ -276,7 +284,8 @@ public class PlayerListener implements Listener {
@EventHandler
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.
if(!Herobrine.getPluginCore().getConfigDB().ShowInTabList)
PluginCore.getAICore().toggleHerobrinePlayerVisibility(event.getPlayer());
// Prevent player from moving when in Herobrine's Graveyard.