Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Integrations: add DiscordSRV support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Nov 8, 2023
1 parent 68d63ab commit ee1760c
Show file tree
Hide file tree
Showing 15 changed files with 1,004 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.flectone.chat.model.player.Moderation;
import net.flectone.chat.module.FCommand;
import net.flectone.chat.module.FModule;
import net.flectone.chat.module.integrations.IntegrationsModule;
import net.flectone.chat.util.MessageUtil;
import net.flectone.chat.util.TimeUtil;
import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -121,6 +122,9 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
: null;

banFPlayer.ban(reason, banTime, moderator);

IntegrationsModule.sendDiscordBan(banFPlayer.getOfflinePlayer(), banFPlayer.getBan());

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.flectone.chat.module.FCommand;
import net.flectone.chat.module.FModule;
import net.flectone.chat.module.integrations.IntegrationsModule;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -47,6 +48,8 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command

sendGlobalMessage(cmdSettings.getSender(), cmdSettings.getItemStack(), formatString, message, true);

IntegrationsModule.sendDiscordBroadcast(cmdSettings.getSender(), message);

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.flectone.chat.module.FCommand;
import net.flectone.chat.module.FModule;
import net.flectone.chat.module.integrations.IntegrationsModule;
import net.flectone.chat.util.MessageUtil;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
Expand Down Expand Up @@ -100,5 +101,7 @@ public void kick(@NotNull Player toKick, @NotNull CommandSender commandSender, @
playerMessage = MessageUtil.formatAll(cmdSettings.getSender(), playerMessage);

toKick.kickPlayer(playerMessage);

IntegrationsModule.sendDiscordKick(toKick, reason, commandSender.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.flectone.chat.manager.FActionManager;
import net.flectone.chat.module.FCommand;
import net.flectone.chat.module.FModule;
import net.flectone.chat.module.integrations.IntegrationsModule;
import net.flectone.chat.util.MessageUtil;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
Expand Down Expand Up @@ -86,6 +87,8 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
commands.set(getName() + ".turned-on", isEnabled);
commands.save();

IntegrationsModule.sendDiscordMaintenance(cmdSettings.getSender(), isEnabled ? "turn-on" : "turn-off");

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.flectone.chat.model.player.FPlayer;
import net.flectone.chat.module.FCommand;
import net.flectone.chat.module.FModule;
import net.flectone.chat.module.integrations.IntegrationsModule;
import net.flectone.chat.util.MessageUtil;
import net.flectone.chat.util.TimeUtil;
import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -84,6 +85,8 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command

mutedFPlayer.mute(reason, muteTime, moderator);

IntegrationsModule.sendDiscordMute(mutedFPlayer.getOfflinePlayer(), mutedFPlayer.getMute());

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.flectone.chat.model.sound.FSound;
import net.flectone.chat.module.FCommand;
import net.flectone.chat.module.FModule;
import net.flectone.chat.module.integrations.IntegrationsModule;
import net.flectone.chat.module.sounds.SoundsModule;
import net.flectone.chat.util.MessageUtil;
import net.md_5.bungee.api.chat.ComponentBuilder;
Expand Down Expand Up @@ -107,6 +108,8 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
commands.set(getName() + ".last-id", poll.getId());
commands.save();

IntegrationsModule.sendDiscordPoll(cmdSettings.getSender(), poll.getMessage(), poll.getId());

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.flectone.chat.model.player.Settings;
import net.flectone.chat.module.FCommand;
import net.flectone.chat.module.FModule;
import net.flectone.chat.module.integrations.IntegrationsModule;
import net.flectone.chat.util.MessageUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -85,21 +86,26 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command

}

String urls = MessageUtil.joinArray(args, 1, "\n");

StringBuilder stringBuilder = new StringBuilder();

locale.getVaultStringList(commandSender,this + ".start.message")
.forEach(string -> {

string = string
.replace("<player>", commandSender.getName())
.replace("<urls>", MessageUtil.joinArray(args, 1, "\n") + " ");
.replace("<urls>", urls + " ");

stringBuilder.append(string);
stringBuilder.append("\n");

});

sendGlobalMessage(cmdSettings.getSender(), cmdSettings.getItemStack(), stringBuilder.toString(), "", false);

IntegrationsModule.sendDiscordStream(cmdSettings.getSender(), urls);

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.flectone.chat.model.player.FPlayer;
import net.flectone.chat.module.FCommand;
import net.flectone.chat.module.FModule;
import net.flectone.chat.module.integrations.IntegrationsModule;
import net.flectone.chat.util.MessageUtil;
import net.flectone.chat.util.TimeUtil;
import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -96,6 +97,10 @@ public void asyncOnCommand(@NotNull CommandSender commandSender, @NotNull Comman
: null;

warnedFPlayer.warn(reason, time, moderator);

IntegrationsModule.sendDiscordWarn(warnedFPlayer.getOfflinePlayer(),
warnedFPlayer.getWarnList().get(warnedFPlayer.getWarnList().size() - 1),
warnedFPlayer.getCountWarns() + 1);
}

@Override
Expand Down
Loading

0 comments on commit ee1760c

Please sign in to comment.