Prepare for release and deprecate old RPC sdk
This commit is contained in:
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
* Class containing references to all available discord event handles.
|
||||
* Registering a handler is optional, and non-assigned handlers will be ignored
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordEventHandlers extends Structure {
|
||||
|
||||
// Callback for when the RPC was initialized successfully
|
||||
|
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author HypherionSA
|
||||
* Java Wrapper of the Discord-RPC Library
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DiscordRPC extends Library {
|
||||
|
||||
DiscordRPC INSTANCE = Native.load("discord-rpc", DiscordRPC.class);
|
||||
|
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class reprenting a Discord RPC activity
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordRichPresence extends Structure {
|
||||
|
||||
// First line of text on the RPC
|
||||
|
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class representing the Discord User
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordUser extends Structure {
|
||||
|
||||
// The User ID of the User
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the Discord RPC disconnects
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DisconnectedCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC ran into an error
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ErroredCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone was approved to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone requests to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinRequestCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC has connected successfully
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ReadyCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone is requesting to spectate your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface SpectateGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -9,6 +9,7 @@ import java.io.Serializable;
|
||||
* Helper class to add Buttons to Discord Rich Presence
|
||||
* This can not be used with Join/Spectate
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class RPCButton implements Serializable {
|
||||
|
||||
// The label of the button
|
||||
|
@@ -1,7 +1,7 @@
|
||||
**New Features**:
|
||||
|
||||
- Paper Support. Currently only available on Modrinth and NightBloom
|
||||
- Added API's for working with FTB Ranks and LuckPerms groups
|
||||
- Paper Support. Currently only available on [NightBloom](https://nightbloom.cc/project/craterlib/files?loader=paper)
|
||||
- Added APIs for working with FTB Ranks and LuckPerms groups
|
||||
|
||||
**Bug Fixes**:
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
* Class containing references to all available discord event handles.
|
||||
* Registering a handler is optional, and non-assigned handlers will be ignored
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordEventHandlers extends Structure {
|
||||
|
||||
// Callback for when the RPC was initialized successfully
|
||||
|
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author HypherionSA
|
||||
* Java Wrapper of the Discord-RPC Library
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DiscordRPC extends Library {
|
||||
|
||||
DiscordRPC INSTANCE = Native.load("discord-rpc", DiscordRPC.class);
|
||||
|
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class reprenting a Discord RPC activity
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordRichPresence extends Structure {
|
||||
|
||||
// First line of text on the RPC
|
||||
|
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class representing the Discord User
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordUser extends Structure {
|
||||
|
||||
// The User ID of the User
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the Discord RPC disconnects
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DisconnectedCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC ran into an error
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ErroredCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone was approved to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone requests to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinRequestCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC has connected successfully
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ReadyCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone is requesting to spectate your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface SpectateGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -9,6 +9,7 @@ import java.io.Serializable;
|
||||
* Helper class to add Buttons to Discord Rich Presence
|
||||
* This can not be used with Join/Spectate
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class RPCButton implements Serializable {
|
||||
|
||||
// The label of the button
|
||||
|
@@ -1,7 +1,7 @@
|
||||
**New Features**:
|
||||
|
||||
- Paper Support. Currently only available on Modrinth and NightBloom
|
||||
- Added API's for working with FTB Ranks and LuckPerms groups
|
||||
- Paper Support. Currently only available on [NightBloom](https://nightbloom.cc/project/craterlib/files?loader=paper)
|
||||
- Added APIs for working with FTB Ranks and LuckPerms groups
|
||||
|
||||
**Bug Fixes**:
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
* Class containing references to all available discord event handles.
|
||||
* Registering a handler is optional, and non-assigned handlers will be ignored
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordEventHandlers extends Structure {
|
||||
|
||||
// Callback for when the RPC was initialized successfully
|
||||
|
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author HypherionSA
|
||||
* Java Wrapper of the Discord-RPC Library
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DiscordRPC extends Library {
|
||||
|
||||
DiscordRPC INSTANCE = Native.load("discord-rpc", DiscordRPC.class);
|
||||
|
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class reprenting a Discord RPC activity
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordRichPresence extends Structure {
|
||||
|
||||
// First line of text on the RPC
|
||||
|
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class representing the Discord User
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordUser extends Structure {
|
||||
|
||||
// The User ID of the User
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the Discord RPC disconnects
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DisconnectedCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC ran into an error
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ErroredCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone was approved to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone requests to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinRequestCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC has connected successfully
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ReadyCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone is requesting to spectate your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface SpectateGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -9,6 +9,7 @@ import java.io.Serializable;
|
||||
* Helper class to add Buttons to Discord Rich Presence
|
||||
* This can not be used with Join/Spectate
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class RPCButton implements Serializable {
|
||||
|
||||
// The label of the button
|
||||
|
@@ -61,11 +61,9 @@ tasks.assemble {
|
||||
|
||||
publisher {
|
||||
apiKeys {
|
||||
modrinth(System.getenv("MODRINTH_TOKEN"))
|
||||
nightbloom(System.getenv("PLATFORM_KEY"))
|
||||
}
|
||||
|
||||
setModrinthID(modrinth_id)
|
||||
setNightbloomID("craterlib")
|
||||
setVersionType("alpha")
|
||||
setChangelog(rootProject.file("changelog.md"))
|
||||
|
@@ -1,7 +1,7 @@
|
||||
**New Features**:
|
||||
|
||||
- Paper Support. Currently only available on Modrinth and NightBloom
|
||||
- Added API's for working with FTB Ranks and LuckPerms groups
|
||||
- Paper Support. Currently only available on [NightBloom](https://nightbloom.cc/project/craterlib/files?loader=paper)
|
||||
- Added APIs for working with FTB Ranks and LuckPerms groups
|
||||
|
||||
**Bug Fixes**:
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
* Class containing references to all available discord event handles.
|
||||
* Registering a handler is optional, and non-assigned handlers will be ignored
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordEventHandlers extends Structure {
|
||||
|
||||
// Callback for when the RPC was initialized successfully
|
||||
|
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author HypherionSA
|
||||
* Java Wrapper of the Discord-RPC Library
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DiscordRPC extends Library {
|
||||
|
||||
DiscordRPC INSTANCE = Native.load("discord-rpc", DiscordRPC.class);
|
||||
|
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class reprenting a Discord RPC activity
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordRichPresence extends Structure {
|
||||
|
||||
// First line of text on the RPC
|
||||
|
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class representing the Discord User
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordUser extends Structure {
|
||||
|
||||
// The User ID of the User
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the Discord RPC disconnects
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DisconnectedCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC ran into an error
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ErroredCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone was approved to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone requests to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinRequestCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC has connected successfully
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ReadyCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone is requesting to spectate your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface SpectateGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -9,6 +9,7 @@ import java.io.Serializable;
|
||||
* Helper class to add Buttons to Discord Rich Presence
|
||||
* This can not be used with Join/Spectate
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class RPCButton implements Serializable {
|
||||
|
||||
// The label of the button
|
||||
|
@@ -61,11 +61,9 @@ tasks.assemble {
|
||||
|
||||
publisher {
|
||||
apiKeys {
|
||||
modrinth(System.getenv("MODRINTH_TOKEN"))
|
||||
nightbloom(System.getenv("PLATFORM_KEY"))
|
||||
}
|
||||
|
||||
setModrinthID(modrinth_id)
|
||||
setNightbloomID("craterlib")
|
||||
setVersionType("alpha")
|
||||
setChangelog(rootProject.file("changelog.md"))
|
||||
|
@@ -1,7 +1,7 @@
|
||||
**New Features**:
|
||||
|
||||
- Paper Support. Currently only available on Modrinth and NightBloom
|
||||
- Added API's for working with FTB Ranks and LuckPerms groups
|
||||
- Paper Support. Currently only available on [NightBloom](https://nightbloom.cc/project/craterlib/files?loader=paper)
|
||||
- Added APIs for working with FTB Ranks and LuckPerms groups
|
||||
|
||||
**Bug Fixes**:
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
* Class containing references to all available discord event handles.
|
||||
* Registering a handler is optional, and non-assigned handlers will be ignored
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordEventHandlers extends Structure {
|
||||
|
||||
// Callback for when the RPC was initialized successfully
|
||||
|
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author HypherionSA
|
||||
* Java Wrapper of the Discord-RPC Library
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DiscordRPC extends Library {
|
||||
|
||||
DiscordRPC INSTANCE = Native.load("discord-rpc", DiscordRPC.class);
|
||||
|
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class reprenting a Discord RPC activity
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordRichPresence extends Structure {
|
||||
|
||||
// First line of text on the RPC
|
||||
|
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class representing the Discord User
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordUser extends Structure {
|
||||
|
||||
// The User ID of the User
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the Discord RPC disconnects
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DisconnectedCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC ran into an error
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ErroredCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone was approved to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone requests to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinRequestCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC has connected successfully
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ReadyCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone is requesting to spectate your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface SpectateGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -9,6 +9,7 @@ import java.io.Serializable;
|
||||
* Helper class to add Buttons to Discord Rich Presence
|
||||
* This can not be used with Join/Spectate
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class RPCButton implements Serializable {
|
||||
|
||||
// The label of the button
|
||||
|
@@ -0,0 +1,118 @@
|
||||
archivesBaseName = "${mod_name.replace(" ", "")}-NeoForge-${minecraft_version}"
|
||||
|
||||
dependencies {
|
||||
// Compat
|
||||
modImplementation("maven.modrinth:vanishmod:${vanishmod_neo}")
|
||||
|
||||
stupidRemapArch("dev.ftb.mods:ftb-essentials-neoforge:${ftb_essentials}")
|
||||
stupidRemapArch("dev.ftb.mods:ftb-ranks-neoforge:${ftb_ranks}")
|
||||
|
||||
// Do not edit or remove
|
||||
implementation project(":Common")
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
from sourceSets.main.output
|
||||
configurations = [project.configurations.shade]
|
||||
|
||||
dependencies {
|
||||
exclude(dependency('com.google.code.gson:.*'))
|
||||
|
||||
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
|
||||
relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
|
||||
relocate 'net.kyori', 'shadow.kyori'
|
||||
}
|
||||
|
||||
setArchiveClassifier('dev-shadow')
|
||||
mergeServiceFiles()
|
||||
}
|
||||
|
||||
/**
|
||||
* ===============================================================================
|
||||
* = DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING =
|
||||
* ===============================================================================
|
||||
*/
|
||||
|
||||
unimined.minecraft {
|
||||
neoForged {
|
||||
loader neoforge_version
|
||||
mixinConfig("${mod_id}.mixins.json", "${mod_id}.neoforge.mixins.json")
|
||||
}
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
archiveClassifier.set null
|
||||
}
|
||||
|
||||
jar {
|
||||
archiveClassifier.set "dev"
|
||||
}
|
||||
|
||||
processResources {
|
||||
from project(":Common").sourceSets.main.resources
|
||||
def buildProps = project.properties.clone()
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
expand buildProps
|
||||
}
|
||||
}
|
||||
|
||||
compileTestJava.enabled = false
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
source(project(":Common").sourceSets.main.allSource)
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishing Config
|
||||
*/
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifactId project.archivesBaseName
|
||||
from components.java
|
||||
|
||||
artifact(remapJar) {
|
||||
builtBy remapJar
|
||||
}
|
||||
|
||||
pom.withXml {
|
||||
Node pomNode = asNode()
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
it.artifactId.text() == 'regutils-joined-fabric' ||
|
||||
it.artifactId.text() == 'core' ||
|
||||
it.artifactId.text() == 'toml'
|
||||
}.each() {
|
||||
it.parent().remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven rootProject.orion.getPublishingMaven()
|
||||
}
|
||||
}
|
||||
|
||||
publisher {
|
||||
apiKeys {
|
||||
modrinth(System.getenv("MODRINTH_TOKEN"))
|
||||
curseforge(System.getenv("CURSE_TOKEN"))
|
||||
nightbloom(System.getenv("PLATFORM_KEY"))
|
||||
}
|
||||
|
||||
setCurseID(curse_id)
|
||||
setModrinthID(modrinth_id)
|
||||
setNightbloomID("craterlib")
|
||||
setVersionType("release")
|
||||
setChangelog(rootProject.file("changelog.md"))
|
||||
setProjectVersion("${minecraft_version}-${project.version}")
|
||||
setDisplayName("[NeoForge 1.20.4] CraterLib - ${project.version}")
|
||||
setGameVersions("1.20.4")
|
||||
setLoaders("neoforge")
|
||||
setArtifact(remapJar)
|
||||
setCurseEnvironment("both")
|
||||
setIsManualRelease(true)
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
package com.hypherionmc.craterlib;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.client.LateInitEvent;
|
||||
import com.hypherionmc.craterlib.common.NeoForgeServerEvents;
|
||||
import com.hypherionmc.craterlib.compat.Vanish;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
|
||||
import com.hypherionmc.craterlib.core.networking.PacketRegistry;
|
||||
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import com.hypherionmc.craterlib.network.CraterNeoForgeNetworkHandler;
|
||||
import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
|
||||
import com.hypherionmc.craterlib.nojang.client.BridgedOptions;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.fml.loading.FMLLoader;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
|
||||
@Mod(CraterConstants.MOD_ID)
|
||||
public class CraterLib {
|
||||
|
||||
private final PacketRegistry handler;
|
||||
|
||||
public CraterLib(IEventBus eventBus) {
|
||||
NeoForge.EVENT_BUS.register(new NeoForgeServerEvents());
|
||||
eventBus.addListener(this::commonSetup);
|
||||
handler = new CraterNeoForgeNetworkHandler(FMLLoader.getDist().isClient() ? PacketSide.CLIENT : PacketSide.SERVER);
|
||||
|
||||
if (ModloaderEnvironment.INSTANCE.isModLoaded("vmod")) {
|
||||
NeoForge.EVENT_BUS.register(new Vanish());
|
||||
}
|
||||
}
|
||||
|
||||
public void commonSetup(FMLCommonSetupEvent evt) {
|
||||
new CraterPacketNetwork(handler);
|
||||
if (FMLEnvironment.dist.isClient()) {
|
||||
LateInitEvent event = new LateInitEvent(new BridgedMinecraft(), BridgedOptions.of(Minecraft.getInstance().options));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,25 @@
|
||||
package com.hypherionmc.craterlib.client;
|
||||
|
||||
import com.hypherionmc.craterlib.CraterConstants;
|
||||
import com.hypherionmc.craterlib.api.events.client.CraterClientTickEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.nojang.client.multiplayer.BridgedClientLevel;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = CraterConstants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
|
||||
public class NeoForgeClientEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void clientTick(TickEvent.LevelTickEvent event) {
|
||||
if (Minecraft.getInstance().level == null)
|
||||
return;
|
||||
|
||||
CraterClientTickEvent craterClientTickEvent = new CraterClientTickEvent(BridgedClientLevel.of(Minecraft.getInstance().level));
|
||||
CraterEventBus.INSTANCE.postEvent(craterClientTickEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,40 @@
|
||||
package com.hypherionmc.craterlib.client;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
|
||||
import com.hypherionmc.craterlib.nojang.client.multiplayer.BridgedClientLevel;
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.Connection;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class NeoForgeClientHelper implements ClientPlatform {
|
||||
|
||||
public NeoForgeClientHelper() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BridgedMinecraft getClientInstance() {
|
||||
return new BridgedMinecraft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BridgedPlayer getClientPlayer() {
|
||||
return BridgedPlayer.of(Minecraft.getInstance().player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BridgedClientLevel getClientLevel() {
|
||||
return BridgedClientLevel.of(Minecraft.getInstance().level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getClientConnection() {
|
||||
Objects.requireNonNull(Minecraft.getInstance().getConnection(), "Cannot send packets when not in game!");
|
||||
return Minecraft.getInstance().getConnection().getConnection();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,19 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.CommonPlatform;
|
||||
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
import net.neoforged.neoforge.server.ServerLifecycleHooks;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class NeoForgeCommonHelper implements CommonPlatform {
|
||||
|
||||
public NeoForgeCommonHelper() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BridgedMinecraftServer getMCServer() {
|
||||
return BridgedMinecraftServer.of(ServerLifecycleHooks.getCurrentServer());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.CompatUtils;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
import redstonedubstep.mods.vanishmod.VanishUtil;
|
||||
|
||||
public class NeoForgeCompatHelper implements CompatUtils {
|
||||
|
||||
@Override
|
||||
public boolean isPlayerActive(BridgedPlayer player) {
|
||||
if (!ModloaderEnvironment.INSTANCE.isModLoaded("vmod"))
|
||||
return true;
|
||||
|
||||
return !VanishUtil.isVanished(player.toMojangServerPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkinUUID(BridgedPlayer player) {
|
||||
return player.getStringUUID();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,79 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.Environment;
|
||||
import com.hypherionmc.craterlib.core.platform.LoaderType;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.loading.FMLLoader;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class NeoForgeLoaderHelper implements ModloaderEnvironment {
|
||||
|
||||
public NeoForgeLoaderHelper() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFabric() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderType getLoaderType() {
|
||||
return LoaderType.NEOFORGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getGameFolder() {
|
||||
return Minecraft.getInstance().gameDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getConfigFolder() {
|
||||
return FMLPaths.CONFIGDIR.get().toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getModsFolder() {
|
||||
return FMLPaths.MODSDIR.get().toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Environment getEnvironment() {
|
||||
switch (FMLLoader.getDist()) {
|
||||
case CLIENT -> {
|
||||
return Environment.CLIENT;
|
||||
}
|
||||
case DEDICATED_SERVER -> {
|
||||
return Environment.SERVER;
|
||||
}
|
||||
}
|
||||
return Environment.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modid) {
|
||||
return ModList.get().isLoaded(modid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDevEnv() {
|
||||
return !FMLLoader.isProduction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getModCount() {
|
||||
return ModList.get().size();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,41 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent;
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppedEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
||||
|
||||
public class NeoForgeServerEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStarting(ServerStartingEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Starting(BridgedMinecraftServer.of(event.getServer())));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStarted(ServerStartedEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Started(BridgedMinecraftServer.of(event.getServer())));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStopping(ServerStoppingEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopping(BridgedMinecraftServer.of(event.getServer())));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStopped(ServerStoppedEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopped(BridgedMinecraftServer.of(event.getServer())));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCommandRegister(RegisterCommandsEvent event) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(event.getDispatcher()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,24 @@
|
||||
package com.hypherionmc.craterlib.compat;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterPlayerEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import redstonedubstep.mods.vanishmod.api.PlayerVanishEvent;
|
||||
|
||||
public class Vanish {
|
||||
|
||||
public Vanish() {
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void vanishevent(PlayerVanishEvent event) {
|
||||
if (event.isVanished()) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedOut(BridgedPlayer.of(event.getEntity()), true));
|
||||
} else {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedIn(BridgedPlayer.of(event.getEntity()), true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
package com.hypherionmc.craterlib.mixin;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import com.hypherionmc.craterlib.core.config.AbstractConfig;
|
||||
import com.hypherionmc.craterlib.core.config.ConfigController;
|
||||
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
import net.neoforged.neoforgespi.language.IModInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
@Mixin(ConfigScreenHandler.class)
|
||||
public class ConfigScreenHandlerMixin {
|
||||
|
||||
/**
|
||||
* Inject Auto Generated config Screens into forge
|
||||
*
|
||||
*/
|
||||
@Inject(at = @At("RETURN"), method = "getScreenFactoryFor", cancellable = true, remap = false)
|
||||
private static void injectConfigScreen(IModInfo selectedMod, CallbackInfoReturnable<Optional<BiFunction<Minecraft, Screen, Screen>>> cir) {
|
||||
ConfigController.getWatchedConfigs().forEach((conf, watcher) -> {
|
||||
if (!conf.getClass().isAnnotationPresent(NoConfigScreen.class)) {
|
||||
AbstractConfig config = watcher.getLeft();
|
||||
if (config.getModId().equals(selectedMod.getModId())) {
|
||||
cir.setReturnValue(
|
||||
Optional.of((minecraft, screen) -> new CraterConfigScreen(config, screen))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package com.hypherionmc.craterlib.mixin;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterServerChatEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
import com.hypherionmc.craterlib.utils.ChatUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.FilteredText;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = ServerGamePacketListenerImpl.class, priority = Integer.MIN_VALUE)
|
||||
public class ServerGamePacketListenerImplMixin {
|
||||
|
||||
@Shadow
|
||||
public ServerPlayer player;
|
||||
|
||||
@Inject(
|
||||
method = "lambda$handleChat$6",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void injectChatEvent(Component component, PlayerChatMessage arg, FilteredText p_296589_, CallbackInfo ci) {
|
||||
Component finalcomp = component == null ? arg.decoratedContent() : component;
|
||||
CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), finalcomp.getString(), ChatUtils.mojangToAdventure(finalcomp));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
if (event.wasCancelled())
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,53 @@
|
||||
package com.hypherionmc.craterlib.mixin;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.server.ServerStatusEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.utils.ChatUtils;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.network.protocol.status.ServerboundStatusRequestPacket;
|
||||
import net.minecraft.server.network.ServerStatusPacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerStatusPacketListenerImpl.class)
|
||||
public class ServerStatusPacketListenerMixin {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerStatus status;
|
||||
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Inject(method = "handleStatusRequest",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/Connection;send(Lnet/minecraft/network/protocol/Packet;)V",
|
||||
shift = At.Shift.BEFORE),
|
||||
cancellable = true
|
||||
)
|
||||
private void injectHandleStatusRequest(ServerboundStatusRequestPacket arg, CallbackInfo ci) {
|
||||
ServerStatusEvent.StatusRequestEvent event = new ServerStatusEvent.StatusRequestEvent(ChatUtils.mojangToAdventure(status.description()));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
|
||||
if (event.getNewStatus() != null) {
|
||||
ci.cancel();
|
||||
this.connection.send(new ClientboundStatusResponsePacket(
|
||||
new ServerStatus(ChatUtils.adventureToMojang(
|
||||
event.getNewStatus()),
|
||||
status.players(),
|
||||
status.version(),
|
||||
status.favicon(),
|
||||
status.enforcesSecureChat(),
|
||||
status.isModded()
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
import com.hypherionmc.craterlib.CraterConstants;
|
||||
import com.hypherionmc.craterlib.core.networking.PacketRegistry;
|
||||
import com.hypherionmc.craterlib.core.networking.data.PacketContext;
|
||||
import com.hypherionmc.craterlib.core.networking.data.PacketHolder;
|
||||
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||
import com.hypherionmc.craterlib.nojang.network.BridgedFriendlyByteBuf;
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.LogicalSide;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
||||
import net.neoforged.neoforge.network.registration.IPayloadRegistrar;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||
*/
|
||||
public class CraterNeoForgeNetworkHandler extends PacketRegistry {
|
||||
|
||||
private final Map<Class<?>, NeoForgePacketContainer> PACKETS = new HashMap<>();
|
||||
|
||||
public CraterNeoForgeNetworkHandler(PacketSide side) {
|
||||
super(side);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void register(final RegisterPayloadHandlerEvent event) {
|
||||
if (!PACKETS.isEmpty()) {
|
||||
PACKETS.forEach((type, container) -> {
|
||||
final IPayloadRegistrar registrar = event.registrar(container.packetId().getNamespace());
|
||||
registrar.common(
|
||||
container.packetId(),
|
||||
container.decoder(),
|
||||
container.handler());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> void registerPacket(PacketHolder<T> container) {
|
||||
if (PACKETS.get(container.messageType()) == null) {
|
||||
var packetContainer = new NeoForgePacketContainer<>(
|
||||
container.messageType(),
|
||||
container.type().toMojang(),
|
||||
this.mojangEncoder(container.encoder()),
|
||||
decoder(this.mojangDecoder(container.decoder())),
|
||||
buildHandler(container.handler())
|
||||
);
|
||||
|
||||
PACKETS.put(container.messageType(), packetContainer);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> FriendlyByteBuf.Reader<NeoForgePacket<T>> decoder(Function<FriendlyByteBuf, T> decoder) {
|
||||
return (buf -> {
|
||||
T packet = decoder.apply(buf);
|
||||
return new NeoForgePacket<T>(PACKETS.get(packet.getClass()), packet);
|
||||
});
|
||||
}
|
||||
|
||||
public <T> void sendToServer(T packet) {
|
||||
this.sendToServer(packet, false);
|
||||
}
|
||||
|
||||
public <T> void sendToServer(T packet, boolean ignoreCheck) {
|
||||
NeoForgePacketContainer<T> container = PACKETS.get(packet.getClass());
|
||||
try {
|
||||
PacketDistributor.SERVER.noArg().send(new NeoForgePacket<>(container, packet));
|
||||
} catch (Throwable t) {
|
||||
CraterConstants.LOG.error("{} packet not registered on the client, this is needed.", packet.getClass(), t);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void sendToClient(T packet, BridgedPlayer player) {
|
||||
NeoForgePacketContainer<T> container = PACKETS.get(packet.getClass());
|
||||
try {
|
||||
if (player.getConnection() == null)
|
||||
return;
|
||||
|
||||
if (player.getConnection().isConnected(container.packetId())) {
|
||||
PacketDistributor.PLAYER.with(player.toMojangServerPlayer()).send(new NeoForgePacket<>(container, packet));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
CraterConstants.LOG.error("{} packet not registered on the server, this is needed.", packet.getClass(), t);
|
||||
}
|
||||
}
|
||||
|
||||
private <T, K extends NeoForgePacket<T>> IPayloadHandler<K> buildHandler(Consumer<PacketContext<T>> handler) {
|
||||
return (payload, ctx) -> {
|
||||
try {
|
||||
PacketSide side = ctx.flow().getReceptionSide().equals(LogicalSide.SERVER) ? PacketSide.SERVER : PacketSide.CLIENT;
|
||||
Player player = ctx.player().orElse(null);
|
||||
handler.accept(new PacketContext<>(BridgedPlayer.of(player), payload.packet(), side));
|
||||
} catch (Throwable t) {
|
||||
CraterConstants.LOG.error("Error handling packet: {} -> ", payload.packet().getClass(), t);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private <T> Function<FriendlyByteBuf, T> mojangDecoder(Function<BridgedFriendlyByteBuf, T> handler) {
|
||||
return (byteBuf) -> handler.apply(BridgedFriendlyByteBuf.of(byteBuf));
|
||||
}
|
||||
|
||||
private <T> BiConsumer<T, FriendlyByteBuf> mojangEncoder(BiConsumer<T, BridgedFriendlyByteBuf> handler) {
|
||||
return (t, byteBuf) -> handler.accept(t, BridgedFriendlyByteBuf.of(byteBuf));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,21 @@
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
/**
|
||||
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||
*/
|
||||
public record NeoForgePacket<T>(NeoForgePacketContainer<T> container, T packet) implements CustomPacketPayload {
|
||||
|
||||
@Override
|
||||
public void write(FriendlyByteBuf buff) {
|
||||
container().encoder().accept(packet(), buff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation id() {
|
||||
return container().packetId();
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadHandler;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* Based on https://github.com/mysticdrew/common-networking/tree/1.20.4
|
||||
*/
|
||||
public record NeoForgePacketContainer<T>(Class<T> messageType,
|
||||
ResourceLocation packetId,
|
||||
BiConsumer<T, FriendlyByteBuf> encoder,
|
||||
FriendlyByteBuf.Reader<NeoForgePacket<T>> decoder,
|
||||
IPayloadHandler<NeoForgePacket<T>> handler) { }
|
@@ -0,0 +1,33 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[1,)"
|
||||
license = "MIT"
|
||||
issueTrackerURL = "https://github.com/firstdarkdev/craterLib/issues"
|
||||
|
||||
[[mods]]
|
||||
modId = "${mod_id}"
|
||||
version = "${version}"
|
||||
displayName = "${mod_name}"
|
||||
displayURL = "https://modrinth.com/mod/craterlib"
|
||||
logoFile = "craterlib_logo.png"
|
||||
#credits="Thanks for this example mod goes to Java"
|
||||
authors = "${mod_author}, Zenith"
|
||||
description = '''
|
||||
A library mod used by First Dark Development and HypherionSA Mods
|
||||
'''
|
||||
displayTest = "NONE"
|
||||
|
||||
[[dependencies.${ mod_id }]]
|
||||
modId = "neoforge"
|
||||
type="required"
|
||||
required=true
|
||||
versionRange = "[20.4,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.${ mod_id }]]
|
||||
modId = "minecraft"
|
||||
type="required"
|
||||
required=true
|
||||
versionRange = "[1.20.4,1.20.5)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.client.NeoForgeClientHelper
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.NeoForgeCommonHelper
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.NeoForgeCompatHelper
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.NeoForgeLoaderHelper
|
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.hypherionmc.craterlib.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
"ConfigScreenHandlerMixin"
|
||||
],
|
||||
"server": [
|
||||
"ServerGamePacketListenerImplMixin",
|
||||
"ServerStatusPacketListenerMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 48 KiB |
@@ -61,11 +61,9 @@ tasks.assemble {
|
||||
|
||||
publisher {
|
||||
apiKeys {
|
||||
modrinth(System.getenv("MODRINTH_TOKEN"))
|
||||
nightbloom(System.getenv("PLATFORM_KEY"))
|
||||
}
|
||||
|
||||
setModrinthID(modrinth_id)
|
||||
setNightbloomID("craterlib")
|
||||
setVersionType("alpha")
|
||||
setChangelog(rootProject.file("changelog.md"))
|
||||
|
@@ -1,7 +1,7 @@
|
||||
**New Features**:
|
||||
|
||||
- Paper Support. Currently only available on Modrinth and NightBloom
|
||||
- Added API's for working with FTB Ranks and LuckPerms groups
|
||||
- Paper Support. Currently only available on [NightBloom](https://nightbloom.cc/project/craterlib/files?loader=paper)
|
||||
- Added APIs for working with FTB Ranks and LuckPerms groups
|
||||
|
||||
**Bug Fixes**:
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
* Class containing references to all available discord event handles.
|
||||
* Registering a handler is optional, and non-assigned handlers will be ignored
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordEventHandlers extends Structure {
|
||||
|
||||
// Callback for when the RPC was initialized successfully
|
||||
|
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author HypherionSA
|
||||
* Java Wrapper of the Discord-RPC Library
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DiscordRPC extends Library {
|
||||
|
||||
DiscordRPC INSTANCE = Native.load("discord-rpc", DiscordRPC.class);
|
||||
|
@@ -13,6 +13,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class reprenting a Discord RPC activity
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordRichPresence extends Structure {
|
||||
|
||||
// First line of text on the RPC
|
||||
|
@@ -9,6 +9,7 @@ import java.util.List;
|
||||
* @author HypherionSA
|
||||
* Class representing the Discord User
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordUser extends Structure {
|
||||
|
||||
// The User ID of the User
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the Discord RPC disconnects
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DisconnectedCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC ran into an error
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ErroredCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone was approved to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone requests to join your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface JoinRequestCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -7,6 +7,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when the RPC has connected successfully
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface ReadyCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import com.sun.jna.Callback;
|
||||
* @author HypherionSA
|
||||
* Callback for when someone is requesting to spectate your game
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface SpectateGameCallback extends Callback {
|
||||
|
||||
/**
|
||||
|
@@ -9,6 +9,7 @@ import java.io.Serializable;
|
||||
* Helper class to add Buttons to Discord Rich Presence
|
||||
* This can not be used with Join/Spectate
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class RPCButton implements Serializable {
|
||||
|
||||
// The label of the button
|
||||
|
@@ -61,11 +61,9 @@ tasks.assemble {
|
||||
|
||||
publisher {
|
||||
apiKeys {
|
||||
modrinth(System.getenv("MODRINTH_TOKEN"))
|
||||
nightbloom(System.getenv("PLATFORM_KEY"))
|
||||
}
|
||||
|
||||
setModrinthID(modrinth_id)
|
||||
setNightbloomID("craterlib")
|
||||
setVersionType("alpha")
|
||||
setChangelog(rootProject.file("changelog.md"))
|
||||
|
@@ -1,7 +1,7 @@
|
||||
**New Features**:
|
||||
|
||||
- Paper Support. Currently only available on Modrinth and NightBloom
|
||||
- Added API's for working with FTB Ranks and LuckPerms groups
|
||||
- Paper Support. Currently only available on [NightBloom](https://nightbloom.cc/project/craterlib/files?loader=paper)
|
||||
- Added APIs for working with FTB Ranks and LuckPerms groups
|
||||
|
||||
**Bug Fixes**:
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
* Class containing references to all available discord event handles.
|
||||
* Registering a handler is optional, and non-assigned handlers will be ignored
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DiscordEventHandlers extends Structure {
|
||||
|
||||
// Callback for when the RPC was initialized successfully
|
||||
|
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author HypherionSA
|
||||
* Java Wrapper of the Discord-RPC Library
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public interface DiscordRPC extends Library {
|
||||
|
||||
DiscordRPC INSTANCE = Native.load("discord-rpc", DiscordRPC.class);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user