Merge pull request 'Enable native trail wear on the Guild's existing worlds' (#547) from dev/MC:release/guild-trails-20261124 into main
This commit is contained in:
commit
79ca68144b
3 changed files with 27 additions and 2 deletions
|
|
@ -22,7 +22,7 @@ General:
|
|||
step-decay-fraction: 0.1
|
||||
strict-links: false
|
||||
trails-particle: NAUTILUS
|
||||
enabled-worlds: [lobby, world, world_the_end]
|
||||
enabled-worlds: [guild_lobby, lobby_base, lobby_base_the_end, lobby_base_nether]
|
||||
Messages:
|
||||
SendDenyMessage: false
|
||||
Interval: 10
|
||||
|
|
|
|||
25
tools/PatchGuildTrails.java
Normal file
25
tools/PatchGuildTrails.java
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import java.nio.file.*;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import org.objectweb.asm.*;
|
||||
import org.objectweb.asm.tree.*;
|
||||
|
||||
/** Install the same native Trails provenance bridge in the existing Guild plugin. */
|
||||
public final class PatchGuildTrails {
|
||||
public static void main(String[] args)throws Exception{
|
||||
Path input=Path.of(args[0]),classes=Path.of(args[1]),output=Path.of(args[2]);
|
||||
if(Files.exists(output)||!HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(Files.readAllBytes(input))).equals("a1fe48e2ab4f7963287b2fb2b1b1db8c83d8de3338d793c29b66814fcd1e631f"))throw new IllegalStateException("Unexpected Guild plugin");
|
||||
var entries=new LinkedHashMap<String,byte[]>();try(var zip=new ZipInputStream(Files.newInputStream(input))){for(ZipEntry e;(e=zip.getNextEntry())!=null;)if(entries.put(e.getName(),zip.readAllBytes())!=null)throw new IllegalStateException("Duplicate entry");}
|
||||
var original=new LinkedHashMap<>(entries);String main="com/example/dunelobby/DuneLobby.class",bridge="com/example/duneterrain/TrailsBridge";
|
||||
if(entries.containsKey(bridge+".class"))throw new IllegalStateException("Already installed");
|
||||
var type=new ClassNode();new ClassReader(entries.get(main)).accept(type,0);var methods=new HashMap<String,byte[]>();for(var method:type.methods)methods.put(method.name+method.desc,PatchArrakisEcology.methodBytes(method));
|
||||
int hooks=0;for(var method:type.methods)if(method.name.equals("onEnable")&&method.desc.equals("()V")){var hook=new InsnList();hook.add(new VarInsnNode(Opcodes.ALOAD,0));hook.add(new MethodInsnNode(Opcodes.INVOKESTATIC,bridge,"start","(Lorg/bukkit/plugin/Plugin;)V",false));method.instructions.insert(hook);method.maxStack=Math.max(method.maxStack,1);hooks++;}
|
||||
if(hooks!=1)throw new IllegalStateException("Activation hook changed");var writer=new ClassWriter(0);type.accept(writer);entries.put(main,writer.toByteArray());
|
||||
var verify=new ClassNode();new ClassReader(entries.get(main)).accept(verify,0);for(var method:verify.methods)if(!method.name.equals("onEnable")&&!Arrays.equals(methods.get(method.name+method.desc),PatchArrakisEcology.methodBytes(method)))throw new IllegalStateException("Unrelated method changed");
|
||||
entries.put(bridge+".class",Files.readAllBytes(classes.resolve(bridge+".class")));entries.put("plugin.yml",new String(entries.get("plugin.yml"),java.nio.charset.StandardCharsets.UTF_8).replace("version: 1.0.1-exchange","version: 1.0.1-exchange-trails1").getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
for(var entry:original.entrySet())if(!Set.of(main,"plugin.yml").contains(entry.getKey())&&!Arrays.equals(entry.getValue(),entries.get(entry.getKey())))throw new IllegalStateException("Unrelated archive entry changed");
|
||||
try(var zip=new ZipOutputStream(Files.newOutputStream(output,StandardOpenOption.CREATE_NEW))){for(var entry:entries.entrySet()){var next=new ZipEntry(entry.getKey());next.setTime(0);zip.putNextEntry(next);zip.write(entry.getValue());zip.closeEntry();}}
|
||||
System.out.println("Guild plugin preserved; SHA256 "+HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(Files.readAllBytes(output))));
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ const profiles={
|
|||
kaitain:{worlds:['kaitain'],links:[['GRASS_BLOCK','DIRT_PATH'],['DIRT','DIRT_PATH'],['COARSE_DIRT','DIRT_PATH'],['SAND','SANDSTONE']]},
|
||||
giedi_prime:{worlds:['giedi_prime','giedi_prime_nether'],links:[['DIRT','DIRT_PATH'],['COARSE_DIRT','DIRT_PATH'],['DEEPSLATE','COBBLED_DEEPSLATE'],['NETHERRACK','CRACKED_NETHER_BRICKS'],['SOUL_SAND','SOUL_SOIL'],['BASALT','SMOOTH_BASALT'],['BLACKSTONE','POLISHED_BLACKSTONE']]},
|
||||
sigma_draconis_iv:{worlds:['sigma_draconis_iv','sigma_draconis_iv_the_end'],links:[['SNOW_BLOCK','PACKED_ICE'],['ICE','PACKED_ICE'],['PODZOL','DIRT_PATH'],['DIRT','DIRT_PATH'],['COARSE_DIRT','DIRT_PATH'],['RED_SAND','RED_SANDSTONE'],['END_STONE','END_STONE_BRICKS']]},
|
||||
lobby:{worlds:['lobby','world','world_the_end'],links:[['END_STONE','END_STONE_BRICKS'],['GRASS_BLOCK','DIRT_PATH'],['DIRT','DIRT_PATH']]}
|
||||
lobby:{worlds:['guild_lobby','lobby_base','lobby_base_the_end','lobby_base_nether'],links:[['END_STONE','END_STONE_BRICKS'],['GRASS_BLOCK','DIRT_PATH'],['DIRT','DIRT_PATH']]}
|
||||
};
|
||||
for(const [name,profile] of Object.entries(profiles)){
|
||||
const links=[...profile.links,...common];
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff