2013-08-07 02:03:09 +02:00
|
|
|
package com.Acrobot.ChestShop.Listeners.ShopRemoval;
|
|
|
|
|
|
|
|
import com.Acrobot.Breeze.Utils.LocationUtil;
|
|
|
|
import com.Acrobot.ChestShop.ChestShop;
|
2019-04-01 14:49:48 +02:00
|
|
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
2013-08-07 02:03:09 +02:00
|
|
|
import com.Acrobot.ChestShop.Events.ShopDestroyedEvent;
|
|
|
|
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
|
|
|
public class ShopRemovalLogger implements Listener {
|
2019-04-01 14:49:48 +02:00
|
|
|
private static final String REMOVAL_MESSAGE = "%1$s was removed by %2$s - %3$s - %4$s - at %5$s";
|
2013-08-07 02:03:09 +02:00
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
|
|
|
public static void onShopRemoval(final ShopDestroyedEvent event) {
|
2019-04-01 14:49:48 +02:00
|
|
|
if (Properties.LOG_ALL_SHOP_REMOVALS || event.getDestroyer() != null) {
|
2013-12-07 18:31:25 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-03-23 23:50:08 +01:00
|
|
|
ChestShop.runInAsyncThread(() -> {
|
2022-01-26 20:35:42 +01:00
|
|
|
String shopOwner = ChestShopSign.getOwner(event.getSign());
|
|
|
|
String typeOfShop = ChestShopSign.isAdminShop(shopOwner) ? "An Admin Shop" : "A shop belonging to " + shopOwner;
|
2013-08-07 02:03:09 +02:00
|
|
|
|
2022-01-26 20:35:42 +01:00
|
|
|
String item = ChestShopSign.getQuantity(event.getSign()) + ' ' + ChestShopSign.getItem(event.getSign());
|
|
|
|
String prices = ChestShopSign.getPrice(event.getSign());
|
|
|
|
String location = LocationUtil.locationToString(event.getSign().getLocation());
|
2013-08-07 02:03:09 +02:00
|
|
|
|
2022-01-26 20:35:42 +01:00
|
|
|
String message = String.format(REMOVAL_MESSAGE,
|
|
|
|
typeOfShop,
|
|
|
|
event.getDestroyer() != null ? event.getDestroyer().getName() : "???",
|
|
|
|
item,
|
|
|
|
prices,
|
|
|
|
location);
|
2013-08-07 02:03:09 +02:00
|
|
|
|
2022-01-26 20:35:42 +01:00
|
|
|
ChestShop.getBukkitLogger().info(message);
|
2013-08-07 02:03:09 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|