Skip to content

Instantly share code, notes, and snippets.

@Alvin-LB
Created September 3, 2017 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alvin-LB/78143057122cd3f9f1c9f53e959c3fe8 to your computer and use it in GitHub Desktop.
Save Alvin-LB/78143057122cd3f9f1c9f53e959c3fe8 to your computer and use it in GitHub Desktop.
name: PrivateBrewingStand
version: 1.0
main: com.bringholm.privatebrewingstand.PrivateBrewingStand
author: AlvinB
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