LunaChat v2.6.0 : Added auto update schem for UUID.
このコミットが含まれているのは:
1 親
2459af7e2b
コミット
b367917c55
3ファイル変更
+74
-41
検索条件に一致するファイルはありません
@@ -17,6 +17,7 @@ import java.io.OutputStreamWriter;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
@@ -181,4 +182,42 @@ public class Utility {
|
||||
}
|
||||
return code.matches("&[0-9a-f]");
|
||||
}
|
||||
|
||||
/**
|
||||
* 現在動作中のCraftBukkitが、v1.7.8 以上かどうかを確認する
|
||||
* @return v1.7.8以上ならtrue、そうでないならfalse
|
||||
*/
|
||||
public static boolean isCB178orLater() {
|
||||
|
||||
int[] borderNumbers = {1, 7, 8};
|
||||
|
||||
String version = Bukkit.getBukkitVersion();
|
||||
int hyphen = version.indexOf("-");
|
||||
if ( hyphen > 0 ) {
|
||||
version = version.substring(0, hyphen);
|
||||
}
|
||||
|
||||
String[] versionArray = version.split("\\.");
|
||||
int[] versionNumbers = new int[versionArray.length];
|
||||
for ( int i=0; i<versionArray.length; i++ ) {
|
||||
if ( !versionArray[i].matches("[0-9]+") )
|
||||
return false;
|
||||
versionNumbers[i] = Integer.parseInt(versionArray[i]);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
while ( (versionNumbers.length > index) && (borderNumbers.length > index) ) {
|
||||
if ( versionNumbers[index] > borderNumbers[index] ) {
|
||||
return true;
|
||||
} else if ( versionNumbers[index] < borderNumbers[index] ) {
|
||||
return false;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if ( borderNumbers.length == index ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import org.bukkit.entity.Player;
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelMemberChangedEvent;
|
||||
|
||||
/**
|
||||
@@ -566,6 +567,30 @@ public abstract class Channel implements ConfigurationSerializable {
|
||||
return (Map<String, Long>)obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの設定ファイルが、UUID化のために一旦保存が必要かどうかを返す
|
||||
* @param data チャンネルの実コンフィグデータ
|
||||
*/
|
||||
private static boolean isNeedToSaveForUUIDUpdate(Map<String, Object> data) {
|
||||
|
||||
if ( !Utility.isCB178orLater() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<String> members = castToStringList(data.get(KEY_MEMBERS));
|
||||
if ( members.size() == 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( String member : members ) {
|
||||
if ( member.startsWith("$") ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの説明文を返す
|
||||
* @return チャンネルの説明文
|
||||
@@ -863,6 +888,12 @@ public abstract class Channel implements ConfigurationSerializable {
|
||||
data.put(key, config.get(key));
|
||||
}
|
||||
Channel channel = deserialize(data);
|
||||
|
||||
// 自動アップデート
|
||||
if ( isNeedToSaveForUUIDUpdate(data) ) {
|
||||
channel.save();
|
||||
}
|
||||
|
||||
result.put(channel.name.toLowerCase(), channel);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
|
||||
/**
|
||||
* プレイヤーの抽象クラス
|
||||
* @author ucchy
|
||||
@@ -106,7 +107,7 @@ public abstract class ChannelPlayer implements Comparable<ChannelPlayer> {
|
||||
String id = nameOrUuid.substring(1);
|
||||
return new ChannelPlayerUUID(id);
|
||||
}
|
||||
if ( isCB175orLater() ) {
|
||||
if ( Utility.isCB178orLater() ) {
|
||||
ChannelPlayer player =
|
||||
ChannelPlayerUUID.getChannelPlayerUUIDFromName(nameOrUuid);
|
||||
if ( player != null ) {
|
||||
@@ -125,47 +126,9 @@ public abstract class ChannelPlayer implements Comparable<ChannelPlayer> {
|
||||
if ( sender == null ) {
|
||||
return null;
|
||||
}
|
||||
if ( isCB175orLater() ) {
|
||||
if ( Utility.isCB178orLater() ) {
|
||||
return ChannelPlayerUUID.getChannelPlayer(sender);
|
||||
}
|
||||
return new ChannelPlayerName(sender.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 現在動作中のCraftBukkitが、v1.7.5 以上かどうかを確認する
|
||||
* @return v1.7.5以上ならtrue、そうでないならfalse
|
||||
*/
|
||||
private static boolean isCB175orLater() {
|
||||
|
||||
int[] borderNumbers = {1, 7, 5};
|
||||
|
||||
String version = Bukkit.getBukkitVersion();
|
||||
int hyphen = version.indexOf("-");
|
||||
if ( hyphen > 0 ) {
|
||||
version = version.substring(0, hyphen);
|
||||
}
|
||||
|
||||
String[] versionArray = version.split("\\.");
|
||||
int[] versionNumbers = new int[versionArray.length];
|
||||
for ( int i=0; i<versionArray.length; i++ ) {
|
||||
if ( !versionArray[i].matches("[0-9]+") )
|
||||
return false;
|
||||
versionNumbers[i] = Integer.parseInt(versionArray[i]);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
while ( (versionNumbers.length > index) && (borderNumbers.length > index) ) {
|
||||
if ( versionNumbers[index] > borderNumbers[index] ) {
|
||||
return true;
|
||||
} else if ( versionNumbers[index] < borderNumbers[index] ) {
|
||||
return false;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if ( borderNumbers.length == index ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする