Added MiniPlaceholders support
This commit is contained in:
parent
8668feb8d0
commit
962ad1ee41
@ -25,6 +25,10 @@
|
|||||||
<id>codemc-snapshots</id>
|
<id>codemc-snapshots</id>
|
||||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -40,6 +44,11 @@
|
|||||||
<version>1.11-SNAPSHOT</version>
|
<version>1.11-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.4drian3d</groupId>
|
||||||
|
<artifactId>MiniPlaceholders</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -56,6 +56,10 @@ public class AuthMeVelocityPlugin {
|
|||||||
proxy.getEventManager().register(this, new FastLoginListener(proxy, api));
|
proxy.getEventManager().register(this, new FastLoginListener(proxy, api));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(proxy.getPluginManager().isLoaded("miniplaceholders")){
|
||||||
|
AuthmePlaceholders.getExpansion(this).register();
|
||||||
|
}
|
||||||
|
|
||||||
logger.info("-- AuthMeVelocity enabled --");
|
logger.info("-- AuthMeVelocity enabled --");
|
||||||
logger.info("AuthServers: {}", config.getAuthServers());
|
logger.info("AuthServers: {}", config.getAuthServers());
|
||||||
if(config.getToServerOptions().sendToServer()){
|
if(config.getToServerOptions().sendToServer()){
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.glyart.authmevelocity.proxy;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import me.dreamerzero.miniplaceholders.api.Expansion;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
|
|
||||||
|
final class AuthmePlaceholders {
|
||||||
|
private AuthmePlaceholders(){}
|
||||||
|
|
||||||
|
private static final Component TRUE = Component.text("true", NamedTextColor.GREEN);
|
||||||
|
private static final Component FALSE = Component.text("false", NamedTextColor.RED);
|
||||||
|
|
||||||
|
static Expansion getExpansion(AuthMeVelocityPlugin plugin){
|
||||||
|
return Expansion.builder("authme")
|
||||||
|
.filter(Player.class)
|
||||||
|
.audiencePlaceholder("is_logged", (aud, queue, ctx) ->
|
||||||
|
Tag.selfClosingInserting(plugin.getAPI().isLogged((Player)aud) ? TRUE : FALSE))
|
||||||
|
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
|
||||||
|
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
||||||
|
return Tag.selfClosingInserting(
|
||||||
|
plugin.getProxy().getPlayer(playerName).map(pl -> plugin.getAPI().isLogged(pl)).orElse(false)
|
||||||
|
? TRUE
|
||||||
|
: FALSE);
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
@ -26,13 +26,18 @@
|
|||||||
<id>codemc-repo</id>
|
<id>codemc-repo</id>
|
||||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -41,6 +46,12 @@
|
|||||||
<version>5.6.0-SNAPSHOT</version>
|
<version>5.6.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.4drian3d</groupId>
|
||||||
|
<artifactId>MiniPlaceholders</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -16,6 +16,10 @@ public class AuthMeVelocityPlugin extends JavaPlugin {
|
|||||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, CHANNEL);
|
this.getServer().getMessenger().registerOutgoingPluginChannel(this, CHANNEL);
|
||||||
this.getServer().getPluginManager().registerEvents(new AuthMeListener(this), this);
|
this.getServer().getPluginManager().registerEvents(new AuthMeListener(this), this);
|
||||||
|
|
||||||
|
if(this.getServer().getPluginManager().isPluginEnabled("MiniPlaceholders")){
|
||||||
|
AuthmePlaceholders.getExpansion().register();
|
||||||
|
}
|
||||||
|
|
||||||
this.getSLF4JLogger().info("AuthMeVelocity enabled");
|
this.getSLF4JLogger().info("AuthMeVelocity enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.glyart.authmevelocity.spigot;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||||
|
import me.dreamerzero.miniplaceholders.api.Expansion;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
|
|
||||||
|
final class AuthmePlaceholders {
|
||||||
|
private AuthmePlaceholders(){}
|
||||||
|
|
||||||
|
private static final Component TRUE = Component.text("true", NamedTextColor.GREEN);
|
||||||
|
private static final Component FALSE = Component.text("false", NamedTextColor.RED);
|
||||||
|
|
||||||
|
static Expansion getExpansion(){
|
||||||
|
return Expansion.builder("authme")
|
||||||
|
.audiencePlaceholder("is_logged", (aud, queue, ctx) ->
|
||||||
|
Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated((Player)aud)
|
||||||
|
? TRUE
|
||||||
|
: FALSE)
|
||||||
|
)
|
||||||
|
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
|
||||||
|
String playerName = queue.popOr(() -> "you need to provide a player name").value();
|
||||||
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
|
if(player == null) return Tag.selfClosingInserting(FALSE);
|
||||||
|
return Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated(player)
|
||||||
|
? TRUE
|
||||||
|
: FALSE);
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user