Skip to content

Commit

Permalink
Remove calio reload - invalid bytecode????
Browse files Browse the repository at this point in the history
  • Loading branch information
Dueris committed Sep 1, 2024
1 parent 321e7ed commit 033f91f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.objectweb.asm.tree.analysis.BasicValue;
import org.objectweb.asm.tree.analysis.SimpleVerifier;
import org.objectweb.asm.util.CheckClassAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -32,6 +34,7 @@

public class MixinPlugin {

private static final Logger log = LoggerFactory.getLogger(MixinPlugin.class);
@Getter
private final ObfMap obfMap;
@Getter
Expand Down Expand Up @@ -134,10 +137,10 @@ public void write(int b) throws IOException {
CheckClassAdapter.verify(classReader, getClass().getClassLoader().getParent(), false, printWriter);
}
if (MixBukkit.SAFE_MODE) {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[!] Failed to load mixin: " + plugin.name() + ":" + namespace + ", Reason: Invalid Bytecode, and safe-mode is on");
MixinPlugin.log.info("{}[!] Failed to load mixin: {}:{}, Reason: Invalid Bytecode, and safe-mode is on", ChatColor.RED, plugin.name(), namespace);
return false;
} else {
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "[?] Mixin: " + plugin.name() + ":" + namespace + " has failed the verification, and it might crash your server! Be careful.");
MixinPlugin.log.info("{}[?] Mixin: {}:{} has failed the verification, and it might crash your server! Be careful.", ChatColor.YELLOW, plugin.name(), namespace);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,46 +53,46 @@ public static void tickHook(MinecraftServer server, BooleanSupplier shouldKeepTi
calio.shutdown();
}

@Inject(method = "reloadResources", locator = At.Value.HEAD)
public static void calio$reload(@NotNull MinecraftServer server, Collection<String> dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause, CallbackInfo info) {
CraftCalio calio = buildNewCalio();
CalioRegistry.INSTANCE.clearRegistries();
RecipePower.recipeMapping.clear();
RecipePower.tags.clear();
for (ServerPlayer player : server.getPlayerList().players) {
PlayerPowerRepository repository = PlayerPowerRepository.getOrCreateRepo(player);
String saveData = repository.serializePowers(new CompoundTag()).toString();
player.getBukkitEntity().getPersistentDataContainer()
.set(identifier(), PersistentDataType.STRING, saveData);
PowerHolderComponent.unloadPowers(player.getBukkitEntity());
repository.clearData();
}

try {
PlayerPowerRepository.clearRepository();
OriginsPaper.reload();
parse(server, calio);
BuiltinRegistry.bootstrap();

OriginsPaper.getRegistry().retrieve(Registries.POWER).values().forEach(powerType -> {
OriginsPaper.getPlugin().getServer().getPluginManager().registerEvents(powerType, OriginsPaper.getPlugin());
});
} catch (Throwable e) {
throw new RuntimeException("Unable to run calio reload!", e);
}

for (ServerPlayer player : server.getPlayerList().players) {
PlayerPowerRepository repository = PlayerPowerRepository.getOrCreateRepo(player);
repository.readPowers(
player.getBukkitEntity().getPersistentDataContainer()
.get(identifier(), PersistentDataType.STRING)
);

PowerHolderComponent.loadPowers(player.getBukkitEntity());
}

Bukkit.updateRecipes();
}
// @Inject(method = "reloadResources", locator = At.Value.HEAD)
// public static void calio$reload(@NotNull MinecraftServer server, Collection<String> dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause, CallbackInfo info) {
// CraftCalio calio = buildNewCalio();
// CalioRegistry.INSTANCE.clearRegistries();
// RecipePower.recipeMapping.clear();
// RecipePower.tags.clear();
// for (ServerPlayer player : server.getPlayerList().players) {
// PlayerPowerRepository repository = PlayerPowerRepository.getOrCreateRepo(player);
// String saveData = repository.serializePowers(new CompoundTag()).toString();
// player.getBukkitEntity().getPersistentDataContainer()
// .set(identifier(), PersistentDataType.STRING, saveData);
// PowerHolderComponent.unloadPowers(player.getBukkitEntity());
// repository.clearData();
// }
//
// try {
// PlayerPowerRepository.clearRepository();
// OriginsPaper.reload();
// parse(server, calio);
// BuiltinRegistry.bootstrap();
//
// OriginsPaper.getRegistry().retrieve(Registries.POWER).values().forEach(powerType -> {
// OriginsPaper.getPlugin().getServer().getPluginManager().registerEvents(powerType, OriginsPaper.getPlugin());
// });
// } catch (Throwable e) {
// throw new RuntimeException("Unable to run calio reload!", e);
// }
//
// for (ServerPlayer player : server.getPlayerList().players) {
// PlayerPowerRepository repository = PlayerPowerRepository.getOrCreateRepo(player);
// repository.readPowers(
// player.getBukkitEntity().getPersistentDataContainer()
// .get(identifier(), PersistentDataType.STRING)
// );
//
// PowerHolderComponent.loadPowers(player.getBukkitEntity());
// }
//
// Bukkit.updateRecipes();
// }

private static void parse(@NotNull MinecraftServer server, CraftCalio calio) {
PackRepositoryMixin.getAvailable(server.getPackRepository()).forEach((id, pack) -> {
Expand Down

0 comments on commit 033f91f

Please sign in to comment.