Added many permissions

This commit is contained in:
Lilac 2019-08-24 15:36:04 +01:00
parent d7a4661b59
commit 60501c5c3f
21 changed files with 214 additions and 83 deletions

View File

@ -4,7 +4,7 @@ stages:
variables: variables:
name: "UltimateModeration" name: "UltimateModeration"
path: "/builds/$CI_PROJECT_PATH" path: "/builds/$CI_PROJECT_PATH"
version: "1.1.11" version: "1.1.12"
build: build:
stage: build stage: build

View File

@ -68,5 +68,10 @@
<artifactId>songodaupdater</artifactId> <artifactId>songodaupdater</artifactId>
<version>1</version> <version>1</version>
</dependency> </dependency>
<dependency>
<groupId>net.milkbowl</groupId>
<artifactId>vault</artifactId>
<version>1.7.1</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -29,9 +29,11 @@ import com.songoda.ultimatemoderation.utils.settings.SettingsManager;
import com.songoda.ultimatemoderation.utils.updateModules.LocaleModule; import com.songoda.ultimatemoderation.utils.updateModules.LocaleModule;
import com.songoda.update.Plugin; import com.songoda.update.Plugin;
import com.songoda.update.SongodaUpdate; import com.songoda.update.SongodaUpdate;
import net.milkbowl.vault.permission.Permission;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.UUID; import java.util.UUID;
@ -52,6 +54,8 @@ public class UltimateModeration extends JavaPlugin {
private Locale locale; private Locale locale;
private Storage storage; private Storage storage;
private Permission perms = null;
public static UltimateModeration getInstance() { public static UltimateModeration getInstance() {
return INSTANCE; return INSTANCE;
} }
@ -105,6 +109,11 @@ public class UltimateModeration extends JavaPlugin {
// Starting Metrics // Starting Metrics
new Metrics(this); new Metrics(this);
if (getServer().getPluginManager().getPlugin("Vault") != null) {
setupPermissions();
console.sendMessage("Hooked Vault.");
}
int timeout = Setting.AUTOSAVE.getInt() * 60 * 20; int timeout = Setting.AUTOSAVE.getInt() * 60 * 20;
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> storage.doSave(), timeout, timeout); Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> storage.doSave(), timeout, timeout);
console.sendMessage(Methods.formatText("&a=============================")); console.sendMessage(Methods.formatText("&a============================="));
@ -200,6 +209,12 @@ public class UltimateModeration extends JavaPlugin {
storage.doSave(); storage.doSave();
} }
private boolean setupPermissions() {
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
perms = rsp.getProvider();
return perms != null;
}
public ServerVersion getServerVersion() { public ServerVersion getServerVersion() {
return serverVersion; return serverVersion;
} }
@ -248,4 +263,8 @@ public class UltimateModeration extends JavaPlugin {
public StaffChatManager getStaffChatManager() { public StaffChatManager getStaffChatManager() {
return staffChatManager; return staffChatManager;
} }
public Permission getPerms() {
return perms;
}
} }

View File

@ -50,12 +50,23 @@ public class CommandBan extends AbstractCommand {
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
if (instance.getPerms() != null && sender instanceof Player
&& instance.getPerms().playerHas(Bukkit.getWorlds().get(0).getName(), player, "um.ban.exempt")) {
instance.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
if (instance.getPunishmentManager().getPlayer(player).getActivePunishments() if (instance.getPunishmentManager().getPlayer(player).getActivePunishments()
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) { .stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
instance.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender); instance.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender);
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
if (duration == 0 && !sender.hasPermission("um.ban.permanent")) {
instance.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
new Punishment(PunishmentType.BAN, duration == 0 ? -1 : duration, reason.equals("") ? null : reason) new Punishment(PunishmentType.BAN, duration == 0 ? -1 : duration, reason.equals("") ? null : reason)
.execute(sender, player); .execute(sender, player);

View File

@ -48,6 +48,11 @@ public class CommandFreeze extends AbstractCommand {
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
if (sender instanceof Player && player.hasPermission("um.freeze.exempt")) {
instance.getLocale().newMessage("That player cannot be frozen.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
freeze(player, (Player) sender); freeze(player, (Player) sender);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;

View File

@ -29,6 +29,11 @@ public class CommandInvSee extends AbstractCommand {
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
if (player.hasPermission("um.invsee.exempt")) {
instance.getLocale().newMessage("You cannot invsee that player.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
((Player) sender).openInventory(player.getInventory()); ((Player) sender).openInventory(player.getInventory());
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -43,6 +43,11 @@ public class CommandKick extends AbstractCommand {
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
if (sender instanceof Player && player.getPlayer().hasPermission("um.kick.exempt")) {
instance.getLocale().newMessage("You cannot kick this player.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
new Punishment(PunishmentType.KICK, reason.equals("") ? null : reason) new Punishment(PunishmentType.KICK, reason.equals("") ? null : reason)
.execute(sender, player); .execute(sender, player);

View File

@ -50,6 +50,11 @@ public class CommandMute extends AbstractCommand {
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
if (sender instanceof Player && player.getPlayer().hasPermission("um.mute.exempt")) {
instance.getLocale().newMessage("You cannot mute that player.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
if (instance.getPunishmentManager().getPlayer(player).getActivePunishments() if (instance.getPunishmentManager().getPlayer(player).getActivePunishments()
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) { .stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) {
instance.getLocale().newMessage("That player is already muted.").sendPrefixedMessage(sender); instance.getLocale().newMessage("That player is already muted.").sendPrefixedMessage(sender);

View File

@ -79,6 +79,11 @@ public class CommandSpy extends AbstractCommand {
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
if (player.hasPermission("um.spy.exempt")) {
instance.getLocale().newMessage("You cannot spy on that player.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
spy(player, senderP); spy(player, senderP);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;

View File

@ -7,8 +7,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
public class CommandViewEnderChest extends AbstractCommand { public class CommandViewEnderChest extends AbstractCommand {
@ -30,6 +28,11 @@ public class CommandViewEnderChest extends AbstractCommand {
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
if (player.hasPermission("um.viewenderchest.exempt")) {
instance.getLocale().newMessage("You cannot view the enderchest of that player.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
((Player) sender).openInventory(player.getEnderChest()); ((Player) sender).openInventory(player.getEnderChest());
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }

View File

@ -50,6 +50,12 @@ public class CommandWarn extends AbstractCommand {
return ReturnType.FAILURE; return ReturnType.FAILURE;
} }
if (instance.getPerms() != null && sender instanceof Player
&& instance.getPerms().playerHas(Bukkit.getWorlds().get(0).getName(), player, "um.warning.exempt")) {
instance.getLocale().newMessage("You cannot warn that player.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
new Punishment(PunishmentType.WARNING, duration == 0 ? -1 : duration, reason.equals("") ? null : reason) new Punishment(PunishmentType.WARNING, duration == 0 ? -1 : duration, reason.equals("") ? null : reason)
.execute(sender, player); .execute(sender, player);

View File

@ -15,13 +15,18 @@ import org.bukkit.inventory.meta.SkullMeta;
public class GUIModerate extends AbstractGUI { public class GUIModerate extends AbstractGUI {
private final UltimateModeration plugin; private final UltimateModeration plugin;
private final OfflinePlayer toModerate; private final OfflinePlayer toModerate;
private boolean freeze, spy, invsee, enderview, revive;
public GUIModerate(UltimateModeration plugin, OfflinePlayer toModerate, Player player) { public GUIModerate(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
super(player); super(player);
this.plugin = plugin; this.plugin = plugin;
this.toModerate = toModerate; this.toModerate = toModerate;
this.freeze = !toModerate.getPlayer().hasPermission("um.freeze.exempt") && player.hasPermission("um.freeze");
this.spy = !toModerate.getPlayer().hasPermission("um.spy.exempt") && player.hasPermission("um.spy");
this.invsee = !toModerate.getPlayer().hasPermission("um.invsee.exempt") && player.hasPermission("um.invsee");
this.enderview = !toModerate.getPlayer().hasPermission("um.viewenderchest.exempt") && player.hasPermission("um.viewenderchest");
this.revive = player.hasPermission("um.revive");
init(plugin.getLocale().getMessage("gui.moderate.title") init(plugin.getLocale().getMessage("gui.moderate.title")
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 45); .processPlaceholder("toModerate", toModerate.getName()).getMessage(), 45);
@ -34,12 +39,11 @@ public class GUIModerate extends AbstractGUI {
? Material.OAK_DOOR ? Material.OAK_DOOR
: Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage()); : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage());
createButton(10, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.BLUE_ICE : Material.valueOf("PACKED_ICE"), "&6&lFreeze", "&7Stop this player from moving.", "", "&7Currently:&6 " + (CommandFreeze.isFrozen(toModerate) ? "Frozen" : "Unfrozen")); if (freeze) createButton(10, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.BLUE_ICE : Material.valueOf("PACKED_ICE"), "&6&lFreeze", "&7Stop this player from moving.", "", "&7Currently:&6 " + (CommandFreeze.isFrozen(toModerate) ? "Frozen" : "Unfrozen"));
createButton(12, Material.SADDLE, "&6&lSpy", "&7Spy on this player"); if (spy) createButton(12, Material.SADDLE, "&6&lSpy", "&7Spy on this player");
createButton(14, Material.CHEST, "&c&lInventory", "&7Access this players Inventory."); if (invsee) createButton(14, Material.CHEST, "&c&lInventory", "&7Access this players Inventory.");
createButton(16, Material.ENDER_CHEST, "&a&lEnderchest", "&7Access this players Enderchest"); if (enderview) createButton(16, Material.ENDER_CHEST, "&a&lEnderchest", "&7Access this players Enderchest");
if (revive) createButton(28, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.SPLASH_POTION : Material.valueOf("POTION"), "&c&lRevive", "&7Revive this player.");
createButton(28, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.SPLASH_POTION : Material.valueOf("POTION"), "&c&lRevive", "&7Revive this player.");
} }
@Override @Override
@ -47,24 +51,34 @@ public class GUIModerate extends AbstractGUI {
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
new GUIPlayer(plugin, toModerate, player1))); new GUIPlayer(plugin, toModerate, player1)));
registerClickable(10, ((player1, inventory1, cursor, slot, type) -> { if (freeze) {
CommandFreeze.freeze(toModerate, player); registerClickable(10, ((player1, inventory1, cursor, slot, type) -> {
constructGUI(); CommandFreeze.freeze(toModerate, player);
})); constructGUI();
}));
}
registerClickable(12, ((player1, inventory1, cursor, slot, type) -> { if (spy) {
CommandSpy.spy(toModerate, player); registerClickable(12, ((player1, inventory1, cursor, slot, type) -> {
player.closeInventory(); CommandSpy.spy(toModerate, player);
})); player.closeInventory();
}));
}
registerClickable(14, ((player1, inventory1, cursor, slot, type) -> if (invsee) {
player.openInventory(toModerate.getPlayer().getInventory()))); registerClickable(14, ((player1, inventory1, cursor, slot, type) ->
player.openInventory(toModerate.getPlayer().getInventory())));
}
registerClickable(16, ((player1, inventory1, cursor, slot, type) -> if (enderview) {
player.openInventory(toModerate.getPlayer().getEnderChest()))); registerClickable(16, ((player1, inventory1, cursor, slot, type) ->
player.openInventory(toModerate.getPlayer().getEnderChest())));
}
registerClickable(28, ((player1, inventory1, cursor, slot, type) -> if (revive) {
CommandRevive.revive(toModerate.getPlayer(), player))); registerClickable(28, ((player1, inventory1, cursor, slot, type) ->
CommandRevive.revive(toModerate.getPlayer(), player)));
}
} }
@Override @Override

View File

@ -27,10 +27,14 @@ public class GUINotesManager extends AbstractGUI {
private int page = 0; private int page = 0;
private boolean create, delete;
public GUINotesManager(UltimateModeration plugin, OfflinePlayer toModerate, Player player) { public GUINotesManager(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
super(player); super(player);
this.plugin = plugin; this.plugin = plugin;
this.toModerate = toModerate; this.toModerate = toModerate;
this.create = player.hasPermission("um.notes.create");
this.delete = player.hasPermission("um.notes.delete");
init(plugin.getLocale().getMessage("gui.notes.title") init(plugin.getLocale().getMessage("gui.notes.title")
.processPlaceholder("tonotes", player.getName()).getMessage(), 54); .processPlaceholder("tonotes", player.getName()).getMessage(), 54);
@ -71,7 +75,7 @@ public class GUINotesManager extends AbstractGUI {
? Material.OAK_DOOR ? Material.OAK_DOOR
: Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage()); : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage());
createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.notes.create").getMessage()); if (create) createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.notes.create").getMessage());
for (int i = 0; i < notes.size(); i++) { for (int i = 0; i < notes.size(); i++) {
PunishmentNote note = notes.get(i); PunishmentNote note = notes.get(i);
@ -106,14 +110,16 @@ public class GUINotesManager extends AbstractGUI {
lore.add(plugin.getLocale().getMessage("gui.notes.createdon") lore.add(plugin.getLocale().getMessage("gui.notes.createdon")
.processPlaceholder("sent", format.format(new Date(note.getCreationDate()))) .processPlaceholder("sent", format.format(new Date(note.getCreationDate())))
.getMessage()); .getMessage());
lore.add(plugin.getLocale().getMessage("gui.notes.remove").getMessage()); if (delete) lore.add(plugin.getLocale().getMessage("gui.notes.remove").getMessage());
createButton(18 + i, Material.MAP, name, lore); createButton(18 + i, Material.MAP, name, lore);
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> { if (delete) {
plugin.getPunishmentManager().getPlayer(toModerate).removeNote(note); registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> {
constructGUI(); plugin.getPunishmentManager().getPlayer(toModerate).removeNote(note);
})); constructGUI();
}));
}
} }
} }
@ -123,17 +129,19 @@ public class GUINotesManager extends AbstractGUI {
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
new GUIPlayer(plugin, toModerate, player1))); new GUIPlayer(plugin, toModerate, player1)));
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> { if (create) {
plugin.getLocale().getMessage("gui.notes.type").sendMessage(player); registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event -> { plugin.getLocale().getMessage("gui.notes.type").sendMessage(player);
plugin.getPunishmentManager().getPlayer(toModerate).addNotes(new PunishmentNote(event.getMessage(), AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event -> {
player.getUniqueId(), toModerate.getUniqueId(), System.currentTimeMillis())); plugin.getPunishmentManager().getPlayer(toModerate).addNotes(new PunishmentNote(event.getMessage(),
constructGUI(); player.getUniqueId(), toModerate.getUniqueId(), System.currentTimeMillis()));
}); constructGUI();
});
abstractChatConfirm.setOnClose(() -> abstractChatConfirm.setOnClose(() ->
init(setTitle, inventory.getSize())); init(setTitle, inventory.getSize()));
})); }));
}
} }
@Override @Override

View File

@ -15,10 +15,17 @@ public class GUIPlayer extends AbstractGUI {
private final OfflinePlayer toModerate; private final OfflinePlayer toModerate;
private boolean punish, tickets, punishments, notes, moderate;
public GUIPlayer(UltimateModeration plugin, OfflinePlayer toModerate, Player player) { public GUIPlayer(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
super(player); super(player);
this.plugin = plugin; this.plugin = plugin;
this.toModerate = toModerate; this.toModerate = toModerate;
this.punish = player.hasPermission("um.punish");
this.tickets = player.hasPermission("um.tickets");
this.punishments = player.hasPermission("um.punishments");
this.notes = player.hasPermission("um.notes");
this.moderate = player.hasPermission("um.moderation");
init(plugin.getLocale().getMessage("gui.player.title") init(plugin.getLocale().getMessage("gui.player.title")
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 54); .processPlaceholder("toModerate", toModerate.getName()).getMessage(), 54);
@ -41,12 +48,12 @@ public class GUIPlayer extends AbstractGUI {
? Material.OAK_DOOR ? Material.OAK_DOOR
: Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage()); : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage());
createButton(38, Material.ANVIL, plugin.getLocale().getMessage("gui.player.punish").getMessage()); if (punish) createButton(38, Material.ANVIL, plugin.getLocale().getMessage("gui.player.punish").getMessage());
createButton(30, Material.CHEST, plugin.getLocale().getMessage("gui.player.tickets").getMessage()); if (tickets) createButton(30, Material.CHEST, plugin.getLocale().getMessage("gui.player.tickets").getMessage());
if (player.isOnline()) if (player.isOnline() && punishments)
createButton(32, Material.DIAMOND_SWORD, plugin.getLocale().getMessage("gui.player.punishments").getMessage()); createButton(32, Material.DIAMOND_SWORD, plugin.getLocale().getMessage("gui.player.punishments").getMessage());
createButton(42, Material.MAP, plugin.getLocale().getMessage("gui.player.notes").getMessage()); if (notes) createButton(42, Material.MAP, plugin.getLocale().getMessage("gui.player.notes").getMessage());
createButton(40, Material.DIAMOND_CHESTPLATE, plugin.getLocale().getMessage("gui.player.moderate").getMessage()); if (moderate) createButton(40, Material.DIAMOND_CHESTPLATE, plugin.getLocale().getMessage("gui.player.moderate").getMessage());
} }
@Override @Override
@ -54,20 +61,30 @@ public class GUIPlayer extends AbstractGUI {
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
new GUIPlayers(plugin, player1))); new GUIPlayers(plugin, player1)));
registerClickable(38, ((player1, inventory1, cursor, slot, type) -> if (punish) {
new GUIPunish(plugin, toModerate, null, player1))); registerClickable(38, ((player1, inventory1, cursor, slot, type) ->
new GUIPunish(plugin, toModerate, null, player1)));
}
registerClickable(30, ((player1, inventory1, cursor, slot, type) -> if (tickets) {
new GUITicketManager(plugin, toModerate, player1))); registerClickable(30, ((player1, inventory1, cursor, slot, type) ->
new GUITicketManager(plugin, toModerate, player1)));
}
registerClickable(32, ((player1, inventory1, cursor, slot, type) -> if (punishments) {
new GUIPunishments(plugin, toModerate, player1))); registerClickable(32, ((player1, inventory1, cursor, slot, type) ->
new GUIPunishments(plugin, toModerate, player1)));
}
registerClickable(42, ((player1, inventory1, cursor, slot, type) -> if (notes) {
new GUINotesManager(plugin, toModerate, player1))); registerClickable(42, ((player1, inventory1, cursor, slot, type) ->
new GUINotesManager(plugin, toModerate, player1)));
}
registerClickable(40, ((player1, inventory1, cursor, slot, type) -> if (moderate) {
new GUIModerate(plugin, toModerate, player1))); registerClickable(40, ((player1, inventory1, cursor, slot, type) ->
new GUIModerate(plugin, toModerate, player1)));
}
} }
@Override @Override

View File

@ -132,8 +132,11 @@ public class GUIPlayers extends AbstractGUI {
createButton(46, Material.ENDER_PEARL, plugin.getLocale().getMessage("gui.players.search").getMessage()); createButton(46, Material.ENDER_PEARL, plugin.getLocale().getMessage("gui.players.search").getMessage());
createButton(47, Material.HOPPER, "&6" + currentOnline.getTranslation()); createButton(47, Material.HOPPER, "&6" + currentOnline.getTranslation());
createButton(51, Material.CHEST, plugin.getLocale().getMessage("gui.players.button.tickets").getMessage()); if (player.hasPermission("um.tickets"))
createButton(52, Material.MAP, plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage()); createButton(51, Material.CHEST, plugin.getLocale().getMessage("gui.players.button.tickets").getMessage());
if (player.hasPermission("um.templates"))
createButton(52, Material.MAP, plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage());
} }
@ -194,11 +197,17 @@ public class GUIPlayers extends AbstractGUI {
constructGUI(); constructGUI();
})); }));
registerClickable(51, (player1, inventory1, cursor, slot, type) -> if (player.hasPermission("um.tickets")) {
new GUITicketManager(plugin, null, player)); registerClickable(51, (player1, inventory1, cursor, slot, type) -> {
new GUITicketManager(plugin, null, player);
});
}
registerClickable(52, (player1, inventory1, cursor, slot, type) -> if (player.hasPermission("um.templates")) {
new GUITemplateManager(plugin, player)); registerClickable(52, (player1, inventory1, cursor, slot, type) -> {
if (player.hasPermission("um.templates")) new GUITemplateManager(plugin, player);
});
}
} }
@Override @Override

View File

@ -69,7 +69,8 @@ public class GUIPunish extends AbstractGUI {
createButton(13, head, "&7&l" + toModerate.getName()); createButton(13, head, "&7&l" + toModerate.getName());
} }
createButton(22, Material.EMERALD_BLOCK, plugin.getLocale().getMessage("gui.punish.submit").getMessage()); if (player.hasPermission("um." + type.toString().toLowerCase()))
createButton(22, Material.EMERALD_BLOCK, plugin.getLocale().getMessage("gui.punish.submit").getMessage());
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13)
? Material.OAK_DOOR ? Material.OAK_DOOR
@ -188,8 +189,9 @@ public class GUIPunish extends AbstractGUI {
} }
if (plugin.getTemplateManager().getTemplates().size() == 0) return; if (plugin.getTemplateManager().getTemplates().size() == 0) return;
new GUITemplateSelector(plugin, this, player); if (player.hasPermission("um.templates.use")) new GUITemplateSelector(plugin, this, player);
})); }));
registerClickable(32, ((player1, inventory1, cursor, slot, type) -> { registerClickable(32, ((player1, inventory1, cursor, slot, type) -> {
if (this.type == PunishmentType.KICK) return; if (this.type == PunishmentType.KICK) return;
if (type == ClickType.LEFT) { if (type == ClickType.LEFT) {
@ -233,6 +235,9 @@ public class GUIPunish extends AbstractGUI {
})); }));
registerClickable(22, ((player1, inventory1, cursor, slot, type1) -> { registerClickable(22, ((player1, inventory1, cursor, slot, type1) -> {
if (!player.hasPermission("um." + type.toString().toLowerCase())) return;
if (duration == -1 && type == PunishmentType.BAN && !player.hasPermission("um.ban.permanent")) return;
if (toModerate == null) { if (toModerate == null) {
if (reason == null || duration == 0 || templateName == null) return; if (reason == null || duration == 0 || templateName == null) return;
@ -253,6 +258,7 @@ public class GUIPunish extends AbstractGUI {
new Punishment(type, reason).execute(player, toModerate); new Punishment(type, reason).execute(player, toModerate);
break; break;
} }
new GUIPlayer(plugin, toModerate, player); new GUIPlayer(plugin, toModerate, player);
})); }));
} }

View File

@ -66,7 +66,8 @@ public class GUITemplateManager extends AbstractGUI {
: Material.valueOf("WOOD_DOOR"), : Material.valueOf("WOOD_DOOR"),
plugin.getLocale().getMessage("gui.general.back").getMessage()); plugin.getLocale().getMessage("gui.general.back").getMessage());
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.templatemanager.create").getMessage()); if (player.hasPermission("um.templates.create"))
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.templatemanager.create").getMessage());
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
createButton(9 + i, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1"); createButton(9 + i, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
@ -81,9 +82,9 @@ public class GUITemplateManager extends AbstractGUI {
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> { registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> {
if (type == ClickType.LEFT) { if (type == ClickType.LEFT) {
new GUIPunish(plugin, null, template, player); if (player.hasPermission("um.templates.edit")) new GUIPunish(plugin, null, template, player);
} else if (type == ClickType.RIGHT) { } else if (type == ClickType.RIGHT) {
plugin.getTemplateManager().removeTemplate(template.getUUID()); if (player.hasPermission("um.templates.destroy")) plugin.getTemplateManager().removeTemplate(template.getUUID());
constructGUI(); constructGUI();
} }
})); }));
@ -95,8 +96,11 @@ public class GUITemplateManager extends AbstractGUI {
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
new GUIPlayers(plugin, player))); new GUIPlayers(plugin, player)));
registerClickable(7, ((player1, inventory1, cursor, slot, type) -> if (player.hasPermission("um.templates.create")) {
new GUIPunish(plugin, null, null, player))); registerClickable(7, ((player1, inventory1, cursor, slot, type) -> {
new GUIPunish(plugin, null, null, player);
}));
}
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> { registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
this.punishmentType = punishmentType.nextFilter(); this.punishmentType = punishmentType.nextFilter();

View File

@ -80,7 +80,7 @@ public class GUITicket extends AbstractGUI {
createButton(7, Material.REDSTONE, createButton(7, Material.REDSTONE,
plugin.getLocale().getMessage("gui.ticket.clicktotele").getMessage()); plugin.getLocale().getMessage("gui.ticket.clicktotele").getMessage());
createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.ticket.respond").getMessage()); if (player.hasPermission("um.tickets.respond")) createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.ticket.respond").getMessage());
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
createButton(9 + i, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1"); createButton(9 + i, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
@ -139,16 +139,18 @@ public class GUITicket extends AbstractGUI {
})); }));
} }
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> { if (player.hasPermission("um.ticket.respond")) {
player.sendMessage(plugin.getLocale().getMessage("gui.ticket.what").getMessage()); registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event2 -> { player.sendMessage(plugin.getLocale().getMessage("gui.ticket.what").getMessage());
ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis())); AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event2 -> {
constructGUI(); ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis()));
}); constructGUI();
});
abstractChatConfirm.setOnClose(() -> abstractChatConfirm.setOnClose(() ->
init(setTitle, inventory.getSize())); init(setTitle, inventory.getSize()));
})); }));
}
} }
@Override @Override

View File

@ -73,8 +73,8 @@ public class GUITicketManager extends AbstractGUI {
createButton(3 ,Material.DIAMOND_SWORD, Methods.formatText("&6" + status.getStatus())); createButton(3 ,Material.DIAMOND_SWORD, Methods.formatText("&6" + status.getStatus()));
if (toModerate != null) if (toModerate != null && player.hasPermission("um.tickets.create"))
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.tickets.create").getMessage()); createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.tickets.create").getMessage());
if (player.hasPermission("um.ticket")) if (player.hasPermission("um.ticket"))
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13)
@ -149,9 +149,9 @@ public class GUITicketManager extends AbstractGUI {
constructGUI(); constructGUI();
})); }));
if (toModerate != null) { if (toModerate != null && player.hasPermission("um.tickets.create")) {
registerClickable(7, ((player1, inventory1, cursor, slot, type) -> registerClickable(7, ((player1, inventory1, cursor, slot, type) ->
createNew(player, toModerate))); createNew(player, toModerate)));
} }
} }

View File

@ -8,6 +8,7 @@ import com.songoda.ultimatemoderation.utils.Methods;
import com.songoda.ultimatemoderation.utils.settings.Setting; import com.songoda.ultimatemoderation.utils.settings.Setting;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;

View File

@ -4,6 +4,7 @@ main: com.songoda.ultimatemoderation.UltimateModeration
version: maven-version-number version: maven-version-number
author: Songoda author: Songoda
api-version: 1.13 api-version: 1.13
softdepend: [Vault]
commands: commands:
UltimateModeration: UltimateModeration:
description: View information on this plugin. description: View information on this plugin.