✨ Ajout pourcentages de stats pour chaque rang
This commit is contained in:
parent
4649f3d8f4
commit
4abbb8b0aa
@ -31,6 +31,7 @@ dependencies {
|
|||||||
implementation("io.github.cdimascio:dotenv-kotlin:6.4.2")
|
implementation("io.github.cdimascio:dotenv-kotlin:6.4.2")
|
||||||
implementation("net.dv8tion:JDA:5.2.1")
|
implementation("net.dv8tion:JDA:5.2.1")
|
||||||
implementation("ch.qos.logback:logback-classic:1.5.12")
|
implementation("ch.qos.logback:logback-classic:1.5.12")
|
||||||
|
implementation("jakarta.annotation:jakarta.annotation-api:3.0.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import org.camelia.studio.gachamelia.services.RankService;
|
|||||||
import org.camelia.studio.gachamelia.services.UserService;
|
import org.camelia.studio.gachamelia.services.UserService;
|
||||||
import org.camelia.studio.gachamelia.utils.Configuration;
|
import org.camelia.studio.gachamelia.utils.Configuration;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import javax.annotation.Nonnull;
|
import jakarta.annotation.Nonnull;
|
||||||
|
|
||||||
|
|
||||||
public class GuildMemberJoinListener extends ListenerAdapter {
|
public class GuildMemberJoinListener extends ListenerAdapter {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.camelia.studio.gachamelia.listeners;
|
package org.camelia.studio.gachamelia.listeners;
|
||||||
|
|
||||||
|
import jakarta.annotation.Nonnull;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
@ -12,7 +13,6 @@ import org.camelia.studio.gachamelia.services.UserService;
|
|||||||
import org.camelia.studio.gachamelia.utils.Configuration;
|
import org.camelia.studio.gachamelia.utils.Configuration;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
|
|
||||||
public class GuildMemberLeaveListener extends ListenerAdapter {
|
public class GuildMemberLeaveListener extends ListenerAdapter {
|
||||||
|
@ -5,7 +5,7 @@ import net.dv8tion.jda.api.entities.Guild;
|
|||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.events.session.ReadyEvent;
|
import net.dv8tion.jda.api.events.session.ReadyEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import javax.annotation.Nonnull;
|
import jakarta.annotation.Nonnull;
|
||||||
import org.camelia.studio.gachamelia.models.User;
|
import org.camelia.studio.gachamelia.models.User;
|
||||||
import org.camelia.studio.gachamelia.repossitories.RankRepository;
|
import org.camelia.studio.gachamelia.repossitories.RankRepository;
|
||||||
import org.camelia.studio.gachamelia.services.RankService;
|
import org.camelia.studio.gachamelia.services.RankService;
|
||||||
|
@ -2,7 +2,7 @@ package org.camelia.studio.gachamelia.listeners;
|
|||||||
|
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import javax.annotation.Nonnull;
|
import jakarta.annotation.Nonnull;
|
||||||
import org.camelia.studio.gachamelia.managers.CommandManager;
|
import org.camelia.studio.gachamelia.managers.CommandManager;
|
||||||
|
|
||||||
public class SlashCommandListener extends ListenerAdapter {
|
public class SlashCommandListener extends ListenerAdapter {
|
||||||
|
@ -6,6 +6,7 @@ import org.hibernate.annotations.CreationTimestamp;
|
|||||||
import org.hibernate.annotations.UpdateTimestamp;
|
import org.hibernate.annotations.UpdateTimestamp;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -44,6 +45,14 @@ public class Rank implements IEntity {
|
|||||||
@Column(name = "byeTitle")
|
@Column(name = "byeTitle")
|
||||||
private String byeTitle;
|
private String byeTitle;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "id.rank", fetch = FetchType.LAZY)
|
||||||
|
private final List<RankStat> rankStats = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<RankStat> getRankStats() {
|
||||||
|
return rankStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Rank(String discordId, String name, int percentage) {
|
public Rank(String discordId, String name, int percentage) {
|
||||||
this.discordId = discordId;
|
this.discordId = discordId;
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
package org.camelia.studio.gachamelia.models;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.EmbeddedId;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import org.camelia.studio.gachamelia.interfaces.IEntity;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "rank_stats")
|
||||||
|
public class RankStat implements IEntity {
|
||||||
|
@EmbeddedId
|
||||||
|
private RankStatId id;
|
||||||
|
|
||||||
|
@Column(nullable = false)
|
||||||
|
private int percentage;
|
||||||
|
|
||||||
|
public RankStat() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public RankStat(Rank rank, Stat stat, int percentage) {
|
||||||
|
this.id = new RankStatId(rank, stat);
|
||||||
|
this.percentage = percentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RankStatId getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rank getRank() {
|
||||||
|
return id.getRank();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stat getStat() {
|
||||||
|
return id.getStat();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPercentage() {
|
||||||
|
return percentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPercentage(int percentage) {
|
||||||
|
this.percentage = percentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRank(Rank rank) {
|
||||||
|
if (this.id == null) {
|
||||||
|
this.id = new RankStatId();
|
||||||
|
}
|
||||||
|
this.id.setRank(rank);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStat(Stat stat) {
|
||||||
|
if (this.id == null) {
|
||||||
|
this.id = new RankStatId();
|
||||||
|
}
|
||||||
|
this.id.setStat(stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof RankStat rankStat)) return false;
|
||||||
|
return Objects.equals(id, rankStat.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package org.camelia.studio.gachamelia.models;
|
||||||
|
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class RankStatId implements Serializable {
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "rank_id", nullable = false)
|
||||||
|
private Rank rank;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "stat_id", nullable = false)
|
||||||
|
private Stat stat;
|
||||||
|
|
||||||
|
public RankStatId() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public RankStatId(Rank rank, Stat stat) {
|
||||||
|
this.rank = rank;
|
||||||
|
this.stat = stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rank getRank() {
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stat getStat() {
|
||||||
|
return stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRank(Rank rank) {
|
||||||
|
this.rank = rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStat(Stat stat) {
|
||||||
|
this.stat = stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (!(o instanceof RankStatId that)) return false;
|
||||||
|
return rank.equals(that.rank) && stat.equals(that.stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(rank, stat);
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,9 @@ package org.camelia.studio.gachamelia.models;
|
|||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import org.camelia.studio.gachamelia.interfaces.IEntity;
|
import org.camelia.studio.gachamelia.interfaces.IEntity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "stats")
|
@Table(name = "stats")
|
||||||
public class Stat implements IEntity {
|
public class Stat implements IEntity {
|
||||||
@ -13,6 +16,13 @@ public class Stat implements IEntity {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "id.stat", fetch = FetchType.LAZY)
|
||||||
|
private final List<RankStat> rankStats = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<RankStat> getRankStats() {
|
||||||
|
return rankStats;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -31,4 +41,5 @@ public class Stat implements IEntity {
|
|||||||
public Stat(String name) {
|
public Stat(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user