Skip to content

Commit

Permalink
1.7.5
Browse files Browse the repository at this point in the history
* Update Rank Image.
- Removed Server related Stats.
  • Loading branch information
DxsSucuk committed Apr 22, 2022
1 parent 0db0b09 commit ec44507
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 47 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>de.presti</groupId>
<artifactId>Ree6</artifactId>
<version>1.7.4</version>
<version>1.7.5</version>
<packaging>jar</packaging>
<name>Ree6</name>
<description>Ree6 is an open-Source Discord Bot.</description>
Expand Down Expand Up @@ -116,7 +116,7 @@
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-youtube</artifactId>
<version>v3-rev20220320-1.32.1</version>
<version>v3-rev20220403-1.32.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/presti/ree6/bot/BotWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void createBot(BotVersion version1, String build1) throws LoginExc
state = BotState.INIT;
build = build1;

shardManager = DefaultShardManagerBuilder.createDefault(token).setShardsTotal(10).enableIntents(GatewayIntent.getIntents(GatewayIntent.ALL_INTENTS)).disableIntents(GatewayIntent.GUILD_PRESENCES).setMemberCachePolicy(MemberCachePolicy.ALL).disableCache(CacheFlag.EMOTE, CacheFlag.ACTIVITY).build();
shardManager = DefaultShardManagerBuilder.createDefault(token).setShardsTotal(getVersion() == BotVersion.DEV ? 1 : 10).enableIntents(GatewayIntent.getIntents(GatewayIntent.ALL_INTENTS)).disableIntents(GatewayIntent.GUILD_PRESENCES).setMemberCachePolicy(MemberCachePolicy.ALL).disableCache(CacheFlag.EMOTE, CacheFlag.ACTIVITY).build();
}

/**
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/de/presti/ree6/commands/impl/info/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ public void onPerform(CommandEvent commandEvent) {
em.addField("**Response Time**", (Integer.parseInt((System.currentTimeMillis() - start) + "")) + "ms", true);
em.addField("**System Date**", new SimpleDateFormat("dd.MM.yyyy HH:mm").format(new Date()), true);

if (commandEvent.getMember().getId().equalsIgnoreCase("321580743488831490")) {
em.addField("**Server Stats:**", "", true);
em.addField("**Ram Usage:**", String.format("%.2f GB / %.2f GB", ((Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) / 1e+9), (Runtime.getRuntime().maxMemory() / 1e+9)), true);
em.addField("**CPU Usage:**", String.format("%.2f", ((OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getProcessCpuLoad() * 100) + "%", true);
}

StringBuilder end = new StringBuilder();

for (Map.Entry<String, Long> sheesh : StatsManager.getCommandStats(commandEvent.getGuild().getId()).entrySet()) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/de/presti/ree6/commands/impl/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public CommandData getCommandData() {

@Override
public String[] getAlias() {
return new String[] {"lvl", "xp", "rank"};
return new String[]{"lvl", "xp", "rank"};
}

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

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 userLevel = type.equalsIgnoreCase("voice") ?
Main.getInstance().getSqlConnector().getSqlWorker().getVoiceLevelData(commandEvent.getGuild().getId(), member.getId()) :
Main.getInstance().getSqlConnector().getSqlWorker().getChatLevelData(commandEvent.getGuild().getId(), member.getId());

userLevel.setUser(member.getUser());
if (commandEvent.isSlashCommand()) {
Expand All @@ -68,8 +68,8 @@ public void sendLevel(Member member, CommandEvent commandEvent, String type) {
}
} else {
try {
commandEvent.getTextChannel().sendFile(ImageCreationUtility.createRankImage(userLevel),"rank.png").queue();
} catch (Exception ignore) {
commandEvent.getTextChannel().sendFile(ImageCreationUtility.createRankImage(userLevel), "rank.png").queue();
} catch (Exception ignore) {
Main.getInstance().getCommandManager().sendMessage("Couldn't generated Rank Image!", commandEvent.getTextChannel(), commandEvent.getInteractionHook());
}
}
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 @@ -126,7 +126,7 @@ public static void main(String[] args) {

// Create a new Instance of the Bot, as well as add the Events.
try {
BotWorker.createBot(BotVersion.PUBLIC, "1.7.4");
BotWorker.createBot(BotVersion.PUBLIC, "1.7.5");
instance.musicWorker = new MusicWorker();
instance.addEvents();
} catch (Exception ex) {
Expand Down
88 changes: 57 additions & 31 deletions src/main/java/de/presti/ree6/utils/data/ImageCreationUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
Expand All @@ -33,7 +34,7 @@ public static byte[] createRankImage(UserLevel userLevel) throws IOException {
return new byte[128];

// Generate a 885x211 Image Background.
BufferedImage base = new BufferedImage(885, 211, BufferedImage.TYPE_INT_ARGB);
BufferedImage base = ImageIO.read(new File("images/base.png"));

User user = userLevel.getUser();
BufferedImage userImage;
Expand All @@ -49,71 +50,75 @@ public static byte[] createRankImage(UserLevel userLevel) throws IOException {
Graphics2D graphics2D = base.createGraphics();

// Change the background to black.
graphics2D.setColor(Color.BLACK);
graphics2D.fillRoundRect(0, 0, base.getWidth(), base.getHeight(), 10, 10);

// Draw basic Information, such as the User Image, Username and the Experience Rect.
graphics2D.drawImage(userImage, null, 25, 45);
graphics2D.drawImage(userImage, null, 175, 450);
graphics2D.setColor(Color.WHITE);
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Font verdana40Font = new Font("Verdana", Font.PLAIN, 40);

Font verdana60 = new Font("Verdana", Font.PLAIN, 60);
Font verdana50 = new Font("Verdana", Font.PLAIN, 50);
Font verdana40 = 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);
if (username.length() > 13) {
username = username.substring(0, 12);
}

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);
graphics2D.setFont(verdana60);
graphics2D.drawString(username, 425, 675);
graphics2D.setColor(Color.LIGHT_GRAY);
graphics2D.setFont(verdana40);
graphics2D.drawString("#" + user.getDiscriminator(), 425, 675 - graphics2D.getFontMetrics(verdana60).getHeight() + 5);
graphics2D.setColor(Color.magenta.darker().darker());
graphics2D.fillRoundRect(175, 705, base.getWidth() - 950, 50, 50, 50);

//region Experience

// Draw The current Experience and needed Experience for the next Level.
graphics2D.setFont(new Font("Verdana", Font.PLAIN, 20));
graphics2D.drawString(userLevel.getFormattedExperience() + "", (base.getWidth() - 210), 110);
graphics2D.setColor(Color.DARK_GRAY);
graphics2D.drawString("/" + userLevel.getFormattedExperience(userLevel.getExperienceForNextLevel()), (base.getWidth() - 170), 110);
graphics2D.setColor(Color.LIGHT_GRAY);
graphics2D.setFont(verdana40);
graphics2D.drawString(userLevel.getFormattedExperience() + "", (base.getWidth() - 800) - (graphics2D.getFontMetrics().stringWidth("/" + userLevel.getFormattedExperience(userLevel.getExperienceForNextLevel()))) - 5 - graphics2D.getFontMetrics().stringWidth(userLevel.getFormattedExperience() + ""), 675);
graphics2D.setColor(Color.GRAY);
graphics2D.drawString("/" + userLevel.getFormattedExperience(userLevel.getExperienceForNextLevel()), (base.getWidth() - 800) - (graphics2D.getFontMetrics().stringWidth("/" + userLevel.getFormattedExperience(userLevel.getExperienceForNextLevel()))), 675);

//endregion

//region Rank

// Draw the current Ranking.
graphics2D.setColor(Color.WHITE);
graphics2D.setFont(new Font("Verdana", Font.PLAIN, 20));
graphics2D.drawString("Rank", (base.getWidth() - 370), 60);
graphics2D.setFont(verdana40);
graphics2D.drawString("Rank", (base.getWidth() - 800) - (graphics2D.getFontMetrics(verdana50).stringWidth("" + userLevel.getLevel())) - (graphics2D.getFontMetrics().stringWidth("Rank")) - 10, 675 - graphics2D.getFontMetrics().getHeight() - graphics2D.getFontMetrics().getHeight());

graphics2D.setFont(new Font("Verdana", Font.PLAIN, 30));
graphics2D.drawString("" + userLevel.getRank(), (base.getWidth() - 310), 60);
graphics2D.setColor(Color.MAGENTA.brighter());
graphics2D.setFont(verdana50);
graphics2D.drawString("" + userLevel.getRank(), (base.getWidth() - 800) - (graphics2D.getFontMetrics().stringWidth("" + userLevel.getRank())), 675 - graphics2D.getFontMetrics(verdana40).getHeight() - graphics2D.getFontMetrics(verdana40).getHeight());

//endregion

//region Level

// Draw the current Level.
graphics2D.setColor(Color.WHITE);
graphics2D.setFont(new Font("Verdana", Font.PLAIN, 20));
graphics2D.drawString("Level", (base.getWidth() - 235), 60);
graphics2D.setFont(verdana40);
graphics2D.drawString("Level", (base.getWidth() - 800) - (graphics2D.getFontMetrics(verdana50).stringWidth("" + userLevel.getLevel())) - (graphics2D.getFontMetrics().stringWidth("Level")) - 10, 675 - graphics2D.getFontMetrics().getHeight());

graphics2D.setColor(Color.magenta.darker().darker());
graphics2D.setFont(new Font("Verdana", Font.PLAIN, 30));
graphics2D.drawString("" + userLevel.getLevel(), (base.getWidth() - 175), 60);
graphics2D.setColor(Color.magenta.brighter());
graphics2D.setFont(verdana50);
graphics2D.drawString("" + userLevel.getLevel(), (base.getWidth() - 800) - (graphics2D.getFontMetrics().stringWidth("" + userLevel.getLevel())), 675 - graphics2D.getFontMetrics(verdana40).getHeight());

//endregion

// Draw the Progressbar.
graphics2D.setColor(Color.magenta.darker().darker());
graphics2D.fillRoundRect(200, 130, (base.getWidth() - 300) * userLevel.getProgress() / 100, 50, 50, 50);
graphics2D.setColor(Color.magenta);
graphics2D.fillRoundRect(175, 705, (base.getWidth() - 950) * userLevel.getProgress() / 100, 50, 50, 50);

// Close the Graphics2d instance.
graphics2D.dispose();

// Create a ByteArrayOutputStream to convert the BufferedImage to a Array of Bytes.
// Create a ByteArrayOutputStream to convert the BufferedImage to an Array of Bytes.
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

ImageIO.write(base, "PNG", outputStream);
Expand Down Expand Up @@ -201,7 +206,7 @@ public static byte[] createHornyJailImage(User user) throws IOException {
// Close the Graphics2d instance.
graphics2D.dispose();

// Create a ByteArrayOutputStream to convert the BufferedImage to a Array of Bytes.
// Create a ByteArrayOutputStream to convert the BufferedImage to an Array of Bytes.
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

ImageIO.write(base, "PNG", outputStream);
Expand Down Expand Up @@ -240,7 +245,28 @@ public static BufferedImage convertToCircleShape(URL url) throws IOException {

g2.dispose();

return output;
return resize(output, 250, 250);
}

/**
* Resizes an image to an absolute width and height (the image may not be
* proportional)
* @param inputImage The original image
* @param scaledWidth absolute width in pixels
* @param scaledHeight absolute height in pixels
*/
public static BufferedImage resize(BufferedImage inputImage, int scaledWidth, int scaledHeight){

// creates output image
BufferedImage outputImage = new BufferedImage(scaledWidth,
scaledHeight, inputImage.getType());

// scales the input image to the output image
Graphics2D g2d = outputImage.createGraphics();
g2d.drawImage(inputImage, 0, 0, scaledWidth, scaledHeight, null);
g2d.dispose();

return outputImage;
}

}

0 comments on commit ec44507

Please sign in to comment.