Skip to content

Commit aeeb584

Browse files
committed
Support 5.0.0-SNAPSHOT
1 parent 87ae47e commit aeeb584

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<dependency>
7070
<groupId>org.spongepowered</groupId>
7171
<artifactId>spongeapi</artifactId>
72-
<version>4.0.0</version>
72+
<version>5.0.0-SNAPSHOT</version>
7373
<type>jar</type>
7474
<optional>true</optional>
7575
<scope>provided</scope>

src/main/java/org/kitteh/tim/Tim.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.spongepowered.api.command.spec.CommandSpec;
3737
import org.spongepowered.api.data.key.Keys;
3838
import org.spongepowered.api.data.meta.ItemEnchantment;
39+
import org.spongepowered.api.data.type.HandTypes;
3940
import org.spongepowered.api.entity.living.player.Player;
4041
import org.spongepowered.api.event.Listener;
4142
import org.spongepowered.api.event.game.state.GamePostInitializationEvent;
@@ -160,14 +161,14 @@ private Player getPlayer(CommandSource commandSource) throws CommandException {
160161
}
161162

162163
private void enchant(Player player, Enchantment enchantment, int level) throws CommandException {
163-
ItemStack item = player.getItemInHand().orElseThrow(() -> new CommandException(this.getErrorText("You need to be holding an item to enchant it!")));
164+
ItemStack item = player.getItemInHand(HandTypes.MAIN_HAND).orElseThrow(() -> new CommandException(this.getErrorText("You need to be holding an item to enchant it!")));
164165
item.transform(Keys.ITEM_ENCHANTMENTS, list -> {
165166
List<ItemEnchantment> newList = new LinkedList<>();
166167
list.stream().filter(ench -> ench.getEnchantment() != enchantment).forEach(newList::add);
167168
newList.add(new ItemEnchantment(enchantment, level));
168169
return newList;
169170
});
170-
player.setItemInHand(item);
171+
player.setItemInHand(HandTypes.MAIN_HAND, item);
171172
}
172173

173174
private Text getErrorText(String error) {

0 commit comments

Comments
 (0)