コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
a981b1050a |
検索条件に一致するファイルはありません
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.github.ucchyocean</groupId>
|
||||
<artifactId>LunaChat</artifactId>
|
||||
<version>2.8.12</version>
|
||||
<version>2.8.13</version>
|
||||
<description>A powerfull chat channel plugin with IME (Kana-Kanji conversion) support</description>
|
||||
|
||||
<licenses>
|
||||
@@ -140,7 +140,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -66,12 +66,12 @@ public class Resources {
|
||||
|
||||
YamlConfiguration messages = new YamlConfiguration();
|
||||
JarFile jarFile = null;
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
jarFile = new JarFile(LunaChat.getPluginJarFile());
|
||||
ZipEntry zipEntry = jarFile.getEntry(FILE_NAME);
|
||||
InputStream inputStream = jarFile.getInputStream(zipEntry);
|
||||
BufferedReader reader =
|
||||
new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
String line;
|
||||
while ( (line = reader.readLine()) != null ) {
|
||||
if ( line.contains(":") && !line.startsWith("#") ) {
|
||||
@@ -85,6 +85,13 @@ public class Resources {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if ( reader != null ) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
if ( jarFile != null ) {
|
||||
try {
|
||||
jarFile.close();
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -22,6 +24,7 @@ import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
public class ListCommand extends SubCommandAbst {
|
||||
|
||||
private static final String LIST_FIRSTLINE = Resources.get("listFirstLine");
|
||||
private static final String LIST_FIRSTLINE_PAGING = Resources.get("listFirstLinePaging");
|
||||
private static final String LIST_ENDLINE = Resources.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Resources.get("listFormat");
|
||||
|
||||
@@ -29,6 +32,8 @@ public class ListCommand extends SubCommandAbst {
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageList";
|
||||
|
||||
private static final int PAGE_SIZE = 8;
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
@@ -88,8 +93,13 @@ public class ListCommand extends SubCommandAbst {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
int page = 0;
|
||||
if ( args.length >= 2 && args[1].matches("[0-9]") ) {
|
||||
page = Integer.parseInt(args[1]);
|
||||
}
|
||||
|
||||
// リストを取得して表示する
|
||||
ArrayList<String> list = getList(player);
|
||||
ArrayList<String> list = getList(player, page);
|
||||
for (String msg : list) {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
@@ -99,9 +109,39 @@ public class ListCommand extends SubCommandAbst {
|
||||
/**
|
||||
* リスト表示用のリストを返す
|
||||
* @param player プレイヤー、指定しない場合はnullにする
|
||||
* @param page 表示するページ、0を指定した場合は全表示
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getList(Player player) {
|
||||
private ArrayList<String> getList(Player player, int page) {
|
||||
|
||||
ArrayList<String> list = getPlayerList(player);
|
||||
int size = list.size();
|
||||
int maxPage = (int)(size / PAGE_SIZE) + 1;
|
||||
|
||||
if ( page < 0 ) page = 0;
|
||||
if ( page > maxPage ) page = maxPage;
|
||||
|
||||
ArrayList<String> items = new ArrayList<>();
|
||||
if ( page == 0 ) { // 全表示
|
||||
items.add(LIST_FIRSTLINE);
|
||||
items.addAll(list);
|
||||
items.add(LIST_ENDLINE);
|
||||
} else { // ページ表示
|
||||
items.add(String.format(LIST_FIRSTLINE_PAGING, page, maxPage));
|
||||
int endIndex = (page * PAGE_SIZE > size) ? size : page * PAGE_SIZE;
|
||||
items.addAll(list.subList((page - 1) * PAGE_SIZE, endIndex));
|
||||
items.add(LIST_ENDLINE);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーに対するチャンネルリストを返す
|
||||
* @param player プレイヤー
|
||||
* @return チャンネルリスト
|
||||
*/
|
||||
private ArrayList<String> getPlayerList(Player player) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
String dchannel = "";
|
||||
@@ -117,8 +157,16 @@ public class ListCommand extends SubCommandAbst {
|
||||
}
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(player);
|
||||
|
||||
items.add(LIST_FIRSTLINE);
|
||||
for ( Channel channel : api.getChannels() ) {
|
||||
// チャンネルを取得して、チャンネル名でソートする
|
||||
ArrayList<Channel> channels = new ArrayList<>(api.getChannels());
|
||||
Collections.sort(channels, new Comparator<Channel>() {
|
||||
public int compare(Channel c1, Channel c2) {
|
||||
return c1.getName().compareTo(c2.getName());
|
||||
}
|
||||
});
|
||||
|
||||
// 指定されたプレイヤー名に合うように、フィルタ&表示用整形する。
|
||||
for ( Channel channel : channels ) {
|
||||
|
||||
// BANされているチャンネルは表示しない
|
||||
if ( channel.getBanned().contains(cp) ) {
|
||||
@@ -155,7 +203,6 @@ public class ListCommand extends SubCommandAbst {
|
||||
LIST_FORMAT, disp, onlineNum, memberNum, desc);
|
||||
items.add(item);
|
||||
}
|
||||
items.add(LIST_ENDLINE);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ removeModeratorMessage: '&f[%color%ch&f]&7%player さんがチャンネルのモ
|
||||
noRecipientMessage: '&f[%color%ch&f]&7あなたの発言は、誰にも届きませんでした。'
|
||||
|
||||
listFirstLine: '&7---------- &bチャンネルリスト &7----------'
|
||||
listFirstLinePaging: '&7---------- &bチャンネルリスト&7(&c%d&7/&c%d&7) ----------'
|
||||
listEndLine: '&7----------------------------------'
|
||||
listFormat: '&7| &f%s&7(&c%d&7/&c%d&7) &a%s'
|
||||
listPlainPrefix: '&7| '
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする