mirror of
https://github.com/Shiewk/SModeration.git
synced 2026-04-29 06:34:17 +02:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4266b7ebb6 | |||
| a46e00a68d | |||
| bad8a4bb90 | |||
| 05c41dc4c3 | |||
| bf476c7a4b | |||
| d93a9aa9e4 | |||
| 7d94c782b8 | |||
| d8ff58191f | |||
| e2a344d92c | |||
| 1f91b2aa4e | |||
| 2b5a089a86 | |||
| 8698d7991d | |||
| 121d736468 | |||
| 762629e263 |
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Report bugs to help us make the plugin better and more reliable.
|
||||||
|
title: "[BUG]"
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**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.
|
||||||
|
|
||||||
|
**Server**
|
||||||
|
Please provide information about the plugin version and the server.
|
||||||
|
This section should include:
|
||||||
|
1. Server Software
|
||||||
|
2. Server version
|
||||||
|
3. Plugin Version you are using
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this plugin
|
||||||
|
title: "[REQUEST]"
|
||||||
|
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.
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
@@ -17,62 +17,15 @@ SModeration provides a nice user interface that can be used instead of chat comm
|
|||||||
It has helpful functions like filtering and sorting options.
|
It has helpful functions like filtering and sorting options.
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
This plugin has many commands, for a complete list of commands and their usage, please see [the commands list](https://github.com/Shiewk/SModeration/blob/main/docs/commands.md).
|
||||||
### /smod
|
The most important ones are:
|
||||||
The /smod command just opens the SMod menu. It takes no arguments.
|
- /mute
|
||||||
### /mute
|
- /ban
|
||||||
The /mute command is used to mute players.
|
- /kick
|
||||||
|
- /smod
|
||||||
It requires 2 arguments:
|
- /unmute & /unban
|
||||||
- Player name
|
- /invsee & /enderchestsee
|
||||||
- Duration
|
|
||||||
|
|
||||||
If you want to, you can also add a **reason**.
|
|
||||||
|
|
||||||
For example, if you want to mute a player for breaking server rules, just use **/mute playername 1h 30min Breaking server rules.**
|
|
||||||
|
|
||||||
The player will be muted for 1 hour and 30 minutes with the reason "Breaking server rules.".
|
|
||||||
|
|
||||||
Muted players can still join the server, but can't use the chat.
|
|
||||||
### /ban
|
|
||||||
The /ban command works the same as the /mute command, with one important difference:
|
|
||||||
|
|
||||||
Banned players **can't even join** the server until the ban expires.
|
|
||||||
### /kick
|
|
||||||
The /kick command is a bit different. It does not require a duration because kicks are instant. Instead, you can use the command like this: **/kick playername reason**
|
|
||||||
### /modlogs
|
|
||||||
The /modlogs command can be used when the /smod menu is unavailable. It displays information about a player in chat instead of a menu.
|
|
||||||
|
|
||||||
Example: **/modlogs playername** shows you a message in chat that tells you whether the player is muted or banned.
|
|
||||||
### /unmute & /unban
|
|
||||||
The /unmute and /unban commands only take one argument, the player name.
|
|
||||||
|
|
||||||
The specified player will then be unmuted or unbanned.
|
|
||||||
### /invsee
|
|
||||||
The /invsee command can be used to view the inventory of another player.
|
|
||||||
|
|
||||||
It takes one argument: the player name.
|
|
||||||
The player has to be online.
|
|
||||||
### /enderchestsee
|
|
||||||
The /enderchestsee command can, similarly to /invsee, be used to view the ender chest of another player.
|
|
||||||
|
|
||||||
It takes one argument: the player name.
|
|
||||||
The player has to be online.
|
|
||||||
|
|
||||||
## Permissions
|
## Permissions
|
||||||
This plugin uses Bukkit permissions for commands and other actions.
|
This plugin uses Bukkit permissions for commands and other actions.
|
||||||
- **smod.mute**: Allows the player to mute other players.
|
For a list of permissions, please see [the permissions file](https://github.com/Shiewk/SModeration/blob/main/docs/permissions.md).
|
||||||
- **smod.ban**: Allows the player to ban and kick other players.
|
|
||||||
- **smod.kick**: Allows the player to kick other players.
|
|
||||||
- **smod.menu**: Allows the player to use the SModeration menu.
|
|
||||||
- **smod.notifications**: Allows the player to be notified when a punishment is issued.
|
|
||||||
- **smod.unmute**: Allows the player to unmute other players.
|
|
||||||
- **smod.unban**: Allows the player to unban other players.
|
|
||||||
- **smod.logs**: Allows the player to view mod logs.
|
|
||||||
- **smod.invsee**: Allows the player to view other players inventories.
|
|
||||||
- **smod.invsee.modify**: Allows the player to view and modify other players inventories.
|
|
||||||
- **smod.invsee.preventmodify**: When giving this permission to a player, prevents their inventory from being modified.
|
|
||||||
- **smod.enderchestsee**: Allows the player to view other players ender chests.
|
|
||||||
- **smod.enderchestsee.modify**: Allows the player to view and modify other players ender chests.
|
|
||||||
|
|
||||||
All of these permissions are granted by default if the player is a server operator.
|
|
||||||
+1
-1
@@ -3,7 +3,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'de.shiewk'
|
group = 'de.shiewk'
|
||||||
version = '1.1'
|
version = pluginVersion
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# SModeration commands
|
||||||
|
|
||||||
|
### /smod
|
||||||
|
The /smod command just opens the SMod menu. It takes no arguments.
|
||||||
|
### /mute
|
||||||
|
The /mute command is used to mute players.
|
||||||
|
|
||||||
|
It requires 2 arguments:
|
||||||
|
- Player name
|
||||||
|
- Duration
|
||||||
|
|
||||||
|
If you want to, you can also add a **reason**.
|
||||||
|
|
||||||
|
For example, if you want to mute a player for breaking server rules, just use **/mute playername 1h 30min Breaking server rules.**
|
||||||
|
|
||||||
|
The player will be muted for 1 hour and 30 minutes with the reason "Breaking server rules.".
|
||||||
|
|
||||||
|
Muted players can still join the server, but can't use the chat.
|
||||||
|
### /ban
|
||||||
|
The /ban command works the same as the /mute command, with one important difference:
|
||||||
|
|
||||||
|
Banned players **can't even join** the server until the ban expires.
|
||||||
|
### /kick
|
||||||
|
The /kick command is a bit different. It does not require a duration because kicks are instant. Instead, you can use the command like this: **/kick playername reason**
|
||||||
|
### /modlogs
|
||||||
|
The /modlogs command can be used when the /smod menu is unavailable. It displays information about a player in chat instead of a menu.
|
||||||
|
|
||||||
|
Example: **/modlogs playername** shows you a message in chat that tells you whether the player is muted or banned.
|
||||||
|
### /unmute & /unban
|
||||||
|
The /unmute and /unban commands only take one argument, the player name.
|
||||||
|
|
||||||
|
The specified player will then be unmuted or unbanned.
|
||||||
|
### /invsee
|
||||||
|
The /invsee command can be used to view the inventory of another player.
|
||||||
|
|
||||||
|
It takes one argument: the player name.
|
||||||
|
The player has to be online.
|
||||||
|
### /enderchestsee
|
||||||
|
The /enderchestsee command can, similarly to /invsee, be used to view the ender chest of another player.
|
||||||
|
|
||||||
|
It takes one argument: the player name.
|
||||||
|
The player has to be online.
|
||||||
|
|
||||||
|
### /vanish
|
||||||
|
The /vanish command is used to toggle vanish mode.
|
||||||
|
|
||||||
|
In vanish mode, other players (who don't have the necessary permissions) can't see that you're online.
|
||||||
|
|
||||||
|
To toggle vanish mode for yourself, use **/vanish**.
|
||||||
|
|
||||||
|
To toggle vanish mode for someone else, use **/vanish <playername>**.
|
||||||
|
|
||||||
|
Vanish status is not saved, so you re-appear when you leave the server.
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# SModeration permissions
|
||||||
|
- **smod.mute**: Allows the player to mute other players.
|
||||||
|
- **smod.preventmute**: Prevents the player from being muted (if they are online).
|
||||||
|
- **smod.ban**: Allows the player to ban and kick other players.
|
||||||
|
- **smod.preventban**: Prevents the player from being banned (if they are online).
|
||||||
|
- **smod.kick**: Allows the player to kick other players.
|
||||||
|
- **smod.preventkick**: Prevents the player from being kicked (if they are online).
|
||||||
|
- **smod.menu**: Allows the player to use the SModeration menu.
|
||||||
|
- **smod.notifications**: Allows the player to be notified when a punishment is issued.
|
||||||
|
- **smod.unmute**: Allows the player to unmute other players.
|
||||||
|
- **smod.unban**: Allows the player to unban other players.
|
||||||
|
- **smod.logs**: Allows the player to view mod logs.
|
||||||
|
- **smod.invsee**: Allows the player to view other players inventories.
|
||||||
|
- **smod.invsee.modify**: Allows the player to view and modify other players inventories.
|
||||||
|
- **smod.invsee.preventmodify**: When giving this permission to a player, prevents their inventory from being modified.
|
||||||
|
- **smod.enderchestsee**: Allows the player to view other players ender chests.
|
||||||
|
- **smod.enderchestsee.modify**: Allows the player to view and modify other players ender chests.
|
||||||
|
|
||||||
|
All of these permissions are granted by default if the player is a server operator.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
pluginVersion = 1.2.0
|
||||||
@@ -5,17 +5,23 @@ import de.shiewk.smoderation.event.CustomInventoryEvents;
|
|||||||
import de.shiewk.smoderation.event.EnderchestSeeEvents;
|
import de.shiewk.smoderation.event.EnderchestSeeEvents;
|
||||||
import de.shiewk.smoderation.event.InvSeeEvents;
|
import de.shiewk.smoderation.event.InvSeeEvents;
|
||||||
import de.shiewk.smoderation.listener.PunishmentListener;
|
import de.shiewk.smoderation.listener.PunishmentListener;
|
||||||
|
import de.shiewk.smoderation.listener.VanishListener;
|
||||||
import de.shiewk.smoderation.storage.PunishmentContainer;
|
import de.shiewk.smoderation.storage.PunishmentContainer;
|
||||||
import net.kyori.adventure.text.Component;
|
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
|
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.text.Component.text;
|
||||||
import static org.bukkit.Bukkit.getPluginManager;
|
import static org.bukkit.Bukkit.getPluginManager;
|
||||||
|
|
||||||
public final class SModeration extends JavaPlugin {
|
public final class SModeration extends JavaPlugin {
|
||||||
@@ -29,7 +35,7 @@ public final class SModeration extends JavaPlugin {
|
|||||||
public static final TextColor SECONDARY_COLOR = TextColor.color(52, 143, 255);
|
public static final TextColor SECONDARY_COLOR = TextColor.color(52, 143, 255);
|
||||||
public static final TextColor INACTIVE_COLOR = NamedTextColor.GRAY;
|
public static final TextColor INACTIVE_COLOR = NamedTextColor.GRAY;
|
||||||
public static final TextColor FAIL_COLOR = NamedTextColor.RED;
|
public static final TextColor FAIL_COLOR = NamedTextColor.RED;
|
||||||
public static final TextComponent CHAT_PREFIX = Component.text("SM \u00BB ").color(PRIMARY_COLOR);
|
public static final TextComponent CHAT_PREFIX = text("SM \u00BB ").color(PRIMARY_COLOR);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
@@ -44,57 +50,88 @@ public final class SModeration extends JavaPlugin {
|
|||||||
getPluginManager().registerEvents(new CustomInventoryEvents(), this);
|
getPluginManager().registerEvents(new CustomInventoryEvents(), this);
|
||||||
getPluginManager().registerEvents(new InvSeeEvents(), this);
|
getPluginManager().registerEvents(new InvSeeEvents(), this);
|
||||||
getPluginManager().registerEvents(new EnderchestSeeEvents(), this);
|
getPluginManager().registerEvents(new EnderchestSeeEvents(), this);
|
||||||
|
getPluginManager().registerEvents(new VanishListener(), this);
|
||||||
|
|
||||||
final PluginCommand mute = getCommand("mute");
|
registerCommand("mute", new MuteCommand());
|
||||||
assert mute != null;
|
registerCommand("ban", new BanCommand());
|
||||||
mute.setExecutor(new MuteCommand());
|
registerCommand("kick", new KickCommand());
|
||||||
mute.setTabCompleter(new MuteCommand());
|
registerCommand("smod", new SModCommand());
|
||||||
|
registerCommand("modlogs", new ModLogsCommand());
|
||||||
final PluginCommand ban = getCommand("ban");
|
registerCommand("unmute", new UnmuteCommand());
|
||||||
assert ban != null;
|
registerCommand("unban", new UnbanCommand());
|
||||||
ban.setExecutor(new BanCommand());
|
registerCommand("invsee", new InvseeCommand());
|
||||||
ban.setTabCompleter(new BanCommand());
|
registerCommand("enderchestsee", new EnderchestSeeCommand());
|
||||||
|
registerCommand("vanish", new VanishCommand());
|
||||||
final PluginCommand kick = getCommand("kick");
|
|
||||||
assert kick != null;
|
|
||||||
kick.setExecutor(new KickCommand());
|
|
||||||
kick.setTabCompleter(new KickCommand());
|
|
||||||
|
|
||||||
final PluginCommand smod = getCommand("smod");
|
|
||||||
assert smod != null;
|
|
||||||
smod.setExecutor(new SModCommand());
|
|
||||||
smod.setTabCompleter(new SModCommand());
|
|
||||||
|
|
||||||
final PluginCommand logs = getCommand("modlogs");
|
|
||||||
assert logs != null;
|
|
||||||
logs.setExecutor(new ModLogsCommand());
|
|
||||||
logs.setTabCompleter(new ModLogsCommand());
|
|
||||||
|
|
||||||
final PluginCommand unmute = getCommand("unmute");
|
|
||||||
assert unmute != null;
|
|
||||||
unmute.setExecutor(new UnmuteCommand());
|
|
||||||
unmute.setTabCompleter(new UnmuteCommand());
|
|
||||||
|
|
||||||
final PluginCommand unban = getCommand("unban");
|
|
||||||
assert unban != null;
|
|
||||||
unban.setExecutor(new UnbanCommand());
|
|
||||||
unban.setTabCompleter(new UnbanCommand());
|
|
||||||
|
|
||||||
final PluginCommand invsee = getCommand("invsee");
|
|
||||||
assert invsee != null;
|
|
||||||
invsee.setExecutor(new InvseeCommand());
|
|
||||||
invsee.setTabCompleter(new InvseeCommand());
|
|
||||||
|
|
||||||
final PluginCommand ecsee = getCommand("enderchestsee");
|
|
||||||
assert ecsee != null;
|
|
||||||
ecsee.setExecutor(new EnderchestSeeCommand());
|
|
||||||
ecsee.setTabCompleter(new EnderchestSeeCommand());
|
|
||||||
|
|
||||||
container.load(SAVE_FILE);
|
container.load(SAVE_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerCommand(String label, TabExecutor executor){
|
||||||
|
final PluginCommand command = getCommand(label);
|
||||||
|
if (command != null) {
|
||||||
|
command.setExecutor(executor);
|
||||||
|
command.setTabCompleter(executor);
|
||||||
|
} else {
|
||||||
|
LOGGER.warn("Command %s failed to register: This command does not exist".formatted(label));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
SModeration.container.save(SModeration.SAVE_FILE);
|
SModeration.container.save(SModeration.SAVE_FILE);
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
// in case players are still vanished when the server shuts down
|
||||||
|
if (isVanished(player)){
|
||||||
|
toggleVanish(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ObjectArrayList<Player> vanishedPlayers = new ObjectArrayList<>();
|
||||||
|
|
||||||
|
public static void toggleVanish(Player player){
|
||||||
|
final boolean newStatus = !isVanished(player);
|
||||||
|
if (newStatus){
|
||||||
|
vanishedPlayers.add(player);
|
||||||
|
for (CommandSender sender : container.collectBroadcastTargets()) {
|
||||||
|
sender.sendMessage(CHAT_PREFIX.append(
|
||||||
|
player.displayName()
|
||||||
|
.colorIfAbsent(SECONDARY_COLOR)
|
||||||
|
).append(
|
||||||
|
text()
|
||||||
|
.content(" vanished.")
|
||||||
|
.color(PRIMARY_COLOR)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
player.sendMessage(CHAT_PREFIX.append(text("You are now vanished.").color(PRIMARY_COLOR)));
|
||||||
|
player.setVisibleByDefault(false);
|
||||||
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (onlinePlayer.hasPermission("smod.vanish.see")){
|
||||||
|
onlinePlayer.showEntity(PLUGIN, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vanishedPlayers.remove(player);
|
||||||
|
for (CommandSender sender : container.collectBroadcastTargets()) {
|
||||||
|
sender.sendMessage(CHAT_PREFIX.append(
|
||||||
|
player.displayName()
|
||||||
|
.colorIfAbsent(SECONDARY_COLOR)
|
||||||
|
).append(
|
||||||
|
text()
|
||||||
|
.content(" re-appeared.")
|
||||||
|
.color(PRIMARY_COLOR)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
player.sendMessage(CHAT_PREFIX.append(text("You are no longer vanished.").color(PRIMARY_COLOR)));
|
||||||
|
player.setVisibleByDefault(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isVanished(Player player){
|
||||||
|
return vanishedPlayers.contains(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ObjectArrayList<Player> getVanishedPlayers() {
|
||||||
|
return vanishedPlayers.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BanCommand implements CommandExecutor, TabCompleter {
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
|
public class BanCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (args.length < 2){
|
if (args.length < 2){
|
||||||
@@ -45,6 +47,11 @@ public class BanCommand implements CommandExecutor, TabCompleter {
|
|||||||
sender.sendMessage(Component.text("This player is either offline or was never on this server.").color(NamedTextColor.RED));
|
sender.sendMessage(Component.text("This player is either offline or was never on this server.").color(NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
final Player toPlayer = Bukkit.getPlayer(uuid);
|
||||||
|
if (toPlayer != null && toPlayer.hasPermission("smod.preventban")){
|
||||||
|
sender.sendMessage(text().content("This player can't be banned.").color(NamedTextColor.RED));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
long duration = 0;
|
long duration = 0;
|
||||||
int p = 1;
|
int p = 1;
|
||||||
for (int i = 1 /* start with index 1 to avoid player name */; i < args.length; i++) {
|
for (int i = 1 /* start with index 1 to avoid player name */; i < args.length; i++) {
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import de.shiewk.smoderation.util.PlayerUtil;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
@@ -18,7 +17,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static de.shiewk.smoderation.SModeration.*;
|
import static de.shiewk.smoderation.SModeration.*;
|
||||||
|
|
||||||
public class EnderchestSeeCommand implements CommandExecutor, TabCompleter {
|
public class EnderchestSeeCommand implements TabExecutor {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import de.shiewk.smoderation.util.PlayerUtil;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
@@ -18,7 +17,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static de.shiewk.smoderation.SModeration.*;
|
import static de.shiewk.smoderation.SModeration.*;
|
||||||
|
|
||||||
public class InvseeCommand implements CommandExecutor, TabCompleter {
|
public class InvseeCommand implements TabExecutor {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class KickCommand implements CommandExecutor, TabCompleter {
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
|
public class KickCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (args.length < 1){
|
if (args.length < 1){
|
||||||
@@ -45,6 +47,10 @@ public class KickCommand implements CommandExecutor, TabCompleter {
|
|||||||
sender.sendMessage(Component.text("You can't kick yourself.").color(NamedTextColor.RED));
|
sender.sendMessage(Component.text("You can't kick yourself.").color(NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (player.hasPermission("smod.preventkick")){
|
||||||
|
sender.sendMessage(text().content("This player can't be kicked.").color(NamedTextColor.RED));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
StringBuilder reason = new StringBuilder();
|
StringBuilder reason = new StringBuilder();
|
||||||
for (int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
if (!reason.isEmpty()){
|
if (!reason.isEmpty()){
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -23,7 +22,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import static de.shiewk.smoderation.SModeration.*;
|
import static de.shiewk.smoderation.SModeration.*;
|
||||||
|
|
||||||
public class ModLogsCommand implements CommandExecutor, TabCompleter {
|
public class ModLogsCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (args.length < 1){
|
if (args.length < 1){
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import de.shiewk.smoderation.SModeration;
|
|||||||
import de.shiewk.smoderation.punishments.Punishment;
|
import de.shiewk.smoderation.punishments.Punishment;
|
||||||
import de.shiewk.smoderation.util.PlayerUtil;
|
import de.shiewk.smoderation.util.PlayerUtil;
|
||||||
import de.shiewk.smoderation.util.TimeUtil;
|
import de.shiewk.smoderation.util.TimeUtil;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
@@ -17,7 +16,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MuteCommand implements CommandExecutor, TabCompleter {
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
|
public class MuteCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (args.length < 2){
|
if (args.length < 2){
|
||||||
@@ -29,20 +30,25 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
|
|||||||
} else if (sender instanceof Player pl){
|
} else if (sender instanceof Player pl){
|
||||||
senderUUID = pl.getUniqueId();
|
senderUUID = pl.getUniqueId();
|
||||||
} else if (sender instanceof BlockCommandSender){
|
} else if (sender instanceof BlockCommandSender){
|
||||||
sender.sendMessage(Component.text("Blocks can't execute this command.").color(NamedTextColor.RED));
|
sender.sendMessage(text("Blocks can't execute this command.").color(NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(Component.text("Your command sender type is unknown (%s).".formatted(sender.getClass().getName())).color(NamedTextColor.RED));
|
sender.sendMessage(text("Your command sender type is unknown (%s).".formatted(sender.getClass().getName())).color(NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String playerName = args[0];
|
String playerName = args[0];
|
||||||
UUID uuid = PlayerUtil.offlinePlayerUUIDByName(playerName);
|
UUID uuid = PlayerUtil.offlinePlayerUUIDByName(playerName);
|
||||||
if (senderUUID.equals(uuid)) {
|
if (senderUUID.equals(uuid)) {
|
||||||
sender.sendMessage(Component.text("You can't mute yourself.").color(NamedTextColor.RED));
|
sender.sendMessage(text("You can't mute yourself.").color(NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
sender.sendMessage(Component.text("This player is either offline or was never on this server.").color(NamedTextColor.RED));
|
sender.sendMessage(text("This player is either offline or was never on this server.").color(NamedTextColor.RED));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final Player toPlayer = Bukkit.getPlayer(uuid);
|
||||||
|
if (toPlayer != null && toPlayer.hasPermission("smod.preventmute")){
|
||||||
|
sender.sendMessage(text().content("This player can't be muted.").color(NamedTextColor.RED));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
long duration = 0;
|
long duration = 0;
|
||||||
@@ -59,11 +65,11 @@ public class MuteCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (i == args.length - 1){ p = args.length; }
|
if (i == args.length - 1){ p = args.length; }
|
||||||
}
|
}
|
||||||
if (duration == 0){
|
if (duration == 0){
|
||||||
sender.sendMessage(Component.text("Please provide a valid duration.").color(NamedTextColor.RED));
|
sender.sendMessage(text("Please provide a valid duration.").color(NamedTextColor.RED));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (duration < 0){
|
if (duration < 0){
|
||||||
sender.sendMessage(Component.text("Please provide a duration that's longer than 0ms.").color(NamedTextColor.RED));
|
sender.sendMessage(text("Please provide a duration that's longer than 0ms.").color(NamedTextColor.RED));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
StringBuilder reason = new StringBuilder();
|
StringBuilder reason = new StringBuilder();
|
||||||
|
|||||||
@@ -3,16 +3,15 @@ package de.shiewk.smoderation.command;
|
|||||||
import de.shiewk.smoderation.SModeration;
|
import de.shiewk.smoderation.SModeration;
|
||||||
import de.shiewk.smoderation.inventory.SModMenu;
|
import de.shiewk.smoderation.inventory.SModMenu;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SModCommand implements CommandExecutor, TabCompleter {
|
public class SModCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
|
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
|
||||||
if (commandSender instanceof Player player){
|
if (commandSender instanceof Player player){
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UnbanCommand implements CommandExecutor, TabCompleter {
|
public class UnbanCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (args.length < 1){
|
if (args.length < 1){
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UnmuteCommand implements CommandExecutor, TabCompleter {
|
public class UnmuteCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (args.length < 1){
|
if (args.length < 1){
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package de.shiewk.smoderation.command;
|
||||||
|
|
||||||
|
import de.shiewk.smoderation.SModeration;
|
||||||
|
import de.shiewk.smoderation.util.PlayerUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class VanishCommand implements TabExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
Player player = null;
|
||||||
|
if (args.length > 0){
|
||||||
|
player = PlayerUtil.findOnlinePlayer(args[0]);
|
||||||
|
} else if (sender instanceof Player){
|
||||||
|
player = (Player) sender;
|
||||||
|
}
|
||||||
|
if (player != null){
|
||||||
|
SModeration.toggleVanish(player);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (args.length < 2){
|
||||||
|
return PlayerUtil.listPlayerNames();
|
||||||
|
}
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class InvSeeEvents implements Listener {
|
public class InvSeeEvents implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -14,6 +16,9 @@ public class InvSeeEvents implements Listener {
|
|||||||
final Inventory clicked = event.getView().getTopInventory();
|
final Inventory clicked = event.getView().getTopInventory();
|
||||||
if (clicked instanceof PlayerInventory inventory){
|
if (clicked instanceof PlayerInventory inventory){
|
||||||
final HumanEntity holder = inventory.getHolder();
|
final HumanEntity holder = inventory.getHolder();
|
||||||
|
if (Objects.equals(holder, event.getWhoClicked())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!event.getWhoClicked().hasPermission("smod.invsee.modify")){
|
if (!event.getWhoClicked().hasPermission("smod.invsee.modify")){
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package de.shiewk.smoderation.listener;
|
||||||
|
|
||||||
|
import de.shiewk.smoderation.SModeration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class VanishListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler public void onPlayerQuit(PlayerQuitEvent event){
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (SModeration.isVanished(player)){
|
||||||
|
SModeration.toggleVanish(player);
|
||||||
|
}
|
||||||
|
for (Player vanishedPlayer : SModeration.getVanishedPlayers()) {
|
||||||
|
// to clean up visibility status
|
||||||
|
player.hideEntity(SModeration.PLUGIN, vanishedPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoin(PlayerJoinEvent event){
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (player.hasPermission("smod.vanish.see")){
|
||||||
|
for (Player vanishedPlayer : SModeration.getVanishedPlayers()) {
|
||||||
|
// to show visible vanished players
|
||||||
|
player.showEntity(SModeration.PLUGIN, vanishedPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,7 +9,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public abstract class PlayerUtil {
|
public abstract class PlayerUtil {
|
||||||
private PlayerUtil(){}
|
private PlayerUtil(){}
|
||||||
@@ -55,4 +58,17 @@ public abstract class PlayerUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> listPlayerNames(){
|
||||||
|
return listPlayerNames(pl -> true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> listPlayerNames(final Predicate<Player> predicate) {
|
||||||
|
final ArrayList<String> names = new ArrayList<>();
|
||||||
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (predicate.test(onlinePlayer)){
|
||||||
|
names.add(onlinePlayer.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return List.copyOf(names);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,12 @@ commands:
|
|||||||
- ecs
|
- ecs
|
||||||
permission: smod.enderchestsee
|
permission: smod.enderchestsee
|
||||||
description: Views the ender chest of another player.
|
description: Views the ender chest of another player.
|
||||||
|
vanish:
|
||||||
|
usage: "§cUsage: /vanish <player>"
|
||||||
|
aliases:
|
||||||
|
- smvanish
|
||||||
|
permission: smod.vanish
|
||||||
|
description: Toggles vanish mode which prevents other players from seeing you're online
|
||||||
permissions:
|
permissions:
|
||||||
smod.mute:
|
smod.mute:
|
||||||
default: op
|
default: op
|
||||||
@@ -117,3 +123,18 @@ permissions:
|
|||||||
description: Allows the player to view and modify other players ender chests.
|
description: Allows the player to view and modify other players ender chests.
|
||||||
children:
|
children:
|
||||||
- smod.enderchestsee
|
- smod.enderchestsee
|
||||||
|
smod.preventmute:
|
||||||
|
default: op
|
||||||
|
description: Prevents the player from being muted (if online)
|
||||||
|
smod.preventkick:
|
||||||
|
default: op
|
||||||
|
description: Prevents the player from being muted (if online)
|
||||||
|
smod.preventban:
|
||||||
|
default: op
|
||||||
|
description: Prevents the player from being muted (if online)
|
||||||
|
smod.vanish:
|
||||||
|
default: op
|
||||||
|
description: Allows the player to use /vanish
|
||||||
|
smod.vanish.see:
|
||||||
|
default: op
|
||||||
|
description: Allows the player to see vanished players
|
||||||
Reference in New Issue
Block a user