Guest User

Untitled

a guest
Jun 5th, 2015
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. package com.looke81.biowarfare.commands;
  2.  
  3. import java.util.List;
  4. import java.util.UUID;
  5.  
  6. import com.looke81.biowarfare.Reference;
  7.  
  8. import net.minecraft.command.CommandException;
  9. import net.minecraft.command.ICommand;
  10. import net.minecraft.command.ICommandSender;
  11. import net.minecraft.command.PlayerNotFoundException;
  12. import net.minecraft.command.PlayerSelector;
  13. import net.minecraft.entity.player.EntityPlayerMP;
  14. import net.minecraft.server.MinecraftServer;
  15. import net.minecraft.util.BlockPos;
  16. import net.minecraft.util.Vec3;
  17. import net.minecraft.world.World;
  18.  
  19. public class CommandMusic implements ICommand {
  20.  
  21. @Override
  22. public int compareTo(Object arg0) {
  23. return 0;
  24. }
  25.  
  26. public static EntityPlayerMP getPlayer(ICommandSender sender, String username) throws PlayerNotFoundException
  27. {
  28. EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(sender, username);
  29.  
  30. if (entityplayermp == null)
  31. {
  32. try
  33. {
  34. entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerByUUID(UUID.fromString(username));
  35. }
  36. catch (IllegalArgumentException illegalargumentexception)
  37. {
  38. ;
  39. }
  40. }
  41.  
  42. if (entityplayermp == null)
  43. {
  44. entityplayermp = MinecraftServer.getServer().getConfigurationManager().getPlayerByUsername(username);
  45. }
  46.  
  47. if (entityplayermp == null)
  48. {
  49. throw new PlayerNotFoundException();
  50. }
  51. else
  52. {
  53. return entityplayermp;
  54. }
  55. }
  56.  
  57. @Override
  58. public String getName() {
  59. return "Music";
  60. }
  61.  
  62. public int getRequiredPermissionLevel() {
  63. return 2;
  64. }
  65.  
  66. @Override
  67. public String getCommandUsage(ICommandSender sender) {
  68. return "Makes da musics";
  69. }
  70.  
  71. @Override
  72. public List getAliases() {
  73. return null;
  74. }
  75.  
  76. @Override
  77. public void execute(ICommandSender sender, String[] args) throws CommandException {
  78. World world = sender.getEntityWorld();
  79.  
  80. if (world.isRemote)
  81. {
  82. System.out.println("Not processing on Client side");
  83. }
  84. else
  85. {
  86. System.out.println("Processing on Server side");
  87. byte b0 = 0;
  88. int i = b0 + 1;
  89. String s = args[b0];
  90. EntityPlayerMP playermp = getPlayer(sender, args[i++]);
  91. Vec3 vec3 = sender.getPositionVector();
  92. world.playSound(0, 0, 0, Reference.MOD_ID + "Nyan_Cat_Alex_S", 1, 1, false);
  93. }
  94. }
  95.  
  96. @Override
  97. public boolean canCommandSenderUse(ICommandSender sender) {
  98. return true;
  99. }
  100.  
  101. @Override
  102. public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) {
  103. return null;
  104. }
  105.  
  106. @Override
  107. public boolean isUsernameIndex(String[] args, int index) {
  108. return false;
  109. }
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment