[URGENT] ForceTexture revival!

Discussion in 'WIP and Development Status' started by BlueMustache, Jun 21, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    BlueMustache

    Hello Everyone,
    I am currently working on a project known as ForceResource (previously know as ForceTexture).
    This project I inherited from MylesC.
    This is an amazing concept that the owner abandoned, that I am reviving.
    I need someone who can help me compact his messy code. (OPTIONAL: Maybe help with a few features.)

    A couple of Requirements.
    -Skype
    -Java Experience
    - An 1hr a week.
    - Basic knowledge of Web Sockets, and File input-outputs.
    -Quick to learn.

    I have a basic concept of how this works. I know exactly what to do.
    My problem lies where I have had people help me before, but quit.
    They just didn't understand the concept. Even though it is simple, I can't explain it easily. (So, please be patient.)
    I would be very appreciative of any responses.
    I'm looking for 1-2 devs.
    I will say ahead of time, that you guys will get shared credit of what may be a very popular plugin.

    Please respond ASAP, :)
    -Blue

    P.S. I will be out of office for a week, so in that time, I will not be doing any programming.
    I will have sent out a new jar for 1.7.9 of the old plugin, which will be approved while I'm gone.
    Send me a PM if you're interested!
     
  2. Offline

    mazentheamazin

    BlueMustache
    I would recommend making a git repo. on GitHub and I'm sure some fellow developers would make some PR's :).
     
    Zupsub likes this.
  3. Offline

    BlueMustache


    IK, I have tried Github.
    1. I don't get it.
    2. My computer says the certificates are forged. Even though they are valid.
    I do not know how to fix them and unblock them. Github is something blocked.
    Ill just give you the source, If you will help.
     
  4. Offline

    mazentheamazin

    BlueMustache
    I recommend using https for GitHub when you're starting off. If you're using IntelliJ, its extremely easy to integrate.
     
  5. Offline

    BlueMustache

    mazentheamazin

    I use Eclipse, because I have know that all my life.
    I can view GitHub via an unsupported feature in chrome. (Making it not blocked, but it is super slow to load.)
    I think if they are invalid, I wouldn't be able to connect to GitHub.
    I probably will include the source in the new jar I am publishing.

    -Blue
     
  6. Offline

    jthort

    BlueMustache Every time I work with Github I want to smash my computer against the ground. It's the most complicated piece of software I have ever used.
     
    Im_Zeus likes this.
  7. Offline

    mazentheamazin

    BlueMustache
    I.. how.
    Go into your command line (make sure Git is installed) and go to your project directory; enter in this command:
    Code:
    git init
    Then, go to your git project and get the https link; and run this command:
    Code:
    git remote add origin [put link here]
    Now, make a .gitignore file (in project directory) and put this in it:
    Code:
    /target
    *.pydevproject
    .metadata
    .gradle
    bin/
    tmp/
    *.tmp
    *.bak
    *.swp
    *~.nib
    local.properties
    .settings/
    .loadpath
    .externalToolBuilders/
    *.launch
    .cproject
    .buildpath
    .texlipse
    .project
    .classpath
    We're now going to add the project files:
    Code:
    git add *
    Here is what you'll need to remember:
    To commit, you'll need to do this:
    Code:
    git commit -m "Message for commit"
    To push to GitHub, do this:
    Code:
    git push origin master
     
  8. Offline

    jthort

    mazentheamazin
    http://steveko.wordpress.com/2012/02/24/10-things-i-hate-about-git/
    http://merrigrove.blogspot.com/2014/02/why-heck-is-git-so-hard-places-model-ok.html
    https://news.ycombinator.com/item?id=7174554
    http://www.jesshamrick.com/2013/04/03/why-is-making-a-git-commit-so-complicated/

    I know i'm not alone. I'm sure if I spent the time to read all those tutorials and understand it I would like it. Just seems like a waste of time and everytime I have to do six commands to push a damn project it brings up the question that drives me away from it

    Why the hell do I have to do six things just to push a project to github?

    This is just my personal experience though, i'm sure it's a great if you get to know it. But for me...ehh

    This basically sums up everything, i'm on stage one...
    http://planetozh.com/blog/2012/11/so-ive-tried-git-and-its/
     
    BlueMustache likes this.
  9. Offline

    BlueMustache

    @mazintheamazin

    I just don't Git it. If you have say 6 classes. Why not just take the source for each class, and paste it in?
    Github is OK to view (not the best), but I find it tedious to install unnecessary programs on a Windows XP SP2 computer, with 1Gb ram, and 70Gb hard drive. That I use for jar writing and compiling. I then drag, drop, and test it on the same old dinosaur. I just include source in the jars. You don't even need 7zip for that if you really want, just change the extension from .jar to .zip and unzip it.
    -Blue
     
  10. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

  11. Offline

    BlueMustache

  12. Offline

    mazentheamazin

    BlueMustache jthort
    Alrighty then, I will respect your opinion towards git, not that I have not already. I would just like to give you tips on learning if you decide to do so; for one, I recommend starting with integrating GitHub with your IDE (Eclipse). With IntelliJ, you're able to look at the log of whats going on, and that's mainly how I learned how to use git in general. Its not hard when you simplify it and take baby steps to figure out what command does what. If you decide not to learn how to use git, however; I perfectly respect your decision.
     
    Phasesaber, jthort and BlueMustache like this.
  13. Offline

    BlueMustache

  14. Offline

    Onlineids

    jthort likes this.
  15. Offline

    RawCode

    special note to developer:

    client can change resource pack AFTER joined server and passed timestamp\integrity verification.
    this action does not trigger any packet and completely undetectable serverside.

    it will work as expected only on complete noobs, who dont know how to change resource pack (if they downloaded xray textures thay know about how to change resource pack)

    soo your plugin will feature only illusion of protection.
    also 180th version have this feature buildin

    only valid method to "disallow" modded clients and force resource pack is custom build client wrapped by virtualization, client enforcement done by changing signatures of packets and some core methods.
    jar also encrypted and obfuscated again in case of virtualization breach.

    after all this still possible to crack protection, but process require skill beyond youtube videos and Java for Dummies.
     
    Garris0n, Skye, Zupsub and 2 others like this.
  16. Offline

    BlueMustache

    RawCode
    Thanks for your pessimism and realism. (As always.)
    I was not trying to implement x ray protection.
    That was the old authors goal, pre 1.6 (Old messy description)
    My goal is not x ray protection.
    My goal is to try my best to force a client to download a resource pack.
    Yes, this can be tricked and bypassed, but I said my best.
    I thought of all those solutions.
    Since it would be too much work for jeb_ to integrate into the client a packet that would send a simple response to the server, if they click yes.
    So I'm having to do it the hard way.
    All I'm doing is hosting a mini file server in the server on a port.
    Then telling the client to download it. Then the server collects the IP of the player. And sees if the client every attempts to download the file from the server.
    Simple.

    Also.. What are you implying about me?

    @Everyoneelseexceptrawcode
    Thesis statement of what I need help doing, in light of RawCode's post.
    All I need is to measure how big the resource pack is, and how much of it has transferred to the client from the internal webserver.
    Can anyone help with this?
    I would post the source code of what I have so far, to whoever is interested in helping. (Helping, not stealing. (Which I doubt anyone will do, but I don't want to take chances. (Man these parenthesis are long.)))

    -Blue ;)
     
  17. Offline

    RawCode

    looks like you dont want to read my posts, i will repeat one more final time
    BlueMustache

    client can change resource pack AFTER joined server and passed timestamp\integrity verification.
     
    xTigerRebornx likes this.
  18. Offline

    BlueMustache

    RawCode
    Sorry for yesterday.
    I was suffering from jetlag, and I got had just got back when I checked this.
    I also was a little mad, after I explained all this, and accidentally hit reload, and all that I typed was erased.
    Your are correct in your idea, and as far as you knew, my intentions were to make anti-xray.
    That is not correct. I should have gone about it in a more professional way. :(
    -Blue

    Here is for developers, of which what I have made so far.
    Begin Code:

    ForceTexture.class

    Code:java
    1. package me.bluemustache.forceresource;
    2.  
    3. import java.io.IOException;
    4. import java.net.HttpURLConnection;
    5. import java.net.ServerSocket;
    6. import java.net.URL;
    7. import java.util.HashMap;
    8.  
    9. import org.bukkit.Bukkit;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.plugin.PluginManager;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. public final class ForceTexture extends JavaPlugin
    15. implements Listener
    16. {
    17. ServerSocket Server = null;
    18. Webserver ws = null;
    19. static String externalAddress = null;
    20. static int usablePort = 0;
    21. public static HashMap<String, Boolean> isDownloading = new HashMap<String, Boolean>();
    22. public static HashMap<String, Boolean> isLocked = new HashMap<String, Boolean>();
    23. public static HashMap<String, Boolean> finishedDownloading = new HashMap<String, Boolean>();
    24.  
    25. public void onEnable()
    26. {
    27. getLogger().info("is now enabled");
    28. externalAddress = FTUtils.getExternalAddress();
    29. usablePort = FTUtils.getFreeSocket();
    30. getLogger().info("Your external IP is: " + externalAddress);
    31. getLogger().info("Your free socket is: " + usablePort);
    32. getLogger().info("Please port forward the port above, no questions asked.");
    33. startPackHoster();
    34. PluginManager pm = Bukkit.getPluginManager();
    35. pm.registerEvents(new FTListener(this), this);
    36. }
    37.  
    38. public void onDisable()
    39. {
    40. getLogger().info("is now disabled");
    41. stopPackHoster();
    42. }
    43.  
    44. public void startPackHoster(){
    45. (this.ws = new Webserver(this)).start();
    46. }
    47.  
    48. public void stopPackHoster(){
    49. try {
    50. this.ws.interrupt();
    51. this.ws.running = false;
    52. this.ws = null;
    53. this.Server.close();
    54. }
    55. catch (IOException localIOException) {
    56. }
    57. getLogger().info("Disabled");
    58. }
    59.  
    60. public boolean checkServer(String ip) {
    61. try { URL u = new URL("http://" + ip + ":5000/ping");
    62. HttpURLConnection huc = (HttpURLConnection)u.openConnection();
    63. huc.setRequestMethod("GET");
    64. huc.connect();
    65. if (huc.getResponseCode() == 222) {
    66. return true;
    67. }
    68. }
    69. catch (IOException localIOException)
    70. {
    71. }
    72. return false;
    73. }
    74.  
    75. }
    76.  


    Webserver.class

    Code:java
    1. package me.bluemustache.forceresource;
    2.  
    3. import java.io.IOException;
    4. import java.net.InetAddress;
    5. import java.net.ServerSocket;
    6. import java.net.Socket;
    7. import java.net.UnknownHostException;
    8.  
    9. public class Webserver extends Thread
    10. {
    11. public ForceTexture ft = null;
    12. public boolean running = true;
    13.  
    14. public Webserver(ForceTexture f) { this.ft = f; }
    15.  
    16. public void run() {
    17. try {
    18. this.ft.Server = new ServerSocket(ForceTexture.usablePort, 10, InetAddress.getByName("0"));
    19. }
    20. catch (UnknownHostException e1) {
    21. e1.printStackTrace();
    22. }
    23. catch (IOException e1) {
    24. e1.printStackTrace();
    25. }
    26.  
    27. while (this.running) {
    28. Socket connected = null;
    29. try {
    30. connected = this.ft.Server.accept();
    31. new WebHandler(connected, this).start();
    32. }
    33. catch (IOException localIOException1)
    34. {
    35. }
    36. }
    37. }
    38. }


    Webhandler.class

    Code:java
    1. package me.bluemustache.forceresource;
    2.  
    3. import java.io.BufferedReader;
    4. import java.io.DataOutputStream;
    5. import java.io.File;
    6. import java.io.FileInputStream;
    7. import java.io.InputStreamReader;
    8. import java.net.Socket;
    9. import java.util.HashMap;
    10. import java.util.StringTokenizer;
    11.  
    12. public class WebHandler extends Thread
    13. {
    14. private Socket client;
    15. private BufferedReader inFromClient = null;
    16. private DataOutputStream outToClient = null;
    17. private Webserver ws = null;
    18. ForceTexture ft;
    19. public HashMap<String, Integer> bytesTransferred = new HashMap<String, Integer>();
    20. public HashMap<String, Integer> bytesTotal = new HashMap<String, Integer>();
    21.  
    22. public WebHandler(Socket c, Webserver w) { this.client = c;
    23. this.ws = w;}
    24.  
    25. public void run() {
    26. try {
    27. this.inFromClient = new BufferedReader(new InputStreamReader(this.client.getInputStream()));
    28. this.outToClient = new DataOutputStream(this.client.getOutputStream());
    29.  
    30. String requestString = this.inFromClient.readLine();
    31. String headerLine = requestString;
    32. StringTokenizer tokenizer = new StringTokenizer(headerLine);
    33. String httpMethod = tokenizer.nextToken();
    34. String httpQueryString = tokenizer.nextToken();
    35. while (this.inFromClient.ready())
    36. {
    37. requestString = this.inFromClient.readLine();
    38. String[] v = requestString.split(": ");
    39. if (v.length > 1) {
    40. String field = v[0];
    41. String value = v[1];
    42. if (field.equals("X-Minecraft-Username")) {
    43. ForceTexture.isDownloading.put(value, true);
    44. }
    45. }
    46.  
    47. }
    48.  
    49. if (httpMethod.equals("GET")) {
    50. if (httpQueryString.equals("/"))
    51. {
    52. sendResponse(200, "MC Resource Pack Server - Created by MylesC & BlueMustache", false);
    53. }
    54. if (httpQueryString.equals("/ping"))
    55. {
    56. sendResponse(222, "MC|RP Server ONLINE", false);
    57. }
    58. if (httpQueryString.equals("/debug")) {
    59. sendResponse(200, "MC|RP Server v" + this.ws.ft.getDescription().getVersion(), false);
    60. }
    61. if (httpQueryString.equals("/texturepack.zip")) {
    62. String fileName = "texturepack.zip";
    63. if (new File(fileName).isFile()) {
    64. sendResponse(200, fileName, true);
    65. }
    66. else
    67. sendResponse(404, "", false);
    68. }
    69. }
    70. else {
    71. sendResponse(404, "<b>The Requested resource not found. </b>", false);
    72. }
    73. } catch (Exception localException) {
    74. }
    75. }
    76.  
    77. public void sendResponse(int statusCode, String responseString, boolean isFile) throws Exception {
    78. String statusLine = null;
    79. String serverdetails = "Server: Java HTTPServer";
    80. String contentLengthLine = null;
    81. String fileName = null;
    82. String contentTypeLine = "Content-Type: text/html\r\n";
    83. FileInputStream fin = null;
    84. statusLine = "HTTP/1.1 200 OK\r\n";
    85. switch (statusCode) {
    86. case 200:
    87. statusLine = "HTTP/1.1 200 OK\r\n";
    88. break;
    89. case 500:
    90. statusLine = "HTTP/1.1 500 Internal Server Error\r\n";
    91. break;
    92. case 222:
    93. statusLine = "HTTP/1.1 222 Ping Response\r\n";
    94. break;
    95. default:
    96. statusLine = "HTTP/1.1 404 Not Found\r\n";
    97. }
    98.  
    99. if (isFile) {
    100. fileName = responseString;
    101. fin = new FileInputStream(fileName);
    102. contentLengthLine = "Content-Length: " + Integer.toString(fin.available()) + "\r\n";
    103. if ((!fileName.endsWith(".htm")) && (!fileName.endsWith(".html")))
    104. contentTypeLine = "Content-Type: application/zip\r\n";
    105. }
    106. else {
    107. contentLengthLine = "Content-Length: " + responseString.length() + "\r\n";
    108. }
    109. if (!this.client.isClosed()) {
    110. this.outToClient.writeBytes(statusLine);
    111. this.outToClient.writeBytes(serverdetails);
    112. this.outToClient.writeBytes(contentTypeLine);
    113. this.outToClient.writeBytes(contentLengthLine);
    114. this.outToClient.writeBytes("Connection: close\r\n");
    115. this.outToClient.writeBytes("\r\n");
    116.  
    117. if (isFile) {
    118. byte[] buffer = new byte[1024];
    119. int bytesRead;
    120. while ((bytesRead = fin.read(buffer)) != -1)
    121. {
    122. this.outToClient.write(buffer, 0, bytesRead);;
    123. }
    124. }
    125. fin.close();
    126. }
    127. else {
    128. this.outToClient.writeBytes(responseString);
    129. }
    130. this.outToClient.close();
    131. }
    132. }


    @above
    The code here is have I have so far.
    I just need help making my thesis statement work in Webhandler.class
    Then I will mark this as solved.
    Please help. :(
    -Blue

    EDIT: I assume you can figure out how all the hashmaps fit together. If not, I'll explain it.

    Anyone? :(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  19. Offline

    BlueMustache

  20. Offline

    BlueMustache

  21. Offline

    BungeeTheCookie

    BlueMustache
    You are trying to revive a force texture plugin.
    How about just have the user store the resource in the plugin.datafolder, then just load it off of that and force the resource instead of doing the webserver crap?

    Anyways, does it work? What do you want to add? Where are you errors [if any?]
     
  22. Offline

    BlueMustache

Thread Status:
Not open for further replies.

Share This Page