Update WorldEdit-Sponge to 1.12

Also added support for minecraft:stone item types.
This commit is contained in:
Me4502 2017-06-12 12:08:09 +10:00
parent b557b2b71d
commit aabc229076
8 changed files with 13 additions and 9 deletions

View File

@ -13,7 +13,7 @@ plugins {
dependencies {
compile project(':worldedit-core')
compile 'org.spongepowered:spongeapi:6.0.0-SNAPSHOT'
compile 'org.spongepowered:spongeapi:7.0.0-SNAPSHOT'
testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1'
}

View File

@ -42,7 +42,7 @@ class SpongeBiomeRegistry implements BiomeRegistry {
@Override
public List<BaseBiome> getBiomes() {
List<BaseBiome> list = new ArrayList<BaseBiome>();
List<BaseBiome> list = new ArrayList<>();
for (BiomeType biome : Sponge.getGame().getRegistry().getAllOf(BiomeType.class)) {
list.add(new BaseBiome(SpongeWorldEdit.inst().getAdapter().resolve(biome)));
}

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.sponge;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
@ -57,10 +58,13 @@ class SpongePlatform extends AbstractPlatform implements MultiUserPlatform {
public int resolveItem(String name) {
if (name == null) return 0;
Optional<ItemType> optType = Sponge.getRegistry().getType(ItemType.class, name);
return optType.map(itemType -> SpongeWorldEdit.inst().getAdapter().resolve(itemType)).orElse(0);
Optional<org.spongepowered.api.block.BlockType> optBlock = Sponge.getRegistry().getType(org.spongepowered.api.block.BlockType.class, name);
if (optBlock.isPresent()) {
return optBlock.map(blockType -> SpongeWorldEdit.inst().getAdapter().resolve(blockType)).orElse(0);
} else {
Optional<ItemType> optType = Sponge.getRegistry().getType(ItemType.class, name);
return optType.map(itemType -> SpongeWorldEdit.inst().getAdapter().resolve(itemType)).orElse(0);
}
}
@Override
@ -96,7 +100,7 @@ class SpongePlatform extends AbstractPlatform implements MultiUserPlatform {
return player;
} else {
Optional<org.spongepowered.api.entity.living.player.Player> optPlayer = Sponge.getServer().getPlayer(player.getUniqueId());
return optPlayer.isPresent() ? new SpongePlayer(this, optPlayer.get()) : null;
return optPlayer.<Player>map(player1 -> new SpongePlayer(this, player1)).orElse(null);
}
}
@ -178,7 +182,7 @@ class SpongePlatform extends AbstractPlatform implements MultiUserPlatform {
@Override
public Collection<Actor> getConnectedUsers() {
List<Actor> users = new ArrayList<Actor>();
List<Actor> users = new ArrayList<>();
for (org.spongepowered.api.entity.living.player.Player player : Sponge.getServer().getOnlinePlayers()) {
users.add(new SpongePlayer(this, player));
}

View File

@ -61,7 +61,7 @@ public class SpongePlayer extends AbstractPlayerActor {
@Override
public int getItemInHand() {
Optional<ItemStack> is = this.player.getItemInHand(HandTypes.MAIN_HAND);
return is.isPresent() ? SpongeWorldEdit.inst().getAdapter().resolve(is.get().getItem()) : 0;
return is.map(itemStack -> SpongeWorldEdit.inst().getAdapter().resolve(itemStack.getItem())).orElse(0);
}
@Override