mirror of
https://e.coding.net/circlecloud/AuthMe.git
synced 2024-12-22 06:48:55 +00:00
移除无用的事件和接口...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
e926547f83
commit
2d2ab1e4bd
@ -46,10 +46,7 @@ import cn.citycraft.AuthMe.datasource.SQLite;
|
|||||||
import cn.citycraft.AuthMe.datasource.SQLite_HIKARI;
|
import cn.citycraft.AuthMe.datasource.SQLite_HIKARI;
|
||||||
import cn.citycraft.AuthMe.listener.AuthMeBlockListener;
|
import cn.citycraft.AuthMe.listener.AuthMeBlockListener;
|
||||||
import cn.citycraft.AuthMe.listener.AuthMeEntityListener;
|
import cn.citycraft.AuthMe.listener.AuthMeEntityListener;
|
||||||
import cn.citycraft.AuthMe.listener.AuthMeInventoryPacketAdapter;
|
|
||||||
import cn.citycraft.AuthMe.listener.AuthMePlayerListener;
|
import cn.citycraft.AuthMe.listener.AuthMePlayerListener;
|
||||||
import cn.citycraft.AuthMe.listener.AuthMePlayerListener16;
|
|
||||||
import cn.citycraft.AuthMe.listener.AuthMePlayerListener18;
|
|
||||||
import cn.citycraft.AuthMe.listener.AuthMeServerListener;
|
import cn.citycraft.AuthMe.listener.AuthMeServerListener;
|
||||||
import cn.citycraft.AuthMe.plugin.manager.BungeeCordMessage;
|
import cn.citycraft.AuthMe.plugin.manager.BungeeCordMessage;
|
||||||
import cn.citycraft.AuthMe.plugin.manager.EssSpawn;
|
import cn.citycraft.AuthMe.plugin.manager.EssSpawn;
|
||||||
@ -83,7 +80,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
public boolean delayedAntiBot = true;
|
public boolean delayedAntiBot = true;
|
||||||
public Essentials ess;
|
public Essentials ess;
|
||||||
public Location essentialsSpawn;
|
public Location essentialsSpawn;
|
||||||
public AuthMeInventoryPacketAdapter inventoryProtector;
|
|
||||||
public Management management;
|
public Management management;
|
||||||
|
|
||||||
public OtherAccounts otherAccounts;
|
public OtherAccounts otherAccounts;
|
||||||
@ -145,19 +141,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the presence of the ProtocolLib plugin
|
|
||||||
public void checkProtocolLib() {
|
|
||||||
if (Settings.protectInventoryBeforeLogInEnabled) {
|
|
||||||
if (server.getPluginManager().isPluginEnabled("ProtocolLib")) {
|
|
||||||
inventoryProtector = new AuthMeInventoryPacketAdapter(this);
|
|
||||||
inventoryProtector.register();
|
|
||||||
} else {
|
|
||||||
ConsoleLogger.showError("警告!!! 服务器内未找到 ProtocolLib 插件 关闭背包保护功能...");
|
|
||||||
Settings.protectInventoryBeforeLogInEnabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the presence of the Vault plugin and a permissions provider
|
// Check the presence of the Vault plugin and a permissions provider
|
||||||
public void checkVault() {
|
public void checkVault() {
|
||||||
if (server.getPluginManager().isPluginEnabled("Vault")) {
|
if (server.getPluginManager().isPluginEnabled("Vault")) {
|
||||||
@ -364,10 +347,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
// Check Essentials
|
// Check Essentials
|
||||||
checkEssentials();
|
checkEssentials();
|
||||||
|
|
||||||
// Check if the protocollib is available. If so we could listen for
|
|
||||||
// inventory protection
|
|
||||||
checkProtocolLib();
|
|
||||||
|
|
||||||
// Do backup on start if enabled
|
// Do backup on start if enabled
|
||||||
if (Settings.isBackupActivated && Settings.isBackupOnStart) {
|
if (Settings.isBackupActivated && Settings.isBackupOnStart) {
|
||||||
// Do backup and check return value!
|
// Do backup and check return value!
|
||||||
@ -431,18 +410,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
pm.registerEvents(new AuthMePlayerListener(this), this);
|
pm.registerEvents(new AuthMePlayerListener(this), this);
|
||||||
// Try to register 1.6 player listeners
|
|
||||||
try {
|
|
||||||
Class.forName("org.bukkit.event.player.PlayerEditBookEvent");
|
|
||||||
pm.registerEvents(new AuthMePlayerListener16(this), this);
|
|
||||||
} catch (final ClassNotFoundException ignore) {
|
|
||||||
}
|
|
||||||
// Try to register 1.8 player listeners
|
|
||||||
try {
|
|
||||||
Class.forName("org.bukkit.event.player.PlayerInteractAtEntityEvent");
|
|
||||||
pm.registerEvents(new AuthMePlayerListener18(this), this);
|
|
||||||
} catch (final ClassNotFoundException ignore) {
|
|
||||||
}
|
|
||||||
pm.registerEvents(new AuthMeBlockListener(this), this);
|
pm.registerEvents(new AuthMeBlockListener(this), this);
|
||||||
pm.registerEvents(new AuthMeEntityListener(this), this);
|
pm.registerEvents(new AuthMeEntityListener(this), this);
|
||||||
pm.registerEvents(new AuthMeServerListener(this), this);
|
pm.registerEvents(new AuthMeServerListener(this), this);
|
||||||
|
@ -2,7 +2,6 @@ package cn.citycraft.AuthMe.cache.limbo;
|
|||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -12,21 +11,10 @@ import cn.citycraft.AuthMe.ConsoleLogger;
|
|||||||
import cn.citycraft.AuthMe.cache.backup.DataFileCache;
|
import cn.citycraft.AuthMe.cache.backup.DataFileCache;
|
||||||
import cn.citycraft.AuthMe.cache.backup.JsonCache;
|
import cn.citycraft.AuthMe.cache.backup.JsonCache;
|
||||||
import cn.citycraft.AuthMe.settings.Settings;
|
import cn.citycraft.AuthMe.settings.Settings;
|
||||||
import fr.xephi.authme.events.ResetInventoryEvent;
|
|
||||||
import fr.xephi.authme.events.StoreInventoryEvent;
|
|
||||||
|
|
||||||
public class LimboCache {
|
public class LimboCache {
|
||||||
|
|
||||||
private volatile static LimboCache singleton;
|
private volatile static LimboCache singleton;
|
||||||
public ConcurrentHashMap<String, LimboPlayer> cache;
|
|
||||||
public AuthMe plugin;
|
|
||||||
private JsonCache playerData;
|
|
||||||
|
|
||||||
private LimboCache(AuthMe plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.cache = new ConcurrentHashMap<>();
|
|
||||||
this.playerData = new JsonCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LimboCache getInstance() {
|
public static LimboCache getInstance() {
|
||||||
if (singleton == null) {
|
if (singleton == null) {
|
||||||
@ -35,8 +23,19 @@ public class LimboCache {
|
|||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLimboPlayer(Player player) {
|
public ConcurrentHashMap<String, LimboPlayer> cache;
|
||||||
String name = player.getName().toLowerCase();
|
public AuthMe plugin;
|
||||||
|
|
||||||
|
private final JsonCache playerData;
|
||||||
|
|
||||||
|
private LimboCache(final AuthMe plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.cache = new ConcurrentHashMap<>();
|
||||||
|
this.playerData = new JsonCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLimboPlayer(final Player player) {
|
||||||
|
final String name = player.getName().toLowerCase();
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
GameMode gameMode = player.getGameMode();
|
GameMode gameMode = player.getGameMode();
|
||||||
boolean operator = false;
|
boolean operator = false;
|
||||||
@ -44,33 +43,19 @@ public class LimboCache {
|
|||||||
boolean flying = false;
|
boolean flying = false;
|
||||||
|
|
||||||
if (playerData.doesCacheExist(player)) {
|
if (playerData.doesCacheExist(player)) {
|
||||||
final StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
|
final DataFileCache cache = playerData.readCache(player);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
|
|
||||||
player.getInventory().setContents(event.getInventory());
|
|
||||||
player.getInventory().setArmorContents(event.getArmor());
|
|
||||||
}
|
|
||||||
|
|
||||||
DataFileCache cache = playerData.readCache(player);
|
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
playerGroup = cache.getGroup();
|
playerGroup = cache.getGroup();
|
||||||
operator = cache.getOperator();
|
operator = cache.getOperator();
|
||||||
flying = cache.isFlying();
|
flying = cache.isFlying();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
StoreInventoryEvent event = new StoreInventoryEvent(player);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
|
|
||||||
player.getInventory().setContents(event.getInventory());
|
|
||||||
player.getInventory().setArmorContents(event.getArmor());
|
|
||||||
}
|
|
||||||
|
|
||||||
operator = player.isOp();
|
operator = player.isOp();
|
||||||
flying = player.isFlying();
|
flying = player.isFlying();
|
||||||
if (plugin.permission != null) {
|
if (plugin.permission != null) {
|
||||||
try {
|
try {
|
||||||
playerGroup = plugin.permission.getPrimaryGroup(player);
|
playerGroup = plugin.permission.getPrimaryGroup(player);
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (final UnsupportedOperationException e) {
|
||||||
ConsoleLogger.showError("Your permission system (" + plugin.permission.getName() + ") do not support Group system with that config... unhook!");
|
ConsoleLogger.showError("Your permission system (" + plugin.permission.getName() + ") do not support Group system with that config... unhook!");
|
||||||
plugin.permission = null;
|
plugin.permission = null;
|
||||||
}
|
}
|
||||||
@ -78,14 +63,6 @@ public class LimboCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.isForceSurvivalModeEnabled) {
|
if (Settings.isForceSurvivalModeEnabled) {
|
||||||
if (Settings.isResetInventoryIfCreative && gameMode == GameMode.CREATIVE) {
|
|
||||||
ResetInventoryEvent event = new ResetInventoryEvent(player);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
player.getInventory().clear();
|
|
||||||
player.sendMessage("Your inventory has been cleaned!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (gameMode == GameMode.CREATIVE) {
|
if (gameMode == GameMode.CREATIVE) {
|
||||||
flying = false;
|
flying = false;
|
||||||
}
|
}
|
||||||
@ -97,23 +74,23 @@ public class LimboCache {
|
|||||||
cache.put(name, new LimboPlayer(name, loc, gameMode, operator, playerGroup, flying));
|
cache.put(name, new LimboPlayer(name, loc, gameMode, operator, playerGroup, flying));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLimboPlayer(Player player, String group) {
|
public void addLimboPlayer(final Player player, final String group) {
|
||||||
cache.put(player.getName().toLowerCase(), new LimboPlayer(player.getName().toLowerCase(), group));
|
cache.put(player.getName().toLowerCase(), new LimboPlayer(player.getName().toLowerCase(), group));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteLimboPlayer(String name) {
|
public void deleteLimboPlayer(final String name) {
|
||||||
cache.remove(name);
|
cache.remove(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LimboPlayer getLimboPlayer(String name) {
|
public LimboPlayer getLimboPlayer(final String name) {
|
||||||
return cache.get(name);
|
return cache.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasLimboPlayer(String name) {
|
public boolean hasLimboPlayer(final String name) {
|
||||||
return cache.containsKey(name);
|
return cache.containsKey(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLimboPlayer(Player player) {
|
public void updateLimboPlayer(final Player player) {
|
||||||
if (this.hasLimboPlayer(player.getName().toLowerCase())) {
|
if (this.hasLimboPlayer(player.getName().toLowerCase())) {
|
||||||
this.deleteLimboPlayer(player.getName().toLowerCase());
|
this.deleteLimboPlayer(player.getName().toLowerCase());
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import cn.citycraft.AuthMe.AuthMe;
|
import cn.citycraft.AuthMe.AuthMe;
|
||||||
import cn.citycraft.AuthMe.cache.auth.PlayerAuth;
|
import cn.citycraft.AuthMe.cache.auth.PlayerAuth;
|
||||||
import cn.citycraft.AuthMe.security.RandomString;
|
|
||||||
import cn.citycraft.AuthMe.settings.Messages;
|
import cn.citycraft.AuthMe.settings.Messages;
|
||||||
import cn.citycraft.AuthMe.settings.Settings;
|
import cn.citycraft.AuthMe.settings.Settings;
|
||||||
|
|
||||||
@ -15,14 +14,14 @@ public class RegisterCommand implements CommandExecutor {
|
|||||||
|
|
||||||
public PlayerAuth auth;
|
public PlayerAuth auth;
|
||||||
public AuthMe plugin;
|
public AuthMe plugin;
|
||||||
private Messages m = Messages.getInstance();
|
private final Messages m = Messages.getInstance();
|
||||||
|
|
||||||
public RegisterCommand(AuthMe plugin) {
|
public RegisterCommand(final AuthMe plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmnd, String label, String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command cmnd, final String label, final String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Player Only! Use 'authme register <playername> <password>' instead");
|
sender.sendMessage("Player Only! Use 'authme register <playername> <password>' instead");
|
||||||
return true;
|
return true;
|
||||||
@ -36,28 +35,30 @@ public class RegisterCommand implements CommandExecutor {
|
|||||||
m.send(player, "no_perm");
|
m.send(player, "no_perm");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
// TODO 计划删除邮箱功能
|
||||||
if (Settings.doubleEmailCheck) {
|
// if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
|
||||||
if (args.length < 2 || !args[0].equals(args[1])) {
|
// if (Settings.doubleEmailCheck) {
|
||||||
m.send(player, "usage_reg");
|
// if (args.length < 2 || !args[0].equals(args[1])) {
|
||||||
return true;
|
// m.send(player, "usage_reg");
|
||||||
}
|
// return true;
|
||||||
}
|
// }
|
||||||
final String email = args[0];
|
// }
|
||||||
if (!Settings.isEmailCorrect(email)) {
|
// final String email = args[0];
|
||||||
m.send(player, "email_invalid");
|
// if (!Settings.isEmailCorrect(email)) {
|
||||||
return true;
|
// m.send(player, "email_invalid");
|
||||||
}
|
// return true;
|
||||||
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
|
// }
|
||||||
final String thePass = rand.nextString();
|
// RandomString rand = new RandomString(Settings.getRecoveryPassLength);
|
||||||
plugin.management.performRegister(player, thePass, email);
|
// final String thePass = rand.nextString();
|
||||||
return true;
|
// plugin.management.performRegister(player, thePass, email);
|
||||||
}
|
// return true;
|
||||||
if (args.length > 1 && Settings.getEnablePasswordVerifier)
|
// }
|
||||||
|
if (args.length > 1 && Settings.getEnablePasswordVerifier) {
|
||||||
if (!args[0].equals(args[1])) {
|
if (!args[0].equals(args[1])) {
|
||||||
m.send(player, "password_error");
|
m.send(player, "password_error");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
plugin.management.performRegister(player, args[0], "");
|
plugin.management.performRegister(player, args[0], "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2015 AuthMe-Team
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package cn.citycraft.AuthMe.listener;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
|
|
||||||
import cn.citycraft.AuthMe.AuthMe;
|
|
||||||
import cn.citycraft.AuthMe.cache.auth.PlayerCache;
|
|
||||||
import cn.citycraft.AuthMe.settings.Settings;
|
|
||||||
|
|
||||||
public class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
|
||||||
|
|
||||||
private static final int HOTBAR_SIZE = 9;
|
|
||||||
// http://wiki.vg/Inventory#Inventory (0-4 crafting, 5-8 armor, 9-35 main inventory, 36-44 inventory)
|
|
||||||
// +1 because an index starts with 0
|
|
||||||
private static final int PLAYER_CRAFTING_SIZE = 5;
|
|
||||||
private static final int PLAYER_INVENTORY = 0;
|
|
||||||
|
|
||||||
public AuthMeInventoryPacketAdapter(AuthMe plugin) {
|
|
||||||
super(plugin, PacketType.Play.Server.SET_SLOT, PacketType.Play.Server.WINDOW_ITEMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPacketSending(PacketEvent packetEvent) {
|
|
||||||
Player player = packetEvent.getPlayer();
|
|
||||||
PacketContainer packet = packetEvent.getPacket();
|
|
||||||
|
|
||||||
byte windowId = packet.getIntegers().read(0).byteValue();
|
|
||||||
if (windowId == PLAYER_INVENTORY && Settings.protectInventoryBeforeLogInEnabled && !PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
|
||||||
packetEvent.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void register() {
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendInventoryPacket(Player player) {
|
|
||||||
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
|
|
||||||
PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS);
|
|
||||||
|
|
||||||
// we are sending our own inventory
|
|
||||||
inventoryPacket.getIntegers().write(0, PLAYER_INVENTORY);
|
|
||||||
|
|
||||||
ItemStack[] playerCrafting = new ItemStack[PLAYER_CRAFTING_SIZE];
|
|
||||||
Arrays.fill(playerCrafting, new ItemStack(Material.AIR));
|
|
||||||
ItemStack[] armorContents = player.getInventory().getArmorContents();
|
|
||||||
ItemStack[] mainInventory = player.getInventory().getContents();
|
|
||||||
|
|
||||||
// bukkit saves the armor in reversed order
|
|
||||||
Collections.reverse(Arrays.asList(armorContents));
|
|
||||||
|
|
||||||
// same main inventory. The hotbar is at the beginning but it should be at the end of the array
|
|
||||||
ItemStack[] hotbar = Arrays.copyOfRange(mainInventory, 0, HOTBAR_SIZE);
|
|
||||||
ItemStack[] storedInventory = Arrays.copyOfRange(mainInventory, HOTBAR_SIZE, mainInventory.length);
|
|
||||||
|
|
||||||
// concat all parts of the inventory together
|
|
||||||
int inventorySize = playerCrafting.length + armorContents.length + mainInventory.length;
|
|
||||||
ItemStack[] completeInventory = new ItemStack[inventorySize];
|
|
||||||
|
|
||||||
System.arraycopy(playerCrafting, 0, completeInventory, 0, playerCrafting.length);
|
|
||||||
System.arraycopy(armorContents, 0, completeInventory, playerCrafting.length, armorContents.length);
|
|
||||||
|
|
||||||
// storedInventory and hotbar
|
|
||||||
System.arraycopy(storedInventory, 0, completeInventory, playerCrafting.length + armorContents.length, storedInventory.length);
|
|
||||||
System.arraycopy(hotbar, 0, completeInventory, playerCrafting.length + armorContents.length + storedInventory.length, hotbar.length);
|
|
||||||
|
|
||||||
inventoryPacket.getItemArrayModifier().write(0, completeInventory);
|
|
||||||
try {
|
|
||||||
protocolManager.sendServerPacket(player, inventoryPacket, false);
|
|
||||||
} catch (InvocationTargetException invocationExc) {
|
|
||||||
plugin.getLogger().log(Level.WARNING, "Error during inventory recovery", invocationExc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.regex.PatternSyntaxException;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -272,27 +271,9 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
|
||||||
final String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
|
||||||
if (((code == null) || Settings.countriesBlacklist.contains(code))) {
|
|
||||||
event.setKickMessage(m.send("country_banned")[0]);
|
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
|
||||||
final String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
|
||||||
if (((code == null) || !Settings.countries.contains(code))) {
|
|
||||||
event.setKickMessage(m.send("country_banned")[0]);
|
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Add message to the messages file!!!
|
|
||||||
if (Settings.isKickNonRegisteredEnabled && !isAuthAvailable) {
|
if (Settings.isKickNonRegisteredEnabled && !isAuthAvailable) {
|
||||||
if (Settings.antiBotInAction) {
|
if (Settings.antiBotInAction) {
|
||||||
event.setKickMessage("AntiBot service in action! You actually need to be registered!");
|
event.setKickMessage(m.send("antibot_no_register")[0]);
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -313,28 +294,12 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!player.getName().matches(regex) || name.equalsIgnoreCase("Player")) {
|
if (!player.getName().matches(regex) || name.equalsIgnoreCase("Player")) {
|
||||||
try {
|
|
||||||
event.setKickMessage(m.send("regex")[0].replace("REG_EX", regex));
|
event.setKickMessage(m.send("regex")[0].replace("REG_EX", regex));
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
} catch (final Exception exc) {
|
}
|
||||||
|
} catch (final Exception pse) {
|
||||||
event.setKickMessage("allowed char : " + regex);
|
event.setKickMessage("allowed char : " + regex);
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (final PatternSyntaxException pse) {
|
|
||||||
if (regex == null || regex.isEmpty()) {
|
|
||||||
event.setKickMessage("Your nickname do not match");
|
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
event.setKickMessage(m.send("regex")[0].replace("REG_EX", regex));
|
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
|
||||||
} catch (final Exception exc) {
|
|
||||||
event.setKickMessage("allowed char : " + regex);
|
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,31 +348,10 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
if (Utils.checkAuth(player)) {
|
if (Utils.checkAuth(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Settings.isMovementAllowed) {
|
|
||||||
final Location from = event.getFrom();
|
final Location from = event.getFrom();
|
||||||
from.setPitch(event.getTo().getPitch());
|
from.setPitch(event.getTo().getPitch());
|
||||||
from.setYaw(event.getTo().getYaw());
|
from.setYaw(event.getTo().getYaw());
|
||||||
|
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings.getMovementRadius == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int radius = Settings.getMovementRadius;
|
|
||||||
final Location spawn = plugin.getSpawnLocation(player);
|
|
||||||
if (spawn != null && spawn.getWorld() != null) {
|
|
||||||
if (!event.getPlayer().getWorld().equals(spawn.getWorld())) {
|
|
||||||
event.getPlayer().teleport(spawn);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((spawn.distance(player.getLocation()) > radius)) {
|
|
||||||
event.getPlayer().teleport(spawn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
package cn.citycraft.AuthMe.listener;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerEditBookEvent;
|
|
||||||
|
|
||||||
import cn.citycraft.AuthMe.AuthMe;
|
|
||||||
import cn.citycraft.AuthMe.Utils;
|
|
||||||
|
|
||||||
public class AuthMePlayerListener16 implements Listener {
|
|
||||||
|
|
||||||
public AuthMe plugin;
|
|
||||||
|
|
||||||
public AuthMePlayerListener16(AuthMe plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
|
||||||
public void onPlayerEditBook(PlayerEditBookEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (player == null || Utils.checkAuth(player))
|
|
||||||
return;
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package cn.citycraft.AuthMe.listener;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
|
||||||
|
|
||||||
import cn.citycraft.AuthMe.AuthMe;
|
|
||||||
import cn.citycraft.AuthMe.Utils;
|
|
||||||
|
|
||||||
public class AuthMePlayerListener18 implements Listener {
|
|
||||||
|
|
||||||
public AuthMe plugin;
|
|
||||||
|
|
||||||
public AuthMePlayerListener18(AuthMe plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
|
||||||
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (player == null || Utils.checkAuth(player))
|
|
||||||
return;
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -39,10 +39,6 @@ public class AuthMeServerListener implements Listener {
|
|||||||
plugin.permission = null;
|
plugin.permission = null;
|
||||||
ConsoleLogger.showError("Vault has been disabled, unhook permissions!");
|
ConsoleLogger.showError("Vault has been disabled, unhook permissions!");
|
||||||
}
|
}
|
||||||
if (pluginName.equalsIgnoreCase("ProtocolLib")) {
|
|
||||||
plugin.inventoryProtector = null;
|
|
||||||
ConsoleLogger.showError("ProtocolLib has been disabled, unhook packet inventory protection!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
@ -54,9 +50,6 @@ public class AuthMeServerListener implements Listener {
|
|||||||
if (pluginName.equalsIgnoreCase("Vault")) {
|
if (pluginName.equalsIgnoreCase("Vault")) {
|
||||||
plugin.checkVault();
|
plugin.checkVault();
|
||||||
}
|
}
|
||||||
if (pluginName.equalsIgnoreCase("ProtocolLib")) {
|
|
||||||
plugin.checkProtocolLib();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
@ -12,7 +12,6 @@ import org.bukkit.scheduler.BukkitScheduler;
|
|||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import cn.citycraft.AuthMe.AuthMe;
|
import cn.citycraft.AuthMe.AuthMe;
|
||||||
import cn.citycraft.AuthMe.ConsoleLogger;
|
|
||||||
import cn.citycraft.AuthMe.Utils;
|
import cn.citycraft.AuthMe.Utils;
|
||||||
import cn.citycraft.AuthMe.Utils.GroupType;
|
import cn.citycraft.AuthMe.Utils.GroupType;
|
||||||
import cn.citycraft.AuthMe.cache.auth.PlayerAuth;
|
import cn.citycraft.AuthMe.cache.auth.PlayerAuth;
|
||||||
@ -26,7 +25,6 @@ import cn.citycraft.AuthMe.settings.Spawn;
|
|||||||
import cn.citycraft.AuthMe.task.MessageTask;
|
import cn.citycraft.AuthMe.task.MessageTask;
|
||||||
import cn.citycraft.AuthMe.task.TimeoutTask;
|
import cn.citycraft.AuthMe.task.TimeoutTask;
|
||||||
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
||||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
|
||||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||||
|
|
||||||
public class AsyncronousJoin {
|
public class AsyncronousJoin {
|
||||||
@ -126,17 +124,6 @@ public class AsyncronousJoin {
|
|||||||
}
|
}
|
||||||
placePlayerSafely(player, spawnLoc);
|
placePlayerSafely(player, spawnLoc);
|
||||||
LimboCache.getInstance().updateLimboPlayer(player);
|
LimboCache.getInstance().updateLimboPlayer(player);
|
||||||
// protect inventory
|
|
||||||
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
|
|
||||||
final ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
|
|
||||||
plugin.getServer().getPluginManager().callEvent(ev);
|
|
||||||
if (ev.isCancelled()) {
|
|
||||||
plugin.inventoryProtector.sendInventoryPacket(player);
|
|
||||||
if (!Settings.noConsoleSpam) {
|
|
||||||
ConsoleLogger.info("玩家 " + player.getName() + " 的背包保护事件已被取消...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
||||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
@ -19,7 +19,6 @@ import cn.citycraft.AuthMe.listener.AuthMePlayerListener;
|
|||||||
import cn.citycraft.AuthMe.settings.Settings;
|
import cn.citycraft.AuthMe.settings.Settings;
|
||||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||||
import fr.xephi.authme.events.LoginEvent;
|
import fr.xephi.authme.events.LoginEvent;
|
||||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
|
||||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||||
|
|
||||||
public class ProcessSyncronousPlayerLogin implements Runnable {
|
public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||||
@ -62,12 +61,6 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
* world inventory !
|
* world inventory !
|
||||||
*/
|
*/
|
||||||
player.setGameMode(limbo.getGameMode());
|
player.setGameMode(limbo.getGameMode());
|
||||||
// Inventory - Make it after restore GameMode , cause we need to
|
|
||||||
// restore the
|
|
||||||
// right inventory in the right gamemode
|
|
||||||
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
|
|
||||||
restoreInventory();
|
|
||||||
}
|
|
||||||
if (Settings.forceOnlyAfterLogin) {
|
if (Settings.forceOnlyAfterLogin) {
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
}
|
}
|
||||||
@ -160,14 +153,6 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
|||||||
Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
Utils.packCoords(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), player);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void restoreInventory() {
|
|
||||||
final RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
plugin.inventoryProtector.sendInventoryPacket(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void restoreOpState() {
|
protected void restoreOpState() {
|
||||||
player.setOp(limbo.getOperator());
|
player.setOp(limbo.getOperator());
|
||||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||||
|
@ -40,47 +40,48 @@ public class AsyncronousRegister {
|
|||||||
if (!allowRegister) {
|
if (!allowRegister) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!email.isEmpty() && !email.equals("")) {
|
// TODO 计划删除邮箱
|
||||||
if (Settings.getmaxRegPerEmail > 0) {
|
// if (!email.isEmpty() && !email.equals("")) {
|
||||||
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
// if (Settings.getmaxRegPerEmail > 0) {
|
||||||
m.send(player, "max_reg");
|
// if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||||
return;
|
// m.send(player, "max_reg");
|
||||||
}
|
// return;
|
||||||
}
|
// }
|
||||||
emailRegister();
|
// }
|
||||||
return;
|
// emailRegister();
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
passwordRegister();
|
passwordRegister();
|
||||||
}
|
}
|
||||||
|
// TODO 计划删除邮箱
|
||||||
protected void emailRegister() {
|
// protected void emailRegister() {
|
||||||
if (Settings.getmaxRegPerEmail > 0) {
|
// if (Settings.getmaxRegPerEmail > 0) {
|
||||||
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
// if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
|
||||||
m.send(player, "max_reg");
|
// m.send(player, "max_reg");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
PlayerAuth auth;
|
// PlayerAuth auth;
|
||||||
try {
|
// try {
|
||||||
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
|
// final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
|
||||||
auth = new PlayerAuth(name, hashnew, getIp(), 0, (int) player.getLocation().getX(), (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player
|
// auth = new PlayerAuth(name, hashnew, getIp(), 0, (int) player.getLocation().getX(), (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player
|
||||||
.getLocation()
|
// .getLocation()
|
||||||
.getWorld()
|
// .getWorld()
|
||||||
.getName(), email, player.getName());
|
// .getName(), email, player.getName());
|
||||||
} catch (final NoSuchAlgorithmException e) {
|
// } catch (final NoSuchAlgorithmException e) {
|
||||||
ConsoleLogger.showError(e.getMessage());
|
// ConsoleLogger.showError(e.getMessage());
|
||||||
m.send(player, "error");
|
// m.send(player, "error");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (PasswordSecurity.userSalt.containsKey(name)) {
|
// if (PasswordSecurity.userSalt.containsKey(name)) {
|
||||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
// auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||||
}
|
// }
|
||||||
database.saveAuth(auth);
|
// database.saveAuth(auth);
|
||||||
database.updateEmail(auth);
|
// database.updateEmail(auth);
|
||||||
database.updateSession(auth);
|
// database.updateSession(auth);
|
||||||
final ProcessSyncronousEmailRegister syncronous = new ProcessSyncronousEmailRegister(player, plugin);
|
// final ProcessSyncronousEmailRegister syncronous = new ProcessSyncronousEmailRegister(player, plugin);
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
|
// plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected String getIp() {
|
protected String getIp() {
|
||||||
return plugin.getIP(player);
|
return plugin.getIP(player);
|
||||||
|
@ -20,7 +20,6 @@ import cn.citycraft.AuthMe.task.TimeoutTask;
|
|||||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||||
import fr.xephi.authme.events.LoginEvent;
|
import fr.xephi.authme.events.LoginEvent;
|
||||||
import fr.xephi.authme.events.RegisterTeleportEvent;
|
import fr.xephi.authme.events.RegisterTeleportEvent;
|
||||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
|
||||||
|
|
||||||
public class ProcessSyncronousPasswordRegister implements Runnable {
|
public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||||
|
|
||||||
@ -48,15 +47,6 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
|||||||
Utils.safeTP(player, tpEvent.getTo());
|
Utils.safeTP(player, tpEvent.getTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.protectInventoryBeforeLogInEnabled && plugin.inventoryProtector != null) {
|
|
||||||
final RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
plugin.inventoryProtector.sendInventoryPacket(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
limbo.getTimeoutTaskId().cancel();
|
limbo.getTimeoutTaskId().cancel();
|
||||||
limbo.getMessageTaskId().cancel();
|
limbo.getMessageTaskId().cancel();
|
||||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||||
|
@ -52,11 +52,11 @@ public final class Settings {
|
|||||||
delayRecall, getMaxLoginPerIp, getMaxJoinPerIp, getMySQLMaxConnections;
|
delayRecall, getMaxLoginPerIp, getMaxJoinPerIp, getMySQLMaxConnections;
|
||||||
public static boolean isPermissionCheckEnabled, isRegistrationEnabled, isForcedRegistrationEnabled, isTeleportToSpawnEnabled, isSessionsEnabled, isChatAllowed, isAllowRestrictedIp,
|
public static boolean isPermissionCheckEnabled, isRegistrationEnabled, isForcedRegistrationEnabled, isTeleportToSpawnEnabled, isSessionsEnabled, isChatAllowed, isAllowRestrictedIp,
|
||||||
isMovementAllowed, isKickNonRegisteredEnabled, isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled, isSaveQuitLocationEnabled, isForceSurvivalModeEnabled, isResetInventoryIfCreative,
|
isMovementAllowed, isKickNonRegisteredEnabled, isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled, isSaveQuitLocationEnabled, isForceSurvivalModeEnabled, isResetInventoryIfCreative,
|
||||||
isCachingEnabled, isKickOnWrongPasswordEnabled, getEnablePasswordVerifier, protectInventoryBeforeLogInEnabled, isBackupActivated, isBackupOnStart, isBackupOnStop, isStopEnabled,
|
isCachingEnabled, isKickOnWrongPasswordEnabled, getEnablePasswordVerifier, isBackupActivated, isBackupOnStart, isBackupOnStop, isStopEnabled, reloadSupport, rakamakUseIp, noConsoleSpam,
|
||||||
reloadSupport, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts, useCaptcha, emailRegistration, multiverse, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
removePassword, displayOtherAccounts, useCaptcha, emailRegistration, multiverse, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange, disableSocialSpy, forceOnlyAfterLogin,
|
||||||
disableSocialSpy, forceOnlyAfterLogin, useEssentialsMotd, usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative, purgeAntiXray, purgePermissions,
|
useEssentialsMotd, usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative, purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail,
|
||||||
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage, broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames, delayJoinMessage, noTeleport, applyBlindEffect,
|
useWelcomeMessage, broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames, delayJoinMessage, noTeleport, applyBlindEffect, customAttributes, generateImage,
|
||||||
customAttributes, generateImage, isRemoveSpeedEnabled;
|
isRemoveSpeedEnabled;
|
||||||
public static final File LOG_FILE = new File(APLUGIN_FOLDER, "authme.log");
|
public static final File LOG_FILE = new File(APLUGIN_FOLDER, "authme.log");
|
||||||
public static int purgeDelay = 60;
|
public static int purgeDelay = 60;
|
||||||
public static final File SETTINGS_FILE = new File(APLUGIN_FOLDER, "config.yml");
|
public static final File SETTINGS_FILE = new File(APLUGIN_FOLDER, "config.yml");
|
||||||
@ -69,11 +69,6 @@ public final class Settings {
|
|||||||
|
|
||||||
protected static FileConfig configFile;
|
protected static FileConfig configFile;
|
||||||
|
|
||||||
public Settings(final AuthMe pl) {
|
|
||||||
plugin = pl;
|
|
||||||
configFile = (FileConfig) plugin.getConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config option for setting and check restricted user by username;ip ,
|
* Config option for setting and check restricted user by username;ip ,
|
||||||
* return false if ip and name doesnt amtch with player that join the
|
* return false if ip and name doesnt amtch with player that join the
|
||||||
@ -155,7 +150,6 @@ public final class Settings {
|
|||||||
isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
|
isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
|
||||||
isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false);
|
isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false);
|
||||||
isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode", false);
|
isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode", false);
|
||||||
isResetInventoryIfCreative = configFile.getBoolean("settings.GameMode.ResetInventoryIfCreative", false);
|
|
||||||
getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
|
getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
|
||||||
getPasswordHash = getPasswordHash();
|
getPasswordHash = getPasswordHash();
|
||||||
getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup");
|
getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup");
|
||||||
@ -185,7 +179,6 @@ public final class Settings {
|
|||||||
getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName");
|
getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName");
|
||||||
getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", "");
|
getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", "");
|
||||||
getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier", true);
|
getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier", true);
|
||||||
protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true);
|
|
||||||
passwordMaxLength = configFile.getInt("settings.security.passwordMaxLength", 20);
|
passwordMaxLength = configFile.getInt("settings.security.passwordMaxLength", 20);
|
||||||
isBackupActivated = configFile.getBoolean("BackupSystem.ActivateBackup", false);
|
isBackupActivated = configFile.getBoolean("BackupSystem.ActivateBackup", false);
|
||||||
isBackupOnStart = configFile.getBoolean("BackupSystem.OnServerStart", false);
|
isBackupOnStart = configFile.getBoolean("BackupSystem.OnServerStart", false);
|
||||||
@ -366,6 +359,11 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Settings(final AuthMe pl) {
|
||||||
|
plugin = pl;
|
||||||
|
configFile = (FileConfig) plugin.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
public void mergeConfig() {
|
public void mergeConfig() {
|
||||||
boolean changes = false;
|
boolean changes = false;
|
||||||
if (configFile.contains("Xenoforo.predefinedSalt")) {
|
if (configFile.contains("Xenoforo.predefinedSalt")) {
|
||||||
|
@ -19,7 +19,7 @@ public class ChangePasswordTask implements Runnable {
|
|||||||
private final Player player;
|
private final Player player;
|
||||||
private final AuthMe plugin;
|
private final AuthMe plugin;
|
||||||
|
|
||||||
public ChangePasswordTask(AuthMe plugin, Player player, String oldPassword, String newPassword) {
|
public ChangePasswordTask(final AuthMe plugin, final Player player, final String oldPassword, final String newPassword) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.oldPassword = oldPassword;
|
this.oldPassword = oldPassword;
|
||||||
@ -28,11 +28,11 @@ public class ChangePasswordTask implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Messages m = Messages.getInstance();
|
final Messages m = Messages.getInstance();
|
||||||
try {
|
try {
|
||||||
String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, newPassword, name);
|
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, newPassword, name);
|
||||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
final PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||||
if (PasswordSecurity.comparePasswordWithHash(oldPassword, auth.getHash(), player.getName())) {
|
if (PasswordSecurity.comparePasswordWithHash(oldPassword, auth.getHash(), player.getName())) {
|
||||||
auth.setHash(hashnew);
|
auth.setHash(hashnew);
|
||||||
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) {
|
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) {
|
||||||
@ -47,11 +47,11 @@ public class ChangePasswordTask implements Runnable {
|
|||||||
plugin.database.updateSalt(auth);
|
plugin.database.updateSalt(auth);
|
||||||
PlayerCache.getInstance().updatePlayer(auth);
|
PlayerCache.getInstance().updatePlayer(auth);
|
||||||
m.send(player, "pwd_changed");
|
m.send(player, "pwd_changed");
|
||||||
ConsoleLogger.info(player.getName() + " changed his password");
|
ConsoleLogger.info(player.getName() + " 修改了账户密码!");
|
||||||
} else {
|
} else {
|
||||||
m.send(player, "wrong_pwd");
|
m.send(player, "wrong_pwd");
|
||||||
}
|
}
|
||||||
} catch (NoSuchAlgorithmException ex) {
|
} catch (final NoSuchAlgorithmException ex) {
|
||||||
ConsoleLogger.showError(ex.getMessage());
|
ConsoleLogger.showError(ex.getMessage());
|
||||||
m.send(player, "error");
|
m.send(player, "error");
|
||||||
}
|
}
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
package fr.xephi.authme.events;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This event is call just after store inventory into cache and will empty the
|
|
||||||
* player inventory.
|
|
||||||
*
|
|
||||||
* @author Xephi59
|
|
||||||
*/
|
|
||||||
public class ProtectInventoryEvent extends CustomEvent {
|
|
||||||
|
|
||||||
private ItemStack[] emptyArmor = null;
|
|
||||||
private ItemStack[] emptyInventory = null;
|
|
||||||
private Player player;
|
|
||||||
private ItemStack[] storedarmor;
|
|
||||||
private ItemStack[] storedinventory;
|
|
||||||
|
|
||||||
public ProtectInventoryEvent(Player player) {
|
|
||||||
super(true);
|
|
||||||
this.player = player;
|
|
||||||
this.storedinventory = player.getInventory().getContents();
|
|
||||||
this.storedarmor = player.getInventory().getArmorContents();
|
|
||||||
this.emptyInventory = new ItemStack[36];
|
|
||||||
this.emptyArmor = new ItemStack[4];
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getEmptyArmor() {
|
|
||||||
return this.emptyArmor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getEmptyInventory() {
|
|
||||||
return this.emptyInventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer() {
|
|
||||||
return this.player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getStoredArmor() {
|
|
||||||
return this.storedarmor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getStoredInventory() {
|
|
||||||
return this.storedinventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNewArmor(ItemStack[] emptyArmor) {
|
|
||||||
this.emptyArmor = emptyArmor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNewInventory(ItemStack[] emptyInventory) {
|
|
||||||
this.emptyInventory = emptyInventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package fr.xephi.authme.events;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* This event is call when a creative inventory is reseted.
|
|
||||||
*
|
|
||||||
* @author Xephi59
|
|
||||||
*/
|
|
||||||
public class ResetInventoryEvent extends CustomEvent {
|
|
||||||
|
|
||||||
private Player player;
|
|
||||||
|
|
||||||
public ResetInventoryEvent(Player player) {
|
|
||||||
super(true);
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer() {
|
|
||||||
return this.player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayer(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package fr.xephi.authme.events;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This event restore the inventory.
|
|
||||||
*
|
|
||||||
* @author Xephi59
|
|
||||||
*/
|
|
||||||
public class RestoreInventoryEvent extends CustomEvent {
|
|
||||||
|
|
||||||
private Player player;
|
|
||||||
|
|
||||||
public RestoreInventoryEvent(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RestoreInventoryEvent(Player player, boolean async) {
|
|
||||||
super(async);
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer() {
|
|
||||||
return this.player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayer(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package fr.xephi.authme.events;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import cn.citycraft.AuthMe.cache.backup.JsonCache;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This event is call just before write inventory content to cache
|
|
||||||
*
|
|
||||||
* @author Xephi59
|
|
||||||
*/
|
|
||||||
public class StoreInventoryEvent extends CustomEvent {
|
|
||||||
|
|
||||||
private ItemStack[] armor;
|
|
||||||
private ItemStack[] inventory;
|
|
||||||
private Player player;
|
|
||||||
|
|
||||||
public StoreInventoryEvent(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
this.inventory = player.getInventory().getContents();
|
|
||||||
this.armor = player.getInventory().getArmorContents();
|
|
||||||
}
|
|
||||||
|
|
||||||
public StoreInventoryEvent(Player player, JsonCache jsonCache) {
|
|
||||||
this.player = player;
|
|
||||||
this.inventory = player.getInventory().getContents();
|
|
||||||
this.armor = player.getInventory().getArmorContents();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getArmor() {
|
|
||||||
return this.armor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack[] getInventory() {
|
|
||||||
return this.inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer() {
|
|
||||||
return this.player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setArmor(ItemStack[] armor) {
|
|
||||||
this.armor = armor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInventory(ItemStack[] inventory) {
|
|
||||||
this.inventory = inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayer(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
}
|
|
@ -54,4 +54,5 @@ email_changed: '&f邮箱已改变!'
|
|||||||
email_send: '&f恢复邮件已发送!'
|
email_send: '&f恢复邮件已发送!'
|
||||||
country_banned: '&f这个服务器禁止该国家登陆!'
|
country_banned: '&f这个服务器禁止该国家登陆!'
|
||||||
antibot_auto_enabled: '[AuthMe] 防机器人程序由于大量异常连接而启用!'
|
antibot_auto_enabled: '[AuthMe] 防机器人程序由于大量异常连接而启用!'
|
||||||
|
antibot_no_register: '[AuthMe] 防机器人程序已启用 目前仅限已注册玩家登录!'
|
||||||
antibot_auto_disabled: '[AuthMe] 防机器人程序由于异常连接减少而在 %m 分钟后停止!'
|
antibot_auto_disabled: '[AuthMe] 防机器人程序由于异常连接减少而在 %m 分钟后停止!'
|
Loading…
Reference in New Issue
Block a user