#help-development
1 messages ยท Page 1919 of 1
setitem?
val item = ItemStack(Material.STONE)
val meta = item.itemMeta
meta.displayName = "name"
item.itemMeta = meta
e.player.inventory.setItem(2, ItemStack(Material.STONE).setDisplayName)
how do i give it to them
You have it in a variable called item
What do you think
You just pass item instead of constructing an ItemStack there
It seems like you lack a basic understanding, you should probably be using java rather than kotlin and you should make sure you have the fundamentals down
?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.
val item = ItemStack(Material.STONE)
val meta = item.itemMeta
meta.displayName = "name"
item.itemMeta = meta
e.player.inventory.setItem(2, item)
why are you using Kotlin for spigot?
did u try thid
was asking breh
o ok
Because my friend decided that we should work wKotlin
here
fun onPlayerJoin(e: PlayerJoinEvent) {
val item = ItemStack(Material.STONE)
val meta = item.itemMeta
meta.displayName = "name"
item.itemMeta = meta
e.player.inventory.setItem(2, item)
}
Check the link
how
yh
If you're not sure how to print debug output I think you really need to go back and learn the fundamentals
Just add a print statement to ensure the event handler is being called
Does anyone know how to remove this lead? Its not a real lead, but it doesn't go away unless you look at it from another angle, I feel like I have explained this very poorly lmao
The lead only breaks when the animal dies
What do you mean it's not a real lead?
kotlin.Unit
like its not technically connected to anything
I don't think a lead is an entity
So I don't know how you would remove it if it's glitched like that
dam, other than that one visual bug this plugin works great lmao
why kotlin.Unit
What do you mean
That is such a frustratingly vague question
https://communitymgt.fandom.com/wiki/Help_Vampire Please understand what a help vampire is and make an effort to avoid being one
declaration: package: org.bukkit.entity, interface: LeashHitch
it is an entity there Redempt ๐
this is just the knot I believe
Is the lead attached to a fence?
Then you misunderstood
You seem to have a lack of understanding of the underlying mechanics of the code you're trying to write
Which is why I am recommending you use java rather than kotlin and make sure you have the basics down
I'm not going to spoonfeed you all the answers because you're not going to learn anything from it unless you understand why these things are happening
You're asking very vague questions and learning almost nothing from the answers you get, and you don't seem to have a grasp on the programming concepts you need to, which is why I linked the page on what a help vampire is, because you're being one
Lol
What
pretty sure yeah, however the image above doesn't make clear how it is attached and I was merely pointing out there is a point where the lead is an entity lol
yeah, I spawn a bat inside of a fence post and connect to the bat, then I connect a lead to the bat and the player and the player then can click on a fence like any other leaded animal
ah okay my bad
Then you should be able to kill the leash knot
yep grab its uuid and kill it dead and then you shouldn't have an issue after or maybe you will because it releases the bat?
oh my bad wrong one, but eh get the point >>
Sorry let me try to explain it better.
So I create a lead by connecting it to a bat inside of a fence post and it acts as a normal lead after that.
It connects fine and no issues, however the issue shows up only after the player tries to setup another lead between 2 fence posts
Im not sure why since the lead is no longer connected to the player
It also only shows up after the new lead is tied to the post
does the lead get attached to the fence?
killing the bat isnt/lead knot isn't really an option as it is what makes the ropes tie together for aesthetics
yeah the only issue with everything is that the new lead that doesnt have any segments on it is generated as well
let me try to record a video one sec
could be a client side issue
ah it could be let me load up an alt
it shows up on my alt too and after full server shut downs
weird
yeah, cuz it doesn't look like a real lead since its all one color
alright
do the minimum necessary
and then print out the entities
see if its adding an extra in there
if not, then you are going to have to look at the data of those fence posts/entities to see what is up
might be a server side issue of extra data being added for some odd reason? lmao
never really seen that before so I can't really say for uncertain why it would do that
Hm, i got a question
I have a string from an argument of a command and i want to conver tthis into a player so i can get their uuid how can i do this
if you can't find no extra lead or data then it really is a client side issue specifically XD
?jd
javadocs have a search function
search the event you are using and odds are it has something in there for doing that ๐
and what do you want me to search for exactly?
what event are you using?
what are you on about
Maybe should see what some of those terms there reveal if you search for them in the Javadocs I linked above ๐
You sent me 1.18 javadoc anyway
and?
Not using that
oh, can't help you with outdated stuff anyways, not that what you are wanting changed api wise since like forever before you were using MC
I mean onCommand has existed for many years ๐
so wouldn't matter which javadocs you use to look at that
"not that what you are wanting changed api wise since like forever before you were using MC"
or some of the other api stuff
what?
?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.
that makes no sense.
what you just wrote
"not that what you are wanting changed api wise since like forever before you were using MC"
it means that it wouldn't matter which API version you were looking at, the information you seek would be the same
it hasn't changed and what you are wanting to do is nothing new
in fact probably could find a ton of tutorials that will spoonfeed you this for you
Bro u said U canโt use the 1.18 docs because ur not using 1.18 but most of the stuff is the same across versions
Ok so do any of you know how to turn arg[2] (string) (username) into a player's uuid
of course we do? What are we novice developers here?
So can you let me know how? Ty
Bukkit.getPlayer(String name).getUniqueId();
'getPlayer(String!): Player!' is deprecated. Deprecated in Java
it sure is, but isn't unusable either
Unresolved reference: getUUID
In kotlin it will just be uuid
Again, you need to understand the language you're working with
You should really think about switching to Java if youโre gonna ask about spigot programming
Unresolved reference: uuid
99% of spigot programmers use Java
updated my message
Kotlin abstracts away getter calls and makes them accessed like fields
Look
We're not going to walk you through every tiny little error
You should be able to figure some of these things out on your own
doesn't your IDE give you a list of methods you could select from that?
Put more time into learning the fundamentals of java, then go to kotlin
You are making it much harder than it needs to be to help you
And trust me, I am saying this to help you
You will be much better off learning the fundamentals than relying on other people to solve every minor problem you run into
Also I don't know kotlin so I can not translate java to kotlin that is on you XD
Better then me probably ๐
It's worth noting that you can have java files in a kotlin project and vice versa
I am aware
I would recommend sticking with java because kotlin is a more complicated and less beginner-friendly language
It's far less explicit and hides away a lot of details
1.14
you beat me to it ๐ฆ
java.lang.NullPointerException: null
print(Bukkit.getPlayer(args[2]).getUniqueId());
I am trying to convert username to uuid but dont seem like it works
Why, what are you trying to do?
If he wants to use Kotlin he needs to learn the language itself more rather than running before he walks
java.lang.NullPointerException: null
You're ignoring everything I am telling you
Do you know what this means?
Yes!
We are not here to do every step of it for you
Great! now what went wrong?
arrays in java start at 0, not 1
the index you think the username is at is incorrect
Um, arg[2] is my username
I am pretty sure it is 1
what is the command ur using
If you have 2 arguments
like the full thing
the full command you are trying to execute
But seriously it's getting very frustrating trying to help you because you only seem interested in getting what's right in front of you working
Which is an absolutely terrible approach
/command thing1 thing2 thing3 thing1 is arg[0] thing2 is arg[1] and so on
just heads up, the person you are going to help wants to be spoonfed
If you're going to continue like this I won't help you anymore
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
Yeah i see that
Find your own answers
Im just still learning
And follow some tutorials until you get comfortable with it
You're ASKING US FOR HELP
Then stop asking people to tell you what to do
LMAO
Lmao
WTF??
lmao
isnt that why you came here to get told what to do to fix your problem?
@quaint mantle look at this clown
This cool you are still learning but you also have to understand the community you are asking for help from. If you can't learn to help yourself especially after we have pointed you in resources to do so, then you won't survive long in this community
yhh im learning
- ask for advice
- dont listen to advice
- ???
- still ???
whats your main language?
This isnt a learning discord. This is a discord to help with existing code
cuz that could be the issue here
im learning and coding at same time
what is this actually all about? I just joined
oh noes you woke everyone up ๐ฎ
Did you not listen to what I said
If thats the case then go learn the language on ur own then come back when you want help. not for people to just tell you what to do
uhhhh
can some1 summarize to me in one sentence what this discussion is about pls?
Guy wants to be spoonfed, we tell him to go back and learn the fundamentals better, he says "don't tell me what to do"
some guys angry cus i dont know something lmao
thank you ๐
thanks ๐
@neon minnow is having issues with spigot but just wants everyone to spoon feed code to him. Hes basically asking others to code his plugin for him
We're angry becausse you expect us to give you all the answers without putting in any effort on your own
person wanting help is learning java, AKA novice but is instead trying to use kotlin, they don't know the api and basically keep asking questions to the point in getting spoonfed
uh no i dont think so
okay I'll contribute
@neon minnow
don't listen to all those jerks
listen to me instead
lmao
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.
lol
LMAO
Already linked that
He has ignored every single time we've tried to get him to switch to the simpler language and learn the basics before diving in the deep end
i already got help with the thing i needed anyway
Okay see you in 20 minutes when you run into the next brick wall
He doesnt understand that he can look up his own problems rather than asking people about language related issues
do you know the difference between an instance's method and a static field?
well I mean idk, we linked 5-6 different resources for learning purposes?
I'm perfectly happy to help people with language related issues here if they show that they're actually trying to solve their problems and learn on their own
read the message and you'll know what to do
need to use the appropriate load and save methods
I haven't used the normal config library in a long time
probably foreign to you by now
that message is NOT from the spigot api anyway btw
What I'm wondering is if it's just an issue with a plugin they didn't even write
So they came in here and just posted it without reading any of the channel descriptions
This place needs better moderation smh
well if that message isn't from the API I would suspect so ๐
probably, lol
we probably confused them just as much as they confused us ๐
Did you write that plugin
?paste your code
If you did not write the plugin then this is not the place to ask
well, uh saving a config is not loading it
this code will never trigger the message you've sent
What are you even doing with the config variable
alright I think I am going to go back to my game lol
not sure if I can handle more of this novice stuff XD
I can't even plug my library to beginners ๐
.....and i stillllllll havent foouuuuund what I'm maven for
nah I just listen to U2 and it came to my mind
sorry ๐ didnt want to cause confusion ๐
think it happened anyways for someone here ๐ค
U2
Do they still make music
Ok apparently they do, there's something from 2 months ago
not entirely sure if I would say UB40 is a rock band
Well I've never heard of them so I wouldn't know lol
The official music video for 'Red Red Wine' by UB40, from the album โLabour Of Loveโ.
Explore more music from UB40: https://UB40.lnk.to/Essentials
Watch more official videos from UB40: https://ub40.lnk.to/WatchMoreID
Follow UB40:
Facebook: https://ub40.lnk.to/FacebookID
Instagram: https://ub40.lnk.to/InstagramID
Twitter: https://ub40.lnk.to/...
Oh I've heard this one
Guess I just never knew the name of the band
Not my kinda music regardless
so if someone made a plugin using 1.13 api for 1.17 server do i need to change anything in the maven dependencys
No
May I ask what TAG contains all grass, or flowers
Replaceable_Plants doesn't exist on 1.18 spigot api
declaration: package: org.bukkit, interface: Tag
oops my bad was using
Is it intended that if you register new team with plugin it does not show on the list when doing /team list ?
I even wrapped the code in try and catch, to see if something weird happens but it adds the player to the newly registered team etc. but it just does not show it on /team list
show the code for others to see
public void CreateTeam(){
getLogger().info("Setting up new team!");
try {
ScoreboardManager sbm = Bukkit.getScoreboardManager();
Scoreboard sb = sbm.getNewScoreboard();
noname_team = sb.registerNewTeam(getName());
noname_team.setAllowFriendlyFire(true);
noname_team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
noname_team.setOption(Team.Option.DEATH_MESSAGE_VISIBILITY, Team.OptionStatus.NEVER);
getLogger().info("Team has been setup!");
} catch (Exception e){
e.printStackTrace();
getLogger().severe("Something went wrong while trying to create the team, please check logs!");
}
}
and adding player to the team
@EventHandler
public void PlayerJoin(PlayerJoinEvent e){
Player p = e.getPlayer();
plugin.noname_team.addEntry(p.getName());
plugin.getLogger().info(p.getName() + " added to the team " + plugin.noname_team.getName());
}
don't worry about indentations... the copy paste f*ks them up when sending to discord..
you are certain getName() isn't blank?
I wonder if it only shows if there is more then 1 team
๐คทโโ๏ธ
try creating a second team and put a random entity in it
and then see if it lets you list the teams
or maybe it does not show it at all because it is created by plugin and when the plugin is not tracking it anymore
idk how to explain it but
well yeah if you lose the reference it tends to go away
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
How can i do this in Kotlin?
Maybe it does not just show it
Well it is a weak reference type so, that means you need to hold your scoreboard instance somewhere like a List or HashMap etc
if you lose that reference because you don't have a way to get back to the object, then it dies
Well then I am uncertain, it should list the team
that isn't a scoreboard
that is a team
ScoreBoard is the Object that essentially holds all the information in what you are setting up, if it goes away so does everything else it contained as well
but if it would go away, it would throw an error on playerjoin event when trying to add player to the team, right?
not necessarily
u meant like dis?
yes and no anyways I am uncertain as to why that command isn't listing your team
so I will let someone else better quipped to handle this XD
I don't use SB's all that much
Same, it's just strange
Neither do I :D
First time
Okey I fixed it, idk if you care but it was to do with .getMainScoreboard() and .getNewScoreboard()
how can I get every block that has a blockentity when placed
so it was an instance problem
the last one gets a new scoreboard instance
MainScoreboard was the one linked with minecraft's scoreboard commands
thanks for trying to help!
EntityType cat = EntityType.CAT;
player.getWorld().spawnEntity(loc.add(0,1,0), cat);```
anyone know why this isn't spawning a cat?
System.out.println(cat.isAlive() + " " +cat.isSpawnable());
both return true
nvm it was related to my worldguard flags
Question: does death affect a player's persistent data container?
excellent, thanks
Bro
Finally I decided to instead of modifying a spigot and bungee. For adding this custom packet sender and receiver. I can just do it as a library
o.o
Better idea right?
Cuz If not they will always need custom backend for loading the plugins
And sorry for the tag
not sure what you are making, but libraries work too ๐
The library for cross server communication
That you Where helping me before
ah right
I will do it just as library and load it from bungee and spigot plugin
well wouldn't make sense to do it as a library I don't think, unless you are intending to enable other plugins to cross communicate without the need of bungee
The problems is that if not they are oblice to use custom spigot and bungee
That why im thinking to do it a library. And the load it from each side
I didn't really understand that
Like instead of coding the backend side for sending and receiving data, directly on the spigot and bungee (them compile it). I will put that backend inside each plugin (bungee and spigot side). Because if not they will need to use that spigot and bungee jars
Understood?
I was under the impression this was already a plugin thing, I didn't know you were modifying server code directly lol
Omg I dont explain myself
Oh lol
I never told it?
So you recommend me as plugin in each side right?
I think that its the better idea
maybe you have and we didn't realize? But I think everyone assumed it to be a plugin thing because not many people here go about modifying the server code ๐
Well yes and it is a doable thing like this
and like I said I believed this was the route you were going all along XD
Doable u dont understand
so all my advice was related to plugin ๐
Ok. Really thanks
I will keept your recommendations
It will take more than a moth. But i dont care because with pacience I can do it
Yeah taking your time is probably the best, no need to rush if there isn't a reason for doing so
As I did my Menรบ api I take 2 weeks asking and asking and finally I do it
Im think im really good. But with no rush. And not doing if I dont want
Like if want to do something I dont work on it every day. Sometime I want to play
Well, you get better over time and so far you seem to being doing good at the pace you are doing it ๐
Oh thanks
Really good perdรณn
Person*
Every time needing helping trying to help
I really apreciate
well as the old sayings go, have to give a little to receive a little
not a staff helper no, but a helper I am ๐
Yes
he helps more than i do of recent
its like a routine in this community of the old members. We are active for a period of time and sort of take over while someone else takes a break for while
then we have a period where everyone gets together and is active
Cuz you are not being paid. Or at least that its what I think
and then the cycle repeats ๐
i was one the most active helper when i was out of town (family issues) and only had my phone and a sports TV
and a shitty motel room
they are two separate people
yeah all of us helpers are just connected under one consiousness and physical being
@ancient plank
I would imagine some things becoming more efficient in that manner
Oh. I really get confused. Oh I will take a phill. I just came to home from being drinking voodka with sprite and my head its about to explode
I mean you can only take so many kids who think they can learn java through Spigot every day.
I can learn java through spigot just trust me bro
water is what you need. Otherwise known as hydrate
unless we speaking of hangovers you need a small bit of caffeine and water
I actually tried this and it was awful and excruciating in every way.
The problem I have is that I cannot work everytime in a Project because one day I dont want to work bexusse iget tired
I think im the only one
Like 1 day work on Project next 2 days do other things. And then its change
you technically can learn java through spigot, however generally you have to have an understanding of concepts or be able to understand concepts with relative ease
You get burnout literally the most common thing people get
What its burnout?
This happens even to the best of us ๐
you are not the only one that has days they don't want to work on their projects
some of us like to take 2-3 month breaks from such things ๐
like me for example
I haven't worked on a java project code wise in probably the last 2 months but I still provide advice and help with Java related things ๐
Spigot was the first time I ever interacted with java. Though it wasn't all bad because I had some basic concepts down from python / other scripting languages. My view of OOP was flawed because I hadn't dealt with the ideas surrounding it so my early code was really bad and i just kept redoing it as I learned more. I did have the luxury of having a personal experienced java dev help me along the way.
I dont understand "difficult" concept likes async and sync. Thread locking
Imagine me. I used to work with Script from Skript plugin
๐คฃ
well don't worry, some of the experienced developers still have issues with multi-threading
or still have yet to fully understand it
CompleteFuturable is async
I think the hardest thing for a lot of people is stuff like pattern design which cuts out a bulk amount of work when done right
What others things you have like Consumer
Supplier as well
I abuse about consumerz
Imagine just for doing my Menรบ api I used consume for 3 different object
this isn't hard for me, just I am lazy sometimes and just code even if its a bit more work and then later I will probably refactor it
Yeah for experienced devs but you'll have people with the same chunk of code in 5 different classes
you would think I would be more into python
because I am more of lets get it working before we make it look pretty
People I finally stopping to smoke marihuana
Does pulling too much information from the config cause lag?
Because my gf and me started again. And she its helping me a lot
depends how much your pulling how often your pulling it
the config is loaded into memory all at once so if it is large the initial loading could cause some lag especially if the loading is done sync, which if you are using the API most likely is.
Should only be pulling information at the beginning. Otherwise everything should be in memory unless saving
10 information per command (it's a warp system)
I am from the US so I have a different outlook on this. If it was causing you problems then I say congrats ๐
you should be fine as long as your not changing it a crap ton
you mean saving it
Thanks the big problems is that Im just 15 old
A lot of people replace databases with config files
I dont think I was reading more than 100 yaml files and them converting each yaml data to Object
And Server never goes down 19 tps
Is it feasible to develop a system of houses per yml of each player?
probably wise to not be using that being that young, but it also isn't for me to dictate how people should do things either. So I can only go based on how I feel about the stuff and that is, if its causing you problems then yeah probably should stop doing it, if it is solving a problem or helping with a problem(depends what kind obviously) then probably not a bad thing either ๐
If possible use a database for saving
Use a database for that much data. You'll save yourself so much pain
file based storage isn't very efficient and since you can potentially have a thousand or so player files
Yeja
I used to had lot of pain problems converting many yamls data to Objects class and them adding to a repository manager
Whats a good database to use for spigot Doesn't it have something built in to the API I forgot tbh and I've never used a database before lol.
SQL is nice
I will straight use MongoDB
Mongo is a bit heavy for what it does
But use the one you best like
SQLite work you think?
For smaller read and writes yeah
My problems is that I work with cross server all sync un real tome. So you need a really good storage with fast pulling
i'd just be storing how much money a player has + playername I figure it'd be bad to keep using yaml files
Depends on the db
SQLite for example doesn't work if 2 things try to access it at the same time
hmm ๐ค might just do regular SQL then
Someone told me in order to use javacord i need to shade it how would i do that
oh ok
i`m using mysql
๐ ๐
are you using maven
Javacord? JDA gang where u at
I code my discord bots in Python lol
Yep
There I have my biggest pains. And discovred that non typed languages are not for me
go on goolge and look up how to shade a dependency maven I give you a 10,000% you find a good answer
Just do it like this
Does developing a warps system and pulling the information directly from the database cause lag?

depends
im using mysql
I tried and cpuldnt figure it out thats why i asked here
First on build add plugin maven-shade-plugin
what
I shade using maven-shade-plugin and them I shade every maven lib to my application libraries package
Good idea?
probably not
Okay why!
should only shade what is required and will most likely not be present on the server
an example hikaricp
but if you depend on another plugin however, best you don't shade it in ๐
I worked with maven since a year
I think its called refactoring. Cuz for example I shade mysql
From org.mysql
To dev.alex.net.libraries.org.mysql
It is officially called relocating, but same thing
All allright
Wait
Would that be better the one on top or downloading the library from repo and them loading to JVM?
I always have that dude
As long as you don't use reflection to load the libraries at runtime
Problem every doesk tonos
I only code 1.8x*
Im stuck to dont use newer versiones
Im think its because i had bad experience with jdk 18
Regardless of the database implementation, you can't really guarantee there will no lag
Pull warps at startup and itโs not an issue
Assuming I run a house system, wouldn't pulling information from the database all the time cause a delay?
Which is why you reflect it into memory
you technically can guarantee that the SQL connection does not lag the server
especially now given unix sockets are native in Java ๐
I thought of putting a hashmap
But that's if the database is hosted locally?
I thought of putting a hashmap
for unix sockets yes, but if its not you use a separate thread for the connection
yes
how to remove lore in banner pattern
pls help me in #help-server
in Java 8?
๐ง
I mean, I can't guarantee that's what you intend to do. Or for the long future
Java 17
hi I got a custom items on my server can I sell custom items using essnetials economy
What is the problem with the mysql?
There is?
I'm wondering if developing a house system and pulling the data directly from the database can slow down the server.
I made a system to cache player information, but how do I store several houses?
Dont ask it on every channel
import org.bukkit.Location;
import java.util.UUID;
public class LBLocation {
private UUID uuid;
private Location location;
public UUID getUUID() {
return this.uuid;
}
public void setUUID(String uuid) {
this.uuid = UUID.fromString(uuid);
}
public Location getLocation() {
return this.location;
}
public Location setLocation() {
return this.location;
}
}
sorry
you should do this asynchronousity, and, if it is called oftenly, cache
private static final HashMap<UUID, ?> cacheLocation = new HashMap<>();
You can cache it as a hashset/map
Up to you
What is the primary key
uuid
I prefer using Hasmap when need to cach uuid and data object. And then for caching data like reports, coldowns, punishments, etc I use hashset
What I use in my warp plugin? Sqlite or Mysql or File configuration?
Doesnt really matter
Do any of you know of any decent itemstack serializers/deserializers that takes up 1 string instead of 4, similar to Essentials? Also, I'm after a nice GUI API for 1.18. Any ideas?
If you want a good relational db, sql
You should work lime this:
Hashmap<Uuid, a playerObject>
I had code my own menรบ library
Yes, I use this, but each home will be an object
So I need by UUID and the home object in the hashmap
Yeah I wilm call
Exemple
private static final HashMap<UUID, (UUID, LBLocation) > cacheLocation = new HashMap<>();
import org.bukkit.Location;
import java.util.UUID;
public class LBLocation {
private UUID uuid;
private Location location;
public UUID getUUID() {
return this.uuid;
}
public void setUUID(String uuid) {
this.uuid = UUID.fromString(uuid);
}
public Location getLocation() {
return this.location;
}
public Location setLocation() {
return this.location;
}
}
this is my home class
If only java has such syntax for tuples
Leonardo
How am I going to add several houses to a single player in the hashmap?
Use a collection or custom class that includes a collection for value
He amresyd have
can u use minimesage in spigot
Hashmap<Uuid, LB Location>
Then Where you have that Map add this methods
LBLocation getHome(Uuid uuid) {
Return Hashmap.get(uuid)
}
void create(Uuid uuid, LBLocation location) {
Hashmap.put(uuid, location)
}
Void delete(Uuid uuid){
Hashmap.remove(uuid)
}
Thanks!!
๐
How you want mรบltiple homes?
You will need to do it different
how?
Each house will be individual in the database
Hashmap<Uuid, Set<LBLocation>> homes
If a player has 10 houses, how do I put the 10 in a hashmap?
oh ,ok
Code changed
I dont rember how to add the home object
Check how add value to a Set that its inside a Hashmap
Google its your best friend now
getHome(UUID uuid, String homeName)
hmm
i put uuid, homename, and location in mysql
Wait wait
Forglt about mysql
You will hsve really difficult with mysql. Your will need to use relstional tables
Cuz on mysql you cannot save Objects
But for nos
I explain the cache let say
Them ask how to save it
Omg its really difficult to help from cellphone
Cuz from pc I write the example on intellij
With copilot
๐ณ
you technically can save objects in mysql, that is what blob is for ๐
but, setting up the tables and what not is also not hard either
Explain him how to use this please
I dont remember how he add the object to the Set
Im so confused as to what he need help with
Cuz he will have mรบltiples homes for each player
Ok?
He doing a home system
Each player can have may homes
So i give him the Hashmap strucutre for the cache
yes
yess
Ok?
You explained to him the necessary objects already and you don't need a set, but another Map would probably be better since homes can have names ๐
HashMap<UUID, HashMap<String,LBLocation>>
HashMap().get(UUID).get(String)
with this it will be possible to cache several houses?
Yes leonardo
certainly
This are some basic java
map.get(uuid).put(name, location) if inner map has been initialized
example code stuff for caching
Still difficult to put data
feel free to look through all the rest of the classes too it is open source after all ๐
might find something useful in it ๐
?
well I linked a project that contains some very useful code either way ๐
๐
There must be reasons why manya discouraged the use of double map
well if there was only coordinates for the home sets but no names, a set would be better
but since it is easier for players to name their home sets a map is going to be more ideal for that
I would say creating a custom key class would be optimal
I would put the home name inside the object and them using Set#Filter
reject 2d maps
Me too
accept guava tables
Hum
You know it is built-in in spigot
You technically cant put anything inside i think
tables are similar to a DB design. Guava tables are good for larger data sets, like in the millions, but if you have anything less than a few hundred thousand hashmaps are going to either have same or better performance. If this is why you are recommending tables. However we shouldn't be do pre-optimization stuff when there isn't an inherent need for it.
I do
Table<UUID, String, Location>
table.get(uuid, string)
table.put(uuid, string, value)
Wtf it is just a fancy 2d map wrapper
Just use simple Map with uuid and Set object. Inside object the home name, loc, etc
Then just for get the home get it with
Object getHome(Uuid, Name) return Map.get(uuid).stream.filter(i -> I.quals(name)).findFirst().orElse(null)
Table<String, String, String> relations = HashBasedTable.create();
addRelationships1(dataSource1, relations);
addRelationships2(dataSource2, relations);
Map<String,String> idByName = relations.column("hasId");
Map<String,String> nameByFullName = relations.column("hasName");
relations.put(id, "hasFullName", fullname);
relations.put(relations.remove(id,"hasFullName"), "hasName", name);
relations.put(name, "hasId", id);
looks like more then just a fancy 2d map wrapper
Anyways, my point still stands however. Hashmap is going to be fine with what they are needing/wanting it for
maybe once their data set gets into the millions sure switch over to Tables
Table is just eaiser to use, and does the same thing
opinion really on that first one
Can someone help verify this
I mean there is nothing difficult about a HashMap
yes you cant
but the null checks, new map creation.. Table just reduces boilerplate
DRY
what do you mean by this?
So if you have a extends wildcard like this
The compiler cannot know the actual implementation of the key
And hence cannot accept anything other then null
it is an unchecked cast
So for example, HashMap<UUID, HashMap<String, Location>> is a possible implementation
you are allowed to do it, just the runtime can't be certain that whatever gets put through it is what it should be
and therefore it is on you to ensure the integrity of the object
Not unchecked cast
You simply cannot put anything inside
Lemme simplify this
If you have HashSet<? extends Number>
what do you mean put inside? You would be allowed to use it as I just said. All that is happening here or the issue you are describing is one of the downfalls of working with generics
Say you have this, and you try to .add(1), but how would the compiler know it is a set of double or a set of integer?
it will compile
public void putAll(Map<? extends K, ? extends V> map) {
for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
checkArgument(apply(entry.getKey(), entry.getValue()));
}
unfiltered.putAll(map);
}
telling me this won't compile?
generics don't prevent compiling, they prevent automatic integrity checks from the runtime and thus it is on you to create such checks yourself
I guess you dont understand what im saying
maybe not? But you could still put data into it if that is what you are saying
I don't see where generics would prevent it
Try giving it an Integer instead of an int
same thing
as said, the compiler must ensure that what is added is correct as of all possible implementations
that is, accepted by HashMap<Double>, HashMap<Integer>, HashMap<Long>, etc.
which means it cannot accept anything other than null
same concept for this, declaring a map like this will effectively make it useless
Well, not useless
useless in the sense that you cant add, that's all
you are right now that you illustrated. Anyways you can read from it which means you can assign a collection to that has data
correct however there is a way to add though
instead of extends
use super ๐
however the reverse would be true from extends
you could add but you couldn't read
no it isn't
you wouldn't be able to read it
sorry yea
but yea, that's what i meant by putting sth inside
List<? super Number> foo3 = new ArrayList<Object>();
//You can't read the specific type T (e.g. Number) from List<? super T> because you can't guarantee what kind of List it is really //pointing to. The only "guarantee" you have is you are able to add a value of type T (or any subclass of T) without violating the //integrity of the list being pointed to.
List<? extends Number> foo3 = new ArrayList<Integer>();
//You can't add any object to List<? extends T> because you can't guarantee what kind of List it is really pointing to, so you can't //guarantee that the object is allowed in that List. The only "guarantee" is that you can only read from it and you'll get a T or //subclass of T.
so as I said I agree with what you were saying about extends
just if you need to add anything to it, you just substitute out extends for super ๐
but again you have one end of the extreme you encounter problems with
you could add to it but never read from it or you can read from it but never add to it lol
@Entity
@Table(name = "players")
public class PlayerInfo extends Model {
public static PlayerInfoFinder find = new PlayerInfoFinder();
@Id
long id;
@NotNull
@Column(unique = true)
public UUID uuid;
@NotNull
@DbComment("Weather the user has verified their discord account linkage")
public boolean verified = false;
@NotNull
@Column(unique = true)
@DbComment("Players discord ID")
public String discordId;
@Unique
public String verificationMessageId;
public PlayerInfo(
@org.jetbrains.annotations.NotNull UUID uuid,
@org.jetbrains.annotations.NotNull String discordId,
@org.jetbrains.annotations.NotNull String verificationMessageId) {
this.uuid = uuid;
this.discordId = discordId;
this.verificationMessageId = verificationMessageId;
}
public PlayerInfo setVerified(boolean verified) {
this.verified = verified;
return this;
}
}
finally got ebean working
automatically supports every sql database, auto generates queries and migrations
๐
you can read from it from ? super T, just not the specific type. For which you can, as you said, cast it
you can read it of specific type if you wanted
just there is no guarantee that it is of specific type
List<? super Number> listSuperNumber_ListNumber = new ArrayList<Number>();
this is valid
that's exactly what I meant...
Hey guys, what could cause
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "org.bukkit.Server.getPluginCommand(String)" is null
on one server but not another when the plugin version is exactly the same?
I think we will get a long just fine with confusing new people with wild code
haha
i saw sth similar but with depth
like mind blown
it is a donut shape
"Donut math: how donut.c works" blog post by Andy Sloane:
https://www.a1k0n.net/2011/07/20/donut-math.html
Deobfuscated code: https://bit.ly/2BITbQm
easier to work with GPU contexts especially if the contexts are driver specific unlike Java you need to rely on something like OpenGL, or start using JNI for OpenCL
you should see the math behind this
it is as easy as ABC
C developers don't got a lot else to do
lol
I want mobs to float in sky, but have normal api they shouldnt go up nor down exactly like players' fly mode how can I do that
Create a barrier block underneath where they walk?
setGravity to false ?
i think your talking about AI
it will not remove AI
would be dump
but i think their code is designed to: if not on ground: dont move
i thought the only way to move no gravity entity is tp
if the AI would be set to false they wont attack you ... but if they fly somewhere they can still attack you
Is there no other way
why do you want to do this ?
I mean you could have them ride invisible bats but they'd move vertically as well.
?jd
is three a way to cancel sit animation
I mean the setgravity should be tested first
ok thanks
before I make a hashmap, there is no method to get the cooked equivalent of a raw food right?
you can check all Recipes ^^
Hello everyone! I'm currently trying to make an ArmorStand go from a point to another using teleports, I'm using this method that you can see in the photo, and I want to make 2 things: the ArmorStand should move also in the y axis (currently it only works horizontally) and i also want to make it move in a specific time... as you can see i'm parsing a total_time_in_seconds value and i want the armorstand to be at the b point in that specific time...
Can someone help me please?
looks strange and too complicated to use Math cos/sin stuff
i found that online... i thought it was the easiest way ๐คฃ
i would use LocationB - LocationA = DifVector
DifVector.normalize.multiplay(distance_per_second_or_tick)
I'd just use something like
double xDist = src.getX() - dest.getX();
double yDist = src.getY() - dest.getY();
double xPerTick = xDist / ticks;
double yPerTick = yDist / ticks;
Location loc = src.clone();
foreachtick -> {
loc.add(xPerTick, yPerTick, 0.0);
entity.teleport(loc);
}
so there is no way to make it with teleports?
The least computationally expensive implementation
thank you i'm trying
add the DifVector to the location the entity has
Just make sure to use cancel the task when it needs to be
ok
It is working but not quite.. it is going in the right direction but not in the z axis...
okk.. tysm
how do I check if a blocktype is equal to fire? when i do getType().equals(Material.FIRE) it always returns false even if the type returns as FIRE. If i change it to for example oak planks it does work.
Tysm! It worked perfectly @quiet ice
Hi guys, I was wondering if there is a way to make an entity morph into another for a specific time.
Btw, thanks everyone
You'd need to remove the entity & replace it with another and then respawn it after the specified time. Kinda lossy
So there is no way to change the entity_type?
no, because the entity type correlates with the entity class, and as you should know you cannot change the class of an object (without creating a new instance that is)
ok ty
there are nms methods to "transform" the entity ... but its just copy nbt and spawn new, remove old
ty
Wait so you mean that the equals isnt working
Because it does return FIRE from getType()
yes it does but the if statement returns false
Hi guys, again, I wonder if there is a way to remove the collision from an Entity... As I was doing before, I'm making the morph but I didn't remove the entity and I just used invisibility (because I also want to use it with the player) and what is happing is that the collision of the Entity overlaps with the player and it moves just by that...
Sorry for all this questions...
a byte can hold numbers from 0 to 255 right
an integer is 4 bytes
to get a bigger integer limit
cant u just make 4 bytes
it will cost the same memory as an integer
but will have a bigger limit
255,255,255,255
thats 255billion
byte is - 128 to 127
what
No, 4 bytes is 32 bits
An int is also 32 bits
this thing said that
Java types are signed
except for char
its different for java?
It's the same in any language
Sadly Java does not provide ubyte or uint
then this is wrong
Also, even if you were to manually make them unsigned, how are you going to represent 300?
uh
Itโs correct, 255 patterns
lmao
Hey, can someone help me with this?
https://www.spigotmc.org/threads/entity-player-player-noclassdeffounderror.544476/#post-4354750
"Each number is stored in one byte (so the number is in 0..255)"
What you are searching for it BCD, but it is useless given that 6 out of the 16 possibillities are wasted for parity
Are you building with maven
-127 to 128 is still 255 values
Also the people working on computers are smart
Yes.
but like it says 32 is a space right
If 4 bytes somehow provided an advantage over 1 int, they would have realized that
Char is unsigned
o
For a moment I was confused
Shh itโs half 6 in the morning
BCD can only encode 10 possible numbers with 4 bits while more traditional binary can encode 16 possible numbers
In java, yes
but isnt a char a byte
Yep
what the fuck
IN java that is
oh so a char extends a byte
In c char = byte
no, in java char = short but unsigned
bru
Which is why you should use int (codepoints) to represent characters :)
a char is two bytes
what the
(16 bits)
its different in java?
Yes
ASCII is not all the characters
C does not have byte, only char
Unicode prevents that
255 is not enough to represent all characters
You technically need quadruple the memory now
I read there that a unicode thing is like 16 bits
However
No, it's more than that, which is why java is getting rid of char more or less
what the fuck
Modern java is smart, and strings actually use a byte[] rather than a char[]
i might have to look for a guide in java then
Does anyone know how I program a BungeeCord and a Spigot plugin in a Jar?
Just have both entry classes
have a plugin.yml file and a whatever-it-is-called.yml
Plus a plugin.yml and whatever bungee uses
do u know a guide
for these stuff
that applies to java
I mean yeah i know that stuff
Common sense
wdym common sense
And the javadocs in the String class
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Does not working
Ah, I see I am not the only one with bad english
Iโm not sure if that was a typo or intentional
But Iโm going to pretend it was intentional
Likely intentional
I personally have all the data types nonsense in school and for some reason many are not able to grasp it.
So don't be afraid if you do not understand this
and then also have non-zero types so we do not get divide by 0 errors
what is a hexadecimal format
base 16
0 - 9, A - F
so its a number between 0 and 16?
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
whats this then
binary is a base2 number system
if it had a max of 16
That is 2^31


