Skip to content

Commit aa23618

Browse files
committed
Initial Commit
0 parents  commit aa23618

45 files changed

Lines changed: 3432 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
*.iml
5+
*.ipr
6+
*.iws
7+
8+
# IntelliJ
9+
out/
10+
# mpeltonen/sbt-idea plugin
11+
.idea_modules/
12+
13+
# JIRA plugin
14+
atlassian-ide-plugin.xml
15+
16+
# Compiled class file
17+
*.class
18+
19+
# Log file
20+
*.log
21+
22+
# BlueJ files
23+
*.ctxt
24+
25+
# Package Files #
26+
*.jar
27+
*.war
28+
*.nar
29+
*.ear
30+
*.zip
31+
*.tar.gz
32+
*.rar
33+
34+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
35+
hs_err_pid*
36+
37+
*~
38+
39+
# temporary files which can be created if a process still has a handle open of a deleted file
40+
.fuse_hidden*
41+
42+
# KDE directory preferences
43+
.directory
44+
45+
# Linux trash folder which might appear on any partition or disk
46+
.Trash-*
47+
48+
# .nfs files are created when an open file is removed but is still being accessed
49+
.nfs*
50+
51+
# General
52+
.DS_Store
53+
.AppleDouble
54+
.LSOverride
55+
56+
# Icon must end with two \r
57+
Icon
58+
59+
# Thumbnails
60+
._*
61+
62+
# Files that might appear in the root of a volume
63+
.DocumentRevisions-V100
64+
.fseventsd
65+
.Spotlight-V100
66+
.TemporaryItems
67+
.Trashes
68+
.VolumeIcon.icns
69+
.com.apple.timemachine.donotpresent
70+
71+
# Directories potentially created on remote AFP share
72+
.AppleDB
73+
.AppleDesktop
74+
Network Trash Folder
75+
Temporary Items
76+
.apdisk
77+
78+
# Windows thumbnail cache files
79+
Thumbs.db
80+
Thumbs.db:encryptable
81+
ehthumbs.db
82+
ehthumbs_vista.db
83+
84+
# Dump file
85+
*.stackdump
86+
87+
# Folder config file
88+
[Dd]esktop.ini
89+
90+
# Recycle Bin used on file shares
91+
$RECYCLE.BIN/
92+
93+
# Windows Installer files
94+
*.cab
95+
*.msi
96+
*.msix
97+
*.msm
98+
*.msp
99+
100+
# Windows shortcuts
101+
*.lnk
102+
103+
.gradle
104+
build/
105+
106+
# Ignore Gradle GUI config
107+
gradle-app.setting
108+
109+
# Cache of project
110+
.gradletasknamecache
111+
112+
**/build/
113+
114+
# Common working directory
115+
run/
116+
runs/
117+
118+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
119+
!gradle-wrapper.jar

build.gradle

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
group = 'me.jeremiah'
6+
version = '1.0.0'
7+
8+
repositories {
9+
mavenCentral()
10+
11+
// me.jeremiah.minecraft repositories
12+
maven { url = 'https://repo.papermc.io/repository/maven-public/' }
13+
// me.jeremiah.minecraft.hooks repositories
14+
maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
15+
}
16+
17+
dependencies {
18+
implementation 'org.slf4j:slf4j-api:2.1.0-alpha1'
19+
20+
implementation 'org.jetbrains:annotations:26.0.1'
21+
annotationProcessor 'org.jetbrains:annotations:26.0.1'
22+
23+
compileOnly 'io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT'
24+
25+
// me.jeremiah.minecraft.hooks dependencies
26+
compileOnly 'me.clip:placeholderapi:2.11.6'
27+
28+
// me.jeremiah.data.storage.databases dependencies
29+
compileOnly 'com.zaxxer:HikariCP:6.2.1'
30+
compileOnly 'org.xerial:sqlite-jdbc:3.47.2.0'
31+
compileOnly 'com.h2database:h2:2.3.232'
32+
compileOnly 'org.mariadb.jdbc:mariadb-java-client:3.5.1'
33+
compileOnly 'org.postgresql:postgresql:42.7.4'
34+
compileOnly 'org.mongodb:mongodb-driver-sync:5.3.0-beta0'
35+
compileOnly 'redis.clients:jedis:5.3.0-beta1'
36+
37+
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
38+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
39+
40+
testImplementation 'org.slf4j:slf4j-api:2.1.0-alpha1'
41+
42+
testImplementation 'org.jetbrains:annotations:26.0.1'
43+
testAnnotationProcessor 'org.jetbrains:annotations:26.0.1'
44+
45+
testRuntimeOnly 'com.zaxxer:HikariCP:6.2.1'
46+
testRuntimeOnly 'org.xerial:sqlite-jdbc:3.47.2.0'
47+
testRuntimeOnly 'com.h2database:h2:2.3.232'
48+
testRuntimeOnly 'org.mariadb.jdbc:mariadb-java-client:3.5.1'
49+
testRuntimeOnly 'org.postgresql:postgresql:42.7.4'
50+
testRuntimeOnly 'org.mongodb:mongodb-driver-sync:5.3.0-beta0'
51+
testRuntimeOnly 'redis.clients:jedis:5.3.0-beta1'
52+
}
53+
54+
test {
55+
useJUnitPlatform()
56+
}

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
org.gradle.parallel=true
2+
org.gradle.configuration-cache=true
3+
org.gradle.caching=true
4+
org.gradle.jvmargs=-Xmx2048M
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'StuffIUse'
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package me.jeremiah.data;
2+
3+
import org.jetbrains.annotations.NotNull;
4+
5+
import java.nio.ByteBuffer;
6+
import java.nio.charset.StandardCharsets;
7+
import java.util.Arrays;
8+
import java.util.UUID;
9+
10+
public record ByteTranslatable(byte[] bytes) {
11+
12+
@Override
13+
public int hashCode() {
14+
return Arrays.hashCode(bytes);
15+
}
16+
17+
@Override
18+
public boolean equals(Object obj) {
19+
if (this == obj) return true;
20+
if (!(obj instanceof ByteTranslatable(byte[] bytes1)))
21+
return false;
22+
if (bytes.length != bytes1.length) return false;
23+
return Arrays.equals(bytes, bytes1);
24+
}
25+
26+
public static ByteTranslatable from(@NotNull Object object) {
27+
return switch (object) {
28+
case ByteTranslatable byteTranslatable -> byteTranslatable;
29+
case byte[] b -> fromBytes(b);
30+
case Boolean b -> fromBoolean(b);
31+
case Byte b -> fromBytes(b);
32+
case Short i -> fromShort(i);
33+
case Integer i -> fromInt(i);
34+
case Long l -> fromLong(l);
35+
case Float v -> fromFloat(v);
36+
case Double v -> fromDouble(v);
37+
case Character c -> fromChar(c);
38+
case String string -> fromString(string);
39+
case UUID uuid -> fromUUID(uuid);
40+
default -> throw new IllegalArgumentException("Unsupported object type: " + object.getClass().getName());
41+
};
42+
}
43+
44+
public static ByteTranslatable fromBoolean(boolean value) {
45+
return new ByteTranslatable(new byte[]{(byte) (value ? 1 : 0)});
46+
}
47+
48+
public boolean asBoolean() {
49+
return bytes[0] == 1;
50+
}
51+
52+
public static ByteTranslatable fromBytes(byte... value) {
53+
return new ByteTranslatable(value);
54+
}
55+
56+
public byte asByte() {
57+
return bytes[0];
58+
}
59+
60+
public static ByteTranslatable fromShort(short value) {
61+
return new ByteTranslatable(ByteBuffer.allocate(Short.BYTES).putShort(value).array());
62+
}
63+
64+
public short asShort() {
65+
return ByteBuffer.wrap(bytes).getShort();
66+
}
67+
68+
public static ByteTranslatable fromInt(int value) {
69+
return new ByteTranslatable(ByteBuffer.allocate(Integer.BYTES).putInt(value).array());
70+
}
71+
72+
public int asInt() {
73+
return ByteBuffer.wrap(bytes).getInt();
74+
}
75+
76+
public static ByteTranslatable fromLong(long value) {
77+
return new ByteTranslatable(ByteBuffer.allocate(Long.BYTES).putLong(value).array());
78+
}
79+
80+
public long asLong() {
81+
return ByteBuffer.wrap(bytes).getLong();
82+
}
83+
84+
public static ByteTranslatable fromFloat(float value) {
85+
return new ByteTranslatable(ByteBuffer.allocate(Float.BYTES).putFloat(value).array());
86+
}
87+
88+
public float asFloat() {
89+
return ByteBuffer.wrap(bytes).getFloat();
90+
}
91+
92+
public static ByteTranslatable fromDouble(double value) {
93+
return new ByteTranslatable(ByteBuffer.allocate(Double.BYTES).putDouble(value).array());
94+
}
95+
96+
public double asDouble() {
97+
return ByteBuffer.wrap(bytes).getDouble();
98+
}
99+
100+
public static ByteTranslatable fromChar(char value) {
101+
return new ByteTranslatable(ByteBuffer.allocate(Character.BYTES).putChar(value).array());
102+
}
103+
104+
public char asChar() {
105+
return ByteBuffer.wrap(bytes).getChar();
106+
}
107+
108+
public static ByteTranslatable fromString(String value) {
109+
return new ByteTranslatable(value.getBytes(StandardCharsets.UTF_8));
110+
}
111+
112+
public String asString() {
113+
return new String(bytes, StandardCharsets.UTF_8);
114+
}
115+
116+
private static final int UUID_BYTE_SIZE = Long.BYTES * 2;
117+
118+
public static ByteTranslatable fromUUID(UUID value) {
119+
return new ByteTranslatable(
120+
ByteBuffer.allocate(UUID_BYTE_SIZE)
121+
.putLong(value.getMostSignificantBits())
122+
.putLong(value.getLeastSignificantBits())
123+
.array()
124+
);
125+
}
126+
127+
public UUID asUUID() {
128+
ByteBuffer buffer = ByteBuffer.wrap(bytes);
129+
long mostSigBits = buffer.getLong();
130+
long leastSigBits = buffer.getLong();
131+
return new UUID(mostSigBits, leastSigBits);
132+
}
133+
134+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package me.jeremiah.data;
2+
3+
import java.util.concurrent.TimeUnit;
4+
5+
public class DatabaseInfo {
6+
7+
private final String address;
8+
private final int port;
9+
10+
private final String name;
11+
12+
private final String username;
13+
private final String password;
14+
15+
private long autoSaveInterval = 300;
16+
private TimeUnit autoSaveTimeUnit = TimeUnit.SECONDS;
17+
18+
public DatabaseInfo(String databaseAddress, int databasePort, String name, String username, String password) {
19+
this.address = databaseAddress;
20+
this.port = databasePort;
21+
this.name = name;
22+
this.username = username;
23+
this.password = password;
24+
}
25+
26+
public String getAddress() {
27+
return address;
28+
}
29+
30+
public int getPort() {
31+
return port;
32+
}
33+
34+
public String getUrl() {
35+
return "%s:%d".formatted(address, port);
36+
}
37+
38+
public String getName() {
39+
return name;
40+
}
41+
42+
public String getUsername() {
43+
return username;
44+
}
45+
46+
public String getPassword() {
47+
return password;
48+
}
49+
50+
public void setAutoSaveInterval(long autoSaveInterval) {
51+
this.autoSaveInterval = autoSaveInterval;
52+
}
53+
54+
public long getAutoSaveInterval() {
55+
return autoSaveInterval;
56+
}
57+
58+
public void setAutoSaveTimeUnit(TimeUnit autoSaveTimeUnit) {
59+
this.autoSaveTimeUnit = autoSaveTimeUnit;
60+
}
61+
62+
public TimeUnit getAutoSaveTimeUnit() {
63+
return autoSaveTimeUnit;
64+
}
65+
66+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package me.jeremiah.data;
2+
3+
public interface Dirtyable {
4+
5+
boolean isDirty();
6+
7+
void markClean();
8+
9+
}

0 commit comments

Comments
 (0)