This commit is contained in:
snowleo 2011-07-05 23:50:50 +02:00
commit f280985dd6
9 changed files with 122 additions and 33 deletions

View File

@ -80,6 +80,11 @@ public class EssentialsPlayerListener extends PlayerListener
it.remove();
}
}
if(user.isAfk())
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
}
}
@Override
@ -91,6 +96,12 @@ public class EssentialsPlayerListener extends PlayerListener
}
final User user = ess.getUser(event.getPlayer());
if(user.isAfk())
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
}
if (!ess.getSettings().getNetherPortalsEnabled())
{
return;
@ -617,7 +628,7 @@ public class EssentialsPlayerListener extends PlayerListener
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
if (event.isCancelled()) return;
Player commandUser = event.getPlayer();
User user = ess.getUser(event.getPlayer());
String cmd = event.getMessage().toLowerCase();
if (("msg".equals(cmd) || "r".equals(cmd) || "mail".equals(cmd)))
{
@ -625,9 +636,14 @@ public class EssentialsPlayerListener extends PlayerListener
{
if (ess.getUser(player).isSocialSpyEnabled())
{
player.sendMessage(ess.getUser(commandUser).getDisplayName() + " : " + cmd);
player.sendMessage(user.getDisplayName() + " : " + cmd);
}
}
}
if(user.isAfk())
{
user.setAfk(false);
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
}
}
}

View File

@ -17,11 +17,29 @@ public class Commandafk extends EssentialsCommand
{
charge(user);
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
{
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
if (afkUser != null)
{
toggleAfk(afkUser);
}
}
else
{
toggleAfk(user);
}
}
private final void toggleAfk(User user)
{
if (!user.toggleAfk())
{
user.sendMessage(Util.i18n("markedAsNotAway"));
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
} else {
}
else
{
user.sendMessage(Util.i18n("markedAsAway"));
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
}

View File

@ -27,11 +27,13 @@ dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.bukkit-0.0.1-SNAPSHOT.jar=../lib/bukkit-0.0.1-SNAPSHOT.jar
file.reference.Factions.jar=../lib/Factions.jar
includes=**
jar.compress=false
javac.classpath=\
${reference.Essentials.jar}:\
${file.reference.bukkit-0.0.1-SNAPSHOT.jar}
${file.reference.bukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.Factions.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false

View File

@ -17,6 +17,9 @@ public class EssentialsChat extends JavaPlugin
public void onEnable()
{
final PluginManager pluginManager = getServer().getPluginManager();
EssentialsChatPlayerListener.checkFactions(pluginManager);
final EssentialsChatPlayerListener playerListener = new EssentialsChatPlayerListener(getServer());
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Lowest, this);
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Highest, this);

View File

@ -13,6 +13,10 @@ import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.mcteam.factions.Factions;
public class EssentialsChatPlayerListener extends PlayerListener
@ -20,6 +24,7 @@ public class EssentialsChatPlayerListener extends PlayerListener
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient IEssentials ess = Essentials.getStatic();
private final transient Server server;
private static Factions factions = null;
public EssentialsChatPlayerListener(final Server server)
{
@ -48,6 +53,10 @@ public class EssentialsChatPlayerListener extends PlayerListener
{
return;
}
if (factions != null && (factions.shouldLetFactionsHandleThisChat(event)))
return;
final User user = ess.getUser(event.getPlayer());
updateDisplayName(user);
@ -118,8 +127,39 @@ public class EssentialsChatPlayerListener extends PlayerListener
continue;
}
}
String message = String.format(event.getFormat(), user.getDisplayName(), event.getMessage());
u.sendMessage(String.format(event.getFormat(), user.getDisplayName(), event.getMessage()));
if (factions != null)
message = message.replace("{FACTION}", factions.getPlayerFactionTagRelation(event.getPlayer(), p)).replace("{FACTION_TITLE}", factions.getPlayerTitle(event.getPlayer()));
u.sendMessage(message);
}
}
protected static void checkFactions(PluginManager pm)
{
if (factions != null)
return;
Plugin factionsPlugin = pm.getPlugin("Factions");
if (factionsPlugin == null)
return;
factions = (Factions)factionsPlugin;
try
{ // make sure Factions is sufficiently up-to-date
if (factions.hookSupportVersion() < 1)
factions = null;
}
catch (NoSuchMethodError ex)
{ // if not, we can't work with it, so don't bother
factions = null;
}
if (factions == null)
return;
// normally a good thing, but we'll skip it to let Factions handle faction tags for global messages
//factions.handleFactionTagExternally(true);
}
}

View File

@ -1,9 +1,10 @@
# This determines the command prefix when there are conflicts (/name:home, /name:help, etc.)
name: EssentialsChat
main: com.earth2me.essentials.chat.EssentialsChat
# Note to developers: This next line cannot change, or the automatic versioning system will break.
version: TeamCity
website: http://www.earth2me.net:8001/
description: Provides chat control features for Essentials. Requires Permissions.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
depend: [Essentials]
# This determines the command prefix when there are conflicts (/name:home, /name:help, etc.)
name: EssentialsChat
main: com.earth2me.essentials.chat.EssentialsChat
# Note to developers: This next line cannot change, or the automatic versioning system will break.
version: TeamCity
website: http://www.earth2me.net:8001/
description: Provides chat control features for Essentials. Requires Permissions.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
depend: [Essentials]
softdepend: [Factions]

View File

@ -18,13 +18,18 @@ groups:
permissions:
- -groupmanager.mantogglesave
- essentials
- essentials.antioch
- essentials.burn
- essentials.clearinventory
- essentials.cooldown.bypass
- essentials.deljail
- essentials.fireball
- essentials.gc
- essentials.give
- essentials.god
- essentials.heal
- essentials.heal.others
- essentials.lightning
- essentials.invsee
- essentials.item
- essentials.jails
@ -33,13 +38,12 @@ groups:
- essentials.mute
- essentials.sell
- essentials.setjail
- essentials.signs.protection.override
- essentials.signs.*
- essentials.spawnmob
- essentials.teleport.cooldown.bypass
- essentials.teleport.timer.bypass
- essentials.togglejail
- groupmanager.*
- essentials.burn
inheritance:
- moderator
info:
@ -50,11 +54,13 @@ groups:
default: false
permissions:
- essentials.afk
- essentials.back
- essentials.back.ondeath
- essentials.balance
- essentials.chat.shout
- essentials.compass
- essentials.home
- essentials.depth
- essentials.kit
- essentials.kit.tools
- essentials.mail
@ -64,20 +70,18 @@ groups:
- essentials.nick
- essentials.pay
- essentials.portal
- essentials.powertool
- essentials.protect
- essentials.sethome
- essentials.signs.buy.use
- essentials.signs.disposal.create
- essentials.signs.disposal.use
- essentials.signs.free.use
- essentials.signs.heal.use
- essentials.signs.mail.create
- essentials.signs.mail.use
- essentials.signs.protection.create
- essentials.signs.protection.use
- essentials.signs.sell.use
- essentials.signs.trade.create
- essentials.signs.trade.use
- essentials.signs.use.*
- essentials.signs.create.disposal
- essentials.signs.create.mail
- essentials.signs.create.protection
- essentials.signs.create.trade
- essentials.signs.break.disposal
- essentials.signs.break.mail
- essentials.signs.break.protection
- essentials.signs.break.trade
- essentials.suicide
- essentials.tpa
- essentials.tpaccept
@ -95,19 +99,23 @@ groups:
Moderator:
default: false
permissions:
- essentials.back
- essentials.ban
- essentials.banip
- essentials.broadcast
- essentials.delwarp
- essentials.depth
- essentials.eco
- essentials.ext
- essentials.getpos
- essentials.jump
- essentials.kick
- essentials.kill
- essentials.setwarp
- essentials.signs.create.*
- essentials.signs.break.*
- essentials.spawner
- essentials.thunder
- essentials.time
- essentials.time.world
- essentials.togglejail
- essentials.top
- essentials.tp
@ -118,6 +126,7 @@ groups:
- essentials.tptoggle
- essentials.unban
- essentials.unbanip
- essentials.weather
- essentials.whois
- essentials.world
- groupmanager.listgroups
@ -128,7 +137,6 @@ groups:
- groupmanager.manselect
- groupmanager.manuadd
- groupmanager.manudel
- essentials.ext
inheritance:
- builder
info:
@ -139,7 +147,6 @@ groups:
default: false
permissions:
- '*'
- -essentials.protect.damage.*
inheritance:
- semiadmin
info:

View File

@ -13,4 +13,6 @@ Recommended NetBeans plugins:
In the root folder of the repository is a file called settings.zip. It contains the code guidelines settings. Open the preferences of NetBeans and import the zip file. Use "Source > Format" before each commit please.
To build all jars, select the BuildAll project and build that. You'll find all jars inside the dist/lib folder of the BuildAll project.
To build all jars, select the BuildAll project and build that. You'll find all jars inside the dist/lib folder of the BuildAll project.
If you create pull requests, always make them for the master branch.

BIN
lib/Factions.jar Normal file

Binary file not shown.