declaration: module: java.base, package: java.util, class: Random
#help-development
1 messages · Page 84 of 1
I mean it does save code but it would also give away that you aren't very experienced with java 💀
Random implements RandomGenerator
I see 😂 But that's what SecureRandom is made for aswell
Probably yea
it's not probable, it's pretty much a fact
why is it like that and now "Sand" / "Stone"!?
I mean it doesn't hurt to use it. + you don't have to create an instance of random. So go for it
Hello! Is there any way to get the source location (or entity if possible) of ClientboundSoundEntityPacket (PacketPlayOutSoundEntity)? I don't want to use protocollib
hmm would implementing this syntax with acf work, i dont want to check string manually but rather use a subcommand
altho it assumes here that the syntax is /vanish <target>
and passing in "on" in the subcommand annotation would let it think the syntax is /vanish on <player>
without knowing anything about acf I just wanna mention that I love annotations
ill hope acf will create an impl based on my syntax annotation
no i want the real name
except that annotations are disencouraged in most cases
rather annotations than alot of if else statements
I was only talking about the ThreadLocalRandom vs Random topic
You can do a lot of very abstract stuff with annotations. There's a reason that there's soo many different annotations in the Spring Framework
why is that?
It's great if you value readability over a little performance. Especially when it only runs at startup
in most cases, annotations change things at runtime. maaking some aspects and details of the code really unclear
spring is quite complex but once you understand their way of DI, some annotations and the Model, Repository, Controller structure it's a very nice framework
thats one of the reasons people hate on lombok
though, lombok functionality is extremely straight forward
lombok has nice stuff
so my personal opinion is that lombok is fine
but in acf tbh
stuff doesnt really explain what they do
and there are a shit ton of annotations it gets confusing
someone who doesnt know acf
will give up reading ur code
?jd-s refers to that to find the right method. Search in Material
me spending weeks with no one being able to solve my problem because practically no one knows how:
I only use simple lombok annotations. Getter, Setter and AllArgsConstructor aswell as NoArgsConstructor
Item#getItemStack#getType
name()
Or something like that
blc 🤡
yeah and?
why # and not .
javadocs formattings
looks cooler
and has a feature!
doesnt trigger any anti IP/domain discord filters
smart
yes i made java
:: is cooler
🤡
ok better but its not the name so like "Grass Block" instead of "GRASS_BLOCK"
smh gotta edit my command syntax cuz acf doesnt want to work with me
i was trying to fixx that with dropping the item and getting the name
in 1.18.2 its working
Now work on some reformatting magic. Have fun, or use the locale
but not 1.8 for some reson
Cause 1.8 is satan
1.8 more like kekw
developing on 1.8 is harder because of the poor nature
im coding a gamemode
you have to do dumb workarounds
for a server
getLocalizedName()
Although this will change depending on the server language!!!
theres no item class either
ItemStack#getItemMeta()#getLocalizedName()
Adelemphi i thought it was already the case 👀
k
@azure hawk what do you want to do
Na for some reason I had assumed 1.8 was 11 years old
nah
yes do that
then get meta
1.8?
yes still
Yes :)
1.8 moment
wait i have a code for it
ok
You'll earn some time trying to convince your client switching to last versions 🐌
End of 1.8 topic
String itemName;
ItemMeta meta = item.getItemMeta();
if (meta.hasDisplayName()) {
itemName = meta.getDisplayName();
} else {
String[] split = item.getType().toString().split("_");
StringBuilder builder = new StringBuilder();
for (String part : split) {
builder.append(String.valueOf(part.charAt(0)).toUpperCase()).append(part.substring(1).toLowerCase());
}
itemName = builder.toString();
}
its only for the pvp based section
shit
thats a long boi
- it uses java 8, that means the NPEs are soooo unhelpful
Can I mute a firework explosion? Or is it completly clientside?
Never saw a muted firework, so I'd say clientside
public static String toTitleCase(final String words) {
return Stream.of(words.trim().split("\\s"))
.filter(word -> word.length() > 0)
.map(word -> word.substring(0, 1).toUpperCase() + word.substring(1).toLowerCase())
.collect(Collectors.joining(" "));
}```
GRASS_BLOCK -> Grass Block
What I've been using for a while now at least
can i make player run command as OP or i need to give player OP and then remove it?
i need a safe way
let console sender run it or smth like that
the command needs player to execute it
the player executes it
You can't safely
and you make whatever he executed run by console
actually ill just move command logic to util class
is there any other way
What I sent ^^
did i do it correctly?
like it does some error
the stacktrance is not understandble
Send the stacktrace
java.sql.SQLException: Operand should contain 1 column(s)
thats the only thing is nessacary from stacktrace
the rest is the event that uses it
so
GROUP_CONCAT isnt a column
how to retrive the string that it creates?
You try to fetch a players from a request right ?
fetch == ???
PLAYERNAME is an column in the database
its a binanry UUID
its fine it works
hey so I have a string with the name of a type of mode (for ex. ZOMBIE)
and I need to turn that string into an EntityType value
how do I do that
I'd remove the GROUP_CONCAT, and concatenate java side
CreatureSpawner spawner = (CreatureSpawner) e.getBlockPlaced().getState();
try{
spawner.setSpawnedType( (EntityType) e.getItemInHand().getItemMeta().getLore().get(0));
}catch (Exception err){}
spawner.update();
Im dumb
help me
Entity.StringValueOf(TheEntity)...
So Select PLAYERNAME and loop through results
use stringvalue method
im dumb.
i did it in looping in the past
I forgot valueof existed
but i used flatfile
looping would be way too many requests to database isnt soluation
Oh yeah
in the past i did a stringbuilder and looped thru it
how do i retrive the the group_concat
your welcome ❤️
Try naming it (add "AS coolname")
does .setOp inform the console?
And I never used GROUP_CONCAT so I won't help you with that
No
false..
why?
because its not an event like /op
you cloud make a listener for it
ty
i m making a security plugin and i wanted to avoid malwares from oping without the owner knowing
oo thats smort
or make OP ussless make only users that are in list able to use commands
- i use discord channel as a logging thing, so i can send an embed which would confirm if that player should be opied
true webhooks are great thing
??? what it meant to be even
bruh
Whats Item
Entity representing dropped item
How to return GROUP_CONCAT from sql command.?>
How can i add multi version support to my plugin?
which versions you wanna support?
is there a way to store some data in a placed block? (ex. the name of the person who placed it)
if blocks have a pdc, in the pdc
The native version of the plugin is 1.12.2 and i want to support 1.13 and the upper versions to
can't remember whether they have
Switch to native of last version, older version will be supported
then code against the highest version you wanna support and give downward compatibility
what if he uses new functions that don't exist in older version tho
I want to add modeldata and thigs like this for the newer versions
Hello! One question, is this the correct way to query "If there is a player's head in a player's helmet slot"?
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (p.getInventory().getHelmet() == p.getInventory().getHelmet().getType() == Material.PLAYER_HEAD) {
}```
that if makes no sense
helmet might be null ig
should be != null ?
too many ways
what version are you running it in?
if(p.getInventory().getHelmet() != null && p.getInventory().getHelmet().getType() == Material.PLAYER_HEAD) {}
are you serious?
What's the problem?
spoon feed me too now
okay what problem are you facing rn
Very Thanks!
PreparedStatement ps = conn.prepareStatement("SELECT " +
"GROUP_CONCAT(DISTINCT PLAYERNAME SEPARATOR ',') AS NBOL" +
"FROM blocks WHERE (X,Y,Z) BETWEEN (?,?,?) AND (?,?,?)")) {
what the syntax error here
for god sake
oh mysql?
bah been forever since I used it the last time
missing space before FROM
1.19
use presist data
it GET wiped on restarts as wel
important to mention
otherwise maybe stick to MySQL/MongoDB
can i give bukkit scheduler ID and stop it later using that?
or flatfiles
yeah...
oh i can make it an int
like not real real ID yeah
well it run on ticks
so you can check if time == time for example and cancel it
time == config...
just think out of box honestly i'm in love with schedulers lol
you can either make something pretty simple
make a hashmap contaning key (scheudlers) and boolean
and everytime before executing what the runnable should
check if boolean is true or false
@onyx fjord you get my logic???
Key == ID , boolean
all good man
so its good?
i made it a static variable that i later cancelled
or i didnt understand you correctly?
i think the hashmap is pretty good way to handle it
would be really easy
ye it was even easier than you said
;D
making it static...
whats the problem?
you shouldnt be storing taskid but rather the bukkittask itself
?scheduling
yes i use top one
wondering why they havent deprecated them tho
my code has no warnings 🥵
wondering when the damn acf is going to make docs on its gh page
current docs kinda suck
smart lad
how good are you with sql?
good enough
could you rephrase that
PreparedStatement ps = conn.prepareStatement("SELECT " +
"GROUP_CONCAT(DISTINCT PLAYERNAME SEPARATOR ',') AS NBOL" +
"FROM blocks WHERE (X,Y,Z) BETWEEN (?,?,?) AND (?,?,?)")) {
what is my syntax problem here?
someone already mentioned
missing space before FROM
^^
so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which ill send later,
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.
the jvm args are here: https://pastebin.com/3mK9yZFf
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
still unsolved
also add an ; after your statement
still not fixed?
i tried restarting my pc
didnt notice the space gonna test it quickly
removeItem() removes entire ItemStack, I wanna remove only one item in the stack
i switched to my other gpu and restarted my pc a few times
nothing happened
hmm itemstack api kinda sucks
gonna change amount yourself I guess
i swear there was some method
what if its 1 and i remove 1
it gets removed?
or some weird shit happens
weird shit i believe
idk honestly
but i said it as
try it out and if weird shit happens check it in code and just remove the item
check docs
sql impl speciffic docs
how do i retun an group_concat
thanks for the answer man the docs didnt help me in general
edit: i was tripping
to understand how to retrive it
i need spoon feed here.
imma read docs one again later
and do a small research
but i dont think docs gonna help me with syntax problems
fucking mysql looks like python
whast this shit DISTINCT PLAYERNAME SEPARATOR ','
well i know distinct
wondering if that separator is valid there
check docs
to understand what it means
same as your answer
its from the docs
basically
it sperates the coloumns
so it will be A,B,C
like that
you might wanto to remove the space you have between separator and ' '
i need to keep ',' since this is the char
that will appear between PLAYERNAME columons output
FourteenBrush ill be back later im gonnna hit the gym
WE ARE GOING TO THE GYM!!@O#$J!)$)*U$@$&)
❤️
i hope too
not gonna be stuck with it for more then 10 hours
not sure
SELECT SOME_OPERATION AS columnName
columnName is a dummy to represent the output
anyway bro not sure why it doesnt works
ill be back later
i fucking hate mysqll
but > yaml as storage
lmao
and still some how more powerful then flatfiles
WE GO TO THE GYMMMMMMMMMMMMMMMM
hi
hello guys, I have a problem, the event InventoryClickEvent isn't called when player place item in an inventory and move mouse really faster after, do someone know why ?
@tardy delta also it gets worse after letting the gaame run for a few minutes
it becomes pretty much like your video
hows your gpu usage?
if i make a plugin with /enchant will it override the vanilla command or do i have to do something like PlayerCommandPreprocessEvent
it will unless you type /minecraft:enchant
why is this cut of tf
The join message could have a hardcoded max length, maybe?
Instead set the joinmessage to "null" and send a message by hand
ok
Remove the underline in the space
But that's a phrase in Czech :D
actually no
but back in the day there was 0 slot size
what the heck its still sending the join message BUT ITS NULL/""
InventoryDragEvent
instead of doing event.setJoinMessage("") do event.setJoinMessage(null)
^^
yeah null is not an empty string
i tried before
but it didnt work too
declaration: package: org.bukkit.event.player, class: PlayerJoinEvent
null will remove it
did you recompile the plugin and either restart or reload the server?
Put your event priority as Monitor or Highest
Another plugin overrides it
How can i make right click event work if player has two item instead of one, for example now if i have 1 of gunpowder in hand and right click with it i wear it, but if i have two of gunpowder nothing happends
What's your current code?
its okay
public void MaskEvent(PlayerInteractEvent event) {
Player p = event.getPlayer();
if (event.getHand() == EquipmentSlot.HAND) {
ItemStack itemInHand = p.getItemInHand();
if (event.getPlayer().getInventory().getItemInMainHand().equals(Utils.getMask())) {
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (p.getInventory().getHelmet() != null) {
p.sendMessage(ConfigUtils.PREFIX.getFormattedString() + ConfigUtils.ALREADY_WEARING.getFormattedString());
} else {
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
p.getInventory().setHelmet(Utils.getMask());
p.getInventory().removeItem(Utils.getMask());
p.sendMessage(ConfigUtils.PREFIX.getFormattedString() + ConfigUtils.WORE.getFormattedString());
p.playSound(p.getLocation(), Sound.ITEM_ARMOR_EQUIP_LEATHER, 1.0F, 1.0F);
TabAPI.getInstance().getTeamManager().hideNametag(TabAPI.getInstance().getPlayer(p.getName()));
}
}
}
}
}
}```
maybe using #isSimilar instead of #equals does the job
if (event.getPlayer().getInventory()``` also just use the player variable here you declared earlier on
Thanks, it works!
do you think im dumb?
I'd also recommend using guard clauses.
They are something like this: if (event.getHand() != EquipmentSlot.HAND) return;.
So instead of checking if something is true, you check if it's false and then just skipp the rest of the code.
Makes it easier to read, as all of those brackets at the end disappear
also called a guard condition
why would I?
it's something you could have forgotten
That's nice to hear :D
I'm trying to make it so that it generates the dungeon within a square with specified dimensions. Pretty much like this as I said above https://battleda.sh/dungeons/
BattleDash
i can spawn fake but collectable dropped items only thru packets right?
aka when you collect it dissapears
Yeah but it would be a little pain
smh people should learn naming conventions
another example
que?
You'll have to send the spawn packet, check when the player is close enough and send the collect packet
Definitely not french bro, at least not like this
que is french
yep
can i replace itemstack in PlayerFishEvent?
my 6 years of being forced to learn french can confirm
Yeah but "que?" Not it doesn't mean anything
I'm sorry for learning that
all meta?
why not just replace it with new meta?
It was clearly meant to be a joke
quoi is what
Quoi 😂
Caught is an entity
Ça manque de français ici
i msut somehow get itemstack
non
ahh entity *@%&!
I hate all those apostrophes
bruh it was so simple
Work of art
i just had to cast
is it a item entity?
to Item entity
i almost fell for bad advice trap
someone said "remove item and spawn new one with the same velocity"
💀
always read entire posts
Does anyone here have experience with XPath expressions?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Okay, is this a valid XPath expression?
//div[@id='content-container-single-col']/*/section[@id='combo-display']/*//li/a
I'm not sure how I can share the webpage though
don't work.
?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.
☝️
InventoryDragEvent isn't called when we do what I showed on the gif
how can i make an entity follow a player with path finders remapped?
wdym bruh!!
dont work is a perfectly valid sentence
!!
An armor stand following the player?
yes
What you show on the gif is not a dragevent
public PremiumDataManager(BetterSpawners plugin) {
configFile = new File(plugin.getDataFolder(), "premiumdata.json");
initializeConfig();
}
/**
* Should only be used by this class to grab/create the config
*/
private void initializeConfig() {
try {
if (!configFile.exists()) {
FileWriter fileWriter = new FileWriter(configFile);
gson.toJson(new PremiumData(), fileWriter);
fileWriter.close();
}
config = gson.fromJson(new FileReader(configFile), PremiumData.class);
} catch (IOException e) {
e.printStackTrace();
}
}
[11:27:02] [Server thread/WARN]: java.io.IOException: The system cannot find the path specified
[11:27:02] [Server thread/WARN]: at java.base/java.io.WinNTFileSystem.createFileExclusively(Native Method)
[11:27:02] [Server thread/WARN]: at java.base/java.io.File.createNewFile(File.java:1043)
[11:27:02] [Server thread/WARN]: at me.silentprogram.betterspawnerspremium.config.PremiumDataManager.initializeConfig(PremiumDataManager.java:32)
[11:27:02] [Server thread/WARN]: at me.silentprogram.betterspawnerspremium.config.PremiumDataManager.<init>(PremiumDataManager.java:23)
[11:27:02] [Server thread/WARN]: at me.silentprogram.betterspawnerspremium.BetterSpawners.onEnable(BetterSpawners.java:19)
[11:27:02] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264)
[11:27:02] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342)
[11:27:02] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:479)
[11:27:02] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:523)
[11:27:02] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:437)
[11:27:02] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:582)
[11:27:02] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:401)
[11:27:02] [Server thread/WARN]: at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:255)
[11:27:02] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:966)
[11:27:02] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:291)
[11:27:02] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:833)
Idk whats wrong
But i have another class that is exactly like it for a different purpose
this is what I said bro
And it works
Same exact code
heres the other class that works
public DataManager(StartupClass plugin) {
configFile = new File(plugin.getPlugin().getDataFolder(), "data.json");
initializeConfig();
}
/**
* Should only be used by this class to grab/create the config
*/
private void initializeConfig() {
try {
if (!configFile.exists()) {
FileWriter fileWriter = new FileWriter(configFile);
gson.toJson(new Data(), fileWriter);
fileWriter.close();
}
config = gson.fromJson(new FileReader(configFile), Data.class);
} catch (IOException e) {
e.printStackTrace();
}
}
but i wanna use it in other classed duh
idk, on one you have "plugin.getDataFolder()" and on the other you have "plugin.getPlugin().getDataFolder()" if that has something to do with that
So pass main class instance?
You can see that plugin is different in both classes
The plugin.getPlugin returns the regular main class
Its due to me switching project structure halfway through making the plugin
Im gonna go through and fix some of it later
do you dont see the error
i have a brain lag rn
Does your plugin folder exists before you create that json
D:
Have fun being rude
this is not going to be 0 btw
I would assume so, let me check the order that i create these
Because java can't create file if folder doesn't exist
You should check that
Dependency Injection is a thing
I feel really stupid
I put the datamanager instantiation above my main startup method
i did
Wich creates the default config wich creates the data folder
please don't tell me you named your class extending JavaPlugin "main"
lowercased too
i did
and!?
Happy you fixed it 🤗
Class names should always be Capitalised methods should always be likeThis with the first word lowercase and proceeding words capitalised, and theres a lot mroe you will get yelled at for
ik
but i like it
so i leave it that way
oh god
xd
?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.
lmao
that has nothing to do with ?learnjava
It has
i can decide how i name my files
and you guys can cry about it
naming conventions are everything
Not just naming convention
readability
You show 0 knowledge in your code
Hello
Anyway to get the strength of an enchantment? Like if i wanted to get the value of the items sharpness?
uhhhhh
leme find it
ItemStack#getEnchantmentLevel
@boreal python
Tysm
np
I would recomend looking in the documentation before asking, cause its a great skill to not depend on others and it took me like a minute to find it
To find the documentation i litterally just look up spigot docs on google
Yeah. Im at school rn and the doc is blocked
HUGE L
lmao
Why would school block docs
Some random ass java compiler was blocked too
And you are brave enough to go to phub while at school lmao?
I mean if they want you to have every method on top of your head idk
sure I'm gonna find my hot math teacher from back then
lol
ok umm i have problem
String json = gson.toJson(((Player) sender).getInventory().getItemInMainHand().serialize());
this works fine when the item is normal item with nothing else
but when i add enchants or lore or anything to it it breaks,
https://paste.md-5.net/bureroquni.bash
its cause its hosted on the spigot site
i just died
And the spigot site is labeled as "gaming"
literally i just died
I bet because of the main thing
oh yeah, I cringed when I read that.
I name my main classes like "<PluginName>Plugin"
That way it isn't confusing to server owners when they have to try and figure out what the issue is
maybe its not saving the NBT data correctly?
Are you saving it as a material or smthng
I name my main class main_Class
what i do after this line is sending the json to player
thats it
Is dis a prublem?
that's good
cause I like it that way
"Naming conventions are suggestions right?"
- People when they wonder why nobody will help them because their code is unreadable.
my new pfp is awesome
naming conventions are like the easiest thing you can do right and some people still don't get it or don't wanna
didnt ask
i asked in fact
I used to be like that, back when I thought I knew everything better than everyone else even though I basically just started lol
didnt ask for you to say "didnt ask"
ok
even though i refused to learn java at first
it was just because i was learning from a very boring website
Haha yeah I think as a dev we have to be humble enough when someone comes up with a better solution or just wants to help
My snobby and narcissistic behavior when I was young is the main driver for why I try to be as helpful as I can nowadays. It's something I look at and deeply regret.
well, at least ur making the best out of your "mistakes"
Or trying to at least
Some people just don't learn though. I've had to deal with a few people like that over the years.
Some people just be like that, "I dOnT nEeD yOuR hElP"
After asking for help, lol
yea
I remember back in the day when I was googling my issue and creating a thread in the spigot forums
back in the day
Well I'm still googling :d
Those were the days
Same here, 4 years deep
But since there's a discord you'll probably get an answer here way faster
I didn't start with java though, I learned how to write GML which is proprietary language originating in a tool called GameMaker
I branched out to java and C# after
Worst thing an aspiring developer can do is to stay developing for Minecraft
Biggest shock when a lot of the stuff I've learned from Spigot can't be widely applied
I bet
it turns out developing plugins for an existing and entrenched api doesn't really apply to other things lol
Springs pretty fun
Sometimes I use PascalCase for my function names in java if I've been writing C# recently
By accident of course
Could be worse
Yep
THIS_WOULD_BE_WORSE()
Ah yes, the C++ macro
Error?
and what's in your super class?
Never really delved into NMS
But make sure everything you're importing is from the craftbukkit library
That always got me
Send the packet to the player to display it
Fairly sure it works like that
Because you have to spawn it yourself. ((CraftWorld) loc.getWorld()).addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
Hi, i'm trying to make a bungeecord version of the grimAC using bungee channels and grimAPI. the channels worked until i tryied to send a message to all of the staffers when there is a PluginMessageEvent. Now, when i try to connect with my client using hack, whenever there is a flag event, i get kicked for "EOFException : null @ java.io.DataInputStream:321". Down here i leave the main file, the PluginMessageListener and the FlagEvent.
public static ItemStack itemStackArrayFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];
items[0] = (ItemStack) dataInput.readObject();
dataInput.close();
return items[0];
} catch (ClassNotFoundException ex) {
throw new IOException(ex);
}
}
any idea why this throws https://paste.md-5.net/ekedinaruh.sql error?
the data is equal to rO0ABXNyABpvcmcuYnVra2l0LnV0aWwuaW8uV3JhcHBlcvJQR+zxEm8FAgABTAADbWFwdAAPTGph dmEvdXRpbC9NYXA7eHBzcgA1Y29tLmdvb2dsZS5jb21tb24uY29sbGVjdC5JbW11dGFibGVNYXAk U2VyaWFsaXplZEZvcm0AAAAAAAAAAAIAAkwABGtleXN0ABJMamF2YS9sYW5nL09iamVjdDtMAAZ2 YWx1ZXNxAH4ABHhwdXIAE1tMamF2YS5sYW5nLk9iamVjdDuQzlifEHMpbAIAAHhwAAAABHQAAj09 dAABdnQABHR5cGV0AARtZXRhdXEAfgAGAAAABHQAHm9yZy5idWtraXQuaW52ZW50b3J5Lkl0ZW1T dGFja3NyABFqYXZhLmxhbmcuSW50ZWdlchLioKT3gYc4AgABSQAFdmFsdWV4cgAQamF2YS5sYW5n Lk51bWJlcoaslR0LlOCLAgAAeHAAAAwwdAALRklTSElOR19ST0RzcQB+AABzcQB+AAN1cQB+AAYA AAAEcQB+AAh0AAltZXRhLXR5cGV0AAhlbmNoYW50c3QABkRhbWFnZXVxAH4ABgAAAAR0AAhJdGVt TWV0YXQAClVOU1BFQ0lGSUNzcgA3Y29tLmdvb2dsZS5jb21tb24uY29sbGVjdC5JbW11dGFibGVC aU1hcCRTZXJpYWxpemVkRm9ybQAAAAAAAAAAAgAAeHEAfgADdXEAfgAGAAAAAXQABExVUkV1cQB+ AAYAAAABc3EAfgAOAAAAA3NxAH4ADgAAAAI=
i don’t think you initialize the array like hat
you just do (ItemStack[]) input.readObject()
readObject returns a single ItemStack I believe
let me try with my Base64 decoder and see if it works
well depends on how it’s serialized
i always just serialize an itemstack array, and then read it as an itemstack array
Is your Base64 corrupted? Mine just says StreamCorruptedException. You might just try re-generating the base 64
?paste the entire PetGoal
Paste the error also
Why are you using distance() and then squaring the radius?
Then how do you know its null
The only way it can be null is if the Player you're passing is null
Did your compiler say this or the server?
Put it back, try again, and send the code with that there. ?paste it all into one thing
okay
google def trolled me
so Gson wasnt working for me right?
and just after i remove gson, i got logged out of youtube and gmail
I SWEAR its like first time in 2 years
and now i readded gson and it works
how do i set enchantment level of item
do you guys know any utility that can deserialize ItemStack from json?
i see a method for ItemStack#getEnchantmentLevel but not for setting it
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/meta/ItemMeta.html#addEnchant(org.bukkit.enchantments.Enchantment,int,boolean)
or
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/ItemStack.html#addEnchantment(org.bukkit.enchantments.Enchantment,int)
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
declaration: package: org.bukkit.inventory, class: ItemStack
Spigot
which method
actually ill show code first
maybe something is wrong
Gson gson = new Gson();
Map<String, Object> map = gson.fromJson(
config.getString("items." + item + ".item"),
new TypeToken<Map<String, Object>>() {
}.getType());
fishedItemStack = ItemStack.deserialize(map);
i get the item but with no enchants, lore, name
just plain material
the config string is equal to
item: '{"v":3120,"type":"FISHING_ROD","meta":{"enchantments":{"Enchantment[minecraft:lure, LURE]":3},"attributeModifiers":{},"repairCost":0,"hideFlag":0,"unbreakable":false,"damage":7,"placeableKeys":[],"destroyableKeys":[],"unhandledTags":{},"persistentDataContainer":{"customDataTags":{},"registry":{"CREATE_ADAPTER":{},"adapters":{}},"adapterContext":{"registry":{"CREATE_ADAPTER":{},"adapters":{}}}},"version":3120}}'
alr thanks got the way
This breaks for skulls because spigot serialisation is bad
private static final Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
public static String toJson(ItemStack itemStack) {
return gson.toJson(itemStack.serialize());
}
public static ItemStack fromJson(String json) {
return ItemStack.deserialize(gson.fromJson(json, new TypeToken<Map<String, Object>>(){}.getType()));
}
BukkitObjectOutputStream is more reliable
anyone has an idea of a library i can make?
Will this also work with enchants and shit?
Can't test cuz on mobile rn
Sure. This will work with everything but skulls
Any reason why my previous one breaks lol
I don't think that should happen
Bug in spigot deserialization?
You know that you can just throw an ItemStack in a config file, right?
No json needed
Could you drop me an example how it looks in yanl?
Yaml
What I do is make items from hand, but configuration that can be done manually might also be handy
ItemStack itemStack = ...;
FileConfiguration configuration = ...;
configuration.set("some.path", itemStack);
And getting it
FileConfiguration configuration = ...;
ItemStack itemStack = configuration.getItemStack("some.path");
Looks like this I'm pretty sure
It only works for spigots yml configuration api because it uses the ConfigurationSerializable interface.
What if I load boostedyaml config and edit it in spigot api
It's still just yaml file
I'll test tomorrow and see, thanks
How are you getting scID
?scheduling
Your merhod is deprecated
Use runTaskTimerAsynchronously and call BukkitTask#cancel on what that returns.
welp
# represent instance method, and not static one
?scheduling there even are many examples
also BukkitTask is interface, it cant have static method
ok
can somebody help me?
and how do i cancel it?
Pretty sure DessieYT and Rolyn already told you
Bro I'm sorry but did you even go to the page ?
I think you just found a way to avoid cheaters on ypur server :o
yes
Why is that a problem not being able to join with a hax?
Ohhh
and the anti cheat sometimes has false-flags
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.
its a BukkitTask
not a Runnable
and doing Runnable. will only list static methods
still same
the task is a parameter from the lambda function passed to BukkitScheduler#runTask
of type BukkitTask
dude, those are interfaces, please learn java
bro
nerd actually used "`"s bruh
nerd actually edited his message 3 times to get quotes around the `
:(
i knew u were gonna say that
BUT
i have a good reply made for that
nerd actually counted how many edits i did
This beginner Java tutorial describes fundamentals of programming in the Java programming language
It was an observation made unconsiously which came back to the surface when I started thinking of a comeback to your message.
bru htheres not even an example here
shit
Sex not gender
where are the other 900 genders!!!
wheres dreamsexual????/?/////???
they have a variable
named gender
of type sex
Sex gender;
There's 3rd
exposed
so fucking gross uhhh imagine homohpboic
Cuz I helpedbu
What's wrong with being gay?
I'm gay
we need to make a twitlonger with stupid trigger warnings and out of context screenshots and cancel them
pretty sure itemsadder cant convert models into entity data or whatever
OK
I'm here researching
in the wrong channels asking devs
🔎
go to the plugin page and read the desc
Cuz models r like developer stuff
Read already
Btw ur status have rong grammer
It's you're not your lol
It's fucked you're mom
stop
anyways model engine only lists entities as feature
while itemsadder lists a whole variety
but no model generation shit
so i think its pretty clear
Ok so itemsadder can do everything model engine can
no
What means 😕
model engine can convert models made in applications to a list of entities like armor stands to make custom models in vanilla minecraft
and it packages the required textures in a resource pack automatically
thats the selling point of model engine
what
20 x 500
Um
5k?
bro
10k
So 100k + 10k
is an integer object that holds a number "90000" the same size in ram as an object that holds a number "2,000,000,000"?
10k that's how much items adder made
yeah
damnnnnnn
So how do I make custom guis with itemsadder again
Player player = (Player) sender;
char[] alpha = "abcdopefnm".toCharArray();
Random r = new Random();
String random = "";
for (int i = 0; i < 9; i++) {
random += alpha[r.nextInt(alpha.length)];
}
player.setDisplayName(random);
Doesn't change the player's nickname, what did I do wrong?
Don't they have an API?
Where do you mean ? In tab? Nametag? Chat ?
Hey guys, how do i access the GameProfile? because it cant found and or import that class. If it helps i use maven
In case you meant that:
You have to import spigot insteand of spigot-api
so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which ill send later,
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.
the jvm args are here: https://pastebin.com/3mK9yZFf
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
though i doubt i can fix this
without people like frostalf and mfnalex online
and when i use paper-api i just import only paper?
This is not the place, (but actually yes)
It does that even on another computers ?
Time to install Spark
Spark time
I bet there are some problem with your java ver or a program just hates your mc and tries to kill it
whats that
But ^
no.
i closed all my apps
and any app that isnt related to java or mc
and my java ver works for any version 1.17 or lower
lol
what even is spark time
Closed or killed ? 😈
task ended
anyone knows
where is registerEnchantment
called?
in which class
because I can't figure it out
Are you trying to register your own enchantments?
from where does registerEnchantment get's called?
@eternal night (sorry for ping but i saw you were online and you often know stuff about internals) you know anything about this? i have seen it before but the whole stacktrace is just nms, not plugin
I use nms but not for that at all
It's because a backend assert fails
Is there a specific reason (or jira issue) why the library loader doesn't have the option to specify repositories but only pulls from central?
yeah, i thought i saw it before with negative itemstack amounts but he doesn’t seem to be doing that
Because otherwise it would be trivially easy to make malware
The repo is just a fileserver
You could easily alter the jar that's sent over
how will I check if it works
Maven central is a trusted repo
cancel it and intract with it?
Generally it's safe to assume code you get from it isn't malware
At the very least, it's moderated
Arbitrary repos could be owned by an attacker
What is being interacted with
but what’s the difference between just using an infected plugin vs a safe plugin downloading an infected library
Detection
hmm, yeah i suppose
sorry but I dont really get you
If my plugin is on the server I can already download whatever I want, not a real argument in my opinion
If you had your own repo you could make it return a legit jar at first
How does this event get called in the first place?
you wouldn’t think that JDA would be malware
And that would immediately be flagged by optic
by clicking the item
what item
Or other resource staff
how do they get the item
pfffft, what other resource staff
Sure, but it's between having that feature and making my own library loader. It's just annoying that it isn't supported out of the box
So the reason you can't specify another repo is the same reason they would take down your resource if it's downloading and executing arbitrary code
is it a specific slimeball, or just one that you get from the creative inventory for example
like is there pdc to it
paste builditem please
whole class
Is it possible that the material isn't parsed properly and that's throwing the assert trap
What do you mean by that? Wouldn't that just be a library loader? 🤔
mmm, they wouldn’t be getting a valid slime item tho
Most libraries I want to use aren't plugins
¯_(ツ)_/¯
no; like:
$ spig install RedLib
Yeah
And ideally it would be able to resolve non-plugin deps too
Probably still maven central only though
use new ItemStack(material, amount)
you ignore the amount
ahhh happy days
also, with these builder patterns, the itemstack is normally created on the parse() call, not just returned
frick me
did it work?
alr thx i will try
I've seen that error before when setting the item used in the event to null without cancelling the event
nope
Like I said
Cancel the event
for all items?
Sure
Are you modifying what's in he players hand at any point?
Cause that error usually stems from that
em no
well I set the item when i player join
thats it
to slot 8 (9)
Point being, if the event isn't canceled and you mess with something before the event ends, chances are you made a valid event invalid and that's what caused the error
Ohhhh right I remove the item when he clicks it
tyvr < 3
hi, i wanna know which is the best way create a custom recipe that involves a certain amount of items per slot.
there are some smart ppl online now
so reposting
so um, I had this bug with minecraft where any versions 1.18 and above would freeze every 1 second, meaning the graph would be some thing like this:
300 -> 1 - 250 -> 1..etc
so well i used some jvm args i got recommended which ill send later,
and that fixed it, however after 3 days the bug is back, but i realized something, when the bug was fixed i had 2gb allocated and it was using 2.7gb, but when the bug still existed it was using 2gb flat, so i thought maybe that was the problem, i just tried allocating 3gb or 4gb and no luck.
the jvm args are here: https://pastebin.com/3mK9yZFf
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
You will want to use the PrepareItemCraftEvent, and check if the item in the recipe is your custom recipe, and from there check if the ItemStacks in the crafting inventory slots are of the right amount
declaration: package: org.bukkit.event.inventory, class: PrepareItemCraftEvent
yeah, i tried with that but the problem is that the recipe is not register and for some reason when i pick the result the recipe items dupplicate
Can you show your code for your custom recipe and for the event?
yes, where can i share it?
Either send it here and format it as code by highlighting over it and selecting the "<>" icon, or:
?paste
did you find something?
So just to be sure, you want the first, third, fifth, and seventh slots in the crafting table to be 32x emerald block?
Small question, I've made a shop plugin and now the issue is that if I buy an unstackable like pickaxe they are stacked.. now was thinking would this be a bug or a feature? Idk the downsides of them being stacked
Lmao
Downside is if it’s used while in a stacjk, all the items take durability at the same time
yes
Sad and makes sense thanks! I'll fix that one
i have this problem: https://www.spigotmc.org/threads/prepareitemcraftevent-duplication-bug.260206/
but i don't understand how to solve it

