Comments (4)
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.
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.
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisonpearl.