Skip to content

Commit

Permalink
Release 1.7.0
Browse files Browse the repository at this point in the history
+ Added Voice Level support to Level Command.
+ Added limit to name display.
  • Loading branch information
DxsSucuk committed Mar 29, 2022
1 parent 12194ae commit 6cec8ba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
25 changes: 13 additions & 12 deletions src/main/java/de/presti/ree6/commands/impl/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,30 @@ public void onPerform(CommandEvent commandEvent) {

if (commandEvent.isSlashCommand()) {
OptionMapping targetOption = commandEvent.getSlashCommandInteractionEvent().getOption("target");
OptionMapping levelType = commandEvent.getSlashCommandInteractionEvent().getOption("typ");

if (targetOption != null && targetOption.getAsMember() != null) {
sendLevel(targetOption.getAsMember(), commandEvent);
if (targetOption != null && targetOption.getAsMember() != null && levelType != null) {
sendLevel(targetOption.getAsMember(), commandEvent, levelType.getAsString());
} else {
sendLevel(commandEvent.getMember(), commandEvent);
sendLevel(commandEvent.getMember(), commandEvent, "chat");
}
} else {
if (commandEvent.getArguments().length <= 1) {
if (commandEvent.getArguments().length == 1 || commandEvent.getArguments().length == 2) {
if (commandEvent.getMessage().getMentionedMembers().isEmpty()) {
sendLevel(commandEvent.getMember(), commandEvent);
sendLevel(commandEvent.getMember(), commandEvent, commandEvent.getArguments()[0]);
} else {
sendLevel(commandEvent.getMessage().getMentionedMembers().get(0), commandEvent);
sendLevel(commandEvent.getMessage().getMentionedMembers().get(0), commandEvent, commandEvent.getArguments()[0]);
}
} else {
Main.getInstance().getCommandManager().sendMessage("Not enough Arguments!", commandEvent.getTextChannel(), commandEvent.getInteractionHook());
Main.getInstance().getCommandManager().sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level or " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level @user", commandEvent.getTextChannel(), commandEvent.getInteractionHook());
Main.getInstance().getCommandManager().sendMessage("Use " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level chat/voice or " + Main.getInstance().getSqlConnector().getSqlWorker().getSetting(commandEvent.getGuild().getId(), "chatprefix").getStringValue() + "level chat/voice @user", commandEvent.getTextChannel(), commandEvent.getInteractionHook());
}
}
}

@Override
public CommandData getCommandData() {
return new CommandDataImpl("level", "Show your own Level or the Level of another User in the Guild.")
return new CommandDataImpl("level", "Show your own Level or the Level of another User in the Guild.").addOptions(new OptionData(OptionType.STRING, "typ", "Do you want to see chat or voice level?").setRequired(true))
.addOptions(new OptionData(OptionType.USER, "target", "Show the Level of the User."));
}

Expand All @@ -52,11 +53,11 @@ public String[] getAlias() {
return new String[] {"lvl", "xp", "rank"};
}

public void sendLevel(Member member, CommandEvent commandEvent) {
public void sendLevel(Member member, CommandEvent commandEvent, String type) {

// TODO Add Voice Level support.

UserLevel userLevel = Main.getInstance().getSqlConnector().getSqlWorker().getChatLevelData(commandEvent.getGuild().getId(), member.getId());
UserLevel userLevel = type.equalsIgnoreCase("chat") ?
Main.getInstance().getSqlConnector().getSqlWorker().getChatLevelData(commandEvent.getGuild().getId(), member.getId()) :
Main.getInstance().getSqlConnector().getSqlWorker().getVoiceLevelData(commandEvent.getGuild().getId(), member.getId());

userLevel.setUser(member.getUser());
if (commandEvent.isSlashCommand()) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/presti/ree6/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static void main(String[] args) {

// Create a new Instance of the Bot, as well as add the Events.
try {
BotWorker.createBot(BotVersion.DEV, "1.7.0");
BotWorker.createBot(BotVersion.PUBLIC, "1.7.0");
instance.musicWorker = new MusicWorker();
instance.addEvents();
} catch (Exception ex) {
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/de/presti/ree6/utils/data/ImageCreationUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,22 @@ public static byte[] createRankImage(UserLevel userLevel) throws IOException {
graphics2D.setColor(Color.BLACK);
graphics2D.fillRoundRect(0, 0, base.getWidth(), base.getHeight(), 10, 10);

// TODO find a way to allow unicode Names.

// Draw basic Information, such as the User Image, Username and the Experience Rect.
graphics2D.drawImage(userImage, null, 25, 45);
graphics2D.setColor(Color.WHITE);
graphics2D.setFont(new Font("Verdana", Font.PLAIN, 40));
graphics2D.drawString(new String(user.getName().getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8), 200, 110);
Font verdana40Font = new Font("Verdana", Font.PLAIN, 40);

String username = new String(user.getName().getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);

if (username.length() > 16) {
username = username.substring(0, 15);
}

graphics2D.setFont(verdana40Font);
graphics2D.drawString(username, 200, 110);
graphics2D.setColor(Color.GRAY);
graphics2D.setFont(new Font("Verdana", Font.PLAIN, 20));
graphics2D.drawString("#" + user.getDiscriminator(), 200 + graphics2D.getFontMetrics(verdana40Font).stringWidth(username) + 5, 110);
graphics2D.fillRoundRect(200, 130, base.getWidth() - 300, 50, 50, 50);

//region Experience
Expand Down

0 comments on commit 6cec8ba

Please sign in to comment.