Guest User

Untitled

a guest
Jul 18th, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. package fr.impuuu.havenrp.commands;
  2.  
  3. import java.util.List;
  4.  
  5. import fr.impuuu.havenrp.common.HavenRP;
  6. import fr.impuuu.havenrp.packets.PacketMessage;
  7. import fr.impuuu.havenrp.utils.PlayerHelper;
  8. import net.minecraft.command.ICommand;
  9. import net.minecraft.command.ICommandSender;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.entity.player.EntityPlayerMP;
  12. import net.minecraft.util.ChatComponentTranslation;
  13.  
  14. public class CommandSendMessage
  15. implements ICommand
  16. {
  17. public int compareTo(Object arg0)
  18. {
  19. return 0;
  20. }
  21.  
  22. public String getCommandName()
  23. {
  24. return "title";
  25. }
  26.  
  27. public String getCommandUsage(ICommandSender sender)
  28. {
  29. return "title [title] [subtitle] [time] [player/@all]";
  30. }
  31.  
  32. public List getCommandAliases()
  33. {
  34. return null;
  35. }
  36.  
  37. public void processCommand(ICommandSender sender, String[] command)
  38. {
  39. if (command.length <= 3)
  40. {
  41. sender.addChatMessage(new ChatComponentTranslation("Mauvais usage : title [title] [subtitle] [time] [player/@all]", new Object[0]));
  42. return;
  43. }
  44. PacketMessage packet = new PacketMessage();
  45. int time = 0;
  46. try
  47. {
  48. time = Integer.parseInt(command[2]);
  49. }
  50. catch (NumberFormatException e)
  51. {
  52. sender.addChatMessage(new ChatComponentTranslation("Mauvais usage : title [title] [subtitle] [time] [player/@all]", new Object[0]));
  53. return;
  54. }
  55. command[0].replaceAll("_", " ");
  56. command[1].replaceAll("_", " ");
  57. packet.addInformations(command[0], command[1], time);
  58. if (command[3].equalsIgnoreCase("@all"))
  59. {
  60. HavenRP.packets.sendToAll(packet);
  61. }
  62. else
  63. {
  64. EntityPlayer p = PlayerHelper.getPlayerByName(command[3]);
  65. if (p == null) {
  66. return;
  67. }
  68. HavenRP.packets.sendTo(packet, (EntityPlayerMP)p);
  69. }
  70. }
  71.  
  72. public boolean canCommandSenderUseCommand(ICommandSender sender)
  73. {
  74. return true;
  75. }
  76.  
  77. public List addTabCompletionOptions(ICommandSender p_71516_1_, String[] p_71516_2_)
  78. {
  79. return null;
  80. }
  81.  
  82. public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_)
  83. {
  84. return false;
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment