add vote command
This commit is contained in:
@ -22,9 +22,6 @@ public class Aetheria extends JavaPlugin {
|
|||||||
|
|
||||||
public static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(2, 8, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
|
public static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(2, 8, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
|
||||||
|
|
||||||
// todo: move to config
|
|
||||||
public static final String PREFIX = "§6§lAetheria §7» §f";
|
|
||||||
|
|
||||||
public Aetheria() {
|
public Aetheria() {
|
||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
}
|
}
|
||||||
|
@ -105,19 +105,19 @@ public class Account {
|
|||||||
/**
|
/**
|
||||||
* Send a message to the player.
|
* Send a message to the player.
|
||||||
*
|
*
|
||||||
* @param message the message to send
|
* @param component the message to send
|
||||||
*/
|
*/
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(Component component) {
|
||||||
getPlayer().sendPlainMessage(message);
|
getPlayer().sendMessage(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to the player.
|
* Send a message to the player.
|
||||||
*
|
*
|
||||||
* @param component the message to send
|
* @param message the message to send
|
||||||
*/
|
*/
|
||||||
public void sendMessage(Component component) {
|
public void sendMessage(String message) {
|
||||||
getPlayer().sendMessage(component);
|
this.sendMessage(Component.text(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,11 +32,9 @@ public abstract class Command implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender commandSender, org.bukkit.command.@NotNull Command command, @NotNull String s, @NotNull String[] strings) {
|
public boolean onCommand(@NotNull CommandSender commandSender, org.bukkit.command.@NotNull Command command, @NotNull String s, @NotNull String[] strings) {
|
||||||
if (this.permission != null) {
|
if (this.permission != null && !commandSender.hasPermission(permission)) {
|
||||||
if (!commandSender.hasPermission(permission)) {
|
commandSender.sendMessage("§cYou do not have permission to execute this command.");
|
||||||
commandSender.sendMessage("§cYou do not have permission to execute this command.");
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) commandSender;
|
Player player = (Player) commandSender;
|
||||||
|
@ -4,6 +4,7 @@ import cc.fascinated.Aetheria;
|
|||||||
import cc.fascinated.command.impl.HelpCommand;
|
import cc.fascinated.command.impl.HelpCommand;
|
||||||
import cc.fascinated.command.impl.SeedCommand;
|
import cc.fascinated.command.impl.SeedCommand;
|
||||||
import cc.fascinated.command.impl.TotalJoinsCommand;
|
import cc.fascinated.command.impl.TotalJoinsCommand;
|
||||||
|
import cc.fascinated.command.impl.VoteCommand;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
|
||||||
public class CommandManager {
|
public class CommandManager {
|
||||||
@ -12,6 +13,7 @@ public class CommandManager {
|
|||||||
registerCommand(new TotalJoinsCommand());
|
registerCommand(new TotalJoinsCommand());
|
||||||
registerCommand(new HelpCommand());
|
registerCommand(new HelpCommand());
|
||||||
registerCommand(new SeedCommand());
|
registerCommand(new SeedCommand());
|
||||||
|
registerCommand(new VoteCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerCommand(Command command) {
|
public static void registerCommand(Command command) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cc.fascinated.command.impl;
|
package cc.fascinated.command.impl;
|
||||||
|
|
||||||
import cc.fascinated.Aetheria;
|
|
||||||
import cc.fascinated.account.Account;
|
import cc.fascinated.account.Account;
|
||||||
import cc.fascinated.command.Command;
|
import cc.fascinated.command.Command;
|
||||||
|
import cc.fascinated.config.Lang;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class TotalJoinsCommand extends Command {
|
public class TotalJoinsCommand extends Command {
|
||||||
@ -13,6 +13,6 @@ public class TotalJoinsCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Account account, String[] args) {
|
public void execute(Account account, String[] args) {
|
||||||
account.sendMessage(Aetheria.PREFIX + "§fTotal joins: §e" + Bukkit.getOfflinePlayers().length + "§f.");
|
account.sendMessage(Lang.PREFIX.getAsString() + "§fTotal joins: §e" + Bukkit.getOfflinePlayers().length + "§f.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
src/main/java/cc/fascinated/command/impl/VoteCommand.java
Normal file
29
src/main/java/cc/fascinated/command/impl/VoteCommand.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package cc.fascinated.command.impl;
|
||||||
|
|
||||||
|
import cc.fascinated.account.Account;
|
||||||
|
import cc.fascinated.command.Command;
|
||||||
|
import cc.fascinated.config.Lang;
|
||||||
|
import cc.fascinated.utils.ChatUtils;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class VoteCommand extends Command {
|
||||||
|
|
||||||
|
public VoteCommand() {
|
||||||
|
super("vote");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(Account account, String[] args) {
|
||||||
|
account.sendMessage(ChatUtils.color(Lang.VOTE_HEADER.getAsString()));
|
||||||
|
List<String> voteLinks = Lang.VOTE_LINKS.getAsStringList();
|
||||||
|
for (String link : voteLinks) {
|
||||||
|
account.sendMessage(Component.text(ChatUtils.color(Lang.VOTE_FORMAT.getAsString())
|
||||||
|
.replace("%link%", link)
|
||||||
|
.replace("%number%", String.valueOf(voteLinks.indexOf(link) + 1))
|
||||||
|
).clickEvent(ClickEvent.openUrl(link)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,11 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
public enum Lang {
|
public enum Lang {
|
||||||
|
|
||||||
HELP_COMMAND("help-command");
|
PREFIX("prefix"),
|
||||||
|
HELP_COMMAND("help-command"),
|
||||||
|
VOTE_HEADER("vote.header"),
|
||||||
|
VOTE_FORMAT("vote.format"),
|
||||||
|
VOTE_LINKS("vote.links");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The path of the lang in the lang.yml file.
|
* The path of the lang in the lang.yml file.
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cc.fascinated.worldsize.impl;
|
package cc.fascinated.worldsize.impl;
|
||||||
|
|
||||||
import cc.fascinated.Aetheria;
|
|
||||||
import cc.fascinated.account.Account;
|
import cc.fascinated.account.Account;
|
||||||
import cc.fascinated.command.Command;
|
import cc.fascinated.command.Command;
|
||||||
|
import cc.fascinated.config.Lang;
|
||||||
import cc.fascinated.utils.FormatterUtils;
|
import cc.fascinated.utils.FormatterUtils;
|
||||||
import cc.fascinated.utils.TimeUtils;
|
import cc.fascinated.utils.TimeUtils;
|
||||||
import cc.fascinated.worldsize.WorldSizeManager;
|
import cc.fascinated.worldsize.WorldSizeManager;
|
||||||
@ -18,7 +18,7 @@ public class WorldSizeCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Account account, String[] args) {
|
public void execute(Account account, String[] args) {
|
||||||
account.sendMessage(Aetheria.PREFIX + "§fWorld information:");
|
account.sendMessage(Lang.PREFIX + "§fWorld information:");
|
||||||
long totalSize = 0;
|
long totalSize = 0;
|
||||||
for (Map.Entry<World, Long> entry : WorldSizeManager.getWorldSizes().entrySet()) {
|
for (Map.Entry<World, Long> entry : WorldSizeManager.getWorldSizes().entrySet()) {
|
||||||
long size = entry.getValue();
|
long size = entry.getValue();
|
||||||
|
@ -1,6 +1,20 @@
|
|||||||
|
prefix: "&6&lAetheria &7» &f"
|
||||||
|
|
||||||
help-command:
|
help-command:
|
||||||
- "&6&lAetheria &7» &fCommands:"
|
- "&6&lAetheria &7» &fCommands:"
|
||||||
- "&e/kill &7- &fKills you"
|
- "&e/kill &7- &fKills you"
|
||||||
- "&e/worldsize &7- &fShows the total file size of all worlds"
|
- "&e/worldsize &7- &fShows the total file size of all worlds"
|
||||||
- "&e/playercolor [color] &7- &fChange your player name color"
|
- "&e/playercolor [color] &7- &fChange your player name color"
|
||||||
- "&e/seed &7- &fShows you the world seed"
|
- "&e/seed &7- &fShows you the world seed"
|
||||||
|
|
||||||
|
vote:
|
||||||
|
header: "&6&lAetheria &7» &fVote for us on the following websites:"
|
||||||
|
format: "&e%number%. &f%link%"
|
||||||
|
links:
|
||||||
|
- "https://minecraft.menu/server-aetheria-anarchy.2827/vote"
|
||||||
|
- "https://topg.org/minecraft-servers/server-662463"
|
||||||
|
- "https://minecraft-server-list.com/server/496608/vote"
|
||||||
|
- "https://minecraftservers.org/vote/650863"
|
||||||
|
- "https://servers-minecraft.net/server-aetheria.24701"
|
||||||
|
- "https://topminecraftservers.org/vote/33565"
|
||||||
|
- "https://best-minecraft-servers.co/server-aetheria.16373/vote"
|
@ -21,3 +21,6 @@ commands:
|
|||||||
seed:
|
seed:
|
||||||
description: "Shows the seed of the world"
|
description: "Shows the seed of the world"
|
||||||
usage: "/seed"
|
usage: "/seed"
|
||||||
|
vote:
|
||||||
|
description: "Shows the vote links"
|
||||||
|
usage: "/vote"
|
Reference in New Issue
Block a user