mirror of
https://github.com/Maxlego08/zKoth.git
synced 2024-11-13 10:34:13 +01:00
📝 Add superiorskyblock hook
This commit is contained in:
parent
e696b80e74
commit
f2494891b1
10
pom.xml
10
pom.xml
@ -99,6 +99,10 @@
|
||||
<id>william278.net</id>
|
||||
<url>https://repo.william278.net/releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bg-repo</id>
|
||||
<url>https://repo.bg-software.com/repository/api/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@ -199,5 +203,11 @@
|
||||
<systemPath>${basedir}/libs/DecentHolograms-2.8.6.jar</systemPath>
|
||||
<scope>system</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bgsoftware</groupId>
|
||||
<artifactId>SuperiorSkyblockAPI</artifactId>
|
||||
<version>2022.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -4,6 +4,7 @@ import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothTeam;
|
||||
import fr.maxlego08.koth.hook.teams.HuskTownHook;
|
||||
import fr.maxlego08.koth.hook.teams.LandHook;
|
||||
import fr.maxlego08.koth.hook.teams.SuperiorSkyblock2Hook;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@ -13,6 +14,7 @@ public enum TeamPlugin {
|
||||
|
||||
LANDS("Lands", LandHook.class),
|
||||
HUSKTOWN("HuskTowns", HuskTownHook.class),
|
||||
SUPERIORSKYBLOCK("SuperiorSkyblock2", SuperiorSkyblock2Hook.class),
|
||||
|
||||
;
|
||||
|
||||
|
62
src/fr/maxlego08/koth/hook/teams/SuperiorSkyblock2Hook.java
Normal file
62
src/fr/maxlego08/koth/hook/teams/SuperiorSkyblock2Hook.java
Normal file
@ -0,0 +1,62 @@
|
||||
package fr.maxlego08.koth.hook.teams;
|
||||
|
||||
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblock;
|
||||
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;
|
||||
import com.bgsoftware.superiorskyblock.api.events.IslandDisbandEvent;
|
||||
import com.bgsoftware.superiorskyblock.api.island.Island;
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothTeam;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SuperiorSkyblock2Hook implements KothTeam {
|
||||
|
||||
private final KothPlugin plugin;
|
||||
|
||||
public SuperiorSkyblock2Hook(KothPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private Island getIsland(Player player) {
|
||||
return SuperiorSkyblockAPI.getPlayer(player).getIsland();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFactionTag(Player player) {
|
||||
Island island = getIsland(player);
|
||||
return island == null ? player.getName() : getIsland(player).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getOnlinePlayer(Player player) {
|
||||
Island island = getIsland(player);
|
||||
if (island == null) return Collections.singletonList(player);
|
||||
|
||||
return island.getIslandMembers(true).stream().map(p -> Bukkit.getOfflinePlayer(p.getUniqueId()))
|
||||
.filter(OfflinePlayer::isOnline).map(OfflinePlayer::getPlayer).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLeaderName(Player player) {
|
||||
Island island = getIsland(player);
|
||||
return island != null ? island.getOwner().getName() : player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeamId(Player player) {
|
||||
Island island = getIsland(player);
|
||||
return island != null ? island.getUniqueId().toString() : player.getUniqueId().toString();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onIslandDisband(IslandDisbandEvent event) {
|
||||
this.plugin.getStorageManager().onTeamDisband(event.getIsland().getUniqueId().toString());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user