mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-24 03:25:24 +01:00
Added comments and messages. Made the blacklist notification messages more compact and a different color.
This commit is contained in:
parent
93c0295744
commit
cf7874f776
@ -12,5 +12,10 @@ CREATE TABLE `blacklist_events` (
|
|||||||
`z` int(11) NOT NULL,
|
`z` int(11) NOT NULL,
|
||||||
`item` int(11) NOT NULL,
|
`item` int(11) NOT NULL,
|
||||||
`time` int(11) NOT NULL,
|
`time` int(11) NOT NULL,
|
||||||
|
`comment` varchar(255) NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Required update if you have an older version of the table:
|
||||||
|
|
||||||
|
ALTER TABLE `blacklist_events` ADD `comment` VARCHAR( 255 ) NULL
|
@ -304,6 +304,10 @@ public void load(File file) throws IOException {
|
|||||||
entry.setUseActions(parts[1].split(","));
|
entry.setUseActions(parts[1].split(","));
|
||||||
} 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("message")) {
|
||||||
|
entry.setMessage(parts[1].trim());
|
||||||
|
} else if (parts[0].equalsIgnoreCase("comment")) {
|
||||||
|
entry.setComment(parts[1].trim());
|
||||||
} else {
|
} else {
|
||||||
unknownOption = true;
|
unknownOption = true;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,11 @@ public class BlacklistEntry {
|
|||||||
* List of actions to perform on drop.
|
* List of actions to perform on drop.
|
||||||
*/
|
*/
|
||||||
private String[] dropActions;
|
private String[] dropActions;
|
||||||
|
/**
|
||||||
|
* Comment for the log.
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
private String comment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
@ -178,6 +183,34 @@ public void setDropActions(String[] actions) {
|
|||||||
this.dropActions = actions;
|
this.dropActions = actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the message
|
||||||
|
*/
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message the message to set
|
||||||
|
*/
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the comment
|
||||||
|
*/
|
||||||
|
public String getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param comment the comment to set
|
||||||
|
*/
|
||||||
|
public void setComment(String comment) {
|
||||||
|
this.comment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this player should be ignored.
|
* Returns true if this player should be ignored.
|
||||||
*
|
*
|
||||||
@ -206,7 +239,7 @@ public void notifyAdmins(String str) {
|
|||||||
for (Player player : etc.getServer().getPlayerList()) {
|
for (Player player : etc.getServer().getPlayerList()) {
|
||||||
if (player.canUseCommand("/wprotectalerts")
|
if (player.canUseCommand("/wprotectalerts")
|
||||||
|| player.canUseCommand("/worldguardnotify")) {
|
|| player.canUseCommand("/worldguardnotify")) {
|
||||||
player.sendMessage(Colors.LightPurple + "WorldGuard: " + str);
|
player.sendMessage(Colors.LightGray + "WG: " + str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,7 +275,7 @@ public boolean onDestroy(final Block block, final Player player) {
|
|||||||
|
|
||||||
ActionHandler handler = new ActionHandler() {
|
ActionHandler handler = new ActionHandler() {
|
||||||
public void log(String itemName) {
|
public void log(String itemName) {
|
||||||
blacklist.getLogger().logDestroyAttempt(player, block);
|
blacklist.getLogger().logDestroyAttempt(player, block, comment);
|
||||||
}
|
}
|
||||||
public void kick(String itemName) {
|
public void kick(String itemName) {
|
||||||
player.kick("You are not allowed to destroy " + itemName);
|
player.kick("You are not allowed to destroy " + itemName);
|
||||||
@ -251,7 +284,8 @@ public void ban(String itemName) {
|
|||||||
entry.banPlayer(player, "Banned: You are not allowed to destroy " + itemName);
|
entry.banPlayer(player, "Banned: You are not allowed to destroy " + itemName);
|
||||||
}
|
}
|
||||||
public void notifyAdmins(String itemName) {
|
public void notifyAdmins(String itemName) {
|
||||||
entry.notifyAdmins(player.getName() + " tried to destroy " + itemName + ".");
|
entry.notifyAdmins(player.getName() + " (destroy) " + itemName
|
||||||
|
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||||
}
|
}
|
||||||
public void tell(String itemName) {
|
public void tell(String itemName) {
|
||||||
player.sendMessage(Colors.Yellow + "You are not allowed to destroy " + itemName + ".");
|
player.sendMessage(Colors.Yellow + "You are not allowed to destroy " + itemName + ".");
|
||||||
@ -278,7 +312,7 @@ public boolean onBreak(final Block block, final Player player) {
|
|||||||
|
|
||||||
ActionHandler handler = new ActionHandler() {
|
ActionHandler handler = new ActionHandler() {
|
||||||
public void log(String itemName) {
|
public void log(String itemName) {
|
||||||
blacklist.getLogger().logBreakAttempt(player, block);
|
blacklist.getLogger().logBreakAttempt(player, block, comment);
|
||||||
}
|
}
|
||||||
public void kick(String itemName) {
|
public void kick(String itemName) {
|
||||||
player.kick("You are not allowed to break " + itemName);
|
player.kick("You are not allowed to break " + itemName);
|
||||||
@ -287,7 +321,8 @@ public void ban(String itemName) {
|
|||||||
entry.banPlayer(player, "Banned: You are not allowed to break " + itemName);
|
entry.banPlayer(player, "Banned: You are not allowed to break " + itemName);
|
||||||
}
|
}
|
||||||
public void notifyAdmins(String itemName) {
|
public void notifyAdmins(String itemName) {
|
||||||
entry.notifyAdmins(player.getName() + " tried to break " + itemName + ".");
|
entry.notifyAdmins(player.getName() + " (break) " + itemName
|
||||||
|
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||||
}
|
}
|
||||||
public void tell(String itemName) {
|
public void tell(String itemName) {
|
||||||
player.sendMessage(Colors.Yellow + "You are not allowed to break " + itemName + ".");
|
player.sendMessage(Colors.Yellow + "You are not allowed to break " + itemName + ".");
|
||||||
@ -313,7 +348,7 @@ public boolean onDestroyWith(final int item, final Player player) {
|
|||||||
|
|
||||||
ActionHandler handler = new ActionHandler() {
|
ActionHandler handler = new ActionHandler() {
|
||||||
public void log(String itemName) {
|
public void log(String itemName) {
|
||||||
blacklist.getLogger().logDestroyWithAttempt(player, item);
|
blacklist.getLogger().logDestroyWithAttempt(player, item, comment);
|
||||||
}
|
}
|
||||||
public void kick(String itemName) {
|
public void kick(String itemName) {
|
||||||
player.kick("You can't destroy with " + itemName);
|
player.kick("You can't destroy with " + itemName);
|
||||||
@ -322,7 +357,8 @@ public void ban(String itemName) {
|
|||||||
entry.banPlayer(player, "Banned: You can't destroy with " + itemName);
|
entry.banPlayer(player, "Banned: You can't destroy with " + itemName);
|
||||||
}
|
}
|
||||||
public void notifyAdmins(String itemName) {
|
public void notifyAdmins(String itemName) {
|
||||||
entry.notifyAdmins(player.getName() + " tried to destroyed with " + itemName + ".");
|
entry.notifyAdmins(player.getName() + " (destroy w/) " + itemName
|
||||||
|
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||||
}
|
}
|
||||||
public void tell(String itemName) {
|
public void tell(String itemName) {
|
||||||
player.sendMessage(Colors.Yellow + "You can't destroy with " + itemName + ".");
|
player.sendMessage(Colors.Yellow + "You can't destroy with " + itemName + ".");
|
||||||
@ -348,19 +384,20 @@ public boolean onCreate(final int item, final Player player) {
|
|||||||
|
|
||||||
ActionHandler handler = new ActionHandler() {
|
ActionHandler handler = new ActionHandler() {
|
||||||
public void log(String itemName) {
|
public void log(String itemName) {
|
||||||
blacklist.getLogger().logCreateAttempt(player, item);
|
blacklist.getLogger().logCreateAttempt(player, item, comment);
|
||||||
}
|
}
|
||||||
public void kick(String itemName) {
|
public void kick(String itemName) {
|
||||||
player.kick("You can't create " + itemName);
|
player.kick("You can't place " + itemName);
|
||||||
}
|
}
|
||||||
public void ban(String itemName) {
|
public void ban(String itemName) {
|
||||||
entry.banPlayer(player, "Banned: You can't create " + itemName);
|
entry.banPlayer(player, "Banned: You can't place " + itemName);
|
||||||
}
|
}
|
||||||
public void notifyAdmins(String itemName) {
|
public void notifyAdmins(String itemName) {
|
||||||
entry.notifyAdmins(player.getName() + " tried to create " + itemName + ".");
|
entry.notifyAdmins(player.getName() + " (place) " + itemName
|
||||||
|
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||||
}
|
}
|
||||||
public void tell(String itemName) {
|
public void tell(String itemName) {
|
||||||
player.sendMessage(Colors.Yellow + "You can't create " + itemName + ".");
|
player.sendMessage(Colors.Yellow + "You can't place " + itemName + ".");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -383,7 +420,7 @@ public boolean onUse(final Block block, final Player player) {
|
|||||||
|
|
||||||
ActionHandler handler = new ActionHandler() {
|
ActionHandler handler = new ActionHandler() {
|
||||||
public void log(String itemName) {
|
public void log(String itemName) {
|
||||||
blacklist.getLogger().logUseAttempt(player, block);
|
blacklist.getLogger().logUseAttempt(player, block, comment);
|
||||||
}
|
}
|
||||||
public void kick(String itemName) {
|
public void kick(String itemName) {
|
||||||
player.kick("You can't use " + itemName);
|
player.kick("You can't use " + itemName);
|
||||||
@ -392,7 +429,8 @@ public void ban(String itemName) {
|
|||||||
entry.banPlayer(player, "Banned: You can't use " + itemName);
|
entry.banPlayer(player, "Banned: You can't use " + itemName);
|
||||||
}
|
}
|
||||||
public void notifyAdmins(String itemName) {
|
public void notifyAdmins(String itemName) {
|
||||||
entry.notifyAdmins(player.getName() + " tried to use " + itemName + ".");
|
entry.notifyAdmins(player.getName() + " (use) " + itemName
|
||||||
|
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||||
}
|
}
|
||||||
public void tell(String itemName) {
|
public void tell(String itemName) {
|
||||||
player.sendMessage(Colors.Yellow + "You're not allowed to use " + itemName + ".");
|
player.sendMessage(Colors.Yellow + "You're not allowed to use " + itemName + ".");
|
||||||
@ -446,7 +484,7 @@ public boolean onDrop(final int item, final Player player) {
|
|||||||
|
|
||||||
ActionHandler handler = new ActionHandler() {
|
ActionHandler handler = new ActionHandler() {
|
||||||
public void log(String itemName) {
|
public void log(String itemName) {
|
||||||
blacklist.getLogger().logDropAttempt(player, item);
|
blacklist.getLogger().logDropAttempt(player, item, comment);
|
||||||
}
|
}
|
||||||
public void kick(String itemName) {
|
public void kick(String itemName) {
|
||||||
player.kick("You can't drop " + itemName);
|
player.kick("You can't drop " + itemName);
|
||||||
@ -455,7 +493,8 @@ public void ban(String itemName) {
|
|||||||
entry.banPlayer(player, "Banned: You can't drop " + itemName);
|
entry.banPlayer(player, "Banned: You can't drop " + itemName);
|
||||||
}
|
}
|
||||||
public void notifyAdmins(String itemName) {
|
public void notifyAdmins(String itemName) {
|
||||||
entry.notifyAdmins(player.getName() + " tried to drop " + itemName + ".");
|
entry.notifyAdmins(player.getName() + " (drop) " + itemName
|
||||||
|
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||||
}
|
}
|
||||||
public void tell(String itemName) {
|
public void tell(String itemName) {
|
||||||
player.sendMessage(Colors.Yellow + "You're not allowed to drop " + itemName + ".");
|
player.sendMessage(Colors.Yellow + "You're not allowed to drop " + itemName + ".");
|
||||||
@ -498,19 +537,47 @@ private boolean process(int id, Player player, String[] actions, ActionHandler h
|
|||||||
boolean ret = true;
|
boolean ret = true;
|
||||||
|
|
||||||
for (String action : actions) {
|
for (String action : actions) {
|
||||||
|
// Deny
|
||||||
if (action.equalsIgnoreCase("deny")) {
|
if (action.equalsIgnoreCase("deny")) {
|
||||||
ret = false;
|
ret = false;
|
||||||
|
|
||||||
|
// Kick
|
||||||
} else if (action.equalsIgnoreCase("kick")) {
|
} else if (action.equalsIgnoreCase("kick")) {
|
||||||
handler.kick(etc.getDataSource().getItem(id));
|
if (this.message != null) {
|
||||||
|
player.kick(String.format(this.message,
|
||||||
|
etc.getDataSource().getItem(id)));
|
||||||
|
} else {
|
||||||
|
handler.kick(etc.getDataSource().getItem(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ban
|
||||||
} else if (action.equalsIgnoreCase("ban")) {
|
} else if (action.equalsIgnoreCase("ban")) {
|
||||||
handler.ban(etc.getDataSource().getItem(id));
|
handler.ban(etc.getDataSource().getItem(id));
|
||||||
|
if (this.message != null) {
|
||||||
|
banPlayer(player, "Banned: " + String.format(this.message,
|
||||||
|
etc.getDataSource().getItem(id)));
|
||||||
|
} else {
|
||||||
|
handler.ban(etc.getDataSource().getItem(id));
|
||||||
|
}
|
||||||
|
|
||||||
} else if (!repeating) {
|
} else if (!repeating) {
|
||||||
|
// Notify
|
||||||
if (action.equalsIgnoreCase("notify")) {
|
if (action.equalsIgnoreCase("notify")) {
|
||||||
handler.notifyAdmins(etc.getDataSource().getItem(id));
|
handler.notifyAdmins(etc.getDataSource().getItem(id));
|
||||||
|
|
||||||
|
// Log
|
||||||
} else if (action.equalsIgnoreCase("log")) {
|
} else if (action.equalsIgnoreCase("log")) {
|
||||||
handler.log(etc.getDataSource().getItem(id));
|
handler.log(etc.getDataSource().getItem(id));
|
||||||
|
|
||||||
|
// Tell
|
||||||
} else if (!repeating && action.equalsIgnoreCase("tell")) {
|
} else if (!repeating && action.equalsIgnoreCase("tell")) {
|
||||||
handler.tell(etc.getDataSource().getItem(id));
|
if (this.message != null) {
|
||||||
|
player.sendMessage(Colors.Yellow +
|
||||||
|
String.format(message, etc.getDataSource().getItem(id))
|
||||||
|
+ ".");
|
||||||
|
} else {
|
||||||
|
handler.tell(etc.getDataSource().getItem(id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,9 @@ public void clearHandlers() {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logDestroyAttempt(Player player, Block block) {
|
public void logDestroyAttempt(Player player, Block block, String comment) {
|
||||||
for (BlacklistLoggerHandler handler : handlers) {
|
for (BlacklistLoggerHandler handler : handlers) {
|
||||||
handler.logDestroyAttempt(player, block);
|
handler.logDestroyAttempt(player, block, comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,9 +76,9 @@ public void logDestroyAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logBreakAttempt(Player player, Block block) {
|
public void logBreakAttempt(Player player, Block block, String comment) {
|
||||||
for (BlacklistLoggerHandler handler : handlers) {
|
for (BlacklistLoggerHandler handler : handlers) {
|
||||||
handler.logBreakAttempt(player, block);
|
handler.logBreakAttempt(player, block, comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,9 +88,9 @@ public void logBreakAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logUseAttempt(Player player, Block block) {
|
public void logUseAttempt(Player player, Block block, String comment) {
|
||||||
for (BlacklistLoggerHandler handler : handlers) {
|
for (BlacklistLoggerHandler handler : handlers) {
|
||||||
handler.logUseAttempt(player, block);
|
handler.logUseAttempt(player, block, comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,9 +100,9 @@ public void logUseAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDestroyWithAttempt(Player player, int item) {
|
public void logDestroyWithAttempt(Player player, int item, String comment) {
|
||||||
for (BlacklistLoggerHandler handler : handlers) {
|
for (BlacklistLoggerHandler handler : handlers) {
|
||||||
handler.logDestroyWithAttempt(player, item);
|
handler.logDestroyWithAttempt(player, item, comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,9 +112,9 @@ public void logDestroyWithAttempt(Player player, int item) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logCreateAttempt(Player player, int item) {
|
public void logCreateAttempt(Player player, int item, String comment) {
|
||||||
for (BlacklistLoggerHandler handler : handlers) {
|
for (BlacklistLoggerHandler handler : handlers) {
|
||||||
handler.logCreateAttempt(player, item);
|
handler.logCreateAttempt(player, item, comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,9 +124,9 @@ public void logCreateAttempt(Player player, int item) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDropAttempt(Player player, int item) {
|
public void logDropAttempt(Player player, int item, String comment) {
|
||||||
for (BlacklistLoggerHandler handler : handlers) {
|
for (BlacklistLoggerHandler handler : handlers) {
|
||||||
handler.logDropAttempt(player, item);
|
handler.logDropAttempt(player, item, comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,42 +29,42 @@ public interface BlacklistLoggerHandler {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logDestroyAttempt(Player player, Block block);
|
public void logDestroyAttempt(Player player, Block block, String comment);
|
||||||
/**
|
/**
|
||||||
* Log a block break attempt.
|
* Log a block break attempt.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logBreakAttempt(Player player, Block block);
|
public void logBreakAttempt(Player player, Block block, String comment);
|
||||||
/**
|
/**
|
||||||
* Log a right click on attempt.
|
* Log a right click on attempt.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logUseAttempt(Player player, Block block);
|
public void logUseAttempt(Player player, Block block, String comment);
|
||||||
/**
|
/**
|
||||||
* Right a left click attempt.
|
* Right a left click attempt.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDestroyWithAttempt(Player player, int item);
|
public void logDestroyWithAttempt(Player player, int item, String comment);
|
||||||
/**
|
/**
|
||||||
* Log a right click attempt.
|
* Log a right click attempt.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logCreateAttempt(Player player, int item);
|
public void logCreateAttempt(Player player, int item, String comment);
|
||||||
/**
|
/**
|
||||||
* Log a drop attempt.
|
* Log a drop attempt.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDropAttempt(Player player, int item);
|
public void logDropAttempt(Player player, int item, String comment);
|
||||||
/**
|
/**
|
||||||
* Close the logger.
|
* Close the logger.
|
||||||
*/
|
*/
|
||||||
|
@ -36,9 +36,10 @@ public class ConsoleLoggerHandler implements BlacklistLoggerHandler {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logDestroyAttempt(Player player, Block block) {
|
public void logDestroyAttempt(Player player, Block block, String comment) {
|
||||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||||
+ " tried to destroy " + getFriendlyItemName(block.getType()));
|
+ " tried to destroy " + getFriendlyItemName(block.getType())
|
||||||
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,9 +48,10 @@ public void logDestroyAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logBreakAttempt(Player player, Block block) {
|
public void logBreakAttempt(Player player, Block block, String comment) {
|
||||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||||
+ " tried to break " + getFriendlyItemName(block.getType()));
|
+ " tried to break " + getFriendlyItemName(block.getType())
|
||||||
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,9 +60,10 @@ public void logBreakAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logUseAttempt(Player player, Block block) {
|
public void logUseAttempt(Player player, Block block, String comment) {
|
||||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||||
+ " tried to use " + getFriendlyItemName(block.getType()));
|
+ " tried to use " + getFriendlyItemName(block.getType())
|
||||||
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,9 +72,10 @@ public void logUseAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDestroyWithAttempt(Player player, int item) {
|
public void logDestroyWithAttempt(Player player, int item, String comment) {
|
||||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||||
+ " tried to destroy with " + getFriendlyItemName(item));
|
+ " tried to destroy with " + getFriendlyItemName(item)
|
||||||
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,9 +84,10 @@ public void logDestroyWithAttempt(Player player, int item) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logCreateAttempt(Player player, int item) {
|
public void logCreateAttempt(Player player, int item, String comment) {
|
||||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||||
+ " tried to create " + getFriendlyItemName(item));
|
+ " tried to create " + getFriendlyItemName(item)
|
||||||
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,9 +96,10 @@ public void logCreateAttempt(Player player, int item) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDropAttempt(Player player, int item) {
|
public void logDropAttempt(Player player, int item, String comment) {
|
||||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||||
+ " tried to drop " + getFriendlyItemName(item));
|
+ " tried to drop " + getFriendlyItemName(item)
|
||||||
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,14 +91,16 @@ private Connection getConnection() throws SQLException {
|
|||||||
* @param y
|
* @param y
|
||||||
* @param z
|
* @param z
|
||||||
* @param item
|
* @param item
|
||||||
|
* @param comment
|
||||||
*/
|
*/
|
||||||
private void logEvent(String event, String name, int x, int y, int z, int item) {
|
private void logEvent(String event, String name, int x, int y, int z, int item,
|
||||||
|
String comment) {
|
||||||
try {
|
try {
|
||||||
Connection conn = getConnection();
|
Connection conn = getConnection();
|
||||||
PreparedStatement stmt = conn.prepareStatement(
|
PreparedStatement stmt = conn.prepareStatement(
|
||||||
"INSERT INTO " + table
|
"INSERT INTO " + table
|
||||||
+ "(event, player, x, y, z, item, time) VALUES "
|
+ "(event, player, x, y, z, item, time, comment) VALUES "
|
||||||
+ "(?, ?, ?, ?, ?, ?, ?)");
|
+ "(?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
stmt.setString(1, event);
|
stmt.setString(1, event);
|
||||||
stmt.setString(2, name);
|
stmt.setString(2, name);
|
||||||
stmt.setInt(3, x);
|
stmt.setInt(3, x);
|
||||||
@ -106,6 +108,7 @@ private void logEvent(String event, String name, int x, int y, int z, int item)
|
|||||||
stmt.setInt(5, z);
|
stmt.setInt(5, z);
|
||||||
stmt.setInt(6, item);
|
stmt.setInt(6, item);
|
||||||
stmt.setInt(7, (int)(System.currentTimeMillis() / 1000));
|
stmt.setInt(7, (int)(System.currentTimeMillis() / 1000));
|
||||||
|
stmt.setString(8, comment);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
logger.log(Level.SEVERE, "Failed to log blacklist event to database: "
|
logger.log(Level.SEVERE, "Failed to log blacklist event to database: "
|
||||||
@ -119,9 +122,10 @@ private void logEvent(String event, String name, int x, int y, int z, int item)
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logDestroyAttempt(Player player, Block block) {
|
public void logDestroyAttempt(Player player, Block block, String comment) {
|
||||||
logEvent("DESTROY", player.getName(),
|
logEvent("DESTROY", player.getName(),
|
||||||
block.getX(), block.getY(), block.getZ(), block.getType());
|
block.getX(), block.getY(), block.getZ(), block.getType(),
|
||||||
|
comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,9 +134,10 @@ public void logDestroyAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logBreakAttempt(Player player, Block block) {
|
public void logBreakAttempt(Player player, Block block, String comment) {
|
||||||
logEvent("BREAK", player.getName(),
|
logEvent("BREAK", player.getName(),
|
||||||
block.getX(), block.getY(), block.getZ(), block.getType());
|
block.getX(), block.getY(), block.getZ(), block.getType(),
|
||||||
|
comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,9 +146,10 @@ public void logBreakAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logUseAttempt(Player player, Block block) {
|
public void logUseAttempt(Player player, Block block, String comment) {
|
||||||
logEvent("USE", player.getName(),
|
logEvent("USE", player.getName(),
|
||||||
block.getX(), block.getY(), block.getZ(), block.getType());
|
block.getX(), block.getY(), block.getZ(), block.getType(),
|
||||||
|
comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,10 +158,10 @@ public void logUseAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDestroyWithAttempt(Player player, int item) {
|
public void logDestroyWithAttempt(Player player, int item, String comment) {
|
||||||
logEvent("DESTROY_WITH", player.getName(),
|
logEvent("DESTROY_WITH", player.getName(),
|
||||||
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
||||||
(int)Math.floor(player.getZ()), item);
|
(int)Math.floor(player.getZ()), item, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,10 +170,10 @@ public void logDestroyWithAttempt(Player player, int item) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logCreateAttempt(Player player, int item) {
|
public void logCreateAttempt(Player player, int item, String comment) {
|
||||||
logEvent("CREATE", player.getName(),
|
logEvent("CREATE", player.getName(),
|
||||||
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
||||||
(int)Math.floor(player.getZ()), item);
|
(int)Math.floor(player.getZ()), item, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -176,10 +182,10 @@ public void logCreateAttempt(Player player, int item) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDropAttempt(Player player, int item) {
|
public void logDropAttempt(Player player, int item, String comment) {
|
||||||
logEvent("DROP", player.getName(),
|
logEvent("DROP", player.getName(),
|
||||||
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
||||||
(int)Math.floor(player.getZ()), item);
|
(int)Math.floor(player.getZ()), item, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -143,11 +143,12 @@ private String buildPath(String playerName) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
private void log(Player player, String message) {
|
private void log(Player player, String message, String comment) {
|
||||||
String path = buildPath(player.getName());
|
String path = buildPath(player.getName());
|
||||||
try {
|
try {
|
||||||
String date = dateFormat.format(new Date());
|
String date = dateFormat.format(new Date());
|
||||||
String line = "[" + date + "] " + player.getName() + ": " + message + "\r\n";
|
String line = "[" + date + "] " + player.getName() + ": " + message
|
||||||
|
+ (comment != null ? " (" + comment + ")" : "") + "\r\n";
|
||||||
|
|
||||||
FileLoggerWriter writer = writers.get(path);
|
FileLoggerWriter writer = writers.get(path);
|
||||||
|
|
||||||
@ -211,8 +212,9 @@ private void log(Player player, String message) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logDestroyAttempt(Player player, Block block) {
|
public void logDestroyAttempt(Player player, Block block, String comment) {
|
||||||
log(player, "Tried to destroy " + getFriendlyItemName(block.getType()));
|
log(player, "Tried to destroy " + getFriendlyItemName(block.getType()),
|
||||||
|
comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,8 +223,9 @@ public void logDestroyAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logBreakAttempt(Player player, Block block) {
|
public void logBreakAttempt(Player player, Block block, String comment) {
|
||||||
log(player, "Tried to break " + getFriendlyItemName(block.getType()));
|
log(player, "Tried to break " + getFriendlyItemName(block.getType()),
|
||||||
|
comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -231,8 +234,9 @@ public void logBreakAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param block
|
* @param block
|
||||||
*/
|
*/
|
||||||
public void logUseAttempt(Player player, Block block) {
|
public void logUseAttempt(Player player, Block block, String comment) {
|
||||||
log(player, "Tried to use " + getFriendlyItemName(block.getType()));
|
log(player, "Tried to use " + getFriendlyItemName(block.getType()),
|
||||||
|
comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,8 +245,8 @@ public void logUseAttempt(Player player, Block block) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDestroyWithAttempt(Player player, int item) {
|
public void logDestroyWithAttempt(Player player, int item, String comment) {
|
||||||
log(player, "Tried to destroy with " + getFriendlyItemName(item));
|
log(player, "Tried to destroy with " + getFriendlyItemName(item), comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -251,8 +255,8 @@ public void logDestroyWithAttempt(Player player, int item) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logCreateAttempt(Player player, int item) {
|
public void logCreateAttempt(Player player, int item, String comment) {
|
||||||
log(player, "Tried to create " + getFriendlyItemName(item));
|
log(player, "Tried to create " + getFriendlyItemName(item), comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -261,8 +265,8 @@ public void logCreateAttempt(Player player, int item) {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param item
|
* @param item
|
||||||
*/
|
*/
|
||||||
public void logDropAttempt(Player player, int item) {
|
public void logDropAttempt(Player player, int item, String comment) {
|
||||||
log(player, "Tried to drop " + getFriendlyItemName(item));
|
log(player, "Tried to drop " + getFriendlyItemName(item), comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#
|
#
|
||||||
# Options:
|
# Options:
|
||||||
# - ignore-groups (comma-delimited list of groups to not affect)
|
# - ignore-groups (comma-delimited list of groups to not affect)
|
||||||
|
# - comment (message for yourself that is printed with 'log' and 'notify')
|
||||||
|
# - message (optional message to show the user instead; %s is the item name)
|
||||||
#
|
#
|
||||||
# Events:
|
# Events:
|
||||||
# - on-destroy (when a block of this type is being destroyed)
|
# - on-destroy (when a block of this type is being destroyed)
|
||||||
@ -71,4 +73,9 @@
|
|||||||
#on-create=deny,tell,log
|
#on-create=deny,tell,log
|
||||||
|
|
||||||
#[lever]
|
#[lever]
|
||||||
#on-break=deny
|
#on-break=deny
|
||||||
|
|
||||||
|
#[diamondpickaxe,woodpickaxe]
|
||||||
|
#on-drop=deny
|
||||||
|
#comment=durability cheat
|
||||||
|
#message=Your item was destroyed
|
Loading…
Reference in New Issue
Block a user