Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

InventoryTransactionEvent

Comments in 'Plugin Development' started by Bluplayz, Nov 20, 2015.

  1. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    i copy paste a Code from a bedwars plugin but want to know what is what

    PHP:
    public function onTransaction(InventoryTransactionEvent $event) {
      
    $trans $event->getTransaction()->getTransactions();
      
    $int $event->getTransaction()->getInventories();
      
    $isChest false;
      
    $isPlayer false;
      
    $player;
      
    $chestNew;
      
    $realTrans;
      foreach (
    $trans as $t) {
      foreach (
    $int as $chest) {
      if (!(
    $chest instanceof ChestInventory) && !($chest instanceof PlayerInventory)) {
      return;
      }
      
    $chest $chest->getHolder();
      if (
    $chest instanceof Chest) {
      
    $chestNew $chest->getBlock();
      
    $isChest true;
      
    $realTrans $t;
      }
      if (
    $chest instanceof Player) {
      
    $player $chest;
      
    $isPlayer true;
      }
      }
      }
      if (
    $isPlayer == true && $isChest == true) {
    $mainChest $player->getLevel()->getTile($chestNew);
    if(
    $mainChest instanceof Chest){
    $realItemTrans $realTrans->getTargetItem(); //item das gehandelt wird
    $inventoryTrans $mainChest->getInventory();
    $itemTransID $realTrans->getTargetItem()->getId();
    if(
    $itemTransID == 2){
    foreach (
    $this->getServer()->getLevelByName("LobbyBW")->getPlayers() as $player) {
    $player->sendMessage($this->prefix "InventoryTransactionEvent works !");
    $this->getLogger()->info($this->prefix "InventoryTransactionEvent works !");
    }
    }
    }
    }
    }
    by the way ist dont work but i want that if the Player grab a item from the chest that he opens a new chest but dont know how :D and how i can get the player
    Last edited: Nov 20, 2015
    Legoboy0215 likes this.
  2. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    I dont know :p
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    First, why do you copy a part of my Code? Second, if you copy, you need to understand what you did, and I see, you don't(there are mistakes in the code). Third, copying isn't coding - Learn PHP and the Pocketmine API and build your way up, instead of copying other Plugins/Codes.
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Why does he even have your code lol
  5. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    I made a thread because I needed help
  6. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    I know there is a mistake because i wantto understand what the event does , but with you sentences "copy my code bla" i dont know what that is xD it works with other code but i copy paste and dont know what is what so i Ask again ... What variable is what and what does this do? ->
    If($ItemTrans % 2 ==0){} ? What is %
  7. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    % is remainder.
  8. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    How Remainder ? Any example ?
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Did you pass 3rd grade math?
  10. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    Yes but dont know what remainder is , (my english skills) di this mean / 2 ?
  11. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    3 / 2 = 1 ... 1
  12. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
  13. Bluplayz
    Offline

    Bluplayz Active Member

    Joined:
    Aug 20, 2015
    Posts:
    74
    Minecraft User:
    Bluplayz
    Hmm dont know but is any thing like this->

    150 % *14

    And the answer is 21 ??
  14. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Sigh... Just study PHP at codeacademy first. If you don't want to, then you are not worthy enough to be here.
    Legoboy0215 likes this.
  15. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    This event does not fire for me...

Share This Page

Advertisement