Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
improve mailbox
Browse files Browse the repository at this point in the history
  • Loading branch information
cyilin committed Jun 18, 2016
1 parent 7f7be24 commit c72a76f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/cat/nyaa/HamsterEcoHelper/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.HashMap;
import java.util.List;
import java.util.UUID;

public class Events implements Listener {
private final HamsterEcoHelper plugin;

public Events(HamsterEcoHelper plugin) {
this.plugin = plugin;
plugin.getServer().getPluginManager().registerEvents(this, plugin);
Expand All @@ -28,6 +30,9 @@ public void onInventoryClose(InventoryCloseEvent e) {
if (MarketManager.viewMailbox.contains(player)) {
MarketManager.viewMailbox.remove(player);
MarketManager.setMailbox(player, e.getInventory().getContents());
if (MarketManager.viewPage.get(player) != null) {
new openMarket(player, MarketManager.viewPage.get(player), MarketManager.viewSeller.get(player)).runTaskLater(this.plugin, 5);
}
return;
}
}
Expand Down Expand Up @@ -79,3 +84,25 @@ public void onPlayerJoin(PlayerJoinEvent ev) {
}
}
}

class openMarket extends BukkitRunnable {

private final UUID seller;
private final int page;
private final Player player;

public openMarket(Player player, int page, UUID seller) {
this.player = player;
this.page = page;
this.seller = seller;
}

@Override
public void run() {
if (player.isOnline()) {
MarketManager.openGUI(player, page, seller);
}
this.cancel();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class MarketCommands {
@SubCommand(value = "mailbox", permission = "heh.user")
public static void openMailbox(CommandSender sender, Arguments args, HamsterEcoHelper plugin) {
Player player = asPlayer(sender);
MarketManager.viewPage.put(player,null);
MarketManager.openMailbox(player);
}

Expand Down

0 comments on commit c72a76f

Please sign in to comment.