#help-development
1 messages · Page 68 of 1
what about cloudnet hmm
firecracker style
would cloudnet be a viable solution
docker yucky
might go with it honestly
either that or I charge 1k$ and make my own
might charge 200$ to set it up tho
does anyone know how to repair an item bc something has changed and you can no longer cast an ItemStack to a Damageable
and casting ItemMeta to Damageable also doesn't work
you imported the wrong Damageable
ive heard you can get child labour pretty cheap
nope
there is one for itemmeta and one for entities
and you can definitely cast it if it's the correct one
im using one for itemmeta
what error do you get?
i dont get any errors it just doesnt work
yeah that's my go to solution for many things
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
public class RepairUtils {
public static void repairall(Player p) {
for (ItemStack items : p.getInventory().getContents()) {
if (items != null) {
ItemMeta itemsMeta = items.getItemMeta();
Damageable item = (Damageable) itemsMeta;
item.setDamage(0);
}
}
for (ItemStack items : p.getInventory().getArmorContents()) {
if (items != null) {
ItemMeta itemsMeta = items.getItemMeta();
Damageable armor = (Damageable) itemsMeta;
armor.setDamage(0);
}
}
}
public static void repairHand(Player p) {
ItemMeta itemMeta = p.getInventory().getItemInMainHand().getItemMeta();
Damageable handItem = (Damageable) itemMeta;
handItem.setDamage(0);
}
}```
you also have to set back the itemmeta to the itemstack
^
omg true
its ass
i also dont like it but meh, it works fine
could have been there at the inception
i wish I was 10 years younger lol
I mean, item meta kind of stuff is okay in terms of API itself
what it does below the hood is trash
Well, its def somewhere on the paper goal thingy
there is always the decision on what is better as well, ye you could keep it all as a plain wrapper around a CompoundTag
but if you use a single item a LOT parsing its contents first might be nicer
If I had been there when it started I would def. have questioned the enchantment naming scheme severely
oh yes
like i understand the want to not tie things to vanilla naming, but errrr
DIG_SPEED my ass
👀
The same goes for the material API
the material enum has just gotten too big, there should have been an attempt to split it out sooner than for it to get to here where accidently opening the source might crash your IDE
Having it as an enum was an okay descision at the time (do note that back then mods were almost unheard of) but at least there should been enum entries for everything, including the things with the "magic" data values
i think it was implied in the last couple of updates to not use EnumSets anymore
yeah NMS has two classes, Item and block
no idea why spigot decided to mix both
and imho they should also remove all those LEGACY materials
fuck old versions
I wish md5 would just say "fuck everything prior to 1.16"
with a big commumity re-write
Then I can add my @since :D

fuck it we ball
I like this idea
1.20 mojang adds all the mobs that lost in the mob votes
what is 1.20? i forget
we finally get copper golem and the yellow cow
I still have to ping md_5 about it but I'm on vacay till tomorrow
No idea, even hmod didn't do it
1.20, mojang adds a bunch of packets servers can use to make cool stuff
1.20 mojang deletes the game
well, it was bukkit no?
put kennytv at gunpoint to drop 1.8 for all the via* plugins
i mean 1.8 > 1.2
Minecraft 2.0 when

second thursday in october
we already have the custom message plugin
what
I think they are talking about server transfer packets
I mean
I wanna see via version hack their way through that
just use bungee lolez
Bedrock already has server change packets
If geolocation is your main concern
Then bungee won't cut it
what can i say
You need multiple bungee cords
death to aussie pings
And do DNS shenanigans
You can setup multiple bungee cords
And vaguely target players in the same region to nearby subpools
But that's overkill
It would allow for good ping though
Without server transfer packets
Not round robin
what else did you mean then?
Redirecting people to closest bungee cord
oh that's what you meant
Having multiple bungee cords all access the same pool of spigot servers
I didnt read the prior chat
And for the bungee to always prioritize servers closest to itself
im watching "who wants to be a millionaire" and only spam my weird messages here inbetween from time to time
But we're talking a 20+ dedicated machine setup for good world wide coverage
And there are no public solutions afaik
But some ANYCAST shenanigans might work
That or regional DNS
But that's beyond me atm
O
K
I'm starting to think he doesn't care he just keeps talking
who?
your mum
no yours
no yours
which of the explosion types is 6 blocks in radius? explosion, explosion huge, or explosion large?
with Java Valhalla 👀 👀 👀
yes mine
how can i create a fallingblock using nms? using new FallingBlock it asks for a properties object, what is that and how do i make it
Why would you want to make it using NMS?
just use the API?
Bukkit
.
Yeah but you don't have to make an NMS entity for that do you
Just send the packet to that single person
use World#spawnFallingBlock and then do Player#hideEntity for all others
or that
uhhh
id rather use nms though since im already using nms armorstands also its less laggy
id be using quite a lot of fallingnlock
Kappa
How is it less laggy
idk it just is
API isnt any slower than nms
oh?
Even if it was it would be negligible
The API is legit just some code over the top of nms to make it easier to use
unless youre dealing with setting millions of blocks the difference is negligible
?jd-s
id be spawning like 100-200
Though #hideEntity() is still draft API so
Helo, I am making a signature plugin; Players can use a command so sign an item.
It adds a lore line to the item, and sets a value in the persistentState.
Now, when a player wants to remove that signature, cool, I can get rid of the entry in the persistentState, but, I cannot remove the line added to the lore, because I don't know which item in the lore list it is... ( also this can change in between )
This issue is for more stuff to do with custom items.
You don't have access to the individual ItemStacks, meaning everything has to be done from the outside.
any recommendations for sites to learn java
?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.
yk in new versions you can put water in the middle of some blocks which is annoying af for me because i now can't set the waterblock to air or it will remove the whole thing
is there any workaround to remove only the water?
Yes
waterlogged
declaration: package: org.bukkit.block.data, interface: Waterlogged
What
Wouldn’t the question technically be is air waterloggable
you're trying to make a question which is similar to "is water wet"
and i don't know if it's in Minecraft because dear god i can tell it's possible
ugh smh
2$ water & air isn't waterloggable
what is nms again?-
ah ok
what is the advantages of that over spigot api?
there are some things which don't have an api in spigot but you should always use the api over nms
since nms is per-version, it makes it harder to maintain your plugin across versions etc
Hello. I'm trying to generate a block outline, however, right now, we are using an invisible shulker to get the outline. this works for most blocks, but for blocks like redstone, sugarcane, you see the shulker head. Is there another approach to get a block outline?
and nms isn't any faster than the api
example: https://i.imgur.com/3sFRupK.png
What is the max inv GUI size?
I guess 6 lines
54
would it be possible to do bigger with packets
No
Maybe
But they are visually a mess anyway
I think it was worjubg
Well if you succeed ping me please
It overlaps the inventory iirc
thru RP
link
me too lol
I need an 8x8 inventory size
time to do push up ladies
use a custom texture pack, and overlap it with the player's inventory
or try creating a slider
Wouldn't it be just a graphic rather than something you can store stuff in?
Well you'll need to do some code behind it to make it able to store things
muscle up*
What do I have to audit/change? Could you perhaps give me a rough guideline?
I need a bar
Well this would be a mess for your player inventory cause it will remove two lines so you'll have to find an alternative for that
My best advice is to create a scroll inv
or make multiple pages
And then just listen to inventories events to do so
Gotchu, how do I make this?
well the easiest way is to create a paged gui
Create an inventory, put an item somewhere to change the page.
Listen to that item with InventoryClickEvent and whenever the player clicks, change the page.
For each page save the items as you wish, like a list or a map. And each time inventory is closed, save it
Ah I see, so it'll be like going through pages, thanks
my bad lol, i tried to react it
GUIs are such a pain lol
not only in MC but in general
Imagine how the world would be with bedrock's GUIs
how can i check how close to the players center of screen a given entity is
thb I never used bedrock so I have no idea
Well, are you good at geometry?
guys, how could i set max durability of an item?
not particularly but im down to learn
damn that's going to be hard I guess
do you still have your math book from school? lol
look at projective space
this is exactly how rendering works
any thoughts?
transforming a 3d point to 2d space
well well well
it definitely is faster
the question is "how much faster" it is, and whether it's worth it to worry about it
e.g. setting blocks can be done waaaaay faster using NMS
haha gluProject go brrrrr
weard error any idea
recursion issue
uwu
you keep calling your method from your method
recursive
wrong reply
mb
what's line 206?
hi alex ❤️ ily
happens to me all the time haha
I always reply to the wrong msg
henlo ❤️
how do i fix
anywayi doubt i will be able to do the maths
why do u keep calling getPlayer().getPlayer()
that is how jobs do it
treat the centre of your entity as 1 vertex
i didnt know steve jobs knew java
because getPlayer() probably returns a JobsPlayer, and another gerPlayer() will get the bukkit player
damn
oh my-
also what is the code for EnderliteMasyer.luck()
get out
LOL
any idea i am trying to get when you join a job it puts them in the rank of luckerms that maches the job
weird thing to say - but I think I just cracked my hip and it felt so FUCKING weird 👀 wtf 
as said, what's line 206?
and whats the code for EnderliteMaster.luck() method
all in the picture i sent
I can dislocate my hand
lemme send a video
BET
i think i can do it with my right shoulder
I have a feeling I'm asking too hard questions xd
the code for EnderliteMaster.luck is not shown there smh
also u dont have the actual line numbers shown
actually theres another thing u could do which is way easier
theres ur issue
what the issue
Create a Vector between player and entity, create a vector in player direction, then find the vector to create an orthogonal triangle (pi/2 rad between the the one you create and the player-entity vector)
ur calling luck inside luck
I'd try and store the line in the PDC and then retrieve it when you're removing it to remove that line in the lore ❤️
it works in other classes
Lmaoo
When you got this last Vector, compute it's projection to get the length on the screen (simple ratio)
no
it douse
no
not possible
Get the norm of the Vector, and compute the distance with the entity to find the length on screen
public void luck() { luck(); }
this will ALWAYS cause a stackoverflow, I mean just look at it
ohmm yeah that is a good option. not fullproof however which my perfectionist brain doesn't like xP
because line numbers can change
if you insert
that seems so much lol i thought the api would have something
i just want to target entites that are closer to the crosshair
well i should learn some maths
wrong ping
Ohhhhhhh you mean you want which entity the player is looking at ?
Only if you insert above
they wanna know which entity is closest to the crosshair, so raytrace wont help
isnt there a method for that
no
another thing you could also do is compose a line shooting out of the players eyes. Then find the distance between that line and a point, being the entity’s pos. That would be high school math so probably the easiest
Lmao I went onto computing the "on-screen distance between crosshair and an entity"
yeah ubt that's kinda what they need
lemme draw diagram
how do i fix then
dont call luck() in your luck() method
Yeah for sure, but mine was to compute the onscreen distance lmao
get vector between entity and player, use distance formula between line an point (look it up) ez pz
at first mine was as well lmao
guess we both misunderstood
how would that solve their problem?
i have a homing weapon
u want the closest entity to the crosshair right?
Fact is: which point ? 🙂
do you know how i can create a building who can produce like a barrel of the plugin brewelry but changin bloks or givin the item in the owen or in a chest
im on the voice chanel
i want to target the creeper in the middle rather than the skeleton on the right
entity pos
programatically
they want to get the entity the player is "trying to look at" even if they dont exactly look at it
NICE PC
THANKS
exactly what that method can do
get distance and sort to the nearest entity…
when i remove return luck it gives red line
then you get the closest entity to the target location, that's not what they wawnt
dont u mean like
distance?
distance to what target location?
Distance between a point and a Vector means nothing
You need to return an instance of LuckPerms.
why wouldnt it
how
distance from crosshair
otherwise use world.rayTraceEntities in the direction of the player, and expand the entity hitbox by like 2 or so
@crimson scarab Do we agree on that statement: you want to get the entity the player is looking at, even if he's looking not directly at it ?
What exactly would you want it to return? as the distance?
then get the hit entity if one exists
just the closest one?
and use that entity
@crimson scarab btw
Take a paper, draw a line, draw a point, and tell me what's the "distance between the line and the point"
compose a line coming out of the crosshair, basically a vector. For every entity get the closest distance to that line. Sort to the nearest and voila
dude
the distance between a line and a point is defined as the closest distance
its basic high school maths
Let me find a link for it
Then we're talking, be precise, we're in a tuff world 🙂
yes
Imagine both the jägermeister and my phones (the white box) are entities. In this case im trying to point at the phones. If you just go by distance, it would return the jägermeister which is the wrong entity
No need x)
In Euclidean geometry, the distance from a point to a line is the shortest distance from a given point to any point on an infinite straight line. It is the perpendicular distance of the point to the line, the length of the line segment which joins the point to nearest point on the line. The formula for calculating it can be derived and expressed...
but not raytrace as i want to sort all the nearby entites
TOE
yes, I do have toes
by how centered they are in the players vision
would be weird if I hadn't any
look at the link above. Your line is the player look at and the point is each entities position
beautiful toes
ok then
i have an idea
how will i do that because anything i put in there dont work
Basically, we want distance in 2d space so time to math
take the displacement vector of the entity to the player
In any case I'll return the jager
(entityLoc - playerLoc)
and then use the player's looking direction
and find the angle
smaller the angle, closer the entity to the crosshair
to make it more performant just check for dot product
Best method, congrats
damn never thought of that 👀
fucking nerd
im not a math guy
Hi, can someone help me understand hows that even possible?
Error: https://pastebin.com/fXe31NZ2
Code: https://pastebin.com/vfHCh9dY
How it can make an access violation when I encapsulate all :/
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.
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.
ah fair enough mart ❤️
you are an inspiration to me lol
that is some commitment
martoph? more like marry me
actually checking the dot product between the player look at and the vector between entity and player could be better for performance, since no trig. The dot product closest to 0 is the entity you want
just make sure both vectors are normalized
like rolyn mentioned earlier
I think
Not sure about performance, but dot product is easier to accomplish
Normalization is also pretty intensive
fair enough
sqrt
its a cos vs sqrt
from my own testing a sqrt usually is less cycles than a cos
"my own testing"
sqrt is nothing to worry about unless you do it 10000 times per tick
Complexity speaking it's slower x)
its nothing high performance
Minecraft doesn't need to care about that kind of performance
setType(Material.IRON_SWORD);
setAmount(1);
ItemMeta meta = getItemMeta();
meta.setDisplayName(ChatColor.WHITE + "Miecz z Wytrzymałej kości");
meta.setCustomModelData(1000000000);
AttributeModifier modifier = new AttributeModifier(UUID.randomUUID(), "generic.durability", 0.101, AttributeModifier.Operation.ADD_NUMBER);
meta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, modifier);
meta.getItemFlags().add(ItemFlag.HIDE_ATTRIBUTES);
setItemMeta(meta);
}``` why is this code not hiding attributes?
just use whatever is easiest honestly
Dot is tricky cuz itta hard to visualize what it means
the dot product tells you how similar two vectors are
angle uses acos i think
thats just it
atan2 actually
can any one plz help me
You also need to normalize anyways… it takes the magnitude of the two vectors
Well i mean
and converting vector to angle doesnt require normalization
In all case angles and dot are linked
In term of simplicity use dot
at this point were nitpicking lol
weve handed them 2 different ways of solving it
they can decide what to use as either of them have pros and cons
Hope we haven't got him lost
a little high school vector math doesnt hurt
i agree
entity.getLocation().subtract(player.getLocation()).toVector().angle(player.getLocation().getDirection())
does this look ok mathmatically wise
What would the prepared statement be for creating, and adding to an array in SQL? I've found ARRAY_APPEND, but not sure how to use it in this context.
Example of how I'm setting integers: setInt(String uuid, String category)
PreparedStatement ps = connection.prepareStatement("UPDATE " + table + " SET " + category.toUpperCase() + "=? WHERE UUID=?");
ps.setInt(1, value);
ps.setString(2, uuid.toString());
ps.executeUpdate();
Any sort of help would be appreciated
Depends on the level, 3D angles need to introduce a plan so can be harder sometimes for some...
yes but please designate some of these to variables
I'm using a DAT file to save data, how can I clear the data in the file to save it again without erasing the file? Or is there a way of editing lines of those files with data already in it without just making more lines?
DAT... as in nbt?
i would but its gotta be used inside an optional predicate
not scientifically posible
private boolean myPredicate(ObjectInPredicate) {
return true;
}```
and then this::myPredicate
is it possible to use multiple min statements in an optional
Show your code
don't reccomend using optional's in java
just use null checks the only reason you should ever really deal with them is in java streams
it makes the code sexier
it also makes it 3x slower (at low frequency)
Optional<Entity> optionalEntity = nearbyEntities.stream()
.filter(entity -> entity instanceof LivingEntity && ((Projectile) arrow).getShooter() != entity)
.filter(entity -> ((LivingEntity) entity).hasLineOfSight(arrow))
.min(Comparator.comparing(entity -> entity.getLocation().distanceSquared(arrow.getLocation()) * entity.getLocation().subtract(player.getLocation()).toVector().angle(player.getLocation().getDirection())));
graphs
discord formatting really fuckeed that
I'm interested in reading some explaination about it, is it a personal test or something known?
well if you think about it an Optional is just another object in java's back end
so all your doing is creating another object to do the null check for you
Yeah I understand, more memory, more time to allocate memory, and (little) time to do checks
if you use Optional's all the time its going to be creating lots of Optional objects for every var to manage nulls that stacks up
How to I delay a function in ticks
Bukkit#getScheduler#runTaskLater
I’m still new to this what does this mean
Bukkit.getScheduler.runTaskLater(plugin, task -> {
do stuff
}, 20L, 1L);
Thats how its done i think
learn java :/ but the # are just dots
Bukkit.getScheduler().runTaskLater(Plugin, task)
sorry for spoonfeed but i found scheduling difficult when i started it out
it just takes time to understand i think
Thanks
private Location playerLocation;
is this bad naming
i assume i am wrong
most of the time
personal opinion:
should targeting for homing projectiles be:
100% closeness to crosshair
100% distance to potential target
50% distance 50% crosshair
other ->
how do i uncapitalise messages
.toLowercase()
learn java message incoming
I don't understand
so i have a homing weapon how should the automatic targeting for entites be based off
like should the closest enemy be targeted
or should the enemy most visible by the player be targeted
I'd say the player should select the entity at launch, and then it will keep the same entity
Well, if you want frustrating make it closest. If you want a more enjoyable mechanic it should be targeted
I imagine a kind of cool glow effect to select the entity to reach
thats a really good idea actually
Free ideas tonight
Can I make a unenchantable item enchantable on enchanting table
Maybe highlight in hex the closest enemies that the player can see
How to add a default configuration section?
so not likely to be targeted in red
basically the target in 0xff0000
using colored glow
anyways gtg
cya
I've already searched up
Really funny
I love this website
If you've searched it how did you not find it
I am not stupid, not at all, searching on Google it's the first thing I do.
Great question.
A sec
None of these answers can help me, except the last one, that suggested instead to create the section if it doesn't exist.
So now, step 2 if you didn't find your answer, explicit it more clearly, more precisely
You should skip on 3rd step since I've already done that, but I'll do it again so: "How do I create a default section in a config?".
That's exactly the search you've done, so you're still on step 1
Open your mind, try to think more deeply
What do you mean by "default section"? Do you mean set default values? or simply create a section via code?
searching_stuff != ask_to_some_one;
Look ElgarL questions, that's the one you need to explore
The exact same thing you do when adding a default Value to a config, but with a section, so basically create a section if doesn't exist.
you're right, 5G DOES mean the earth is flat
how else would the waves travel?
You just opened my mind
thanks rolyn
all you do is set with whatever data you want to put in
how do i rename item stacks?
earth IS flat
this is fantastic, we really managed to empty our minds thanks to Rolyn
Does it override if it already exists?
yes
next I think everyone should move their projects to Kotlin
So it's not what I've asked for..
So...
So it's the same thing on that page, but I think there is a way of doing it without checking the existence of the section.
Like using one of this method.
oh yeah has anyone played around with setComments already? I noticed that was added semi-recently
yesterday i made so complex if statement that my muscles legit started to hurt
methinks you need to hit the gym or at least get up more than once every year
No, that will still overwrite an existing section
No.
The defaults system for configs is weird
Uh, fine, I thought that the "default" word would work as the addDefaul() logic.
I’ve never actually used it
then you'll have to suffer me flexing on you for the rest of your life. I'm doing it right now, I just came home from the gym
real men use boostedyaml
no one used setComments?
too big? just use plugin.yml libraries
guess I'll try it out myself
Should I add a config in the resources?
Yes
Default in the context of a Configuration is simply referring to a value that is provided if no actual value has been set.
Thanks, that helped, it did the opposite someone else. (coff coff)
ie, you can define a whole yml as the Default and its values will be returned unless you set your own
Should I open a thread about my question?
I didn;t see any question, sorry
What is it ?
On spigot? Not reliably
you can addUnsafeEnchantment
I don't want to enchant it, I want players to be able to enchant it on enchanting table
Like a steak that is enchanted by a player will give more saturation
Oh, I'll listen the event and change it's content?
I have been playing with some code and wanted to use one entry from stringList #1 and add the entry from the stringList #2 to it and i used 2 for loops and got the output i wanted, but there's an issue that it pastes 4 messages instead of 2. Could someone give me a tip how can i fix it? (codes is below)
I'd probably make plugin a static variable first of all
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
If I have lots of event & command handler classes I do the plugin static, it works Fine
bro
do u mean public static?
i didnt assk u
i asked him
lol
mb
but well
i asked him
and btw
di isnt better than that
theyre seriously the same. except that a singleton pattern is better in this case
Hi when I set a displayName for an itemStack, the intellij linter says method invocation for"setDisplayName" may produce "nullPointerException"
its not really affecting my plugin as it is working as it should, but out of curiostiy, what could this mean?
since a plugin main class is a singleton in the first place
if the bookmeta is null
itll return an error
e.g
ItemMeta meta = null;
meta.setDisplayName("hello");
this will throw an npe
ah ok, thanks!
it means bookMeta could be null
Hey there.
Im trying to add a command that gets the displayname and lore of an item and saves it to a config
However since the displaynames are colored using & they get replaced in my yaml file.
In order to make yaml not replace those reserved symbols I would need to escape them using ' at the beginning and end of the string
How can I add those ' plugin sided?
I already tried adding "'" before and after it but that only resolved in this ''' in my yaml file
Can I simplify this even more?
String singularPlural = newDelay == 1 ? newDelay + " second" : newDelay + " seconds";
String finalOutputMessage = newDelay == 0 ? "none" : singularPlural;```
String outputMessage = newDelay == 0 ? "none" : (newDelay == 1 ? newDelay + " second" : newDelay + " seconds);
Pft, how inefficent
That would be an easy solution I guess, but I want "seconds" to be spelled out
Yeah, looks a bit ugly but ur right, thanks!
2Hex? Do you by any chance have a solution to my question aswell? 😄
no 😄
§?
§
Umh??
looks like you fucked with the jar while the server was running
Use ChatColor#translateAlternateColorCodes in that case before saving to config I guess
if its so then do replaceAll("§", "&"); to the string before saving
nope
ahw ait ur right
yeah I confused them for a sec lel
lol
How do I make two chests connect to a double chest?
Cause I tried and they don't connect
Usually I just take them and place them next to each other funny
did u do what i told u to
What exactly are you doing? Setting 2 blocks to chest next to each other?
thx for the hint ❤️
anyone got a clue why the output is being doubled when i use for loop inside of a for loop?
ok yall gn
or rather why is it output in 1, 1, 2, 2, 3, 3? instead of 1, 2 ,3
yes
yes, sorry
wrong ping
doesnt work
displayName.length() == ChatColor.stripColor(displayName).length()```
Does this make sense to check if a string contains a chatcolor?
It won't be equal
Or is there some method I'm missing
Can’t you just use .equals
I'd personally opt for an equals() check too
alright then I'll try that
no idea
how would I play a sound a player's location?
Because it halts the thread
And most of the server runs on that thread
ohh
so i have the use schedules?
Im trying to make a slight delay between click and check
because when you equip the helmet in game its not registering
you have to click somewhere in your inv
alr, ill check it out!
No
ok
and could i get a little help intergrating runTaskLater into this code?
I want a delay before the check is done so it waits a little and then sees if he has a helmet
first off, fix your brackets, thats ugly af
Why so many plugins
also #help-server
got it thank you wasnt sure :D
nah
{
}
is better
difference?
so prefrence
No
???
Practice
it's all just personal preference
mhm
wait...
how can i get the killer in PlayerDeathEvent
Ah yes
yeah i usually do capital method names i just didn't for that one
Thats objectively wrong
?
alrught
Yup
Java names are meant to be lowerCamelCase
Player killer = event.getPlayer().getKiller();
variables are atleast
and packages are all lowercase
classes are CamelCase
Variables and method names
^
Except for static final variables
How would I play notes at a player?
Depends what u mean exactly
???
like a piece of music?
"this" is supposed to be an instance of main
ok but runTaskLater isn't recognized
what does it say
^ unless thats what you defined "scheduler" as
then it should work
as well
yes, I plan to use the wait feature to make a string of notes
NoteblockAPI
Don’t sleep the main thread
^
scheduler.runTaskLater(Main.getPlugin(), () -> {
}, 20L, 20);```
this is the code you gave me
Why define a variable, takes up a line for no reason, not like you're gonna reuse it and if u do then u can make one
I tried that to fix runTaskLater
yeah, got that now
Thanks!
runTaskTimer
Also PLEASE look at your naming conventions, not only makes you code look amateur but is objectively wrong, see;
https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
I'm so tempted to write a plugin all uppercase just to be a prick
Then watch it get accepted into teh Github code vault 🙂
PUBLIC VOID METHOD() {
IF (PLAYER.HASPERMISSION)
PLAYER.SENDMESSAGE
//WHY IS IT NOT WORKING?????
}
Are they still accepting projects?
I thought it was done and everything was stored
No idea, they keep taking mine for some reason.
I keep getting these silly award badges for it
do you know if there are any articles or videos on this topic?
so im trying to make a death chest where when a player dies, their items get put in a chest but i get null from inventoryItems in onRightClick
Send full error and use haste so I can see lines
im getting this error
what does it say when you hover over it
Invalid content was found starting with element '{"http://maven.apache.org/POM/4.0.0":dependency}'. One of '{"http://maven.apache.org/POM/4.0.0":parent, "http://maven.apache.org/POM/4.0.0":description, "http://maven.apache.org/POM/4.0.0":url, "http://maven.apache.org/POM/4.0.0":prerequisites, "http://maven.apache.org/POM/4.0.0":issueManagement, "http://maven.apache.org/POM/4.0.0":ciManagement, "http://maven.apache.org/POM/4.0.0":inceptionYear, "http://maven.apache.org/POM/4.0.0":mailingLists, "http://maven.apache.org/POM/4.0.0":developers, "http://maven.apache.org/POM/4.0.0":contributors, "http://maven.apache.org/POM/4.0.0":licenses, "http://maven.apache.org/POM/4.0.0":scm, "http://maven.apache.org/POM/4.0.0":organization, "http://maven.apache.org/POM/4.0.0":profiles, "http://maven.apache.org/POM/4.0.0":modules, "http://maven.apache.org/POM/4.0.0":pluginRepositories, "http://maven.apache.org/POM/4.0.0":dependencies, "http://maven.apache.org/POM/4.0.0":reports, "http://maven.apache.org/POM/4.0.0":reporting, "http://maven.apache.org/POM/4.0.0":dependencyManagement, "http://maven.apache.org/POM/4.0.0":distributionManagement}' is expected.
thats what it says
Show some more of your pom
hello, i'm searching for a way to display all strings of an arraylist<String> in one and unique message, is that possible ?
like a list but in one message
You just wanna add all entries of a list to a string?
fixed some of it now im getting these errors
?paste
is player in PlayerQuitEvent a offline player?
thanks
https://paste.md-5.net/yodejedima.cs
I'm trying to change PersistentDataContainer(), and this happend.
The first time Events runs, the value normally increases from 0 to 1.
However, when the next event is triggered, it does not work from line 24.
I checked the ItemMeta of the item in hand, but I don't know why the if statement doesn't work although CWname exists and value "nasus" exists.
What should I do? or Does some knows why this happen?
what do you mean "Does not work"
does it throw an error
also please just use early returns instead of nested if statements and variables instead of inline checks
makes oyur code more readable
hi, is it not possible to use maven placeholders in my plugin code like ${project.version} ? I have tried using them but they don't seem to work. is this normal?
whats the usecase?
i dont think maven affects .java files on compile
ah ok yes that was my intent. I wanted to have a loading message outputted to the console displaying the version of the plugin.
you can use maven to set the plugin version in plugin.yml
just sync that and read it
how could I sync that?
If I set default: false in Plugin.yml, will the console still be able to execute it?
*how to allow console to execute command but not players, even if they are op
Check if the command sender is instance of ConsoleCommandSender
if (sender instanceof ConsoleCommandSender) {
oh yea, thanks!
sorry but I just don't get what is wrong here
@EventHandler
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
//WORLD PLAYER WENT TO
World world = player.getWorld();
if (world.getName().equals("world")) {
for (Player p : player.getWorld().getPlayers()) {
p.sendMessage(player.getName() +" JOINED!");
}
}
}
Even in a server with only one player, it sends the welcome message for that player twice, as in
name JOINED!
name JOINED!
Why do it that way? You can do Bukkit.broadcastMessage("");
Unless you're purposely only broadcasting to the players in that world
You can avoid the loop entirely if you're not on older version of Java, maybe world.getPlayers().forEach(player -> player.sendMessage(""));
ok, ill try that, thanks!
just use Bukkit.broadcastMessage
He only wants to broadcast to players in the specific world
ah didnt see that
I will try this, but can someone explain why my code above didn't work? It seems logical to me
still displays two times
Maybe the event gets fired twice
I though so too, but how? ChangeWorld event only fires once when a player changes worlds?
Haven't you registered it twice or smth
I have a really odd error;
The following code works fine after I restart the server BUT if I save then try to get the new save without restarting the server then it doesn't work and prints this error
public class InventoryUtility {
private final FileConfiguration config = Survival.getInstance().getConfig();
public void saveInventory(Player p) throws IOException {
Configuration config = Survival.getInstance().getConfig();
config.set(p.getName() + ".inventory.armor", p.getInventory().getArmorContents());
config.set(p.getName() + ".inventory.content", p.getInventory().getContents());
Survival.getInstance().saveConfig();
}
@SuppressWarnings("unchecked")
public void restoreInventory(Player p) throws IOException {
Configuration config= Survival.getInstance().getConfig();
ItemStack[] armour = config.getList(p.getName() + ".inventory.armor").toArray(new ItemStack[0]);
ItemStack[] content = config.getList(p.getName() + ".inventory.content").toArray(new ItemStack[0]);
p.getInventory().setArmorContents(armour);
p.getInventory().setContents(content);
}
[16:46:42 ERROR]: Could not pass event AsyncPlayerChatEvent to Survival v1.0-SNAPSHOT
java.lang.NullPointerException: Cannot invoke "java.util.List.toArray(Object[])" because the return value of "org.bukkit.configuration.Configuration.getList(String)" is null
at me.zoibox.survival.utils.InventoryUtility.restoreInventory(InventoryUtility.java:31) ~[Survival-1.0-SNAPSHOT.jar:?]
at me.zoibox.survival.listeners.ChatListeners.onChat(ChatListeners.java:27) ~[Survival-1.0-SNAPSHOT.jar:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor3.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:git-Purpur-1761]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:678) ~[purpur-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.adventure.ChatProcessor.post(ChatProcessor.java:381) ~[purpur-1.19.2.jar:git-Purpur-1761]
at io.papermc.paper.adventure.ChatProcessor.process(ChatProcessor.java:96) ~[purpur-1.19.2.jar:git-Purpur-1761]
at net.minecraft.server.network.ServerGamePacketListenerImpl.chat(ServerGamePacketListenerImpl.java:2500) ~[?:?] at net.minecraft.server.network.ServerGamePacketListenerImpl.broadcastChatMessage(ServerGamePacketListenerImpl.java:2681) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChat$18(ServerGamePacketListenerImpl.java:2325) ~[?:?]
at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718) ~[?:?]
at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
List<WrappedChatComponent> components = packet.getChatComponents().getValues();
for (WrappedChatComponent component : components) {
//component.setJson(component.getJson().replace("Swear", "*****"));
packet.getChatComponents().write(components.indexOf(component), component);
}
}
Hi i made this code with protocollib one thing how i can get the message sent by the server?
How do i change spawn point orientation?
hello . i want to make a plugin when i kill a zombie summon a nother zombie and when i kill secend one , do an action
public class spawn implements Listener {
@EventHandler
public void onDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof Zombie) {
if (event.getEntity().getKiller() != null) {
World myWorld = Bukkit.getWorld("world");
Entity entity = event.getEntity();
Location spawnLocation =entity.getLocation();
Entity spawnnedZombie = myWorld.spawnEntity(spawnLocation, EntityType.ZOMBIE);
}
}
}
Rename ur class
maybe custom name your second zombie so u can test for it
bump
tnx
How can I get the numbers of players in a given world?
I use this but it's giving me problems
public static int getPlayerCount(String world) {
World converted = Bukkit.getServer().getWorld(world);
assert converted != null;
int count = 0;
for(Player p : Bukkit.getOnlinePlayers()){
if(p.getWorld() == converted){
count++;
}
}
return count;
}
wait im dumb
(Bukkit.getServer().getWorld(world)).getPlayers().size();
No idea sorry
... this doesn't really work
is there a better way to get the amount of players in a world?
no
Why not?
so add 1
and the third player zero again
Bukkit.getServer().getWorld(world)).getPlayers().size() + 1;
.
Huh
i know it makes no sence
this is the method:
public static int getPlayerCount(String world) {
World converted = Bukkit.getServer().getWorld(world);
return Objects.requireNonNull(Bukkit.getServer().getWorld(world)).getPlayers().size();
}
Called like this:
//Player World Change Event
Player player = event.getPlayer();
World world = player.getWorld();
//Send join message to everyone
for (Player p : world.getPlayers()) {
p.sendMessage(player.getName + Handlers(Dumb class name i know).getPlayerCount() + " has joined the world!"
}
getPlayerCount needs a world argument, doesn’t it?
anyways instead of using the world name use the actual world object
also you should probably use Bukkit#broadcastMessage instead of sending all the players a message manually
Hey folks, I'm having some difficulty with raytracing.
The goal is to raytrace from a block to a nearby player and see if the raytrace hits the player rather than a block in the way.
I've been testing the following code to do this, however, the RayTraceResult is always null for some reason:
https://hastebin.com/ujazatozap.kotlin
Any advice on where I'm going wrong would be much appreciated! ❤️
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Hey there! 👋
How to get the id of an entity the player is looking at? (like if you do /kill while looking at something you can tab the id of it)
thy already ❤️
how do i check if a server is on hardcore mode?
how can i dispatch a command with argmuments
you could also do player.chat("/timer start"); iirc
or performCommand(); prob better
👍
how do i check if a server is on hardcore mode?
.
@EventHandler
public void onZombieDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof Zombie) {
if (event.getEntity().getKiller() != null) {
Zombie zombie = (Zombie) event.getEntity();
World myWorld = Bukkit.getWorld("world");
Entity entity = event.getEntity();
Location spawnLocation = entity.getLocation();
zombie.setCustomName("ghost");
if (zombie.getCustomName() == "ghost") {
Entity spawnnedZombie = myWorld.spawnEntity(spawnLocation, EntityType.ZOMBIE);
zombie.setCustomName("dead");
event.setDroppedExp(100000);
} else if (zombie.getCustomName() == "dead") {
return;
}
else return;
}
}
}
help !
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Bukkit.getWorld("world ").isHardcore();
(example)
is there a properly way to indicate optional arguments for a command in plugin.yml
yea but how do I show that it's optional?
like /<command> argument doesn't show it as optional
how can i get the Integer out of the Hasmap (ik ?learnjava im on it xd)
myes but you can use sth like
look into docs HashMap got a get method
usage: /<command> [optional] <required>
ok ty
tho I personally use brig directly as that has good support for arguments and literals
but it makes sense to put all optional at the end right?
-something=value
ohhh ok bruh
also learn Java before api's
the error literally says why it's wrong
you prob want pItemCount++
BRUH
but not enough information
I TABBED THE WRONG
HAHHA
shit
lol
sry
and now i wanna put the value back into the hashmap
but how
If the player is not present in the map you Will get a nullpointer
how can i stop magma block damage? & deny ice slipperiness?
Also please learn Java instead of wasting our time here with Basic Java questions
Check the entity damage event, and cancel the event. For the ice it's impossible
^^
Aw man, can i register a new block and steal ice textures? without making a resource pack
No :/
You need mods to register new blocks
You'll need a resource pack
But resource packs are great, use it!
Sure!
Wait, since you said i need mods, can i not do it serverside?
Or is my only option to set a random/unused block textures to look like ice
What's your version ?
1.19
This
You cannot add new blocks
Then with custom model data you can use a block and change it's texture without affecting others
Blocks cannot have custom model data
Oh my bad
Geez okay
I'm not sure but you should check datapacks. I think they allow you with resource packs to add blocks
They don't
:(( it's okay, thank you guys
noteblocks are one of the best options for this
easiest too
mushroom blocks are next easiest, but theyre more annoying since breaking adjacent ones change block states (Which is whats used to change the texture)
Guys anyone know how to make a rotatinf shop with stock using deluxe menu?
Oh, why are they easier than other blocks?
its subjective, but overall its a lot less overhead to work with
Go to #help-server for plugin help
BOOP
Bump
It's null when it doesn't hit anything I believe
what's the repo for authlib, brigadier etc again?
I thought it was libraries.minecraft.net ubt that's a 403
