Merge pull request #112 from RealGatt/feature/remove-per-player-hologram
Feature/remove per player hologram
This commit is contained in:
commit
f3377b0519
|
@ -28,7 +28,23 @@ public interface NPC {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param uniqueLines The text that the targetPlayer will see
|
||||
* @param targetPlayer The target player
|
||||
* @return object instance
|
||||
* @author Gatt
|
||||
*/
|
||||
NPC removePlayerLines(Player targetPlayer);
|
||||
/**
|
||||
*
|
||||
* @param targetPlayer The target player
|
||||
* @param update whether or not to update the hologram
|
||||
* @return object instance
|
||||
* @author Gatt
|
||||
*/
|
||||
NPC removePlayerLines(Player targetPlayer, boolean update);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param uniqueLines The text that the targetPlayer will see. Null to remove
|
||||
* @param targetPlayer The target player
|
||||
* @return object instance
|
||||
* @author Gatt
|
||||
|
@ -49,6 +65,7 @@ public interface NPC {
|
|||
*
|
||||
* @param targetPlayer The target player
|
||||
* @return the lines that the targetPlayer will see, if null; default lines.
|
||||
* @author Gatt
|
||||
*/
|
||||
List<String> getPlayerLines(Player targetPlayer);
|
||||
|
||||
|
|
|
@ -73,10 +73,26 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
|
|||
return playerHologram;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NPC removePlayerLines(Player targetPlayer) {
|
||||
Validate.notNull(targetPlayer, "Player cannot be null.");
|
||||
setPlayerLines(null, targetPlayer);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC removePlayerLines(Player targetPlayer, boolean update) {
|
||||
Validate.notNull(targetPlayer, "Player cannot be null.");
|
||||
setPlayerLines(null, targetPlayer, update);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC setPlayerLines(List<String> uniqueLines, Player targetPlayer) {
|
||||
Validate.notNull(targetPlayer, "Player cannot be null.");
|
||||
uniqueText.put(targetPlayer.getUniqueId(), uniqueLines);
|
||||
if (uniqueLines == null) uniqueText.remove(targetPlayer.getUniqueId());
|
||||
else uniqueText.put(targetPlayer.getUniqueId(), uniqueLines);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -86,6 +102,9 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
|
|||
List<String> originalLines = getPlayerLines(targetPlayer);
|
||||
setPlayerLines(uniqueLines, targetPlayer);
|
||||
if (update) {
|
||||
|
||||
uniqueLines = getPlayerLines(targetPlayer); // retrieve the player lines from this function, incase it's been removed.
|
||||
|
||||
if (originalLines.size() != uniqueLines.size()) { // recreate the entire hologram
|
||||
Hologram originalhologram = getPlayerHologram(targetPlayer);
|
||||
originalhologram.hide(targetPlayer); // essentially destroy the hologram
|
||||
|
|
Loading…
Reference in New Issue