mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-02-17 04:11:33 +01:00
General npc support, fixes and enhancements
This commit is contained in:
parent
c473e81eb9
commit
026d84427b
24
pom.xml
24
pom.xml
@ -129,12 +129,6 @@
|
||||
<url>https://ci.drtshock.net/plugin/repository/everything</url>
|
||||
</repository>
|
||||
|
||||
<!-- Citizens API 2.X Repo -->
|
||||
<repository>
|
||||
<id>citizensapi-repo</id>
|
||||
<url>http://ci.citizensnpcs.co/plugin/repository/project/CitizensAPI/LastSuccessful/repository</url>
|
||||
</repository>
|
||||
|
||||
<!-- CombatTagPlus Repo -->
|
||||
<repository>
|
||||
<id>minelink-thirdparty</id>
|
||||
@ -299,24 +293,6 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Citizens 2.X, NPC plugin, http://dev.bukkit.org/bukkit-plugins/citizens/ -->
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizensapi</artifactId>
|
||||
<version>2.0.16-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>
|
||||
|
||||
<!-- Multi World plugin, http://www.spigotmc.org/resources/multiverse-core.390/ -->
|
||||
<dependency>
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
|
@ -16,7 +16,6 @@ import fr.xephi.authme.converter.ForceFlatToSqlite;
|
||||
import fr.xephi.authme.datasource.*;
|
||||
import fr.xephi.authme.listener.*;
|
||||
import fr.xephi.authme.plugin.manager.BungeeCordMessage;
|
||||
import fr.xephi.authme.plugin.manager.CitizensCommunicator;
|
||||
import fr.xephi.authme.plugin.manager.CombatTagComunicator;
|
||||
import fr.xephi.authme.plugin.manager.EssSpawn;
|
||||
import fr.xephi.authme.process.Management;
|
||||
@ -71,8 +70,6 @@ public class AuthMe extends JavaPlugin {
|
||||
public Location essentialsSpawn;
|
||||
public MultiverseCore multiverse;
|
||||
public LookupService lookupService;
|
||||
public CitizensCommunicator citizens;
|
||||
public boolean isCitizensActive = false;
|
||||
public boolean CombatTag = false;
|
||||
public boolean legacyChestShop = false;
|
||||
public boolean antibotMod = false;
|
||||
@ -98,9 +95,6 @@ public class AuthMe extends JavaPlugin {
|
||||
return m;
|
||||
}
|
||||
|
||||
public CitizensCommunicator getCitizensCommunicator() {
|
||||
return citizens;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -182,10 +176,6 @@ public class AuthMe extends JavaPlugin {
|
||||
// Find Permissions
|
||||
checkVault();
|
||||
|
||||
// Check Citizens Version
|
||||
citizens = new CitizensCommunicator(this);
|
||||
checkCitizens();
|
||||
|
||||
// Check Combat Tag Version
|
||||
checkCombatTag();
|
||||
|
||||
@ -515,11 +505,6 @@ public class AuthMe extends JavaPlugin {
|
||||
this.CombatTag = server.getPluginManager().isPluginEnabled("CombatTag");
|
||||
}
|
||||
|
||||
// Check if Citizens is active
|
||||
public void checkCitizens() {
|
||||
this.isCitizensActive = server.getPluginManager().isPluginEnabled("Citizens");
|
||||
}
|
||||
|
||||
// Check if a player/command sender have a permission
|
||||
public boolean authmePermissible(Player player, String perm) {
|
||||
if (player.hasPermission(perm)) {
|
||||
@ -541,7 +526,7 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
// Save Player Data
|
||||
public void savePlayer(Player player) {
|
||||
if ((citizens.isNPC(player)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
|
||||
if ((utils.isNPC(player)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
|
||||
return;
|
||||
}
|
||||
String name = player.getName().toLowerCase();
|
||||
|
@ -14,14 +14,13 @@ import java.util.logging.Logger;
|
||||
public class ConsoleLogger {
|
||||
|
||||
private static final Logger log = AuthMe.getInstance().getLogger();
|
||||
private static final DateFormat format = DateFormat.getDateTimeInstance();
|
||||
|
||||
|
||||
public static void info(String message) {
|
||||
if (AuthMe.getInstance().isEnabled()) {
|
||||
log.info("[AuthMe] " + message);
|
||||
if (Settings.useLogging) {
|
||||
writeLog("[" + format.format(new Date()) + "] " + message);
|
||||
writeLog("[" + DateFormat.getDateTimeInstance().format(new Date()) + "] " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -30,7 +29,7 @@ public class ConsoleLogger {
|
||||
if (AuthMe.getInstance().isEnabled()) {
|
||||
log.warning("[AuthMe] " + message);
|
||||
if (Settings.useLogging) {
|
||||
writeLog("[" + format.format(new Date()) + "] ERROR: " + message);
|
||||
writeLog("[" + DateFormat.getDateTimeInstance().format(new Date()) + "] ERROR: " + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
@ -211,4 +212,12 @@ public class Utils {
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean isNPC(final Entity player) {
|
||||
try {
|
||||
return player.hasMetadata("NPC");
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class API {
|
||||
|
||||
public static final String newline = System.getProperty("line.separator");
|
||||
public static AuthMe instance;
|
||||
private Utils utils = Utils.getInstance();
|
||||
|
||||
@Deprecated
|
||||
public API(AuthMe instance) {
|
||||
@ -65,7 +66,7 @@ public class API {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isaNPC(Player player) {
|
||||
if (instance.getCitizensCommunicator().isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return true;
|
||||
return CombatTagComunicator.isNPC(player);
|
||||
}
|
||||
@ -77,7 +78,7 @@ public class API {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isNPC(Player player) {
|
||||
if (instance.getCitizensCommunicator().isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return true;
|
||||
return CombatTagComunicator.isNPC(player);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ public class NewAPI {
|
||||
public static final String newline = System.getProperty("line.separator");
|
||||
public static NewAPI singleton;
|
||||
public AuthMe plugin;
|
||||
private Utils utils = Utils.getInstance();
|
||||
|
||||
public NewAPI(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -70,7 +71,7 @@ public class NewAPI {
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
public boolean isNPC(Player player) {
|
||||
return plugin.getCitizensCommunicator().isNPC(player) || CombatTagComunicator.isNPC(player);
|
||||
return utils.isNPC(player) || CombatTagComunicator.isNPC(player);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class JsonCache {
|
||||
|
||||
|
@ -263,6 +263,7 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
|
||||
rs.close();
|
||||
pst.close();
|
||||
pst = con.prepareStatement("SELECT * FROM xf_user_authenticate WHERE " + columnID + "=?;");
|
||||
pst.setInt(1, id);
|
||||
rs = pst.executeQuery();
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.event.entity.*;
|
||||
public class AuthMeEntityListener implements Listener {
|
||||
|
||||
public AuthMe instance;
|
||||
private Utils utils = Utils.getInstance();
|
||||
|
||||
public AuthMeEntityListener(AuthMe instance) {
|
||||
this.instance = instance;
|
||||
@ -32,7 +33,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(entity))
|
||||
if (utils.isNPC(entity))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
@ -64,7 +65,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(entity))
|
||||
if (utils.isNPC(entity))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
@ -114,7 +115,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(entity))
|
||||
if (utils.isNPC(entity))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
@ -141,7 +142,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(entity))
|
||||
if (utils.isNPC(entity))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
@ -174,7 +175,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
||||
@ -202,7 +203,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
||||
|
@ -40,6 +40,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||
private Messages m = Messages.getInstance();
|
||||
public AuthMe plugin;
|
||||
private Utils utils = Utils.getInstance();
|
||||
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||
private List<String> antibot = new ArrayList<>();
|
||||
|
||||
@ -305,7 +306,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (utils.isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -440,7 +441,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
final String name = player.getName().toLowerCase();
|
||||
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (utils.isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -608,7 +609,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
@ -636,7 +637,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
@ -667,7 +668,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player)) {
|
||||
if (utils.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -693,7 +694,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (Utils.getInstance().isUnrestricted(player)) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return;
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
return;
|
||||
@ -732,7 +733,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
@ -762,7 +763,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player)) {
|
||||
if (utils.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -786,7 +787,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (utils.isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -814,7 +815,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
@ -886,7 +887,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
|
||||
return;
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
@ -921,7 +922,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
|
||||
return;
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
if (utils.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
|
@ -63,10 +63,6 @@ public class AuthMeServerListener implements Listener {
|
||||
plugin.CombatTag = false;
|
||||
ConsoleLogger.info("CombatTag has been disabled, unhook!");
|
||||
}
|
||||
if (pluginName.equalsIgnoreCase("Citizens")) {
|
||||
plugin.isCitizensActive = false;
|
||||
ConsoleLogger.info("Citizens has been disabled, unhook!");
|
||||
}
|
||||
if (pluginName.equalsIgnoreCase("Vault")) {
|
||||
plugin.permission = null;
|
||||
ConsoleLogger.showError("Vault has been disabled, unhook permissions!");
|
||||
@ -84,8 +80,6 @@ public class AuthMeServerListener implements Listener {
|
||||
plugin.checkChestShop();
|
||||
if (pluginName.equalsIgnoreCase("CombatTag"))
|
||||
plugin.checkCombatTag();
|
||||
if (pluginName.equalsIgnoreCase("Citizens"))
|
||||
plugin.checkCitizens();
|
||||
if (pluginName.equalsIgnoreCase("Vault"))
|
||||
plugin.checkVault();
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
package fr.xephi.authme.plugin.manager;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
|
||||
public class CitizensCommunicator {
|
||||
|
||||
public AuthMe instance;
|
||||
|
||||
public CitizensCommunicator(AuthMe instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public boolean isNPC(final Entity player) {
|
||||
if (!this.instance.isCitizensActive)
|
||||
return false;
|
||||
try {
|
||||
return CitizensAPI.getNPCRegistry().isNPC(player);
|
||||
} catch (NoClassDefFoundError ncdfe) {
|
||||
return false;
|
||||
} catch (Exception npe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ public class AsyncronousJoin {
|
||||
AuthMePlayerListener.gameMode.putIfAbsent(name, player.getGameMode());
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (utils.isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class AsyncronousQuit {
|
||||
public void process() {
|
||||
if (player == null)
|
||||
return;
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (utils.isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@ package fr.xephi.authme.settings;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Messages extends CustomConfiguration {
|
||||
|
Loading…
Reference in New Issue
Block a user