Skip to content

Commit

Permalink
V1.0.17 Adding entities in lib
Browse files Browse the repository at this point in the history
  • Loading branch information
pwaillette committed May 2, 2024
1 parent 2ca619b commit 7845b90
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 1 deletion.
10 changes: 9 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "com.stmarygate"
version = "1.0.16"
version = "1.0.17"

repositories {
mavenCentral()
Expand Down Expand Up @@ -46,6 +46,14 @@ dependencies {

implementation("org.jetbrains:annotations:24.1.0")

// Database
implementation("org.postgresql:postgresql:42.7.0")
implementation("com.zaxxer:HikariCP:5.0.1")
implementation("org.hibernate.orm:hibernate-core:6.4.1.Final")
implementation("org.hibernate.orm:hibernate-hikaricp:6.4.1.Final")
implementation("io.hypersistence:hypersistence-utils-hibernate-63:3.7.3")
implementation("com.fasterxml.jackson.core:jackson-databind:2.16.1")

// Jupiter
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/stmarygate/coral/entities/Account.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.stmarygate.coral.entities;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@Entity
@Table(name = "accounts")
public class Account {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false, unique = true)
private String username;

@Column(nullable = false)
private String password; // Hashed password

@Column(nullable = false, unique = true)
private String email;

@Column(nullable = true)
private String jwt;

@OneToOne()
@JoinColumn(name = "player_id")
private Player player;
}
20 changes: 20 additions & 0 deletions src/main/java/com/stmarygate/coral/entities/Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.stmarygate.coral.entities;

import jakarta.persistence.*;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
@Entity
@Table(name = "players")
public class Player {

@Id
@GeneratedValue(strategy = GenerationType.UUID)
private UUID id;

@OneToOne(mappedBy = "player")
private Account account;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.stmarygate.coral.network.packets.client;

import com.stmarygate.coral.network.packets.Packet;
import com.stmarygate.coral.network.packets.PacketBuffer;
import com.stmarygate.coral.network.packets.PacketHandler;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class PacketGetPlayerInformations extends Packet {

/**
* Constructs a new {@code PacketGetPlayerInformations}.
*/
public PacketGetPlayerInformations() {

}

/**
* Encodes the packet data into the provided {@link PacketBuffer}.
*
* @param packet The {@link PacketBuffer} to which the packet data will be written.
*/
@Override
public void encode(PacketBuffer packet) throws Exception {
}

/**
* Handles the packet using the specified {@link PacketHandler}.
*
* @param handler The {@link PacketHandler} responsible for handling the packet.
*/
@Override
public void handle(PacketHandler handler) throws Exception {
handler.handlePacket(this);
}

/**
* Returns a string representation of the {@code PacketVersion}.
*
* @return A string representation containing version information.
*/
@Override
public String toString() {
return "";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.stmarygate.coral.network.packets.server;

import com.stmarygate.coral.network.packets.Packet;

public class PacketGetPlayerInformationsResult extends Packet {

}

0 comments on commit 7845b90

Please sign in to comment.