java


Repeating an effect on blocks in a world


What I am trying to accomplish is so when the server starts/reloads the plugin is going to detect all SKULLS in the world and then set a effect on them that is looping and does not end.
My current code:
#EventHandler
public void onChunkLoad(ChunkLoadEvent event){
Chunk chunk = event.getChunk();
if(event.getWorld().getName().equals("world")){
for (int x = 0; x < 16; x++){
for (int y = 0; y < 256; y++){
for(int z = 0; z <16; z++){
Block block = chunk.getBlock(x, y, z);
if(block.getType() == Material.SKULL){
event.getWorld().playEffect(block.getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
Looping over 65536 blocks for each chunk loaded is going to put a lot of stress on your server's processor.
You should try Chunk#getTileEntities() and see if the tile entity is instanceof org.bukkit.block.Skull
Additionally, you are only spawning the particles once, which is when the chunk loads. The best way to make the effect repeating is to store the skulls that get loaded into an ArrayList and use a BukkitRunnable to continually loop over all the skulls and create a particle effect.
You can read about how to use a BukkitRunnable here

Related Links

Continue development of Plugin
Efficient Approach: JSON File Write or File Append
Different sorting algorithms fail on large arrays
TextView doesn't synchronize
XSLT fails to transform bigger XML file. Process getting killed becauase of memory overhead
Tomcat encode redirect in https
Error when using lambda in java 1.8
Generating unique list of numbers each time in java
Appium/Selenium - assert that element declared as field is NOT displayed
Looping for the handling exception
Bench Mark in Multi threaded environment
java.lang.ClassNotFoundException when run Mule apllication from IntelliJ IDEA
How to replace <datatable> tag by <table> tag
Blocking threads using javassist in web app
Hibernate ManyToOne Mapping
Average Score Java using a Do While loop

Categories

HOME
testing
osgi
cloud
smarty
appx
lodash
relayjs
indesign
multiple-records
spring-kafka
offline
handsontable
spring-tool-suite
usergrid
visual-studio-2005
visual-studio-cordova
serilog
undefined
text-rendering
h2db
buildbot
phpfox
ping
madlib
sql-server-2012-express
framemaker
accelerate-framework
restlet
code-search-engine
sqlite2
impersonation
bootstrapper
osx-mavericks
return-value
sqlbulkcopy
orthogonal
eventkit
url-pattern
merge-conflict-resolution
fputcsv
pickadate
asp.net5
freedesktop.org
unity-networking
intellij-14
qdialog
dundas
notify
google-style-guide
cctv
dealloc
oracle-warehouse-builder
ember-charts
industrial
blending
flash-builder4.5
javaspaces
subscript
adk
remember-me
site.master
infrastructure
jquery-ui-droppable
asp.net-profiles
swing-app-framework
sustainable-pace
project-hosting
thread-local-storage
mdac
commodore

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App