invis killstreak
This commit is contained in:
parent
0ac192a12e
commit
43dd143d96
2 changed files with 22 additions and 1 deletions
|
|
@ -36,6 +36,13 @@ public class KillstreakExpansion extends PlaceholderExpansion {
|
||||||
final long killstreak = km.getKillstreak(p);
|
final long killstreak = km.getKillstreak(p);
|
||||||
if(killstreak == 0) return "";
|
if(killstreak == 0) return "";
|
||||||
|
|
||||||
|
final Component output = km.getKillstreakComponent(killstreak);
|
||||||
|
return MiniMessage.miniMessage().serialize(output);
|
||||||
|
} else if(identifier.equalsIgnoreCase("killstreak_invis")) {
|
||||||
|
KillstreakManager km = KillstreakManager.getInstance();
|
||||||
|
final long killstreak = km.getInvisKillstreak(p);
|
||||||
|
if(killstreak == 0) return "";
|
||||||
|
|
||||||
final Component output = km.getKillstreakComponent(killstreak);
|
final Component output = km.getKillstreakComponent(killstreak);
|
||||||
return MiniMessage.miniMessage().serialize(output);
|
return MiniMessage.miniMessage().serialize(output);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,18 +17,32 @@ public class KillstreakManager {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
public NamespacedKey playerKillstreakKey;
|
public NamespacedKey playerKillstreakKey;
|
||||||
|
public NamespacedKey playerInvisKSKey;
|
||||||
|
|
||||||
private Killstreak plugin;
|
private Killstreak plugin;
|
||||||
public KillstreakManager(Killstreak plugin) {
|
public KillstreakManager(Killstreak plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
instance = this;
|
instance = this;
|
||||||
this.playerKillstreakKey = new NamespacedKey(plugin, "playerKillstreakKey");
|
this.playerKillstreakKey = new NamespacedKey(plugin, "playerKillstreakKey");
|
||||||
|
this.playerInvisKSKey = new NamespacedKey(plugin, "playerInvisKSKey");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setKillstreak(Player player, long streak) {
|
public void setKillstreak(Player player, long streak) {
|
||||||
if(streak < 0) return;
|
if(streak < 0) return;
|
||||||
player.getPersistentDataContainer().set(playerKillstreakKey, PersistentDataType.LONG, streak);
|
player.getPersistentDataContainer().set(playerKillstreakKey, PersistentDataType.LONG, streak);
|
||||||
|
if(Killstreak.getInvisNinja() == null || !InvisNinja.isPlayerInvisible(player)) {
|
||||||
|
setInvisKillstreak(player, streak);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvisKillstreak(Player player, long streak) {
|
||||||
|
if(streak < 0) return;
|
||||||
|
player.getPersistentDataContainer().set(playerInvisKSKey, PersistentDataType.LONG, streak);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getInvisKillstreak(Player player) {
|
||||||
|
if(Killstreak.getInvisNinja() == null || !InvisNinja.isPlayerInvisible(player)) return getKillstreak(player);
|
||||||
|
return player.getPersistentDataContainer().getOrDefault(playerInvisKSKey, PersistentDataType.LONG, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getKillstreak(OfflinePlayer player) {
|
public long getKillstreak(OfflinePlayer player) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue