#help-development
1 messages · Page 1648 of 1
damn
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
see that
looks accurate
you dont have to
it gives you a little bit more functionallity
but you rarely use the things it adds
paper is very good for server performance though
but when you use spigot it will work fine on paper servers
personally use this
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
and this repo
I can't go lower than 1.12 too with spigot
make sure you added the repo
in the lib?
in your pom
?paste
@tall dragon getting error with new pom
what is it
I just started in with 1.17 and changed the pom, would that work?
are you getting errors in your code?
that would be normal as the api of 1.17 has some substancial changes from 1.8
would you say it would be better to develop in 1.17?
Don't ever remove the api-version
yea ik, but for developing plugins, is it better or easier to do that in 1.17
To support everything, use api-version: 1.13
why woulnt you use the website of the creator
Adopt is prefered over oracle
@EventHandler
public void onBlaze(EntityDeathEvent event) {
if (event.getEntity().getType() == EntityType.BLAZE) {
}
}
}
}
How do i check if the killer is a player in this code?
Oracle JRE is paid and has a few other caveats
event.getEntity().getKiller() instanceof Player if im not mistaken @quaint mantle
thats it tysm
np
is there any place where i can physically see the uid of a world? in some file
AdoptOpenJDK has also a larger usership here (given that almost cannot obtain Oracle JRE)
erm
so I tried storing a HashMap<Integer, String> inside of YAML file
and retrieving it
but I'm guessing it's not as simple as that is it
Maps are flattened in yaml
How do you retrieve it?
.getMap exists iirc
Yea
erm
And throws it into a hashmao
It requires unsafe casts, but it is the way to Go here
getMapList()?
No, that is a list of maps iirc
iirc
I mean tbh you just get the configuration section and then parse it into a map
Not much effort
then I can't find getConfig().getMap
?jd
erm
public void onBlaze(EntityDeathEvent event) {
if (event.getEntity().getType() == EntityType.BLAZE && event.getEntity().getKiller() instanceof Player) {
Player player = event.getEntity().getKiller().getPlayer();
player.sendMessage("HI");
}
}
}```
Any1 knpw the issue with this code? When i kill a blaze i dont get the message
did you register the event
you should :)
& new to java my bad
lol
http://prntscr.com/1qcr7t8 how do i get these two sections?
getKeys(true) only give me Map2
loop through the map
wym
also
can't iterate through the set of keys since you can't tell if the name is loc1, or its the property loc1
How do I get a custom file in the main directory of a server?
actually nvm i have an idea
are you wanting the values of them?
i wanna get all the keys of Map2
how disable door, trapdoor, repeater etc click?
use flags
wg?
/region flag region name use deny
you are welcome
how would I implement the dependency to use NMS in my IDE
public static ItemStack getWateringCan(FarmingOverhaul plugin) {
ItemStack wateringCan = new ItemStack(Material.CLOCK);
ItemMeta canMeta = wateringCan.getItemMeta();
List<String> lore = new ArrayList<>();
PersistentDataContainer canData = wateringCan.getItemMeta().getPersistentDataContainer();
canData.set(new NamespacedKey(plugin, "isWateringCan"), PersistentDataType.BYTE, (byte) 1);
canData.set(new NamespacedKey(plugin, "waterLeft"), PersistentDataType.INTEGER, 10);
canMeta.setDisplayName(ChatColor.DARK_BLUE + "Watering Can");
lore.add("");
lore.add(ChatColor.AQUA + "Hold shift near crops to water them!");
lore.add("");
lore.add(ChatColor.AQUA + "Held water: " + ChatColor.GRAY + "10/10");
canMeta.setLore(lore);
wateringCan.setItemMeta(canMeta);
return wateringCan;
}
Any idea why it has no NBT data?
i set its data for 2 tags
because you're not setting it
😳
getItemMeta is missleading slightly
wateringCan.setItemMeta(canMeta);
I did that
the name shoould be something like createNewItemMetaFromMaterial
yes but you create another item meta instance and get the pdc of that one
Your datacontainer is using a clone, not canMeta
wateringCan.getItemMeta().getPersistentDataContainer();
yea :sadyeehaw:
i just saw that
😔
thank you lol
It really should be getItemMetaCopy() or something
Idk
that might be a little long 
how would i add a variable to that for everytime the player kills the blaze, it adds a number (int) to a variable
do you know when player are braking stone to sound is triggered on the server or client side?
meth the issue is even when i cancel the break block event the sound is played
Yeah
what if i send to player fake blockData?
is it possible to make block look like stone but acctually be for example glass?
i hope so
😢
can some1 help me maek a NON-mc project
in intellij?
iv literly only evr coded plogens LOL
liek its missing stuff, i needs YamlConfiguration
FileConfituration
Hmm
You could use something else Leo
Like a config library
Cuz that is bundled with spigot right
:IIII im usin java cuz im alredy used 2 th-
wait wut
file/yaml configuration is spiget...?
Yes
coulda sworn it was java bruhb
lol
Doesn’t spigot use snakeyaml?
:I cn i use em still if i jus bundle th jar?
Have you looked in to that library?
or will it break if it not a plogen
Or course you could skid the Bukkit config classes
Yeah gizmo it does
I guess you could shade spigot or something
Lol that’s such a disgusting solution
ehh ya ill try taht .-. it aint a rleese projkect or nothin
Yeah
ty gais ❤️
Ye (:
🥴
how tf do i add jar 😳 w/o mavin
What do u use
i just did file>new>project
java tab, clkick next
wait i guess i cn try makin a maven 1
Or gradle (:

maybe.
ehh ill stick 2 mavin lol iv shed blood learnin 2 use taht
Sure
😢
ok it works now but 4 som reson
autocomplet
dosent find it
igottat manual type out th hwole packege name
org.bukkit.configuration.file.FileConfiguration
how do i add an integer to a variable?
so how would i add 5 to a variable called money
wtf
money += 5;
RECURSION
PlayerBucketFillEvent
thank you
wait
ill look at it
but does that only work with buckets?
Cause the item their holding is a clock
ty
@hasty prawn
What are you trying to do
PlayerInteractEvent works up until my final check check
if (!(block.getType() == Material.WATER)) return;
when a player right clicks on water --> do this
i got a little confused on this if (sender instanceof Player){ String rules = getConfig().getStringList("rules"); Player player = (Player) sender; player.sendMessage(rules); why wont it select the entire string list in the config? does anyone know?
@ivory sleet i... i cant run dis project 🤣 thers no maven buioild config
Weird
just loop through the list, and add it to a copy list
lameeeee
and then send that new list as a message
Lifecycle
ok thanks
Probably just need to detect right clicks and then use player.rayTraceBlocks(3, FluidCollisonMode.ALWAYS);
alright ill check this out
any of tehse? o.O
clean then install
Enchanting name btw
fluidcollisionmode.always isnt a thing
ty 🤣
What version of spigot are you using
Idk how to fix since I don’t use maven
grrrrrr maven y u so stupid
jus run th fucken main methed
c++ been runnin main since 1980
wtf bruh
nvm ithink i found it
Exception in thread "main" java.lang.NoClassDefFoundError: org/bukkit/configuration/file/YamlConfiguration at io.github.leocab.ToyTest.<init>(ToyTest.java:8) at io.github.leocab.ToyTest.main(ToyTest.java:12) Caused by: java.lang.ClassNotFoundException: org.bukkit.configuration.file.YamlConfiguration at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 2 more @ivory sleet 👺
f*** dis LOL leme boot up dev-c++
Send ur pom
wa-
pom.xml
🤣 i lit5erly read porn LOL
My bad iPhone just love to autocorrect every thing it can get its hands on
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
o LOLOLOLOLO
is md paste down...? say ssl error 4 me

fack 🤩
public static void refillWateringCan(PlayerInteractEvent event, FarmingOverhaul plugin) {
Player plr = event.getPlayer();
RayTraceResult rayTraceResult = plr.rayTraceBlocks(3, FluidCollisionMode.ALWAYS);
NamespacedKey waterKey = new NamespacedKey(plugin, "waterLeft");
NamespacedKey canKey = new NamespacedKey(plugin, "isWateringCan");
//Check if player is holder watering can
if (rayTraceResult == null) return;
Block block = rayTraceResult.getHitBlock();
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (plr.getInventory().getItemInMainHand() == null) return;
if (plr.getInventory().getItemInMainHand().getType() == Material.AIR) return;
if (!plr.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(canKey, PersistentDataType.BYTE))
return;
if (block == null) return;
if (!(block.getType() == Material.WATER)) return;
//Player is holding watering can, get can data
ItemStack can = plr.getInventory().getItemInMainHand();
ItemMeta canMeta = can.getItemMeta();
PersistentDataContainer canData = canMeta.getPersistentDataContainer();
canData.set(waterKey, PersistentDataType.INTEGER, 10);
canMeta.setLore(CanCreator.getLore(10));
can.setItemMeta(canMeta);
plr.sendMessage(ChatColor.AQUA + "Filled up bucket!");
}
this runs twice
and its not from lifting up the mouse
i tested that
it sends that message at the bottom twice
Where do u call that function?
at the bottom of the thing i sent
🤡 still same error... no yamlconfig class
ya screw dis 🤣 ill jus go c++ atleast i kno how 2 set up a basic ass project wit taht
this doesnt work im kinda confused can someone explain this error? ```for(String rules : getConfig().getStringList("rules:")){
Player p = (Player) sender;
p.sendMessage(rules);
}``` it doesnt send the config stringlist
😳
when he uses a : instead of a .
ohhh
so plr.sendMessage.getStringList() would probably work
you just gotta do .
also pretty sure
if theres nothing on top you can just do rules
with no .
just rules
ok
p.sendMessage.getStringList() is error
oh, then ig i was wrong
just do this then
a
I send it here
Yes
That’s the declaration of it
Not where you call it
/run it
i figure out
if e.getHand() != EquipmentSlot.HAND return;
apparently it runs for your main hand and offhand
Hello i am new to Java and i am trying to code a custom death messages but they are working only for players . How can i code them to work for entities too?
so
uhh
EneityDeathEvent
not PlayerDeathEvent
that should answer all your questions

;-; i didnt relize th conveneince of spigets yaml class till i cant use it
ima give eclips a try
taht snakeyaml shit suxx doe
o mi god bruh LOL
how is dis so fucken hard
some1 know how 2 set th main class in eclipse??
eclipse 😳
What was ur issue?
you didnt compile it right
can u link the message
well
META_INF/MAIFEST.mf
i import spiget jar in2 non-spiget project rite
it compiles n evrythin
but wen it runs it cant find YamlConfiguration class
it jus says classnotfoundexceptien or w/e its called
you tryna make soiet plugin?
but liek, i link it literally th same way i do it wit spiget projects :III in pom.xml
no, jus reguler java projec
System.out.println type shit
then whats wrong in that you just gotta add a manifest for ur main class to be detected
i figurd taht part out in intellij, it does try 2 run th correct main()
but
YamlConfiguration ._. notfound
wat do
import spigot api
make a shaded jar
mave shade plugin
poogle
ull find the build tag for that
use it
then compile
o.? wat
ukeep sayin poogl 🤣
how would i get started on creating kit data for each player? like if i wanted a plugin which saved player choices for weapons and armor, how would I save that data and access it?
http://maven.apache.org/shared/maven-archiver/examples/classpath.html <=== helpful af docs@cloud berry
wait @spiral dome r u talkin bout importin spigot-shaded.jar as a local depedency?? cuz ik how 2 do taht
u fast bisch
wait nvm
its not same link
use the plugin i linked to compile
then use the shaded jar
the page covers execution of the jar too (mby)
bruh 🤣 its alredy executebel
im past taht part
it jus
whats the scope for ur spigot depend?
https://www.baeldung.com/java-jar-manifest <=== also helpful af
dosent find a class ina dependency tahts
a) in pom.xml
b) detected by ide (eg. no errors)
<dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.16.5-R0.1-SNAPSHOT</version> </dependency>
default iguess?
<scope>include</scope>
you having errors when running the jar right?
yaa
it was scope that was missing all along? :l
idk im bout 2 try runn it :IIII
🙏
🙏
aefjnhiaNfklsjnafkljngsklasng
package org.bukkit.configuration.file does not exist
dafuq
itsnot in red in th ide :IIII wtf
ya
exe
is not mc plogen
i jus need yamlconfiguratien 🤣
ok uhh leme try
local depedendcy
what ru trynna make anyways :l
simpl numbr crunchin :IIIII
for wot
jackson api better ngl
tbh i should b usin soem shit liek pythan or lua but 🤣 iaint used eithr of thohse in years LOL
whyd you need the spigot api for number crunching?
imaed a game outta buildin blox 🤣 but im tryna automate th math
cuz it need 2 load/save shit from yml
and
ilook up snakeyaml
n it sux ass
so :I
spiget api got literaly th best yaml api
it would probably be better than shading spigot imo
no 🤣 dat syntax... i h8 it
mattr of fact i h8 apache sites
in generel
but ya liek i jus need iteratien
cant evn iterate
i mean, it's not the best choice imo
it aint a relese projec or anythin 🤣 ijus need it 2 workk so icn start typin numbr crunchin code
https://dzone.com/articles/read-yaml-in-java-with-jackson <=== gud alternative to snakeyaml @cloud berry
;-; dose it hav regular yaml file reading doe? all i c in taht page is classes as yaml
uhh idk actually, i haven't used it much
🤣
dafuq
if im makin mi own file i/o class it gonnan b csv
not fucken yaml tahts hard LOL
might be worth a shot to use json instead of yaml, shit suxx to work wif ngl
if you need a json library i recommend gson (google's one)
i dont see any real benefits in using yaml, json is good
elment1:
papi: 3
elment2:
randemshit: 90
foo: bar
elment3: oi```
^ i wana iterate thru elments without me program knowin wat th elments need 2 b called
eg.
elment1, elment2, elment3
cn i do taht in gson wit th json equivelent file?
you can
gson?
jackson
it parses json so yes
:I it can?
@spiral dome cn u find doc? iv alredy found 2 tutoriels but tehy both deal wit class yamls only
good luck with ur shit leo ima sleep
tysm reda 😍 imneed all i cn get
breh i sent that already :l
and that's not what leos looking for
🤣
NOW TAHT SHIT LOOK FAMILIER
key/value
yap 😄
ill lern gson
;-; i probs ahv 2 maek me own data conversien dont i
-_-
som1 let me ping md
why do you type dysfunctionally
@worldly ingot cn u ping md 4 me mr choco 😳 is supr good idea ipromise
i type like that when i'm on desktop too, shit's easier
maybe if you're a brainlet sure
^ also desksktop 🤣 😳 tahts probs y
don't knock it till you try it
if branelt mean rly cool supr 😎 supr cool water 🚰 water drinkin persen tehn yes we r branaults
sug me nuts
damn ok that was fast
speakinof g 😳 ineed 2 go lern gson icant sugg nut rn
gsonis vey ez
🤡
i cant i find any toutoriels taht arnt about fucken serializatien
for eithr json or yaml
o m fucken g
cn u help me wit it
jerkson
no just do it yourself
it's not hard
i literly cant find th info doe cuz all th tutoriels i keep runnin in 2 r about SERIALIZING
wen wat i need is ITERATING
2 diffrent worlds
👀 jerkson?
ye jaksen
imean unless u cn find iterater in it
cuz icant :I
u kno wat im tired af ijus wanna code
notdeal w/ all dis stupid ide/depedency shit
?
if you can't brain your way through gson just use json-simple
saw that?
nah it ok @spiral dome i gib up ill jus maek spiget project 🤣
it kinda sucks but it's stupid easy
dun giv up :(
okok itry 1 more
:D
;-; i been atdis so long igot 3 diff project open 2 diff ides n idfk which 1 which anymor
guess ill try th maven 1
but 4 th record ithink yamlconfiguration not bein its own api is slap in th face of yaml
@spiral dome aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/Gson```
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
WHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
ur jar is definitely not including the depends
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
how tf i get shade versien
Gson is built with Spigot isn't it?
;-; thers 2 runs
where shade?
neithr made shade jar
wat
Leo, you're just trying to use Gson?
the run maven build
but firdt include shade plugin in ur build
oooo okok so i replace whole plugins sectien?
after wat :I
tysm ❤️
How can I make it so my farmland doesn't go to dirt and stays as dry farmland, so just cancel the transition
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
dont mind the bad indent
couldn't indent on mobile
is ok 🤣 tyty
@spiral dome You know this?
hmm not rlly i can poogle toh
just a sec
I'm googling too
BlockFadeEvent maybe?
Yea, I was looking into that as well
lemme try that, and what about when a player tramples a crop?
PlayerInteractEvent where the action is Physical I think
@spiral dome ok it do work 🤩 🤩 tysm!!! tha tutorial json file is read
:D
is that the only physical interaction?
ifinally got 2 dis point ;-; n i gottat look mor shit up
well
it ok
ill sho u yml code wen done
okay
im jus baffeld thers no YamlConfiguration equivlent outsid spiget api
liek wtf java world
meanwhile me
🤩 Linus Update ™️
im being tortured with kalis server speed
okok
@spiral dome https://pastebin.com/xWt1NkxK <-- actuel file ineed 2 read
how do i eg. iter8 thru top levl items .-.
i haven't used jackson in soo long either so ima have to poogle a bit
how do i make a block immune to silk touch so when u break it with a islk touch pick it still does all the stuff from the breakblockevent but doesnt drop the block
tahts gson 😳
actually ifound it: https://www.tutorialspoint.com/how-to-get-all-the-keys-of-a-json-object-using-gson-in-java
A Gson is a library that can be used to parse Java objects to JSON and vice-versa. It can also be used to convert a JSON string to an equivalent Java object. ...
idek gson
create a copy of the item, remove silk touch, then do Block#getDrops(clonedItem)

ya ill jus go 2 bed 🤣
hoep dis easier 2moro
cuz ill probs regret doin dis as mc plogen evn tho itll get me codin faster
iswear if i ahd started programmin in java iwould not b programmin rn
java always so hard 2 find docs on god dam
n i coem from c++... it should b th othr way around
i find java the easiest
wdym
by create a copy of the item
oh
wait nvm
that seems kinda complicated is there a way to just not drop anything from the event
it th easiest 4 me 2 once i figur out wat i need 2 do... it th figurin part taht seem 2 b harder in java :I
oh
event.setDropItems(false)
o thats easy lmfao
i find that part interesting :p
thx
How could you say that about my homeboy intellij
@cloud berry u gon find this one super helpful http://tutorials.jenkov.com/java-json/index.html
no igotta go in pom... n if im not usin maven tehn im jus f'd 🤣
U can
n evn if i add it in pom i add it rong
dependencies tab
cmon bruh wat centryu r we in
ok wehr.
@waxen plinth tell leo unblock so we can truce
🤩 omfg tytyty
Why'd he block you?

BRUH I BEEN SAYIN TRUCE 🤣
yesplz truce ❤️
Lol
no 🤣 tahts kacparlegen
Korea...
boi what the hell boi
🇺🇸 😎
No way
Is English your first language
Leo gotta be 7
AMERICA F*#K YEAH! MUSIC VIDEO from the move "Team America World Police"
Regular & Bummer Versions !!!!!!
leo cant be in korea
Y
its day time there
he has a korean girl as pfp
🤩 geodoxx'd
5_5
😳 ithink she also 🇺🇸
cap
Redempt asking questions
I do have a question
Nobody's been able to help me with it yet
Probably cause nms
nms 😱 🔫
🤸
🏌️

How do you refresh lighting for a chunk in nms 1.17
they already added
unocoed alredy did doe ;-;
🤰
unicoded**

not on my phone
I have a library in development
And
Which would let you edit blocks fast without fawe
waitso wehr tf did dis versien of it coem from LOL
But it needs to be able to do lighting updates
ithought it wass leak official discor
I can't figure out how to do them for 1.17
i just added it in my server

Pybad
🤩 guys discor ahs ddr
Yes
discor dance revilutien
🤩 MOOSIC
Hey there - general quick question. What's the best way to store data ephemerally within a Java spigot plugin? Basically just looking to store a string or bool, no need for it to stay across restarts.
ephera who LOL
Wat
static
Just temp store data for the length that the server is online for
If you don't need persistence
persistence
Just store it in variables
no stay across restrat... so liek a varieble? 🤣
yea variables is the best way
Oh bother I'm stupid, thanks very new to this :P
🤩 welcom 2 spiget code ❤️ is fun
im so bad at speaking positivity
Not me
Java is going to be the death of me I swear to god
By the time I was born I had already written a parser
ur gods gift
saem :IIIII
ispent th past 3-4hrs trynn figur soemthin out
still not doen
hey
Could someone help me with something?
I just submitted a new rescource and I think it was botted.
It wasn't me that botted it and I have no clue what to do.
It was at 35 downloads, I went out to a store, and now it's at 500.
Why does it matter
how random actually is threadlocalrandom
im making a lucky block plugin and im getting the same thing like 3 times in a row even with 16 possibilities
and is there a way to make a true actual random
It's a seeded pseudorandom number generator
It's random enough for all purposes except security
For which you want SecureRandom
But that's also pseudorandom
Just harder to predict
ok so im just really lucky getting a ton of stuff the same in a row
Most likely yes
As for "true actual random"
Not feasible unless you have a geiger counter and some depleted uranium handy
Then you can program an arduino to make a true random number generator
too ez
does anyone know why this: EntityPlayer npc = new EntityPlayer(server,world,gameProfile,new PlayerInteractManager(world)); doesnt work
What doesn't work about it?
says PlayerInteractManager requires an EntityPlayer and was given EntityWorld
The EntityPlayer constructor doesn't need a PlayerInteractManager
just the server , world, and game profile? but how do i get the npc to interact then?
yeah sure.
Gotta use packets for that.
The server just sends packets
Yeah
You need to send packets for whatever the npc is "doing"
thats what im trying to do though, are you saying you dont need that manager to send packets?
ok
Id like to learn Java and Plugin developent. Are there any useful resources to learn with?
ive been using this guy: https://www.youtube.com/channel/UC_kPUW3XPrCCRT9a4Pnf1Tg
yes, he’s very good
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
how do i remove the ai from this entity?
Entity chicken = p.getWorld().spawnEntity(e.getBlock().getLocation(), EntityType.CHICKEN);
declaration: package: org.bukkit.entity, interface: LivingEntity
Can I use new EntityDamageEvent() to hurt player?、
thx
OK thx
do yall know how to put this chicken http://prntscr.com/1qcyt9w into the center of the block?
Location chickenLoc = chicken.getLocation();
chickenLoc.setX(chickenLoc.getX() - 0.5);
chickenLoc.setZ(chickenLoc.getZ() - 0.5);
adding 0.5
does seem to work
ill tr adding
doesnt work
adding does the same as doing nothing at all
@EventHandler
public void onBlockPlace(BlockPlaceEvent e){
Player p = e.getPlayer();
if(e.getBlockPlaced().getType() == Material.YELLOW_STAINED_GLASS){
p.playNote(e.getBlock().getLocation(), Instrument.PIANO, Note.natural(1, Note.Tone.E));
p.playNote(e.getBlock().getLocation(), Instrument.PIANO, Note.natural(1, Note.Tone.A));
p.playNote(e.getBlock().getLocation(), Instrument.PIANO, Note.natural(1, Note.Tone.C));
Entity chicken = p.getWorld().spawnEntity(e.getBlock().getLocation(), EntityType.CHICKEN);
LivingEntity chickAI = (LivingEntity) chicken;
Location chickenLoc = chicken.getLocation();
chickAI.setAI(false);
chicken.setInvulnerable(true);
}
}
also there is a Location#add method
I can't find this event
you arent even setting the location
LivingEntity chickAI = (LivingEntity) chicken; this is redundant
the location is at e.getBlock()
Chicken chicken = (Chicken) p.getWorld().spawnEntity(e.getBlock().getLocation(), EntityType.CHICKEN); does the trick
yeah but you arent adding the offsets to it
yeah thats without it
when i add the offsets it still does nothing
wait
let me do it with offsets
chickAI.setAI(false);
chicken.setInvulnerable(true);
```?
ill send the code and the result
I only found EntityDamageEvent @hybrid spoke
you wanted to damage the player. there is a METHOD which name is damage in the LivingEntity class
@EventHandler
public void onBlockPlace(BlockPlaceEvent e){
Player p = e.getPlayer();
if(e.getBlockPlaced().getType() == Material.YELLOW_STAINED_GLASS){
p.playNote(e.getBlock().getLocation(), Instrument.PIANO, Note.natural(1, Note.Tone.E));
p.playNote(e.getBlock().getLocation(), Instrument.PIANO, Note.natural(1, Note.Tone.A));
p.playNote(e.getBlock().getLocation(), Instrument.PIANO, Note.natural(1, Note.Tone.C));
Entity chicken = p.getWorld().spawnEntity(e.getBlock().getLocation(), EntityType.CHICKEN);
LivingEntity chickAI = (LivingEntity) chicken;
Location chickenLoc = chicken.getLocation();
chickAI.setAI(false);
chicken.setInvulnerable(true);
chickenLoc.setX(chickenLoc.getX() + 0.5);
chickenLoc.setZ(chickenLoc.getZ() + 0.5);
}
}
totally wrong
whats wrong
What's the meaning of this?
you are getting the location of the chicken which doesnt affect the chicken anymore
why doesnt it affect it anymore? does livingentity cancel that
javadoc. the Player class provides a #damage method because extending LivingEntity
first of all: its totally redundant what you are doing there
Chicken chicken = (Chicken) p.getWorld().spawnEntity(e.getBlock().getLocation().add(0.5, 0, 0.5), EntityType.CHICKEN);
chicken.setAI(false);
chicken.setInvulnerable(true);
that would be the solution.
your current code is completely over the top
and your code wont work since you are getting the chickens current location, resetting the X and Z but never updating it.
instead you could just spawn it right away into the block
and #getLocation is returning a clone of the current location so you just extracted the location out of the entity
ohh thats why it wasnt working
yeah ok fair enough
ig you cant really set the location of nothing
wdym?
cuz if its just the location of the chicken which isnt connected to the chicken anymore
u cant set htat
you can update it by teleporting the chicken f.e.
:(
i wanted to suggest you to recreate that
by doubletiming
make the video 2 mins
easy
ok so now i have an entity inside the block on blockplaceevent, how do i remove() it when the block is destroyed? i think you get the block and get the nearest entity and kill it but idk how to get the nearest entity
I’m so confused
You would store it in a hashmap with the block as the key and chicken as the value
But why would you do what you are doing
wait can hashmaps store a location that corresponds to an entity?
oh i thought they had to correspond to the same data type
ngl idk why i thought that but the hashmap worked nicely, ty
is java same as js?

lol
Whats the best way to go about asyncing something like a teleport? I want to async this because i setblock (Usaing FAWE API) and once thats done i teleport the player there
Becase currently i
TP
SetBlock
and the server dies
You need to find out if there is a Future<T> that is returned by FAWE.
FAWE edits are blocking if you use the WorldEdit examples
You need to call them async
post that elsewhere but not here
NMS, look at how the data command does it
FAWE edits are always blocking. They just block short times over several ticks.
Yeah it splits things over multiple ticks however it won't stop blocking causing the thread to be dead locked
NMS entities have a method save(NBTCompound)
The question is: Does FAWE return a Future<T> you can append on?
alr @hybrid spoke so i have this slime
Slime slime = (Slime) p.getWorld().spawnEntity(e.getBlock().getLocation().add(0.5, 0.25, 0.5), EntityType.SLIME);
is there a way to set its size to 1 before it spawns? cuz its massive for a split second before the thing executes slime.setSize(1);
Not that I'm aware of
how can i make it so & colors work in config messages?
all I do is call things async then run the rest of the code after with a scheduler
Since the edit will block the thread that works perfectly fine
But you dont know how long the first action will take.
and? I just want things to run after it
I dont think i understand what you mean. Do you mean that you use the scheduler to sync on the main thread again?
Yes
Ah ok. Now it makes sense.
-> async call FAWE edit -> back to main thread with scheduler -> code after edit is done
._. Look at the data command
I thought you meant:
Bukkit.getScheduler().runTaskLater(plugin, () ->{
// Some stuff sync later
}, 40);
CompletableFuture.runAsync(() -> {
// Some async stuff
});
Instead you meant:
CompletableFuture.runAsync(() -> {
// Some async stuff
}).thenRun(() -> Bukkit.getScheduler().runTask(plugin, () -> {
// Some sync stuff
}));
Aight
doesnt #thenRun is already synced?
Wait can you call FAWE methods async? Never used their API tbh
No it runs on the common fork join pool thread that was grabbed by the CF before.
I got told to do that when my server crashed after using the API
It's a vanilla command /data
I hope you're not on a dead version now
Is it a tile entity
so i have this in one of my classes
but i wanna add it to another, but its a public void. Is that possable?
because i write it all out and i get a bunch of errors
Uh oh.



oh i now get an error with this line
'BanInvListener(bangui.me.duke.Me.Duke)' in 'bangui.me.duke.Me.listeners.BanInvListener' cannot be applied to '()'
Yes. You defined a constructor that needs an instance of Duke but you pass nothing.
oh so this
Yes. This is your constructor. And you defined it to have one argument which is of type Duke. Now if you want to
create a new instance of your BanInvListener you need to pass all arguments to the constructor.
In your case you just need to pass an instance of Duke.
Hint: You can reference the instance of the class you are currently in with the this keyword.
because this is java
very very good point
Chests are tile entities
no. tile entity
i think its ok to call a tile entity a tile block or block entity
Can I always cast from human entity to player?
No but the otherway around
yes since there should be no other entity what could be a human entity iirc
Usually you can. Unless someone has a very specific NPC implementation that opens Inventories.
right
this is a human entity passed from an event tho
so it will always be a player
Why do you want to save a tile entity yourself anyways?
Why does he need to save a tile entity into a file?
So I had a similar issue https://www.spigotmc.org/threads/bossbar-problems.495229/
The boss bar itself will not cause the music to play, you would have to use the player.playSound(..)
But then what's the point of having that flag in the first place? I'm pretty sure it worked just fine without manually playing a sound in older versions.
what is a good way to do a queue system , im thinking having a list of players and adding the players when they click something , do something etc and remove if they die or leave , and i'd check if the queue length is bigger than (num) and start it when it is , is this a viable way to make a queue system
I mean there’s literally a data structure for it
A plentiful amount of implementations actually
Queue<E>?
Yes that’s the interface
alright i'll look into it , thanks
Idk what you need here but maybe an ArrayDequeue is enough or LinkedList if you want your remove operations to be O(1)

I think you should use a HashSet<UUID> for that. But in a small scale really any data structure would be viable here.
willing to gift steam games for a modded version of optifine 1.8.9 with toggle sprint included
dm if interested
is this request allowed here?
no
oh mb
https://paste.md-5.net/bubulajuga.m
i have somethibg like this, and i need to deserialise it
what is the best way to get the entire file as potentially a string ? the b64 hash is often over several lines so there is no garuntee that it is gonna be one line per object
a Base64 encoded object is alwasy a single line
Thats a json array not just base64
yeah but it can be a list of then - depends on the contents of what you serialise
Yoiu are serializing individual ItemStacks
yea?
Usually you would use base64 to turn a bunch of data into a single string
oh right hm ok
so each ItemStack will be in its own string
atm yes
so i should be passing several itemstacks into that method rather than just one?
👍
Hello, I'm trying to update the text on a sign in 1.17. Has anyone any idea why it does not work?
for(int i = 0; i < s.length; i++) {
sign.setLine(i, s[i]);
}
sign.update();
```s is a String[] with 4 elements

