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

JAXB binding for xs:integer to Java Integer instead of BigInteger
Error:Process 'command '/usr/local/android-studio/jre/bin/java'' finished with non-zero exit value 2
Java - enum with static counter
ActiveMQ java client startup hangs when server is unavailable
Java DetachedCriteria: wrong order if using accented characters
Reading multiple rows for DB2 using JDBC named templates but without “IN” clause in SQL
Searching objects nearby using radius. Google maps
Connect to rabbitmq on local host from a Docker container
SIGILL occurs when calling env->ThrowNew() in JNI
Spring Security Java logout configuration [duplicate]
How can I get a return?
IntelliJ IDEA Error Running Application
How do I keep a piece of code in Java always running on ubuntu/centOS?
how get the name of the first array1bits from Array storebits?
Hangman Java Game Printing Both Wrong and Correct Guesses
shapes becomes invisible after changing location of components

Categories

HOME
testing
netsuite
urbancode
electron
bookshelf.js
rdf
win32gui
callback
angular-ui-bootstrap
enterprise-library-5
flyway4
bs4
applepay
node-pdfkit
modelica
progressive-web-apps
shared-hosting
arabic
lcd
autosys
apache-commons-io
dynamic-featured-image
chromebook
url-scheme
brunch
ejabberd-module
libssl
stormpath
iframe-resizer
key-value-observing
xquery-3.0
android-browser
greenrobot-eventbus
dism
import-from-excel
avconv
user-accounts
rainbowtable
jquery-validate
typescript1.8
sage-one
dotnetzip
slickedit
flutterwave
color-picker
android-textview
thrust
ctest
storekit
ready-api
make-install
hexdump
uid
ford-fulkerson
natvis
angular-leaflet-directive
sysinternals
sniffer
clicktag
nstableviewcell
wordpress-theme-customize
php-5.4
castle
eol
p4java
comexception
mysql-error-1062
undefined-reference
gnu-smalltalk
ivyde
dir
easy-install
rabl
orchardcms-1.7
ocunit
distutils
postgresql-performance
code-cleanup
cufon
window-management
deobfuscation
gcj
javax.script
inotifycollectionchanged
w3wp
ajax-forms

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App