2015-08-06 15:59:51 +02:00
|
|
|
package com.Acrobot.ChestShop.Listeners;
|
|
|
|
|
2018-10-15 21:27:17 +02:00
|
|
|
import fr.xephi.authme.api.v3.AuthMeApi;
|
2016-08-20 22:17:10 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
2015-08-06 15:59:51 +02:00
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
|
2016-08-20 22:17:10 +02:00
|
|
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
|
|
|
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
|
|
|
|
import com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome;
|
|
|
|
|
2015-08-06 15:59:51 +02:00
|
|
|
public class AuthMeChestShopListener implements Listener {
|
|
|
|
|
2018-10-15 21:27:17 +02:00
|
|
|
private AuthMeApi authmeApi = AuthMeApi.getInstance();
|
2015-08-06 15:59:51 +02:00
|
|
|
|
|
|
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
|
|
|
public void onPreTransaction(PreTransactionEvent event) {
|
|
|
|
if (event.getClient() == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Player player = event.getClient();
|
|
|
|
|
2016-08-20 22:17:10 +02:00
|
|
|
if (!Properties.AUTHME_HOOK) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-15 21:27:17 +02:00
|
|
|
if (authmeApi.isUnrestricted(player)) {
|
2015-08-06 15:59:51 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-15 21:27:17 +02:00
|
|
|
if (!authmeApi.isRegistered(player.getName()) && Properties.AUTHME_ALLOW_UNREGISTERED) {
|
2016-08-20 22:17:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-15 21:27:17 +02:00
|
|
|
if (authmeApi.isAuthenticated(player)) {
|
2015-08-06 15:59:51 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-08-07 15:18:21 +02:00
|
|
|
|
2015-08-07 15:15:35 +02:00
|
|
|
event.setCancelled(TransactionOutcome.CLIENT_DOES_NOT_HAVE_PERMISSION);
|
2016-08-20 22:17:10 +02:00
|
|
|
}
|
|
|
|
}
|