#help-development
1 messages · Page 146 of 1
Yeah looks like it
alright
ahhh yes i too name my variables names that make absolutely zero sense!
if(6*blabla / blahblah == 0){
momma.doRandomStuff();
}
💀
ah please dont forget int asdasiuohydkbsajdfohbauisdfbouihhelpplesase
How can i set the gang name to indicate the path to where it have to add the player?
List<String> membersList = RPGangs.getInstance().getGangsData().getStringList(".gangs" + "." + gangName + "." + ".Members" + ".", player.getUniqueID);
How do people do dependency injection? is there some way to have a di container from spigot to basically autowire the things or is it just basic constructor injection?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
thats all understood
just asking if theres more to it
Ive been hearing and seeing di containers with autowire capabilities like springboot and the likes. If that ever becomes reality in spigot ima be happy 😄
Crash report: https://paste.md-5.net/oquwiyuceq.cs
Command: https://paste.md-5.net/jixutuwuta.java
Event: https://paste.md-5.net/ilozuhazim.cs
Okay so the first problem is that when I withdraw lets say 100, it puts 1 extra 0 so 1000 on the paper. Dont know why. Also when I try to deposit the bank note the server crashes. Could someone look at this?
Should I try to support /reload or is it jsut not worth the effort
I understand, but he should just try to do something easier if he needs help with every single line
?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.
Everyones go to is to type ?learnjava like thats not what people are already trying to do
Ya but like, if I support it. I need to support it the entire way or else my brain wont be happy
no everyones go to is ?learnjava when people dont know how to write a method
But he’s learning, he asked a question, linking docs isn’t the solution lol
Sometimes i can do normal java but when im doing bukkit api it gets more confusing
Crash report: https://paste.md-5.net/oquwiyuceq.cs
Command: https://paste.md-5.net/jixutuwuta.java
Event: https://paste.md-5.net/ilozuhazim.cs
Okay so the first problem is that when I withdraw lets say 100, it puts 1 extra 0 so 1000 on the paper. Dont know why. Also when I try to deposit the bank note the server crashes. Could someone look at this?
Whats economyManager
TRAP is because somethings null right
its the economyManager
how does this even work
ur using amount before its even set
It did work tho just added a 0 after
will that remove the crash?
ok i will try
"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.
its java idk why it rendered as cs
well still the error is in the .bash
error happend when:
[15:27:26 INFO]: EthanGarey issued server command: /gamemode survival EthanGarey
I compact it when it’s finished
Idk why it does
isn't possible and it takes like 2 minutes to compile a file of 20kb 💀
removed the objects requirenonnull
still crashes the server
Somethings null
I had this before and used try and catch to fix it
Its the itemstack
?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.
Runnable need to be registed and in case how?
this kilocodes kid cant be serious btw
I had the exact same error when i was redeeming a heart item for lifesteal
Kid? Im 21
Your brackets are wrong, i gave u links for java
Morice
I’m aware its not your code
I was referring to it
But we all know its his code so i figured you’d put 2 and 2 together
?
Back to your problem i had this exact same error when i was redeeming a heart capsule (lifesteal), try and catch of the recipe fixed it and i also got it when i was in gamemode and tried to redeem it so i made a gamemode check, so maybe its something simple like that
Try catching an npe is like putting a small bandaid over a bullet wond
Try using regex101.com
When did i say catch it, i was referring to something i had experienced
I suck at regex @river oracle
do you ever just find what the issue was while writing a question about it?
Same but it has a key and everything for yoh on there
It's super helpful
Just a rec ofcourse
?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.
Lol don't expect help If your going to act like that. tbh also if your currently learning Java spigot api isn't the place to start
Look how mad you get
I was explaining something i’d experienced and you are having a x generational melt down because im voicing an opinion
Im entitled to talk
Do I have to do Player#sendBlockDamage every tick?
Seems like it disappears after the first one-
Imma try it
Method: https://paste.md-5.net/pazotobeva.cs
I need to rewrite the above to support the following
Dim dimName;
Dim dimName, dimName2, ... // Each of those would be considered a different VariableInit
Dim dimName : dimName = Array("", "", ...);
The above would return
dimName
dimName, dimName2, ...
dimName, dimName, Aray("", "", ...)
There's some other stuff, but I need to find examples
So just match after comma?
Not an option for all of those
and exclude semi-colons etc
hmm hold up I'ma take a crack at this though my regex knowledge is limited
Im so confused
How would I disguise a mob such as a zombie as a player with packets?
There's a lot of things that need to be taken into account @river oracle lmao
I know lol its crazy does the line need to end in a semi colon
nope, that's not that this uses. There's no line ending
Unless you know of a way to add zombie ai to an EntityPlayer then yes, I would like to implement it myself lol. I don’t care how hard it’ll be xD
Dim appOlk
Returns appOlk
Dim arrNormal21 : arrNormal21 = Array("元日,1,1","建国記念の日,2,11","天皇誕生日,2,23","昭和の日,4,29","憲法記念日,5,3","みどりの日,5,4","こどもの日,5,5","海の日,7,19,7,22","スポーツの日,10,11,7,23","山の日,8,11,8,8","文化の日,11,3","勤労感謝の日,11,23","大みそか,12,31")
ReturnsarrNormal21, arrNormal21, Array("元日,1,1","建国記念の日,2,11","天皇誕生日,2,23","昭和の日,4,29","憲法記念日,5,3","みどりの日,5,4","こどもの日,5,5","海の日,7,19,7,22","スポーツの日,10,11,7,23","山の日,8,11,8,8","文化の日,11,3","勤労感謝の日,11,23","大みそか,12,31")
Dim objConnection, objCommand, objRecordSet, objRype, objGroup, objUser, objType
Returns objConnection, objCommand, objRecordSet, objRype, objGroup, objUser, objType
Dim dif1(), dif2(), Diff() As Single
Returns dif1(), dif2(), Dif(), Single
Dim n As Integer
Returns n, Integer
Dim propArray()
Returns propArray()
Dim strArgSortDes(10)
Returns strArgSortDes(10)
@river oracle
That's most examples I can provide lmao
wtf is this is this obfuscation or something?
what is VBScript for
how can i display hex colors on scoreboards
VBScript is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. It allows Microsoft Windows system administrators to generate powerful tools for managing computers with error handling, subroutines, and other advanced programming constructs. @river oracle
hmmm interesting
Found another 2 examples lmao
Dim Zvalue1(0 To 1) As Single
Not sure on this one, Idk VBScript
Dim fileName : fileName = ""
Dim min : min = ""
Dim max : max = ""
Dim strings : strings = ""
Dim progressStr : progressStr = ""
These need to pass as well
Dim objConfig ' Dictionary object for configuration
This too, minus the comment. The comment being the ' and everything after it
what i am trying to say is how do i add exact colors to a scoreboard and not just the stuff in the chat color enum
Dim arrArray(), _
i
There's also this, not sure. Again I don't know VBScript
That should be the majority of them @river oracle
tldr; It's complex af
Anyone? Wow, did not think this was such a hard question to answer lol
Ahhh, the fun times of having 656 files to test with lmao
you could use mythical mobs
sorry i didnt see your question
“With packets”
Thank you for the suggestion though
They most likely want either an NMS or ProtocolLib answer @jaunty crag
i dont know what nms is but i do know what protocolLib is
net.minecraft.server
ohh
do you know to get hex code colors on scoreboards 1.19
i know its possible i just dont know if it is on spigot
should I use assert?
ah, no idea for either of those
@river oracle
Here's a semi-complete list of things that need handled lmao
Dim dimName;
Dim objConnection, objCommand, objRecordSet, objRype, objGroup, objUser, objType
dim dimName, dimName2
Dim dimName : dimName = Array("", "", ...)
im arrNormal21 : arrNormal21 = Array("元日,1,1","建国記念の日,2,11","天皇誕生日,2,23","昭和の日,4,29","憲法記念日,5,3","みどりの日,5,4","こどもの日,5,5","海の日,7,19,7,22","スポーツの日,10,11,7,23","山の日,8,11,8,8","文化の日,11,3","勤労感謝の日,11,23","大みそか,12,31")
Dim dif1(), dif2(), Diff() As Single
Dim n As Integer
Dim propArray()
Dim Zvalue1(0 To 1) As Single
Dim fileName : fileName = ""
Dim min : min = ""
Dim max : max = ""
Dim strings : strings = ""
Dim progressStr : progressStr = ""
Dim objConfig ' Dictionary object for configuration. This comment should be ignored
Dim arrArray(), _
i
Dim varPivot, _
intLoSwap, _
intHiSwap, _
varTemp
Not fun lmao
only for tests, not for actual use
Ughhhhhhh I tried doing Player#sendBlockDamage every tick but it still has that flash between the client and the server
I tried giving mining fatigue
just made it wrose
Might be worth doing each of those as separate things actually Y2K
Yeah, either or
also just remembered I need to re-do the vbs stuff in general lmao
does dim have to be capital? or can it be lowercase as well
case insensitive I'm pretty sure
😭 I though tI was so close
the only thing i'm stuck on is recursively matching after cutting out the keyword than filtering again idk how to do that with one regex
since I'm not doing a BNF or anything like that, I'll probably just do a fuck ton of if statements given the complexity of this
for example rn I have this
(?<=dim | Dim )(?![As])([a-zA-z0-9]+) which filters some keywords and such but it stops after first match 🤷♂️
This is all the current VBS code btw 😛
https://github.com/OpticFusion1/Kitsune/tree/master/src/main/java/optic_fusion1/kitsune/parser/vbs
https://github.com/OpticFusion1/Kitsune/issues/58
https://github.com/OpticFusion1/Kitsune/issues/57
https://github.com/OpticFusion1/Kitsune/issues/56
and those are the open issues which are specifically for VBS 😛
more to come as I go through and test everything lol
Are you trying to implement some "obscure" scripting language in java or what
Analyzing, actually.
It's for analyzing malware, found it in html so I need something to deal w/ that lmao
Also just so you are aware of it - it is possible that ZipFile has a different implementation to the implementation used by the JVM
None of these are zip files lmao
can World.getWorldBorder() be null?
unless you mean the pk check, then yea. It's just a quick check
I need to go through a bunch and handle the various different types
I just saw https://github.com/OpticFusion1/Kitsune/blob/master/src/main/java/optic_fusion1/kitsune/tool/impl/StringsTool.java (and others) use ZipFiles
Ah yea. I need to do more testing and figure out what to do w/ any files that break
If you're gonna throw stuff at it, just open an issue for anything that breaks
https://github.com/OpticFusion1/Kitsune/issues
The JVM zip reader implementation is based off this piece.
This is a zip format reader for seekable files, that tolerates leading and trailing garbage, and tolerates having had internal offsets adjusted for leading garbage (as with Info-Zip's zip -A).But that's not all it does. That's just what that one comment says. Some other fun quirks of the JVM zip parser:
The end central directory entry is found by scanning from the end of the file, rather than from the beginning. The central directory values are authoritative. Names/values defined by the local file headers are ignored. The file data of local file headers is not size bound by the file header's compressed size field. Instead, it uses the central directory header's declared size. Class names are allowed to end in trailing / which most tools interpret as directories.
If anything I find or make a library that handles multiple types :p
Latter quirk is definitely accounted for though
Err, only in the fix tool lol
I also need to rewrite the VBS code. Most likely gonna do that once I have it supporting more of the VBS functionality however
I have a collection of vbs scripts if anyone hates themselves enough to attempt that lmao
is there a way I'd make a method that tells IntelliJ that my object isn't null without a null check? i don't have a better way to explain it so i'll give an example
like I have the Bukkit player and I have the MinigamePlayer class
and I have a getMinigamePlayer method which can be null
how would I make intellij stop giving me warnings with a isInMinigame(Player p) which acts as a null check without it being directly a null check
use the jetbrains annotations like @NotNull and @Nullable
i do
but getMinigamePlayer(Player) can be null
but it won't be if isInMinigame(Player) is true
oh so like
how do i let it knjow that
ah
over 1k to be exactly lol
ok not sure if this is what your looking for, but for statements like this
Dim objConnection, objCommand, objRecordSet, objRype, objGroup, objUser, objType
(?<=[^dimDim])([^ Array][a-zA-z0-9]+) ok this one shoulddd work for this example and other similar examples to it I'm not sure how i'd shove array stuff into here so I didn't idk if you mind having another matcher for that or what
or getMinigamePlayer
like
@Contract("null -> false")
public boolean isInGame(@Nullable Player player) {
return player != null;
}
this would tell intellij
that your method would always return false for a null player
relying on null for code logic:
agreeing with 2hex, isInMinigame should not really do the nullcheck imo
null can never be in a minigame
so it being a valid parameter value feels a bit off
getMinigamePlayer(Player) should return a non-null value if the player is playing in that minigame instance
since there are multiple running at once
it's not how i find what game they are in
Well yea but that certainly can be null
yes
Yes
Enum.values[random]
Get the values array and select a random index
well just use null objects
not rlly a spigot question but has any1 here worked with AffineTransform's with Graphics2D?
since im drawing stuff on the screen
those are getting translated by the affinetransform. but i cannot figure out how to translate said drawings back to screen positions so that i can calculate wether or not the mouse is hovering said drawings...
Text: Dim obj; Type: class optic_fusion1.kitsune.parser.vbs.VariableInit Line Number: 0
Text: Dim objConnection, objCommand, objRecordSet, objRype, objGroup, objUser, objType Type: class optic_fusion1.kitsune.parser.vbs.VariableInit Line Number: 1
end goal is having something similar for the first line, but for each of those in the array
i.e.
Text: Dim objConnection; Type: class optic_fusion1.kitsune.parser.vbs.VariableInit Line Number: 1
Text: Dim objCommand; Type: class optic_fusion1.kitsune.parser.vbs.VariableInit Line Number: 1
Text: Dim objRecordSet; Type: class optic_fusion1.kitsune.parser.vbs.VariableInit Line Number: 1
Text: Dim objRype; Type: class optic_fusion1.kitsune.parser.vbs.VariableInit Line Number: 1
etc, etc, etc
Which means getting https://github.com/OpticFusion1/Kitsune/blob/master/src/main/java/optic_fusion1/kitsune/parser/vbs/StatementFactory.java#L62 to handle that, among the other variations of Dim lmao
return getPlayerList().stream().filter(Objects::nonNull).map(ExtendedPlayer.class::cast).toList();```
how come this is immutable?
because toList is immutable ?
.collect(Collectors.toList
I wish my bank account wasn't immutable
in terms of implementation anyone happen to know if getNearbyEntities iterates through all loaded entities in a world off the top of their heads?
how would i attach nbt to a dropped item? couldnt find any nbt stuff to use
Hey, can anyone help me think of some non messy way of doing this:
So I have string in my config that looks like this:
|-
&8---&6%player &3Something&8---
&3%placeholder - &6%timestamp
&3%placeholder - &6%timestamp
&3%placeholder - &6%timestamp
&3%placeholder - &6%timestamp
&3%placeholder - &6%timestamp
&8--------&6%current&8/&3%max&8---------
I want to make it TextComponent and only %placeholder parts clickable (each with different click event), but it seems to bit a little more complicated for me then expected
is that your own placeholder system or from placeholder API?
@echo basalt imagine needing more than one line
getTargets(eliteEntity, directTarget).forEach(target -> getZoneTargets(target.getLocation()).forEach(livingEntity -> behavior.forEach(key -> scriptActionMap.get(key).runActions(eliteEntity, livingEntity))));
imagine wanting more than one line
https://paste.md-5.net/tisogijuha.bash <--- error
https://paste.md-5.net/obomivopeh.cs <--- java code
Dude seriously fix that code before worrying about those errors. Clean it up it's way more than it needs to be.
I compact it when I fix the errors.
How do I compact it if I dont know how it works? (Errors going to be more painfull)
That sounds like you need to rewrite it then if you don't know how it works
It'd take me about 20m to clean it all up. Google functions and how to use them in java
my own
okay so first split the string using that placeholder as the separator
then make the message and add an extra component in the middle that can be clicked
for some reason i didn't even think of it
thanks, will try that later
How do I add arguments to acf commands
seriously
uh
they made the whole thing and never made you be able to make args in it
hi quared
why does this make their XP go negative 💀
public void checkForLevelUp(Player player) {
while (getXP(player) >= getRequiredXP(player)) {
incrementXP(player, getRequiredXP(player) * -1);
incrementLevel(player, 1);
}
}
hi
i could do -getRequiredXP(player)
actually
wait
but that's besides the point
lemme rewrite this for ya ❤️
the methods are sql queries btw
🥄
hi lynx ❤️
lol xD
I really can't type the coed
I mean a) I'd highly suggest caching these values
instead of doing SQL query calls
guessing the required amount of XP goes up each time? @torn oyster
ye
exponentially?
what is the formula yea
its 240*level
alr
could I use redis for that?
wonder if this is possible without a loop 
oh
ok
that will be fine?
oh yeah it's level + 1 btw
240 * (level + 1)
if that changes anything 🤷
that forumlar seems a bit off
oh?
I presume your level is actually the xp needed to get to that level
right ?
or does each level just require 240 xp more
thiss
ah
public void checkForLevelUp(Player player) {
long currentXP = getXP(player); // Cache the current XP of the player
long requiredXP = 0; // The required amount of XP for a level up
long currentLevel = getLevel(player); // Cache the current level
while (currentXP >= (requiredXP = getRequiredXP(currentLevel))) { // Re-define the variable requiredXP to the new xp required to level up
currentXP -= requiredXP; // Take away the amount of required xp from the current xp of the player (cached value)
currentLevel++; // Increment the level if they have enough
}
setCurrentXP(player, currentXP); // Set the current XP value of the player in the database
setLevel(player, currentLevel); // Set the current Level value of the player in the database
}```
If I'm correct, you could probably do something like this. And you probably need to create a new method "getRequiredXP(long currentLevel)" and do your calculation in there.
Yeah, then you're not querying the database every time the while loop executes
yep
I hate this.
yeah but guess what buddy
it works
or so I assume I'm testing it rn on stream
good
you should see the class now
it's grown
like a benign tumor
the cool kind that makes you grow to 7ft tall
Funky
is it good to have a boolean as a method parameter?
in your case?
like what is it used for
most likely
if it cant find the mitsubishi material
well i'm making a gameSummary method which increments their xp at the end of the game and gives them a summary
and i want a boolean win
ah
to determine if they won or not
sorta
its a bunch of different sendmessages
like
if (win) {
player.sendMessage("Win Bonus: 100 XP");
database.incrementXP(player, 100);
}
I mean I guess that should be fine
you can just use win without the ==
oh thats neat.
or !win
I never new that lol ty
that actually looks half decent what
pop off king
That looks neat
i just forgot to use my colourize method on my two top things
that isn't good looking
depends on many factors
Yeah that will vary from project to project and what all is cached
After i do config.save(file), would I need to use YamlConfiguration.loadConfiguration(file) to update the config file's data?
you should only need to load it again if you made changes to the file.
kk
I am getting a ton of errors on my IDE saying that Java can't find symbol when I'm trying to register my commands/listeners. This worked completely fine before and had no problems. Here is the part where it thinks it's wrong and all my classes:
if (object.getItem().getType() == Material.PLAYER_HEAD) {
SkullMeta meta = (SkullMeta) object.getItem().getItemMeta();
meta.setOwnerProfile(Bukkit.createPlayerProfile(
item.getString("skull-owner").equals("self") ? player.getUniqueId() : UUID.fromString(item.getString("skull-owner"))
));
object.getItem().setItemMeta(meta);
}```
how come this throws the Caused by: java.lang.IllegalArgumentException: The skull profile is missing a name or textures!
error
restart
- invalidate caches
restart what
try that first
mhm
k thx
a
Because you didn't add a texture
Bukkit.createPlayerProfile(
item.getString("skull-owner").equals("self") ? player.getUniqueId() : UUID.fromString(item.getString("skull-owner"))
));
That is the profile you make, you only give it a uuid
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.nameUUIDFromBytes(texture.getBytes()));
PlayerTextures textures = profile.getTextures();
try {
textures.setSkin(new URL(TEXTURE_URL + texture));
} catch (MalformedURLException e) {
e.printStackTrace();
}
profile.setTextures(textures);
Example of adding a texture
im getting an error when I run a command I made... can anyone help me?
hi redempt ❤️
Hi
Usually helps to include code but also the error pretty much says what's happening
You're trying to read index 0 of an array that is empty
So you need to check that the array has an element to get first
check the args.length btw
to prevent that from happening
yea ima do that
like what redempt said
uh I have another error... I have a cmd /particles and u use an arg and set the particles to something and the particles are not showing up. I have animations in video settings on in mc. Here is the code for the move event for particles to be summoned:
public class Particles implements Listener {
public Particles(CoolPlugin plugin) {
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onMove(PlayerMoveEvent event) {
if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getY() != event.getTo().getY() || event.getFrom().getZ() != event.getTo().getZ()) {
if (particlemap.get(event.getPlayer().getUniqueId()).equals("smoke")) {
event.getPlayer().getWorld().spawnParticle(Particle.SMOKE_NORMAL, event.getPlayer().getLocation().getX(), event.getPlayer().getLocation().getY(), event.getPlayer().getLocation().getZ(), 5);
} else if (particlemap.get(event.getPlayer().getUniqueId()).equals("hearts")) {
event.getPlayer().getWorld().spawnParticle(Particle.HEART, event.getPlayer().getLocation().getX(), event.getPlayer().getLocation().getY(), event.getPlayer().getLocation().getZ(), 3);
} else if (particlemap.get(event.getPlayer().getUniqueId()).equals("fire")) {
event.getPlayer().getWorld().spawnParticle(Particle.FLAME, event.getPlayer().getLocation().getX(), event.getPlayer().getLocation().getY(), event.getPlayer().getLocation().getZ(), 10);
}
}
}
}
what's the TEXTURE_URL
private static final String TEXTURE_URL = "http://textures.minecraft.net/texture/";
is it a uuid after that?
because the texture is just steve
and i put my uuid afet that
after
are you wanting to get a texture from a UUID?
yes
the texture is just sbeve though 🗿
Alright, I'm not sure if there's an api for that in later versions
that's what the texture url is
how do i get that though
it's a randomly generated string at the end
that weird thing
.
oh
i didn't see that
okay
agh i have another question
i'm on fire today
anyways
what would be the best way to store a friend system in mysq?
mysql*
can you store lists in mysql?
I wouldn't do that personally. I would opt for a friendship table
(CHAR(36) friend1UUID, CHAR(36) friend2UUID)
No?
this is why I love mongoDB
No?
no
Every unique friendship is put in there
i see
They're not unique, ye
that makes sense
choco what do you prefer
i'm slow asf 💀
mongo or sql owo
To get a player's friends you can do a quick query of SELECT * FROM friendships WHERE friend1UUID = ? OR friend2UUID = ?
(where the two ? are just the player's UUID you want to search for)
yep
so each player has 2 rows per friendship, one is where they are friend1, the other is where they are friend2, correct?
if that's the case, then you should only need to select friend1
since that makes more sense
Actually, to add to that, I'd format that table with a unique identifier too. INT id AUTO INCREMENT, (CHAR(36) friend1UUID, CHAR(36) friend2UUID)
Where the id is the primary key
or else it would overwrite
No, not necessarily
The reason for it is so that if you want to associate data with specific friendships, you can do that in a new table with a foreign key that refers to the friendship id
Say for example you want to associate a level with each friendship
Now you can make a table with the columns (INT friendshipId, INT level), where the friendshipId is a foreign key to the id column in the friendship table
SQL is fun :)
?
(poor example - in the one above you'd just have a level column, but it's useful for the future in case you add more unique data!)
I really do suggest including a unique id with it. It will save you headaches in the future
I'd honestly put the creation timestamp in the friendship table too
Any basic information you expect to get from a friendship should go into it
or if you want sneaky-peeky data like hypixel loves to have
they store a lot of stats
I am trying to use an if statement if the player's uuid is this and its not working. it is my uuid and it will give me an error if I put it in as anything but a string so I did this. How do I make it work?
if (event.getPlayer().getUniqueId().equals("f8725c52-c5e5-some numbers :)-8609-42b70fdbfb77")) {
uuid isnt a string
well a uuid is uuid object
it wont let me put it as anything else
UUID.fromString("string")
how would I do the exact line I had up there as a uuid object
could call uuid.tostring
uh
getUniqueId().toString().equals("the uuid")
UUID uuid = UUID.fromString("f8725c52-c5e5-some numbers :)-8609-42b70fdbfb77");
if (event.getPlayer().getUniqueId().equals(uuid)) {
or that
I'd really recommend learning java before doing plugin dev, it will help you a lot
I did a course on it
but how would a course tell me that a uuid in minecraft is not a string
this is basic java objects
well the course will teach u about types
bump
have you verified that the user is in the map?
also please use local variables
will make your code so much cleaner
the fact you can't do expandible code with yml highlighting in github wikis makes me a sad camper
best I can seem to make it is using the pre and code tags but that doesn't do any nice colors
not inside a spoiler my boy
not unless there's a different kind of spoiler to the one I'm using
it breaks ``` formatting
it doesn't break code but code isn't as fancy
well
it breaks code it doesn't break pre + code
How are you doing spoilers?
summary
<details>
<summary>Example </summary>
<pre><code>
particles:
x: 0.1
y: 0.1
z: 0.1
particle: FLAME
speed: 0.01
amount: 1
</code></pre>
</details>
Yeah you can definitely code block that, you just have to indent accordingly
<details>
<summary>Example </summary>
\`\`\`yaml
particles:
x: 0.1
y: 0.1
z: 0.1
particle: FLAME
speed: 0.01
amount: 1
\`\`\`
</details>
Grrr
Stupid Discord formatting
oh god this formatting is horrendous
I get the idea, it's github that doesn't

yay I can make my wiki marginally less daunting
boy
let me tell you
I've been on a crusade

I'm opening my remote desktop app to steal this rn
feedback?
do you have a site i can find minecraft models?
WorldBorder wb = Bukkit.getWorld("world").getWorldBorder();
wb.setCenter();
and the error is
Cannot resolve symbol 'setCenter'
why is that
it takes a parameter
the getWorldBorder?
oh no no
wb.setcenter is just not working at all
and all other commands
yesh setCenter takes a parameter
i cant send a photo but
WorldBorder wb = Bukkit.getWorld("world").getWorldBorder();
wb.setCenter(0,0);
error Cannot resolve symbol 'setCenter'
are your imports set up correctly
NetBeans probably??
Are you using the right bukkit ver?
im using the latest
And with using I mean declared as a dependency in maven/gradle
Not to be rude but i dont understand what your saying
Are you using maven
yes
https://paste.md-5.net/getiridaya.java I am using this type of config, i am saving it onDisable. But it still is resetting the file.
well i handled
i just pasted load();method everywhere and fixed
public class Main extends JavaPlugin {
private static Main plugin;
TestConfig.load();
@Override
public void onEnable() {
TestConfig.load();
TestConfig.load();
TestConfig.load();
TestConfig.load();
TestConfig.load();
TestConfig.load();
TestConfig.load();
TestConfig.load();
TestConfig.load();
plugin = this;
saveDefaultConfig();
getServer().getPluginManager().registerEvents(new onDie(), this);
getServer().getPluginManager().registerEvents(new onJoin(), this);
TestConfig.setup();
TestConfig.load();
TestConfig.save();
}
@Override
public void onDisable() {
TestConfig.load();
TestConfig.load();
TestConfig.load();
TestConfig.load();
TestConfig.load();
TestConfig.save();
}
}
maybe try this?
customConfig
ah
Just check if file exist, if not copy input stream from resources to file
Why are you repeatedly loading it lol
in what way is it reset? do you add anything to it?
YamlConfiguration#save() overwrites the existing file, so if you save the thing you loaded from it it will reset every time
Looks amazing , sorry i just woke up xd
how do i kill the exp a player drops when he dies?
declaration: package: org.bukkit.event.entity, class: EntityDeathEvent
PlayerDeathEvent#setDroppedExp(int)
tysm
why wont this work?
isn't there a take method
(Inventorycloseevent)
I haven't used spigot in ages but surely that's trying to compare an ItemStack and a Material which won't equal each other.
nope
the inventory has a #contains(Material)
Ahh oke
so you want the player to lose levels when they dont have a dragon egg when their inventory closes?
(This evaluates to: If the player's inventory does not contain a dragon egg revoke 100 levels from them)
yes
if they put the egg in the inventory
what?
if they put the egg in inv and close it it should remove 100 levels?
describe to us how it should work
and should it then not remove the egg or what?
so basically i wanted it to happen as soon as they put it in the inventory (anything else than the player inventory) but this would also work out
okay
so
if they remove the dragon egg from the player inventory, and put it in a chest, you want to remove 100 levels?
is that what you mean?
I mean I see what you are going for but this will subtract a lot of levels from a lot of people just playing the game normally
yes
and then what?
because if they put it in their inventory again and move it again it will still remove 100 levels
and if they put it back in their inventory they gain 100 levels
okay so how would you write that part then
how?
well i couldnt really fugure out how the player can gain -100 levels if it happens as soon as they put it in the chest (nvm i actually did figure it out but there are too many exp dupes..) but its also ok if u get the -100 levels if u close it
sucks to be you
what do you need
.
please use my actual username if you want me to help you
lol i was jk
@pseudo hazel
umm
im confused what your actually trying to do
setLevel(getLevel() - 100);
so what they essentially want is to give a dragon egg a value of 100 levels, i.e. when you pick it up it should give you 100 levels and when you get rid of it it should subtract 100 levels
exactly
so I would actually just not use events at all and make a bukkit scheduler
that just checks every x seconds if a dragon egg is in your inventory
but thats probably not the best solution
nah
but I believe it will prevent most if not all dupes
i tried that already but it didnt work
why not
it was too hard
which part
how do i get click from upper chest inventory, i tried getView#getTopInventory but it also reads player inventory above hotbar
like i did the for loop part but i whenever i got the egg i always gained more and more levels
and also it isnt really efficient
so i sticked to events
getRawSlot gets a slotnumber unique in the whole inventory
nvm i fixed it, i was using getInventory instead of getClickedInventory
i see
im so confused, does #saveConfig(); remove strings for some reason
Things in quote marks
eg i have
player: "The__Epic"
on the default config
after saving it becomes
player: The__Epic
oh
well for yml it doesnt really matter
unless you use quotes in the string directly
I dont, i was just wondering why it did that
but those 2 are still the same value when read
it probably does that since its the default way for strings to be saved
if you do ''
it's gonna save as ''
but if you put a new string inside it won't have quotes
as far a i remember
correct unless you use 'string' to wrap
Bukkit.getPlayer(UUID).getName
getOfflinePlayer(UUID)
always try to use OfflinePlayer if you don;t need an actual Player.
If it exists the OfflinePlayer will always be there and will never change instance. Player is transient
Doesn't offline player need to query something 🤔 I always thought it did
Does OfflinePlayers containts Online players?
no, its cached
No actually other way around iirc
Player extends OfflinePlayer
^
Everyone online will be possible to gran the OfflinePlayer as well it's not for specifically if they are offline
No, check every tick
but i just dont understand why this doesnt work
actually nevermind
@fluid river
if doesn't work then it doesn't accept negatives
alr
lol
then what's not working
check if that is even executed
maybe condition was false
i think nuker needs java lessons
maybe you didn't register listener/commandexecutor
jk
not knowing about new spigot API's methods doesn't make me bad at jaw
lol jk
check if condition is true or false
lol how much i slept
getInventory().contains(Material)
is this even spigot?
not paper
declaration: package: org.bukkit.inventory, interface: Inventory
here is itemStack
nvm it works
oh
i just didn't want to open the link
i get it
Can i create gradient ChatColor?
Hex Color?
go to spigot and check any topic about hex color codes
👍
how would i go about assigning e.g. a texture_id to a skull? I've used setNbt via NbtCompounds on fabric, how does that work with spigot?
via GameProfile
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta meta = (SkullMeta) head.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", value));
Field profileField = null;
try {
profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(meta, profile);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
head.setItemMeta(meta);
return head;
}```
tysm!
If you’re on a modern version there’s a profile api
nah, i can't use that, i get the texture_id from a web api
you can still use it
Everytime i reload the server, the configuration list i made is being cleared
why are u saving the configuration on a list
oh
are you actually trying to save Player objects in a list?
UUIDS
just UUIDs?
then so long as you save teh config you will be fine
always save if you make changes
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
TestConfig.load();
Main.getPlayers().add(p.getUniqueId().toString());
TestConfig.load();
TestConfig.get().set("players", Main.getPlayers());
TestConfig.save();
TestConfig.get().set(p.getName() + ".deaths", 0);
TestConfig.get().set(p.getName() + ".kills", 0);
TestConfig.save();
}```When a player joins i load the config, add him to the list and save it
public HashSet newHashSet() {
return new HashSet();
}
@Override
public void onEnable() {
plugin = this;
saveDefaultConfig();
getServer().getPluginManager().registerEvents(new onDie(), this);
getServer().getPluginManager().registerEvents(new onJoin(), this);
getCommand("takestats").setExecutor(new TakeStats());
TestConfig.setup();
players = new HashSet<>();
TestConfig.load();
TestConfig.save();
}
@Override
public void onDisable() {
TestConfig.load();
for(String z: players) {
newHashSet().add(players);
}
TestConfig.get().set("players", newHashSet());
TestConfig.save();
}```This is the main
you are wiping out the in memory config in yoru onDisable
why r u loading everytime the config
I can not save configuration if i wont put it to onDisable();
its somehow clearing
you also load it twice in the join event
Dont know maybe something would change
it just need to be loaded on the onEnable
after changing things, wouldnt i have to load it again?
is some text channel deleted?
spigotcraft
oh
no bc its already loaded
You are also wiping the config in onDisable TestConfig.get().set("players", newHashSet());
ah not new HashSet
sounds like a skill issue
public HashSet newHashSet() {
return new HashSet();
}```its this
actually yes, its a method, you get a new HashSet every time
you are literally getting a new empty Set every time you call that
Why wouldn't you just do new HashSet lmao
I am filling it
Yes, then you get a new one to save
you are getting a NEW Set every single call and adding a single player, then you get a NEW empty Set and save it
Honestly this is hillarious to look at it's so non sensecal
It is Java, but
You get a new piece of paper, write a single player UUID to it, then throw it away and do the same for the next.
I hate instantiating
💀
then you get a fresh blank pieve of paper and save it
public class ImBadAtCoding extends JavaPlugin {
private File configFile = new File(getDataFolder(), "bruh.yml");
private FileConfiguartion config;
public void onEnable() {
saveResource("bruh.yml", false);
// OR
if (!configFile.exists()) configFile.createNewFile();
config = YamlConfiguration.loadConfiguration(configFile);
}
public void saveMyConfig() {
try {
config.save(configFile);
} catch (IOException ignored) {}
}
public FileConfiguration getMyConfig() {
return config;
}
}```
Then might as well quit java lmao
Its not going like that
It adds the list
all the uuids
then in ur code of listener
imBadAtCodingInstance.getMyConfig().set("key", value);
imBadAtCodingInstance.saveConfig(); // SAVE CONFIG EVERYTIME YOU MODIFY IT
and for reloading with command
public class ImBadAtCoding extends JavaPlugin {
// all of the code from above
public void reloadConfig() {
config = YamlConfiguration.loadConfiguration(configFile);
}
}
like it fills the whole paper and clears it
Yes it is, thats exactly what you are doing
you are putting every player onto its own piece of paper and throwing it away
why not creating a new HashSet and adding players into it
Static instance 😢
instead of creating everytime a new hashset
I have tried it
Every time you use newHashSet() you are fetching a new blank piece of paper.
public void onDisable() {
TestConfig.load();
TestConfig.get().set("players", players);
TestConfig.save();
}```What is the difference of this
because i tried it like this way either
it's not a static instance
that's just the name of the variable
check if your method does not return clone or save clone of actual fileConfiguration
yoru?!!? from valorant?!?!
No, from old age
saving config in onDisable() is shit
onDisable() is mostly shit
only used it in plugins to send "Bye bye dumb server owner" message to console
XD
well tried this either nothing changed.
Why would it change
i have the same methods
No offense, but do you know what you are doing/writing? Even more so, do you understand how spigot handles the default configuration file?
valorant 💀
no didnt and will not
yoru??
plat 1 😭
i dont enjoy comp games anymore
wtf
if i set a entity invisible the name will keep displaying?
No? That's now how that's intended to work.
😠
sorry ❤️
#general
fucking nerdddddd
wdym
I am trying to get used to it
bro i have like 1300 hours
and i regret each and every one of them
What I mean is, the code you have given is full of logical errors. Then your response to people telling you what's wrong is backwards.
🫡
202 hours on reyna 😭
I have not seen anyone told me my mistake
on my main i had 600 hours on reyna alone
make some methods kinda hard to understand
pop off king
and to refactor
i got it permanently banned
because i talked too much shit
spent 400 aud on that account 😢
lollll
And ask us to show where you mistaken
F
I mean
I dont have another class
Just the things you texted
I put them in a class
assuming a handler for a yaml file ?
probably
.get() returns a FileConfiguration
clone of actual as i can see
Let me pass the pc
well then you overwrite
isntead of adding to
so they get wiped out
you need to get the collection from the config
to variable
modify it
and then put back on the same path
and .save()
and never keep anything except fileconfiguration instance in heap
?paste
I have problem with set
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
TestConfig.load();
Main.getPlayers().add(p.getUniqueId().toString());
TestConfig.get().set("players", Main.getPlayers());
TestConfig.save();
TestConfig.get().set(p.getName() + ".deaths", 0);
TestConfig.get().set(p.getName() + ".kills", 0);
TestConfig.save();
}```And this is the class i set the list
tf
what's this shit
XD
bruh
TestConfig.get().set("players", Main.getPlayers());
WHAT THE HECK ARE U STORING
any need for full caps lol
Dude, besides the static getters for everything, I again ask. Do you know what you are doing?
That code, albiet jank af, will work. It just depends on what you are storing and what you do to that collection before it gets written.

Sry just dropped my airpods case on caps
still sure you need
FREE JAVA LESSONS
or idk
free basic logic lesons
uuid
Because players are not plural right
does Bukkit.getVersion() return like 1.8.9 1.8 etc?
Thats why im using list
nope
it returns a lot of weird patterns
1_8_R3 I think?
public static String getServerVersion() {
return Bukkit.getServer().getClass().getPackage().getName().substring(23);
}
Yes why did you ask
oh yeah that
I ask because it doesn't seem like you actually do.
"1.14-R0.1-SNAPSHOT" for example
I am checking if a command argument matches
diab lo que piquete la chamaquita
que?
so
no hablo espanol
I dont have an experiment
where is the connection between command args match and all players stored in config
Of I/O
What?
oh yeah
I am trying to check if the command argument matches with a node index
node index?
I am trying to take that players kills and deaths
Explain in plain english what you are trying to do
how can i simulate a block break particle
No one here has any idea what you are trying to do limpeex
Mann
You are showing broken code but no one has a clue what you are actually tryign to achieve
player section contains uuids and i check them if the command argument matches thats all
what precisely are you trying to do?
so you want to use a player UUID as a command arg?
if (section.contains(args)) {
//
}
I dont use uuid as a command arg
then what are the UUID used for
I'll ask once more then I'm out. Tell us exactly what you are trying to achieve. Not what code you are using or anything like that. What is your END goal?
Bukkit.getOfflinePlayers().contains(string[0]);
you are trying to get an offline player by their name?
I am trying to see the kill and death counts of a player
then you should be using statistics