mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-01-30 12:51:17 +08:00
Merge branch 'version/7.2.x'
This commit is contained in:
commit
b4ae41a4b6
4
.github/workflows/codeql-analysis.yml
vendored
4
.github/workflows/codeql-analysis.yml
vendored
@ -25,9 +25,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 17
|
||||
cache: 'gradle'
|
||||
|
13
.github/workflows/gradle.yml
vendored
13
.github/workflows/gradle.yml
vendored
@ -11,18 +11,25 @@ jobs:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v2
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 17
|
||||
cache: 'gradle'
|
||||
distribution: 'temurin'
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build -s
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
name: Archive Reports
|
||||
if: always()
|
||||
with:
|
||||
name: reports for ${{ matrix.os }}
|
||||
path: '**/build/reports/**'
|
||||
- uses: actions/upload-artifact@v3
|
||||
name: Archive Logs
|
||||
if: always()
|
||||
with:
|
||||
name: logs for ${{ matrix.os }}
|
||||
path: '**/*.log'
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -57,11 +58,12 @@
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -361,8 +363,10 @@ public static GameMode adapt(org.bukkit.GameMode gameMode) {
|
||||
return GameModes.get(gameMode.name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
private static final EnumMap<Biome, BiomeType> biomeBiomeTypeCache = new EnumMap<>(Biome.class);
|
||||
private static final Map<BiomeType, Biome> biomeTypeBiomeCache = new HashMap<>();
|
||||
private static final Map<Biome, BiomeType> biomeBiomeTypeCache = Collections.synchronizedMap(
|
||||
new EnumMap<>(Biome.class)
|
||||
);
|
||||
private static final Map<BiomeType, Biome> biomeTypeBiomeCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BiomeType from a Bukkit one.
|
||||
@ -408,8 +412,12 @@ public static org.bukkit.entity.EntityType adapt(EntityType entityType) {
|
||||
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10));
|
||||
}
|
||||
|
||||
private static final EnumMap<Material, BlockType> materialBlockTypeCache = new EnumMap<>(Material.class);
|
||||
private static final EnumMap<Material, ItemType> materialItemTypeCache = new EnumMap<>(Material.class);
|
||||
private static final Map<Material, BlockType> materialBlockTypeCache = Collections.synchronizedMap(
|
||||
new EnumMap<>(Material.class)
|
||||
);
|
||||
private static final Map<Material, ItemType> materialItemTypeCache = Collections.synchronizedMap(
|
||||
new EnumMap<>(Material.class)
|
||||
);
|
||||
|
||||
/**
|
||||
* Converts a Material to a BlockType.
|
||||
@ -435,8 +443,10 @@ public static ItemType asItemType(Material material) {
|
||||
return materialItemTypeCache.computeIfAbsent(material, input -> ItemTypes.get(material.getKey().toString()));
|
||||
}
|
||||
|
||||
private static final Int2ObjectMap<BlockState> blockStateCache = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, BlockState> blockStateStringCache = new HashMap<>();
|
||||
private static final Int2ObjectMap<BlockState> blockStateCache = Int2ObjectMaps.synchronize(
|
||||
new Int2ObjectOpenHashMap<>()
|
||||
);
|
||||
private static final Map<String, BlockState> blockStateStringCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BlockState from a Bukkit BlockData.
|
||||
@ -473,7 +483,7 @@ public static BlockState adapt(BlockData blockData) {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Int2ObjectMap<BlockData> blockDataCache = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<BlockData> blockDataCache = Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>());
|
||||
|
||||
/**
|
||||
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder.
|
||||
|
@ -70,7 +70,7 @@ public BlockArrayClipboard(Region region) {
|
||||
|
||||
@Override
|
||||
public Region getRegion() {
|
||||
return region;
|
||||
return region.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +72,7 @@ public void setInternalId(BlockState blockState, int internalId) {
|
||||
/**
|
||||
* The internal ID of the block state.
|
||||
*/
|
||||
private int internalId = BlockStateIdAccess.invalidId();
|
||||
private volatile int internalId = BlockStateIdAccess.invalidId();
|
||||
|
||||
BlockState(BlockType blockType) {
|
||||
this.blockType = blockType;
|
||||
|
@ -16,7 +16,7 @@
|
||||
val nextMajorMinecraftVersion: String = minecraftVersion.split('.').let { (useless, major) ->
|
||||
"$useless.${major.toInt() + 1}"
|
||||
}
|
||||
val forgeVersion = "41.0.1"
|
||||
val forgeVersion = "41.0.98"
|
||||
|
||||
val apiClasspath = configurations.create("apiClasspath") {
|
||||
isCanBeResolved = true
|
||||
|
@ -54,7 +54,7 @@ public BaseEntity getState() {
|
||||
if (entity == null || entity.isPassenger()) {
|
||||
return null;
|
||||
}
|
||||
ResourceLocation id = ForgeRegistries.ENTITIES.getKey(entity.getType());
|
||||
ResourceLocation id = ForgeRegistries.ENTITY_TYPES.getKey(entity.getType());
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public DataFixer getDataFixer() {
|
||||
|
||||
@Override
|
||||
public boolean isValidMobType(String type) {
|
||||
return net.minecraftforge.registries.ForgeRegistries.ENTITIES.containsKey(new ResourceLocation(type));
|
||||
return net.minecraftforge.registries.ForgeRegistries.ENTITY_TYPES.containsKey(new ResourceLocation(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,7 +89,6 @@
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.forge.ForgeAdapter.adaptPlayer;
|
||||
import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
/**
|
||||
* The Forge implementation of WorldEdit.
|
||||
@ -189,7 +188,7 @@ private void setupRegistries(MinecraftServer server) {
|
||||
}
|
||||
}
|
||||
// Entities
|
||||
for (ResourceLocation name : ForgeRegistries.ENTITIES.getKeys()) {
|
||||
for (ResourceLocation name : ForgeRegistries.ENTITY_TYPES.getKeys()) {
|
||||
if (EntityType.REGISTRY.get(name.toString()) == null) {
|
||||
EntityType.REGISTRY.register(name.toString(), new EntityType(name.toString()));
|
||||
}
|
||||
@ -225,7 +224,7 @@ public void registerCommands(RegisterCommandsEvent event) {
|
||||
}
|
||||
|
||||
List<Command> commands = manager.getPlatformCommandManager().getCommandManager()
|
||||
.getAllCommands().collect(toList());
|
||||
.getAllCommands().toList();
|
||||
for (Command command : commands) {
|
||||
CommandWrapper.register(event.getDispatcher(), command);
|
||||
Set<String> perms = command.getCondition().as(PermissionCondition.class)
|
||||
@ -270,26 +269,23 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
return; // We have to be told to catch these events
|
||||
}
|
||||
|
||||
if (event.getWorld().isClientSide && event instanceof LeftClickEmpty) {
|
||||
if (event.getLevel().isClientSide && event instanceof LeftClickEmpty) {
|
||||
// catch LCE, pass it to server
|
||||
InternalPacketHandler.getHandler().sendToServer(LeftClickAirEventMessage.INSTANCE);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isLeftDeny = event instanceof PlayerInteractEvent.LeftClickBlock
|
||||
&& ((PlayerInteractEvent.LeftClickBlock) event)
|
||||
.getUseItem() == Event.Result.DENY;
|
||||
boolean isRightDeny =
|
||||
event instanceof PlayerInteractEvent.RightClickBlock
|
||||
&& ((PlayerInteractEvent.RightClickBlock) event)
|
||||
.getUseItem() == Event.Result.DENY;
|
||||
boolean isLeftDeny = event instanceof PlayerInteractEvent.LeftClickBlock lcb
|
||||
&& lcb.getUseItem() == Event.Result.DENY;
|
||||
boolean isRightDeny = event instanceof PlayerInteractEvent.RightClickBlock rcb
|
||||
&& rcb.getUseItem() == Event.Result.DENY;
|
||||
if (isLeftDeny || isRightDeny || event.getEntity().level.isClientSide || event.getHand() == InteractionHand.OFF_HAND) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldEdit we = WorldEdit.getInstance();
|
||||
ForgePlayer player = adaptPlayer((ServerPlayer) event.getPlayer());
|
||||
ForgeWorld world = getWorld((ServerLevel) event.getPlayer().level);
|
||||
ForgePlayer player = adaptPlayer((ServerPlayer) event.getEntity());
|
||||
ForgeWorld world = getWorld((ServerLevel) event.getEntity().level);
|
||||
Direction direction = ForgeAdapter.adaptEnumFacing(event.getFace());
|
||||
|
||||
if (event instanceof PlayerInteractEvent.LeftClickEmpty) {
|
||||
@ -324,10 +320,9 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
@SubscribeEvent
|
||||
public void onCommandEvent(CommandEvent event) throws CommandSyntaxException {
|
||||
ParseResults<CommandSourceStack> parseResults = event.getParseResults();
|
||||
if (!(parseResults.getContext().getSource().getEntity() instanceof ServerPlayer)) {
|
||||
if (!(parseResults.getContext().getSource().getEntity() instanceof ServerPlayer player)) {
|
||||
return;
|
||||
}
|
||||
ServerPlayer player = parseResults.getContext().getSource().getPlayerOrException();
|
||||
if (player.level.isClientSide) {
|
||||
return;
|
||||
}
|
||||
@ -343,9 +338,9 @@ public void onCommandEvent(CommandEvent event) throws CommandSyntaxException {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerLogOut(PlayerEvent.PlayerLoggedOutEvent event) {
|
||||
if (event.getPlayer() instanceof ServerPlayer) {
|
||||
if (event.getEntity() instanceof ServerPlayer player) {
|
||||
WorldEdit.getInstance().getEventBus()
|
||||
.post(new SessionIdleEvent(new ForgePlayer.SessionKeyImpl((ServerPlayer) event.getPlayer())));
|
||||
.post(new SessionIdleEvent(new ForgePlayer.SessionKeyImpl(player)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,8 +148,8 @@ public static Location adapt(ServerLocation location, Vector3d rotation) {
|
||||
return new Location(
|
||||
adapt(location.world()),
|
||||
position,
|
||||
(float) rotation.x(),
|
||||
(float) rotation.y()
|
||||
(float) rotation.y(),
|
||||
(float) rotation.x()
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user