Skip to content

Commit

Permalink
чтоооо
Browse files Browse the repository at this point in the history
  • Loading branch information
NazrinNya committed Jul 5, 2023
1 parent 915219f commit 9ed16de
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
3 changes: 2 additions & 1 deletion configTemplate/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 2 additions & 0 deletions src/main/java/plugin/Ploogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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());
});
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/plugin/commands/BanMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.time.Duration;
import java.util.Date;
import java.util.concurrent.TimeUnit;

import static mindustry.Vars.*;

Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/plugin/discord/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.*;
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/plugin/functions/Other.java
Original file line number Diff line number Diff line change
@@ -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}});
}
}

0 comments on commit 9ed16de

Please sign in to comment.