Correctifs du commit précédent
This commit is contained in:
parent
dddaa83fe0
commit
10afd18f35
@ -96,6 +96,11 @@ commands:
|
|||||||
usage: /tell <Joueur> <Message>
|
usage: /tell <Joueur> <Message>
|
||||||
permission: pandacraft.tell
|
permission: pandacraft.tell
|
||||||
aliases: [m, msg, t, w, whisper]
|
aliases: [m, msg, t, w, whisper]
|
||||||
|
mail:
|
||||||
|
description: Message privé
|
||||||
|
usage: /mail
|
||||||
|
permission: pandacraft.tell
|
||||||
|
aliases: [email]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
package net.mc_pandacraft.java.plugin.pandacraftutils.commands;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class CommandMail extends AbstractCommandExecutor {
|
||||||
|
|
||||||
|
public CommandMail() {
|
||||||
|
super("mail");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||||
|
String[] args) {
|
||||||
|
String[] m = new String[] {
|
||||||
|
ChatColor.GOLD+"---------- Messagerie privée ----------",
|
||||||
|
ChatColor.GRAY+"/m <Pseudo> <Message>"+ChatColor.GOLD+" pour envoyer un message à un joueur même quand il est hors-ligne",
|
||||||
|
ChatColor.GRAY+"/m"+ChatColor.GOLD+" pour lire vos messages non lus",
|
||||||
|
ChatColor.GOLD+"------------------------------------",
|
||||||
|
};
|
||||||
|
|
||||||
|
sender.sendMessage(m);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -57,6 +57,8 @@ public class PandacraftUtilsCommandsManager {
|
|||||||
add(new CommandMuco());
|
add(new CommandMuco());
|
||||||
add(new CommandModo());
|
add(new CommandModo());
|
||||||
add(new CommandGhost());
|
add(new CommandGhost());
|
||||||
|
add(new CommandTell());
|
||||||
|
add(new CommandMail());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class MPMessageTable extends SQLTable<MPMessageElement> {
|
|||||||
public List<MPMessageElement> getAllUnreadForPlayer(String player) throws SQLException {
|
public List<MPMessageElement> getAllUnreadForPlayer(String player) throws SQLException {
|
||||||
if (!AbstractCommandExecutor.isValidPlayerName(player)) return null;
|
if (!AbstractCommandExecutor.isValidPlayerName(player)) return null;
|
||||||
|
|
||||||
return getAll("viewerNick = "+player+" AND read = 0", "time ASC", null, null);
|
return getAll("viewerNick = '"+player+"' AND wasRead = 0", "time ASC", null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.data_model;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
@ -87,9 +88,16 @@ public abstract class SQLElement {
|
|||||||
st.setString(i+1, values[i]);
|
st.setString(i+1, values[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
id = st.executeUpdate();
|
st.executeUpdate();
|
||||||
st.close();
|
|
||||||
|
ResultSet rs = st.getGeneratedKeys();
|
||||||
|
if(rs.next())
|
||||||
|
{
|
||||||
|
id = rs.getInt(1);
|
||||||
|
}
|
||||||
|
|
||||||
saved = true;
|
saved = true;
|
||||||
|
st.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -7,6 +7,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import mkremins.fanciful.FancyMessage;
|
import mkremins.fanciful.FancyMessage;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||||
@ -21,6 +22,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.data_model.ORM;
|
|||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OffPlayer;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OffPlayer;
|
||||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
||||||
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 org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -28,6 +30,9 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.UserMap;
|
||||||
|
|
||||||
public class PrivateMessagesManager extends BukkitRunnable {
|
public class PrivateMessagesManager extends BukkitRunnable {
|
||||||
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
private PandacraftUtils plugin = PandacraftUtils.getInstance();
|
||||||
|
|
||||||
@ -36,6 +41,46 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
|||||||
public PrivateMessagesManager()
|
public PrivateMessagesManager()
|
||||||
{
|
{
|
||||||
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 2L, 10L);
|
plugin.getServer().getScheduler().runTaskTimer(plugin, this, 2L, 10L);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// récupération des /mail
|
||||||
|
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
UserMap players = EssentialsInterface.getPlugin().getUserMap();
|
||||||
|
plugin.getLogger().info("Importing player's /mail from Essentials data ...");
|
||||||
|
if (players == null) return;
|
||||||
|
plugin.getLogger().info("There are "+players.getUniqueUsers()+" players files in Essentials/userdata");
|
||||||
|
Set<String> users = players.getAllUniqueUsers();
|
||||||
|
|
||||||
|
for (String su : users) {
|
||||||
|
User u = players.getUser(su);
|
||||||
|
if (u.getBase() != null && u.getBase().isOnline()) continue;
|
||||||
|
List<String> mails = u.getMails();
|
||||||
|
if (mails.isEmpty()) continue;
|
||||||
|
|
||||||
|
for (String mail : mails) {
|
||||||
|
String[] split = mail.split(":", 2);
|
||||||
|
|
||||||
|
String sourceName = split[0].trim();
|
||||||
|
String message = split[1].trim();
|
||||||
|
|
||||||
|
try {
|
||||||
|
inputMessage(new MessageSender(sourceName), u.getName(), message);
|
||||||
|
} catch (MessageSendingException e) {
|
||||||
|
plugin.getLogger().severe(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u.setMails(null);
|
||||||
|
}
|
||||||
|
players.reloadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
}, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +112,13 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
plugin.getLogger().severe("Impossible de récupérer les messages privés de la base de donnée");
|
plugin.getLogger().severe("Impossible de récupérer les messages privés de la base de donnée");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -171,7 +223,7 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
|||||||
tryDisplayMessage(el);
|
tryDisplayMessage(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
MPMessageElement elCible = new MPMessageElement(time, secKey, destUserName, sender.senderName, message, true, true);
|
MPMessageElement elCible = new MPMessageElement(time, secKey, destUserName, sender.senderName, message, false, true);
|
||||||
elCible.setDestNick(destUserName);
|
elCible.setDestNick(destUserName);
|
||||||
elCible.save();
|
elCible.save();
|
||||||
tryDisplayMessage(elCible);
|
tryDisplayMessage(elCible);
|
||||||
@ -179,8 +231,11 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
|||||||
|
|
||||||
tryDisplayMessageToConsole(elCible);
|
tryDisplayMessageToConsole(elCible);
|
||||||
|
|
||||||
if (sender.isPlayer())
|
if (sender.isPlayer()) {
|
||||||
OnlinePlayerManager.get(plugin.getServer().getPlayer(sender.senderName)).setLastMessageTarget(destUserName);
|
OnlinePlayer op = OnlinePlayerManager.get(plugin.getServer().getPlayer(sender.senderName));
|
||||||
|
if (op != null)
|
||||||
|
op.setLastMessageTarget(destUserName);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +327,10 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
|||||||
if (dispToSender) {
|
if (dispToSender) {
|
||||||
|
|
||||||
String destAff = (message.getDestGroup() == null)?
|
String destAff = (message.getDestGroup() == null)?
|
||||||
new OffPlayer(message.getDestNick()).getDisplayName():
|
( (message.getDestNick().equalsIgnoreCase(message.getViewerNick())) ?
|
||||||
|
"moi":
|
||||||
|
new OffPlayer(message.getDestNick()).getDisplayName()
|
||||||
|
):
|
||||||
"g:"+message.getDestGroupElement().getGroupName();
|
"g:"+message.getDestGroupElement().getGroupName();
|
||||||
|
|
||||||
String destCommand = (message.getDestGroup() == null)?
|
String destCommand = (message.getDestGroup() == null)?
|
||||||
@ -280,11 +338,12 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
|||||||
"g:"+message.getDestGroupElement().getGroupName();
|
"g:"+message.getDestGroupElement().getGroupName();
|
||||||
|
|
||||||
|
|
||||||
new FancyMessage()
|
new FancyMessage("")
|
||||||
.then("§6<§rmoi§6 → §r"+destAff+"§r§6>")
|
.then("§6<§rmoi§6 → §r"+destAff+"§r§6>")
|
||||||
.suggest("/m "+destCommand+" ")
|
.suggest("/m "+destCommand+" ")
|
||||||
.tooltip(tooltipLines)
|
.tooltip(tooltipLines)
|
||||||
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()))
|
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()))
|
||||||
|
.color(ChatColor.GOLD)
|
||||||
.send(op.getPlayer());
|
.send(op.getPlayer());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -304,11 +363,12 @@ public class PrivateMessagesManager extends BukkitRunnable {
|
|||||||
"g:"+message.getDestGroupElement().getGroupName();
|
"g:"+message.getDestGroupElement().getGroupName();
|
||||||
|
|
||||||
|
|
||||||
new FancyMessage()
|
new FancyMessage("")
|
||||||
.then("§6<§r"+senderAff+"§r§6 → §r"+destAff+"§r§6>")
|
.then("§6<§r"+senderAff+"§r§6 → §r"+destAff+"§r§6>")
|
||||||
.suggest("/m "+destCommand+" ")
|
.suggest("/m "+destCommand+" ")
|
||||||
.tooltip(tooltipLines)
|
.tooltip(tooltipLines)
|
||||||
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()))
|
.then(" §6"+ChatColor.translateAlternateColorCodes('&', message.getMessage()))
|
||||||
|
.color(ChatColor.GOLD)
|
||||||
.send(op.getPlayer());
|
.send(op.getPlayer());
|
||||||
|
|
||||||
// op.getPlayer().playSound(op.getPlayer().getLocation(), Sound.ORB_PICKUP, 1, 0.3F);
|
// op.getPlayer().playSound(op.getPlayer().getLocation(), Sound.ORB_PICKUP, 1, 0.3F);
|
||||||
|
@ -326,7 +326,8 @@ public class StaffQueueManager {
|
|||||||
|
|
||||||
el.setMessage(message);
|
el.setMessage(message);
|
||||||
el.save();
|
el.save();
|
||||||
} catch (SQLException e) {
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().severe("Impossible de récupérer l'élément en base de donnée : id="+dbId);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +346,8 @@ public class StaffQueueManager {
|
|||||||
|
|
||||||
el.setStaffPlayer(staffPlayer);
|
el.setStaffPlayer(staffPlayer);
|
||||||
el.save();
|
el.save();
|
||||||
} catch (SQLException e) {
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().severe("Impossible de récupérer l'élément en base de donnée : id="+dbId);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user