#help-development
1 messages · Page 648 of 1
#1100941063058894868 is the place for code reviews. Remember to read the pinned message!
what does World#hasSkyLight do?
what does the docs say
Well from the description I would assume it is the opposite of world#hasCeiling
that method exists?
Yeah
I think so
lmao
i would assume skylight as overworld
since the end doesnt have skylight
rhetorically
Is the end light level 0?
there's also World#isUltraWarm() lol
lol what
That's funny
world#hasCeiling is true for nether
They're asking about world#hasSkyLight
//in mainclass
private static Main plugin;
public static ManaFriends getPlugin() {
return plugin;
}
//in other class
private File file;
file = new File(Main.getPlugin().getDataFolder());```
is this usage correct?
why wrong ?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
It's for anything in java
why tf did they overcomplicate things lol
alright but why my this is wrong ?
couldnt they just do #isNether #isEnd #isOverworld
Nope
at me.vasir.manafriends.ConfigManager.initializeConfig(ConfigManager.java:18)
at me.vasir.manafriends.ManaFriends.onEnable(ManaFriends.java:10)
at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:266)
at net.md_5.bungee.BungeeCord.start(BungeeCord.java:295)```
If it has light in it by default
Aka
A sun
Did you forget to set plugin
or you called it before the plugin was initalized
also use di
u mean to onenable ?
well i create config.class without implement events
obviously getPlugin() returns null
you need to add plugin = this
nvm
to onEnable ?
Dude your not setting the plugin to anything
ah
blud has no clue what he's doing
OKEY
it seems network manager is no more on PlayerConnection in 1.20 so how would u guys get the players' NetworkManager?
?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.
UNDERSTOOD
playerHandle.connection.connection.channel.pipeline().addBefore("packet_handler", PACKET_LISTENER_NAME, handler); apparently
set the field as soon as possible
public class MyPlugin extends JavaPlugin {
private static MyPlugin instance;
{
instance = this;
}
}
but thats exactly what i need tho
It is, but is not called the same
Then go for it
Constructor
plugins dont have a constructor
technically they do
technically, but i wouldnt really recomened using them
It doesn't
im pretty sure its one with params
You can have a no-args constructor. Bukkit looks into your plugin.yml, loads the class and creates an instance
of your JavaPlugin. It uses reflections for this and needs a no-args constructor for this.
This
Huh thats interesting
no point in having a constructor though
Hello, arraylists are exposed to concurency problems when working desuss in async?
just use onLoad if you want that
Java "creates" it if you don't have it anyway
concurrency you mean
You can't have a class without constructor
using reflection to access it, just to be able to set 1 variable before onLoad is pretty pointless
There's no point in a concurrent list because order doesn't matter
yes
Just use a concurrent hash set
Or if you really need the order of which things are operating maybe some sort of synchronized list
why reflection? You can just create a no args constructor
im just going off what 7smile said
No, the simple action of creating an instance of a class, call to the method constructor, if not defined specifically, java will "create" one
i knew there was a constructor for the plugin, just not how you could access it
synchronized list is a special list like concurent hashmap?
hows that in nms obfuscated? player.getHandle().c but there is nothing really like connection
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
It's list where actions are wrapped with synchronized block
Which leads to utility constructor, a constructor shouldn't contain class "utils", for example, defining the instance of the plugin. Instead, and as said, a method should be specifically created
Collections.synchronizedCollection(new ArrayList<>());
do you mean that all operations such as .add are performed in the main thread?
But I got no clue why you're trying to preserve order in a concurrent environment
Just use a concurrent hashset
EntityPlayer.c.h.m
Sets.newConcurrentHashSet / ConcurrentHashMap.newKeySet
but that does have private access
I added an external jar to my plugin and included it in maven. Do I also need to include the dependency in my plugin.yml?
Right now the plugin wont enable spitting out errors that it cannot find some classes.
Which are part of the dependency I'm using.
without the order a list 1; 2; 3 4 could become 2; 4; 3; 1 right?
That's in any concurrent environment
Why did you add the external jar and use maven?
Asking about your attempted solution rather than your actual problem
How should I add my external jar then?
well, I'd need to keep order by performing the async task
If the entire task is performed async in a single separate thread then the order is maintained
either use reflection to access it or find the correct way to ac cess it
If you have multiple threads working together, the order doesn't matter because some threads can be quicker than others and your results would've never been in order anyways
mvn install it
then add the dep
if its a plugin add the depend: name to plugin.yml or shdae it
hey, how do you get the same effect as if you are standing under fire? i tried to setFireTicks but that only sets the visual fire... how do you also do the same damage?
got it thanks
won't the list get mixed up?
In what context?
Just explain what you're trying to do
Unless you want me to explain multithreading from scratch
i need to retrieve a list of player info from the db and display it chronologically in a gui
So yeah you can fetch the entire list however you want and then sort it
well, if you don't mind, why not? It would help me understand better.
The list won't get mixed up because you're doing a single database call in a single separate thread
So it's fine
?
this will take a while
?docs
Can i ask questions about Intellij IDEA in here? (I use it to code plugins for my MC server, but i'm kinda new)
🙂
sure ig
You can
can someone please help?
Alright. I now have a zip file which should be a JDK for 1.8 (https://builds.openlogic.com/downloadJDK/openlogic-openjdk/8u372-b07/openlogic-openjdk-8u372-b07-windows-x64.zip). How would i import/install that into Intellij? My guess is that it's from here: https://imgur.com/a/Dzjzef3, but how do i do it from there?
how can I check if a long is not set?
to use lambok do I need to shade it in my plugin
???
or is it avilable already in server jar?
what do you mean?
No? It will work only at compile time.
nvm I am stupid
lol
oh so it will create getter and setters for example on compile
that looks like one very cursed screenshot
no
how do i save file ?
or i need ?
bcs my set methods not working
it excplicitly mentions <scope>provided there
I have very little experience with maven, idk how to mvn install it
Thanks. But i need to do it before i start the project, right? This is how i got the screen on the image that i sent: https://imgur.com/a/OcigZGs.
And i want it to be a 1.8 plugin, but i can't select that without the JDK
Usually plugins have their maven dependency provided and I just copy paste it
is it another maven project
Yes.
run the install goal then
then just add the same maven info to ur other project
@sterile breach
re you using intelliJ? then just double click on "install" in the maven tab of the other project
.
you can also use JDK 20 for an outdated 1.8 plugin
you can also just create your own maven project without that mc dev plugin https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/
how do i save file with bungeecord configuration ?
if I assign metadata to the block, then if it is moved by a piston, will the information be saved?
Or how is it generally easier to understand whether a block is generated or placed by a player? Do a database or logic on MetaData or save all blocks in a List?
is it possible to make a fog/not so far see effect? my goal is to make players not be able to look very far, kind of like blindness, but a little farer
Could try working with shaders and a resourcepack
In short: Save which block was placed by a player in the PDC of the chunk.
You need to keep track of event like piston moves yourself.
and something server-side?
Then no
I guess you could do something with display entities
wdym?
Is a hard cut ok or does it need to be a gradient
then just keep a sphere of display entities around the player
what are display entities?
I would just use a limited amount of maybe 9 scaled blocks or something.
Then place them in a circle configuration all facing the player.
How can I make plugins work across multiple versions?? Please tell me how or how to do it
simple:
make it the latest version (if you dont use anything version specific)
Just use spigot. Old versions are almost always forward compatible
thanks
😴 tl;dr?
okay thanks, i understand
at the lowest level. Are threads managed by the processor?
uhh yea
and on a machine running Windows, for example. Each program is given a main thread and the possibility of creating others?
I'm talking about threads in general, not just java.
On the lowest level the threads are managed by the kernel.
I'll let smile do the talking
How can I save all the data about an entity (location, nbt tags and other entity-specific stuff) without actually saving an entity instance?
I just wanted to throw that in, feel free explaining the rest
Save into a list I mean
so the maximum number of threads depends on the processor? to give you an idea, an i5 processor can have up to how many threads?
You mean the same way minecraft saves the entity when a chunk is unloaded?
Idk, I just need to save an entity, delete it and then later spawn the same entity with all the same data, nbt, location and stuff
There's something called virtual threads
Anyone got any idea what causes this message?
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
(it happens when surefire starts running tests)
the maximum number of threads is dependent on how much ram you have to support the stack allocations of the threads
In that case you need to use nms and store the entity in an NBT Container.
can be ignored
also there are like a billion different i5
a what
which is false because modern OSes use virtual memory to not be hard dependant on ram
if we assume 32mb for every thread then you could spawn 1000 threads using up 32GB of ram to allocate all of them
virtual memory is just physical memory stored elsewhere
I think he meant hardware threads. No?
if I understand correctly:
let's imagine that I add a 1 +1 calculation to A.
then I also ask him for 1 + 2, unless I create another thread. While waiting for 1+1 to be finished, 1+2 will be put on hold in the ram?
while this is true it really depends on the system, the only guarantee is how much ram you have to support the stack allocation
So you're asking if the "instruction queue" is in ram
yes
either way it bugs me and I don't remember it happening before and idk what I changed to cause this.
probably yes since your program runs in ram as well
Might even be in the cpu cache
Each thread has its own memory section and interthread communication/synchronisation is very complicated.
You should try to tackle this on a higher level when working with java. Dont think about hardware threads or ram.
Most important thing you should take away:
Data is never thread safe. You need to create a system where
each thread accesses data one after another.
are our brains thread safe
no
when does our mutlithreading update drop
ptsd is like a memory leak
just connect your brain to the X hivemind in 2030
when is someone gonna make an implant that adds ads to our thoughts
thats already there
fuck
do you ever just wake up and be hungry?
everyday
how to set the render distance in spigot?
You can call setViewDistance() per world
nvm
whats the minimum?
oh
you need to use spigot.yml
1
1 chunk?
y
can you??
no, but i want to do it in the plugin
no
can you not do that?
Hm you can probably tinker with the spigot settings in the onLoad
and is it possible to set the view distance of the client?
Well, ig you can not send chunks that are further away than x, but I don't think the client accepts more chunks than set in settings
Hi, its possible to get an entity with a string?
exemple
String type = "cow";
Entity entity = new entoty(type); ?
you would have to value of the EntitiyType
how?
EntityType.valueOf(String)
ah yes thanks
Is it in theory possible to transfer a string into executable code like eval() in js? Like, let's say I need an /eval command that could evaluate any code I pass into it to debug my plugin
My problem is that when i open the dropdown menu for "Minecraft Version", I can only select down to 1.12, but i need a 1.8 plugin (i don't know alot about this stuff, i'm probably just dumb)
Java is compiled. You would need to compile it before running it.
But i think what you want is hotswapping where you can edit code and see changes
live in the game. Intellij can be configured to do this.
Then setup a project manually or change the version after project creation
?1.8
Too old! (Click the link to get the exact time)
also I hope you know basic Java before starting with your plugin
Yeah i know basic java
am I maybe able to compile the code into bytecode and then execute it on the server?
Yes you can do that
Myeah. Why tho?
Well there's some plugins that only works for 1.8 that i need, soo..
just for debugging purposes. Like, testing some configs maybe, idk
change version in pom.xml
Oh okay, so i can just select version 1.12 or something, and then change it afterwards?
yes
Okay, thank yoou
Like what? Kit pvp v17.3?
Here are all the versions you can pull currently
https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/
I don't remember, but i'm pretty sure that on some of the pages of the plugins that i have, it says that they only work for old versions, and besides the plugins, in newer versions of minecraft, there's the super annoying chat reporting thing
super annoying chat reporting thing
it's not really annoying?
how do i send message to console in bungeecord?
sout not working
Well i don't want players on the server to report someone, and then get them banned from multiplayer. That's why plugins like litebans exist
so kinda annoying
so just disable it
but anyways, i'll just change the version then
If they get banned they probably deserve it
How do I check if an item is a placeable block? I want to check if the player is holding something that can be placed (any blocks) or something that can't be placed (any non-block item).
declaration: package: org.bukkit, enum: Material
oh alright
chat reporting is very annoying, because it causes people to constantly cry about it - and that's annoying.
oh chat reporting itself? that's a decent feature
glad it was added
How do I cast an ItemStack to a Material though?
oh
It causes a block update
^
and since the seed is in an invalid position it will break
You can setType with a second argument false and listen to the physics event
This method should NOT be used to "hack" physics by placing blocks in impossible locations.
Do keep this warning in mind ^^
declaration: package: org.bukkit.block, interface: Block
Should I use MySQL Workbench do set up databases for a minecraft server?
everyone says i should you mysql to setup my databases
but i dont know which program
You need mysql-server installed if you want to setup and access databases.
^^
I do recommend just using MariaDB
Then make sure it's up and running. Then you can have your plugin connect to it and add your data.
It's fully compatible with MySQL queries and is what most people will be running anyways
ok, but this is the program you guys are talking about right?
No, the workbench is just a GUI tool that lets you access what is running with mysql-server.
It also kinda sucks tbh.
mysql workbench is shit
HediSQL >>>
this is what i installeed
So how do I get the NBT tags from an itemstack?
to do database migration for you
Postgres is nice
You should be able to open a terminal and run mysql then. If the server is already running then it will drop you into the mysql command line.
well which ones
idk what i should use, you are all talking about something else
Why do you need nbt?
use pdc?
?pdc
Generally, the compound tag has get methods or the likes
its just a fancy Map<String, NBTTag>
Are you wanting to just use MySQL or do you want a GUI to make changes a little easier?
idk anything about databases, i just want to set up a plugin and i need to save stuff, but i dont know anything abotu this
Hi, I am looking for a plugin that logs bans and mutes in my discord server could someone give me some suggestions.
Can I use pdc to add custom model data? (not only using it for that though)
Depending on what you are storing, you may not actually need a database. Databases are typically reserved for plugins that need scalability. If your plugin doesn't actually need it, then you can get away with storing your data in flat files.
i need scalability, i want it so save from server to serer too, so i definetely need it
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/meta/ItemMeta.html#setCustomModelData(java.lang.Integer)
Why not use the API
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
first two checks are redundant
MySQL tutorial for beginners - Learn MySQL, the world's most popular open source database.
🔥 Want to master MySQL? Get the full MySQL course: http://bit.ly/2uAoPM3
👍 Subscribe for more SQL tutorials like this: https://goo.gl/6PYaGF
⭐️Want to learn more from me? Check out these links:
Courses: https://codewithmosh.com
Twitter: https://twitter....
how do i get player from my command args ? in bungeecord
That's going to depend on what kinda of data you need to store. Is it going to be structured or unstructured data?
If you need structured data, then any SQL language will be the way to go. (MySQL, MariaDB, PostgreSQL)
If you use unstructured data, then any NoSQL language will be what you use. (MongoDB, Redis, Cassandra)
phpMyAdmin >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
Then you'll probably be best off using MySQL or MariaDB. Plenty of people here know how to write MySQL queries and MariaDB is just MySQL with some extra safety and QOL features.
That's just a frontend for MySQL.
💀
MySQL is backend/cli program.
If you want an easier way to modify data in mysql, then a GUI tool will be needed.
That is kinda not the same lol
Otherwise, you have to use the command line to update your mysql database.
really nice program
PMA is breaking randomly if using that shit program that i forgot how it's called
https://www.youtube.com/watch?v=Od-hGwKcTmg
i have found this video do you think it is worth it? he uses xampp?
Follow the video I sent
Tbh, I don't really know what xampp is. My best guess would be that it is some sort of software stack like LAMP.
but it is 3 hours i cant take this
yes but i would like to learn it bit by bit
Xampp is just easy way to install apache mysql and tomcat, like gui for all in one
i am a MEAN enjoyer
You don't have to watch it all at once
i want to use it and when a problem ocurrs i google again and again until perfection
bro what is all of this now?
What
apache tomcat?
You don't need any of that though. You just need the mysql server.
You can. Download is found here. https://mariadb.org/download/
have you ever interacted with a db
He literally said he needs structured data.
where
yes, but i want to have multiple server use the data
you must be an idiot
Use your eyes and read. (Scroll up)
why so mad
do you know what i mean by document based
yes yml
i dont know what this is either
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
Just ignore him. He's been bitchy for the last couple days. Hard to tell if he's trolling or just extremely pissed off at the world rn.
ur an npc
sainte why are you so mad then?
what have i said that makes me appear mad
you called me an idiot?
so?
seems mad
i am stating a fact and you say im "mad"
Someone not knowing something and have intention to learn = idiot
i may be re tarded, but i started programming two weeks ago
Seems right to me
Damn, I must be hella stupid then.
Same tbf
so learn then
dont ask stupid questions
How do you expect to learn if you don't ask questions?
by reading
His question is one of least stupid I encountered
Fr
I hope ur trolling
Hi, I am looking for a plugin that logs bans and mutes in my discord server could someone give me some suggestions.
you can make one, it should be pretty simple
@inner mulch Once you have either MySQL or MariaDB installed, you just have to make sure it's running in the background.
Your plugin will interface with the db using command line queries.
You can also interact with it using the command line if you want. However GUI programs make it easier.
HediSQL looks pretty good. Haven't used it myself as I use the built in tools that IntelliJ provides.
phpMyAdmin requires you to set up a lot of stuff in order to use it.
there are built in tools for databases?
In the Ultimate Edition of IntelliJ
oh
You can get the Ultimate Edition for free if you have a student email.
can you not afford education?
You could also try Beekeeper Studio. https://www.beekeeperstudio.io
Use Beekeeper Studio to query and manage your relational databases, like MySQL, Postgres, SQLite, and SQL Server.
public static void placePoster(Location location, String type, BlockFace facing){
ItemStack item = getCustomItem(type);
ItemFrame itemFrame = (ItemFrame) world.spawnEntity(location, EntityType.GLOW_ITEM_FRAME);
itemFrame.setFacingDirectionfacing.name(); //NOT SURE WHATT TO DO HERE
itemFrame.setItem(item);
}
public static void placePosters(){
placePoster(new Location(world,0,92,7),"Tablets",BlockFace.NORTH);
}
}``` problem is on the marked line, thanks
i havbe no idea what method to sie tp set direction or whatever'
what are you even trying to do?
place an item frame, with an item in, facing a certain direction.
why did you call .name
do you know java?
some
evidently not enough
declaration: package: org.bukkit.material, interface: Directional
problem isnt with it not compiling, i just dont know what method to call there
setFacingDirection takes in a BlockFace
so provide a blockface
setFacingDirection(BlockFace.NORTH)
for example
okay i think it working ty
is there a way to stop it POPPING every time its not on a block?
breaking*
Probably not anything reliable. ItemFrames will break if they don't have a supporting block. BlockPhysics will only go so far as any update that is caused to the itemframe will cause it to realize that it's not supported.
ItemFrame is an entity so I believe it just checks the supporting block every few ticks
Could use nms to override the tick behaviour
so it compiles with the red line
alright ty
is there some kind of event that occurs when a player takes any damage? I mean, after the fire, from the entity, from the fall
if not, can you give list?)
EntityDamageEvent ig
Does anyone here know how I can prevent the loading of worlds and the loading of chunks to have only the end dimension. So like the 2b2t lobby?
But if you wanna track what entity damaged, you should also listen to the EntityDamageByEntityEvent
thank you guys
Is there a simple and efficient way to temporarily save and update an inventory, for example in a trade plugin, or do i need to save it in a file/database to get the results im looking for?
is it normal to return object builders through factories?
When your making dynamic torches, what seems better? (A): You put an instance in a hashmap and update on events, accessing the hashmap and checking if the player is holding the torch. (B): You have a runnable and iterate through a list of instances, checking if the player is holding the torch, every few ticks.
im currently developing an api
that could be compiled only and accessed if the main classes are within the same class loader
so basically i could use builder classes to build implementation specific objects
without relying them on compilation time
that way i could edit the underlying code without recompiling the whole plugin that relies on it
A is better
HeldItemEvent for this
A is more efficient
But doesn’t a hashmap search the entire map for a key? If their are multiple players moving in a tick, it will iterate through the map twice, reducing efficiency?
hashmap get the hash of the object
through that probable index
where the object is
then does comparison operation to check if the object is equal
if it is equal it returns you
Oh, alright makes sense
if you want even more performance use IdentityHashMap in this case
it would compare memory locations (practically) of the player objects
that way it wouldnt need to hash the object
but be note it doesnt work for strings
and integers iirc
So besides strings and integers, it is preferable?
or if you want even MORE performance use fastutil
in javadocs it says it shouldnt be used because it breaks the contract of the map interface
but i tbh think if its created why not use it
This class is not a general-purpose Map implementation! While this class implements the Map interface, it intentionally violates Map's general contract, which mandates the use of the equals method when comparing objects. This class is designed for use only in the rare cases wherein reference-equality semantics are required.
because you have player objects
which are unique
what exactly is your problem?
I was wondering if more intensive operations would have to be performed in case A, but I was wrong.
scheduling runnables are a lot expensive operations
avoid them as much as you can
if you cant avoid them, then use them
some runnables require multiple threads to run
and firing threads costs performance
but nowadays software uses thread pools
which fire the threads as soon as the application launches
and it halts them until the work is provided to them
idk i mean
they optimize the hell out of runnables
or in particular functional interfaces
that's very short explanation, but you should get the point
but that's still expensive operation outside java's boundaries
na
Yeah, makes sense. Thanks for the help!
it compiles down to an invokedynamic bytecode instruction
much faster than invokevirtual
what i meant is the bytecode instruction would get interpreted in binary level
and OS level operations regarding threads are not cheap
yeah threads, but runnables arent synonymous to threads
i mean sure to a vague extent
tho in essence its just a class with a single method, nothing more, nothing less to it (well not rly true but u get the point)
am i check if online and last login date ?
with bungeecord ?
Use UTF-8
^
How do I set UTF-8 ?
if you're using gradle build system for building plugins, add this to your build.gradle.kts
tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
}
}
if you're using maven build system for building plugins, add this to your pom.xml
<project>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
also its not recommended to do coloring like this, it really depends on the encoding and that's a bad design
and coloring like this exists only for legacy support only
it doesnt work with hex color codes as well
overall its a bad way
if you're using paper, i suggest using TextComponent by retrieving it via Component.text() method, which is provided by adventure-api built into paper-api
?whereami
or use bungeecord's chat components
dont be mad md_5
i should be mad that spigot doesnt have proper component support
am i check players is offline or online ? with bungeecord ?
soz havent touched proxy servers (like bungee), so cant answer this one
there is no such thing as an offline player in bungee
how can i name a builde rclass which provides, when built, multiple objects of the same object
and a builder class which when built, provides one object
i was thinking
PluralProviderBuilder
and
SingularProviderBuilder
but it doesnt sound right for me
any ideas?
i dont want to put it inside one builder since implementation could be distinctively different for both of the classes
FactoryBuilder maybe?
like the builder builds a factory
and the factory is used to create objects
yes but im pretty sure there would be no method besides build() for factory builders
and it sounds a bit silly
your system sounds silly
it separates user code which uses objects from implementation classes
how's that silly
i dont need to recompile plugins in that case
if the same builder classes with the same method names exist
ImplementationClass -> ImplementationBuilder -> Builder interface which is retrieved through some endpoint -> build() retrieves Object interface with implementation specific object -> use that object without relying on the implementation code
I mean thats fine but then I would atleast name the class after what it is trying to build
instead of generic builderfactory
because I wouldnt be able to know what it builds or factorizes from that name
im not building factories i use factories to create implementation specific builders
im naming them properly, i just provided the example
Getting this error:
https://paste.learnspigot.com/orenesamaf.md
With this code:
https://paste.learnspigot.com/uyoxuwured.java
line 140 in the code is: } catch (WorldEditException e) { Has anyone ever gotten an error like this/similar to this. And have an Idea of how to fix it?
LearnSpigot provides a free web-based pastebin service for storing and sharing code snippets with anyone. Powered by hastebin.
LearnSpigot provides a free web-based pastebin service for storing and sharing code snippets with anyone. Powered by hastebin.
im sorry to ask such generic question, but have you tried updating your world edit plugin? 😄
maybe versions do not match
if you're using vanilla WorldEdit, it could be laggy with large structures as well
FAWE solves this, but im not familiar with its implementation
this is not an error
its just that the server hangs for over 10 secs with no tick updates
[22:48:25 ERROR]: --- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - git-Paper-550 (MC: 1.19.4) ---
[22:48:25 ERROR]: The server has not responded for 10 seconds! Creating thread dump
also to make md_5 happy
?whereami
You should be happy we don't use components for everything in spigot
oh lol, true. recently changed xd.
Components are neat
Not when you use them for everything 🗿
Like, why replace sendMessage(String) with sendMessage(Component)?
I keep on getting
Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
I added 2 dependencies to my plugin which it uses. But one of the dependency I added also uses the 2nd dependency I added.
I ran mvn install on both of the plugins.
And then threw the dependency into my pom.xml.
Hi, in an hashmap its possible to stock pultiple value for the same key?
package me.c0kerat.testingplugin.Commands;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class ArmorstandCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length == 0) {
p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
}
if (args.length == 1) {
switch (args[0].toLowerCase()){
case "baseplate":
if (args.length == 2) {
if (args[1].equalsIgnoreCase("true")) {
p.sendMessage("you chose true");
}
if (args[1].equalsIgnoreCase("false")) {
p.sendMessage("you chose false");
}
}
p.sendMessage("you need to provide a true or false statement");
break;
default:
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cPlease use a correct parameter: &e[baseplate|arms|pose|small|visibility]"));
}
}
}
return true;
}
}
im trying to make an easy to use armorstand command, but for some reason, its not detecting whenever I have true or false as my argument 3. please excuse any poor programming optimizations or just straight up stupid coding since ive only pretty much learnt the basics
you can use a MultiMap for that
multi map is like hashmap but i can add multiple value for any key?
yea. im not sure a multimap is in standard java lib tho
take a note u can do it with normal map too Map<Key, Set<Value>>
Multimap is in Gson which is provided by spigot anyways
Doesn't have to be really
you are checking if the arg length is 2 inside a block where you checked if they are 1 in length
that can never be true
nvm i read that wrong
no i read that right
lmfao
yep
and caffeine can use multimap?
not sure what u mean by that
by default, caffeine works as a basic hashmap, it can work as a multimap?
Caffine supporst lists?
they just use generics in their caches
there is no MultiCache in caffeine its rather uneeded too
okay
okay okay, I'll state my problem. For each player I need to store instances of classes that I load on startup and unload when he leaves. And per player I may have to store the same instance 10 times sometimes. How do I tokenize them? hashmap? array?
And per player I may have to store the same instance 10 times sometimes
This seems like a design flaw
also if you're just going to load on join and unload on leave just use a ConcurrentHashMap
I can't do otherwise. Each instance represents a row in the db.
why not have one dataclass? having 10 seems like a huge design flaw
I assume its probably some kind of home system
and those are actually instances of Home class or smth like that
an instance containing a hashmap?
or I don't really understand why you need that
what's wrong with a Map<UUID, List<Home> in that case? is that what we're trying to avoid or sometihng
nah i see nothing wrong with it
though I think in this case if we're using a database a data class is more appropiate
just trying to understand what is he trying to do
so
class PlayerData {
private final UUID uuid;
private final List<Home> homes;
}
seems like the best solution to easily load from a DB
then just have a PlayerDataManager and you're good to go
Any Map can work as a multimap
^^
Hey I want to display the rank (prefix) of a player in a message I sent with my plugin....How can I get the prefix?
Is there a simple and efficient way to temporarily save and update an inventory, for example in a trade plugin, or do i need to save it in a file/database to get the results im looking for?
mby with a Map
i thought of that too, but would it be inefficient? storing each item that the player put in the trade
You store the inventory object
Not each item on its own
in a trade inventory, both the people put their itemsi nto it
And I think as loong as you dont perform any not thread safe issues its no problem
Yeah and everytime someone puts something in you update the inventory in the cache
okay
Thats the best way to save something temporarly......You don't need to store it in a db
ok thank you for the help :).
make sure your plugin jars from the plugins folder
so it doesn't load the old one
How are you compiling your jar
I actually think its the best solution...I mean a DB is too much for a short inv and you just have to update something as soon as there is a cliick event and the inventory is the one you are monitoring
sry to interject, how can I get a block object?
okay
You could create an Object like "TradeContainer" and this one stores the Inventory , the players who are trading and the items each player offers
And then you have everything you need
i have never used objects (as far as i know) what the difference?
Are you pretty new to Java?

Its just a class where you store stuff
yes, i started 2 weeks ago
Object is the instance of the class
SCHNITZEL xD
german?
ah nice okay...Just one thing....I ve someone ever tells you to just learn the basics and does not help you...Fuck those people
yes
new keyword instanciates it and makes an object
im german too, and i agree, telling ppl to learn the basics doesnt really help them
yes had that
i mean there are flip sides to your point
on one hand you cant really teach java properly on discord
on everything
on the other hand being rude doesnt help either
yeah but most of the time suich people are just rude
yeah, i mean if the person doesnt know something like if statements they should probably learn the basics first, but if the qeustions are more complex its not helpful so say something like that.
The problem I had back in the day was that I only knew the german names for something like constructer....Then I asked what was is and the only answer I get is "learn java".....It doenst really help if you just tell someone that without knowing why someone does ask that
yeah thats not nice
yeah
you are right, i will start developing my plugin now :)
I'm getting this error when starting my server
[00:55:53 ERROR]: Could not load 'plugins\helper.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!
In my plugin, I'm using 2 dependencies, i mvn installed both of them and then threw them into pom.xml. The thing is, one of the dependencies uses the 2nd dependency aswell in it's code.
Are you doing new MyMainClass anywhere
not in my own code.
Are the dependencies doing that for some reason
Well they might, but when both of the dependencies are on my server and I remove my plugin, the error doesnt occur.
make sure there are no circular dependencies or whatever it's called
Well the dependencies are actually connected, the first dependency (a prison core) uses the 2nd dependency (the helper)
it's fine for them to be connected as long as it's not in a circle
if A depends on B, B can't depend on A
Well yeah my plugin depends on the core since I'm using it's functionality.
The core uses the helper
But noone needs my plugin in order to work, so there should be no circle.
But there is that error.
Do you have 2 plugins with the same name
are there any lines in the stacktrace that trace back to some of your code?
oh right I should've started with that lmao
no.
Yep.
Only one, let me show it.
?paste
Well, something is somehow creating new instance of class which is extending JavaPlugin
Do you have two Plugins with the Main class called "Main"?
No.
Send ExtendedJavaPlugin line 56
CompositeTerminable var10001 = this.terminableRegistry;
Just some member initialization
What are those var namings
Not sure, not my code.
Yep
thats the beginning of my class
which extends java plugin
the line of the class definition
I got that
Before compiling
Its a warning
[WARNING] WildTile-1.0-SNAPSHOT.jar, XPrison-1.0.jar, helper-1.0.jar define 2 overlapping resources:
[WARNING] - META-INF/MANIFEST.MF
[WARNING] - plugin.yml
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
That is not really problem
Gotchu.
Are you shading your helper lib
Is that helper plugin open source?
And trying to load it too?
Oh well, I didn't notice plugin yml here
I don't think you're supposed to shade helper
How should I add it to my project then?
Maven or gradle?
iam adding with maven
Set scope to provided
Done.
I ran mvn install on the helper jar file
and then added the dependency to my pom.xml
Thats how I did it
Well I have no idea how to go from here.
It cant be the library problem, its such a big plugin they would have discovered it already.
Okay
I added the <provided> scope to both of the dependencies
now I don't get the plugin already intialized error
but now it spits our errors that it can't find classes
Do I need to include the dependencies in my plugin.yml aswell?
Did you add the helper jar to the server
Try doing that
How do I know the correct names to add there though
That worked.
if (!Bukkit.getPluginManager().isPluginEnabled("XPrison-1.12.2-RELEASE")) {
this.getLogger().warning("Unable to hook into UltraPrisonCore! Disabling...");
this.getServer().getPluginManager().disablePlugin(this);
return;
}
this method does not work, it returns false, even though I have a plugin named exactly that in my plugins folder
Also XPrison is in my dependencies in the plugin.yml
I tried changing the XPrison name to Vault and then the method worked correctly.
i suggest using bukkit service api
that way you dont need to retrieve the plugin by its name
and you can just specify that api class instead
That worked, now I'm just getting this error in the console:
[02:23:23 ERROR]: Error occurred while enabling WildTile v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
i Honestly dont know what the fuck is going on today
onEnable
i meant depend not loadbefore
am i correct thinking that you've added depend: XPrison inside plugin.yml
there's probably more lines of stacktrace than just this
X-Prison
yeah
As the plugin.yml had it
Okay I closed the server instead of reloading and started it again, you were right, thats the error: https://paste.md-5.net/ujobixewoz.css
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[WildTile] Successfully enabled!");
That has literally never caused me any problems before
In other plugins
im pretty sure your field inside ChatColor.translateAlternateColorCodes() somewhere is null
i doubt that this is actually line 13. Or if it is, then the stacktrace you sent doesn't match your source code
reloadDefaultAttributes() line 49
null string object inside ChatColor.translateAlternateColorCodes()
if i had to guess
or does WildTileEnchantment extend XPrisonEnchantment?
yes it does
then it looks like you're creating your enchantment instance before XPrison got properly enabled
check in your log whether XPrison gets enabled before your plugin
it does
is this prison thing on github?
ALso the code should be in the correct order, I just checked + I followed the exact Devs guide on github
yes lemme send it
the message parameter in TextUtils line 26 is null, so lets see where it comes from
there is no "RawName" set for your enchantment in the xprison enchantment config
this returns null for your enchantment
and then it gets passed to translateAlternateColorCodes which doesn't accept a null to translate
no, this is line 26, and "message" there is null
there's either no Name or no RawName set for that enchantment
Yeah I had to add that to the config
I did add it
I still get the exact same error
Even though i shouldnt
cuz I specificied both the rawname and name in the config as the dev guide asked me to.
Yeah Idk i literall added the rawname and name to the config
Like the dev guide told me to
Still null
Would block.getFace() return the face that is forward on a dispenser?
Cause I need a way to modify dispensers but make it look vanilla
It’s part of BlockData
Thas rly weird, I removed the text i added to the config and just switched the id of another existing basic enchantment and now my plugin works
It returns a blockface. But from that method you can specify which face you want
Thanks for that.
Which property
Check which BlockData type dispenser uses
It’ll be in the docs of its material
I think it’s orientable
When I get the Dispenser event’s (forgot name) block, it won’t let me get it as a Dispenser type instead of just block
THe example code provided in the developer api didnt include "GuiName" parameter in the example config and provided a wrong copy paste lmao
What
I try to get the block as a dispenser but it says I can’t cast it as one ( because the only block that comes from the event is a dispenser )
Show the code
K idea is being slow so one minute
So it won’t let me copy for some reason
There is the code though
Yes
Can u store an arraylist in a hashmap?
I just need to dispense custom spawn eggs like charged creepers and giants
They are just spawn eggs with pdc values
block.getRelative(face)
Yes
Okay thank you
But is it possible to edit that arraylist though?
Like add objects
I'm trying to store the player's created hologram so that they can edit it
That returns the block at the face, is that the dispenser or the block next to it
Yes
But if you find yourself nesting collections you probably want a data class
Well the dispense event only returns a dispenser so yea
uhm the problem is, I don't know what that is. I'm new to java, it's only been like 3 days
A data class is a class designed to just hold data
In this case you’d have a Map<UUID,DataClass> and the dataclass would have all the holograms
As well as methods to interact with them
anyone can help me with bungee messaging channel?
I see it on the docs
.
You need the BlockData one
Yea now it works lol
nobody?
?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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I am trying to do a cross server staffchat using the bungee messaging channel, the thing is that the message is sent but the other server does not receive it
The server needs an online player to receive it
and there is one
Show code
public void bungeeStaffChatSend(Player sender, String message) {
if (!plugin.getPlugin().getConfig().getBoolean("bungeecord")) {
return;
}
String format = plugin.getConfig().getStaffchatFormat().replace("{player}", sender.getName()).replace("{message}", message);
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(format);
sender.sendPluginMessage(plugin.getPlugin(), "kumastaff:staffchat", out.toByteArray());
System.out.println("Sending message to BungeeCord");
}
@Override
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) {
if (!channel.equals("kumastaff:staffchat")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String msg = in.readUTF();
System.out.println("Received message from BungeeCord");
player. sendMessage(msg);
}```
Did you register the plugin channel
Yes I believe
show proof
and in the main I did
StaffchatBungee bungee = new StaffchatBungee(this);
bungee.load();```
No
Yeah that's your problem
oh
and what should i do then?
Switch to redis or make a bungee plugin
Is it very difficult to use redis? xd
eh
can you open an inventory asynchronously
U h h
Great question
don't think so
ok
is that a yes or no
It's not complicated
But it's an added dependency
you'll need a redis server
and to either shade or use the library loader feature to load the redis driver
oh
Then how can I open an inventory when the player is done chatting
runTask, do your thing
How do I give infinite potion effects to players? Like with the /effect command in the newer versions?
set the ticks as integer.max_limit
do you also know how i can remove certain effects from a player or can i only remove all of them at once?
Use -1 for duration
literally use your ide
There is a constant for it somewhere
and just type "player.potion" and see what it comes up with
PotionEffect.INFINITE_DURATION
if you are not willing to help on this question then dont, but when i looked i couldnt find something like that
maybe im blind
thanks, do you also know if i can remove certain potion effects of a player?
removePotionEffect
