#help-development
1 messages · Page 1793 of 1
this is not #give-me-free-java-course-please
i have offered you help
should I put the dependency-reduced-pom in my .gitignore?
#im-not-asking-for-java-course lol
you literally said this
that doesn't mean that is the only way that i've to learn
think so, just uploading the pom.xml should be fine
whatever
anyways for(Object name : objects) that's how a foreach works
You will not have a clue what this does, but study it and learnjava player.getInventory().forEach(itemStack -> { if (itemStack.getItemMeta() instanceof Damageable meta) { meta.setDamage(0); itemStack.setItemMeta((ItemMeta) meta); } });
imagine he's not running java 16
do we really have to beat you down in order for you to understand...
guaranteed
Stop pinging
dude can we make people take a java test before being able to chat here
#help-development is how i push all my anger out after getting tilted for playing comp in valorant 😂
please don't, this discord would be useless 😭
i like how people talks with new people that is learning java, i have to see how they started, that will make me laugh
i didn't start learning java coding plugins
same
^
i started learning java like you are meant to learn java
you didn't born with 100% java knowledge
one of my first projects was tic tac toe
thats why we're telling you to learn it first
it was a public static mess but it worked
you probably was stuck like me with some other things that doesn't have to be a plugin when you're new
yes, and i googled them
but, im telling you man. with how shitty bukkit api is. and your current knowledge of Java. just
tbf if we had to elaborate the internal jvm string cache to you, that would be acceptable xD for-each loops aren't
dont
and they were that basic that it took me 2 minutes to find them on stackoverflow
on an unrelated note, ive been watching uncle bob
i have been searching for fixall command like 30min
hes a legend
i didn't search for how to make tictactoe
Just fix it !!!11
only place you'll get will be on people's nerves
wtf? i search all my doubts and if i don't found anything then i come here?
I gave you the code you need, but if you'd rather argue with people
There is also just https://www.spigotmc.org/threads/repair-items.400391/
Im not just doing this:
i have a doubt, lets ask then and c&p
i always search first
and if not then ask
that's all
guys just dont... hes like the average 18 year old shared server provider who doesnt want to learn java cause its too slow...
Also most of your questions can simply be answered by using javadocs
?jd
shared?
Yeah pulse we should have an uncle bob command
shared?
Mhm
Did you order any of his books?
Aha
I think a lot of is just to think conservative programming
How about comments then 
Political programming?
🥲
Lol
"A comment is a failure to express yourself in code. If you fail, then write a comment; but try not to fail."
thats what he said in a twitter post
its pretty good
Yuh it’s the gist of it
and also who has the time even to write comments the first place
Tho I guess javadocs can be excused sometimes when we don’t want to dive into implementation of apis 
Yeah
Hehe, Ponclure
Oh I think we wrote comments on the among us thing back then?
Wait really XD
Idr tbf lol
Tho likely
and i didnt know any design patterns
lol
lol
I remember the all the static
Yeah
😅
Oh lmao
My college was really specific about comments for java
They wanted a comment for each field
tf
// The heck do you think it is?
private int xPosition;
Why static
Why not 
You right
static abuse good
What am I doing wrong using GridPane https://imgur.com/Jidq9Ci
burger is 0,3 and fries is 1,3
spacing
also how is that spigot help
I have this neat little runnable that'll spawn a wave of falling blocks, but the blocks they originate from turn into air for the client
ghost blocks so to speak, any idea how i can prevent that / make them re-appear for the client
if its a client side render issue use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#sendBlockChange(org.bukkit.Location,org.bukkit.block.data.BlockData)
This is what happens
https://gyazo.com/e87be2729b347c31a8be5ff5140d26bd
doesn't need to be spigot help
Okay but real shit, how do I prevent a falling block from turning the block it falls into to air
how can i extend a class to add my own features, and then make an instance of that class into an instance of my own class?
(cant change that superclass)
i just get a ClassCastException
when trying to cast it to my subclass
its possible with a wrapper class, but then i'd need to re-make every method and direct them to the method on the super object
That's my try using a wrapper class
public class Canvas {
CraftMapCanvas craftMapCanvas;
public Canvas(CraftMapCanvas craftMapCanvas) {
this.craftMapCanvas = craftMapCanvas;
}
public void drawRect(int x, int y, int width, int height, byte color) {
for(int i = x; i < x + (width-1); i++) {
for (int j = y; j < y + (height-1); j++) {
craftMapCanvas.setPixel(x, y, color);
}
}
}
public void drawText(int x, int y, MapFont font, String text) {
craftMapCanvas.drawText(x, y, font, text);
}
// ^ Would need to do this for all other methods, which is a lot of work
}
Or you can just expose the super object and call methods on it directly
how
Except the ones you want to change
how can i do that
oh
i see
no way to connect myPlayerWrapperInstace.sendMessage() directly to the internal Player Instance?
You could
But if you don’t need to change anything, don’t bother
Otherwise you’ll just have a ton of 1 line methods calling this.wrappedPlayer.XYZ
making it exposed is just kinda un-intuitive to use imo
but if thats the only solution
well yeah, but i meant connecting it automatically
without redoing all methods
xD
You might be able to do it with your IDE
i use IntelliJ
Eclipse has an option to overwrite/inherit methods
I’m sure IntelliJ does too, somewhere
alright xD
I can't use extends to achieve my goal, can i?
extends would allow me to easily add some methods and stuff. but then theres the problem that bukkit gives me an instance of the extended class / superclass, so i cant downcast it. or can i somehow?
Generate -> Delegate Methods. Found it
ill just use this wrapper than, ty
i need a regex to validate the following:
test-1.0.0.jar
test1.0.0.jar
test.jar
test1.0.jar
basically i want only the test
^([A-Za-z]+)\.[Jj][Aa][Rr]$
I'm using an InvetoryDragEvent, is there anyway that I can get the clicked inventory?
nothing
?
oh i thought you meant just validate that its abc.jar
what do you want exactly
i just want to ignore the version in the file name
if it is there
test-1.0.0.jar -> test
just rename it
or i think you can use maven config
or something
to make it always produce the name
or you want to check?
.JaR
Also there is a case insensitive flag for regex
.jar
.Jar
.jAr
.jaR
.JAr
.jAR
.JaR
.JAR
.jAR
Hello
I need help to find the version someone is joining my server with
such as: "Fabric 1.17.1"
or whatever their client says
I already have an on join event setup
I just can't find anything to do after that
If you really want to do it yourself you need to read the incoming packets
The version I believe is just part of normal connection packets
Forge fires a specific packet you can use to detect it
Not sure if fabric does
i wanna have a drawPolygon function which you can pass vertices: public void drawPolygon(int x1, int y1, int x2, int y2, (int, int)... rest).
Is there a way to have optional parameters (so you can pass infinitely many vertices), but always force two (x and y) at once?
So when using that function you can either call drawPolygon(x1, y1, x2, y2) , or drawPolygon(x1, y1, x2, y2, x3, y3), but not drawPolygon(x1, y1, x2, y2, x3)
(I know i could use a Pair<Integer, Integer> or SimpleEntry<Integer, Integer>, but i dont really like having to make objects for simply passing numbers)
You can overload the method with all the different options
what does that mean
u mean create
drawPolygon(int x1, int y1, int x2, int y2)
drawPolygon(int x1, int y1, int x2, int y2, int x3, int y3)
drawPolygon(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
etc ?
Yes
but then i cant have infinitely many
alright :/
or just throw an error if args.length%2 == 1
xD
but thats at runtime sadly
You could also do that
or is it
can do varargs and do the length check
Yes it’s runtime
does the compiler know/warn its gonna throw an error?
No
just dont do user error 🙂
programmers are the users in my case
so then usererror is alright, right?
its an api
Spigot has a lot of stuff like that
For example, if you try to use .distance between 2 locations in different worlds you will get a runtime exception
ok, so i tried using Pairs, and i get the following warning: Possible heap pollution from parameterized vararg type
What does it mean?
Googling didnt really make it any clearer
Set<Pair<Integer, Integer>> getPolygonPoints(Pair<Integer, Integer> ... vertices) { ... }
well idk if its save
how can i fix it
i saw that post before, but didnt really help me fix the problem
is it unfixable?
just add @SafeVarargs and hope for the best?
and that will fix it?
Yes
Confused for title component? (custom inventory btw).
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
'TextComponent(java.lang.String)' is not public in 'java.awt.TextComponent'. Cannot be accessed from outside package D:
that's not spigot
Wrong import
I was wondering, with NMS, if you are trying to develop against mojang mappings, how can i check, for ex, what the name of the class EntityInsentient, is in the mojang mappings?
https://nms.screamingsandals.org/ <-- this is a pretty good website, however it only shows your the remapped things and not the original spigot mappings, so if I try to search EntityInsentient, nothing shows up
You can view all mappings in the bt work folder
Or just figure it out based in context
context is my preferred way
ye usually thats how i would do it
but it took me more than 30 mins to find that EntityInsentient was just Mob LOL
- using context is ridiculously hard when you are dealing with this such as pathfinders
packets are understandable
woulda took a couple seconds if you just started from an actual mob and went down the chain
ctrl+click from intellij is op
nah nah thats not the problem
Cuz basically what happened was i needed a private field of type EntityInsentient but obv needed that in mojang mappings
i dont see how that would've been useful, would've had nothing to off on anyway
That's how I made my simulator so it should be fine for anything else
when I was converting I just setup a 2nd project with spigot mappings
yeah tbh thats what I did in the end
go down the extend chain
extend off what tho? If i knew EntityInsentient was talking abt a mob, i easily would've gone to the zombie class or smt and see what it inherited
Here i had no clue what EntityInsentient actually was, therefore didn't know what it was linked to
just go off the same mob
like cow
you'll see the different class names if you do the 2 project setup very quickly
yeah thats what I did in the end
Like for ex, now with pathfinders I have a completely different issue, trying to find what the mojang mapping equivalent of EntityLiving.h(EntityInsentient) and the h() name is from a yt vid like 2 years ago so method names prolly changed as well
but I get what you mean and stuff
Just really wished that https://nms.screamingsandals.org/ would let you search for spigot names as well
hey there
I need help
Why i can't get the compile spigot?
The BuildTools.bat said Unable to access jarfile Buildtools.jar
The BuildTools jar needs to be in the same folder
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()){
if (player.getLocation().getY() >= 50){
cold++;
if (!playerHeigh.containsKey(player)){
playerHeigh.put(player.getUniqueId(), player);
player.sendMessage("You are getting cold!");
}
} else if (player.getLocation().getY() <= 49){
if (playerHeigh.containsKey(player)){
playerHeigh.remove(player.getUniqueId(), player);
}
}
}
}
};```
```java
if (player.getLocation().getY() >= 50){
if (playerHeigh.containsKey(player)) {
player.sendMessage(warningMessageUp);
task0 = scheduler.scheduleSyncRepeatingTask(plugin, () -> {
cold++;
}, 0, 20);
} else {
playerHeigh.put(player.getUniqueId(), player);
}
} else if (player.getLocation().getY() <= 49){
if (playerHeigh.containsKey(player)){
playerHeigh.remove(player.getUniqueId(), player);
if (scheduler.isCurrentlyRunning(task0)){
scheduler.cancelTask(task0);
}
}
}```
Hey! which is the best way for doing this?
First seems fine
so the first way should be better?
how come org.apache.commons.io was moved back into the location it was in for version 1.13
I think that is what happened from testing, it just seems like the class I used for 1.8-1.13 builds works for 1.18, and the other class only works for 1.14-1.17 (different classes for different import locations)
How do you get click events for this panel?
It doesnt print anything not even null or -999 like when you click on the outside of the inv (InventoryClickEvent)
take a look at this, might be what you're looking for
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/Merchant.html
You see i did see that class
However, i wanted to use this class:
declaration: package: org.bukkit.inventory, interface: MerchantInventory
However the click events only give Merchent inventories when villager GUI's get clicked...
my bad i meant clicked
wait where comes click event from again?
Essentially InventoryClickEvent doesnt give a MerchantInventory
If i could get a MerchantInventory, it has a selected recipe method
However i feel MerchantInventory would be something you would need to make yourself?
And then you would have to handle esentially the whole trading system yourself?
aren't you already casting that to MerchantInventory? Why is that an issue then?
Because Merchant != MerchantInventory
the most bottom broadcast doesnt get fired
well of course
were both stupid
you cast the inventory to a merchant inventory
but you check if its a merchant inventory before you do
does it give an error when removing that if line?
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()){
if (player.getLocation().getY() >= 50){
if (!(cold >= 100)){
cold++;
}
if (!playerHeigh.containsKey(player)){
player.sendMessage("You are getting cold!");
playerHeigh.put(player.getUniqueId(), player);
}
} else if (player.getLocation().getY() <= 49){
if (cold >= 1){
cold--;
}
if (playerHeigh.containsKey(player)){
playerHeigh.remove(player.getUniqueId(), player);
}
}
}
}
}.runTaskTimer(ClimaticEffects.getInstance(), 0, 20);```
Hello! i have this code^^
but for some reason the value is increasing like very fast and the messages keep sending, what do i have bad?
If its not a instance of something, you cant cast so yes it will error
20 = 1 second
yes
but
it sends like 30 messages in a second
i can send you video if you want
does it keep getting faster and faster
until your server crashes
omg discord come on
It basically just keeps printing "You are getting cold!"?
but sends many messages in a second
yep
and increasing very fast the cold value
@noble lantern https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/InventoryView.html#getTitle()
check if its the correct inventory then return if it isnt. InventoryView should be part of the event
and with what you were doing earlier, event.getInventory() there should be no errors
do you know how to solve it burchard?
wait
event.getClickedInventory()
i think event.getInventory() returns player inventory
oops
the value reaches 100 in 1 second xD
Im actually gonna use getView()getTopInventory() rn and see if that does something
Its the way your calling the runnable
Your probably creating a bunch of those runnables
oh
makes sense
@noble lantern if (playerHeigh.containsKey(player)) {
if (player.getLocation().getY() >= 50)
}
maybe like that should be done?
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()){
if (!playerHeigh.containsKey(player)) {
if (player.getLocation().getY() >= 50){
playerHeigh.put(player.getUniqueId(), player);
}
}```
like that
im talking about outside of the runnable
Or your creating more runnables inside the runnable
If it continuinly gets faster, that means more runnables keep getting registered
yes, i understand that
However if its the same rate, then its just the rate of the runnable
So you need to find where you calling the method that registers that runnable
but here, i'm using a hashmap
to place the user
and if the user is not in the hashmap it just create one
@EventHandler
public void coldAndHeatSetter(PlayerMoveEvent e) {
^^
your calling a runnable in that?!?!?!
Am I missing something?
public void onBlockPhysics(BlockPhysicsEvent event) {
Block b = event.getBlock();
if (b.getType() == Material.REDSTONE_TORCH || event.getSourceBlock().getType() == Material.REDSTONE_TORCH ||
event.getChangedType() == Material.REDSTONE_TORCH) {
Bukkit.broadcastMessage("Cancelled redstone torch!");
event.setCancelled(true);
}
}```
Only if I cancel air (Where all 3 block/materials are air) will this physics update be cancelled.
do not even use that event lmao xD
Just call the runnable once in onEnable
and check player positions every x ticks
i just realized
PlayerMoveEvent calls so many times, and when you have lots of players it becomes pretty rough
and it would explain stuff getting faster
yes, ty
Uhm yes
I dont see event.setCancelled(true); ?
unless im an idiot and blind
Whoops
xD
Just cancelled it and same result 😛
It's basically an extract of code in a larger plugin
Hmm
Ive never done block physics like that before
However maybe you need to cancel physics directly on the Block?
burchard, now it works, but keep sending the message instead of just 1 time
How exactly does that work..
You can see I'm cancelling it everytime there's a redstone torch involved in the physics
if (!playerHeigh.containsKey(player)){
player.sendMessage("You are getting cold!");
playerHeigh.put(player.getUniqueId(), player);
}```
and i don't understand why this doesn't work
ngl suprised you dont get an error for this
Unless your Key is an Object?
sec
is the player
So your key is a Player, however your puting a UUID as the key?
So,
you should be checking
Map<UUID, Player> playerHeigh = new HashMap<>();```
for the UUID, not the Player
Because your just directly checking the Player object
Not the Player's UUID
if (!playerHeigh.containsKey(player.getUniqueId())) {}
oh
However, what is the purpose of this HashMap?
IMO it seems kind of redundant if you just want to see if player are above 50
Instead keep a list of UUID's
HashMap of UUID, Player will use up more memory in the long run
List of UUID's though is very lightweight and serves the same purpose
and you can just get Player from Bukkit#getPlayer(UUID)
Wait dont go Bukkit.getPlayer(UUID)
Bukkit.getOnlinePlayers()
If you do the List way, use Bukkit.getOnlinePlayers() and then check UUID
hi, weird question, anyone know how i can make the water not flow outside the worldborder but also still flow normally inside? whenever i check if its outside and cancel the event it does that since the closest path for it to flow is only outside the border https://gyazo.com/7f508bf92004c858c8e57091f4a6eee0
I forgot getPlayer sends a request to Mojang
but getOnlinePlayers is just players online on your server, and also prevents the error of sending messages to an offline player
getOfflinePlayer*
Ah so getPlayer(UUID) is just an internal check?
Not sure if there's a proper way to do it, but an easy fix could be to set the blocks outside the border, to barrier
Yes
So if you cancel it, then set the block it tried to barrier
ye tried that already, but it doesnt do it first time
Do you know how to get a MerchantInventory?
InventoryClickEvent returns Merchant only
Also I'm unsure if the uuid version of get offline player does a request might just be string one
I think your right, i know somewhere one of those methods did a request to mojang, and when i did skulls i learned the hard way to bring a server to its knees
I don't understand what you mean by that unfortunately.
That seems odd you could grab the players open inventory and cast it
I tried this
Im trying something now where i get the Villager entity itself, and then get its ivnentory that way sec
how it looks vs how it should look
Did you forget an ! Before that instance of check
omg
your right lmfao
Ow it was that
Cause i was jsut trying right now, and it said i couldnt cast to Merchant when it was a MerchantInventory im like wtf
Don't have a solution, but a suggestion would be to try re-call physics?
Another could be to set the blocks outside the border to barrier before it even tries to flow.
Such as on barrier shrink, or on bucket place, or w/e scenario you're trying.
Well it's not returning a Merchant it's returning an inventory with the merchant type i.e. Merchant Inventory
Well thing it that was confusing me
When i used event.getInventory.getType
it printed Merchant
And my instanceof check typo made me think it wasnt MerchantInventory
Quick tip when you try to troubleshoot inside of printing getType print getClass
This way you know exactly what it is
Hmm lemme try that right now
Okay so
what? in the for loop i'm using Bukkit.getOnlinePlayers()
When i logged getInventory it logged the same thing
and the class name made it seem really weird and not like it was MerchantInventory because it was InventoryMerchant by NMS
Ignore anything i said about getPlayer()
Just use List of UUID and then loop through it using getPlayer(UUID)
getOfflinePlayer(String) was the method i was getting confused with so ignore me for that sorry
Also doesnt a plugin do this by default?
Maybe you can look into theyre source code and see how they do it?
k np
Since you appear to be using Paper API I suggest you try paperweight. This way you can access NMS and other classes and see what they do
Never heard of PaperWeight tbf
In this case you could check and see that the CraftInventoryMerchant is the implementation of the Merchant inventory interface
In what cases for clicking inventory would inventory even be Merchant anyways?
Would the Merchant inventory be what the Villager is holding? Like when they pickup food?
Nvm
I'm actually not sure
This is why having access to NMS can be useful you can check how things work
ill definatly take a look into PaperWeight, i assume its just Spigot equivilent of BuildTools huh?
is there any way to access block ids in modern versions of minecraft
java.lang.NoClassDefFoundError: org/apache/commons/io/FilenameUtils
at com.splyfof.splymain.SplyMain.onEnable(SplyMain.java:47) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[server.jar:3277-Spigot-3892929-2071671]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[server.jar:3277-Spigot-3892929-2071671]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[server.jar:3277-Spigot-3892929-2071671]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:520) ~[server.jar:3277-Spigot-3892929-2071671]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:434) ~[server.jar:3277-Spigot-3892929-2071671]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:619) ~[server.jar:3277-Spigot-3892929-2071671]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:266) ~[server.jar:3277-Spigot-3892929-2071671]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[server.jar:3277-Spigot-3892929-2071671]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[server.jar:3277-Spigot-3892929-2071671]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FilenameUtils
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:147) ~[server.jar:3277-Spigot-3892929-2071671]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:99) ~[server.jar:3277-Spigot-3892929-2071671]
at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
... 11 more```
hmm can anyone see the problem here
You're missing dependency: org.apache.commons.io.FilenameUtils
shouldnt that be installing it?
ahh then i get this tho
then i get this tho
Its basically saying that is provided in another dependency
Try removing it from maven pom file
and using it
Maybe Spigot already includes it?
if it has both commons and io commons
so i doubt it
And does it still compile with this?
so no
It should still compile with that
Omg discord lag again come on man
I wish discord would fix this bs
anyone?
it says that the commons io does not exist
@Deprecated
public int getId() {
Validate.isTrue(this.legacy, "Cannot get ID of Modern Material");
return this.id;
}
Material.STONE.getId() wouldnt work
since it has guard check
for what usecase?
similar question was asked a while ago, i think your only option is making your own util class
wait so a post-flattening packet requires a pre-flattened id?
OptBlockID (VarInt) 0 for absent (implies air); otherwise, a block state ID as per the global palette
shall i try with full stack trace or whatever that is
Honestly im not sure because the first error your sent it should still compile
It just takes the newest version and uses that during compile time
i think im cursed lol
everything i get a tech problem stuff noone knows how to solve it lol
Im kinda spoiled with maven ive never had any groundbreaking issues so i dont know how to fix much with it xD
So im trying to get all of a specific material from a Players into a List and i want to know the more efficient TPS Safe way to do this:
Should i: Inventory#forEach((material)) and then add to List if material is true
Or use: Inventory#all(Material) and then go through the hashmap specifically grabbing the ItemStack that way? Does using Inventory#all do the same thing as basically the first thing i said under the hood:
I agree it is nice
i like to randomly use gradle at times though
wait wtf the all() method doesnt even return a proper item stack weird
why is it that when I click the block on the ground, the message does not output, and when I click on the air or on the ground where I can install the block, it does not output?
if (e.getHand() == EquipmentSlot.HAND) {
if (itemInHand.isSimilar(it)) {
e.getPlayer().sendMessage("HAND");
}
}
does not output a message after this condition:
if (itemInHand.isSimilar(it)) {
What are you ultimatly trying to achieve?
Let me send a video?
No its fine, im just curious as to what your trying to do? Are you trying to make something happen if someone is holding a specific item in hand?
I have a problem, i try to make an NPC Spawn Command, but then i get this error
NPC -> npc
probably npc is an abstract class
Okay
Its free, it has a well made API kinda, and the devs will always add things if you have a legitimate use case for it
But, is there anyway to fix that problem? XD
Yea
Do I need to create different class for that NPC? So the command and the NPC are not in the same class?
well idek what your trying to do because the code is covered by an error panel, it looks like your trying to reskin a spawned npc but idk
and its weird
Why your accessing it statically unless it needs to be done that, which i doubt it, it looks like you need to call that o nthe actual npc object
opa
Maybe it's in registry or smth?
manya
zaebal
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack it = ItemManager.bottle(Material.STONE, Config.bottleOneName(p), Config.bottleOneLore(p));
ItemStack itemInHand = p.getInventory().getItemInMainHand();
ItemStack itemInOffHand = e.getPlayer().getInventory().getItemInOffHand();
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
e.setCancelled(true);
if (e.getHand() == EquipmentSlot.HAND) {
if (itemInHand.isSimilar(it)) {
e.getPlayer().sendMessage("HAND");
}
}
if (e.getHand() == EquipmentSlot.OFF_HAND) {
if (itemInOffHand.isSimilar(it)) {
if (itemInHand.isSimilar(it))
return;
e.getPlayer().sendMessage("OFF_HAND");
}
}
}
}
}
ne rabotiet s blokami((
oh god the pyramid of doom
Menya zaebival, teper manya, nu dalbaeb realna
packets are fun
Top 10 anime villans of all time:
(
lambdas feel so useless
now put a sheep in front of it 😇
ya tebe kyni ne budu delat
you can fix this By mentioning it like that ClassName.this.json
oh shoot smart
wait really
oh i feel stupid now
ngl i hate using for is looks so ugly ik theres no different in forEach and for
but forEach looks nicer
i like lambdas more
Yeah i typically use for when anything im doing edits a List or HashMap etc
also there's filter method iirc
yea
But Lambdas for things like notifying or whatever doesnt let me use for
Never dabbled to much in filters
i probably should
been doing this years now LMAO, and never really touched them too much
https://pastebin.com/MUZtk3Ep This is my code. But i get the same error
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.
you can't construct NPC
What i need to do?
yeah was just about to try that and it gave me those errors
i wonder if endermen can hold items, not just blocks too
Why not just use Citizens2?
they probably can
IIRC they can
but they'll appear in the center i suppose?
There was a rather hacky plugin a few years back that just offset the item in between the endermans hands
That was way long ago
now i get it why minecraft has namespaced key registry since 1.13
it would be cancer to sort the block types by IDS for developers
namespaced keys are godsends
well in the end they all end up as numeric ID's in packets
Anything to deal with PersistantDataContainer is just godsend
its just that developers don't need them to handle
Ofc course but would you rather do all that by without those wrappers? That would be so much torture
i'd rather directly use nbt
yea lol
something that never made sense is that different items have the same id
pain for everyone
especially with modpacks
like dyes
i'm pretty sure ids were starting to be deprecated when i started playing mc
around 1.8
too bad that they removed Auto update feature
it would've made community shift more quickly
to newer versions of minecraft
i'm 16 and i was not allowed to play games sooo i kinda started at 9/10
1.13 👍
1.13's also a godsend for datapack developers
i used to be one
and i'm glad i'm not anymore
Minecraft was so at my veins at that time that i've stolen money off my parents (I was a dumb kid) just to buy premium minecraft account
meet the belt
Where can i download the Citizens API?
i've never requested much from my parents so they didn't really mind buying me mc when i asked
Or i need to download the plugin and import that as a jar?
There is a maven import for it
sec
ill give you it im using it rn
okay
btw can you make npcs pathfind with citizens
<repositories>
<!-- Citizens2 API -->
<repository>
<id>everything</id>
<url>http://repo.citizensnpcs.co/</url>
</repository>
</repositories>
<dependencies>
<!-- Citizens2 dependency -->
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizensapi</artifactId>
<version>2.0.28-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Thats the most recent version
or can you implement your own code to make them pathfind
^
Ngl Minecraft is like a drug, it never gets old
The only thing i hate about the citizens api is
mc never gets old because i always have something to do
that... the getting of npc's during startup is weird asf
I typically spend 6 months out of the year addicted to minecraft, the other 6 goes to rust
now i'm developing, 6 mo ago i was playing modded with some friends of mine
even earlier i play on a random server i've found
Rock man vs Speared naked man
and the cycle continues
rock man wins 9/10 times
really sucks to play
My AK spray has prolly gotten so dogwater
I've had classmate that i've played rust with sadly, he moved out to the other location
big sad :c
so we don't hangout anymore
I havent played rust in this long dang
i really don't play many games else than minecraft
sometimes i play factorio
or dyson sphere program
I play lots of Ark and Rust, more than i should admit
damn what am i doing with my life
ugh im making custom damage and enchants system and i can't count the number of issues i've had
NaN health, random 1500 damage
OOF
Use an existing library or plugin for enchants
now i still get random 100/200 damage spikes
I should add the ability to make custom enchants to my API
im kinda stumped on what to add next for it
i already have a pretty solid custom enchant structure
mmmmmmm
I do have a damage system though if you wanna look into it but
its burried inside 3k lines of code
lol
what i do is setting the damage to what i want the final damage to be and then there's a final entitydamagevent with highest priority
that sets the final damage to the damage
I learned a lot more advanced java stuff i need to add to it to make it more readable
Like i had methods in there to update an objects values inside a hashmap after i edit it via a method ontha tobject...
idek remember how idid mine
setting the final damage how i do it is probably what causes issues
it's pretty sketchy
yeah i remove the damage
and handle it myself
this way though doesnt support other plugins
i need to set priority to highest
custom mining?
If it was yes, i used to be a dev on there, if not then no
hm not sure
Owner is lowkey a D word if its BrokeSkies
Oh its still running?
basically to have more control over the mining speed
or what tools can mine what
also block breaking states remain even if you stop mining
let's say i want a stone pickaxe to break emeralds in 12 ticks
i can
Sounds like assloads of NMS ngl
yeah few packets
i listen for player dig and play block break animations
not that bad tho
the worst will be armorstand animations
all packets
for performance reasons
Ngl though you can have a pretty popular plugin if you take one of those features and make it standalong
If you made a standalone for making the block breaking status staying after mining people would love that
cause iirc only a mod can do that
yea but in that case i would have to try to replicate vanilla mining
i don't think i can get somehow else what stage was a block in when a player stopped mining
Hello! how can i solve they both have the same value? (look scoreboard)
I tried when they joined putting them in a hashmap but i think i have to specify something else, could anyone help me?
Map<UUID, Double> playerHeat = new HashMap<>();
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (!playerHeat.containsKey(player.getUniqueId())) {
playerHeat.put(player.getUniqueId(), 0.0);
}
}```
wdym?
I would assume all you would have to do is either set mining state on a block, if possible ofc, or play a fake mining animation on the block and set its speed anim speed to 0
it's because you're putting the same value?
put will overwrite old values anyways
uhu
However, it does remove the if check i forgot about that part
Map<UUID, Double> playerHeat = new HashMap<>();
Map<UUID, Double> playerCold = new HashMap<>();
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (!playerHeat.containsKey(player.getUniqueId())) {
playerHeat.put(player.getUniqueId(), PlayerHeight.heat);
} else if (!playerCold.containsKey(player.getUniqueId())){
playerCold.put(player.getUniqueId(), PlayerHeight.cold);
}
}```
something like this you mean?
nope, doesn't work
instead of java if (!playerHeat.containsKey(player.getUniqueId())) { playerHeat.put(player.getUniqueId(), PlayerHeight.heat); }
use
playerHeat.putIfAbsent(player.getUniqueId(), PlayerHeight.heat);```
but i need the if
putIfAbsent checks if the key doesnt exist so you dont need the if anymore
Damn yall im banned from maven 😢
but, still doesn't work
yes but what are you trying to change from the scoreboard?
``
make it non static
Oh wait
xd
are two different maps
but still the same problem
huh did the barrier particle change for the 1.18 snapshot api again?
I'm now getting block markers requiring data
i thought of saving the mining state every time a packet is sent
in a map Location, Integer
but then when a player starts mining the block again, i'd have to make so each time a mining packet is sent, it gets modified to the last saved state +1
and when the state is 10, break the block and spawn the item
and delete the mining stat
Yall i wanna apologize
I was gonna rant on you all for why maven is so retarded when importing local jar files
Btw you should try and separate the concerns of your classes. A listeners task is not the management of data. Rather build a structure like this:
https://gist.github.com/Flo0/6ea76adfc21961fca0957d31834ffc03
Just manually install them in your local maven repo. Pretty straight forward
Like i was typing up a storm on why maven is bs for importing jar files lmfao
HEy guys I developed an Rank plugin which works with permissions https://www.spigotmc.org/resources/oranks-1-17-x.96208/
Everything is working BUT if I reload the server, everyone which is on the server will loose his rank because LuckPerms is loading AFTER Oranks
Is there anything I can do so that my plugin loads AFTER any permission plugin?
Thats what i did but when adding the dependency to my file i messe dup the groupId
And i thought it was maven being stupid
F
btw burchard were you the guy looking for people to dev a server on MH? did you start working on anything?
i used net instead of com and i was confused for well over 15 mins
lol
Yes i was an i am actually working on a lot rn
dms?
sure
how can I check if the player exp level is minor 15?
yes, but there isn't a method that returns the exact level
why do you even allow reload in the first place?
it is horrible
ngl
dont just tell people not to reload it
Yo you helped me a while ago with this Pathfinder thing, maybe you remember. I got a issue with it now. Do you have time right now to look at it?
Is there something like a permissionchangeevent? @quaint mantle
Pathfinding... You mean the A* implementation?
yes
What do you mean by "exact level". Do you want a floating point like 13.15337?
Sure lets give it a try
okay give me a minute
Do you want the amount of experience since last/till next level? Do you just want the current level?
So the problem is that it not really comes from the nearest water block anymore its looks a little bit weird (you can see it in the video). And the second thing is that it, only if I stand really close to a block between me and the water source, it goes through the block(you can see it in the video aswell).
code:
https://gist.github.com/ItzJustNico/e112e193527f61937f95a659d5bb1721
Ok lets see if i can remember what i fabricated there...
Maybe don't set the block if the block isn't AIR?
yeah but then the whole path is wrong cause it shouldnt be going through blocks
Anyone got a clue why there's ghost block being created where the falling sand dissapears?
public void run() {
for (Location loc : getCircle(l, rad, (rad * ((int) (Math.PI * 2))))) {
FallingBlock fb = loc.getWorld().spawnFallingBlock(loc.add(0, 0.1, 0), loc.getBlock().getType(), loc.getBlock().getData());
fb.setDropItem(false);
fb.setVelocity(new Vector(0, .4, 0));
}
rad++;
rad = (((rad % 20) == 0) ? 1 : rad);
}```
hmm
@EventHandler
public void onFallingSand(EntityChangeBlockEvent e) {
if (e.getEntity().getType() == EntityType.FALLING_BLOCK) {
e.setCancelled(true);
}
}```
The blocks are still there, just not for the client
i have done something like this before
it’s an old project so it’s a one class wonder https://github.com/olijeffers0n/RealPhysics/blob/main/src/main/java/com/jeff/realphysics/RealPhysics.java#L168
here's me showing that it is in fact just ghost blocks
It's got something to do with the block being deleted, when the falling entity dies it just sets the block to air or something
you could always try setting the block to air as well as cancelling the event
idk if that would work tho
especially for your usecase
well I don't really want it to affect the area, just the cosmetic wave effect
Ok first some optimization on your WaterManager class:
public class WaterAbilityManager {
public static Block getNearestWater(final Player player) {
final Block center = player.getLocation().getBlock();
// Optionals can be used like this.
// The method ".orElse(Block)" returns the value if present or
// the specified value if not
return BlockFinder.findNearest(center, 10, Material.WATER).orElse(null);
}
public static void refillWater(final Player player) {
final Block startBlock = getNearestWater(player);
if (startBlock == null) {
return;
}
// This is not how you get the Block a Player is looking at. You should ray trace instead.
// final Block to = player.getEyeLocation().add(player.getLocation().getDirection().normalize()).getBlock();
// Like this:
final RayTraceResult rayTraceResult = player.rayTraceBlocks(3.0);
if (rayTraceResult == null || rayTraceResult.getHitBlock() == null) {
return;
}
final Block to = rayTraceResult.getHitBlock();
final Pathfinder.Path path = Pathfinder.findShortest(to, startBlock, 20, true);
if (path == null) {
return;
}
Main.getPlugin().getTaskRunnable().addTask(new RefillWaterTask(path, player.getUniqueId()));
}
}
how do i check if something is null again? I forgot you can't call .equals on null
boolean expression is obj == null
that did it thanks
why is there 3.0
final RayTraceResult rayTraceResult = player.rayTraceBlocks(3.0);
hey i saw your thread on spigot
what is PlayerHeight.heat and PlayerHeight.cold ?
If a Blocks state us updated then a packet is sent to the client. If the client does not have this Block then he will create it.
I think for some Blocks a physics update is triggered and thus corresponding data is sent to the clients nearby so the client
re-creates the Blocks based on those packets.
Thats the ray tracing distance
well it's deleting the blocks for the client
dm
Yes but if the client receives an update packet for this Block afterwards then the client will simply re-create the Block based on the received data.
Hmm. what can I do to prevent that
This is whats probably happening
- Send delete packet
- Block gets updated (redstone, or lightning, or state change)
- Client becomes update packet and realises that there is no Block
- Client re-creates the Block and applies the update
Per-Player Block states are a bit tricky. You should probably build a whole state handler abstraction for that. It involves listening to outgoing packets and fetching those which could affect a clients perception of changed Blocks.
so no real good way to solve this issue then
thanks, I forgot too
You gotta buy a rank to see diamond ore
p2w be like o-o
weird thing is when I spawn a falling sand block through commands this doesn't happen at all
Its only a problem if the servers and clients state differ
:/
when using a summon command instead of creating the FallingBlock thing it's fine
now it only works if I am standing next to a block tho cause otherwise the rayTrace is null
just to make double sure, Minecraft 1.18 is still slated to come out on the 30th of this month, right?
no delays announced thus far?
Yes
is there maybe a way to fix wrong blockstates in the world?
instead of doing it all manualy
worldedit seems to change them
How can i send a player an empty line?
sendmessage("")
hello, im looking for method to decrease health of an entity
And how can i sent a message with multiple lines?
But when a player sen a message in this time, it will split
p.sendMessage("");
p.sendMessage("Hewoo");
p.sendMessage("");
p.sendMessage("!!!");```
Is it possible for Citizens NPC to have an inventory?
or ```java
p.sendMessage("\nHewoo\n!!!");
I tried using the Inventory Trait but it doesnt work
smh my server version doesnt support citizen
Ok thanks
but i dare you use it
How many characters fit in the chat?
hardcoded messages arent cool bro
how do i change the weather?
oh ok fpund out, that i need to cast it into a living entity, anyways ty for help anyways
unlimited, but the amount of characters that a player can send is limited, at least in 1.8
i dont think you need to.
yeah def unnecessary
yeah you do, entity can be an arrow for example
im an entity
Oh, sry. I mean how many characters till minecraft splits the line
setweather or something in javadocs
depends
ok
you cant really know
because that is client settings
but by default then idk
wiki might help yoi
unnecessary. player extends living entity
it dont need to cast to living entity
Is it possible for Citizens NPC to have an inventory?
I tried using the Inventory Trait but it doesnt work
args[1] by default is a string
ok ty
But first, check if the value is an integer or not
i did
Otherwise an exception will be thrown
alt tab and tab back in?
Not sure, restart the application
ok
everyone using String.valueOf(int) me Integer.toString(int) 😳
is there any difference tho lol
no 😳
😳
😳
like this?
int amount = Integer.parseInt(args[1]);
?learnjava when
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.
Is it possible that chunk's PDC are broken in 1.18-rc3?
Everything I save into a chunk's PDC is gone after a server restart
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
Player player = (Player) sender;
Chunk chunk = player.getLocation().getChunk();
if(args[0].equals("get")) {
for(NamespacedKey key : chunk.getPersistentDataContainer().getKeys()) {
System.out.println(key.getNamespace()+":"+key.getKey());
}
}
if(args[0].equals("set")) {
chunk.getPersistentDataContainer().set(new NamespacedKey(this,"test"),PersistentDataType.STRING,"someValue");
}
return true;
}
using /test set, then /test get, it shows "test:test", but after a restart, nothing
String online = String.valueOf(getServer().getOnlinePlayers());
e.setMaxPlayers(Integer.parseInt(online))
why?
because getOnlinePlayers() returns a Collection and not an integer
use size() on the player collection
okay ty
can someone please try whether you can confirm this?
I love ur plugins mfnalex :)
thx 🙂
hmm
you can't just add filters inside <project>
btw you can see the full error message when you click on the top entry on the left side
the one above the one you have selected
is there even a way to change the player's name above his head without using packets?
scoreboards hmmm
oh shit, I was right, it's indeed a bug: https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6814?filter=allopenissues
It is safe to extend location? I wanna make an unmodifiable wrapper around
just ping me then thank you
i'm using https://www.spigotmc.org/threads/user-friendly-material-type-to-in-game-item-name-enum.82425/ for an /item command, does anyone know how i can check if the enum contains args[0] i tried if(ItemNamesEnum.valueOf(args[0]) == null ) { but it says Condition 'ItemNamesEnum.valueOf(args[0]) == null' is always 'false'
Because valueOf is never null, if there's no value for given string, it will throw an exception
ItemNamesEnum.VALUE.toString().contains(args[0])
VALUE?
whatever value your enum has that you want to compare
at least it's not forbidden in the docs
i don't understand
my command is /item <item name> i'm comparing arg0 to see if it matches an enum
how can i make it so it shows the breaking block animation on a certain block? without someone actually breaking that block
in your case you would loop through the enum and compare each value rather than only one
