mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-23 16:11:31 +01:00
commit
c45192a348
@ -3,7 +3,7 @@ machine:
|
||||
version: oraclejdk7
|
||||
general:
|
||||
artifacts:
|
||||
- "target/*.jar"
|
||||
- "target/AuthMe-*.jar"
|
||||
test:
|
||||
override:
|
||||
- mvn clean install
|
||||
|
16
pom.xml
16
pom.xml
@ -24,10 +24,10 @@
|
||||
<bukkitVersion>1.8.7-R0.1-SNAPSHOT</bukkitVersion>
|
||||
</properties>
|
||||
|
||||
<!-- Official Build Server ALLERT: sometimes jenkins is offline, no panic! -->
|
||||
<!-- Official Build Server -->
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://ci.xephi.fr</url>
|
||||
<url>http://ci.xephi.fr/job/AuthMeReloaded/</url>
|
||||
</ciManagement>
|
||||
|
||||
<issueManagement>
|
||||
@ -116,16 +116,16 @@
|
||||
<!-- SpigotMC Repo (Bukkit and SpigotAPI) -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
|
||||
<!-- Mcstats.org Metrics Repo -->
|
||||
<repository>
|
||||
<id>Plugin Metrics</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/public</url>
|
||||
<url>http://repo.mcstats.org/content/repositories/releases</url>
|
||||
</repository>
|
||||
|
||||
<!-- Vault Repo (Already in ess repo!) -->
|
||||
<!-- Vault Repo -->
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
||||
@ -152,19 +152,19 @@
|
||||
<!-- XAuth Repo -->
|
||||
<repository>
|
||||
<id>luricos-releases</id>
|
||||
<url>http://repo.luricos.de/content/repositories/releases/</url>
|
||||
<url>http://repo.luricos.de/content/repositories/bukkit-plugins</url>
|
||||
</repository>
|
||||
|
||||
<!-- Attribute Repo -->
|
||||
<repository>
|
||||
<id>comphenix-snapshots</id>
|
||||
<url>http://repo.comphenix.net/content/repositories/snapshots/</url>
|
||||
<url>http://repo.comphenix.net/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
|
||||
<!-- Multiverse Repo -->
|
||||
<repository>
|
||||
<id>onarandombox</id>
|
||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||
<url>http://repo.onarandombox.com/content/repositories/multiverse</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
@ -460,7 +460,7 @@ public class AuthMe extends JavaPlugin {
|
||||
public void savePlayer(Player player)
|
||||
throws IllegalStateException, NullPointerException {
|
||||
try {
|
||||
if ((citizens.isNPC(player, this)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
|
||||
if ((citizens.isNPC(player)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) {
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -566,8 +566,8 @@ public class AuthMe extends JavaPlugin {
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
for (int i = spawnPriority.length - 1; i >= 0; i--) {
|
||||
String s = spawnPriority[i];
|
||||
if (s.equalsIgnoreCase("default") && getDefaultSpawn(world) != null)
|
||||
spawnLoc = getDefaultSpawn(world);
|
||||
if (s.equalsIgnoreCase("default") && getDefaultSpawn() != null)
|
||||
spawnLoc = getDefaultSpawn();
|
||||
if (s.equalsIgnoreCase("multiverse") && getMultiverseSpawn(world) != null)
|
||||
spawnLoc = getMultiverseSpawn(world);
|
||||
if (s.equalsIgnoreCase("essentials") && getEssentialsSpawn() != null)
|
||||
@ -580,8 +580,8 @@ public class AuthMe extends JavaPlugin {
|
||||
return spawnLoc;
|
||||
}
|
||||
|
||||
private Location getDefaultSpawn(World world) {
|
||||
return world.getSpawnLocation();
|
||||
private Location getDefaultSpawn() {
|
||||
return this.getServer().getWorld(Settings.defaultWorld).getSpawnLocation();
|
||||
}
|
||||
|
||||
private Location getMultiverseSpawn(World world) {
|
||||
@ -607,7 +607,7 @@ public class AuthMe extends JavaPlugin {
|
||||
return Spawn.getInstance().getFirstSpawn();
|
||||
if (Spawn.getInstance().getSpawn() != null)
|
||||
return Spawn.getInstance().getSpawn();
|
||||
return null;
|
||||
return this.getServer().getWorld(Settings.defaultWorld).getSpawnLocation();
|
||||
}
|
||||
|
||||
public void downloadGeoIp() {
|
||||
|
33
src/main/java/fr/xephi/authme/ImageGenerator.java
Normal file
33
src/main/java/fr/xephi/authme/ImageGenerator.java
Normal file
@ -0,0 +1,33 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class ImageGenerator {
|
||||
|
||||
private String pass;
|
||||
private AuthMe plugin;
|
||||
|
||||
public ImageGenerator(AuthMe plugin, String pass) {
|
||||
this.pass = pass;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public BufferedImage generateImage() {
|
||||
BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
|
||||
Graphics2D graphics = image.createGraphics();
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.fillRect(0, 0, 200, 40);
|
||||
GradientPaint gradientPaint = new GradientPaint(10, 5, Color.WHITE, 20, 10, Color.WHITE, true);
|
||||
graphics.setPaint(gradientPaint);
|
||||
Font font = new Font("Comic Sans MS", Font.BOLD, 30);
|
||||
graphics.setFont(font);
|
||||
graphics.drawString(pass, 5, 30);
|
||||
graphics.dispose();
|
||||
image.flush();
|
||||
return image;
|
||||
}
|
||||
}
|
@ -1,9 +1,14 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.DataSource;
|
||||
import javax.activation.FileDataSource;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.mail.BodyPart;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.Multipart;
|
||||
@ -46,9 +51,8 @@ public class SendMailSSL {
|
||||
final String subject = Settings.getMailSubject;
|
||||
final String smtp = Settings.getmailSMTP;
|
||||
final String password = Settings.getmailPassword;
|
||||
final String mailText = Settings.getMailText;
|
||||
final String mailText = Settings.getMailText.replace("<playername>", auth.getNickname()).replace("<servername>", plugin.getServer().getServerName()).replace("<generatedpass>", newPass);
|
||||
final String mail = auth.getEmail();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@ -74,10 +78,26 @@ public class SendMailSSL {
|
||||
messageBodyPart.setText(mailText);
|
||||
Multipart multipart = new MimeMultipart();
|
||||
multipart.addBodyPart(messageBodyPart);
|
||||
|
||||
// Generate an image ?
|
||||
File file = null;
|
||||
if (Settings.generateImage) {
|
||||
ImageGenerator gen = new ImageGenerator(plugin, newPass);
|
||||
file = new File(plugin.getDataFolder() + File.separator + auth.getNickname() + "_new_pass.jpg");
|
||||
ImageIO.write(gen.generateImage(), "jpg", file);
|
||||
messageBodyPart = new MimeBodyPart();
|
||||
DataSource source = new FileDataSource(file);
|
||||
messageBodyPart.setDataHandler(new DataHandler(source));
|
||||
messageBodyPart.setFileName(auth.getNickname() + "_new_pass.jpg");
|
||||
multipart.addBodyPart(messageBodyPart);
|
||||
}
|
||||
|
||||
message.setContent(multipart);
|
||||
Transport transport = session.getTransport("smtp");
|
||||
transport.connect(smtp, acc, password);
|
||||
transport.sendMessage(message, message.getAllRecipients());
|
||||
if (file != null)
|
||||
file.delete();
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println("Some error occured while trying to send a mail to " + mail);
|
||||
|
@ -67,25 +67,13 @@ public class API {
|
||||
return PlayerCache.getInstance().isAuthenticated(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isaNPC(Player player) {
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
return true;
|
||||
return CombatTagComunicator.isNPC(player);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
public boolean isNPC(Player player) {
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
return true;
|
||||
return CombatTagComunicator.isNPC(player);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class LimboCache {
|
||||
boolean flying = false;
|
||||
|
||||
if (playerData.doesCacheExist(player)) {
|
||||
StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
|
||||
final StoreInventoryEvent event = new StoreInventoryEvent(player, playerData);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled() && event.getInventory() != null && event.getArmor() != null) {
|
||||
inv = event.getInventory();
|
||||
@ -90,6 +90,9 @@ public class LimboCache {
|
||||
player.sendMessage("Your inventory has been cleaned!");
|
||||
}
|
||||
}
|
||||
if (gameMode == GameMode.CREATIVE) {
|
||||
flying = false;
|
||||
}
|
||||
gameMode = GameMode.SURVIVAL;
|
||||
}
|
||||
if (player.isDead()) {
|
||||
|
@ -0,0 +1,40 @@
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* Called if a player is teleported to the authme first spawn
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class FirstSpawnTeleportEvent extends CustomEvent {
|
||||
|
||||
private Player player;
|
||||
private Location to;
|
||||
private Location from;
|
||||
|
||||
public FirstSpawnTeleportEvent(Player player, Location from, Location to) {
|
||||
this.player = player;
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setTo(Location to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public Location getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
}
|
@ -5,8 +5,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
@ -29,7 +29,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@ -44,7 +44,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(entity, instance))
|
||||
if (instance.citizens.isNPC(entity))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
@ -67,7 +67,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityTarget(EntityTargetEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@ -79,7 +79,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(entity, instance))
|
||||
if (instance.citizens.isNPC(entity))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
@ -97,22 +97,22 @@ public class AuthMeEntityListener implements Listener {
|
||||
event.setTarget(null);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onDmg(EntityDamageByEntityEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
public void onDmg(EntityDamageByEntityEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = event.getDamager();
|
||||
|
||||
if (entity == null || !(entity instanceof Player)) {
|
||||
|
||||
Entity entity = event.getDamager();
|
||||
|
||||
if (entity == null || !(entity instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) entity;
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
|
||||
Player player = (Player) entity;
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
return;
|
||||
}
|
||||
@ -122,11 +122,11 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@ -137,7 +137,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(entity, instance))
|
||||
if (instance.citizens.isNPC(entity))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
@ -168,7 +168,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(entity, instance))
|
||||
if (instance.citizens.isNPC(entity))
|
||||
return;
|
||||
|
||||
Player player = (Player) entity;
|
||||
@ -205,7 +205,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(player, instance))
|
||||
if (instance.citizens.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
||||
@ -237,7 +237,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance.citizens.isNPC(player, instance))
|
||||
if (instance.citizens.isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
||||
|
@ -50,7 +50,6 @@ import fr.xephi.authme.settings.Settings;
|
||||
|
||||
public class AuthMePlayerListener implements Listener {
|
||||
|
||||
public static GameMode gm = GameMode.SURVIVAL;
|
||||
public static ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<String, GameMode>();
|
||||
public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<String, String>();
|
||||
private Messages m = Messages.getInstance();
|
||||
@ -328,7 +327,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -407,7 +406,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
final String name = player.getName().toLowerCase();
|
||||
boolean isAuthAvailable = data.isAuthAvailable(name);
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -616,7 +615,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
@ -644,7 +643,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
@ -673,7 +672,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
@ -702,7 +701,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
@ -727,7 +726,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -755,7 +754,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
@ -827,7 +826,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
|
||||
return;
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
@ -855,8 +854,6 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
if (event.getPlayer() == null || event == null)
|
||||
return;
|
||||
if (!Settings.isForceSurvivalModeEnabled)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@ -868,7 +865,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
|
||||
return;
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
if (plugin.getCitizensCommunicator().isNPC(player))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
@ -880,6 +877,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
if (causeByAuthMe.containsKey(name) && causeByAuthMe.get(name))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class CitizensCommunicator {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public boolean isNPC(final Entity player, AuthMe instance) {
|
||||
public boolean isNPC(final Entity player) {
|
||||
if (!this.instance.isCitizensActive)
|
||||
return false;
|
||||
try {
|
||||
|
@ -22,12 +22,14 @@ import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.plugin.manager.CombatTagComunicator;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
|
||||
@ -53,7 +55,7 @@ public class AsyncronousJoin {
|
||||
AuthMePlayerListener.gameMode.put(name, player.getGameMode());
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -149,7 +151,7 @@ public class AsyncronousJoin {
|
||||
return;
|
||||
}
|
||||
if (!Settings.noTeleport)
|
||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||
if (!needFirstspawn() && Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@ -216,7 +218,7 @@ public class AsyncronousJoin {
|
||||
public void run() {
|
||||
if (player.isOp())
|
||||
player.setOp(false);
|
||||
if (!Settings.isMovementAllowed) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}
|
||||
@ -249,6 +251,31 @@ public class AsyncronousJoin {
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
}
|
||||
|
||||
private boolean needFirstspawn() {
|
||||
if (database.isAuthAvailable(player.getName().toLowerCase()) && player.hasPlayedBefore())
|
||||
return false;
|
||||
else {
|
||||
if (Spawn.getInstance().getFirstSpawn() == null || Spawn.getInstance().getFirstSpawn().getWorld() == null)
|
||||
return false;
|
||||
final Location loc = Spawn.getInstance().getFirstSpawn();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), loc);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
if (player != null && player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) {
|
||||
player.teleport(tpEvent.getTo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void placePlayerSafely(final Player player,
|
||||
final Location spawnLoc) {
|
||||
Location loc = null;
|
||||
@ -258,14 +285,16 @@ public class AsyncronousJoin {
|
||||
return;
|
||||
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())))
|
||||
return;
|
||||
if (!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore())
|
||||
return;
|
||||
Block b = player.getLocation().getBlock();
|
||||
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL || b.getType() == Material.LAVA || b.getType() == Material.STATIONARY_LAVA) {
|
||||
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL) {
|
||||
m.send(player, "unsafe_spawn");
|
||||
if (spawnLoc.getWorld() != null)
|
||||
loc = spawnLoc;
|
||||
} else {
|
||||
Block c = player.getLocation().add(0D, 1D, 0D).getBlock();
|
||||
if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL || c.getType() == Material.LAVA || c.getType() == Material.STATIONARY_LAVA) {
|
||||
if (c.getType() == Material.PORTAL || c.getType() == Material.ENDER_PORTAL) {
|
||||
m.send(player, "unsafe_spawn");
|
||||
if (spawnLoc.getWorld() != null)
|
||||
loc = spawnLoc;
|
||||
|
@ -10,7 +10,6 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.Utils.groupType;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
@ -53,8 +52,13 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
protected void restoreOpState() {
|
||||
player.setOp(limbo.getOperator());
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
if (limbo.getGameMode() != GameMode.CREATIVE) {
|
||||
player.setAllowFlight(limbo.isFlying());
|
||||
player.setFlying(limbo.isFlying());
|
||||
} else {
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,8 +124,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
* ProtectInventoryEvent after Teleporting Also it's the current
|
||||
* world inventory !
|
||||
*/
|
||||
player.setGameMode(limbo.getGameMode());
|
||||
if (!Settings.forceOnlyAfterLogin) {
|
||||
player.setGameMode(limbo.getGameMode());
|
||||
// Inventory - Make it after restore GameMode , cause we need to
|
||||
// restore the
|
||||
// right inventory in the right gamemode
|
||||
@ -146,7 +150,8 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
} else {
|
||||
teleportBackFromSpawn();
|
||||
}
|
||||
} else if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||
} else
|
||||
if (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName())) {
|
||||
teleportToSpawn();
|
||||
} else if (Settings.isSaveQuitLocationEnabled && auth.getQuitLocY() != 0) {
|
||||
packQuitLocation();
|
||||
|
@ -51,8 +51,10 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
if (Settings.applyBlindEffect)
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
||||
player.setOp(false);
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
if (!Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}
|
||||
// Player is now logout... Time to fire event !
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class AsyncronousQuit {
|
||||
|
||||
public void process() {
|
||||
final Player player = p;
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
if (plugin.getCitizensCommunicator().isNPC(player) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public final class Settings extends YamlConfiguration {
|
||||
purgePermissions, enableProtection, enableAntiBot, recallEmail,
|
||||
useWelcomeMessage, broadcastWelcomeMessage, forceRegKick,
|
||||
forceRegLogin, checkVeryGames, delayJoinMessage, noTeleport,
|
||||
applyBlindEffect, customAttributes;
|
||||
applyBlindEffect, customAttributes, generateImage;
|
||||
|
||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
|
||||
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
||||
@ -269,6 +269,7 @@ public final class Settings extends YamlConfiguration {
|
||||
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
|
||||
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
|
||||
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
||||
generateImage = configFile.getBoolean("Email.generateImage", true);
|
||||
|
||||
// Load the welcome message
|
||||
getWelcomeMessage(plugin);
|
||||
@ -435,6 +436,7 @@ public final class Settings extends YamlConfiguration {
|
||||
forceRegisterCommands = (List<String>) configFile.getList("settings.forceRegisterCommands", new ArrayList<String>());
|
||||
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
|
||||
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
||||
generateImage = configFile.getBoolean("Email.generateImage", true);
|
||||
|
||||
// Reload the welcome message
|
||||
getWelcomeMessage(AuthMe.getInstance());
|
||||
@ -587,6 +589,10 @@ public final class Settings extends YamlConfiguration {
|
||||
}
|
||||
if (contains("Hooks.notifications"))
|
||||
set("Hooks.notifications", null);
|
||||
if (!contains("Email.generateImage")) {
|
||||
set("Email.generateImage", true);
|
||||
changes = true;
|
||||
}
|
||||
|
||||
if (changes) {
|
||||
plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me");
|
||||
|
Loading…
Reference in New Issue
Block a user