コミットを比較

..
5 コミット
作成者 SHA1 メッセージ 日付
ucchy 33ffff385d LunaChat v2.7.0 : Fixed issue #119 2015-02-13 19:44:34 +09:00
ucchy 3da5bd6a78 LunaChat v2.7.0 : Fixed issue #118 2015-02-13 18:57:19 +09:00
ucchy 93d3cb7f73 LunaChat v2.7.0 : Fixed issue #117 2015-02-13 17:44:26 +09:00
ucchy 0e5bd3fe0a LunaChat v2.7.0 : Updated dependencies for Bukkit1.8. 2015-02-13 15:07:24 +09:00
ucchy 7fea872978 LunaChat v2.7.0 : Fixed issue #116 2015-02-13 14:29:54 +09:00
21個のファイルの変更、363行の追加、66行の削除

検索条件に一致するファイルはありません

+8 -3
ファイルの表示
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.ucchyocean</groupId>
<artifactId>LunaChat</artifactId>
<version>2.6.14</version>
<version>2.7.0</version>
<description>チャンネルチャットプラグイン</description>
<licenses>
@@ -96,18 +96,23 @@
<name>mikeprimm repository</name>
<url>http://repo.mikeprimm.com/</url>
</repository>
<repository>
<id>rasagne-repo</id>
<name>Craft Bukkit Alternate Nexus Repository</name>
<url>http://lasagne.tgnmc.com:8081/nexus/content/groups/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.7.9-R0.2</version>
<version>1.8-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.4.1</version>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.dynmap</groupId>
+5 -2
ファイルの表示
@@ -8,6 +8,7 @@ package com.github.ucchyocean.lc;
import java.io.File;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
@@ -53,7 +54,6 @@ public class LunaChat extends JavaPlugin {
public void onEnable() {
// 変数などの初期化
instance = this;
config = new LunaChatConfig();
manager = new ChannelManager();
normalChatLogger = new LunaChatLogger("==normalchat");
@@ -152,6 +152,9 @@ public class LunaChat extends JavaPlugin {
* @return LunaChat
*/
public static LunaChat getInstance() {
if ( instance == null ) {
instance = (LunaChat)Bukkit.getPluginManager().getPlugin("LunaChat");
}
return instance;
}
@@ -160,7 +163,7 @@ public class LunaChat extends JavaPlugin {
* @return Jarファイル
*/
protected static File getPluginJarFile() {
return instance.getFile();
return getInstance().getFile();
}
/**
+32 -2
ファイルの表示
@@ -10,6 +10,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -24,6 +25,7 @@ import com.github.ucchyocean.lc.channel.ChannelPlayer;
import com.github.ucchyocean.lc.channel.ChannelPlayerName;
import com.github.ucchyocean.lc.channel.ChannelPlayerUUID;
import com.github.ucchyocean.lc.channel.DelayedJapanizeConvertTask;
import com.github.ucchyocean.lc.event.LunaChatPreChatEvent;
import com.github.ucchyocean.lc.japanize.JapanizeType;
/**
@@ -76,8 +78,22 @@ public class PlayerListener implements Listener {
}
}
// LunaChatPreChatEvent イベントコール
LunaChatPreChatEvent preChatEvent = new LunaChatPreChatEvent(
channel.getName(), player, event.getMessage());
Bukkit.getPluginManager().callEvent(preChatEvent);
if ( preChatEvent.isCancelled() ) {
event.setCancelled(true);
return;
}
Channel alt = preChatEvent.getChannel();
if ( alt != null ) {
channel = alt;
}
String message = preChatEvent.getMessage();
// チャンネルチャット発言
channel.chat(player, event.getMessage());
channel.chat(player, message);
// もとのイベントをキャンセル
event.setCancelled(true);
@@ -164,6 +180,20 @@ public class PlayerListener implements Listener {
global = api.createChannel(config.getGlobalChannel());
}
// LunaChatPreChatEvent イベントコール
LunaChatPreChatEvent preChatEvent = new LunaChatPreChatEvent(
global.getName(), player, event.getMessage());
Bukkit.getPluginManager().callEvent(preChatEvent);
if ( preChatEvent.isCancelled() ) {
event.setCancelled(true);
return;
}
Channel alt = preChatEvent.getChannel();
if ( alt != null ) {
global = alt;
}
String message = preChatEvent.getMessage();
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
Channel dchannel = api.getDefaultChannel(player.getName());
if ( dchannel == null ) {
@@ -171,7 +201,7 @@ public class PlayerListener implements Listener {
}
// チャンネルチャット発言
global.chat(player, event.getMessage());
global.chat(player, message);
// もとのイベントをキャンセル
event.setCancelled(true);
+63 -30
ファイルの表示
@@ -14,6 +14,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
@@ -46,7 +49,7 @@ public class Utility {
BufferedWriter writer = null;
File parent = targetFile.getParentFile();
if ( !parent.exists() ) {
if (!parent.exists()) {
parent.mkdirs();
}
@@ -57,10 +60,10 @@ public class Utility {
fos = new FileOutputStream(targetFile);
if ( isBinary ) {
if (isBinary) {
byte[] buf = new byte[8192];
int len;
while ( (len = is.read(buf)) != -1 ) {
while ((len = is.read(buf)) != -1) {
fos.write(buf, 0, len);
}
@@ -81,7 +84,7 @@ public class Utility {
} catch (IOException e) {
e.printStackTrace();
} finally {
if ( writer != null ) {
if (writer != null) {
try {
writer.flush();
writer.close();
@@ -89,14 +92,14 @@ public class Utility {
// do nothing.
}
}
if ( reader != null ) {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
// do nothing.
}
}
if ( fos != null ) {
if (fos != null) {
try {
fos.flush();
fos.close();
@@ -104,7 +107,7 @@ public class Utility {
// do nothing.
}
}
if ( is != null ) {
if (is != null) {
try {
is.close();
} catch (IOException e) {
@@ -120,7 +123,8 @@ public class Utility {
* @return 置き換え後の文字列
*/
public static String replaceColorCode(String source) {
if ( source == null ) return null;
if (source == null)
return null;
return ChatColor.translateAlternateColorCodes('&', source);
}
@@ -130,7 +134,8 @@ public class Utility {
* @return 置き換え後の文字列
*/
public static String stripColor(String source) {
if ( source == null ) return null;
if (source == null)
return null;
return ChatColor.stripColor(source);
}
@@ -141,7 +146,7 @@ public class Utility {
*/
public static String getAstariskString(int length) {
StringBuilder buf = new StringBuilder();
for ( int i=0; i<length; i++ ) {
for (int i = 0; i < length; i++) {
buf.append("*");
}
return buf.toString();
@@ -154,7 +159,7 @@ public class Utility {
*/
public static ChatColor changeToChatColor(String color) {
if ( isValidColor(color) ) {
if (isValidColor(color)) {
return ChatColor.valueOf(color.toUpperCase());
}
return ChatColor.WHITE;
@@ -177,8 +182,8 @@ public class Utility {
*/
public static boolean isValidColor(String color) {
for ( ChatColor c : ChatColor.values() ) {
if ( c.name().equals(color.toUpperCase()) ) {
for (ChatColor c : ChatColor.values()) {
if (c.name().equals(color.toUpperCase())) {
return true;
}
}
@@ -192,7 +197,7 @@ public class Utility {
*/
public static boolean isValidColorCode(String code) {
if ( code == null ) {
if (code == null) {
return false;
}
return code.matches("&[0-9a-f]");
@@ -204,22 +209,22 @@ public class Utility {
*/
public static boolean isCB178orLater() {
if ( isCB178orLaterCache != null ) {
if (isCB178orLaterCache != null) {
return isCB178orLaterCache;
}
int[] borderNumbers = {1, 7, 8};
int[] borderNumbers = { 1, 7, 8 };
String version = Bukkit.getBukkitVersion();
int hyphen = version.indexOf("-");
if ( hyphen > 0 ) {
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]+") ) {
for (int i = 0; i < versionArray.length; i++) {
if (!versionArray[i].matches("[0-9]+")) {
isCB178orLaterCache = false;
return false;
}
@@ -227,17 +232,17 @@ public class Utility {
}
int index = 0;
while ( (versionNumbers.length > index) && (borderNumbers.length > index) ) {
if ( versionNumbers[index] > borderNumbers[index] ) {
while ((versionNumbers.length > index) && (borderNumbers.length > index)) {
if (versionNumbers[index] > borderNumbers[index]) {
isCB178orLaterCache = true;
return true;
} else if ( versionNumbers[index] < borderNumbers[index] ) {
} else if (versionNumbers[index] < borderNumbers[index]) {
isCB178orLaterCache = false;
return false;
}
index++;
}
if ( borderNumbers.length == index ) {
if (borderNumbers.length == index) {
isCB178orLaterCache = true;
return true;
} else {
@@ -246,17 +251,42 @@ public class Utility {
}
}
/**
* 現在接続中のプレイヤーを全て取得する
* @return 接続中の全てのプレイヤー
*/
@SuppressWarnings("unchecked")
public static ArrayList<Player> getOnlinePlayers() {
// CB179以前と、CB1710以降で戻り値が異なるため、
// リフレクションを使って互換性を(無理やり)保つ。
try {
if (Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).getReturnType() == Collection.class) {
Collection<?> temp =
((Collection<?>) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0])
.invoke(null, new Object[0]));
return new ArrayList<Player>((Collection<? extends Player>) temp);
} else {
Player[] temp =
((Player[]) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0])
.invoke(null, new Object[0]));
ArrayList<Player> players = new ArrayList<Player>();
for (Player t : temp) {
players.add(t);
}
return players;
}
} catch (NoSuchMethodException ex) {} // never happen
catch (InvocationTargetException ex) {} // never happen
catch (IllegalAccessException ex) {} // never happen
return new ArrayList<Player>();
}
/**
* 現在のサーバー接続人数を返します。
* @return サーバー接続人数
*/
public static int getOnlinePlayersCount() {
int count = 0;
for ( @SuppressWarnings("unused")
Player player : Bukkit.getOnlinePlayers() ) {
count++;
}
return count;
return getOnlinePlayers().size();
}
/**
@@ -266,6 +296,9 @@ public class Utility {
*/
@SuppressWarnings("deprecation")
public static OfflinePlayer getOfflinePlayer(String name) {
return Bukkit.getOfflinePlayer(name);
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
if (player == null || (!player.hasPlayedBefore() && !player.isOnline()))
return null;
return player;
}
}
+24 -1
ファイルの表示
@@ -36,6 +36,7 @@ public abstract class Channel implements ConfigurationSerializable {
private static final String FOLDER_NAME_CHANNELS = "channels";
private static final String KEY_NAME = "name";
private static final String KEY_ALIAS = "alias";
private static final String KEY_DESC = "desc";
private static final String KEY_FORMAT = "format";
private static final String KEY_MEMBERS = "members";
@@ -71,6 +72,9 @@ public abstract class Channel implements ConfigurationSerializable {
/** チャンネルの名称 */
private String name;
/** チャンネルの別名 */
private String alias;
/** チャンネルの説明文 */
private String description;
@@ -122,6 +126,7 @@ public abstract class Channel implements ConfigurationSerializable {
protected Channel(String name) {
this.name = name;
this.alias = "";
this.description = "";
this.members = new ArrayList<ChannelPlayer>();
this.banned = new ArrayList<ChannelPlayer>();
@@ -425,6 +430,7 @@ public abstract class Channel implements ConfigurationSerializable {
Map<String, Object> map = new HashMap<String, Object>();
map.put(KEY_NAME, name);
map.put(KEY_ALIAS, alias);
map.put(KEY_DESC, description);
map.put(KEY_FORMAT, format);
map.put(KEY_MEMBERS, getStringList(members));
@@ -458,6 +464,7 @@ public abstract class Channel implements ConfigurationSerializable {
}
Channel channel = new ChannelImpl(name);
channel.alias = castWithDefault(data.get(KEY_ALIAS), "");
channel.description = castWithDefault(data.get(KEY_DESC), "");
channel.format = castWithDefault(data.get(KEY_FORMAT), channel.format);
channel.members = castToChannelPlayerList(data.get(KEY_MEMBERS));
@@ -613,6 +620,22 @@ public abstract class Channel implements ConfigurationSerializable {
return true;
}
/**
* チャンネルの別名を返す
* @return チャンネルの別名
*/
public String getAlias() {
return alias;
}
/**
* チャンネルの別名を設定する
* @param alias チャンネルの別名
*/
public void setAlias(String alias) {
this.alias = alias;
}
/**
* チャンネルの説明文を返す
* @return チャンネルの説明文
@@ -687,7 +710,7 @@ public abstract class Channel implements ConfigurationSerializable {
// 現在サーバーに接続している全プレイヤーをメンバーとして返す
if ( isBroadcastChannel() ) {
List<ChannelPlayer> mem = new ArrayList<ChannelPlayer>();
for ( Player p : Bukkit.getOnlinePlayers() ) {
for ( Player p : Utility.getOnlinePlayers() ) {
mem.add(ChannelPlayer.getChannelPlayer(p));
}
return mem;
+42 -5
ファイルの表示
@@ -33,8 +33,11 @@ import com.github.ucchyocean.lc.japanize.JapanizeType;
*/
public class ChannelImpl extends Channel {
private static final String PERMISSION_SPEAK_PREFIX = "lunachat.speak";
private static final String INFO_FIRSTLINE = Resources.get("channelInfoFirstLine");
private static final String INFO_PREFIX = Resources.get("channelInfoPrefix");
private static final String INFO_ALIAS = Resources.get("channelInfoAlias");
private static final String INFO_GLOBAL = Resources.get("channelInfoGlobal");
private static final String INFO_BROADCAST = Resources.get("channelInfoBroadcast");
private static final String INFO_SECRET = Resources.get("channelInfoSecret");
@@ -86,6 +89,14 @@ public class ChannelImpl extends Channel {
@Override
public void chat(ChannelPlayer player, String message) {
// 発言権限を確認する
if (!player.hasPermission(PERMISSION_SPEAK_PREFIX + ".*")
&& !player.hasPermission(PERMISSION_SPEAK_PREFIX + "." + getName())) {
sendResourceMessage(player, PREERR, "errmsgPermission",
PERMISSION_SPEAK_PREFIX + "." + getName());
return;
}
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
@@ -314,7 +325,7 @@ public class ChannelImpl extends Channel {
// 範囲チャット
Location origin = player.getPlayer().getLocation();
for ( Player p : Bukkit.getOnlinePlayers() ) {
for ( Player p : Utility.getOnlinePlayers() ) {
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(p);
if ( p.getWorld().equals(w) &&
origin.distance(p.getLocation()) <= getChatRange() &&
@@ -326,7 +337,7 @@ public class ChannelImpl extends Channel {
} else {
// ワールドチャット
for ( Player p : Bukkit.getOnlinePlayers() ) {
for ( Player p : Utility.getOnlinePlayers() ) {
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(p);
if ( p.getWorld().equals(w) && !getHided().contains(cp) ) {
recipients.add(ChannelPlayer.getChannelPlayer(p));
@@ -345,7 +356,7 @@ public class ChannelImpl extends Channel {
} else {
// 通常ブロードキャスト(全員へ送信)
for ( Player p : Bukkit.getOnlinePlayers() ) {
for ( Player p : Utility.getOnlinePlayers() ) {
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(p);
if ( !getHided().contains(cp) ) {
recipients.add(cp);
@@ -367,7 +378,7 @@ public class ChannelImpl extends Channel {
// パーミッション lunachat-admin.listen-all-channels を持つプレイヤーを
// 受信者に加える。
if ( config.isOpListenAllChannel() ) {
for ( Player p : Bukkit.getOnlinePlayers() ) {
for ( Player p : Utility.getOnlinePlayers() ) {
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(p);
if ( cp.hasPermission("lunachat-admin.listen-all-channels")
&& !recipients.contains(cp) ) {
@@ -450,6 +461,13 @@ public class ChannelImpl extends Channel {
info.add( String.format(
LIST_FORMAT, getName(), getOnlineNum(), getTotalNum(), getDescription()) );
// チャンネル別名
String alias = getAlias();
if ( alias != null && alias.length() > 0 ) {
info.add(INFO_ALIAS + alias);
}
// INFO_ALIAS
// 参加メンバー一覧
if ( isGlobalChannel() ) {
info.add(INFO_GLOBAL);
@@ -512,7 +530,8 @@ public class ChannelImpl extends Channel {
if ( forModerator ) {
// フォーマット情報
info.add(INFO_FORMAT + getFormat());
info.add(INFO_FORMAT);
info.add(INFO_PREFIX + " " + ChatColor.WHITE + getFormat());
// Muteリスト情報、5人ごとに表示する
if ( getMuted().size() > 0 ) {
@@ -712,4 +731,22 @@ public class ChannelImpl extends Channel {
logger.log(message, player);
}
}
/**
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
* @param player メッセージの送り先
* @param pre プレフィックス
* @param key リソースキー
* @param args リソース内の置き換え対象キーワード
*/
private void sendResourceMessage(
ChannelPlayer player, String pre, String key, Object... args) {
String org = Resources.get(key);
if ( org == null || org.equals("") ) {
return;
}
String msg = String.format(pre + org, args);
player.sendMessage(msg);
}
}
+11 -2
ファイルの表示
@@ -396,14 +396,23 @@ public class ChannelManager implements LunaChatAPI {
/**
* チャンネルを取得する
* @param channelName チャンネル名
* @param channelName チャンネル名、または、チャンネルの別名
* @return チャンネル
* @see com.github.ucchyocean.lc.LunaChatAPI#getChannel(java.lang.String)
*/
@Override
public Channel getChannel(String channelName) {
if ( channelName == null ) return null;
return channels.get(channelName.toLowerCase());
Channel channel = channels.get(channelName.toLowerCase());
if ( channel != null ) return channel;
for ( Channel ch : channels.values() ) {
String alias = ch.getAlias();
if ( alias != null && alias.length() > 0
&& channelName.equalsIgnoreCase(ch.getAlias()) ) {
return ch;
}
}
return null;
}
/**
+1 -1
ファイルの表示
@@ -92,7 +92,7 @@ public class DelayedJapanizeConvertTask extends BukkitRunnable {
HashMap<String, String> keywordMap = new HashMap<String, String>();
ArrayList<String> keywords = new ArrayList<String>();
if ( LunaChat.getInstance().getLunaChatConfig().isJapanizeIgnorePlayerName() ) {
for ( Player player : Bukkit.getOnlinePlayers() ) {
for ( Player player : Utility.getOnlinePlayers() ) {
keywords.add(player.getName());
}
}
+1 -1
ファイルの表示
@@ -95,7 +95,7 @@ public class CreateCommand extends SubCommandAbst {
// 使用可能なチャンネル名かどうかをチェックする
if ( !LunaChat.checkForChannelName(name) ) {
sendResourceMessage(sender, PREINFO, "errmsgCannotUseForChannel", name);
sendResourceMessage(sender, PREERR, "errmsgCannotUseForChannel", name);
return true;
}
+2 -2
ファイルの表示
@@ -105,13 +105,13 @@ public class FormatCommand extends SubCommandAbst {
format = format.trim();
// チャンネルが存在するかどうかをチェックする
if ( !api.isExistChannel(cname) ) {
Channel channel = api.getChannel(cname);
if ( channel == null ) {
sendResourceMessage(sender, PREERR, "errmsgNotExist");
return true;
}
// モデレーターかどうか確認する
Channel channel = api.getChannel(cname);
if ( !channel.hasModeratorPermission(sender) ) {
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
return true;
+2 -2
ファイルの表示
@@ -119,7 +119,8 @@ public class HideCommand extends SubCommandAbst {
// チャンネルかプレイヤーが存在するかどうかをチェックする
boolean isChannelCommand = false;
if ( api.isExistChannel(cname) ) {
Channel channel = api.getChannel(cname);
if ( channel != null ) {
isChannelCommand = true;
} else if ( Utility.getOfflinePlayer(cname) == null ) {
sendResourceMessage(sender, PREERR, "errmsgNotExistChannelAndPlayer");
@@ -130,7 +131,6 @@ public class HideCommand extends SubCommandAbst {
// チャンネルが対象の場合の処理
// 既に非表示になっていないかどうかをチェックする
Channel channel = api.getChannel(cname);
if ( channel.getHided().contains(player) ) {
sendResourceMessage(sender, PREERR, "errmsgAlreadyHided");
return true;
+19 -5
ファイルの表示
@@ -20,6 +20,7 @@ public class JoinCommand extends SubCommandAbst {
private static final String COMMAND_NAME = "join";
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
private static final String PERMISSION_SPEAK_PREFIX = "lunachat.speak";
private static final String USAGE_KEY = "usageJoin";
/**
@@ -105,8 +106,11 @@ public class JoinCommand extends SubCommandAbst {
return true;
}
// チャンネルを取得する
Channel channel = api.getChannel(channelName);
// チャンネルが存在するかどうかをチェックする
if ( !api.isExistChannel(channelName) ) {
if ( channel == null ) {
if ( config.getGlobalChannel().equals("") &&
channelName.equals(config.getGlobalMarker()) ) {
// グローバルチャンネル設定が無くて、指定チャンネルがマーカーの場合、
@@ -145,8 +149,14 @@ public class JoinCommand extends SubCommandAbst {
}
}
// チャンネルを取得する
Channel channel = api.getChannel(channelName);
channelName = channel.getName();
// 入室権限を確認する
if (!sender.hasPermission(PERMISSION_NODE + "." + channelName)) {
sendResourceMessage(sender, PREERR, "errmsgPermission",
PERMISSION_NODE + "." + channelName);
return true;
}
// BANされていないか確認する
if (channel.getBanned().contains(player)) {
@@ -163,7 +173,7 @@ public class JoinCommand extends SubCommandAbst {
if (channel.getMembers().contains(player)) {
// 何かメッセージがあるなら、そのままチャット送信する
if (message.length() > 0) {
if (message.length() > 0 && hasSpeakPermission(sender, channelName)) {
channel.chat(player, message.toString());
return true;
}
@@ -176,7 +186,7 @@ public class JoinCommand extends SubCommandAbst {
// グローバルチャンネルで、何かメッセージがあるなら、そのままチャット送信する
if (channel.getName().equals(config.getGlobalChannel()) &&
message.length() > 0) {
message.length() > 0 && hasSpeakPermission(sender, channelName)) {
channel.chat(player, message.toString());
return true;
}
@@ -214,4 +224,8 @@ public class JoinCommand extends SubCommandAbst {
return true;
}
private boolean hasSpeakPermission(CommandSender sender, String channelName) {
return sender.hasPermission(PERMISSION_SPEAK_PREFIX + "." + channelName);
}
}
+12 -2
ファイルの表示
@@ -93,12 +93,22 @@ public class LeaveCommand extends SubCommandAbst {
channelName = args[1];
}
Channel channel = api.getChannel(channelName);
// チャンネルが存在するかどうかをチェックする
if ( !api.isExistChannel(channelName) ) {
if ( channel == null ) {
sendResourceMessage(sender, PREERR, "errmsgNotExist");
return true;
}
Channel channel = api.getChannel(channelName);
channelName = channel.getName();
// 退室権限を確認する
if (!sender.hasPermission(PERMISSION_NODE + "." + channelName)) {
sendResourceMessage(sender, PREERR, "errmsgPermission",
PERMISSION_NODE + "." + channelName);
return true;
}
// グローバルチャンネルなら退出できない
if ( channel.isGlobalChannel() ) {
+7
ファイルの表示
@@ -121,6 +121,13 @@ public class LogCommand extends SubCommandAbst {
}
}
// 参照権限を確認する
if (!sender.hasPermission(PERMISSION_NODE + "." + cname)) {
sendResourceMessage(sender, PREERR, "errmsgPermission",
PERMISSION_NODE + "." + cname);
return true;
}
// ログの取得
ArrayList<String> logs;
+2 -2
ファイルの表示
@@ -8,7 +8,6 @@ package com.github.ucchyocean.lc.command;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -16,6 +15,7 @@ import org.bukkit.entity.Player;
import com.github.ucchyocean.lc.LunaChat;
import com.github.ucchyocean.lc.Resources;
import com.github.ucchyocean.lc.Utility;
import com.github.ucchyocean.lc.channel.Channel;
import com.github.ucchyocean.lc.channel.ChannelPlayer;
@@ -161,7 +161,7 @@ public class LunaChatCommand implements CommandExecutor {
items.add(name);
}
}
for ( Player player : Bukkit.getOnlinePlayers() ) {
for ( Player player : Utility.getOnlinePlayers() ) {
if ( player.getName().toLowerCase().startsWith(arg) ) {
items.add(player.getName());
}
+5 -2
ファイルの表示
@@ -104,14 +104,17 @@ public class ModeratorCommand extends SubCommandAbst {
return true;
}
Channel channel = api.getChannel(cname);
// チャンネルが存在するかどうかをチェックする
if ( !api.isExistChannel(cname) ) {
if ( channel == null ) {
sendResourceMessage(sender, PREERR, "errmsgNotExist");
return true;
}
cname = channel.getName();
// モデレーターかどうか確認する
Channel channel = api.getChannel(cname);
if ( !channel.hasModeratorPermission(sender) ) {
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
return true;
+36 -2
ファイルの表示
@@ -23,6 +23,7 @@ import com.github.ucchyocean.lc.event.LunaChatChannelOptionChangedEvent;
public class OptionCommand extends SubCommandAbst {
private static final int MAX_LENGTH_DESCRIPTION = 30;
private static final int MAX_LENGTH_ALIAS = 15;
private static final int MAX_LENGTH_PASSWORD = 15;
private static final String COMMAND_NAME = "option";
@@ -110,14 +111,17 @@ public class OptionCommand extends SubCommandAbst {
return true;
}
Channel channel = api.getChannel(cname);
// チャンネルが存在するかどうかをチェックする
if ( !api.isExistChannel(cname) ) {
if ( channel == null ) {
sendResourceMessage(sender, PREERR, "errmsgNotExist");
return true;
}
cname = channel.getName();
// モデレーターかどうか確認する
Channel channel = api.getChannel(cname);
if ( !channel.hasModeratorPermission(sender) ) {
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
return true;
@@ -168,6 +172,36 @@ public class OptionCommand extends SubCommandAbst {
}
}
if ( options.containsKey("alias") ) {
// チャンネル別名
String pnode = PERMISSION_NODE + ".alias";
if ( !sender.hasPermission(pnode) ) {
sendResourceMessage(sender, PREERR,
"errmsgNotPermission", pnode);
} else {
String alias = options.get("alias");
if ( alias.length() > MAX_LENGTH_ALIAS ) {
// チャンネル別名が最大文字長を超えている
sendResourceMessage(sender, PREERR,
"errmsgToolongAlias", MAX_LENGTH_ALIAS);
} else if (api.getChannel(alias) != null) {
// 別のチャンネル名またはチャンネル別名と重複する
sendResourceMessage(sender, PREERR,
"errmsgDuplicatedAlias",
alias, api.getChannel(alias).getName());
} else {
channel.setAlias(alias);
sendResourceMessage(sender, PREINFO,
"cmdmsgOption", "alias", alias);
setOption = true;
}
}
}
if ( options.containsKey("color") ) {
// チャンネルカラー
+2 -2
ファイルの表示
@@ -101,7 +101,8 @@ public class UnhideCommand extends SubCommandAbst {
// チャンネルかプレイヤーが存在するかどうかをチェックする
boolean isChannelCommand = false;
if ( api.isExistChannel(cname) ) {
Channel channel = api.getChannel(cname);
if ( channel != null ) {
isChannelCommand = true;
} else if ( Utility.getOfflinePlayer(cname) == null ) {
sendResourceMessage(sender, PREERR, "errmsgNotExistChannelAndPlayer");
@@ -112,7 +113,6 @@ public class UnhideCommand extends SubCommandAbst {
// チャンネルが対象の場合の処理
// 非表示になっているかどうかをチェックする
Channel channel = api.getChannel(cname);
if ( !channel.getHided().contains(player) ) {
sendResourceMessage(sender, PREERR, "errmsgAlreadyUnhided");
return true;
+66
ファイルの表示
@@ -0,0 +1,66 @@
/*
* @author ucchy
* @license LGPLv3
* @copyright Copyright ucchy 2015
*/
package com.github.ucchyocean.lc.event;
import com.github.ucchyocean.lc.channel.Channel;
import com.github.ucchyocean.lc.channel.ChannelPlayer;
/**
* チャンネルチャットへの発言前に発生するイベント
* @author ucchy
*/
public class LunaChatPreChatEvent extends LunaChatBaseCancellableEvent {
private ChannelPlayer player;
private String message;
public LunaChatPreChatEvent(String channelName, ChannelPlayer player, String message) {
super(channelName);
this.player = player;
this.message = message;
}
/**
* 発言を行ったプレイヤーを取得します。
* @return 発言したプレイヤー
*/
public ChannelPlayer getPlayer() {
return player;
}
/**
* 発言内容を取得します。
* @return 発言内容
*/
public String getMessage() {
return message;
}
/**
* 発言先チャンネルを変更します。
* @param channelName 発言先チャンネル名
*/
public void setChannelName(String channelName) {
this.channelName = channelName;
}
/**
* 発言先チャンネルを変更します。
* @param channel 発言先チャンネル
*/
public void setChannel(Channel channel) {
if ( channel == null ) return;
this.channelName = channel.getName();
}
/**
* 発言内容を変更します。
* @param message 発言内容
*/
public void setMessage(String message) {
this.message = message;
}
}
+3
ファイルの表示
@@ -31,6 +31,7 @@ listPlainPrefix: '&7| '
channelInfoFirstLine: '&7---------- &bチャンネル情報 &7----------'
channelInfoPrefix: '&7| '
channelInfoAlias: '&7| &cチャンネル別名:&f'
channelInfoGlobal: '&7| &cグローバルチャンネル'
channelInfoBroadcast: '&7| &cブロードキャストチャンネル'
channelInfoSecret: '&7| &cシークレットチャンネル'
@@ -143,6 +144,7 @@ errmsgCannotUseForGlobal: '%s はグローバルチャンネル名に使用で
errmsgInvalidColorCode: '%s はカラーコードとして正しくありません。'
errmsgInvalidTemplateNumber: 'テンプレート番号は、0から9までの数字を指定してください。'
errmsgToolongDescription: '説明文は %d 文字以下にしてください。'
errmsgToolongAlias: 'チャンネル別名は %d 文字以下にしてください。'
errmsgToolongPassword: 'パスワードは %d 文字以下にしてください。'
errmsgInvalidBooleanOption: '%s は true/false で指定してください。'
errmsgInvalidRangeOption: 'range に正しくない値が指定されました。'
@@ -152,6 +154,7 @@ errmsgInvalidBanExpireParameter: 'BAN期限(分)の指定が正しくありま
errmsgInvalidMuteExpireParameter: 'Mute期限(分)の指定が正しくありません。1 から 43200 の間の数値を指定してください。'
errmsgNotInCheckRemoveConfirm: 'あなたはクリーンアップモードに入っていません。先に、/%s check を実行してください。'
errmsgCannotHideSelf: '自分の発言を非表示にすることはできません。'
errmsgDuplicatedAlias: '指定されたチャンネル別名 %s は、チャンネル %s と重複するので設定できません。'
errmsgNotPermission: '権限がありません&7(%s)'
errmsgChannelChatDisabled: 'このサーバーでは、チャンネルチャットは動作しません。'
+20
ファイルの表示
@@ -65,9 +65,15 @@ permissions:
lunachat.join:
description: joinコマンドの使用権限
default: true
lunachat.join.*:
description: joinコマンドの使用権限
default: true
lunachat.leave:
description: leaveコマンドの使用権限
default: true
lunachat.leave.*:
description: leaveコマンドの使用権限
default: true
lunachat.list:
description: listコマンドの使用権限
default: true
@@ -107,6 +113,9 @@ permissions:
lunachat.log:
description: logコマンドの使用権限
default: true
lunachat.log.*:
description: logコマンドの使用権限
default: true
lunachat.create:
description: createコマンドの使用権限
default: true
@@ -137,10 +146,15 @@ permissions:
lunachat.allowcc:
description: チャットにおけるカラーコードの使用権限
default: true
lunachat.speak.*:
description: チャンネルにおける発言権限
default: true
lunachat.*:
children:
lunachat.join: true
lunachat.join.*: true
lunachat.leave: true
lunachat.leave.*: true
lunachat.list: true
lunachat.invite: true
lunachat.accept: true
@@ -154,6 +168,7 @@ permissions:
lunachat.unhide: true
lunachat.info: true
lunachat.log: true
lunachat.log.*: true
lunachat.create: true
lunachat.remove: true
lunachat.format: true
@@ -164,11 +179,15 @@ permissions:
lunachat.help: true
lunachat.japanize: true
lunachat.allowcc: true
lunachat.speak.*: true
description: 一般ユーザー向けの全コマンドの使用権限
lunachat.option.description:
description: descriptionオプション設定コマンドの使用権限
default: true
lunachat.option.alias:
description: aliasオプション設定コマンドの使用権限
default: true
lunachat.option.color:
description: colorオプション設定コマンドの使用権限
default: true
@@ -190,6 +209,7 @@ permissions:
lunachat.option.*:
children:
lunachat.option.description: true
lunachat.option.alias: true
lunachat.option.color: true
lunachat.option.broadcast: true
lunachat.option.range: true