Added List and Plugins commands

master
Etzelia 2018-09-14 00:08:13 -05:00
parent 941f0a40b6
commit a31a32edea
6 changed files with 125 additions and 8 deletions

View File

@ -168,6 +168,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -85,20 +85,25 @@ public class QoL extends JavaPlugin {
WorldInfoCommand worldInfoCommand = new WorldInfoCommand(this); WorldInfoCommand worldInfoCommand = new WorldInfoCommand(this);
this.getCommand("worldinfo").setExecutor(worldInfoCommand); this.getCommand("worldinfo").setExecutor(worldInfoCommand);
if (getConfig().getStringList("list").size() > 0) {
ListCommand listCommand = new ListCommand(this);
this.getCommand("list").setExecutor(listCommand);
}
if (getConfig().getStringList("plugins").size() > 0) {
PluginsCommand pluginsCommand = new PluginsCommand(this);
this.getCommand("plugins").setExecutor(pluginsCommand);
}
// Scheduler // Scheduler
int schedule = config.getInt("schedule.frequency"); int schedule = config.getInt("schedule.frequency");
if (schedule > 0) { if (schedule > 0) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(QoL.getInstance(), new Runnable() { Bukkit.getScheduler().scheduleSyncRepeatingTask(QoL.getInstance(), () -> {
@Override
public void run() {
List<String> scheduled = config.getStringList("schedule.commands"); List<String> scheduled = config.getStringList("schedule.commands");
for (String command : scheduled) { for (String command : scheduled) {
runTask(command); runTask(command);
} }
}
}, 0, EtzTechUtil.minutesToTicks(schedule)); }, 0, EtzTechUtil.minutesToTicks(schedule));
} }

View File

@ -0,0 +1,55 @@
package xyz.etztech.qol.commands;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import xyz.etztech.qol.QoL;
import java.util.*;
public class ListCommand implements CommandExecutor {
QoL plugin;
public ListCommand(QoL plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
Map<String, List<String>> list = new HashMap<>();
List<String> groups = plugin.getConfig().getStringList("list");
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
for (String group : groups) {
if (player.hasPermission("qol.list." + group)) {
List<String> names = list.containsKey(group) ? list.get(group) : new ArrayList<String>();
names.add(player.getName());
list.put(group, names);
break;
}
}
}
StringBuilder message = new StringBuilder();
for (String key : list.keySet()) {
List<String> parts = Arrays.asList(key.split("_"));
parts.forEach(StringUtils::capitalize);
message.append(ChatColor.GOLD)
.append(StringUtils.join(parts, " "))
.append(": ")
.append(ChatColor.YELLOW)
.append(StringUtils.join(list.get(key), ", "))
.append("\n");
}
commandSender.sendMessage(message.toString());
return true;
}
}

View File

@ -0,0 +1,27 @@
package xyz.etztech.qol.commands;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import xyz.etztech.qol.QoL;
public class PluginsCommand implements CommandExecutor {
QoL plugin;
public PluginsCommand(QoL plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
commandSender.sendMessage(ChatColor.GOLD + "Plugins: " + ChatColor.YELLOW +
StringUtils.join(plugin.getConfig().getStringList("plugins"), ", "));
return true;
}
}

View File

@ -8,6 +8,22 @@ makeme:
# Can either be PermissionsEX or LuckPerms # Can either be PermissionsEX or LuckPerms
engine: 'LuckPerms' engine: 'LuckPerms'
# Each item in the following list will be used to split players in /list
# Give the group the permission qol.list.<item>
# Group names will be generated by title-case and replacing underscores with spaces
# e.g. senior_staff -> Senior Staff (qol.list.senior_staff)
# Make sure the items are ordered from most to least important
# Leave blank to disable
list:
# - admin
# - mod
# - member
# A list of plugins to show, overriding the Vanilla /pl
# Leave blank to disable
plugins:
# - QoL
# A list of commands to send to Discord if anyone uses them # A list of commands to send to Discord if anyone uses them
audit: audit:
enabled: true enabled: true

View File

@ -10,6 +10,12 @@ commands:
colors: colors:
description: See all color/formatting codes description: See all color/formatting codes
aliases: [color, c] aliases: [color, c]
list:
description: See a list of players
aliases: [players, playerlist]
plugins:
description: See a list of plugins
aliases: [pl]
history: history:
description: Name History utility command description: Name History utility command
aliases: [names, name] aliases: [names, name]