#help-development
1 messages · Page 647 of 1
Well yeah, but forget abt that lol.
lol
Probably startup
Idk how trying to create a world at shutdown would go
Probably wouldn’t go
true
this is how I usually do my commands. I only have main commands where it makes sense, and then anything fitting in those main commands are sub commands
https://github.com/frostalf/ServerTutorial/tree/master/ServerTutorial/src/main/java/pw/hwk/tutorial/commands
is it generally better to use color codes rather than ChatColor?
but magic values are fun 🙂
&6 means nothing, ChatColor.GOLD means something
ohh.
I'm not able to get NMS to work. I ran buildtools and copied the exact pom <plugin> and <dependency> the NMS tutorial showed, but when I put the dependency in my pom.xml, it compiles with an error telling me
Unresolved dependency: 'org.spigotmc:spigot:jar:1.12.2-R0.1-SNAPSHOT'
You ran buildtools for 1.12 I assume?
did you run buildtools?
On start can easily be done by a plugin and you can even roll back to a certain state if you saved it (even for the main world)
Remove the :jar: part
Lmao
🫙 moment
That seems to be a common issue lol
I was about to say, we communicating with emojis now?
It still spits out the same unresolved dependency error
I removed the : jar :
Unresolved dependency: 'org.spigotmc:spigot:jar:1.12.2-R0.1-SNAPSHOT'
Yeah you’re trying to use remapped
Doesn’t exist for 1.12
Remove <classifier>remapped-mojang</classifier>
And the entire special source plugin
Yeah most likely. depends on player count as well.
Thank you!
i think you'll be fine. you might have some hiccups along the way. mine runs fairly well.
less
6gb of ram, 2 cores. but I have like 30 people instead. I have my world size capped to help as well.
maybe not as many plugins as you, but there are a lot.
Plugin count doesn’t mean much
You could have 100 plugins that do basically nothing
Or 5 that are very heavy
?
Paper/spigot are apis
they are APIs
If you use the paper api you have to use a paper server
If you use the spigot api you can use spigot or paper
You can also use spigot plugins on paper server.
I tried unloading the gameworld, but its literally just not continuing beyond Bukkit.unloadWorld(worldName, false);
There are no players on the world
did you unload all the chunks?
^ you should do that first as well
Even then I believe unloadWorld may not be instant
Not sure
Like that?
World world = Bukkit.getWorld(worldName);
if (world == null) continue;
for (Chunk chunk : world.getLoadedChunks()) {
chunk.unload();
}
Bukkit.unloadWorld(worldName, false);
Its literally minutes...
Check after you call unloadWorld if getWorld returns null
Unloading blocks the executionContext completly...
Hmm?
why would you continue if world is null?
its not returning
typically wouldn't want to continue if that condition is met, you would want to break out of the loop
what is the purpose of the int? lol
this code is more better to use btw
just not sure of the int there is all
Should continue with the next world tho
well as we stated you can't unload the main worlds
im not
so you have multiple worlds needing to be unloaded?
o.O
thought it was just a single world lol
Its actually currently only one world, but could handle multiple
yeah but if we unloading chunks because we want to unload the world, not sure why we care how many are unloaded?
as I said was just curious more then anything lmao
?paste
Look at it. I dont get it...
https://paste.md-5.net/belepuzasu.cs
one is to save the chunk before unloading and the other is to force unload
there used to be
no?
if 1 world is null don't skip entire loop, it should just skip loop for world that is null
they clarified on it was for multiple worlds, where as I was under the impression for a single world. In which case if the world is null you wouldn't want to continue
oh ok
it doesnt even seem like its unloading any chunks.. https://paste.md-5.net/ixemohotog.cs
Why should i do it async?
I get it. But thats not the problem.
Then i could also jsut delete the files
I think he wants to create a new world without restarting the server
This Bukkit.unloadWorld(worldName, false) doesnt returns. Therefore nothing behind it in the code is getting executed
Actually not. I just want to delete the world. I was told that i have to unload it first.
same
You’d have to attach a remote debugger
Is restarting the server an option? Or does that take too long?
Im shuting down the server after deleting the world, if the function would return anything
Why don't you delete the world on startup?
Wouldn't have to deal with unloading then
Thats true...
yeah and you can then stop the world from being loaded in the first place then delete it.
Don’t even need to stop it from being loaded if it’s a custom world
How can i achieve this?
Just don’t load it
perfect
oh truee
Set the plugin to run before world loading using the plugin.yml
Turns out that’s a bit misleading
It controls when the plugin enables, not when it loads
Maybe the world is getting unloaded beforehand so there is nothing to unload. Also the unloading of chunks hasnt worked. Is there a way to check if a world is loaded?
getWorld == null
Minigame Map Rollback
null if if non exists... so unloaded should still return the world..
okay
Do you just create a new thread for help or do you post in here? I assume thread
You can do either
So just like this lol
Yup that's fine, too
ok great thanks
So what you are saying is that your world still gets saved?
Yup
And its really making me mad because I've been stuck on this all weekend
Even changed the bukkit.yml to -1
autosave value
can you check the logs whether it saves on disable?
Since autosave is probably every X minutes
How do you do that
But no way to implement in my reset() method?
I'd have to add another listener?
Okay
if you see those messages something probably gets saved
Nether_portals dosnt work on non main world
Really?
You can delete the main world using the load on startup mechanic
Huh til portals don’t like custom worlds
I also already made a plugin to delete and regenerate or rollback worlds on restart if you don't wanna make it yourself.
So deleting the worlds on startup?
Yes
Yeah its doing that
its just a little part of an game im making for me and friends
e.setSaveChunk(false) since we don't wanna save the chunk?
Yep
this is whats happening
https://github.com/Fabsi23/World-Rollback/blob/main/src/main/java/me/fabsi23/worldrollback/WorldRollback.java
You can still use that as a reference
Since you don't wanna rollback it's even simpler
I added nbttag to my custom item, but when I print out #getTag of the NMS item, I'm getting only printed out the display and lore of the item
I guess they are tags aswell
But I can't access my custom tag
Your not unloading, so you delete on "onLoad" instead of enable?
And this will work for arena maps right like maps I pregenerated
It should
The onEnable of the plugin is called before the world loads if you set the load: STARTUP in the plugin.yml
So you can just delete the world at that point
bet lemme try
Any benefits or no?
if(args[1] instanceof Player) {
// is player
}
Lol
ty
oh right lmao I kinda thought about some listener xD
Turns out sleeping 3 hours a night isn't enough
i did like you
:S
No that does not work. That's what you would do in a listener. Like the EntityDeathEvent
You have to do what Coll said
getPlayer(args[1]) and then null-check it
ur array index is out of bounds obv
😄
Yes, you are probably size checking the array before and access an index that's larger than the size-1
Just tested it and it didn't work
Weird
alright
As far as I know auto save and unload are the only times when a chunk is saved
Aside from when generated
tf what
Unless the saving at shutdown is something other than the unload save
isnt args a String array
Yeah I mixed things up as I stated afterwards
(time to get ignored again) whats the package name of the full bungee jar not just the api
Any advice I have been stuck on this all weekend
No idea sadly
Didn't work with bungee either, sry
Well and on server shutdown apparently
maven package
I don’t think there is one
You could try unloading the world in onDisable to prevent the server autosaving it. If it's the main world you are probably out of luck on that route.
Dunno if the main world can be unloaded in onDisable but I doubt it
I'm unloading the arena world when the game ends
Does player#sendBlockChange cause a block update on the cleint?
make your own world with nms e z
Yes, but it's only for the client. The server will not see that change.
Is that unloading and then loading it again?
I thought you restarted in between
Because in that case the restart save obviously isn't the problem
No this is done after the game ends
Then once the loading is done the map can be played again
So no restarts
nope
Alright
How it works it should work we no server restarts
I mean I would know a workaround but there has to be a better way
So you tried the listener, too?
I can check
This warning does not correlate to your plugin.yml
The IDE does not check your plugin.yml in order to fire code-related warnings
Alright, what's not working then?
BUT it takes ages to join the world
Yeah making a world isn’t exactly fast
Is there a way to preload a world?
sadly no
shit
Not unless you have a copy of the premade world somewhere
And can't be done asynchronous either
Oh no
Its a random world..
You could go overkill.
Have another server create the world for you and transfer the files.
You would still have to load it which does cause lag though
Seems like a normalw workaround hahah
Definitly not normal in terms of resources used xD
So the current problem is that the world generation takes too long?
But i could await the world loading... Is it the WorldLoadEvent?
Countdown starts in loadscreen.. So yeah
Countdown of?
Aren't you restarting the server? Your plugin should not load before the world got fully generated and loaded
The countdown one I mean
Its a little game im doing for friends, we spawn in a new world and can move after 5seconds
Yeah then either start the countdown on WorldLoadEvent or even better: PlayerJoinEvent
Nah bro... When i teleport the players to "world" the loading screen is taking ages
Hmm I don't know about more methods of denying save either
Oh that's probably because you are teleporting them to unloaded chunks that then have to be generated
Preload them
Well if you know where they are
location.getChunk().load(true)
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Location.html#getChunk()
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Chunk.html#load(boolean)
declaration: package: org.bukkit, class: Location
declaration: package: org.bukkit, interface: Chunk
You should have the location since you are teleporting players there
I have
lol
We need the console error
There should be more
wanna see my code ?
That’s not the full error
1m
Also wtf is that console formatting
i will write to paste
Is that the full stacktrace? It's missing the "caused by"
ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
my code works fine with args
You are accessing index 1 when your size is 1
Therefore the maximum index you can access is 0
(Or 0)
Oh true, dunno how the error message is implemented
But since it says "for length 1" it should be 1
And then use LUA
And cry
I’m sure there are other languages LUA is just the one I know
Fortran
Go
Pascal
This comparison of programming languages (array) compares the features of array data structures or matrix processing for various computer programming languages.
Ohh no async there 😦
How we delete one of our resources, or can we just report it with requested deletion reason?
Yes
I would love to do that
Yes, report your own resource and state you want it deleted
okay thanks.
"Comparison of programming languages":
The '?' is legendary
A bunch of them have a ? there
Including java
It's just weird to pretend powershell is a programming language
Thats true
It’s theoretically Turing complete
Suggest a change to the page and demand them adding it since they added powershell
How would you do the awaiting of the level loading? WorldLoadEvent isnt the way to go i think, because it seems like its firing on inital load only
The world loading or the chunk loading?
I think its the chunks....
Or can i just preload the chunks with the range of the render distance?
Just load them before teleportation. Chunk loading is blocking
Do you know how i can read the chunk render distance ?
Would have to check the docs aswell
But you don't have to load all chunks. Just load a 3x3 and then tp
the rest will load in those few seconds or until you leave the 3x3
I'll do that
Unless it's important to instantly have full view on the map after teleportation
Is there a way to check what part of plugin takes how much ram?
is this even java ?
also -1 will always be less than 0
you could literally just inline true
yeah I can see why idk wtf that code is
I'ma need more context that makes 0 sense on its own
also why wont the console show which class the error occured
are you just not going to elaborate and send more code
because right now that could be a trillion things and none of them make sense
I'm sorry but how would I know whos responsible for this, I have like 15+ classes
and plus it's only been like day 2 I'm still learning
i'm just messing around lol
you should probably start with more basic things
yeah the things im making are basic
the code you sent isn't valid java syntax, and you won't provide the code surrounding it
so I can literally not help you
Uhm sorry for the misunderstanding but thats not a code, that's what the console say
do you not know where that code is at?
no
because its saying that's not valid java code
why don't you just use project search
i didn't code anyting which includes math
that's not math
that's boolean algebra at most if you'd call it that
I guess send the full error your getting on compile then
?paste
okay
send your pom
ItemStack ironHelmet = new ItemStack(Material.getMaterial(plugin.getConfig().getItemStack("warrior.helmet")), 1);
ItemStack ironChestPlate = new ItemStack(Material.getMaterial(plugin.getConfig().getItemStack("warrior.chestplate")), 1);
ItemStack ironLeggings = new ItemStack(Material.getMaterial(plugin.getConfig().getItemStack("warrior.leggings")), 1);
ItemStack ironBoots = new ItemStack(Material.getMaterial(plugin.getConfig().getItemStack("warrior.boots")), 1);```
could it be because of this?
helmet: IRON_HELMET```
cuz yk this isn't an itemstack
this is a material
that's not why it won't compile
but that's definitely an error bound to happen at runtime
yeah but why wont it compile
not sure why it'd be erroring though your pom looks fine to me, something about your resources though
can't help further thuogh becaus I'm not sure about that error tbh
why wont it compile
i dont know
what ide are you using
IDE has nothing to do with it
doesn't change the fact that maven compilation failed
im aware
IJ
can you run the code with the run button
what
with an entry point
uhm sorry but I don't know how to do that, it's only been day 2
i'm not familiar with java
uh it automatically compiles it for me when I press run
Shift + F10
can you send a screenshot of that
try removing <filtering>true</filtering>
than compile again
okay
OHhhh
it's saying this now
incompatible types: missing return value```
kek
if you handle nulls wrong it does
if (target == null){
p.sendMessage(ChatColor.RED + "Player does not exists!");
return;
}
return false;
probably
unless your method is void you need to return whatever type is specified
otherwise you can just return
ain't this called like "early returning"
ohhh okay
there we go
finally
thanks ya'll
woah it's broken
it did compile but the plugin is broken rip
wait nvm I know why
im dumb, fixed it
Hey so I have been trying to optimize changing large amounts of blocks and have run into alot of trouble. I tried using nms because people have said it's alot faster than setType so I tried using the PacketPlayOutBlockChange to send a block change to the player but it is significantly slower than setType and even overwhelms the cleint after a while forcing the client to time out. After looking through nms code I found PacketPlayOutMultiBlockChange but I have no idea how it works. Could I somehow use that to send an entire batch of block changes at once and would it be faster than the other methods?
For context I'm working on a video player project and need to optimize 1.1m block changes per second
I also can't seem to figure out how to stop block and lightning updates from happening
Paper has api for the multiblock change and Spigot has API for block change
You don't need to touch the packets manually
I know about Player#sendBlockChange but won't that effectively do the same thing?
Yes but without the nms
Ok but the problem is optimization not nms, I can work with nms. Paper has an api for PacketPlayOutMultiBlockChange?
are you just trying to set blocks?
or are you trying to send it to the player rn
Essentially yes but I need it to be as optimized as possible. setType isn't fast enough
I need a way to basically just update the block textures without effecting block updates or lighting
Thanks! this is exactly what I was looking for
wow they dont even do bulk subchunk sets smh
not even doing a billion blocks sets in half a second smh
How would I update the player after using something like method 2?
There is an nms method in the nms world class that can update blocks, if you don't want reinvent the wheel: https://github.com/TheGaming999/BlockChanger
@unkempt peak
setSectionBlock is for the third method, setChunkBlock for the second
How do I cancel the advancement completed broadcast for a specified player?
setText()
Hey @lean widget I'm trying to get your code to work but It's throwning an npe "because "mh" is null" (BlockChanger.java:428) Do you know this is refering to?
mh?
I just looked at the code and there is nothing called mh
Not sure
send the full stacktrace
It also sends this after all the "mh" npes
I've verified and the materials are definitly valid
?paste it pls
Thats easier im on the phone
?paste your whole BlockChanger class
Stacktrace: https://paste.md-5.net/ijowiweyik.sql
BlockChanger: https://github.com/TheGaming999/BlockChanger
that can't be the code you used
your package name is me.blockchanger and that doesn't even appear in the stacktrace
I changed the package name but everything else is the same
I can paste it if you want but it's the same exact class
the whole class relies on using spigot mappings, or in other words, this won't work on 1.17+
looks like it some got weird patches for versions 1.19 etc but 1.20 definitely won't work
I'm running it on 1.19.2
it only checks for "19" and doesn't differentiate between 1.19.1, 1.19.2, 1.19.3, or 1.19.4
Hmm ok
Maybe I'll try downgrading the plugin to see if I can even get this method working
it'd be easier to just understand the original code and properly translate it to mojang maps using this:
?switchmappings
Yeah, I might just try to rewrite it
where did you get this blockchanger class from? i don't see it in the linked spigot thread
ah ok. yeah it uses hardcoded "obfuscated" method and field names so it'll only work on one specific 1.19 version. the proper way would be to use mojang maps, then you have the same code for all versions, and then run it through the maven specialsource plugin with the respective mappings for the version you want it to work on
basically, these two blog posts are about using mojang maps + how to switch from obfuscated/spigot mappings to mojang maps:
?nms
?switchmappings
Thanks, I'll see what I can do
How would one make multiple lines with text displays?
Just \n or what?
Since theres only .setText()
try it out ig
I'm currently writing a blog post about multi-module maven projects. Does somebody have an example of something easy (just a few lines) that requires NMS in 1.20?
Setting the motd of the server
that can be done through ServerListPingEvent or what's it called
Nvm they added it
That doesn't change the motd, but only what you see in the server list
where else would you see the motd
There are plugins that ping the server's motd using getMotd
but yeah anyway, NMS isn't needed to change that
hm maybe I'll just do getting the TPS
Hey there i'm new to java and was wondering how can i get Arrays.toString without the []
what
in this case i have an Array called "groups" that has the players permission groups
what do you want it as
i want to have it as just group1, group2, etc...
instead of [group1, group2, etc...]
so format it
how do i do that?
String.join(", ", myArray);
ok ill try that
btw how do I get the verified role
Usage: !verify <forums username>
I did
leave and rejoin
I can't think of any beginner projects anymore bruh
you would have to make the url
they realease maven info, you would have to convert that maven info into the url to download it
sure
Edited - I don't use noteblocks anymore.
How can I prevent mushroom block textures from changing when a block update happens?
if you use maven you don't ever (almost never) install jars
do you have a pom.xml?
then you are not using maven
no
your imports look fine
select yoru project and (if Eclipse) press F5
else, project menu and clean
no
you said you were not using maven
I'm finished
no screen yet
good job discord
I don;tr do pm
just say what your issue is
you have an imported essentials, it has the api
ok got screen
What would be the best way to get a block behind another block? I'm trying to get the block behind a block I've just broken. Currently I think the blockfaces are the best solution, I saved the last clickedblockface on the oninteract event and I'm accessing that from the blockbreak event.
you can stream in verified
Thats good because we are not in verified 😉
lol
your Economy import looks bad too
hover over it
you shoudl get a popup
3rd one
milkbowl
select 3rd option for import, milkbowl
any other errors?
I see 3 marked lower down
press CTRL+SHIFT+O
you sure that PayMoneyEvent is in teh version of ess you are using?
delete the import
then scroll down to the error lines
click save so the IDE updates
um I'm fairly sure you shoudl not be raising payMoneyEvents yourself if they are essentials events
delete line 125 and 126
then hover the other errors and see options
actually, you are using vault so you shoudl not even be using ess for money
economy.
you are using vault, which support many economies
you should query the Vault API not essentials
Vault/essentials also have an auto format built in
that doesnt look like an essentials command
its his plugin
so it is an essentials command?
vault
yes, you shoudl be doing everything via vault
you have to add the placeholder api and parse it
those arent even valid papi placeholders
if you want to format essential's messages go and ask in their help channels, see if theres a built in way or pr it
Hey there i've got this slashcommand to 'say' the block that you are currently looking at
player.sendMessage(ChatColor.YELLOW + "You are looking at " + block.getType());
but i want instead of block.getType() (that gives the block in all capitals and spaces are _ something like OAK_PLANKS)
that it just gives the displayname of the block. (like Oak Planks)
format it
how do i do that?
public static String getNiceMaterialName(final Material mat) {
final StringBuilder builder = new StringBuilder();
final Iterator<String> iterator = Arrays.stream(mat.name().split("_")).iterator();
while (iterator.hasNext()) {
builder.append(upperCaseFirstLetterOnly(iterator.next()));
if (iterator.hasNext()) builder.append(" ");
}
return builder.toString();
}
public static String upperCaseFirstLetterOnly(final String word) {
return upperCaseFirstLetter(word.toLowerCase(Locale.ROOT));
}
public static String upperCaseFirstLetter(final String word) {
if (word.length() < 1) return word;
if (word.length() == 1) return word.toUpperCase(Locale.ROOT);
return word.substring(0, 1).toUpperCase(Locale.ROOT) + word.substring(1);
}
why use stream there lol
lmao
stream expensive :c
cutest blaming ever
yeah, well speaking of which this looks like one should be using StringJoiner and not StringBuilder
yeah
ofc
One class wonder
it works, thank you!
hi, how do you set a player completely invisible (not even the username is visible) ? I dont want to use Player#hidePlayer() however, because the player should still be able to interact with other players, eg hitting, etc
What eventhandler handles the players input?
Like how do I know when they right click
Im having difficulties finding it in the wiki
I mean, invisibility potion without ambient particles ?
PlayerInteractEvent
does that also remove the username above his head?
Ohhhhhh
The client doesnt send keystrokes to the server.
You can only check if a client interacted with something.
I must be blind
yea, invis does
cool
Right, thanks!
/effect give @s minecraft:invisibility Infinity 255 true
idk if you can execute command from within a plugin
We do java here, sir
Run the command using Bukkit.dispatchCommand()
why
i-
theres api methods
Then smile is happy 😛


I was joking 
return if the effect has an icon
Whether the player sees the icon
what icon?
top right
The small icon that indicates you have Regeneration or whatever else effect
iirc
ohh
alright
thabks
did i do it right?
player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false, false));```
(i just want the invis, bothing else)
Yes looks alright
If you apply it to multiple players (e.g. in a loop) you can use the same PotionEffect instance
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
also, how can you make it that it doesnt go away after death/drinking milk?
do you really have to also listen for those events 😩
What is your overall goal? What is the invisibility for?
do armorstands automatically save? or do I have to make a database for it to save
Non-packet-based armorstands do save automatically. How else would they be saved on a survival server?
does this mean I can make a hologram plugin without having a database
Yes. Keep in mind that those are still entities and require more server performance than packet based armorstands.
Also on new versions there are display entities
ofc. you dont even need real armostands for that.
do those automatically save too?
cuz I don't know how to make databases yet, It's only been like day 2
Tbh I don't think armour stands (especially if you noai them?) use much performance
does anyone know what happens if the itemstack param in World#dropItem() is null?
exception is being throws. Same for an air itemstack.
alright
But your IDE should yell at you if anything that could be null is passed anyways:
what exactly do i have to check in the ItemStack obj?
oh missed that..
cuz its always not null
If its always not null then there is no problem...
Well ItemStack refers to the type. You cant do anything with types on their own.
basically, what i want to do is get the itemstack the player is holding and drop it in the world
ItemStack someItemFromSomewhere = ...;
if(someItemFromSomewhere != null) {
// drop it
}
Create more variables pls. Otherwise this gets messy quickly.
what do u mean?
ItemStack currentItem = player.getInventory().getItemInMainHand();
Sure. And if its type is AIR as well
but thats also always true
(the null check)
its never null
Yes, players cant have null in their main hand. Only in the offhand.
If a player holds nothing then he actually has air in his hand.
so only check air?
Yeah
It I put air in the offhand using the replaceitem command or using my plugin will it return air then?
And while you are at it: Make it a utility method:
public static void dropHandItem(Player player) {
}
And if you want to make this even more useful you can implement it
for everything a player can hold:
public static void dropItem(Player player, EquipmentSlot slot) {
}
Will teach you a bit.
oh
Huh?
lmao
I got another problem and maybe you guys can see it. I created a command called WorldTeleporter and it basicly loops through all worlds on the server, sets it on a menu and the player can click on the items to teleport to the world. For example if i have a world in my server folder called "World_end" it will see the folder, create a grass_block called "world_end" and if the person clicks on it, the plugin will read out the name of the block (in this case "world_end") and teleport the player too it. But for some reason i got 10 worlds and all worlds work correctly except one. This world generates a NULL error and it says
[13:21:33 ERROR]: Could not pass event InventoryClickEvent to VTDPlugin v1.0-SNAPSHOT
java.lang.RuntimeException: java.io.IOException: The process cannot access the file because another process has locked a portion of the file
at org.bukkit.craftbukkit.v1_20_R1.CraftServer.createWorld(CraftServer.java:1284) ~[paper-1.20.1.jar:git-Paper-68]
at me.viciousthedark.vtdplugin.listeners.MenuListener.onMenuClick(MenuListener.java:59) ~[VTDPlugin-1.0-SNAPSHOT.jar:?]
Does someone know why this specific world doesnt load or cant be reached with #.createWorld() function. I know it says cannot acces the file because another process has locked a portion of the file. but i have no idea where this is happening
Looks like another application or plugin hogged resources for this folder. An open file pointer for example.
Did you try simply restarting the machine?
Restarting the machine as in my whole pc or the server?
The whole pc/root
I didnt try that yet, let me try it now
how do I avoid having mobs spawn mounted when spawned via the api?
I know there's a way
randomizeData to false
hm?
param on the spawn method
Out of curiousity, i restarted my PC and got this error now:
[STDOUT] [org.bukkit.craftbukkit.v1_20_R1.CraftServer] World lobby_prophunt is a duplicate of another world and has been prevented from loading. Please delete the uid.dat file from lobby_prophunt's world directory if you want to be able to load the duplicate world.
I do know when i created this world i copied it from a void world, is this something i need to stop doing to make sure this doesnt happen again?
If you want to know my steps:
- created void world with minecraft
- did copy paste and renamed the world before i started building it
Inside your world folder there is a file which stores the UUID of the world.
If you use a world as template you need to remove this UUID file from it.
Because two worlds with e same UUID won't work
Ahh so thats why this specific world does this. Good to know, thank you
There's a reason it's an unique id
And you can just delete the uid.dat and it will generate a new one?
Well, try it and see
Tbh forgot that when you copy a world you copy everything ofc haha
Ahh yeahh now it works. Thank you so much
Dont know how it used to work sometimes but now i understand what the possible problem could have been
Hello, i have a question with this gui techniques.
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
how i can reopen the inventory in the inventory? (because if i reopen directly, the inventory got removed in the guimanagers.)
So how to do? Getting the manager instance in the gui and make menuManager.openGUI(this()); ?
thanks
i wanna insert data to sql but if this data is exists i don't wanna insert data
and i wanna control with java
can i do this ?
sorry
wdym for that
well when you insert data you have a primary key in that table, what is it? You could just check if that primary key exists in the table before inserting
public void onPlayerChat(AsyncPlayerChatEvent e){
Player p = e.getPlayer();
if (plugin.playerCreatingHologram.containsKey(p)){
String hologramMessage = e.getMessage();
plugin.hologramText.put(p, hologramMessage);
plugin.playerDoneCreating.put(p, true);
}
}```
am I doing it right
well can i check this with java ?
as ElgarL said, INSERT wont overwrite
Hello, ive been trying for a while to find a way to be able to change the name above players heads as id like to add a rank and bounty next to the name but everything ive tried hasnt worked, does anyone know how to do this? even by using protocollib
i could use nametagedit but so far my entire server ive coded into 1 plugin and i would like to also make this myself
maybe player.setDisplayName
idk it sounds like it'll do the job
i will store friend requests in db like this
but if requests is sended they will not send again
do you have an idea to do this
if you want no error use INSERT IGNORE INTO
i dont think so, i believe i tried this but it only changed the name in chat and on tab, not the name tag
oh damn
but i need to send it in message like "u already send requests to this player"
why are friend requests persistent
friend requests seem something that shouldnt need to persist across restart
send in a message? Not sure what you mean
they will be friend requests box
and see requests from this gui
well can i check if my data already set in my db ?
with sql and java ?
yeah
if you already did a SELECT query you already know who are friends, so you know not to try and insert them again
why arent you saving the data to a map to start with tho
i think this
but if they change server
doesnt accept requests in another server
Hello, i have a question with this gui techniques.
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
how i can reopen the inventory in the inventory? (because if i reopen directly, the inventory got removed in the guimanagers.)
So how to do? Getting the manager instance in the gui and make menuManager.openGUI(this()); ?
thanks
but i think something for this
still llookin for help
set a text display as a passenger
No? It makes sense
and whatr does that mean
armorStand.setCustomNameVisible(true);
armorStand.setCustomName("test");
armorStand.setGravity(false);
armorStand.setVisible(false);
event.getPlayer().setPassenger(armorStand);```
like that?
i put it in my asyncplayerchatevent
just to test
so how do i do a text display
dont think textdisplay is a thing in 1.8
so how would i do it in 1.8
isnt that exactly what i just tried tho
it didnt do anything
why do you need an instance of the main class, if you can just take it through the constructor of another class
who know
i mean getter
you are on your own with 1.8
potpvp servers are 1.7.10 - 1.8
sooo
Caused by: java.lang.IllegalStateException: Asynchronous entity add!
runTask to add it sync
My plugin uses a lot of resources, when I use this website that tracks the usage of plugins, I can see that my plugin uses 3 tasks and 1 event and only the first task uses up most of the resources. What can I do to optimize it?
(The last 2 tasks are basicly identical copies of the 1st one, with a few changes)
Show your timings pls
In the code or in the tracker website?
What did you profile your plugin with? Spark or timings?
timings
Then send your timings
can I send it in dms? I dont wanna send the link in the public chat
exceptionally
I sent it
Code of this runnable pls
Hello, i have a question with this gui techniques.
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
how i can reopen the inventory in the inventory? (because if i reopen directly, the inventory got removed in the guimanagers.)
So how to do? Getting the manager instance in the gui and make menuManager.openGUI(this()); ?
thanks
This is a complicated topic. Simplest approach: Open a new inventory and put it in the map.
Make sure to not open any inventories in the InventoryClickEvent.
you want the first or the second task? Because you send a pic of the second one.
The second one
public void spawnHellMobs(int size, int mobCap, int spawnTime) {
CustomHellMob[] mobTypes = CustomHellMob.values();
task = new BukkitRunnable() {
Set<Entity> spawned = hellEntities.keySet();
List<Entity> removal = new ArrayList<>();
@Override
public void run() {
for (Entity entity : spawned) {
if (!entity.isValid() || entity.isDead()) removal.add(entity);
}
spawned.removeAll(removal);
// Spawning Algorithm
int diff = mobCap - hellEntities.size();
if (diff <= 0) return;
int spawnAmount = (int) (Math.random() * (diff + 1)), count = 0;
while (count <= spawnAmount) {
count++;
int ranX = getRandomWithNeg(size), ranZ = getRandomWithNeg(size);
Block block = world.getBlockAt(-233,52,-4);
double xOffset = getRandomOffset(), zOffset = getRandomOffset();
Location loc = block.getLocation().clone().add(xOffset, 1, zOffset);
if (!isSpawnable(loc)) continue;
double random = Math.random() * 101, previous = 0;
CustomHellMob typeToSpawn = mobTypes[0];
for (CustomHellMob type : mobTypes) {
previous += type.getSpawnChance();
if (random <= previous) {
typeToSpawn = type;
break;
}
}
hellEntities.put(typeToSpawn.spawn(loc), typeToSpawn);
}
}
}.runTaskTimer(this, 0L, spawnTime);
}
The tasks are basicly identical, the only thing I changed was the mobs to spawn and the location.
I see the problem. You are probably not checking if the chunk you are trying to spawn an entity in is loaded.
If you try to spawn an entity at an unloaded position then the chunk gets loaded first. This can be very expensive.
Wait i see a lot more issues...
I copy pasted this from a video to replace the old custom mob/spawning system so I would apriciate some help.
Block block = world.getBlockAt(-233,52,-4);
This one could cause some lag if the chunk there is not loaded.
hellEntities.put(typeToSpawn.spawn(loc), typeToSpawn);
And this one will create a ton of lag.
Yes
So i need to get the menu manager instance in my guiinevntory and make guiinventory.open(this) ?
No
I see, thank you for spotting it out for me, but how is it that only the first task lags the server?
You create a new instance of your other inventory and open it
What do you mean by that? This is the second task.
Yes and this one uses 3.68%, but the first one uses up 21.46%
and they are basicly indentical except for the mobs,location and the spawn time
I looked at the average, not the worst case
Could it be that the spawn time causes the issue?
Send the first task as well. I see it being very heavy as well
Completely missed the 22ms per tick. Holy, that plugin is just a lag machine.
public void spawnWaterMobs(int size, int mobCap, int spawnTime) {
CustomWaterMob[] mobTypes = CustomWaterMob.values();
task = new BukkitRunnable() {
Set<Entity> spawned = waterEntities.keySet();
List<Entity> removal = new ArrayList<>();
@Override
public void run() {
for (Entity entity : spawned) {
if (!entity.isValid() || entity.isDead()) removal.add(entity);
}
spawned.removeAll(removal);
// Spawning Algorithm
int diff = mobCap - waterEntities.size();
if (diff <= 0) return;
int spawnAmount = (int) (Math.random() * (diff + 1)), count = 0;
while (count <= spawnAmount) {
count++;
int ranX = getRandomWithNeg(size), ranZ = getRandomWithNeg(size);
Block block = world.getBlockAt(-358,58,-122);
double xOffset = getRandomOffset(), zOffset = getRandomOffset();
Location loc = block.getLocation().clone().add(xOffset, 1, zOffset);
if (!isSpawnable(loc)) continue;
double random = Math.random() * 101, previous = 0;
CustomWaterMob typeToSpawn = mobTypes[0];
for (CustomWaterMob type : mobTypes) {
previous += type.getSpawnChance();
if (random <= previous) {
typeToSpawn = type;
break;
}
}
waterEntities.put(typeToSpawn.spawn(loc), typeToSpawn);
}
}
}.runTaskTimer(this, 0L, spawnTime);
}
Just like I said, this only differs in the location and the mob
spawnWaterMobs(27, 15, 5 * 20);
spawnHellMobs(27, 10, 10 * 20);
spawnEndMobs(27, 10, 15 * 20);
Wait this is literally just copy pasted from the other task...
Yes I know
Well... dont do that
this is the only thing I can think of that causes all that lag
If you see yourself copy/pasting code then its time to take a step back and write something that can be
applied to all 3 cases with just one method.
Otherwise you going to have to fix the same code 3 times if you see a problem or want to make a change.
Anyways all of those tasks produce lag in the same way i described.
All 3 produce lag
I'll fix them first and maybe increse the spawn time and lower the mob cap
How about you dont spawn mobs in unloaded chunks?
Yeah, that's what I was thinking.
Youll figure it out. Spawning mobs is a pretty hard task to get right.
And keeping track of mobs is as well.
Yes I've noticed that. Before this one I was using an armor stand to spawn the mobs, and used an int to keep track of them 💀
Using a scheduler is also a very questionable approach
What would you use to spawn custom mobs and keep track of them?
Events to keep track and scheduling to spawn
You could use NBT data to keep track of them no?
All I need is the amount of mobs alive.
Not really
ah yes manual method obfuscation 💀
Your method names are a b and c
That's not how you're supposed to name things
Also when spawning an entity and you'd like to modify it you should use the spawn method that takes a consumer
This will ensure the entity is modified before it's spawned
I do love me some block displays
But if i need to keep the old instance ?
A gui is just a view of data. You should be able to view this data with a new instance without any problems.
So there is no need to keep an instance. But you can design a system to keep track of nested guis if you want.
There is an endless amount of approaches to this.
Yes but if i have a page system i need to keep the var index.
Then implement the decorate method in a way that incorporates this index.
This way you dont have to open a new inventory. Simply use the same inventory and update the icons.
The index is in the old instance
are you opening a new gui for each page?
I dont know what you are doing... pass the index to the "new" instance then?
Why do you need multiple instances for pagination?
Just use one Inventory and re-decorate it.
I haven't done the system yet, but I think I will, because I prefer to do it myself. It avoids the player to see the items changing little by little.
yes, but when I click on a new page, I open a new inventory.
What will happen in reality is that your cursor keeps resetting to the middle and the screen flashes for each page
which is very annoying
its true
If you're really concerned about items refreshing little by little just populate the item array instead
you have reason
But you shouldn't need to because bukkit doesn't send a packet for each setItem call iirc, just marks it as dirty and updates it at the end of the tick
new blog post: Multi-Module maven projects for multi-version plugins https://blog.jeff-media.com/maven-multi-module-setup-for-supporting-different-nms-versions/
personally a fan of nesting the nms impls inside of another module
spigot pls
I gave you my 2fa
I really don't have much time to update my resources
I don't understand. Item array ? We can Set all Intems in the same time?
Inventory#getContents / setContents
ah set contents and give array?
yes
spigot pls, I have to go in 1h20
yeah I hate 2fa
I am going to have a conniption
so its normal ?
am i need fix ?
if i don't fix what happens ?
Not much you can do to fix that. It's up to md and Bungee contributors to update dependencies
Keep your project up to date with the latest dependencies. Not much more you can do.
well i see some versions of bungeecord in my minecraft project plugin
is this bungeecord versions or minecraft versions ?=
Hm maybe getting a newer version of the transitive dependencies and relocating? Let me think if that makes sense.
i'm having a problem with maven to add another plugin of mine in dependency of my plugin. can i ask my question here? or is it inappropriate?
Thats a development related question. Go ahead.
well
Never add jars to your maven project.
Are you trying to do that?
yeah
<repositories>
<repository>
<id>ServerCore</id>
<url>C:\Users\Aser\Desktop\maven</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>fr.dylors</groupId>
<artifactId>ServerCore</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
I'm trying to add the local ServerCore dependency located in C:\Users\Aser\Desktop\maven
ServerCore-1.0.jar
maven returns this error
Impossible to transfer the artifact fr.dylors:ServerCore:pom:1.0 from/to ServerCore:pom (C:\NUsers\NAser\NDesktop\Nmaven) : Impossible to access C:\NUsers\NAser\NDesktop\Nmaven with type default using available connector factories : BasicRepositoryConnectorFactory
Just run mvn install on your other project.
This way its installed in your local maven repo and you can use
the dependency in your other maven poms.
in inteleji, is the install mvn available in the maven menu? (the comand path mvn is not implemented on my system).
ok that's work
after i just add dependecy and he finds it all by himself?
thats work
thanks
after end my plugin
if i upload my sourcecode to github can u check my plugin?
and tell me mistakes?
bcs this is my first serious project
I don't think I'll ever need it again. But the day I really need it. I pass the menu manager instance into my inventory and do a guimanager.open(new inventory)?