Created
September 3, 2017 20:04
-
-
Save Alvin-LB/78143057122cd3f9f1c9f53e959c3fe8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PrivateBrewingStand | |
version: 1.0 | |
main: com.bringholm.privatebrewingstand.PrivateBrewingStand | |
author: AlvinB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.bringholm.privatebrewingstand; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.inventory.InventoryOpenEvent; | |
import org.bukkit.inventory.BrewerInventory; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class PrivateBrewingStand extends JavaPlugin implements Listener { | |
@Override | |
public void onEnable() { | |
this.getServer().getPluginManager().registerEvents(this, this); | |
} | |
@EventHandler | |
public void onInventoryOpen(InventoryOpenEvent e) { | |
if (e.getInventory() instanceof BrewerInventory) { | |
// By the time this event is fired the player | |
// has already been added as a viewer, so we | |
// check if there are more than 1 player | |
// in the list. | |
if (e.getViewers().size() > 1) { | |
e.setCancelled(true); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment