mirror of
https://github.com/Maxlego08/zKoth.git
synced 2025-02-17 01:52:25 +01:00
🐛 Fix TAB scoreboard
This commit is contained in:
parent
81c2a85e74
commit
5b2c0e923e
@ -1,7 +1,7 @@
|
||||
name: zKoth
|
||||
author: Maxlego08
|
||||
main: fr.maxlego08.zkoth.ZKothPlugin
|
||||
version: 2.1.0.5
|
||||
version: 2.1.0.8
|
||||
softdepend: [PlaceholderAPI, Guilds, Factions, FactionsX, SuperiorSkyblock2, LegacyFactions, FeatherBoard, TAB, TitleManager, UltimateFactions, Multiverse-Core, SternalBoard, SimpleClan]
|
||||
commands:
|
||||
api-version: 1.13
|
@ -179,7 +179,11 @@ public class ZKothManager extends ListenerAdapter implements KothManager {
|
||||
|
||||
@Override
|
||||
public Optional<Koth> getKoth(String name) {
|
||||
Optional<ZKoth> zKoth = koths.stream().filter(koth -> koth.getName().equalsIgnoreCase(name)).findFirst();
|
||||
if (name == null || name.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
Optional<ZKoth> zKoth = koths.stream()
|
||||
.filter(koth -> koth.getName() != null && koth.getName().equalsIgnoreCase(name)).findFirst();
|
||||
return zKoth.isPresent() ? Optional.of(zKoth.get()) : Optional.empty();
|
||||
}
|
||||
|
||||
@ -193,6 +197,12 @@ public class ZKothManager extends ListenerAdapter implements KothManager {
|
||||
return;
|
||||
}
|
||||
|
||||
int distance = Math.abs(minLocation.getBlockX() - maxLocation.getBlockY());
|
||||
if (distance <= 0) {
|
||||
message(sender, Message.ZKOTH_SIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
Koth koth = new ZKoth(name, captureSeconds, minLocation, maxLocation);
|
||||
|
||||
KothCreateEvent event = new KothCreateEvent(koth);
|
||||
|
@ -73,7 +73,6 @@ public class ZKothPlugin extends ZPlugin {
|
||||
}
|
||||
|
||||
if (this.isEnable(Plugins.TAB)) {
|
||||
System.out.println("ici !");
|
||||
this.scoreboardManager.setScoreboard(new TabPremiumHook());
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,12 @@ public class ScoreBoardManager extends ZUtils {
|
||||
|
||||
Iterator<FastBoard> iterator = this.boards.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
FastBoard b = iterator.next();
|
||||
if (b.isDeleted() || !b.getPlayer().isOnline()) {
|
||||
this.boards.remove(b.getPlayer());
|
||||
try {
|
||||
FastBoard b = iterator.next();
|
||||
if (b.isDeleted() || !b.getPlayer().isOnline()) {
|
||||
this.boards.remove(b.getPlayer());
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,38 +2,33 @@ package fr.maxlego08.zkoth.scoreboard.implementations;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.maxlego08.zkoth.api.Scoreboard;
|
||||
import fr.maxlego08.zkoth.zcore.ZPlugin;
|
||||
import me.neznamy.tab.api.TABAPI;
|
||||
import me.neznamy.tab.api.TabAPI;
|
||||
import me.neznamy.tab.api.TabPlayer;
|
||||
import me.neznamy.tab.api.scoreboard.ScoreboardManager;
|
||||
|
||||
public class TabPremiumHook implements Scoreboard {
|
||||
|
||||
@Override
|
||||
public void toggle(Player player, Consumer<Player> after) {
|
||||
TabPlayer tabPlayer = TABAPI.getPlayer(player.getUniqueId());
|
||||
if (tabPlayer != null && !tabPlayer.isScoreboardVisible()) {
|
||||
tabPlayer.toggleScoreboard(false);
|
||||
|
||||
TabAPI api = TabAPI.getInstance();
|
||||
TabPlayer tabPlayer = api.getPlayer(player.getUniqueId());
|
||||
ScoreboardManager manager = TabAPI.getInstance().getScoreboardManager();
|
||||
if (tabPlayer != null && manager != null) {
|
||||
manager.toggleScoreboard(tabPlayer, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide(Player player, Consumer<Player> after) {
|
||||
TabPlayer tabPlayer = TABAPI.getPlayer(player.getUniqueId());
|
||||
if (tabPlayer != null && tabPlayer.isScoreboardVisible()) {
|
||||
tabPlayer.toggleScoreboard(false);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskLater(ZPlugin.z(), () -> {
|
||||
final TabPlayer tabPlayer2 = TABAPI.getPlayer(player.getUniqueId());
|
||||
if (tabPlayer2 != null && tabPlayer2.isScoreboardVisible()) {
|
||||
tabPlayer2.toggleScoreboard(false);
|
||||
if (after != null)
|
||||
after.accept(player);
|
||||
}
|
||||
}, 20);
|
||||
TabAPI api = TabAPI.getInstance();
|
||||
TabPlayer tabPlayer = api.getPlayer(player.getUniqueId());
|
||||
ScoreboardManager manager = TabAPI.getInstance().getScoreboardManager();
|
||||
if (tabPlayer != null && manager != null) {
|
||||
manager.toggleScoreboard(tabPlayer, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ public enum Message {
|
||||
ZKOTH_AXE_POS1("§7You have just put the first position in §f%world%§7, §f%x%§7, §f%y%§7, §f%z%§7."),
|
||||
ZKOTH_AXE_POS2("§7You have just put the second position in §f%world%§7, §f%x%§7, §f%y%§7, §f%z%§7."),
|
||||
ZKOTH_ALREADY_EXIST("§cThe koth §f%name% §calready exists."),
|
||||
ZKOTH_SIZE("§cYour koth is too small, you can't create one that small. Then you will come on discord for support when the problem comes from you."),
|
||||
ZKOTH_DOESNT_EXIST("§cThe koth §f%name% §cdoesnt exists."),
|
||||
|
||||
ZKOTH_CREATE_SUCCESS("§7You just created the koth §f%name%§7."),
|
||||
|
Loading…
Reference in New Issue
Block a user