コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
9e65f0f63b | ||
|
|
7b73ad1c21 | ||
|
|
167293d5e5 | ||
|
|
d14840f144 | ||
|
|
b3ed3103e4 | ||
|
|
d652fcb39a | ||
|
|
e2eea8798d | ||
|
|
0466653e89 | ||
|
|
74a2e4de8c | ||
|
|
881d3504b6 | ||
|
|
f0fe3f02e6 | ||
|
|
7f877d0674 | ||
|
|
b9fcb18aac | ||
|
|
134ad9b264 | ||
|
|
59f7ffd858 | ||
|
|
86773b9b85 | ||
|
|
398532a127 | ||
|
|
f4d736cc50 | ||
|
|
4a5bc4ccfa | ||
|
|
4e0c3e50e3 | ||
|
|
783c8628be | ||
|
|
758cfc067d | ||
|
|
4a3aeef20c | ||
|
|
cc69fad512 | ||
|
|
40c8ad01c9 | ||
|
|
82aed2e129 | ||
|
|
1fbbba5a80 | ||
|
|
75fe8a98ec | ||
|
|
7abc57f9ac | ||
|
|
172e64aa50 | ||
|
|
a08c043055 | ||
|
|
62ba2bab60 | ||
|
|
2091e4f66c | ||
|
|
43d0d6946e | ||
|
|
f5e78338b3 | ||
|
|
fc6589d188 | ||
|
|
adfc7db64b | ||
|
|
a127034d91 | ||
|
|
89763cfe4d | ||
|
|
1513dd8197 | ||
|
|
f5910411f4 | ||
|
|
e82aa534ba | ||
|
|
db5fad0bb8 | ||
|
|
4dc513242c | ||
|
|
6202f00729 | ||
|
|
330fb0aaab | ||
|
|
e8b61c5a64 | ||
|
|
730d221442 | ||
|
|
a638580b6d | ||
|
|
6e7a3a7195 | ||
|
|
3027bedb10 | ||
|
|
5ddd0959d8 | ||
|
|
7fdb159cff | ||
|
|
73154ba43d | ||
|
|
3e857dd1dd | ||
|
|
5ba796a198 | ||
|
|
7135b867d3 | ||
|
|
a981b1050a | ||
|
|
2fe4c2b960 | ||
|
|
534130f0a8 | ||
|
|
1cc17ec0b6 | ||
|
|
95ef86a6d0 | ||
|
|
edbba82258 | ||
|
|
62311a0db0 | ||
|
|
75656e8e5c | ||
|
|
06a817ff35 | ||
|
|
c139bbd79c | ||
|
|
23da91109e | ||
|
|
df6e351bc9 | ||
|
|
f334b685a5 | ||
|
|
24390f3c95 | ||
|
|
38e3f436a1 | ||
|
|
0c4d9e48b6 | ||
|
|
9406baf743 | ||
|
|
0a1e41c11b | ||
|
|
8e804ca852 | ||
|
|
99732a8e3b | ||
|
|
14cfe86dc6 | ||
|
|
bc48258ce5 | ||
|
|
15ef0850ee | ||
|
|
52b8e1f684 | ||
|
|
16eb0ad1dd | ||
|
|
48f8841a67 | ||
|
|
bc892499b1 | ||
|
|
0285630a95 | ||
|
|
d926068e9a | ||
|
|
8eb47f3936 | ||
|
|
4fddd66bef | ||
|
|
c2512d0de2 | ||
|
|
680464636b | ||
|
|
49a514b1ac | ||
|
|
3b927e4df7 | ||
|
|
92cc083564 | ||
|
|
4ab7b3259b | ||
|
|
8e4591926f | ||
|
|
8956113960 | ||
|
|
e8d2583ac0 | ||
|
|
2ca00098e5 | ||
|
|
edf3947879 | ||
|
|
a15fbd6dfd | ||
|
|
3c35001148 | ||
|
|
397f92c825 | ||
|
|
6951eb77fc | ||
|
|
82fa7a73f8 | ||
|
|
a7b28931e9 | ||
|
|
d3fa98509d | ||
|
|
42a9625595 | ||
|
|
aab06a502a | ||
|
|
2e032f9ecf | ||
|
|
f7f741d926 | ||
|
|
c9e4d01a68 | ||
|
|
fdeb9d0610 | ||
|
|
2b0e3a9b97 | ||
|
|
e053d72010 | ||
|
|
eeb1a28911 | ||
|
|
dca18b87e4 | ||
|
|
b99d447d81 | ||
|
|
d647fadd17 | ||
|
|
0dfd00b57c | ||
|
|
d17f2396d9 | ||
|
|
9508b3a782 | ||
|
|
7fbf4922c3 | ||
|
|
6e724cd982 | ||
|
|
09ffa3331c | ||
|
|
4c5aa2e74a | ||
|
|
c0e62e291f | ||
|
|
33ffff385d | ||
|
|
3da5bd6a78 | ||
|
|
93d3cb7f73 | ||
|
|
0e5bd3fe0a | ||
|
|
7fea872978 | ||
|
|
2ab48a42b6 | ||
|
|
469aed23eb | ||
|
|
6e0e815fea | ||
|
|
f7d710c35e | ||
|
|
24850a1b12 | ||
|
|
3e32bcf4ec | ||
|
|
b9fbc2faf1 | ||
|
|
4733ae7e88 | ||
|
|
ef864c1fc1 | ||
|
|
5f4622798a | ||
|
|
4438eb4798 | ||
|
|
7a1e36ce87 | ||
|
|
2b382ec31c | ||
|
|
571c060beb | ||
|
|
1ed874b6fd | ||
|
|
1fe273fa58 | ||
|
|
26ceb8db45 | ||
|
|
0dfd18440e | ||
|
|
b2af663fcd | ||
|
|
b1b91a0864 | ||
|
|
24c5de4e7c | ||
|
|
22541c1c9d | ||
|
|
23559dfebf | ||
|
|
6128131b11 | ||
|
|
2107091307 | ||
|
|
3dfd6d03be | ||
|
|
89a8decae6 | ||
|
|
1bacfee569 | ||
|
|
d1b979fc77 | ||
|
|
53e0eaae04 | ||
|
|
b1da4400f9 | ||
|
|
a0712c89fc | ||
|
|
4ecbe10636 | ||
|
|
148ef46937 | ||
|
|
30bfd3f2e8 | ||
|
|
e80aa29253 | ||
|
|
a98007ecce | ||
|
|
cd69bc713e | ||
|
|
8cc4c1a096 | ||
|
|
713501d859 | ||
|
|
5ff50f28fd | ||
|
|
c6a7476310 | ||
|
|
4b22e36235 | ||
|
|
b367917c55 | ||
|
|
2459af7e2b | ||
|
|
f282d50400 | ||
|
|
d5b3906275 | ||
|
|
6dbfe8eba6 | ||
|
|
cf719a8bd4 | ||
|
|
4eae2d9785 | ||
|
|
3e35f5fceb | ||
|
|
22cfbe56a6 | ||
|
|
592913440e | ||
|
|
e4b1d8db3b | ||
|
|
bc6773c517 | ||
|
|
70ce772237 | ||
|
|
8dbdb7f60c | ||
|
|
24b774833f | ||
|
|
e6eefbfca8 | ||
|
|
a0ee4550ec | ||
|
|
ef5ed27d27 | ||
|
|
9b0ceebd91 | ||
|
|
14656671ab | ||
|
|
1849e7c702 | ||
|
|
71437b33f8 | ||
|
|
22b9a719b0 | ||
|
|
6e7bbe9734 | ||
|
|
a49eb3dea7 | ||
|
|
cad998945d | ||
|
|
307a1c5db6 | ||
|
|
498423b0f1 | ||
|
|
daad74c493 | ||
|
|
2610367f89 | ||
|
|
6b75612d17 | ||
|
|
6a1e82421a | ||
|
|
0ac072433c | ||
|
|
0bcdcfd03f | ||
|
|
050a46d814 | ||
|
|
150cf775c5 | ||
|
|
62aa27e7ff | ||
|
|
a3ce08b48a | ||
|
|
2e2044022b | ||
|
|
4ee7937b89 | ||
|
|
42b63d1359 | ||
|
|
f647cfc90e | ||
|
|
046f865d15 | ||
|
|
098cc360dd | ||
|
|
cb03184c81 |
検索条件に一致するファイルはありません
@@ -0,0 +1 @@
|
||||
github: ucchyocean
|
||||
@@ -2,3 +2,8 @@
|
||||
/.classpath
|
||||
/.project
|
||||
/target
|
||||
#IntelliJ
|
||||
.idea/
|
||||
*.iml
|
||||
/.sts4-cache
|
||||
/LunaChat
|
||||
@@ -0,0 +1,9 @@
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk11
|
||||
- openjdk8
|
||||
- openjdk10
|
||||
- openjdk11
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
@@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
@@ -1,10 +1,12 @@
|
||||
LunaChat
|
||||
========
|
||||
|
||||
チャンネルチャットプラグイン for ShiroumiServer<br />
|
||||
Build Status : [](https://travis-ci.org/ucchyocean/LunaChat)
|
||||
|
||||
チャンネルチャットプラグイン<br />
|
||||
<br />
|
||||
ダウンロードはこちらから<br />
|
||||
http://forum.minecraftuser.jp/viewtopic.php?f=38&t=13739<br />
|
||||
https://github.com/ucchyocean/LunaChat/releases<br />
|
||||
<br />
|
||||
コマンドリファレンスや、設定リファレンスは、こちらから<br />
|
||||
https://github.com/ucchyocean/LunaChat/wiki/Commands<br />
|
||||
|
||||
@@ -2,92 +2,288 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.github.ucchyocean</groupId>
|
||||
<artifactId>LunaChat</artifactId>
|
||||
<version>2.5.4</version>
|
||||
<version>3.0.3</version>
|
||||
<description>A powerfull chat channel plugin with IME (Kana-Kanji conversion) support</description>
|
||||
<url>https://github.com/ucchyocean/LunaChat</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU Lesser General Public License version 3</name>
|
||||
<url>http://www.gnu.org/licenses/lgpl-3.0.en.html</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<java.version.short>8</java.version.short>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
<url>file://${project.basedir}/../mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<defaultGoal>clean javadoc:jar source:jar deploy</defaultGoal>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Built-By>ucchy</Built-By>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<source>${java.version}</source>
|
||||
<encoding>UTF-8</encoding>
|
||||
<docencoding>UTF-8</docencoding>
|
||||
<charset>UTF-8</charset>
|
||||
<show>public</show>
|
||||
<nohelp>true</nohelp>
|
||||
<links>
|
||||
<link>https://docs.oracle.com/javase/jp/${java.version.short}/docs/api/</link>
|
||||
<link>https://hub.spigotmc.org/javadocs/bukkit/</link>
|
||||
</links>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.google.gson</pattern>
|
||||
<shadedPattern>com.github.ucchyocean.lc.lib.com.google.gson</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.apache.commons.lang3</pattern>
|
||||
<shadedPattern>com.github.ucchyocean.lc.lib.org.apache.commons.lang3</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.jetbrains</pattern>
|
||||
<shadedPattern>com.github.ucchyocean.lc.lib.org.jetbrains</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>com.github.ucchyocean.lc.lib.org.bstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
<configuration>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
<encoding>UTF-8</encoding>
|
||||
<inputEncoding>UTF-8</inputEncoding>
|
||||
<outputEncoding>UTF-8</outputEncoding>
|
||||
<argLine>-Dfile.encoding=UTF-8</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<name>Craft Bukkit Maven Repository</name>
|
||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||
<id>jitpack.io</id>
|
||||
<name>Vault Repository</name>
|
||||
<url>https://jitpack.io/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>herocraft-repo</id>
|
||||
<name>Herocraft Repository</name>
|
||||
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
|
||||
<id>mikeprimm-repo</id>
|
||||
<name>Dynmap repository</name>
|
||||
<url>https://repo.mikeprimm.com/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>dynmap-repo</id>
|
||||
<name>mikeprimm repository</name>
|
||||
<url>http://repo.mikeprimm.com/</url>
|
||||
<id>onarandombox-repo</id>
|
||||
<name>Multiverse repository</name>
|
||||
<url>http://repo.onarandombox.com/content/repositories/multiverse/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<name>CodeMC Repository</name>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>weaondara-repo</id>
|
||||
<name>wea_ondara's Repository</name>
|
||||
<url>http://repo.wea-ondara.net/repository/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>md5-repo</id>
|
||||
<name>MD5 repository</name>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>BungeeCord-repo</id>
|
||||
<name>sonatype repository</name>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.6.4-R2.0</version>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.6.4-R2.0</version>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.16-R0.2-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>1.2.27</version>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>1.16-R0.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>dynmap-api</artifactId>
|
||||
<version>1.9</version>
|
||||
<version>2.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>4.1.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.128</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.maven.scm</groupId>
|
||||
<artifactId>maven-scm-provider-gitexe</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-legacy</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.alpenblock</groupId>
|
||||
<artifactId>BungeePerms</artifactId>
|
||||
<version>4.0-dev-106</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.luckperms</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>5.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bungeecord</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -1,530 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelCreateEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelRemoveEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatPostJapanizeEvent;
|
||||
import com.github.ucchyocean.lc.japanize.IMEConverter;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc.japanize.KanaConverter;
|
||||
|
||||
/**
|
||||
* チャンネルマネージャー
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ChannelManager implements LunaChatAPI {
|
||||
|
||||
private static final String MOTD_FIRSTLINE = Resources.get("motdFirstLine");
|
||||
private static final String LIST_ENDLINE = Resources.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Resources.get("listFormat");
|
||||
|
||||
private static final String MSG_BREAKUP = Resources.get("breakupMessage");
|
||||
|
||||
private static final String FILE_NAME_DCHANNELS = "defaults.yml";
|
||||
private static final String FILE_NAME_TEMPLATES = "templates.yml";
|
||||
private static final String FILE_NAME_JAPANIZE = "japanize.yml";
|
||||
|
||||
private File fileDefaults;
|
||||
private File fileTemplates;
|
||||
private File fileJapanize;
|
||||
private HashMap<String, Channel> channels;
|
||||
private HashMap<String, String> defaultChannels;
|
||||
private HashMap<String, String> templates;
|
||||
private HashMap<String, Boolean> japanize;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*/
|
||||
public ChannelManager() {
|
||||
reloadAllData();
|
||||
}
|
||||
|
||||
/**
|
||||
* すべて読み込みする
|
||||
*/
|
||||
@Override
|
||||
public void reloadAllData() {
|
||||
|
||||
// デフォルトチャンネル設定のロード
|
||||
fileDefaults = new File(
|
||||
LunaChat.instance.getDataFolder(), FILE_NAME_DCHANNELS);
|
||||
|
||||
if ( !fileDefaults.exists() ) {
|
||||
YamlConfiguration conf = new YamlConfiguration();
|
||||
try {
|
||||
conf.save(fileDefaults);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
YamlConfiguration config =
|
||||
YamlConfiguration.loadConfiguration(fileDefaults);
|
||||
|
||||
defaultChannels = new HashMap<String, String>();
|
||||
for ( String key : config.getKeys(false) ) {
|
||||
defaultChannels.put(key, config.getString(key).toLowerCase());
|
||||
}
|
||||
|
||||
// テンプレート設定のロード
|
||||
fileTemplates = new File(
|
||||
LunaChat.instance.getDataFolder(), FILE_NAME_TEMPLATES);
|
||||
|
||||
if ( !fileTemplates.exists() ) {
|
||||
YamlConfiguration conf = new YamlConfiguration();
|
||||
try {
|
||||
conf.save(fileTemplates);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
YamlConfiguration configTemplates =
|
||||
YamlConfiguration.loadConfiguration(fileTemplates);
|
||||
|
||||
templates = new HashMap<String, String>();
|
||||
for ( String key : configTemplates.getKeys(false) ) {
|
||||
templates.put(key, configTemplates.getString(key));
|
||||
}
|
||||
|
||||
// Japanize設定のロード
|
||||
fileJapanize = new File(
|
||||
LunaChat.instance.getDataFolder(), FILE_NAME_JAPANIZE);
|
||||
|
||||
if ( !fileJapanize.exists() ) {
|
||||
YamlConfiguration conf = new YamlConfiguration();
|
||||
try {
|
||||
conf.save(fileJapanize);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
YamlConfiguration configJapanize =
|
||||
YamlConfiguration.loadConfiguration(fileJapanize);
|
||||
|
||||
japanize = new HashMap<String, Boolean>();
|
||||
for ( String key : configJapanize.getKeys(false) ) {
|
||||
japanize.put(key, configJapanize.getBoolean(key));
|
||||
}
|
||||
|
||||
// チャンネル設定のロード
|
||||
channels = Channel.loadAllChannels();
|
||||
|
||||
// コンフィグのリロード
|
||||
if ( LunaChat.config != null ) {
|
||||
LunaChat.config.reloadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* すべて保存する
|
||||
*/
|
||||
protected void saveAllChannels() {
|
||||
|
||||
saveDefaults();
|
||||
|
||||
for ( Channel channel : channels.values() ) {
|
||||
channel.save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* デフォルトチャンネル設定を保存する
|
||||
* @return 保存したかどうか
|
||||
*/
|
||||
private boolean saveDefaults() {
|
||||
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
for ( String key : defaultChannels.keySet() ) {
|
||||
config.set(key, defaultChannels.get(key));
|
||||
}
|
||||
config.save(fileDefaults);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* テンプレート設定を保存する
|
||||
* @return 保存したかどうか
|
||||
*/
|
||||
private boolean saveTemplates() {
|
||||
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
for ( String key : templates.keySet() ) {
|
||||
config.set(key, templates.get(key));
|
||||
}
|
||||
config.save(fileTemplates);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize設定を保存する
|
||||
* @return 保存したかどうか
|
||||
*/
|
||||
private boolean saveJapanize() {
|
||||
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
for ( String key : japanize.keySet() ) {
|
||||
config.set(key, japanize.get(key));
|
||||
}
|
||||
config.save(fileJapanize);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのサーバー参加時用の参加チャンネルリストを返す
|
||||
* @param player プレイヤー
|
||||
* @return リスト
|
||||
*/
|
||||
protected ArrayList<String> getListForMotd(Player player) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
String playerName = player.getName();
|
||||
String dchannel = defaultChannels.get(player.getName());
|
||||
if ( dchannel == null ) {
|
||||
dchannel = "";
|
||||
}
|
||||
|
||||
items.add(MOTD_FIRSTLINE);
|
||||
for ( String key : channels.keySet() ) {
|
||||
Channel channel = channels.get(key);
|
||||
|
||||
// BANされているチャンネルは表示しない
|
||||
if ( channel.getBanned().contains(playerName) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットはリストに表示しない
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 参加していないチャンネルは、グローバルチャンネルを除き表示しない
|
||||
if ( !channel.getMembers().contains(playerName) &&
|
||||
!channel.isGlobalChannel() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String disp = ChatColor.WHITE + channel.getName();
|
||||
if ( key.equals(dchannel.toLowerCase()) ) {
|
||||
disp = ChatColor.RED + channel.getName();
|
||||
}
|
||||
String desc = channel.getDescription();
|
||||
int onlineNum = channel.getOnlineNum();
|
||||
int memberNum = channel.getTotalNum();
|
||||
String item = String.format(
|
||||
LIST_FORMAT, disp, onlineNum, memberNum, desc);
|
||||
items.add(item);
|
||||
}
|
||||
items.add(LIST_ENDLINE);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのJapanize設定を返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return Japanize設定
|
||||
*/
|
||||
protected boolean isPlayerJapanize(String playerName) {
|
||||
if ( !japanize.containsKey(playerName) ) {
|
||||
return true;
|
||||
}
|
||||
return japanize.get(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* デフォルトチャンネル設定を全て削除する
|
||||
*/
|
||||
protected void removeAllDefaultChannels() {
|
||||
defaultChannels.clear();
|
||||
saveDefaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定したチャンネル名が存在するかどうかを返す
|
||||
* @param channelName チャンネル名
|
||||
* @return 存在するかどうか
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#isExistChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isExistChannel(String channelName) {
|
||||
if ( channelName == null ) {
|
||||
return false;
|
||||
}
|
||||
return channels.containsKey(channelName.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* 全てのチャンネルを返す
|
||||
* @return 全てのチャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#getChannels()
|
||||
*/
|
||||
@Override
|
||||
public Collection<Channel> getChannels() {
|
||||
|
||||
return channels.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているチャンネルを返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return チャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#getChannelsByPlayer(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Collection<Channel> getChannelsByPlayer(String playerName) {
|
||||
|
||||
Collection<Channel> result = new ArrayList<Channel>();
|
||||
for ( String key : channels.keySet() ) {
|
||||
Channel channel = channels.get(key);
|
||||
if ( channel.getMembers().contains(playerName) ||
|
||||
channel.isGlobalChannel() ) {
|
||||
result.add(channel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているデフォルトのチャンネルを返す
|
||||
* @param playerName プレイヤー
|
||||
* @return チャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#getDefaultChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Channel getDefaultChannel(String playerName) {
|
||||
|
||||
String cname = defaultChannels.get(playerName);
|
||||
|
||||
if ( cname == null || !isExistChannel(cname) ) {
|
||||
return null;
|
||||
}
|
||||
return channels.get(cname);
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのデフォルトチャンネルを設定する
|
||||
* @param playerName プレイヤー
|
||||
* @param channelName チャンネル名
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#setDefaultChannel(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setDefaultChannel(String playerName, String channelName) {
|
||||
if ( channelName == null ) {
|
||||
removeDefaultChannel(playerName);
|
||||
return;
|
||||
}
|
||||
defaultChannels.put(playerName, channelName.toLowerCase());
|
||||
saveDefaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定した名前のプレイヤーに設定されている、デフォルトチャンネルを削除する
|
||||
* @param playerName プレイヤー名
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#removeDefaultChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void removeDefaultChannel(String playerName) {
|
||||
if ( defaultChannels.containsKey(playerName) ) {
|
||||
defaultChannels.remove(playerName);
|
||||
}
|
||||
saveDefaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを取得する
|
||||
* @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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @return 作成されたチャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#createChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Channel createChannel(String channelName) {
|
||||
|
||||
// イベントコール
|
||||
LunaChatChannelCreateEvent event =
|
||||
new LunaChatChannelCreateEvent(channelName);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if ( event.isCancelled() ) {
|
||||
return null;
|
||||
}
|
||||
String name = event.getChannelName();
|
||||
|
||||
Channel channel = new Channel(name);
|
||||
channels.put(name.toLowerCase(), channel);
|
||||
channel.save();
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @return 削除したかどうか
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#removeChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeChannel(String channelName) {
|
||||
|
||||
channelName = channelName.toLowerCase();
|
||||
|
||||
// イベントコール
|
||||
LunaChatChannelRemoveEvent event =
|
||||
new LunaChatChannelRemoveEvent(channelName);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if ( event.isCancelled() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Channel channel = getChannel(channelName);
|
||||
if ( channel != null ) {
|
||||
channel.remove();
|
||||
channels.remove(channelName);
|
||||
|
||||
// チャンネルのメンバーを強制解散させる
|
||||
String message = String.format(MSG_BREAKUP, channelName);
|
||||
for ( String pname : channel.getMembers() ) {
|
||||
Player player = Bukkit.getPlayerExact(pname);
|
||||
if ( player != null ) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* テンプレートを取得する
|
||||
* @param id テンプレートID
|
||||
* @return テンプレート
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#getTemplate(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String getTemplate(String id) {
|
||||
return templates.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* テンプレートを登録する
|
||||
* @param id テンプレートID
|
||||
* @param template テンプレート
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#setTemplate(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setTemplate(String id, String template) {
|
||||
templates.put(id, template);
|
||||
saveTemplates();
|
||||
}
|
||||
|
||||
/**
|
||||
* テンプレートを削除する
|
||||
* @param id テンプレートID
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#removeTemplate(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void removeTemplate(String id) {
|
||||
templates.remove(id);
|
||||
saveTemplates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換を行う
|
||||
* @param message 変換するメッセージ
|
||||
* @param type 変換タイプ
|
||||
* @return 変換後のメッセージ、ただしイベントでキャンセルされた場合はnullが返されるので注意
|
||||
*/
|
||||
@Override
|
||||
public String japanize(String message, JapanizeType type) {
|
||||
|
||||
if ( type == JapanizeType.NONE ) {
|
||||
return message;
|
||||
}
|
||||
|
||||
// カナ変換
|
||||
String japanized = KanaConverter.conv(message);
|
||||
|
||||
// IME変換
|
||||
if ( type == JapanizeType.GOOGLE_IME ) {
|
||||
japanized = IMEConverter.convByGoogleIME(japanized);
|
||||
} else if ( type == JapanizeType.SOCIAL_IME ) {
|
||||
japanized = IMEConverter.convBySocialIME(japanized);
|
||||
}
|
||||
|
||||
// イベントコール
|
||||
LunaChatPostJapanizeEvent event =
|
||||
new LunaChatPostJapanizeEvent("", message, japanized);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if ( event.isCancelled() ) {
|
||||
return null;
|
||||
}
|
||||
japanized = event.getJapanized();
|
||||
|
||||
return japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* 該当プレイヤーのJapanize変換をオン/オフする
|
||||
* @param playerName 設定するプレイヤー名
|
||||
* @param doJapanize Japanize変換するかどうか
|
||||
*/
|
||||
@Override
|
||||
public void setPlayersJapanize(String playerName, boolean doJapanize) {
|
||||
japanize.put(playerName, doJapanize);
|
||||
saveJapanize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された名前がチャンネル名として使用可能かどうかを判定する<br/>
|
||||
* 具体的には、英数字・ハイフン・アンダーバー のいずれかから構成される、
|
||||
* 1文字から20文字の文字列、の場合に、trueを返す。<br/>
|
||||
* (既に存在するチャンネル名をチェックするわけではない。)
|
||||
* @param name 名前
|
||||
* @return チャンネル名として使用可能かどうか
|
||||
*/
|
||||
@Override
|
||||
public boolean checkForChannelName(String name) {
|
||||
return name.matches("[0-9a-zA-Z\\-_]{1,20}");
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.github.ucchyocean.lc.event.LunaChatPostJapanizeEvent;
|
||||
import com.github.ucchyocean.lc.japanize.IMEConverter;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc.japanize.KanaConverter;
|
||||
|
||||
/**
|
||||
* Japanize変換を実行して、実行後に発言を行うタスク
|
||||
* @author ucchy
|
||||
*/
|
||||
public class DelayedJapanizeConvertTask extends BukkitRunnable {
|
||||
|
||||
private String org;
|
||||
private JapanizeType type;
|
||||
private Channel channel;
|
||||
private Player player;
|
||||
private String format;
|
||||
private String lineFormat;
|
||||
private String result;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param org 変換前の文字列
|
||||
* @param type 変換タイプ
|
||||
* @param channel 変換後に発言する、発言先チャンネル
|
||||
* @param player 発言したプレイヤー
|
||||
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
|
||||
*/
|
||||
public DelayedJapanizeConvertTask(String org, JapanizeType type, Channel channel,
|
||||
Player player, String japanizeFormat, String lineFormat) {
|
||||
this.org = org;
|
||||
this.type = type;
|
||||
this.channel = channel;
|
||||
this.player = player;
|
||||
this.format = japanizeFormat;
|
||||
this.lineFormat = lineFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if ( runSync() ) {
|
||||
|
||||
// チャンネルへ送信
|
||||
if ( channel != null ) {
|
||||
channel.sendMessage(player, result, lineFormat);
|
||||
} else {
|
||||
Bukkit.broadcastMessage(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同期処理で変換を行います。結果は getResult() で取得してください。
|
||||
* @return 同期処理を実行したかどうか(イベントでキャンセルされた場合はfalseになります)
|
||||
*/
|
||||
private boolean runSync() {
|
||||
|
||||
// カナ変換
|
||||
String japanized = KanaConverter.conv(org);
|
||||
|
||||
// IME変換
|
||||
if ( type == JapanizeType.GOOGLE_IME ) {
|
||||
japanized = IMEConverter.convByGoogleIME(japanized);
|
||||
} else if ( type == JapanizeType.SOCIAL_IME ) {
|
||||
japanized = IMEConverter.convBySocialIME(japanized);
|
||||
}
|
||||
|
||||
// イベントコール
|
||||
String channelName = (channel == null) ? "" : channel.getName();
|
||||
LunaChatPostJapanizeEvent event =
|
||||
new LunaChatPostJapanizeEvent(channelName, org, japanized);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if ( event.isCancelled() ) {
|
||||
return false;
|
||||
}
|
||||
japanized = event.getJapanized();
|
||||
|
||||
// フォーマットする
|
||||
result = format.replace("%msg", org);
|
||||
result = result.replace("%japanize", japanized);
|
||||
result = Utility.replaceColorCode(result);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,93 +5,31 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.github.ucchyocean.lc.bridge.DynmapBridge;
|
||||
import com.github.ucchyocean.lc.bridge.VaultChatBridge;
|
||||
import com.github.ucchyocean.lc.command.LunaChatCommand;
|
||||
import com.github.ucchyocean.lc.command.LunaChatJapanizeCommand;
|
||||
import com.github.ucchyocean.lc.command.LunaChatMessageCommand;
|
||||
import com.github.ucchyocean.lc.command.LunaChatReplyCommand;
|
||||
|
||||
/**
|
||||
* LunaChat プラグイン
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChat extends JavaPlugin {
|
||||
public class LunaChat {
|
||||
|
||||
public static LunaChat instance;
|
||||
protected static LunaChatConfig config;
|
||||
protected static ChannelManager manager;
|
||||
|
||||
protected static VaultChatBridge vaultchat;
|
||||
protected static DynmapBridge dynmap;
|
||||
private static LunaChat instance = new LunaChat();
|
||||
@SuppressWarnings("deprecation")
|
||||
private LunaChatAPI api = new LunaChatAPIImpl();
|
||||
|
||||
/**
|
||||
* プラグインが有効化されたときに呼び出されるメソッド
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onEnable()
|
||||
* LunaChatのインスタンスを返す
|
||||
* @return LunaChat
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
// 変数などの初期化
|
||||
instance = this;
|
||||
manager = new ChannelManager();
|
||||
config = new LunaChatConfig();
|
||||
|
||||
// Chat Plugin のロード
|
||||
Plugin temp = getServer().getPluginManager().getPlugin("Vault");
|
||||
if ( temp != null ) {
|
||||
vaultchat = VaultChatBridge.load(temp);
|
||||
}
|
||||
|
||||
// Dynmap のロード
|
||||
temp = getServer().getPluginManager().getPlugin("dynmap");
|
||||
if ( temp != null ) {
|
||||
dynmap = DynmapBridge.load(temp);
|
||||
if ( dynmap != null ) {
|
||||
getServer().getPluginManager().registerEvents(dynmap, this);
|
||||
}
|
||||
}
|
||||
|
||||
// リスナーの登録
|
||||
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
|
||||
// コマンドの登録
|
||||
getCommand("lunachat").setExecutor(new LunaChatCommand());
|
||||
getCommand("message").setExecutor(new LunaChatMessageCommand());
|
||||
getCommand("reply").setExecutor(new LunaChatReplyCommand());
|
||||
getCommand("lcjapanize").setExecutor(new LunaChatJapanizeCommand());
|
||||
|
||||
// シリアル化可能オブジェクトの登録
|
||||
ConfigurationSerialization.registerClass(Channel.class, "Channel");
|
||||
}
|
||||
|
||||
/**
|
||||
* このプラグインのJarファイル自身を示すFileクラスを返す。
|
||||
* @return
|
||||
*/
|
||||
protected static File getPluginJarFile() {
|
||||
return instance.getFile();
|
||||
public static LunaChat getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatAPIを取得する
|
||||
* @return LunaChatAPI
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public LunaChatAPI getLunaChatAPI() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatConfigを取得する
|
||||
* @return LunaChatConfig
|
||||
*/
|
||||
public LunaChatConfig getLunaChatConfig() {
|
||||
return config;
|
||||
return api;
|
||||
}
|
||||
}
|
||||
@@ -1,128 +1,215 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
|
||||
/**
|
||||
* LunaChat APIクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public interface LunaChatAPI {
|
||||
|
||||
/**
|
||||
* 指定したチャンネル名が存在するかどうかを返す
|
||||
* @param channelName チャンネル名
|
||||
* @return 存在するかどうか
|
||||
*/
|
||||
public boolean isExistChannel(String channelName);
|
||||
|
||||
/**
|
||||
* 全てのチャンネルを返す
|
||||
* @return 全てのチャンネル
|
||||
*/
|
||||
public Collection<Channel> getChannels();
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているチャンネルを返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return チャンネル
|
||||
*/
|
||||
public Collection<Channel> getChannelsByPlayer(String playerName);
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているデフォルトのチャンネルを返す
|
||||
* @param playerName プレイヤー
|
||||
* @return チャンネル
|
||||
*/
|
||||
public Channel getDefaultChannel(String playerName);
|
||||
|
||||
/**
|
||||
* プレイヤーのデフォルトチャンネルを設定する
|
||||
* @param playerName プレイヤー
|
||||
* @param channelName チャンネル名
|
||||
*/
|
||||
public void setDefaultChannel(String playerName, String channelName);
|
||||
|
||||
/**
|
||||
* 指定した名前のプレイヤーに設定されている、デフォルトチャンネルを削除する
|
||||
* @param playerName プレイヤー名
|
||||
*/
|
||||
public void removeDefaultChannel(String playerName);
|
||||
|
||||
/**
|
||||
* チャンネルを取得する
|
||||
* @param channelName チャンネル名
|
||||
* @return チャンネル
|
||||
*/
|
||||
public Channel getChannel(String channelName);
|
||||
|
||||
/**
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @return 作成されたチャンネル
|
||||
*/
|
||||
public Channel createChannel(String channelName);
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @return 削除したかどうか
|
||||
*/
|
||||
public boolean removeChannel(String channelName);
|
||||
|
||||
/**
|
||||
* テンプレートを取得する
|
||||
* @param id テンプレートID
|
||||
* @return テンプレート
|
||||
*/
|
||||
public String getTemplate(String id);
|
||||
|
||||
/**
|
||||
* テンプレートを登録する
|
||||
* @param id テンプレートID
|
||||
* @param template テンプレート
|
||||
*/
|
||||
public void setTemplate(String id, String template);
|
||||
|
||||
/**
|
||||
* テンプレートを削除する
|
||||
* @param id テンプレートID
|
||||
*/
|
||||
public void removeTemplate(String id);
|
||||
|
||||
/**
|
||||
* Japanize変換を行う
|
||||
* @param message 変換するメッセージ
|
||||
* @param type 変換タイプ
|
||||
* @return 変換後のメッセージ、ただしイベントでキャンセルされた場合はnullが返されるので注意
|
||||
*/
|
||||
public String japanize(String message, JapanizeType type);
|
||||
|
||||
/**
|
||||
* 該当プレイヤーのJapanize変換をオン/オフする
|
||||
* @param playerName 設定するプレイヤー名
|
||||
* @param doJapanize Japanize変換するかどうか
|
||||
*/
|
||||
public void setPlayersJapanize(String playerName, boolean doJapanize);
|
||||
|
||||
/**
|
||||
* 指定された名前がチャンネル名として使用可能かどうかを判定する<br/>
|
||||
* 具体的には、英数字・ハイフン・アンダーバー のいずれかから構成される、
|
||||
* 1文字から20文字の文字列、の場合に、trueを返す。<br/>
|
||||
* (既に存在するチャンネル名をチェックするわけではない。)
|
||||
* @param name 名前
|
||||
* @return チャンネル名として使用可能かどうか
|
||||
*/
|
||||
public boolean checkForChannelName(String name);
|
||||
|
||||
/**
|
||||
* LunaChatの全データを再読み込みする
|
||||
*/
|
||||
public void reloadAllData();
|
||||
}
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
|
||||
/**
|
||||
* LunaChat APIクラス
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public interface LunaChatAPI {
|
||||
|
||||
/**
|
||||
* 指定したチャンネル名が存在するかどうかを返す
|
||||
* @param channelName チャンネル名
|
||||
* @return 存在するかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isExistChannel(String channelName);
|
||||
|
||||
/**
|
||||
* 全てのチャンネルを返す
|
||||
* @return 全てのチャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Collection<Channel> getChannels();
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているチャンネルを返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return チャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Collection<Channel> getChannelsByPlayer(String playerName);
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているデフォルトのチャンネルを返す
|
||||
* @param playerName プレイヤー
|
||||
* @return チャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Channel getDefaultChannel(String playerName);
|
||||
|
||||
/**
|
||||
* プレイヤーのデフォルトチャンネルを設定する
|
||||
* @param playerName プレイヤー
|
||||
* @param channelName チャンネル名
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setDefaultChannel(String playerName, String channelName);
|
||||
|
||||
/**
|
||||
* 指定した名前のプレイヤーに設定されている、デフォルトチャンネルを削除する
|
||||
* @param playerName プレイヤー名
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeDefaultChannel(String playerName);
|
||||
|
||||
/**
|
||||
* チャンネルを取得する
|
||||
* @param channelName チャンネル名
|
||||
* @return チャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Channel getChannel(String channelName);
|
||||
|
||||
/**
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @return 作成されたチャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Channel createChannel(String channelName);
|
||||
|
||||
/**
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @param sender チャンネルを作成した人
|
||||
* @return 作成されたチャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Channel createChannel(String channelName, CommandSender sender);
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @return 削除したかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean removeChannel(String channelName);
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @param sender チャンネルを削除した人
|
||||
* @return 削除したかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean removeChannel(String channelName, CommandSender sender);
|
||||
|
||||
/**
|
||||
* テンプレートを取得する
|
||||
* @param id テンプレートID
|
||||
* @return テンプレート
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String getTemplate(String id);
|
||||
|
||||
/**
|
||||
* テンプレートを登録する
|
||||
* @param id テンプレートID
|
||||
* @param template テンプレート
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setTemplate(String id, String template);
|
||||
|
||||
/**
|
||||
* テンプレートを削除する
|
||||
* @param id テンプレートID
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeTemplate(String id);
|
||||
|
||||
/**
|
||||
* 辞書データを全て取得する
|
||||
* @return 辞書データ
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public HashMap<String, String> getAllDictionary();
|
||||
|
||||
/**
|
||||
* 新しい辞書データを追加する
|
||||
* @param key キー
|
||||
* @param value 値
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setDictionary(String key, String value);
|
||||
|
||||
/**
|
||||
* 指定したキーの辞書データを削除する
|
||||
* @param key キー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeDictionary(String key);
|
||||
|
||||
/**
|
||||
* 該当のプレイヤーに関連するhidelistを取得する。
|
||||
* @param key プレイヤー
|
||||
* @return 指定されたプレイヤーをhideしているプレイヤー(非null)
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public List<ChannelPlayer> getHidelist(ChannelPlayer key);
|
||||
|
||||
/**
|
||||
* 該当のプレイヤーがhideしているプレイヤーのリストを返す。
|
||||
* @param player プレイヤー
|
||||
* @return 指定したプレイヤーがhideしているプレイヤーのリスト
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public ArrayList<ChannelPlayer> getHideinfo(ChannelPlayer player);
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーが、指定されたプレイヤーをhideするように設定する。
|
||||
* @param player hideする側のプレイヤー
|
||||
* @param hided hideされる側のプレイヤー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void addHidelist(ChannelPlayer player, ChannelPlayer hided);
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーが、指定されたプレイヤーのhideを解除するように設定する。
|
||||
* @param player hideしていた側のプレイヤー
|
||||
* @param hided hideされていた側のプレイヤー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeHidelist(ChannelPlayer player, ChannelPlayer hided);
|
||||
|
||||
/**
|
||||
* Japanize変換を行う
|
||||
* @param message 変換するメッセージ
|
||||
* @param type 変換タイプ
|
||||
* @return 変換後のメッセージ、ただしイベントでキャンセルされた場合はnullが返されるので注意
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String japanize(String message, JapanizeType type);
|
||||
|
||||
/**
|
||||
* 該当プレイヤーのJapanize変換をオン/オフする
|
||||
* @param playerName 設定するプレイヤー名
|
||||
* @param doJapanize Japanize変換するかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setPlayersJapanize(String playerName, boolean doJapanize);
|
||||
|
||||
/**
|
||||
* プレイヤーのJapanize設定を返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return Japanize設定
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isPlayerJapanize(String playerName);
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerBlock;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerConsole;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerName;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerUUID;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBlock;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBukkitConsole;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBungee;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberPlayer;
|
||||
|
||||
/**
|
||||
* LunaChat API実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class LunaChatAPIImpl implements LunaChatAPI {
|
||||
|
||||
/**
|
||||
* 指定したチャンネル名が存在するかどうかを返す
|
||||
* @param channelName チャンネル名
|
||||
* @return 存在するかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isExistChannel(String channelName) {
|
||||
return com.github.ucchyocean.lc3.LunaChat.getAPI().isExistChannel(channelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全てのチャンネルを返す
|
||||
* @return 全てのチャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Collection<Channel> getChannels() {
|
||||
Collection<Channel> result = new ArrayList<Channel>();
|
||||
for ( com.github.ucchyocean.lc3.channel.Channel c :
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().getChannels() ) {
|
||||
result.add(new Channel(c));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているチャンネルを返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return チャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Collection<Channel> getChannelsByPlayer(String playerName) {
|
||||
Collection<Channel> result = new ArrayList<Channel>();
|
||||
for ( com.github.ucchyocean.lc3.channel.Channel c :
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().getChannelsByPlayer(playerName) ) {
|
||||
result.add(new Channel(c));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているデフォルトのチャンネルを返す
|
||||
* @param playerName プレイヤー
|
||||
* @return チャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Channel getDefaultChannel(String playerName) {
|
||||
com.github.ucchyocean.lc3.channel.Channel c =
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().getDefaultChannel(playerName);
|
||||
if ( c != null ) return new Channel(c);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのデフォルトチャンネルを設定する
|
||||
* @param playerName プレイヤー
|
||||
* @param channelName チャンネル名
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setDefaultChannel(String playerName, String channelName) {
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().setDefaultChannel(playerName, channelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定した名前のプレイヤーに設定されている、デフォルトチャンネルを削除する
|
||||
* @param playerName プレイヤー名
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeDefaultChannel(String playerName) {
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().removeDefaultChannel(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを取得する
|
||||
* @param channelName チャンネル名
|
||||
* @return チャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Channel getChannel(String channelName) {
|
||||
com.github.ucchyocean.lc3.channel.Channel c =
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().getChannel(channelName);
|
||||
if ( c != null ) return new Channel(c);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @return 作成されたチャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Channel createChannel(String channelName) {
|
||||
com.github.ucchyocean.lc3.channel.Channel c =
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().createChannel(channelName);
|
||||
if ( c != null ) return new Channel(c);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @param sender チャンネルを作成した人
|
||||
* @return 作成されたチャンネル
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Channel createChannel(String channelName, CommandSender sender) {
|
||||
com.github.ucchyocean.lc3.channel.Channel c =
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().createChannel(
|
||||
channelName, ChannelMember.getChannelMember(sender));
|
||||
if ( c != null ) return new Channel(c);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @return 削除したかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean removeChannel(String channelName) {
|
||||
return com.github.ucchyocean.lc3.LunaChat.getAPI().removeChannel(channelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @param sender チャンネルを削除した人
|
||||
* @return 削除したかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean removeChannel(String channelName, CommandSender sender) {
|
||||
return com.github.ucchyocean.lc3.LunaChat.getAPI().removeChannel(
|
||||
channelName, ChannelMember.getChannelMember(sender));
|
||||
}
|
||||
|
||||
/**
|
||||
* テンプレートを取得する
|
||||
* @param id テンプレートID
|
||||
* @return テンプレート
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String getTemplate(String id) {
|
||||
return com.github.ucchyocean.lc3.LunaChat.getAPI().getTemplate(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* テンプレートを登録する
|
||||
* @param id テンプレートID
|
||||
* @param template テンプレート
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setTemplate(String id, String template) {
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().setTemplate(id, template);
|
||||
}
|
||||
|
||||
/**
|
||||
* テンプレートを削除する
|
||||
* @param id テンプレートID
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeTemplate(String id) {
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().removeTemplate(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 辞書データを全て取得する
|
||||
* @return 辞書データ
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public HashMap<String, String> getAllDictionary() {
|
||||
return new HashMap<String, String>(
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().getAllDictionary());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新しい辞書データを追加する
|
||||
* @param key キー
|
||||
* @param value 値
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setDictionary(String key, String value) {
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().setDictionary(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定したキーの辞書データを削除する
|
||||
* @param key キー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeDictionary(String key) {
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().removeDictionary(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 該当のプレイヤーに関連するhidelistを取得する。
|
||||
* @param key プレイヤー
|
||||
* @return 指定されたプレイヤーをhideしているプレイヤー(非null)
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public List<ChannelPlayer> getHidelist(ChannelPlayer key) {
|
||||
List<ChannelPlayer> result = new ArrayList<ChannelPlayer>();
|
||||
ChannelMember mem = convertChannelPlayerToChannelMember(key);
|
||||
if ( mem == null ) return result;
|
||||
for ( ChannelMember m : com.github.ucchyocean.lc3.LunaChat.getAPI().getHidelist(mem) ) {
|
||||
ChannelPlayer p = convertChannelMemberToChannelPlayer(m);
|
||||
if ( p != null ) result.add(p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 該当のプレイヤーがhideしているプレイヤーのリストを返す。
|
||||
* @param player プレイヤー
|
||||
* @return 指定したプレイヤーがhideしているプレイヤーのリスト
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public ArrayList<ChannelPlayer> getHideinfo(ChannelPlayer player) {
|
||||
ArrayList<ChannelPlayer> result = new ArrayList<ChannelPlayer>();
|
||||
ChannelMember mem = convertChannelPlayerToChannelMember(player);
|
||||
if ( mem == null ) return result;
|
||||
for ( ChannelMember m : com.github.ucchyocean.lc3.LunaChat.getAPI().getHideinfo(mem) ) {
|
||||
ChannelPlayer p = convertChannelMemberToChannelPlayer(m);
|
||||
if ( p != null ) result.add(p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーが、指定されたプレイヤーをhideするように設定する。
|
||||
* @param player hideする側のプレイヤー
|
||||
* @param hided hideされる側のプレイヤー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void addHidelist(ChannelPlayer player, ChannelPlayer hided) {
|
||||
ChannelMember memPlayer = convertChannelPlayerToChannelMember(player);
|
||||
ChannelMember memHided = convertChannelPlayerToChannelMember(hided);
|
||||
if ( memPlayer == null || memHided == null ) return;
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().addHidelist(memPlayer, memHided);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーが、指定されたプレイヤーのhideを解除するように設定する。
|
||||
* @param player hideしていた側のプレイヤー
|
||||
* @param hided hideされていた側のプレイヤー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeHidelist(ChannelPlayer player, ChannelPlayer hided) {
|
||||
ChannelMember memPlayer = convertChannelPlayerToChannelMember(player);
|
||||
ChannelMember memHided = convertChannelPlayerToChannelMember(hided);
|
||||
if ( memPlayer == null || memHided == null ) return;
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().removeHidelist(memPlayer, memHided);
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換を行う
|
||||
* @param message 変換するメッセージ
|
||||
* @param type 変換タイプ
|
||||
* @return 変換後のメッセージ、ただしイベントでキャンセルされた場合はnullが返されるので注意
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String japanize(String message, JapanizeType type) {
|
||||
String value = (type != null) ? type.name() : "";
|
||||
com.github.ucchyocean.lc3.japanize.JapanizeType t =
|
||||
com.github.ucchyocean.lc3.japanize.JapanizeType.fromID(value,
|
||||
com.github.ucchyocean.lc3.japanize.JapanizeType.GOOGLE_IME);
|
||||
return com.github.ucchyocean.lc3.LunaChat.getAPI().japanize(message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* 該当プレイヤーのJapanize変換をオン/オフする
|
||||
* @param playerName 設定するプレイヤー名
|
||||
* @param doJapanize Japanize変換するかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setPlayersJapanize(String playerName, boolean doJapanize) {
|
||||
com.github.ucchyocean.lc3.LunaChat.getAPI().setPlayersJapanize(playerName, doJapanize);
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのJapanize設定を返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return Japanize設定
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isPlayerJapanize(String playerName) {
|
||||
return com.github.ucchyocean.lc3.LunaChat.getAPI().isPlayerJapanize(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelPlayerをChannelMemberに変換する
|
||||
* @param cp
|
||||
* @return
|
||||
*/
|
||||
private ChannelMember convertChannelPlayerToChannelMember(ChannelPlayer cp) {
|
||||
if ( cp == null ) return null;
|
||||
if ( cp instanceof ChannelPlayerName || cp instanceof ChannelPlayerUUID ) {
|
||||
return ChannelMember.getChannelMember(cp.toString());
|
||||
} else if ( cp instanceof ChannelPlayerConsole ) {
|
||||
return new ChannelMemberBukkitConsole(Bukkit.getConsoleSender());
|
||||
} else if ( cp instanceof ChannelPlayerBlock ) {
|
||||
ChannelPlayerBlock cpb = (ChannelPlayerBlock)cp;
|
||||
if ( cpb.getBlockCommandSender() != null ) {
|
||||
return new ChannelMemberBlock(cpb.getBlockCommandSender());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelMemberをChannelPlayerに変換する
|
||||
* @param cp
|
||||
* @return
|
||||
*/
|
||||
private ChannelPlayer convertChannelMemberToChannelPlayer(ChannelMember cm) {
|
||||
if ( cm == null ) return null;
|
||||
if ( cm instanceof ChannelMemberBungee ) return null; // Bungeeモードの場合は変換できない
|
||||
if ( cm instanceof ChannelMemberPlayer ) {
|
||||
return ChannelPlayer.getChannelPlayer(cm.toString());
|
||||
} else if ( cm instanceof ChannelMemberBukkitConsole ) {
|
||||
return new ChannelPlayerConsole(Bukkit.getConsoleSender());
|
||||
} else if ( cm instanceof ChannelMemberBlock ) {
|
||||
ChannelMemberBlock cmb = (ChannelMemberBlock)cm;
|
||||
if ( cmb.getBlockCommandSender() != null ) {
|
||||
return new ChannelPlayerBlock(cmb.getBlockCommandSender());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* LunaChatロガー
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatLogger {
|
||||
|
||||
private static final SimpleDateFormat lformat =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private static final SimpleDateFormat dformat =
|
||||
new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
private File file;
|
||||
private String dirPath;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name ログ名
|
||||
*/
|
||||
public LunaChatLogger(String name) {
|
||||
|
||||
this.name = name;
|
||||
checkDir();
|
||||
}
|
||||
|
||||
/**
|
||||
* ログを出力する
|
||||
* @param message ログ内容
|
||||
*/
|
||||
public synchronized void log(final String message) {
|
||||
|
||||
checkDir();
|
||||
|
||||
// 以降の処理を、発言処理の負荷軽減のため、非同期実行にする。(see issue #40.)
|
||||
Bukkit.getScheduler().runTaskAsynchronously(LunaChat.instance, new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(file, true);
|
||||
String str = lformat.format(new Date()) + "," + message;
|
||||
writer.write(str + "\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if ( writer != null ) {
|
||||
try {
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ログの出力先フォルダをチェックし、変更されるなら更新する。
|
||||
*/
|
||||
private void checkDir() {
|
||||
|
||||
String temp = LunaChat.instance.getDataFolder() + File.separator +
|
||||
"logs" + File.separator + dformat.format(new Date());
|
||||
|
||||
if ( temp.equals(dirPath) ) {
|
||||
return;
|
||||
}
|
||||
dirPath = temp;
|
||||
|
||||
File dir = new File(dirPath);
|
||||
if ( !dir.exists() || !dir.isDirectory() ) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
file = new File(dir, name + ".log");
|
||||
}
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
|
||||
/**
|
||||
* プレイヤーの行動を監視するリスナ
|
||||
* @author ucchy
|
||||
*/
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* プレイヤーのチャットごとに呼び出されるメソッド
|
||||
* @param event チャットイベント
|
||||
*/
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
|
||||
// 頭にglobalMarkerが付いている場合は、グローバル発言にする
|
||||
if ( LunaChat.config.getGlobalMarker() != null &&
|
||||
!LunaChat.config.getGlobalMarker().equals("") &&
|
||||
event.getMessage().startsWith(LunaChat.config.getGlobalMarker()) &&
|
||||
event.getMessage().length() > LunaChat.config.getGlobalMarker().length() ) {
|
||||
|
||||
int offset = LunaChat.config.getGlobalMarker().length();
|
||||
event.setMessage( event.getMessage().substring(offset) );
|
||||
chatGlobal(event);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Channel channel = LunaChat.manager.getDefaultChannel(player.getName());
|
||||
|
||||
// デフォルトの発言先が無い場合
|
||||
if ( channel == null ) {
|
||||
if ( LunaChat.config.isNoJoinAsGlobal() ) {
|
||||
// グローバル発言にする
|
||||
chatGlobal(event);
|
||||
return;
|
||||
|
||||
} else {
|
||||
// 発言をキャンセルして終了する
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// チャンネルチャット発言
|
||||
channel.chat(player, event.getMessage());
|
||||
|
||||
// もとのイベントをキャンセル
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのサーバー参加ごとに呼び出されるメソッド
|
||||
* @param event プレイヤー参加イベント
|
||||
*/
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// 強制参加チャンネル設定を確認し、参加させる
|
||||
forceJoinToForceJoinChannels(player);
|
||||
|
||||
// グローバルチャンネル設定がある場合
|
||||
if ( !LunaChat.config.getGlobalChannel().equals("") ) {
|
||||
tryJoinToGlobalChannel(player);
|
||||
}
|
||||
|
||||
// チャンネルチャット情報を表示する
|
||||
if ( LunaChat.config.isShowListOnJoin() ) {
|
||||
ArrayList<String> list = LunaChat.manager.getListForMotd(player);
|
||||
for ( String msg : list ) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのサーバー退出ごとに呼び出されるメソッド
|
||||
* @param event プレイヤー退出イベント
|
||||
*/
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// お互いがオフラインになるPMチャンネルがある場合は
|
||||
// チャンネルをクリアする
|
||||
Collection<Channel> channels = LunaChat.manager.getChannels();
|
||||
ArrayList<Channel> deleteList = new ArrayList<Channel>();
|
||||
|
||||
for ( Channel channel : channels ) {
|
||||
String cname = channel.getName();
|
||||
if ( cname.contains(">") && cname.contains(player.getName()) ) {
|
||||
boolean isAllOffline = true;
|
||||
for ( String pname : channel.getMembers() ) {
|
||||
if ( !pname.equals(player.getName()) ) {
|
||||
Player p = Bukkit.getPlayerExact(pname);
|
||||
if ( p != null && p.isOnline() ) {
|
||||
isAllOffline = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( isAllOffline ) {
|
||||
deleteList.add(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( Channel channel : deleteList ) {
|
||||
LunaChat.manager.removeChannel(channel.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* イベントをグローバルチャット発言として処理する
|
||||
* @param event 処理するイベント
|
||||
*/
|
||||
private void chatGlobal(AsyncPlayerChatEvent event) {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if ( !LunaChat.config.getGlobalChannel().equals("") ) {
|
||||
// グローバルチャンネル設定がある場合
|
||||
|
||||
// グローバルチャンネルの取得、無ければ作成
|
||||
Channel global = LunaChat.manager.getChannel(LunaChat.config.getGlobalChannel());
|
||||
if ( global == null ) {
|
||||
global = LunaChat.manager.createChannel(LunaChat.config.getGlobalChannel());
|
||||
}
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
Channel dchannel = LunaChat.manager.getDefaultChannel(player.getName());
|
||||
if ( dchannel == null ) {
|
||||
LunaChat.manager.setDefaultChannel(player.getName(), global.getName());
|
||||
}
|
||||
|
||||
// チャンネルチャット発言
|
||||
global.chat(player, event.getMessage());
|
||||
|
||||
// もとのイベントをキャンセル
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
|
||||
} else {
|
||||
// グローバルチャンネル設定が無い場合
|
||||
|
||||
String message = event.getMessage();
|
||||
// NGワード発言をマスク
|
||||
for ( String word : LunaChat.config.getNgword() ) {
|
||||
if ( message.contains(word) ) {
|
||||
message = message.replace(
|
||||
word, Utility.getAstariskString(word.length()));
|
||||
}
|
||||
}
|
||||
|
||||
// カラーコード置き換え
|
||||
message = Utility.replaceColorCode(message);
|
||||
|
||||
// 一時的にJapanizeスキップ設定かどうかを確認する
|
||||
boolean skipJapanize = false;
|
||||
String marker = LunaChat.config.getNoneJapanizeMarker();
|
||||
if ( !marker.equals("") && message.startsWith(marker) ) {
|
||||
skipJapanize = true;
|
||||
message = message.substring(marker.length());
|
||||
}
|
||||
|
||||
// 2byteコードを含むなら、Japanize変換は行わない
|
||||
if ( !skipJapanize &&
|
||||
( message.getBytes().length > message.length() ||
|
||||
message.matches("[ \\uFF61-\\uFF9F]+") ) ) {
|
||||
skipJapanize = true;
|
||||
}
|
||||
|
||||
// Japanize変換と、発言処理
|
||||
if ( !skipJapanize &&
|
||||
LunaChat.manager.isPlayerJapanize(player.getName()) &&
|
||||
LunaChat.config.getJapanizeType() != JapanizeType.NONE ) {
|
||||
|
||||
int lineType = LunaChat.config.getJapanizeDisplayLine();
|
||||
String taskFormat;
|
||||
if ( lineType == 1 ) {
|
||||
|
||||
taskFormat = LunaChat.config.getJapanizeLine1Format();
|
||||
|
||||
String japanized = LunaChat.manager.japanize(
|
||||
message, LunaChat.config.getJapanizeType());
|
||||
if ( japanized != null ) {
|
||||
String temp = taskFormat.replace("%msg", message);
|
||||
temp = temp.replace("%japanize", japanized);
|
||||
message = Utility.replaceColorCode(temp);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
taskFormat = LunaChat.config.getJapanizeLine2Format();
|
||||
|
||||
DelayedJapanizeConvertTask task = new DelayedJapanizeConvertTask(message,
|
||||
LunaChat.config.getJapanizeType(), null, player, taskFormat, null);
|
||||
|
||||
// 発言処理を必ず先に実施させるため、遅延を入れてタスクを実行する。
|
||||
int wait = LunaChat.config.getJapanizeWait();
|
||||
Bukkit.getScheduler().runTaskLater(LunaChat.instance, task, wait);
|
||||
}
|
||||
}
|
||||
|
||||
event.setMessage(message);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 既定のチャンネルへの参加を試みる。
|
||||
* @param player プレイヤー
|
||||
* @return 参加できたかどうか
|
||||
*/
|
||||
private boolean tryJoinToGlobalChannel(Player player) {
|
||||
|
||||
String gcName = LunaChat.config.getGlobalChannel();
|
||||
|
||||
// チャンネルが存在しない場合は作成する
|
||||
Channel global = LunaChat.manager.getChannel(gcName);
|
||||
if ( global == null ) {
|
||||
global = LunaChat.manager.createChannel(gcName);
|
||||
}
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
Channel dchannel = LunaChat.manager.getDefaultChannel(player.getName());
|
||||
if ( dchannel == null ) {
|
||||
LunaChat.manager.setDefaultChannel(player.getName(), gcName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 強制参加チャンネルへ参加させる
|
||||
* @param player プレイヤー
|
||||
*/
|
||||
private void forceJoinToForceJoinChannels(Player player) {
|
||||
|
||||
List<String> forceJoinChannels = LunaChat.config.getForceJoinChannels();
|
||||
String playerName = player.getName();
|
||||
|
||||
for ( String cname : forceJoinChannels ) {
|
||||
|
||||
// チャンネルが存在しない場合は作成する
|
||||
Channel channel = LunaChat.manager.getChannel(cname);
|
||||
if ( channel == null ) {
|
||||
channel = LunaChat.manager.createChannel(cname);
|
||||
}
|
||||
|
||||
// チャンネルのメンバーでないなら、参加する
|
||||
if ( !channel.getMembers().contains(playerName) ) {
|
||||
channel.addMember(playerName);
|
||||
}
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
Channel dchannel = LunaChat.manager.getDefaultChannel(playerName);
|
||||
if ( dchannel == null ) {
|
||||
LunaChat.manager.setDefaultChannel(playerName, cname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
/**
|
||||
* プラグインのリソース管理クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class Resources {
|
||||
|
||||
private static final String FILE_NAME = "messages.yml";
|
||||
|
||||
private static YamlConfiguration defaultMessages;
|
||||
private static YamlConfiguration resources;
|
||||
|
||||
/**
|
||||
* 初期化する
|
||||
*/
|
||||
protected static void initialize() {
|
||||
|
||||
File file = new File(
|
||||
LunaChat.instance.getDataFolder() +
|
||||
File.separator + FILE_NAME);
|
||||
|
||||
if ( !file.exists() ) {
|
||||
Utility.copyFileFromJar(LunaChat.getPluginJarFile(),
|
||||
file, FILE_NAME, false);
|
||||
}
|
||||
|
||||
defaultMessages = loadDefaultMessages();
|
||||
resources = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* リソースを取得する
|
||||
* @param key リソースキー
|
||||
* @return リソース
|
||||
*/
|
||||
public static String get(String key) {
|
||||
|
||||
if ( resources == null ) {
|
||||
initialize();
|
||||
}
|
||||
String def = defaultMessages.getString(key, "");
|
||||
return Utility.replaceColorCode(resources.getString(key, def));
|
||||
}
|
||||
|
||||
/**
|
||||
* Jarファイル内から直接 messages.yml を読み込み、YamlConfigurationにして返すメソッド
|
||||
* @return
|
||||
*/
|
||||
private static YamlConfiguration loadDefaultMessages() {
|
||||
|
||||
YamlConfiguration messages = new YamlConfiguration();
|
||||
JarFile jarFile = 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"));
|
||||
String line;
|
||||
while ( (line = reader.readLine()) != null ) {
|
||||
if ( line.contains(":") && !line.startsWith("#") ) {
|
||||
String key = line.substring(0, line.indexOf(":")).trim();
|
||||
String value = line.substring(line.indexOf(":") + 1).trim();
|
||||
if ( value.startsWith("'") && value.endsWith("'") )
|
||||
value = value.substring(1, value.length()-1);
|
||||
messages.set(key, value);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if ( jarFile != null ) {
|
||||
try {
|
||||
jarFile.close();
|
||||
} catch (IOException e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* ユーティリティクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class Utility {
|
||||
|
||||
/**
|
||||
* jarファイルの中に格納されているファイルを、jarファイルの外にコピーするメソッド
|
||||
* @param jarFile jarファイル
|
||||
* @param targetFile コピー先
|
||||
* @param sourceFilePath コピー元
|
||||
* @param isBinary バイナリファイルかどうか
|
||||
*/
|
||||
public static void copyFileFromJar(
|
||||
File jarFile, File targetFile, String sourceFilePath, boolean isBinary) {
|
||||
|
||||
InputStream is = null;
|
||||
FileOutputStream fos = null;
|
||||
BufferedReader reader = null;
|
||||
BufferedWriter writer = null;
|
||||
|
||||
File parent = targetFile.getParentFile();
|
||||
if ( !parent.exists() ) {
|
||||
parent.mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
JarFile jar = new JarFile(jarFile);
|
||||
ZipEntry zipEntry = jar.getEntry(sourceFilePath);
|
||||
is = jar.getInputStream(zipEntry);
|
||||
|
||||
fos = new FileOutputStream(targetFile);
|
||||
|
||||
if ( isBinary ) {
|
||||
byte[] buf = new byte[8192];
|
||||
int len;
|
||||
while ( (len = is.read(buf)) != -1 ) {
|
||||
fos.write(buf, 0, len);
|
||||
}
|
||||
|
||||
} else {
|
||||
reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
writer = new BufferedWriter(new OutputStreamWriter(fos));
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
writer.write(line);
|
||||
writer.newLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if ( writer != null ) {
|
||||
try {
|
||||
writer.flush();
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
if ( reader != null ) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
if ( fos != null ) {
|
||||
try {
|
||||
fos.flush();
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
if ( is != null ) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列内のカラーコードを置き換えする
|
||||
* @param source 置き換え元の文字列
|
||||
* @return 置き換え後の文字列
|
||||
*/
|
||||
public static String replaceColorCode(String source) {
|
||||
return source.replaceAll("&([0-9a-fk-or])", "\u00A7$1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された文字数のアスタリスクの文字列を返す
|
||||
* @param length アスタリスクの個数
|
||||
* @return 指定された文字数のアスタリスク
|
||||
*/
|
||||
public static String getAstariskString(int length) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for ( int i=0; i<length; i++ ) {
|
||||
buf.append("*");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* カラー表記の文字列を、ChatColorクラスに変換する
|
||||
* @param color カラー表記の文字列
|
||||
* @return ChatColorクラス
|
||||
*/
|
||||
public static ChatColor changeToChatColor(String color) {
|
||||
|
||||
if ( isValidColor(color) ) {
|
||||
return ChatColor.valueOf(color.toUpperCase());
|
||||
}
|
||||
return ChatColor.WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* カラー表記の文字列を、カラーコードに変換する
|
||||
* @param color カラー表記の文字列
|
||||
* @return カラーコード
|
||||
*/
|
||||
public static String changeToColorCode(String color) {
|
||||
|
||||
return "&" + changeToChatColor(color).getChar();
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatColorで指定可能な色かどうかを判断する
|
||||
* @param color カラー表記の文字列
|
||||
* @return 指定可能かどうか
|
||||
*/
|
||||
public static boolean isValidColor(String color) {
|
||||
|
||||
for ( ChatColor c : ChatColor.values() ) {
|
||||
if ( c.name().equals(color.toUpperCase()) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* カラーコードかどうかを判断する
|
||||
* @param color カラー表記の文字列
|
||||
* @return 指定可能かどうか
|
||||
*/
|
||||
public static boolean isValidColorCode(String code) {
|
||||
|
||||
if ( code == null ) {
|
||||
return false;
|
||||
}
|
||||
return code.matches("&[0-9a-f]");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,571 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBlock;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBukkitConsole;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBungee;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberPlayer;
|
||||
|
||||
/**
|
||||
* チャンネル
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class Channel {
|
||||
|
||||
private com.github.ucchyocean.lc3.channel.Channel channel;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channel 新バージョンのチャンネル
|
||||
*/
|
||||
public Channel(com.github.ucchyocean.lc3.channel.Channel channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1:1チャットかどうか
|
||||
* @return 1:1チャットかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isPersonalChat() {
|
||||
return channel.isPersonalChat();
|
||||
}
|
||||
|
||||
/**
|
||||
* ブロードキャストチャンネルかどうか
|
||||
* @return ブロードキャストチャンネルかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isBroadcastChannel() {
|
||||
return channel.isBroadcastChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
* グローバルチャンネルかどうか
|
||||
* @return グローバルチャンネルかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isGlobalChannel() {
|
||||
return channel.isGlobalChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 強制参加チャンネルかどうか
|
||||
* @return 強制参加チャンネルかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isForceJoinChannel() {
|
||||
return channel.isForceJoinChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
* このチャンネルのモデレータ権限を持っているかどうかを確認する
|
||||
* @param sender 権限を確認する対象
|
||||
* @return チャンネルのモデレータ権限を持っているかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean hasModeratorPermission(CommandSender sender) {
|
||||
return channel.hasModeratorPermission(ChannelMember.getChannelMember(sender));
|
||||
}
|
||||
|
||||
/**
|
||||
* このチャットに発言をする
|
||||
* @param player 発言をするプレイヤー
|
||||
* @param message 発言をするメッセージ
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void chat(ChannelPlayer player, String message) {
|
||||
channel.chat(ChannelMember.getChannelMember(player.getPlayer()), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* ほかの連携先などから、このチャットに発言する
|
||||
* @param player プレイヤー名
|
||||
* @param source 連携元を判別する文字列
|
||||
* @param message メッセージ
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void chatFromOtherSource(String player, String source, String message) {
|
||||
channel.chatFromOtherSource(player, source, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* メンバーを追加する
|
||||
* @param name 追加するプレイヤー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void addMember(ChannelPlayer player) {
|
||||
if ( player != null ) {
|
||||
channel.addMember(ChannelMember.getChannelMember(player.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* メンバーを削除する
|
||||
* @param name 削除するプレイヤー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeMember(ChannelPlayer player) {
|
||||
if ( player != null ) {
|
||||
channel.removeMember(ChannelMember.getChannelMember(player.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* モデレータを追加する
|
||||
* @param player 追加するプレイヤー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void addModerator(ChannelPlayer player) {
|
||||
if ( player != null ) {
|
||||
channel.addModerator(ChannelMember.getChannelMember(player.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* モデレータを削除する
|
||||
* @param player 削除するプレイヤー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void removeModerator(ChannelPlayer player) {
|
||||
if ( player != null ) {
|
||||
channel.removeModerator(ChannelMember.getChannelMember(player.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーに関連する、システムメッセージをチャンネルに流す
|
||||
* @param key リソースキー
|
||||
* @param player プレイヤー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
protected void sendSystemMessage(String key, ChannelPlayer player) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを表示します。指定したプレイヤーの発言として処理されます。
|
||||
* @param player プレイヤー(ワールドチャット、範囲チャットの場合は必須です)
|
||||
* @param message メッセージ
|
||||
* @param format フォーマット
|
||||
* @param sendDynmap dynmapへ送信するかどうか
|
||||
* @param displayName 発言者の表示名(APIに使用されます)
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void sendMessage(
|
||||
ChannelPlayer player, String message, String format, boolean sendDynmap, String displayName) {
|
||||
if ( format != null ) {
|
||||
message = format.replace("%msg", message);
|
||||
}
|
||||
if ( player != null ) {
|
||||
channel.chat(ChannelMember.getChannelMember(player.toString()), message);
|
||||
} else {
|
||||
channel.chatFromOtherSource(displayName, null, message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル情報を返す
|
||||
* @param forModerator モデレータ向けの情報を含めるかどうか
|
||||
* @return チャンネル情報
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public ArrayList<String> getInfo(boolean forModerator) {
|
||||
return new ArrayList<String>(channel.getInfo(forModerator));
|
||||
}
|
||||
|
||||
/**
|
||||
* ログファイルを読み込んで、ログデータを取得する
|
||||
* @param player プレイヤー名、フィルタしないならnullを指定すること
|
||||
* @param filter フィルタ、フィルタしないならnullを指定すること
|
||||
* @param date 日付、今日のデータを取得するならnullを指定すること
|
||||
* @param reverse 逆順取得
|
||||
* @return ログデータ
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public ArrayList<String> getLog(
|
||||
String player, String filter, String date, boolean reverse) {
|
||||
return new ArrayList<String>(channel.getLog(player, filter, date, reverse));
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのオンライン人数を返す
|
||||
* @return オンライン人数
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public int getOnlineNum() {
|
||||
return channel.getOnlineNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの総参加人数を返す
|
||||
* @return 総参加人数
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public int getTotalNum() {
|
||||
return channel.getTotalNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* 期限付きBanや期限付きMuteをチェックし、期限が切れていたら解除を行う
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void checkExpires() {
|
||||
channel.checkExpires();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの別名を返す
|
||||
* @return チャンネルの別名
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String getAlias() {
|
||||
return channel.getAlias();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの別名を設定する
|
||||
* @param alias チャンネルの別名
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setAlias(String alias) {
|
||||
channel.setAlias(alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの説明文を返す
|
||||
* @return チャンネルの説明文
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String getDescription() {
|
||||
return channel.getDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの説明文を設定する
|
||||
* @param description チャンネルの説明文
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setDescription(String description) {
|
||||
channel.setDescription(description);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのパスワードを返す
|
||||
* @return チャンネルのパスワード
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String getPassword() {
|
||||
return channel.getPassword();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのパスワードを設定する
|
||||
* @param password チャンネルのパスワード
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
channel.setPassword(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの可視性を返す
|
||||
* @return チャンネルの可視性
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isVisible() {
|
||||
return channel.isVisible();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの可視性を設定する
|
||||
* @param visible チャンネルの可視性
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setVisible(boolean visible) {
|
||||
channel.setVisible(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのメッセージフォーマットを返す
|
||||
* @return チャンネルのメッセージフォーマット
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String getFormat() {
|
||||
return channel.getFormat();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのメッセージフォーマットを設定する
|
||||
* @param format チャンネルのメッセージフォーマット
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setFormat(String format) {
|
||||
channel.setFormat(format);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのメンバーを返す
|
||||
* @return チャンネルのメンバー
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public List<ChannelPlayer> getMembers() {
|
||||
return convertMemberListToPlayerList(channel.getMembers());
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのモデレーターを返す
|
||||
* @return チャンネルのモデレーター
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public List<ChannelPlayer> getModerator() {
|
||||
return convertMemberListToPlayerList(channel.getModerator());
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのBANリストを返す
|
||||
* @return チャンネルのBANリスト
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public List<ChannelPlayer> getBanned() {
|
||||
return convertMemberListToPlayerList(channel.getBanned());
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのMuteリストを返す
|
||||
* @return チャンネルのMuteリスト
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public List<ChannelPlayer> getMuted() {
|
||||
return convertMemberListToPlayerList(channel.getMuted());
|
||||
}
|
||||
|
||||
/**
|
||||
* 期限付きBANの期限マップを返す(key=プレイヤー名、value=期日(ミリ秒))
|
||||
* @return banExpires
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Map<ChannelPlayer, Long> getBanExpires() {
|
||||
return convertMemberMapToPlayerMap(channel.getBanExpires());
|
||||
}
|
||||
|
||||
/**
|
||||
* 期限付きMuteの期限マップを返す(key=プレイヤー名、value=期日(ミリ秒))
|
||||
* @return muteExpires
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public Map<ChannelPlayer, Long> getMuteExpires() {
|
||||
return convertMemberMapToPlayerMap(channel.getMuteExpires());
|
||||
}
|
||||
|
||||
/**
|
||||
* 非表示プレイヤーの一覧を返す
|
||||
* @return チャンネルの非表示プレイヤーの一覧
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public List<ChannelPlayer> getHided() {
|
||||
return convertMemberListToPlayerList(channel.getHided());
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル名を返す
|
||||
* @return チャンネル名
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String getName() {
|
||||
return channel.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのカラーコードを返す
|
||||
* @return チャンネルのカラーコード
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String getColorCode() {
|
||||
return channel.getColorCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのカラーコードを設定する
|
||||
* @param colorCode カラーコード
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setColorCode(String colorCode) {
|
||||
channel.setColorCode(colorCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* ブロードキャストチャンネルを設定する
|
||||
* @param broadcast ブロードキャストチャンネルにするかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setBroadcast(boolean broadcast) {
|
||||
channel.setBroadcast(broadcast);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットを同ワールド内に制限するかどうかを設定する
|
||||
* @param isWorldRange 同ワールド制限するかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setWorldRange(boolean isWorldRange) {
|
||||
channel.setWorldRange(isWorldRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットの可聴範囲を設定する
|
||||
* @param range 可聴範囲
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setChatRange(int range) {
|
||||
channel.setChatRange(range);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1:1チャットのときに、会話の相手先を取得する
|
||||
* @return 会話の相手のプレイヤー名
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public String getPrivateMessageTo() {
|
||||
if ( channel.getPrivateMessageTo() != null ) return channel.getPrivateMessageTo().getName();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1:1チャットのときに、会話の相手先を設定する
|
||||
* @param name 会話の相手のプレイヤー名
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setPrivateMessageTo(String name) {
|
||||
channel.setPrivateMessageTo(ChannelMember.getChannelMember(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* ワールドチャットかどうか
|
||||
* @return ワールドチャットかどうか
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isWorldRange() {
|
||||
return channel.isWorldRange();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットの可聴範囲、0の場合は無制限
|
||||
* @return チャットの可聴範囲
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public int getChatRange() {
|
||||
return channel.getChatRange();
|
||||
}
|
||||
|
||||
/**
|
||||
* カラーコードが使用可能な設定かどうか
|
||||
* @return allowccを返す
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean isAllowCC() {
|
||||
return channel.isAllowCC();
|
||||
}
|
||||
|
||||
/**
|
||||
* カラーコードの使用可否を設定する
|
||||
* @param allowcc 使用可否
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setAllowCC(boolean allowcc) {
|
||||
channel.setAllowCC(allowcc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換設定を取得する
|
||||
* @return japanize
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public JapanizeType getJapanizeType() {
|
||||
String value = (channel.getJapanizeType() != null) ? channel.getJapanizeType().name() : "";
|
||||
return JapanizeType.fromID(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換設定を再設定する
|
||||
* @param japanize japanize
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public void setJapanizeType(JapanizeType japanize) {
|
||||
channel.setJapanizeType(com.github.ucchyocean.lc3.japanize.JapanizeType.fromID(
|
||||
japanize.name(), null));
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの情報をファイルに保存する。
|
||||
* @return 保存をしたかどうか。
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public boolean save() {
|
||||
return channel.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelMemberをChannelPlayerに変換する
|
||||
* @param cp
|
||||
* @return
|
||||
*/
|
||||
private ChannelPlayer convertChannelMemberToChannelPlayer(ChannelMember cm) {
|
||||
if ( cm == null ) return null;
|
||||
if ( cm instanceof ChannelMemberBungee ) return null; // Bungeeモードの場合は変換できない
|
||||
if ( cm instanceof ChannelMemberPlayer ) {
|
||||
return ChannelPlayer.getChannelPlayer(cm.toString());
|
||||
} else if ( cm instanceof ChannelMemberBukkitConsole ) {
|
||||
return new ChannelPlayerConsole(Bukkit.getConsoleSender());
|
||||
} else if ( cm instanceof ChannelMemberBlock ) {
|
||||
ChannelMemberBlock cmb = (ChannelMemberBlock)cm;
|
||||
if ( cmb.getBlockCommandSender() != null ) {
|
||||
return new ChannelPlayerBlock(cmb.getBlockCommandSender());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelMemberのリストをChannelPlayerのリストに変換する
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private List<ChannelPlayer> convertMemberListToPlayerList(List<ChannelMember> list) {
|
||||
List<ChannelPlayer> result = new ArrayList<ChannelPlayer>();
|
||||
for ( ChannelMember member : list ) {
|
||||
ChannelPlayer player = convertChannelMemberToChannelPlayer(member);
|
||||
if ( player != null ) result.add(player);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelMemberのマップをChannelPlayerのマップに変換する
|
||||
* @param map
|
||||
* @return
|
||||
*/
|
||||
private Map<ChannelPlayer, Long> convertMemberMapToPlayerMap(Map<ChannelMember, Long> map) {
|
||||
Map<ChannelPlayer, Long> result = new HashMap<ChannelPlayer, Long>();
|
||||
for ( ChannelMember member : map.keySet() ) {
|
||||
ChannelPlayer player = convertChannelMemberToChannelPlayer(member);
|
||||
if ( player != null ) result.put(player, map.get(member));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2014
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* プレイヤーの抽象クラス
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public abstract class ChannelPlayer implements Comparable<ChannelPlayer> {
|
||||
|
||||
/**
|
||||
* オンラインかどうか
|
||||
* @return オンラインかどうか
|
||||
*/
|
||||
public abstract boolean isOnline();
|
||||
|
||||
/**
|
||||
* プレイヤー名を返す
|
||||
* @return プレイヤー名
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* プレイヤー表示名を返す
|
||||
* @return プレイヤー表示名
|
||||
*/
|
||||
public abstract String getDisplayName();
|
||||
|
||||
/**
|
||||
* プレフィックスを返す
|
||||
* @return プレフィックス
|
||||
*/
|
||||
public abstract String getPrefix();
|
||||
|
||||
/**
|
||||
* サフィックスを返す
|
||||
* @return サフィックス
|
||||
*/
|
||||
public abstract String getSuffix();
|
||||
|
||||
/**
|
||||
* メッセージを送る
|
||||
* @param message 送るメッセージ
|
||||
*/
|
||||
public abstract void sendMessage(String message);
|
||||
|
||||
/**
|
||||
* BukkitのPlayerを取得する
|
||||
* @return Player
|
||||
*/
|
||||
public abstract Player getPlayer();
|
||||
|
||||
/**
|
||||
* 発言者が今いるワールドのワールド名を取得する
|
||||
* @return ワールド名
|
||||
*/
|
||||
public abstract String getWorldName();
|
||||
|
||||
/**
|
||||
* 発言者が今いる位置を取得する
|
||||
* @return 発言者の位置
|
||||
*/
|
||||
public abstract Location getLocation();
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードの権限を持っているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 権限を持っているかどうか
|
||||
*/
|
||||
public abstract boolean hasPermission(String node);
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードが定義されているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 定義を持っているかどうか
|
||||
*/
|
||||
public abstract boolean isPermissionSet(String node);
|
||||
|
||||
/**
|
||||
* 指定されたCommandSenderと同一かどうかを返す
|
||||
* @param sender
|
||||
* @return 同一かどうか
|
||||
*/
|
||||
public abstract boolean equals(CommandSender sender);
|
||||
|
||||
/**
|
||||
* 文字列表現を返す
|
||||
* @return 名前管理なら名前、UUID管理なら "$" + UUID を返す
|
||||
*/
|
||||
@Override
|
||||
public abstract String toString();
|
||||
|
||||
/**
|
||||
* 同一のオブジェクトかどうかを返す
|
||||
* @param other 他方のオブジェクト
|
||||
* @return 同一かどうか
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if ( !(other instanceof ChannelPlayer) ) {
|
||||
return false;
|
||||
}
|
||||
return this.toString().equals(other.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* インスタンス同士の比較を行う。このメソッドを実装しておくことで、
|
||||
* Java8でのHashMapのキー挿入における高速化が期待できる(らしい)。
|
||||
* @param other
|
||||
* @return
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(ChannelPlayer other) {
|
||||
return this.toString().compareTo(other.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 名前またはUUIDから、ChannelPlayerを作成して返す
|
||||
* @param nameOrUuid 名前、または、"$" + UUID
|
||||
* @return ChannelPlayer
|
||||
*/
|
||||
public static ChannelPlayer getChannelPlayer(String nameOrUuid) {
|
||||
if ( nameOrUuid.startsWith("$") ) {
|
||||
String id = nameOrUuid.substring(1);
|
||||
return new ChannelPlayerUUID(id);
|
||||
}
|
||||
ChannelPlayer player =
|
||||
ChannelPlayerUUID.getChannelPlayerUUIDFromName(nameOrUuid);
|
||||
if ( player != null ) {
|
||||
return player;
|
||||
}
|
||||
return new ChannelPlayerName(nameOrUuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* CommandSenderから、ChannelPlayerを作成して返す
|
||||
* @param sender
|
||||
* @return ChannelPlayer
|
||||
*/
|
||||
public static ChannelPlayer getChannelPlayer(CommandSender sender) {
|
||||
if ( sender == null ) {
|
||||
return null;
|
||||
} else if ( sender instanceof BlockCommandSender ) {
|
||||
return new ChannelPlayerBlock((BlockCommandSender)sender);
|
||||
} else if ( sender instanceof ConsoleCommandSender ) {
|
||||
return new ChannelPlayerConsole((ConsoleCommandSender)sender);
|
||||
}
|
||||
return ChannelPlayerUUID.getChannelPlayer(sender);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2014
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* コマンドブロック
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class ChannelPlayerBlock extends ChannelPlayer {
|
||||
|
||||
BlockCommandSender sender;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param sender コマンドブロック
|
||||
*/
|
||||
public ChannelPlayerBlock(BlockCommandSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインかどうか
|
||||
* @return 常にtrue
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#isOnline()
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー名を返す
|
||||
* @return プレイヤー名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー表示名を返す
|
||||
* @return プレイヤー表示名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getDisplayName()
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* プレフィックスを返す
|
||||
* @return 常に空文字列
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPrefix()
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* サフィックスを返す
|
||||
* @return 常に空文字列
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getSuffix()
|
||||
*/
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを送る、実際は何もせずにメッセージを捨てる
|
||||
* @param message
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#sendMessage(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* BukkitのPlayerを取得する
|
||||
* @return 常にnullが返される
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPlayer()
|
||||
*/
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者が今いるワールドのワールド名を取得する
|
||||
* @return 常に "-" が返される。
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getWorldName()
|
||||
*/
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return "-";
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者が今いる位置を取得する
|
||||
* @return 発言者の位置
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getLocation()
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
if ( sender != null ) {
|
||||
return sender.getBlock().getLocation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードの権限を持っているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 権限を持っているかどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#hasPermission(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPermission(String node) {
|
||||
return sender.hasPermission(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードが定義されているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 定義を持っているかどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#isPermissionSet(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermissionSet(String node) {
|
||||
return sender.isPermissionSet(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたCommandSenderと同一かどうかを返す
|
||||
* @param sender
|
||||
* @return 同一かどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#equals(org.bukkit.entity.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(CommandSender sender) {
|
||||
return this.sender.equals(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* IDを返す
|
||||
* @return 名前をそのまま返す
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getID()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public BlockCommandSender getBlockCommandSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2014
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* コンソール
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class ChannelPlayerConsole extends ChannelPlayer {
|
||||
|
||||
ConsoleCommandSender sender;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param sender コンソール
|
||||
*/
|
||||
public ChannelPlayerConsole(ConsoleCommandSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインかどうか
|
||||
* @return 常にtrue
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#isOnline()
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー名を返す
|
||||
* @return プレイヤー名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー表示名を返す
|
||||
* @return プレイヤー表示名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getDisplayName()
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* プレフィックスを返す
|
||||
* @return 常に空文字列
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPrefix()
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* サフィックスを返す
|
||||
* @return 常に空文字列
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getSuffix()
|
||||
*/
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを送る
|
||||
* @param message 送信するメッセージ
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#sendMessage(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* BukkitのPlayerを取得する
|
||||
* @return 常にnullが返される
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPlayer()
|
||||
*/
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者が今いるワールドのワールド名を取得する
|
||||
* @return 常に "-" が返される。
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getWorldName()
|
||||
*/
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return "-";
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者が今いる位置を取得する
|
||||
* @return 常にnullが返される
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getLocation()
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードの権限を持っているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 権限を持っているかどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#hasPermission(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPermission(String node) {
|
||||
return sender.hasPermission(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードが定義されているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 定義を持っているかどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#isPermissionSet(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermissionSet(String node) {
|
||||
return sender.isPermissionSet(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたCommandSenderと同一かどうかを返す
|
||||
* @param sender
|
||||
* @return 同一かどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#equals(org.bukkit.entity.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(CommandSender sender) {
|
||||
return this.sender.equals(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* IDを返す
|
||||
* @return 名前をそのまま返す
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getID()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2014
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* 名前管理のプレイヤー
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class ChannelPlayerName extends ChannelPlayer {
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name プレイヤー名
|
||||
*/
|
||||
public ChannelPlayerName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインかどうか
|
||||
* @return オンラインかどうか
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
Player player = getPlayer();
|
||||
return (player != null && player.isOnline());
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー名を返す
|
||||
* @return プレイヤー名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー表示名を返す
|
||||
* @return プレイヤー表示名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getDisplayName()
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return player.getDisplayName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレフィックスを返す
|
||||
* @return プレフィックス
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPrefix()
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* サフィックスを返す
|
||||
* @return サフィックス
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getSuffix()
|
||||
*/
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを送る
|
||||
* @param message 送るメッセージ
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#sendMessage(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* BukkitのPlayerを取得する
|
||||
* @return Player
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPlayer()
|
||||
*/
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return Bukkit.getPlayerExact(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者が今いるワールドのワールド名を取得する
|
||||
* @return ワールド名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getWorldName()
|
||||
*/
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return player.getWorld().getName();
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者が今いる位置を取得する
|
||||
* @return 発言者の位置
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getLocation()
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return player.getLocation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードの権限を持っているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 権限を持っているかどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#hasPermission(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPermission(String node) {
|
||||
Player player = getPlayer();
|
||||
if ( player == null ) {
|
||||
return false;
|
||||
} else {
|
||||
return player.hasPermission(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードが定義されているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 定義を持っているかどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#isPermissionSet(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermissionSet(String node) {
|
||||
Player player = getPlayer();
|
||||
if ( player == null ) {
|
||||
return false;
|
||||
} else {
|
||||
return player.isPermissionSet(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたCommandSenderと同一かどうかを返す
|
||||
* @param sender
|
||||
* @return 同一かどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#equals(org.bukkit.entity.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(CommandSender sender) {
|
||||
if ( sender == null || !(sender instanceof Player) ) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
return name.equals(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* IDを返す
|
||||
* @return 名前をそのまま返す
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getID()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2014
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* UUID管理のプレイヤー
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class ChannelPlayerUUID extends ChannelPlayer {
|
||||
|
||||
private UUID id;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param id プレイヤーID
|
||||
*/
|
||||
public ChannelPlayerUUID(String id) {
|
||||
this.id = UUID.fromString(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param id UUID
|
||||
*/
|
||||
public ChannelPlayerUUID(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー名からUUIDを取得してChannelPlayerUUIDを作成して返す
|
||||
* @param name プレイヤー名
|
||||
* @return ChannelPlayerUUID
|
||||
*/
|
||||
public static ChannelPlayerUUID getChannelPlayerUUIDFromName(String name) {
|
||||
Player player = Bukkit.getPlayerExact(name);
|
||||
if ( player != null ) {
|
||||
return new ChannelPlayerUUID(player.getUniqueId());
|
||||
}
|
||||
OfflinePlayer offline = Bukkit.getOfflinePlayer(name);
|
||||
if ( offline != null && offline.getUniqueId() != null ) {
|
||||
return new ChannelPlayerUUID(offline.getUniqueId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* CommandSenderから、ChannelPlayerを作成して返す
|
||||
* @param sender
|
||||
* @return ChannelPlayer
|
||||
*/
|
||||
public static ChannelPlayer getChannelPlayer(CommandSender sender) {
|
||||
if ( sender instanceof Player ) {
|
||||
return new ChannelPlayerUUID(((Player)sender).getUniqueId());
|
||||
}
|
||||
return new ChannelPlayerName(sender.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインかどうか
|
||||
* @return オンラインかどうか
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
Player player = Bukkit.getPlayer(id);
|
||||
return (player != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー名を返す
|
||||
* @return プレイヤー名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
Player player = Bukkit.getPlayer(id);
|
||||
if ( player != null ) {
|
||||
return player.getName();
|
||||
}
|
||||
OfflinePlayer offlineplayer = Bukkit.getOfflinePlayer(id);
|
||||
if ( offlineplayer != null ) {
|
||||
String name = offlineplayer.getName();
|
||||
return name;
|
||||
}
|
||||
return id.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー表示名を返す
|
||||
* @return プレイヤー表示名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getDisplayName()
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return player.getDisplayName();
|
||||
}
|
||||
return getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* プレフィックスを返す
|
||||
* @return プレフィックス
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPrefix()
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* サフィックスを返す
|
||||
* @return サフィックス
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getSuffix()
|
||||
*/
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを送る
|
||||
* @param message 送るメッセージ
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#sendMessage(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* BukkitのPlayerを取得する
|
||||
* @return Player
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPlayer()
|
||||
*/
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return Bukkit.getPlayer(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者が今いるワールドのワールド名を取得する
|
||||
* @return ワールド名
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getWorldName()
|
||||
*/
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return player.getWorld().getName();
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者が今いる位置を取得する
|
||||
* @return 発言者の位置
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getLocation()
|
||||
*/
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return player.getLocation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードの権限を持っているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 権限を持っているかどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#hasPermission(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPermission(String node) {
|
||||
Player player = getPlayer();
|
||||
if ( player == null ) {
|
||||
return false;
|
||||
} else {
|
||||
return player.hasPermission(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたパーミッションノードが定義されているかどうかを取得する
|
||||
* @param node パーミッションノード
|
||||
* @return 定義を持っているかどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#isPermissionSet(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isPermissionSet(String node) {
|
||||
Player player = getPlayer();
|
||||
if ( player == null ) {
|
||||
return false;
|
||||
} else {
|
||||
return player.isPermissionSet(node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたCommandSenderと同一かどうかを返す
|
||||
* @param sender
|
||||
* @return 同一かどうか
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#equals(org.bukkit.entity.Player)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(CommandSender sender) {
|
||||
if ( sender == null || !(sender instanceof Player) ) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
return id.equals(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* IDを返す
|
||||
* @return "$" + UUID を返す
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getID()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "$" + id.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* acceptコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class AcceptCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "accept";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageAccept";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 招待を受けていないプレイヤーなら、エラーを表示して終了する
|
||||
Player player = (Player) sender;
|
||||
if (!DataMaps.inviteMap.containsKey(player.getName())) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotInvited");
|
||||
return true;
|
||||
}
|
||||
|
||||
// チャンネルを取得して、招待記録を消去する
|
||||
String channelName = DataMaps.inviteMap.get(player.getName());
|
||||
Channel channel = api.getChannel(channelName);
|
||||
DataMaps.inviteMap.remove(player.getName());
|
||||
DataMaps.inviterMap.remove(player.getName());
|
||||
|
||||
// 取得できなかったらエラー終了する
|
||||
if (channel == null) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotfoundChannel");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 既に参加しているなら、エラーを表示して終了する
|
||||
if (channel.getMembers().contains(player.getName())) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgInvitedAlreadyJoin");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 参加する
|
||||
channel.addMember(player.getName());
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgJoin", channel.getName());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* banコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BanCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "ban";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageBan";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.MODERATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行引数から、BANするユーザーを取得する
|
||||
String kickedName = "";
|
||||
if (args.length >= 2) {
|
||||
kickedName = args[1];
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// デフォルト参加チャンネルを取得、取得できない場合はエラー表示して終了する
|
||||
Player kicker = (Player) sender;
|
||||
Channel channel = api.getDefaultChannel(kicker.getName());
|
||||
if (channel == null) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNoJoin");
|
||||
return true;
|
||||
}
|
||||
|
||||
// モデレーターかどうか確認する
|
||||
if (!channel.getModerator().contains(kicker.getName()) && !kicker.isOp()) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
|
||||
return true;
|
||||
}
|
||||
|
||||
// グローバルチャンネルならBANできない
|
||||
if ( channel.isGlobalChannel() ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCannotBANGlobal", channel.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
// BANされるプレイヤーがメンバーかどうかチェックする
|
||||
if (!channel.getMembers().contains(kickedName)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNomemberOther");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 既にBANされているかどうかチェックする
|
||||
if (channel.getBanned().contains(kickedName)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgAlreadyBanned");
|
||||
return true;
|
||||
}
|
||||
|
||||
// BAN実行
|
||||
Player kicked = Bukkit.getPlayerExact(kickedName);
|
||||
channel.getBanned().add(kickedName);
|
||||
channel.removeMember(kickedName);
|
||||
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgBan", kickedName, channel.getName());
|
||||
if (kicked != null) {
|
||||
sendResourceMessage(kicked, PREINFO,
|
||||
"cmdmsgBanned", channel.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* denyコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class DenyCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "deny";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageDeny";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 招待を受けていないプレイヤーなら、エラーを表示して終了する
|
||||
Player player = (Player) sender;
|
||||
if (!DataMaps.inviteMap.containsKey(player.getName())) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotInvited");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 招待者を取得して、招待記録を消去する
|
||||
String inviterName = DataMaps.inviterMap.get(player.getName());
|
||||
DataMaps.inviteMap.remove(player.getName());
|
||||
DataMaps.inviterMap.remove(player.getName());
|
||||
|
||||
// メッセージ送信
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgDeny");
|
||||
Player inviter = Bukkit.getPlayerExact(inviterName);
|
||||
if (inviter != null) {
|
||||
sendResourceMessage(inviter, PREINFO, "cmdmsgDenyed");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* hideコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class HideCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "hide";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageHide";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
|
||||
// 引数チェック
|
||||
String cname = null;
|
||||
if ( args.length <= 1 ) {
|
||||
Channel def = api.getDefaultChannel(player.getName());
|
||||
if ( def != null ) {
|
||||
cname = def.getName();
|
||||
}
|
||||
} else if ( args.length >= 2 ) {
|
||||
cname = args[1];
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// チャンネルが存在するかどうかをチェックする
|
||||
if ( !api.isExistChannel(cname) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotExist");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 既に非表示になっていないかどうかをチェックする
|
||||
Channel channel = api.getChannel(cname);
|
||||
if ( channel.getHided().contains(player.getName()) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgAlreadyHided");
|
||||
return true;
|
||||
}
|
||||
|
||||
// メンバーかどうかをチェックする
|
||||
if ( !channel.getMembers().contains(player.getName()) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNomember");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 設定する
|
||||
channel.getHided().add(player.getName());
|
||||
channel.save();
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgHided", channel.getName());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* inviteコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class InviteCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "invite";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageInvite";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.MODERATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
|
||||
// デフォルトの発言先を取得する
|
||||
Player inviter = (Player)sender;
|
||||
Channel channel = api.getDefaultChannel(inviter.getName());
|
||||
if ( channel == null ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNoJoin");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行引数から招待する人を取得する
|
||||
String invitedName = "";
|
||||
if (args.length >= 2) {
|
||||
invitedName = args[1];
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// モデレーターかどうか確認する
|
||||
if ( !channel.getModerator().contains(inviter.getName()) && !inviter.isOp()) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 招待相手が存在するかどうかを確認する
|
||||
Player invited = Bukkit.getPlayerExact(invitedName);
|
||||
if (invited == null) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgNotfoundPlayer", invitedName);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 招待相手が既にチャンネルに参加しているかどうかを確認する
|
||||
if (channel.getMembers().contains(invitedName)) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgInvitedAlreadyExist", invitedName);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 招待を送信する
|
||||
DataMaps.inviteMap.put(invitedName, channel.getName());
|
||||
DataMaps.inviterMap.put(invitedName, inviter.getName());
|
||||
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgInvite", invitedName, channel.getName());
|
||||
sendResourceMessage(invited, PREINFO,
|
||||
"cmdmsgInvited1", inviter.getName(), channel.getName());
|
||||
sendResourceMessage(invited, PREINFO, "cmdmsgInvited2");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,215 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* joinコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
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 USAGE_KEY = "usageJoin";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
// 実行引数から、参加するチャンネルを取得する
|
||||
String channelName = "";
|
||||
StringBuilder message = new StringBuilder();
|
||||
if (!args[0].equalsIgnoreCase("join")) {
|
||||
channelName = args[0];
|
||||
if (args.length >= 2) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
message.append(args[i] + " ");
|
||||
}
|
||||
}
|
||||
} else if (args.length >= 2) {
|
||||
channelName = args[1];
|
||||
if (args.length >= 3) {
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
message.append(args[i] + " ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// チャンネルが存在するかどうかをチェックする
|
||||
if ( !api.isExistChannel(channelName) ) {
|
||||
if (config.getGlobalChannel().equals("") &&
|
||||
channelName.equals(config.getGlobalMarker()) ) {
|
||||
// グローバルチャンネル設定が無くて、指定チャンネルがマーカーの場合、
|
||||
// 発言先をnullに設定して、グローバルチャンネルにする
|
||||
|
||||
api.removeDefaultChannel(player.getName());
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgSet", "グローバル");
|
||||
if (message.length() > 0) {
|
||||
player.chat(config.getGlobalMarker() + message.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (config.isCreateChannelOnJoinCommand()) {
|
||||
// 存在しないチャットには、チャンネルを作って入る設定の場合
|
||||
|
||||
// 使用可能なチャンネル名かどうかをチェックする
|
||||
if ( !api.checkForChannelName(channelName) ) {
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"errmsgCannotUseForChannel", channelName);
|
||||
return true;
|
||||
}
|
||||
|
||||
// チャンネル作成
|
||||
Channel c = api.createChannel(channelName);
|
||||
if ( c != null ) {
|
||||
c.addMember(player.getName());
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgCreate", channelName);
|
||||
}
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// 存在しないチャットには入れない設定の場合
|
||||
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotExist");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// チャンネルを取得する
|
||||
Channel channel = api.getChannel(channelName);
|
||||
|
||||
// BANされていないか確認する
|
||||
if (channel.getBanned().contains(player.getName())) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgBanned");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 個人チャットの場合はエラーにする
|
||||
if (channel.isPersonalChat()) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCannotJoinPersonal");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (channel.getMembers().contains(player.getName())) {
|
||||
|
||||
// 何かメッセージがあるなら、そのままチャット送信する
|
||||
if (message.length() > 0) {
|
||||
channel.chat(player, message.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
// デフォルトの発言先に設定する
|
||||
api.setDefaultChannel(player.getName(), channelName);
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgSet", channelName);
|
||||
|
||||
} else {
|
||||
|
||||
// グローバルチャンネルで、何かメッセージがあるなら、そのままチャット送信する
|
||||
if (channel.getName().equals(config.getGlobalChannel()) &&
|
||||
message.length() > 0) {
|
||||
channel.chat(player, message.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
// パスワードが設定されている場合は、パスワードを確認する
|
||||
if ( !channel.getPassword().equals("") ) {
|
||||
if ( message.toString().trim().equals("") ) {
|
||||
// パスワード空欄
|
||||
sendResourceMessage(sender, PREERR, "errmsgPassword1");
|
||||
sendResourceMessage(sender, PREERR, "errmsgPassword2");
|
||||
sendResourceMessage(sender, PREERR, "errmsgPassword3");
|
||||
return true;
|
||||
} else if ( !channel.getPassword().equals(message.toString().trim()) ) {
|
||||
// パスワード不一致
|
||||
sendResourceMessage(sender, PREERR, "errmsgPasswordNotmatch");
|
||||
sendResourceMessage(sender, PREERR, "errmsgPassword2");
|
||||
sendResourceMessage(sender, PREERR, "errmsgPassword3");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// チャンネルに参加し、デフォルトの発言先に設定する
|
||||
if ( !channel.getName().equals(config.getGlobalChannel()) ) {
|
||||
channel.addMember(player.getName());
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgJoin", channelName);
|
||||
}
|
||||
api.setDefaultChannel(player.getName(), channelName);
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgSet", channelName);
|
||||
}
|
||||
|
||||
// 非表示に設定しているなら、注意を流す
|
||||
if ( channel.getHided().contains(player.getName()) ) {
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgSetHide");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* kickコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class KickCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "kick";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageKick";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.MODERATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行引数から、キックするユーザーを取得する
|
||||
String kickedName = "";
|
||||
if (args.length >= 2) {
|
||||
kickedName = args[1];
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// デフォルト参加チャンネルを取得、取得できない場合はエラー表示して終了する
|
||||
Player kicker = (Player) sender;
|
||||
Channel channel = api.getDefaultChannel(kicker.getName());
|
||||
if (channel == null) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNoJoin");
|
||||
return true;
|
||||
}
|
||||
|
||||
// モデレーターかどうか確認する
|
||||
if (!channel.getModerator().contains(kicker.getName()) && !kicker.isOp()) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
|
||||
return true;
|
||||
}
|
||||
|
||||
// グローバルチャンネルならキックできない
|
||||
if ( channel.isGlobalChannel() ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCannotKickGlobal", channel.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
// キックされるプレイヤーがメンバーかどうかチェックする
|
||||
if (!channel.getMembers().contains(kickedName)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNomemberOther");
|
||||
return true;
|
||||
}
|
||||
|
||||
// キック実行
|
||||
channel.removeMember(kickedName);
|
||||
channel.save();
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgKick", kickedName, channel.getName());
|
||||
|
||||
Player kicked = Bukkit.getPlayerExact(kickedName);
|
||||
if (kicked != null) {
|
||||
sendResourceMessage(kicked, PREINFO,
|
||||
"cmdmsgKicked", channel.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
|
||||
/**
|
||||
* listコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ListCommand extends SubCommandAbst {
|
||||
|
||||
private static final String LIST_FIRSTLINE = Resources.get("listFirstLine");
|
||||
private static final String LIST_ENDLINE = Resources.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Resources.get("listFormat");
|
||||
|
||||
private static final String COMMAND_NAME = "list";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageList";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
// リストを取得して表示する
|
||||
ArrayList<String> list = getList(player);
|
||||
for (String msg : list) {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* リスト表示用のリストを返す
|
||||
* @param player プレイヤー、指定しない場合はnullにする
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getList(Player player) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
String dchannel = "";
|
||||
String playerName = "";
|
||||
if ( player != null ) {
|
||||
playerName = player.getName();
|
||||
Channel def = api.getDefaultChannel(playerName);
|
||||
if ( def == null ) {
|
||||
dchannel = "";
|
||||
} else {
|
||||
dchannel = def.getName();
|
||||
}
|
||||
}
|
||||
Collection<Channel> channels = api.getChannels();
|
||||
|
||||
items.add(LIST_FIRSTLINE);
|
||||
for ( Channel channel : channels ) {
|
||||
|
||||
// BANされているチャンネルは表示しない
|
||||
if ( channel.getBanned().contains(playerName) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットはリストに表示しない
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// デフォルト発言先なら赤に、非表示中なら暗青にする。
|
||||
String disp = ChatColor.WHITE + channel.getName();
|
||||
if ( channel.getName().equalsIgnoreCase(dchannel) ) {
|
||||
disp = ChatColor.RED + channel.getName();
|
||||
} else if ( channel.getHided().contains(playerName) ) {
|
||||
disp = ChatColor.DARK_AQUA + channel.getName();
|
||||
}
|
||||
|
||||
if ( player != null &&
|
||||
!channel.getMembers().contains(playerName) &&
|
||||
!channel.isGlobalChannel() ) {
|
||||
|
||||
// 未参加で visible=false のチャンネルは表示しない
|
||||
if ( !channel.isVisible() ) {
|
||||
continue;
|
||||
}
|
||||
disp = ChatColor.GRAY + channel.getName();
|
||||
}
|
||||
String desc = channel.getDescription();
|
||||
int onlineNum = channel.getOnlineNum();
|
||||
int memberNum = channel.getTotalNum();
|
||||
String item = String.format(
|
||||
LIST_FORMAT, disp, onlineNum, memberNum, desc);
|
||||
items.add(item);
|
||||
}
|
||||
items.add(LIST_ENDLINE);
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
|
||||
/**
|
||||
* Lunachatコマンドの処理クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatCommand implements CommandExecutor {
|
||||
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
|
||||
private ArrayList<SubCommandAbst> commands;
|
||||
private JoinCommand joinCommand;
|
||||
private HelpCommand helpCommand;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*/
|
||||
public LunaChatCommand() {
|
||||
|
||||
commands = new ArrayList<SubCommandAbst>();
|
||||
joinCommand = new JoinCommand();
|
||||
commands.add(joinCommand);
|
||||
commands.add(new LeaveCommand());
|
||||
commands.add(new ListCommand());
|
||||
commands.add(new InviteCommand());
|
||||
commands.add(new AcceptCommand());
|
||||
commands.add(new DenyCommand());
|
||||
commands.add(new KickCommand());
|
||||
commands.add(new BanCommand());
|
||||
commands.add(new PardonCommand());
|
||||
commands.add(new MuteCommand());
|
||||
commands.add(new UnmuteCommand());
|
||||
commands.add(new HideCommand());
|
||||
commands.add(new UnhideCommand());
|
||||
commands.add(new InfoCommand());
|
||||
commands.add(new CreateCommand());
|
||||
commands.add(new RemoveCommand());
|
||||
commands.add(new FormatCommand());
|
||||
commands.add(new ModeratorCommand());
|
||||
commands.add(new ModCommand());
|
||||
commands.add(new OptionCommand());
|
||||
commands.add(new TemplateCommand());
|
||||
commands.add(new ReloadCommand());
|
||||
helpCommand = new HelpCommand(commands);
|
||||
commands.add(helpCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command,
|
||||
String label, String[] args) {
|
||||
|
||||
// チャンネルチャット機能が無効になっている場合は、メッセージを表示して終了
|
||||
if ( !LunaChat.instance.getLunaChatConfig().isEnableChannelChat()
|
||||
&& !sender.isOp() ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgChannelChatDisabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 引数なしは、ヘルプを表示
|
||||
if (args.length == 0) {
|
||||
helpCommand.runCommand(sender, label, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 第1引数に指定されたコマンドを実行する
|
||||
for ( SubCommandAbst c : commands ) {
|
||||
if ( c.getCommandName().equalsIgnoreCase(args[0]) ) {
|
||||
|
||||
// パーミッションの確認
|
||||
String node = c.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行
|
||||
return c.runCommand(sender, label, args);
|
||||
}
|
||||
}
|
||||
|
||||
// 第1引数がコマンドでないなら、joinが指定されたとみなす
|
||||
String node = joinCommand.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return true;
|
||||
}
|
||||
|
||||
return joinCommand.runCommand(sender, label, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
*
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
private void sendResourceMessage(CommandSender sender, String pre,
|
||||
String key, Object... args) {
|
||||
String msg = String.format(pre + Resources.get(key), args);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
|
||||
/**
|
||||
* Japanize変換設定コマンド
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatJapanizeCommand implements CommandExecutor {
|
||||
|
||||
private static final String PERM_JAPANIZE_OTHER = "lunachat-admin.japanize-other";
|
||||
|
||||
private static final String PREINFO = Resources.get("infoPrefix");
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command,
|
||||
String label, String[] args) {
|
||||
|
||||
if ( args.length == 1 &&
|
||||
(args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off")) ) {
|
||||
// japanize on/off の実行
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
|
||||
// Japanize設定をon/offにする
|
||||
boolean value = args[0].equalsIgnoreCase("on");
|
||||
LunaChatAPI api = LunaChat.instance.getLunaChatAPI();
|
||||
api.setPlayersJapanize(player.getName(), value);
|
||||
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgPlayerJapanize", args[0]);
|
||||
return true;
|
||||
|
||||
} else if ( args.length == 2 &&
|
||||
(args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("off")) ) {
|
||||
// japanize (player) on/off の実行
|
||||
|
||||
// 権限チェック
|
||||
if ( !sender.hasPermission(PERM_JAPANIZE_OTHER) ) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgNotPermission", PERM_JAPANIZE_OTHER);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 指定されたプレイヤーが存在するかチェック
|
||||
Player target = Bukkit.getPlayerExact(args[0]);
|
||||
if ( target == null ) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgNotfoundPlayer", args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Japanize設定をon/offにする
|
||||
boolean value = args[1].equalsIgnoreCase("on");
|
||||
LunaChatAPI api = LunaChat.instance.getLunaChatAPI();
|
||||
api.setPlayersJapanize(target.getName(), value);
|
||||
|
||||
sendResourceMessage(target, PREINFO,
|
||||
"cmdmsgPlayerJapanize", args[1]);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgPlayerJapanizeOther", args[0], args[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
// usageを表示して終了する
|
||||
printUsage(sender, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの使い方を senderに送る
|
||||
*
|
||||
* @param sender
|
||||
* @param label
|
||||
*/
|
||||
private void printUsage(CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", "usageJapanize", label);
|
||||
if ( sender.hasPermission(PERM_JAPANIZE_OTHER) ) {
|
||||
sendResourceMessage(sender, "", "usageJapanizeOther", label);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
*
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
protected void sendResourceMessage(CommandSender sender, String pre,
|
||||
String key, Object... args) {
|
||||
String msg = String.format(pre + Resources.get(key), args);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
|
||||
/**
|
||||
* 1:1チャット送信コマンド
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatMessageCommand implements CommandExecutor {
|
||||
|
||||
// private static final String PREINFO = Resources.get("infoPrefix");
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command,
|
||||
String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
Player inviter = (Player)sender;
|
||||
|
||||
// 引数が無ければ、usageを表示して終了する
|
||||
if (args.length == 0) {
|
||||
printUsage(sender, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行引数から1:1チャットの相手を取得する
|
||||
String invitedName = "";
|
||||
StringBuilder message = new StringBuilder();
|
||||
if (args.length >= 1) {
|
||||
invitedName = args[0];
|
||||
if ( args.length >= 2 ) {
|
||||
for ( int i=1; i<args.length; i++ ) {
|
||||
message.append(args[i] + " ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
printUsage(sender, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
sendTellMessage(inviter, invitedName, message.toString().trim());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tellコマンドの実行処理を行う
|
||||
* @param inviter
|
||||
* @param invitedName
|
||||
* @param message
|
||||
*/
|
||||
protected void sendTellMessage(Player inviter, String invitedName, String message) {
|
||||
|
||||
// 招待相手が自分自身でないか確認する
|
||||
if (inviter.getName().equals(invitedName)) {
|
||||
sendResourceMessage(inviter, PREERR,
|
||||
"errmsgCannotSendPMSelf");
|
||||
return;
|
||||
}
|
||||
|
||||
// 招待相手が存在するかどうかを確認する
|
||||
Player invited = Bukkit.getPlayerExact(invitedName);
|
||||
if (invited == null) {
|
||||
sendResourceMessage(inviter, PREERR,
|
||||
"errmsgNotfoundPlayer", invitedName);
|
||||
return;
|
||||
}
|
||||
|
||||
// チャンネルが存在するかどうかをチェックする
|
||||
LunaChatAPI api = LunaChat.instance.getLunaChatAPI();
|
||||
String cname = inviter.getName() + ">" + invitedName;
|
||||
Channel channel = api.getChannel(cname);
|
||||
if ( channel == null ) {
|
||||
// チャンネルを作成して、送信者、受信者をメンバーにする
|
||||
channel = api.createChannel(cname);
|
||||
channel.setVisible(false);
|
||||
channel.addMember(inviter.getName());
|
||||
channel.addMember(invitedName);
|
||||
}
|
||||
|
||||
// メッセージがあるなら送信する
|
||||
if ( message.trim().length() > 0 ) {
|
||||
channel.chat(inviter, message);
|
||||
}
|
||||
|
||||
// 送信履歴を残す
|
||||
DataMaps.privateMessageMap.put(invitedName, inviter.getName());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの使い方を senderに送る
|
||||
*
|
||||
* @param sender
|
||||
* @param label
|
||||
*/
|
||||
private void printUsage(CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", "usageMessage", label);
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
*
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
protected void sendResourceMessage(CommandSender sender, String pre,
|
||||
String key, Object... args) {
|
||||
String msg = String.format(pre + Resources.get(key), args);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
|
||||
/**
|
||||
* 1:1チャット受信コマンド
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatReplyCommand extends LunaChatMessageCommand {
|
||||
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command,
|
||||
String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
Player inviter = (Player)sender;
|
||||
|
||||
// 引数が無ければ、usageを表示して終了する
|
||||
if (args.length == 0) {
|
||||
printUsage(sender, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
// メッセージを取得する
|
||||
StringBuilder message = new StringBuilder();
|
||||
for ( int i=0; i<args.length; i++ ) {
|
||||
message.append(args[i] + " ");
|
||||
}
|
||||
|
||||
// 招待した人を履歴から取得する
|
||||
String invitedName = DataMaps.privateMessageMap.get(inviter.getName());
|
||||
if ( invitedName == null ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotfoundPM");
|
||||
return true;
|
||||
}
|
||||
|
||||
sendTellMessage(inviter, invitedName, message.toString().trim());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの使い方を senderに送る
|
||||
*
|
||||
* @param sender
|
||||
* @param label
|
||||
*/
|
||||
private void printUsage(CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", "usageReply", label);
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* muteコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class MuteCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "mute";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageMute";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.MODERATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行引数から、Muteするユーザーを取得する
|
||||
String kickedName = "";
|
||||
if (args.length >= 2) {
|
||||
kickedName = args[1];
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// デフォルト参加チャンネルを取得、取得できない場合はエラー表示して終了する
|
||||
Player kicker = (Player) sender;
|
||||
Channel channel = api.getDefaultChannel(kicker.getName());
|
||||
if (channel == null) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNoJoin");
|
||||
return true;
|
||||
}
|
||||
|
||||
// モデレーターかどうか確認する
|
||||
if (!channel.getModerator().contains(kicker.getName()) && !kicker.isOp()) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Muteされるプレイヤーがメンバーかどうかチェックする
|
||||
if (!channel.getMembers().contains(kickedName)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNomemberOther");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 既にMuteされているかどうかチェックする
|
||||
if (channel.getMuted().contains(kickedName)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgAlreadyMuted");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Mute実行
|
||||
Player kicked = Bukkit.getPlayerExact(kickedName);
|
||||
channel.getMuted().add(kickedName);
|
||||
channel.save();
|
||||
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgMute", kickedName, channel.getName());
|
||||
if (kicked != null) {
|
||||
sendResourceMessage(kicked, PREINFO,
|
||||
"cmdmsgMuted", channel.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelOptionChangedEvent;
|
||||
|
||||
/**
|
||||
* optionコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class OptionCommand extends SubCommandAbst {
|
||||
|
||||
private static final int MAX_LENGTH_DESCRIPTION = 30;
|
||||
private static final int MAX_LENGTH_PASSWORD = 15;
|
||||
|
||||
private static final String COMMAND_NAME = "option";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageOption";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.MODERATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
// 引数チェック
|
||||
// このコマンドは、コンソールでも実行できるが、その場合はチャンネル名を指定する必要がある
|
||||
ArrayList<String> optionsTemp = new ArrayList<String>();
|
||||
String cname = null;
|
||||
if ( player != null && args.length >= 2 ) {
|
||||
Channel def = api.getDefaultChannel(player.getName());
|
||||
if ( def != null ) {
|
||||
cname = def.getName();
|
||||
}
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
optionsTemp.add(args[i]);
|
||||
}
|
||||
} else if ( args.length >= 3 ) {
|
||||
cname = args[1];
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
optionsTemp.add(args[i]);
|
||||
}
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// チャンネルが存在するかどうかをチェックする
|
||||
if ( !api.isExistChannel(cname) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotExist");
|
||||
return true;
|
||||
}
|
||||
|
||||
// モデレーターかどうか確認する
|
||||
Channel channel = api.getChannel(cname);
|
||||
if ( player != null ) {
|
||||
if ( !channel.getModerator().contains(player.getName()) && !player.isOp()) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 指定内容を解析する
|
||||
HashMap<String, String> options = new HashMap<String, String>();
|
||||
for ( String t : optionsTemp ) {
|
||||
int index = t.indexOf("=");
|
||||
if ( index == -1 ) {
|
||||
continue;
|
||||
}
|
||||
options.put(t.substring(0, index), t.substring(index + 1));
|
||||
}
|
||||
|
||||
// イベントコール
|
||||
LunaChatChannelOptionChangedEvent event =
|
||||
new LunaChatChannelOptionChangedEvent(cname, options);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if ( event.isCancelled() ) {
|
||||
return true;
|
||||
}
|
||||
options = event.getOptions();
|
||||
|
||||
// 設定する
|
||||
boolean setOption = false;
|
||||
|
||||
if ( options.containsKey("description") ) {
|
||||
// チャンネル説明文
|
||||
String desc = options.get("description");
|
||||
// チャンネル説明文は最大文字長を超えていないか確認
|
||||
if ( desc.length() > MAX_LENGTH_DESCRIPTION ) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgToolongDescription", MAX_LENGTH_DESCRIPTION);
|
||||
} else {
|
||||
channel.setDescription(desc);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "description", desc);
|
||||
setOption = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( options.containsKey("color") ) {
|
||||
// チャンネルカラー
|
||||
String code = options.get("color");
|
||||
if ( Utility.isValidColor(code) ) {
|
||||
code = Utility.changeToColorCode(code);
|
||||
}
|
||||
if ( Utility.isValidColorCode(code) ) {
|
||||
channel.setColorCode(code);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "color", options.get("color"));
|
||||
setOption = true;
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgInvalidColorCode", options.get("color"));
|
||||
}
|
||||
}
|
||||
|
||||
if ( options.containsKey("broadcast") ) {
|
||||
// ブロードキャストチャンネル
|
||||
String value = options.get("broadcast");
|
||||
|
||||
if ( value.equals("") || value.equalsIgnoreCase("false") ) {
|
||||
if ( channel.isGlobalChannel() ) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgCannotOffGlobalBroadcast");
|
||||
} else {
|
||||
channel.setBroadcast(false);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "broadcast", "false");
|
||||
setOption = true;
|
||||
}
|
||||
} else if ( value.equalsIgnoreCase("true") ) {
|
||||
channel.setBroadcast(true);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "broadcast", "true");
|
||||
setOption = true;
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgInvalidBooleanOption", "broadcast");
|
||||
}
|
||||
}
|
||||
|
||||
if ( options.containsKey("range") ) {
|
||||
// レンジ
|
||||
String value = options.get("range");
|
||||
|
||||
if ( value.equals("") ) {
|
||||
channel.setWorldRange(false);
|
||||
channel.setRange(0);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "range", "無効");
|
||||
setOption = true;
|
||||
} else if ( value.equalsIgnoreCase("world") ) {
|
||||
channel.setWorldRange(true);
|
||||
channel.setRange(0);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "range", "world");
|
||||
setOption = true;
|
||||
} else if ( value.matches("[0-9]+") ) {
|
||||
channel.setWorldRange(true);
|
||||
channel.setRange(Integer.parseInt(value));
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "range", value);
|
||||
setOption = true;
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgInvalidRangeOption");
|
||||
}
|
||||
}
|
||||
|
||||
if ( !channel.isGlobalChannel() ) {
|
||||
|
||||
if ( options.containsKey("password") ) {
|
||||
// パスワード
|
||||
String password = options.get("password");
|
||||
// パスワードが文字制限を超える場合はエラー
|
||||
if ( password.length() > MAX_LENGTH_PASSWORD ) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgToolongPassword", MAX_LENGTH_PASSWORD);
|
||||
} else {
|
||||
channel.setPassword(password);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "password", password);
|
||||
setOption = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( options.containsKey("visible") ) {
|
||||
// ビジブル
|
||||
String temp = options.get("visible");
|
||||
if ( temp.equalsIgnoreCase("false") ) {
|
||||
channel.setVisible(false);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "visible", "false");
|
||||
setOption = true;
|
||||
} else if ( temp.equalsIgnoreCase("true") ) {
|
||||
channel.setVisible(true);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "visible", "true");
|
||||
setOption = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !setOption ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgInvalidOptions");
|
||||
} else {
|
||||
channel.save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* pardonコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class PardonCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "pardon";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usagePardon";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.MODERATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行引数から、BAN解除するユーザーを取得する
|
||||
String kickedName = "";
|
||||
if (args.length >= 2) {
|
||||
kickedName = args[1];
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// デフォルト参加チャンネルを取得、取得できない場合はエラー表示して終了する
|
||||
Player kicker = (Player) sender;
|
||||
Channel channel = api.getDefaultChannel(kicker.getName());
|
||||
if (channel == null) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNoJoin");
|
||||
return true;
|
||||
}
|
||||
|
||||
// モデレーターかどうか確認する
|
||||
if (!channel.getModerator().contains(kicker.getName()) && !kicker.isOp()) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
|
||||
return true;
|
||||
}
|
||||
|
||||
// BAN解除されるプレイヤーがBANされているかどうかチェックする
|
||||
if (!channel.getBanned().contains(kickedName)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotBanned");
|
||||
return true;
|
||||
}
|
||||
|
||||
// BAN解除実行
|
||||
Player kicked = Bukkit.getPlayerExact(kickedName);
|
||||
channel.getBanned().remove(kickedName);
|
||||
channel.save();
|
||||
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgPardon", kickedName, channel.getName());
|
||||
if (kicked != null) {
|
||||
sendResourceMessage(kicked, PREINFO,
|
||||
"cmdmsgPardoned", channel.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
|
||||
/**
|
||||
* サブコマンドの抽象クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public abstract class SubCommandAbst {
|
||||
|
||||
/**
|
||||
* コマンドの種別
|
||||
* @author ucchy
|
||||
*/
|
||||
protected enum CommandType {
|
||||
|
||||
/** 一般ユーザー向けコマンド */
|
||||
USER,
|
||||
|
||||
/** チャンネルモデレーター向けコマンド */
|
||||
MODERATOR,
|
||||
|
||||
/** サーバー管理者向けコマンド */
|
||||
ADMIN
|
||||
}
|
||||
|
||||
protected static final String PREINFO = Resources.get("infoPrefix");
|
||||
protected static final String PREERR = Resources.get("errorPrefix");
|
||||
|
||||
protected LunaChatAPI api;
|
||||
protected LunaChatConfig config;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*/
|
||||
public SubCommandAbst() {
|
||||
api = LunaChat.instance.getLunaChatAPI();
|
||||
config = LunaChat.instance.getLunaChatConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
*
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
protected void sendResourceMessage(
|
||||
CommandSender sender, String pre,
|
||||
String key, Object... args) {
|
||||
String msg = String.format(pre + Resources.get(key), args);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
*/
|
||||
public abstract String getCommandName();
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
*/
|
||||
public abstract String getPermissionNode();
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
*/
|
||||
public abstract CommandType getCommandType();
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
*/
|
||||
public abstract void sendUsageMessage(
|
||||
CommandSender sender, String label);
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
*/
|
||||
public abstract boolean runCommand(
|
||||
CommandSender sender, String label, String[] args);
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* unhideコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class UnhideCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "unhide";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageUnhide";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
|
||||
// 引数チェック
|
||||
String cname = null;
|
||||
if ( args.length <= 1 ) {
|
||||
Channel def = api.getDefaultChannel(player.getName());
|
||||
if ( def != null ) {
|
||||
cname = def.getName();
|
||||
}
|
||||
} else if ( args.length >= 2 ) {
|
||||
cname = args[1];
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// チャンネルが存在するかどうかをチェックする
|
||||
if ( !api.isExistChannel(cname) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotExist");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 非表示になっているかどうかをチェックする
|
||||
Channel channel = api.getChannel(cname);
|
||||
if ( !channel.getHided().contains(player.getName()) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgAlreadyUnhided");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 設定する
|
||||
channel.getHided().remove(player.getName());
|
||||
channel.save();
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgUnhided", channel.getName());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
|
||||
/**
|
||||
* unmuteコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class UnmuteCommand extends SubCommandAbst {
|
||||
|
||||
private static final String COMMAND_NAME = "unmute";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY = "usageUnmute";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @return コマンド
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandName()
|
||||
*/
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return COMMAND_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* パーミッションノードを取得します。
|
||||
* @return パーミッションノード
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getPermissionNode()
|
||||
*/
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return PERMISSION_NODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドの種別を取得します。
|
||||
* @return コマンド種別
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#getCommandType()
|
||||
*/
|
||||
@Override
|
||||
public CommandType getCommandType() {
|
||||
return CommandType.MODERATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY, label);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @param args 実行時の引数
|
||||
* @return コマンドが実行されたかどうか
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#runCommand(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean runCommand(
|
||||
CommandSender sender, String label, String[] args) {
|
||||
|
||||
// プレイヤーでなければ終了する
|
||||
if (!(sender instanceof Player)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgIngame");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行引数から、Mute解除するユーザーを取得する
|
||||
String kickedName = "";
|
||||
if (args.length >= 2) {
|
||||
kickedName = args[1];
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCommand");
|
||||
return true;
|
||||
}
|
||||
|
||||
// デフォルト参加チャンネルを取得、取得できない場合はエラー表示して終了する
|
||||
Player kicker = (Player) sender;
|
||||
Channel channel = api.getDefaultChannel(kicker.getName());
|
||||
if (channel == null) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNoJoin");
|
||||
return true;
|
||||
}
|
||||
|
||||
// モデレーターかどうか確認する
|
||||
if (!channel.getModerator().contains(kicker.getName()) && !kicker.isOp()) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotModerator");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Mute解除されるプレイヤーがMuteされているかどうかチェックする
|
||||
if (!channel.getMuted().contains(kickedName)) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotMuted");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Mute解除実行
|
||||
Player kicked = Bukkit.getPlayerExact(kickedName);
|
||||
channel.getMuted().remove(kickedName);
|
||||
channel.save();
|
||||
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgUnmute", kickedName, channel.getName());
|
||||
if (kicked != null) {
|
||||
sendResourceMessage(kicked, PREINFO,
|
||||
"cmdmsgUnmuted", channel.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import org.bukkit.event.Cancellable;
|
||||
/**
|
||||
* 基底のキャンセル可能イベントクラス
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatBaseCancellableEvent extends LunaChatBaseEvent implements Cancellable {
|
||||
|
||||
|
||||
@@ -5,12 +5,17 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc.event;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
|
||||
/**
|
||||
* 基底イベントクラス
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public abstract class LunaChatBaseEvent extends Event {
|
||||
|
||||
@@ -22,6 +27,7 @@ public abstract class LunaChatBaseEvent extends Event {
|
||||
* @param channelName チャンネル名
|
||||
*/
|
||||
public LunaChatBaseEvent(String channelName) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
@@ -35,9 +41,18 @@ public abstract class LunaChatBaseEvent extends Event {
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル名を取得する
|
||||
* @return チャンネル名
|
||||
*/
|
||||
public String getChannelName() {
|
||||
return channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを取得する
|
||||
* @return チャンネル
|
||||
*/
|
||||
public Channel getChannel() {
|
||||
return LunaChat.getInstance().getLunaChatAPI().getChannel(channelName);
|
||||
}
|
||||
}
|
||||
@@ -5,25 +5,38 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc.event;
|
||||
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* チャンネルチャットのチャットイベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelChatEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
private ChannelPlayer player;
|
||||
private String originalMessage;
|
||||
private String ngMaskedMessage;
|
||||
private String messageFormat;
|
||||
|
||||
public LunaChatChannelChatEvent(String channelName,
|
||||
public LunaChatChannelChatEvent(String channelName, ChannelPlayer player,
|
||||
String originalMessage, String ngMaskedMessage,
|
||||
String messageFormat) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.originalMessage = originalMessage;
|
||||
this.ngMaskedMessage = ngMaskedMessage;
|
||||
this.messageFormat = messageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置き換え前の、発言されたままのテキストをかえす
|
||||
* @return 発言内容
|
||||
@@ -47,7 +60,7 @@ public class LunaChatChannelChatEvent extends LunaChatBaseCancellableEvent {
|
||||
public String getMessageFormat() {
|
||||
return messageFormat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* NGワードマスク後のテキストを上書き設定する
|
||||
* @param ngMaskedMessage 上書きする発言内容
|
||||
|
||||
@@ -5,21 +5,47 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc.event;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
|
||||
/**
|
||||
* チャンネル作成イベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelCreateEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
public LunaChatChannelCreateEvent(String channelName) {
|
||||
private CommandSender sender;
|
||||
|
||||
public LunaChatChannelCreateEvent(String channelName, CommandSender sender) {
|
||||
super(channelName);
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* 作成するチャンネルのチャンネル名を上書き設定する
|
||||
* @param channelName 設定するチャンネル名
|
||||
*/
|
||||
protected void setChannelName(String channelName) {
|
||||
public void setChannelName(String channelName) {
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを作成した人を取得する。
|
||||
* @return チャンネルを作成したCommandSender
|
||||
*/
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated チャンネル作成イベントは、チャンネルを作成する前に呼び出されるので、
|
||||
* このメソッドの戻り値は必ずnullになります。
|
||||
* @see com.github.ucchyocean.lc.event.LunaChatBaseEvent#getChannel()
|
||||
*/
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return super.getChannel();
|
||||
}
|
||||
}
|
||||
@@ -7,24 +7,44 @@ package com.github.ucchyocean.lc.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* メンバー変更イベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelMemberChangedEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
private List<String> members;
|
||||
private List<ChannelPlayer> before;
|
||||
private List<ChannelPlayer> after;
|
||||
|
||||
public LunaChatChannelMemberChangedEvent(String channelName, List<String> members) {
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
* @param before 変更前のメンバー
|
||||
* @param after 変更後のメンバー
|
||||
*/
|
||||
public LunaChatChannelMemberChangedEvent(
|
||||
String channelName, List<ChannelPlayer> before, List<ChannelPlayer> after) {
|
||||
super(channelName);
|
||||
this.members = members;
|
||||
this.before = before;
|
||||
this.after = after;
|
||||
}
|
||||
|
||||
/**
|
||||
* 変更前のメンバーリストをかえす
|
||||
* @return
|
||||
*/
|
||||
public List<ChannelPlayer> getMembersBefore() {
|
||||
return before;
|
||||
}
|
||||
|
||||
/**
|
||||
* 変更後のメンバーリストをかえす
|
||||
* @return
|
||||
*/
|
||||
public List<String> getMembers() {
|
||||
return members;
|
||||
public List<ChannelPlayer> getMembersAfter() {
|
||||
return after;
|
||||
}
|
||||
}
|
||||
@@ -7,32 +7,38 @@ package com.github.ucchyocean.lc.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* チャンネルチャットのメッセージイベント、
|
||||
* このイベントはキャンセルできない。
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelMessageEvent extends LunaChatBaseEvent {
|
||||
|
||||
private Player player;
|
||||
private ChannelPlayer player;
|
||||
private String message;
|
||||
private ArrayList<Player> recipients;
|
||||
|
||||
private ArrayList<ChannelPlayer> recipients;
|
||||
private String displayName;
|
||||
private String originalMessage;
|
||||
|
||||
public LunaChatChannelMessageEvent(String channelName,
|
||||
Player player, String message, ArrayList<Player> recipients) {
|
||||
ChannelPlayer player, String message, ArrayList<ChannelPlayer> recipients,
|
||||
String displayName, String originalMessage) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
this.recipients = recipients;
|
||||
this.displayName = displayName;
|
||||
this.originalMessage = originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言したプレイヤー、システムメッセージの場合はnullになることに注意
|
||||
* @return player 発言プレイヤー
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
public ChannelPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@@ -48,10 +54,26 @@ public class LunaChatChannelMessageEvent extends LunaChatBaseEvent {
|
||||
* メッセージを受信するプレイヤーリスト
|
||||
* @return recipients プレイヤーリスト
|
||||
*/
|
||||
public ArrayList<Player> getRecipients() {
|
||||
public ArrayList<ChannelPlayer> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者の表示名を取得する
|
||||
* @return 発言者の表示名
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* オリジナルメッセージ(チャットフォーマットを適用していない状態のメッセージ)を取得する
|
||||
* @return オリジナルメッセージ
|
||||
*/
|
||||
public String getOriginalMessage() {
|
||||
return originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを上書き設定する
|
||||
* @param message メッセージ
|
||||
@@ -64,7 +86,7 @@ public class LunaChatChannelMessageEvent extends LunaChatBaseEvent {
|
||||
* メッセージ受信者を上書き設定する
|
||||
* @param recipients メッセージ受信者
|
||||
*/
|
||||
public void setRecipients(ArrayList<Player> recipients) {
|
||||
public void setRecipients(ArrayList<ChannelPlayer> recipients) {
|
||||
this.recipients = recipients;
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,22 @@ package com.github.ucchyocean.lc.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* オプション変更イベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelOptionChangedEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
private CommandSender sender;
|
||||
private HashMap<String, String> options;
|
||||
|
||||
public LunaChatChannelOptionChangedEvent(String channelName,
|
||||
HashMap<String, String> options) {
|
||||
CommandSender sender, HashMap<String, String> options) {
|
||||
super(channelName);
|
||||
this.sender = sender;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@@ -36,4 +41,12 @@ public class LunaChatChannelOptionChangedEvent extends LunaChatBaseCancellableEv
|
||||
public void setOptions(HashMap<String, String> options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのオプションを変更した人を取得する。
|
||||
* @return チャンネルのオプションを変更したCommandSender
|
||||
*/
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,27 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc.event;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* チャンネル削除イベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelRemoveEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
public LunaChatChannelRemoveEvent(String channelName) {
|
||||
private CommandSender sender;
|
||||
|
||||
public LunaChatChannelRemoveEvent(String channelName, CommandSender sender) {
|
||||
super(channelName);
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを削除した人を取得する。
|
||||
* @return チャンネルを削除したCommandSender
|
||||
*/
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
@@ -5,28 +5,42 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc.event;
|
||||
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* Japanize変換が行われた後に呼び出されるイベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatPostJapanizeEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
private ChannelPlayer player;
|
||||
private String original;
|
||||
private String japanized;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
* @param player 発言したプレイヤー
|
||||
* @param original 変換前の文字列
|
||||
* @param japanized 変換後の文字列
|
||||
*/
|
||||
public LunaChatPostJapanizeEvent(String channelName,
|
||||
public LunaChatPostJapanizeEvent(String channelName, ChannelPlayer player,
|
||||
String original, String japanized) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.original = original;
|
||||
this.japanized = japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換後の文字列を返す
|
||||
* @return 変換後の文字列
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* @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
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,7 @@ public enum JapanizeType {
|
||||
KANA("kana"),
|
||||
|
||||
/** カナ変換後、GoogleIMEで漢字変換 */
|
||||
GOOGLE_IME("googleime"),
|
||||
|
||||
/** カナ変換後、SocialIMEで漢字変換 */
|
||||
SOCIAL_IME("socialime");
|
||||
GOOGLE_IME("googleime");
|
||||
|
||||
private String id;
|
||||
|
||||
@@ -38,15 +35,17 @@ public enum JapanizeType {
|
||||
|
||||
/**
|
||||
* 文字列表記からJapanizeTypeを作成して返す
|
||||
* @param id
|
||||
* @param id ID
|
||||
* @param def デフォルト
|
||||
* @return
|
||||
*/
|
||||
public static JapanizeType fromID(String id) {
|
||||
public static JapanizeType fromID(String id, JapanizeType def) {
|
||||
if ( id == null ) return def;
|
||||
for ( JapanizeType type : values() ) {
|
||||
if ( type.id.equalsIgnoreCase(id) ) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
return def;
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.japanize;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* ローマ字からかな文字へ変換するクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class KanaConverter {
|
||||
|
||||
private static final HashMap<String, String[]> TABLE;
|
||||
static {
|
||||
TABLE = new HashMap<String, String[]>();
|
||||
TABLE.put( "", new String[]{"あ","い","う","え","お"});
|
||||
TABLE.put( "k", new String[]{"か","き","く","け","こ"});
|
||||
TABLE.put( "s", new String[]{"さ","し","す","せ","そ"});
|
||||
TABLE.put( "t", new String[]{"た","ち","つ","て","と"});
|
||||
TABLE.put( "n", new String[]{"な","に","ぬ","ね","の"});
|
||||
TABLE.put( "h", new String[]{"は","ひ","ふ","へ","ほ"});
|
||||
TABLE.put( "m", new String[]{"ま","み","む","め","も"});
|
||||
TABLE.put( "y", new String[]{"や","い","ゆ","いぇ","よ"});
|
||||
TABLE.put( "r", new String[]{"ら","り","る","れ","ろ"});
|
||||
TABLE.put( "w", new String[]{"わ","うぃ","う","うぇ","を"});
|
||||
TABLE.put( "g", new String[]{"が","ぎ","ぐ","げ","ご"});
|
||||
TABLE.put( "z", new String[]{"ざ","じ","ず","ぜ","ぞ"});
|
||||
TABLE.put( "j", new String[]{"じゃ","じ","じゅ","じぇ","じょ"});
|
||||
TABLE.put( "d", new String[]{"だ","ぢ","づ","で","ど"});
|
||||
TABLE.put( "b", new String[]{"ば","び","ぶ","べ","ぼ"});
|
||||
TABLE.put( "p", new String[]{"ぱ","ぴ","ぷ","ぺ","ぽ"});
|
||||
TABLE.put("gy", new String[]{"ぎゃ","ぎぃ","ぎゅ","ぎぇ","ぎょ"});
|
||||
TABLE.put("zy", new String[]{"じゃ","じぃ","じゅ","じぇ","じょ"});
|
||||
TABLE.put("jy", new String[]{"じゃ","じぃ","じゅ","じぇ","じょ"});
|
||||
TABLE.put("dy", new String[]{"ぢゃ","ぢぃ","ぢゅ","ぢぇ","ぢょ"});
|
||||
TABLE.put("by", new String[]{"びゃ","びぃ","びゅ","びぇ","びょ"});
|
||||
TABLE.put("py", new String[]{"ぴゃ","ぴぃ","ぴゅ","ぴぇ","ぴょ"});
|
||||
TABLE.put( "l", new String[]{"ぁ","ぃ","ぅ","ぇ","ぉ"});
|
||||
TABLE.put( "v", new String[]{"ヴぁ","ヴぃ","ヴ","ヴぇ","ヴぉ"});
|
||||
TABLE.put("sh", new String[]{"しゃ","し","しゅ","しぇ","しょ"});
|
||||
TABLE.put("sy", new String[]{"しゃ","し","しゅ","しぇ","しょ"});
|
||||
TABLE.put("ch", new String[]{"ちゃ","ち","ちゅ","ちぇ","ちょ"});
|
||||
TABLE.put("cy", new String[]{"ちゃ","ち","ちゅ","ちぇ","ちょ"});
|
||||
TABLE.put( "f", new String[]{"ふぁ","ふぃ","ふ","ふぇ","ふぉ"});
|
||||
TABLE.put( "q", new String[]{"くぁ","くぃ","く","くぇ","くぉ"});
|
||||
TABLE.put("ky", new String[]{"きゃ","きぃ","きゅ","きぇ","きょ"});
|
||||
TABLE.put("ty", new String[]{"ちゃ","ちぃ","ちゅ","ちぇ","ちょ"});
|
||||
TABLE.put("ny", new String[]{"にゃ","にぃ","にゅ","にぇ","にょ"});
|
||||
TABLE.put("hy", new String[]{"ひゃ","ひぃ","ひゅ","ひぇ","ひょ"});
|
||||
TABLE.put("my", new String[]{"みゃ","みぃ","みゅ","みぇ","みょ"});
|
||||
TABLE.put("ry", new String[]{"りゃ","りぃ","りゅ","りぇ","りょ"});
|
||||
TABLE.put("ly", new String[]{"ゃ","ぃ","ゅ","ぇ","ょ"});
|
||||
TABLE.put("lt", new String[]{"た","ち","っ","て","と"});
|
||||
TABLE.put("xy", new String[]{"ゃ","ぃ","ゅ","ぇ","ょ"});
|
||||
TABLE.put("xt", new String[]{"た","ち","っ","て","と"});
|
||||
TABLE.put( "x", new String[]{"ぁ","ぃ","ぅ","ぇ","ぉ"});
|
||||
};
|
||||
|
||||
private static String getKanaFromTable(String s, int n) {
|
||||
|
||||
if ( TABLE.containsKey(s) ) {
|
||||
return TABLE.get(s)[n];
|
||||
}
|
||||
return s + TABLE.get("")[n];
|
||||
}
|
||||
|
||||
/**
|
||||
* ローマ字をかな文字へ変換する
|
||||
* @param org 変換元文字列
|
||||
* @return 変換後の文字列
|
||||
*/
|
||||
public static String conv(String org) {
|
||||
|
||||
String last = "";
|
||||
StringBuilder line = new StringBuilder();
|
||||
|
||||
for ( int i=0; i<org.length(); i++ ) {
|
||||
String tmp = org.substring(i,i+1);
|
||||
|
||||
if ( tmp.equals("a") ) {
|
||||
line.append( getKanaFromTable(last, 0) );
|
||||
last = "";
|
||||
} else if ( tmp.equals("i") ) {
|
||||
line.append( getKanaFromTable(last, 1) );
|
||||
last = "";
|
||||
} else if ( tmp.equals("u") ) {
|
||||
line.append( getKanaFromTable(last, 2) );
|
||||
last = "";
|
||||
} else if ( tmp.equals("e") ) {
|
||||
line.append( getKanaFromTable(last, 3) );
|
||||
last = "";
|
||||
} else if ( tmp.equals("o") ) {
|
||||
line.append( getKanaFromTable(last, 4) );
|
||||
last = "";
|
||||
} else {
|
||||
if ( last.equals("n") && !(tmp.equals("y")) ) {
|
||||
line.append("ん");
|
||||
last = "";
|
||||
if ( tmp.equals("n") ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ( Character.isLetter(tmp.charAt(0)) ) {
|
||||
if ( Character.isUpperCase(tmp.charAt(0)) ) {
|
||||
line.append(last + tmp);
|
||||
last = "";
|
||||
} else if ( last.equals(tmp) ) {
|
||||
line.append("っ");
|
||||
last = tmp;
|
||||
} else {
|
||||
last = last + tmp;
|
||||
}
|
||||
} else {
|
||||
if ( tmp.equals("-") ) {
|
||||
line.append(last + "ー");
|
||||
last = "";
|
||||
} else {
|
||||
line.append(last + tmp);
|
||||
last = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
line.append(last);
|
||||
|
||||
return line.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
|
||||
/**
|
||||
* 各チャンネルの期限付きBANや期限付きMuteを、1分間隔で確認しに行くタスク
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ExpireCheckTask implements Runnable {
|
||||
|
||||
/**
|
||||
* 1分ごとに呼び出されるメソッド
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
for ( Channel channel : LunaChat.getAPI().getChannels() ) {
|
||||
channel.checkExpires();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.github.ucchyocean.lc3.event.EventSenderInterface;
|
||||
|
||||
/**
|
||||
* LunaChat
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChat {
|
||||
|
||||
private static PluginInterface instance;
|
||||
private static LunaChatMode mode;
|
||||
private static EventSenderInterface esender;
|
||||
|
||||
static void setPlugin(PluginInterface plugin) {
|
||||
instance = plugin;
|
||||
}
|
||||
|
||||
public static PluginInterface getPlugin() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
static void setMode(LunaChatMode _mode) {
|
||||
mode = _mode;
|
||||
}
|
||||
|
||||
public static LunaChatMode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
static void setEventSender(EventSenderInterface eventSender) {
|
||||
esender = eventSender;
|
||||
}
|
||||
|
||||
public static EventSenderInterface getEventSender() {
|
||||
return esender;
|
||||
}
|
||||
|
||||
public static File getDataFolder() {
|
||||
return instance.getDataFolder();
|
||||
}
|
||||
|
||||
public static File getPluginJarFile() {
|
||||
return instance.getPluginJarFile();
|
||||
}
|
||||
|
||||
public static LunaChatConfig getConfig() {
|
||||
return instance.getLunaChatConfig();
|
||||
}
|
||||
|
||||
public static LunaChatAPI getAPI() {
|
||||
return instance.getLunaChatAPI();
|
||||
}
|
||||
|
||||
public static LunaChatLogger getNormalChatLogger() {
|
||||
return instance.getNormalChatLogger();
|
||||
}
|
||||
|
||||
public static UUIDCacheData getUUIDCacheData() {
|
||||
return instance.getUUIDCacheData();
|
||||
}
|
||||
|
||||
public static void runAsyncTask(Runnable task) {
|
||||
instance.runAsyncTask(task);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* LunaChat APIクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public interface LunaChatAPI {
|
||||
|
||||
/**
|
||||
* 指定したチャンネル名が存在するかどうかを返す
|
||||
* @param channelName チャンネル名
|
||||
* @return 存在するかどうか
|
||||
*/
|
||||
public boolean isExistChannel(String channelName);
|
||||
|
||||
/**
|
||||
* 全てのチャンネルを返す
|
||||
* @return 全てのチャンネル
|
||||
*/
|
||||
public Collection<Channel> getChannels();
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているチャンネルを返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return チャンネル
|
||||
*/
|
||||
public Collection<Channel> getChannelsByPlayer(String playerName);
|
||||
|
||||
/**
|
||||
* プレイヤーが参加しているデフォルトのチャンネルを返す
|
||||
* @param playerName プレイヤー
|
||||
* @return チャンネル
|
||||
*/
|
||||
public Channel getDefaultChannel(String playerName);
|
||||
|
||||
/**
|
||||
* プレイヤーのデフォルトチャンネルを設定する
|
||||
* @param playerName プレイヤー
|
||||
* @param channelName チャンネル名
|
||||
*/
|
||||
public void setDefaultChannel(String playerName, String channelName);
|
||||
|
||||
/**
|
||||
* 指定した名前のプレイヤーに設定されている、デフォルトチャンネルを削除する
|
||||
* @param playerName プレイヤー名
|
||||
*/
|
||||
public void removeDefaultChannel(String playerName);
|
||||
|
||||
/**
|
||||
* チャンネルを取得する
|
||||
* @param channelName チャンネル名
|
||||
* @return チャンネル
|
||||
*/
|
||||
public Channel getChannel(String channelName);
|
||||
|
||||
/**
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @return 作成されたチャンネル
|
||||
*/
|
||||
public Channel createChannel(String channelName);
|
||||
|
||||
/**
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @param member チャンネルを作成した人
|
||||
* @return 作成されたチャンネル
|
||||
*/
|
||||
public Channel createChannel(String channelName, ChannelMember member);
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @return 削除したかどうか
|
||||
*/
|
||||
public boolean removeChannel(String channelName);
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @param member チャンネルを削除した人
|
||||
* @return 削除したかどうか
|
||||
*/
|
||||
public boolean removeChannel(String channelName, ChannelMember member);
|
||||
|
||||
/**
|
||||
* テンプレートを取得する
|
||||
* @param id テンプレートID
|
||||
* @return テンプレート
|
||||
*/
|
||||
public String getTemplate(String id);
|
||||
|
||||
/**
|
||||
* テンプレートを登録する
|
||||
* @param id テンプレートID
|
||||
* @param template テンプレート
|
||||
*/
|
||||
public void setTemplate(String id, String template);
|
||||
|
||||
/**
|
||||
* テンプレートを削除する
|
||||
* @param id テンプレートID
|
||||
*/
|
||||
public void removeTemplate(String id);
|
||||
|
||||
/**
|
||||
* 辞書データを全て取得する
|
||||
* @return 辞書データ
|
||||
*/
|
||||
public Map<String, String> getAllDictionary();
|
||||
|
||||
/**
|
||||
* 新しい辞書データを追加する
|
||||
* @param key キー
|
||||
* @param value 値
|
||||
*/
|
||||
public void setDictionary(String key, String value);
|
||||
|
||||
/**
|
||||
* 指定したキーの辞書データを削除する
|
||||
* @param key キー
|
||||
*/
|
||||
public void removeDictionary(String key);
|
||||
|
||||
/**
|
||||
* 該当のプレイヤーに関連するhidelistを取得する。
|
||||
* @param key プレイヤー
|
||||
* @return 指定されたプレイヤーをhideしているプレイヤー(非null)
|
||||
*/
|
||||
public List<ChannelMember> getHidelist(ChannelMember key);
|
||||
|
||||
/**
|
||||
* 該当のプレイヤーがhideしているプレイヤーのリストを返す。
|
||||
* @param player プレイヤー
|
||||
* @return 指定したプレイヤーがhideしているプレイヤーのリスト
|
||||
*/
|
||||
public List<ChannelMember> getHideinfo(ChannelMember player);
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーが、指定されたプレイヤーをhideするように設定する。
|
||||
* @param player hideする側のプレイヤー
|
||||
* @param hided hideされる側のプレイヤー
|
||||
*/
|
||||
public void addHidelist(ChannelMember player, ChannelMember hided);
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーが、指定されたプレイヤーのhideを解除するように設定する。
|
||||
* @param player hideしていた側のプレイヤー
|
||||
* @param hided hideされていた側のプレイヤー
|
||||
*/
|
||||
public void removeHidelist(ChannelMember player, ChannelMember hided);
|
||||
|
||||
/**
|
||||
* Japanize変換を行う
|
||||
* @param message 変換するメッセージ
|
||||
* @param type 変換タイプ
|
||||
* @return 変換後のメッセージ、ただしイベントでキャンセルされた場合はnullが返されるので注意
|
||||
*/
|
||||
public String japanize(String message, JapanizeType type);
|
||||
|
||||
/**
|
||||
* 該当プレイヤーのJapanize変換をオン/オフする
|
||||
* @param playerName 設定するプレイヤー名
|
||||
* @param doJapanize Japanize変換するかどうか
|
||||
*/
|
||||
public void setPlayersJapanize(String playerName, boolean doJapanize);
|
||||
|
||||
/**
|
||||
* プレイヤーのJapanize設定を返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return Japanize設定
|
||||
*/
|
||||
public boolean isPlayerJapanize(String playerName);
|
||||
|
||||
/**
|
||||
* LunaChatの全データを再読み込みする
|
||||
*/
|
||||
public void reloadAllData();
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.github.ucchyocean.lc3.bridge.DynmapBridge;
|
||||
import com.github.ucchyocean.lc3.bridge.McMMOBridge;
|
||||
import com.github.ucchyocean.lc3.bridge.MultiverseCoreBridge;
|
||||
import com.github.ucchyocean.lc3.bridge.VaultChatBridge;
|
||||
import com.github.ucchyocean.lc3.bukkit.BukkitEventListener;
|
||||
import com.github.ucchyocean.lc3.bukkit.BukkitEventSender;
|
||||
import com.github.ucchyocean.lc3.channel.ChannelManager;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatCommand;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatJapanizeCommand;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatMessageCommand;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatReplyCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* LunaChatのBukkit実装
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
|
||||
private static LunaChatBukkit instance;
|
||||
|
||||
private LunaChatConfig config;
|
||||
private ChannelManager manager;
|
||||
private UUIDCacheData uuidCacheData;
|
||||
|
||||
private VaultChatBridge vaultchat;
|
||||
private DynmapBridge dynmap;
|
||||
private MultiverseCoreBridge multiverse;
|
||||
|
||||
private BukkitTask expireCheckerTask;
|
||||
private LunaChatLogger normalChatLogger;
|
||||
|
||||
private LunaChatCommand lunachatCommand;
|
||||
private LunaChatMessageCommand messageCommand;
|
||||
private LunaChatReplyCommand replyCommand;
|
||||
private LunaChatJapanizeCommand lcjapanizeCommand;
|
||||
|
||||
/**
|
||||
* プラグインが有効化されたときに呼び出されるメソッド
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
LunaChat.setPlugin(this);
|
||||
LunaChat.setMode(LunaChatMode.BUKKIT);
|
||||
|
||||
// Metrics
|
||||
Metrics metrics = new Metrics(this, 7936);
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie(
|
||||
"minecraft_server_version", new Callable<Map<String, Map<String, Integer>>>() {
|
||||
public Map<String, Map<String, Integer>> call() throws Exception {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
Map<String, Integer> sub = new HashMap<>();
|
||||
sub.put(Bukkit.getVersion(), 1);
|
||||
map.put(Bukkit.getName(), sub);
|
||||
return map;
|
||||
}
|
||||
}));
|
||||
|
||||
// 変数などの初期化
|
||||
config = new LunaChatConfig(getDataFolder(), getFile());
|
||||
uuidCacheData = new UUIDCacheData(getDataFolder());
|
||||
Messages.initialize(new File(getDataFolder(), "messages"), getFile(), config.getLang());
|
||||
manager = new ChannelManager();
|
||||
normalChatLogger = new LunaChatLogger("==normalchat");
|
||||
|
||||
// チャンネルチャット無効なら、デフォルト発言先をクリアする(see issue #59)
|
||||
if ( !config.isEnableChannelChat() ) {
|
||||
manager.removeAllDefaultChannels();
|
||||
}
|
||||
|
||||
// Vault のロード
|
||||
Plugin temp = getServer().getPluginManager().getPlugin("Vault");
|
||||
if ( temp != null ) {
|
||||
vaultchat = VaultChatBridge.load(temp);
|
||||
}
|
||||
|
||||
// Dynmap のロード
|
||||
temp = getServer().getPluginManager().getPlugin("dynmap");
|
||||
if ( temp != null ) {
|
||||
dynmap = DynmapBridge.load(temp);
|
||||
if ( dynmap != null ) {
|
||||
getServer().getPluginManager().registerEvents(dynmap, this);
|
||||
}
|
||||
}
|
||||
|
||||
// MultiverseCore のロード
|
||||
temp = getServer().getPluginManager().getPlugin("Multiverse-Core");
|
||||
if ( temp != null ) {
|
||||
multiverse = MultiverseCoreBridge.load(temp);
|
||||
}
|
||||
|
||||
// mcMMOのロード
|
||||
if ( getServer().getPluginManager().isPluginEnabled("mcMMO") ) {
|
||||
getServer().getPluginManager().registerEvents(new McMMOBridge(), this);
|
||||
}
|
||||
|
||||
// リスナーの登録
|
||||
getServer().getPluginManager().registerEvents(new BukkitEventListener(), this);
|
||||
|
||||
// コマンドの登録
|
||||
lunachatCommand = new LunaChatCommand();
|
||||
messageCommand = new LunaChatMessageCommand();
|
||||
replyCommand = new LunaChatReplyCommand();
|
||||
lcjapanizeCommand = new LunaChatJapanizeCommand();
|
||||
|
||||
// 期限チェッカータスクの起動
|
||||
expireCheckerTask = Bukkit.getScheduler().runTaskTimerAsynchronously(
|
||||
this, new ExpireCheckTask(), 100, 600);
|
||||
|
||||
// イベント実行クラスの登録
|
||||
LunaChat.setEventSender(new BukkitEventSender());
|
||||
}
|
||||
|
||||
/**
|
||||
* プラグインが無効化されたときに呼び出されるメソッド
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onDisable()
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// 期限チェッカータスクの停止
|
||||
if ( expireCheckerTask != null ) {
|
||||
expireCheckerTask.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンド実行時に呼び出されるメソッド
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if ( command.getName().equals("lunachat") ) {
|
||||
return lunachatCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
} else if ( command.getName().equals("tell") ) {
|
||||
return messageCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
} else if ( command.getName().equals("reply") ) {
|
||||
return replyCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
} else if ( command.getName().equals("lcjapanize") ) {
|
||||
return lcjapanizeCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TABキー補完が実行されたときに呼び出されるメソッド
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onTabComplete(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(
|
||||
CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
List<String> completeList = null;
|
||||
if ( command.getName().equals("lunachat") ) {
|
||||
completeList = lunachatCommand.onTabComplete(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
if ( completeList != null ) {
|
||||
return completeList;
|
||||
}
|
||||
return super.onTabComplete(sender, command, label, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのインスタンスを返す
|
||||
* @return LunaChat
|
||||
*/
|
||||
public static LunaChatBukkit getInstance() {
|
||||
if ( instance == null ) {
|
||||
instance = (LunaChatBukkit)Bukkit.getPluginManager().getPlugin("LunaChat");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* このプラグインのJarファイル自身を示すFileクラスを返す。
|
||||
* @return Jarファイル
|
||||
*/
|
||||
public File getPluginJarFile() {
|
||||
return getFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatAPIを取得する
|
||||
* @return LunaChatAPI
|
||||
*/
|
||||
public LunaChatAPI getLunaChatAPI() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatConfigを取得する
|
||||
* @return LunaChatConfig
|
||||
*/
|
||||
public LunaChatConfig getLunaChatConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* VaultChat連携クラスを返す
|
||||
* @return VaultChatBridge
|
||||
*/
|
||||
public VaultChatBridge getVaultChat() {
|
||||
return vaultchat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynmap連携クラスを返す
|
||||
* @return DynmapBridge
|
||||
*/
|
||||
public DynmapBridge getDynmap() {
|
||||
return dynmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* MultiverseCore連携クラスを返す
|
||||
* @return MultiverseCoreBridge
|
||||
*/
|
||||
public MultiverseCoreBridge getMultiverseCore() {
|
||||
return multiverse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャット用のロガーを返す
|
||||
* @return normalChatLogger
|
||||
*/
|
||||
public LunaChatLogger getNormalChatLogger() {
|
||||
return normalChatLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャット用のロガーを設定する
|
||||
* @param normalChatLogger normalChatLogger
|
||||
*/
|
||||
protected void setNormalChatLogger(LunaChatLogger normalChatLogger) {
|
||||
this.normalChatLogger = normalChatLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインのプレイヤー名一覧を取得する
|
||||
* @return オンラインのプレイヤー名一覧
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getOnlinePlayerNames() {
|
||||
Set<String> list = new TreeSet<>();
|
||||
for ( Player p : Bukkit.getOnlinePlayers() ) {
|
||||
list.add(p.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* このプラグインのログを記録する
|
||||
* @param level ログレベル
|
||||
* @param msg ログメッセージ
|
||||
*/
|
||||
@Override
|
||||
public void log(Level level, String msg) {
|
||||
getLogger().log(level, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* UUIDキャッシュデータを取得する
|
||||
* @return UUIDキャッシュデータ
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getUUIDCacheData()
|
||||
*/
|
||||
@Override
|
||||
public UUIDCacheData getUUIDCacheData() {
|
||||
return uuidCacheData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 非同期タスクを実行する
|
||||
* @param task タスク
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#runAsyncTask(java.lang.Runnable)
|
||||
*/
|
||||
@Override
|
||||
public void runAsyncTask(Runnable task) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this, task);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
|
||||
import com.github.ucchyocean.lc3.bridge.BungeePermsBridge;
|
||||
import com.github.ucchyocean.lc3.bridge.LuckPermsBridge;
|
||||
import com.github.ucchyocean.lc3.bungee.BungeeEventListener;
|
||||
import com.github.ucchyocean.lc3.bungee.BungeeEventSender;
|
||||
import com.github.ucchyocean.lc3.bungee.JapanizeCommandBungee;
|
||||
import com.github.ucchyocean.lc3.bungee.LunaChatCommandBungee;
|
||||
import com.github.ucchyocean.lc3.bungee.MessageCommandBungee;
|
||||
import com.github.ucchyocean.lc3.bungee.ReplyCommandBungee;
|
||||
import com.github.ucchyocean.lc3.channel.ChannelManager;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* LunaChatのBungeeCord実装
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
|
||||
private static LunaChatBungee instance;
|
||||
|
||||
private HashMap<String, String> history;
|
||||
private LunaChatConfig config;
|
||||
private ChannelManager manager;
|
||||
private UUIDCacheData uuidCacheData;
|
||||
private LunaChatLogger normalChatLogger;
|
||||
|
||||
private BungeePermsBridge bungeeperms;
|
||||
private LuckPermsBridge luckperms;
|
||||
|
||||
/**
|
||||
* プラグインが有効化されたときに呼び出されるメソッド
|
||||
* @see net.md_5.bungee.api.plugin.Plugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
LunaChat.setPlugin(this);
|
||||
LunaChat.setMode(LunaChatMode.BUNGEE);
|
||||
|
||||
// Metrics
|
||||
Metrics metrics = new Metrics(this, 7936);
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie(
|
||||
"minecraft_server_version", new Callable<Map<String, Map<String, Integer>>>() {
|
||||
public Map<String, Map<String, Integer>> call() throws Exception {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
Map<String, Integer> sub = new HashMap<>();
|
||||
sub.put(getProxy().getVersion(), 1);
|
||||
map.put(getProxy().getName(), sub);
|
||||
return map;
|
||||
}
|
||||
}));
|
||||
|
||||
// 初期化
|
||||
config = new LunaChatConfig(getDataFolder(), getFile());
|
||||
uuidCacheData = new UUIDCacheData(getDataFolder());
|
||||
Messages.initialize(new File(getDataFolder(), "messages"), getFile(), config.getLang());
|
||||
history = new HashMap<String, String>();
|
||||
|
||||
manager = new ChannelManager();
|
||||
normalChatLogger = new LunaChatLogger("==normalchat");
|
||||
|
||||
// チャンネルチャット無効なら、デフォルト発言先をクリアする
|
||||
if ( !config.isEnableChannelChat() ) {
|
||||
manager.removeAllDefaultChannels();
|
||||
}
|
||||
|
||||
// BungeePermsのロード
|
||||
Plugin temp = getProxy().getPluginManager().getPlugin("BungeePerms");
|
||||
if ( temp != null ) {
|
||||
bungeeperms = BungeePermsBridge.load(temp);
|
||||
}
|
||||
|
||||
// LuckPermsのロード
|
||||
temp = getProxy().getPluginManager().getPlugin("LuckPerms");
|
||||
if ( temp != null ) {
|
||||
luckperms = LuckPermsBridge.load(temp);
|
||||
}
|
||||
|
||||
// コマンド登録
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new LunaChatCommandBungee("lunachat", "", "lc", "ch"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new MessageCommandBungee("tell", "", "msg", "message", "m", "t"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new ReplyCommandBungee("reply", "", "r"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new JapanizeCommandBungee("japanize", "", "jp"));
|
||||
|
||||
// リスナー登録
|
||||
getProxy().getPluginManager().registerListener(this, new BungeeEventListener(this));
|
||||
|
||||
// イベント実行クラスの登録
|
||||
LunaChat.setEventSender(new BungeeEventSender());
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのインスタンスを返す
|
||||
* @return LunaChat
|
||||
*/
|
||||
public static LunaChatBungee getInstance() {
|
||||
if ( instance == null ) {
|
||||
instance = (LunaChatBungee)ProxyServer.getInstance().getPluginManager().getPlugin("LunaChat");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* コンフィグを返す
|
||||
* @return コンフィグ
|
||||
*/
|
||||
public LunaChatConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* プライベートメッセージの受信履歴を記録する
|
||||
* @param reciever 受信者
|
||||
* @param sender 送信者
|
||||
*/
|
||||
protected void putHistory(String reciever, String sender) {
|
||||
history.put(reciever, sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* プライベートメッセージの受信履歴を取得する
|
||||
* @param reciever 受信者
|
||||
* @return 送信者
|
||||
*/
|
||||
protected String getHistory(String reciever) {
|
||||
return history.get(reciever);
|
||||
}
|
||||
|
||||
/**
|
||||
* このプラグインのJarファイル自身を示すFileクラスを返す。
|
||||
* @return Jarファイル
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getPluginJarFile()
|
||||
*/
|
||||
@Override
|
||||
public File getPluginJarFile() {
|
||||
return getFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatConfigを取得する
|
||||
* @return LunaChatConfig
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getLunaChatConfig()
|
||||
*/
|
||||
@Override
|
||||
public LunaChatConfig getLunaChatConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatAPIを取得する
|
||||
* @return LunaChatAPI
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getLunaChatAPI()
|
||||
*/
|
||||
@Override
|
||||
public LunaChatAPI getLunaChatAPI() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャット用のロガーを返す
|
||||
* @return normalChatLogger
|
||||
*/
|
||||
@Override
|
||||
public LunaChatLogger getNormalChatLogger() {
|
||||
return normalChatLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインのプレイヤー名一覧を取得する
|
||||
* @return オンラインのプレイヤー名一覧
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getOnlinePlayerNames() {
|
||||
Set<String> list = new TreeSet<>();
|
||||
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() ) {
|
||||
list.add(p.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* このプラグインのログを記録する
|
||||
* @param level ログレベル
|
||||
* @param msg ログメッセージ
|
||||
*/
|
||||
@Override
|
||||
public void log(Level level, String msg) {
|
||||
getLogger().log(level, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* UUIDキャッシュデータを取得する
|
||||
* @return UUIDキャッシュデータ
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getUUIDCacheData()
|
||||
*/
|
||||
@Override
|
||||
public UUIDCacheData getUUIDCacheData() {
|
||||
return uuidCacheData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 非同期タスクを実行する
|
||||
* @param task タスク
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#runAsyncTask(java.lang.Runnable)
|
||||
*/
|
||||
@Override
|
||||
public void runAsyncTask(Runnable task) {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(this, task);
|
||||
}
|
||||
|
||||
/**
|
||||
* BungeePerms連携クラスを取得する
|
||||
* @return BungeePerms連携クラス
|
||||
*/
|
||||
public BungeePermsBridge getBungeePerms() {
|
||||
return bungeeperms;
|
||||
}
|
||||
|
||||
/**
|
||||
* LuckPerms連携クラスを取得する
|
||||
* @return LuckPerms連携クラス
|
||||
*/
|
||||
public LuckPermsBridge getLuckPerms() {
|
||||
return luckperms;
|
||||
}
|
||||
}
|
||||
+308
-59
@@ -1,17 +1,20 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.util.EventPriority;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
import com.github.ucchyocean.lc3.util.YamlConfig;
|
||||
|
||||
/**
|
||||
* LunaChatのコンフィグクラス
|
||||
@@ -19,9 +22,15 @@ import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
*/
|
||||
public class LunaChatConfig {
|
||||
|
||||
/** メッセージの言語 */
|
||||
private String lang;
|
||||
|
||||
/** チャンネルチャット機能を利用可能にするかどうか */
|
||||
private boolean enableChannelChat;
|
||||
|
||||
|
||||
/** チャットイベントの処理優先度 */
|
||||
private EventPriority playerChatEventListenerPriority;
|
||||
|
||||
/** チャンネルチャットに入っていない人の発言を、グローバルとして扱うかどうか */
|
||||
private boolean noJoinAsGlobal;
|
||||
|
||||
@@ -40,7 +49,8 @@ public class LunaChatConfig {
|
||||
/** ログイン時に、参加中チャンネルを表示するかどうか */
|
||||
private boolean showListOnJoin;
|
||||
|
||||
/** /ch join コマンドで存在しないチャンネルを指定したときに、チャンネルを新規作成して入室するかどうか */
|
||||
/** /ch join コマンドで存在しないチャンネルを指定したときに、
|
||||
* チャンネルを新規作成して入室するかどうか */
|
||||
private boolean createChannelOnJoinCommand;
|
||||
|
||||
/** サーバーに初参加したユーザーを参加させる、既定のチャンネル。<br/>
|
||||
@@ -51,10 +61,37 @@ public class LunaChatConfig {
|
||||
* グローバルチャンネルとは別で指定できる。 */
|
||||
private List<String> forceJoinChannels;
|
||||
|
||||
/** formatコマンド実行時に、必ず含まれる必要があるキーワード。 */
|
||||
private List<String> formatConstraint;
|
||||
|
||||
/** チャンネルを作成したときに、デフォルトで設定されるフォーマット */
|
||||
private String defaultFormat;
|
||||
|
||||
/** プライベートメッセージを送信するときに、適用されるフォーマット */
|
||||
private String defaultFormatForPrivateMessage;
|
||||
|
||||
/** OPの画面に、全チャンネルの発言内容を表示するかどうか */
|
||||
private boolean opListenAllChannel;
|
||||
|
||||
/** チャンネルを新規作成するときに、チャンネル名が満たさなければならない、最低文字列長 */
|
||||
private int minChannelNameLength;
|
||||
|
||||
/** チャンネルを新規作成するときに、チャンネル名が満たさなければならない、最大文字列長 */
|
||||
private int maxChannelNameLength;
|
||||
|
||||
/** クイックチャンネルチャット機能を有効化するかどうか */
|
||||
private boolean enableQuickChannelChat;
|
||||
|
||||
/** クイックチャンネルチャット機能に使用する記号 */
|
||||
private String quickChannelChatSeparator;
|
||||
|
||||
/** ブロードキャストチャンネルの発言内容を、dynmapに送信するかどうか。<br/>
|
||||
* dynmapがロードされていない場合は、この設定は無視される(false扱い)。 */
|
||||
private boolean sendBroadcastChannelChatToDynmap;
|
||||
|
||||
|
||||
/** dynmapへ送信するときに、チャンネルのフォーマットを反映して送信するかどうか。*/
|
||||
private boolean sendFormattedMessageToDynmap;
|
||||
|
||||
/** dynmapのWebUIから発言された発言内容を表示するチャンネル。 */
|
||||
private String dynmapChannel;
|
||||
|
||||
@@ -67,11 +104,22 @@ public class LunaChatConfig {
|
||||
* ban = マスクしてチャンネルからBANする */
|
||||
private NGWordAction ngwordAction;
|
||||
|
||||
/** NGワードの設定、正規表現マッチング用にコンパイルされたもの */
|
||||
private List<Pattern> ngwordCompiled;
|
||||
|
||||
/** 通常チャット(非チャンネルチャット)の装飾を、LunaChatから行うかどうか */
|
||||
private boolean enableNormalChatMessageFormat;
|
||||
|
||||
/** 通常チャットの装飾フォーマット */
|
||||
private String normalChatMessageFormat;
|
||||
|
||||
/** 通常チャットで、カラーコードを使用可能にするかどうか */
|
||||
private boolean enableNormalChatColorCode;
|
||||
|
||||
/** Japanize変換のタイプ<br/>
|
||||
* none = 日本語変換をしない<br/>
|
||||
* kana = カナ変換のみする<br/>
|
||||
* googleime = カナ変換後、GoogleIMEで漢字変換する<br/>
|
||||
* socialime = カナ変換後、SocialIMEで漢字変換する */
|
||||
* googleime = カナ変換後、GoogleIMEで漢字変換する */
|
||||
private JapanizeType japanizeType;
|
||||
|
||||
/** Japanize変換の1行表示と2行表示の切り替え<br/>
|
||||
@@ -84,46 +132,59 @@ public class LunaChatConfig {
|
||||
|
||||
/** Japanize変換の2行表示時の2行目のフォーマット */
|
||||
private String japanizeLine2Format;
|
||||
|
||||
|
||||
/** 発言に含まれているプレイヤー名を、Japanize変換から除外するかどうか */
|
||||
private boolean japanizeIgnorePlayerName;
|
||||
|
||||
/** ノンジャパナイズマーカー これが発言の頭に入っている場合は、一時的にjapanizeを実行しない */
|
||||
private String noneJapanizeMarker;
|
||||
|
||||
|
||||
/** 通常チャットで、JapanizeDisplayLine=2のとき、Japanize変換したあと表示するまでのウェイト(tick)
|
||||
* 隠し設定。 */
|
||||
private int japanizeWait;
|
||||
|
||||
// === 以下、BungeeCord用設定 ===
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param dataFolder コンフィグ格納フォルダ
|
||||
* @param jarFile プラグインJarファイル
|
||||
*/
|
||||
protected LunaChatConfig() {
|
||||
reloadConfig();
|
||||
public LunaChatConfig(File dataFolder, File jarFile) {
|
||||
reloadConfig(dataFolder, jarFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* config.yml を再読み込みする
|
||||
*/
|
||||
public void reloadConfig() {
|
||||
public void reloadConfig(File dataFolder, File jarFile) {
|
||||
|
||||
File configFile = new File(LunaChat.instance.getDataFolder(), "config.yml");
|
||||
File configFile = new File(dataFolder, "config.yml");
|
||||
if ( !configFile.exists() ) {
|
||||
//LunaChat.instance.saveDefaultConfig();
|
||||
Utility.copyFileFromJar(LunaChat.getPluginJarFile(),
|
||||
configFile, "config_ja.yml", false);
|
||||
Utility.copyFileFromJar(jarFile, configFile, "config_ja.yml", false);
|
||||
String language = Utility.getDefaultLocale().getLanguage();
|
||||
if ( language.equals("ja") ) {
|
||||
Utility.copyFileFromJar(jarFile, configFile, "config_ja.yml", false);
|
||||
} else {
|
||||
Utility.copyFileFromJar(jarFile, configFile, "config.yml", false);
|
||||
}
|
||||
}
|
||||
|
||||
LunaChat.instance.reloadConfig();
|
||||
FileConfiguration config = LunaChat.instance.getConfig();
|
||||
YamlConfig config = YamlConfig.load(configFile);
|
||||
|
||||
lang = config.getString("lang", "en");
|
||||
enableChannelChat = config.getBoolean("enableChannelChat", true);
|
||||
playerChatEventListenerPriority
|
||||
= getEventPriority(config.getString("playerChatEventListenerPriority"), EventPriority.HIGH);
|
||||
noJoinAsGlobal = config.getBoolean("noJoinAsGlobal", true);
|
||||
loggingChat = config.getBoolean("loggingChat", true);
|
||||
displayChatOnConsole = config.getBoolean("displayChatOnConsole", false);
|
||||
displayChatOnConsole = config.getBoolean("displayChatOnConsole", true);
|
||||
globalMarker = config.getString("globalMarker", "!");
|
||||
zeroMemberRemove = config.getBoolean("zeroMemberRemove", false);
|
||||
showListOnJoin = config.getBoolean("showListOnJoin", false);
|
||||
createChannelOnJoinCommand =
|
||||
config.getBoolean("createChannelOnJoinCommand", true);
|
||||
|
||||
config.getBoolean("createChannelOnJoinCommand", false);
|
||||
|
||||
// チャンネルチャット有効のときだけ、globalChannel設定を読み込む
|
||||
// (see issue #58)
|
||||
if ( enableChannelChat ) {
|
||||
@@ -131,7 +192,7 @@ public class LunaChatConfig {
|
||||
} else {
|
||||
globalChannel = "";
|
||||
}
|
||||
// チャンネルチャット有効のときだけ、enableChannelChat設定を読み込む
|
||||
// チャンネルチャット有効のときだけ、forceJoinChannels設定を読み込む
|
||||
// (see issue #58)
|
||||
if ( enableChannelChat ) {
|
||||
forceJoinChannels = config.getStringList("forceJoinChannels");
|
||||
@@ -139,43 +200,93 @@ public class LunaChatConfig {
|
||||
forceJoinChannels = new ArrayList<String>();
|
||||
}
|
||||
|
||||
if ( config.contains("formatConstraint") ) {
|
||||
formatConstraint = config.getStringList("formatConstraint");
|
||||
} else {
|
||||
formatConstraint = new ArrayList<String>();
|
||||
formatConstraint.add("%username");
|
||||
formatConstraint.add("%msg");
|
||||
}
|
||||
|
||||
defaultFormat = config.getString("defaultFormat",
|
||||
"&f[%color%ch&f]%prefix%username%suffix&a:&f %msg");
|
||||
defaultFormatForPrivateMessage =
|
||||
config.getString("defaultFormatForPrivateMessage",
|
||||
"&7[%player -> %to]&f %msg");
|
||||
|
||||
opListenAllChannel = config.getBoolean("opListenAllChannel", false);
|
||||
|
||||
minChannelNameLength = config.getInt("minChannelNameLength", 4);
|
||||
maxChannelNameLength = config.getInt("maxChannelNameLength", 20);
|
||||
|
||||
enableQuickChannelChat = config.getBoolean("enableQuickChannelChat", true);
|
||||
quickChannelChatSeparator = config.getString("quickChannelChatSeparator", ":");
|
||||
|
||||
sendBroadcastChannelChatToDynmap =
|
||||
config.getBoolean("sendBroadcastChannelChatToDynmap", true);
|
||||
sendFormattedMessageToDynmap =
|
||||
config.getBoolean("sendFormattedMessageToDynmap", false);
|
||||
dynmapChannel = config.getString("dynmapChannel", "");
|
||||
ngword = config.getStringList("ngword");
|
||||
ngwordAction = NGWordAction.fromID(config.getString("ngwordAction", "mask"));
|
||||
japanizeType = JapanizeType.fromID(config.getString("japanizeType", "kana"));
|
||||
|
||||
ngwordCompiled = new ArrayList<Pattern>();
|
||||
for ( String word : ngword ) {
|
||||
ngwordCompiled.add(Pattern.compile(word));
|
||||
}
|
||||
|
||||
enableNormalChatMessageFormat =
|
||||
config.getBoolean("enableNormalChatMessageFormat", true);
|
||||
normalChatMessageFormat =
|
||||
config.getString("normalChatMessageFormat", "&f%prefix%username%suffix&a:&f %msg");
|
||||
enableNormalChatColorCode =
|
||||
config.getBoolean("enableNormalChatColorCode", true);
|
||||
|
||||
japanizeType = JapanizeType.fromID(config.getString("japanizeType"), null);
|
||||
japanizeDisplayLine = config.getInt("japanizeDisplayLine", 2);
|
||||
if ( japanizeDisplayLine != 1 && japanizeDisplayLine != 2 ) {
|
||||
japanizeDisplayLine = 2;
|
||||
}
|
||||
japanizeLine1Format = config.getString("japanizeLine1Format", "%msg (%japanize)");
|
||||
japanizeLine1Format = config.getString("japanizeLine1Format", "%msg &6(%japanize)");
|
||||
japanizeLine2Format = config.getString("japanizeLine2Format", "&6[JP] %japanize");
|
||||
noneJapanizeMarker = config.getString("noneJapanizeMarker", "#");
|
||||
japanizeIgnorePlayerName = config.getBoolean("japanizeIgnorePlayerName", true);
|
||||
noneJapanizeMarker = config.getString("noneJapanizeMarker", "$");
|
||||
japanizeWait = config.getInt("japanizeWait", 1);
|
||||
|
||||
// globalチャンネルが、使用可能なチャンネル名かどうかを調べる
|
||||
if ( !globalChannel.equals("") && !LunaChat.manager.checkForChannelName(globalChannel) ) {
|
||||
String msg = String.format(
|
||||
Resources.get("errmsgCannotUseForGlobal"), globalChannel);
|
||||
LunaChat.instance.getLogger().warning(msg);
|
||||
globalChannel = "";
|
||||
}
|
||||
if ( globalChannel != null && !globalChannel.equals("") &&
|
||||
!globalChannel.matches("[0-9a-zA-Z\\-_]{1,20}") ) {
|
||||
|
||||
// チャンネルチャット無効なら、デフォルト発言先をクリアする(see issue #59)
|
||||
if ( !enableChannelChat ) {
|
||||
LunaChat.manager.removeAllDefaultChannels();
|
||||
// コンソールに警告を表示する
|
||||
LunaChat.getPlugin().log(Level.WARNING, Messages.errmsgCannotUseForGlobal(globalChannel));
|
||||
globalChannel = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* メッセージの言語
|
||||
* @return lang
|
||||
*/
|
||||
public String getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャット機能を利用可能にするかどうか
|
||||
* @return enableChannelChatを返す
|
||||
*/
|
||||
public boolean isEnableChannelChat() {
|
||||
return enableChannelChat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* チャットイベントの処理優先度
|
||||
* @return playerChatEventListenerPriorityを返す
|
||||
*/
|
||||
public EventPriority getPlayerChatEventListenerPriority() {
|
||||
return playerChatEventListenerPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットに入っていない人の発言を、グローバルとして扱うかどうか
|
||||
* @return noJoinAsGlobalを返す
|
||||
@@ -250,31 +361,80 @@ public class LunaChatConfig {
|
||||
return forceJoinChannels;
|
||||
}
|
||||
|
||||
/**
|
||||
* formatコマンド実行時に、必ず含まれる必要があるキーワード。
|
||||
* @return formatConstraintを返す
|
||||
*/
|
||||
public List<String> getFormatConstraint() {
|
||||
return formatConstraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを作成したときに、デフォルトで設定されるフォーマット。
|
||||
* @return defaultFormatを返す
|
||||
*/
|
||||
public String getDefaultFormat() {
|
||||
return defaultFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* プライベートメッセージを送信するときに、適用されるフォーマット。
|
||||
* @return defaultFormatForPrivateMessageを返す
|
||||
*/
|
||||
public String getDefaultFormatForPrivateMessage() {
|
||||
return defaultFormatForPrivateMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* OPの画面に、全チャンネルの発言内容を表示するかどうか
|
||||
* @return opListenAllChannel opListenAllChannelを返す
|
||||
*/
|
||||
public boolean isOpListenAllChannel() {
|
||||
return opListenAllChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを新規作成するときに、チャンネル名が満たさなければならない、最低文字列長
|
||||
* @return minChannelNameLength
|
||||
*/
|
||||
public int getMinChannelNameLength() {
|
||||
return minChannelNameLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを新規作成するときに、チャンネル名が満たさなければならない、最大文字列長
|
||||
* @return maxChannelNameLength
|
||||
*/
|
||||
public int getMaxChannelNameLength() {
|
||||
return maxChannelNameLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* クイックチャンネルチャット機能を有効化するかどうかを取得する
|
||||
* @return enableQuickChannelChat
|
||||
*/
|
||||
public boolean isEnableQuickChannelChat() {
|
||||
return enableQuickChannelChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* クイックチャンネルチャット機能に使用する記号
|
||||
* @return quickChannelChatSeparator
|
||||
*/
|
||||
public String getQuickChannelChatSeparator() {
|
||||
return quickChannelChatSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* NGワード
|
||||
* @return ngwordを返す
|
||||
* @deprecated 全て正規表現に変更するため、getNgwordCompiledを使用してください
|
||||
*/
|
||||
@Deprecated
|
||||
public List<String> getNgword() {
|
||||
return ngword;
|
||||
}
|
||||
|
||||
/**
|
||||
* ブロードキャストチャンネルの発言内容を、dynmapに送信するかどうか。<br/>
|
||||
* dynmapがロードされていない場合は、この設定は無視される(false扱い)。
|
||||
* @return sendBroadcastChannelChatToDynmapを返す
|
||||
*/
|
||||
public boolean isSendBroadcastChannelChatToDynmap() {
|
||||
return sendBroadcastChannelChatToDynmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* dynmapのWebUIから発言された発言内容を表示するチャンネル。
|
||||
* @return dynmapChannel dynmapの発言を表示するチャンネル名を返す
|
||||
*/
|
||||
public String getDynmapChannel() {
|
||||
return dynmapChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* NGワードを発言した人に対して実行するアクション<br/>
|
||||
* mask = マスクするのみ<br/>
|
||||
@@ -286,12 +446,60 @@ public class LunaChatConfig {
|
||||
return ngwordAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* コンパイルされたNGワード
|
||||
* @return ngwordCompiledを返す
|
||||
*/
|
||||
public List<Pattern> getNgwordCompiled() {
|
||||
return ngwordCompiled;
|
||||
}
|
||||
|
||||
/**
|
||||
* ブロードキャストチャンネルの発言内容を、dynmapに送信するかどうか。<br/>
|
||||
* dynmapがロードされていない場合は、この設定は無視される(false扱い)。
|
||||
* @return sendBroadcastChannelChatToDynmapを返す
|
||||
*/
|
||||
public boolean isSendBroadcastChannelChatToDynmap() {
|
||||
return sendBroadcastChannelChatToDynmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* dynmapへ送信するときに、チャンネルのフォーマットを反映して送信するかどうか。
|
||||
* @return sendFormattedMessageToDynmapを返す
|
||||
*/
|
||||
public boolean isSendFormattedMessageToDynmap() {
|
||||
return sendFormattedMessageToDynmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* dynmapのWebUIから発言された発言内容を表示するチャンネル。
|
||||
* @return dynmapChannel dynmapの発言を表示するチャンネル名を返す
|
||||
*/
|
||||
public String getDynmapChannel() {
|
||||
return dynmapChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャット(非チャンネルチャット)の装飾を、LunaChatから行うかどうか
|
||||
* @return enableNormalChatMessageFormatを返す
|
||||
*/
|
||||
public boolean isEnableNormalChatMessageFormat() {
|
||||
return enableNormalChatMessageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャットの装飾フォーマット
|
||||
* @return normalChatMessageFormatを返す
|
||||
*/
|
||||
public String getNormalChatMessageFormat() {
|
||||
return normalChatMessageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換のタイプ<br/>
|
||||
* none = 日本語変換をしない<br/>
|
||||
* kana = カナ変換のみする<br/>
|
||||
* googleime = カナ変換後、GoogleIMEで漢字変換する<br/>
|
||||
* socialime = カナ変換後、SocialIMEで漢字変換する
|
||||
* googleime = カナ変換後、GoogleIMEで漢字変換する
|
||||
* @return japanizeTypeを返す
|
||||
*/
|
||||
public JapanizeType getJapanizeType() {
|
||||
@@ -324,6 +532,14 @@ public class LunaChatConfig {
|
||||
return japanizeLine2Format;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言に含まれているプレイヤー名を、Japanize変換から除外するかどうか
|
||||
* @return japanizeIgnorePlayerName
|
||||
*/
|
||||
public boolean isJapanizeIgnorePlayerName() {
|
||||
return japanizeIgnorePlayerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* ノンジャパナイズマーカー これが発言の頭に入っている場合は、一時的にjapanizeを実行しない
|
||||
* @return noneJapanizeMarkerを返す
|
||||
@@ -331,7 +547,7 @@ public class LunaChatConfig {
|
||||
public String getNoneJapanizeMarker() {
|
||||
return noneJapanizeMarker;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通常チャットで、JapanizeDisplayLine=2のとき、Japanize変換したあと表示するまでのウェイト(tick)
|
||||
* @return japanizeWaitを返す
|
||||
@@ -339,4 +555,37 @@ public class LunaChatConfig {
|
||||
public int getJapanizeWait() {
|
||||
return japanizeWait;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャットで、カラーコードを使用可能にするかどうか
|
||||
* @return enableNormalChatColorCodeを返す
|
||||
*/
|
||||
public boolean isEnableNormalChatColorCode() {
|
||||
return enableNormalChatColorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された文字列から、対応するEventPriorityを返す。
|
||||
* @param value 文字列
|
||||
* @param def デフォルト
|
||||
* @return EventPriority
|
||||
*/
|
||||
private static EventPriority getEventPriority(String value, EventPriority def) {
|
||||
|
||||
if ( value == null ) return def;
|
||||
|
||||
if ( value.equalsIgnoreCase("LOWEST") ) {
|
||||
return EventPriority.LOWEST;
|
||||
} else if ( value.equalsIgnoreCase("LOW") ) {
|
||||
return EventPriority.LOW;
|
||||
} else if ( value.equalsIgnoreCase("NORMAL") ) {
|
||||
return EventPriority.NORMAL;
|
||||
} else if ( value.equalsIgnoreCase("HIGH") ) {
|
||||
return EventPriority.HIGH;
|
||||
} else if ( value.equalsIgnoreCase("HIGHEST") ) {
|
||||
return EventPriority.HIGHEST;
|
||||
}
|
||||
|
||||
return def;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
|
||||
/**
|
||||
* LunaChatロガー
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatLogger {
|
||||
|
||||
private SimpleDateFormat lformat;
|
||||
private SimpleDateFormat dformat;
|
||||
|
||||
private SimpleDateFormat logYearDateFormat;
|
||||
|
||||
private File file;
|
||||
private String dirPath;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name ログ名
|
||||
*/
|
||||
public LunaChatLogger(String name) {
|
||||
|
||||
lformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
dformat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
logYearDateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
|
||||
this.name = name;
|
||||
checkDir();
|
||||
}
|
||||
|
||||
/**
|
||||
* ログを出力する
|
||||
* @param message ログ内容
|
||||
* @param player 発言者名
|
||||
*/
|
||||
public synchronized void log(final String message, final String player) {
|
||||
|
||||
checkDir();
|
||||
|
||||
// 以降の処理を、発言処理の負荷軽減のため、非同期実行にする。(see issue #40.)
|
||||
LunaChat.runAsyncTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String msg = Utility.stripColorCode(message);
|
||||
if ( msg == null ) msg = "";
|
||||
msg = msg.replace(",", ",");
|
||||
|
||||
try ( OutputStreamWriter writer = new OutputStreamWriter(
|
||||
new FileOutputStream(file, true), "UTF-8"); ) {
|
||||
|
||||
String str = lformat.format(new Date()) + "," + msg + "," + player;
|
||||
writer.write(str + "\r\n");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ログファイルを読み込んで、ログデータを取得する
|
||||
* @param player プレイヤー名、フィルタしないならnullを指定すること
|
||||
* @param filter フィルタ、フィルタしないならnullを指定すること
|
||||
* @param date 日付、今日のデータを取得するならnullを指定すること
|
||||
* @param reverse 逆順取得
|
||||
* @return ログデータ
|
||||
*/
|
||||
public ArrayList<String> getLog(
|
||||
String player, String filter, String date, boolean reverse) {
|
||||
|
||||
// 指定された日付のログを取得する
|
||||
File f = getLogFile(date);
|
||||
if ( f == null ) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
// ログファイルの読み込み
|
||||
ArrayList<String> data = readAllLines(f);
|
||||
|
||||
// プレイヤー指定なら、一致するプレイヤー名が含まれているログに絞る
|
||||
if ( player != null ) {
|
||||
ArrayList<String> temp = new ArrayList<String>(data);
|
||||
data = new ArrayList<String>();
|
||||
for ( String t : temp ) {
|
||||
String[] line = t.split(",");
|
||||
if ( line.length >= 3 && line[2].contains(player) ) {
|
||||
data.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// フィルタ指定なら、指定のキーワードが含まれているログに絞る
|
||||
if ( filter != null ) {
|
||||
ArrayList<String> temp = new ArrayList<String>(data);
|
||||
data = new ArrayList<String>();
|
||||
for ( String t : temp ) {
|
||||
String[] line = t.split(",");
|
||||
if ( line.length >= 2 && line[1].contains(filter) ) {
|
||||
data.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 逆順が指定されているなら、逆順に並び替える
|
||||
if ( reverse ) {
|
||||
Collections.reverse(data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* テキストファイルの内容を読み出す。
|
||||
* @param file ファイル
|
||||
* @return 内容
|
||||
*/
|
||||
private ArrayList<String> readAllLines(File file) {
|
||||
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
if ( !file.exists() ) return data;
|
||||
|
||||
try ( BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(file), "UTF-8")) ) {
|
||||
|
||||
String line;
|
||||
while ( (line = reader.readLine()) != null ) {
|
||||
line = line.trim();
|
||||
if ( line.length() > 0 ) {
|
||||
data.add(line);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された日付のログファイルを取得します。
|
||||
* 取得できない場合は、nullを返します。
|
||||
* @param date 日付
|
||||
* @return 指定された日付のログファイル
|
||||
*/
|
||||
private File getLogFile(String date) {
|
||||
|
||||
if ( date == null ) {
|
||||
return file;
|
||||
}
|
||||
|
||||
Date d;
|
||||
try {
|
||||
if ( date.matches("[0-9]{4}") ) {
|
||||
date = Calendar.getInstance().get(Calendar.YEAR) + date;
|
||||
}
|
||||
if ( date.matches("[0-9]{8}") ) {
|
||||
d = logYearDateFormat.parse(date);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
File folder = new File(getFolderPath(d));
|
||||
if ( !folder.exists() || !folder.isDirectory() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File f = new File(folder, name + ".log");
|
||||
if ( !f.exists() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* ログの出力先フォルダをチェックし、変更されるなら更新する。
|
||||
*/
|
||||
private void checkDir() {
|
||||
|
||||
String temp = getFolderPath(new Date());
|
||||
if ( temp.equals(dirPath) ) {
|
||||
return;
|
||||
}
|
||||
dirPath = temp;
|
||||
|
||||
File dir = new File(dirPath);
|
||||
if ( !dir.exists() || !dir.isDirectory() ) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
file = new File(dir, name + ".log");
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された日付のログファイル名を生成して返します。
|
||||
* @param date 日付
|
||||
* @return ログファイル名
|
||||
*/
|
||||
private String getFolderPath(Date date) {
|
||||
|
||||
return LunaChat.getDataFolder() +
|
||||
File.separator + "logs" +
|
||||
File.separator + dformat.format(date);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
/**
|
||||
* LunaChatの動作モード
|
||||
* @author ucchy
|
||||
*/
|
||||
public enum LunaChatMode {
|
||||
BUKKIT,
|
||||
BUNGEE,
|
||||
STANDALONE,
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.github.ucchyocean.lc3.channel.ChannelManager;
|
||||
|
||||
/**
|
||||
* LunaChatのスタンドアロンサーバー
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatStandalone implements PluginInterface {
|
||||
|
||||
private LunaChatConfig config;
|
||||
private ChannelManager manager;
|
||||
private UUIDCacheData uuidCacheData;
|
||||
private File dataFolder;
|
||||
|
||||
public LunaChatStandalone(File dataFolder) {
|
||||
this.dataFolder = dataFolder;
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
LunaChat.setPlugin(this);
|
||||
LunaChat.setMode(LunaChatMode.STANDALONE);
|
||||
|
||||
// 初期化
|
||||
manager = new ChannelManager();
|
||||
|
||||
// コンフィグ取得
|
||||
config = new LunaChatConfig(getDataFolder(), getPluginJarFile());
|
||||
|
||||
// UUIDキャッシュデータ
|
||||
uuidCacheData = new UUIDCacheData(getDataFolder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getPluginJarFile() {
|
||||
try {
|
||||
return new File(LunaChatStandalone.class
|
||||
.getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LunaChatConfig getLunaChatConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LunaChatAPI getLunaChatAPI() {
|
||||
return manager ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
return dataFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LunaChatLogger getNormalChatLogger() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインのプレイヤー名一覧を取得する
|
||||
* @return オンラインのプレイヤー名一覧
|
||||
*/
|
||||
public Set<String> getOnlinePlayerNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Level level, String msg) {
|
||||
// 画面に表示する
|
||||
System.out.println(String.format("[%s]%s", level.toString(), msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* UUIDキャッシュデータを取得する
|
||||
* @return UUIDキャッシュデータ
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getUUIDCacheData()
|
||||
*/
|
||||
@Override
|
||||
public UUIDCacheData getUUIDCacheData() {
|
||||
return uuidCacheData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 非同期タスクを実行する
|
||||
* @param task タスク
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#runAsyncTask(java.lang.Runnable)
|
||||
*/
|
||||
@Override
|
||||
public void runAsyncTask(Runnable task) {
|
||||
new Thread(task).start();
|
||||
}
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
+3
-3
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@ public enum NGWordAction {
|
||||
|
||||
/** マスクするのみ */
|
||||
MASK("mask"),
|
||||
|
||||
|
||||
/** マスクしつつ、チャンネルからMuteする */
|
||||
MUTE("mute"),
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* プラグインインターフェイス
|
||||
* @author ucchy
|
||||
*/
|
||||
public interface PluginInterface {
|
||||
|
||||
/**
|
||||
* このプラグインのJarファイル自身を示すFileクラスを返す。
|
||||
* @return Jarファイル
|
||||
*/
|
||||
public File getPluginJarFile();
|
||||
|
||||
/**
|
||||
* LunaChatConfigを取得する
|
||||
* @return LunaChatConfig
|
||||
*/
|
||||
public LunaChatConfig getLunaChatConfig();
|
||||
|
||||
/**
|
||||
* LunaChatAPIを取得する
|
||||
* @return LunaChatAPI
|
||||
*/
|
||||
public LunaChatAPI getLunaChatAPI();
|
||||
|
||||
/**
|
||||
* プラグインのデータ格納フォルダを取得する
|
||||
* @return データ格納フォルダ
|
||||
*/
|
||||
public File getDataFolder();
|
||||
|
||||
/**
|
||||
* 通常チャット用のロガーを返す
|
||||
* @return normalChatLogger
|
||||
*/
|
||||
public LunaChatLogger getNormalChatLogger();
|
||||
|
||||
/**
|
||||
* オンラインのプレイヤー名一覧を取得する
|
||||
* @return オンラインのプレイヤー名一覧
|
||||
*/
|
||||
public Set<String> getOnlinePlayerNames();
|
||||
|
||||
/**
|
||||
* このプラグインのログを記録する
|
||||
* @param level ログレベル
|
||||
* @param msg ログメッセージ
|
||||
*/
|
||||
public void log(Level level, String msg);
|
||||
|
||||
/**
|
||||
* UUIDキャッシュデータを取得する
|
||||
* @return UUIDキャッシュデータ
|
||||
*/
|
||||
public UUIDCacheData getUUIDCacheData();
|
||||
|
||||
/**
|
||||
* 非同期タスクを実行する
|
||||
* @param task タスク
|
||||
*/
|
||||
public void runAsyncTask(Runnable task);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.github.ucchyocean.lc3.util.YamlConfig;
|
||||
|
||||
/**
|
||||
* UUIDのキャッシュデータを管理するクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class UUIDCacheData {
|
||||
|
||||
private static final String FILE_NAME = "uuidcache.yml";
|
||||
|
||||
// キャッシュデータ key=UUID文字列、value=プレイヤー名
|
||||
private YamlConfig cache;
|
||||
|
||||
private File dataFolder;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param dataFolder プラグインのデータ格納フォルダ
|
||||
*/
|
||||
public UUIDCacheData(File dataFolder) {
|
||||
cache = new YamlConfig();
|
||||
this.dataFolder = dataFolder;
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* キャッシュデータを読み込む
|
||||
*/
|
||||
public void reload() {
|
||||
File file = new File(dataFolder, FILE_NAME);
|
||||
if ( !file.exists() ) {
|
||||
// キャッシュファイルがまだ無いなら、からファイルを作成しておく。
|
||||
cache = new YamlConfig();
|
||||
try {
|
||||
cache.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
}
|
||||
cache = YamlConfig.load(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* キャッシュデータをファイルに保存する
|
||||
*/
|
||||
public void save() {
|
||||
File file = new File(dataFolder, FILE_NAME);
|
||||
try {
|
||||
cache.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのUUIDとプレイヤー名を追加する。
|
||||
* @param uuid UUID
|
||||
* @param name プレイヤー名
|
||||
*/
|
||||
public void put(String uuid, String name) {
|
||||
cache.set(uuid, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのUUIDからプレイヤー名を取得する。
|
||||
* @param uuid UUID
|
||||
* @return プレイヤー名(キャッシュされていない場合はnullが返される)
|
||||
*/
|
||||
public @Nullable String get(String uuid) {
|
||||
return cache.getString(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤー名からUUIDを取得する
|
||||
* @param name プレイヤー名
|
||||
* @return UUID(キャッシュされていない場合はnullが返される)
|
||||
*/
|
||||
public @Nullable String getUUIDFromName(String name) {
|
||||
if ( name == null ) return null;
|
||||
for ( String uuid : cache.getKeys(false) ) {
|
||||
String n = cache.getString(uuid);
|
||||
if ( name.equalsIgnoreCase(n) ) {
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* @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.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* BungeePerms連携クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BungeePermsBridge {
|
||||
|
||||
// コンストラクタは外から利用不可
|
||||
private BungeePermsBridge() {
|
||||
}
|
||||
|
||||
/**
|
||||
* BungeePermsをロードする
|
||||
* @param plugin BungeePermsのインスタンス
|
||||
* @return ロードされたBungeePermsBridge
|
||||
*/
|
||||
public static BungeePermsBridge load(Plugin plugin) {
|
||||
|
||||
// BungeePermsが指定されたかどうかを確認
|
||||
boolean loaded = (plugin != 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);
|
||||
}
|
||||
}
|
||||
+19
-18
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.bridge;
|
||||
package com.github.ucchyocean.lc3.bridge;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -12,10 +12,10 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.DynmapWebChatEvent;
|
||||
|
||||
import com.github.ucchyocean.lc.Channel;
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc3.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
|
||||
/**
|
||||
* dynmap連携クラス
|
||||
@@ -55,47 +55,48 @@ public class DynmapBridge implements Listener {
|
||||
|
||||
dynmap.postPlayerMessageToWeb(player, message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* dynmapにブロードキャストメッセージを流す
|
||||
* @param message メッセージ
|
||||
*/
|
||||
public void broadcast(String message) {
|
||||
|
||||
|
||||
dynmap.sendBroadcastToWeb(null, message);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DynmapのWebUIからチャット発言されたときのイベント
|
||||
* @param event
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDynmapWebChat(DynmapWebChatEvent event) {
|
||||
|
||||
LunaChatAPI api = LunaChat.instance.getLunaChatAPI();
|
||||
LunaChatConfig config = LunaChat.instance.getLunaChatConfig();
|
||||
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
String dchannel = config.getDynmapChannel();
|
||||
Channel channel = null;
|
||||
|
||||
|
||||
if ( !dchannel.equals("") ) {
|
||||
// dynmapChannelが設定されている場合
|
||||
channel = api.getChannel(dchannel);
|
||||
|
||||
|
||||
} else {
|
||||
String gchannel = config.getGlobalChannel();
|
||||
if ( !gchannel.equals("") ) {
|
||||
// dynmapChannelが設定されていなくて、
|
||||
// globalChannelが設定されている場合
|
||||
channel = api.getChannel(gchannel);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( channel != null ) {
|
||||
// チャンネルへ送信
|
||||
channel.chatFromOtherSource(
|
||||
event.getName(), event.getSource(), event.getMessage());
|
||||
event.setProcessed();
|
||||
event.setProcessed();
|
||||
dynmap.sendBroadcastToWeb(null, event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bridge;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* LuckPerms連携クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LuckPermsBridge {
|
||||
|
||||
private LuckPerms api;
|
||||
|
||||
// コンストラクタは外から利用不可
|
||||
private LuckPermsBridge(LuckPerms api) {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
/**
|
||||
* LuckPermsをロードする
|
||||
* @param plugin LuckPermsのインスタンス
|
||||
* @return ロードされたLuckPermsBridge
|
||||
*/
|
||||
public static LuckPermsBridge load(Plugin plugin) {
|
||||
|
||||
// LuckPermsが指定されたかどうかを確認
|
||||
if ( plugin == null ) return null;
|
||||
|
||||
// ロードされているならLuckPermsBridgeのインスタンスを作成して返す
|
||||
return new LuckPermsBridge(LuckPermsProvider.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのprefixを取得します。
|
||||
* @param uniqueId プレイヤーのUUID
|
||||
* @return プレイヤーのprefix
|
||||
*/
|
||||
public String getPlayerPrefix(UUID uniqueId) {
|
||||
User user = api.getUserManager().getUser(uniqueId);
|
||||
String prefix = user.getCachedData().getMetaData().getPrefix();
|
||||
return (prefix != null) ? prefix : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのsuffixを取得します。
|
||||
* @param uniqueId プレイヤーのUUID
|
||||
* @return プレイヤーのsuffix
|
||||
*/
|
||||
public String getPlayerSuffix(UUID uniqueId) {
|
||||
User user = api.getUserManager().getUser(uniqueId);
|
||||
String suffix = user.getCachedData().getMetaData().getSuffix();
|
||||
return (suffix != null) ? suffix : "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bridge;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc3.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc3.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc3.bukkit.BukkitRecipientChatJapanizeTask;
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
import com.gmail.nossr50.api.PartyAPI;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
|
||||
/**
|
||||
* mcMMO連携クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class McMMOBridge implements Listener {
|
||||
|
||||
/**
|
||||
* mcMMOのパーティチャットが発生したときのイベント
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler
|
||||
public void onMcMMOPartyChatEvent(McMMOPartyChatEvent event) {
|
||||
|
||||
// mcMMOから、パーティのメンバーを取得する
|
||||
List<Player> recipients = PartyAPI.getOnlineMembers(event.getParty());
|
||||
|
||||
String message = event.getMessage();
|
||||
ChannelMember player = ChannelMember.getChannelMember(event.getSender());
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
// NGワード発言をマスク
|
||||
for ( Pattern pattern : config.getNgwordCompiled() ) {
|
||||
Matcher matcher = pattern.matcher(message);
|
||||
if ( matcher.find() ) {
|
||||
message = matcher.replaceAll(
|
||||
Utility.getAstariskString(matcher.group(0).length()));
|
||||
}
|
||||
}
|
||||
|
||||
// カラーコード置き換え
|
||||
// 置き換え設定になっていて、発言者がパーミッションを持っているなら、置き換えする
|
||||
if ( config.isEnableNormalChatColorCode() &&
|
||||
player.hasPermission("lunachat.allowcc") ) {
|
||||
message = Utility.replaceColorCode(message);
|
||||
}
|
||||
|
||||
// 一時的にJapanizeスキップ設定かどうかを確認する
|
||||
boolean skipJapanize = false;
|
||||
String marker = config.getNoneJapanizeMarker();
|
||||
if ( !marker.equals("") && message.startsWith(marker) ) {
|
||||
skipJapanize = true;
|
||||
message = message.substring(marker.length());
|
||||
}
|
||||
|
||||
// 2byteコードを含むなら、Japanize変換は行わない
|
||||
String kanaTemp = Utility.stripColorCode(message);
|
||||
if ( !skipJapanize &&
|
||||
( kanaTemp.getBytes(StandardCharsets.UTF_8).length > kanaTemp.length() ||
|
||||
kanaTemp.matches("[ \\uFF61-\\uFF9F]+") ) ) {
|
||||
skipJapanize = true;
|
||||
}
|
||||
|
||||
// Japanize変換と、発言処理
|
||||
if ( !skipJapanize &&
|
||||
LunaChat.getAPI().isPlayerJapanize(player.getName()) &&
|
||||
config.getJapanizeType() != JapanizeType.NONE ) {
|
||||
|
||||
int lineType = config.getJapanizeDisplayLine();
|
||||
|
||||
if ( lineType == 1 ) {
|
||||
|
||||
String taskFormat = Utility.replaceColorCode(config.getJapanizeLine1Format());
|
||||
|
||||
String japanized = api.japanize(
|
||||
kanaTemp, config.getJapanizeType());
|
||||
if ( japanized != null ) {
|
||||
String temp = taskFormat.replace("%msg", message);
|
||||
message = temp.replace("%japanize", japanized);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
String taskFormat = Utility.replaceColorCode(config.getJapanizeLine2Format());
|
||||
|
||||
BukkitRecipientChatJapanizeTask task = new BukkitRecipientChatJapanizeTask(
|
||||
message, config.getJapanizeType(), player, taskFormat, recipients);
|
||||
|
||||
// 発言処理を必ず先に実施させるため、遅延を入れてタスクを実行する。
|
||||
int wait = config.getJapanizeWait();
|
||||
task.runTaskLater(LunaChatBukkit.getInstance(), wait);
|
||||
}
|
||||
}
|
||||
|
||||
// 発言内容の設定
|
||||
event.setMessage(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bridge;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
|
||||
/**
|
||||
* MultiverseCore連携クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class MultiverseCoreBridge {
|
||||
|
||||
/** MultiverseCore API クラス */
|
||||
private Core mvc;
|
||||
|
||||
/** コンストラクタは使用不可 */
|
||||
private MultiverseCoreBridge() {
|
||||
}
|
||||
|
||||
/**
|
||||
* MultiverseCore-apiをロードする
|
||||
* @param plugin MultiverseCoreのプラグインインスタンス
|
||||
* @param ロードしたかどうか
|
||||
*/
|
||||
public static MultiverseCoreBridge load(Plugin plugin) {
|
||||
|
||||
if ( plugin instanceof MultiverseCore ) {
|
||||
MultiverseCoreBridge bridge = new MultiverseCoreBridge();
|
||||
bridge.mvc = (Core)plugin;
|
||||
return bridge;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたワールドのエイリアス名を取得する
|
||||
* @param worldName ワールド名
|
||||
* @return エイリアス名、取得できない場合はnullが返される
|
||||
*/
|
||||
public String getWorldAlias(String worldName) {
|
||||
|
||||
MultiverseWorld mvworld = mvc.getMVWorldManager().getMVWorld(worldName);
|
||||
if ( mvworld != null ) {
|
||||
return mvworld.getColoredWorldString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたワールドのエイリアス名を取得する
|
||||
* @param world ワールド
|
||||
* @return エイリアス名、取得できない場合はnullが返される
|
||||
*/
|
||||
public String getWorldAlias(World world) {
|
||||
|
||||
MultiverseWorld mvworld = mvc.getMVWorldManager().getMVWorld(world);
|
||||
if ( mvworld != null ) {
|
||||
return mvworld.getColoredWorldString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-14
@@ -1,18 +1,17 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.bridge;
|
||||
|
||||
import net.milkbowl.vault.Vault;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
package com.github.ucchyocean.lc3.bridge;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
|
||||
/**
|
||||
* Vault-Chat連携クラス
|
||||
* @author ucchy
|
||||
@@ -29,18 +28,16 @@ public class VaultChatBridge {
|
||||
/**
|
||||
* vault-chatをロードする
|
||||
* @param plugin vaultのプラグインインスタンス
|
||||
* @param ロードしたかどうか
|
||||
* @return ロードしたブリッジのインスタンス
|
||||
*/
|
||||
public static VaultChatBridge load(Plugin plugin) {
|
||||
|
||||
if ( plugin instanceof Vault ) {
|
||||
RegisteredServiceProvider<Chat> chatProvider =
|
||||
Bukkit.getServicesManager().getRegistration(Chat.class);
|
||||
if ( chatProvider != null ) {
|
||||
VaultChatBridge bridge = new VaultChatBridge();
|
||||
bridge.chatPlugin = chatProvider.getProvider();
|
||||
return bridge;
|
||||
}
|
||||
RegisteredServiceProvider<Chat> chatProvider =
|
||||
Bukkit.getServicesManager().getRegistration(Chat.class);
|
||||
if ( chatProvider != null ) {
|
||||
VaultChatBridge bridge = new VaultChatBridge();
|
||||
bridge.chatPlugin = chatProvider.getProvider();
|
||||
return bridge;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -0,0 +1,571 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc3.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc3.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.event.EventResult;
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBukkit;
|
||||
import com.github.ucchyocean.lc3.util.ClickableFormat;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* Bukkit関連のイベントを監視するリスナ
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BukkitEventListener implements Listener {
|
||||
|
||||
private static final int MAX_LIST_ITEMS = 8;
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.LOWEST, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatLowest(AsyncPlayerChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.LOWEST) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.LOW, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatLow(AsyncPlayerChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.LOW) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.NORMAL, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatNormal(AsyncPlayerChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.NORMAL) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatHigh(AsyncPlayerChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.HIGH) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatHighest(AsyncPlayerChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.HIGHEST) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのサーバー参加ごとに呼び出されるメソッド
|
||||
* @param event プレイヤー参加イベント
|
||||
*/
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// UUIDをキャッシュ
|
||||
LunaChat.getUUIDCacheData().put(player.getUniqueId().toString(), player.getName());
|
||||
LunaChat.getUUIDCacheData().save();
|
||||
|
||||
// 強制参加チャンネル設定を確認し、参加させる
|
||||
forceJoinToForceJoinChannels(player);
|
||||
|
||||
// グローバルチャンネル設定がある場合
|
||||
if ( !config.getGlobalChannel().equals("") ) {
|
||||
tryJoinToGlobalChannel(player);
|
||||
}
|
||||
|
||||
// チャンネルチャット情報を表示する
|
||||
if ( config.isShowListOnJoin() ) {
|
||||
for ( BaseComponent[] msg : getListForMotd(player) ) {
|
||||
ChannelMember.getChannelMember(player).sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのサーバー退出ごとに呼び出されるメソッド
|
||||
* @param event プレイヤー退出イベント
|
||||
*/
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String pname = player.getName();
|
||||
|
||||
// お互いがオフラインになるPMチャンネルがある場合は
|
||||
// チャンネルをクリアする
|
||||
ArrayList<Channel> deleteList = new ArrayList<Channel>();
|
||||
|
||||
for ( Channel channel : LunaChat.getAPI().getChannels() ) {
|
||||
String cname = channel.getName();
|
||||
if ( channel.isPersonalChat() && cname.contains(pname) ) {
|
||||
boolean isAllOffline = true;
|
||||
for ( ChannelMember cp : channel.getMembers() ) {
|
||||
if ( cp.isOnline() ) {
|
||||
isAllOffline = false;
|
||||
}
|
||||
}
|
||||
if ( isAllOffline ) {
|
||||
deleteList.add(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( Channel channel : deleteList ) {
|
||||
LunaChat.getAPI().removeChannel(channel.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのチャットごとに呼び出されるメソッド
|
||||
* @param event チャットイベント
|
||||
*/
|
||||
private void processChatEvent(AsyncPlayerChatEvent event) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
// 頭にglobalMarkerが付いている場合は、グローバル発言にする
|
||||
if ( config.getGlobalMarker() != null &&
|
||||
!config.getGlobalMarker().equals("") &&
|
||||
event.getMessage().startsWith(config.getGlobalMarker()) &&
|
||||
event.getMessage().length() > config.getGlobalMarker().length() ) {
|
||||
|
||||
int offset = config.getGlobalMarker().length();
|
||||
event.setMessage( event.getMessage().substring(offset) );
|
||||
chatGlobal(event);
|
||||
return;
|
||||
}
|
||||
|
||||
// クイックチャンネルチャット機能が有効で、専用の記号が含まれるなら、
|
||||
// クイックチャンネルチャットとして処理する。
|
||||
if ( config.isEnableQuickChannelChat() ) {
|
||||
String separator = config.getQuickChannelChatSeparator();
|
||||
if ( event.getMessage().contains(separator) ) {
|
||||
String[] temp = event.getMessage().split(separator, 2);
|
||||
String name = temp[0];
|
||||
String value = "";
|
||||
if ( temp.length > 0 ) {
|
||||
value = temp[1];
|
||||
}
|
||||
|
||||
Channel channel = api.getChannel(name);
|
||||
if ( channel != null && !channel.isPersonalChat() ) {
|
||||
ChannelMember player =
|
||||
ChannelMember.getChannelMember(event.getPlayer());
|
||||
if ( !channel.getMembers().contains(player) ) {
|
||||
// 指定されたチャンネルに参加していないなら、エラーを表示して何も発言せずに終了する。
|
||||
event.getPlayer().sendMessage(Messages.errmsgNomember());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 指定されたチャンネルに発言して終了する。
|
||||
chatToChannelWithEvent(player, channel, value);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ChannelMember player =
|
||||
ChannelMember.getChannelMember(event.getPlayer());
|
||||
Channel channel = api.getDefaultChannel(player.getName());
|
||||
|
||||
// デフォルトの発言先が無い場合
|
||||
if ( channel == null ) {
|
||||
if ( config.isNoJoinAsGlobal() ) {
|
||||
// グローバル発言にする
|
||||
chatGlobal(event);
|
||||
return;
|
||||
|
||||
} else {
|
||||
// 発言をキャンセルして終了する
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
chatToChannelWithEvent(player, channel, event.getMessage());
|
||||
|
||||
// もとのイベントをキャンセル
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* イベントをグローバルチャット発言として処理する
|
||||
* @param event 処理するイベント
|
||||
*/
|
||||
private void chatGlobal(AsyncPlayerChatEvent event) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
ChannelMember player =
|
||||
ChannelMember.getChannelMember(event.getPlayer());
|
||||
|
||||
if ( !config.getGlobalChannel().equals("") ) {
|
||||
// グローバルチャンネル設定がある場合
|
||||
|
||||
// グローバルチャンネルの取得、無ければ作成
|
||||
Channel global = api.getChannel(config.getGlobalChannel());
|
||||
if ( global == null ) {
|
||||
global = api.createChannel(config.getGlobalChannel());
|
||||
}
|
||||
|
||||
// LunaChatPreChatEvent イベントコール
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatPreChatEvent(
|
||||
global.getName(), player, event.getMessage());
|
||||
if ( result.isCancelled() ) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Channel alt = result.getChannel();
|
||||
if ( alt != null ) {
|
||||
global = alt;
|
||||
}
|
||||
String message = result.getMessage();
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
Channel dchannel = api.getDefaultChannel(player.getName());
|
||||
if ( dchannel == null ) {
|
||||
api.setDefaultChannel(player.getName(), global.getName());
|
||||
}
|
||||
|
||||
// チャンネルチャット発言
|
||||
chatToChannelWithEvent(player, global, message);
|
||||
|
||||
// もとのイベントをキャンセル
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
|
||||
} else {
|
||||
// グローバルチャンネル設定が無い場合
|
||||
|
||||
String message = event.getMessage();
|
||||
// NGワード発言をマスク
|
||||
for ( Pattern pattern : config.getNgwordCompiled() ) {
|
||||
Matcher matcher = pattern.matcher(message);
|
||||
if ( matcher.find() ) {
|
||||
message = matcher.replaceAll(
|
||||
Utility.getAstariskString(matcher.group(0).length()));
|
||||
}
|
||||
}
|
||||
|
||||
// チャットフォーマット装飾の適用
|
||||
ClickableFormat format;
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
String f = config.getNormalChatMessageFormat();
|
||||
format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
// event.setFormat(format);
|
||||
} else {
|
||||
String f = event.getFormat()
|
||||
.replace("%1$s", "%displayName")
|
||||
.replace("%2$s", "%msg");
|
||||
format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
}
|
||||
|
||||
// カラーコード置き換え
|
||||
// 置き換え設定になっていて、発言者がパーミッションを持っているなら、置き換えする
|
||||
if ( config.isEnableNormalChatColorCode() &&
|
||||
event.getPlayer().hasPermission("lunachat.allowcc") ) {
|
||||
message = Utility.replaceColorCode(message);
|
||||
}
|
||||
|
||||
// hideされているプレイヤーを、recipientから抜く
|
||||
for ( ChannelMember cp : api.getHidelist(player) ) {
|
||||
Player p = ((ChannelMemberBukkit)cp).getPlayer();
|
||||
if ( p != null ) {
|
||||
event.getRecipients().remove(p);
|
||||
}
|
||||
}
|
||||
|
||||
// 一時的にJapanizeスキップ設定かどうかを確認する
|
||||
boolean skipJapanize = false;
|
||||
String marker = config.getNoneJapanizeMarker();
|
||||
if ( !marker.equals("") && message.startsWith(marker) ) {
|
||||
skipJapanize = true;
|
||||
message = message.substring(marker.length());
|
||||
}
|
||||
|
||||
// 2byteコードを含む、または、半角カタカナのみなら、Japanize変換は行わない
|
||||
String kanaTemp = Utility.stripColorCode(message);
|
||||
if ( !skipJapanize &&
|
||||
( kanaTemp.getBytes(StandardCharsets.UTF_8).length > kanaTemp.length() ||
|
||||
kanaTemp.matches("[ \\uFF61-\\uFF9F]+") ) ) {
|
||||
skipJapanize = true;
|
||||
}
|
||||
|
||||
// Japanize変換と、発言処理
|
||||
if ( !skipJapanize &&
|
||||
LunaChat.getAPI().isPlayerJapanize(player.getName()) &&
|
||||
config.getJapanizeType() != JapanizeType.NONE ) {
|
||||
|
||||
int lineType = config.getJapanizeDisplayLine();
|
||||
|
||||
if ( lineType == 1 ) {
|
||||
|
||||
String taskFormat = Utility.replaceColorCode(config.getJapanizeLine1Format());
|
||||
|
||||
String japanized = api.japanize(
|
||||
kanaTemp, config.getJapanizeType());
|
||||
if ( japanized != null ) {
|
||||
String temp = taskFormat.replace("%msg", message);
|
||||
message = temp.replace("%japanize", japanized);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
String taskFormat = Utility.replaceColorCode(config.getJapanizeLine2Format());
|
||||
|
||||
BukkitNormalChatJapanizeTask task = new BukkitNormalChatJapanizeTask(
|
||||
message, config.getJapanizeType(), player, taskFormat, event);
|
||||
|
||||
// 発言処理を必ず先に実施させるため、遅延を入れてタスクを実行する。
|
||||
int wait = config.getJapanizeWait();
|
||||
task.runTaskLater(LunaChatBukkit.getInstance(), wait);
|
||||
}
|
||||
}
|
||||
|
||||
// 発言内容の設定
|
||||
// event.setMessage(message);
|
||||
|
||||
// 発言内容の送信
|
||||
format.replace("%msg", message);
|
||||
BaseComponent[] comps = format.makeTextComponent();
|
||||
for ( Player recipient : event.getRecipients() ) {
|
||||
ChannelMember cm = ChannelMember.getChannelMember(recipient);
|
||||
if ( cm != null ) {
|
||||
cm.sendMessage(comps);
|
||||
}
|
||||
}
|
||||
|
||||
// イベントのキャンセル
|
||||
event.setCancelled(true);
|
||||
|
||||
// ロギング
|
||||
logNormalChat(message, player.getName());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 既定のチャンネルへの参加を試みる。
|
||||
* @param player プレイヤー
|
||||
* @return 参加できたかどうか
|
||||
*/
|
||||
private boolean tryJoinToGlobalChannel(Player player) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
String gcName = config.getGlobalChannel();
|
||||
|
||||
// チャンネルが存在しない場合は作成する
|
||||
Channel global = api.getChannel(gcName);
|
||||
if ( global == null ) {
|
||||
global = api.createChannel(gcName);
|
||||
}
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
Channel dchannel = api.getDefaultChannel(player.getName());
|
||||
if ( dchannel == null ) {
|
||||
api.setDefaultChannel(player.getName(), gcName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 強制参加チャンネルへ参加させる
|
||||
* @param player プレイヤー
|
||||
*/
|
||||
private void forceJoinToForceJoinChannels(Player player) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
List<String> forceJoinChannels = config.getForceJoinChannels();
|
||||
|
||||
for ( String cname : forceJoinChannels ) {
|
||||
|
||||
// チャンネルが存在しない場合は作成する
|
||||
Channel channel = api.getChannel(cname);
|
||||
if ( channel == null ) {
|
||||
channel = api.createChannel(cname);
|
||||
}
|
||||
|
||||
// チャンネルのメンバーでないなら、参加する
|
||||
ChannelMember cp = ChannelMember.getChannelMember(player);
|
||||
if ( !channel.getMembers().contains(cp) ) {
|
||||
channel.addMember(cp);
|
||||
}
|
||||
|
||||
// デフォルト発言先が無いなら、デフォルトチャンネルに設定する
|
||||
Channel dchannel = api.getDefaultChannel(player.getName());
|
||||
if ( dchannel == null ) {
|
||||
api.setDefaultChannel(player.getName(), cname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのサーバー参加時用の参加チャンネルリストを返す
|
||||
* @param player プレイヤー
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<BaseComponent[]> getListForMotd(Player player) {
|
||||
|
||||
ChannelMember cp = ChannelMember.getChannelMember(player);
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
Channel dc = api.getDefaultChannel(cp.getName());
|
||||
String dchannel = "";
|
||||
if ( dc != null ) {
|
||||
dchannel = dc.getName().toLowerCase();
|
||||
}
|
||||
|
||||
// チャンネル一覧を取得して、参加人数でソートする
|
||||
ArrayList<Channel> channels = new ArrayList<>(api.getChannels());
|
||||
Collections.sort(channels, new Comparator<Channel>() {
|
||||
public int compare(Channel c1, Channel c2) {
|
||||
if ( c1.getOnlineNum() == c2.getOnlineNum() ) return c1.getName().compareTo(c2.getName());
|
||||
return c2.getOnlineNum() - c1.getOnlineNum();
|
||||
}
|
||||
});
|
||||
|
||||
int count = 0;
|
||||
ArrayList<BaseComponent[]> items = new ArrayList<>();
|
||||
items.add(TextComponent.fromLegacyText(Messages.motdFirstLine()));
|
||||
for ( Channel channel : channels ) {
|
||||
|
||||
// BANされているチャンネルは表示しない
|
||||
if ( channel.getBanned().contains(cp) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットはリストに表示しない
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 参加していないチャンネルは、グローバルチャンネルを除き表示しない
|
||||
if ( !channel.getMembers().contains(cp) &&
|
||||
!channel.isGlobalChannel() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String disp = ChatColor.WHITE + channel.getName();
|
||||
if ( channel.getName().equals(dchannel) ) {
|
||||
disp = ChatColor.RED + channel.getName();
|
||||
}
|
||||
String desc = channel.getDescription();
|
||||
int onlineNum = channel.getOnlineNum();
|
||||
int memberNum = channel.getTotalNum();
|
||||
items.add(Messages.listFormat(disp, onlineNum, memberNum, desc));
|
||||
count++;
|
||||
|
||||
if ( count > MAX_LIST_ITEMS ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
items.add(TextComponent.fromLegacyText(Messages.listEndLine()));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルに発言処理を行う
|
||||
* @param player プレイヤー
|
||||
* @param channel チャンネル
|
||||
* @param message 発言内容
|
||||
* @return イベントでキャンセルされたかどうか
|
||||
*/
|
||||
private boolean chatToChannelWithEvent(ChannelMember player, Channel channel, String message) {
|
||||
|
||||
// LunaChatPreChatEvent イベントコール
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatPreChatEvent(
|
||||
channel.getName(), player, message);
|
||||
if ( result.isCancelled() ) {
|
||||
return true;
|
||||
}
|
||||
Channel alt = result.getChannel();
|
||||
if ( alt != null ) {
|
||||
channel = alt;
|
||||
}
|
||||
message = result.getMessage();
|
||||
|
||||
// チャンネルチャット発言
|
||||
channel.chat(player, message);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャットの発言をログファイルへ記録する
|
||||
* @param message
|
||||
* @param player
|
||||
*/
|
||||
private void logNormalChat(String message, String player) {
|
||||
LunaChat.getNormalChatLogger().log(message, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたEventPriorityが、LunaChatConfigで指定されているEventPriorityと一致するかどうかを調べる
|
||||
* @param priority
|
||||
* @return 一致するかどうか
|
||||
*/
|
||||
private boolean matchesEventPriority(EventPriority priority) {
|
||||
String c = LunaChat.getConfig().getPlayerChatEventListenerPriority().name();
|
||||
return c.equals(priority.name());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerBlock;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerConsole;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerName;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerUUID;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelChatEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelCreateEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelMemberChangedEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelMessageEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelOptionChangedEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelRemoveEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatPostJapanizeEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatPreChatEvent;
|
||||
import com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitChannelChatEvent;
|
||||
import com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitChannelCreateEvent;
|
||||
import com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitChannelMemberChangedEvent;
|
||||
import com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitChannelMessageEvent;
|
||||
import com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitChannelOptionChangedEvent;
|
||||
import com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitChannelRemoveEvent;
|
||||
import com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitPostJapanizeEvent;
|
||||
import com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitPreChatEvent;
|
||||
import com.github.ucchyocean.lc3.event.EventResult;
|
||||
import com.github.ucchyocean.lc3.event.EventSenderInterface;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBlock;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBukkitConsole;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberBungee;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberPlayer;
|
||||
|
||||
/**
|
||||
* Bukkitのイベント実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BukkitEventSender implements EventSenderInterface {
|
||||
|
||||
/**
|
||||
* チャンネルチャットのチャットイベント
|
||||
* @param channelName チャンネル名
|
||||
* @param player 発言者
|
||||
* @param originalMessage 発言内容
|
||||
* @param ngMaskedMessage 発言内容(NGマスク後)
|
||||
* @param messageFormat 発言に適用されるフォーマット
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelChatEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelChatEvent(String channelName, ChannelMember member, String originalMessage,
|
||||
String ngMaskedMessage, String messageFormat) {
|
||||
|
||||
LunaChatBukkitChannelChatEvent event =
|
||||
new LunaChatBukkitChannelChatEvent(
|
||||
channelName, member, originalMessage, ngMaskedMessage, messageFormat);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
LunaChatChannelChatEvent legacy = new LunaChatChannelChatEvent(
|
||||
channelName, convertChannelMemberToChannelPlayer(member),
|
||||
originalMessage, event.getNgMaskedMessage(), event.getMessageFormat());
|
||||
legacy.setCancelled(event.isCancelled());
|
||||
Bukkit.getPluginManager().callEvent(legacy);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(legacy.isCancelled());
|
||||
result.setNgMaskedMessage(legacy.getNgMaskedMessage());
|
||||
result.setMessageFormat(legacy.getMessageFormat());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル作成イベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member 作成した人
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelCreateEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelCreateEvent(String channelName, ChannelMember member) {
|
||||
|
||||
LunaChatBukkitChannelCreateEvent event =
|
||||
new LunaChatBukkitChannelCreateEvent(channelName, member);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
LunaChatChannelCreateEvent legacy = new LunaChatChannelCreateEvent(
|
||||
event.getChannelName(), convertChannelMemberToCommandSender(member));
|
||||
legacy.setCancelled(event.isCancelled());
|
||||
Bukkit.getPluginManager().callEvent(legacy);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(legacy.isCancelled());
|
||||
result.setChannelName(legacy.getChannelName());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* メンバー変更イベント
|
||||
* @param channelName チャンネル名
|
||||
* @param before 変更前のメンバー
|
||||
* @param after 変更後のメンバー
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelMemberChangedEvent(java.lang.String, java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelMemberChangedEvent(String channelName, List<ChannelMember> before,
|
||||
List<ChannelMember> after) {
|
||||
|
||||
LunaChatBukkitChannelMemberChangedEvent event =
|
||||
new LunaChatBukkitChannelMemberChangedEvent(channelName, before, after);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
LunaChatChannelMemberChangedEvent legacy =
|
||||
new LunaChatChannelMemberChangedEvent(channelName,
|
||||
convertMemberListToPlayerList(before), convertMemberListToPlayerList(after));
|
||||
legacy.setCancelled(event.isCancelled());
|
||||
Bukkit.getPluginManager().callEvent(legacy);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(event.isCancelled());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットのメッセージイベント。このイベントはキャンセルできない。
|
||||
* @param channelName チャンネル名
|
||||
* @param member 発言者
|
||||
* @param message 発言内容(NGマスクやJapanizeされた後の内容)
|
||||
* @param recipients 受信者
|
||||
* @param displayName 発言者の表示名
|
||||
* @param originalMessage 発言内容(元々の内容)
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelMessageEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String, java.util.ArrayList, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelMessageEvent(String channelName, ChannelMember member, String message,
|
||||
List<ChannelMember> recipients, String displayName, String originalMessage) {
|
||||
|
||||
LunaChatBukkitChannelMessageEvent event =
|
||||
new LunaChatBukkitChannelMessageEvent(
|
||||
channelName, member, message, recipients, displayName, originalMessage);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
ArrayList<ChannelPlayer> recipientsTemp =
|
||||
new ArrayList<ChannelPlayer>(convertMemberListToPlayerList(event.getRecipients()));
|
||||
LunaChatChannelMessageEvent legacy =
|
||||
new LunaChatChannelMessageEvent(
|
||||
channelName, convertChannelMemberToChannelPlayer(member),
|
||||
event.getMessage(), recipientsTemp, displayName, originalMessage);
|
||||
Bukkit.getPluginManager().callEvent(legacy);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setMessage(legacy.getMessage());
|
||||
result.setRecipients(convertPlayerListToMemberList(legacy.getRecipients()));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* オプション変更イベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member オプションを変更した人
|
||||
* @param options 変更後のオプション
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelOptionChangedEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.util.HashMap)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelOptionChangedEvent(String channelName, ChannelMember member,
|
||||
Map<String, String> options) {
|
||||
|
||||
LunaChatBukkitChannelOptionChangedEvent event =
|
||||
new LunaChatBukkitChannelOptionChangedEvent(channelName, member, options);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
LunaChatChannelOptionChangedEvent legacy =
|
||||
new LunaChatChannelOptionChangedEvent(
|
||||
channelName, convertChannelMemberToCommandSender(member),
|
||||
new HashMap<String, String>(options));
|
||||
legacy.setCancelled(event.isCancelled());
|
||||
Bukkit.getPluginManager().callEvent(legacy);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(legacy.isCancelled());
|
||||
result.setOptions(legacy.getOptions());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル削除イベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member 削除を実行した人
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelRemoveEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelRemoveEvent(String channelName, ChannelMember member) {
|
||||
|
||||
LunaChatBukkitChannelRemoveEvent event = new LunaChatBukkitChannelRemoveEvent(channelName, member);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
LunaChatChannelRemoveEvent legacy =
|
||||
new LunaChatChannelRemoveEvent(
|
||||
event.getChannelName(), convertChannelMemberToCommandSender(member));
|
||||
legacy.setCancelled(event.isCancelled());
|
||||
Bukkit.getPluginManager().callEvent(legacy);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(legacy.isCancelled());
|
||||
result.setChannelName(legacy.getChannelName());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換が行われた後に呼び出されるイベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member 発言したメンバー
|
||||
* @param original 変換前の文字列
|
||||
* @param japanized 変換後の文字列
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatPostJapanizeEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatPostJapanizeEvent(String channelName, ChannelMember member, String original,
|
||||
String japanized) {
|
||||
|
||||
LunaChatBukkitPostJapanizeEvent event =
|
||||
new LunaChatBukkitPostJapanizeEvent(channelName, member, original, japanized);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
LunaChatPostJapanizeEvent legacy =
|
||||
new LunaChatPostJapanizeEvent(
|
||||
channelName, convertChannelMemberToChannelPlayer(member), original, event.getJapanized());
|
||||
legacy.setCancelled(event.isCancelled());
|
||||
Bukkit.getPluginManager().callEvent(legacy);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(legacy.isCancelled());
|
||||
result.setJapanized(legacy.getJapanized());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットへの発言前に発生するイベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member 発言したメンバー
|
||||
* @param message 発言内容
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatPreChatEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatPreChatEvent(String channelName, ChannelMember member, String message) {
|
||||
|
||||
LunaChatBukkitPreChatEvent event =
|
||||
new LunaChatBukkitPreChatEvent(channelName, member, message);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
|
||||
LunaChatPreChatEvent legacy =
|
||||
new LunaChatPreChatEvent(channelName, convertChannelMemberToChannelPlayer(member), event.getMessage());
|
||||
legacy.setCancelled(event.isCancelled());
|
||||
Bukkit.getPluginManager().callEvent(legacy);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(legacy.isCancelled());
|
||||
result.setMessage(legacy.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelMemberをChannelPlayerに変換する
|
||||
* @param cm
|
||||
* @return
|
||||
*/
|
||||
private ChannelPlayer convertChannelMemberToChannelPlayer(ChannelMember cm) {
|
||||
if ( cm == null ) return null;
|
||||
if ( cm instanceof ChannelMemberBungee ) return null; // Bungeeモードの場合は変換できない
|
||||
if ( cm instanceof ChannelMemberPlayer ) {
|
||||
return ChannelPlayer.getChannelPlayer(cm.toString());
|
||||
} else if ( cm instanceof ChannelMemberBukkitConsole ) {
|
||||
return new ChannelPlayerConsole(Bukkit.getConsoleSender());
|
||||
} else if ( cm instanceof ChannelMemberBlock ) {
|
||||
ChannelMemberBlock cmb = (ChannelMemberBlock)cm;
|
||||
if ( cmb.getBlockCommandSender() != null ) {
|
||||
return new ChannelPlayerBlock(cmb.getBlockCommandSender());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelPlayerをChannelMemberに変換する
|
||||
* @param cp
|
||||
* @return
|
||||
*/
|
||||
private ChannelMember convertChannelPlayerToChannelMember(ChannelPlayer cp) {
|
||||
if ( cp == null ) return null;
|
||||
if ( cp instanceof ChannelPlayerName || cp instanceof ChannelPlayerUUID ) {
|
||||
return ChannelMember.getChannelMember(cp.toString());
|
||||
} else if ( cp instanceof ChannelPlayerConsole ) {
|
||||
return new ChannelMemberBukkitConsole(Bukkit.getConsoleSender());
|
||||
} else if ( cp instanceof ChannelPlayerBlock ) {
|
||||
ChannelPlayerBlock cpb = (ChannelPlayerBlock)cp;
|
||||
if ( cpb.getBlockCommandSender() != null ) {
|
||||
return new ChannelMemberBlock(cpb.getBlockCommandSender());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelMemberをCommandSenderに変換する
|
||||
* @param cm
|
||||
* @return
|
||||
*/
|
||||
private CommandSender convertChannelMemberToCommandSender(ChannelMember cm) {
|
||||
if ( cm == null ) return null;
|
||||
if ( cm instanceof ChannelMemberBungee ) return null; // Bungeeモードの場合は変換できない
|
||||
if ( cm instanceof ChannelMemberPlayer ) {
|
||||
return ((ChannelMemberPlayer)cm).getPlayer();
|
||||
} else if ( cm instanceof ChannelMemberBukkitConsole ) {
|
||||
return Bukkit.getConsoleSender();
|
||||
} else if ( cm instanceof ChannelMemberBlock ) {
|
||||
return ((ChannelMemberBlock)cm).getBlockCommandSender();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelMemberのリストをChannelPlayerのリストに変換する
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private List<ChannelPlayer> convertMemberListToPlayerList(List<ChannelMember> list) {
|
||||
List<ChannelPlayer> result = new ArrayList<ChannelPlayer>();
|
||||
for ( ChannelMember member : list ) {
|
||||
ChannelPlayer player = convertChannelMemberToChannelPlayer(member);
|
||||
if ( player != null ) result.add(player);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelPlayerのリストをChannelMemberのリストに変換する
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private List<ChannelMember> convertPlayerListToMemberList(List<ChannelPlayer> list) {
|
||||
List<ChannelMember> result = new ArrayList<ChannelMember>();
|
||||
for ( ChannelPlayer player : list ) {
|
||||
ChannelMember member = convertChannelPlayerToChannelMember(player);
|
||||
if ( member != null ) result.add(member);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc3.channel.JapanizeConvertTask;
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberPlayer;
|
||||
|
||||
/**
|
||||
* Japanize2行表示のときに、変換結果を遅延して通常チャットに表示するためのタスク
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BukkitNormalChatJapanizeTask extends BukkitRunnable {
|
||||
|
||||
private ChannelMember player;
|
||||
private AsyncPlayerChatEvent event;
|
||||
|
||||
private JapanizeConvertTask task;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param org 変換前の文字列
|
||||
* @param type 変換タイプ
|
||||
* @param player 発言したプレイヤー
|
||||
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
|
||||
* @param event イベント
|
||||
*/
|
||||
public BukkitNormalChatJapanizeTask(String org, JapanizeType type,
|
||||
ChannelMember player, String japanizeFormat, final AsyncPlayerChatEvent event) {
|
||||
|
||||
task = new JapanizeConvertTask(org, type, japanizeFormat, null, player);
|
||||
this.player = player;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if ( task.runSync() ) {
|
||||
|
||||
String result = task.getResult();
|
||||
|
||||
// 送信
|
||||
for ( Player p : event.getRecipients() ) {
|
||||
p.sendMessage(result);
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(result);
|
||||
|
||||
// 設定に応じてdynmapへ送信する
|
||||
if ( LunaChat.getConfig().isSendBroadcastChannelChatToDynmap() &&
|
||||
LunaChatBukkit.getInstance().getDynmap() != null ) {
|
||||
if ( player != null && player instanceof ChannelMemberPlayer
|
||||
&& ((ChannelMemberPlayer)player).getPlayer() != null )
|
||||
LunaChatBukkit.getInstance().getDynmap().chat(((ChannelMemberPlayer)player).getPlayer(), result);
|
||||
else
|
||||
LunaChatBukkit.getInstance().getDynmap().broadcast(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.github.ucchyocean.lc3.channel.JapanizeConvertTask;
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* Japanize2行表示のときに、変換結果を遅延して指定した受信者に表示するためのタスク。
|
||||
* 他プラグインのチャンネル(mcMMOのパーティチャットや、TownyChatなど)に、Japanize変換結果を表示するために使用する。
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BukkitRecipientChatJapanizeTask extends BukkitRunnable {
|
||||
|
||||
private List<Player> recipients;
|
||||
|
||||
private JapanizeConvertTask task;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param org 変換前の文字列
|
||||
* @param type 変換タイプ
|
||||
* @param player 発言したプレイヤー
|
||||
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
|
||||
* @param recipients メッセージ受信者
|
||||
*/
|
||||
public BukkitRecipientChatJapanizeTask(String org, JapanizeType type, ChannelMember player,
|
||||
String japanizeFormat, List<Player> recipients) {
|
||||
task = new JapanizeConvertTask(org, type, japanizeFormat, null, player);
|
||||
this.recipients = recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if ( task.runSync() ) {
|
||||
|
||||
String result = task.getResult();
|
||||
|
||||
// 送信
|
||||
for ( Player p : recipients ) {
|
||||
p.sendMessage(result);
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
/**
|
||||
* 基底のキャンセル可能イベントクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkitBaseCancellableEvent extends LunaChatBukkitBaseEvent implements Cancellable {
|
||||
|
||||
private boolean isCancelled;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
*/
|
||||
public LunaChatBukkitBaseCancellableEvent(String channelName) {
|
||||
super(channelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* イベントがキャンセルされたかどうかをかえす
|
||||
* @see org.bukkit.event.Cancellable#isCancelled()
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return isCancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* イベントをキャンセルするかどうかを設定する
|
||||
* @see org.bukkit.event.Cancellable#setCancelled(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
isCancelled = cancelled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
|
||||
/**
|
||||
* 基底イベントクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public abstract class LunaChatBukkitBaseEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
protected String channelName;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
*/
|
||||
public LunaChatBukkitBaseEvent(String channelName) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル名を取得する
|
||||
* @return チャンネル名
|
||||
*/
|
||||
public String getChannelName() {
|
||||
return channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを取得する
|
||||
* @return チャンネル
|
||||
*/
|
||||
public Channel getChannel() {
|
||||
return LunaChat.getAPI().getChannel(channelName);
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネルチャットのチャットイベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkitChannelChatEvent extends LunaChatBukkitBaseCancellableEvent {
|
||||
|
||||
private ChannelMember player;
|
||||
private String originalMessage;
|
||||
private String ngMaskedMessage;
|
||||
private String messageFormat;
|
||||
|
||||
public LunaChatBukkitChannelChatEvent(String channelName, ChannelMember player,
|
||||
String originalMessage, String ngMaskedMessage,
|
||||
String messageFormat) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.originalMessage = originalMessage;
|
||||
this.ngMaskedMessage = ngMaskedMessage;
|
||||
this.messageFormat = messageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置き換え前の、発言されたままのテキストをかえす
|
||||
* @return 発言内容
|
||||
*/
|
||||
public String getPreReplaceMessage() {
|
||||
return originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* NGワードがマスクされた後のテキストをかえす
|
||||
* @return NGワードマスク済みの発言内容
|
||||
*/
|
||||
public String getNgMaskedMessage() {
|
||||
return ngMaskedMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージに適用されるフォーマットをかえす
|
||||
* @return フォーマット
|
||||
*/
|
||||
public String getMessageFormat() {
|
||||
return messageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* NGワードマスク後のテキストを上書き設定する
|
||||
* @param ngMaskedMessage 上書きする発言内容
|
||||
*/
|
||||
public void setNgMaskedMessage(String ngMaskedMessage) {
|
||||
this.ngMaskedMessage = ngMaskedMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージフォーマットを上書き設定する
|
||||
* @param messageFormat フォーマット
|
||||
*/
|
||||
public void setMessageFormat(String messageFormat) {
|
||||
this.messageFormat = messageFormat;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネル作成イベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkitChannelCreateEvent extends LunaChatBukkitBaseCancellableEvent {
|
||||
|
||||
private ChannelMember member;
|
||||
|
||||
public LunaChatBukkitChannelCreateEvent(String channelName, ChannelMember member) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 作成するチャンネルのチャンネル名を上書き設定する
|
||||
* @param channelName 設定するチャンネル名
|
||||
*/
|
||||
public void setChannelName(String channelName) {
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを作成した人を取得する。
|
||||
* @return チャンネルを作成したChannelMember
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated チャンネル作成イベントは、チャンネルを作成する前に呼び出されるので、
|
||||
* このメソッドの戻り値は必ずnullになります。
|
||||
* @see com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitBaseEvent#getChannel()
|
||||
*/
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return super.getChannel();
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* メンバー変更イベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkitChannelMemberChangedEvent extends LunaChatBukkitBaseCancellableEvent {
|
||||
|
||||
private List<ChannelMember> before;
|
||||
private List<ChannelMember> after;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
* @param before 変更前のメンバー
|
||||
* @param after 変更後のメンバー
|
||||
*/
|
||||
public LunaChatBukkitChannelMemberChangedEvent(
|
||||
String channelName, List<ChannelMember> before, List<ChannelMember> after) {
|
||||
super(channelName);
|
||||
this.before = before;
|
||||
this.after = after;
|
||||
}
|
||||
|
||||
/**
|
||||
* 変更前のメンバーリストをかえす
|
||||
* @return
|
||||
*/
|
||||
public List<ChannelMember> getMembersBefore() {
|
||||
return before;
|
||||
}
|
||||
|
||||
/**
|
||||
* 変更後のメンバーリストをかえす
|
||||
* @return
|
||||
*/
|
||||
public List<ChannelMember> getMembersAfter() {
|
||||
return after;
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネルチャットのメッセージイベント、
|
||||
* このイベントはキャンセルできない。
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkitChannelMessageEvent extends LunaChatBukkitBaseEvent {
|
||||
|
||||
private ChannelMember player;
|
||||
private String message;
|
||||
private List<ChannelMember> recipients;
|
||||
private String displayName;
|
||||
private String originalMessage;
|
||||
|
||||
public LunaChatBukkitChannelMessageEvent(String channelName,
|
||||
ChannelMember player, String message, List<ChannelMember> recipients,
|
||||
String displayName, String originalMessage) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
this.recipients = recipients;
|
||||
this.displayName = displayName;
|
||||
this.originalMessage = originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言したプレイヤー、システムメッセージの場合はnullになることに注意
|
||||
* @return player 発言プレイヤー
|
||||
*/
|
||||
public ChannelMember getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置き換えされたメッセージ
|
||||
* @return message メッセージ
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを受信するプレイヤーリスト
|
||||
* @return recipients プレイヤーリスト
|
||||
*/
|
||||
public List<ChannelMember> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者の表示名を取得する
|
||||
* @return 発言者の表示名
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* オリジナルメッセージ(チャットフォーマットを適用していない状態のメッセージ)を取得する
|
||||
* @return オリジナルメッセージ
|
||||
*/
|
||||
public String getOriginalMessage() {
|
||||
return originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを上書き設定する
|
||||
* @param message メッセージ
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージ受信者を上書き設定する
|
||||
* @param recipients メッセージ受信者
|
||||
*/
|
||||
public void setRecipients(List<ChannelMember> recipients) {
|
||||
this.recipients = recipients;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* オプション変更イベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkitChannelOptionChangedEvent extends LunaChatBukkitBaseCancellableEvent {
|
||||
|
||||
private ChannelMember member;
|
||||
private Map<String, String> options;
|
||||
|
||||
public LunaChatBukkitChannelOptionChangedEvent(String channelName,
|
||||
ChannelMember member, Map<String, String> options) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* 変更後のオプションリストをかえす
|
||||
* @return オプションリスト
|
||||
*/
|
||||
public Map<String, String> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* オプションリストを上書き設定する
|
||||
* @param options オプションリスト
|
||||
*/
|
||||
public void setOptions(HashMap<String, String> options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのオプションを変更した人を取得する。
|
||||
* @return チャンネルのオプションを変更したChannelMember
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネル削除イベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkitChannelRemoveEvent extends LunaChatBukkitBaseCancellableEvent {
|
||||
|
||||
private ChannelMember member;
|
||||
|
||||
public LunaChatBukkitChannelRemoveEvent(String channelName, ChannelMember member) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを削除した人を取得する。
|
||||
* @return チャンネルを削除したChannelMember
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* Japanize変換が行われた後に呼び出されるイベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkitPostJapanizeEvent extends LunaChatBukkitBaseCancellableEvent {
|
||||
|
||||
private ChannelMember player;
|
||||
private String original;
|
||||
private String japanized;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
* @param player 発言したプレイヤー
|
||||
* @param original 変換前の文字列
|
||||
* @param japanized 変換後の文字列
|
||||
*/
|
||||
public LunaChatBukkitPostJapanizeEvent(String channelName, ChannelMember player,
|
||||
String original, String japanized) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.original = original;
|
||||
this.japanized = japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換後の文字列を返す
|
||||
* @return 変換後の文字列
|
||||
*/
|
||||
public String getJapanized() {
|
||||
return japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換後の文字列を差し替える
|
||||
* @param japanized 変換後の文字列
|
||||
*/
|
||||
public void setJapanized(String japanized) {
|
||||
this.japanized = japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換前の文字列を返す
|
||||
* @return 変換前の文字列
|
||||
*/
|
||||
public String getOriginal() {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネルチャットへの発言前に発生するイベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBukkitPreChatEvent extends LunaChatBukkitBaseCancellableEvent {
|
||||
|
||||
private ChannelMember player;
|
||||
private String message;
|
||||
|
||||
public LunaChatBukkitPreChatEvent(String channelName, ChannelMember player, String message) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,617 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc3.LunaChatBungee;
|
||||
import com.github.ucchyocean.lc3.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.event.EventResult;
|
||||
import com.github.ucchyocean.lc3.japanize.Japanizer;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.util.ChatColor;
|
||||
import com.github.ucchyocean.lc3.util.ClickableFormat;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
|
||||
/**
|
||||
* BungeeCordのイベントを監視するリスナークラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BungeeEventListener implements Listener {
|
||||
|
||||
private static final int MAX_LIST_ITEMS = 8;
|
||||
|
||||
private LunaChatBungee parent;
|
||||
private LunaChatConfig config;
|
||||
private LunaChatAPI api;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param parent LunaChatBungeeのインスタンス
|
||||
*/
|
||||
public BungeeEventListener(LunaChatBungee parent) {
|
||||
this.parent = parent;
|
||||
config = parent.getConfig();
|
||||
api = parent.getLunaChatAPI();
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onAsyncPlayerChatLowest(ChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.LOWEST) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.LOW)
|
||||
public void onAsyncPlayerChatLow(ChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.LOW) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.NORMAL)
|
||||
public void onAsyncPlayerChatNormal(ChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.NORMAL) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.HIGH)
|
||||
public void onAsyncPlayerChatHigh(ChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.HIGH) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void onAsyncPlayerChatHighest(ChatEvent event) {
|
||||
if ( matchesEventPriority(EventPriority.HIGHEST) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーが接続したときに呼び出されるメソッド
|
||||
* @param event プレイヤーログインイベント
|
||||
*/
|
||||
@EventHandler
|
||||
public void onJoin(PostLoginEvent event) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
|
||||
// UUIDをキャッシュ
|
||||
LunaChat.getUUIDCacheData().put(player.getUniqueId().toString(), player.getName());
|
||||
LunaChat.getUUIDCacheData().save();
|
||||
|
||||
// 強制参加チャンネル設定を確認し、参加させる
|
||||
forceJoinToForceJoinChannels(player);
|
||||
|
||||
// グローバルチャンネル設定がある場合
|
||||
if ( !config.getGlobalChannel().equals("") ) {
|
||||
tryJoinToGlobalChannel(player);
|
||||
}
|
||||
|
||||
// チャンネルチャット情報を表示する
|
||||
if ( config.isShowListOnJoin() ) {
|
||||
for ( BaseComponent[] msg : getListForMotd(player) ) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのサーバー退出ごとに呼び出されるメソッド
|
||||
* @param event プレイヤー退出イベント
|
||||
*/
|
||||
@EventHandler
|
||||
public void onQuit(PlayerDisconnectEvent event) {
|
||||
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
String pname = player.getName();
|
||||
|
||||
// お互いがオフラインになるPMチャンネルがある場合は
|
||||
// チャンネルをクリアする
|
||||
ArrayList<Channel> deleteList = new ArrayList<Channel>();
|
||||
|
||||
for ( Channel channel : LunaChat.getAPI().getChannels() ) {
|
||||
String cname = channel.getName();
|
||||
if ( channel.isPersonalChat() && cname.contains(pname) ) {
|
||||
boolean isAllOffline = true;
|
||||
for ( ChannelMember cp : channel.getMembers() ) {
|
||||
if ( cp.isOnline() ) {
|
||||
isAllOffline = false;
|
||||
}
|
||||
}
|
||||
if ( isAllOffline ) {
|
||||
deleteList.add(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( Channel channel : deleteList ) {
|
||||
LunaChat.getAPI().removeChannel(channel.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのチャットごとに呼び出されるメソッド
|
||||
* @param event チャットイベント
|
||||
*/
|
||||
private void processChatEvent(ChatEvent event) {
|
||||
|
||||
// コマンド実行の場合は、そのまま無視する
|
||||
if ( event.isCommand() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// プレイヤーの発言ではない場合は、そのまま無視する
|
||||
if ( !(event.getSender() instanceof ProxiedPlayer) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 頭にglobalMarkerが付いている場合は、グローバル発言にする
|
||||
if ( config.getGlobalMarker() != null &&
|
||||
!config.getGlobalMarker().equals("") &&
|
||||
event.getMessage().startsWith(config.getGlobalMarker()) &&
|
||||
event.getMessage().length() > config.getGlobalMarker().length() ) {
|
||||
|
||||
int offset = config.getGlobalMarker().length();
|
||||
event.setMessage( event.getMessage().substring(offset) );
|
||||
chatGlobal(event);
|
||||
return;
|
||||
}
|
||||
|
||||
// クイックチャンネルチャット機能が有効で、専用の記号が含まれるなら、
|
||||
// クイックチャンネルチャットとして処理する。
|
||||
if ( config.isEnableQuickChannelChat() ) {
|
||||
String separator = config.getQuickChannelChatSeparator();
|
||||
if ( event.getMessage().contains(separator) ) {
|
||||
String[] temp = event.getMessage().split(separator, 2);
|
||||
String name = temp[0];
|
||||
String value = "";
|
||||
if ( temp.length > 0 ) {
|
||||
value = temp[1];
|
||||
}
|
||||
|
||||
Channel channel = api.getChannel(name);
|
||||
if ( channel != null && !channel.isPersonalChat()
|
||||
&& event.getSender() instanceof ProxiedPlayer ) {
|
||||
ChannelMember player =
|
||||
ChannelMember.getChannelMember(event.getSender());
|
||||
if ( !channel.getMembers().contains(player) ) {
|
||||
// 指定されたチャンネルに参加していないなら、エラーを表示して何も発言せずに終了する。
|
||||
((ProxiedPlayer)event.getSender()).sendMessage(
|
||||
TextComponent.fromLegacyText(Messages.errmsgNomember()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 指定されたチャンネルに発言して終了する。
|
||||
chatToChannelWithEvent(player, channel, value);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ChannelMember player =
|
||||
ChannelMember.getChannelMember(event.getSender());
|
||||
Channel channel = api.getDefaultChannel(player.getName());
|
||||
|
||||
// デフォルトの発言先が無い場合
|
||||
if ( channel == null ) {
|
||||
if ( config.isNoJoinAsGlobal() ) {
|
||||
// グローバル発言にする
|
||||
chatGlobal(event);
|
||||
return;
|
||||
|
||||
} else {
|
||||
// 発言をキャンセルして終了する
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
chatToChannelWithEvent(player, channel, event.getMessage());
|
||||
|
||||
// もとのイベントをキャンセル
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private void chatGlobal(ChatEvent event) {
|
||||
|
||||
// 発言者と発言サーバーと発言内容の取得
|
||||
final ProxiedPlayer sender = (ProxiedPlayer)event.getSender();
|
||||
String message = event.getMessage();
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
// NGワードのマスク
|
||||
message = maskNGWord(message, config.getNgwordCompiled());
|
||||
|
||||
// Japanizeをスキップするかどうかフラグ
|
||||
boolean skipJapanize = !LunaChat.getAPI().isPlayerJapanize(sender.getName());
|
||||
|
||||
// 一時的なJapanizeスキップが指定されているか確認する
|
||||
String marker = config.getNoneJapanizeMarker();
|
||||
if ( !marker.equals("") && message.startsWith(marker) ) {
|
||||
message = message.substring(marker.length());
|
||||
skipJapanize = true;
|
||||
}
|
||||
|
||||
// 2byteコードを含む、または、半角カタカナのみなら、Japanize変換は行わない
|
||||
String kanaTemp = Utility.stripColorCode(message);
|
||||
|
||||
if ( !skipJapanize &&
|
||||
( kanaTemp.getBytes(StandardCharsets.UTF_8).length > kanaTemp.length() ||
|
||||
kanaTemp.matches("[ \\uFF61-\\uFF9F]+") ) ) {
|
||||
skipJapanize = true;
|
||||
}
|
||||
|
||||
// Japanizeの付加
|
||||
if ( !skipJapanize ) {
|
||||
|
||||
String japanize = Japanizer.japanize(Utility.stripColorCode(message), config.getJapanizeType(),
|
||||
LunaChat.getAPI().getAllDictionary());
|
||||
if ( japanize.length() > 0 ) {
|
||||
|
||||
// NGワードのマスク
|
||||
japanize = maskNGWord(japanize, config.getNgwordCompiled());
|
||||
|
||||
// フォーマット化してメッセージを上書きする
|
||||
String japanizeFormat = config.getJapanizeDisplayLine() == 1 ?
|
||||
config.getJapanizeLine1Format() :
|
||||
"%msg\n" + config.getJapanizeLine2Format();
|
||||
String preMessage = new String(message);
|
||||
message = japanizeFormat.replace("%msg", preMessage).replace("%japanize", japanize);
|
||||
}
|
||||
}
|
||||
|
||||
String result;
|
||||
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
// チャットフォーマット装飾を適用する場合
|
||||
String f = config.getNormalChatMessageFormat();
|
||||
ClickableFormat format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(sender));
|
||||
format.replace("%msg", message);
|
||||
|
||||
// イベントをキャンセルする
|
||||
event.setCancelled(true);
|
||||
|
||||
// hideされているプレイヤーを除くすべてのプレイヤーに、
|
||||
// 発言内容を送信する。
|
||||
BaseComponent[] msg = format.makeTextComponent();
|
||||
List<ChannelMember> hidelist = api.getHidelist(ChannelMember.getChannelMember(sender));
|
||||
|
||||
for ( String server : parent.getProxy().getServers().keySet() ) {
|
||||
|
||||
ServerInfo info = parent.getProxy().getServerInfo(server);
|
||||
for ( ProxiedPlayer player : info.getPlayers() ) {
|
||||
if ( !containsHideList(player, hidelist) ) {
|
||||
sendMessage(player, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = format.toLegacyText();
|
||||
|
||||
} else {
|
||||
// チャットフォーマットを適用しない場合
|
||||
// NOTE: ChatEvent経由で送信する都合上、hideは適用しない(できない)仕様とする。
|
||||
|
||||
// NOTE: 改行がサポートされないので、改行を含む場合は、
|
||||
// \nで分割して前半をセットし、後半は150ミリ秒後に送信する。
|
||||
if ( !message.contains("\n") ) {
|
||||
event.setMessage(Utility.stripColorCode(message));
|
||||
} else {
|
||||
int index = message.indexOf("\n");
|
||||
String pre = message.substring(0, index);
|
||||
final String post = Utility.replaceColorCode(
|
||||
message.substring(index + "\n".length()));
|
||||
event.setMessage(Utility.stripColorCode(pre));
|
||||
|
||||
parent.getProxy().getScheduler().schedule(parent, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for ( ProxiedPlayer p : sender.getServer().getInfo().getPlayers() ) {
|
||||
sendMessage(p, post);
|
||||
}
|
||||
}
|
||||
}, 150, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
result = Utility.replaceColorCode(message);
|
||||
|
||||
// 発言したプレイヤーがいるサーバー"以外"のサーバーに、
|
||||
// 発言内容を送信する。
|
||||
for ( String server : parent.getProxy().getServers().keySet() ) {
|
||||
|
||||
String senderServer = sender.getServer().getInfo().getName();
|
||||
if ( server.equals(senderServer) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ServerInfo info = parent.getProxy().getServerInfo(server);
|
||||
for ( ProxiedPlayer player : info.getPlayers() ) {
|
||||
sendMessage(player, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// コンソールに表示設定なら、コンソールに表示する
|
||||
if ( config.isDisplayChatOnConsole() ) {
|
||||
parent.getLogger().info(result);
|
||||
}
|
||||
|
||||
// ログに記録する
|
||||
LunaChat.getNormalChatLogger().log(Utility.stripColorCode(result), sender.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルに発言処理を行う
|
||||
* @param player プレイヤー
|
||||
* @param channel チャンネル
|
||||
* @param message 発言内容
|
||||
* @return イベントでキャンセルされたかどうか
|
||||
*/
|
||||
private boolean chatToChannelWithEvent(ChannelMember player, Channel channel, String message) {
|
||||
|
||||
// LunaChatPreChatEvent イベントコール
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatPreChatEvent(
|
||||
channel.getName(), player, message);
|
||||
if ( result.isCancelled() ) {
|
||||
return true;
|
||||
}
|
||||
Channel alt = result.getChannel();
|
||||
if ( alt != null ) {
|
||||
channel = alt;
|
||||
}
|
||||
message = result.getMessage();
|
||||
|
||||
// チャンネルチャット発言
|
||||
channel.chat(player, message);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* NGワードをマスクする
|
||||
* @param message メッセージ
|
||||
* @param ngwords NGワード
|
||||
* @return マスクされたメッセージ
|
||||
*/
|
||||
private String maskNGWord(String message, List<Pattern> ngwords) {
|
||||
for ( Pattern pattern : ngwords ) {
|
||||
Matcher matcher = pattern.matcher(message);
|
||||
if ( matcher.find() ) {
|
||||
message = matcher.replaceAll(
|
||||
Utility.getAstariskString(matcher.group(0).length()));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 強制参加チャンネルへ参加させる
|
||||
* @param player プレイヤー
|
||||
*/
|
||||
private void forceJoinToForceJoinChannels(ProxiedPlayer player) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
List<String> forceJoinChannels = config.getForceJoinChannels();
|
||||
|
||||
for ( String cname : forceJoinChannels ) {
|
||||
|
||||
// チャンネルが存在しない場合は作成する
|
||||
Channel channel = api.getChannel(cname);
|
||||
if ( channel == null ) {
|
||||
channel = api.createChannel(cname);
|
||||
}
|
||||
|
||||
// チャンネルのメンバーでないなら、参加する
|
||||
ChannelMember cp = ChannelMember.getChannelMember(player);
|
||||
if ( !channel.getMembers().contains(cp) ) {
|
||||
channel.addMember(cp);
|
||||
}
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
Channel dchannel = api.getDefaultChannel(player.getName());
|
||||
if ( dchannel == null ) {
|
||||
api.setDefaultChannel(player.getName(), cname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 既定のチャンネルへの参加を試みる。
|
||||
* @param player プレイヤー
|
||||
* @return 参加できたかどうか
|
||||
*/
|
||||
private boolean tryJoinToGlobalChannel(ProxiedPlayer player) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
String gcName = config.getGlobalChannel();
|
||||
|
||||
// チャンネルが存在しない場合は作成する
|
||||
Channel global = api.getChannel(gcName);
|
||||
if ( global == null ) {
|
||||
global = api.createChannel(gcName);
|
||||
}
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
Channel dchannel = api.getDefaultChannel(player.getName());
|
||||
if ( dchannel == null ) {
|
||||
api.setDefaultChannel(player.getName(), gcName);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのサーバー参加時用の参加チャンネルリストを返す
|
||||
* @param player プレイヤー
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<BaseComponent[]> getListForMotd(ProxiedPlayer player) {
|
||||
|
||||
ChannelMember cp = ChannelMember.getChannelMember(player);
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
Channel dc = api.getDefaultChannel(cp.getName());
|
||||
String dchannel = "";
|
||||
if ( dc != null ) {
|
||||
dchannel = dc.getName().toLowerCase();
|
||||
}
|
||||
|
||||
// チャンネル一覧を取得して、参加人数でソートする
|
||||
ArrayList<Channel> channels = new ArrayList<>(api.getChannels());
|
||||
Collections.sort(channels, new Comparator<Channel>() {
|
||||
public int compare(Channel c1, Channel c2) {
|
||||
if ( c1.getOnlineNum() == c2.getOnlineNum() ) return c1.getName().compareTo(c2.getName());
|
||||
return c2.getOnlineNum() - c1.getOnlineNum();
|
||||
}
|
||||
});
|
||||
|
||||
int count = 0;
|
||||
ArrayList<BaseComponent[]> items = new ArrayList<>();
|
||||
items.add(TextComponent.fromLegacyText(Messages.motdFirstLine()));
|
||||
for ( Channel channel : channels ) {
|
||||
|
||||
// BANされているチャンネルは表示しない
|
||||
if ( channel.getBanned().contains(cp) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットはリストに表示しない
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 参加していないチャンネルは、グローバルチャンネルを除き表示しない
|
||||
if ( !channel.getMembers().contains(cp) &&
|
||||
!channel.isGlobalChannel() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String disp = ChatColor.WHITE + channel.getName();
|
||||
if ( channel.getName().equals(dchannel) ) {
|
||||
disp = ChatColor.RED + channel.getName();
|
||||
}
|
||||
String desc = channel.getDescription();
|
||||
int onlineNum = channel.getOnlineNum();
|
||||
int memberNum = channel.getTotalNum();
|
||||
items.add(Messages.listFormat(disp, onlineNum, memberNum, desc));
|
||||
count++;
|
||||
|
||||
if ( count > MAX_LIST_ITEMS ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
items.add(TextComponent.fromLegacyText(Messages.listEndLine()));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定した対象にメッセージを送信する
|
||||
* @param reciever 送信先
|
||||
* @param message メッセージ
|
||||
*/
|
||||
private void sendMessage(CommandSender reciever, String message) {
|
||||
if ( message == null ) return;
|
||||
ChannelMember cm = ChannelMember.getChannelMember(reciever);
|
||||
if ( cm != null ) {
|
||||
cm.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定した対象にメッセージを送信する
|
||||
* @param reciever 送信先
|
||||
* @param message メッセージ
|
||||
*/
|
||||
private void sendMessage(CommandSender reciever, BaseComponent[] message) {
|
||||
if ( message == null ) return;
|
||||
ChannelMember cm = ChannelMember.getChannelMember(reciever);
|
||||
if ( cm != null ) {
|
||||
cm.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたEventPriorityが、LunaChatConfigで指定されているEventPriorityと一致するかどうかを調べる
|
||||
* @param priority
|
||||
* @return 一致するかどうか
|
||||
*/
|
||||
private boolean matchesEventPriority(int priority) {
|
||||
String c = LunaChat.getConfig().getPlayerChatEventListenerPriority().name();
|
||||
if ( priority == EventPriority.LOWEST ) return "LOWEST".equals(c);
|
||||
if ( priority == EventPriority.LOW ) return "LOW".equals(c);
|
||||
if ( priority == EventPriority.NORMAL ) return "NORMAL".equals(c);
|
||||
if ( priority == EventPriority.HIGH ) return "HIGH".equals(c);
|
||||
if ( priority == EventPriority.HIGHEST ) return "HIGHEST".equals(c);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーが指定されたHideListに含まれるかどうかを判定する
|
||||
* @param p プレイヤー
|
||||
* @param list リスト
|
||||
* @return 含まれるかどうか
|
||||
*/
|
||||
private boolean containsHideList(ProxiedPlayer p, List<ChannelMember> list) {
|
||||
for ( ChannelMember m : list ) {
|
||||
if (m.getName().equals(p.getName())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.ucchyocean.lc3.bungee.event.LunaChatBungeeChannelChatEvent;
|
||||
import com.github.ucchyocean.lc3.bungee.event.LunaChatBungeeChannelCreateEvent;
|
||||
import com.github.ucchyocean.lc3.bungee.event.LunaChatBungeeChannelMemberChangedEvent;
|
||||
import com.github.ucchyocean.lc3.bungee.event.LunaChatBungeeChannelMessageEvent;
|
||||
import com.github.ucchyocean.lc3.bungee.event.LunaChatBungeeChannelOptionChangedEvent;
|
||||
import com.github.ucchyocean.lc3.bungee.event.LunaChatBungeeChannelRemoveEvent;
|
||||
import com.github.ucchyocean.lc3.bungee.event.LunaChatBungeePostJapanizeEvent;
|
||||
import com.github.ucchyocean.lc3.bungee.event.LunaChatBungeePreChatEvent;
|
||||
import com.github.ucchyocean.lc3.event.EventResult;
|
||||
import com.github.ucchyocean.lc3.event.EventSenderInterface;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
/**
|
||||
* Bungeeのイベント実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BungeeEventSender implements EventSenderInterface {
|
||||
|
||||
/**
|
||||
* チャンネルチャットのチャットイベント
|
||||
* @param channelName チャンネル名
|
||||
* @param player 発言者
|
||||
* @param originalMessage 発言内容
|
||||
* @param ngMaskedMessage 発言内容(NGマスク後)
|
||||
* @param messageFormat 発言に適用されるフォーマット
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelChatEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelChatEvent(String channelName, ChannelMember member, String originalMessage,
|
||||
String ngMaskedMessage, String messageFormat) {
|
||||
|
||||
LunaChatBungeeChannelChatEvent event =
|
||||
new LunaChatBungeeChannelChatEvent(
|
||||
channelName, member, originalMessage, ngMaskedMessage, messageFormat);
|
||||
event = ProxyServer.getInstance().getPluginManager().callEvent(event);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(event.isCancelled());
|
||||
result.setNgMaskedMessage(event.getNgMaskedMessage());
|
||||
result.setMessageFormat(event.getMessageFormat());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル作成イベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member 作成した人
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelCreateEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelCreateEvent(String channelName, ChannelMember member) {
|
||||
|
||||
LunaChatBungeeChannelCreateEvent event =
|
||||
new LunaChatBungeeChannelCreateEvent(channelName, member);
|
||||
event = ProxyServer.getInstance().getPluginManager().callEvent(event);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(event.isCancelled());
|
||||
result.setChannelName(event.getChannelName());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* メンバー変更イベント
|
||||
* @param channelName チャンネル名
|
||||
* @param before 変更前のメンバー
|
||||
* @param after 変更後のメンバー
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelMemberChangedEvent(java.lang.String, java.util.List, java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelMemberChangedEvent(String channelName, List<ChannelMember> before,
|
||||
List<ChannelMember> after) {
|
||||
|
||||
LunaChatBungeeChannelMemberChangedEvent event =
|
||||
new LunaChatBungeeChannelMemberChangedEvent(channelName, before, after);
|
||||
event = ProxyServer.getInstance().getPluginManager().callEvent(event);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(event.isCancelled());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットのメッセージイベント。このイベントはキャンセルできない。
|
||||
* @param channelName チャンネル名
|
||||
* @param member 発言者
|
||||
* @param message 発言内容(NGマスクやJapanizeされた後の内容)
|
||||
* @param recipients 受信者
|
||||
* @param displayName 発言者の表示名
|
||||
* @param originalMessage 発言内容(元々の内容)
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelMessageEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String, java.util.ArrayList, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelMessageEvent(String channelName, ChannelMember member, String message,
|
||||
List<ChannelMember> recipients, String displayName, String originalMessage) {
|
||||
|
||||
LunaChatBungeeChannelMessageEvent event =
|
||||
new LunaChatBungeeChannelMessageEvent(
|
||||
channelName, member, message, recipients, displayName, originalMessage);
|
||||
event = ProxyServer.getInstance().getPluginManager().callEvent(event);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setMessage(event.getMessage());
|
||||
result.setRecipients(event.getRecipients());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* オプション変更イベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member オプションを変更した人
|
||||
* @param options 変更後のオプション
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelOptionChangedEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.util.HashMap)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelOptionChangedEvent(String channelName, ChannelMember member,
|
||||
Map<String, String> options) {
|
||||
|
||||
LunaChatBungeeChannelOptionChangedEvent event =
|
||||
new LunaChatBungeeChannelOptionChangedEvent(channelName, member, options);
|
||||
event = ProxyServer.getInstance().getPluginManager().callEvent(event);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(event.isCancelled());
|
||||
result.setOptions(event.getOptions());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル削除イベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member 削除を実行した人
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatChannelRemoveEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatChannelRemoveEvent(String channelName, ChannelMember member) {
|
||||
|
||||
LunaChatBungeeChannelRemoveEvent event = new LunaChatBungeeChannelRemoveEvent(channelName, member);
|
||||
event = ProxyServer.getInstance().getPluginManager().callEvent(event);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(event.isCancelled());
|
||||
result.setChannelName(event.getChannelName());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換が行われた後に呼び出されるイベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member 発言したメンバー
|
||||
* @param original 変換前の文字列
|
||||
* @param japanized 変換後の文字列
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatPostJapanizeEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatPostJapanizeEvent(String channelName, ChannelMember member, String original,
|
||||
String japanized) {
|
||||
|
||||
LunaChatBungeePostJapanizeEvent event =
|
||||
new LunaChatBungeePostJapanizeEvent(channelName, member, original, japanized);
|
||||
event = ProxyServer.getInstance().getPluginManager().callEvent(event);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(event.isCancelled());
|
||||
result.setJapanized(event.getJapanized());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットへの発言前に発生するイベント
|
||||
* @param channelName チャンネル名
|
||||
* @param member 発言したメンバー
|
||||
* @param message 発言内容
|
||||
* @return イベント実行結果
|
||||
* @see com.github.ucchyocean.lc3.event.EventSenderInterface#sendLunaChatPreChatEvent(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public EventResult sendLunaChatPreChatEvent(String channelName, ChannelMember member, String message) {
|
||||
|
||||
LunaChatBungeePreChatEvent event =
|
||||
new LunaChatBungeePreChatEvent(channelName, member, message);
|
||||
event = ProxyServer.getInstance().getPluginManager().callEvent(event);
|
||||
|
||||
EventResult result = new EventResult();
|
||||
result.setCancelled(event.isCancelled());
|
||||
result.setMessage(event.getMessage());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import com.github.ucchyocean.lc3.command.LunaChatJapanizeCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
/**
|
||||
* Japanizeコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class JapanizeCommandBungee extends Command {
|
||||
|
||||
private LunaChatJapanizeCommand command;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name
|
||||
* @param permission
|
||||
* @param aliases
|
||||
*/
|
||||
public JapanizeCommandBungee(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
command = new LunaChatJapanizeCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
command.execute(ChannelMember.getChannelMember(sender), "jp", args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import com.github.ucchyocean.lc3.command.LunaChatCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
/**
|
||||
* Lunachatコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatCommandBungee extends Command implements TabExecutor {
|
||||
|
||||
private LunaChatCommand command;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name
|
||||
* @param permission
|
||||
* @param aliases
|
||||
*/
|
||||
public LunaChatCommandBungee(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
command = new LunaChatCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
command.execute(ChannelMember.getChannelMember(sender), "ch", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* TABキー補完が実行されたときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 補完候補
|
||||
* @see net.md_5.bungee.api.plugin.TabExecutor#onTabComplete(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
return command.onTabComplete(ChannelMember.getChannelMember(sender), "ch", args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import com.github.ucchyocean.lc3.command.LunaChatMessageCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
/**
|
||||
* Tellコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class MessageCommandBungee extends Command {
|
||||
|
||||
private LunaChatMessageCommand command;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name
|
||||
* @param permission
|
||||
* @param aliases
|
||||
*/
|
||||
public MessageCommandBungee(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
command = new LunaChatMessageCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
command.execute(ChannelMember.getChannelMember(sender), "m", args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import com.github.ucchyocean.lc3.command.LunaChatReplyCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
/**
|
||||
* Replyコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ReplyCommandBungee extends Command {
|
||||
|
||||
private LunaChatReplyCommand command;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name
|
||||
* @param permission
|
||||
* @param aliases
|
||||
*/
|
||||
public ReplyCommandBungee(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
command = new LunaChatReplyCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
command.execute(ChannelMember.getChannelMember(sender), "r", args);
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee.event;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
|
||||
/**
|
||||
* 基底のキャンセル可能イベントクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungeeBaseCancellableEvent extends LunaChatBungeeBaseEvent implements Cancellable {
|
||||
|
||||
private boolean isCancelled;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
*/
|
||||
public LunaChatBungeeBaseCancellableEvent(String channelName) {
|
||||
super(channelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* イベントがキャンセルされたかどうかをかえす
|
||||
* @see org.bukkit.event.Cancellable#isCancelled()
|
||||
*/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return isCancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* イベントをキャンセルするかどうかを設定する
|
||||
* @see org.bukkit.event.Cancellable#setCancelled(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
isCancelled = cancelled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
/**
|
||||
* 基底イベントクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public abstract class LunaChatBungeeBaseEvent extends Event {
|
||||
|
||||
protected String channelName;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
*/
|
||||
public LunaChatBungeeBaseEvent(String channelName) {
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル名を取得する
|
||||
* @return チャンネル名
|
||||
*/
|
||||
public String getChannelName() {
|
||||
return channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを取得する
|
||||
* @return チャンネル
|
||||
*/
|
||||
public Channel getChannel() {
|
||||
return LunaChat.getAPI().getChannel(channelName);
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネルチャットのチャットイベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungeeChannelChatEvent extends LunaChatBungeeBaseCancellableEvent {
|
||||
|
||||
private ChannelMember player;
|
||||
private String originalMessage;
|
||||
private String ngMaskedMessage;
|
||||
private String messageFormat;
|
||||
|
||||
public LunaChatBungeeChannelChatEvent(String channelName, ChannelMember player,
|
||||
String originalMessage, String ngMaskedMessage,
|
||||
String messageFormat) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.originalMessage = originalMessage;
|
||||
this.ngMaskedMessage = ngMaskedMessage;
|
||||
this.messageFormat = messageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置き換え前の、発言されたままのテキストをかえす
|
||||
* @return 発言内容
|
||||
*/
|
||||
public String getPreReplaceMessage() {
|
||||
return originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* NGワードがマスクされた後のテキストをかえす
|
||||
* @return NGワードマスク済みの発言内容
|
||||
*/
|
||||
public String getNgMaskedMessage() {
|
||||
return ngMaskedMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージに適用されるフォーマットをかえす
|
||||
* @return フォーマット
|
||||
*/
|
||||
public String getMessageFormat() {
|
||||
return messageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* NGワードマスク後のテキストを上書き設定する
|
||||
* @param ngMaskedMessage 上書きする発言内容
|
||||
*/
|
||||
public void setNgMaskedMessage(String ngMaskedMessage) {
|
||||
this.ngMaskedMessage = ngMaskedMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージフォーマットを上書き設定する
|
||||
* @param messageFormat フォーマット
|
||||
*/
|
||||
public void setMessageFormat(String messageFormat) {
|
||||
this.messageFormat = messageFormat;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネル作成イベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungeeChannelCreateEvent extends LunaChatBungeeBaseCancellableEvent {
|
||||
|
||||
private ChannelMember member;
|
||||
|
||||
public LunaChatBungeeChannelCreateEvent(String channelName, ChannelMember member) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 作成するチャンネルのチャンネル名を上書き設定する
|
||||
* @param channelName 設定するチャンネル名
|
||||
*/
|
||||
public void setChannelName(String channelName) {
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを作成した人を取得する。
|
||||
* @return チャンネルを作成したChannelMember
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated チャンネル作成イベントは、チャンネルを作成する前に呼び出されるので、
|
||||
* このメソッドの戻り値は必ずnullになります。
|
||||
* @see com.github.ucchyocean.lc3.bukkit.event.LunaChatBukkitBaseEvent#getChannel()
|
||||
*/
|
||||
@Override
|
||||
public Channel getChannel() {
|
||||
return super.getChannel();
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* メンバー変更イベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungeeChannelMemberChangedEvent extends LunaChatBungeeBaseCancellableEvent {
|
||||
|
||||
private List<ChannelMember> before;
|
||||
private List<ChannelMember> after;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
* @param before 変更前のメンバー
|
||||
* @param after 変更後のメンバー
|
||||
*/
|
||||
public LunaChatBungeeChannelMemberChangedEvent(
|
||||
String channelName, List<ChannelMember> before, List<ChannelMember> after) {
|
||||
super(channelName);
|
||||
this.before = before;
|
||||
this.after = after;
|
||||
}
|
||||
|
||||
/**
|
||||
* 変更前のメンバーリストをかえす
|
||||
* @return
|
||||
*/
|
||||
public List<ChannelMember> getMembersBefore() {
|
||||
return before;
|
||||
}
|
||||
|
||||
/**
|
||||
* 変更後のメンバーリストをかえす
|
||||
* @return
|
||||
*/
|
||||
public List<ChannelMember> getMembersAfter() {
|
||||
return after;
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネルチャットのメッセージイベント、
|
||||
* このイベントはキャンセルできない。
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungeeChannelMessageEvent extends LunaChatBungeeBaseEvent {
|
||||
|
||||
private ChannelMember player;
|
||||
private String message;
|
||||
private List<ChannelMember> recipients;
|
||||
private String displayName;
|
||||
private String originalMessage;
|
||||
|
||||
public LunaChatBungeeChannelMessageEvent(String channelName,
|
||||
ChannelMember player, String message, List<ChannelMember> recipients,
|
||||
String displayName, String originalMessage) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
this.recipients = recipients;
|
||||
this.displayName = displayName;
|
||||
this.originalMessage = originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言したプレイヤー、システムメッセージの場合はnullになることに注意
|
||||
* @return player 発言プレイヤー
|
||||
*/
|
||||
public ChannelMember getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置き換えされたメッセージ
|
||||
* @return message メッセージ
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを受信するプレイヤーリスト
|
||||
* @return recipients プレイヤーリスト
|
||||
*/
|
||||
public List<ChannelMember> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言者の表示名を取得する
|
||||
* @return 発言者の表示名
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* オリジナルメッセージ(チャットフォーマットを適用していない状態のメッセージ)を取得する
|
||||
* @return オリジナルメッセージ
|
||||
*/
|
||||
public String getOriginalMessage() {
|
||||
return originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを上書き設定する
|
||||
* @param message メッセージ
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージ受信者を上書き設定する
|
||||
* @param recipients メッセージ受信者
|
||||
*/
|
||||
public void setRecipients(ArrayList<ChannelMember> recipients) {
|
||||
this.recipients = recipients;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* オプション変更イベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungeeChannelOptionChangedEvent extends LunaChatBungeeBaseCancellableEvent {
|
||||
|
||||
private ChannelMember member;
|
||||
private Map<String, String> options;
|
||||
|
||||
public LunaChatBungeeChannelOptionChangedEvent(String channelName,
|
||||
ChannelMember member, Map<String, String> options) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* 変更後のオプションリストをかえす
|
||||
* @return オプションリスト
|
||||
*/
|
||||
public Map<String, String> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* オプションリストを上書き設定する
|
||||
* @param options オプションリスト
|
||||
*/
|
||||
public void setOptions(HashMap<String, String> options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのオプションを変更した人を取得する。
|
||||
* @return チャンネルのオプションを変更したChannelMember
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネル削除イベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungeeChannelRemoveEvent extends LunaChatBungeeBaseCancellableEvent {
|
||||
|
||||
private ChannelMember member;
|
||||
|
||||
public LunaChatBungeeChannelRemoveEvent(String channelName, ChannelMember member) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルを削除した人を取得する。
|
||||
* @return チャンネルを削除したChannelMember
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* Japanize変換が行われた後に呼び出されるイベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungeePostJapanizeEvent extends LunaChatBungeeBaseCancellableEvent {
|
||||
|
||||
private ChannelMember player;
|
||||
private String original;
|
||||
private String japanized;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
* @param player 発言したプレイヤー
|
||||
* @param original 変換前の文字列
|
||||
* @param japanized 変換後の文字列
|
||||
*/
|
||||
public LunaChatBungeePostJapanizeEvent(String channelName, ChannelMember player,
|
||||
String original, String japanized) {
|
||||
super(channelName);
|
||||
this.player = player;
|
||||
this.original = original;
|
||||
this.japanized = japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換後の文字列を返す
|
||||
* @return 変換後の文字列
|
||||
*/
|
||||
public String getJapanized() {
|
||||
return japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換後の文字列を差し替える
|
||||
* @param japanized 変換後の文字列
|
||||
*/
|
||||
public void setJapanized(String japanized) {
|
||||
this.japanized = japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Japanize変換前の文字列を返す
|
||||
* @return 変換前の文字列
|
||||
*/
|
||||
public String getOriginal() {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
179ファイル中100ファイルを読み込みました。 変更されたファイルが多すぎるため、それ以降のファイルは表示していません。
さらに表示
新しいイシューから参照
ユーザーをブロックする