#help-development
1 messages ยท Page 1953 of 1
I can't believe c# doesn't have a single line random number generator
this is a betrayal of the highest order
I'm pretty sure JavaPlugin class just uses its own classloader's getResourceAsStream in this method internally
that's just an alias
iirc
How does sqlite Work? Is it a server like MySQL?
it's very, very similar to mysql
Disagree
One is a real database, the other one is filebased
@manic furnace i assume the not being a server is what you are asking
OK so MySQL is a real database?
Yo
So which one is better in performance?
Depends on what you need
A lot of interactions
??
In different threads?
CoderTheDuggy, Iโd certainly say that mysql/postgre is much more powerful
Ok
I want to make a gui and if the next that is here, there must come a new gui Guys, how
I disagree with that as well. If you have 2 or more plugins writing to a DB sqlite dies
Sqlite is great for internal storage
As you dont occupy any ports and network
Just disk read and write bandwidth
Lq how about an inventory?
yeah i know, cuz this is dev comunity i suppose he is asking for plugin internal storage, if i am wrong, sorry
A reasonable assumption for sure
So it's just like writing to files?
Sqlite is literally you writing to a file
Its just abstracted away through some library
You could just as well write a txt or json, but sqlite is faster and nicer to work with
Ok because in the moment i am using files lol
OK i add both options to my plugin so the user can decide
Json and txt are kinda write only, for an edit you read, change and write, right?
Yes
mariadb
It really doesnt matter which sql server
Let's not devolve into a religious war on sql servers
Alltough im on mariadb side as well
@quaint mantle have you looked for any libraries? Im sure there is good spigot UI libraries
anyway, I didnt even get to ask my question yet:
I am trying to:
interfere with dispenser events and stop it from dropping its item. Not like cancelling the event, but just like empty buckets pick up water without throwing the bucket on the floor
sql.execute("CREATE TABLE IF NOT EXISTS ?fluxcredit (uuid VARCHAR(225),username VARCHAR(225),credits INT) ENGINE=INNODB;", "fluxcore_");
This should replace the ? with fluxcore_ in the string correct?
That wouldnt work
Im gonna assume JDBC?
And no, im pretty sure you can only have lonestanding ?
else you are back to funny SQL injection
wait no JDBC looks different
https://github.com/Redempt/RedLib/wiki/SQLHelper - Using the RedLib library and this is exampled in that. What should I do instead?
sql.execute("CREATE TABLE IF NOT EXISTS "+prefix+"fluxcredit (uuid VARCHAR(225),username VARCHAR(225),credits INT) ENGINE=INNODB;");
oh god everything but that
What do you mean
Wich libarie
why?
wdym?
laggy asf
mysql has scary syntax
bullshit lol
depends on what u do
just cancel the playermove lol
they just want to cancel the move event
uhm
thats like
the best way to stop movement
but i prefer potion effects
so players dont get that draggin effect
that works too yea
LQ you are trying to make a GUI, have you looked for any libraries that may accomplish that? If not, may I recommend looking into how to open inventories for players and getting info from them?
Because "it needs to make new GUI" does not really provide any info whatsoever
This is the correct way to get people to delete your database
why that?
so? if the admin decides to inject sql into their own database, it's their fault
the admin literally has 100% control over the DB anyway
seems like prefix is sth like "wp_" used by wordpress by default
if an admin decides to use db-prefix: "prefix; DROP DATABASE asd;" it's a bit stupid but not really a security concern because obviously they have the credentials anyway
yeah sure man
Why not just `sql.execute("CREATE TABLE IF NOT EXISTS ? (uuid VARCHAR(225),username VARCHAR(225),credits INT) ENGINE=INNODB;", prefix+"fluxcredit");
literally lags when i turn my head
use anvil gui to take a string
or would that not work
well i am using playermoveevent and it don't lag
"frozen" players are normally allowed to turn their head, just not to change the actual location
yes thats what i want
when i try and move my head
it spazzes out
player controlled? its not?
I wasnt sure
well don't blindly cancel the event, but only cancel it if the x,y,z has changed
Thats an easy hash map cancellation
that's what I said, the prefix is probably some "table" or "database" prefix that can only be set by the admin
hash map?
ok but would this not work?
just adding the string outside of the template?
When i write a program to use SQL, can I use it in MySQL and PostgreSQL?
generally no
Different SQL engine syntax could be different
practically no
I can try
but for example MariaDB and MySQL are inter-compatible generally with each other
If the player moves, from the last location saved in a hashmap then tp him back or just cancel the event for Christ sake
SQL norms are a mess, and you are going to be using two completely different engines anyway
why? that's quite useless
@EventHandler
public void onMove(PlayerMoveEvent event) {
if(!isFrozen(event.getPlayer())) return;
if(!hasMoved(event.getFrom(), event.getTo())) return;
event.setCancelled(true);
}
private static boolean hasMoved(Location loc1, Location loc2) {
return loc1.getX() != loc2.getX()
|| loc1.getY() != loc2.getY()
|| loc1.getZ() != loc2.getZ();
}
no map or anything needed
why two if statements for the same return action
merge them
this doesn't matter at all lol
event.getFrom()? did i understand you wrong?
Didn't know these methods exist but that would do it
which methods?
I barely touch player move event
Nope didn't work still..
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax
The method thinks the ,prefix+"fluxcredit" is part of the string..
yeah well without getTo and getFrom, the move event would be pretty pointless ๐
sometimes adding backticks ` helps for column names
you gotta use prepared statements
if you want to use ?
preparedStatement.setString(1,prefix+"fluxcredit");
Ideally just hardcode the table name lol
its not JDBC
Much much cleaner
Gotcha.. RedLib should probably document that rather than using this example then lmao
pretty sure that uses prepared statements
oh you're using some lib. if that's an example from its docs, it probobably already uses prepared statements
Its not working though?
^^ Its open source, just checked and it does use PreparedStatements
what sql server do you have?
hm maybe prepared statements don't work at all with table names
MariaDB I think...
however I wouldn't worry about it. since the table name cannot be changed by user input, no prepared statements needed
that has nothing to do with the sql server
you can totally just insert the tablename yourself as long as it's not consisting of ANY player input
depends on what weird stuff the library does, if it goes through jdbc you are right
Bro @vagrant heath Wich libarie
I need
For this ""I want to make a gui and if the next that is here, there must come a new gui""
I dont get that sentence at all
Hi guys, I have a String which is actually a List of string translated to a string, (Example: I have List that contains A and B, my String will be "AโB" [As "โ" is the symbol that defines an end of a string and the start of another one]). How can i retranslate this into a List? is there any way to break it into other strings for every "โ" symbol that it contains?
Hope you understand.
.split
"CREATE TABLE IF NOT EXISTS `" + prefix + "pluginname`;"``` is 100% fine to use
Will use this then. Thanks
"I want to make a gui and if the next that is here, there must come a new gui" huh?
yeah but how do i know when it doesn't need to do this anymore?
I want to make 2 gui's Ok? Then i want each day a another gui. Like this. 15-02-2022 GUI1 With Stone block in it. En 16-02-2022 With Cobblestone Block in it
Hardly possible with spigot
as a player can only have one inventory open
Nooo
and spigot UI is mostly implemented as inventory
spigot can not run code on the client
well you can use player's inventory as second ui
and chest as first
you could, but I dont think thats the usecase here
I guess they just want to have a paginated GUI
(also then you could just split the chest in half lol)
yeah, but still it is possible
if (date == 15-02-222) {add stone}
if (date == 16-02-222) {add cobblestone}
Thats my only guess to what you want?
oh
But the gui must change, they dont need to open 2 inventory's but if the command is ./shop and they use ./shop 15-02-2022 23:59 She wil get GUI 1. And if they run 1 time more round 16-02-2022 00:00 She will get Gui2
then just check the date?
I dont get your usecase
you want to show different things at different dates
is my only guess
then get todays date and show different things
LocalDateTime now = LocalDateTime.now();
EDIT - This will return the date-time of the local machine the server is hosted on
get current date, check if it's date X, show item X, if it's date Y, show item Y, where's the problem?
Yes but how
you should have something like map with date as key, and item as value, and depending on the commands argument get right item, create inventory, put item in it, open inv for player
nothing hard
please
if you know basics
your usecase is not clear
Yes but how
something is either a string or a list
you want code?
ohhhh
just gnoodle "get current data java"
How to Get Current Date and Time in Java examples using java.time.LocalDate, java.time.Calendar, java.time.LocalTime, java.util.Date, java.sql.Date and Calendar classes. We can get current date and time int java by different ways.
will0 gimme a sec
Yes and then. How can i make that date1 open gui1
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
if (date == x) {open inventory}
And what is X?
do you know what is map, how to create inventory in spigot and open it for plauer?
Yes
X is whatever date you're checking for
I have a gui system
I can only save a STRING type. But i want to save a List of strings! The only way i can think of is by adding them into one single string using some symbol to define a string end end a string start. (I'm saving this to a PDC so i cannot even modify it to use the Array)
That doesn't change anything.
Custom PDC type?
you create a map Map<Date, ItemStack>, in command, you create inventory, get right item from that map, put it in inventory, open it for player
Yers
if you use plain inv
ok lemme check again: you want to turn a List<String> into a String?
if you have gui system it depends
I understood it vice versa first
Are you trying to store a list of strings in pdc?
anti pollution
I dont understand it
No i already made the part where i translate it into a single string, i want it to become a List after that
will0 come thread
yes
there are 2 discussions
But how guys
You'll need to understand maps to use this method.
Can you guys send a example
you must learn basic java
Ok lol
Arrays.asList(string.split("delimeter"));
https://github.com/decalium/persistent-data-types
Check it out ๐
?
no because your usecase is not clear at all
The split method has a problem: it breaks when you have a string which contains the separator
^
Seeing you're editing a 'ShopPlugin' project, I'm assuming you want different items to appear in the shop on different days?
The lib i sent avoids that problem by storing string array efficiently as bytes
Yes thats wat i want
Use super strange delimeter lol
Or stick with a custom pdc type like gepron1x suggested
I Have a tread
guys we already have a thread for the string list pdc thing
hes using "โ"
Why lol
because nbt is a good format lol
PDC is just the API way to use NBT
How can i check the time
gnoogle it
yes but not for basic stuff
Particle.BARRIER was removed in 1.18. How do I spawn the particle now?
yes but you arent willing to do your own research
it's particle.block_effect or sth like that
BLOCK_MARKER?
/Lqrss no offence, that's just super basic java, not spigot
yes exactly
and this has a BlockData to determine whether it is barrier or light effect?
yes although I currently don't remember how to use it
IIRC Particle has a method getDataType
you can just provide BLockData as object
@EventHandler
public void onMove(PlayerMoveEvent event) {
//System.out.println(Particle.BLOCK_MARKER.getDataType());
event.getTo().getWorld().spawnParticle(Particle.BLOCK_MARKER,event.getTo(),5, Bukkit.createBlockData(Material.GOLD_BLOCK));
}
it's the code I sent above ๐
yeah
np ๐
it's a bit annoying that the particle javadocs don't show the actual particle data class
so you always have to print out Particle.WHAT_EVER:getDataType() to know what it actually needs
wait you can do that
Could PR that ๐
this is soo cool
obviously ๐
It's a simple JD change so ye
you can do so much stuff with this
text
yeah I guess I'll have to do it now
How would I avoid an event going through to vanilla without cancelling it? I want to handle it and suppress the default action
sadge
was about to use it on my 1.17.2 server
not sure, maybe if you cancel it in eventhandler with lower priority than the actual handler it will work, idk
what are you trying to do?
"go through to vanilla"? vanilla doesn't care about events
events are ONLY for plugins
Paper staff chat plugin issue
sir this is spigot
Ok so my usecase: custom dropper behaviour, I want to not drop a bucket when there is a cauldron in front and instead get the water into the bucket
I already have the water level in the cauldron and all that, but the event does not differ between dropped and not dropped items
what if you cancel the event and dispatch a new one with same data? i think it won't affect vanilla
yeah cancelling is probably the way to go then
just means I need to implement the noise and smoke custom
but that clears up my understanding of events, thx
any idea on how to do this? I doubt that md_5 will consider this to be good enough for merging
FLAME,
LAVA,
CLOUD,
/**
* Uses {@link Particle.DustOptions} as DataType
*/
REDSTONE(DustOptions.class),
SNOWBALL,
SNOW_SHOVEL,
Yeah that's just fine 
alrighty
oh nice some fancy changes i can see there
ok yikes
when a bucket is dropped the velocity is the items velocity.
when a bucket is not dropped but it collects water the velocity is the block position
thx mojang or MS or whoever
What
depending on if there is water in front of the dispenser or not, it either drops the bucket item or just fills it, yes?
Right
and if it fills it, then the event information on the dispensed item velocity is instead the coordinates of the block it picks up
And so what's the problem
Picking something up shouldn't even have a velocity
probably
And I can't think of a usecase where you'd want to use that velocity
the api is not microsoft O.o
i mean i dont know when stuff was written
oh wait team is still mojang, right?
my bad
what ?
turns out the smoke and sound doesnt disappear when I cancel the event (?)
i dont understand dispensers in spigot
if anyone ever figures out how dispensers work please message me
the stuff written in the api is not mojang or microsoft... its mostly md_5 or the army of helping developers behind him ?
if someone who made the event thought its a good idea to set the velocity to the blocks location when its a bucketfill-event it wasn't microsoft or the nms code at all
could be a client-rendering or maybe some leak in the dispenser-class where the event fires
i assume that the event data still has correlation to the underlying code
but I guess I gotta decompile and look whats going on if I really want to find out
HI! Have never gotten this issue before but tried setting up a server to test a plugin im working on, anyone knows why I get this error when running my bat file?
\Servers\1.18.1 Bungeecord\Servers\Lobby>java -Xmx1024M -Xms4024M -jar server.jar nogui
Error occurred during initialization of VM
Initial heap size set to a larger value than the maximum heap size
you set the max ram to 1GB
and the min ram to like 4GB
obviously 4 is more than 1
you probably confused Xmx and Xms
(although tbh the error message is quite obvious on what the problem is ๐ )
Wait what, I thought I changed that well thanks
could just use buildtools?
not sure why you would need to decompile it lol
also items are a type of entity and thus can have velocity
im complaining about the case where no item is dropped
like when a bucket picks up water
then instead of the velocity it is somehow the coordinates
not that it matters for my usecase, its just really really weird
Ok another question, I just noticed that Dispenser doesnt extend Block, so my casting approach obviously wont work. How do I go about getting a container from a Block?
BlockState
not Block
yeah just arrived at that as well
Dispenser dispenser = (Dispenser) block.getState()
thx
Does bungee use offline or online UUIDs?
depends on settings i guess
What settings?
online_mode: true or false
Oh, bungee also has that option huh
Yep
only makes sense. Mojang was the one to implement that setting for the server
Never knew. Thought online mode should always be false
I'd assume that's for the actual servers now
On the spigot servers it has to be off for using bungee
For online mode tho it has to be the default of on in bungee
yeah a bit of a pain to proxy encrypted stuff
I see, yeah true. Thanks guys
what's this game called again that comes with windows and also has this kind of animation in the end lol
Solitaire, hearts, spades
lol
ah yes!
solitaire
thanks lol
I thought about it for 5 minutes
For some it just shows my age ๐
Is there a way to automatically update a server resource pack when a push has been made to a github? (The github repo is the texture pack)
sure
you can check whether the file has changed and then just... push the resource pack to all players
texturepack on github lol
yeah, but how would I get the server download the github repo, zip it and then replace the old one? ๐ Any tips on what I should read for this?
you do know that you could just create versions and host the zip/jar in that area of the repo?
there is that too
alright! Thanks!
so you can basically just provide that link as resource pack url
if teh whole repo zipped is what you want then http get for that zip it is
otherwise im sure there are some git wrapper libraries
yeah e.g. jgit
yep! That will work ๐
String repoUrl = "https://github.com/onecompiler/tutorials.git";
String cloneDirectoryPath = "/path/to/directory/"; // Ex.in windows c:\\gitProjects\SpringBootMongoDbCRUD\
try {
System.out.println("Cloning "+repoUrl+" into "+repoUrl);
Git.cloneRepository()
.setURI(repoUrl)
.setDirectory(Paths.get(cloneDirectoryPath).toFile())
.call();
System.out.println("Completed Cloning");
} catch (GitAPIException e) {
System.out.println("Exception occurred while cloning repo");
e.printStackTrace();
}
I have a question for which I sadly think I know the answer. When canceling a BlockDispenseEvent the inventory im accessing is already missing the correct items (this is what I want). However due to me canceling the event the item is added back after my event handling is done. is there any way to prevent this?
you could manually remove the item after the event
Hello, I'm not sure I'm in the right place, despite hours of research, I can't find a solution, so here's my problem; the server can't find my main class when I use Cauldron API, while with a Bukkit server, the plugin works perfectly. What should I do?
what's cauldronAPI?
Cauldron server to load Forge mods and Plugins
then ask at Cauldron's discord
I can't find it
When i put Essential, it works
looks abandoned
Personally my server uses magma a way better bridge
What would you use if you wanted to make a modded server that supports plugins?
Magma
Don't listen to Olivo do whatever you want to do
It's not for my server, but the only problem is that it's in a very old version (1.7.10) and so it's complicated to find something that is reliable and so old
How to compile project with additional dependencies maven?
yet it does not seem to compile with the proejct
I mean there is a reason most of those forge + bukkit projects die, but if thats what you want then oof
Well you're stuck then. Magma is 1.16.5 focused rn
Can spigot hide stack traces?
hide from whomst?
the console? Why would you want that (genuinely curious)
I see, the real problem is that a plugin like Essential works perfectly on the server, but my plugin does not work on this server (while on a traditional bukkit server, it works)
Because sometimes the bridge messed with something on the backend and didn't fix it on their custom version of Bukkit as well
did you try looking at essential maven/gradle file if thats available?
it seems to work for OP here
so im guessing you are doing something different from essential, id try to find out where
So there's nothing I can do?
Sponge is the best atm
How to compile project with additional dependencies maven? I have tried adding <scope>compile</scope> yet it doesn't seem to work
it had 1.16.5 builds recently
I see but the server that asked me for it needs to be in 1.7.10 unfortunately
seems like you want to shade your plugins
yes
how do I shade the dependency
which in turn there is also maven plugins for
in my final jar
maven-shade-plugin
oh 1.7.10
well, there's Sponge on 1.7.10..
Don't know how to use it? Apache's got documentation, look it up.
how do I specify dependency
theres also KCauldron
I have
?learnmaven
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>```
We should have that-
oh nvm
It's under configuration I believe one sec
?maven
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
yeah
woa
I don't see Sponge in 1.7.10 on their site, 1.8 is the oldest version
Or actually no, @gritty urchin
Shade will automatically find deps of the compile scope
And those will be shaded
provided deps aren't.
You should relocate dependency classes though
is that possible?!!!?!?!!?!?!???
As of 1.18, apparently it is.
oh mb that was removed recently
Yeah 1.7 is like more unsupported than the very unsupported 1.8 lol
You're probably building wrong.
No the fuck it ain't lol
We don't offer support for 1.8 anymore
sad
Pretty sure md_5 is eventually planning on removing 1.8 from BuildTools because of all the idiotic server owners who think they have to use it for PVP.
mew
mrow
๐
There are no performance gains from 1.8.
Well latest happens to be compiled with modern Java :p
well no shit it'd perform better, theres way less stuff on 1.8
thats a pretty unfair comparison considering the feature difference
Modern iterations of the JVM have improved bytecode, probably new JIT optimizations, and a bunch of different, more optimized GCs than the basic CMS.
xD
I'd argue it's not too different for servers :p
Wellll if you knew how the game was written you would know why that's not so simple.
gonna be honest.... its a bit different
Either way
1.8 starts quicker but chunk management is still as dogpoo as ever on all the versions
1.8 is not performant at all
It just has no features at all
DOS works better than Windows
everything works better than windows :lul:
(Linux cool)
Oh yeah also 1.8 vs 1.18 is a terrible comparison.
1.18's world generation is very complex.
The issue arises with whether features are the focus or PvP. Sadly, clowns over in 1.8 land circle about the PvP all the time and it keeps them in the dark ages
1.8 vs 1.17 probably not so much.
people who dont know that you can remove the attack cooldown in 1.9+
Yeah
yeh u cant
not fully
you will have an attack cooldown of 0.000000000000000000000000001s
๐
I mean 1.8 PvP is so boring.. No counterplay at all
^
my pre-1.18 servers loaded in about 10 seconds max, my 1.18 world? 25-30 seconds avg, 20 absolute minimum
oOoOoH noOoOo My StRaTeGic ButtERfLY cLicKiNG
๐ฑ
Fast clicking almost always kills your aim
i have no clue how people play with jitterclick
Yeah but it's the only way you can actually PvP in Minecraft 1.8 since it's that shit.
but muh blockhitting
I got angry when 1.9 dropped initially but nowadays I kinda realized how 1.8 PVP is just sorta meh.
1.8 pvp is awful
It's one of those things where it doesn't feel very satisfying to get good at? :/
the only annoying thing about 1.9+ combat is the regen
And there's not really
i make that my scroll works as the left click button ๐
skill
1.9 combat still isnโt great, but at least itโs not spam clicking bullshit
more so muscle memory
It's mainly the whole range-lock-no-counter-play stuff that makes it unfun
Yeah
Like I don't fuckin' know how most PvP encounters work lol
Fax
u could have like half a heart and then u eat some food and instantly back to full health
There's still an underground 1.9 pvp community filled with toxic kids
There's still a Minecraft community filled with toxic kids
theres still kids
i hate 1.8 regen
It's so nice to land like 5 cross in a row an out manuever your opponent
๐ซ But not for long.
Nah you can still craft golden apples, just not god apples.
yes
i hate waiting 5 minutes to go back fighting
pvp is impossible without gapples on 1.8
lmao
idk why but I've always enjoyed being that one guy on SkyWars who just hides the entire time
it's tense
and also slightly comedic
I just like stealth more tbh ๐คทโโ๏ธ
1.9 PvP is also kinda meh once you figure it out
I liked Hunger Games when kitpvp stuff was around and you could build huge tower bases
i wonder how often we discuss pvp here
it just standing in front of each other with shields
I mean yeah we ain't sayin' it's like a godsend or anythin'
the first person to try and hit loses in 1.9
you probably never played it lol
Just that it's better than 1.8.
as is 1.8 is any better
ive had my fair share of UHCs
1.8 UHC is hell
Axes exist
A thingo
Uhh, Shields are for noobs
one of those diagrams with the squares and arrows
Yeah I think that's a thingo
Axe pvp community suxxxx
:)
flowchart
lemme fuck some shield n axe normies on a record
if you hit with axe, you get hit back with axe and you dont have a recharged hit
only real way is to run around people which is pretty fun
Oh so you mean you're not supposed to rush directly into your enemy where it is obvious that they can perform a counter-play due to them having a range of attack on you?
Damn beat me to it
Like, 1.9 actually requires strategy and not just Zerg Rush maneuvers? :)
Clearly a PvP match should just be unga bunga bonking each other until someone falls over
one could argue the fundamental approach to pvp in minecraft has not actually changed
no i will not elaborate
Unga bunga bonk
Look at my status Coll
When enough new games come out where the mechanics of it are more fun than 1.8 unga bunga we'll see a shift
Kinky
theres a reason minecraft isn't actually known for pvp
Remember the combat snapshots
Damn ok then.
If shields are an issue in 1.9 pvp, why not just ban them?
I myself never use them, so it's not like it's any relevant to gameplay or anything
I've never had any issues with shields. To be fair I usually play on Cube not sure if they've nerfed them
โBlockhit substitutesโ
Oh yeah, never used blockhit either
how do i fix that
Despite me playing 1.8 pvp for what ... 8 years?
ClickedBlock is null. Do a null check
how
?learnjava ;/
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Clicking air
I mean blockhitting has become a crucial component of 1.8 pvp now apparently, when even servers take those into account especially geol
if (e.getClickedBlock != null) {// your code}
No, that is the wrong way to do it, you IDE will scream at you if you do that
Abstract it out to a variable and do a null check on that var
Early return ftw
damn
ye implicit else is very nice
thank you
The IDE will otherwise not know that getClickBlock is not null after the null check
if (e.getClickedBlock == Material.DIRT) {}
unnessecary variables but then conclure will say "the jvm handles that relatively good"
not unnecessary tho
Yes, but a pedantric IDE will be able to handle these cases better
What is the most efficient way of storing list of player's UUIDs? On every player join I want to check if his UUID is on the list
Use a HashSet
Use a set
or maybe even a CHM keyset if its in AsyncPlayerPreLoginEvent
sometimes i doubt if i should use a variable or not
Or linkedHashSet if iteration order is important
Sorry I mean storing on the disk
JSON
DataOutputStream
Read the list once at plugin start, then check it
Save the list again at plugin shutdown
I mean I'd argue for that most of times, unless its patches, go for the unnecessary variable, they are usually called explanatory variables tho.
Alright thanks for the tips
try (DataOutputStream dos = new DataOutputStream(out)) {
for (UUID uid : uidlist) {
dos.write(1); // If you want to save concurrently while not cloning any collections, do this
dos.writeLong(uid.getMostSigBits());
dos.writeLong(uid.getLeastSigBits());
}
dos.write(0);
}
I mean that is the fastest way.
For reading
try (DataInputStream dis = new DataInputStream(in)) {
while (dis.read() == 1) {
uidlist.add(new UUID(dis.readLong(), dis.readLong()));
}
}
Quick question here, I'm trying to modify a block from a certain world onEnabled. World is not loaded so I went to world load event. It still appears as if the world is null even tho it is on the WorldLoadEvent and it is that exact world. How do I wait for the world to finish loading or I just schedule the task? If I do, how long should it be or that changes?
why do you need the byte
Concurrency and not relying on EOT
i am still getting if you left click midair it is erroring
You cannot write the size because the underlying collection may change, so that is the second-best guess
Idk, you probably could do better things, I know
EOT?
I get the idea behind the whole byte separator thing
but I personally think saving the size is safer
(and also likely more efficient since it allows you to create a collection with an initial size)
when i left click in mid air it still erros and only right click errors when it is not the right line
I guess you could add a expected size value before any other value
?paste your code/ error
Hi guys is there any way to get a random stone block in ChunkLoadEvent?
iterate over all blocks in the chunk below y=59 and check if they are stone, if one is stone select a random number using Math.random() and check it to a certain value, if its below the value return the stone block
sounds a lot more complicated than it is
declaration: package: org.bukkit, interface: Chunk
You'd always have a certain bias
i'd do it async
declaration: package: org.bukkit, interface: Chunk
The only unbiased way is to just spam the method with fully random values, which means that 80% of attempts will yield air.
does entityspawnevent called when player is spawned?
don't think so
PlayerRespawnEvent
hi guys , i'm having problems with serialization in gson , its spam my console so much , idk what is this error about, can someone help?
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < 60; y++) {
Block b = chunk.getBlock(x, y, z);
if (b.getType() == Material.STONE && Math.random() < 0.01) // 1/100 chance
return b;
}
}
}
oh wait
That is severely biased however
And ignores the fact that there can be stone below y = 0
even if rarely
yeah but its simple
That is still biased
infinite loop
Code?
https://hub.spigotmc.org/javadocs/bukkit/org/spigotmc/event/player/PlayerSpawnLocationEvent.html
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerRespawnEvent.html
declaration: package: org.spigotmc.event.player, class: PlayerSpawnLocationEvent
declaration: package: org.bukkit.event.player, class: PlayerRespawnEvent
the type has reference to a type which has reference to the first type, do you use bukkit's Location?
You have two datatypes referring to each other, and thus you have a circulatory reference
i don't use bukkit location , just around uuid and enum and boolean
How can I get the Direction from one location to another?
maths. Should've paid attention to school because I did not
try replacing enum with string ig?
get B vector subtract for A vector
or write serializer/deserializer
i personally use strings
i convert all the enum to string before serialize it
Or if you are certain you will never change the enums, use it's ordinals
what is the difference between
PlayerInteractAtEntityEvent
and
PlayerInteractEntityEvent
public class PlayerInteractAtEntityEvent
extends PlayerInteractEntityEvent
Represents an event that is called when a player right clicks an entity that also contains the location where the entity was clicked.
Note that the client may sometimes spuriously send this packet in addition to PlayerInteractEntityEvent. Users are advised to listen to this (parent) class unless specifically required.
please do some checks before casting
What is extends
the class PlayerInteractAtEntityEvent extends PlayerInteractEntityEvent
what checks
for what reason
how can i get e.action from that event, i need to know if the player is right clicking thanks
PlayerInteractEvent is a subclass of PlayerInteractAtEvent
you're casting the block state to a sign before even knowing if the player clicked a block or just air and then you aren't checking if the block is a sign
vice versa
Oh right
Man yall need to stop spoonfeeding doc info to people and make them actually read the docs 
ssshhh
we should make a faq page about programming things
like how to make command, listener etc
fun
shouldnt all that be something everyone already knows?
ye.. not newbies
https://www.spigotmc.org/wiki/spigot-plugin-development/ I mean it's all here
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
and a small java guide page
Iโd argue for a lot of that if you need a step by step tutorial then you donโt know enough Java to be doing it in the first place
some of the resources are just bs
Well to be fair, there are things like NMS that you kinda need them for.
cant give one now but i saw really weird code
Then update it
NMS is very different from making a listener
Lol
Fair
but people still will be asking it here, you can't just force them to read docs or guide
just like with java
You arenโt going to make them a self sufficient programmer by spoon feeding them
Youโre doing them a disservice in the long run
agree
but how would you force them to read docs?
By not giving them the answer
You can force them by not spoon-feeding the answers and just linking the docs
If they donโt read it then they canโt move forward with what they want to do
Simple as that
Itโs not a matter of me โforcingโ them to read the docs
If they donโt read them I wonโt be devastated or anything
But Iโm not going to be the replacement for the docs because theyโre too lazy to read
Some of the docs suck though. Docs become pretty much worthless if they arenโt written well.
The only thing to go off then is the method names
the spigot docs are well written tho
Spigot and Java have very explanatory and robust documentation
Java does, spigot could use some work in some departments.
I've never had an issue with Spigot's docs, if you want documentation problems go make a Forge mod
Spigot could use some work but it is far from poorly written
We're bringing red herrings into this to distract from the point that learning to read documentation > asking a question where the documentation could or does already contain the answer
^
a random question: why is Enchantment enum enchant names not same as their real name? why ARROW_DAMAGE not POWER, why DAMAGE_ALL not SHARPNESS?
Because 2011
wdym?
That enum was made way back in 2011
tbh the internal names make much more sense
^
and? the enchant names was different in 2011? i am not that old
stuff has been unchanged since the beginning of the game when thats all it was. Since its a descriptive name it fits better
code takes awhile to change if the name is good enough, thats the main thing
what checks because it is spamming my console
maybe. but when you are used to minecraft names, it's confusing
Those were probably the old internal names
yeah true
but it's the names that mojang used iirc
If you want to use minecraft names use getByKey
any ideas
Simple null checks
Like a simple null check?
like simple instanceof
That too. I forgot this is the sign thing
smh
Oh my
if(e.getAction() != Action.RIGHT_CLICK_BLOCK){
return;
}
first check if the .. yeah that ^^
So much wrong
early return would be useful in this case
^^
Intellij is already warning you
what the f are you doing lol
i dont know some one plz
?learnjava Please
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
We can't just spoon feed you everything
Inb4 Objects.requiresnonnull
every single right click is on a sign
I'll sign for that xd
what the heck
Hue
three times setCancelled(true) lol
4
Casting to Playe there does nothing because getPlayer already returns a player.
Your first condition reads as "if getState returns not not null" which can be simplified to just "if getState reurns null"
and would therefor always throw a NullpointerException. getClickedBlock() will also sometimes be null leading to another
NullpointerException.
Dont use deprecated methods. They are deprecated for a reason and have a replacement.
Your e.setCancelled() calls make no sense. Also your intendation is abysmal and makes this really hard to read. Use ctrl + alt + L to auto format your code.
also they are casting the block to sign
and then 10 lines later check if it's actually a sign
lul
is PlaceholderAPI async? (I don't know where to ask this, i asked in #help-server, #help-development)
What do you mean by that? If its thread safe? What part exactly?
sec
PlaceholderExpansion
Are you asking if onRequest is called async? What exactly is the question ^^
He want to run sql queries in placeholder expansion
As i said before, cache the values on player join
It is, so basically i need to do MySQL request, how could i do it? even if i cache em it would be inaccurate *
update the cache...
4 million players? No
Keep cached online players only lol
Then the answer is no. onRequest ultimately blocks.
Any suggestions?
Cache. Values.
Use a cache
Wouldn't cache of 4mil players take much memory? I've noticed it take alot
You will never get 4 millions of players online
I have 4mil unique, and i might get 4 million players, you can't really know
I mean at the same time, on the server
Yes it would take quite a bit of memory. Thats why a cache does evict old entries.
You only keep those regularly used. Worst case a couple hundred.
A leaderboard that can hold 4mil unique players
That just called a sql table
Exactly
Not rly. A simple select query should be enough.
I don't believe that a player on the top 101 would reach 10th place easily
I tried, it took around 150 seconds
to use UUID.fromString() I just pass in the UUID in string format. Like if get a player's UUID as a string?
yes
Thank you
if i cancel a bukkitrunnable twice will it throw an exception?
- Thats a LOT even for 4 mil entries
- Not a problem. Juist update the local toplist every 5 minutes. Should be plenty.
iirc ye
I knew there something wrong with the query
how do i use
armorstandinteractevent
it says
Parameter is not a subclass of org.bukkit.event.Event Compiling and running this listener may result in a runtime exception
I used left join in it
to my question?
something like minigame
Is there a way to make a charged creeper invisible and the aura visible?
start with something simple
You mean PlayerArmorStandManipulateEvent?
thanks
mhz take a rest
I want a dollar for everytime someone comes in here making skywars/bedwars. I could retire soon
You just said you don't know how to develop dude..
Do a clans plugin with clan wars
WHOLE PRISON CORE??
Oh and do it for 1.8 also. We dont have enough pvp/minigame plugins for that version.
VIP Features, cosmetics, particles, bla bla
hmm i cant find the implementation but why would you cancel it twice?
just stuff that happens
Really stupid question, but does anyone know of a MIT-licensed (or similar) replacement of ConcurrentHashMap?
Wtf
I don't want to map everything around having it coded perfectly
maybe check if BukkitTask#isCancelled
(I want to fork the map and use it inside my own repo, which is why I can't just copy & paste the OpenJDK ConcurrentHashMap)
ConcurrentHashMap is part of the java framework...
You could take a look into FastUtil and see if they have a solution
Wasn't FastUtil removed in some version?
OpenJDK is GPL (even if it has a linker exception)
how to use a custom .yml file? i set the file in main in onEnable section, but in another class with plugin.... is not working. why?
Dont know why that would matter...
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
to use
Multi java version, anyways thanks for the help with the cache
yep, i tried plugin.name and it not works
Hm. shouldnt be too hard to implement one yourself.
o.0
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
youre returning a class?
๐ static ๐
probably. Guess It's worth trying it.
not even that
you know constructors exist
in main class?
welp. Not as easy as i thought XD.
return FileConfiguration;
i have the file set with
FileConfiguration lan = YamlConfiguration.loadConfiguration(lang);```
Hashtables are compilcated, but I think it is worth at least attempting to understand them
/ is fine to use in the file constructor
In what context we use hashtables?
does it translate it?
๐ code in constructor ๐
I think a more trivial approach would be sufficient. Didnt think about how bulk operations would be handled tho.
Hm the lock map might have to be a java.ConcurrentMap itself...
Yes
Locks are quite slow but yeah
I believe chm uses parallelism and conlevel to determine lock amount btw
If they are used. But most of the time the Map will be empty.
I mean honestly I probably could use a Concurrent map as a backend, I just want to minimize object allocations that are the result of me currently having to combine a UUID Int and another Int into a single object for the key.
why
why would you implement concurrent hashmap
gl solving thread locks
and other headaches
You might be thinking that it is premature optimisation, but I don't quite enjoy having a GC intervall of 14 secs on an empty server after it runs for an hour
cant you adjust that with a jvm arg presupposing one exists
wtf are you doing that there's so much to clean up to
I have an issue,
My scoreboard doesn't wanna update and its in a bukkit runnable and set for the on join method, So im just curious, how can i fix this?
This is my code
How to cancel Villager interact event so inventory wouldnt show
@Nullable
public PlayerAttachedScore getOwner(@NotNull UUID world, int x, int y) {
return leaders.get(new WorldPosition(world, hashPositions(x, y)));
}
Once for every chunk every 5 seconds is (for a reason I cannot understand) fast but (for a reason I understand) taxing on GC
there is no villagerinteractevent
how to cancel it
PlayerInteractEntityEvent
just use the player interact entity event
you can't cancel non existing events. cancel playerinteractatentityevent
can u help me if possible with an issue i got?
Thanks
And no it doesnt have to do with guis
np
whoa why is the font so ugly
eclipse
That is not the default eclipse font
That is just the absence of antialias
well what do you expect your code to do
moving past that, do you know why the bukkit runnable wont refresh the scoreboard?
to refresh the scoreboard
your runnable doesn't do anything useful besides setting the same scoreboard to the player all the time
you never refresh it though
....
all you do is "player x uses scoreboard y" every time
i thought resetting it refreshes it?
what do you mean with "refresh"?
like okay
you never change any values on the scoreboard
It doesn't refresh at all, if you want you can just put the whole code in that runnable
so I have no idea what you want to be "refreshed"