mirror of
https://github.com/Shiewk/SModeration.git
synced 2026-04-28 05:54:16 +02:00
merge 1.1
update main to v1.1
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
SModeration can be used to mute, ban, and kick players that break the rules while providing a nice interface to your moderators.
|
SModeration can be used to mute, ban, and kick players that break the rules while providing a nice interface to your moderators.
|
||||||
It keeps track of all punishments to ensure that you get a complete overview of every rule violation on your server.
|
It keeps track of all punishments to ensure that you get a complete overview of every rule violation on your server.
|
||||||
|
You can also modify player inventories and ender chests.
|
||||||
|
|
||||||
If you have any feature requests, please [open an issue](https://github.com/Shiewk/SModeration/issues).
|
If you have any feature requests, please [open an issue](https://github.com/Shiewk/SModeration/issues).
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ If you have any feature requests, please [open an issue](https://github.com/Shie
|
|||||||

|

|
||||||
|
|
||||||
SModeration provides a nice user interface that can be used instead of chat commands.
|
SModeration provides a nice user interface that can be used instead of chat commands.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
It has helpful functions like filtering and sorting options.
|
It has helpful functions like filtering and sorting options.
|
||||||
@@ -46,6 +48,17 @@ Example: **/modlogs playername** shows you a message in chat that tells you whet
|
|||||||
The /unmute and /unban commands only take one argument, the player name.
|
The /unmute and /unban commands only take one argument, the player name.
|
||||||
|
|
||||||
The specified player will then be unmuted or unbanned.
|
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.
|
- **smod.mute**: Allows the player to mute other players.
|
||||||
@@ -56,5 +69,10 @@ This plugin uses Bukkit permissions for commands and other actions.
|
|||||||
- **smod.unmute**: Allows the player to unmute other players.
|
- **smod.unmute**: Allows the player to unmute other players.
|
||||||
- **smod.unban**: Allows the player to unban other players.
|
- **smod.unban**: Allows the player to unban other players.
|
||||||
- **smod.logs**: Allows the player to view mod logs.
|
- **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.
|
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.0'
|
version = '1.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package de.shiewk.smoderation;
|
|||||||
|
|
||||||
import de.shiewk.smoderation.command.*;
|
import de.shiewk.smoderation.command.*;
|
||||||
import de.shiewk.smoderation.event.CustomInventoryEvents;
|
import de.shiewk.smoderation.event.CustomInventoryEvents;
|
||||||
|
import de.shiewk.smoderation.event.EnderchestSeeEvents;
|
||||||
|
import de.shiewk.smoderation.event.InvSeeEvents;
|
||||||
import de.shiewk.smoderation.listener.PunishmentListener;
|
import de.shiewk.smoderation.listener.PunishmentListener;
|
||||||
import de.shiewk.smoderation.storage.PunishmentContainer;
|
import de.shiewk.smoderation.storage.PunishmentContainer;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@@ -26,6 +28,7 @@ public final class SModeration extends JavaPlugin {
|
|||||||
public static final TextColor PRIMARY_COLOR = TextColor.color(212, 0, 255);
|
public static final TextColor PRIMARY_COLOR = TextColor.color(212, 0, 255);
|
||||||
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 TextComponent CHAT_PREFIX = Component.text("SM \u00BB ").color(PRIMARY_COLOR);
|
public static final TextComponent CHAT_PREFIX = Component.text("SM \u00BB ").color(PRIMARY_COLOR);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -39,6 +42,8 @@ public final class SModeration extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getPluginManager().registerEvents(new PunishmentListener(), this);
|
getPluginManager().registerEvents(new PunishmentListener(), this);
|
||||||
getPluginManager().registerEvents(new CustomInventoryEvents(), this);
|
getPluginManager().registerEvents(new CustomInventoryEvents(), this);
|
||||||
|
getPluginManager().registerEvents(new InvSeeEvents(), this);
|
||||||
|
getPluginManager().registerEvents(new EnderchestSeeEvents(), this);
|
||||||
|
|
||||||
final PluginCommand mute = getCommand("mute");
|
final PluginCommand mute = getCommand("mute");
|
||||||
assert mute != null;
|
assert mute != null;
|
||||||
@@ -75,6 +80,16 @@ public final class SModeration extends JavaPlugin {
|
|||||||
unban.setExecutor(new UnbanCommand());
|
unban.setExecutor(new UnbanCommand());
|
||||||
unban.setTabCompleter(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package de.shiewk.smoderation.command;
|
||||||
|
|
||||||
|
import de.shiewk.smoderation.util.PlayerUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static de.shiewk.smoderation.SModeration.*;
|
||||||
|
|
||||||
|
public class EnderchestSeeCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (sender instanceof HumanEntity human){
|
||||||
|
final Player player = PlayerUtil.findOnlinePlayer(args[0]);
|
||||||
|
if (player != null) {
|
||||||
|
if (human.getUniqueId().equals(player.getUniqueId())){
|
||||||
|
human.sendMessage(Component.text("You can't open your own ender chest.").color(FAIL_COLOR));
|
||||||
|
} else {
|
||||||
|
human.sendMessage(CHAT_PREFIX.append(
|
||||||
|
Component.text("Opening ender chest of ").color(PRIMARY_COLOR)
|
||||||
|
.append(Component.text(player.getName()).color(SECONDARY_COLOR))
|
||||||
|
.append(Component.text("."))
|
||||||
|
));
|
||||||
|
human.openInventory(player.getEnderChest());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
human.sendMessage(Component.text("This player is not online.").color(FAIL_COLOR));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(Component.text("Only an entity that can open inventories can execute this command!").color(FAIL_COLOR));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (args.length > 1){
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
List<String> available = new ArrayList<>();
|
||||||
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
available.add(onlinePlayer.getName());
|
||||||
|
}
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
StringUtil.copyPartialMatches(args.length > 0 ? args[0] : "", available, completions);
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package de.shiewk.smoderation.command;
|
||||||
|
|
||||||
|
import de.shiewk.smoderation.util.PlayerUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static de.shiewk.smoderation.SModeration.*;
|
||||||
|
|
||||||
|
public class InvseeCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (sender instanceof HumanEntity human){
|
||||||
|
final Player player = PlayerUtil.findOnlinePlayer(args[0]);
|
||||||
|
if (player != null) {
|
||||||
|
if (human.getUniqueId().equals(player.getUniqueId())){
|
||||||
|
human.sendMessage(Component.text("You can't open your own inventory.").color(FAIL_COLOR));
|
||||||
|
} else {
|
||||||
|
human.sendMessage(CHAT_PREFIX.append(
|
||||||
|
Component.text("Opening inventory of ").color(PRIMARY_COLOR)
|
||||||
|
.append(Component.text(player.getName()).color(SECONDARY_COLOR))
|
||||||
|
.append(Component.text("."))
|
||||||
|
));
|
||||||
|
human.openInventory(player.getInventory());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
human.sendMessage(Component.text("This player is not online.").color(FAIL_COLOR));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(Component.text("Only an entity that can open inventories can execute this command!").color(FAIL_COLOR));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (args.length > 1){
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
List<String> available = new ArrayList<>();
|
||||||
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
available.add(onlinePlayer.getName());
|
||||||
|
}
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
StringUtil.copyPartialMatches(args.length > 0 ? args[0] : "", available, completions);
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package de.shiewk.smoderation.event;
|
||||||
|
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
|
public class EnderchestSeeEvents implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event){
|
||||||
|
final Inventory clicked = event.getView().getTopInventory();
|
||||||
|
if (!(clicked instanceof PlayerInventory)){
|
||||||
|
final InventoryHolder holder = clicked.getHolder();
|
||||||
|
if (holder instanceof HumanEntity humanHolder){
|
||||||
|
if (!event.getWhoClicked().hasPermission("smod.enderchestsee.modify")){
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package de.shiewk.smoderation.event;
|
||||||
|
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
|
public class InvSeeEvents implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event){
|
||||||
|
final Inventory clicked = event.getView().getTopInventory();
|
||||||
|
if (clicked instanceof PlayerInventory inventory){
|
||||||
|
final HumanEntity holder = inventory.getHolder();
|
||||||
|
if (!event.getWhoClicked().hasPermission("smod.invsee.modify")){
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (holder != null) {
|
||||||
|
if (holder.hasPermission("smod.invsee.preventmodify")){
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import de.shiewk.smoderation.punishments.Punishment;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -45,4 +46,13 @@ public abstract class PlayerUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static @Nullable Player findOnlinePlayer(String name){
|
||||||
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (onlinePlayer.getName().equalsIgnoreCase(name)){
|
||||||
|
return onlinePlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,23 @@ commands:
|
|||||||
- spardon
|
- spardon
|
||||||
permission: smod.unban
|
permission: smod.unban
|
||||||
description: Unbans a banned player.
|
description: Unbans a banned player.
|
||||||
|
invsee:
|
||||||
|
usage: "§cUsage: /invsee <player>"
|
||||||
|
aliases:
|
||||||
|
- sinvsee
|
||||||
|
- smodinvsee
|
||||||
|
- invs
|
||||||
|
permission: smod.invsee
|
||||||
|
description: Views the inventory of another player.
|
||||||
|
enderchestsee:
|
||||||
|
usage: "§cUsage: /enderchestsee <player>"
|
||||||
|
aliases:
|
||||||
|
- secsee
|
||||||
|
- senderchestsee
|
||||||
|
- ecsee
|
||||||
|
- ecs
|
||||||
|
permission: smod.enderchestsee
|
||||||
|
description: Views the ender chest of another player.
|
||||||
permissions:
|
permissions:
|
||||||
smod.mute:
|
smod.mute:
|
||||||
default: op
|
default: op
|
||||||
@@ -80,4 +97,23 @@ permissions:
|
|||||||
description: Allows the player to unban other players.
|
description: Allows the player to unban other players.
|
||||||
smod.logs:
|
smod.logs:
|
||||||
default: op
|
default: op
|
||||||
description: Allows the player to view mod logs.
|
description: Allows the player to view mod logs.
|
||||||
|
smod.invsee:
|
||||||
|
default: op
|
||||||
|
description: Allows the player to view other players inventories.
|
||||||
|
smod.invsee.modify:
|
||||||
|
default: op
|
||||||
|
description: Allows the player to view and modify other players inventories.
|
||||||
|
children:
|
||||||
|
- smod.invsee
|
||||||
|
smod.invsee.preventmodify:
|
||||||
|
default: op
|
||||||
|
description: When giving this permission to a player, prevents their inventory from being modified.
|
||||||
|
smod.enderchestsee:
|
||||||
|
default: op
|
||||||
|
description: Allows the player to view other players ender chests.
|
||||||
|
smod.enderchestsee.modify:
|
||||||
|
default: op
|
||||||
|
description: Allows the player to view and modify other players ender chests.
|
||||||
|
children:
|
||||||
|
- smod.enderchestsee
|
||||||
Reference in New Issue
Block a user