Jump to content

Divine-X

Member
  • Content count

    1,660
  • Joined

  • Last visited

1 Follower

About Divine-X

  • Rank
    Rune Member
  • Birthday 10/01/1990

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. [video=youtube;vaeA43-U5kM]http://www.youtube.com/watch?v=vaeA43-U5kM[/video]
  2. Divine-X

    Ghosts vs BF4

    [quote name='bigboysss']ghosts ftw[/QUOTE] Battlefield 4.
  3. [url]http://kotaku.com/hackers-claim-takedown-of-battle-net-league-of-legends-1491906080?utm_campaign=Socialflow_Kotaku_Facebook&utm_source=Kotaku_Facebook&utm_medium=Socialflow[/url] Omg wow, such smart, much DDOS
  4. Divine-X

    Python?

    [quote name='SSion']What is the best language to learn first? I heard its python.[/QUOTE] When I started I learned HTML(not considered a real language) and then I went to Java. I would say Java is the 1st language you should learn since a lot of companies and machines use Java. But then they also use C <.<.
  5. [quote name='Trey']You're abusing/misunderstanding the point of the static keyword. When a variable is static, it is the same value for all instances of that class, rather than each instance having its own separate value such as for non-static variables. This mean every instance of Player will have the same hp, which is almost assuredly not intended. You say that you make it static so that you can change it, and I don't understand why this is. You have setters/getters for all your other instance variables, so why is hp any different? Are you using serialization (Serializable interface, read/writeObject)? The fact that it is static is also probably why it isn't saved in the XML. It doesn't make sense to save static variables, so they aren't.[/QUOTE] If I have the regular getter/setter setup and I do some calculations for the damage done to the player, and I try to save the game, the player file will stay at[code]<hp>100</hp>[/code] when in the game itself the player is at for example 70hp.
  6. [quote name='Emily']Why is 'hp' static? You're using setters, so I'm assuming you have getters as well. This line: [IMG]return Integer.parseInt(element.get(name));[/IMG] parseInt is meant for strings only, which the value could be an object in this case. Should be: [CODE] return Integer.parseInt(element.get(name).toString()); [/CODE] Only thing I can see on a quick glance.[/QUOTE] If I didn't make it static I wouldn't be able to change the players HP, it'll only change the classes HP value temporarily.
  7. [quote name='zizema660']hey so I want to start hosting my 317 [pi] but for some reason people cant load the cache from my website so whatever if I buy a vps will it help with that problem if I purchase a vps what files do you think I will have to change and how do I change them? thanks for looking guys[/QUOTE] VPS: Virtual Private Server, it's a virtual machine(computer) that is sold by an Internet Hosting Service. A VPS runs it's own copy of an operating system. It's basically a virtual computer that never turns off(unless the company is doing something). They probably can't load the cache because it's probably not being downloaded properly. I don't know, I'm not a 317 person. And buying a vps will not help the problem. People buy VPSs to host their server so people can enjoy it at anytime of the day.
  8. [quote name='Friss']Well where do you create the file? From a quick look over I don't see where you create the file. Also your set hp you use Player.hp while everywhere else you use this.hp any reason why? Sent from my XT1034 using Tapatalk[/QUOTE] [code] public static void create(Player p) { try { String username = JOptionPane.showInputDialog("Please enter a username"); String password = JOptionPane.showInputDialog("Please enter a password"); if(password.length() == 0) { JOptionPane.showMessageDialog(null, "Enter a password greater than 0!"); create(p); } else { File f = new File("data/games/"+username+".xml"); if(f.exists()) { JOptionPane.showMessageDialog(null, "This file already exists!", "Alert", JOptionPane.ERROR_MESSAGE); create(p); } else { p.setUsername(username); p.setPassword(password); save(p); } } } catch(Exception e) { JOptionPane.showMessageDialog(null, "There is no such directory.", "Alert", JOptionPane.INFORMATION_MESSAGE); } }[/code] [code] public static void save(Player p) { try { XStream xst = FileManager.getXStream(); xst.toXML(p, new FileOutputStream( "data/games/"+p.getUsername()+".xml")); } catch(Exception e) { System.out.println("Error with saving player!"); } }[/code] And I use "Player.hp" because eclipse said it should be accessed in a static way.
  9. [quote name='yehimnick']and yes i do got team viewer[/QUOTE] PM your ID and Pass
  10. [quote name='yehimnick'][url]http://gyazo.com/ef142e2fb1f0a4ee0bb84449cca67476[/url] <--- compiler code [url]http://gyazo.com/fb6a843afc377b09aad3f6e0e44f6a25[/url] <--- variable[/QUOTE] Do you have Teamviewer? If so pm me your ID and Pass
  11. [quote name='yehimnick']:( weird this is hard[/QUOTE] Can you post your compilers code?
  12. [code]public void drawLoginScreen(boolean flag) { if (normalLogin == true) { resetImageProducers(); aRSImageProducer_1109.initDrawingArea(); aBackground_966.drawBackground(0, 0); char c = '\u0168'; char c1 = '\310'; } if(loginScreenState == 0) { int i = c1 / 2 + 80; smallText.method382(0x75a9a9, c / 2, onDemandFetcher.statusString, i, true); i = c1 / 2 - 20; chatTextDrawingArea.method382(0xffff00, c / 2, "Welcome to RuneScape", i, true); i += 30; int l = c / 2 - 80; int k1 = c1 / 2 + 20; aBackground_967.drawBackground(l - 73, k1 - 20); chatTextDrawingArea.method382(0xffffff, l, "New User", k1 + 5, true); l = c / 2 + 80; aBackground_967.drawBackground(l - 73, k1 - 20); chatTextDrawingArea.method382(0xffffff, l, "Existing User", k1 + 5, true); } if(loginScreenState == 2) { int j = c1 / 2 - 40; } if(loginMessage1.length() > 0) { chatTextDrawingArea.method382(0xffff00, c / 2, loginMessage1, j - 15, true); chatTextDrawingArea.method382(0xffff00, c / 2, loginMessage2, j, true); j += 30; } else { chatTextDrawingArea.method382(0xffff00, c / 2, loginMessage2, j - 7, true); j += 30; } chatTextDrawingArea.method389(true, c / 2 - 90, 0xffffff, "Username: " + myUsername + ((loginScreenCursorPos == 0) & (loopCycle % 40 < 20) ? "@[email protected]|" : ""), j); j += 15; chatTextDrawingArea.method389(true, c / 2 - 88, 0xffffff, "Password: " + TextClass.passwordAsterisks(myPassword) + ((loginScreenCursorPos == 1) & (loopCycle % 40 < 20) ? "@[email protected]|" : ""), j); j += 15; if(!flag) { int i1 = c / 2 - 80; int l1 = c1 / 2 + 50; aBackground_967.drawBackground(i1 - 73, l1 - 20); chatTextDrawingArea.method382(0xffffff, i1, "Login", l1 + 5, true); i1 = c / 2 + 80; aBackground_967.drawBackground(i1 - 73, l1 - 20); chatTextDrawingArea.method382(0xffffff, i1, "Cancel", l1 + 5, true); } if(loginScreenState == 3) { chatTextDrawingArea.method382(0xffff00, c / 2, "Create a free account", c1 / 2 - 60, true); int k = c1 / 2 - 35; chatTextDrawingArea.method382(0xffffff, c / 2, "To create a new account you need to", k, true); k += 15; chatTextDrawingArea.method382(0xffffff, c / 2, "go back to the main RuneScape webpage", k, true); k += 15; chatTextDrawingArea.method382(0xffffff, c / 2, "and choose the red 'create account'", k, true); k += 15; chatTextDrawingArea.method382(0xffffff, c / 2, "button at the top right of that page.", k, true); k += 15; int j1 = c / 2; int i2 = c1 / 2 + 50; aBackground_967.drawBackground(j1 - 73, i2 - 20); chatTextDrawingArea.method382(0xffffff, j1, "Cancel", i2 + 5, true); } aRSImageProducer_1109.drawGraphics(500, super.graphics, 155); if(welcomeScreenRaised) { welcomeScreenRaised = false; aRSImageProducer_1107.drawGraphics(0, super.graphics, 128); aRSImageProducer_1108.drawGraphics(371, super.graphics, 202); aRSImageProducer_1112.drawGraphics(265, super.graphics, 0); aRSImageProducer_1113.drawGraphics(265, super.graphics, 562); aRSImageProducer_1114.drawGraphics(171, super.graphics, 128); aRSImageProducer_1115.drawGraphics(171, super.graphics, 562); } else if(normalLogin == false) { worldLoginScreen(); resetImageProducers(); aRSImageProducer_1109.initDrawingArea(); Sprite loginTest = new Sprite("Login/login"); loginTest.drawSprite(0, 0); } if(loginMessage1.length() > 0) { chatTextDrawingArea.method382(0x00ccff, 255, loginMessage2, 60, true); } else { chatTextDrawingArea.method382(0x00ccff, 255, loginMessage2, 60, true); } if (loginButtonint == 0) { Sprite LOGINBUTTON = new Sprite("Login/LOGINBUTTON"); LOGINBUTTON.drawSprite(382, 89); } else if (loginButtonint == 1) { Sprite LOGINBUTTON0 = new Sprite("Login/LOGINBUTTON1"); LOGINBUTTON0.drawSprite(382, 89); } if (!rememberMe) { Sprite unclickedR = new Sprite("Login/unclicked"); unclickedR.drawSprite(13, 130); } else if (rememberMe) { Sprite clickedR = new Sprite("Login/clicked"); clickedR.drawSprite(13, 130); } if (textbox == 0) { Sprite textbox = new Sprite("Login/textbox"); textbox.drawSprite(13, 91); } else if (textbox == 1) { Sprite textbox1 = new Sprite("Login/textbox1"); textbox1.drawSprite(13, 91); } if (textbox1 == 0) { Sprite textbox = new Sprite("Login/textbox"); textbox.drawSprite(197, 91); } else if (textbox1 == 1) { Sprite textbox1 = new Sprite("Login/textbox1"); textbox1.drawSprite(197, 91); } /** Font types **/ //chatTextDrawingArea.method389(true, 18, 0x00f0ff, "" + capitalize(myUsername) + ((loginScreenCursorPos == 0) & (loopCycle % 40 < 20) ? "|" : ""), 110); aTextDrawingArea_1271.method389(false,18,0x000000,"" + (myUsername) + ((loginScreenCursorPos == 0) & (loopCycle % 40 < 20) ? "|" : ""), 110); //chatTextDrawingArea.method389(true, 203, 0x00f0ff, "" + TextClass.passwordAsterisks(myPassword) + ((loginScreenCursorPos == 1) & (loopCycle % 40 < 20) ? "|" : ""), 110); aTextDrawingArea_1271.method389(false,203,0x000000,"" + TextClass.passwordAsterisks(myPassword) + ((loginScreenCursorPos == 1) & (loopCycle % 40 < 20) ? "|" : ""), 110); aRSImageProducer_1109.drawGraphics(171, super.graphics, 133); if(welcomeScreenRaised) { welcomeScreenRaised = false; aRSImageProducer_1107.drawGraphics(0, super.graphics, 128); aRSImageProducer_1108.drawGraphics(371, super.graphics, 202); aRSImageProducer_1112.drawGraphics(265, super.graphics, 0); aRSImageProducer_1113.drawGraphics(265, super.graphics, 562); aRSImageProducer_1114.drawGraphics(171, super.graphics, 128); aRSImageProducer_1115.drawGraphics(171, super.graphics, 562); } } }[/code] I tried my best to clean it. Edit: You might need to delete the last } but yeah.
  13. Okay, I know what the problem is, I just don't know how to fix it. The problem is when I create a new file my code would get everything from the player class but not the hp. And when I try to load the game I would get an error since [code]<hp>AMOUNT</hp>[/code] isn't in the xml file. I feel like and it probably is because the variable is static but if it's not static I wouldn't be able to change the value. When I create a new game/file, what the game makes: [code]<player> <username>Storm</username> <password>k</password> <attack>5</attack> <defence>1</defence> <magic>1</magic> <warrior>false</warrior> <archer>false</archer> <mage>false</mage> <rights>1</rights> </player>[/code] What it's missing: [code]<player> <username>Storm</username> <password>k</password> [COLOR="#FF0000"] <hp>100</hp>[/COLOR] <attack>5</attack> <defence>1</defence> <magic>1</magic> <warrior>false</warrior> <archer>false</archer> <mage>false</mage> <rights>1</rights> </player>[/code] Load file code: [code] public static void load(Player p) { String name = JOptionPane.showInputDialog("Please enter your username"); if(name.length() == 0) { JOptionPane.showMessageDialog(null, "Enter a name longer than 0 characters!"); load(p); } String pass = JOptionPane.showInputDialog("Please enter your password"); if(pass.length() == 0) { JOptionPane.showMessageDialog(null, "Enter a password longer than 0 characters!"); load(p); } else { try { XML playerFile = new XML("data/games/"+name+".xml"); playerFile.setByElement("player"); for(int i = 0; i < playerFile.getElements().size(); i++) { Map<String, String> element = playerFile.getElements().get(i); String username = playerFile.getStringByTag(element, "username"); p.setUsername(username); String password = playerFile.getStringByTag(element, "password"); p.setPassword(password); int hp = playerFile.getIntByTag(element, "hp"); p.setHp(hp); int attack = playerFile.getIntByTag(element, "attack"); p.setAttack(attack); int defence = playerFile.getIntByTag(element, "defence"); p.setDefence(defence); int magic = playerFile.getIntByTag(element, "magic"); p.setMagic(magic); boolean warrior = Boolean.parseBoolean(playerFile.getStringByTag(element, "warrior")); p.setWarrior(warrior); boolean archer = Boolean.parseBoolean(playerFile.getStringByTag(element, "archer")); p.setArcher(archer); boolean mage = Boolean.parseBoolean(playerFile.getStringByTag(element, "mage")); p.setMage(mage); int rights = playerFile.getIntByTag(element, "rights"); p.setRights(rights); } } catch(Exception e) { JOptionPane.showMessageDialog(null, "Error with loading!", "Alert", JOptionPane.INFORMATION_MESSAGE); e.printStackTrace(); } } }[/code] XML stuff: [code]public class XML { private List<Map<String, String>> elements = new ArrayList<Map<String, String>>(); private BufferedReader reader; public XML(final String file) throws IOException { reader = new BufferedReader(new FileReader(file)); } public void setByElement(String name) throws IOException { String line; String endName = "</" + name +">"; name = "<" + name + ">"; while ((line = reader.readLine()) != null) { if (line.contains(name)) { Map<String, String> element = new HashMap<String, String>(); while (!(line = reader.readLine()).contains(endName)) { element.put(line.substring(line.indexOf("<") + 1, line.indexOf(">")), line.substring(line.indexOf(">") + 1, line.lastIndexOf("<"))); } elements.add(element); } } reader.close(); } public List<Map<String, String>> getElements() { return elements; } public String getStringByTag(Map<String, String> element, String name) { return element.get(name); } public long getLongByTag(Map<String, String> element, String name) { return Long.parseLong(element.get(name)); } public int getIntByTag(Map<String, String> element, String name) { return Integer.parseInt(element.get(name)); } public short getShortByTag(Map<String, String> element, String name) { return Short.parseShort(element.get(name)); } public byte getByteByTag(Map<String, String> element, String name) { return Byte.parseByte(element.get(name)); } }[/code] Player: [code] package text.game.player; public class Player { String username, password; [COLOR="#FF0000"] private static int hp = 100;[/COLOR] private int attack = 5; private int defence = 1; private int magic = 1; private boolean warrior = false; private boolean archer = false; private boolean mage = false; private int rights = 0; private Inventory inventory; /** * @return the username */ public String getUsername() { return username; } /** * @param username the username to set */ public void setUsername(String username) { this.username = username; } /** * @return the password */ public String getPassword() { return password; } /** * @param password the password to set */ public void setPassword(String password) { this.password = password; } [COLOR="#FF0000"] /** * @return the hp */ public int getHp() { return hp; }[/COLOR] [COLOR="#FF0000"] /** * @param newHp the hp to set */ public void setHp(int newHp) { Player.hp = newHp; }[/COLOR] /** * @return the rights */ public int getRights() { return rights; } /** * @param rights the rights to set */ public void setRights(int rights) { this.rights = rights; } /** * @return the warrior */ public boolean isWarrior() { return warrior; } /** * @param warrior the warrior to set */ public void setWarrior(boolean warrior) { this.warrior = warrior; } /** * @return the archer */ public boolean isArcher() { return archer; } /** * @param archer the archer to set */ public void setArcher(boolean archer) { this.archer = archer; } /** * @return the mage */ public boolean isMage() { return mage; } /** * @param mage the mage to set */ public void setMage(boolean mage) { this.mage = mage; } /** * @return the attack */ public int getAttack() { return attack; } /** * @param attack the attack to set */ public void setAttack(int attack) { this.attack = attack; } /** * @return the defence */ public int getDefence() { return defence; } /** * @param defence the defence to set */ public void setDefence(int defence) { this.defence = defence; } /** * @return the magic */ public int getMagic() { return magic; } /** * @param magic the magic to set */ public void setMagic(int magic) { this.magic = magic; } public Inventory getInventory() { return inventory; } public void setInventory(Inventory inventory) { this.inventory = inventory; } } [/code] Error: [code]Item info loaded: 2 java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at text.game.managers.XML.getIntByTag(XML.java:49) at text.game.managers.FileManager.load(FileManager.java:92) at text.gui.GUI$4.actionPerformed(GUI.java:87) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.AbstractButton.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$400(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)[/code]
×