Skip to content

Commit

Permalink
Deduplicate adapter fields into superclass (#2967)
Browse files Browse the repository at this point in the history
Move common adapter fields into supertype
  • Loading branch information
SirYwell authored Nov 4, 2024
1 parent 9eafbf1 commit bd94632
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
}

private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R2.PaperweightAdapter parent;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
private final PaperweightMapChunkUtil mapUtil = new PaperweightMapChunkUtil();
private char[] ibdToStateOrdinal = null;
private int[] ordinalToIbdID = null;
private boolean initialised = false;
private Map<String, List<Property<?>>> allBlockProperties = null;

public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R2.PaperweightAdapter();
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R2.PaperweightAdapter());
}

public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
}

private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R3.PaperweightAdapter parent;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
private final PaperweightMapChunkUtil mapUtil = new PaperweightMapChunkUtil();
private char[] ibdToStateOrdinal = null;
private int[] ordinalToIbdID = null;
private boolean initialised = false;
private Map<String, List<Property<?>>> allBlockProperties = null;

public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R3.PaperweightAdapter();
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R3.PaperweightAdapter());
}

public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
}

private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter parent;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
private final PaperweightMapChunkUtil mapUtil = new PaperweightMapChunkUtil();
private char[] ibdToStateOrdinal = null;
private int[] ordinalToIbdID = null;
private boolean initialised = false;
private Map<String, List<Property<?>>> allBlockProperties = null;

public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter();
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter());
}

public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
}
}

private final com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter parent;
// ------------------------------------------------------------------------
// Code that may break between versions of Minecraft
// ------------------------------------------------------------------------
private final PaperweightMapChunkUtil mapUtil = new PaperweightMapChunkUtil();
private char[] ibdToStateOrdinal = null;
private int[] ordinalToIbdID = null;
private boolean initialised = false;
private Map<String, List<Property<?>>> allBlockProperties = null;

public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter();
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter());
}

public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.TreeGenerator;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.block.BlockState;

import java.util.List;
import java.util.Map;

/**
* A base class for version-specific implementations of the BukkitImplAdapter
Expand All @@ -21,6 +24,16 @@
*/
public abstract class FaweAdapter<TAG, SERVER_LEVEL> extends CachedBukkitAdapter implements IDelegateBukkitImplAdapter<TAG> {

protected final BukkitImplAdapter<TAG> parent;
protected char[] ibdToStateOrdinal = null;
protected int[] ordinalToIbdID = null;
protected boolean initialised = false;
protected Map<String, List<Property<?>>> allBlockProperties = null;

protected FaweAdapter(final BukkitImplAdapter<TAG> parent) {
this.parent = parent;
}

@Override
public boolean generateTree(
final TreeGenerator.TreeType treeType,
Expand Down

0 comments on commit bd94632

Please sign in to comment.