Skip to content

Commit 9068f75

Browse files
committed
雨屏梦见cb补丁😔
1 parent 9aad505 commit 9068f75

36 files changed

Lines changed: 140 additions & 32 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ build
4545
**/runs/
4646

4747
**/out/
48+
/projects/cb-base/

build.gradle

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import io.codechicken.diffpatch.cli.PatchOperation
2+
3+
import java.nio.file.Paths
14
import java.util.regex.Matcher
25
import java.util.regex.Pattern
36
import net.neoforged.neodev.CheckSplitSources
@@ -51,4 +54,107 @@ sourceSets {
5154
srcDirs = []
5255
}
5356
}
57+
}
58+
59+
tasks.register('copyCB', Copy) {
60+
group = 'neotenet'
61+
62+
from('projects/bukkit/src/main/java') {
63+
exclude 'com/**'
64+
}
65+
from('projects/craftbukkit/src/main/java') {
66+
exclude 'com/**'
67+
}
68+
69+
into 'projects/neotenet/src/main/java'
70+
71+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
72+
}
73+
74+
def rootDir = rootProject.projectDir
75+
76+
tasks.register('prepareCleanCB', Copy) {
77+
group = 'neotenet'
78+
79+
from('projects/bukkit/src/main/java') {
80+
exclude 'com/mojang/**'
81+
}
82+
from('projects/craftbukkit/src/main/java') {
83+
exclude 'com/mojang/**'
84+
}
85+
into 'projects/cb-base/src/main/java'
86+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
87+
}
88+
89+
import io.codechicken.diffpatch.cli.DiffOperation
90+
import io.codechicken.diffpatch.util.Input.MultiInput
91+
import io.codechicken.diffpatch.util.Output.MultiOutput
92+
93+
tasks.register('genCBPatchesJar') {
94+
group = 'neotenet'
95+
dependsOn 'prepareCleanCB'
96+
97+
inputs.dir('projects/cb-base/src/main/java/org/bukkit')
98+
inputs.dir('projects/neotenet/src/main/java/org/bukkit')
99+
outputs.file('projects/neotenet/cb-patches.jar')
100+
101+
doLast {
102+
def baseDir = new File(rootDir, 'projects/cb-base/src/main/java/org/bukkit').toPath()
103+
def modifiedDir = new File(rootDir, 'projects/neotenet/src/main/java/org/bukkit').toPath()
104+
def patchesJar = new File(rootDir, 'projects/neotenet/cb-patches.jar').toPath()
105+
106+
java.nio.file.Files.deleteIfExists(patchesJar)
107+
108+
def builder = DiffOperation.builder()
109+
.logTo(logger::lifecycle)
110+
.baseInput(MultiInput.folder(baseDir))
111+
.changedInput(MultiInput.folder(modifiedDir))
112+
.patchesOutput(MultiOutput.detectedArchive(patchesJar))
113+
.autoHeader(true)
114+
.level(io.codechicken.diffpatch.util.LogLevel.WARN)
115+
.summary(false)
116+
.aPrefix('a/')
117+
.bPrefix('b/')
118+
.lineEnding('\n')
119+
120+
def result = builder.build().operate()
121+
int exit = result.exit
122+
if (exit != 0 && exit != 1) {
123+
throw new RuntimeException("Diffpatch Failed,Code: " + exit)
124+
}
125+
logger.lifecycle('Patched Successful: cb-patches.jar')
126+
}
127+
}
128+
129+
tasks.register('applyCBPatches') {
130+
group = 'neotenet'
131+
dependsOn 'copyCB'
132+
133+
inputs.file('projects/neotenet/cb-patches.jar')
134+
outputs.dir('projects/neotenet/src/main/java/org/bukkit')
135+
136+
doLast {
137+
def patchesJar = new File(rootDir, 'projects/neotenet/cb-patches.jar')
138+
if (!patchesJar.exists()) {
139+
logger.lifecycle('cb-patches.jar None Exist,Skip')
140+
return
141+
}
142+
def baseDir = new File(rootDir, 'projects/cb-base/src/main/java/org/bukkit').toPath()
143+
def targetDir = new File(rootDir, 'projects/neotenet/src/main/java/org/bukkit').toPath()
144+
145+
def builder = PatchOperation.builder()
146+
.logTo(logger::lifecycle)
147+
.baseInput(MultiInput.folder(baseDir))
148+
.patchesInput(MultiInput.detectedArchive(patchesJar.toPath()))
149+
.patchedOutput(MultiOutput.folder(targetDir))
150+
.level(io.codechicken.diffpatch.util.LogLevel.WARN)
151+
.summary(false)
152+
.lineEnding('\n')
153+
154+
def result = builder.build().operate()
155+
if (result.exit != 0 && result.exit != 1) {
156+
throw new RuntimeException("Failed,Code: " + result.exit)
157+
}
158+
logger.lifecycle('Applied Successful')
159+
}
54160
}

projects/neotenet/cb-patches.jar

390 Bytes
Binary file not shown.

projects/neotenet/src/main/java/org/bukkit/craftbukkit/CraftArt.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.bukkit.craftbukkit.registry.CraftOldEnumRegistryItem;
1111
import org.jetbrains.annotations.NotNull;
1212

13+
// ABSTRACT
1314
public class CraftArt extends CraftOldEnumRegistryItem<Art, PaintingVariant> implements Art {
1415

1516
private static int count = 0;

projects/neotenet/src/main/java/org/teneted/neotenet/injection/advancements/AdvancementHolderInjection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ public interface AdvancementHolderInjection {
55
default org.bukkit.advancement.Advancement toBukkit() {
66
throw new IllegalArgumentException("Not implemented");
77
}
8-
}
8+
}

projects/neotenet/src/main/java/org/teneted/neotenet/injection/commands/CommandSourceInjection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ public interface CommandSourceInjection {
77
default org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) {
88
throw new IllegalArgumentException("Not implemented");
99
}
10-
}
10+
}

projects/neotenet/src/main/java/org/teneted/neotenet/injection/commands/CommandSourceStackInjection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ public interface CommandSourceStackInjection {
55
default org.bukkit.command.CommandSender getBukkitSender() {
66
throw new IllegalArgumentException("Not implemented");
77
}
8-
}
8+
}

projects/neotenet/src/main/java/org/teneted/neotenet/injection/commands/CommandsInjection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ default void performPrefixedCommand(CommandSourceStack sender, String command, S
1616
default void performCommand(ParseResults<CommandSourceStack> command, String commandString, String label) {
1717
throw new IllegalArgumentException("Not implemented");
1818
}
19-
}
19+
}

projects/neotenet/src/main/java/org/teneted/neotenet/injection/commands/arguments/EntityArgumentInjection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ public interface EntityArgumentInjection {
99
default EntitySelector parse(StringReader reader, boolean allowSelectors, boolean overridePermissions) throws CommandSyntaxException {
1010
throw new IllegalArgumentException("Not implemented");
1111
}
12-
}
12+
}

projects/neotenet/src/main/java/org/teneted/neotenet/injection/commands/arguments/selector/EntitySelectorParserInjection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ public interface EntitySelectorParserInjection {
88
default EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException {
99
throw new IllegalArgumentException("Not implemented");
1010
}
11-
}
11+
}

0 commit comments

Comments
 (0)