mirror of
https://github.com/Maxlego08/zKoth.git
synced 2025-02-19 02:11:29 +01:00
📝 Add Ultimate clan and fix papi
This commit is contained in:
parent
145c4bf4d6
commit
c042183c2b
@ -1,3 +1,7 @@
|
||||
# Unreleased
|
||||
|
||||
- Fix errors with Placeholders
|
||||
|
||||
# 3.0.6
|
||||
|
||||
- Some fixs
|
||||
|
@ -184,6 +184,12 @@
|
||||
<version>2.15.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.UlrichBR</groupId>
|
||||
<artifactId>UClansV7-API</artifactId>
|
||||
<version>7.7.0-r1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ShieldCommunity</groupId>
|
||||
<artifactId>SternalBoard</artifactId>
|
||||
|
6
pom.xml
6
pom.xml
@ -242,5 +242,11 @@
|
||||
<systemPath>${basedir}/libs/GangsPlus-2.6.4.jar</systemPath>
|
||||
<scope>system</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.UlrichBR</groupId>
|
||||
<artifactId>UClansV7-API</artifactId>
|
||||
<version>7.7.0-r1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -120,9 +120,14 @@ public class KothPlaceholder extends ZUtils {
|
||||
try {
|
||||
return consumer.accept(Integer.parseInt(argument), optional.get());
|
||||
} catch (Exception exception) {
|
||||
if (Config.enableDebug) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return consumer.accept(-1, optional.get());
|
||||
}
|
||||
} else return Config.noKoth;
|
||||
} else {
|
||||
return Config.noKoth;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ public class ZKoth extends ZUtils implements Koth {
|
||||
public PlayerResult getPlayer(int position) {
|
||||
|
||||
this.sortScores();
|
||||
if (this.playerResults.size() > position) return Config.defaultPlayerResult;
|
||||
if (this.playerResults.isEmpty() || position > this.playerResults.size()) return Config.defaultPlayerResult;
|
||||
return this.playerResults.get(position - 1);
|
||||
}
|
||||
|
||||
|
@ -35,4 +35,15 @@ public class PlayerResult {
|
||||
public String getTeamLeader() {
|
||||
return teamLeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlayerResult{" +
|
||||
"playerName='" + playerName + '\'' +
|
||||
", points=" + points +
|
||||
", teamName='" + teamName + '\'' +
|
||||
", teamId='" + teamId + '\'' +
|
||||
", teamLeader='" + teamLeader + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import fr.maxlego08.koth.hook.teams.LandHook;
|
||||
import fr.maxlego08.koth.hook.teams.SaberFactionHook;
|
||||
import fr.maxlego08.koth.hook.teams.SimpleClanHook;
|
||||
import fr.maxlego08.koth.hook.teams.SuperiorSkyblock2Hook;
|
||||
import fr.maxlego08.koth.hook.teams.UltimateClan;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@ -23,6 +24,7 @@ public enum TeamPlugin {
|
||||
FACTIONS("Factions", SaberFactionHook.class),
|
||||
SIMPLECLANS("SimpleClans", SimpleClanHook.class),
|
||||
GANGSPLUS("GangsPlus", GangsHook.class),
|
||||
ULTIMATE_CLANS("UltimateClans", UltimateClan.class),
|
||||
|
||||
;
|
||||
|
||||
|
56
src/fr/maxlego08/koth/hook/teams/UltimateClan.java
Normal file
56
src/fr/maxlego08/koth/hook/teams/UltimateClan.java
Normal file
@ -0,0 +1,56 @@
|
||||
package fr.maxlego08.koth.hook.teams;
|
||||
|
||||
import fr.maxlego08.koth.KothPlugin;
|
||||
import fr.maxlego08.koth.api.KothTeam;
|
||||
import me.ulrich.clans.Clans;
|
||||
import me.ulrich.clans.data.ClanData;
|
||||
import me.ulrich.clans.events.ClanDeleteEvent;
|
||||
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.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UltimateClan implements KothTeam {
|
||||
|
||||
private final KothPlugin plugin;
|
||||
private final Clans clans;
|
||||
|
||||
public UltimateClan(KothPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.clans = (Clans) Bukkit.getPluginManager().getPlugin("UltimateClans");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeamName(OfflinePlayer player) {
|
||||
Optional<ClanData> optional = this.clans.getPlayerAPI().getPlayerClan(player.getUniqueId());
|
||||
return optional.isPresent() ? optional.get().getTag() : player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getOnlinePlayer(OfflinePlayer player) {
|
||||
Optional<ClanData> optional = this.clans.getPlayerAPI().getPlayerClan(player.getUniqueId());
|
||||
return optional.map(clanData -> clanData.getOnlineMembers().stream().map(Bukkit::getPlayer).collect(Collectors.toList())).orElseGet(() -> Collections.singletonList(player.getPlayer()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLeaderName(OfflinePlayer player) {
|
||||
Optional<ClanData> optional = this.clans.getPlayerAPI().getPlayerClan(player.getUniqueId());
|
||||
return optional.isPresent() ? Bukkit.getOfflinePlayer(optional.get().getLeader()).getName() : player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeamId(OfflinePlayer player) {
|
||||
Optional<ClanData> optional = this.clans.getPlayerAPI().getPlayerClan(player.getUniqueId());
|
||||
return optional.isPresent() ? optional.get().getId().toString() : player.getUniqueId().toString();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDelete(ClanDeleteEvent event) {
|
||||
this.plugin.getStorageManager().onTeamDisband(String.valueOf(event.getClanID().toString()));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user