Nick82285

Untitled

Sep 5th, 2019
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. --------------------------------------------------------------------------------------------------------------------
  4. // Executed by local player
  5.  
  6. @Override
  7. public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
  8.     if (args.length == 2) {
  9.         EntityPlayerMP target = (EntityPlayerMP) getEntity(server, sender, args[0]);
  10.         if (target != null) {
  11.             MovieMainClass.INSTANCE.sendToServer(new SendMessage("\\Movies\\" + args[1] + ".mp4"));
  12.         }
  13.     } else {
  14.         return;
  15.     }
  16. }
  17.  
  18. --------------------------------------------------------------------------------------------------------------
  19.  
  20. // Declaration of IMessage
  21.  
  22. public static CharSequence directoryToSend = "";
  23.  
  24.     public SendMessage() {
  25.     }
  26.  
  27.     public SendMessage(String directoryToSend) {
  28.         this.directoryToSend = directoryToSend;
  29.     }
  30.  
  31.     @Override
  32.     public void toBytes(ByteBuf buf) {
  33.         buf.writeCharSequence(directoryToSend, Charset.defaultCharset());
  34.     }
  35.  
  36.     @Override
  37.     public void fromBytes(ByteBuf buf) {
  38.         directoryToSend = ((String) buf.readCharSequence(directoryToSend.length(), Charset.defaultCharset()));
  39.     }
  40. --------------------------------------------------------------------------------------------------------------
  41.  
  42. // Messaged recieved on server side (I believe)
  43.  
  44. @Override
  45. public IMessage onMessage(SendMessage message, MessageContext ctx) {
  46.  
  47.     if (ctx.side == Side.CLIENT) {
  48.         MovieMainClass.INSTANCE.sendTo(new SendMessage((String) message.directoryToSend), ctx.getServerHandler().player);
  49.         MovieMainClass.proxy.doOverlay(message.directoryToSend.toString());
  50.     }
  51.     return null;
  52. }
  53.  
  54. ---------------------------------------------------------------------------------------------------------
  55.  
  56. // This is the client-side proxy
  57.  
  58. public MovieOverlay overlay;
  59. public Thread thread;
  60. public static String localDirectory = "";
  61. @Override
  62. public void doOverlay(CharSequence string) {
  63.     try {
  64.         // EntityPlayerSP targetPlayer = Minecraft.getMinecraft().player;
  65.         String directory = Minecraft.getMinecraft().mcDataDir.getCanonicalPath() + string.toString();
  66.  
  67.         File f = new File(directory);
  68.  
  69.         if (f.exists()) {
  70.                 overlay = new MovieOverlay(string);
  71.                 thread = new Thread(overlay);
  72.                 thread.start();
  73.  
  74.             }
  75.         } catch (IOException e) {
  76.             e.printStackTrace();
  77.         }
  78.     }
RAW Paste Data