Add tabcompletes, fix some commands and help texts
This commit is contained in:
parent
5d8ae7fbd0
commit
052149bcb7
13 changed files with 121 additions and 66 deletions
|
@ -2,6 +2,7 @@ package buttondevteam.chat.commands.ucmds;
|
|||
|
||||
import buttondevteam.lib.chat.Command2;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.CustomTabComplete;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandClass(modOnly = false, helpText = {
|
||||
|
@ -10,7 +11,8 @@ import org.bukkit.command.CommandSender;
|
|||
})
|
||||
public final class HelpCommand extends UCommandBase {
|
||||
@Command2.Subcommand
|
||||
public boolean def(CommandSender sender, @Command2.TextArg @Command2.OptionalArg String topicOrCommand) {
|
||||
public boolean def(CommandSender sender, @Command2.TextArg @Command2.OptionalArg
|
||||
@CustomTabComplete({"commands", "chat", "colors"}) String topicOrCommand) {
|
||||
if (topicOrCommand == null) {
|
||||
sender.sendMessage(new String[]{
|
||||
"§6---- Chroma Help ----",
|
||||
|
@ -25,26 +27,26 @@ public final class HelpCommand extends UCommandBase {
|
|||
}
|
||||
if (topicOrCommand.equalsIgnoreCase("chat"))
|
||||
sender.sendMessage(new String[]{"§6---- Chat features ----",
|
||||
"- [g] Channel identifier: Click it to copy message", "-- [g]: Global chat (/g)",
|
||||
"- [g] Channel identifier: Click it to copy message", "-- [g] Global chat (/g)",
|
||||
"-- [TC] Town chat (/tc)", "-- [NC] Nation chat (/nc)",
|
||||
"- Playernames: Hover over them to get some player info",
|
||||
"-- Respect: This is the number of paid respects divided by eliglble deaths. This is a reference to CoD:AW's \"Press F to pay respects\""});
|
||||
"-- Respect: This is the number of paid respects divided by eligible deaths. This is a reference to CoD:AW's \"Press F to pay respects\""});
|
||||
else if (topicOrCommand.equalsIgnoreCase("commands")) {
|
||||
sender.sendMessage(getManager().getCommandsText());
|
||||
} else if (topicOrCommand.equalsIgnoreCase("colors")) {
|
||||
sender.sendMessage(new String[]{"§6---- Chat colors/formats ----", //
|
||||
"Tellraw name - Code | Tellraw name - Code", //
|
||||
"§0black - &0 | §1dark_blue - &1", //
|
||||
"§2dark_green - &2 | §3dark_aqua - &3", //
|
||||
"§4dark_red - &4 | §5dark_purple - &5", //
|
||||
"§6gold - &6 | §7gray - &7", //
|
||||
"§8dark_gray - &8 | §9blue - &9", //
|
||||
"§agreen - &a | §baqua - &b", //
|
||||
"§cred - &c | §dlight_purple - &d", //
|
||||
"§eyellow - &e | §fwhite - &f", //
|
||||
"§rreset - &r | §kk§robfuscated - &k", //
|
||||
"§lbold - &l | §mstrikethrough - &m", //
|
||||
"§nunderline - &n | §oitalic - &o", //
|
||||
"§0black - &0§r | §1dark_blue - &1§r", //
|
||||
"§2dark_green - &2§r | §3dark_aqua - &3§r", //
|
||||
"§4dark_red - &4§r | §5dark_purple - &5§r", //
|
||||
"§6gold - &6§r | §7gray - &7§r", //
|
||||
"§8dark_gray - &8§r | §9blue - &9§r", //
|
||||
"§agreen - &a§r | §baqua - &b§r", //
|
||||
"§cred - &c§r | §dlight_purple - &d§r", //
|
||||
"§eyellow - &e§r | §fwhite - &f§r", //
|
||||
"§rreset - &r§r | §kk§robfuscated - &k§r", //
|
||||
"§lbold - &l§r | §mstrikethrough - &m§r", //
|
||||
"§nunderline - &n§r | §oitalic - &o§r", //
|
||||
"The format codes in tellraw should be used like \"italic\":\"true\""}); //
|
||||
} else {
|
||||
String[] text = getManager().getHelpText(topicOrCommand);
|
||||
|
|
|
@ -5,6 +5,7 @@ import buttondevteam.core.component.channel.Channel;
|
|||
import buttondevteam.lib.chat.ChatMessage;
|
||||
import buttondevteam.lib.chat.Command2;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.CustomTabCompleteMethod;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.val;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -63,6 +64,11 @@ public class HistoryCommand extends UCommandBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
@CustomTabCompleteMethod(param = "channel")
|
||||
public Iterable<String> def() {
|
||||
return Channel.getChannels().map(ch -> ch.ID)::iterator;
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
private static class HistoryEntry {
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,7 @@ import buttondevteam.lib.player.ChromaGamerBase.InfoTarget;
|
|||
import buttondevteam.lib.player.TBMCPlayer;
|
||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@CommandClass(modOnly = false, helpText = {
|
||||
|
@ -16,14 +17,9 @@ import org.bukkit.command.CommandSender;
|
|||
})
|
||||
public class InfoCommand extends UCommandBase {
|
||||
@Command2.Subcommand
|
||||
public boolean def(CommandSender sender, String player) {
|
||||
if (player.equalsIgnoreCase("console") || player.equalsIgnoreCase("server")
|
||||
|| player.equalsIgnoreCase("@console")) {
|
||||
sender.sendMessage("The server console.");
|
||||
return true;
|
||||
}
|
||||
public boolean def(CommandSender sender, OfflinePlayer player) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> {
|
||||
try (TBMCPlayer p = TBMCPlayerBase.getFromName(player, TBMCPlayer.class)) {
|
||||
try (TBMCPlayer p = TBMCPlayerBase.getPlayer(player.getUniqueId(), TBMCPlayer.class)) {
|
||||
if (p == null) {
|
||||
sender.sendMessage("§cThe specified player cannot be found");
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package buttondevteam.chat.components.chatonly;
|
||||
|
||||
import buttondevteam.chat.ChatPlayer;
|
||||
import buttondevteam.lib.chat.Command2;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.ICommand2MC;
|
||||
import buttondevteam.lib.player.TBMCPlayer;
|
||||
|
@ -15,6 +16,7 @@ import org.bukkit.entity.Player;
|
|||
})
|
||||
public final class ChatonlyCommand extends ICommand2MC {
|
||||
|
||||
@Command2.Subcommand
|
||||
public boolean def(Player player) {
|
||||
ChatPlayer p = TBMCPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class);
|
||||
p.ChatOnly = true;
|
||||
|
|
|
@ -107,7 +107,7 @@ public class ChatProcessing {
|
|||
Player player = (sender instanceof Player ? (Player) sender : null);
|
||||
User user = PluginMain.essentials.getUser(player);
|
||||
|
||||
if (player != null) {
|
||||
if (player != null && PluginMain.essentials.getSettings().cancelAfkOnInteract()) {
|
||||
user.updateActivity(true); //Could talk in a private channel, so broadcast
|
||||
if (user.isMuted())
|
||||
return true;
|
||||
|
|
|
@ -2,15 +2,13 @@ package buttondevteam.chat.components.fun;
|
|||
|
||||
import buttondevteam.chat.ChatPlayer;
|
||||
import buttondevteam.chat.PluginMain;
|
||||
import buttondevteam.lib.chat.Color;
|
||||
import buttondevteam.lib.chat.Command2;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.ICommand2MC;
|
||||
import buttondevteam.lib.chat.*;
|
||||
import buttondevteam.lib.player.TBMCPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@CommandClass(path = "u c", helpText = {
|
||||
"Rainbow mode",
|
||||
|
@ -57,4 +55,9 @@ public class CCommand extends ICommand2MC {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@CustomTabCompleteMethod(param = "color")
|
||||
public Iterable<String> def() {
|
||||
return Stream.concat(Stream.of("off"), Arrays.stream(Color.values()).map(Color::getName))::iterator;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public class FTopCommand extends ICommand2MC {
|
|||
private ChatPlayer[] cached;
|
||||
private long lastcache = 0;
|
||||
|
||||
@Command2.Subcommand
|
||||
public boolean def(CommandSender sender, @Command2.OptionalArg int page) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> {
|
||||
if (cached == null || lastcache < System.nanoTime() - 60000000000L) { // 1m - (no guarantees of nanoTime's relation to 0, so we need the null check too)
|
||||
|
@ -47,7 +48,7 @@ public class FTopCommand extends ICommand2MC {
|
|||
}
|
||||
int i;
|
||||
try {
|
||||
i = page<1?1:page;
|
||||
i = page < 1 ? 1 : page;
|
||||
} catch (Exception e) {
|
||||
i = 1;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,11 @@ import org.bukkit.event.Listener;
|
|||
|
||||
import java.util.HashSet;
|
||||
|
||||
@CommandClass
|
||||
@CommandClass(helpText = {
|
||||
"Press",
|
||||
"This command resets the restart countdown if it's active. Can only be used once per player.",
|
||||
"It's based on Reddit's /r/thebutton"
|
||||
})
|
||||
public class PressCommand extends ICommand2MC implements Listener {
|
||||
private HashSet<CommandSender> pressers; //Will be cleared with this class on shutdown/disable
|
||||
private ScheduledRestartCommand command;
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
|
||||
@CommandClass(modOnly = false, helpText = {
|
||||
"Unlol/unlaugh",
|
||||
"This command is based on a joke between NorbiPeti and Ghostise",
|
||||
"This command is based on an inside joke",
|
||||
"It will make the last person saying one of the recognized laugh strings blind for a few seconds",
|
||||
"Note that you can only unlaugh laughs that weren't unlaughed before"
|
||||
})
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package buttondevteam.chat.components.towncolors;
|
||||
|
||||
import buttondevteam.chat.commands.ucmds.UCommandBase;
|
||||
import buttondevteam.chat.components.towncolors.admin.TownColorCommand;
|
||||
import buttondevteam.chat.components.towny.TownyComponent;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.Command2;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.CustomTabCompleteMethod;
|
||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
|
@ -35,4 +37,9 @@ public class NationColorCommand extends UCommandBase {
|
|||
}
|
||||
return buttondevteam.chat.components.towncolors.admin.NationColorCommand.SetNationColor(player, n, color);
|
||||
}
|
||||
|
||||
@CustomTabCompleteMethod(param = "color")
|
||||
public Iterable<String> def() {
|
||||
return TownColorCommand.tabcompleteColor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import buttondevteam.chat.components.towny.TownyComponent;
|
|||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.Command2;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.CustomTabCompleteMethod;
|
||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
|
@ -45,4 +46,9 @@ public class TownColorCommand extends UCommandBase {
|
|||
}
|
||||
return buttondevteam.chat.components.towncolors.admin.TownColorCommand.SetTownColor(player, t, colornames);
|
||||
}
|
||||
|
||||
@CustomTabCompleteMethod(param = "colornames")
|
||||
public Iterable<String> def() {
|
||||
return buttondevteam.chat.components.towncolors.admin.TownColorCommand.tabcompleteColor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,10 @@ import buttondevteam.chat.components.towny.TownyComponent;
|
|||
import buttondevteam.lib.chat.Color;
|
||||
import buttondevteam.lib.chat.Command2;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.CustomTabCompleteMethod;
|
||||
import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.TownyObject;
|
||||
import lombok.val;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -29,6 +31,16 @@ public class NationColorCommand extends AdminCommandBase {
|
|||
return SetNationColor(sender, n, color);
|
||||
}
|
||||
|
||||
@CustomTabCompleteMethod(param = "color")
|
||||
public Iterable<String> def(String nation) {
|
||||
return TownColorCommand.tabcompleteColor();
|
||||
}
|
||||
|
||||
@CustomTabCompleteMethod(param = "nation")
|
||||
public Iterable<String> def() {
|
||||
return TownyComponent.TU.getDataSource().getNations().stream().map(TownyObject::getName)::iterator;
|
||||
}
|
||||
|
||||
public static boolean SetNationColor(CommandSender sender, Nation nation, String color) {
|
||||
val c = TownColorCommand.getColorOrSendError(color, sender);
|
||||
if (!c.isPresent()) return true;
|
||||
|
|
|
@ -7,7 +7,9 @@ import buttondevteam.chat.components.towny.TownyComponent;
|
|||
import buttondevteam.lib.chat.Color;
|
||||
import buttondevteam.lib.chat.Command2;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.CustomTabCompleteMethod;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.TownyObject;
|
||||
import lombok.val;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -34,6 +36,16 @@ public class TownColorCommand extends AdminCommandBase { //TODO: Command path al
|
|||
return SetTownColor(sender, targetTown, colornames);
|
||||
}
|
||||
|
||||
@CustomTabCompleteMethod(param = "colornames")
|
||||
public Iterable<String> def(String town) {
|
||||
return TownColorCommand.tabcompleteColor();
|
||||
}
|
||||
|
||||
@CustomTabCompleteMethod(param = "town")
|
||||
public Iterable<String> def() {
|
||||
return TownyComponent.TU.getDataSource().getTowns().stream().map(TownyObject::getName)::iterator;
|
||||
}
|
||||
|
||||
public static boolean SetTownColor(CommandSender sender, Town town, String[] colors) {
|
||||
Color[] clrs = new Color[colors.length];
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
|
@ -102,4 +114,8 @@ public class TownColorCommand extends AdminCommandBase { //TODO: Command path al
|
|||
public static String getTownNameCased(String name) {
|
||||
return TownyComponent.TU.getTownsMap().get(name.toLowerCase()).getName();
|
||||
}
|
||||
|
||||
public static Iterable<String> tabcompleteColor() {
|
||||
return Arrays.stream(Color.values()).skip(1).map(Color::getName)::iterator;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue