Intégration et gestion des mute et des vanish dans le plugin

This commit is contained in:
Marc Baloup 2015-01-02 18:41:30 -05:00
parent 9b77a5f8dd
commit 6b559f69c6
9 changed files with 77 additions and 3 deletions

View File

@ -9,5 +9,6 @@
<classpathentry kind="lib" path="lib/WorldEdit-5.6.jar"/> <classpathentry kind="lib" path="lib/WorldEdit-5.6.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/PandacraftAuth.jar" sourcepath="R:/Dropbox/wspace_java_minecraft/xAuth.src"/> <classpathentry kind="lib" path="lib/PandacraftAuth.jar" sourcepath="R:/Dropbox/wspace_java_minecraft/xAuth.src"/>
<classpathentry kind="lib" path="lib/Essentials-Pre2.13.1.2.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

Binary file not shown.

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jardesc> <jardesc>
<jar path="PandacraftUtils/jar_export/PandacraftUtils-2.6.jar"/> <jar path="PandacraftUtils/jar_export/PandacraftUtils-2.7.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/PandacraftUtils/make_jar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/> <options buildIfNeeded="true" compress="true" descriptionLocation="/PandacraftUtils/make_jar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/> <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/> <selectedProjects/>

View File

@ -1,6 +1,6 @@
name: PandacraftUtils name: PandacraftUtils
main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils
version: 2.6 version: 2.7

View File

@ -1,7 +1,11 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.afk; package net.mc_pandacraft.java.plugin.pandacraftutils.afk;
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.earth2me.essentials.Essentials;
public class AfkPlayer { public class AfkPlayer {
private Player player; private Player player;
private long timeLastAction; private long timeLastAction;
@ -26,6 +30,11 @@ public class AfkPlayer {
return; return;
afk = a; afk = a;
String message; String message;
// on affiche pas le status AFK des joueurs vanish
if (EssentialsInterface.isPlayerVanished(player)) return;
// affichage du message
if (afk) if (afk)
message = player.getDisplayName()+"§r est désormais AFK."; message = player.getDisplayName()+"§r est désormais AFK.";
else else

View File

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -37,8 +38,11 @@ public class LoginLogoutManager implements Listener {
@EventHandler @EventHandler
public void onxAuthLogin(xAuthLoginEvent event) { public void onxAuthLogin(xAuthLoginEvent event) {
plugin.getServer().broadcastMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" vient de se connecter");
loggedInPlayer.add(event.getPlayer()); loggedInPlayer.add(event.getPlayer());
if (EssentialsInterface.isPlayerVanished(event.getPlayer())) return;
plugin.getServer().broadcastMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" vient de se connecter");
} }
@EventHandler @EventHandler
@ -47,11 +51,18 @@ public class LoginLogoutManager implements Listener {
if (!isPlayerLoggedIn(event.getPlayer())) if (!isPlayerLoggedIn(event.getPlayer()))
return; return;
loggedInPlayer.remove(event.getPlayer()); loggedInPlayer.remove(event.getPlayer());
// on affiche le message que si le joueur n'est pas vanish
if (EssentialsInterface.isPlayerVanished(event.getPlayer())) return;
plugin.getServer().broadcastMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" a quitté le jeu"); plugin.getServer().broadcastMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" a quitté le jeu");
} }
public List<Player> getLoggedInPlayers() { return loggedInPlayer; } public List<Player> getLoggedInPlayers() { return loggedInPlayer; }
public List<Player> getLoggedOutPlayers() { public List<Player> getLoggedOutPlayers() {

View File

@ -15,6 +15,7 @@ import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedGameProfile;
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
public class PacketOutServerInfoListener { public class PacketOutServerInfoListener {
private PandacraftUtils plugin; private PandacraftUtils plugin;
@ -38,6 +39,8 @@ public class PacketOutServerInfoListener {
{ {
Player[] pl_list = PacketOutServerInfoListener.this.plugin.getServer().getOnlinePlayers(); Player[] pl_list = PacketOutServerInfoListener.this.plugin.getServer().getOnlinePlayers();
int count_player = 0;
List<Player> plAdmin = new ArrayList<Player>(); List<Player> plAdmin = new ArrayList<Player>();
List<Player> plModo = new ArrayList<Player>(); List<Player> plModo = new ArrayList<Player>();
@ -49,6 +52,9 @@ public class PacketOutServerInfoListener {
{ {
if (p != null && p.isOnline()) if (p != null && p.isOnline())
{ {
// on passe si le joueur est vanish
if(EssentialsInterface.isPlayerVanished(p)) continue;
if (p.hasPermission("pandacraft.grade.admins")) if (p.hasPermission("pandacraft.grade.admins"))
plAdmin.add(p); plAdmin.add(p);
else if (p.hasPermission("pandacraft.grade.modos")) else if (p.hasPermission("pandacraft.grade.modos"))
@ -59,6 +65,8 @@ public class PacketOutServerInfoListener {
plPlayerPremium.add(p); plPlayerPremium.add(p);
else else
plPlayer.add(p); plPlayer.add(p);
count_player++;
} }
} }
@ -97,6 +105,7 @@ public class PacketOutServerInfoListener {
event.getPacket().getServerPings().read(0).setPlayers(list); event.getPacket().getServerPings().read(0).setPlayers(list);
event.getPacket().getServerPings().read(0).setPlayersOnline(count_player);
} }
} }
); );

View File

@ -0,0 +1,37 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface;
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
import org.bukkit.entity.Player;
import com.earth2me.essentials.Essentials;
public class EssentialsInterface {
public static boolean isPlayerVanished(Player p) {
try {
return ((Essentials)PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("Essentials")).getUser(p).isVanished();
} catch (Exception e) { }
return false;
}
public static boolean canPlayerSeeVanishedPlayer(Player p, Player hiddenP) {
try {
Essentials ess = (Essentials)PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("Essentials");
return ess.getUser(p).canSee(hiddenP);
} catch (Exception e) { }
return false;
}
public static boolean isPlayerMuted(Player p) {
try {
return ((Essentials)PandacraftUtils.getInstance().getServer().getPluginManager().getPlugin("Essentials")).getUser(p).isMuted();
} catch (Exception e) { }
return false;
}
}

View File

@ -1,6 +1,7 @@
package net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.me; package net.mc_pandacraft.java.plugin.pandacraftutils.simple_commands.me;
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -24,9 +25,15 @@ public class CommandMe implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0) return false; if (args.length == 0) return false;
String name; String name;
if (sender instanceof Player) if (sender instanceof Player)
{
// pas de /me pour les mute
if (EssentialsInterface.isPlayerMuted((Player)sender)) return true;
name = ((Player)sender).getDisplayName()+ChatColor.RESET+" "+ChatColor.ITALIC; name = ((Player)sender).getDisplayName()+ChatColor.RESET+" "+ChatColor.ITALIC;
}
else if (sender instanceof ConsoleCommandSender else if (sender instanceof ConsoleCommandSender
|| sender instanceof RemoteConsoleCommandSender) || sender instanceof RemoteConsoleCommandSender)
name = ChatColor.ITALIC+"Le serveur "; name = ChatColor.ITALIC+"Le serveur ";