*Added new option "ShowInTabList" to the configuration. This option allows the server administrator to set whether Herobrine will always show in the tab list or will only show to Herobrine's current target.

*Updated version number from 1.2.2 to 1.2.3.
*Updated internal version number from six to seven.
This commit is contained in:
David Berdik 2015-11-26 19:33:24 -05:00
parent 7b8b8d90bc
commit 095e5c49f1
5 changed files with 31 additions and 7 deletions

View File

@ -216,13 +216,15 @@ public class AICore {
}
private void removeHero(Player p){
//make hero invisible
EntityPlayer pcon = ((CraftPlayer) p).getHandle();
pcon.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, HerobrineAI.herobrineNPC.getNMSEntity()));
// Remove Herobrine from the tab list unless he is configured to always be listed.
if(!HerobrineAI.getPluginCore().getConfigDB().ShowInTabList) {
EntityPlayer pcon = ((CraftPlayer) p).getHandle();
pcon.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, HerobrineAI.herobrineNPC.getNMSEntity()));
}
}
private void showHero(Player p){
//make hero visible
public static void showHero(Player p){
// Show Herobrine in the tab list.
EntityPlayer pcon = ((CraftPlayer) p).getHandle();
pcon.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, HerobrineAI.herobrineNPC.getNMSEntity()));
}

View File

@ -88,6 +88,7 @@ public class ConfigDB
public String HerobrineWorldName = "world_herobrine_graveyard";
public String HerobrineUUID = "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2";
public boolean UseSound = true;
public boolean ShowInTabList = false;
private boolean isStartupDone = false;
public ConfigDB(Logger l)
@ -263,6 +264,7 @@ public class ConfigDB
this.config.set("config.HerobrineWorldName", "world_herobrine_graveyard");
this.config.set("config.HerobrineUUID", "f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2");
this.config.set("config.UseHauntSound", Boolean.valueOf(true));
this.config.set("config.ShowInTabList", Boolean.valueOf(false));
try
{
this.config.save(this.configF);
@ -523,6 +525,15 @@ public class ConfigDB
this.config.set("config.UseHauntSound", Boolean.valueOf(true));
}
if (!this.config.contains("config.ShowInTabList"))
{
if (!hasUpdated) {
this.log.info("[Herobrine] Updating old config...");
}
hasUpdated = true;
this.config.set("config.ShowInTabList", Boolean.valueOf(false));
}
if (hasUpdated)
{
try
@ -627,6 +638,7 @@ public class ConfigDB
this.HerobrineWorldName = this.config.getString("config.HerobrineWorldName");
this.HerobrineUUID = this.config.getString("config.HerobrineUUID");
this.UseSound = this.config.getBoolean("config.UseHauntSound");
this.ShowInTabList = this.config.getBoolean("config.ShowInTabList");
HerobrineAI.HerobrineMaxHP = this.HerobrineHP;
HerobrineAI.getPluginCore().getAICore().stopMAIN();
HerobrineAI.getPluginCore().getAICore().startMAIN();

View File

@ -60,7 +60,7 @@ public class HerobrineAI extends JavaPlugin implements Listener {
public Location hbSpawnData = null;
public boolean removeHBNextTick = false;
public String pluginVersionCount = "6";
public String pluginVersionCount = "7";
@Override
public void onEnable() {

View File

@ -23,6 +23,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -185,6 +186,15 @@ public class PlayerListener implements Listener {
event.setCancelled(true);
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
// If the plugin is configured to show Herobrine in the tab list, add him to the list
// when the user logs on.
if(HerobrineAI.getPluginCore().getConfigDB().ShowInTabList) {
AICore.showHero(event.getPlayer());
}
}
@EventHandler
public void onPlayerDeathEvent(final PlayerDeathEvent event) {

View File

@ -1,6 +1,6 @@
name: Herobrine
main: net.theprogrammersworld.herobrine.HerobrineAI
version: 1.2.2
version: 1.2.3
commands:
herobrine:
description: Main command.