Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    PEMapModder
    @PEMapModder
    let me check...
    Jorge González
    @iksaku
    :O
    PEMapModder
    @PEMapModder
    so we really need to make good constructors
    like, a FactionBuilder class
    do you know what is special about builder classes?
    I mean, do you know what people use builder classes for?
    they usually have this thing:
    Jorge González
    @iksaku
    Nope...
    To?
    PEMapModder
    @PEMapModder
    class FooBuilder{
    private $field1;
    private $field2;
    private $field3;
    public function set1($one){
      $this->field1 = $one;
      return $this;
    }
    public function set2($one){
      $this->field2 = $one;
      return $this;
    }
    public function set3($one){
      $this->field3 = $one;
      return $this;
    }
    public function build(){
      return new Foo($field1, $field2, $field3);
    }
    }
    so you can just do
    $foo = (new FooBuilder)->set1($one)->set2($two)->set3($three)->build();
    Jorge González
    @iksaku
    What about events for that?
    PEMapModder
    @PEMapModder
    or splilt them up to lines
    what events?
    like FactionCreateEvent?
    what do you mean by what about?
    Jorge González
    @iksaku
    Yes, call events when someone is going to build a faction, this will open the doors for other developers
    PEMapModder
    @PEMapModder
    yes, so we should add them.
    I agree that we should add them.
    Jorge González
    @iksaku
    ;)
    PEMapModder
    @PEMapModder
    I was just thinking that...
    never mind.
    Jorge González
    @iksaku
    So, create the builder function, it will call the 'Faction Create' event, with the corresponding information, and lastly, call the Builder class to create the faction correctly
    PEMapModder
    @PEMapModder
    maybe like this:
    class FooBuilder{
      private $field1;
      private $field2;
      private $field3;
      public function set1($one){
        $this->field1 = $one;
        return $this;
      }
      public function set2($one){
        $this->field2 = $one;
        return $this;
      }
      public function set3($one){
        $this->field3 = $one;
        return $this;
      }
      public function build(){
        $pluginMgr->callEvent($ev = new FactionCreateEvent($this));
        return $ev->isCancelled() ? null : new Foo($field1, $field2, $field3);
      }
    }
    oops
    wait I edit
    Jorge González
    @iksaku
    xD
    PEMapModder
    @PEMapModder
    see edit
    at the build() functon
    Jorge González
    @iksaku
    Yes
    PEMapModder
    @PEMapModder
    :)
    Jorge González
    @iksaku
    I mean, call the event from the main API, and after call the builder class
    PEMapModder
    @PEMapModder
    we should look back at StasCore and xEcon meanwhile
    Jorge González
    @iksaku
    Yes
    PEMapModder
    @PEMapModder
    so
    about xEcon
    we should test it :P
    Jorge González
    @iksaku
    xD true
    PEMapModder
    @PEMapModder
    I did a little tests
    some commands are working
    Jorge González
    @iksaku
    wooo!
    And what left?
    PEMapModder
    @PEMapModder
    We should talk about that on xEcon chatroom :P
    Jorge González
    @iksaku
    Okey :3
    BotsHateNames
    @BotsHateNames
    Yo, ! Random text: Keep it logically awesome.
    NycuRO
    @NycuRO
    Project is abandonated?
    Jorge González
    @iksaku
    Had always been
    Jonathan Chan Kwan Yin
    @SOF3
    @iksaku pay attention to your words ;)