Pseudo des joueurs hors ligne + préparation du grade Esprit
This commit is contained in:
parent
b02dbe4d4d
commit
6196c3e2fd
@ -86,6 +86,10 @@ commands:
|
|||||||
description: Commande de modération
|
description: Commande de modération
|
||||||
usage: /modo
|
usage: /modo
|
||||||
permission: pandacraft.modo
|
permission: pandacraft.modo
|
||||||
|
ghost:
|
||||||
|
description: mystère :3
|
||||||
|
usage: /ghost
|
||||||
|
permission: pandacraft.ghost
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -177,19 +181,16 @@ permissions:
|
|||||||
description: Utiliser la commande coeur
|
description: Utiliser la commande coeur
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
#### à ajouter
|
|
||||||
pandacraft.muco:
|
pandacraft.muco:
|
||||||
description: Utiliser la commande muco
|
description: Utiliser la commande muco
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
# pandacraft.muco.sitemembre donne accès à la liste de commande nommé "sitemembre"
|
# pandacraft.muco.sitemembre donne accès à la liste de commande nommé "sitemembre"
|
||||||
#### à ajouter
|
|
||||||
pandacraft.muco.*:
|
pandacraft.muco.*:
|
||||||
description: Utiliser toutes les listes de commandes muco
|
description: Utiliser toutes les listes de commandes muco
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
|
|
||||||
#### à ajouter
|
|
||||||
pandacraft.modo:
|
pandacraft.modo:
|
||||||
description: Utiliser la commande modo
|
description: Utiliser la commande modo
|
||||||
default: op
|
default: op
|
||||||
@ -203,7 +204,9 @@ permissions:
|
|||||||
description: Utiliser les plus hauts niveau de sanction
|
description: Utiliser les plus hauts niveau de sanction
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
|
pandacraft.ghost:
|
||||||
|
description: Utiliser la commande ghost et avoir tout les pouvoirs qui y sont associés
|
||||||
|
default: false
|
||||||
|
|
||||||
pandacraft.antispam.exempt:
|
pandacraft.antispam.exempt:
|
||||||
description: Ignoré par le système anti-spam
|
description: Ignoré par le système anti-spam
|
||||||
|
@ -11,7 +11,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
|||||||
* Classe parente de toutes les classes devant prendre en charge l'exécution d'une commande Minecraft
|
* Classe parente de toutes les classes devant prendre en charge l'exécution d'une commande Minecraft
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* package */ abstract class AbstractCommandExecutor implements CommandExecutor {
|
public abstract class AbstractCommandExecutor implements CommandExecutor {
|
||||||
|
|
||||||
protected PandacraftUtils plugin = PandacraftUtils.getInstance();
|
protected PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
@ -36,7 +36,8 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isValidPlayerName(String name) {
|
public static boolean isValidPlayerName(String name) {
|
||||||
|
if (name == null) return false;
|
||||||
return name.matches("[0-9a-zA-Z_]{2,16}");
|
return name.matches("[0-9a-zA-Z_]{2,16}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,19 +67,16 @@ public class CommandAfk extends AbstractCommandExecutor {
|
|||||||
if (execute_self)
|
if (execute_self)
|
||||||
{
|
{
|
||||||
Player p = (Player)sender;
|
Player p = (Player)sender;
|
||||||
OnlinePlayer ap = OnlinePlayerManager.get(p);
|
OnlinePlayerManager.get(p).toggleAFK();
|
||||||
if (ap == null)
|
|
||||||
plugin.getLogger().severe("Cant find AfkPlayer with name "+p.getName()+" when performing command /afk");
|
|
||||||
else
|
|
||||||
ap.performAfkCommand();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (execute_other && other_player != null)
|
else if (execute_other && other_player != null)
|
||||||
{
|
{
|
||||||
OnlinePlayer ap = OnlinePlayerManager.get(other_player);
|
OnlinePlayer ap = OnlinePlayerManager.get(other_player);
|
||||||
if (ap == null)
|
if (ap == null)
|
||||||
plugin.getLogger().severe("Cant find AfkPlayer with name "+other_player.getName()+" when performing command /afk <player>");
|
plugin.getLogger().severe("Cant find Player with name "+other_player.getName()+" when performing command /afk <player>");
|
||||||
ap.adminToggleAfk();
|
else
|
||||||
|
ap.toggleAFK();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +621,6 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void onCommandListe(Player commandSender, String owner, int page) {
|
private void onCommandListe(Player commandSender, String owner, int page) {
|
||||||
List<Cubo> cubos = plugin.survivalCuboManager.getPlayerCubo(owner, commandSender.getWorld());
|
List<Cubo> cubos = plugin.survivalCuboManager.getPlayerCubo(owner, commandSender.getWorld());
|
||||||
|
|
||||||
@ -651,7 +650,6 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void onCommandInfo(Player commandSender, Cubo insideCubo) {
|
private void onCommandInfo(Player commandSender, Cubo insideCubo) {
|
||||||
Vector size = insideCubo.getSize();
|
Vector size = insideCubo.getSize();
|
||||||
Vector midpoint = insideCubo.getMinimumPoint().getMidpoint(insideCubo.getMaximumPoint());
|
Vector midpoint = insideCubo.getMinimumPoint().getMidpoint(insideCubo.getMaximumPoint());
|
||||||
@ -676,7 +674,6 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void onCommandSupprimer(Player commandSender, Cubo insideCubo) {
|
private void onCommandSupprimer(Player commandSender, Cubo insideCubo) {
|
||||||
|
|
||||||
String proprio_cubo = insideCubo.getOwnerName();
|
String proprio_cubo = insideCubo.getOwnerName();
|
||||||
@ -712,7 +709,6 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void onCommandAjouter(Player commandSender, Cubo insideCubo, String newMember) {
|
private void onCommandAjouter(Player commandSender, Cubo insideCubo, String newMember) {
|
||||||
|
|
||||||
insideCubo.addMember(newMember);
|
insideCubo.addMember(newMember);
|
||||||
@ -730,7 +726,6 @@ public class CommandCubo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void onCommandEnlever(Player commandSender, Cubo insideCubo, String oldMember) {
|
private void onCommandEnlever(Player commandSender, Cubo insideCubo, String oldMember) {
|
||||||
insideCubo.removeMember(oldMember);
|
insideCubo.removeMember(oldMember);
|
||||||
|
|
||||||
|
@ -502,7 +502,6 @@ public class CommandModo extends AbstractCommandExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param duration en seconde
|
* @param duration en seconde
|
||||||
*/
|
*/
|
||||||
|
@ -142,7 +142,7 @@ public class CommandStaff extends AbstractCommandExecutor {
|
|||||||
if (p != null && p.isOnline()) {
|
if (p != null && p.isOnline()) {
|
||||||
// le joueur est en ligne
|
// le joueur est en ligne
|
||||||
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
||||||
sender.sendMessage(p.getName()+ChatColor.RESET+" : "+wp.getMessage()+" - "+ChatColor.ITALIC+"Il y a "+TimeUtil.durationToString((new Date()).getTime() - wp.getDate().getTime()));
|
sender.sendMessage(p.getDisplayName()+ChatColor.RESET+" : "+wp.getMessage()+" - "+ChatColor.ITALIC+"Il y a "+TimeUtil.durationToString((new Date()).getTime() - wp.getDate().getTime()));
|
||||||
sender.sendMessage(ChatColor.GREEN+"Vous avez été téléporté vers ce joueur");
|
sender.sendMessage(ChatColor.GREEN+"Vous avez été téléporté vers ce joueur");
|
||||||
((Player)sender).teleport(p.getLocation());
|
((Player)sender).teleport(p.getLocation());
|
||||||
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
sender.sendMessage(ChatColor.GREEN+"-----------------------------------------------");
|
||||||
|
@ -61,12 +61,12 @@ public class Command_Selection extends AbstractCommandExecutor {
|
|||||||
if (op.hasPlayerForWiewingHisWESelection(otherP))
|
if (op.hasPlayerForWiewingHisWESelection(otherP))
|
||||||
{
|
{
|
||||||
op.removePlayerForWiewingHisWESelection(otherP);
|
op.removePlayerForWiewingHisWESelection(otherP);
|
||||||
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" désactivé.");
|
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getDisplayName()+ChatColor.GREEN+" désactivé.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
op.addPlayerForWiewingHisWESelection(otherP);
|
op.addPlayerForWiewingHisWESelection(otherP);
|
||||||
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" activé.");
|
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getDisplayName()+ChatColor.GREEN+" activé.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class Command_Selection extends AbstractCommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection activé. Si vous ne voyez pas les particules, activez les dans vos options Minecraft.");
|
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection activé. Si vous ne voyez pas les particules, activez les dans vos options Minecraft.");
|
||||||
if (otherP != null) {
|
if (otherP != null) {
|
||||||
op.addPlayerForWiewingHisWESelection(otherP);
|
op.addPlayerForWiewingHisWESelection(otherP);
|
||||||
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getName()+ChatColor.GREEN+" activé.");
|
sender.sendMessage(ChatColor.GREEN+"Affichage de la sélection de "+ChatColor.GRAY+otherP.getDisplayName()+ChatColor.GREEN+" activé.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection;
|
|||||||
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.players.OnlinePlayerManager;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -79,6 +80,9 @@ public class NoPvpProtectManager {
|
|||||||
if (pl == p || pl.getGameMode() == GameMode.CREATIVE)
|
if (pl == p || pl.getGameMode() == GameMode.CREATIVE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (OnlinePlayerManager.get(pl).isVanished())
|
||||||
|
continue;
|
||||||
|
|
||||||
Location ent_loc = pl.getLocation();
|
Location ent_loc = pl.getLocation();
|
||||||
if (ent_loc.distance(block_loc) < distance)
|
if (ent_loc.distance(block_loc) < distance)
|
||||||
{ // un joueur autre que celui qui a pos§ est trop proche
|
{ // un joueur autre que celui qui a pos§ est trop proche
|
||||||
@ -118,6 +122,9 @@ public class NoPvpProtectManager {
|
|||||||
if (pl == p || pl.getGameMode() == GameMode.CREATIVE)
|
if (pl == p || pl.getGameMode() == GameMode.CREATIVE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (OnlinePlayerManager.get(pl).isVanished())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
Location ent_loc = pl.getLocation();
|
Location ent_loc = pl.getLocation();
|
||||||
if (ent_loc.distance(block_loc) < distance)
|
if (ent_loc.distance(block_loc) < distance)
|
||||||
@ -160,6 +167,8 @@ public class NoPvpProtectManager {
|
|||||||
if (pl == p || pl.getGameMode() == GameMode.CREATIVE)
|
if (pl == p || pl.getGameMode() == GameMode.CREATIVE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (OnlinePlayerManager.get(pl).isVanished())
|
||||||
|
continue;
|
||||||
|
|
||||||
Location ent_loc = pl.getLocation();
|
Location ent_loc = pl.getLocation();
|
||||||
if (ent_loc.distance(block_loc) < distance)
|
if (ent_loc.distance(block_loc) < distance)
|
||||||
@ -198,6 +207,9 @@ public class NoPvpProtectManager {
|
|||||||
if (pl == p || pl.isFlying())
|
if (pl == p || pl.isFlying())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (OnlinePlayerManager.get(pl).isVanished())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
Location pl_loc = pl.getLocation().getBlock().getLocation();
|
Location pl_loc = pl.getLocation().getBlock().getLocation();
|
||||||
Location pl_loc_under = new Location(pl_loc.getWorld(), pl_loc.getX(), pl_loc.getY()-1, pl_loc.getZ());
|
Location pl_loc_under = new Location(pl_loc.getWorld(), pl_loc.getX(), pl_loc.getY()-1, pl_loc.getZ());
|
||||||
@ -237,10 +249,13 @@ public class NoPvpProtectManager {
|
|||||||
// on fait le tour de tout les joueurs de la map
|
// on fait le tour de tout les joueurs de la map
|
||||||
for (Player pl : pls)
|
for (Player pl : pls)
|
||||||
{
|
{
|
||||||
// on ignore ceux en cr§atif
|
// on ignore ceux en créatif
|
||||||
if (pl.getGameMode() == GameMode.CREATIVE)
|
if (pl.getGameMode() == GameMode.CREATIVE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (OnlinePlayerManager.get(pl).isVanished())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
Location pl_loc = pl.getLocation().getBlock().getLocation();
|
Location pl_loc = pl.getLocation().getBlock().getLocation();
|
||||||
|
|
||||||
@ -253,9 +268,6 @@ public class NoPvpProtectManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Location pl_loc_floor = new Location(pl_loc.getWorld(), Math.floor(pl.getLocation().getX()), Math.floor(pl.getLocation().getY()), Math.floor(pl.getLocation().getZ()));
|
Location pl_loc_floor = new Location(pl_loc.getWorld(), Math.floor(pl.getLocation().getX()), Math.floor(pl.getLocation().getY()), Math.floor(pl.getLocation().getZ()));
|
||||||
|
|
||||||
Location pl_loc_inner_block = pl.getLocation().subtract(pl_loc_floor);
|
Location pl_loc_inner_block = pl.getLocation().subtract(pl_loc_floor);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection;
|
package net.mc_pandacraft.java.plugin.pandacraftutils.modules.protection;
|
||||||
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OffPlayer;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -114,7 +115,8 @@ public class TamedEntityProtectManager {
|
|||||||
if (owner instanceof Player) // si le joueur est en ligne
|
if (owner instanceof Player) // si le joueur est en ligne
|
||||||
return ((Player) owner).getDisplayName();
|
return ((Player) owner).getDisplayName();
|
||||||
|
|
||||||
return owner.getName();
|
|
||||||
|
return new OffPlayer(owner.getName()).getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,11 +126,11 @@ public class StaffQueueManager {
|
|||||||
ArrayList<String> lines = new ArrayList<String>();
|
ArrayList<String> lines = new ArrayList<String>();
|
||||||
|
|
||||||
if (!selectedPlayers.isEmpty()) {
|
if (!selectedPlayers.isEmpty()) {
|
||||||
lines.add("En traitement :");
|
lines.add(ChatColor.GREEN+"En traitement:");
|
||||||
lines.addAll(selectedPlayers);
|
lines.addAll(selectedPlayers);
|
||||||
}
|
}
|
||||||
if (!newPlayers.isEmpty()) {
|
if (!newPlayers.isEmpty()) {
|
||||||
lines.add("En attente :");
|
lines.add(ChatColor.GOLD+"En attente :");
|
||||||
lines.addAll(newPlayers);
|
lines.addAll(newPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
|
|||||||
import ru.tehkode.permissions.PermissionUser;
|
import ru.tehkode.permissions.PermissionUser;
|
||||||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.Response;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.Response;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OffPlayer;
|
||||||
|
|
||||||
public class RequestExecutorChatSend extends AbstractRequestExecutor {
|
public class RequestExecutorChatSend extends AbstractRequestExecutor {
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ public class RequestExecutorChatSend extends AbstractRequestExecutor {
|
|||||||
if (permUser == null)
|
if (permUser == null)
|
||||||
return new Response(false, "user_not_exist : user is not registered in permission plugin");
|
return new Response(false, "user_not_exist : user is not registered in permission plugin");
|
||||||
|
|
||||||
String displayName = permUser.getPrefix() + permUser.getName() + permUser.getSuffix();
|
String displayName = new OffPlayer(dataSplit[0]).getDisplayName();
|
||||||
|
|
||||||
|
|
||||||
String finalMessage = "["+ChatColor.GRAY+"Console"+ChatColor.RESET+"]<"+displayName+ChatColor.RESET+"> "+dataSplit[1];
|
String finalMessage = "["+ChatColor.GRAY+"Console"+ChatColor.RESET+"]<"+displayName+ChatColor.RESET+"> "+dataSplit[1];
|
||||||
|
@ -7,9 +7,8 @@ import org.bukkit.entity.Player;
|
|||||||
import com.earth2me.essentials.CommandSource;
|
import com.earth2me.essentials.CommandSource;
|
||||||
import com.earth2me.essentials.Console;
|
import com.earth2me.essentials.Console;
|
||||||
|
|
||||||
import ru.tehkode.permissions.PermissionUser;
|
|
||||||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.Response;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.network_api.Response;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OffPlayer;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
|
||||||
|
|
||||||
@ -27,10 +26,6 @@ public class RequestExecutorPrivateMessage extends AbstractRequestExecutor {
|
|||||||
return new Response(false, "bad_data : at least two space");
|
return new Response(false, "bad_data : at least two space");
|
||||||
|
|
||||||
|
|
||||||
PermissionUser permUser = PermissionsEx.getUser(dataSplit[0]);
|
|
||||||
|
|
||||||
if (permUser == null)
|
|
||||||
return new Response(false, "user_src_not_exist : user is not registered in permission plugin");
|
|
||||||
|
|
||||||
CommandSender cible;
|
CommandSender cible;
|
||||||
String cibleName;
|
String cibleName;
|
||||||
@ -44,7 +39,7 @@ public class RequestExecutorPrivateMessage extends AbstractRequestExecutor {
|
|||||||
|
|
||||||
if (p == null || !p.isOnline()) {
|
if (p == null || !p.isOnline()) {
|
||||||
plugin.getLogger().warning(ChatColor.RED+dataSplit[1]+" n'est pas en ligne");
|
plugin.getLogger().warning(ChatColor.RED+dataSplit[1]+" n'est pas en ligne");
|
||||||
return new Response(false, "user_dest_not_online");
|
return new Response(false, "user_doest_not_online");
|
||||||
}
|
}
|
||||||
|
|
||||||
cible = p;
|
cible = p;
|
||||||
@ -53,7 +48,7 @@ public class RequestExecutorPrivateMessage extends AbstractRequestExecutor {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
String displayName = "["+ChatColor.GRAY+"Console"+ChatColor.GOLD+"]"+permUser.getPrefix() + permUser.getName() + permUser.getSuffix();
|
String displayName = "["+ChatColor.GRAY+"Console"+ChatColor.GOLD+"]"+ (new OffPlayer(dataSplit[0]).getDisplayName());
|
||||||
|
|
||||||
|
|
||||||
String finalMessageToUser = ChatColor.GOLD+"["+displayName+ChatColor.GOLD+" -> moi] "+ChatColor.RESET+dataSplit[2];
|
String finalMessageToUser = ChatColor.GOLD+"["+displayName+ChatColor.GOLD+" -> moi] "+ChatColor.RESET+dataSplit[2];
|
||||||
|
@ -0,0 +1,252 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.players;
|
||||||
|
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.commands.AbstractCommandExecutor;
|
||||||
|
import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import ru.tehkode.permissions.PermissionUser;
|
||||||
|
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
|
||||||
|
import de.luricos.bukkit.xAuth.xAuth;
|
||||||
|
import de.luricos.bukkit.xAuth.xAuthPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Représente un joueur du serveur, qu'il soit en ligne ou non.
|
||||||
|
* @author Marc Baloup
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class OffPlayer {
|
||||||
|
|
||||||
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
|
private String playerName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public OffPlayer(String name) {
|
||||||
|
if (!AbstractCommandExecutor.isValidPlayerName(name))
|
||||||
|
throw new RuntimeException("Invalid player name : "+name);
|
||||||
|
|
||||||
|
playerName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OffPlayer(OfflinePlayer p) {
|
||||||
|
this(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public OffPlayer(User p) {
|
||||||
|
this(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return l'instance Bukkit du joueur en ligne, ou null si il n'est pas en ligne
|
||||||
|
*/
|
||||||
|
public Player getBukkitOnlinePlayer() {
|
||||||
|
return plugin.getServer().getPlayerExact(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isOnline() {
|
||||||
|
return (getBukkitOnlinePlayer() != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return l'instance Bukkit du joueur (en ligne ou non), ou null si il n'a jamais existé sur le serveur
|
||||||
|
*/
|
||||||
|
public OfflinePlayer getBukkitOfflinePlayer() {
|
||||||
|
OfflinePlayer offP = plugin.getServer().getOfflinePlayer(playerName);
|
||||||
|
if (offP == null || !offP.hasPlayedBefore()) return null;
|
||||||
|
return offP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public User getEssentialsUser() {
|
||||||
|
return EssentialsInterface.getPlugin().getOfflineUser(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return l'instance xAuth du joueur, ou null si aucune donnée n'est présente à propos du joueur
|
||||||
|
*/
|
||||||
|
public xAuthPlayer getXAuthPlayer() {
|
||||||
|
xAuthPlayer xAP = xAuth.getPlugin().getPlayerManager().getPlayer(playerName);
|
||||||
|
if (xAP.getAccountId() == -1)
|
||||||
|
return null;
|
||||||
|
return xAP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public PermissionUser getPermissionExUser() {
|
||||||
|
return PermissionsEx.getUser(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
Player p = getBukkitOnlinePlayer();
|
||||||
|
if (p != null)
|
||||||
|
return p.getDisplayName();
|
||||||
|
|
||||||
|
User essU = getEssentialsUser();
|
||||||
|
|
||||||
|
return (essU == null) ? getName() : essU.getNick(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Grades
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Récupère le groupe parent direct ayant le poids le plus fort
|
||||||
|
* @return le groupe
|
||||||
|
*/
|
||||||
|
public String getGroup() {
|
||||||
|
String[] groups = getGroups();
|
||||||
|
return (groups != null && groups.length > 0) ? groups[0] : PermissionsEx.getPermissionManager().getDefaultGroup().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Défini si le joueur à la permission dont le noeux est passé sous forme de
|
||||||
|
* chaine de caractère. Cette méthode ajoute une surcouche par rapport à la méthode
|
||||||
|
* Player.hasPermission(String) permettant de tester si un joueur est dans un groupe, de
|
||||||
|
* la même manière que OnlinePlayer.isInGroup(String). En d'autre terme, appeler
|
||||||
|
* <code>hasPermission("pandacraft.grade.test")</code> revient à appeler
|
||||||
|
* <code></code>
|
||||||
|
* @param permission la permission testée
|
||||||
|
* @return si le joueur a la permission
|
||||||
|
*/
|
||||||
|
public boolean hasPermission(String permission) {
|
||||||
|
String permissionGroupPrefix = "pandacraft.grade.";
|
||||||
|
if (permission != null && permission.startsWith(permissionGroupPrefix)) {
|
||||||
|
String group = permission.substring(permissionGroupPrefix.length());
|
||||||
|
return isInGroup(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
Player p = getBukkitOnlinePlayer();
|
||||||
|
if (p != null)
|
||||||
|
return p.hasPermission(permission);
|
||||||
|
|
||||||
|
User u = getEssentialsUser();
|
||||||
|
if (u != null)
|
||||||
|
return u.hasPermission(permission);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère la liste des groupes dans lequel le joueur se trouve
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String[] getGroups() {
|
||||||
|
try {
|
||||||
|
return getPermissionExUser().getGroupsNames();
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
String[] g = {"default"};
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Indique si le joueur est dans le groupe Spécifié
|
||||||
|
* @param group Le groupe par rapport au plugin de permission
|
||||||
|
* @return <i>true</i> si le joueur est dans le groupe spécifié, <i>false</i> sinon
|
||||||
|
*/
|
||||||
|
public boolean isInGroup(String group) {
|
||||||
|
if (group == null) return false;
|
||||||
|
return group.equalsIgnoreCase(getGroup());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indique si le joueur est un nouveau joueur (si il ne s'est pas inscrit sur le site)
|
||||||
|
* @return <i>true</i> si le joueur n'est pas inscrit, <i>false</i> sinon
|
||||||
|
*/
|
||||||
|
public boolean isGuest() {
|
||||||
|
return isInGroup("default");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indique si le joueur s'est inscrit sur le site
|
||||||
|
* @return <i>true</i> si c'est le cas, <i>false</i> sinon
|
||||||
|
*/
|
||||||
|
public boolean isRegistered() {
|
||||||
|
return !isGuest();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indique si le joueur fait parti du staff
|
||||||
|
* @return <i>true</i> si c'est le cas, <i>false</i> sinon
|
||||||
|
*/
|
||||||
|
public boolean isInStaff() {
|
||||||
|
return isInGroup("admins") ||
|
||||||
|
isInGroup("devs") ||
|
||||||
|
isInGroup("modos") ||
|
||||||
|
isInGroup("archis") ||
|
||||||
|
isInGroup("guides");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class PlayerNeverConnectedToServerException extends RuntimeException {
|
||||||
|
private PlayerNeverConnectedToServerException(String name, String reason) {
|
||||||
|
super("Never played before : "+name+". Because : "+reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -14,22 +14,32 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.Essentials
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
|
|
||||||
import de.luricos.bukkit.xAuth.xAuth;
|
public class OnlinePlayer extends OffPlayer {
|
||||||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
|
||||||
|
|
||||||
public class OnlinePlayer {
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final PandacraftUtils plugin = PandacraftUtils.getInstance();
|
private final PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
public OnlinePlayer(Player p) {
|
public OnlinePlayer(Player p) {
|
||||||
|
super(p);
|
||||||
|
if (p == null) throw new IllegalArgumentException("Player can't be null");
|
||||||
player = p;
|
player = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() { return player; }
|
public Player getPlayer() { return player; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Player getBukkitOnlinePlayer() {
|
||||||
|
return getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OfflinePlayer getBukkitOfflinePlayer() {
|
||||||
|
return getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -58,17 +68,12 @@ public class OnlinePlayer {
|
|||||||
player.getServer().broadcastMessage(message);
|
player.getServer().broadcastMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performAfkCommand() {
|
public void toggleAFK() {
|
||||||
setAfk(!isAfk());
|
setAfk(!isAfk());
|
||||||
if (!isAfk())
|
if (!isAfk())
|
||||||
isDoingAction();
|
isDoingAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adminToggleAfk() {
|
|
||||||
setAfk(!isAfk());
|
|
||||||
if (!isAfk())
|
|
||||||
isDoingAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDurationSinceLastAction() {
|
public double getDurationSinceLastAction() {
|
||||||
return (System.currentTimeMillis() - timeLastAction)/1000D;
|
return (System.currentTimeMillis() - timeLastAction)/1000D;
|
||||||
@ -325,7 +330,7 @@ public class OnlinePlayer {
|
|||||||
|
|
||||||
|
|
||||||
public boolean isAuthenticated() {
|
public boolean isAuthenticated() {
|
||||||
return xAuth.getPlugin().getPlayerManager().getPlayer(player).isAuthenticated();
|
return getXAuthPlayer().isAuthenticated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -349,82 +354,5 @@ public class OnlinePlayer {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Grades
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Récupère le groupe parent direct ayant le poids le plus fort
|
|
||||||
* @return le groupe
|
|
||||||
*/
|
|
||||||
public String getGroup() {
|
|
||||||
String[] groups = getGroups();
|
|
||||||
return (groups != null && groups.length > 0) ? groups[0] : PermissionsEx.getPermissionManager().getDefaultGroup().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Défini si le joueur à la permission dont le noeux est passé sous forme de
|
|
||||||
* chaine de caractère. Cetteméthode ajoute une surcouche par rapport à la méthode
|
|
||||||
* Player.hasPermission(String) permettant de tester si un joueur est dans un groupe, de
|
|
||||||
* la même manière que OnlinePlayer.isInGroup(String)
|
|
||||||
* @param permission la permission testée
|
|
||||||
* @return si le joueur a la permission
|
|
||||||
*/
|
|
||||||
public boolean hasPermission(String permission) {
|
|
||||||
String permissionGroupPrefix = "pandacraft.grade.";
|
|
||||||
if (permission != null && permission.startsWith(permissionGroupPrefix)) {
|
|
||||||
String group = permission.substring(permissionGroupPrefix.length());
|
|
||||||
return isInGroup(group);
|
|
||||||
}
|
|
||||||
return player.hasPermission(permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Récupère la liste des groupes dans lequel le joueur se trouve
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String[] getGroups() {
|
|
||||||
try {
|
|
||||||
return PermissionsEx.getUser(player).getGroupsNames();
|
|
||||||
} catch (NoClassDefFoundError e) {
|
|
||||||
String[] g = {"default"};
|
|
||||||
return g;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Indique si le joueur est dans le groupe Spécifié
|
|
||||||
* @param group Le groupe par rapport au plugin de permission
|
|
||||||
* @return <i>true</i> si le joueur est dans le groupe spécifié, <i>false</i> sinon
|
|
||||||
*/
|
|
||||||
public boolean isInGroup(String group) {
|
|
||||||
if (group == null) return false;
|
|
||||||
return group.equalsIgnoreCase(getGroup());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indique si le joueur est un nouveau joueur (si il ne s'est pas inscrit sur le site)
|
|
||||||
* @return <i>true</i> si le joueur n'est pas inscrit, <i>false</i> sinon
|
|
||||||
*/
|
|
||||||
public boolean isGuest() {
|
|
||||||
return isInGroup("default");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indique si le joueur s'est inscrit sur le site
|
|
||||||
* @return <i>true</i> si c'est le cas, <i>false</i> sinon
|
|
||||||
*/
|
|
||||||
public boolean isRegistered() {
|
|
||||||
return !isGuest();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indique si le joueur fait parti du staff
|
|
||||||
* @return <i>true</i> si c'est le cas, <i>false</i> sinon
|
|
||||||
*/
|
|
||||||
public boolean isInStaff() {
|
|
||||||
return isInGroup("admins") ||
|
|
||||||
isInGroup("devs") ||
|
|
||||||
isInGroup("modos") ||
|
|
||||||
isInGroup("archis") ||
|
|
||||||
isInGroup("guides");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user