#help-development
1 messages ยท Page 1512 of 1
like I said, x/z applies when you only process one shroom at a time
for multiple shrooms, use a treemap keyed by y
Show me how you think that would work compared to just checking the blocks above the stem.
you break the entire mushroom in one go, yes?
yeap
for each vertical column x/z, populate a treemap keyed by y
insert the mushroom type into this treemap
the above image literally breaks that
then, when you need to know the type of a stem, query the treemap located at that column, and find the nearest y key above that block's y value
for the lower mushroom, it will return red
for the top mushroom, it will return brown
If you check X/Z there is both a brown mushroom and a red mushroom. If you check Y there is a stem for a brown mushroom and a stem for a red mushroom.
do you know what a treemap is
the cap of the red mushroom and the cap of the brown mushroom are both in the treemap
however, only one can be nearest&above to a given y key at the same time
that is the type of the stem being queried
Now the mushroom blocks are the exact distances from each other so that would break your above solution
can I get a private static class in another class with reflection?
Class.forName
define "get"
Class.forName("outerclass$innerclass"); if not obfuscated nor compiled unconventionally
I want to create a instance of it
Otherwise, you are fucked
Also... blocks are broken down wards.... meaning there are no mushroom blocks to be checked. Only stems.
thanks
i would prefer Class::getDeclaredClasses and finding it by name there
what is the rationale behind that?
its not obfuscated
as some compilers don't use the same syntax
and the class could be relocated
and hardcoding entire class names in strings is bad news bears
I recently saw people making custom blocks through barriers. How can this be repeated? I already use one method related to note blocks, but I find barriers to be more practical.
@stone sinew breaking blocks downwards means that you are checking the caps first and the stems last
coughs vioently
which is fine
is only temporary
but its cursed
Which means this is the only thing left when it needs to plant the brown or red mushroom.
I know it's not a great solution, but. maybe just have the stems drop nothing? ๐ฆ
They don't drop they replant
oh.. well unless you really want to save every block broke (which sounds like a very cumbersome idea) I think you are stuck
hey? anyone?
My solution would be just to replant below leaves, but it is inefficient at times
also, if you are doing it top-to-bottom, you are doing it 1 mushroom at a time as far as the y axis is concerned
so the x/z solution will work as well
You could always put some meta on the bottom block when you start chopping
In my latest test I'm running the lumberjack through 50x132x50 region... to test for speed/performance.... imagine if all of those were mushroom blocks.... I can't check each of those blocks for a stem underneath then saving those to memory (memory leak) then checking that map for the location and material of that stem.
mushroom blocks aren't tile entities, no meta for you
that's not what a memory leak is
and also yes, you can
can't you just store it in a x, y, z, boolean record?
Blocks have MetaData. not PDC though
tell that to people running servers with less then 4gb
spigot just died. No jd
does it actually respect stuff like pistons/explosions/whatever, or is it just a glorified Block -> data map
4gb is an enermous amount of memory
treemaps are highly space efficient, moreso than regular hashmaps
Even then, you could probably store around 12.5k instances per MB
(assuming 80 bytes per entry - which is quite a lot)
I have a single lumberjack with its region/radius set to 50. Imagine an 800+ player server with just 1 each lumberjack... thats over 1m blocks that you expect to be saved to memory???
Permenently or not thats a shit ton of blocks on memory... keep in mind thats over 1m blocks per lumberjack
only 80 Mb (assuming 80 bytes per entry)
and not all of those 1m blocks will be mushroom blocks
and yeah, even so, insignificant memory wise
you underestimate the size of a gigabyte
a gigabyte is absolutely a fucking enermous amount of space
Tell that to my docker daemon
Also with an actual 800+ player server, I would hope they got more than 4GB of memory lol.
I overestimate the users lol I expect them to have High radius's high speed of the lumberjack, multiple lumberjacks per player etc...
weird suggestion, but instead of storing data you could maybe tweak the stem block data. Like vanilla sets EWNS, maybe for red stems you set up as well
tell that to pretty much everything
also with an 800 player server with everybody cutting down 1 million fucking blocks concurrently the CPU will die way before you run into memory issues
no idea if that'll do something weird or make them render in a broken way though ๐
most wouldn't touch the config if anything
would still have to be done on every stem block which is what the initial convo was about and what I didn't want to do
thats one of the issues xD
True, but you could do it on structure grow event I guess
just catch them growing and tag the stems ๐คทโโ๏ธ
Then I have to check each lumberjack to see if its within the radius
CPU is not
And.... whats is used to check if the map contains the data?
I just mean tag every mushroom tree stem as it grows to know if it's red/brown
what's that supposed to mean
I'm not like completely following but if that's the part you're trying to get back, that might work
treemap has the data stored at an easily computable spot
I think, lemme check
that data would also have to be saved... which if not removed could cause memory leaks.. also would fail if the server restarts
yes, you would have to persist the data while cutting things down
you can set the block state flags, there are directional flags for mushroom blocks
but that in no way differs from what you have to do now
saying which faces are visible
Only O(log n), not too bad
NESW for stems normally, I'll bet the bottom bit is never used (no real idea tho)
@eager sapphire ^^^
yeah, treemaps are logarithmic time complexity for most operations
as opposed to constant time for hashmaps
but the advantage is that they are sorted and have cheap next/pervious operations
Well it differs in that you don't have to store the data yourself in a separate map that you maybe have to persist (not sure if you care about coming back to a chunk after a server restart or something?)
but hashmaps are pretty expensive when they recompute the hashes
yeah, you would want to estimate the initial size properly for a hashmap
I only want to touch blocks in the lumberjacks region... so if I use structure grow event (Which doesn't work in 1.13 on mushrooms) i would have to loop through all lumberjacks and check their regions and thats even more calculation then what I'm doing now.
anyway, yeah, if you're truly doing it top to bottom, use a simple x/z map
if you're doing it in a more complicated fashion, nest a y treemap in the x/z map
possibly use a quadtree for the x/z map but a hashmap will suffice just fine as well
Is there a clean way to know if you're on the main thread (not inside of an async scheduler task)?
nice, thank you!
that is also doable
that's what I did iirc before that primary thread one was added
i'd like weakref the main thread in onenable and compare that to currentThread
Seems like that's more or less what Bukkit.isPrimaryThread does
myeah
and I will probably have to do it your way for old api support reasons ๐
you people should just stop pandering to ancient versions
I move to 1.16.5 and lose access to seeing which mushroom a stem is from ๐
I get real nervous when someone with a Hitler avatar starts throwing around "you people" ๐
TOTALEN KRIEG
but the sunglasses!
how i can set inventory location when it creating?
is there like a chance somone got spring data jpa to work with there plugin, would help me a lot if there is a sample plugin with it. I really need it to speed up my development
Can someone test if config.getString with a default returns the right value? seems its always returning the default
might be a bug with 1.17
Works fine. Nothing changed with snake
strange for some reason
it takes the default everytime
i removed it and it took the value right
int size = elements.size();
List<ItemStack> items = new ArrayList<>();
for (int i = 0; i < size; i++) {
items.set(i, elements.get(i).getItemStack());
}
this.contentPacket.getItemListModifier().write(0,
items);
am i dumb or what but for some reason this throws out of bounds error for items arraylist (ArrayOutOfBoundsException)
any ideas?
Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
How can it be outofbounds
when im literally using arraylist
which grows
wtf
You can;t set an item in the list that is empty
set
interesting
ah, I know why
meaning once created should have a size of 0
yes, if your items List is empty you can;t randomly set(0)
not 1
yea, use add instead
Intellij keeps eating my disc usage even tho it's doing nothing
Does that happen with you guys?
it doesnt grow
ther is no value to overwrite
?
i have been coding for a year
and still didnt knew
this was a thing
how pathetic i am
its a thing you usually dont care about
there are cases never met or discussed for everyone
now you know๐
Disc usage?
Disk Usage
You could just put elements in the newArrayLIst() and it will be inserted. you can then loop your list
not sure why you are transfering to a List
what is an event for when an entity moves
Hard Drive Usage, however it's called in english
dont think there is one
It's always on 10mb/s no matter what
with reason also..
Just wanted to make sure since usually it is the memory that is the issue with intelliJ
how can i add a particle trail to an arrow
haven't seen anyone complain about the FIO of IntelliJ
run a task that every tick places a particle
i would go with velocity as canceller
cancel the runnable when velocity hits 0(arrow stopped in something)
or it dissapeared(hit a entity)
just cancel it in the hit event
arrow already disappears on projectile hit
then just check ifthe arrow is null
what if i preset the capacity of arraylist
doesnt it
preload arraylist
with nonsense data
should work
if theres no arrow cancel the task
an ArrayList has no capacity
call the task from onshootbowevent
Arrays do
Why are you copy from an array to a list?
You can just List<ItemStack> items = Arrays.asList(elements);
it does have initialcapacity
not fixed one
ofc
data is nested inside another object
new ArrayList<Integer>(10); ?
Yes, it has a default of 10, but it contains no actual data, no elements to reference. The capacity is just a measure of when it needs to be expanded
not even null
ah yeah nvm
create a new List and try to access the 10th element
the capcity is the size of the underlying array
^
However arraylist does not allow to set values beyond the first empty spot
Yep, you have to fill it at creation or add.
Is there a good tutorial for making random chest loot?
Like skywars, hunger games, ect.
i don't get it why java doesn't allow method static fields
like in c we have both global per translation unit variables and local variables
which are static
Hello guys, I have issue that when I perform command /arena set <name>, nothing change in arenas.yml file (the file is reloaded), what am I doing wrong?
Code: https://paste.helpch.at/buragokofe.java
why are creating new file object every save?
sorry im too busy right now to debug your code
maybe someone who can help will help to you
Does anyone have a good tutorial 4 that
declaring static fields within a method scope?
That would wreck havoc
well in C langs it doesnt
its basically within function encapsulated global static field
which is only accessible within the function scope
I guess the compiler could just knock it out into a class scope as a synthetic field
But that is too much synthetic sugar for me, I would prefer my goto statements over that
You call getArenaConfig() in yoru saveArenaConfig() which gets a new copy of the yaml file.
wipes out anything in memory
@eternal oxide do u have a link to a tutorial that could help me
is it normal that on the interact event, the when I left click it counts as a right click?
two hands
okay I am really confused now xd What part of create new file?
what do you mean @eternal oxide ?
so e.getHand()?
and if it's left it's a right click? x/
Hey, quick question: I already had a problem earlier when I programmed a villager whose custom name corresponds to the display name of the book when you click on it with a written book in your hand. Unfortunately, as I said, this gave me an error, with which unfortunately several people have not yet been able to help me. So I wanted to ask whether it is possible to right-click on a villager to bring up a sign on which you can write something and what you write on it becomes the custom name of the villager. Does anyone know how to do that? Thanks in advance
I dont think you can open a sign in code easy, maybe with protlib.
I think the sign menu is client side
you can for sure do it in chat
Yes ever since the off hand became a thing, you have to weed out what click it was.
if (event.getHand() != EquipmentSlot.HAND)
return;
OK. So there is really no way to do it in any other way using a display name, book pages, etc.?
its possible through all the ways the problem is how advanced are you when it comes to nsm
That is why i said maybe with protlib.
ok but i'm not using the offhand tho
Doesn't matter the game thinks you are.
yea the event is called 2 times
^
okay but I added that
if(e.getHand() != EquipmentSlot.HAND)
return;
still doesn't work
and + it never detects a right click
only the left one
would be better if you show us your code
^
{
e.setCancelled(true);
if(e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR)
{
if(e.getHand() != EquipmentSlot.HAND)
return;
player.sendMessage(String.valueOf(e.getAction() + "SCORE: " + ce.getFishingData().getScore()));
if(ce.getFishingData().getCursor().getLoc() > 0){
ce.getFishingData().getCursor().setLoc(ce.getFishingData().getCursor().getLoc()-1);
}
player.sendMessage(String.valueOf(ce.getFishingData().getCursor().getLoc()));
}```
cause you aonly check for left click only
na
bruh
LEFT_CLICK_BLOCK || LEFT_CLICK_AIR
I check for right too
thats left click...
no you dont
yes i do
that would be RIGHT_CLICK_AIR ...
^
if(e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR)
this if statment is saying left click only
{
e.setCancelled(true);
if(e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR)
{
if(e.getHand() != EquipmentSlot.HAND)
return;
player.sendMessage(String.valueOf(e.getAction() + "SCORE: " + ce.getFishingData().getScore()));
if(ce.getFishingData().getCursor().getLoc() > 0){
ce.getFishingData().getCursor().setLoc(ce.getFishingData().getCursor().getLoc()-1);
}
player.sendMessage(String.valueOf(ce.getFishingData().getCursor().getLoc()));
}
if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR)
{
player.sendMessage(String.valueOf(e.getAction() + "SCORE: " + ce.getFishingData().getScore()));
if(ce.getFishingData().getCursor().getLoc() <ce.getTotalLength()){
ce.getFishingData().getCursor().setLoc(ce.getFishingData().getCursor().getLoc()+1);
}
player.sendMessage(String.valueOf(ce.getFishingData().getCursor().getLoc()));
}```
didn't wanna send the whole thing cuz its kinda useless
ok
-.-
else if maybe ?
you want to move the hand check before any of that
probley the first check you do
also do you get any errors?
I do not
there is no issue except that the right click is somehow replaced with a left one
else if might help with that
exactly
and also would be better for the proformace with a else if
dont think so
wouldn't change anything
its faster
with a else if it does the validation once where 2 if does the check 2 times
but that is back to me saying it all adds up and cause lag time in the code.
try to just debug it
o.o
so do this
do the hand check before the is fishing check
and make the right click a else if
and see what it does
if(ce.getFishingData().isFishing())
{
e.setCancelled(true);
if(e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_AIR)
{
if(e.getHand() != EquipmentSlot.HAND) {
return;
}
player.sendMessage("Left click");
player.sendMessage(String.valueOf(e.getAction() + "SCORE: " + ce.getFishingData().getScore()));
if(ce.getFishingData().getCursor().getLoc() > 0){
ce.getFishingData().getCursor().setLoc(ce.getFishingData().getCursor().getLoc()-1);
}
player.sendMessage(String.valueOf(ce.getFishingData().getCursor().getLoc()));
}
if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR)
{
if(e.getHand() != EquipmentSlot.HAND) {
return;
}
player.sendMessage("Right click");
player.sendMessage(String.valueOf(e.getAction() + "SCORE: " + ce.getFishingData().getScore()));
if(ce.getFishingData().getCursor().getLoc() <ce.getTotalLength()){
ce.getFishingData().getCursor().setLoc(ce.getFishingData().getCursor().getLoc()+1);
}
player.sendMessage(String.valueOf(ce.getFishingData().getCursor().getLoc()));
}
now you are doing more work in the if statments lol
I just copied his code
else if also validates the boolean expression?
i'm a cool kid now
yes but when you have a if else if it checks all the validation at once with if and if it takes longer cause you are doing the work aprat from each other
its faster in the end with else if
so
didn't change a thing, still detects a left click
wth
source?
cause its an enum
wait
enum are numbers
enums should always be checked with ==
you just see the value in the IDE but in running code ints 1,2,3,4
idk where's the issue
...
.equals() litterally returns an ==
if u go into the method
but == is nullsafe
gotcha
.equals is not
ah yea
Short for enumeration, an enum variable type can be found in C (ANSI, not the original K&R), C++ and C#. The idea is that instead of using an int to represent a set of values, a type with a restricted set of values is used instead.
The idea is that instead of using an int to represent a set of values
enum are int when its running the code on the client level
the IDE shows the value as set value
i swear no knows programming 101
you use == for enums, because == checks if the checked enum is the same adress in the heap or not
lol k
stupid question i have to ask, you are right clicking on the mouse right?
i have seen some werid things in my time coding and support lol
and there still could be an issue in an other part of his code
i mean we can change it from If to a switch to clean it up a bit, but it looks ok
yes
can you paste the whole method or event (w/e its called in here ๐ ) ?
when you right click, it tells you left-click in the chat?
well it does
u know what
you do realize they're coding in Java, right?
no need to be a dick
ya ๐ณ
uh yea
@gaunt hatch I might know wheres the issue
because mc calls events by hand animations
and when you right click the rod
it looks like left click
nope
ye no
the same issue is when you drop an item
we're not in packets
I am not talking about packets
ye
thats in the interact event
i am adding to me code to see
- when i click a block it works normally
Interact event does fire twice once for each hand
the interaction event is not called when a hand animation is made
the interaction event is called when an interaction is being made
it only calls left *
i did.
make a listener
Represents an event that is called when a player interacts with an object or air, potentially fired once for each hand. The hand can be determined using getHand().
i do not like this
FishingTask.runningTasks.containsKey(player.getUniqueId()
why do you still talk about 2 hands?
Access the list from outside of a control state is BAD!!
we already return it
was more pointing to Represents an event that is called when a player interacts with an object or air,
I am telling you that when you even drop an item, it calls the interact event for left-click-air
MC receives client packet information regarding PacketPlayInArmAnimation to carry out your PlayerInteractEvent
dont worry i dont use it except when the server stops to cancel them :)<
still building method to add,get,check,remove and keeping the list object private and final is way safer
ill double check that for you
what version btw
mhm i don't really know how that would change anything here
is this for fishing?
?
Is this event when a player pulls when they catch a fish?
4
no its player interact event
@vivid lion
when is it used?
weird cuz when i right click on the block it doesnt trigger the interact event but still does the animation
ye ill try in 1.16
however I just sent a vid from 1.16
and ill let you know
bruh I just sent you a video o.o
never trust people on the internet
xDD
seems like i were wrong FOR THE NEWER VERSIONS
I am going to sleep, cya
cya
you will have a nightmare
oh no notyou
Hi guys, when I call saveArenaConfig method, it create new file instead of saving actual one. Can somebody explain my why please? My head is not getting it - https://paste.helpch.at/nefesebodu.java
your save method does nothing
the first thing it does is loads the config from the disk
^^
then it immediately saves that same, unchanged config back to the disk
nothing happens
Its possible return a type of object in java ? I mean boolean, string, int indtead of check the object value
wat
return yourType?
Yeah, I set the value to something different in onCommand method and then I call saveArenaConfig method, what just create new config but I don't understand why, in all threads I see FileConfiguration#set & FileConfiguration#save what am I doing (https://www.spigotmc.org/threads/how-to-save-to-custom-config-file.350288/ for example)
yes, again, you are not doing anything
let me reiterate; the first thing your save method does is loads the config
the config on the disk will not have any of the changes you made with FileConfiguration#set
it will be blank
the blank configuration is loaded
and then saved back to disk
you call getArenaConfig(), which is
return YamlConfiguration.loadConfiguration(getArenaFile());
notice the loadConfiguration
It is possible to return the object type without making a condition to check its type in java
public void saveArenaConfig() {
try {
getArenaConfig().save(YamlConfiguration.loadConfiguration(getArenaFile()));
} catch (IOException e) {
e.printStackTrace();
}
}
this is what you code does
it first loads the blank config from disk, and then saves that blank config back to disk
it doesn't actually do anything
I want to create a hashmap where I can accept values โโof type int and boolean without creating several for each type of value.
oh
no, you can not have a map that takes both ints and booleans
or, well, you "can", by having a Map<K, Object>, and then checking instanceof and casting the Object to either Integer or Boolean
but that is gay and you shouldn't do that, nor should you have any need to do that
not some smart java tool that does that
Why gay
design your shit so that you don't need to hold both integers and booleans in the same place
type safety is a thing for a reason
@lean osprey
fix it to be better now
but heres a solution
public class PlayerInteractListener implements Listener {
private final Map<UUID, ItemStack> drop = new HashMap<>();
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p;
e.setCancelled(drop.containsKey((p = e.getPlayer()).getUniqueId()));
Bukkit.broadcastMessage(String.valueOf(e.isCancelled()));
drop.remove(p.getUniqueId());
}
@EventHandler
public void onDrop(PlayerDropItemEvent e) {
Player p;
drop.put((p = e.getPlayer()).getUniqueId(),p.getInventory().getItemInMainHand());
}
@EventHandler
public void onQuit(PlayerQuitEvent e) {
drop.remove(e.getPlayer().getUniqueId());
}
}
i think it was @quaint mantles thing
drop.put((p = e.getPlayer()).getUniqueId(),p.getInventory().getItemInMainHand());
what
probably want to get the dropped item from the event
as the player can drop items from other slots than the main hand slot
and there is no guarantee the item is in the main hand slot anymore
thats why i said fix it XD
also it should work with ignoreCancelled
and what the shit is up with these assignments
but this is a temp solution to his problem
.containsKey((p = e.getPlayer()).getUniqueId()));
bcs the left click is a cancelled event
why do you repeatedly do this
whats wrong lol
just Player p = e.getPlayer()
it should be able to work from what i see in your vid
but let me readjust this code
to be better rq
go to your bathroom, there you have 1
I m really not getting it lol, then how? I thought that its getArenaConfig().save(FILE) then but it's not working too (sorry im stupid)
File customFile = new File(plugin.getDataFolder(), "arenas.yml");
FileConfiguration customConfig = YamlConfiguration.loadConfiguration(customFile);
try {
customConfig.save(customFile);```
you are loading the config and then saving the loaded config
you aren't changing anything
its like
hey, gimme my data.
thanks.
now save it unchanged again.
thanks
imagine the disk is a shop
you go to the shop to buy some coca cola
now, once you have your bottle of coke
you immediately return it back to the shop
without doing anything with it
why are you still thirsty?
im thirsty but i dont know how to get bottle of coca cola ๐
you need to hold onto the bottle of coke that you get
right now you are either getting it and throwing it away, or getting it and putting it back immediately
you need a field in this class that holds the coke bottle
private YamlConfiguration config;
make getCustomConfig return that config
make it return that coke bottle that you have
instead of getting a new one from the shop each time
I don't really know how to get that bottle https://paste.helpch.at/dipumiseno.cpp
rip coca cola
YamlConfiguration.loadConfiguration(getCustomFile()) gets the bottle from the shop
getCustomConfig().save(getCustomFile()) takes it back to the shop
now, since you want to drink it, you will want to put it in the fridge in between
so, you have 3 operations that you want to do
#1 get the bottle from the shop, put it in the fridge
#2 take the bottle from the fridge when you want a drink
#3 once you're done with the bottle, take it back to the shop
#1 -> customConfig = YamlConfiguration.loadConfiguration(getCustomFile());
#2 -> a method that does nothing else than return customConfig;
#3 -> getCustomConfig().save(getCustomFile());
private YamlConfiguration customConfig; //this is our fridge, the coke bottle will be put here
private File customFile;
public File getCustomFile() {
this.customFile = new File(plugin.getDataFolder(), "arenas.yml");
return customFile;
}
public YamlConfiguration getCustomConfig() { //take the bottle out of the fridge
return customConfig;
}
public void loadCustomConfig() { //get the bottle from the shop, put it in the fridge
this.customConfig = YamlConfiguration.loadConfiguration(getCustomFile());
}
public void saveCustomConfig() { //return the bottle to the shop
try {
getCustomConfig().save(getCustomFile());
} catch (IOException e) {
e.printStackTrace();
}
}
Oh my god
It's working and I get it finally
Thank you Mr. NNYaKNpGms0eUVpiSdHx
Thank you for cocacola bottle ๐
How do u make text bold and color like for example. lore.add(ChatColor.GOLD + โLegendaryโ) how would i make it also bold
ChatColor.GOLD + "" + ChatColor.BOLD I think (maybe, not sure) or just use ยง
how can i use java player.discoverRecipe(); With a custom recipe
the NamespacedKey...?
or .toString
I'm curious: because I use Linux, is there any reason at all to use a development environment to make a plugin?
I mean, Linux IS a dev environment, so idk why I would use eclipse or something else
Linux isnt an IDE.
IDE != DE
No it isn't, but everything is integrated
You need an IDE and compiler to make plugins.
^
Youโre telling me your linux comes with an IDE and compiler?
So what, writing code in a file doesn't work anymore?
Java code needs to be compiled in order for the jvm to run it
Yes
For that you need what is called a Java compiler
yes, write java code in a txt file
It also needs the correct formatting
Kali comes with java pre-installed
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-post-Debian-1)
OpenJDK 64-Bit Server VM (build 11.0.11+9-post-Debian-1, mixed mode, sharing)
Probably no IDE though
with wordpad
Yes I can compile Java from terminal
I mean, what is jdk for?
java development kit
its basically the java standard lib
its for.. developing java programs
it's how you compile your java classes :3
I use jdk as the runtime not gonna lie
Same lol
Okay well, that aside, I'm not sure where to start. I've tried before to write a plugin, but either the documentation is outdated or it's just something I'm not getting.
Anyone wanna help me test out my plugin on 1.17?
Depends which documentation you're using. And how you're doing it
The documentation on the Spigot website
Oh yeah some of that stuff is outdated
I think it's because, back when I tried to follow it, nothing linked right so it would never compile and I thought it was my fault for doing something wrong
I'm not formally educated in development, but as long as I get the basics down where I can compile a hello world example, everything from there is fine
So if the Spigot docs are outdated, where should I be looking instead?
my butt
wht is namespaceKey
?jd
Look it up in the documentation m8
Pay attention to the conversation, m8
The conversation is all over the place ๐
Javadocs are up to date
Some wiki pages are not up to date but worth checking out
Some forum threads are very old so check the date
how did you make your custom recipe then
ItemStack pickaxe = new ItemStack(itemManager.smallPickaxe);
ShapedRecipe pickaxe1 = new ShapedRecipe(pickaxe);
pickaxe1.shape("ddd", "aea", "ddd");
pickaxe1.setIngredient('d', Material.DIAMOND_BLOCK);
pickaxe1.setIngredient('a', Material.NETHERITE_PICKAXE);
pickaxe1.setIngredient('e', Material.NETHERITE_BLOCK);
getServer().addRecipe(pickaxe1);
``` I made them like this
literally deprecated
java.lang.NoClassDefFoundError: me/clip/placeholderapi/external/EZPlaceholderHook
huh?
my friend showed me this how make recipes and it works... i just want to make it show in the recipe book
any help?
hello?
what?
user preference, i use intellij and vscode
Ultimate
For web and enterprise development
Community
For JVM and Android development
best?
its what ever you want to use
idk
java.lang.NoClassDefFoundError: me/clip/placeholderapi/external/EZPlaceholderHook btw you know how to fix?
nope i only started java and plugin dev 2 days ago
oh ok
oh no
also do u use the most recent version of papi?
This wiki page is no longer maintained, please visit the GitHub page for an up to date version.
yea i have it
may I ask what you're doing exactly
Error occurred while enabling NetworkLevels v2.7 (Is it up to date?)
java.lang.NoClassDefFoundError: me/clip/placeholderapi/external/EZPlaceholderHook
only the problem
NetworkLevels is using a legacy version of PlaceholderAPI
ask the developer if they can update it
I've created a custom configuration file and I have been trying to save the default but I get this error: https://paste.md-5.net/modecocexu.css
This is the code I've tried to use:
public void saveDefaultConfig() {
if (this.getMessageConfig() == null) {
file = new File(Bukkit.getServer().getPluginManager().getPlugin("OITC").getDataFolder(), "messages.yml");
}
if (!file.exists()) {
Bukkit.getServer().getPluginManager().getPlugin("OITC").saveResource("messages.yml", false);
}
}```
what is at line 21?
this.messageConfigManager.saveDefaultConfig();
seems like messageConfigManager is null
ait I fixed that, it's not null anymore and does not print any error
but it still doesnt save the default
I've put stuff in the messages.yml fie in my ide and none of it is in the yml file
My custom economy is returning null to other plugins
public double getBalance(OfflinePlayer offlinePlayer) {
Bukkit.broadcastMessage("OFFLINE_PLAYER#22");
map.put(offlinePlayer, PlayerData.getIntOF2(offlinePlayer, "Coins"));
Double i = map.get(offlinePlayer);
Bukkit.broadcastMessage("Double: " + i);
return i;
}
null is not 0
i meant null my bad
maybe because you r creating a new messages.yml file ๐ค
Your system doesn't have requirements to run JavaScript expressions
wat
Your system doesn't have requirements to run JavaScript expressions
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
@hot gull โฌ๏ธ
the plugin cant load because i dont have that
and idk why its say
LMAO
bump
Guys, do u know if there's a plugin that allows to change the normal exp given on breaking any type of block? I found some plugins that allow that but only with ores... ty
This is the place where you make your own plugin for it
I really don't know where can I ask it... but if i don't found anything I should make it myself
how do i add a custom recipe to players' recipe books
Bukkit.getServer().addRecipe(Recipe)
i mean add the recipe to their recipebooks not the server
like the green one you click
ty
any easy way to get a chatcolor from a string? like take the argument command "blue" and convert to ChatColor.BLUE?
ChatColor.valueOf
thanks
What code would I use to set the loottable of a chest that has been opend
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
Block b = e.getClickedBlock();
if (b.getType() == Material.CHEST) {
}
}```
Is what I have
Get the state and cast to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/loot/Lootable.html
And I need to switch the loot table to random loot
Any know why npc's always look south on spawn?
doesn't work
hm
i have that set in the contrustior of the npc
setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
i thought it was PacketPlayOutEntityHeadRotation but that didnt work
ahhhh
I just wanna know how to make chests spawn with random loot
And some of the Javadocs are confusing me
Any ideas on hooking into the Mojang structure system?
I'd rather avoid a custom jar, but ASM seems like a headache as well
noob question : how do I store a string from args 1 and on
String t = args[WHAT DO I PUT HERE];
the index
?
What?
What does Level Height Accessor do and what should I set it too?
It's a new thing in 1.17, 1.16 does not have it
Passing a world should work fine
Noob question but why do I have to use BuildTools instead of download a spigot jar from the bukkit website?
the world variable only has private access, so I am unable to.
Rehosting Mincraft code is illegal
dont i need a symbol?
no?
like form anything arg 1 and on
no?
Welcome to NMS, enjoy the reflection
๐ฑ
And then you will find a private static final variable
And become sad that you can't change it
idk how else to explain
I think I may of figured it out, thanks for your help
it's the net.minecraft.server package so u can fuck with packets and stuff
๐คท๐พโโ๏ธ
what I dont understand is, how does buildtools solve the problem
yea how is that diff from downloading sth that already has its shit put tgt
cuz the shit thatโs put together has minecraft code in it
so if you distribute that
u distribute my
mc
which is the problem
but cloning the code locally not considered distribution?
well itโs downloading the minecraft server from mojang
and itโs cloning the patches from spigot
and then puts it all together and spits out a patched jar
so no
no distributing mojang code
noob question, so if I upload this jar that it spits out, it is illegal?
oh ok I understand that
Anyone able to help me with "The project cannot be built until build path errors are resolved" in eclipse? ive tried everything on stack overslow but I just cant get it. Happening with trying to use java 16
what do you mean
like read the contents that are going to the console
catch System.out
ive tried
I got that with an easy google search
I think Iโve discovered code cursed enough to get past my little reflections issue
Make sure you actually have Java 16 installed and it's pointed to in your preferences (See Preferences -> Installed JREs)
The power of the unsafe class
So I have a List of Entity and I wanted to check if there is no Player inside the List, how can I do that?
All I can think is something like this
int players = 0;
for(Entity entity : nearbyEntities){
if(entity instanceof Player){
players++;
}
}
if(players == 0){
// Means the list doesn't have any player
}
Start with a false Boolean
As soon as you find a player, set it to true and then break;
No reason to keep looking unless you want the number of players in the list
why does worldDataServer.getGeneratorSettings() return null?
On previous versions, such as 1.16 it does not.
I am importing net.minecraft.world.level.levelgen.GeneratorSettings
Goodness what are you doing with all this NMs
why do NMS on 1.16 and not use mojang mappings is the real question
I would prefer to not use nms, but I'm updating a plugin that uses it.
What plugin
slime world manager
I see
some of the issues make almost no sense, because the code from 1.16 is nearly identical to 1.17
this isnt what i wanted
anyone know what this does? (Specifically what are level data, nbt, and craft magic numbers) extraTag.hasKeyOfType("LevelData", CraftMagicNumbers.NBT.TAG_COMPOUND)
if (nearbyEntities.stream().anyMatch(e -> e instanceof Player))
{
// There is a player in the list.
}```
anybody know of this plugin
where you have like a hub/server star
that gives u access to many things
i have seen it on different servers so it cant be custom made
why can't I cast the bukkit chunk generator to the nms chunk generator?
then how can I get the chunk generator? The getChunkProvider().getChunkGenerator() method has been removed in 1.17.
so nobody know the plguin I showed above? ๐ฆ
Itโs something like .d() now
Static getHandlerList method required!
?paste
anyone here know the difference between javax.vecmath.matrix4f vs just matrix4f? Is there one that's more optimal than the other?
how would I go about obtaining the block xz coordinates from given chunk xz coordinates?
i bitshifted the chunk coordinates to the left by 4, but that doesn't seem to line up with the right block coordinates
Descripe the Plugin better
Can anyone help me with this? Trying to fix an issue with GriefPrevention, and for that, I need to add Material.GLOW_ITEM_FRAME in the PlayerEventHandler. I did that (without adding an import statement which I think is where my mistake is), and changed the dependency in the screenshot below, but its giving me an error. I know I'm doing something wrong
compiled remapped buildtools
ah, so I'll run buildtools with --remapped
Hey Guys , i think im obviosly too dumb for creating a config file and the wiki page doesnt helps me much ,could someone explain me in an easier way how i do that ? Thanks
Yep that worked thank you! I also had to remove the classifier from the dependency
Hi guys! I'm trying to send complex chat messages using BaseComponents, but I'm having some weird issues with it. When ever I run the command to see the message it works fine, but when my friend runs the command it doesnt send anything in his chat. The server is running Tunity 1.16.5, I am using fabric 1.16.5, and he is using Lunar 1.16.5. The client shouldn't make a difference but it works for him when he uses a vanilla client. Am I doing something wrong or is it just a lunar bug? This is the code for my chat message.
ComponentBuilder message = new ComponentBuilder().append("ยง7[ยง9DiscordVerificationยง7] ");
// Clickable and Hoverable code
{
TextComponent code = new TextComponent(encoded);
code.setColor(ChatColor.AQUA);
code.setUnderlined(true);
Text codeHover = new Text(ChatColor.translateAlternateColorCodes('&',
"&7Click to copy &b " + encoded + " &7to clipboard!"
));
code.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, codeHover));
code.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, encoded));
message.append(code);
}
p.spigot().sendMessage(ChatMessageType.CHAT, message.create());
System.out.println(p.getDisplayName() + " | " + encoded);```
I've already got a problem with lunar client
So I think that the problem is lunar
does anyone happen to know off the top of their minds if I make a feature for the worldedit API whether it will automatically work with FAWE?
ok so if all I want to do is import a schematic and paste it and nothing else it should be fine?
Yeah
thanks
is https://www.spigotmc.org/wiki/spigot-plugin-development/ a decent enough place to start learning about plugins?
DeluxeHub
Do you have any previous experience with Java?
A passing impression of it, but I'm confident I can pick it up fairly quickly based on the C# Ive done
C# is quite simillar however we do follow different naming conventions, not that it affects anything important
Well that wiki page should be enough
alrighty
afaict, the normal whitelist command will look up a player's current name through mojang's api to find their uuid
Is there a bukkit api function that behaves the same way?
https://www.spigotmc.org/threads/get-uuid-from-name-of-offline-player.156098/ seems to imply server.getOfflinePlayer wont ask mojang's api, which is less useful for a whitelist where it'll nearly only ever be used for players who haven't joined before
getOfflinePlayer will not query mojang's api if you are querying by UUID
if you are querying by name, it will first check the local cache and return the user from there if found, or query mojang for it
The command syntax is /whitelist add <Player Name> so I need to be able to query by name
Great!
Thats perfect then, ty
which is network IO and should not be done on the main thread
well, the issue with it is that it takes time, since it has to grab a server from across the globe and communicate with it
if you call the method on the main thread, the main thread will have to wait for that communication to complete
Yup, I understand ๐ I'd assumed bukkit would do it internally
my point is that even if it did it internally, it would still be an issue
since it returns the plain OfflinePlayer object
the method cannot return before it has something to return
for it to have something to return, the communication has to happen
Right. Does Java use explicit promise style concurrency?
that'd be Futures
Nice, okay. If I wanted to write a function that looked up the name off the main thread (and encapsulate it), I'd use Futures, right?
you could do that, or you could move all of your logic off the main thread, depending on how much of the bukkit api you're using
I think it's just this query. Im only planning on writing a thin command wrapper over bukkit's whitelist api
Is there a way to tell which commands might block for a while in the api docs?
nnot really
and if you actually block the command execution, the whole main thread will be blocking on it too, as commands run on the main thread
you'll want to do whatever you can do immediately in the command executor, then rig up the futures or scheduling you need for the query, and then return immediately
and then either continue asynchronously on a separate thread, or resume on the main thread once you've completed the query
What's the idiomatic way to schedule a future in spigot?
with futures, you can use CompletableFuture.supplyAsync or whatever
depending on how much you need to hop off and back onto the main thread though, futures may not be the best option
getting the whole arsenal provided by futures to work with bukkit properly is kind of difficult
as bukkit wants you to be on the main thread if you invoke most of its api methods
and futures don't have a good and simple way of telling something to execute on a specific thread
How silly would it be to store some persistent data in my config file that isn't actually config related?
all comments get nuked levels of silly
Like, I have a single boolean flag that I want for my mod to manage. Just one. It seems like the most efficient way of handling this is writing a file
but ... I've already got a config file. It seems like the server administrators will interact with it in essentially the same way
the issue with writing data to a config file is that each time you write to it, all of the formatting and comments and everything other than the raw data in the config file are nuked
which means that you can't have comments in your config, the end user can't comment-out parts of the config, the formatting will be ass, and so on
write it to a separate config file
ah. hm. okay, you're right
Could someone help so i can fully understand this:
private void drawCircle(Location loc, float radius, Player p) {
for (double t = 0; t < 50; t += 0.5) {
float x = radius * (float) Math.sin(t);
float z = radius * (float) Math.cos(t);
loc.getWorld().spawnParticle(Particle.REDSTONE,
new Location(loc.getWorld(), loc.getX() + x, loc.getY() + 0.5, loc.getZ() + z), 1,
new Particle.DustOptions(Color.PURPLE, 1));
}
}
Like Ik that sin gets the y and cos gets the x
but i dont rlly understand how its used to create a circle like that, like i have an idea, but not fully.
I dont understand why the double t is used for the cos and sin since I know that you take degrees to cos or sin and multiply it with hypothenus to calculate the x or y trajectory in math.
Can I see what the block was generated or placed by the player?
I think that you can also make a for loop to 0 at 360, with an increment of 0.1 (angle theta) for exemple, and so
x = rcos(theta)
y = rsin(theta)
Okay but like Id want to understand the code, as I can understand the place where I copied it was wrong, cuz x goes with cos and z goes with sin
Did someone know how exactly how this works? (backpack cosmetics)
https://www.spigotmc.org/attachments/upload_2021-3-29_23-55-52-png.607051/
https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-intellij-idea/
This mentions I need "SpigotAPI". Where do I download that?
by running buildtools
Where will it be output?
"SpigotAPI" has a link behind it: https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/
You get the .jar from the versions that are listed on the site.
However, are you familiar with Gradle or Maven?
If you run BuildTools the SpigotAPI jar gets copied into your local maven repository
Im not, but Im not following the IDEA Maven guide
oh that apache-maven-3.6.0 thing?
no it get's put at C:\Users\<username>\.m2\repository\org\spigotmc\
however there is no real difference from doing that to getting it from the online maven: https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/
Right, I'm just not sure how to point idea at that page
Well you would when using Maven :)
However if you really are following that guide that does not use maven or gradle, I think it's telling you to download the .jar files from the link I sent
however, I really recommend using maven or gradle
Alright, I have the maven tutorial working
How do I make my plugin non-legacy?
oic
unless you compile craftbukkit to it
๐ค I thought Spigot was a "fork" of CraftBukkit?
they include bukkit in the official jar but not craftbukkit
if u run --compile craftbukkit (not 100% sure) it'll compile craftbukkit to ur local maven repo
so u can use it
used for nms stuff
Hey, does anyone know how I can use custom skulls from the Custom heads site? I found a little bit on the internet but it was always a bit older and didn't work.
Sure - what website
Anyone got a good version checker that checks the minor versions?
package red.frost.Whitelist;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
class WelcomeCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 1) {
Bukkit.getOfflinePlayer(args[0]).setWhitelisted(true);
return true;
} else {
return false;
}
}
}
public class Whitelist extends JavaPlugin {
@Override
public void onEnable() {
this.getCommand("welcome").setExecutor(new WelcomeCommand());
}
}
```Wonderful ๐ any style tips?
I can recommend always returning true and adding your own error messages
Validate the returned Offline Player or you may be whitelisting an unkown/fake player
this works for newer version where the material is PLAYER_HEAD
try matching material with name, if not found, get a SKULL and set dura to 1 iirc
{
"uuid": "7be8b622-36ae-3b79-b0c3-68b7f0ed32b6",
"name": "seifouhsriefgueriofgusedroifugseiruh"
}
```huh...
What happened there?
Is the UUID just made up on the spot by spigot?
If you getOfflinePlayer(name) and they are unknown/invalid, you still get an OfflinePlayer object returned. However their name will/should be null and they have a generated UUID. You MUST check if their name is null to know if they are a valid player.
how does bungee's ProxyServer#getPlayer behave when specifying a uuid of an offline player?
Alright, that helps ๐
thankyou!
ok than you, i will try this
Is there an easy way to get vanilla-style errors?
The "Unknown or incomplete blah blah"
prob just set it in your language YAML file and get the string from it
Im not sure how Id begin doing that ๐
Sure ๐
does brigadier have multi-lang support?
yes, its all client side
which is great if youre writing a vanilla command but its also super inflexible
https://github.com/lucko/commodore take a look at this
commodore doesnt handle any of the parsing, just the validation iirc
i tried using it once
how the hell does bungee tabcompletion work
i found an event, is that all i get?
what is the Property import?
com.mojang.authlib.properties.Property
GameProfile from there too
yep
that's weird, it should be included in spigot jar
it seems i was depending on the api
not the jar
๐คท
idk why
nice method tho
1.16.5 has those classes iirc?
thx, but I definitely didn't write that myself, i forgot whr i got that from lol
yea, even 1.17
you sure your artifactId for spigot dependency is spigot?๐
yea that's prob why
yeah it was
i was so confused cause all of the imports didn't look correct
whoops
๐คฃ
ghost ping?
ok np
How can I spawn invisible armor stand? I've tried to use armorStand.setInvisible(true); but the armor stand still visible.
They should both work afaik
honestly I don't know why the method exist
oh wow
But if yours didn't work - try solar's
OfflinePlayer player = Bukkit.getOfflinePlayer(playerName);
if (player.getName() != null) {
player.setWhitelisted(true);
return true;
}
```I'm finding that I can still use nonsense names with this check. Am I misunderstanding you?
oh and btw i put the armor stand in the player passenger
what spigot version? Its possible its changed but I doubt it
both doesn't work.
player passenger?
I'm using a spigot jar that I just build on --rev 1.17 and api-version: 1.16
Huuhhh it must be something else you are doing to it
yes, i'm trying to create backpack cosmetic
ohh
cool
@grand swan Hello, I need help. My paid resource has been under review for over a week. When will it be published? https://www.spigotmc.org/resources/staranimatedmenu-into-the-first-animated-menus-for-your-server.93035/
you are testing in online mode?