Added /p as an aliast for /ultimatemoderation.

You can no longer pick up blocks while spying.
Added a search feature to find users faster.
Added the ability to alter online players.
Added the ability to toggle between online and offline players in the players menu.
This commit is contained in:
Brianna 2019-04-15 17:48:25 -04:00
parent be453c69ab
commit a68fd0dee3
8 changed files with 93 additions and 9 deletions

View File

@ -41,8 +41,8 @@ public class CommandSpy extends AbstractCommand {
boolean didVanish = false;
if (!CommandVanish.isVanished(senderP)) {
didVanish = true;
CommandVanish.vanish(senderP);
senderP.setCanPickupItems(false);
}
senderP.teleport(player.getPlayer().getLocation());

View File

@ -42,9 +42,11 @@ public class CommandVanish extends AbstractCommand {
if (inVanish.contains(uuid)) {
inVanish.remove(uuid);
player.setCanPickupItems(true);
player.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.vanish.toggledOff")));
} else {
inVanish.add(uuid);
player.setCanPickupItems(false);
player.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.vanish.toggledOn")));
}
if (SettingsManager.Setting.VANISH_EFFECTS.getBoolean()) {

View File

@ -29,7 +29,7 @@ public class GUIModerate extends AbstractGUI {
@Override
protected void constructGUI() {
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), "Back");
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
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");

View File

@ -33,13 +33,15 @@ public class GUIPlayer extends AbstractGUI {
meta.setOwner(toModerate.getName());
head.setItemMeta(meta);
createButton(13, head, "&7&l" + toModerate.getName());
createButton(13, head, "&7&l" + toModerate.getName(),
player.isOnline() ? "&a" + plugin.getLocale().getMessage("gui.players.online.online") : "&c" + plugin.getLocale().getMessage("gui.players.online.offline"));
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
createButton(38, Material.ANVIL, plugin.getLocale().getMessage("gui.player.punish"));
createButton(30, Material.CHEST, plugin.getLocale().getMessage("gui.player.tickets"));
createButton(32, Material.DIAMOND_SWORD, plugin.getLocale().getMessage("gui.player.punishments"));
if (player.isOnline())
createButton(32, Material.DIAMOND_SWORD, plugin.getLocale().getMessage("gui.player.punishments"));
createButton(42, Material.MAP, plugin.getLocale().getMessage("gui.player.notes"));
createButton(40, Material.DIAMOND_CHESTPLATE, plugin.getLocale().getMessage("gui.player.moderate"));
}

View File

@ -5,15 +5,19 @@ import com.songoda.ultimatemoderation.punish.PunishmentType;
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
import com.songoda.ultimatemoderation.tickets.TicketStatus;
import com.songoda.ultimatemoderation.utils.ServerVersion;
import com.songoda.ultimatemoderation.utils.gui.AbstractAnvilGUI;
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
public class GUIPlayers extends AbstractGUI {
@ -22,6 +26,7 @@ public class GUIPlayers extends AbstractGUI {
private int task;
private int page = 0;
private Online currentOnline = Online.ONLINE;
public GUIPlayers(UltimateModeration plugin, Player player) {
super(player);
@ -41,7 +46,21 @@ public class GUIPlayers extends AbstractGUI {
int numNotes = Bukkit.getOnlinePlayers().size();
int maxPage = (int) Math.floor(numNotes / 36.0);
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers()).stream()
List<UUID> players = new ArrayList<>();
if (currentOnline == Online.ONLINE || currentOnline == Online.BOTH) {
for (Player player : Bukkit.getOnlinePlayers()) {
players.add(player.getUniqueId());
}
}
if (currentOnline == Online.OFFLINE || currentOnline == Online.BOTH) {
for (UUID uuid : plugin.getPunishmentManager().getPunishments().keySet()) {
if (Bukkit.getOfflinePlayer(uuid).isOnline()) continue;
players.add(uuid);
}
}
players = players.stream()
.skip(page * 36).limit(36).collect(Collectors.toList());
if (page != 0) {
@ -61,7 +80,7 @@ public class GUIPlayers extends AbstractGUI {
}
for (int i = 0; i < players.size(); i++) {
Player pl = players.get(i);
OfflinePlayer pl = Bukkit.getOfflinePlayer(players.get(i));
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(pl);
@ -108,16 +127,70 @@ public class GUIPlayers extends AbstractGUI {
for (int i = 0; i < 9; i++)
createButton(36 + i, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
createButton(51, Material.CHEST, "&7Tickets");
createButton(46, Material.ENDER_PEARL, plugin.getLocale().getMessage("gui.players.search"));
createButton(47, Material.HOPPER, "&6" + currentOnline.getTranslation());
createButton(51, Material.CHEST, plugin.getLocale().getMessage("gui.players.button.tickets"));
createButton(52, Material.MAP, plugin.getLocale().getMessage("gui.players.button.templatemanager"));
}
private enum Online {
ONLINE, OFFLINE, BOTH;
private static Online[] vals = values();
public Online next() {
return vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)];
}
public String getTranslation() {
return UltimateModeration.getInstance().getLocale().getMessage("gui.players.online." + this.name().toLowerCase());
}
}
private void runTask() {
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::constructGUI, 5L, 5L);
}
@Override
protected void registerClickables() {
registerClickable(46, ((player1, inventory1, cursor, slot, type) -> {
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
List<UUID> players = new ArrayList<>(plugin.getPunishmentManager().getPunishments().keySet());
for (Player player : Bukkit.getOnlinePlayers()) {
if (players.contains(player.getUniqueId())) continue;
players.add(player.getUniqueId());
}
List<UUID> found = players.stream().filter(uuid -> Bukkit.getOfflinePlayer(uuid).getName().equalsIgnoreCase(event.getName())).collect(Collectors.toList());
if (found.size() == 1) {
new GUIPlayer(plugin, Bukkit.getOfflinePlayer(found.get(0)), player);
} else {
player.sendMessage(plugin.getLocale().getMessage("gui.players.nonefound"));
}
});
ItemStack item = new ItemStack(Material.PAPER);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(plugin.getLocale().getMessage("gui.players.name"));
item.setItemMeta(meta);
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
gui.open();
}));
registerClickable(47, ((player1, inventory1, cursor, slot, type) -> {
this.currentOnline = currentOnline.next();
this.page = 0;
constructGUI();
}));
registerClickable(51, (player1, inventory1, cursor, slot, type) ->
new GUITicketManager(plugin, null, player));

View File

@ -33,7 +33,7 @@ public class TicketManager {
return registeredTickets.values().stream().filter(ticket -> ticket.getStatus() == status).collect(Collectors.toList());
}
public List<Ticket> getTicketsAbout(Player player) {
public List<Ticket> getTicketsAbout(OfflinePlayer player) {
return getTicketsAbout(player.getUniqueId());
}

View File

@ -83,7 +83,14 @@ gui.players.ticketsone = "&7This player has &61 &7open ticket."
gui.players.nowarnings = "&7No warnings recorded."
gui.players.warnings = "&7This player has received &6%amount% &7warnings."
gui.players.warningsone = "&7This player has received &61 &7warning."
gui.players.online.online = "Online"
gui.players.online.offline = "Offline"
gui.players.online.both = "Both"
gui.players.button.tickets = "&7Tickets"
gui.players.button.templatemanager = "&6&lTemplate Manager"
gui.players.name = "Player Name"
gui.players.search = "&7Search for player"
gui.players.nonefound = "No players found."
gui.templateselector.title = "&8Select a Template"
gui.templateselector.click = "&7Click to select this template."

View File

@ -8,7 +8,7 @@ commands:
UltimateModeration:
description: View information on this plugin.
default: true
aliases: [um]
aliases: [um, p]
usage: /um
ClearChat:
description: Clear the chat