LunaChat v3.0.1 : Added BungeePerms co-operation. #170
このコミットが含まれているのは:
1 親
4e0c3e50e3
コミット
4a5bc4ccfa
5ファイル変更
+104
-13
検索条件に一致するファイルはありません
@@ -11,6 +11,7 @@ import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.github.ucchyocean.lc3.bridge.BungeePermsBridge;
|
||||
import com.github.ucchyocean.lc3.bungee.BungeeEventListener;
|
||||
import com.github.ucchyocean.lc3.bungee.BungeeEventSender;
|
||||
import com.github.ucchyocean.lc3.bungee.JapanizeCommandBungee;
|
||||
@@ -37,6 +38,8 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
private UUIDCacheData uuidCacheData;
|
||||
private LunaChatLogger normalChatLogger;
|
||||
|
||||
private BungeePermsBridge bungeeperms;
|
||||
|
||||
/**
|
||||
* プラグインが有効化されたときに呼び出されるメソッド
|
||||
* @see net.md_5.bungee.api.plugin.Plugin#onEnable()
|
||||
@@ -61,6 +64,9 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
manager.removeAllDefaultChannels();
|
||||
}
|
||||
|
||||
// BungeePermsのロード
|
||||
bungeeperms = BungeePermsBridge.load();
|
||||
|
||||
// コマンド登録
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new LunaChatCommandBungee("lunachat", "", "lc", "ch"));
|
||||
@@ -196,4 +202,12 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
public void runAsyncTask(Runnable task) {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(this, task);
|
||||
}
|
||||
|
||||
/**
|
||||
* BungeePerms連携クラスを取得する
|
||||
* @return BungeePerms連携クラス
|
||||
*/
|
||||
public BungeePermsBridge getBungeePerms() {
|
||||
return bungeeperms;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bridge;
|
||||
|
||||
import net.alpenblock.bungeeperms.BungeePermsAPI;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
/**
|
||||
* BungeePerms連携クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BungeePermsBridge {
|
||||
|
||||
// コンストラクタは外から利用不可
|
||||
private BungeePermsBridge() {
|
||||
}
|
||||
|
||||
/**
|
||||
* BungeePermsをロードする
|
||||
* @return ロードされたBungeePermsBridge
|
||||
*/
|
||||
public static BungeePermsBridge load() {
|
||||
|
||||
// BungeePermsが動作しているかどうか確認
|
||||
boolean loaded = ProxyServer.getInstance().getPluginManager().getPlugin("BungeePerms") != null;
|
||||
|
||||
// ロードされているならBungeePermsBridgeのインスタンスを、ロードされていないならnullを返す
|
||||
return loaded ? new BungeePermsBridge() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the full prefix of the player
|
||||
* @param nameoruuid the username or uuid of the player
|
||||
* @param server the server; may be null; if server == "" then the current server is used or null if BungeeCord
|
||||
* @param world the world; may be null
|
||||
* @return the full prefix; may be null
|
||||
*/
|
||||
public String userPrefix(String nameoruuid, String server, String world) {
|
||||
return BungeePermsAPI.userPrefix(nameoruuid, server, world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the full suffix of the player
|
||||
* @param nameoruuid the username or uuid of the player
|
||||
* @param server the server; may be null; if server == "" then the current server is used or null if BungeeCord
|
||||
* @param world the world; may be null
|
||||
* @return the full suffix; may be null
|
||||
*/
|
||||
public String userSuffix(String nameoruuid, String server, String world) {
|
||||
return BungeePermsAPI.userSuffix(nameoruuid, server, world);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.github.ucchyocean.lc3.LunaChatBungee;
|
||||
import com.github.ucchyocean.lc3.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
import com.github.ucchyocean.lc3.Utility;
|
||||
import com.github.ucchyocean.lc3.bridge.BungeePermsBridge;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.event.EventResult;
|
||||
import com.github.ucchyocean.lc3.japanize.Japanizer;
|
||||
@@ -412,9 +413,16 @@ public class BungeeEventListener implements Listener {
|
||||
}
|
||||
|
||||
if ( format.contains("%prefix") || format.contains("%suffix") ) {
|
||||
// TODO 未実装
|
||||
format = format.replace("%prefix", "");
|
||||
format = format.replace("%suffix", "");
|
||||
|
||||
String prefix = "";
|
||||
String suffix = "";
|
||||
BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms();
|
||||
if ( bungeeperms != null ) {
|
||||
prefix = bungeeperms.userPrefix(player.getUniqueId().toString(), null, null);
|
||||
suffix = bungeeperms.userSuffix(player.getUniqueId().toString(), null, null);
|
||||
}
|
||||
format = format.replace("%prefix", prefix);
|
||||
format = format.replace("%suffix", suffix);
|
||||
}
|
||||
|
||||
if ( format.contains("%world") ) {
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.util.UUID;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatBungee;
|
||||
import com.github.ucchyocean.lc3.bridge.BungeePermsBridge;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -49,7 +51,6 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee {
|
||||
if ( nameOrUuid.startsWith("$") ) {
|
||||
return new ChannelMemberProxiedPlayer(UUID.fromString(nameOrUuid.substring(1)));
|
||||
} else {
|
||||
// TODO オフラインのプレイヤー取得について検討する
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(nameOrUuid);
|
||||
if ( player != null ) return new ChannelMemberProxiedPlayer(player.getUniqueId());
|
||||
}
|
||||
@@ -104,10 +105,11 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee {
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
|
||||
// TODO 未実装
|
||||
|
||||
return "";
|
||||
BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms();
|
||||
if ( bungeeperms == null ) {
|
||||
return "";
|
||||
}
|
||||
return bungeeperms.userPrefix(id.toString(), null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,10 +119,11 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee {
|
||||
*/
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
|
||||
// TODO 未実装
|
||||
|
||||
return "";
|
||||
BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms();
|
||||
if ( bungeeperms == null ) {
|
||||
return "";
|
||||
}
|
||||
return bungeeperms.userSuffix(id.toString(), null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +174,6 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee {
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermissionSet(String node) {
|
||||
// TODO 要テスト
|
||||
ProxiedPlayer player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return player.getPermissions().contains(node);
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする