Comments (11)
What happened to this? I can't find any equivalent in 7.1.0
It's available through Keys.
from spongeapi.
@blablubbabc Mojang already has a persistence method called
protected boolean canDespawn()
{
return false;
}
By default all animals(cows, pigs, chickens, etc.) are persistent so if your plugin was spawning animals that extended this class, you wouldn't need to override this method.
However, I can simply add this method to our Living API so it can be overridden. As long as you are keeping track of each entity UUID, you should be able to remove them easily by listening to the proper event.
"server starts again with entity A, plugin however has stored uuid of entity B therefore can't identify and remove entity A"
Why isn't this plugin smart enough to remove the UUID only when the world has been saved? These events exist for a reason.
In any case, I'll add the appropriate methods to our Entity API as I can see it being useful.
from spongeapi.
@bloodmc
"By default all animals(cows, pigs, chickens, etc.) are persistent so if your plugin was spawning animals that extended this class, you wouldn't need to override this method."
My usecase would probably be more about disabling the saving of those entities rather than enabling.
"I can simply add this method to our Living API so it can be overridden."
With that you mean only adding the 'canDespawn' method but no method in the api which allows modifying the output of that (similar to 'setPersistent' or 'setDespawning()') without having to create a class for all available living entity types (like npc plugins are already doing currently in craftbukkit) and overriding that method? If so it would mean that plugins would have to maintain and update custom entity classes (which extend the original ones) for all the entity types they want to support, right?
With the modifiable flag this wouldn't be needed and a plugin could work with any new entity which is added to minecraft without needing any update.
Also if that flag would reside in Entity rather than Living it would mean that this api wouldn't be limited to Living entities only.
"Why isn't this plugin smart enough to remove the UUID ONLY when the world has been saved? These events exist for a reason."
Well, in craftbukkit at least the WorldSaveEvent wasn't called in all situations (see https://bukkit.atlassian.net/browse/BUKKIT-3681 as example). If that won't be the case in sponge then it will indeed be far easier to workaround the issue.
Neverthelss I just thought it might be more straight-forward having this flag and making sure that those entities are not persistenly stored to disk in the first place, rather than trying to cleanup the remaining entities after a crash.
Edit:
Just saw your edit including the 'setPersistent()' method. That's exactly what I was suggesting with this ticket, thanks!
Though having this inside of Entity rather than only Living would maybe be worth a thought. So it could work for things which would normally be stored to disk as well, like items or vehicles. So plugins could spawn those temporary in (for whatever purpose, ex. only for temporary visual purposes), but don't have to care about their removal (or potential non-removal at server crashes).
from spongeapi.
@blablubbabc OK, I can see your point.
/**
* Returns whether this entity will be persistent when no player is near.
*
* @return True if this entity is persistent
*/
boolean isPersistent();
/**
* Sets whether the entity will be persistent when no player is near.
*
* @param persistent Whether the entity will be persistent
*/
void setPersistent(boolean persistent);
How do the above methods work for you for our Entity API?
from spongeapi.
@bloodmc
"How do the above methods work for you for our Entity API?"
Perfect, thanks!
from spongeapi.
@blablubbabc OK so after much discussion, we have decided that we will add this ONLY to Living API as this is what Vanilla supports. If you want to have this type of functionality for non-living then you will need to write the logic yourself. So the above methods will be added to our Living API but not Entity.
from spongeapi.
@blablubbabc Fixed in a6e4c67
from spongeapi.
@bloodmc
"as this is what Vanilla supports"
Hm, well, entity saving/persistence is something which not only exists for living entities in vanilla minecraft ('isLoaded' and the internal saving method 'd(NBTTagCompound nbttagcompound)' also exist for all entities..).
I am glad it was at least added for living entities as that fulfills my own usecase currently.
However I am sure there are similar usecases for other entities as well: an example usecase would be the one of the Showcase plugin (http://dev.bukkit.org/bukkit-plugins/scs/) which spawns and removes item entities similar to how I spawn and remove living entities.
Entities which are never persistently stored / which don't support persistent storage in minecraft could ignore the persistent flag, in case that this argument was part of your internal discussion.
from spongeapi.
It would also be useful for holograms without messing around with packet api unless the display is per player, But armor stands are "living" in vanilla anyway.
from spongeapi.
What happened to this? I can't find any equivalent in 7.1.0
from spongeapi.
What happened to this? I can't find any equivalent in 7.1.0
It's available through Keys.
Cheers, thanks
from spongeapi.
Related Issues (20)
- Expose FastUtil in API HOT 2
- Can't get Biome Volume Factory with factory provider HOT 1
- Server-scoped PlayerChatRouter
- Ability to Hide Entities - "Sending Single Client Data" HOT 1
- Add method to retrieve level name from world properties
- Add Java Modules to Sponge API
- Amendments to API org.spongepowered.api.service.permission.SubjectData
- Enhanced Loot Table support HOT 1
- Typo
- automatic parameterized registration of plugin derived permission sets HOT 1
- Add a DataFormats.SNBT
- DataTranslator registry HOT 1
- Unregister an existing command registration
- Compile API 9 in Java 8 HOT 1
- Review content of util package HOT 1
- Make ServersideConnectionEvent.Handshake a Cancellable MessageEvent, like Auth
- Inventory from BlockSnapshot
- Return type of Container#type()
- Ability to get active bossbars on player
- error which mod spongepowered HOT 1
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 spongeapi.