mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-22 14:23:09 +02:00
Merge gravy's pull and reformat code
This commit is contained in:
@@ -1,50 +1,49 @@
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>net.essentials3</groupId>
|
||||
<artifactId>BuildAll</artifactId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>net.essentials3</groupId>
|
||||
<artifactId>BuildAll</artifactId>
|
||||
<version>3.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>EssentialsXMPP</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>Essentials</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jivesoftware</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<artifactId>EssentialsXMPP</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>Essentials</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jivesoftware</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>jivesoftware:smack</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>jivesoftware:smack</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package net.ess3.xmpp;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import net.ess3.Console;
|
||||
import net.ess3.commands.EssentialsCommand;
|
||||
import net.ess3.commands.NotEnoughArgumentsException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandxmpp extends EssentialsCommand
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package net.ess3.xmpp;
|
||||
|
||||
import java.util.List;
|
||||
import net.ess3.commands.EssentialsCommand;
|
||||
import net.ess3.commands.NotEnoughArgumentsException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.ess3.commands.EssentialsCommand;
|
||||
import net.ess3.commands.NotEnoughArgumentsException;
|
||||
|
||||
|
||||
public class Commandxmppspy extends EssentialsCommand
|
||||
|
@@ -1,20 +1,19 @@
|
||||
package net.ess3.xmpp;
|
||||
|
||||
import static net.ess3.I18n._;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import static net.ess3.I18n._;
|
||||
import net.ess3.api.ICommandHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.api.IPlugin;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.commands.EssentialsCommandHandler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
||||
|
||||
public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package net.ess3.xmpp;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import net.ess3.api.IEssentials;
|
||||
|
||||
|
||||
class EssentialsXMPPPlayerListener implements Listener
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package net.ess3.xmpp;
|
||||
|
||||
import java.util.List;
|
||||
import net.ess3.api.IUser;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import net.ess3.api.IUser;
|
||||
|
||||
|
||||
public interface IEssentialsXMPP extends Plugin
|
||||
|
@@ -5,8 +5,8 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.ess3.api.IReload;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import net.ess3.api.IReload;
|
||||
|
||||
|
||||
public class UserManager implements IReload
|
||||
|
@@ -6,11 +6,11 @@ import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.ess3.api.IReload;
|
||||
import net.ess3.api.IUser;
|
||||
import net.ess3.utils.FormatUtil;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jivesoftware.smack.*;
|
||||
import org.jivesoftware.smack.Roster.SubscriptionMode;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
@@ -234,68 +234,70 @@ public final class XMPPManager extends Handler implements MessageListener, ChatM
|
||||
|
||||
private void startLoggerThread()
|
||||
{
|
||||
loggerThread = new Thread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final Set<LogRecord> copy = new HashSet<LogRecord>();
|
||||
final Set<String> failedUsers = new HashSet<String>();
|
||||
while (threadrunning)
|
||||
loggerThread = new Thread(
|
||||
new Runnable()
|
||||
{
|
||||
synchronized (logrecords)
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!logrecords.isEmpty())
|
||||
final Set<LogRecord> copy = new HashSet<LogRecord>();
|
||||
final Set<String> failedUsers = new HashSet<String>();
|
||||
while (threadrunning)
|
||||
{
|
||||
copy.addAll(logrecords);
|
||||
logrecords.clear();
|
||||
}
|
||||
}
|
||||
if (!copy.isEmpty())
|
||||
{
|
||||
for (String user : logUsers)
|
||||
{
|
||||
try
|
||||
synchronized (logrecords)
|
||||
{
|
||||
XMPPManager.this.startChat(user);
|
||||
for (LogRecord logRecord : copy)
|
||||
if (!logrecords.isEmpty())
|
||||
{
|
||||
final String message = String.format("[" + logRecord.getLevel().getLocalizedName() + "] " + logRecord.getMessage(), logRecord.getParameters());
|
||||
if (!XMPPManager.this.sendMessage(user, message))
|
||||
{
|
||||
failedUsers.add(user);
|
||||
break;
|
||||
}
|
||||
|
||||
copy.addAll(logrecords);
|
||||
logrecords.clear();
|
||||
}
|
||||
}
|
||||
catch (XMPPException ex)
|
||||
if (!copy.isEmpty())
|
||||
{
|
||||
failedUsers.add(user);
|
||||
LOGGER.removeHandler(XMPPManager.this);
|
||||
LOGGER.log(Level.SEVERE, "Failed to deliver log message! Disabling logging to XMPP.", ex);
|
||||
for (String user : logUsers)
|
||||
{
|
||||
try
|
||||
{
|
||||
XMPPManager.this.startChat(user);
|
||||
for (LogRecord logRecord : copy)
|
||||
{
|
||||
final String message = String.format(
|
||||
"[" + logRecord.getLevel().getLocalizedName() + "] " + logRecord.getMessage(), logRecord.getParameters());
|
||||
if (!XMPPManager.this.sendMessage(user, message))
|
||||
{
|
||||
failedUsers.add(user);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (XMPPException ex)
|
||||
{
|
||||
failedUsers.add(user);
|
||||
LOGGER.removeHandler(XMPPManager.this);
|
||||
LOGGER.log(Level.SEVERE, "Failed to deliver log message! Disabling logging to XMPP.", ex);
|
||||
}
|
||||
}
|
||||
logUsers.removeAll(failedUsers);
|
||||
if (logUsers.isEmpty())
|
||||
{
|
||||
LOGGER.removeHandler(XMPPManager.this);
|
||||
threadrunning = false;
|
||||
}
|
||||
copy.clear();
|
||||
}
|
||||
try
|
||||
{
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
threadrunning = false;
|
||||
}
|
||||
}
|
||||
logUsers.removeAll(failedUsers);
|
||||
if (logUsers.isEmpty())
|
||||
{
|
||||
LOGGER.removeHandler(XMPPManager.this);
|
||||
threadrunning = false;
|
||||
}
|
||||
copy.clear();
|
||||
LOGGER.removeHandler(XMPPManager.this);
|
||||
}
|
||||
try
|
||||
{
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
threadrunning = false;
|
||||
}
|
||||
}
|
||||
LOGGER.removeHandler(XMPPManager.this);
|
||||
}
|
||||
});
|
||||
});
|
||||
loggerThread.start();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user