geforkt von Mirrors/Paper
#1251: Use Java Consumer instead of Bukkit Consumer
By: DerFrZocker <derrieple@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
e903417936
Commit
0b9699cc2e
@ -6,6 +6,7 @@ import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.EnumDirection;
|
||||
@ -213,7 +214,6 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.util.Consumer;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
|
@ -21,6 +21,7 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
@ -137,7 +138,6 @@ import org.bukkit.plugin.messaging.StandardMessenger;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.Consumer;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.StructureSearchResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@ -29,7 +30,6 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.generator.LimitedRegion;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.Consumer;
|
||||
|
||||
public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRegion {
|
||||
|
||||
|
@ -4,9 +4,11 @@ import com.google.common.io.ByteStreams;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
@ -20,6 +22,7 @@ import org.bukkit.plugin.AuthorNagException;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Handle;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
@ -329,6 +332,12 @@ public class Commodore
|
||||
return;
|
||||
}
|
||||
|
||||
if ( owner.startsWith( "org/bukkit" ) && desc.contains( "org/bukkit/util/Consumer" ) )
|
||||
{
|
||||
super.visitMethodInsn( opcode, owner, name, desc.replace( "org/bukkit/util/Consumer", "java/util/function/Consumer" ), itf );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( modern )
|
||||
{
|
||||
if ( owner.equals( "org/bukkit/Material" ) )
|
||||
@ -426,6 +435,35 @@ public class Commodore
|
||||
|
||||
super.visitLdcInsn( value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInvokeDynamicInsn( String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments )
|
||||
{
|
||||
if ( bootstrapMethodHandle.getOwner().equals( "java/lang/invoke/LambdaMetafactory" )
|
||||
&& bootstrapMethodHandle.getName().equals( "metafactory" ) && bootstrapMethodArguments.length == 3 )
|
||||
{
|
||||
Type samMethodType = (Type) bootstrapMethodArguments[ 0 ];
|
||||
Handle implMethod = (Handle) bootstrapMethodArguments[ 1 ];
|
||||
Type instantiatedMethodType = (Type) bootstrapMethodArguments[ 2 ];
|
||||
|
||||
List<Object> newTypes = new ArrayList<>();
|
||||
newTypes.add( samMethodType );
|
||||
|
||||
if ( implMethod.getOwner().startsWith( "org/bukkit" ) && implMethod.getDesc().contains( "org/bukkit/util/Consumer" ) )
|
||||
{
|
||||
implMethod = new Handle( implMethod.getTag(), implMethod.getOwner(), implMethod.getName(),
|
||||
implMethod.getDesc().replace( "org/bukkit/util/Consumer", "java/util/function/Consumer" ), implMethod.isInterface() );
|
||||
}
|
||||
|
||||
newTypes.add( implMethod );
|
||||
newTypes.add( instantiatedMethodType );
|
||||
|
||||
super.visitInvokeDynamicInsn( name, descriptor, bootstrapMethodHandle, newTypes.toArray() );
|
||||
return;
|
||||
}
|
||||
|
||||
super.visitInvokeDynamicInsn( name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments );
|
||||
}
|
||||
};
|
||||
}
|
||||
}, 0 );
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren