Code Monkey home page Code Monkey logo

Comments (4)

matthewbot avatar matthewbot commented on August 16, 2024

I don't think I understand the problem. The line you listed has nothing to do with the players inventory, but the surrounding code does have what seems to me to be sufficient inventory validation. If the players inventory is full, the plugin opts to imprison the player by overwriting a stack of enderpearls with a single prison pearl instead of letting the player go free.

from prisonpearl.

Rudd-O avatar Rudd-O commented on August 16, 2024

But that is not what the code does, right?

    PrisonPearl pp = pearls.newPearl(imprisoned, imprisoner); // create the prison pearl
    inv.setItem(pearlnum, new ItemStack(Material.ENDER_PEARL, 1, pp.getID())); // give it to the imprisoner
    imprisoned.setBedSpawnLocation(respawnworld.getSpawnLocation()); // reset the player's normal spawn location

    Bukkit.getPluginManager().callEvent(new PrisonPearlEvent(pp, PrisonPearlEvent.Type.NEW)); // set off an event
    return true;

Seems to me like the "give" fails here, and then the event is inconsistent because the "give" didn't actually take place in the case of a full inventory. The give does not overwrite stuff just like that, does it?

from prisonpearl.

matthewbot avatar matthewbot commented on August 16, 2024

inv.setItem() is what modifies the inventory, but it overwrites the contents of the slot with the given item, so it can't fail, whatever was in that slot just gets deleted. pearlnum, the slot number, gets chosen based on the logic above that snippit, which finds an empty slot if at all possible but otherwise elects to overwrite ender pearls.

from prisonpearl.

Rudd-O avatar Rudd-O commented on August 16, 2024

Ahhhh.

I think it should consume inventory but not nuke an entire stack, only overwriting if it falls back. Add it to the TODO file I guess.

from prisonpearl.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.