How to make this..

Discussion in 'Plugin Development' started by MarceloEstigar, Dec 17, 2014.

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

    MarceloEstigar

    hello guys, i want to make this:
    i have integers:
    int v1; & int v2;
    when i modofy the "v1", i whant reflect this in the "v2" and when i modify the "v2", reflect this in the "v1"
    This is Possible?:confused:
     
  2. Offline

    Skionz

  3. Offline

    MarceloEstigar

    How? I searched, but i don't find nothing about this
     
  4. Offline

    Skionz

    @MarceloEstigar
    Code:
    public void set(String newString) {
        this.myString = newString;
    }
     
  5. Offline

    MarceloEstigar

    This only change myString.. :oops:

    i want to change the "V1" and reflect this on "V2" and vice versa.. like the same object
     
  6. Offline

    Skionz

  7. Offline

    MarceloEstigar

    yes, v1 = v2 and v2 = v1
    a reference to an int.. :oops:
     
  8. Offline

    97WaterPolo

    @MarceloEstigar
    Set them both with a setter method?
    PHP:
    public void set(String newString) {
        
    this.v1newString;
        
    this.v2newString;
    }
     
  9. Offline

    Webbeh

    I'm pretty sure you can easily find a way to transform that method to do what you want...
     
  10. Offline

    MarceloEstigar

    nop, this not work for me..
    An example..
    Code:
    CopyOnWriteArrayList<Player> players = new CopyOnWriteArrayList<Player>();
    int originalvalue1 = 0;
    int anotheroriginalvalue = 0;
    
    public void thefunction(Player p){
    int value1 = 0;
    
    if(players.contains(p)){
    value1 = originalvalue1;
    }else{
    value1= anotheroriginalvalue;
    }
    
    if(p.hasPermission("perm.*")){
    value1 = 5; // and change the respective original value in the top of the script
    }
    
    
    }
     
  11. Offline

    Webbeh

    This code is an absolute nightmare.

    CopyOnWrite arraylists, using player instances. Values that mean absolutely nothing, for which we absolutely don't get the use, ...

    If you can explain clearly what you're trying to achieve, we'll be able to help.

    Otherwise... just add a "originalvalue1 = value1;" just after the "value1 = 5" and you're set.
     
  12. Offline

    MarceloEstigar

    i know, to change the original value, i can use the "if"... but i want to make more short this script... the original script have +400 lines.. with a lot of "if's".. i want to make a direct reference to te original value.. :oops:
     
Thread Status:
Not open for further replies.

Share This Page