Skip to content

Commit

Permalink
✨ code_version.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
kitUIN committed Dec 2, 2024
1 parent 96cc7e4 commit 4a7765c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 53 deletions.
1 change: 1 addition & 0 deletions code_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.11.1
23 changes: 13 additions & 10 deletions fabric/origin/fabric.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ repositories {
url "https://maven.kituin.fun/releases"
}
}
def getVersionFromFile() {
def versionFile = file('../../version.txt')
if (versionFile.exists()) {
return versionFile.text.trim()
} else {
throw new Exception("Version file not found: ${versionFile.absolutePath}") as Throwable
}
}

ext.includeMod = { String localOverrideKey, Object dep ->
File file = file("../.${localOverrideKey}-local");
if (file.exists()) {
Expand All @@ -28,7 +21,17 @@ ext.includeMod = { String localOverrideKey, Object dep ->
}
dependencies.include(dep)
}
def mod_version = getVersionFromFile()
def getVersionFromFile(String f) {
def versionFile = file(f)
if (versionFile.exists()) {
return versionFile.text.trim()
} else {
throw new Exception("Version file not found: ${versionFile.absolutePath}") as Throwable
}
}

def code_version = getVersionFromFile('../../code_version.txt')
def mod_version = getVersionFromFile('../../version.txt')
version = mod_version + "+" + project.minecraft_version + "+fabric"
group = project.maven_group

Expand All @@ -48,7 +51,7 @@ dependencies {
includeMod "fabric-api", fabricApi.module(project.command_api, project.fabric_version)
includeMod "fabric-api", fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version)

include modImplementation("io.github.kituin:ChatImageCode:${project.code_version}")
include modImplementation("io.github.kituin:ChatImageCode:${code_version}")
include modImplementation("io.github.kituin:ActionLib:${project.action_version}-fabric")
modApi("com.terraformersmc:modmenu:${project.modmenu_version}") { transitive false }
}
Expand Down
11 changes: 6 additions & 5 deletions forge/origin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ plugins {

apply plugin: 'org.spongepowered.mixin'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
def getVersionFromFile() {
def versionFile = file('../../version.txt')
def getVersionFromFile(String f) {
def versionFile = file(f)
if (versionFile.exists()) {
return versionFile.text.trim()
} else {
throw new Exception("Version file not found: ${versionFile.absolutePath}") as Throwable
}
}

def mod_version = getVersionFromFile()
def code_version = getVersionFromFile('../../code_version.txt')
def mod_version = getVersionFromFile('../../version.txt')
version = mod_version + "+" + project.minecraft_version + "+forge"

def targetJavaVersion = project.targetJavaVersion.toInteger()
Expand Down Expand Up @@ -166,8 +167,8 @@ dependencies {
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency


implementation "io.github.kituin:ChatImageCode:${project.code_version}"
jarJar(group: 'io.github.kituin', name: 'ChatImageCode', version: "${project.code_version}"){
implementation "io.github.kituin:ChatImageCode:${code_version}"
jarJar(group: 'io.github.kituin', name: 'ChatImageCode', version: "${code_version}"){
jarJar.ranged(it, '[0.9.2,1.0)')
}
jarJar(group: 'io.github.kituin', name: 'ActionLib', version: "${project.action_version}-forge"){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,14 @@ public static void loadFromServer(String url) {
*/
public static void serverFileChannelReceived(#ServerPlayer# player, String res) {
ChatImageIndex title = gson.fromJson(res, ChatImageIndex.class);
HashMap<Integer, String> blocks = SERVER_BLOCK_CACHE.containsKey(title.url) ? SERVER_BLOCK_CACHE.get(title.url) : new HashMap<>();
blocks.put(title.index, res);
SERVER_BLOCK_CACHE.put(title.url, blocks);
FILE_COUNT_MAP.put(title.url, title.total);
HashMap<Integer, String> blocks = SERVER_BLOCK_CACHE.createBlock(title, res);
LOGGER.info("[FileChannel->Server:" + title.index + "/" + title.total + "]" + title.url);
if (title.total == blocks.size()) {
if (USER_CACHE_MAP.containsKey(title.url)) {
// 通知之前请求但是没图片的客户端
List<String> names = USER_CACHE_MAP.get(title.url);
for (String uuid : names) {
FileBackChannel.sendToPlayer(new FileInfoChannelPacket("true->" + title.url), player.server.getPlayerList().getPlayer(UUID.fromString(uuid)));
LOGGER.info("[echo to client(" + uuid + ")]" + title.url);
}
USER_CACHE_MAP.put(title.url, Lists.newArrayList());
List<String> names = SERVER_BLOCK_CACHE.getUsers(title.url);
// 通知之前请求但是没图片的客户端
for (String uuid : names) {
FileBackChannel.sendToPlayer(new FileInfoChannelPacket("true->" + title.url), player.server.getPlayerList().getPlayer(UUID.fromString(uuid)));
LOGGER.info("[echo to client(" + uuid + ")]" + title.url);
}
LOGGER.info("[FileChannel->Server]" + title.url);
}
Expand Down Expand Up @@ -108,28 +102,23 @@ public static void clientFileInfoChannelReceived(String data){
}

public static void serverFileInfoChannelReceived(#ServerPlayer# player, String url) {
if (SERVER_BLOCK_CACHE.containsKey(url) && FILE_COUNT_MAP.containsKey(url)) {
HashMap<Integer, String> list = SERVER_BLOCK_CACHE.get(url);
Integer total = FILE_COUNT_MAP.get(url);
if (total == list.size()) {
// 服务器存在缓存图片,直接发送给客户端
for (Map.Entry<Integer, String> entry : list.entrySet()) {
LOGGER.debug("[GetFileChannel->Client:{}/{}]{}", entry.getKey(), list.size() - 1, url);
DownloadFileChannel.sendToPlayer(new DownloadFileChannelPacket(entry.getValue()), player);
}
LOGGER.info("[GetFileChannel->Client]{}", url);
return;
HashMap<Integer, String> list = SERVER_BLOCK_CACHE.getBlock(url);
if (list != null) {
// 服务器存在缓存图片,直接发送给客户端
for (Map.Entry<Integer, String> entry : list.entrySet()) {
LOGGER.debug("[GetFileChannel->Client:{}/{}]{}", entry.getKey(), list.size() - 1, url);
DownloadFileChannel.sendToPlayer(new DownloadFileChannelPacket(entry.getValue()), player);
}
LOGGER.info("[GetFileChannel->Client]{}", url);
return;
}
//通知客户端无文件
FileBackChannel.sendToPlayer(new FileInfoChannelPacket("null->" + url), player);
LOGGER.error("[GetFileChannel]not found in server:{}", url);
// 记录uuid,后续有文件了推送
List<String> names = USER_CACHE_MAP.containsKey(url) ? USER_CACHE_MAP.get(url) : Lists.newArrayList();
if (player != null) {
names.add(player.getStringUUID());
SERVER_BLOCK_CACHE.tryAddUser(url, player.getStringUUID());
}
USER_CACHE_MAP.put(url, names);
LOGGER.info("[GetFileChannel]记录uuid:{}", player.getStringUUID());
LOGGER.info("[not found in server]{}", url);
}
Expand Down
25 changes: 13 additions & 12 deletions neoforge/origin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,31 @@ plugins {
id 'net.neoforged.gradle.userdev' version '7.0.164'
}

def getVersionFromFile() {
def versionFile = file('../../version.txt')
def getVersionFromFile(String f) {
def versionFile = file(f)
if (versionFile.exists()) {
return versionFile.text.trim()
} else {
throw new Exception("Version file not found: ${versionFile.absolutePath}") as Throwable
}
}

def mod_version = getVersionFromFile()
version = mod_version + "+" + project.minecraft_version + "+neoforge"
def code_version = getVersionFromFile('../../code_version.txt')
def mod_version = getVersionFromFile('../../version.txt')
version = mod_version + "+" + project.minecraft_version + "+neoforge"
group = mod_group_id

repositories {
mavenLocal()
mavenCentral()
flatDir{
flatDir {
dirs 'libs'
}
maven {
url "https://mvn.cloud.alipay.com/nexus/content/repositories/open/"
}

maven{
maven {
url 'https://maven.aliyun.com/nexus/content/groups/public/'
}

Expand All @@ -50,7 +51,7 @@ base {
java.toolchain.languageVersion = JavaLanguageVersion.of(project.targetJavaVersion)

jarJar.enable()
tasks.named ('jarJar') {
tasks.named('jarJar') {
archiveClassifier.set('')
destinationDirectory = file("../../ChatImage-jar/${mod_version}")
}
Expand Down Expand Up @@ -137,12 +138,12 @@ dependencies {

// Example mod dependency using a file as dependency
// implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
implementation "io.github.kituin:ChatImageCode:${project.code_version}"
jarJar(group: 'io.github.kituin', name: 'ChatImageCode', version: "${project.code_version}"){
implementation "io.github.kituin:ChatImageCode:${code_version}"
jarJar(group: 'io.github.kituin', name: 'ChatImageCode', version: "${code_version}") {
jarJar.ranged(it, '[0.9.2,1.0)')
}
implementation "io.github.kituin:ActionLib:${project.action_version}"
jarJar(group: 'io.github.kituin', name: 'ActionLib', version: "${project.action_version}"){
jarJar(group: 'io.github.kituin', name: 'ActionLib', version: "${project.action_version}") {
jarJar.ranged(it, '[1.9.1,2.0)')
}
// Example project dependency using a sister or child project:
Expand Down Expand Up @@ -177,8 +178,8 @@ tasks.withType(ProcessResources).configureEach {
// ELSE
// filesMatching(['META-INF/neoforge.mods.toml']) {
// END IF
expand replaceProperties
}
expand replaceProperties
}
}

// Example configuration to allow publishing using the maven-publish plugin
Expand Down

0 comments on commit 4a7765c

Please sign in to comment.