Skip to content

Commit bd94632

Browse files
authored
Deduplicate adapter fields into superclass (#2967)
Move common adapter fields into supertype
1 parent 9eafbf1 commit bd94632

File tree

5 files changed

+17
-36
lines changed

5 files changed

+17
-36
lines changed

worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightFaweAdapter.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
117117
}
118118
}
119119

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

130122
public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
131-
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R2.PaperweightAdapter();
123+
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R2.PaperweightAdapter());
132124
}
133125

134126
public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {

worldedit-bukkit/adapters/adapter-1_20_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R3/PaperweightFaweAdapter.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
117117
}
118118
}
119119

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

130122
public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
131-
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R3.PaperweightAdapter();
123+
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R3.PaperweightAdapter());
132124
}
133125

134126
public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {

worldedit-bukkit/adapters/adapter-1_20_5/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R4/PaperweightFaweAdapter.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
126126
}
127127
}
128128

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

139131
public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
140-
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter();
132+
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_20_R4.PaperweightAdapter());
141133
}
142134

143135
public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {

worldedit-bukkit/adapters/adapter-1_21/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_21_R1/PaperweightFaweAdapter.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,10 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
126126
}
127127
}
128128

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

139131
public PaperweightFaweAdapter() throws NoSuchFieldException, NoSuchMethodException {
140-
this.parent = new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter();
132+
super(new com.sk89q.worldedit.bukkit.adapter.ext.fawe.v1_21_R1.PaperweightAdapter());
141133
}
142134

143135
public Function<BlockEntity, FaweCompoundTag> blockEntityToCompoundTag() {

worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/FaweAdapter.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
import com.sk89q.worldedit.EditSession;
55
import com.sk89q.worldedit.bukkit.BukkitAdapter;
66
import com.sk89q.worldedit.bukkit.BukkitWorld;
7+
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
78
import com.sk89q.worldedit.math.BlockVector3;
9+
import com.sk89q.worldedit.registry.state.Property;
810
import com.sk89q.worldedit.util.TreeGenerator;
911
import org.bukkit.Material;
1012
import org.bukkit.TreeType;
1113
import org.bukkit.World;
1214
import org.bukkit.block.BlockState;
1315

1416
import java.util.List;
17+
import java.util.Map;
1518

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

27+
protected final BukkitImplAdapter<TAG> parent;
28+
protected char[] ibdToStateOrdinal = null;
29+
protected int[] ordinalToIbdID = null;
30+
protected boolean initialised = false;
31+
protected Map<String, List<Property<?>>> allBlockProperties = null;
32+
33+
protected FaweAdapter(final BukkitImplAdapter<TAG> parent) {
34+
this.parent = parent;
35+
}
36+
2437
@Override
2538
public boolean generateTree(
2639
final TreeGenerator.TreeType treeType,

0 commit comments

Comments
 (0)