diff --git a/configTemplate/config.json b/configTemplate/config.json index 2acb9e1..8c5059d 100644 --- a/configTemplate/config.json +++ b/configTemplate/config.json @@ -2,5 +2,6 @@ "token": "bot token", "logchannelid": "channel where messages will be logged", "banlogchannelid": "channel where bans will be logged", - "mongodburl": "Mongo Database URL connection" + "mongodburl": "Mongo Database URL connection", + "discordurl": "Discord invite code" } diff --git a/src/main/java/plugin/Ploogin.java b/src/main/java/plugin/Ploogin.java index 4a30c70..1929100 100644 --- a/src/main/java/plugin/Ploogin.java +++ b/src/main/java/plugin/Ploogin.java @@ -28,6 +28,7 @@ import static plugin.commands.BanMenu.loadBanMenu; import static plugin.functions.MongoDB.MongoDbPlayerCreation; import static plugin.functions.MongoDB.MongoDbPlayerRankCheck; +import static plugin.functions.Other.welcomeMenu; public class Ploogin extends Plugin implements ApplicationListener{ @@ -56,6 +57,7 @@ public void init() { Bundle.load(Ploogin.class); Events.on(EventType.PlayerJoin.class, event -> { Player plr = event.player; + welcomeMenu(plr); MongoDbPlayerCreation(plr); MongoDbPlayerRankCheck(plr.uuid()); }); diff --git a/src/main/java/plugin/commands/BanMenu.java b/src/main/java/plugin/commands/BanMenu.java index e56985b..84f4147 100644 --- a/src/main/java/plugin/commands/BanMenu.java +++ b/src/main/java/plugin/commands/BanMenu.java @@ -21,6 +21,7 @@ import java.time.Duration; import java.util.Date; +import java.util.concurrent.TimeUnit; import static mindustry.Vars.*; @@ -112,7 +113,7 @@ public static void loadBanMenu() { long duration = view.state.get(DURATION); Document usr = Ploogin.playerCollection.find(Filters.eq("uuid", target.uuid())).first(); Date date = new Date(); - long banTime = date.getTime() + duration*86400000; + long banTime = date.getTime() + TimeUnit.DAYS.toMillis(duration); String timeUntilUnban = Bundle.formatDuration(Duration.ofDays(duration)); target.con.kick("You have been banned for: " + text + ". Wait " + timeUntilUnban + " until unban!", 0); Call.sendMessage(target.plainName() + " has been banned for: " + text); diff --git a/src/main/java/plugin/discord/Bot.java b/src/main/java/plugin/discord/Bot.java index f621bb6..175ee38 100644 --- a/src/main/java/plugin/discord/Bot.java +++ b/src/main/java/plugin/discord/Bot.java @@ -3,6 +3,7 @@ import arc.Core; import arc.Events; import arc.util.Log; +import arc.util.Strings; import com.mongodb.client.model.Filters; import com.mongodb.client.model.UpdateOptions; import com.mongodb.client.model.Updates; @@ -34,9 +35,11 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; +import java.util.concurrent.TimeUnit; import mindustry.gen.Player; import plugin.ConfigJson; +import useful.Action; import useful.Bundle; import static mindustry.Vars.*; @@ -141,9 +144,9 @@ private static void addSlashCommandListener(SlashCommandCreateEvent listener) { int id = Math.toIntExact(listener.getSlashCommandInteraction().getOptionByName("id").get().getLongValue().get()); String reason = listener.getSlashCommandInteraction().getOptionByName("reason").get().getStringValue().get(); - Long time = listener.getSlashCommandInteraction().getOptionByName("time").get().getLongValue().get(); + long time = listener.getSlashCommandInteraction().getOptionByName("time").get().getLongValue().get(); Date date = new Date(); - long banTime = date.getTime() + time*86400000; + long banTime = date.getTime() + TimeUnit.DAYS.toMillis(time); String timeUntilUnban = Bundle.formatDuration(Duration.ofDays(time)); Document user = playerCollection.find(Filters.eq("id", id)).first(); if (user == null) { diff --git a/src/main/java/plugin/functions/Other.java b/src/main/java/plugin/functions/Other.java new file mode 100644 index 0000000..2e37192 --- /dev/null +++ b/src/main/java/plugin/functions/Other.java @@ -0,0 +1,21 @@ +package plugin.functions; + +import mindustry.gen.Call; +import mindustry.gen.Player; +import plugin.utils.MenuHandler; + +public class Other { + public static void welcomeMenu(Player player){ + String title = "Welcome message"; + String description = "[orange]Welcome to our server! Before we begin, make sure to read basic rules.\n" + + "[white]- Do not grief or sabotage your team.\n" + + "- Do not build/write any NSFW or offensive content.\n" + + "- Do not try lag the server using lag machines or similar stuff.\n" + + "- Use common sense, do not be toxic/mean to others.\n" + + "[orange]Write /help to see all commands that are available on server.\n" + + "Also make sure to join our discord."; + String button1 = "Close"; + String button2 = "[blue]Join our discord!"; + Call.menu(player.con, MenuHandler.welcomeMenu, title, description, new String[][]{{button1}, {button2}}); + } +}