#help-development
1 messages ยท Page 220 of 1
worst code ive seen in months
?basics
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.
learn java before using spigot api atleast the basics
has his IDE open
That can't be true. You aren't that inactive in this channel
?paste
?
he just insulted you
im active when you sleep
oh lmao
lmfao
I said "not inactive". I know you are active. That's why I said it can't be the worst
mongodb is really fucking with me
invalid bson name 'id' when inserting and its valid when retrieving ๐ค
I don't think I've setup maven to shade correctly because I have a small plugin and its coming out to be 293KB. Heres the important bits of my pom. https://paste.md-5.net/koleninoje.xml . I'm just doing a package build, I read a clean package build would do it, tried it, didn't change the size.
oh shi
just mark it as provided and your good
fellow vscode user ๐๐ฝ
๐ญ
yeah...
i tried to create a maven archetype and that didnt go well
it had been like a week and i just wanted to code
lmao you see I just have a copy and paste pom :P I barely even use my own archetype
see i didnt wanna do that. I thought I could setup something that would like allow me to input the things i wanted and generate a pom
you can google about static block too
toReturn.setContents(InspectRequest.victim.getInventory().getContents());
why help him ๐ญ please lord just atleast help him learn java
does mysql have a visual client or something like mongo compass I want to beable to visualize my data
with that much static clearly not
aye look
Print inv_size
he'll come around
my first plugin I made didn't even know wtf static was lmao a blessing in disguise
my first project became 10k lines long cause i didnt know what a map was
something like phpmyadmin or workbench ?
my first plugin was so jank at the start
yap, you can google its probably what you want
Yes or console
im starting to regret not using sql
your bson file structure makes no sense
I don't understand why you are putting more doccuments inside of your base doccument it seems kinda uneeded
also may be your cause of error
whats your favourite debugging method, System.out, logger or bukkit.broadcastMessage
dont you just have a root documennt where you put other documentns in?
sysout
logger is just too much of a pain to type out its needlesly long same with broadcastMessage when I could just type sysout and its there
Debug.log best
wonder if i should add a debug method to my lib
have you read mongo docs? thats what I did when I first started they have good docs
they arent telling about complicated stuff
same error
dunno what the dif is between Document and BasicDBObject anyways
son ur code has bigger issues
show ur User class
it isnt pojo mapped lol
don't have to use pojos nvm
i see
the link I sent talks about mongo docs what your doing isn't very complex either you should be able to apply from that
whats the point of that new object id vs a id field or smth?
think its like THE document id
thats just creating an empty _id for the doccument
iirc it'll gen a random ID if you do that
in your case _id would be a players UUID
im now wondering when to use _id and id
afaik _id is the doccuments id
the actual id mongo uses is _id
^
in the case of player UUID ^ this will be okay
oh shiiii
they have different uses
i just watched a video that said to never use mongodb lmao
sql doesnt have that weird errors unless you dunno how to write statements lol
lol that video is dumb
it has its uses
web-devs ๐
smth like this maybe
I think you need to use the Updates class
rather than adding to the document directly, add an update like they do in the docs
weird syntax just to upsert but it probably makes more sense for single updates
that looks horrible
Hello! I am trying to clean up my code a bit. And in my onEnable() it looks terrible with the command registering. Because I have alot of commands for my smp server. So I was wondering a good way of cleaning it up.
Here is an image of just over half of the commands:
Thanks!
only way I can think of is to use reflection
is it possible to get a player from its string name?
(example: Player p = (Player) stringPlayer;)
or just have a set of all the command instances and loop over them
Bukkit.getPlayer
:O
is that undeprecated now?
Bukkit.getPlayer(UUID/StringName/StringUUID)
Get offline player from name is deprecated afaik
is there a faster way? cause that would take awhile.
what about users.updateOne(Filters.eq("_id", user.getUniqueId()), document, new UpdateOptions().upsert(true));
does that work if the document doesn't already exist?
Thanks :D
you'd think so if it allowed upserts
lets see
what would take a while about it
Does anyone have experience with Spring Boot, Spring JPA and Liquibase? If so send me a DM, would really appreciate it if someone could point my in the right direction. I basically want to automatically generate migrations and be able to apply those to my DB just like in Entity Framework (.NET). Thanks in advance! ๐
tph is probably a better place to look
?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!
making a set of all the command instances because i have like alot of commands
ok not working
is there any documents in the collection already?
You could look at the reflections library to get all the classes in a package and do it that way
im hosting on that atlas stuff or smth and it says there is nothing inside :/
im terrible at reflection. but ill check it out i guess
maybe the field is invalid because it doesn't exist in any of the documents?
but also you would need a collection anyway to be writing these documents to
im setting up the stuff
how can I hide those names
listen for a server ping packet or something like that
doesnt ::getCollection ensures it gets created tho?
not sure if theres a spigot event for it
im not too sure, havent used the java library
it doesnt return null anyways so it should
yes it does
I tried ServerListPingEvent but there nothing
however you don't have a database
there are however ::createCollection methods
the docs don't mention it
ahhh i can't embed links
I really should verify but I hate my forums name
its like 6 years old
lmfao
lets try database.listCollections().forEach((Consumer<? super Document>) doc -> System.out.println(doc.toJson()));
but you have no collections
atlas is showing you that
you definitely need to be using Updates though
follow that exactly
doesnt print anything
but you have no collections
atlas is showing you that
and how can i use Updates for tthat tho :/
rather than give the document an id when you intialise it, I think mongo may do it on the line when the upsert is done
so create the document for the home as normal
after calling create database::listCollections outputs this
ok calling createCollection twice gives an error too :/
I think I'm a stupid you're right the shadow file was already in plugins file Lmao
ok inserting into atlas doesnt work
gradle ๐
java ๐
skulls ๐
opinions ๐
pojos require awful stuff
like having non final fields and setters ๐
why cant it just use reflections
another java l and kotlin w
so after I just upgrade gradle, why then does intellij also need to download ahhhh
Did anyone help me in world gurd plugin
no they didnt
all this effort because I can't be bothered to manually install jdk18
๐ค
arch jumps straight to jdk19 the second it becomes available
you'd better not be using windows
college lmao
probably why none of the code works tbh
my only teacher that uses linux is teacher computer systems
ye i might but im wondering if i can share programs over both oses
what do you mean by share
dont want to install everything twice
some jetbrains stuff, minecraft, spotify, discord and those things
none of them are massive though
dont have that much installed on my pc actually
when you think about it, most of the big stuff you could only keep on one
depending on what you code, its plausible to only have intellij on one and not on the other
then all games go on windows
hmm
im thinking what classes would require a windows os
maybe for programming if that stupid bluej doesnt worrk on linux, probably does
ugh need excel too
yeah libre suite is not where its at
well ye still dont know how to solve this
yeah just getting things set up I'll figure it out now
bored anyway
what's the roouser password by default?
haven't used mongo in a while
is it just account pass?
to login into atlas or what
dw making a new user
how do i include nms packets in buildtools when building my jars
Ah, glad you figured it out
im wondering if i need a new Document for the homes and in there each home as a separate document too?
mongodb 
Works great for storing simple things
i've been trying to figure out why my code was working only to realise my ip wasn't whitelisted
@tardy delta im dumb and was using updateOne not replaceOne
it works fine the way you've done it?
just dont give the user an id
val users = client.getDatabase("plugin").getCollection("users")
// Setup
val user = User(
uuid = UUID.randomUUID(),
homes = mutableListOf(
Home("home", "world", 0.0, 20.0, 0.0),
Home("farm", "world", 20.0, 20.0, 10.0),
Home("portal", "world", 20.0, 20.0, 20.0),
)
)
val userDocument = Document()
user.homes.forEach { home ->
userDocument.put(home.name, Document().apply {
put("world", home.world)
put("x", home.x)
put("y", home.y)
put("z", home.z)
})
}
val filter = Filters.eq("_id", user.uuid)
users.replaceOne(filter, userDocument, ReplaceOptions().upsert(true))
eh you can read it
glad
I tried to make it as readable as possible without using java
so with not giving the user an id you mean not doing this
then append it later?
You are searching via "_id" property which doesnt exists on your database documents
does not matter
no need to append it, when it doesn't match the filter mongo adds it
thats how upsert replaces work
wouldn't matter anyway, mongo doesn't have a schema
you can query any object to have any field, mongo just wont return it if it doesn't have the field
I dont understand your point
if it exists or doesn't exist, it doesn't matter
No, if mongo doesnt find the query field, will yell with the Bson field exception
I have tested that you wont make me change OOP - in case you are expecting that
Kotlin ๐คข
no
thats not how mongo works
that defeats the whole purpose of mongo to begin with
it does not have a schema so you can rely on certain fields existing
so when you query a field, it cannot just fail if it doesn't exist
that's to be expected
I dont care how works or not, the point is said. When you query with field not contained on documents, will shall with Bson field exception
So stop it please and ?tryandsee
that does not matter
this is mongo
what are you not getting
thats not how mongo works
fun main() {
val settings = MongoClientSettings
.builder()
.uuidRepresentation(UuidRepresentation.STANDARD)
.applyConnectionString(ConnectionString(CONNECTION_STRING))
.build()
(LoggerFactory.getILoggerFactory() as LoggerContext).getLogger("org.mongodb.driver").level = Level.OFF
MongoClients.create(settings).use { client ->
val users = client.getDatabase("plugin").getCollection("users")
users.find(Filters.eq("noexist", true)).forEach {
println(it)
}
users.find(Filters.eq("_id", UUID.fromString("255fd3ba-dbe6-4edb-80c6-4a828fa258e2"))).forEach {
println(it)
}
}
}
Document{{_id=255fd3ba-dbe6-4edb-80c6-4a828fa258e2, home=Document{{world=world, x=0.0, y=0.0, z=0.0}}}}
Process finished with exit code 0
that is the full output
no errors
latest mongodb sync driver
try this:
Document doc = users.find(Filters.eq("noexist", true));
And tell what happens!
I did
๐คก
It will shall you with the exception
that line is in the code i just sent
here, I'll write it in java so you can understand
yeah kotlin is cance really shity syntax
?paste
is there any reason to use that uuid representation?
I'm just using it as im setting the document id with a uuid
and you get an error saying you haven't specified the uuid representation type
and that fixed it
ah
how have you done it?
heres your java code
the full output:
Document{{_id=255fd3ba-dbe6-4edb-80c6-4a828fa258e2, home=Document{{world=world, x=0.0, y=0.0, z=0.0}}}}
thats the full collection
like I said
mongo has no schema so it cant complain if you query a non existing field, because the field doesn't have to exist on all documents
if it threw an error if a field didn't exist, how would mongo possibly work?
lemme test
not all documents have to have the same fields
therefore, you wouldn't be able to query a field if it didn't exist on all types
your logic doesn't make sense
its the first time im using it smh
I'm talking to VERANO123
not complaining about you ๐
I started a test project a while back because I wanted to mess around with mongo and graphql because i hadn't used either but never actually wrote anything
so I haven't either
I just understand how it works
yes another error message
mongo supports arrays, so I would recommend storing all these homes in an array rather than just in the user space
show code
does the user definitely have a home?
lets print the json
but dont i have to store the users uuid too to later search on it
its hard to explain
the first argument of the method
Filters.eq...
checks if there is a document that matches it
because there isn't, it creates the document you've given it
and gives it what you checked against
ahh
because of upsert?
yes
exactly
if you passed it normally, you'd be trying to change the id to the same thing
which I don't think would be wrong?
but i don't know maybe id is immutable
i believe so
you'd hope so
which is why im suggesting you store all the homes in an array
you'd just have an empty array
which is fine, you can store an empty array
is there really a point to do a db operation then
how do you plan on loading this data? you'd have to loop through all the fields in the database
what happens when there's more than just homes stored in there
you'd have to have some way to distinguish
smh home name is test
you are using replaceOne now yes?
ah fuck
ahah that's what happened to me when I first tried
i guess so actually
u cant use completablefuture when you start connection with mongo ?
oh?
you can?
just wait till its finished initializing, that would make sense
wait do i need replaceOne nw?
yes, you are replacing not updating
if you were updating, it would leave old homes
unless you specifically removed them
or used an array
after creating a home, the saving seems to work
2 options
loading is meh
- which i don't recommend, check if they have a home first and then update
- store in a array
array ig
and its more clear what each document is
map each home to a document, and then put the list in homes
you'd have to store the home name in the document now
im just saving a list of homes now, wondering how it retrieves them
there's a getList method
and homes is a List<Document>?
yup
smth like this?
only wrong parameter type ;-;
can i also just save the players uuid in there?
yes that's where you'd want it
Document userDocument = new Document()
userDocument.put("homes", homes)
and you'd upsert userDocument
then any future information thats not homes related gets stored in the user document
if i have a config like "yes: true" for example then i added the plugin to my server it works fine using saveDefaultConfig(); and saveConfig() but if i update the config file in intellij and add "no: true" for example then delete the old jar and add the new 1 "no: true" doesnt get added, i cant really have people delete their config everytime the plugin updates so how can i fix this
FileConfiguration#addDefault
isnt the config cached tho in your plugin data folder?
so yes you probably wanna try to default as creppy pointed out
and then copyDefaults as an option
iirc PlayerInteractEvent
yeah
Yeah but after you pressed it I want to see if it is still pressed
Action.PYHSICAL
Not when it just started currently like 5 seconds after also
ok this seems to be null: List<Document> homes = document.getList("homes", Document.class);
Is there a way to check it with like the blockState or smth?
yes, look at your data
there is no homes field
it should have been replaced on the last save call though
well i can now enter and quit the game without errors
yeah iirc Powerable
BlockData
thanks you for your time lol
copilot gave me this for deleting a home lol users.findOneAndUpdate(Filters.eq("owner", home.owner()), new Document("$unset", new Document("homes." + home.name(), "")));
that uuid is triggering me a bit
whats your uuid representation set to?
minecraft usually uses type 4 which is what mongo calls standard
that just looks wrong lmao
well BinData(3 says uuid type 3 iirc
i dont have explicitly set the uuid representation tho
weird how I had to
I mean it's still correct, just looks wrong to me because I've always seen type 4
i tried setting it once and BinData was replaced by UUID(<string format uuid>)
Has anyone here made a combo system before? like
R = Right click
L = Left Click
R + R + L = Spell #1
R + L + L = Spell #2
Etc
im trying to make one but struggling
What are you struggling woth?
ill try and explain it
i have 2 functions outside of the event
boolean readyCombo = false;
String comboList[] = new String[0];```
the rest of the code look like this
```java
@EventHandler
public void onRightClick(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (event.getItem() == null) {
return;
}
if (!(event.getItem().getItemMeta().equals(ItemManagerTestingItems.testStaff.getItemMeta()))) {
return;
}
if (!(event.getAction().equals(RIGHT_CLICK_AIR))) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText( ChatColor.BLUE +"Pew"));
player.sendMessage(String.valueOf(readyCombo));
readyCombo = false;
}
if (readyCombo == true && event.getAction().equals(RIGHT_CLICK_AIR)) {
player.sendMessage(String.valueOf(comboList[0]));
}
if (event.getAction().equals(RIGHT_CLICK_AIR)) {
readyCombo = true;
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText( ChatColor.BLUE +"You have Started a combo! _ + _ + _"));
player.sendMessage(String.valueOf(readyCombo));
comboList[0] = "R";
}
}
}```
the ready combo part works fine for now
but whenever i rightclick after getting the combo ready i get a error thrown at me (let me get the error)
Be aware, your current combo list is the same for all players, so if a starts it and b finishes it then that will fire the combo
your combo array size is 0
you can't add any elements to that array
array indexes start at 0
?learnjava moment
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.
i was doing some bs before to try and get it working
Could this work?
PlayerProfile playerProfile = null;
PlayerTextures textures = playerProfile.getTextures();
try {
textures.setSkin(new URL("https://textures.minecraft.net/texture/"+val));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
playerProfile.setTextures(textures);
final ItemStack head = XMaterial.PLAYER_HEAD.parseItem();
SkullMeta meta = (SkullMeta) head.getItemMeta();
meta.setOwnerProfile(playerProfile);
head.setItemMeta(meta); ```
ik but... I don't know how to get that value
yes i am aware of this at the moment im just trying to get it working but everytime i move it within the even handler it will reset everytime i call right click event again
that is correct ill need to change this ๐
my question right now is how can i store both the readyCombo and ComboList without it reseting every time i call "Right Click Event"
would i need to implement some sort of database
My idea would be a hashmap with a key of the player uuid and a PlayerCombo object. The playercombo would contain a list of recent actions you could check and add to
and storing the hashmap as a final field
what i was planning to do is the string array is temporary just for testing purposes i will replace that with a int array
Math experts, please help me with this:
sinch im only listening for right and left click (0 = Left & 1 = Right) i could have something like and store that in the hashmap retrieve it and at the end of the combo i could clear the hashmap
You want it per player right?
yes thats correct
so ill need to also make sure the UUID of the player matches with the one in the hashmap correct?
Then have a hashmap item per player which contains a class that contains the list, the class could have a shouldFireCombo method
And just clear the list inside the class if the combo expires/fails
another thing which i couldnt find out is how could i implement a timer to expire the combo
so e.g after 3 seconds they would need to ready the combo again
since i cant just sleep(3) XD
if a combo were 10 actions, would you want the combo to expire 3s after the first action or 3 after the latest?
?scheduling for that part
I disagree, would be better to keep track of the latest use timestamp, and if cur time when using is greater than last use + 3s then clear. No need to schedule for that
oh true
i had a look at scheduling but its not what i exactly need
3 seconds after
after the first or after the latest action?
What if a combo were 10 actions though? Theoretically
im going to limit it to 3
because lets be real no one is going to sit there and memorize a 10 combo spell
10 actions would mean
_ + _ + _ +_ +_ +_ +_ +_ +_ +_
Perhabs, but having the possibility could be interesting, besides, if you write the code well it could be expanded without rewriting
i want to definitely do that where by i can easily change the combo system to have 2 abilities
3 abilities etc
background information is im building a MMO rpg with different classes
and different tiers of weapons
T1 will have like 1 spell
while T3 has 3 spells
Have a list skills which have a list of required actions you loop through on each tool use and see if it matches the spell
Sounds like an interesting idea
Probably been done before but what hasn't
i could just make it easy and do each right click cycles through a spell list and they choose like that but thats not fun
Hover and click on all the messages you want! Learn how to code and use TextComponent and more :)
------ Links ------
Download Eclipse: https://www.eclipse.org/downloads/packages/release/2019-03/r/eclipse-ide-java-developers
Download Spigot: https://getbukkit.org/download/spigot
Build Spigot: https://www.spigotmc.org/wiki/buildtools/
Starti...
like this?
honestly i never understand anything they "teach"
i just look at docs
its so much better
yep
because they dont teach concepts
reading is a lot faster than watching and listening to somebody speaking with 1 word a minute
they "teach" what to type
Why is that happening?
id need to add every configuration value though? that would be a lot to do
put the defaults in the config in the resources folder, then add a saveDefaultConfig() on enable
load the default config manually and run through it, adding the defaults to the servers config
i made the config in intellij everything is in there but when i use that it doesnt update when the config file updates
don't even understand the logic behind your use of the trig functions maybe some sort of drawing would help me out. But for a start you are looping through degrees when javas trig functions use radians
Hey guys, What is the packet? As I know Spawning Block, Or everything can send to player but I can't understand how they work
no
Wow, that's cool, good job
packets are how the client and server actually talk to each other. Everything the player does is sent as a packet, and all the logic that the server handles, as well as all the other players actions are sent by the server. Spigot provides nice wrappers around these packets like the player move event, but not all of them are mapped, so sometimes you have to send packets manually youself
a packet is just information regarding an action that the player is taking
you can find a description of all the packets the server and client send on https://wiki.vg/
what are you actually trying to achieve, and what's your logic behind your rotation algorithm
I literally sent the code
yes, I see the code, but I don't know what it is you actually want it to be doing
dont you see something wrong?
you keep sending different images, I'm not too sure what you are trying to convey. Are you trying to get a cross pattern around the chest?
Oh, I get it But I can't find ((CraftPlayer)player).getHandle().playerConnection(version on 1.19.2) How can I send packet upper version?
yes
and you are unhappy with the offset?
getHandle().b.a() If I remember
right, okay
Oh, I'll try it
my brain is awful at interpreting anything in space, especially when you move 3d into 2d with an image. So that second image is hard for me to process. Let me look through the code
And the other packets changed the name?
yes
Oh
Guys, a quick question, I have created an InventoryBuilder which, to allow commands/events to be triggered after clicking on an item, uses predefined Enums. Once an item is clicked, it checks if the same has an enum of value X then performs Y and so on (Relating it to the one in the list created by the InventoryBuilder (quick forEach) ).
Would you have any better ideas?
(Maybe lighter ideas)
Something is probably wrong with your rotate calculations
Inventory inventory = /* your inventory */;
Map<Integer, Runnable> items = new HashMap<>();
inventory.setItem(slot, item);
items.put(slot, () -> /* run code */);
//InventoryClickEvent
//check if it your inventory
if (items.containsKey(event.getRawSlot()))
items.get(event.getRawSlot()).run();```
for a start its using the wrong angle unit
I changed to radians and nothing happened
Items position and action can be changed from the config... Perhaps there is a more easily usable method
it should be centered with the white thing
For one rotateXY and rotateYX are the same thing so idk why you have both
hmh
i am using only xz and yx
Ik but I'm saying you should just remove rotateXY
add a vector of 0,5 0,5 0,5 to it
Maybe this is the only solution
if(elementArray.getSlot(Clicked).getEnum() == TAKE_A_POTATO) {
}...```
already doing
maybe 0.6 or 0.7 y
if we treat along the chest as the x axis, and up as the y, then we're rotating around the z axis right?
oh wait
that wouldn't work
@golden turret I assume this is what you want?
Dear god the particles 
Lmao
weaker clients for sure will love that xD
rip client
Hey man it's not my idea 
fuck the clients
run it
LMAO alr
I've got a rather specific question on a nuance of the spigotapi, specifically OfflinePlayer::getLastPlayed(). Javadoc says it's the "last time the player was witnessed on this server", but doesn't state exactly when it's updated. Is it updated before or after the PlayerJoinEvent for the player in question?
damn looks kinda cool tho
https://github.com/Bastian/bStats-Metrics/blob/single-file/bukkit/MetricsLite.java
Does anyone have the code in metricslite.java?
https://paste.gg/p/anonymous/bf038320b45c40f8a827d5e962e35f77
Anyone know whats happening here?
Idk if there's too many people that use Kotlin for Spigot dev here tbh
:(
My only guess with that is something is wrong with your dependencies/building the JAR
Or the server doesn't have whatever that is
Hi, I'm doing something with PlayerTeleportEvent right now in an event handler. If I have event where event is an instance of PlayerTeleportEvent and I call event.getPlayer().getLocation() does that return the equivalent of event.getFrom()?
yes
Also pleas euse ?paste
Ugh that's frustrating
I think im going to use Groovy with Kotlin because kotlin gradle is weird
ClassNotFoundException, something is calling something from a class that doesn't exist in your binary.
yea ik its a shading problem
might be this, this is all I could find https://github.com/Bastian/bstats-metrics/blob/1.x.x/bstats-bukkit-lite/src/main/java/org/bstats/bukkit/MetricsLite.java
thanks
https://paste.md-5.net/eyunebesah.xml
/
|
Code, it's been 30 minutes and it still hasnt done anything
Is there a way to create a local variable inside
list.stream().map()?
sGames.stream().map(sGame ->
new Game(
sGame.getGame().getId(),
sGame.getGame().getQueue(),
sGame.getGame().getWinteam(),
sGame.getGame().getDuration(),
sGame.getGame().getStart().getTime()
)
)
Basically I would like to create a variable that does the ".getGame()" part and then use that in the constructor
stream.map(sGame -> {
Object game = sGame.getGame();
return new Game(game.getId(), etc);
});
Dont use Object use whatever getGame returns obviously but yeah
Ofc :) Thanks a lot!
If i want to learn java for making plugins where and what is the easiest way to learn it?
np if it costs money
?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.
Do you wanna learn java or do you know basic java and wanna get into developing plugins?
i know the basics i have come so far as doing simple if statments and varibals
I would recommend if you only know if statements / variables; you start at the ?learnjava above and get a decent understanding of basic Java
yep ty
then move onto plugin dev
Jetbrains (the company behind the IntelliJ IDE) also has java tutorials. Those are not free tho.
https://hyperskill.org/tracks?category=2
if i have a config like "yes: true" for example then i added the plugin to my server it works fine using
saveDefaultConfig();
and
saveConfig()
but if i update the config file in intellij and add "no: true" for example then delete the old jar and add the new 1 "no: true" doesnt get added, i cant really have people delete their config everytime the plugin updates so how can i fix this
Hi, im having problems with my wand and region system, for a fkn reason while im using the wand its allows me to break the block, etc, while that shouldnt be allow
You can use this function to add new keys.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/ConfigurationSection.html#addDefault(java.lang.String,java.lang.Object)
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
YamlConfiguration also has it
no thats not the problem its the default config when i modify it/update it and add the new version the modifications dont get added
that why i use my own file handler instead of shity getConfig() from JavaPlugin
๐
Yeah I doubt that it's possible. Unless you write functionality to check for differences yourself and add them
thats rly dumb ๐
Can you elaborate?
Just start with the "addDefault" after you released v1
Yeah, let say, by default you must not be able to break, interact nor place blocks. Right?
Alright
I have divided the logic into 2 classes, WandListener and RegionListener
Cannot invoke "fr.fokpi.hcproxylogin.HCProxyLogin.getDataLink()" because "instance" is null
Why do I have this error when I have always called my main class this way?
Probably called it before initialization
Which have a BlockBreakListener I suppose?
i call my class at proxyinitialization how can i know ?
WandListener - https://paste.md-5.net/miqimewibe.cs
RegionListener - https://paste.md-5.net/inadacapux.cs
Proxy initialization? What proxy? Are you coding for Bungee?
I sent u the code up
So basically you wanna protect using the interact event and then those other events apply for the protected regions, right?
Do the other events cancel as expected? Is it only the BlockBreakEvent that fails?
- Inside a region, block everything allowed (breaking, placing, interacting, dropping, etc)
- When you use the wand item allow you to select 2 pos
yes for velocity but its the same
But i also have issues while im op
Velocity is not supported here
Sorry
I'm afraid I don't know bungeecord either :x
So let try helping me
And then we try gelping him
Fabsi its really weird what happening
Answer my question then.
Do the other events cancel as expected? Is it only the BlockBreakEvent that fails?
IM really exausted
One 1m please
Dont leave i will test smth
Because i made so much changes lmao
Sure, take your time
thanks mate im really exausted of this shit
I have been with this shit since 2 pm and its 6 pm
Programming takes its time
No defintly nothing is getting blocked
So it should be smth wrong with the wand checks
๐ก
@flint coyote
Sorry for ping haha im really strssed
I have a test sever tho
Did you try debugging any of it so far? Like checking where the events fail?
lets take the block place event. You have 4 returns.
So first you should check which one fails you (and returns something else than what you expect)
fabsi
Let me write the logic
Mainly i need is while claiming and not claiming, with the wand block everything allow (placing, breaking, dropping, etc)
yeah I get that. While you are claiming you aren't supposed to do anything else
But you should still test each guard clause
You should only be able to do actions, only if you are op or a member of a region - only must be done if you are not claiming
I hate logic
basically you wanna change
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if (!this.wand.getSelections().containsKey(player.getUniqueId())) return;
Profile profile = this.profiles.getProfile(player.getUniqueId());
if (profile == null) return;
if (profile.isBuild()) return;
Region region = this.regions.getRegion(player.getUniqueId());
if (region != null && region.getCuboid().contains(event.getBlock().getLocation())) return;
event.setCancelled(true);
}
to
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if (!this.wand.getSelections().containsKey(player.getUniqueId())) { System.out.println("test1"); return; }
Profile profile = this.profiles.getProfile(player.getUniqueId());
if (profile == null) { System.out.println("test2"); return; }
if (profile.isBuild()) { System.out.println("test3"); return; }
Region region = this.regions.getRegion(player.getUniqueId());
if (region != null && region.getCuboid().contains(event.getBlock().getLocation())) { System.out.println("test4"); return; }
event.setCancelled(true);
}
And then see which one returns
After that you can further investigate what's wrong
Just add those 4 changes and re-test
You know exactly what you want to achieve. So test what wasn't working (by placing a block) and then you know which guard clause is behaving odd
After that you can look for issues inside your methods
So basically you narrow down the issue and then you search for details
I fixed
I think
Atleast now i can claim now without breaking
But now i have cuboid issues
๐ก
Is there a way to Override the /msg command ?
i think there would
to listen to command execution
yeah
plugin-name:msg
/nsg is not from spigot tho ๐ค
/msg is default iirc
hmn
I testing it and not
default from spigot is /tell
idk which version u are using
does anyone know of a way to update the config.yml when its updated with newer versions? i cant see how addDefault is the best option since that could take hours and seems extremely unncessesary
include a config version so you can read teh current config and the default and you'll know what needs updating
if tried instance.getResource("config.yml") but it doesnt return a file
it returns a stream
would that be the way to update the config?
So long as you actually have a config.yml in your jar
take a look at teh spigot config
wdym
it doesnt auto update when i do it
its a resource in my project but it doesnt update with the newer version
i use saveDefaultConfig();
that will only save teh config from teh jar to file, if it doesn;t already exist
is there another method to use?
i dont see anything that auto updates it though
that code I linked performs an update
it gets the current config from file, then loads the defaults from the jar and saves
Do you want to use my own filehandler?
Its more simplier than coding everytime the code for creating, updating, etc yaml files
if its available sure
but if i put a new jar in, restart my server, the config doesnt update, it stays the same
you have to write teh code in your plugin to update
I liked you to code which shows you how to do it
Jeffa
https://paste.md-5.net/eponaroraz.java
// Construtor: FileHandler(plugin, name, parent)
// Plugin param: your plugin instance
// Name param: your file name with the extension
// Parent param: when set to true, will create/load the file from the same file from your resource folder
// Example
FileHandler config = new FileHandler(plugin, "config.yml", true);
config.reload() // Reloading the file
config.save() // For saving the file
and that updates the config when theres new stuff?
eXPLain more tHAT
hi guys can someone explain to me how to implement an algorithm in a java plugin?
what?
Alaborate more
so i created a dice that randomize a number to 0 to 100
and i need to implement it in a minecraft plugin
if i have my config version 1 as "value: true" for example then i make a new version of my plugin and update the config to add "2ndvalue: false" for example, does it update the config to add the new values
and i want to do if a player does /roll does that algorithm
and then gets the number
it doesn't look like it will. no
Please be pacient and dont tag anyone, none of us is getting paid for being instant/fast help
i know sorry
?jd-s
For the one who sent the message
that was the wrong thing lmao
there is already random object in java, you dont need to imp your alg
so i did an algorithm with flowgorithm then i coded in java, then i am creating a minecraft plugin, so i need to put this algorithm in this minecraft plugin when a player does /roll then he can get the random number
Its your first plugin?
how can i create it, can you help me please, i am a noobie on java
yes
Ok
ThreadLocalRandom.nextInt iirc
i am just starting
So i will send you some useful info
idk where to put hands man
i am just learning by tutorials
getConfig().setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("config.yml"), Charsets.UTF_8)));``` the config doesnt update and no errors
just the code I was writing aha
you need to save the config afterwards
btw can i create the config at the end?
ah
also, from the code you've sent already, I have the feeling you aren't using maven?
QuiteLabs
https://www.spigotmc.org/wiki/plugin-yml/
https://www.spigotmc.org/wiki/create-a-simple-command/
https://www.spigotmc.org/wiki/using-dependency-injection/
https://www.spigotmc.org/wiki/spigot-plugin-development/
https://www.spigotmc.org/wiki/using-the-event-api/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i am
saveConfig not saveDefaultConfig, using that code
saveDefaultConfig() hasn't worked for me with maven
Your welcome
like, at all
Just use my file handler class
It will make you forget your headaches
you 'handler' class doesn't do what he wants
LMAO
What he wants?
I dont even udnerstand
btw can you help me create the randomizer number?
or teach them how to do it properly so they leanr, rather than spoonfeed then a class
its written in the spigot files that you send me?
getConfig().setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("config.yml"), Charsets.UTF_8)));
saveConfig();``` this still doesnt update the config no errors
Does your jar have a different config to the one that is saved?
That code looks fine
I explain how it works bruh
my jar has extra config options vs the 1 that it is currently on the server
YOu dont read
share your file structure and full code? similar code works fine for me
getConfig().setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("config.yml"), Charsets.UTF_8)));
saveConfig();``` the only code involving config file in my plugin and file is
resources:
config.yml
data.yml
that code is fine. So long as you are actually calling it
its in onenable
hey goksi can you explain better to me how to create that random object in java?
BRUH
YOu are wrong
He is doing/tring what does my FileHandler
๐คก๐คก๐คก๐คก๐คก๐คก๐คก๐คก๐คก๐คก๐คก
Stop being toxic
oh
wait
why does it make the new stuff at the top of the config
and not where it is in the jar
because it's not ordered
is there a way to order it
Its possible to make a PR to spigot to be added ?
๐ค
not as far as I know since it's handled for you
only by doing it programmatically . So not easy
is there a way to make it copy comments?
mines does everything
Make your own yaml parser ahah
give a try it
too much work
exactly
comments are preserved, but not sure about for default. They should be
the saveResource call should copy comments, but the addDefaults won't since all it sees is what's parsed by YamlConfiguration
hey im here, trying to help you. dont ignore me
well they are preserved in teh current Spigot. I think it was added in 1.18.2?
yes
oh yeah
sorry but the thing u sent isnt what i need
its bruh
just try it
it will load your config.yml from resource folder with the content
not sure if you don't understand your own code, or if you don't understand what Jerelfa is wanting, but your code does not do what he wants
The code you pasted will not do what he is asking.
What we posted does
what he wants
I dont understad
He is just trying to load afile with content from resource folder
Which is that what does mine
๐ค
He wants that when he uploads a newer jar to his server it automatically adds any new config entries to the existing config
to preserve the comments, you'd have to loop through the comments on the default config resource and then set them for the server's config
don't think theres a way around order
rip
config is by insertion order
you could probably change that through reflection? but that would be a mess
Plugin#saveResource("file-name.yml", true)
๐
no
that will override their current config
Your dumb verano
๐
actually I think I have thought of a solution
No, im trying to help
force save the resource with saveResource(path, true), and then loop through each key and check if its set in the config in memory. If it is, overwrite it?
sounds like theres room for potential errors though
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
hmm maybe ill try smthn like that
What event runs when the player moves their camera, like their mouse
Player move event
Thank you
The constructor ItemStack(int, int) is undefined
I get this error on this line of code
ItemStack currentitem = new ItemStack(id, quant);
Any idea how I can fix this?
What the fuck version are you using that you think item id is viable
How can I detect if the player is looking at a certain coordinate, for example how can I check if the player is looking at 0, 0 from all the wya 2000, 3000?
I was following a tutorial when I made that bit and I think it was a little bit outdated
player.hasLineOfSight(Location)
?basics
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.
or you could ray cast yourself
What if the chunks aren't loaded?
alright thanks
afaik that uses maths so it won't require the chunks to be loaded
Won't using hasLineOfSight just be easier
yes, of course
but it depends on how accurate you want to be
// Paper start
@Override
public boolean hasLineOfSight(Location loc) {
if (this.getHandle().level != ((CraftWorld) loc.getWorld()).getHandle()) return false;
Vec3 vec3d = new Vec3(this.getHandle().getX(), this.getHandle().getEyeY(), this.getHandle().getZ());
Vec3 vec3d1 = new Vec3(loc.getX(), loc.getY(), loc.getZ());
if (vec3d1.distanceToSqr(vec3d) > 128D * 128D) return false; //Return early if the distance is greater than 128 blocks
return this.getHandle().level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this.getHandle())).getType() == HitResult.Type.MISS;
}
that is the actual implementation
Oh thank you very much
Hi guys, me and my friend Tobias want to start a Craft Attack project and have only one problem and that is we need a plugin that removes all end_Portal_frame
so it only works if it's closer than 128 blocks
So I need to raycast it?
i don't think you understand how hard it is to look at a specific block 2000 blocks away ahha
Well basically I am trying to make a waypoint mod but as a plugin or datapack
Thank you ๐
Would it be possible to make like a gui text that points towards a coordinate with an arrow symbol?
val configFile = File(plugin.dataFolder, "config.yml")
val oldConfig = YamlConfiguration.loadConfiguration(configFile)
saveResource("config.yml", true)
val config = YamlConfiguration.loadConfiguration(configFile)
for (key in config.getKeys(true)) {
if (oldConfig.isSet(key)) config.set(key, oldConfig.get(key))
}
// This part is only needed if you want to preserve old config that is now not used
for (key in oldConfig.getKeys(true)) {
if (!config.isSet(key)) config.set(key, oldConfig.get(key))
}
config.save(configFile)
excuse the kotlin, but this works
I tried to write it in a way that its easy to read for java folk
essentially, we are overwriting the old config with the new one, and whilst the old one is still in memory, we update the overwritten config with the old values
downside to this approach is that the formatting that whoever the configurator used will not be saved
but comments and order will
imo just leave user to add new configuration entries by himself and rely on defaults from your resources folder
Is there a way to check if a pressure plate is pressed outside of the PlayerInteractEvent (so just checking the current state)
kotlin physically and mentally hurts me
kotlin got more keywords than a janitor got keys
People who use kotlin for plugin dev physicly and mentally hurt me. Sorry for my comment on that
probably touch grass to fix that or something ?
Helo Lynx ur here too?
quick ban him
XD im just here so I can help some people when im bored
spigot is fun banter xD
and guess what, we can make our own too!
(sorta)
yeees
i want the code please
Uh it uses my Particle lib lol
It's basically the exact same thing you're doing.
Look at the ParticleRotate class on the github
alright
the client said he dont need the animation anymore
so I wont care anymore too
I wanted literally the same animation you did
Ah
i remember this being the same error i got on my pc since i didnt have --remapped in my buildtools args
but this one is in github
you'd have to clone and build spigot buildtools first as a setup
Any library recommendations for inventory GUI's for 1.19.2 spigot?
can't remember if its possible with github actions
but if im not mistaken you can have it cache the m2 repo
Try coding it and the impl the same as this one
MenuPlugin plugin = (MenuPlugin) getSever().getPluginManager().getPlugin("MenuPlugin");
if (plugin == null) return;
A a = plugin.getA();
B b = a.newC().a("&6Users").b(3).c(27, new C(itemstack, ClickType.RIGHT, (d) -> d.getA().sendMessage("Stop")).e();
a.getA().a("users", b);
b.f(event.getPlayer());
๐
don't personally use helper libraries even though they probably would speed things up. Only one that springs to mind is lucko's
https://github.com/lucko/helper
Thanks
although it is quite large and most of it you won't use so it make be better to look around for a specific library for guis
Yeah that's one thing I'm concerned when it comes to helper
just putting it forward as a possibility, definitely not the best
I avoid 3rd party libs also as most of them do not encapsulate any sort of guarantee against bugs like issues
fe no unit tests
poor code architecture
Hello guys c;
just searching google:
https://github.com/NichtStudioCode/InvUI (support for resource packs)
https://github.com/Simplix-Softworks/Cirrus (built in preview)
https://github.com/TriumphTeam/triumph-gui/tree/master
^
Today I'm trying to create a plugin that allows users to set their own homes (a home is specific of an user), so the way I thought I could do it was; "Create a class of Players that contains an arraylist of Homes and then everytime they execute a command it should add the home to the home arraylist"
Is my idea correct?
still haven't ever written tests for spigot, seemed like too much hassle for little benefit? Is there any easy way other than manually mocking classes?
or is there an easier way to do it
i mean i don't even know how that would work
mockito works, for most part
but if u need to mock the entire lifetime then mock bukkit maybe
and for integration tests u do have mini's thing (dont remember the name)
sounds about right, you'd need a map of players to your player class
What do you mean a map? I'm starting
how does mokito actually mock the server though? What's needed from the dev?
Only tests i've ever written were for challenges with clear goals, so never used mockito myself though I've seen it used before
no it doesnt
but everything doesnt need an entire server lifetime mock
lets say ur persistence layer
thanks c;
I love how the tutorials on the threads are so bad too
i didn't have time or the mental capacity to explain
i was just seeing if https://www.spigotmc.org/wiki/intellij-debug-your-plugin/ worked, ive got the cmd line args in and it says it connects but doesnt attach
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.


