Permalink
Browse files

Update WorldEdit-Sponge to 1.12

Also added support for minecraft:stone item types.
  • Loading branch information...
me4502 committed Jun 12, 2017
1 parent b557b2b commit aabc2290765cc4d6cd2f60af5ae2cdf2ca97b36e
@@ -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'
}
@@ -42,7 +42,7 @@ public BaseBiome createFromId(int id) {
@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)));
}
@@ -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 @@ boolean isHookingEvents() {
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);
}

This comment has been minimized.

Show comment
Hide comment
@DarkArc

DarkArc Jun 16, 2017

Collaborator

@me4502 Why is this trying to resolve block type if this is for getting items?

@DarkArc

DarkArc Jun 16, 2017

Collaborator

@me4502 Why is this trying to resolve block type if this is for getting items?

This comment has been minimized.

Show comment
Hide comment
@me4502

me4502 Jun 16, 2017

Collaborator

The method name does not reflect the usage.

@me4502

me4502 Jun 16, 2017

Collaborator

The method name does not reflect the usage.

This comment has been minimized.

Show comment
Hide comment
@kashike

kashike Jun 16, 2017

Contributor

...what?

@kashike

kashike Jun 16, 2017

Contributor

...what?

This comment has been minimized.

Show comment
Hide comment
@me4502

me4502 Jun 16, 2017

Collaborator

DefaultBlockParser uses this method when doing a lookup on BlockType.

@me4502

me4502 Jun 16, 2017

Collaborator

DefaultBlockParser uses this method when doing a lookup on BlockType.

}
@Override
@@ -96,7 +100,7 @@ public Player matchPlayer(Player player) {
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 @@ public String getPlatformVersion() {
@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));
}
@@ -61,7 +61,7 @@ public UUID getUniqueId() {
@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

0 comments on commit aabc229

Please sign in to comment.