mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-05 11:57:14 +01:00
Add gradle publishing config, remove remaining player usage
This commit is contained in:
@@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "at.helpch"
|
||||
version = "1.0.0-experifuckingmental"
|
||||
version = "1.0.0"
|
||||
|
||||
description = "An awesome placeholder provider!"
|
||||
|
||||
@@ -37,8 +37,44 @@ java {
|
||||
disableAutoTargetJvm()
|
||||
}
|
||||
|
||||
val javaComponent: SoftwareComponent = components["java"]
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
eachFile { expand("version" to project.version) }
|
||||
}
|
||||
|
||||
withType<ShadowJar> {
|
||||
archiveClassifier.set("")
|
||||
|
||||
relocate("org.yaml.snakeyaml", "at.helpch.placeholderapi.libs.yaml")
|
||||
|
||||
exclude("META-INF/versions/**")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
artifactId = "placeholderapi-hytale"
|
||||
from(javaComponent)
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
if ("-DEV" in version.toString()) {
|
||||
url = uri("https://repo.extendedclip.com/snapshots")
|
||||
} else {
|
||||
url = uri("https://repo.extendedclip.com/releases")
|
||||
}
|
||||
|
||||
credentials {
|
||||
username = System.getenv("JENKINS_USER")
|
||||
password = System.getenv("JENKINS_PASS")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publish.get().setDependsOn(listOf(build.get()))
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public final class PlaceholderAPI {
|
||||
* @param text Text to parse the placeholders in
|
||||
* @return The text containing the parsed relational placeholders
|
||||
*/
|
||||
public static String setRelationalPlaceholders(Player one, Player two, String text) {
|
||||
public static String setRelationalPlaceholders(PlayerRef one, PlayerRef two, String text) {
|
||||
final Matcher matcher = RELATIONAL_PLACEHOLDER_PATTERN.matcher(text);
|
||||
|
||||
while (matcher.find()) {
|
||||
@@ -248,7 +248,7 @@ public final class PlaceholderAPI {
|
||||
* @param text text to parse the placeholder values to
|
||||
* @return The text containing the parsed relational placeholders
|
||||
*/
|
||||
public static List<String> setRelationalPlaceholders(Player one, Player two, List<String> text) {
|
||||
public static List<String> setRelationalPlaceholders(PlayerRef one, PlayerRef two, List<String> text) {
|
||||
return text.stream().map(line -> setRelationalPlaceholders(one, two, line))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -107,5 +107,4 @@ public abstract class PlaceholderCommand {
|
||||
@NotNull @Unmodifiable final List<String> params, @NotNull final List<String> suggestions) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.commands.PlaceholderCommand;
|
||||
import at.helpch.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.NameMatching;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandSender;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
@@ -99,20 +100,24 @@ public final class CommandParse extends PlaceholderCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player;
|
||||
PlayerRef player;
|
||||
|
||||
if ("me".equalsIgnoreCase(params.get(0))) {
|
||||
if (!(sender instanceof Player)) {
|
||||
if ("me".equalsIgnoreCase(params.getFirst())) {
|
||||
if (!(sender instanceof Player) && !(sender instanceof PlayerRef)) {
|
||||
sender.sendMessage(Message.raw("You must be a player to use ").color(Color.RED).insert(Message.raw("me").color(Color.GRAY)).insert(Message.raw(" as a target!").color(Color.RED)));
|
||||
// Msg.msg(sender, "&cYou must be a player to use &7me&c as a target!");
|
||||
return;
|
||||
}
|
||||
|
||||
player = ((Player) sender);
|
||||
if (sender instanceof Player) {
|
||||
player = ((Player) sender).getPlayerRef();
|
||||
}
|
||||
|
||||
player = (PlayerRef) sender;
|
||||
} else if ("--null".equalsIgnoreCase(params.get(0))) {
|
||||
player = null;
|
||||
} else {
|
||||
final Player target = resolvePlayer(params.get(0), sender instanceof Player ? ((Player) sender).getWorld() : Universe.get().getDefaultWorld());
|
||||
final PlayerRef target = resolvePlayer(params.get(0));
|
||||
if (target == null) {
|
||||
sender.sendMessage(Message.raw("Failed to find player: ").color(Color.RED).insert(Message.raw(params.get(0)).color(Color.WHITE)));
|
||||
// Msg.msg(sender, "&cFailed to find player: &7" + params.get(0));
|
||||
@@ -152,10 +157,10 @@ public final class CommandParse extends PlaceholderCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Player playerOne;
|
||||
PlayerRef playerOne;
|
||||
|
||||
if ("me".equalsIgnoreCase(params.get(0))) {
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player) && !(sender instanceof PlayerRef)) {
|
||||
sender.sendMessage(Message.raw("You must be a player to use ").color(Color.RED)
|
||||
.insert(Message.raw("me").color(Color.GRAY))
|
||||
.insert(Message.raw(" as a target!").color(Color.RED)));
|
||||
@@ -163,9 +168,13 @@ public final class CommandParse extends PlaceholderCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
playerOne = ((Player) sender);
|
||||
if (sender instanceof Player) {
|
||||
playerOne = ((Player) sender).getPlayerRef();
|
||||
}
|
||||
|
||||
playerOne = (PlayerRef) sender;
|
||||
} else {
|
||||
playerOne = resolvePlayer(params.get(0), sender instanceof Player ? ((Player) sender).getWorld() : Universe.get().getDefaultWorld());
|
||||
playerOne = resolvePlayer(params.get(0));
|
||||
}
|
||||
|
||||
if (playerOne == null/* || !playerOne.isOnline()*/) {
|
||||
@@ -174,18 +183,22 @@ public final class CommandParse extends PlaceholderCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Player playerTwo;
|
||||
PlayerRef playerTwo;
|
||||
|
||||
if ("me".equalsIgnoreCase(params.get(1))) {
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player) && !(sender instanceof PlayerRef)) {
|
||||
sender.sendMessage(Message.raw("You must be a player to use ").color(Color.RED).insert(Message.raw("me").color(Color.GRAY)).insert(Message.raw(" as a target!").color(Color.RED)));
|
||||
// Msg.msg(sender, "&cYou must be a player to use &7me&c as a target!");
|
||||
return;
|
||||
}
|
||||
|
||||
playerTwo = ((Player) sender);
|
||||
if (sender instanceof Player) {
|
||||
playerTwo = ((Player) sender).getPlayerRef();
|
||||
}
|
||||
|
||||
playerTwo = (PlayerRef) sender;
|
||||
} else {
|
||||
playerTwo = resolvePlayer(params.get(1), sender instanceof Player ? ((Player) sender).getWorld() : Universe.get().getDefaultWorld());
|
||||
playerTwo = resolvePlayer(params.get(1));
|
||||
}
|
||||
|
||||
if (playerTwo == null/* || !playerTwo.isOnline()*/) {
|
||||
@@ -195,7 +208,7 @@ public final class CommandParse extends PlaceholderCommand {
|
||||
}
|
||||
|
||||
final String message = PlaceholderAPI
|
||||
.setRelationalPlaceholders((Player) playerOne, (Player) playerTwo,
|
||||
.setRelationalPlaceholders(playerOne, playerTwo,
|
||||
String.join(" ", params.subList(2, params.size())));
|
||||
|
||||
sender.sendMessage(Message.raw(message));
|
||||
@@ -260,20 +273,20 @@ public final class CommandParse extends PlaceholderCommand {
|
||||
|
||||
|
||||
@Nullable
|
||||
private Player resolvePlayer(@NotNull final String name, @NotNull final World world) {
|
||||
private PlayerRef resolvePlayer(@NotNull final String name) {
|
||||
// Player target = Universe.get().getPlayerByUsername(name, NameMatching.EXACT);
|
||||
final Optional<Player> target = world.getPlayers().stream().filter(player -> player.getDisplayName().equals(name)).findAny();
|
||||
|
||||
if (target.isEmpty()) {
|
||||
// Not the best option, but Spigot doesn't offer a good replacement (as usual)
|
||||
// target = Bukkit.getOfflinePlayer(name);
|
||||
// final Optional<Player> target = world.getPlayers().stream().filter(player -> player.getDisplayName().equals(name)).findAny();
|
||||
//
|
||||
// return target.hasPlayedBefore() ? target : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
return target.get();
|
||||
|
||||
// if (target.isEmpty()) {
|
||||
// // Not the best option, but Spigot doesn't offer a good replacement (as usual)
|
||||
//// target = Bukkit.getOfflinePlayer(name);
|
||||
////
|
||||
//// return target.hasPlayedBefore() ? target : null;
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return target.get();
|
||||
return Universe.get().getPlayerByUsername(name, NameMatching.EXACT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,13 @@ import java.util.regex.Pattern;
|
||||
|
||||
import at.helpch.placeholderapi.PlaceholderAPIPlugin;
|
||||
import at.helpch.placeholderapi.PlaceholderHook;
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.component.Store;
|
||||
import com.hypixel.hytale.server.core.HytaleServer;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.plugin.PluginBase;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -526,4 +531,16 @@ public abstract class PlaceholderExpansion implements PlaceholderHook {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Player player(@NotNull final PlayerRef target) {
|
||||
final Ref<EntityStore> ref = target.getReference();
|
||||
|
||||
if (ref == null || !ref.isValid()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Store<EntityStore> store = ref.getStore();
|
||||
|
||||
return store.isInThread() ? store.getComponent(ref, Player.getComponentType()) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package at.helpch.placeholderapi.expansion;
|
||||
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
|
||||
/**
|
||||
* Implementing this interface allows your {@link at.helpch.placeholderapi.expansion.PlaceholderExpansion PlaceholderExpansion}
|
||||
@@ -39,5 +40,5 @@ public interface Relational {
|
||||
* @param identifier The text right after the expansion's name (%expansion_<b>identifier</b>%)
|
||||
* @return Parsed String from the expansion.
|
||||
*/
|
||||
String onPlaceholderRequest(Player one, Player two, String identifier);
|
||||
String onPlaceholderRequest(PlayerRef one, PlayerRef two, String identifier);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class CharsReplacer implements Replacer {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String replacement = placeholder.onRequest(player, parametersString);
|
||||
final String replacement = placeholder.onPlaceholderRequest(player, parametersString);
|
||||
if (replacement == null) {
|
||||
builder.append(closure.head).append(identifierString);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user