mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-27 21:15:57 +01:00
Added 'right click on' events to the blacklist.
This commit is contained in:
parent
84eb9343ce
commit
7b3a8402a1
@ -54,6 +54,10 @@ public class BlacklistEntry {
|
||||
* List of actions to perform on right click.
|
||||
*/
|
||||
private String[] rightClickActions;
|
||||
/**
|
||||
* List of actions to perform on right click upon.
|
||||
*/
|
||||
private String[] rightClickOnActions;
|
||||
|
||||
/**
|
||||
* @return the ignoreGroups
|
||||
@ -115,6 +119,20 @@ public void setRightClickActions(String[] rightClickActions) {
|
||||
this.rightClickActions = rightClickActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String[] getRightClickOnActions() {
|
||||
return rightClickOnActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
*/
|
||||
public void setRightClickOnActions(String[] actions) {
|
||||
this.rightClickOnActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this player should be ignored.
|
||||
*
|
||||
@ -190,7 +208,7 @@ public boolean onLeftClick(int item, Player player) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right right. Returns true to let the action pass through.
|
||||
* Called on right click. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
@ -205,6 +223,22 @@ public boolean onRightClick(int item, Player player) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right click upon. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onRightClickOn(Block block, Player player) {
|
||||
if (rightClickOnActions == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = process(block.getType(), player, rightClickOnActions);
|
||||
lastAffected.put(player.getName(), block.getType());
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to handle the actions.
|
||||
*
|
||||
|
@ -229,7 +229,7 @@ public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicke
|
||||
int itemInHand) {
|
||||
if (blacklist != null) {
|
||||
BlacklistEntry entry = blacklist.get(itemInHand);
|
||||
if (entry != null) {
|
||||
if (entry != null) {
|
||||
if (!entry.onRightClick(itemInHand, player)) {
|
||||
// Water/lava bucket fix
|
||||
if (itemInHand == 326 || itemInHand == 327) {
|
||||
@ -250,6 +250,10 @@ public void run() {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!entry.onRightClickOn(blockClicked, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -578,6 +582,8 @@ public Map<Integer,BlacklistEntry> loadBlacklist(File file)
|
||||
entry.setLeftClickActions(parts[1].split(","));
|
||||
} else if(parts[0].equalsIgnoreCase("on-right")) {
|
||||
entry.setRightClickActions(parts[1].split(","));
|
||||
} else if(parts[0].equalsIgnoreCase("on-right-on")) {
|
||||
entry.setRightClickOnActions(parts[1].split(","));
|
||||
} else {
|
||||
unknownOption = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user