Replace all use of CommonUtil with LogicUtil where appropriate
Signed-off-by: Irmo van den Berge <irmo.vandenberge@mailbox.org>
This commit is contained in:
1 parent
dbd131a284
commit
0075578446
40 files changed
+94
-80
No files matched your search
@@ -1,7 +1,7 @@
|
||||
package com.bergerkiller.bukkit.common;
|
||||
|
||||
import com.bergerkiller.bukkit.common.conversion.Conversion;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.ParseUtil;
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ public class TypedValue<T> {
|
||||
*/
|
||||
public void parseSet(String text) {
|
||||
if (this.type == boolean.class || this.type == Boolean.class) {
|
||||
value = CommonUtil.unsafeCast(ParseUtil.parseBool(text));
|
||||
value = LogicUtil.unsafeCast(ParseUtil.parseBool(text));
|
||||
} else {
|
||||
value = Conversion.convert(text, type, value);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.EntityEffect;
|
||||
import org.bukkit.Location;
|
||||
@@ -290,7 +291,7 @@ public class ExtendedEntity<T extends org.bukkit.entity.Entity> {
|
||||
* @return the NMS entity handle, cast to the given type
|
||||
*/
|
||||
public <H> H getHandle(Class<H> type) {
|
||||
return CommonUtil.tryCast(handle.getRaw(), type);
|
||||
return LogicUtil.tryCast(handle.getRaw(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -686,7 +687,7 @@ public class ExtendedEntity<T extends org.bukkit.entity.Entity> {
|
||||
*/
|
||||
@Deprecated
|
||||
public Player getPlayerPassenger() {
|
||||
return CommonUtil.tryCast(getPassenger(), Player.class);
|
||||
return LogicUtil.tryCast(getPassenger(), Player.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -159,11 +159,11 @@ abstract class ChunkFutureProviderImpl implements ChunkFutureProvider, Listener,
|
||||
Chain chain = entries.get(key);
|
||||
Entry entry;
|
||||
if (chain == null) {
|
||||
chain = new Chain(this, key, world, mode, passChunkToFuture, CommonUtil.unsafeCast(future));
|
||||
chain = new Chain(this, key, world, mode, passChunkToFuture, LogicUtil.unsafeCast(future));
|
||||
entry = chain.first;
|
||||
entries.put(key, chain);
|
||||
} else {
|
||||
entry = chain.add(world, mode, passChunkToFuture, CommonUtil.unsafeCast(future));
|
||||
entry = chain.add(world, mode, passChunkToFuture, LogicUtil.unsafeCast(future));
|
||||
}
|
||||
|
||||
// This may randomly instantly remove it if the operation was done asynchronously!
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.bergerkiller.bukkit.common.Common;
|
||||
import com.bergerkiller.bukkit.common.cloud.captions.BKCommonLibCaptionKeys;
|
||||
import com.bergerkiller.bukkit.common.resources.ResourceKey;
|
||||
import com.bergerkiller.bukkit.common.resources.SoundEffect;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.resources.MinecraftKeyHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.sounds.SoundEffectHandle;
|
||||
import com.bergerkiller.mountiplex.reflection.declarations.ClassResolver;
|
||||
@@ -160,7 +160,7 @@ public class SoundEffectParser<C> implements ArgumentParser<C, ResourceKey<Sound
|
||||
},
|
||||
(Consumer<BrigadierMappingBuilder<?, ?>>) builder -> {
|
||||
builderTo.invoke(builder, (Function<Object, Object>) o -> createResourceLocationArgument.invoke(null));
|
||||
builder.suggestedBy(CommonUtil.unsafeCast(suggestionProvider));
|
||||
builder.suggestedBy(LogicUtil.unsafeCast(suggestionProvider));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
|
||||
/**
|
||||
* Simple cache of objects. Each cache consists of an allocator method, which creates
|
||||
@@ -26,8 +27,8 @@ public final class ObjectCache<T> {
|
||||
private static final ObjectCache<?> HASHMAP_CACHE = create(HashMap::new, HashMap::clear);
|
||||
|
||||
private ObjectCache(Supplier<?> allocator, Consumer<?> resetMethod) {
|
||||
_allocator = CommonUtil.unsafeCast(allocator);
|
||||
_resetMethod = CommonUtil.unsafeCast(resetMethod);
|
||||
_allocator = LogicUtil.unsafeCast(allocator);
|
||||
_resetMethod = LogicUtil.unsafeCast(resetMethod);
|
||||
_root = new Entry<T>(this, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public class YamlDeserializer {
|
||||
try {
|
||||
this.preParser.open(reader);
|
||||
Output output = new Output();
|
||||
output.root = CommonUtil.tryCast(this.yaml.load(this.preParser), Map.class, Collections.emptyMap());
|
||||
output.root = LogicUtil.tryCast(this.yaml.load(this.preParser), Map.class, Collections.emptyMap());
|
||||
output.headers = new HashMap<YamlPath, String>(this.preParser.headers);
|
||||
if (this.preParser.mainHeader.length() > 0) {
|
||||
output.headers.put(YamlPath.ROOT, this.preParser.mainHeader.toString());
|
||||
@@ -490,7 +490,7 @@ public class YamlDeserializer {
|
||||
public Object construct(Map<?, ?> mapping) {
|
||||
String serialized_type = LogicUtil.applyIfNotNull(mapping.get(ConfigurationSerialization.SERIALIZED_TYPE_KEY), Object::toString, null);
|
||||
if (serialized_type != null) {
|
||||
Map<String, Object> typed = CommonUtil.unsafeCast(mapping);
|
||||
Map<String, Object> typed = LogicUtil.unsafeCast(mapping);
|
||||
|
||||
// If any entries in the mapping uses non-String keys, convert those to a String
|
||||
// Almost all the time this operation is unneeded, so we do a detection step first
|
||||
@@ -555,7 +555,7 @@ public class YamlDeserializer {
|
||||
|
||||
private void initConstructor(SafeConstructor ctor) {
|
||||
try {
|
||||
Map<Tag, Construct> yamlConstructors = CommonUtil.unsafeCast(SafeField.get(ctor, "yamlConstructors", Map.class));
|
||||
Map<Tag, Construct> yamlConstructors = LogicUtil.unsafeCast(SafeField.get(ctor, "yamlConstructors", Map.class));
|
||||
|
||||
// Replace the 'Map' constructor with one that handles our custom type de-serialization logic
|
||||
// The original 'Map' constructor is re-purposed to construct the map itself (super call)
|
||||
|
||||
+2
-2
@@ -377,7 +377,7 @@ public abstract class EntityNetworkController<T extends CommonEntity<?>> extends
|
||||
if (this.entry != null) {
|
||||
EntityTrackerEntryHook oldHook = EntityTypingHandler.INSTANCE.getEntityTrackerEntryHook(this.entry.getRaw());
|
||||
if (oldHook != null && oldHook.getController() == this) {
|
||||
EntityNetworkController<CommonEntity<?>> defaultController = CommonUtil.unsafeCast(new DefaultEntityNetworkController());
|
||||
EntityNetworkController<CommonEntity<?>> defaultController = LogicUtil.unsafeCast(new DefaultEntityNetworkController());
|
||||
defaultController.bind(this.entity, this.entry.getRaw());
|
||||
}
|
||||
}
|
||||
@@ -887,7 +887,7 @@ public abstract class EntityNetworkController<T extends CommonEntity<?>> extends
|
||||
ArrayList<org.bukkit.entity.Entity> old_passengers_bu = new ArrayList<org.bukkit.entity.Entity>(old_passengers);
|
||||
|
||||
// Update the raw List. This prevents converters being used in the final List.
|
||||
List<Object> newList = CommonUtil.unsafeCast(EntityTrackerEntryStateHandle.T.opt_passengers.raw.get(state.getRaw()));
|
||||
List<Object> newList = LogicUtil.unsafeCast(EntityTrackerEntryStateHandle.T.opt_passengers.raw.get(state.getRaw()));
|
||||
if (newList instanceof ArrayList) {
|
||||
newList.clear();
|
||||
} else {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.bergerkiller.bukkit.common.internal.CommonBootstrap;
|
||||
import com.bergerkiller.bukkit.common.nbt.CommonTag;
|
||||
import com.bergerkiller.bukkit.common.protocol.CommonPacket;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.bukkit.common.wrappers.*;
|
||||
import com.bergerkiller.mountiplex.conversion.Converter;
|
||||
import com.bergerkiller.mountiplex.conversion.type.InputConverter;
|
||||
@@ -93,8 +94,8 @@ public class Conversion {
|
||||
public static final InputConverter<BlockState> toBlockState = getConverterTo(BlockState.class);
|
||||
public static final InputConverter<CommonTag> toCommonTag = getConverterTo(CommonTag.class);
|
||||
public static final InputConverter<DataWatcher> toDataWatcher = getConverterTo(DataWatcher.class);
|
||||
public static final InputConverter<DataWatcher.Key<?>> toDataWatcherKey = CommonUtil.unsafeCast(getConverterTo(DataWatcher.Key.class));
|
||||
public static final InputConverter<DataWatcher.Item<?>> toDataWatcherItem = CommonUtil.unsafeCast(getConverterTo(DataWatcher.Item.class));
|
||||
public static final InputConverter<DataWatcher.Key<?>> toDataWatcherKey = LogicUtil.unsafeCast(getConverterTo(DataWatcher.Key.class));
|
||||
public static final InputConverter<DataWatcher.Item<?>> toDataWatcherItem = LogicUtil.unsafeCast(getConverterTo(DataWatcher.Item.class));
|
||||
public static final InputConverter<ItemStack> toItemStack = getConverterTo(ItemStack.class);
|
||||
public static final InputConverter<Material> toMaterial = getConverterTo(Material.class);
|
||||
public static final InputConverter<Inventory> toInventory = getConverterTo(Inventory.class);
|
||||
@@ -108,7 +109,7 @@ public class Conversion {
|
||||
public static final InputConverter<PlayerAbilities> toPlayerAbilities = getConverterTo(PlayerAbilities.class);
|
||||
public static final InputConverter<EntityTracker> toEntityTracker = getConverterTo(EntityTracker.class);
|
||||
public static final InputConverter<LongHashSet> toLongHashSet = getConverterTo(LongHashSet.class);
|
||||
public static final InputConverter<IntHashMap<Object>> toIntHashMap = CommonUtil.unsafeCast(getConverterTo(IntHashMap.class));
|
||||
public static final InputConverter<IntHashMap<Object>> toIntHashMap = LogicUtil.unsafeCast(getConverterTo(IntHashMap.class));
|
||||
public static final InputConverter<BlockData> toBlockData = getConverterTo(BlockData.class);
|
||||
public static final InputConverter<ChunkSection> toChunkSection = getConverterTo(ChunkSection.class);
|
||||
public static final InputConverter<PotionEffectType> toPotionEffectType = getConverterTo(PotionEffectType.class);
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.bergerkiller.bukkit.common.protocol.PacketType;
|
||||
import com.bergerkiller.bukkit.common.resources.DimensionType;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.EntityUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.PacketUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.PlayerUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.WorldUtil;
|
||||
@@ -128,7 +129,7 @@ public class CommonEntity<T extends org.bukkit.entity.Entity> extends ExtendedEn
|
||||
}
|
||||
EntityTrackerEntryHook hook = EntityTypingHandler.INSTANCE.getEntityTrackerEntryHook(entityTrackerEntry);
|
||||
if (hook != null) {
|
||||
return CommonUtil.unsafeCast(hook.getController());
|
||||
return LogicUtil.unsafeCast(hook.getController());
|
||||
}
|
||||
if (EntityTrackerEntryHandle.T.isType(entityTrackerEntry)) {
|
||||
result = new DefaultEntityNetworkController();
|
||||
@@ -827,7 +828,7 @@ public class CommonEntity<T extends org.bukkit.entity.Entity> extends ExtendedEn
|
||||
* failed/entity is invalid
|
||||
*/
|
||||
public static <T extends org.bukkit.entity.Entity, C extends CommonEntity<? extends T>> C get(T entity, Class<C> type) {
|
||||
return CommonUtil.tryCast(get(entity), type);
|
||||
return LogicUtil.tryCast(get(entity), type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bergerkiller.bukkit.common.events.map;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
|
||||
/**
|
||||
* Event broadcast by widgets, allowing other widgets to be informed of status changes
|
||||
@@ -50,7 +50,7 @@ public class MapStatusEvent {
|
||||
* @return argument cast to the type
|
||||
*/
|
||||
public <T> T getArgument(Class<T> type) {
|
||||
return CommonUtil.tryCast(this.argument, type);
|
||||
return LogicUtil.tryCast(this.argument, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.bergerkiller.bukkit.common.Common;
|
||||
import com.bergerkiller.bukkit.common.conversion.Conversion;
|
||||
import com.bergerkiller.bukkit.common.conversion.type.HandleConversion;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.server.dedicated.DedicatedPlayerListHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.server.level.EntityPlayerHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.server.level.WorldServerHandle;
|
||||
@@ -110,7 +111,7 @@ public class CommonNMS {
|
||||
}
|
||||
|
||||
public static Object getRawHandle(org.bukkit.entity.Entity e, Template.Class<?> type) {
|
||||
return CommonUtil.tryCast(HandleConversion.toEntityHandle(e), type.getType());
|
||||
return LogicUtil.tryCast(HandleConversion.toEntityHandle(e), type.getType());
|
||||
}
|
||||
|
||||
public static <T extends Template.Handle> T getHandle(org.bukkit.entity.Entity e, Template.Class<T> type) {
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class IBlockDataToMaterialData {
|
||||
|
||||
java.lang.reflect.Field f = craftLegacyClass.getDeclaredField("dataToMaterial");
|
||||
f.setAccessible(true);
|
||||
iblockdataToMaterialdata_map = CommonUtil.unsafeCast(f.get(null));
|
||||
iblockdataToMaterialdata_map = LogicUtil.unsafeCast(f.get(null));
|
||||
f.setAccessible(false);
|
||||
} catch (Throwable t) {
|
||||
Logging.LOGGER_REFLECTION.log(Level.SEVERE, "Failed to initialize CraftLegacy dataToMaterial", t);
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.material.MaterialData;
|
||||
@@ -203,7 +204,7 @@ public class MaterialDataToIBlockData {
|
||||
}
|
||||
|
||||
Material legacyType = IBlockDataToMaterialData.toLegacy(materialdata.getItemType());
|
||||
IBlockDataBuilder<MaterialData> builder = CommonUtil.unsafeCast(iblockdataBuilders.get(legacyType));
|
||||
IBlockDataBuilder<MaterialData> builder = LogicUtil.unsafeCast(iblockdataBuilders.get(legacyType));
|
||||
try {
|
||||
IBlockDataHandle blockData = IBlockDataHandle.createHandle(craftBukkitgetIBlockData.invoke(null, materialdata));
|
||||
if (builder != null) {
|
||||
|
||||
+3
-3
@@ -57,13 +57,13 @@ public class CreaturePreSpawnHandler_Spigot extends CreaturePreSpawnHandler {
|
||||
}
|
||||
|
||||
if (CommonBootstrap.evaluateMCVersion(">=", "1.17")) {
|
||||
cpsChunkGeneratorField = CommonUtil.unsafeCast(SafeField.create(ChunkProviderServerHandle.T.getType(),
|
||||
cpsChunkGeneratorField = LogicUtil.unsafeCast(SafeField.create(ChunkProviderServerHandle.T.getType(),
|
||||
"generator", CommonUtil.getClass("net.minecraft.world.level.chunk.ChunkGenerator")));
|
||||
} else if (CommonBootstrap.evaluateMCVersion(">=", "1.9")) {
|
||||
cpsChunkGeneratorField = CommonUtil.unsafeCast(SafeField.create(ChunkProviderServerHandle.T.getType(),
|
||||
cpsChunkGeneratorField = LogicUtil.unsafeCast(SafeField.create(ChunkProviderServerHandle.T.getType(),
|
||||
"chunkGenerator", CommonUtil.getClass("net.minecraft.world.level.chunk.ChunkGenerator")));
|
||||
} else {
|
||||
cpsChunkGeneratorField = CommonUtil.unsafeCast(SafeField.create(ChunkProviderServerHandle.T.getType(),
|
||||
cpsChunkGeneratorField = LogicUtil.unsafeCast(SafeField.create(ChunkProviderServerHandle.T.getType(),
|
||||
"chunkProvider", CommonUtil.getClass("net.minecraft.world.level.chunk.IChunkProvider")));
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -89,7 +90,7 @@ class EntityAddRemoveHandler_1_14_to_1_16_5 extends EntityAddRemoveHandler {
|
||||
|
||||
{
|
||||
String fieldName = Resolver.resolveFieldName(WorldServerHandle.T.getType(), "entitiesToAdd");
|
||||
this.entitiesToAddField = CommonUtil.unsafeCast(SafeField.create(WorldServerHandle.T.getType(), fieldName, Queue.class));
|
||||
this.entitiesToAddField = LogicUtil.unsafeCast(SafeField.create(WorldServerHandle.T.getType(), fieldName, Queue.class));
|
||||
}
|
||||
|
||||
// Tuinity support: 'loadedEntities' field of WorldServer
|
||||
|
||||
+3
-2
@@ -12,6 +12,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
@@ -820,7 +821,7 @@ class EntityAddRemoveHandler_1_17 extends EntityAddRemoveHandler {
|
||||
|
||||
@Override
|
||||
public void enable(final EntityAddRemoveHandler_1_17 handler, CommonPlugin plugin) {
|
||||
Class<? extends Event> entitiesLoadEventType = CommonUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesLoadEvent"));
|
||||
Class<? extends Event> entitiesLoadEventType = LogicUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesLoadEvent"));
|
||||
Bukkit.getPluginManager().registerEvent(entitiesLoadEventType, this, EventPriority.LOWEST, new EventExecutor() {
|
||||
@Override
|
||||
public void execute(Listener listener, Event event) throws EventException {
|
||||
@@ -828,7 +829,7 @@ class EntityAddRemoveHandler_1_17 extends EntityAddRemoveHandler {
|
||||
}
|
||||
}, plugin);
|
||||
|
||||
Class<? extends Event> entitiesUnloadEventType = CommonUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesUnloadEvent"));
|
||||
Class<? extends Event> entitiesUnloadEventType = LogicUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesUnloadEvent"));
|
||||
Bukkit.getPluginManager().registerEvent(entitiesUnloadEventType, this, EventPriority.LOWEST, new EventExecutor() {
|
||||
@Override
|
||||
public void execute(Listener listener, Event event) throws EventException {
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
@@ -639,7 +640,7 @@ class EntityAddRemoveHandler_1_19_2_Paper_ChunkSystem extends EntityAddRemoveHan
|
||||
|
||||
@Override
|
||||
public void enable(final EntityAddRemoveHandler_1_19_2_Paper_ChunkSystem handler, CommonPlugin plugin) {
|
||||
Class<? extends Event> entitiesLoadEventType = CommonUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesLoadEvent"));
|
||||
Class<? extends Event> entitiesLoadEventType = LogicUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesLoadEvent"));
|
||||
Bukkit.getPluginManager().registerEvent(entitiesLoadEventType, this, EventPriority.LOWEST, new EventExecutor() {
|
||||
@Override
|
||||
public void execute(Listener listener, Event event) throws EventException {
|
||||
@@ -647,7 +648,7 @@ class EntityAddRemoveHandler_1_19_2_Paper_ChunkSystem extends EntityAddRemoveHan
|
||||
}
|
||||
}, plugin);
|
||||
|
||||
Class<? extends Event> entitiesUnloadEventType = CommonUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesUnloadEvent"));
|
||||
Class<? extends Event> entitiesUnloadEventType = LogicUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesUnloadEvent"));
|
||||
Bukkit.getPluginManager().registerEvent(entitiesUnloadEventType, this, EventPriority.LOWEST, new EventExecutor() {
|
||||
@Override
|
||||
public void execute(Listener listener, Event event) throws EventException {
|
||||
|
||||
+5
-5
@@ -4,6 +4,7 @@ import com.bergerkiller.bukkit.common.Common;
|
||||
import com.bergerkiller.bukkit.common.conversion.type.HandleConversion;
|
||||
import com.bergerkiller.bukkit.common.internal.CommonPlugin;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.WorldUtil;
|
||||
import com.bergerkiller.bukkit.common.wrappers.EntityTracker;
|
||||
import com.bergerkiller.generated.net.minecraft.server.level.EntityTrackerEntryHandle;
|
||||
@@ -27,7 +28,6 @@ import org.bukkit.event.world.ChunkEvent;
|
||||
import org.bukkit.plugin.EventExecutor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
@@ -116,7 +116,7 @@ class EntityAddRemoveHandler_1_21_Paper_ChunkSystem extends EntityAddRemoveHandl
|
||||
}
|
||||
|
||||
public void enable(CommonPlugin plugin) {
|
||||
Class<? extends EntityEvent> entitiesLoadEventType = CommonUtil.unsafeCast(CommonUtil.getClass("com.destroystokyo.paper.event.entity.EntityAddToWorldEvent"));
|
||||
Class<? extends EntityEvent> entitiesLoadEventType = LogicUtil.unsafeCast(CommonUtil.getClass("com.destroystokyo.paper.event.entity.EntityAddToWorldEvent"));
|
||||
try {
|
||||
addToWorldGetWorldMethod.init(entitiesLoadEventType.getMethod("getWorld"));
|
||||
} catch (Throwable t) {
|
||||
@@ -129,7 +129,7 @@ class EntityAddRemoveHandler_1_21_Paper_ChunkSystem extends EntityAddRemoveHandl
|
||||
}
|
||||
}, plugin);
|
||||
|
||||
Class<? extends EntityEvent> entitiesUnloadEventType = CommonUtil.unsafeCast(CommonUtil.getClass("com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent"));
|
||||
Class<? extends EntityEvent> entitiesUnloadEventType = LogicUtil.unsafeCast(CommonUtil.getClass("com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent"));
|
||||
try {
|
||||
removeFromWorldGetWorldMethod.init(entitiesUnloadEventType.getMethod("getWorld"));
|
||||
} catch (Throwable t) {
|
||||
@@ -531,7 +531,7 @@ class EntityAddRemoveHandler_1_21_Paper_ChunkSystem extends EntityAddRemoveHandl
|
||||
|
||||
@Override
|
||||
public void enable(final EntityAddRemoveHandler_1_21_Paper_ChunkSystem handler, CommonPlugin plugin) {
|
||||
Class<? extends Event> entitiesLoadEventType = CommonUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesLoadEvent"));
|
||||
Class<? extends Event> entitiesLoadEventType = LogicUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesLoadEvent"));
|
||||
Bukkit.getPluginManager().registerEvent(entitiesLoadEventType, this, EventPriority.LOWEST, new EventExecutor() {
|
||||
@Override
|
||||
public void execute(Listener listener, Event event) throws EventException {
|
||||
@@ -539,7 +539,7 @@ class EntityAddRemoveHandler_1_21_Paper_ChunkSystem extends EntityAddRemoveHandl
|
||||
}
|
||||
}, plugin);
|
||||
|
||||
Class<? extends Event> entitiesUnloadEventType = CommonUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesUnloadEvent"));
|
||||
Class<? extends Event> entitiesUnloadEventType = LogicUtil.unsafeCast(CommonUtil.getClass("org.bukkit.event.world.EntitiesUnloadEvent"));
|
||||
Bukkit.getPluginManager().registerEvent(entitiesUnloadEventType, this, EventPriority.LOWEST, new EventExecutor() {
|
||||
@Override
|
||||
public void execute(Listener listener, Event event) throws EventException {
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -78,9 +79,9 @@ class EntityAddRemoveHandler_1_8_to_1_13_2 extends EntityAddRemoveHandler {
|
||||
}
|
||||
|
||||
if (CommonBootstrap.evaluateMCVersion(">=", "1.13")) {
|
||||
accessListField = CommonUtil.unsafeCast(SafeField.create(WorldHandle.T.getType(), "v", List.class));
|
||||
accessListField = LogicUtil.unsafeCast(SafeField.create(WorldHandle.T.getType(), "v", List.class));
|
||||
} else {
|
||||
accessListField = CommonUtil.unsafeCast(SafeField.create(WorldHandle.T.getType(), "u", List.class));
|
||||
accessListField = LogicUtil.unsafeCast(SafeField.create(WorldHandle.T.getType(), "u", List.class));
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import java.util.Scanner;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
@@ -176,7 +177,7 @@ class EntityMoveHandler_1_13 extends EntityMoveHandler {
|
||||
|
||||
public HandlerLogic() throws Throwable {
|
||||
// Turn Stream<VoxelShape> into Stream<VoxelShapeHandle>
|
||||
streamConverter = CommonUtil.unsafeCast(Conversion.find(
|
||||
streamConverter = LogicUtil.unsafeCast(Conversion.find(
|
||||
TypeDeclaration.createGeneric(Stream.class, VoxelShapeHandle.T.getType()),
|
||||
TypeDeclaration.createGeneric(Stream.class, VoxelShapeHandle.class)));
|
||||
|
||||
|
||||
+2
-2
@@ -6,12 +6,12 @@ import java.util.Scanner;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import com.bergerkiller.bukkit.common.Common;
|
||||
import com.bergerkiller.bukkit.common.internal.CommonBootstrap;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.FaceUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.MathUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.world.phys.shapes.VoxelShapeHandle;
|
||||
@@ -169,7 +169,7 @@ class EntityMoveHandler_1_14 extends EntityMoveHandler {
|
||||
|
||||
public HandlerLogic() throws Throwable {
|
||||
// Turn Stream<VoxelShape> into Stream<VoxelShapeHandle>
|
||||
streamConverter = CommonUtil.unsafeCast(Conversion.find(
|
||||
streamConverter = LogicUtil.unsafeCast(Conversion.find(
|
||||
TypeDeclaration.createGeneric(Stream.class, VoxelShapeHandle.T.getType()),
|
||||
TypeDeclaration.createGeneric(Stream.class, VoxelShapeHandle.class)));
|
||||
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@ package com.bergerkiller.bukkit.common.internal.logic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.bergerkiller.bukkit.common.Common;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.mountiplex.conversion.Conversion;
|
||||
import com.bergerkiller.mountiplex.conversion.Converter;
|
||||
import com.bergerkiller.mountiplex.reflection.declarations.Template;
|
||||
@@ -20,7 +20,7 @@ class ItemVariantListHandler_1_12_1 extends ItemVariantListHandler {
|
||||
|
||||
@Override
|
||||
public void enable() throws Throwable {
|
||||
converter = CommonUtil.unsafeCast(Conversion.find(TypeDeclaration.parse("net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>"),
|
||||
converter = LogicUtil.unsafeCast(Conversion.find(TypeDeclaration.parse("net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>"),
|
||||
TypeDeclaration.createGeneric(List.class, ItemStack.class)));
|
||||
if (converter == null) {
|
||||
throw new IllegalStateException("Converter from NonNullList<ItemStack> to List<bukkit.ItemStack> not found!");
|
||||
|
||||
+4
-3
@@ -6,6 +6,7 @@ import java.util.logging.Level;
|
||||
import com.bergerkiller.bukkit.common.Logging;
|
||||
import com.bergerkiller.bukkit.common.conversion.type.WrapperConversion;
|
||||
import com.bergerkiller.bukkit.common.nbt.CommonTagCompound;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.mountiplex.reflection.ClassHook;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@@ -60,7 +61,7 @@ class PlayerFileDataHandler_1_16_to_1_21_5 extends PlayerFileDataHandler {
|
||||
String fieldName = CommonBootstrap.evaluateMCVersion(">=", "1.17") ? "playerIo" : "playerFileData";
|
||||
Class<?> playerFileDataType = CommonUtil.getClass("net.minecraft.world.level.storage.WorldNBTStorage");
|
||||
String realFieldName = Resolver.resolveFieldName(PlayerListHandle.T.getType(), fieldName);
|
||||
playerListFileDataField = CommonUtil.unsafeCast(SafeField.create(PlayerListHandle.T.getType(), realFieldName, playerFileDataType).getFastField());
|
||||
playerListFileDataField = LogicUtil.unsafeCast(SafeField.create(PlayerListHandle.T.getType(), realFieldName, playerFileDataType).getFastField());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,7 +170,7 @@ class PlayerFileDataHandler_1_16_to_1_21_5 extends PlayerFileDataHandler {
|
||||
@HookMethod("public abstract java.util.Optional<net.minecraft.nbt.NBTTagCompound> load(net.minecraft.world.entity.player.EntityHuman paramEntityHuman)")
|
||||
public java.util.Optional<Object> loadOpt(Object entityHuman) {
|
||||
if (this.controller != null) {
|
||||
Player player = CommonUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
Player player = LogicUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
if (player != null) {
|
||||
CommonTagCompound compound = null;
|
||||
try {
|
||||
@@ -193,7 +194,7 @@ class PlayerFileDataHandler_1_16_to_1_21_5 extends PlayerFileDataHandler {
|
||||
@HookMethod("public abstract void save(net.minecraft.world.entity.player.EntityHuman paramEntityHuman)")
|
||||
public void save(Object entityHuman) {
|
||||
if (this.controller != null) {
|
||||
Player player = CommonUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
Player player = LogicUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
if (player != null) {
|
||||
try {
|
||||
this.controller.onSave(player);
|
||||
|
||||
+4
-3
@@ -7,6 +7,7 @@ import com.bergerkiller.bukkit.common.conversion.type.HandleConversion;
|
||||
import com.bergerkiller.bukkit.common.conversion.type.WrapperConversion;
|
||||
import com.bergerkiller.bukkit.common.nbt.CommonTagCompound;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.server.players.PlayerListHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.util.ProblemReporterHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.world.level.storage.ValueInputHandle;
|
||||
@@ -68,7 +69,7 @@ class PlayerFileDataHandler_1_21_6 extends PlayerFileDataHandler {
|
||||
String fieldName = "playerIo";
|
||||
Class<?> playerFileDataType = CommonUtil.getClass("net.minecraft.world.level.storage.WorldNBTStorage");
|
||||
String realFieldName = Resolver.resolveFieldName(PlayerListHandle.T.getType(), fieldName);
|
||||
playerListFileDataField = CommonUtil.unsafeCast(SafeField.create(PlayerListHandle.T.getType(), realFieldName, playerFileDataType).getFastField());
|
||||
playerListFileDataField = LogicUtil.unsafeCast(SafeField.create(PlayerListHandle.T.getType(), realFieldName, playerFileDataType).getFastField());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,7 +215,7 @@ class PlayerFileDataHandler_1_21_6 extends PlayerFileDataHandler {
|
||||
@HookMethod("public java.util.Optional<ValueInput> load(EntityHuman entityhuman, ProblemReporter problemreporter)")
|
||||
public java.util.Optional<Object> load(Object entityHuman, Object problemReporter) {
|
||||
if (this.controller != null) {
|
||||
Player player = CommonUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
Player player = LogicUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
if (player != null) {
|
||||
CommonTagCompound compound = null;
|
||||
try {
|
||||
@@ -237,7 +238,7 @@ class PlayerFileDataHandler_1_21_6 extends PlayerFileDataHandler {
|
||||
@HookMethod("public abstract void save(net.minecraft.world.entity.player.EntityHuman paramEntityHuman)")
|
||||
public void save(Object entityHuman) {
|
||||
if (this.controller != null) {
|
||||
Player player = CommonUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
Player player = LogicUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
if (player != null) {
|
||||
try {
|
||||
this.controller.onSave(player);
|
||||
|
||||
+4
-3
@@ -6,6 +6,7 @@ import java.util.logging.Level;
|
||||
import com.bergerkiller.bukkit.common.Logging;
|
||||
import com.bergerkiller.bukkit.common.conversion.type.WrapperConversion;
|
||||
import com.bergerkiller.bukkit.common.nbt.CommonTagCompound;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.mountiplex.reflection.ClassHook;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@@ -46,7 +47,7 @@ class PlayerFileDataHandler_1_8_to_1_15_2 extends PlayerFileDataHandler {
|
||||
}
|
||||
|
||||
Class<?> playerFileDataType = CommonUtil.getClass("net.minecraft.world.level.storage.IPlayerFileData");
|
||||
playerListFileDataField = CommonUtil.unsafeCast(SafeField.create(PlayerListHandle.T.getType(), "playerFileData", playerFileDataType).getFastField());
|
||||
playerListFileDataField = LogicUtil.unsafeCast(SafeField.create(PlayerListHandle.T.getType(), "playerFileData", playerFileDataType).getFastField());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,7 +139,7 @@ class PlayerFileDataHandler_1_8_to_1_15_2 extends PlayerFileDataHandler {
|
||||
@HookMethod("public abstract net.minecraft.nbt.NBTTagCompound load(net.minecraft.world.entity.player.EntityHuman paramEntityHuman)")
|
||||
public Object load(Object entityHuman) {
|
||||
if (this.controller != null) {
|
||||
Player player = CommonUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
Player player = LogicUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
if (player != null) {
|
||||
CommonTagCompound compound = null;
|
||||
try {
|
||||
@@ -155,7 +156,7 @@ class PlayerFileDataHandler_1_8_to_1_15_2 extends PlayerFileDataHandler {
|
||||
@HookMethod("public abstract void save(net.minecraft.world.entity.player.EntityHuman paramEntityHuman)")
|
||||
public void save(Object entityHuman) {
|
||||
if (this.controller != null) {
|
||||
Player player = CommonUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
Player player = LogicUtil.tryCast(WrapperConversion.toEntity(entityHuman), Player.class);
|
||||
if (player != null) {
|
||||
try {
|
||||
this.controller.onSave(player);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle;
|
||||
import com.bergerkiller.mountiplex.conversion.Conversion;
|
||||
import com.bergerkiller.mountiplex.conversion.type.DuplexConverter;
|
||||
@@ -16,7 +17,7 @@ import com.bergerkiller.mountiplex.conversion.util.ConvertingList;
|
||||
*/
|
||||
public class VoxelShapeProxy {
|
||||
public static final VoxelShapeProxy EMPTY = new VoxelShapeProxy(Collections.emptyList());
|
||||
private static final DuplexConverter<Object, AxisAlignedBBHandle> toAABBHandle = CommonUtil.unsafeCast(Conversion.findDuplex(
|
||||
private static final DuplexConverter<Object, AxisAlignedBBHandle> toAABBHandle = LogicUtil.unsafeCast(Conversion.findDuplex(
|
||||
CommonUtil.getClass("net.minecraft.world.phys.AxisAlignedBB"), AxisAlignedBBHandle.class));
|
||||
private final List<AxisAlignedBBHandle> _aabb;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.bergerkiller.bukkit.common.BlockLocation;
|
||||
import com.bergerkiller.bukkit.common.bases.IntVector3;
|
||||
import com.bergerkiller.bukkit.common.config.TempFileOutputStream;
|
||||
import com.bergerkiller.bukkit.common.conversion.Conversion;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.bukkit.common.wrappers.ChatText;
|
||||
import com.bergerkiller.generated.net.minecraft.nbt.NBTBaseHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.nbt.NBTCompressedStreamToolsHandle;
|
||||
@@ -695,7 +695,7 @@ public class CommonTagCompound extends CommonTag implements Map<String, CommonTa
|
||||
* @return Wrapper class suitable for the given handle
|
||||
*/
|
||||
public static CommonTagCompound create(Object handle) {
|
||||
return CommonUtil.tryCast(CommonTag.create(handle), CommonTagCompound.class);
|
||||
return LogicUtil.tryCast(CommonTag.create(handle), CommonTagCompound.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.bergerkiller.bukkit.common.nbt;
|
||||
|
||||
import com.bergerkiller.bukkit.common.collections.CollectionBasics;
|
||||
import com.bergerkiller.bukkit.common.conversion.Conversion;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.nbt.NBTBaseHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.nbt.NBTTagListHandle;
|
||||
@@ -419,7 +418,7 @@ public class CommonTagList extends CommonTag implements List<CommonTag> {
|
||||
* @return Wrapper class suitable for the given handle
|
||||
*/
|
||||
public static CommonTagList create(Object handle) {
|
||||
return CommonUtil.tryCast(CommonTag.create(handle), CommonTagList.class);
|
||||
return LogicUtil.tryCast(CommonTag.create(handle), CommonTagList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -201,7 +201,7 @@ public class BlockUtil extends MaterialUtil {
|
||||
* casting failed
|
||||
*/
|
||||
public static <T> T getData(org.bukkit.block.Block block, Class<T> type) {
|
||||
return CommonUtil.tryCast(getData(block), type);
|
||||
return LogicUtil.tryCast(getData(block), type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -478,7 +478,7 @@ public class BlockUtil extends MaterialUtil {
|
||||
* possible
|
||||
*/
|
||||
public static <T extends BlockState> T getState(org.bukkit.block.Block block, Class<T> type) {
|
||||
return CommonUtil.tryCast(getState(block), type);
|
||||
return LogicUtil.tryCast(getState(block), type);
|
||||
}
|
||||
|
||||
public static org.bukkit.material.Rails getRails(org.bukkit.block.Block railsblock) {
|
||||
|
||||
@@ -251,7 +251,7 @@ public class CommonUtil {
|
||||
* @return unmodifiable collection of online players
|
||||
*/
|
||||
public static Collection<Player> getOnlinePlayers() {
|
||||
return CommonUtil.unsafeCast(Bukkit.getOnlinePlayers());
|
||||
return LogicUtil.unsafeCast(Bukkit.getOnlinePlayers());
|
||||
// return CommonNMS.getPlayerList().getPlayers();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class EntityUtil extends EntityPropertyUtil {
|
||||
* @return the found Entity, or null if not found
|
||||
*/
|
||||
public static <T extends org.bukkit.entity.Entity> T getEntity(org.bukkit.World world, UUID uid, Class<T> type) {
|
||||
return CommonUtil.tryCast(getEntity(world, uid), type);
|
||||
return LogicUtil.tryCast(getEntity(world, uid), type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -499,7 +499,7 @@ public class LogicUtil {
|
||||
* @throws IllegalArgumentException If the type has no clone method
|
||||
*/
|
||||
public static <T> UnaryOperator<T> findCloneMethod(Class<T> type) {
|
||||
return CommonUtil.unsafeCast(synchronizeCopyOnWrite(LogicUtil.class, () -> _cloneMethodCache, type, (map, inType) -> map.get(inType), (map, inType) -> {
|
||||
return unsafeCast(synchronizeCopyOnWrite(LogicUtil.class, () -> _cloneMethodCache, type, (map, inType) -> map.get(inType), (map, inType) -> {
|
||||
// Generate new operator
|
||||
Method cloneMethod;
|
||||
try {
|
||||
@@ -766,7 +766,7 @@ public class LogicUtil {
|
||||
return Arrays.copyOf(input, len - 1);
|
||||
}
|
||||
|
||||
T[] rval = CommonUtil.unsafeCast(createArray(input.getClass().getComponentType(), input.length - 1));
|
||||
T[] rval = LogicUtil.unsafeCast(createArray(input.getClass().getComponentType(), input.length - 1));
|
||||
System.arraycopy(input, 0, rval, 0, index);
|
||||
System.arraycopy(input, index + 1, rval, index, input.length - index - 1);
|
||||
return rval;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bergerkiller.bukkit.common.wrappers;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.mountiplex.reflection.declarations.Template;
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public class BasicWrapper<T extends Template.Handle> {
|
||||
* fails
|
||||
*/
|
||||
public <H> H getRawHandle(Class<H> type) {
|
||||
return CommonUtil.tryCast(handle.getRaw(), type);
|
||||
return LogicUtil.tryCast(handle.getRaw(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ public class BasicWrapper<T extends Template.Handle> {
|
||||
*/
|
||||
@Deprecated
|
||||
public <H> H getHandle(Class<H> type) {
|
||||
return CommonUtil.tryCast(handle.getRaw(), type);
|
||||
return LogicUtil.tryCast(handle.getRaw(), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.bergerkiller.bukkit.common.wrappers;
|
||||
import java.util.Map;
|
||||
|
||||
import com.bergerkiller.bukkit.common.inventory.CommonItemStack;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -16,7 +17,6 @@ import com.bergerkiller.bukkit.common.bases.IntVector3;
|
||||
import com.bergerkiller.bukkit.common.collections.BlockFaceSet;
|
||||
import com.bergerkiller.bukkit.common.resources.ResourceKey;
|
||||
import com.bergerkiller.bukkit.common.resources.SoundEffect;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.MaterialUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.world.level.block.BlockHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.world.phys.AxisAlignedBBHandle;
|
||||
@@ -384,7 +384,7 @@ public abstract class BlockData extends BlockDataRegistry {
|
||||
* @return Block Material Data, or null on failure
|
||||
*/
|
||||
public final <T extends MaterialData> T newMaterialData(Class<T> type) {
|
||||
return CommonUtil.tryCast(newMaterialData(), type);
|
||||
return LogicUtil.tryCast(newMaterialData(), type);
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
@@ -658,7 +658,7 @@ class BlockDataImpl extends BlockData {
|
||||
|
||||
@Override
|
||||
public <T extends Comparable<?>> T getState(BlockDataStateKey<T> stateKey) {
|
||||
return CommonUtil.unsafeCast(this.data.get(stateKey.getBackingHandle()));
|
||||
return LogicUtil.unsafeCast(this.data.get(stateKey.getBackingHandle()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.bergerkiller.bukkit.common.wrappers;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.world.level.block.state.properties.IBlockStateHandle;
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ public class BlockDataStateKey<T extends Comparable<?>> extends BlockState<T> {
|
||||
* @return values
|
||||
*/
|
||||
public Collection<T> values() {
|
||||
return CommonUtil.unsafeCast(handle.getValues());
|
||||
return LogicUtil.unsafeCast(handle.getValues());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bergerkiller.bukkit.common.wrappers;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.world.level.block.state.properties.IBlockStateHandle;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -28,7 +28,7 @@ public abstract class BlockState<T extends Comparable<?>> extends BasicWrapper<I
|
||||
* @return values
|
||||
*/
|
||||
public Collection<T> values() {
|
||||
return CommonUtil.unsafeCast(handle.getValues());
|
||||
return LogicUtil.unsafeCast(handle.getValues());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.bergerkiller.bukkit.common.internal.CommonBootstrap;
|
||||
import com.bergerkiller.bukkit.common.internal.CommonCapabilities;
|
||||
import com.bergerkiller.bukkit.common.internal.CommonDisabledEntity;
|
||||
import com.bergerkiller.bukkit.common.math.Quaternion;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.core.Vector3fHandle;
|
||||
import com.bergerkiller.generated.net.minecraft.network.syncher.DataWatcherHandle;
|
||||
@@ -877,7 +876,7 @@ public class DataWatcher extends BasicWrapper<DataWatcherHandle> implements Clon
|
||||
|
||||
if (internalType != null) {
|
||||
if (serializer == null) {
|
||||
serializer = Type.getForType(CommonUtil.unsafeCast(internalType.type));
|
||||
serializer = Type.getForType(LogicUtil.unsafeCast(internalType.type));
|
||||
}
|
||||
|
||||
this._serializer = serializer.setInternalOptional(internalType.optional);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.bergerkiller.bukkit.common.wrappers;
|
||||
import java.util.List;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import com.bergerkiller.generated.net.minecraft.util.IntHashMapHandle;
|
||||
|
||||
/**
|
||||
@@ -96,7 +97,7 @@ public class IntHashMap<T> extends BasicWrapper<IntHashMapHandle> implements Clo
|
||||
* @return list of hashmap entries
|
||||
*/
|
||||
public List<Entry<T>> entries() {
|
||||
return CommonUtil.unsafeCast(this.handle.getEntries());
|
||||
return LogicUtil.unsafeCast(this.handle.getEntries());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,11 +4,11 @@ import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bergerkiller.bukkit.common.utils.LogicUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.bergerkiller.bukkit.common.conversion.Conversion;
|
||||
import com.bergerkiller.bukkit.common.conversion.DuplexConversion;
|
||||
import com.bergerkiller.bukkit.common.utils.CommonUtil;
|
||||
import com.bergerkiller.bukkit.common.wrappers.IntHashMap;
|
||||
|
||||
public class IntHashMapTest {
|
||||
@@ -42,7 +42,7 @@ public class IntHashMapTest {
|
||||
Object handle = DuplexConversion.intHashMap.convertReverse(test);
|
||||
assertNotNull(handle);
|
||||
|
||||
IntHashMap<String> original = CommonUtil.unsafeCast(Conversion.toIntHashMap.convert(handle));
|
||||
IntHashMap<String> original = LogicUtil.unsafeCast(Conversion.toIntHashMap.convert(handle));
|
||||
assertNotNull(original);
|
||||
assertEquals("test_string", original.get(154));
|
||||
|
||||
|
||||
Reference in new issue
Block a user