コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
6cdd8438f7 | ||
|
|
854abef1b3 | ||
|
|
0c8212e979 | ||
|
|
55810cf084 | ||
|
|
bbfcacfe4c | ||
|
|
9912870fba | ||
|
|
9407fe942e | ||
|
|
af662bdc23 | ||
|
|
7b3943746f | ||
|
|
40770574b7 | ||
|
|
e3cbb59044 | ||
|
|
b4cb6569b4 | ||
|
|
fefd5f0c1b | ||
|
|
ef2490d7ab | ||
|
|
2235c28140 | ||
|
|
85ef758db8 | ||
|
|
d247da92dd | ||
|
|
58ec14a160 | ||
|
|
267b9714e5 | ||
|
|
83be0ce0f1 | ||
|
|
11a6ffb2de | ||
|
|
6886843548 | ||
|
|
7874d47b33 | ||
|
|
978100ab02 | ||
|
|
f9df5353c9 | ||
|
|
1735ba5386 | ||
|
|
90b0a33c0f | ||
|
|
4cf64c2318 | ||
|
|
9099ac968e | ||
|
|
bdd148f313 | ||
|
|
bfd6bbbe87 | ||
|
|
81b75f3f0f | ||
|
|
ff722c79a1 | ||
|
|
f95cf9da33 | ||
|
|
18c47505c7 | ||
|
|
a7234efe84 | ||
|
|
9d5fd5ceb5 | ||
|
|
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 |
検索条件に一致するファイルはありません
@@ -0,0 +1 @@
|
||||
github: ucchyocean
|
||||
@@ -0,0 +1,33 @@
|
||||
---
|
||||
name: Bug report/バグ報告
|
||||
about: Create a report to help us improve/バグ報告をしたい場合はこちらを選択してください
|
||||
title: ''
|
||||
labels: バグ
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug/バグの概要**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Server and version/サーバーとバージョン**
|
||||
- Server: Spigot / Paper / BungeeCord / Waterfall / etc...
|
||||
- Server version (Minecraft version) : 1.16.1 / 1.15.2 / etc...
|
||||
- Other plugins:
|
||||
- LunaChat version :
|
||||
|
||||
**To Reproduce/再現手順**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior/期待する結果**
|
||||
A clear and concise description of what you expected to happen./上記の再現手順に書いた状態について、何か期待と違っていたのか、どこに問題があったのかを、明確に記載してください。
|
||||
|
||||
**Screenshots/スクリーンショット**
|
||||
If applicable, add screenshots to help explain your problem./スクリーンショットがあれば添付してください。ブラウザに画像ファイルをドラッグアンドドロップしてアップロードできます。
|
||||
|
||||
**Additional context/備考**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request/機能追加リクエスト
|
||||
about: Suggest an idea for this project/機能追加要望をしたい場合はこちらを選択してください
|
||||
title: ''
|
||||
labels: 機能追加・要望
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
+3
-1
@@ -4,4 +4,6 @@
|
||||
/target
|
||||
#IntelliJ
|
||||
.idea/
|
||||
*.iml
|
||||
*.iml
|
||||
/.sts4-cache
|
||||
/LunaChat
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk7
|
||||
- oraclejdk8
|
||||
- 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.
|
||||
@@ -6,7 +6,7 @@ Build Status : [ support</description>
|
||||
<url>https://github.com/ucchyocean/LunaChat</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
@@ -15,13 +16,15 @@
|
||||
|
||||
<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>
|
||||
|
||||
@@ -36,120 +39,251 @@
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<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>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<source>${java.version}</source>
|
||||
<encoding>UTF-8</encoding>
|
||||
<docencoding>UTF-8</docencoding>
|
||||
<charset>UTF-8</charset>
|
||||
<show>public</show>
|
||||
<nohelp>true</nohelp>
|
||||
<links>
|
||||
<link>http://docs.oracle.com/javase/6/docs/api/</link>
|
||||
<link>http://jd.bukkit.org/dev/apidocs/</link>
|
||||
<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-assembly-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<configuration>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<descriptors>
|
||||
<descriptor>distribution.xml</descriptor>
|
||||
</descriptors>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>deploy</phase>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>assembly</goal>
|
||||
<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>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<id>jitpack.io</id>
|
||||
<name>Vault Repository</name>
|
||||
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
||||
<url>https://jitpack.io/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mikeprimm-repo</id>
|
||||
<name>Dynmap repository</name>
|
||||
<url>http://repo.mikeprimm.com/</url>
|
||||
<url>https://repo.mikeprimm.com/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>onarandombox-repo</id>
|
||||
<name>Multiverse repository</name>
|
||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||
<url>http://repo.onarandombox.com/content/repositories/multiverse/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<name>Spigot Maven Repository</name>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public</url>
|
||||
<id>codemc-repo</id>
|
||||
<name>CodeMC Repository</name>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>minebuilders-repo</id>
|
||||
<name>HawkEye Reloaded repository</name>
|
||||
<url>http://minebuilders.me:8080/plugin/repository/everything</url>
|
||||
<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>http://repo.md-5.net/content/repositories/releases</url>
|
||||
<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>bukkit</artifactId>
|
||||
<version>1.9.4-R0.1-SNAPSHOT</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>net.milkbowl.vault</groupId>
|
||||
<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.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.6</version>
|
||||
<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>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>uk.co.oliwali</groupId>
|
||||
<artifactId>HawkEye</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/HawkEye.jar</systemPath>
|
||||
<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>2.5</version>
|
||||
<version>4.1.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.5.00</version>
|
||||
<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>
|
||||
@@ -5,245 +5,31 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.github.ucchyocean.lc.bridge.DynmapBridge;
|
||||
import com.github.ucchyocean.lc.bridge.HawkEyeBridge;
|
||||
import com.github.ucchyocean.lc.bridge.McMMOBridge;
|
||||
import com.github.ucchyocean.lc.bridge.MultiverseCoreBridge;
|
||||
import com.github.ucchyocean.lc.bridge.VaultChatBridge;
|
||||
import com.github.ucchyocean.lc.channel.ChannelManager;
|
||||
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 {
|
||||
|
||||
private static LunaChat instance;
|
||||
|
||||
private LunaChatConfig config;
|
||||
private ChannelManager manager;
|
||||
|
||||
private VaultChatBridge vaultchat;
|
||||
private DynmapBridge dynmap;
|
||||
private HawkEyeBridge hawkeye;
|
||||
private MultiverseCoreBridge multiverse;
|
||||
|
||||
private ExpireCheckTask 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() {
|
||||
|
||||
// 変数などの初期化
|
||||
config = new LunaChatConfig();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// HawkEye のロード
|
||||
temp = getServer().getPluginManager().getPlugin("HawkEye");
|
||||
if ( temp != null ) {
|
||||
hawkeye = HawkEyeBridge.load(temp);
|
||||
}
|
||||
|
||||
// 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 PlayerListener(), this);
|
||||
|
||||
// コマンドの登録
|
||||
lunachatCommand = new LunaChatCommand();
|
||||
messageCommand = new LunaChatMessageCommand();
|
||||
replyCommand = new LunaChatReplyCommand();
|
||||
lcjapanizeCommand = new LunaChatJapanizeCommand();
|
||||
|
||||
// 期限チェッカータスクの起動
|
||||
expireCheckerTask = new ExpireCheckTask();
|
||||
expireCheckerTask.runTaskTimerAsynchronously(this, 100, 600);
|
||||
}
|
||||
|
||||
/**
|
||||
* プラグインが無効化されたときに呼び出されるメソッド
|
||||
* @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.onCommand(sender, command, label, args);
|
||||
} else if ( command.getName().equals("tell") ) {
|
||||
return messageCommand.onCommand(sender, command, label, args);
|
||||
} else if ( command.getName().equals("reply") ) {
|
||||
return replyCommand.onCommand(sender, command, label, args);
|
||||
} else if ( command.getName().equals("lcjapanize") ) {
|
||||
return lcjapanizeCommand.onCommand(sender, command, 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(sender, command, label, args);
|
||||
}
|
||||
if ( completeList != null ) {
|
||||
return completeList;
|
||||
}
|
||||
return super.onTabComplete(sender, command, label, args);
|
||||
}
|
||||
private static LunaChat instance = new LunaChat();
|
||||
@SuppressWarnings("deprecation")
|
||||
private LunaChatAPI api = new LunaChatAPIImpl();
|
||||
|
||||
/**
|
||||
* LunaChatのインスタンスを返す
|
||||
* @return LunaChat
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public static LunaChat getInstance() {
|
||||
if ( instance == null ) {
|
||||
instance = (LunaChat)Bukkit.getPluginManager().getPlugin("LunaChat");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* このプラグインのJarファイル自身を示すFileクラスを返す。
|
||||
* @return Jarファイル
|
||||
*/
|
||||
protected static File getPluginJarFile() {
|
||||
return getInstance().getFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatAPIを取得する
|
||||
* @return LunaChatAPI
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* HawkEye連携クラスを返す
|
||||
* @return HawkEyeBridge
|
||||
*/
|
||||
public HawkEyeBridge getHawkEye() {
|
||||
return hawkeye;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 api;
|
||||
}
|
||||
}
|
||||
@@ -1,195 +1,215 @@
|
||||
/*
|
||||
* @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.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
|
||||
*/
|
||||
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 sender チャンネルを作成した人
|
||||
* @return 作成されたチャンネル
|
||||
*/
|
||||
public Channel createChannel(String channelName, CommandSender sender);
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @return 削除したかどうか
|
||||
*/
|
||||
public boolean removeChannel(String channelName);
|
||||
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @param sender チャンネルを削除した人
|
||||
* @return 削除したかどうか
|
||||
*/
|
||||
public boolean removeChannel(String channelName, CommandSender sender);
|
||||
|
||||
/**
|
||||
* テンプレートを取得する
|
||||
* @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 HashMap<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<ChannelPlayer> getHidelist(ChannelPlayer key);
|
||||
|
||||
/**
|
||||
* 該当のプレイヤーがhideしているプレイヤーのリストを返す。
|
||||
* @param player プレイヤー
|
||||
* @return 指定したプレイヤーがhideしているプレイヤーのリスト
|
||||
*/
|
||||
public ArrayList<ChannelPlayer> getHideinfo(ChannelPlayer player);
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーが、指定されたプレイヤーをhideするように設定する。
|
||||
* @param player hideする側のプレイヤー
|
||||
* @param hided hideされる側のプレイヤー
|
||||
*/
|
||||
public void addHidelist(ChannelPlayer player, ChannelPlayer hided);
|
||||
|
||||
/**
|
||||
* 指定されたプレイヤーが、指定されたプレイヤーのhideを解除するように設定する。
|
||||
* @param player hideしていた側のプレイヤー
|
||||
* @param hided hideされていた側のプレイヤー
|
||||
*/
|
||||
public void removeHidelist(ChannelPlayer player, ChannelPlayer 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();
|
||||
}
|
||||
/*
|
||||
* @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,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.getInstance().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,342 +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.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* ユーティリティクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class Utility {
|
||||
|
||||
private static Boolean isCB178orLaterCache;
|
||||
private static Boolean isCB19orLaterCache;
|
||||
|
||||
/**
|
||||
* 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"));
|
||||
|
||||
// CB190以降は、書き出すファイルエンコードにUTF-8を強制する。see issue #141.
|
||||
if ( isCB19orLater() ) {
|
||||
writer = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
|
||||
} else {
|
||||
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.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列内のカラーコード候補(&a)を、カラーコード(§a)に置き換えする
|
||||
* @param source 置き換え元の文字列
|
||||
* @return 置き換え後の文字列
|
||||
*/
|
||||
public static String replaceColorCode(String source) {
|
||||
if (source == null)
|
||||
return null;
|
||||
return ChatColor.translateAlternateColorCodes('&', source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列に含まれているカラーコード(§a)を除去して返す
|
||||
* @param source 置き換え元の文字列
|
||||
* @return 置き換え後の文字列
|
||||
*/
|
||||
public static String stripColor(String source) {
|
||||
if (source == null)
|
||||
return null;
|
||||
return ChatColor.stripColor(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された文字数のアスタリスクの文字列を返す
|
||||
* @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]");
|
||||
}
|
||||
|
||||
/**
|
||||
* 現在動作中のCraftBukkitが、v1.7.8 以上かどうかを確認する
|
||||
* @return v1.7.8以上ならtrue、そうでないならfalse
|
||||
*/
|
||||
public static boolean isCB178orLater() {
|
||||
if ( isCB178orLaterCache == null ) {
|
||||
isCB178orLaterCache = isUpperVersion(Bukkit.getBukkitVersion(), "1.7.8");
|
||||
}
|
||||
return isCB178orLaterCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* 現在動作中のCraftBukkitが、v1.9 以上かどうかを確認する
|
||||
* @return v1.9以上ならtrue、そうでないならfalse
|
||||
*/
|
||||
public static boolean isCB19orLater() {
|
||||
if ( isCB19orLaterCache == null ) {
|
||||
isCB19orLaterCache = isUpperVersion(Bukkit.getBukkitVersion(), "1.9");
|
||||
}
|
||||
return isCB19orLaterCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたバージョンが、基準より新しいバージョンかどうかを確認する
|
||||
* @param version 確認するバージョン
|
||||
* @param border 基準のバージョン
|
||||
* @return 基準より確認対象の方が新しいバージョンかどうか<br/>
|
||||
* ただし、無効なバージョン番号(数値でないなど)が指定された場合はfalseに、
|
||||
* 2つのバージョンが完全一致した場合はtrueになる。
|
||||
*/
|
||||
public static boolean isUpperVersion(String version, String border) {
|
||||
|
||||
int hyphen = version.indexOf("-");
|
||||
if ( hyphen > 0 ) {
|
||||
version = version.substring(0, hyphen);
|
||||
}
|
||||
|
||||
String[] versionArray = version.split("\\.");
|
||||
int[] versionNumbers = new int[versionArray.length];
|
||||
for ( int i=0; i<versionArray.length; i++ ) {
|
||||
if ( !versionArray[i].matches("[0-9]+") )
|
||||
return false;
|
||||
versionNumbers[i] = Integer.parseInt(versionArray[i]);
|
||||
}
|
||||
|
||||
String[] borderArray = border.split("\\.");
|
||||
int[] borderNumbers = new int[borderArray.length];
|
||||
for ( int i=0; i<borderArray.length; i++ ) {
|
||||
if ( !borderArray[i].matches("[0-9]+") )
|
||||
return false;
|
||||
borderNumbers[i] = Integer.parseInt(borderArray[i]);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
while ( (versionNumbers.length > index) && (borderNumbers.length > index) ) {
|
||||
if ( versionNumbers[index] > borderNumbers[index] ) {
|
||||
return true;
|
||||
} else if ( versionNumbers[index] < borderNumbers[index] ) {
|
||||
return false;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
if ( borderNumbers.length == index ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 現在接続中のプレイヤーを全て取得する
|
||||
* @return 接続中の全てのプレイヤー
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static ArrayList<Player> getOnlinePlayers() {
|
||||
// CB179以前と、CB1710以降で戻り値が異なるため、
|
||||
// リフレクションを使って互換性を(無理やり)保つ。
|
||||
try {
|
||||
if (Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0]).getReturnType() == Collection.class) {
|
||||
Collection<?> temp =
|
||||
((Collection<?>) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0])
|
||||
.invoke(null, new Object[0]));
|
||||
return new ArrayList<Player>((Collection<? extends Player>) temp);
|
||||
} else {
|
||||
Player[] temp =
|
||||
((Player[]) Bukkit.class.getMethod("getOnlinePlayers", new Class<?>[0])
|
||||
.invoke(null, new Object[0]));
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player t : temp) {
|
||||
players.add(t);
|
||||
}
|
||||
return players;
|
||||
}
|
||||
} catch (NoSuchMethodException ex) {} // never happen
|
||||
catch (InvocationTargetException ex) {} // never happen
|
||||
catch (IllegalAccessException ex) {} // never happen
|
||||
return new ArrayList<Player>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 現在のサーバー接続人数を返します。
|
||||
* @return サーバー接続人数
|
||||
*/
|
||||
public static int getOnlinePlayersCount() {
|
||||
return getOnlinePlayers().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された名前のオフラインプレイヤーを取得する
|
||||
* @param name プレイヤー名
|
||||
* @return オフラインプレイヤー
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static OfflinePlayer getOfflinePlayer(String name) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
if (player == null || (!player.hasPlayedBefore() && !player.isOnline()))
|
||||
return null;
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された名前のプレイヤーを取得する
|
||||
* @param name プレイヤー名
|
||||
* @return プレイヤー
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Player getPlayerExact(String name) {
|
||||
return Bukkit.getPlayer(stripColor(name));
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2015
|
||||
*/
|
||||
package com.github.ucchyocean.lc.bridge;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
|
||||
import uk.co.oliwali.HawkEye.DataType;
|
||||
import uk.co.oliwali.HawkEye.entry.DataEntry;
|
||||
import uk.co.oliwali.HawkEye.util.HawkEyeAPI;
|
||||
|
||||
/**
|
||||
* HawkEye連携クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class HawkEyeBridge {
|
||||
|
||||
private boolean isV162orLater;
|
||||
|
||||
/** コンストラクタは使用不可 */
|
||||
private HawkEyeBridge() {
|
||||
}
|
||||
|
||||
/**
|
||||
* HawkEye Reloaded をロードする
|
||||
* @param plugin HawkEye Reloaded のプラグインインスタンス
|
||||
* @return ロードしたブリッジのインスタンス
|
||||
*/
|
||||
public static HawkEyeBridge load(Plugin plugin) {
|
||||
|
||||
String version = plugin.getDescription().getVersion();
|
||||
HawkEyeBridge instance = new HawkEyeBridge();
|
||||
instance.isV162orLater = Utility.isUpperVersion(version, "1.6.2");
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* HawkEyeにCHATログを書き出す
|
||||
* @param player プレイヤー名
|
||||
* @param location 場所
|
||||
* @param data データ
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void writeLog(String player, Location location, String data) {
|
||||
DataEntry entry = new DataEntry(player, DataType.CHAT, location, data);
|
||||
if ( isV162orLater ) {
|
||||
HawkEyeAPI.addEntry(entry);
|
||||
} else {
|
||||
HawkEyeAPI.addEntry(LunaChat.getInstance(), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -1,781 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2014
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc.LunaChatLogger;
|
||||
import com.github.ucchyocean.lc.NGWordAction;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.bridge.DynmapBridge;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelChatEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelMessageEvent;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
|
||||
/**
|
||||
* チャンネルの実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ChannelImpl extends Channel {
|
||||
|
||||
private static final String PERMISSION_SPEAK_PREFIX = "lunachat.speak";
|
||||
|
||||
private static final String INFO_FIRSTLINE = Resources.get("channelInfoFirstLine");
|
||||
private static final String INFO_PREFIX = Resources.get("channelInfoPrefix");
|
||||
private static final String INFO_ALIAS = Resources.get("channelInfoAlias");
|
||||
private static final String INFO_GLOBAL = Resources.get("channelInfoGlobal");
|
||||
private static final String INFO_BROADCAST = Resources.get("channelInfoBroadcast");
|
||||
private static final String INFO_SECRET = Resources.get("channelInfoSecret");
|
||||
private static final String INFO_PASSWORD = Resources.get("channelInfoPassword");
|
||||
private static final String INFO_WORLDCHAT = Resources.get("channelInfoWorldChat");
|
||||
private static final String INFO_RANGECHAT = Resources.get("channelInfoRangeChat");
|
||||
private static final String INFO_FORMAT = Resources.get("channelInfoFormat");
|
||||
private static final String INFO_BANNED = Resources.get("channelInfoBanned");
|
||||
private static final String INFO_MUTED = Resources.get("channelInfoMuted");
|
||||
|
||||
private static final String LIST_ENDLINE = Resources.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Resources.get("listFormat");
|
||||
|
||||
private static final String MSG_BAN_NGWORD = Resources.get("banNGWordMessage");
|
||||
private static final String MSG_KICK_NGWORD = Resources.get("kickNGWordMessage");
|
||||
private static final String MSG_MUTE_NGWORD = Resources.get("muteNGWordMessage");
|
||||
|
||||
private static final String MSG_BAN_EXPIRED = Resources.get("expiredBanMessage");
|
||||
private static final String MSG_MUTE_EXPIRED = Resources.get("expiredMuteMessage");
|
||||
private static final String MSG_BAN_EXPIRED_PLAYER = Resources.get("cmdmsgPardoned");
|
||||
private static final String MSG_MUTE_EXPIRED_PLAYER = Resources.get("cmdmsgUnmuted");
|
||||
|
||||
private static final String PREINFO = Resources.get("infoPrefix");
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
|
||||
private static final String MSG_NO_RECIPIENT = Resources.get("noRecipientMessage");
|
||||
|
||||
private static final String ERRMSG_MUTED = Resources.get("errmsgMuted");
|
||||
|
||||
private SimpleDateFormat dateFormat;
|
||||
private SimpleDateFormat timeFormat;
|
||||
|
||||
/** ロガー */
|
||||
private LunaChatLogger logger;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name チャンネル名
|
||||
*/
|
||||
protected ChannelImpl(String name) {
|
||||
|
||||
super(name);
|
||||
|
||||
logger = new LunaChatLogger(name.replace(">", "-"));
|
||||
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||||
timeFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
}
|
||||
|
||||
/**
|
||||
* このチャットに発言をする
|
||||
* @param player 発言をするプレイヤー
|
||||
* @param message 発言をするメッセージ
|
||||
*/
|
||||
@Override
|
||||
public void chat(ChannelPlayer player, String message) {
|
||||
|
||||
// 発言権限を確認する
|
||||
String node = PERMISSION_SPEAK_PREFIX + "." + getName();
|
||||
if ( player.isPermissionSet(node) && !player.hasPermission(node) ) {
|
||||
sendResourceMessage(player, PREERR, "errmsgPermission",
|
||||
PERMISSION_SPEAK_PREFIX + "." + getName());
|
||||
return;
|
||||
}
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
|
||||
// Muteされているかどうかを確認する
|
||||
if ( getMuted().contains(player) ) {
|
||||
player.sendMessage( PREERR + ERRMSG_MUTED );
|
||||
return;
|
||||
}
|
||||
|
||||
String preReplaceMessage = new String(message);
|
||||
String maskedMessage = new String(message);
|
||||
|
||||
// 一時的にJapanizeスキップ設定かどうかを確認する
|
||||
boolean skipJapanize = false;
|
||||
String marker = config.getNoneJapanizeMarker();
|
||||
if ( !marker.equals("") && maskedMessage.startsWith(marker) ) {
|
||||
skipJapanize = true;
|
||||
maskedMessage = maskedMessage.substring(marker.length());
|
||||
}
|
||||
|
||||
// NGワード発言をしたかどうかのチェックとマスク
|
||||
boolean isNG = false;
|
||||
for ( Pattern pattern : config.getNgwordCompiled() ) {
|
||||
Matcher matcher = pattern.matcher(maskedMessage);
|
||||
if ( matcher.find() ) {
|
||||
maskedMessage = matcher.replaceAll(
|
||||
Utility.getAstariskString(matcher.group(0).length()));
|
||||
isNG = true;
|
||||
}
|
||||
}
|
||||
|
||||
// キーワード置き換え
|
||||
String msgFormat = replaceKeywords(getFormat(), player);
|
||||
|
||||
// カラーコード置き換え
|
||||
// チャンネルで許可されていて、発言者がパーミッションを持っている場合に置き換える
|
||||
if ( isAllowCC() && player.hasPermission("lunachat.allowcc") ) {
|
||||
maskedMessage = Utility.replaceColorCode(maskedMessage);
|
||||
}
|
||||
|
||||
// イベントコール
|
||||
LunaChatChannelChatEvent event =
|
||||
new LunaChatChannelChatEvent(getName(), player,
|
||||
preReplaceMessage, maskedMessage, msgFormat);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if ( event.isCancelled() ) {
|
||||
return;
|
||||
}
|
||||
msgFormat = event.getMessageFormat();
|
||||
maskedMessage = event.getNgMaskedMessage();
|
||||
|
||||
// 2byteコードを含むか、半角カタカナのみなら、Japanize変換は行わない
|
||||
String kanaTemp = Utility.stripColor(maskedMessage);
|
||||
if ( !skipJapanize &&
|
||||
( kanaTemp.getBytes().length > kanaTemp.length() ||
|
||||
kanaTemp.matches("[ \\uFF61-\\uFF9F]+") ) ) {
|
||||
skipJapanize = true;
|
||||
}
|
||||
|
||||
// Japanize変換タスクを作成する
|
||||
boolean isIncludeSyncChat = true;
|
||||
DelayedJapanizeConvertTask delayedTask = null;
|
||||
JapanizeType japanizeType = (getJapanizeType() == null)
|
||||
? config.getJapanizeType() : getJapanizeType();
|
||||
|
||||
if ( !skipJapanize &&
|
||||
api.isPlayerJapanize(player.getName()) &&
|
||||
japanizeType != JapanizeType.NONE ) {
|
||||
|
||||
int lineType = config.getJapanizeDisplayLine();
|
||||
String jpFormat;
|
||||
String messageFormat = null;
|
||||
if ( lineType == 1 ) {
|
||||
jpFormat = Utility.replaceColorCode(config.getJapanizeLine1Format());
|
||||
messageFormat = msgFormat;
|
||||
isIncludeSyncChat = false;
|
||||
} else {
|
||||
jpFormat = Utility.replaceColorCode(config.getJapanizeLine2Format());
|
||||
}
|
||||
|
||||
// タスクを作成しておく
|
||||
delayedTask = new DelayedJapanizeChannelChatTask(maskedMessage,
|
||||
japanizeType, this, player, jpFormat, messageFormat);
|
||||
}
|
||||
|
||||
if ( isIncludeSyncChat ) {
|
||||
// メッセージの送信
|
||||
sendMessage(player, maskedMessage, msgFormat, true, player.getDisplayName());
|
||||
}
|
||||
|
||||
// 非同期実行タスクがある場合、追加で実行する
|
||||
if ( delayedTask != null ) {
|
||||
delayedTask.runTaskAsynchronously(LunaChat.getInstance());
|
||||
}
|
||||
|
||||
// NGワード発言者に、NGワードアクションを実行する
|
||||
if ( isNG && player != null ) {
|
||||
if ( config.getNgwordAction() == NGWordAction.BAN ) {
|
||||
// BANする
|
||||
|
||||
if ( !isGlobalChannel() ) {
|
||||
getBanned().add(player);
|
||||
removeMember(player);
|
||||
if ( !MSG_BAN_NGWORD.equals("") ) {
|
||||
String m = replaceKeywordsForSystemMessages(
|
||||
MSG_BAN_NGWORD, player.getName());
|
||||
player.sendMessage(m);
|
||||
sendMessage(null, m, null, true, "system");
|
||||
}
|
||||
}
|
||||
|
||||
} else if ( config.getNgwordAction() == NGWordAction.KICK ) {
|
||||
// キックする
|
||||
|
||||
if ( !isGlobalChannel() ) {
|
||||
removeMember(player);
|
||||
if ( !MSG_KICK_NGWORD.equals("") ) {
|
||||
String m = replaceKeywordsForSystemMessages(
|
||||
MSG_KICK_NGWORD, player.getName());
|
||||
player.sendMessage(m);
|
||||
sendMessage(null, m, null, true, "system");
|
||||
}
|
||||
}
|
||||
|
||||
} else if ( config.getNgwordAction() == NGWordAction.MUTE ) {
|
||||
// Muteする
|
||||
|
||||
getMuted().add(player);
|
||||
save();
|
||||
if ( !MSG_MUTE_NGWORD.equals("") ) {
|
||||
String m = replaceKeywordsForSystemMessages(
|
||||
MSG_MUTE_NGWORD, player.getName());
|
||||
player.sendMessage(m);
|
||||
sendMessage(null, m, null, true, "system");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ほかの連携先などから、このチャットに発言する
|
||||
* @param player プレイヤー名
|
||||
* @param source 連携元を判別する文字列
|
||||
* @param message メッセージ
|
||||
*/
|
||||
@Override
|
||||
public void chatFromOtherSource(String player, String source, String message) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
|
||||
// 表示名
|
||||
String name = player + "@" + source;
|
||||
|
||||
// NGワード発言のマスク
|
||||
String maskedMessage = new String(message);
|
||||
for ( Pattern pattern : config.getNgwordCompiled() ) {
|
||||
Matcher matcher = pattern.matcher(maskedMessage);
|
||||
if ( matcher.find() ) {
|
||||
maskedMessage = matcher.replaceAll(
|
||||
Utility.getAstariskString(matcher.group(0).length()));
|
||||
}
|
||||
}
|
||||
|
||||
// キーワード置き換え
|
||||
String msgFormat = replaceKeywordsForSystemMessages(getFormat(), name);
|
||||
msgFormat = msgFormat.replace("%prefix", "");
|
||||
msgFormat = msgFormat.replace("%suffix", "");
|
||||
|
||||
// カラーコード置き換え チャンネルで許可されている場合に置き換える。
|
||||
if ( isAllowCC() ) {
|
||||
maskedMessage = Utility.replaceColorCode(maskedMessage);
|
||||
}
|
||||
|
||||
// メッセージの送信
|
||||
boolean sendDynmap = source == null || !source.equals("web");
|
||||
sendMessage(null, maskedMessage, msgFormat, sendDynmap, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーに関連する、システムメッセージをチャンネルに流す
|
||||
* @param key リソースキー
|
||||
* @param player プレイヤー
|
||||
*/
|
||||
@Override
|
||||
protected void sendSystemMessage(String key, ChannelPlayer player) {
|
||||
|
||||
// プライベートチャットならシステムメッセージを流さない
|
||||
if ( isPersonalChat() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = Resources.get(key);
|
||||
if ( msg == null || msg.equals("") ) {
|
||||
return;
|
||||
}
|
||||
msg = replaceKeywordsForSystemMessages(msg, player.getName());
|
||||
sendMessage(null, msg, null, false, "system");
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを表示します。指定したプレイヤーの発言として処理されます。
|
||||
* @param player プレイヤー(ワールドチャット、範囲チャットの場合は必須です)
|
||||
* @param message メッセージ
|
||||
* @param format フォーマット
|
||||
* @param sendDynmap dynmapへ送信するかどうか
|
||||
* @param name 発言者名
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(ChannelPlayer player, String message,
|
||||
String format, boolean sendDynmap, String name) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
|
||||
String originalMessage = new String(message);
|
||||
|
||||
// 受信者を設定する
|
||||
ArrayList<ChannelPlayer> recipients = new ArrayList<ChannelPlayer>();
|
||||
boolean sendNoRecipientMessage = false;
|
||||
|
||||
if ( isBroadcastChannel() ) {
|
||||
// ブロードキャストチャンネル
|
||||
|
||||
if ( isWorldRange() && player != null &&
|
||||
player.isOnline() && player.getPlayer() != null ) {
|
||||
|
||||
World w = player.getPlayer().getWorld();
|
||||
|
||||
if ( getChatRange() > 0 ) {
|
||||
// 範囲チャット
|
||||
|
||||
Location origin = player.getPlayer().getLocation();
|
||||
for ( Player p : Utility.getOnlinePlayers() ) {
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(p);
|
||||
if ( p.getWorld().equals(w) &&
|
||||
origin.distance(p.getLocation()) <= getChatRange() &&
|
||||
!getHided().contains(cp) ) {
|
||||
recipients.add(ChannelPlayer.getChannelPlayer(p));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// ワールドチャット
|
||||
|
||||
for ( Player p : Utility.getOnlinePlayers() ) {
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(p);
|
||||
if ( p.getWorld().equals(w) && !getHided().contains(cp) ) {
|
||||
recipients.add(ChannelPlayer.getChannelPlayer(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 受信者が自分以外いない場合は、メッセージを表示する
|
||||
if ( !MSG_NO_RECIPIENT.equals("") && (
|
||||
recipients.size() == 0 ||
|
||||
(recipients.size() == 1 &&
|
||||
recipients.get(0).getName().equals(player.getName()) ) ) ) {
|
||||
sendNoRecipientMessage = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
// 通常ブロードキャスト(全員へ送信)
|
||||
|
||||
for ( Player p : Utility.getOnlinePlayers() ) {
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(p);
|
||||
if ( !getHided().contains(cp) ) {
|
||||
recipients.add(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// 通常チャンネル
|
||||
|
||||
for ( ChannelPlayer mem : getMembers() ) {
|
||||
if ( mem != null && mem.isOnline() && !getHided().contains(mem) ) {
|
||||
recipients.add(mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// opListenAllChannel 設定がある場合は、
|
||||
// パーミッション lunachat-admin.listen-all-channels を持つプレイヤーを
|
||||
// 受信者に加える。
|
||||
if ( config.isOpListenAllChannel() ) {
|
||||
for ( Player p : Utility.getOnlinePlayers() ) {
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(p);
|
||||
if ( cp.hasPermission("lunachat-admin.listen-all-channels")
|
||||
&& !recipients.contains(cp) ) {
|
||||
recipients.add(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hideされている場合は、受信対象者から抜く。
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
for ( ChannelPlayer cp : api.getHidelist(player) ) {
|
||||
if ( recipients.contains(cp) ) {
|
||||
recipients.remove(cp);
|
||||
}
|
||||
}
|
||||
|
||||
// フォーマットがある場合は置き換える
|
||||
if ( format != null ) {
|
||||
message = format.replace("%msg", message);
|
||||
}
|
||||
|
||||
// イベントコール
|
||||
LunaChatChannelMessageEvent event =
|
||||
new LunaChatChannelMessageEvent(
|
||||
getName(), player, message, recipients, name, originalMessage);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
message = event.getMessage();
|
||||
recipients = event.getRecipients();
|
||||
|
||||
// 通常ブロードキャストなら、設定に応じてdynmapへ送信する
|
||||
DynmapBridge dynmap = LunaChat.getInstance().getDynmap();
|
||||
if ( config.isSendBroadcastChannelChatToDynmap() &&
|
||||
sendDynmap &&
|
||||
dynmap != null &&
|
||||
isBroadcastChannel() &&
|
||||
!isWorldRange() ) {
|
||||
if ( config.isSendFormattedMessageToDynmap() ) {
|
||||
if ( player != null && player.getPlayer() != null ) {
|
||||
dynmap.chat(player.getPlayer(), message);
|
||||
} else {
|
||||
dynmap.broadcast(message);
|
||||
}
|
||||
} else {
|
||||
if ( player != null && player.getPlayer() != null ) {
|
||||
dynmap.chat(player.getPlayer(), originalMessage);
|
||||
} else {
|
||||
dynmap.broadcast(originalMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 送信する
|
||||
for ( ChannelPlayer p : recipients ) {
|
||||
p.sendMessage(message);
|
||||
}
|
||||
|
||||
// 設定に応じて、コンソールに出力する
|
||||
if ( config.isDisplayChatOnConsole() ) {
|
||||
Bukkit.getLogger().info(ChatColor.stripColor(message));
|
||||
}
|
||||
|
||||
// 受信者が自分以外いない場合は、メッセージを表示する
|
||||
if ( sendNoRecipientMessage ) {
|
||||
String msg = replaceKeywordsForSystemMessages(MSG_NO_RECIPIENT, "");
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
|
||||
// ロギング
|
||||
log(originalMessage, name, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル情報を返す
|
||||
* @param forModerator モデレータ向けの情報を含めるかどうか
|
||||
* @return チャンネル情報
|
||||
*/
|
||||
@Override
|
||||
public ArrayList<String> getInfo(boolean forModerator) {
|
||||
|
||||
ArrayList<String> info = new ArrayList<String>();
|
||||
info.add(INFO_FIRSTLINE);
|
||||
|
||||
// チャンネル名、参加人数、総人数、チャンネル説明文
|
||||
info.add( String.format(
|
||||
LIST_FORMAT, getName(), getOnlineNum(), getTotalNum(), getDescription()) );
|
||||
|
||||
// チャンネル別名
|
||||
String alias = getAlias();
|
||||
if ( alias != null && alias.length() > 0 ) {
|
||||
info.add(INFO_ALIAS + alias);
|
||||
}
|
||||
|
||||
// 参加メンバー一覧
|
||||
if ( isGlobalChannel() ) {
|
||||
info.add(INFO_GLOBAL);
|
||||
} else if ( isBroadcastChannel() ) {
|
||||
info.add(INFO_BROADCAST);
|
||||
} else {
|
||||
// メンバーを、5人ごとに表示する
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(INFO_PREFIX);
|
||||
|
||||
for ( int i=0; i<getMembers().size(); i++ ) {
|
||||
|
||||
if ( i%5 == 0 && i != 0 ) {
|
||||
info.add(buf.toString());
|
||||
buf = new StringBuffer();
|
||||
buf.append(INFO_PREFIX);
|
||||
}
|
||||
|
||||
ChannelPlayer cp = getMembers().get(i);
|
||||
String name = cp.getName();
|
||||
String disp;
|
||||
if ( getModerator().contains(cp) ) {
|
||||
name = "@" + name;
|
||||
}
|
||||
if ( cp.isOnline() ) {
|
||||
if ( getHided().contains(cp) )
|
||||
disp = ChatColor.DARK_AQUA + name;
|
||||
else
|
||||
disp = ChatColor.WHITE + name;
|
||||
} else {
|
||||
disp = ChatColor.GRAY + name;
|
||||
}
|
||||
buf.append(disp + ",");
|
||||
}
|
||||
|
||||
info.add(buf.toString());
|
||||
}
|
||||
|
||||
// シークレットチャンネルかどうか
|
||||
if ( !isVisible() ) {
|
||||
info.add(INFO_SECRET);
|
||||
}
|
||||
|
||||
// パスワード設定があるかどうか
|
||||
if ( getPassword().length() > 0 ) {
|
||||
if ( !forModerator ) {
|
||||
info.add(INFO_PASSWORD);
|
||||
} else {
|
||||
info.add(INFO_PASSWORD + " " + getPassword());
|
||||
}
|
||||
}
|
||||
|
||||
// 範囲チャット、ワールドチャット
|
||||
if ( isWorldRange() && getChatRange() > 0 ) {
|
||||
info.add(String.format(INFO_RANGECHAT, getChatRange()));
|
||||
} else if ( isWorldRange() ) {
|
||||
info.add(INFO_WORLDCHAT);
|
||||
}
|
||||
|
||||
if ( forModerator ) {
|
||||
|
||||
// フォーマット情報
|
||||
info.add(INFO_FORMAT);
|
||||
info.add(INFO_PREFIX + " " + ChatColor.WHITE + getFormat());
|
||||
|
||||
// Muteリスト情報、5人ごとに表示する
|
||||
if ( getMuted().size() > 0 ) {
|
||||
info.add(INFO_MUTED);
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(INFO_PREFIX + ChatColor.WHITE);
|
||||
for ( int i=0; i<getMuted().size(); i++ ) {
|
||||
if ( i%5 == 0 && i != 0 ) {
|
||||
info.add(buf.toString());
|
||||
buf = new StringBuffer();
|
||||
buf.append(INFO_PREFIX + ChatColor.WHITE);
|
||||
}
|
||||
buf.append(getMuted().get(i).getName() + ",");
|
||||
}
|
||||
|
||||
info.add(buf.toString());
|
||||
}
|
||||
|
||||
// BANリスト情報、5人ごとに表示する
|
||||
if ( getBanned().size() > 0 ) {
|
||||
info.add(INFO_BANNED);
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(INFO_PREFIX + ChatColor.WHITE);
|
||||
for ( int i=0; i<getBanned().size(); i++ ) {
|
||||
if ( i%5 == 0 && i != 0 ) {
|
||||
info.add(buf.toString());
|
||||
buf = new StringBuffer();
|
||||
buf.append(INFO_PREFIX + ChatColor.WHITE);
|
||||
}
|
||||
buf.append(getBanned().get(i).getName() + ",");
|
||||
}
|
||||
|
||||
info.add(buf.toString());
|
||||
}
|
||||
}
|
||||
|
||||
info.add(LIST_ENDLINE);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* ログファイルを読み込んで、ログデータを取得する
|
||||
* @param player プレイヤー名、フィルタしないならnullを指定すること
|
||||
* @param filter フィルタ、フィルタしないならnullを指定すること
|
||||
* @param date 日付、今日のデータを取得するならnullを指定すること
|
||||
* @param reverse 逆順取得
|
||||
* @return ログデータ
|
||||
*/
|
||||
public ArrayList<String> getLog(
|
||||
String player, String filter, String date, boolean reverse) {
|
||||
|
||||
return logger.getLog(player, filter, date, reverse);
|
||||
}
|
||||
|
||||
/**
|
||||
* 期限付きBanや期限付きMuteをチェックし、期限が切れていたら解除を行う
|
||||
*/
|
||||
@Override
|
||||
public void checkExpires() {
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
// 期限付きBANのチェック
|
||||
for ( ChannelPlayer cp : getBanExpires().keySet() ) {
|
||||
if ( getBanExpires().get(cp) <= now ) {
|
||||
|
||||
// 期限マップから削除し、BANを解除
|
||||
getBanExpires().remove(cp);
|
||||
if ( getBanned().contains(cp) ) {
|
||||
getBanned().remove(cp);
|
||||
save();
|
||||
|
||||
// メッセージ通知を流す
|
||||
if ( !MSG_BAN_EXPIRED.equals("") ) {
|
||||
String msg = replaceKeywords(MSG_BAN_EXPIRED, cp);
|
||||
sendMessage(null, msg, null, false, "system");
|
||||
}
|
||||
|
||||
if ( cp.isOnline() && !MSG_BAN_EXPIRED_PLAYER.equals("") ) {
|
||||
String msg = PREINFO + String.format(MSG_BAN_EXPIRED_PLAYER, getName());
|
||||
cp.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 期限付きMuteのチェック
|
||||
for ( ChannelPlayer cp : getMuteExpires().keySet() ) {
|
||||
if ( getMuteExpires().get(cp) <= now ) {
|
||||
|
||||
// 期限マップから削除し、Muteを解除
|
||||
getMuteExpires().remove(cp);
|
||||
if ( getMuted().contains(cp) ) {
|
||||
getMuted().remove(cp);
|
||||
save();
|
||||
|
||||
// メッセージ通知を流す
|
||||
if ( !MSG_MUTE_EXPIRED.equals("") ) {
|
||||
String msg = replaceKeywords(MSG_MUTE_EXPIRED, cp);
|
||||
sendMessage(null, msg, null, false, "system");
|
||||
}
|
||||
|
||||
if ( cp.isOnline() && !MSG_MUTE_EXPIRED_PLAYER.equals("") ) {
|
||||
String msg = PREINFO + String.format(MSG_MUTE_EXPIRED_PLAYER, getName());
|
||||
cp.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットフォーマット内のキーワードを置き換えする
|
||||
* @param format チャットフォーマット
|
||||
* @param player プレイヤー
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
private String replaceKeywords(String format, ChannelPlayer player) {
|
||||
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
|
||||
String msg = format;
|
||||
|
||||
// テンプレートのキーワードを、まず最初に置き換える
|
||||
for ( int i=0; i<=9; i++ ) {
|
||||
String key = "%" + i;
|
||||
if ( msg.contains(key) ) {
|
||||
if ( api.getTemplate("" + i) != null ) {
|
||||
msg = msg.replace(key, api.getTemplate("" + i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg = msg.replace("%ch", getName());
|
||||
//msg = msg.replace("%msg", message);
|
||||
msg = msg.replace("%color", getColorCode());
|
||||
msg = msg.replace("%to", getPrivateMessageTo());
|
||||
|
||||
if ( msg.contains("%date") ) {
|
||||
msg = msg.replace("%date", dateFormat.format(new Date()));
|
||||
}
|
||||
if ( msg.contains("%time") ) {
|
||||
msg = msg.replace("%time", timeFormat.format(new Date()));
|
||||
}
|
||||
|
||||
if ( player != null ) {
|
||||
msg = msg.replace("%username", player.getDisplayName());
|
||||
msg = msg.replace("%player", player.getName());
|
||||
|
||||
if ( msg.contains("%prefix") || msg.contains("%suffix") ) {
|
||||
msg = msg.replace("%prefix", player.getPrefix());
|
||||
msg = msg.replace("%suffix", player.getSuffix());
|
||||
}
|
||||
|
||||
if ( msg.contains("%world") ) {
|
||||
|
||||
String worldname = null;
|
||||
if ( LunaChat.getInstance().getMultiverseCore() != null ) {
|
||||
worldname = LunaChat.getInstance().getMultiverseCore().getWorldAlias(player.getWorldName());
|
||||
}
|
||||
if ( worldname == null || worldname.equals("") ) {
|
||||
worldname = player.getWorldName();
|
||||
}
|
||||
msg = msg.replace("%world", worldname);
|
||||
}
|
||||
|
||||
} else {
|
||||
msg = msg.replace("%username", "");
|
||||
msg = msg.replace("%player", "");
|
||||
msg = msg.replace("%prefix", "");
|
||||
msg = msg.replace("%suffix", "");
|
||||
msg = msg.replace("%world", "");
|
||||
}
|
||||
|
||||
return Utility.replaceColorCode(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットフォーマット内のキーワードを置き換えする
|
||||
* @param format チャットフォーマット
|
||||
* @param playerName プレイヤー名
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
private String replaceKeywordsForSystemMessages(String format, String playerName) {
|
||||
|
||||
String msg = format;
|
||||
msg = msg.replace("%ch", getName());
|
||||
msg = msg.replace("%color", getColorCode());
|
||||
msg = msg.replace("%username", playerName);
|
||||
msg = msg.replace("%player", playerName);
|
||||
|
||||
return Utility.replaceColorCode(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* ログを記録する
|
||||
* @param name 発言者
|
||||
* @param message 記録するメッセージ
|
||||
* @param player プレイヤー
|
||||
*/
|
||||
private void log(String message, String name, ChannelPlayer player) {
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
if ( config.isLoggingChat() && logger != null ) {
|
||||
logger.log(message, name);
|
||||
}
|
||||
if ( config.isLoggingChatToHawkEye() && LunaChat.getInstance().getHawkEye() != null
|
||||
&& player != null && player.getLocation() != null ) {
|
||||
LunaChat.getInstance().getHawkEye().writeLog(name, player.getLocation(),
|
||||
"channel(" + getName() + ")-" + Utility.stripColor(message));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
* @param player メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
private void sendResourceMessage(
|
||||
ChannelPlayer player, String pre, String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
|
||||
/**
|
||||
* プレイヤーの抽象クラス
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public abstract class ChannelPlayer implements Comparable<ChannelPlayer> {
|
||||
|
||||
@@ -136,12 +135,10 @@ public abstract class ChannelPlayer implements Comparable<ChannelPlayer> {
|
||||
String id = nameOrUuid.substring(1);
|
||||
return new ChannelPlayerUUID(id);
|
||||
}
|
||||
if ( Utility.isCB178orLater() ) {
|
||||
ChannelPlayer player =
|
||||
ChannelPlayerUUID.getChannelPlayerUUIDFromName(nameOrUuid);
|
||||
if ( player != null ) {
|
||||
return player;
|
||||
}
|
||||
ChannelPlayer player =
|
||||
ChannelPlayerUUID.getChannelPlayerUUIDFromName(nameOrUuid);
|
||||
if ( player != null ) {
|
||||
return player;
|
||||
}
|
||||
return new ChannelPlayerName(nameOrUuid);
|
||||
}
|
||||
@@ -158,9 +155,7 @@ public abstract class ChannelPlayer implements Comparable<ChannelPlayer> {
|
||||
return new ChannelPlayerBlock((BlockCommandSender)sender);
|
||||
} else if ( sender instanceof ConsoleCommandSender ) {
|
||||
return new ChannelPlayerConsole((ConsoleCommandSender)sender);
|
||||
} else if ( Utility.isCB178orLater() ) {
|
||||
return ChannelPlayerUUID.getChannelPlayer(sender);
|
||||
}
|
||||
return new ChannelPlayerName(sender.getName());
|
||||
return ChannelPlayerUUID.getChannelPlayer(sender);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* コマンドブロック
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class ChannelPlayerBlock extends ChannelPlayer {
|
||||
|
||||
@@ -161,4 +162,8 @@ public class ChannelPlayerBlock extends ChannelPlayer {
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public BlockCommandSender getBlockCommandSender() {
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* コンソール
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class ChannelPlayerConsole extends ChannelPlayer {
|
||||
|
||||
|
||||
@@ -10,12 +10,10 @@ import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.bridge.VaultChatBridge;
|
||||
|
||||
/**
|
||||
* 名前管理のプレイヤー
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class ChannelPlayerName extends ChannelPlayer {
|
||||
|
||||
@@ -70,14 +68,6 @@ public class ChannelPlayerName extends ChannelPlayer {
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
VaultChatBridge vault = LunaChat.getInstance().getVaultChat();
|
||||
if ( vault == null ) {
|
||||
return "";
|
||||
}
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return vault.getPlayerPrefix(player);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -88,14 +78,6 @@ public class ChannelPlayerName extends ChannelPlayer {
|
||||
*/
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
VaultChatBridge vault = LunaChat.getInstance().getVaultChat();
|
||||
if ( vault == null ) {
|
||||
return "";
|
||||
}
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return vault.getPlayerSuffix(player);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -117,7 +99,6 @@ public class ChannelPlayerName extends ChannelPlayer {
|
||||
* @return Player
|
||||
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getPlayer()
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return Bukkit.getPlayerExact(name);
|
||||
|
||||
@@ -13,12 +13,10 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.bridge.VaultChatBridge;
|
||||
|
||||
/**
|
||||
* UUID管理のプレイヤー
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class ChannelPlayerUUID extends ChannelPlayer {
|
||||
|
||||
@@ -46,12 +44,10 @@ public class ChannelPlayerUUID extends ChannelPlayer {
|
||||
* @return ChannelPlayerUUID
|
||||
*/
|
||||
public static ChannelPlayerUUID getChannelPlayerUUIDFromName(String name) {
|
||||
@SuppressWarnings("deprecation")
|
||||
Player player = Bukkit.getPlayerExact(name);
|
||||
if ( player != null ) {
|
||||
return new ChannelPlayerUUID(player.getUniqueId());
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offline = Bukkit.getOfflinePlayer(name);
|
||||
if ( offline != null && offline.getUniqueId() != null ) {
|
||||
return new ChannelPlayerUUID(offline.getUniqueId());
|
||||
@@ -121,14 +117,6 @@ public class ChannelPlayerUUID extends ChannelPlayer {
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
VaultChatBridge vault = LunaChat.getInstance().getVaultChat();
|
||||
if ( vault == null ) {
|
||||
return "";
|
||||
}
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return vault.getPlayerPrefix(player);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -139,14 +127,6 @@ public class ChannelPlayerUUID extends ChannelPlayer {
|
||||
*/
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
VaultChatBridge vault = LunaChat.getInstance().getVaultChat();
|
||||
if ( vault == null ) {
|
||||
return "";
|
||||
}
|
||||
Player player = getPlayer();
|
||||
if ( player != null ) {
|
||||
return vault.getPlayerSuffix(player);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2015
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
|
||||
/**
|
||||
* Japanize2行表示のときに、変換結果を遅延してチャンネルに表示するためのタスク
|
||||
* @author ucchy
|
||||
*/
|
||||
public class DelayedJapanizeChannelChatTask extends DelayedJapanizeConvertTask {
|
||||
|
||||
private Channel channel;
|
||||
private ChannelPlayer player;
|
||||
private String lineFormat;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param org 変換前の文字列
|
||||
* @param type 変換タイプ
|
||||
* @param channel 変換後に発言する、発言先チャンネル
|
||||
* @param player 発言したプレイヤー
|
||||
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
|
||||
* @param lineFormat
|
||||
*/
|
||||
public DelayedJapanizeChannelChatTask(String org, JapanizeType type, Channel channel,
|
||||
ChannelPlayer player, String japanizeFormat, String lineFormat) {
|
||||
super(org, type, channel, player, japanizeFormat);
|
||||
this.channel = channel;
|
||||
this.player = player;
|
||||
this.lineFormat = lineFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if ( runSync() ) {
|
||||
// チャンネルへ送信
|
||||
String name = (player != null) ? player.getDisplayName() : "";
|
||||
channel.sendMessage(player, getResult(), lineFormat, true, name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2015
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
|
||||
/**
|
||||
* Japanize2行表示のときに、変換結果を遅延して通常チャットに表示するためのタスク
|
||||
* @author ucchy
|
||||
*/
|
||||
public class DelayedJapanizeNormalChatTask extends DelayedJapanizeConvertTask {
|
||||
|
||||
private ChannelPlayer player;
|
||||
private AsyncPlayerChatEvent event;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param org 変換前の文字列
|
||||
* @param type 変換タイプ
|
||||
* @param player 発言したプレイヤー
|
||||
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
|
||||
* @param event イベント
|
||||
*/
|
||||
public DelayedJapanizeNormalChatTask(String org, JapanizeType type,
|
||||
ChannelPlayer player, String japanizeFormat, final AsyncPlayerChatEvent event) {
|
||||
super(org, type, null, player, japanizeFormat);
|
||||
this.player = player;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if ( runSync() ) {
|
||||
|
||||
String result = getResult();
|
||||
|
||||
// 送信
|
||||
for ( Player p : event.getRecipients() ) {
|
||||
p.sendMessage(result);
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(result);
|
||||
|
||||
// 設定に応じてdynmapへ送信する
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().
|
||||
isSendBroadcastChannelChatToDynmap() &&
|
||||
LunaChat.getInstance().getDynmap() != null ) {
|
||||
if ( player != null && player.getPlayer() != null )
|
||||
LunaChat.getInstance().getDynmap().chat(player.getPlayer(), result);
|
||||
else
|
||||
LunaChat.getInstance().getDynmap().broadcast(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,226 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* checkコマンドの実行クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class CheckCommand 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 = "check";
|
||||
private static final String PERMISSION_NODE = "lunachat-admin." + COMMAND_NAME;
|
||||
private static final String USAGE_KEY1 = "usageCheck1";
|
||||
private static final String USAGE_KEY2 = "usageCheck2";
|
||||
private static final String COMMAND_TRACKER_NAME = "lunachat-check-command";
|
||||
|
||||
private boolean consoleRemoveTracker;
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @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.ADMIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用方法に関するメッセージをsenderに送信します。
|
||||
* @param sender コマンド実行者
|
||||
* @param label 実行ラベル
|
||||
* @see com.github.ucchyocean.lc.command.SubCommandAbst#sendUsageMessage()
|
||||
*/
|
||||
@Override
|
||||
public void sendUsageMessage(
|
||||
CommandSender sender, String label) {
|
||||
sendResourceMessage(sender, "", USAGE_KEY1, label);
|
||||
sendResourceMessage(sender, "", USAGE_KEY2, 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) {
|
||||
|
||||
boolean isRemove = false;
|
||||
|
||||
Player player = null;
|
||||
if ( sender instanceof Player ) {
|
||||
player = (Player)sender;
|
||||
}
|
||||
|
||||
// 引数チェック
|
||||
// このコマンドは、コンソールでも実行できる
|
||||
if (args.length >= 2 && args[1].equalsIgnoreCase("remove")) {
|
||||
if (player != null && player.hasMetadata(COMMAND_TRACKER_NAME)) {
|
||||
// フラグをたてて、トラッカーを除去する
|
||||
isRemove = true;
|
||||
player.removeMetadata(COMMAND_TRACKER_NAME, LunaChat.getInstance());
|
||||
} else if (sender instanceof ConsoleCommandSender && consoleRemoveTracker) {
|
||||
// フラグをたてて、トラッカーを除去する
|
||||
isRemove = true;
|
||||
consoleRemoveTracker = false;
|
||||
} else {
|
||||
// トラッカーが確認できない実行者には、警告を表示して終了する
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotInCheckRemoveConfirm", label);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isRemove ) {
|
||||
// チェックの実行と確認メッセージ
|
||||
ArrayList<Channel> list = getCheckList();
|
||||
if ( list.size() == 0 ) {
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgCheck", list.size());
|
||||
} else {
|
||||
sendCheckListMessages(sender, list);
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgCheck", list.size());
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgCheckConfirm", label);
|
||||
|
||||
// コマンドトラッカーを設定する
|
||||
if (player != null) {
|
||||
player.setMetadata(COMMAND_TRACKER_NAME,
|
||||
new FixedMetadataValue(LunaChat.getInstance(), true));
|
||||
} else if (sender instanceof ConsoleCommandSender) {
|
||||
consoleRemoveTracker = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// クリーンアップの実行
|
||||
int counter = 0;
|
||||
ArrayList<Channel> list = getCheckList();
|
||||
for ( Channel channel : list ) {
|
||||
if ( api.removeChannel(channel.getName(), sender) ) {
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgCheckRemove", counter);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 削除対象となるチャンネルのリストを返す
|
||||
* @return 削除対象のチャンネルのリスト
|
||||
*/
|
||||
private ArrayList<Channel> getCheckList() {
|
||||
|
||||
ArrayList<Channel> list = new ArrayList<Channel>();
|
||||
for ( Channel channel : api.getChannels() ) {
|
||||
if ( channel.getModerator().size() == 0 &&
|
||||
!channel.isBroadcastChannel() && !channel.isPersonalChat() ) {
|
||||
list.add(channel);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 削除対象となるチャンネルを、リスト表示で通知する
|
||||
* @param sender 通知先
|
||||
* @param list 対象チャンネル
|
||||
*/
|
||||
private void sendCheckListMessages(CommandSender sender, ArrayList<Channel> list) {
|
||||
|
||||
Player player = null;
|
||||
if ( sender instanceof Player ) {
|
||||
player = (Player)sender;
|
||||
}
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
String dchannel = "";
|
||||
String playerName = "";
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(player);
|
||||
if ( player != null ) {
|
||||
playerName = player.getName();
|
||||
Channel def = api.getDefaultChannel(playerName);
|
||||
if ( def != null ) {
|
||||
dchannel = def.getName();
|
||||
}
|
||||
}
|
||||
|
||||
// メッセージを作成する
|
||||
items.add(LIST_FIRSTLINE);
|
||||
for ( Channel channel : list ) {
|
||||
|
||||
// デフォルト発言先なら赤にする。
|
||||
String disp = ChatColor.WHITE + channel.getName();
|
||||
if ( channel.getName().equalsIgnoreCase(dchannel) ) {
|
||||
disp = ChatColor.RED + channel.getName();
|
||||
}
|
||||
|
||||
if ( player != null &&
|
||||
!channel.getMembers().contains(cp) &&
|
||||
!channel.isGlobalChannel() ) {
|
||||
|
||||
// 参加していないチャンネルならグレーにする
|
||||
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);
|
||||
|
||||
// メッセージを送信する
|
||||
for (String msg : items) {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +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.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* 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");
|
||||
ChannelPlayer inviter = ChannelPlayer.getChannelPlayer(inviterName);
|
||||
if (inviter != null) {
|
||||
sendResourceMessage(inviter, PREINFO, "cmdmsgDenyed");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* 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_KEY1 = "usageHide";
|
||||
private static final String USAGE_KEY2 = "usageHidePlayer";
|
||||
|
||||
private static final String HIDE_CHANNEL_FIRSTLINE =
|
||||
Resources.get("hideChannelFirstLine");
|
||||
private static final String HIDE_PLAYER_FIRSTLINE =
|
||||
Resources.get("hidePlayerFirstLine");
|
||||
private static final String LIST_ENDLINE = Resources.get("listEndLine");
|
||||
private static final String LIST_PREFIX = Resources.get("listPlainPrefix");
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @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_KEY1, label);
|
||||
sendResourceMessage(sender, "", USAGE_KEY2, 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;
|
||||
}
|
||||
ChannelPlayer player = ChannelPlayer.getChannelPlayer(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;
|
||||
}
|
||||
|
||||
// 指定されたコマンドが「/ch hide list」なら、リストを表示して終了
|
||||
if ( cname != null && cname.equals("list") ) {
|
||||
for ( String item : getHideInfoList(player) ) {
|
||||
player.sendMessage(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// チャンネルかプレイヤーが存在するかどうかをチェックする
|
||||
boolean isChannelCommand = false;
|
||||
Channel channel = api.getChannel(cname);
|
||||
if ( channel != null ) {
|
||||
isChannelCommand = true;
|
||||
} else if ( Utility.getOfflinePlayer(cname) == null ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotExistChannelAndPlayer");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( isChannelCommand ) {
|
||||
// チャンネルが対象の場合の処理
|
||||
|
||||
// 既に非表示になっていないかどうかをチェックする
|
||||
if ( channel.getHided().contains(player) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgAlreadyHided");
|
||||
return true;
|
||||
}
|
||||
|
||||
// メンバーかどうかをチェックする
|
||||
if ( !channel.getMembers().contains(player) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNomember");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 設定する
|
||||
channel.getHided().add(player);
|
||||
channel.save();
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgHided", channel.getName());
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// プレイヤーが対象の場合の処理
|
||||
|
||||
// 既に非表示になっていないかどうかをチェックする
|
||||
ChannelPlayer hided = ChannelPlayer.getChannelPlayer(cname);
|
||||
if ( api.getHidelist(hided).contains(player) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgAlreadyHidedPlayer");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 自分自身を指定していないかどうかチェックする
|
||||
if ( hided.equals(player) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgCannotHideSelf");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 設定する
|
||||
api.addHidelist(player, hided);
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgHidedPlayer", hided.getDisplayName());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* hide情報のメッセージを取得する
|
||||
* @param player 対象となるプレイヤー
|
||||
* @return メッセージ
|
||||
*/
|
||||
private ArrayList<String> getHideInfoList(ChannelPlayer player) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
items.add(HIDE_CHANNEL_FIRSTLINE);
|
||||
for ( String channel : getHideChannelNameList(player) ) {
|
||||
items.add(LIST_PREFIX + channel);
|
||||
}
|
||||
items.add(HIDE_PLAYER_FIRSTLINE);
|
||||
for ( ChannelPlayer p : api.getHideinfo(player) ) {
|
||||
items.add(LIST_PREFIX + p.getDisplayName());
|
||||
}
|
||||
items.add(LIST_ENDLINE);
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定したプレイヤーが非表示にしているチャンネル名のリストを返す
|
||||
* @param player プレイヤー
|
||||
* @return 指定したプレイヤーが非表示にしているチャンネルのリスト
|
||||
*/
|
||||
private ArrayList<String> getHideChannelNameList(ChannelPlayer player) {
|
||||
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
for ( Channel channel : api.getChannels() ) {
|
||||
if ( channel.getHided().contains(player) ) {
|
||||
names.add(channel.getName());
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(player);
|
||||
|
||||
items.add(LIST_FIRSTLINE);
|
||||
for ( Channel channel : api.getChannels() ) {
|
||||
|
||||
// BANされているチャンネルは表示しない
|
||||
if ( channel.getBanned().contains(cp) ) {
|
||||
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(cp) ) {
|
||||
disp = ChatColor.DARK_AQUA + channel.getName();
|
||||
}
|
||||
|
||||
if ( player != null &&
|
||||
!channel.getMembers().contains(cp) &&
|
||||
!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,139 +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.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;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* 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.getInstance().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;
|
||||
}
|
||||
|
||||
// 指定されたプレイヤーが存在するかチェック
|
||||
ChannelPlayer target = ChannelPlayer.getChannelPlayer(args[0]);
|
||||
if ( target == null || !target.isOnline() ) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgNotfoundPlayer", args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Japanize設定をon/offにする
|
||||
boolean value = args[1].equalsIgnoreCase("on");
|
||||
LunaChatAPI api = LunaChat.getInstance().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 org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
* @param cp メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
protected void sendResourceMessage(ChannelPlayer cp, String pre,
|
||||
String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
cp.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,157 +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.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* 1:1チャット送信コマンド
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatMessageCommand implements CommandExecutor {
|
||||
|
||||
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) {
|
||||
|
||||
// senderからChannelPlayerを作成する
|
||||
ChannelPlayer inviter = ChannelPlayer.getChannelPlayer(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(ChannelPlayer inviter, String invitedName, String message) {
|
||||
|
||||
// 招待相手が存在するかどうかを確認する
|
||||
ChannelPlayer invited = ChannelPlayer.getChannelPlayer(invitedName);
|
||||
if ( invited == null || !invited.isOnline() ) {
|
||||
sendResourceMessage(inviter, PREERR,
|
||||
"errmsgNotfoundPlayer", invitedName);
|
||||
return;
|
||||
}
|
||||
|
||||
// 招待相手が自分自身でないか確認する
|
||||
if (inviter.getName().equals(invited.getName())) {
|
||||
sendResourceMessage(inviter, PREERR,
|
||||
"errmsgCannotSendPMSelf");
|
||||
return;
|
||||
}
|
||||
|
||||
// チャンネルが存在するかどうかをチェックする
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
String cname = inviter.getName() + ">" + invited.getName();
|
||||
Channel channel = api.getChannel(cname);
|
||||
if ( channel == null ) {
|
||||
// チャンネルを作成して、送信者、受信者をメンバーにする
|
||||
channel = api.createChannel(cname);
|
||||
channel.setVisible(false);
|
||||
channel.addMember(inviter);
|
||||
channel.addMember(invited);
|
||||
channel.setPrivateMessageTo(invited.getName());
|
||||
}
|
||||
|
||||
// メッセージがあるなら送信する
|
||||
if ( message.trim().length() > 0 ) {
|
||||
channel.chat(inviter, message);
|
||||
}
|
||||
|
||||
// 送信履歴を残す
|
||||
DataMaps.privateMessageMap.put(
|
||||
invited.getName(), inviter.getName());
|
||||
DataMaps.privateMessageMap.put(
|
||||
inviter.getName(), invited.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 org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
protected void sendResourceMessage(ChannelPlayer cp, String pre,
|
||||
String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
cp.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,64 +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 com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* 1:1チャット受信コマンド
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatReplyCommand extends LunaChatMessageCommand {
|
||||
|
||||
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) {
|
||||
|
||||
// senderからChannelPlayerを作成する
|
||||
ChannelPlayer inviter = ChannelPlayer.getChannelPlayer(sender);
|
||||
|
||||
// 会話相手を履歴から取得する
|
||||
String invitedName = DataMaps.privateMessageMap.get(inviter.getName());
|
||||
|
||||
// 引数が無ければ、現在の会話相手を表示して終了する
|
||||
if (args.length == 0) {
|
||||
if ( invitedName == null ) {
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgReplyInviterNone", inviter.getName());
|
||||
} else {
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgReplyInviter", inviter.getName(), invitedName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 会話相手がからっぽなら、コマンドを終了する。
|
||||
if ( invitedName == null ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotfoundPM");
|
||||
return true;
|
||||
}
|
||||
|
||||
// メッセージを取得する
|
||||
StringBuilder message = new StringBuilder();
|
||||
for ( int i=0; i<args.length; i++ ) {
|
||||
message.append(args[i] + " ");
|
||||
}
|
||||
|
||||
sendTellMessage(inviter, invitedName, message.toString().trim());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,181 +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;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* サブコマンドの抽象クラス
|
||||
* @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.getInstance().getLunaChatAPI();
|
||||
config = LunaChat.getInstance().getLunaChatConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、Channelに送信する
|
||||
* @param channel メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param player キーワード置き換えに使用するプレイヤー
|
||||
*/
|
||||
protected void sendResourceMessageWithKeyword(
|
||||
Channel channel, String key, ChannelPlayer player) {
|
||||
|
||||
String msg = Resources.get(key);
|
||||
if ( msg == null || msg.equals("") ) {
|
||||
return;
|
||||
}
|
||||
msg = msg.replace("%ch", channel.getName());
|
||||
msg = msg.replace("%color", channel.getColorCode());
|
||||
if ( player != null ) {
|
||||
msg = msg.replace("%username", player.getDisplayName());
|
||||
msg = msg.replace("%player", player.getName());
|
||||
} else {
|
||||
msg = msg.replace("%username", "");
|
||||
msg = msg.replace("%player", "");
|
||||
}
|
||||
msg = Utility.replaceColorCode(msg);
|
||||
channel.sendMessage(null, msg, null, true, "system");
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、Channelに送信する
|
||||
* @param channel メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param player キーワード置き換えに使用するプレイヤー
|
||||
* @param minutes キーワード置き換えに使用する数値
|
||||
*/
|
||||
protected void sendResourceMessageWithKeyword(
|
||||
Channel channel, String key, ChannelPlayer player, int minutes) {
|
||||
|
||||
String msg = Resources.get(key);
|
||||
if ( msg == null || msg.equals("") ) {
|
||||
return;
|
||||
}
|
||||
msg = msg.replace("%ch", channel.getName());
|
||||
msg = msg.replace("%color", channel.getColorCode());
|
||||
msg = msg.replace("%d", String.valueOf(minutes));
|
||||
if ( player != null ) {
|
||||
msg = msg.replace("%username", player.getDisplayName());
|
||||
msg = msg.replace("%player", player.getName());
|
||||
} else {
|
||||
msg = msg.replace("%username", "");
|
||||
msg = msg.replace("%player", "");
|
||||
}
|
||||
msg = Utility.replaceColorCode(msg);
|
||||
channel.sendMessage(null, msg, null, true, "system");
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
protected void sendResourceMessage(
|
||||
CommandSender sender, String pre, String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、ChannelPlayerに送信する
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
protected void sendResourceMessage(
|
||||
ChannelPlayer cp, String pre, String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
cp.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,145 +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.Utility;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
|
||||
/**
|
||||
* 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_KEY1 = "usageUnhide";
|
||||
private static final String USAGE_KEY2 = "usageUnhidePlayer";
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
* @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_KEY1, label);
|
||||
sendResourceMessage(sender, "", USAGE_KEY2, 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;
|
||||
}
|
||||
ChannelPlayer player = ChannelPlayer.getChannelPlayer(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;
|
||||
}
|
||||
|
||||
// チャンネルかプレイヤーが存在するかどうかをチェックする
|
||||
boolean isChannelCommand = false;
|
||||
Channel channel = api.getChannel(cname);
|
||||
if ( channel != null ) {
|
||||
isChannelCommand = true;
|
||||
} else if ( Utility.getOfflinePlayer(cname) == null ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgNotExistChannelAndPlayer");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( isChannelCommand ) {
|
||||
// チャンネルが対象の場合の処理
|
||||
|
||||
// 非表示になっているかどうかをチェックする
|
||||
if ( !channel.getHided().contains(player) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgAlreadyUnhided");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 設定する
|
||||
channel.getHided().remove(player);
|
||||
channel.save();
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgUnhided", channel.getName());
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// プレイヤーが対象の場合の処理
|
||||
|
||||
// 既に表示になっていないかどうかをチェックする
|
||||
ChannelPlayer hided = ChannelPlayer.getChannelPlayer(cname);
|
||||
if ( !api.getHidelist(hided).contains(player) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgAlreadyUnhidedPlayer");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 設定する
|
||||
api.removeHidelist(player, hided);
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgUnhidedPlayer", hided.getDisplayName());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import org.bukkit.event.Cancellable;
|
||||
/**
|
||||
* 基底のキャンセル可能イベントクラス
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatBaseCancellableEvent extends LunaChatBaseEvent implements Cancellable {
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc.event;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@@ -14,6 +15,7 @@ import com.github.ucchyocean.lc.channel.Channel;
|
||||
/**
|
||||
* 基底イベントクラス
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public abstract class LunaChatBaseEvent extends Event {
|
||||
|
||||
@@ -25,6 +27,7 @@ public abstract class LunaChatBaseEvent extends Event {
|
||||
* @param channelName チャンネル名
|
||||
*/
|
||||
public LunaChatBaseEvent(String channelName) {
|
||||
super(!Bukkit.isPrimaryThread());
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
/**
|
||||
* チャンネルチャットのチャットイベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelChatEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.github.ucchyocean.lc.channel.Channel;
|
||||
/**
|
||||
* チャンネル作成イベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelCreateEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
/**
|
||||
* メンバー変更イベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelMemberChangedEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
* チャンネルチャットのメッセージイベント、
|
||||
* このイベントはキャンセルできない。
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelMessageEvent extends LunaChatBaseEvent {
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.bukkit.command.CommandSender;
|
||||
/**
|
||||
* オプション変更イベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelOptionChangedEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
/**
|
||||
* チャンネル削除イベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatChannelRemoveEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
/**
|
||||
* Japanize変換が行われた後に呼び出されるイベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatPostJapanizeEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
/**
|
||||
* チャンネルチャットへの発言前に発生するイベント
|
||||
* @author ucchy
|
||||
* @deprecated Legacy Version
|
||||
*/
|
||||
public class LunaChatPreChatEvent extends LunaChatBaseCancellableEvent {
|
||||
|
||||
|
||||
@@ -13,10 +13,7 @@ public enum JapanizeType {
|
||||
KANA("kana"),
|
||||
|
||||
/** カナ変換後、GoogleIMEで漢字変換 */
|
||||
GOOGLE_IME("googleime"),
|
||||
|
||||
/** カナ変換後、SocialIMEで漢字変換 */
|
||||
SOCIAL_IME("socialime");
|
||||
GOOGLE_IME("googleime");
|
||||
|
||||
private String id;
|
||||
|
||||
|
||||
@@ -1,179 +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("gw", new String[]{"ぐぁ","ぐぃ","ぐぅ","ぐぇ","ぐぉ"});
|
||||
TABLE.put("zy", new String[]{"じゃ","じぃ","じゅ","じぇ","じょ"});
|
||||
TABLE.put("jy", new String[]{"じゃ","じぃ","じゅ","じぇ","じょ"});
|
||||
TABLE.put("dy", new String[]{"ぢゃ","ぢぃ","ぢゅ","ぢぇ","ぢょ"});
|
||||
TABLE.put("dh", new String[]{"でゃ","でぃ","でゅ","でぇ","でょ"});
|
||||
TABLE.put("dw", new String[]{"どぁ","どぃ","どぅ","どぇ","どぉ"});
|
||||
TABLE.put("by", new String[]{"びゃ","びぃ","びゅ","びぇ","びょ"});
|
||||
TABLE.put("py", new String[]{"ぴゃ","ぴぃ","ぴゅ","ぴぇ","ぴょ"});
|
||||
TABLE.put( "v", new String[]{"ヴぁ","ヴぃ","ヴ","ヴぇ","ヴぉ"});
|
||||
TABLE.put("vy", new String[]{"ヴゃ","ヴぃ","ヴゅ","ヴぇ","ヴょ"});
|
||||
TABLE.put("sh", new String[]{"しゃ","し","しゅ","しぇ","しょ"});
|
||||
TABLE.put("sy", new String[]{"しゃ","し","しゅ","しぇ","しょ"});
|
||||
TABLE.put( "c", new String[]{"か","し","く","せ","こ"});
|
||||
TABLE.put("ch", new String[]{"ちゃ","ち","ちゅ","ちぇ","ちょ"});
|
||||
TABLE.put("cy", new String[]{"ちゃ","ち","ちゅ","ちぇ","ちょ"});
|
||||
TABLE.put( "f", new String[]{"ふぁ","ふぃ","ふ","ふぇ","ふぉ"});
|
||||
TABLE.put("fy", new String[]{"ふゃ","ふぃ","ふゅ","ふぇ","ふょ"});
|
||||
TABLE.put("fw", new String[]{"ふぁ","ふぃ","ふ","ふぇ","ふぉ"});
|
||||
TABLE.put( "q", new String[]{"くぁ","くぃ","く","くぇ","くぉ"});
|
||||
TABLE.put("ky", new String[]{"きゃ","きぃ","きゅ","きぇ","きょ"});
|
||||
TABLE.put("kw", new String[]{"くぁ","くぃ","く","くぇ","くぉ"});
|
||||
TABLE.put("ty", new String[]{"ちゃ","ちぃ","ちゅ","ちぇ","ちょ"});
|
||||
TABLE.put("ts", new String[]{"つぁ","つぃ","つ","つぇ","つぉ"});
|
||||
TABLE.put("th", new String[]{"てゃ","てぃ","てゅ","てぇ","てょ"});
|
||||
TABLE.put("tw", new String[]{"とぁ","とぃ","とぅ","とぇ","とぉ"});
|
||||
TABLE.put("ny", new String[]{"にゃ","にぃ","にゅ","にぇ","にょ"});
|
||||
TABLE.put("hy", new String[]{"ひゃ","ひぃ","ひゅ","ひぇ","ひょ"});
|
||||
TABLE.put("my", new String[]{"みゃ","みぃ","みゅ","みぇ","みょ"});
|
||||
TABLE.put("ry", new String[]{"りゃ","りぃ","りゅ","りぇ","りょ"});
|
||||
TABLE.put( "l", new String[]{"ぁ","ぃ","ぅ","ぇ","ぉ"});
|
||||
TABLE.put( "x", new String[]{"ぁ","ぃ","ぅ","ぇ","ぉ"});
|
||||
TABLE.put("ly", new String[]{"ゃ","ぃ","ゅ","ぇ","ょ"});
|
||||
TABLE.put("lt", new String[]{"た","ち","っ","て","と"});
|
||||
TABLE.put("lk", new String[]{"ヵ","き","く","ヶ","こ"});
|
||||
TABLE.put("xy", new String[]{"ゃ","ぃ","ゅ","ぇ","ょ"});
|
||||
TABLE.put("xt", new String[]{"た","ち","っ","て","と"});
|
||||
TABLE.put("xk", new String[]{"ヵ","き","く","ヶ","こ"});
|
||||
TABLE.put("wy", new String[]{"わ","ゐ","う","ゑ","を"});
|
||||
TABLE.put("wh", 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 if ( tmp.equals(".") ) {
|
||||
line.append(last + "。");
|
||||
last = "";
|
||||
} else if ( tmp.equals(",") ) {
|
||||
line.append(last + "、");
|
||||
last = "";
|
||||
} else if ( tmp.equals("?") ) {
|
||||
line.append(last + "?");
|
||||
last = "";
|
||||
} else if ( tmp.equals("!") ) {
|
||||
line.append(last + "!");
|
||||
last = "";
|
||||
} else if ( tmp.equals("[") ) {
|
||||
line.append(last + "「");
|
||||
last = "";
|
||||
} else if ( tmp.equals("]") ) {
|
||||
line.append(last + "」");
|
||||
last = "";
|
||||
} else if ( tmp.equals("<") ) {
|
||||
line.append(last + "<");
|
||||
last = "";
|
||||
} else if ( tmp.equals(">") ) {
|
||||
line.append(last + ">");
|
||||
last = "";
|
||||
} else if ( tmp.equals("&") ) {
|
||||
line.append(last + "&");
|
||||
last = "";
|
||||
} else if ( tmp.equals("\"") ) {
|
||||
line.append(last + "”");
|
||||
last = "";
|
||||
} else if ( tmp.equals("(") || tmp.equals(")") ) {
|
||||
line.append(last);
|
||||
last = "";
|
||||
} else {
|
||||
line.append(last + tmp);
|
||||
last = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
line.append(last);
|
||||
|
||||
return line.toString();
|
||||
}
|
||||
}
|
||||
+5
-8
@@ -1,19 +1,17 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2014
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
|
||||
/**
|
||||
* 各チャンネルの期限付きBANや期限付きMuteを、1分間隔で確認しに行くタスク
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ExpireCheckTask extends BukkitRunnable {
|
||||
public class ExpireCheckTask implements Runnable {
|
||||
|
||||
/**
|
||||
* 1分ごとに呼び出されるメソッド
|
||||
@@ -21,8 +19,7 @@ public class ExpireCheckTask extends BukkitRunnable {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
for ( Channel channel :
|
||||
LunaChat.getInstance().getLunaChatAPI().getChannels() ) {
|
||||
for ( Channel channel : LunaChat.getAPI().getChannels() ) {
|
||||
channel.checkExpires();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* @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 {
|
||||
|
||||
/** Bukkit→BungeeCord チャット発言内容の転送に使用するプラグインメッセージチャンネル名 */
|
||||
public static final String PMC_MESSAGE = "lunachat:message";
|
||||
|
||||
private static PluginInterface instance;
|
||||
private static LunaChatMode mode;
|
||||
private static EventSenderInterface esender;
|
||||
|
||||
// LunaChatに実行元プラグインクラスを設定する
|
||||
static void setPlugin(PluginInterface plugin) {
|
||||
instance = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのプラグインクラスを取得する
|
||||
* @return プラグインクラス、BukkitモードならLunaChatBukkit、BungeeCordモードならLunaChatBungee
|
||||
*/
|
||||
public static PluginInterface getPlugin() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
// LunaChatの実行モードを設定する
|
||||
static void setMode(LunaChatMode _mode) {
|
||||
mode = _mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatの実行モードを取得する
|
||||
* @return 実行モード(BUKKIT or BUNGEE)
|
||||
*/
|
||||
public static LunaChatMode getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
// LunaChatのイベント実行クラスを取得する
|
||||
static void setEventSender(EventSenderInterface eventSender) {
|
||||
esender = eventSender;
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのイベント実行クラスを取得する
|
||||
* @return イベント実行クラス
|
||||
*/
|
||||
public static EventSenderInterface getEventSender() {
|
||||
return esender;
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのデータ格納フォルダを取得する
|
||||
* @return データ格納フォルダ
|
||||
*/
|
||||
public static File getDataFolder() {
|
||||
return instance.getDataFolder();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのJarファイルを取得する
|
||||
* @return Jarファイル
|
||||
*/
|
||||
public static File getPluginJarFile() {
|
||||
return instance.getPluginJarFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのコンフィグを取得する
|
||||
* @return コンフィグ
|
||||
*/
|
||||
public static LunaChatConfig getConfig() {
|
||||
return instance.getLunaChatConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのAPIを取得する
|
||||
* @return API
|
||||
*/
|
||||
public static LunaChatAPI getAPI() {
|
||||
return instance.getLunaChatAPI();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatの通常チャットロガーを取得する
|
||||
* @return 通常チャットロガー
|
||||
*/
|
||||
public static LunaChatLogger getNormalChatLogger() {
|
||||
return instance.getNormalChatLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのUUIDキャッシュを取得する
|
||||
* @return UUIDキャッシュ
|
||||
*/
|
||||
public static UUIDCacheData getUUIDCacheData() {
|
||||
return instance.getUUIDCacheData();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatで非同期タスクを実行する
|
||||
* @param task 実行するタスク
|
||||
*/
|
||||
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,321 @@
|
||||
/*
|
||||
* @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());
|
||||
|
||||
// プラグインチャンネル登録
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, LunaChat.PMC_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* プラグインが無効化されたときに呼び出されるメソッド
|
||||
* @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("japanize") ) {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* プラグインメッセージを送信する
|
||||
* @param bytes 送信内容
|
||||
*/
|
||||
public void sendPluginMessage(byte[] bytes) {
|
||||
getServer().sendPluginMessage(this, LunaChat.PMC_MESSAGE, bytes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* @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", "w"));
|
||||
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());
|
||||
|
||||
// プラグインチャンネル登録
|
||||
getProxy().registerChannel(LunaChat.PMC_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
+83
-39
@@ -1,19 +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 org.bukkit.event.EventPriority;
|
||||
|
||||
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のコンフィグクラス
|
||||
@@ -21,6 +22,9 @@ import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
*/
|
||||
public class LunaChatConfig {
|
||||
|
||||
/** メッセージの言語 */
|
||||
private String lang;
|
||||
|
||||
/** チャンネルチャット機能を利用可能にするかどうか */
|
||||
private boolean enableChannelChat;
|
||||
|
||||
@@ -33,9 +37,6 @@ public class LunaChatConfig {
|
||||
/** チャンネルチャットの発言内容を、ログに残すかどうか */
|
||||
private boolean loggingChat;
|
||||
|
||||
/** チャンネルチャットの発言内容を、HawkEyeに記録するかどうか */
|
||||
private boolean loggingChatToHawkEye;
|
||||
|
||||
/** チャンネルチャットの発言内容を、コンソールに表示するかどうか */
|
||||
private boolean displayChatOnConsole;
|
||||
|
||||
@@ -115,11 +116,16 @@ public class LunaChatConfig {
|
||||
/** 通常チャットで、カラーコードを使用可能にするかどうか */
|
||||
private boolean enableNormalChatColorCode;
|
||||
|
||||
/** 通常チャットを、クリック可能にするかどうか */
|
||||
private boolean enableNormalChatClickable;
|
||||
|
||||
/** 通常チャットを、コンソールに表示するかどうか */
|
||||
private boolean displayNormalChatOnConsole;
|
||||
|
||||
/** Japanize変換のタイプ<br/>
|
||||
* none = 日本語変換をしない<br/>
|
||||
* kana = カナ変換のみする<br/>
|
||||
* googleime = カナ変換後、GoogleIMEで漢字変換する<br/>
|
||||
* socialime = カナ変換後、SocialIMEで漢字変換する */
|
||||
* googleime = カナ変換後、GoogleIMEで漢字変換する */
|
||||
private JapanizeType japanizeType;
|
||||
|
||||
/** Japanize変換の1行表示と2行表示の切り替え<br/>
|
||||
@@ -143,35 +149,44 @@ public class LunaChatConfig {
|
||||
* 隠し設定。 */
|
||||
private int japanizeWait;
|
||||
|
||||
// === 以下、BungeeCord用設定 ===
|
||||
|
||||
/** Bungeeパススルーモード */
|
||||
private boolean bungeePassThroughMode;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @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.getInstance().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.getInstance().reloadConfig();
|
||||
FileConfiguration config = LunaChat.getInstance().getConfig();
|
||||
YamlConfig config = YamlConfig.load(configFile);
|
||||
|
||||
lang = config.getString("lang", "en");
|
||||
enableChannelChat = config.getBoolean("enableChannelChat", true);
|
||||
playerChatEventListenerPriority
|
||||
= getEventPriority(config.getString("playerChatEventListenerPriority"), EventPriority.HIGH);
|
||||
= getEventPriority(config.getString("playerChatEventListenerPriority"), EventPriority.HIGHEST);
|
||||
noJoinAsGlobal = config.getBoolean("noJoinAsGlobal", true);
|
||||
loggingChat = config.getBoolean("loggingChat", true);
|
||||
loggingChatToHawkEye = config.getBoolean("loggingChatToHawkEye", true);
|
||||
displayChatOnConsole = config.getBoolean("displayChatOnConsole", true);
|
||||
globalMarker = config.getString("globalMarker", "!");
|
||||
zeroMemberRemove = config.getBoolean("zeroMemberRemove", false);
|
||||
@@ -235,8 +250,12 @@ public class LunaChatConfig {
|
||||
config.getString("normalChatMessageFormat", "&f%prefix%username%suffix&a:&f %msg");
|
||||
enableNormalChatColorCode =
|
||||
config.getBoolean("enableNormalChatColorCode", true);
|
||||
enableNormalChatClickable =
|
||||
config.getBoolean("enableNormalChatClickable", false);
|
||||
displayNormalChatOnConsole =
|
||||
config.getBoolean("displayNormalChatOnConsole", true);
|
||||
|
||||
japanizeType = JapanizeType.fromID(config.getString("japanizeType"), JapanizeType.KANA);
|
||||
japanizeType = JapanizeType.fromID(config.getString("japanizeType"), null);
|
||||
japanizeDisplayLine = config.getInt("japanizeDisplayLine", 2);
|
||||
if ( japanizeDisplayLine != 1 && japanizeDisplayLine != 2 ) {
|
||||
japanizeDisplayLine = 2;
|
||||
@@ -244,19 +263,29 @@ public class LunaChatConfig {
|
||||
japanizeLine1Format = config.getString("japanizeLine1Format", "%msg &6(%japanize)");
|
||||
japanizeLine2Format = config.getString("japanizeLine2Format", "&6[JP] %japanize");
|
||||
japanizeIgnorePlayerName = config.getBoolean("japanizeIgnorePlayerName", true);
|
||||
noneJapanizeMarker = config.getString("noneJapanizeMarker", "#");
|
||||
noneJapanizeMarker = config.getString("noneJapanizeMarker", "$");
|
||||
japanizeWait = config.getInt("japanizeWait", 1);
|
||||
|
||||
bungeePassThroughMode = config.getBoolean("bungeePassThroughMode", false);
|
||||
|
||||
// globalチャンネルが、使用可能なチャンネル名かどうかを調べる
|
||||
if ( !globalChannel.equals("") &&
|
||||
if ( globalChannel != null && !globalChannel.equals("") &&
|
||||
!globalChannel.matches("[0-9a-zA-Z\\-_]{1,20}") ) {
|
||||
String msg = String.format(
|
||||
Resources.get("errmsgCannotUseForGlobal"), globalChannel);
|
||||
LunaChat.getInstance().getLogger().warning(msg);
|
||||
|
||||
// コンソールに警告を表示する
|
||||
LunaChat.getPlugin().log(Level.WARNING, Messages.errmsgCannotUseForGlobal(globalChannel));
|
||||
globalChannel = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージの言語
|
||||
* @return lang
|
||||
*/
|
||||
public String getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャット機能を利用可能にするかどうか
|
||||
* @return enableChannelChatを返す
|
||||
@@ -289,14 +318,6 @@ public class LunaChatConfig {
|
||||
return loggingChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットの発言内容を、HawkEyeに記録するかどうか
|
||||
* @return loggingChatToHawkEye
|
||||
*/
|
||||
public boolean isLoggingChatToHawkEye() {
|
||||
return loggingChatToHawkEye;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットの発言内容を、コンソールに表示するかどうか
|
||||
* @return displayChatOnConsoleを返す
|
||||
@@ -493,8 +514,7 @@ public class LunaChatConfig {
|
||||
* Japanize変換のタイプ<br/>
|
||||
* none = 日本語変換をしない<br/>
|
||||
* kana = カナ変換のみする<br/>
|
||||
* googleime = カナ変換後、GoogleIMEで漢字変換する<br/>
|
||||
* socialime = カナ変換後、SocialIMEで漢字変換する
|
||||
* googleime = カナ変換後、GoogleIMEで漢字変換する
|
||||
* @return japanizeTypeを返す
|
||||
*/
|
||||
public JapanizeType getJapanizeType() {
|
||||
@@ -559,6 +579,30 @@ public class LunaChatConfig {
|
||||
return enableNormalChatColorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャットを、クリック可能にするかどうか
|
||||
* @return enableNormalChatClickable
|
||||
*/
|
||||
public boolean isEnableNormalChatClickable() {
|
||||
return enableNormalChatClickable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャットを、コンソールに表示するかどうか
|
||||
* @return displayNormalChatOnConsole
|
||||
*/
|
||||
public boolean isDisplayNormalChatOnConsole() {
|
||||
return displayNormalChatOnConsole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bungeeパススルーモードかどうかを返す
|
||||
* @return bungeePassThroughMode
|
||||
*/
|
||||
public boolean isBungeePassThroughMode() {
|
||||
return bungeePassThroughMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された文字列から、対応するEventPriorityを返す。
|
||||
* @param value 文字列
|
||||
+24
-42
@@ -1,16 +1,17 @@
|
||||
/*
|
||||
* @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.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
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;
|
||||
@@ -18,8 +19,7 @@ import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
|
||||
/**
|
||||
* LunaChatロガー
|
||||
@@ -61,32 +61,24 @@ public class LunaChatLogger {
|
||||
checkDir();
|
||||
|
||||
// 以降の処理を、発言処理の負荷軽減のため、非同期実行にする。(see issue #40.)
|
||||
new BukkitRunnable() {
|
||||
LunaChat.runAsyncTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String msg = ChatColor.stripColor(message).replace(",", ",");
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(file, true);
|
||||
String str = lformat.format(new Date()) +
|
||||
"," + msg + "," + player;
|
||||
writer.write(str + "\r\n");
|
||||
writer.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if ( writer != null ) {
|
||||
try {
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(LunaChat.getInstance());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,11 +141,11 @@ public class LunaChatLogger {
|
||||
private ArrayList<String> readAllLines(File file) {
|
||||
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
if ( !file.exists() ) return data;
|
||||
|
||||
BufferedReader reader = null;
|
||||
try ( BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(file), "UTF-8")) ) {
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while ( (line = reader.readLine()) != null ) {
|
||||
line = line.trim();
|
||||
@@ -161,18 +153,8 @@ public class LunaChatLogger {
|
||||
data.add(line);
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if ( reader != null ) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -244,7 +226,7 @@ public class LunaChatLogger {
|
||||
*/
|
||||
private String getFolderPath(Date date) {
|
||||
|
||||
return LunaChat.getInstance().getDataFolder() +
|
||||
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();
|
||||
}
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
+2
-2
@@ -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;
|
||||
|
||||
|
||||
/**
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -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.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
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連携クラス
|
||||
@@ -72,8 +72,8 @@ public class DynmapBridge implements Listener {
|
||||
@EventHandler
|
||||
public void onDynmapWebChat(DynmapWebChatEvent event) {
|
||||
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
String dchannel = config.getDynmapChannel();
|
||||
Channel channel = null;
|
||||
|
||||
@@ -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 : "";
|
||||
}
|
||||
}
|
||||
+19
-17
@@ -1,10 +1,11 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2016
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.bridge;
|
||||
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;
|
||||
@@ -13,13 +14,14 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
import com.github.ucchyocean.lc.channel.DelayedJapanizeRecipientChatTask;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
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;
|
||||
|
||||
@@ -40,9 +42,9 @@ public class McMMOBridge implements Listener {
|
||||
List<Player> recipients = PartyAPI.getOnlineMembers(event.getParty());
|
||||
|
||||
String message = event.getMessage();
|
||||
ChannelPlayer player = ChannelPlayer.getChannelPlayer(event.getSender());
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
ChannelMember player = ChannelMember.getChannelMember(event.getSender());
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
// NGワード発言をマスク
|
||||
for ( Pattern pattern : config.getNgwordCompiled() ) {
|
||||
@@ -69,16 +71,16 @@ public class McMMOBridge implements Listener {
|
||||
}
|
||||
|
||||
// 2byteコードを含むなら、Japanize変換は行わない
|
||||
String kanaTemp = Utility.stripColor(message);
|
||||
String kanaTemp = Utility.stripColorCode(message);
|
||||
if ( !skipJapanize &&
|
||||
( kanaTemp.getBytes().length > kanaTemp.length() ||
|
||||
( kanaTemp.getBytes(StandardCharsets.UTF_8).length > kanaTemp.length() ||
|
||||
kanaTemp.matches("[ \\uFF61-\\uFF9F]+") ) ) {
|
||||
skipJapanize = true;
|
||||
}
|
||||
|
||||
// Japanize変換と、発言処理
|
||||
if ( !skipJapanize &&
|
||||
LunaChat.getInstance().getLunaChatAPI().isPlayerJapanize(player.getName()) &&
|
||||
LunaChat.getAPI().isPlayerJapanize(player.getName()) &&
|
||||
config.getJapanizeType() != JapanizeType.NONE ) {
|
||||
|
||||
int lineType = config.getJapanizeDisplayLine();
|
||||
@@ -98,12 +100,12 @@ public class McMMOBridge implements Listener {
|
||||
|
||||
String taskFormat = Utility.replaceColorCode(config.getJapanizeLine2Format());
|
||||
|
||||
DelayedJapanizeRecipientChatTask task = new DelayedJapanizeRecipientChatTask(
|
||||
BukkitRecipientChatJapanizeTask task = new BukkitRecipientChatJapanizeTask(
|
||||
message, config.getJapanizeType(), player, taskFormat, recipients);
|
||||
|
||||
// 発言処理を必ず先に実施させるため、遅延を入れてタスクを実行する。
|
||||
int wait = config.getJapanizeWait();
|
||||
task.runTaskLater(LunaChat.getInstance(), wait);
|
||||
task.runTaskLater(LunaChatBukkit.getInstance(), wait);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2015
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.bridge;
|
||||
package com.github.ucchyocean.lc3.bridge;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
+2
-2
@@ -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.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
+188
-170
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
package com.github.ucchyocean.lc3.bukkit;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -23,36 +23,32 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.github.ucchyocean.lc.bridge.VaultChatBridge;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayer;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerName;
|
||||
import com.github.ucchyocean.lc.channel.ChannelPlayerUUID;
|
||||
import com.github.ucchyocean.lc.channel.DelayedJapanizeNormalChatTask;
|
||||
import com.github.ucchyocean.lc.event.LunaChatPreChatEvent;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
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.member.ChannelMemberOther;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberPlayer;
|
||||
import com.github.ucchyocean.lc3.messaging.BukkitChatMessage;
|
||||
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 PlayerListener implements Listener {
|
||||
public class BukkitEventListener implements Listener {
|
||||
|
||||
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 PREERR = Resources.get("errorPrefix");
|
||||
|
||||
private SimpleDateFormat dateFormat;
|
||||
private SimpleDateFormat timeFormat;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*/
|
||||
public PlayerListener() {
|
||||
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||||
timeFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
}
|
||||
private static final int MAX_LIST_ITEMS = 8;
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
@@ -60,7 +56,7 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.LOWEST, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatLowest(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.LOWEST ) {
|
||||
if ( matchesEventPriority(EventPriority.LOWEST) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -71,7 +67,7 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.LOW, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatLow(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.LOW ) {
|
||||
if ( matchesEventPriority(EventPriority.LOW) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -82,7 +78,7 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.NORMAL, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatNormal(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.NORMAL ) {
|
||||
if ( matchesEventPriority(EventPriority.NORMAL) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -93,7 +89,7 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatHigh(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.HIGH ) {
|
||||
if ( matchesEventPriority(EventPriority.HIGH) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -104,7 +100,7 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatHighest(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.HIGHEST ) {
|
||||
if ( matchesEventPriority(EventPriority.HIGHEST) ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -116,9 +112,13 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// UUIDをキャッシュ
|
||||
LunaChat.getUUIDCacheData().put(player.getUniqueId().toString(), player.getName());
|
||||
LunaChat.getUUIDCacheData().save();
|
||||
|
||||
// 強制参加チャンネル設定を確認し、参加させる
|
||||
forceJoinToForceJoinChannels(player);
|
||||
|
||||
@@ -129,9 +129,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
// チャンネルチャット情報を表示する
|
||||
if ( config.isShowListOnJoin() ) {
|
||||
ArrayList<String> list = getListForMotd(player);
|
||||
for ( String msg : list ) {
|
||||
player.sendMessage(msg);
|
||||
for ( BaseComponent[] msg : getListForMotd(player) ) {
|
||||
ChannelMember.getChannelMember(player).sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,18 +143,18 @@ public class PlayerListener implements Listener {
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
String pname = player.getName();
|
||||
|
||||
// お互いがオフラインになるPMチャンネルがある場合は
|
||||
// チャンネルをクリアする
|
||||
ArrayList<Channel> deleteList = new ArrayList<Channel>();
|
||||
|
||||
for ( Channel channel : LunaChat.getInstance().getLunaChatAPI().getChannels() ) {
|
||||
for ( Channel channel : LunaChat.getAPI().getChannels() ) {
|
||||
String cname = channel.getName();
|
||||
if ( channel.isPersonalChat() && cname.contains(player.getName()) ) {
|
||||
if ( channel.isPersonalChat() && cname.contains(pname) ) {
|
||||
boolean isAllOffline = true;
|
||||
for ( ChannelPlayer cp : channel.getMembers() ) {
|
||||
if ( !cp.equals(player) && cp.isOnline() &&
|
||||
(cp instanceof ChannelPlayerName || cp instanceof ChannelPlayerUUID) ) {
|
||||
for ( ChannelMember cp : channel.getMembers() ) {
|
||||
if ( cp.isOnline() ) {
|
||||
isAllOffline = false;
|
||||
}
|
||||
}
|
||||
@@ -166,7 +165,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
for ( Channel channel : deleteList ) {
|
||||
LunaChat.getInstance().getLunaChatAPI().removeChannel(channel.getName());
|
||||
LunaChat.getAPI().removeChannel(channel.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,8 +175,32 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
private void processChatEvent(AsyncPlayerChatEvent event) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
// Bungeeパススルーモードなら、メッセージを返送して終了する
|
||||
if ( config.isBungeePassThroughMode() ) {
|
||||
|
||||
// メッセージの返送
|
||||
ChannelMember member = ChannelMember.getChannelMember(event.getPlayer());
|
||||
if ( member instanceof ChannelMemberPlayer ) {
|
||||
ChannelMemberOther other = ((ChannelMemberPlayer)member).toChannelMemberOther();
|
||||
BukkitChatMessage msg = new BukkitChatMessage(other, event.getMessage());
|
||||
LunaChatBukkit.getInstance().sendPluginMessage(msg.toByteArray());
|
||||
|
||||
// 設定が有効ならコンソールに表示する
|
||||
if ( config.isDisplayNormalChatOnConsole() ) {
|
||||
String logmsg = event.getFormat()
|
||||
.replace("%1$s", member.getDisplayName())
|
||||
.replace("%2$s", event.getMessage());
|
||||
LunaChat.getPlugin().log(Level.INFO, logmsg);
|
||||
}
|
||||
}
|
||||
|
||||
// イベントをキャンセルして終了する
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 頭にglobalMarkerが付いている場合は、グローバル発言にする
|
||||
if ( config.getGlobalMarker() != null &&
|
||||
@@ -205,11 +228,11 @@ public class PlayerListener implements Listener {
|
||||
|
||||
Channel channel = api.getChannel(name);
|
||||
if ( channel != null && !channel.isPersonalChat() ) {
|
||||
ChannelPlayer player =
|
||||
ChannelPlayer.getChannelPlayer(event.getPlayer());
|
||||
ChannelMember player =
|
||||
ChannelMember.getChannelMember(event.getPlayer());
|
||||
if ( !channel.getMembers().contains(player) ) {
|
||||
// 指定されたチャンネルに参加していないなら、エラーを表示して何も発言せずに終了する。
|
||||
sendResourceMessage(event.getPlayer(), PREERR, "errmsgNomember");
|
||||
event.getPlayer().sendMessage(Messages.errmsgNomember());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -222,8 +245,8 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
ChannelPlayer player =
|
||||
ChannelPlayer.getChannelPlayer(event.getPlayer());
|
||||
ChannelMember player =
|
||||
ChannelMember.getChannelMember(event.getPlayer());
|
||||
Channel channel = api.getDefaultChannel(player.getName());
|
||||
|
||||
// デフォルトの発言先が無い場合
|
||||
@@ -252,10 +275,10 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
private void chatGlobal(AsyncPlayerChatEvent event) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
ChannelPlayer player =
|
||||
ChannelPlayer.getChannelPlayer(event.getPlayer());
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
ChannelMember player =
|
||||
ChannelMember.getChannelMember(event.getPlayer());
|
||||
|
||||
if ( !config.getGlobalChannel().equals("") ) {
|
||||
// グローバルチャンネル設定がある場合
|
||||
@@ -266,19 +289,7 @@ public class PlayerListener implements Listener {
|
||||
global = api.createChannel(config.getGlobalChannel());
|
||||
}
|
||||
|
||||
// LunaChatPreChatEvent イベントコール
|
||||
LunaChatPreChatEvent preChatEvent = new LunaChatPreChatEvent(
|
||||
global.getName(), player, event.getMessage());
|
||||
Bukkit.getPluginManager().callEvent(preChatEvent);
|
||||
if ( preChatEvent.isCancelled() ) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Channel alt = preChatEvent.getChannel();
|
||||
if ( alt != null ) {
|
||||
global = alt;
|
||||
}
|
||||
String message = preChatEvent.getMessage();
|
||||
String message = event.getMessage();
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
Channel dchannel = api.getDefaultChannel(player.getName());
|
||||
@@ -307,13 +318,6 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// チャットフォーマット装飾の適用
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
String format = config.getNormalChatMessageFormat();
|
||||
format = replaceNormalChatFormatKeywords(format, event.getPlayer());
|
||||
event.setFormat(format);
|
||||
}
|
||||
|
||||
// カラーコード置き換え
|
||||
// 置き換え設定になっていて、発言者がパーミッションを持っているなら、置き換えする
|
||||
if ( config.isEnableNormalChatColorCode() &&
|
||||
@@ -322,8 +326,8 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
// hideされているプレイヤーを、recipientから抜く
|
||||
for ( ChannelPlayer cp : api.getHidelist(player) ) {
|
||||
Player p = cp.getPlayer();
|
||||
for ( ChannelMember cp : api.getHidelist(player) ) {
|
||||
Player p = ((ChannelMemberBukkit)cp).getPlayer();
|
||||
if ( p != null ) {
|
||||
event.getRecipients().remove(p);
|
||||
}
|
||||
@@ -337,17 +341,17 @@ public class PlayerListener implements Listener {
|
||||
message = message.substring(marker.length());
|
||||
}
|
||||
|
||||
// 2byteコードを含むなら、Japanize変換は行わない
|
||||
String kanaTemp = Utility.stripColor(message);
|
||||
// 2byteコードを含む、または、半角カタカナのみなら、Japanize変換は行わない
|
||||
String kanaTemp = Utility.stripColorCode(message);
|
||||
if ( !skipJapanize &&
|
||||
( kanaTemp.getBytes().length > kanaTemp.length() ||
|
||||
( kanaTemp.getBytes(StandardCharsets.UTF_8).length > kanaTemp.length() ||
|
||||
kanaTemp.matches("[ \\uFF61-\\uFF9F]+") ) ) {
|
||||
skipJapanize = true;
|
||||
}
|
||||
|
||||
// Japanize変換と、発言処理
|
||||
if ( !skipJapanize &&
|
||||
LunaChat.getInstance().getLunaChatAPI().isPlayerJapanize(player.getName()) &&
|
||||
LunaChat.getAPI().isPlayerJapanize(player.getName()) &&
|
||||
config.getJapanizeType() != JapanizeType.NONE ) {
|
||||
|
||||
int lineType = config.getJapanizeDisplayLine();
|
||||
@@ -367,17 +371,62 @@ public class PlayerListener implements Listener {
|
||||
|
||||
String taskFormat = Utility.replaceColorCode(config.getJapanizeLine2Format());
|
||||
|
||||
DelayedJapanizeNormalChatTask task = new DelayedJapanizeNormalChatTask(
|
||||
BukkitNormalChatJapanizeTask task = new BukkitNormalChatJapanizeTask(
|
||||
message, config.getJapanizeType(), player, taskFormat, event);
|
||||
|
||||
// 発言処理を必ず先に実施させるため、遅延を入れてタスクを実行する。
|
||||
int wait = config.getJapanizeWait();
|
||||
task.runTaskLater(LunaChat.getInstance(), wait);
|
||||
task.runTaskLater(LunaChatBukkit.getInstance(), wait);
|
||||
}
|
||||
}
|
||||
|
||||
// 発言内容の設定
|
||||
event.setMessage(message);
|
||||
if ( config.isEnableNormalChatClickable() ) {
|
||||
// クリック可能チャットで発言
|
||||
|
||||
// チャットフォーマット装飾の適用
|
||||
ClickableFormat format;
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
String f = config.getNormalChatMessageFormat();
|
||||
format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
} else {
|
||||
String f = event.getFormat()
|
||||
.replace("%1$s", "%displayName")
|
||||
.replace("%2$s", "%msg");
|
||||
format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
}
|
||||
|
||||
// 発言内容の送信
|
||||
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);
|
||||
|
||||
// 設定が有効ならコンソールに表示する
|
||||
if ( config.isDisplayNormalChatOnConsole() ) {
|
||||
LunaChat.getPlugin().log(Level.INFO, makeLegacyText(comps));
|
||||
}
|
||||
|
||||
} else {
|
||||
// 通常チャットイベントで発言
|
||||
|
||||
// チャットフォーマット装飾の適用
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
String f = config.getNormalChatMessageFormat();
|
||||
f = ClickableFormat.replaceForNormalChatFormat(
|
||||
f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
event.setFormat(Utility.replaceColorCode(f));
|
||||
}
|
||||
|
||||
// 発言内容の設定
|
||||
event.setMessage(message);
|
||||
}
|
||||
|
||||
// ロギング
|
||||
logNormalChat(message, player.getName());
|
||||
@@ -393,8 +442,8 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
private boolean tryJoinToGlobalChannel(Player player) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
String gcName = config.getGlobalChannel();
|
||||
|
||||
@@ -419,8 +468,8 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
private void forceJoinToForceJoinChannels(Player player) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
List<String> forceJoinChannels = config.getForceJoinChannels();
|
||||
|
||||
@@ -433,12 +482,12 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
// チャンネルのメンバーでないなら、参加する
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(player);
|
||||
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);
|
||||
@@ -446,71 +495,34 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャットのフォーマット設定のキーワードを置き換えして返す
|
||||
* @param org フォーマット設定
|
||||
* @param player 発言プレイヤー
|
||||
* @return キーワード置き換え済みの文字列
|
||||
*/
|
||||
private String replaceNormalChatFormatKeywords(String org, Player player) {
|
||||
|
||||
String format = org;
|
||||
format = format.replace("%username", "%1$s");
|
||||
format = format.replace("%msg", "%2$s");
|
||||
|
||||
if ( format.contains("%date") ) {
|
||||
format = format.replace("%date", dateFormat.format(new Date()));
|
||||
}
|
||||
if ( format.contains("%time") ) {
|
||||
format = format.replace("%time", timeFormat.format(new Date()));
|
||||
}
|
||||
|
||||
if ( format.contains("%prefix") || format.contains("%suffix") ) {
|
||||
|
||||
String prefix = "";
|
||||
String suffix = "";
|
||||
VaultChatBridge vaultchat = LunaChat.getInstance().getVaultChat();
|
||||
if ( vaultchat != null ) {
|
||||
prefix = vaultchat.getPlayerPrefix(player);
|
||||
suffix = vaultchat.getPlayerSuffix(player);
|
||||
}
|
||||
format = format.replace("%prefix", prefix);
|
||||
format = format.replace("%suffix", suffix);
|
||||
}
|
||||
|
||||
if ( format.contains("%world") ) {
|
||||
|
||||
String worldname = null;
|
||||
if ( LunaChat.getInstance().getMultiverseCore() != null ) {
|
||||
worldname = LunaChat.getInstance().getMultiverseCore().getWorldAlias(player.getWorld());
|
||||
}
|
||||
if ( worldname == null || worldname.equals("") ) {
|
||||
worldname = player.getWorld().getName();
|
||||
}
|
||||
format = format.replace("%world", worldname);
|
||||
}
|
||||
|
||||
return Utility.replaceColorCode(format);
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのサーバー参加時用の参加チャンネルリストを返す
|
||||
* @param player プレイヤー
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getListForMotd(Player player) {
|
||||
private ArrayList<BaseComponent[]> getListForMotd(Player player) {
|
||||
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(player);
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
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<String> items = new ArrayList<String>();
|
||||
items.add(MOTD_FIRSTLINE);
|
||||
for ( Channel channel : api.getChannels() ) {
|
||||
// チャンネル一覧を取得して、参加人数でソートする
|
||||
ArrayList<Channel> channels = new ArrayList<>(api.getChannels());
|
||||
Collections.sort(channels, new Comparator<Channel>() {
|
||||
public int compare(Channel c1, Channel c2) {
|
||||
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) ) {
|
||||
@@ -535,11 +547,14 @@ public class PlayerListener implements Listener {
|
||||
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(Messages.listFormat(disp, onlineNum, memberNum, desc));
|
||||
count++;
|
||||
|
||||
if ( count > MAX_LIST_ITEMS ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
items.add(LIST_ENDLINE);
|
||||
items.add(TextComponent.fromLegacyText(Messages.listEndLine()));
|
||||
|
||||
return items;
|
||||
}
|
||||
@@ -551,20 +566,19 @@ public class PlayerListener implements Listener {
|
||||
* @param message 発言内容
|
||||
* @return イベントでキャンセルされたかどうか
|
||||
*/
|
||||
private boolean chatToChannelWithEvent(ChannelPlayer player, Channel channel, String message) {
|
||||
private boolean chatToChannelWithEvent(ChannelMember player, Channel channel, String message) {
|
||||
|
||||
// LunaChatPreChatEvent イベントコール
|
||||
LunaChatPreChatEvent preChatEvent = new LunaChatPreChatEvent(
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatPreChatEvent(
|
||||
channel.getName(), player, message);
|
||||
Bukkit.getPluginManager().callEvent(preChatEvent);
|
||||
if ( preChatEvent.isCancelled() ) {
|
||||
if ( result.isCancelled() ) {
|
||||
return true;
|
||||
}
|
||||
Channel alt = preChatEvent.getChannel();
|
||||
Channel alt = result.getChannel();
|
||||
if ( alt != null ) {
|
||||
channel = alt;
|
||||
}
|
||||
message = preChatEvent.getMessage();
|
||||
message = result.getMessage();
|
||||
|
||||
// チャンネルチャット発言
|
||||
channel.chat(player, message);
|
||||
@@ -578,25 +592,29 @@ public class PlayerListener implements Listener {
|
||||
* @param player
|
||||
*/
|
||||
private void logNormalChat(String message, String player) {
|
||||
|
||||
LunaChat.getInstance().getNormalChatLogger().log(message, player);
|
||||
LunaChat.getNormalChatLogger().log(message, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
* 指定されたEventPriorityが、LunaChatConfigで指定されているEventPriorityと一致するかどうかを調べる
|
||||
* @param priority
|
||||
* @return 一致するかどうか
|
||||
*/
|
||||
private void sendResourceMessage(
|
||||
CommandSender sender, String pre, String key, Object... args) {
|
||||
private boolean matchesEventPriority(EventPriority priority) {
|
||||
String c = LunaChat.getConfig().getPlayerChatEventListenerPriority().name();
|
||||
return c.equals(priority.name());
|
||||
}
|
||||
|
||||
String org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
/**
|
||||
* BaseComponent配列を、カラーコードを含むStringに変換する
|
||||
* @param comps BaseComponentの配列
|
||||
* @return カラーコードを含むString
|
||||
*/
|
||||
private static String makeLegacyText(BaseComponent[] comps) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for ( BaseComponent comp : comps ) {
|
||||
builder.append(comp.toLegacyText());
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
sender.sendMessage(msg);
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-8
@@ -1,26 +1,31 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2016
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
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.lc.japanize.JapanizeType;
|
||||
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 DelayedJapanizeRecipientChatTask extends DelayedJapanizeConvertTask {
|
||||
public class BukkitRecipientChatJapanizeTask extends BukkitRunnable {
|
||||
|
||||
private List<Player> recipients;
|
||||
|
||||
private JapanizeConvertTask task;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param org 変換前の文字列
|
||||
@@ -29,9 +34,9 @@ public class DelayedJapanizeRecipientChatTask extends DelayedJapanizeConvertTask
|
||||
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
|
||||
* @param recipients メッセージ受信者
|
||||
*/
|
||||
public DelayedJapanizeRecipientChatTask(String org, JapanizeType type, ChannelPlayer player,
|
||||
public BukkitRecipientChatJapanizeTask(String org, JapanizeType type, ChannelMember player,
|
||||
String japanizeFormat, List<Player> recipients) {
|
||||
super(org, type, null, player, japanizeFormat);
|
||||
task = new JapanizeConvertTask(org, type, japanizeFormat, null, player);
|
||||
this.recipients = recipients;
|
||||
}
|
||||
|
||||
@@ -41,9 +46,9 @@ public class DelayedJapanizeRecipientChatTask extends DelayedJapanizeConvertTask
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if ( runSync() ) {
|
||||
if ( task.runSync() ) {
|
||||
|
||||
String result = getResult();
|
||||
String result = task.getResult();
|
||||
|
||||
// 送信
|
||||
for ( Player p : recipients ) {
|
||||
+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 member;
|
||||
private String originalMessage;
|
||||
private String ngMaskedMessage;
|
||||
private String messageFormat;
|
||||
|
||||
public LunaChatBukkitChannelChatEvent(String channelName, ChannelMember member,
|
||||
String originalMessage, String ngMaskedMessage,
|
||||
String messageFormat) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.originalMessage = originalMessage;
|
||||
this.ngMaskedMessage = ngMaskedMessage;
|
||||
this.messageFormat = messageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置き換え前の、発言されたままのテキストをかえす
|
||||
* @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 member;
|
||||
private String message;
|
||||
private List<ChannelMember> recipients;
|
||||
private String displayName;
|
||||
private String originalMessage;
|
||||
|
||||
public LunaChatBukkitChannelMessageEvent(String channelName,
|
||||
ChannelMember member, String message, List<ChannelMember> recipients,
|
||||
String displayName, String originalMessage) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.message = message;
|
||||
this.recipients = recipients;
|
||||
this.displayName = displayName;
|
||||
this.originalMessage = originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言したプレイヤー、システムメッセージの場合はnullになることに注意
|
||||
* @return player 発言プレイヤー
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置き換えされたメッセージ
|
||||
* @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 member;
|
||||
private String original;
|
||||
private String japanized;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
* @param member 発言したプレイヤー
|
||||
* @param original 変換前の文字列
|
||||
* @param japanized 変換後の文字列
|
||||
*/
|
||||
public LunaChatBukkitPostJapanizeEvent(String channelName, ChannelMember member,
|
||||
String original, String japanized) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.original = original;
|
||||
this.japanized = japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 member;
|
||||
private String message;
|
||||
|
||||
public LunaChatBukkitPreChatEvent(String channelName, ChannelMember member, String message) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言内容を取得します。
|
||||
* @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,619 @@
|
||||
/*
|
||||
* @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.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.member.ChannelMemberOther;
|
||||
import com.github.ucchyocean.lc3.messaging.BukkitChatMessage;
|
||||
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.ProxyServer;
|
||||
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.PluginMessageEvent;
|
||||
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
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPluginMessageReceived(PluginMessageEvent event) {
|
||||
|
||||
// 自分のチャンネルメッセージでない場合は無視する
|
||||
if ( !event.getTag().equals(LunaChat.PMC_MESSAGE) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// データをメッセージに復元する
|
||||
BukkitChatMessage msg = BukkitChatMessage.fromByteArray(event.getData());
|
||||
if ( msg == null ) return;
|
||||
|
||||
// 受信者と発言者が一致しない場合は無視する
|
||||
if ( event.getReceiver() instanceof ProxiedPlayer ) {
|
||||
ProxiedPlayer receiver = (ProxiedPlayer)event.getReceiver();
|
||||
if ( !receiver.getName().equals(msg.getMember().getName()) ) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// 発言者を取得する サーバー名を設定できる場合は設定する
|
||||
ChannelMemberOther member = msg.getMember();
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(member.getName());
|
||||
if ( player != null ) {
|
||||
member.setServerName(player.getServer().getInfo().getName());
|
||||
}
|
||||
|
||||
// 発言処理する
|
||||
processChat(member, msg.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのチャットごとに呼び出されるメソッド
|
||||
* @param event チャットイベント
|
||||
*/
|
||||
private void processChatEvent(ChatEvent event) {
|
||||
|
||||
// Bungeeパススルーモードなら何もしない
|
||||
if ( config.isBungeePassThroughMode() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// コマンド実行の場合は、そのまま無視する
|
||||
if ( event.isCommand() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// プレイヤーの発言ではない場合は、そのまま無視する
|
||||
if ( !(event.getSender() instanceof ProxiedPlayer) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 発言内容を処理する
|
||||
processChat(ChannelMember.getChannelMember(event.getSender()), event.getMessage());
|
||||
|
||||
// イベントをキャンセル
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private void processChat(ChannelMember member, String message) {
|
||||
|
||||
// 頭にglobalMarkerが付いている場合は、グローバル発言にする
|
||||
if ( config.getGlobalMarker() != null &&
|
||||
!config.getGlobalMarker().equals("") &&
|
||||
message.startsWith(config.getGlobalMarker()) &&
|
||||
message.length() > config.getGlobalMarker().length() ) {
|
||||
|
||||
int offset = config.getGlobalMarker().length();
|
||||
message = message.substring(offset);
|
||||
chatGlobal(member, message);
|
||||
return;
|
||||
}
|
||||
|
||||
// クイックチャンネルチャット機能が有効で、専用の記号が含まれるなら、
|
||||
// クイックチャンネルチャットとして処理する。
|
||||
if ( config.isEnableQuickChannelChat() ) {
|
||||
String separator = config.getQuickChannelChatSeparator();
|
||||
if ( message.contains(separator) ) {
|
||||
String[] temp = message.split(separator, 2);
|
||||
String name = temp[0];
|
||||
String value = "";
|
||||
if ( temp.length > 0 ) {
|
||||
value = temp[1];
|
||||
}
|
||||
|
||||
Channel channel = api.getChannel(name);
|
||||
if ( channel != null ) {
|
||||
|
||||
if ( !channel.getMembers().contains(member) ) {
|
||||
// 指定されたチャンネルに参加していないなら、エラーを表示して何も発言せずに終了する。
|
||||
member.sendMessage(
|
||||
TextComponent.fromLegacyText(Messages.errmsgNomember()));
|
||||
return;
|
||||
}
|
||||
|
||||
// 指定されたチャンネルに発言して終了する。
|
||||
chatToChannelWithEvent(member, channel, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Channel channel = api.getDefaultChannel(member.getName());
|
||||
|
||||
// デフォルトの発言先が無い場合
|
||||
if ( channel == null ) {
|
||||
if ( config.isNoJoinAsGlobal() ) {
|
||||
// グローバル発言にする
|
||||
chatGlobal(member, message);
|
||||
return;
|
||||
|
||||
} else {
|
||||
// 何もせずに終了する
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
chatToChannelWithEvent(member, channel, message);
|
||||
}
|
||||
|
||||
private void chatGlobal(ChannelMember member, String message) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
if ( !config.getGlobalChannel().equals("") ) {
|
||||
// グローバルチャンネル設定がある場合
|
||||
|
||||
// グローバルチャンネルの取得、無ければ作成
|
||||
Channel global = api.getChannel(config.getGlobalChannel());
|
||||
if ( global == null ) {
|
||||
global = api.createChannel(config.getGlobalChannel());
|
||||
}
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
Channel dchannel = api.getDefaultChannel(member.getName());
|
||||
if ( dchannel == null ) {
|
||||
api.setDefaultChannel(member.getName(), global.getName());
|
||||
}
|
||||
|
||||
// チャンネルチャット発言
|
||||
chatToChannelWithEvent(member, global, message);
|
||||
|
||||
return;
|
||||
|
||||
} else {
|
||||
// グローバルチャンネル設定が無い場合
|
||||
|
||||
// NGワードのマスク
|
||||
message = maskNGWord(message, config.getNgwordCompiled());
|
||||
|
||||
// Japanizeをスキップするかどうかフラグ
|
||||
boolean skipJapanize = !LunaChat.getAPI().isPlayerJapanize(member.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;
|
||||
|
||||
String f = config.getNormalChatMessageFormat();
|
||||
ClickableFormat format = ClickableFormat.makeFormat(f, member);
|
||||
format.replace("%msg", message);
|
||||
|
||||
// hideされているプレイヤーを除くすべてのプレイヤーに、
|
||||
// 発言内容を送信する。
|
||||
BaseComponent[] msg = format.makeTextComponent();
|
||||
List<ChannelMember> hidelist = api.getHidelist(member);
|
||||
|
||||
for ( ServerInfo info : parent.getProxy().getServers().values() ) {
|
||||
for ( ProxiedPlayer player : info.getPlayers() ) {
|
||||
if ( !containsHideList(player, hidelist) ) {
|
||||
sendMessage(player, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = format.toLegacyText();
|
||||
|
||||
// コンソールに表示設定なら、コンソールに表示する
|
||||
if ( config.isDisplayNormalChatOnConsole() ) {
|
||||
parent.getLogger().info(result);
|
||||
}
|
||||
|
||||
// ログに記録する
|
||||
LunaChat.getNormalChatLogger().log(Utility.stripColorCode(result), member.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, 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,56 @@
|
||||
/*
|
||||
* @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;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
/**
|
||||
* Tellコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class MessageCommandBungee extends Command implements TabExecutor {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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), "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 member;
|
||||
private String originalMessage;
|
||||
private String ngMaskedMessage;
|
||||
private String messageFormat;
|
||||
|
||||
public LunaChatBungeeChannelChatEvent(String channelName, ChannelMember member,
|
||||
String originalMessage, String ngMaskedMessage,
|
||||
String messageFormat) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.originalMessage = originalMessage;
|
||||
this.ngMaskedMessage = ngMaskedMessage;
|
||||
this.messageFormat = messageFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置き換え前の、発言されたままのテキストをかえす
|
||||
* @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 member;
|
||||
private String message;
|
||||
private List<ChannelMember> recipients;
|
||||
private String displayName;
|
||||
private String originalMessage;
|
||||
|
||||
public LunaChatBungeeChannelMessageEvent(String channelName,
|
||||
ChannelMember member, String message, List<ChannelMember> recipients,
|
||||
String displayName, String originalMessage) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.message = message;
|
||||
this.recipients = recipients;
|
||||
this.displayName = displayName;
|
||||
this.originalMessage = originalMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言したプレイヤー、システムメッセージの場合はnullになることに注意
|
||||
* @return player 発言プレイヤー
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 置き換えされたメッセージ
|
||||
* @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 member;
|
||||
private String original;
|
||||
private String japanized;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param channelName チャンネル名
|
||||
* @param member 発言したプレイヤー
|
||||
* @param original 変換前の文字列
|
||||
* @param japanized 変換後の文字列
|
||||
*/
|
||||
public LunaChatBungeePostJapanizeEvent(String channelName, ChannelMember member,
|
||||
String original, String japanized) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.original = original;
|
||||
this.japanized = japanized;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.bungee.event;
|
||||
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* チャンネルチャットへの発言前に発生するイベント
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungeePreChatEvent extends LunaChatBungeeBaseCancellableEvent {
|
||||
|
||||
private ChannelMember member;
|
||||
private String message;
|
||||
|
||||
public LunaChatBungeePreChatEvent(String channelName, ChannelMember member, String message) {
|
||||
super(channelName);
|
||||
this.member = member;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言を行ったプレイヤーを取得します。
|
||||
* @return 発言したプレイヤー
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
/**
|
||||
* 発言内容を取得します。
|
||||
* @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,284 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.channel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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.bridge.DynmapBridge;
|
||||
import com.github.ucchyocean.lc3.event.EventResult;
|
||||
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.UtilityBukkit;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
/**
|
||||
* チャンネルの実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BukkitChannel extends Channel {
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name チャンネル名
|
||||
*/
|
||||
protected BukkitChannel(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを表示します。指定したプレイヤーの発言として処理されます。
|
||||
* @param player プレイヤー(ワールドチャット、範囲チャットの場合は必須です)
|
||||
* @param message メッセージ
|
||||
* @param format フォーマット
|
||||
* @param sendDynmap dynmapへ送信するかどうか
|
||||
*/
|
||||
@Override
|
||||
protected void sendMessage(
|
||||
ChannelMember player, String message,
|
||||
@Nullable ClickableFormat format, boolean sendDynmap) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
String originalMessage = new String(message);
|
||||
|
||||
// 受信者を設定する
|
||||
List<ChannelMember> recipients = new ArrayList<ChannelMember>();
|
||||
boolean sendNoRecipientMessage = false;
|
||||
|
||||
if ( isBroadcastChannel() ) {
|
||||
// ブロードキャストチャンネル
|
||||
|
||||
if ( isWorldRange() && player.isOnline() && player.getWorldName() != null ) {
|
||||
|
||||
World w = Bukkit.getWorld(player.getWorldName());
|
||||
|
||||
if ( getChatRange() > 0 ) {
|
||||
// 範囲チャット
|
||||
|
||||
if ( player instanceof ChannelMemberBukkit ) {
|
||||
// ↑常にtrueだと思うが、念のため。
|
||||
|
||||
Location origin = ((ChannelMemberBukkit)player).getLocation();
|
||||
for ( Player p : Bukkit.getOnlinePlayers() ) {
|
||||
ChannelMember cp = ChannelMember.getChannelMember(p);
|
||||
if ( p.getWorld().equals(w) &&
|
||||
origin.distance(p.getLocation()) <= getChatRange() &&
|
||||
!getHided().contains(cp) ) {
|
||||
recipients.add(ChannelMember.getChannelMember(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// ワールドチャット
|
||||
|
||||
for ( Player p : Bukkit.getOnlinePlayers() ) {
|
||||
ChannelMember cp = ChannelMember.getChannelMember(p);
|
||||
if ( p.getWorld().equals(w) && !getHided().contains(cp) ) {
|
||||
recipients.add(ChannelMember.getChannelMember(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 受信者が自分以外いない場合は、メッセージを表示する
|
||||
if ( Messages.noRecipientMessage("", "").length > 0 && (
|
||||
recipients.size() == 0 ||
|
||||
(recipients.size() == 1 &&
|
||||
recipients.get(0).getName().equals(player.getName()) ) ) ) {
|
||||
sendNoRecipientMessage = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
// 通常ブロードキャスト(全員へ送信)
|
||||
|
||||
for ( Player p : Bukkit.getOnlinePlayers() ) {
|
||||
ChannelMember cp = ChannelMember.getChannelMember(p);
|
||||
if ( !getHided().contains(cp) ) {
|
||||
recipients.add(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// 通常チャンネル
|
||||
|
||||
for ( ChannelMember mem : getMembers() ) {
|
||||
if ( mem != null && mem.isOnline() && !getHided().contains(mem) ) {
|
||||
recipients.add(mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// opListenAllChannel 設定がある場合は、
|
||||
// パーミッション lunachat-admin.listen-all-channels を持つプレイヤーを
|
||||
// 受信者に加える。
|
||||
if ( config.isOpListenAllChannel() ) {
|
||||
for ( Player p : Bukkit.getOnlinePlayers() ) {
|
||||
ChannelMember cp = ChannelMember.getChannelMember(p);
|
||||
if ( cp.hasPermission("lunachat-admin.listen-all-channels")
|
||||
&& !recipients.contains(cp) ) {
|
||||
recipients.add(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hideされている場合は、受信対象者から抜く。
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
for ( ChannelMember cp : api.getHidelist(player) ) {
|
||||
if ( recipients.contains(cp) ) {
|
||||
recipients.remove(cp);
|
||||
}
|
||||
}
|
||||
|
||||
// LunaChatChannelMessageEvent イベントコール
|
||||
String name = (player != null) ? player.getDisplayName() : "<null>";
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatChannelMessageEvent(
|
||||
getName(), player, message, recipients, name, originalMessage);
|
||||
message = result.getMessage();
|
||||
recipients = result.getRecipients();
|
||||
|
||||
// 通常ブロードキャストなら、設定に応じてdynmapへ送信する
|
||||
DynmapBridge dynmap = LunaChatBukkit.getInstance().getDynmap();
|
||||
if ( config.isSendBroadcastChannelChatToDynmap() &&
|
||||
sendDynmap &&
|
||||
dynmap != null &&
|
||||
isBroadcastChannel() &&
|
||||
!isWorldRange() ) {
|
||||
|
||||
String msg = config.isSendFormattedMessageToDynmap() ? message : originalMessage;
|
||||
if ( player != null && player instanceof ChannelMemberBukkit
|
||||
&& ((ChannelMemberBukkit)player).getPlayer() != null ) {
|
||||
dynmap.chat(((ChannelMemberBukkit)player).getPlayer(), msg);
|
||||
} else {
|
||||
dynmap.broadcast(msg);
|
||||
}
|
||||
}
|
||||
|
||||
// 送信する
|
||||
if ( format != null ) {
|
||||
format.replace("%msg", message);
|
||||
BaseComponent[] comps = format.makeTextComponent();
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(comps);
|
||||
}
|
||||
message = format.toLegacyText();
|
||||
} else {
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 設定に応じて、コンソールに出力する
|
||||
if ( config.isDisplayChatOnConsole() ) {
|
||||
Bukkit.getLogger().info(message);
|
||||
}
|
||||
|
||||
// 受信者が自分以外いない場合は、メッセージを表示する
|
||||
if ( sendNoRecipientMessage ) {
|
||||
player.sendMessage(Messages.noRecipientMessage(getColorCode(), getName()));
|
||||
}
|
||||
|
||||
// ロギング
|
||||
log(originalMessage, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのオンライン人数を返す
|
||||
* @return オンライン人数
|
||||
* @see com.github.ucchyocean.lc3.channel.Channel#getOnlineNum()
|
||||
*/
|
||||
@Override
|
||||
public int getOnlineNum() {
|
||||
|
||||
// ブロードキャストチャンネルならサーバー接続人数を返す
|
||||
if ( isBroadcastChannel() ) {
|
||||
return UtilityBukkit.getOnlinePlayersCount();
|
||||
}
|
||||
|
||||
return super.getOnlineNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの総参加人数を返す
|
||||
* @return 総参加人数
|
||||
* @see com.github.ucchyocean.lc3.channel.Channel#getTotalNum()
|
||||
*/
|
||||
@Override
|
||||
public int getTotalNum() {
|
||||
|
||||
// ブロードキャストチャンネルならサーバー接続人数を返す
|
||||
if ( isBroadcastChannel() ) {
|
||||
return UtilityBukkit.getOnlinePlayersCount();
|
||||
}
|
||||
|
||||
return super.getTotalNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのメンバーを返す
|
||||
* @return チャンネルのメンバー
|
||||
* @see com.github.ucchyocean.lc3.channel.Channel#getMembers()
|
||||
*/
|
||||
@Override
|
||||
public List<ChannelMember> getMembers() {
|
||||
|
||||
// ブロードキャストチャンネルなら、
|
||||
// 現在サーバーに接続している全プレイヤーをメンバーとして返す
|
||||
if ( isBroadcastChannel() ) {
|
||||
List<ChannelMember> mem = new ArrayList<ChannelMember>();
|
||||
for ( Player p : Bukkit.getOnlinePlayers() ) {
|
||||
mem.add(ChannelMember.getChannelMember(p));
|
||||
}
|
||||
return mem;
|
||||
}
|
||||
|
||||
return super.getMembers();
|
||||
}
|
||||
|
||||
/**
|
||||
* ログを記録する
|
||||
* @param name 発言者
|
||||
* @param message 記録するメッセージ
|
||||
*/
|
||||
@Override
|
||||
protected void log(String message, String name) {
|
||||
|
||||
// LunaChatのチャットログへ記録
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
if ( config.isLoggingChat() && logger != null ) {
|
||||
logger.log(message, name);
|
||||
}
|
||||
|
||||
// TODO ログ記録プラグイン連携を検討する
|
||||
// // Hawkeye Reloaded のチャットログへ記録
|
||||
// if ( config.isLoggingChatToHawkEye() && LunaChat.getInstance().getHawkEye() != null
|
||||
// && player != null && player.getLocation() != null ) {
|
||||
// LunaChat.getInstance().getHawkEye().writeLog(name, player.getLocation(),
|
||||
// "channel(" + getName() + ")-" + Utility.stripColor(message));
|
||||
// }
|
||||
//
|
||||
// // Prism のチャットログへ記録
|
||||
// if ( config.isLoggingChatToPrism() && LunaChat.getInstance().getPrism() != null
|
||||
// && player != null && player.getPlayer() != null ) {
|
||||
// LunaChat.getInstance().getPrism().writeLog(player.getPlayer(),
|
||||
// "channel(" + getName() + ")-" + Utility.stripColor(message));
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.channel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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.event.EventResult;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.util.ClickableFormat;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
/**
|
||||
* チャンネルのBungee実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BungeeChannel extends Channel {
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name チャンネル名
|
||||
*/
|
||||
protected BungeeChannel(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージを表示します。指定したプレイヤーの発言として処理されます。
|
||||
* @param player プレイヤー(ワールドチャット、範囲チャットの場合は必須です)
|
||||
* @param message メッセージ
|
||||
* @param format フォーマット
|
||||
* @param sendDynmap dynmapへ送信するかどうか
|
||||
*/
|
||||
@Override
|
||||
protected void sendMessage(ChannelMember player, String message,
|
||||
@Nullable ClickableFormat format, boolean sendDynmap) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
String originalMessage = new String(message);
|
||||
|
||||
// 受信者を設定する
|
||||
List<ChannelMember> recipients = new ArrayList<ChannelMember>();
|
||||
|
||||
if ( isBroadcastChannel() ) {
|
||||
// ブロードキャストチャンネル
|
||||
|
||||
// NOTE: BungeeChannelは範囲チャットやワールドチャットをサポートしない
|
||||
|
||||
// 通常ブロードキャスト(全員へ送信)
|
||||
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() ) {
|
||||
ChannelMember cp = ChannelMember.getChannelMember(p);
|
||||
if ( !getHided().contains(cp) ) {
|
||||
recipients.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// 通常チャンネル
|
||||
|
||||
for ( ChannelMember mem : getMembers() ) {
|
||||
if ( mem != null && mem.isOnline() && !getHided().contains(mem) ) {
|
||||
recipients.add(mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// opListenAllChannel 設定がある場合は、
|
||||
// パーミッション lunachat-admin.listen-all-channels を持つプレイヤーを
|
||||
// 受信者に加える。
|
||||
if ( config.isOpListenAllChannel() ) {
|
||||
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() ) {
|
||||
ChannelMember cp = ChannelMember.getChannelMember(p);
|
||||
if ( cp.hasPermission("lunachat-admin.listen-all-channels")
|
||||
&& !recipients.contains(cp) ) {
|
||||
recipients.add(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hideされている場合は、受信対象者から抜く。
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
for ( ChannelMember cp : api.getHidelist(player) ) {
|
||||
if ( recipients.contains(cp) ) {
|
||||
recipients.remove(cp);
|
||||
}
|
||||
}
|
||||
|
||||
// フォーマットがある場合は置き換える
|
||||
|
||||
// LunaChatChannelMessageEvent イベントコール
|
||||
String name = (player != null) ? player.getDisplayName() : "<null>";
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatChannelMessageEvent(
|
||||
getName(), player, message, recipients, name, originalMessage);
|
||||
message = result.getMessage();
|
||||
recipients = result.getRecipients();
|
||||
|
||||
// 送信する
|
||||
if ( format != null ) {
|
||||
format.replace("%msg", message);
|
||||
BaseComponent[] comps = format.makeTextComponent();
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(comps);
|
||||
}
|
||||
message = format.toLegacyText();
|
||||
} else {
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 設定に応じて、コンソールに出力する
|
||||
if ( config.isDisplayChatOnConsole() ) {
|
||||
LunaChatBungee.getInstance().getLogger().info(message);
|
||||
}
|
||||
|
||||
// ロギング
|
||||
log(originalMessage, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのオンライン人数を返す
|
||||
* @return オンライン人数
|
||||
* @see com.github.ucchyocean.lc3.channel.Channel#getOnlineNum()
|
||||
*/
|
||||
@Override
|
||||
public int getOnlineNum() {
|
||||
|
||||
// ブロードキャストチャンネルならサーバー接続人数を返す
|
||||
if ( isBroadcastChannel() ) {
|
||||
return ProxyServer.getInstance().getOnlineCount();
|
||||
}
|
||||
|
||||
return super.getOnlineNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの総参加人数を返す
|
||||
* @return 総参加人数
|
||||
* @see com.github.ucchyocean.lc3.channel.Channel#getTotalNum()
|
||||
*/
|
||||
@Override
|
||||
public int getTotalNum() {
|
||||
|
||||
// ブロードキャストチャンネルならサーバー接続人数を返す
|
||||
if ( isBroadcastChannel() ) {
|
||||
return ProxyServer.getInstance().getOnlineCount();
|
||||
}
|
||||
|
||||
return super.getTotalNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのメンバーを返す
|
||||
* @return チャンネルのメンバー
|
||||
* @see com.github.ucchyocean.lc3.channel.Channel#getMembers()
|
||||
*/
|
||||
@Override
|
||||
public List<ChannelMember> getMembers() {
|
||||
|
||||
// ブロードキャストチャンネルなら、
|
||||
// 現在サーバーに接続している全プレイヤーをメンバーとして返す
|
||||
if ( isBroadcastChannel() ) {
|
||||
List<ChannelMember> mem = new ArrayList<ChannelMember>();
|
||||
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() ) {
|
||||
mem.add(ChannelMember.getChannelMember(p));
|
||||
}
|
||||
return mem;
|
||||
}
|
||||
|
||||
return super.getMembers();
|
||||
}
|
||||
|
||||
/**
|
||||
* ログを記録する
|
||||
* @param name 発言者
|
||||
* @param message 記録するメッセージ
|
||||
*/
|
||||
@Override
|
||||
protected void log(String message, String name) {
|
||||
|
||||
// LunaChatのチャットログへ記録
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
if ( config.isLoggingChat() && logger != null ) {
|
||||
logger.log(message, name);
|
||||
}
|
||||
|
||||
// TODO ログ記録プラグイン連携を検討する
|
||||
}
|
||||
}
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.channel;
|
||||
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.util.ClickableFormat;
|
||||
|
||||
/**
|
||||
* Japanize2行表示のときに、変換結果を遅延してチャンネルに表示するためのタスク
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ChannelChatJapanizeTask implements Runnable {
|
||||
|
||||
private Channel channel;
|
||||
private ChannelMember player;
|
||||
private ClickableFormat lineFormat;
|
||||
|
||||
private JapanizeConvertTask task;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param org 変換前の文字列
|
||||
* @param type 変換タイプ
|
||||
* @param channel 変換後に発言する、発言先チャンネル
|
||||
* @param player 発言したプレイヤー
|
||||
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
|
||||
* @param lineFormat チャンネルのフォーマット
|
||||
*/
|
||||
public ChannelChatJapanizeTask(String org, JapanizeType type, Channel channel,
|
||||
ChannelMember player, String japanizeFormat, ClickableFormat lineFormat) {
|
||||
|
||||
task = new JapanizeConvertTask(org, type, japanizeFormat, channel, player);
|
||||
this.channel = channel;
|
||||
this.player = player;
|
||||
this.lineFormat = lineFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if ( task.runSync() ) {
|
||||
// チャンネルへ送信
|
||||
channel.sendMessage(player, task.getResult(), lineFormat, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
+115
-128
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2013
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.channel;
|
||||
package com.github.ucchyocean.lc3.channel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -12,16 +12,14 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelCreateEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelRemoveEvent;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc3.LunaChatMode;
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
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.util.YamlConfig;
|
||||
|
||||
/**
|
||||
* チャンネルマネージャー
|
||||
@@ -29,8 +27,6 @@ import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
*/
|
||||
public class ChannelManager implements LunaChatAPI {
|
||||
|
||||
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";
|
||||
@@ -47,7 +43,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
private HashMap<String, String> templates;
|
||||
private HashMap<String, Boolean> japanize;
|
||||
private HashMap<String, String> dictionary;
|
||||
private HashMap<String, List<ChannelPlayer>> hidelist;
|
||||
private HashMap<String, List<ChannelMember>> hidelist;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
@@ -63,41 +59,30 @@ public class ChannelManager implements LunaChatAPI {
|
||||
public void reloadAllData() {
|
||||
|
||||
// デフォルトチャンネル設定のロード
|
||||
fileDefaults = new File(
|
||||
LunaChat.getInstance().getDataFolder(), FILE_NAME_DCHANNELS);
|
||||
fileDefaults = new File(LunaChat.getDataFolder(), FILE_NAME_DCHANNELS);
|
||||
|
||||
if ( !fileDefaults.exists() ) {
|
||||
YamlConfiguration conf = new YamlConfiguration();
|
||||
try {
|
||||
conf.save(fileDefaults);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
makeEmptyFile(fileDefaults);
|
||||
}
|
||||
|
||||
YamlConfiguration config =
|
||||
YamlConfiguration.loadConfiguration(fileDefaults);
|
||||
YamlConfig config = YamlConfig.load(fileDefaults);
|
||||
|
||||
defaultChannels = new HashMap<String, String>();
|
||||
for ( String key : config.getKeys(false) ) {
|
||||
defaultChannels.put(key, config.getString(key).toLowerCase());
|
||||
}
|
||||
|
||||
// テンプレート設定のロード
|
||||
fileTemplates = new File(
|
||||
LunaChat.getInstance().getDataFolder(), FILE_NAME_TEMPLATES);
|
||||
|
||||
if ( !fileTemplates.exists() ) {
|
||||
YamlConfiguration conf = new YamlConfiguration();
|
||||
try {
|
||||
conf.save(fileTemplates);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
String value = config.getString(key);
|
||||
if ( value != null) {
|
||||
defaultChannels.put(key, value.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
YamlConfiguration configTemplates =
|
||||
YamlConfiguration.loadConfiguration(fileTemplates);
|
||||
// テンプレート設定のロード
|
||||
fileTemplates = new File(LunaChat.getDataFolder(), FILE_NAME_TEMPLATES);
|
||||
|
||||
if ( !fileTemplates.exists() ) {
|
||||
makeEmptyFile(fileTemplates);
|
||||
}
|
||||
|
||||
YamlConfig configTemplates = YamlConfig.load(fileTemplates);
|
||||
|
||||
templates = new HashMap<String, String>();
|
||||
for ( String key : configTemplates.getKeys(false) ) {
|
||||
@@ -105,20 +90,13 @@ public class ChannelManager implements LunaChatAPI {
|
||||
}
|
||||
|
||||
// Japanize設定のロード
|
||||
fileJapanize = new File(
|
||||
LunaChat.getInstance().getDataFolder(), FILE_NAME_JAPANIZE);
|
||||
fileJapanize = new File(LunaChat.getDataFolder(), FILE_NAME_JAPANIZE);
|
||||
|
||||
if ( !fileJapanize.exists() ) {
|
||||
YamlConfiguration conf = new YamlConfiguration();
|
||||
try {
|
||||
conf.save(fileJapanize);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
makeEmptyFile(fileJapanize);
|
||||
}
|
||||
|
||||
YamlConfiguration configJapanize =
|
||||
YamlConfiguration.loadConfiguration(fileJapanize);
|
||||
YamlConfig configJapanize = YamlConfig.load(fileJapanize);
|
||||
|
||||
japanize = new HashMap<String, Boolean>();
|
||||
for ( String key : configJapanize.getKeys(false) ) {
|
||||
@@ -126,20 +104,13 @@ public class ChannelManager implements LunaChatAPI {
|
||||
}
|
||||
|
||||
// dictionaryのロード
|
||||
fileDictionary = new File(
|
||||
LunaChat.getInstance().getDataFolder(), FILE_NAME_DICTIONARY);
|
||||
fileDictionary = new File(LunaChat.getDataFolder(), FILE_NAME_DICTIONARY);
|
||||
|
||||
if ( !fileDictionary.exists() ) {
|
||||
YamlConfiguration conf = new YamlConfiguration();
|
||||
try {
|
||||
conf.save(fileDictionary);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
makeEmptyFile(fileDictionary);
|
||||
}
|
||||
|
||||
YamlConfiguration configDictionary =
|
||||
YamlConfiguration.loadConfiguration(fileDictionary);
|
||||
YamlConfig configDictionary = YamlConfig.load(fileDictionary);
|
||||
|
||||
dictionary = new HashMap<String, String>();
|
||||
for ( String key : configDictionary.getKeys(false) ) {
|
||||
@@ -147,26 +118,19 @@ public class ChannelManager implements LunaChatAPI {
|
||||
}
|
||||
|
||||
// hideリストのロード
|
||||
fileHidelist = new File(
|
||||
LunaChat.getInstance().getDataFolder(), FILE_NAME_HIDELIST);
|
||||
fileHidelist = new File(LunaChat.getDataFolder(), FILE_NAME_HIDELIST);
|
||||
|
||||
if ( !fileHidelist.exists() ) {
|
||||
YamlConfiguration conf = new YamlConfiguration();
|
||||
try {
|
||||
conf.save(fileHidelist);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
makeEmptyFile(fileHidelist);
|
||||
}
|
||||
|
||||
YamlConfiguration configHidelist =
|
||||
YamlConfiguration.loadConfiguration(fileHidelist);
|
||||
YamlConfig configHidelist = YamlConfig.load(fileHidelist);
|
||||
|
||||
hidelist = new HashMap<String, List<ChannelPlayer>>();
|
||||
hidelist = new HashMap<String, List<ChannelMember>>();
|
||||
for ( String key : configHidelist.getKeys(false) ) {
|
||||
hidelist.put(key, new ArrayList<ChannelPlayer>());
|
||||
hidelist.put(key, new ArrayList<ChannelMember>());
|
||||
for ( String id : configHidelist.getStringList(key) ) {
|
||||
hidelist.get(key).add(ChannelPlayer.getChannelPlayer(id));
|
||||
hidelist.get(key).add(ChannelMember.getChannelMember(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +157,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
private boolean saveDefaults() {
|
||||
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
YamlConfig config = new YamlConfig();
|
||||
for ( String key : defaultChannels.keySet() ) {
|
||||
config.set(key, defaultChannels.get(key));
|
||||
}
|
||||
@@ -212,7 +176,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
private boolean saveTemplates() {
|
||||
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
YamlConfig config = new YamlConfig();
|
||||
for ( String key : templates.keySet() ) {
|
||||
config.set(key, templates.get(key));
|
||||
}
|
||||
@@ -231,7 +195,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
private boolean saveJapanize() {
|
||||
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
YamlConfig config = new YamlConfig();
|
||||
for ( String key : japanize.keySet() ) {
|
||||
config.set(key, japanize.get(key));
|
||||
}
|
||||
@@ -250,7 +214,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
private boolean saveDictionary() {
|
||||
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
YamlConfig config = new YamlConfig();
|
||||
for ( String key : dictionary.keySet() ) {
|
||||
config.set(key, dictionary.get(key));
|
||||
}
|
||||
@@ -269,7 +233,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
private boolean saveHidelist() {
|
||||
|
||||
try {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
YamlConfig config = new YamlConfig();
|
||||
for ( String key : hidelist.keySet() ) {
|
||||
config.set(key, getIdList(hidelist.get(key)));
|
||||
}
|
||||
@@ -306,7 +270,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* 指定したチャンネル名が存在するかどうかを返す
|
||||
* @param channelName チャンネル名
|
||||
* @return 存在するかどうか
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#isExistChannel(java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#isExistChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isExistChannel(String channelName) {
|
||||
@@ -319,7 +283,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
/**
|
||||
* 全てのチャンネルを返す
|
||||
* @return 全てのチャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#getChannels()
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#getChannels()
|
||||
*/
|
||||
@Override
|
||||
public Collection<Channel> getChannels() {
|
||||
@@ -331,12 +295,12 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* プレイヤーが参加しているチャンネルを返す
|
||||
* @param playerName プレイヤー名
|
||||
* @return チャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#getChannelsByPlayer(java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#getChannelsByPlayer(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Collection<Channel> getChannelsByPlayer(String playerName) {
|
||||
|
||||
ChannelPlayer cp = ChannelPlayer.getChannelPlayer(playerName);
|
||||
ChannelMember cp = ChannelMember.getChannelMember(playerName);
|
||||
Collection<Channel> result = new ArrayList<Channel>();
|
||||
for ( String key : channels.keySet() ) {
|
||||
Channel channel = channels.get(key);
|
||||
@@ -352,7 +316,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* プレイヤーが参加しているデフォルトのチャンネルを返す
|
||||
* @param playerName プレイヤー
|
||||
* @return チャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#getDefaultChannel(java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#getDefaultChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Channel getDefaultChannel(String playerName) {
|
||||
@@ -369,7 +333,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* プレイヤーのデフォルトチャンネルを設定する
|
||||
* @param playerName プレイヤー
|
||||
* @param channelName チャンネル名
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#setDefaultChannel(java.lang.String, java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#setDefaultChannel(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setDefaultChannel(String playerName, String channelName) {
|
||||
@@ -384,7 +348,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
/**
|
||||
* 指定した名前のプレイヤーに設定されている、デフォルトチャンネルを削除する
|
||||
* @param playerName プレイヤー名
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#removeDefaultChannel(java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#removeDefaultChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void removeDefaultChannel(String playerName) {
|
||||
@@ -398,7 +362,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* チャンネルを取得する
|
||||
* @param channelName チャンネル名、または、チャンネルの別名
|
||||
* @return チャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#getChannel(java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#getChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Channel getChannel(String channelName) {
|
||||
@@ -419,7 +383,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @return 作成されたチャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#createChannel(java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#createChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Channel createChannel(String channelName) {
|
||||
@@ -429,22 +393,29 @@ public class ChannelManager implements LunaChatAPI {
|
||||
/**
|
||||
* 新しいチャンネルを作成する
|
||||
* @param channelName チャンネル名
|
||||
* @param member チャンネルを作成した人
|
||||
* @return 作成されたチャンネル
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#createChannel(java.lang.String, org.bukkit.command.CommandSender)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#createChannel(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember)
|
||||
*/
|
||||
@Override
|
||||
public Channel createChannel(String channelName, CommandSender sender) {
|
||||
public Channel createChannel(String channelName, ChannelMember member) {
|
||||
|
||||
// イベントコール
|
||||
LunaChatChannelCreateEvent event =
|
||||
new LunaChatChannelCreateEvent(channelName, sender);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if ( event.isCancelled() ) {
|
||||
// LunaChatChannelCreateEvent イベントコール
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatChannelCreateEvent(channelName, member);
|
||||
if ( result.isCancelled() ) {
|
||||
return null;
|
||||
}
|
||||
String name = event.getChannelName();
|
||||
String name = result.getChannelName();
|
||||
|
||||
Channel channel = null;
|
||||
if ( LunaChat.getMode() == LunaChatMode.BUKKIT ) {
|
||||
channel = new BukkitChannel(name);
|
||||
} else if ( LunaChat.getMode() == LunaChatMode.BUNGEE ) {
|
||||
channel = new BungeeChannel(name);
|
||||
} else {
|
||||
channel = new StandaloneChannel(name);
|
||||
}
|
||||
|
||||
Channel channel = new ChannelImpl(name);
|
||||
channels.put(name.toLowerCase(), channel);
|
||||
channel.save();
|
||||
return channel;
|
||||
@@ -454,7 +425,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @return 削除したかどうか
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#removeChannel(java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#removeChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeChannel(String channelName) {
|
||||
@@ -464,31 +435,29 @@ public class ChannelManager implements LunaChatAPI {
|
||||
/**
|
||||
* チャンネルを削除する
|
||||
* @param channelName 削除するチャンネル名
|
||||
* @param member チャンネルを削除した人
|
||||
* @return 削除したかどうか
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#removeChannel(java.lang.String, org.bukkit.command.CommandSender)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#removeChannel(java.lang.String, com.github.ucchyocean.lc3.member.ChannelMember)
|
||||
*/
|
||||
@Override
|
||||
public boolean removeChannel(String channelName, CommandSender sender) {
|
||||
public boolean removeChannel(String channelName, ChannelMember member) {
|
||||
|
||||
channelName = channelName.toLowerCase();
|
||||
|
||||
// イベントコール
|
||||
LunaChatChannelRemoveEvent event =
|
||||
new LunaChatChannelRemoveEvent(channelName, sender);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if ( event.isCancelled() ) {
|
||||
// LunaChatChannelRemoveEvent イベントコール
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatChannelRemoveEvent(channelName, member);
|
||||
if ( result.isCancelled() ) {
|
||||
return false;
|
||||
}
|
||||
channelName = result.getChannelName();
|
||||
|
||||
Channel channel = getChannel(channelName);
|
||||
if ( channel != null ) {
|
||||
|
||||
// 強制解散のメッセージを、残ったメンバーに流す
|
||||
if ( !channel.isPersonalChat() && !MSG_BREAKUP.equals("") ) {
|
||||
String message = new String(MSG_BREAKUP);
|
||||
message = message.replace("%ch", channel.getName());
|
||||
message = message.replace("%color", channel.getColorCode());
|
||||
for ( ChannelPlayer cp : channel.getMembers() ) {
|
||||
String message = Messages.breakupMessage(channel.getColorCode(), channel.getName());
|
||||
if ( !channel.isPersonalChat() && !message.equals("") ) {
|
||||
for ( ChannelMember cp : channel.getMembers() ) {
|
||||
cp.sendMessage(message);
|
||||
}
|
||||
}
|
||||
@@ -505,7 +474,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* テンプレートを取得する
|
||||
* @param id テンプレートID
|
||||
* @return テンプレート
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#getTemplate(java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#getTemplate(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String getTemplate(String id) {
|
||||
@@ -516,7 +485,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* テンプレートを登録する
|
||||
* @param id テンプレートID
|
||||
* @param template テンプレート
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#setTemplate(java.lang.String, java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#setTemplate(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setTemplate(String id, String template) {
|
||||
@@ -527,7 +496,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
/**
|
||||
* テンプレートを削除する
|
||||
* @param id テンプレートID
|
||||
* @see com.github.ucchyocean.lc.LunaChatAPI#removeTemplate(java.lang.String)
|
||||
* @see com.github.ucchyocean.lc3.LunaChatAPI#removeTemplate(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void removeTemplate(String id) {
|
||||
@@ -567,14 +536,14 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* @param key プレイヤー
|
||||
* @return 指定されたプレイヤーをhideしているプレイヤー(非null)
|
||||
*/
|
||||
public List<ChannelPlayer> getHidelist(ChannelPlayer key) {
|
||||
public List<ChannelMember> getHidelist(ChannelMember key) {
|
||||
if ( key == null ) {
|
||||
return new ArrayList<ChannelPlayer>();
|
||||
return new ArrayList<ChannelMember>();
|
||||
}
|
||||
if ( hidelist.containsKey(key.toString()) ) {
|
||||
return hidelist.get(key.toString());
|
||||
}
|
||||
return new ArrayList<ChannelPlayer>();
|
||||
return new ArrayList<ChannelMember>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -582,14 +551,14 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* @param player プレイヤー
|
||||
* @return 指定したプレイヤーがhideしているプレイヤーのリスト(非null)
|
||||
*/
|
||||
public ArrayList<ChannelPlayer> getHideinfo(ChannelPlayer player) {
|
||||
public ArrayList<ChannelMember> getHideinfo(ChannelMember player) {
|
||||
if ( player == null ) {
|
||||
return new ArrayList<ChannelPlayer>();
|
||||
return new ArrayList<ChannelMember>();
|
||||
}
|
||||
ArrayList<ChannelPlayer> info = new ArrayList<ChannelPlayer>();
|
||||
ArrayList<ChannelMember> info = new ArrayList<ChannelMember>();
|
||||
for ( String key : hidelist.keySet() ) {
|
||||
if ( hidelist.get(key).contains(player) ) {
|
||||
info.add(ChannelPlayer.getChannelPlayer(key));
|
||||
info.add(ChannelMember.getChannelMember(key));
|
||||
}
|
||||
}
|
||||
return info;
|
||||
@@ -600,10 +569,10 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* @param player hideする側のプレイヤー
|
||||
* @param hided hideされる側のプレイヤー
|
||||
*/
|
||||
public void addHidelist(ChannelPlayer player, ChannelPlayer hided) {
|
||||
public void addHidelist(ChannelMember player, ChannelMember hided) {
|
||||
String hidedId = hided.toString();
|
||||
if ( !hidelist.containsKey(hidedId) ) {
|
||||
hidelist.put(hidedId, new ArrayList<ChannelPlayer>());
|
||||
hidelist.put(hidedId, new ArrayList<ChannelMember>());
|
||||
}
|
||||
if ( !hidelist.get(hidedId).contains(player) ) {
|
||||
hidelist.get(hidedId).add(player);
|
||||
@@ -616,7 +585,7 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* @param player hideしていた側のプレイヤー
|
||||
* @param hided hideされていた側のプレイヤー
|
||||
*/
|
||||
public void removeHidelist(ChannelPlayer player, ChannelPlayer hided) {
|
||||
public void removeHidelist(ChannelMember player, ChannelMember hided) {
|
||||
String hidedId = hided.toString();
|
||||
if ( !hidelist.containsKey(hidedId) ) {
|
||||
return;
|
||||
@@ -643,9 +612,8 @@ public class ChannelManager implements LunaChatAPI {
|
||||
return message;
|
||||
}
|
||||
|
||||
// Japanize変換タスクを作成して、同期で実行する。
|
||||
DelayedJapanizeConvertTask task = new DelayedJapanizeConvertTask(
|
||||
message, type, null, null, "%japanize");
|
||||
// Japanize変換
|
||||
JapanizeConvertTask task = new JapanizeConvertTask(message, type, "%japanize", null, null);
|
||||
if ( task.runSync() ) {
|
||||
return task.getResult();
|
||||
}
|
||||
@@ -664,15 +632,34 @@ public class ChannelManager implements LunaChatAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* ChannelPlayerのリストを、IDのStringリストに変換して返す
|
||||
* ChannelMemberのリストを、IDのStringリストに変換して返す
|
||||
* @param players
|
||||
* @return
|
||||
*/
|
||||
private List<String> getIdList(List<ChannelPlayer> players) {
|
||||
private List<String> getIdList(List<ChannelMember> players) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
for ( ChannelPlayer cp : players ) {
|
||||
for ( ChannelMember cp : players ) {
|
||||
results.add(cp.toString());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定されたファイル出力先に、空のYamlファイルを作成する
|
||||
* @param file 出力先
|
||||
*/
|
||||
private void makeEmptyFile(File file) {
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
YamlConfig config = new YamlConfig();
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
176ファイル中100ファイルを読み込みました。 変更されたファイルが多すぎるため、それ以降のファイルは表示していません。
さらに表示
新しいイシューから参照
ユーザーをブロックする