mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-10-02 00:27:28 +02:00
Inventory checks now won't be used if there are no on-acquire events.
This commit is contained in:
parent
339bf1a06d
commit
881f050f0d
@ -45,6 +45,11 @@ public class Blacklist {
|
|||||||
*/
|
*/
|
||||||
private BlacklistLogger blacklistLogger = new BlacklistLogger();
|
private BlacklistLogger blacklistLogger = new BlacklistLogger();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blacklist contains on-acquire events.
|
||||||
|
*/
|
||||||
|
private boolean hasOnAcquire;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the list is empty.
|
* Returns whether the list is empty.
|
||||||
*
|
*
|
||||||
@ -277,6 +282,8 @@ public void load(File file) throws IOException {
|
|||||||
input = new FileReader(file);
|
input = new FileReader(file);
|
||||||
BufferedReader buff = new BufferedReader(input);
|
BufferedReader buff = new BufferedReader(input);
|
||||||
|
|
||||||
|
hasOnAcquire = false;
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
List<BlacklistEntry> currentEntries = null;
|
List<BlacklistEntry> currentEntries = null;
|
||||||
while ((line = buff.readLine()) != null) {
|
while ((line = buff.readLine()) != null) {
|
||||||
@ -347,6 +354,7 @@ public void load(File file) throws IOException {
|
|||||||
} else if (parts[0].equalsIgnoreCase("on-drop")) {
|
} else if (parts[0].equalsIgnoreCase("on-drop")) {
|
||||||
entry.setDropActions(parts[1].split(","));
|
entry.setDropActions(parts[1].split(","));
|
||||||
} else if (parts[0].equalsIgnoreCase("on-acquire")) {
|
} else if (parts[0].equalsIgnoreCase("on-acquire")) {
|
||||||
|
hasOnAcquire = true;
|
||||||
entry.setAcquireActions(parts[1].split(","));
|
entry.setAcquireActions(parts[1].split(","));
|
||||||
} else if (parts[0].equalsIgnoreCase("message")) {
|
} else if (parts[0].equalsIgnoreCase("message")) {
|
||||||
entry.setMessage(parts[1].trim());
|
entry.setMessage(parts[1].trim());
|
||||||
@ -377,4 +385,13 @@ public void load(File file) throws IOException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blacklist contains on-acquire events.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean hasOnAcquire() {
|
||||||
|
return hasOnAcquire;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,9 +367,11 @@ public boolean onItemDrop(Player player, Item item) {
|
|||||||
* @return true if you want to leave the item where it was
|
* @return true if you want to leave the item where it was
|
||||||
*/
|
*/
|
||||||
public boolean onItemPickUp(Player player, Item item) {
|
public boolean onItemPickUp(Player player, Item item) {
|
||||||
|
if (blacklist != null && blacklist.hasOnAcquire()) {
|
||||||
if (!blacklist.onSilentAcquire(item.getItemId(), player)) {
|
if (!blacklist.onSilentAcquire(item.getItemId(), player)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -382,7 +384,7 @@ public boolean onItemPickUp(Player player, Item item) {
|
|||||||
* @return true if you want any changes to be reverted
|
* @return true if you want any changes to be reverted
|
||||||
*/
|
*/
|
||||||
public boolean onInventoryChange(Player player) {
|
public boolean onInventoryChange(Player player) {
|
||||||
if (blacklist != null) {
|
if (blacklist != null && blacklist.hasOnAcquire()) {
|
||||||
hj[] items = player.getInventory().getArray();
|
hj[] items = player.getInventory().getArray();
|
||||||
boolean needUpdate = false;
|
boolean needUpdate = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user