Fix and re-enable AuthMe hook

This commit is contained in:
Dan Mulloy 2016-08-20 16:17:10 -04:00
parent 02d18df559
commit 5749c84c28
4 changed files with 35 additions and 12 deletions

10
pom.xml
View File

@ -69,9 +69,9 @@
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.10-R0.1-SNAPSHOT</version>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@ -144,11 +144,10 @@
</exclusions>
</dependency>
<!--
<dependency>
<groupId>fr.xephi</groupId>
<artifactId>authme</artifactId>
<version>5.0-SNAPSHOT</version>
<version>5.2-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@ -161,7 +160,6 @@
</exclusion>
</exclusions>
</dependency>
-->
<dependency>
<groupId>com.griefcraft.lwc</groupId>

View File

@ -43,6 +43,7 @@ import org.bukkit.Server;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.Event;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.mcstats.Metrics;
@ -213,7 +214,8 @@ public class ChestShop extends JavaPlugin {
registerEvent(new ItemInfoListener());
registerEvent(new GarbageTextListener());
if (this.getServer().getPluginManager().getPlugin("AuthMe") != null && this.getServer().getPluginManager().getPlugin("ChestShop").isEnabled()){
Plugin authMe = getServer().getPluginManager().getPlugin("AuthMe");
if (authMe != null && authMe.isEnabled()){
registerEvent(new AuthMeChestShopListener());
}

View File

@ -127,7 +127,14 @@ 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

@ -1,27 +1,43 @@
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.Configuration.Properties;
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();
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 (!Properties.AUTHME_HOOK) {
return;
}
if (AuthMeAPI.isUnrestricted(player)) {
return;
}
if (!AuthMeAPI.isRegistered(player.getName()) && Properties.AUTHME_ALLOW_UNREGISTERED) {
return;
}
if (AuthMeAPI.isAuthenticated(player)) {
return;
}
event.setCancelled(TransactionOutcome.CLIENT_DOES_NOT_HAVE_PERMISSION);
}*/
}
}
}