Initial commit: LoChat v1.0.0 with Gradient module
This commit is contained in:
commit
252b0a60db
86 changed files with 8922 additions and 0 deletions
|
|
@ -0,0 +1,91 @@
|
|||
package com.loki.lochat.integrations;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.gradient.GradientModule;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlaceholderAPIHook extends PlaceholderExpansion {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
public PlaceholderAPIHook(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return "lochat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return "loki";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return plugin.getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||
if (player == null) return "";
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
GradientModule gradient = plugin.getGradientModule();
|
||||
|
||||
return switch (params.toLowerCase()) {
|
||||
case "muted" -> String.valueOf(plugin.getMuteManager().isMuted(uuid));
|
||||
case "mute_time" -> {
|
||||
String time = plugin.getMuteManager().getRemainingTime(uuid);
|
||||
yield time != null ? time : "0";
|
||||
}
|
||||
case "mute_reason" -> {
|
||||
String reason = plugin.getMuteManager().getReason(uuid);
|
||||
yield reason != null ? reason : "";
|
||||
}
|
||||
case "ignored_count" -> String.valueOf(plugin.getIgnoreManager().getIgnoredCount(uuid));
|
||||
case "global_enabled" -> String.valueOf(!plugin.getChatManager().isGlobalChatDisabled(uuid));
|
||||
case "last_pm" -> {
|
||||
UUID last = plugin.getPmManager().getLastConversation(uuid);
|
||||
if (last == null) yield "";
|
||||
var lastPlayer = Bukkit.getOfflinePlayer(last);
|
||||
yield lastPlayer.getName() != null ? lastPlayer.getName() : "";
|
||||
}
|
||||
case "spy_enabled" -> String.valueOf(plugin.getSpyManager().isSpying(uuid));
|
||||
|
||||
// Gradient placeholders (совместимость с LoPreff)
|
||||
case "gradient_full", "full" -> {
|
||||
if (gradient == null || !gradient.isEnabled()) yield player.getName();
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) yield player.getName();
|
||||
yield gradient.getFormattedName(onlinePlayer);
|
||||
}
|
||||
case "gradient_name", "name" -> {
|
||||
if (gradient == null || !gradient.isEnabled()) yield player.getName();
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) yield player.getName();
|
||||
yield gradient.getGradientNick(onlinePlayer);
|
||||
}
|
||||
case "gradient_prefix", "prefix" -> {
|
||||
if (gradient == null || !gradient.isEnabled()) yield "";
|
||||
Player onlinePlayer = player.getPlayer();
|
||||
if (onlinePlayer == null) yield "";
|
||||
yield gradient.getPrefix(onlinePlayer);
|
||||
}
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue