Moved AuthMe hook to ChestShop using the API

This commit is contained in:
Gabriele C 2015-08-06 15:59:51 +02:00
parent 27688735ad
commit be26bea03c
3 changed files with 62 additions and 0 deletions

21
pom.xml
View File

@ -36,6 +36,10 @@
<id>heroes-repo</id>
<url>http://nexus.theyeticave.net/content/repositories/pub_snapshots/</url>
</repository>
<repository>
<id>authme-repo</id>
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
</repository>
<repository>
<id>local_repo</id>
<url>file://${project.basedir}/repo/</url>
@ -140,6 +144,23 @@
</exclusions>
</dependency>
<dependency>
<groupId>fr.xephi</groupId>
<artifactId>authme</artifactId>
<version>5.0-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.griefcraft.lwc</groupId>
<artifactId>lwc</artifactId>

View File

@ -14,6 +14,7 @@ import com.Acrobot.ChestShop.Listeners.Block.Break.SignBreak;
import com.Acrobot.ChestShop.Listeners.Block.SignCreate;
import com.Acrobot.ChestShop.Listeners.Economy.ServerAccountCorrector;
import com.Acrobot.ChestShop.Listeners.Economy.TaxModule;
import com.Acrobot.ChestShop.Listeners.AuthMeChestShopListener;
import com.Acrobot.ChestShop.Listeners.GarbageTextListener;
import com.Acrobot.ChestShop.Listeners.Item.ItemMoveListener;
import com.Acrobot.ChestShop.Listeners.ItemInfoListener;
@ -36,6 +37,7 @@ import com.Acrobot.ChestShop.Metadata.ItemDatabase;
import com.Acrobot.ChestShop.Signs.RestrictedSign;
import com.Acrobot.ChestShop.UUIDs.NameManager;
import com.Acrobot.ChestShop.Updater.Updater;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.configuration.file.YamlConfiguration;
@ -211,6 +213,10 @@ public class ChestShop extends JavaPlugin {
registerEvent(new ItemInfoListener());
registerEvent(new GarbageTextListener());
if (this.getServer().getPluginManager().getPlugin("AuthMe") != null && this.getServer().getPluginManager().getPlugin("ChestShop").isEnabled()){
registerEvent(new AuthMeChestShopListener());
}
registerEvent(new RestrictedSign());
if (!Properties.TURN_OFF_HOPPER_PROTECTION) {

View File

@ -0,0 +1,35 @@
package com.Acrobot.ChestShop.Listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome;
import fr.xephi.authme.api.NewAPI;
public class AuthMeChestShopListener implements Listener {
NewAPI AuthMeAPI = NewAPI.getInstance();
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPreTransaction(PreTransactionEvent event) {
if (event.getClient() == null) {
return;
}
Player player = event.getClient();
if (AuthMeAPI.isUnrestricted(player)) {
return;
}
if (AuthMeAPI.isAuthenticated(player)) {
return;
}
event.setCancelled(TransactionOutcome.OTHER);
}
}