Java Code Examples for org.bukkit.entity.HumanEntity#sendMessage()

The following examples show how to use org.bukkit.entity.HumanEntity#sendMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CivilianListener.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onInventoryMoveEvent(InventoryMoveItemEvent event) {
    if (ConfigManager.getInstance().getAllowSharingCivsItems()) {
        return;
    }
    if (!CVItem.isCivsItem(event.getItem())) {
        return;
    }
    if (!(event.getDestination() instanceof PlayerInventory)) {
        event.setCancelled(true);
        if (!event.getSource().getViewers().isEmpty()) {
            HumanEntity humanEntity = event.getSource().getViewers().get(0);
            humanEntity.sendMessage(Civs.getPrefix() +
                    LocaleManager.getInstance().getTranslationWithPlaceholders((Player) humanEntity,
                            LocaleConstants.PREVENT_CIVS_ITEM_SHARE));
        }
    }
}
 
Example 2
Source File: InventoryForVillagerOffers.java    From NBTEditor with GNU General Public License v3.0 6 votes vote down vote up
private void changeIndex(HumanEntity player, int offset) {
	if (_index + offset >= 0) {
		if (saveOffers(true)) {
			_index += offset;
			loadOffers();
			createWoolButtons();
			updatePaperButtons();
			updateBottleButton();
			int p = _index/9;
			setItemStackName(getItem(44), "[" + p + "] Previous Page");
			setItemStackName(getItem(53), "[" + p + "] Next Page");
		} else {
			player.sendMessage("§eSome offers are invalid. Fix them.");
		}
	}
}
 
Example 3
Source File: TutorialManager.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public void printTutorial(HumanEntity player, Civilian civilian) {
    String tutorialUrl = ConfigManager.getInstance().getTutorialUrl();
    player.sendMessage(Util.parseColors(ConfigManager.getInstance().getTopGuideSpacer()));
    TutorialManager.getInstance().sendMessageForCurrentTutorialStep(civilian, false);
    player.sendMessage(LocaleManager.getInstance().getTranslation(civilian.getLocale(), "tutorial-click"));
    player.sendMessage(tutorialUrl);
    player.sendMessage(Util.parseColors(ConfigManager.getInstance().getBottomGuideSpacer()));
}
 
Example 4
Source File: CivilianListener.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onCivilianDragItem(InventoryDragEvent event) {
    if (event.getView().getTopInventory().getHolder() instanceof Chest) {
        Location inventoryLocation = ((Chest) event.getView().getTopInventory().getHolder()).getLocation();
        UnloadedInventoryHandler.getInstance().updateInventoryAtLocation(inventoryLocation);
    }
    if (ConfigManager.getInstance().getAllowSharingCivsItems()) {
        return;
    }
    ItemStack dragged = event.getOldCursor();

    if (!CVItem.isCivsItem(dragged) ||
            MenuManager.getInstance().hasMenuOpen(event.getWhoClicked().getUniqueId())) {
        return;
    }

    int inventorySize = event.getInventory().getSize();
    for (int i : event.getRawSlots()) {
        if (i < inventorySize) {
            event.setCancelled(true);
            HumanEntity humanEntity = event.getWhoClicked();
            humanEntity.sendMessage(Civs.getPrefix() +
                    LocaleManager.getInstance().getTranslationWithPlaceholders((Player) humanEntity, LocaleConstants.PREVENT_CIVS_ITEM_SHARE));
            return;
        }
    }
}
 
Example 5
Source File: CivilianListener.java    From Civs with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true) @SuppressWarnings("unused")
public void onCivilianClickItem(InventoryClickEvent event) {
    if (event.getClickedInventory() != null) {
        Location inventoryLocation = event.getClickedInventory().getLocation();
        UnloadedInventoryHandler.getInstance().updateInventoryAtLocation(inventoryLocation);
    }
    handleCustomItem(event.getCurrentItem(), event.getWhoClicked().getUniqueId());
    if (ConfigManager.getInstance().getAllowSharingCivsItems()) {
        return;
    }
    boolean shiftClick = event.getClick().isShiftClick() && event.getClickedInventory() != null &&
            event.getClickedInventory().equals(event.getWhoClicked().getInventory());
    boolean dragToChest = event.getClickedInventory() != null &&
            !event.getClickedInventory().equals(event.getWhoClicked().getInventory());

    if (event.getView().getTopInventory().getHolder() instanceof DoubleChest) {
        DoubleChest doubleChest = (DoubleChest) event.getView().getTopInventory().getHolder();
        Location leftLocation = ((Chest) doubleChest.getLeftSide()).getLocation();
        Location rightLocation = ((Chest) doubleChest.getRightSide()).getLocation();
        RegionManager.getInstance().removeCheckedRegion(leftLocation);
        RegionManager.getInstance().removeCheckedRegion(rightLocation);
    } else {
        if (event.getClickedInventory() != null &&
                event.getClickedInventory().getType() != InventoryType.ENDER_CHEST &&
                event.getView().getTopInventory().getType() != InventoryType.ENDER_CHEST) {
            try {
                RegionManager.getInstance().removeCheckedRegion(event.getView().getTopInventory().getLocation());
            } catch (NullPointerException npe) {
                // Doesn't matter if there's an error here
            }
        }
    }

    ItemStack stackInQuestion = shiftClick ? event.getCurrentItem() : event.getCursor();

    if (stackInQuestion == null || (!shiftClick && !dragToChest)) {
        return;
    }

    if (!CVItem.isCivsItem(stackInQuestion) || MenuManager.getInstance().hasMenuOpen(event.getWhoClicked().getUniqueId())) {
        return;
    }
    HumanEntity humanEntity = event.getWhoClicked();
    event.setCancelled(true);
    humanEntity.sendMessage(Civs.getPrefix() +
            LocaleManager.getInstance().getTranslationWithPlaceholders((Player) humanEntity, LocaleConstants.PREVENT_CIVS_ITEM_SHARE));
}