001 package org.bukkit.event.inventory; 002 003 /** 004 * What the client did to trigger this action (not the result). 005 */ 006 public enum ClickType { 007 008 /** 009 * The left (or primary) mouse button. 010 */ 011 LEFT, 012 /** 013 * Holding shift while pressing the left mouse button. 014 */ 015 SHIFT_LEFT, 016 /** 017 * The right mouse button. 018 */ 019 RIGHT, 020 /** 021 * Holding shift while pressing the right mouse button. 022 */ 023 SHIFT_RIGHT, 024 /** 025 * Clicking the left mouse button on the grey area around the inventory. 026 */ 027 WINDOW_BORDER_LEFT, 028 /** 029 * Clicking the right mouse button on the grey area around the inventory. 030 */ 031 WINDOW_BORDER_RIGHT, 032 /** 033 * The middle mouse button, or a "scrollwheel click". 034 */ 035 MIDDLE, 036 /** 037 * One of the number keys 1-9, correspond to slots on the hotbar. 038 */ 039 NUMBER_KEY, 040 /** 041 * Pressing the left mouse button twice in quick succession. 042 */ 043 DOUBLE_CLICK, 044 /** 045 * The "Drop" key (defaults to Q). 046 */ 047 DROP, 048 /** 049 * Holding Ctrl while pressing the "Drop" key (defaults to Q). 050 */ 051 CONTROL_DROP, 052 /** 053 * Any action done with the Creative inventory open. 054 */ 055 CREATIVE, 056 /** 057 * A type of inventory manipulation not yet recognized by Bukkit. 058 * <p> 059 * This is only for transitional purposes on a new Minecraft update, and 060 * should never be relied upon. 061 * <p> 062 * Any ClickType.UNKNOWN is called on a best-effort basis. 063 */ 064 UNKNOWN, 065 ; 066 067 /** 068 * Gets whether this ClickType represents the pressing of a key on a 069 * keyboard. 070 * 071 * @return true if this ClickType represents the pressing of a key 072 */ 073 public boolean isKeyboardClick() { 074 return (this == ClickType.NUMBER_KEY) || (this == ClickType.DROP) || (this == ClickType.CONTROL_DROP); 075 } 076 077 /** 078 * Gets whether this ClickType represents an action that can only be 079 * performed by a Player in creative mode. 080 * 081 * @return true if this action requires Creative mode 082 */ 083 public boolean isCreativeAction() { 084 // Why use middle click? 085 return (this == ClickType.MIDDLE) || (this == ClickType.CREATIVE); 086 } 087 088 /** 089 * Gets whether this ClickType represents a right click. 090 * 091 * @return true if this ClickType represents a right click 092 */ 093 public boolean isRightClick() { 094 return (this == ClickType.RIGHT) || (this == ClickType.SHIFT_RIGHT); 095 } 096 097 /** 098 * Gets whether this ClickType represents a left click. 099 * 100 * @return true if this ClickType represents a left click 101 */ 102 public boolean isLeftClick() { 103 return (this == ClickType.LEFT) || (this == ClickType.SHIFT_LEFT) || (this == ClickType.DOUBLE_CLICK) || (this == ClickType.CREATIVE); 104 } 105 106 /** 107 * Gets whether this ClickType indicates that the shift key was pressed 108 * down when the click was made. 109 * 110 * @return true if the action uses Shift. 111 */ 112 public boolean isShiftClick() { 113 return (this == ClickType.SHIFT_LEFT) || (this == ClickType.SHIFT_RIGHT) || (this == ClickType.CONTROL_DROP); 114 } 115 }