invis ninja compatibility
This commit is contained in:
parent
c22bd468d5
commit
570391ff7c
5 changed files with 27 additions and 8 deletions
|
|
@ -20,6 +20,7 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly "pl.piecuu.jajoptak:leaf-api:1.21.11-R0.1-SNAPSHOT"
|
compileOnly "pl.piecuu.jajoptak:leaf-api:1.21.11-R0.1-SNAPSHOT"
|
||||||
compileOnly "me.clip:placeholderapi:2.11.7"
|
compileOnly "me.clip:placeholderapi:2.11.7"
|
||||||
|
compileOnly "pl.piecuu.invisninja:invis_ninja:1.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,32 @@ package pl.piecuu.killstreak;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import pl.piecuu.invisninja.InvisNinja;
|
||||||
|
|
||||||
public class Killstreak extends JavaPlugin implements Listener {
|
public class Killstreak extends JavaPlugin implements Listener {
|
||||||
|
private static InvisNinja invisNinja;
|
||||||
|
public static InvisNinja getInvisNinja() {
|
||||||
|
return invisNinja;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
PluginManager pm = Bukkit.getPluginManager();
|
||||||
|
if (pm.isPluginEnabled("PlaceholderAPI")) {
|
||||||
|
if(pm.isPluginEnabled("invisninja")) {
|
||||||
|
invisNinja = (InvisNinja)pm.getPlugin("invisninja");
|
||||||
|
}
|
||||||
|
|
||||||
new KillstreakExpansion().register();
|
new KillstreakExpansion().register();
|
||||||
new KillstreakManager(this);
|
new KillstreakManager(this);
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
pm.registerEvents(this, this);
|
||||||
Bukkit.getPluginManager().registerEvents(new PlayerManager(this), this);
|
pm.registerEvents(new PlayerManager(this), this);
|
||||||
} else {
|
} else {
|
||||||
getLogger().warning("Could not find PlaceholderAPI! This plugin is required.");
|
getLogger().warning("Could not find PlaceholderAPI! This plugin is required.");
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
pm.disablePlugin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import org.bukkit.persistence.PersistentDataType;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
import pl.piecuu.invisninja.InvisNinja;
|
||||||
|
|
||||||
public class KillstreakManager {
|
public class KillstreakManager {
|
||||||
private static KillstreakManager instance;
|
private static KillstreakManager instance;
|
||||||
|
|
@ -43,8 +44,11 @@ public class KillstreakManager {
|
||||||
setKillstreak(player, 0L);
|
setKillstreak(player, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldAnnounceKillstreak(long killstreak) {
|
public boolean shouldAnnounceKillstreak(long killstreak, Player p) {
|
||||||
return killstreak >= 5 && killstreak % 5 == 0;
|
InvisNinja in = plugin.getInvisNinja();
|
||||||
|
if(in != null && in.isPlayerInvisible(p)) return false;
|
||||||
|
|
||||||
|
return (killstreak >= 5 && killstreak % 5 == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor(long killstreak) {
|
public int getColor(long killstreak) {
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class PlayerManager implements Listener {
|
||||||
final long killstreak = km.increaseKillstreak(attacker, 1L);
|
final long killstreak = km.increaseKillstreak(attacker, 1L);
|
||||||
if(killstreak >= 3) this.playKillSound(p);
|
if(killstreak >= 3) this.playKillSound(p);
|
||||||
|
|
||||||
if(km.shouldAnnounceKillstreak(killstreak)) {
|
if(km.shouldAnnounceKillstreak(killstreak, attacker)) {
|
||||||
final TextColor blueColor = TextColor.color(0x40b5e3);
|
final TextColor blueColor = TextColor.color(0x40b5e3);
|
||||||
final Component component = attacker.displayName()
|
final Component component = attacker.displayName()
|
||||||
.append(Component.text(" osiągnął killstreak ").color(blueColor))
|
.append(Component.text(" osiągnął killstreak ").color(blueColor))
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,4 @@ main: pl.piecuu.killstreak.Killstreak
|
||||||
api-version: '1.21.11'
|
api-version: '1.21.11'
|
||||||
|
|
||||||
depend: ["PlaceholderAPI"]
|
depend: ["PlaceholderAPI"]
|
||||||
|
softdepend: ["invisninja"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue