Merge pull request #44 from sgdc3/1.8.X

Fix authme hook (final)
This commit is contained in:
Andrzej Pomirski 2016-04-06 11:34:06 +02:00
commit cfd8cff209
4 changed files with 18 additions and 7 deletions

View File

@ -147,17 +147,13 @@
<dependency>
<groupId>fr.xephi</groupId>
<artifactId>authme</artifactId>
<version>5.0-SNAPSHOT</version>
<version>5.2-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>

View File

@ -213,7 +213,7 @@ public class ChestShop extends JavaPlugin {
registerEvent(new ItemInfoListener());
registerEvent(new GarbageTextListener());
if (this.getServer().getPluginManager().getPlugin("AuthMe") != null && this.getServer().getPluginManager().getPlugin("ChestShop").isEnabled()){
if (this.getServer().getPluginManager().getPlugin("AuthMe") != null && this.getServer().getPluginManager().getPlugin("AuthMe").isEnabled()){
registerEvent(new AuthMeChestShopListener());
}

View File

@ -127,6 +127,13 @@ public class Properties {
@ConfigurationComment("Do you want ChestShop to respect WorldGuard's chest protection?")
public static boolean WORLDGUARD_USE_PROTECTION = false;
@PrecededBySpace
@ConfigurationComment("Do you want to deny shop access to unlogged users?")
public static boolean AUTHME_HOOK = true;
@ConfigurationComment("Do you want to allow shop access to unregistered users? (Example: registration is optional)")
public static boolean AUTHME_ALLOW_UNREGISTERED = false;
@PrecededBySpace
@ConfigurationComment("How much Heroes exp should people get for creating a ChestShop?")
public static double HEROES_EXP = 100;

View File

@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import com.Acrobot.ChestShop.Events.PreTransactionEvent.TransactionOutcome;
@ -19,13 +20,20 @@ public class AuthMeChestShopListener implements Listener {
if (event.getClient() == null) {
return;
}
Player player = event.getClient();
if (!Properties.AUTHME_HOOK) {
return;
}
if (AuthMeAPI.isUnrestricted(player)) {
return;
}
if (!AuthMeAPI.isRegistered(player.getName()) && Properties.AUTHME_ALLOW_UNREGISTERED) {
return;
}
if (AuthMeAPI.isAuthenticated(player)) {
return;
}