Skip to content
Permalink
Browse files

Use meta for the MapChanger mechanic.

  • Loading branch information...
me4502 committed Dec 1, 2018
1 parent cd2cbfe commit 5bc8c46ec618206604c5e96f74f37c13d9446168
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/main/java/com/sk89q/craftbook/mechanics/MapChanger.java
@@ -15,6 +15,7 @@
import com.sk89q.craftbook.util.SignUtil;
import com.sk89q.craftbook.util.events.SignClickEvent;
import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.inventory.meta.MapMeta;

public class MapChanger extends AbstractCraftBookMechanic {

@@ -58,7 +59,7 @@ public void onSignClick(SignClickEvent event) {
player.printError("area.use-permissions");
return;
}
if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getType() == Material.MAP) {
if (event.getPlayer().getInventory().getItemInMainHand() != null && event.getPlayer().getInventory().getItemInMainHand().getType() == Material.MAP) {
byte id;
try {
id = Byte.parseByte(sign.getLine(2));
@@ -69,7 +70,9 @@ public void onSignClick(SignClickEvent event) {
player.printError("mech.map.invalid");
return;
}
event.getPlayer().getItemInHand().setDurability(id);
MapMeta meta = (MapMeta) event.getPlayer().getInventory().getItemInMainHand().getItemMeta();
meta.setMapId(id);
event.getPlayer().getInventory().getItemInMainHand().setItemMeta(meta);
}
}

0 comments on commit 5bc8c46

Please sign in to comment.
You can’t perform that action at this time.