Added palceholderAPI supprt
This commit is contained in:
parent
da5df54b62
commit
bb9a72dbf6
5
pom.xml
5
pom.xml
@ -59,6 +59,11 @@
|
||||
<groupId>com.griefcraft</groupId>
|
||||
<artifactId>lwc</artifactId>
|
||||
</dependency>
|
||||
<!-- PlaceholderAPI -->
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Build -->
|
||||
|
@ -62,6 +62,7 @@ import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
||||
import com.massivecraft.factions.integration.V18.IntegrationV18;
|
||||
import com.massivecraft.factions.integration.V19.IntegrationV19;
|
||||
import com.massivecraft.factions.integration.lwc.IntegrationLwc;
|
||||
import com.massivecraft.factions.integration.placeholderapi.IntegrationPlaceholderAPI;
|
||||
import com.massivecraft.factions.integration.worldguard.IntegrationWorldGuard;
|
||||
import com.massivecraft.factions.mixin.PowerMixin;
|
||||
import com.massivecraft.factions.task.TaskEconLandReward;
|
||||
@ -178,6 +179,7 @@ public class Factions extends MassivePlugin
|
||||
public List<Class<?>> getClassesActiveIntegrations()
|
||||
{
|
||||
return MUtil.list(
|
||||
IntegrationPlaceholderAPI.class,
|
||||
IntegrationV18.class,
|
||||
IntegrationV19.class,
|
||||
IntegrationLwc.class,
|
||||
|
@ -0,0 +1,28 @@
|
||||
package com.massivecraft.factions.integration.placeholderapi;
|
||||
|
||||
import com.massivecraft.massivecore.Integration;
|
||||
|
||||
public class IntegrationPlaceholderAPI extends Integration
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static IntegrationPlaceholderAPI i = new IntegrationPlaceholderAPI();
|
||||
public static IntegrationPlaceholderAPI get() { return i; }
|
||||
private IntegrationPlaceholderAPI()
|
||||
{
|
||||
this.setPluginName("PlaceholderAPI");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void setIntegrationActiveInner(boolean active)
|
||||
{
|
||||
PlaceholderFactions.get().register();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.massivecraft.factions.integration.placeholderapi;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlaceholderFactions extends PlaceholderExpansion
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static PlaceholderFactions i = new PlaceholderFactions();
|
||||
public static PlaceholderFactions get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public String getIdentifier()
|
||||
{
|
||||
return "factions";
|
||||
}
|
||||
|
||||
public String getAuthor()
|
||||
{
|
||||
return "Madus";
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return Factions.get().getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, String params)
|
||||
{
|
||||
System.out.println("A");
|
||||
if (player == null) return null;
|
||||
System.out.println("B");
|
||||
|
||||
|
||||
MPlayer mplayer = MPlayer.get(player);
|
||||
if ("role".equals(params)) params = "rank";
|
||||
switch (params)
|
||||
{
|
||||
case "faction": return mplayer.getFaction().describeTo(mplayer);
|
||||
case "power": return Double.toString(mplayer.getPower());
|
||||
case "powermax": return Double.toString(mplayer.getPowerMax());
|
||||
case "factionpower": return Double.toString(mplayer.getFaction().getPower());
|
||||
case "factionpowermax": return Double.toString(mplayer.getFaction().getPowerMax());
|
||||
case "title": return mplayer.getTitle();
|
||||
case "rank": return mplayer.getRank().getName();
|
||||
case "claims": return Long.toString(BoardColl.get().getAll().stream().mapToInt(board -> board.getCount(mplayer.getFaction())).sum());
|
||||
case "onlinemembers": return Integer.toString(mplayer.getFaction().getMPlayersWhereOnlineTo(mplayer).size());
|
||||
case "allmembers": return Integer.toString(mplayer.getFaction().getMPlayers().size());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user