Skip to content

Commit

Permalink
Use meta for the MapChanger mechanic.
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Dec 1, 2018
1 parent cd2cbfe commit 5bc8c46
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/com/sk89q/craftbook/mechanics/MapChanger.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.sk89q.craftbook.util.SignUtil; import com.sk89q.craftbook.util.SignUtil;
import com.sk89q.craftbook.util.events.SignClickEvent; import com.sk89q.craftbook.util.events.SignClickEvent;
import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.inventory.meta.MapMeta;


public class MapChanger extends AbstractCraftBookMechanic { public class MapChanger extends AbstractCraftBookMechanic {


Expand Down Expand Up @@ -58,7 +59,7 @@ public void onSignClick(SignClickEvent event) {
player.printError("area.use-permissions"); player.printError("area.use-permissions");
return; 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; byte id;
try { try {
id = Byte.parseByte(sign.getLine(2)); id = Byte.parseByte(sign.getLine(2));
Expand All @@ -69,7 +70,9 @@ public void onSignClick(SignClickEvent event) {
player.printError("mech.map.invalid"); player.printError("mech.map.invalid");
return; return;
} }
event.getPlayer().getItemInHand().setDurability(id); MapMeta meta = (MapMeta) event.getPlayer().getInventory().getItemInMainHand().getItemMeta();
meta.setMapId(id);
event.getPlayer().getInventory().getItemInMainHand().setItemMeta(meta);
} }
} }


Expand Down

0 comments on commit 5bc8c46

Please sign in to comment.