#help-development
1 messages ยท Page 392 of 1
What is a Consumer?
Basically a callback which takes exactly one argument and returns nothing
You could also broadcast right in the method countDown, I just didn't want to hard-code it in
This way, it's reusable
no varargs?
I put the jar file in my plugins folder but it doesnt appear and wont work in-game
I probably made a stupid error But I cant find it
theres an IntConsumer in the java package tho
Any errors? Your plugin.yml should be in the resources folder.
No errors. Where is the resources folder?
ohh there
Ill move it there
Otherwise, it won't be added to the final jar.
Ahh alright
what's the font you're using?
Still doesnt show when I type /pl
I always do the maven compile thingy, then package
and then put the jar in my plugins folder
Apple's system font, so SF Pro, I guess
Still no errors in the console? You could try unzipping that jar file you copied and check if the plugin.yml is actually in there
Or better yet, if you don't mind, you could share the jar. It's kinda hard telling you what's missing, as there could be a thousand different things wrong with it, xD.
Sure, Ill dm it to you
Alrighty, gonna check it out real quick
Try changing main: me.JustinS_2006.particles to main: me.JustinS_2006.particles.ScrapCollection. No idea how that didn't complain in the console.
hmm jsonObject.get("item").getAsString() should work no? json { "item": "minecraft:yellow_wool" }
Cannot invoke "com.google.gson.JsonElement.getAsString()" because the return value of "com.google.gson.JsonObject.get(String)" is null
Tried that. Didn't work. No error. I unzipped the jar file and it does show the plugin.yml
Do you need to see the code?
ty for the code @dry yacht, I have modified it
I also had a look into the jar, seems like there's nothing wrong with it besides that malformed plugin.yml main entry
instead of 120 seconds it will tell 2 minutes
I already did, as I have the jar. The plugin should be fine
Hmm alright
Yeah, you can just format the timestamp. But other than that, I think that this is the way to go.
way better than what I did tbh
I do have a different plugin in that server, that I made a while ago, and it works
I just tried loading that plugin and I get the error about the malformed main path. Are you sure you load the correct plugin? :-:
uhh
And way better than those people who just count down some integer in a task which is called every second, xD. Let the scheduler do the work, don't try to be your own scheduler. That's just my opinion about the whole thing.
Sounds stupid, I know, but if you changed the main path, there now should be nothing keeping your plugin from being loaded.
What happened to that file? D:
What file?
the plugin.yml you posted
Oh, xDD
lmao
Does someone know how a tabCompleter is registered?
set the overview on package iinstead of project
PluginCommand#setTabCompletor
what
why are you making a new set
Here's the difference between the current plugin.yml and the one used in the working plugin @dry yacht
you are referencing toString before adding
The chad way to do it is to extend org.bukkit.command.Command and register in the server's command map yourself.
Just kidding, your way is preferred for beginners, obviously.
idk i use acf
Okay, all hope is lost then.
and im already using too much reflections so i dont bother
ya no clue why they made that interface
simplicity
Shouldn't be because of your plugin.yml. I'm sure I could successfully load the plugin now, after you have changed that main path.
couldve done smth like <T extends CommandExecutor & TabCompletor> void smth (T t)
but ye
me making things more difficult then they are ๐ฅน
fine for us but a noob would never understand
thats what i love about the minestom discord, its not full of noobs
Its probably toxic to them then
One of the warnings say that ScrapCollection isn't used, which is the main class. Is that an issue?
Good morning guys
gm
If I am trying to change the velocity of a slime when it gets hit. As in the speed that the slime moves. Do I change the velocity of the SlimeEntity itself or do I need to play with a different thing from EntityDamageFromEventityEvent
As in, the slime is a ball
huh
easiest way is if it is knocked back in the damage event schedule a task to run the next tick to which will multiply its velocity
Well elgarl, Currently I'm using EntityDamageFromEventityEvent
what are you doign
To detect when it gets hit
you creating a queue everytime the player executes command??
runTask... entity.setVelocity(entity.getVelocity().multiply(2))
pseudo ^
HashSet queue = new HashSet<Player>();
Yeah that's what I'm doing then
But it's not working correctly
Unless my multiplier is too low
Set<UUID> queue = new HashSet<>();
on class level
ig some game instance polls players from the queue, its not a real 'queue' tho
yea
you should be using something like
Deque<Player> queue = new LinkedList();
and then queue.add(player) to add the player
queue.poll() to remove the first player from the queue
It at least tries to load for me, but there's something wrong with the command, xD. I noticed that you've compiled with java 19, so I first had to download that JDK.
Before that, the server would also complain about a higher compile version than it's own runtime. So I don't get how you're not seeing anything in your console. Maybe try setting up a new server, just to try the plugin, xD.
queue.pop() would remove the player last from the queue
rip
why can't it just work
yea, but sometimes you need to retrieve the object (in most cases you do need it)
well it removes it and retrieves it at the same time
The poll() method of Queue Interface returns and removes the element at the front end of the container
It is. It's not that the command won't load. When I type /pl it doesnt even show the plugin
Then its not in your plugins folder
It is...
I have another plugin in the same folder, and it loads
And I can't find the difference between the 2 plugins
There are only the following possibilities:
Its a jar file
-- Its red in /pl -> Error while enabling
-- Its green in /pl -> All fine
Its not a jar file or not in the folder
-- It wont show up in /pls
It's a jar file and it's in the folder and it doesnt show up
when I type /pl
so something's broken
Not possible
...
Look at your logs. There must be an error while you start the server.
If it doesnt show up at all in /pl then it doesnt have a plugin.yml at all.
Look at your logs. There must be an error while you start the server.
latest.log in server root
ohh alright
99.1% sure its something like "invalid plugin.yml"
That doesnt look good
Ah or that one
You have 2 options:
Compile with an older java version
Run your server with a newer java version
oh
alright
How do I compile with an older version?
Are you using maven?
ye
How do you compile
Provided to YouTube by DistroKid
wozzy ยท Beto Damian
wozzy
โ 2598772 Records DK
Released on: 2021-03-31
Auto-generated by YouTube.
Yeah that as well
After compile I press package
why post this here?
package already runs compile
My pom is really short so I'll post it here ```
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.JustinS</groupId>
<artifactId>ScrapCollection</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>```
oh
Ahh
Change it to 17
Ill just change it to 17 then
is there a way to limit/scale the amount of hearts shown in the healthbar, cus lets say i want 1000 health i dont want 500 hearts showing
it has a scale method
There is an option in either spigot.yml or bukkit.yml
You can also set it per player by calling the scale thingy method
getScale, setScale and setScaled
What type is your queue?
cool time to do math so i can scale it
setScale(20) just sets it to 10 hearts always
I meant what type the queue variable is
how would i make it so it has a max of 20 hearts always? setScale(10)?
How can I detect if a player is jumping or not on the ground
40 sets it to 20 hearts. But default is 20 which sets it to 10 hearts.
ahh okay
Not with an event
A hashset is not a queue
Like player.isJumping()
Also you are using raw types which is very bad
Should I then compile or package?
package only
package runs compile first
in the logs
run clear before pacakage then
k
Also go in File -> Project Structure and change your SDK for the project.
How can I detect if a player is not on the ground using something like player#onGround()
declaration: package: org.bukkit.entity, interface: Entity
Deprecated
Oh ok cool
Thanks
Alright
Also, I assume yaw is what controls the view vertically, right?
Yes
Use a linkedlist if you want dequeue functionality. Hashset isnt ordered and therefore cant be used for a queue
Seemed like a fun project
Or... just a queue. ArrayDequeue for example.
Its like a LinkedList just in good.
Good thing is, it now shows up in /pl and I can run the command. Bad thing is, command doesnt do anything, apart from type it out in the chat
plugin.yml
plugin.yml -> add command
2-0

Show us your main class
package me.JustinS_2006.particles;
import org.bukkit.plugin.java.JavaPlugin;
public final class ScrapCollection extends JavaPlugin{
@Override
public void onEnable(){
this.getCommand("sc add").setExecutor(new AddParticleCommand());
}
}
You are trying to getCommand("sc add"), arent you
Ahaha
I should've predicted it
He was
and uhh whats wrong with it
"sc"
?
So the way commands work
Is that when you set a executor you set the executor for the main command not the arguments
Then you use the executor to check which command is used
Your command is called sc in you plugin.yml
The usage section is completely optional and does nothing really.
hmm I see
So you want to register "sc" and then in your executor class check for the arguments
So I should make the command sc. Then in the command class, I check what argument is used, so in this case add, then do something there?
yes
Good practice to use switch for command arguments if yu want
Volleyball math
wdym
Either a bunch of ifs or a switch
Yeah usually the recommended but i dont know what they want. Linkedlist implements dequeue
So at minimum it would satisfy their requirement for the functionality portion lol
@Override
public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
if (!(cs instanceof Player sender)) return false;
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "Incorrect usage");
return true;
}
switch (args[0]) {
case "add" -> {
queue.add(sender);
sender.sendMessage("You were added to the Queue for the game!");
if(hasPlayer){
}
return true;
}
}
return true;
}
Sure. I just like hating on LinkedList because it performs worse in whatever it does. There is just one use case for a LinkedList.
That's a complete accurate way to do commands @undone yarrow
Ask questions if you dont understand something
Ah got it yeah that is true lol
Anyways time to drive home.
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @4fb57196
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[?:?]
Never gotten this before. I use Oracle 18 JDK fyi
I thought it was reflection too xd
๐
Did you understand it?
ye
something tells me you're trying to serialize something that's not really serializable
probably through gson
But dont you need to check if the second arg is also null? Otherwise a command like '/sc add something' would still work
You can have as many subcommands as you want
I have used this same method before on another project and it went smoothly. Here is the code that looks to create the problem:
But if you want more either another switch, another if, or check that the arguments length is exactly what you need
In each method or where it checks if it's 0
๐
Either check for 0 && check for exact amount
Or if your arguments can have different amount of subarguments
Check in each case
Accordingly
You're using nms?
is player.getTargetBlock(); deprecated?
I saw somewhere that it was deprecated but the docs dont say it is
If docs doesnt say, it isn't
Time to write your own minecraft now then
Hi! Where can I read about adapting my plugin for bungee?
You're making a plugin that lets you switch your children? Nice
Um, you are holding Players in a queue but you then try to cast it to UUID
xd
change ArrayList queue = new ArrayList<Player>(); to ArrayList queue = new ArrayList<UUID>();
I need a list or an array or anything that can store a multitude of Blocks. What would be the best way to go about doing this?
first work out what you actually want to store
Blocks
not blocks, but a Block block
hard to explain
Why do you need a List of Blocks?
because.... uhm
I ask because it's highly unlikely you actually need Blocks
I need to store locations of blocks that will act as a sort of location you can get an item from when you right click that block
How can I make a function that returns a number between x and y in which if the parameter is 45 it will return y and as the parameter descreses it will go closer to x
So you actually need a List of Locations not Blocks
blocks sounded easier to me than to store locations
but locations could work too
then Set<Location>
Now in words a normal human can understand please
Set myLocations = new HashSet<Location>();
What does the HashSet do
prevents storing duplicates
ohh thats cool
?paste
everytime i call this function it doesnt reset the stats but just adds more?
Current stats and base stats are hashmaps of a custom enum and a double
https://paste.md-5.net/izalohegud.java
what am i doing wrong
Not only that but you can call .remove() on sets and it returns a boolean so you don't have to .contains() .remove()
How can I make a function that returns a number between x and y in which if the parameter is 45 it will return y and as the parameter descreses it will go closer to x
Is the only way with a spam of ifs?
I cannot use Location on gson. What else should I use?
Yes you can but you have to write a TypeAdapter
I have a feeling my code won't work
this code operates on the original Map so it never resets
What does the Set mean
set is a superclass, those are made so you have to think less
do i need to use
currentstats = basestats.clone() instead?
no
cus i tried it and it didnt
cus the player always has atleast some of a certain stat
I'm assuming this is totalling mods applied by armour?
nah i have custom stats like base damage or smt that have a default value for all players
then keep a map of yoru base stats and a separate map of your effect totals
yea but how do i add them up to display them/use them
baseStat.get + modified.get
baseStats and currentStats
then in your update you just wipe yoru currentStat Map
yea alright
yep, before totalling
so currentStats.clear()
and then this stuff
yep
use merge
yep
what does that do, i mean how does it work/how do i use it
check the javadocs
currentStats.merge(statType, aDouble, Double::sum);
ya
alrighttt
wait no thats not it
cus if it doesnt exist id need to add the baseStat too
if it doesnt exist it inserts baseStat iirc
well i havent specified it anywhere so how would it
i think.. its this?
nah
oh wait i still need the if statement
smart
also need to add this
private <T, R> List<R> merge(List<T> firstCollection, List<T> secondCollection, BiFunction<T, T, R> transformer) {
List<R> list = new ArrayList<>();
int highestSize = Math.max(firstCollection.size(), secondCollection.size());
for(int index = 0; index < highestSize; index++) {
T firstElement = (index >= firstCollection.size()) ? null : firstCollection.get(index);
T secondElement = (index >= secondCollection.size()) ? null : secondCollection.get(index);
R transformed = transformer.apply(firstElement, secondElement);
list.add(transformed);
}
return list;
}
๐ค
Why do you need the index check if you are maxing the target index?
Either max the index or provide null for out of index access
Because it's not guaranteed that both lists are the same size
If firstCollection has 5 elements, and secondCollection only has 3
we just assume the last 2 elements are null
and transform regardless
This might not be intended behavior, some people might prefer truncating
Sure sure. I thougth you wanted to truncate
or just... throw an exception
๐คท
It's basic idiot proofing
Can you suggest some kind of server code that you can find online and rely on it to create your own minigame server architecture?
IF the license permits
?basics
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
You want a minigame library?
maybe
i just wnat to figure out how big servers are done
like mmc or something
can someone link me a existing page on how to handle data please? the link in ?cc list doesnt exist
cc list works in #bot-commands
well cc list works
but what i need is a tutorial on how to use databases
thats not from 2015
what kind of database?
hasn't really changed since 2015
ah
on a different topic: if i shove a minecraft object into a database as a BLOB, and then return it, is it possible that it cannot be cast to whatever type it is originally if versions changed?
Hello, I'm using markers with ProtocolLib 5.0.0 (Spigot 1.1.9.3) but I got a problem, when I try to put an ARGB color, it doesn't give me the good color. Here's the code and what it does in game. So I don't see what to use
yes it's possible
use it's serialization method if available
would that work with nbt from other plugins included?
it shoudl include all NBT
I do remember some issue with ItemStack enchantments though
vague memory
ItemStack does
so youre telling me to just put 54 serialized item stacks into the db instead of one inventory?
yes, if none are null
i mean null check and if yes return new empty item stack?
whys the non null bit important
saved that
so youre saying to do
UUID | 1 | 2 | 3 |
... | <NULL> | <Serialized Stack> | <SerializedStack>
if i.e. slot 0 doesnt have an item?
Is it able to tab-complete asynchronously in bungeecord
no nulls at all
depending how many inventories you are storing use a table for eac
so you have index, data
smth like TABLE_NAME = "inventory_17" ?
or if you are mashing all together then 1|data|3|data|5|data
hm
problem
the number of inventories may change over time
so do i just generative code that adds the corresponding table if its needed?
yes
i think i know what you mean
now i only need to understand the sql code lol
wait
itemStack serialize returns a mpa
*map
do i stuff that into the DB as BLOB?
yes
ok
or encode to base64
i dislike base64 encoding cuz it just feels inherently unsafe
i know it exists but i really dont know when to use it
the map thing should be more version-change resilient correct?
i mean if they change anything about the serialized class that fucks it if its B64
in that case use https://gist.github.com/graywolf336/8153678 just don;t do the base64 step
Yo, what is used by Marker ? Cause with ARGB (As I saw on wiki.vg here :https://wiki.vg/Plugin_channels#minecraft:debug.2Fgame_test_add_marker) it doesn't get me the good color
God, IdeaVim SUCKS! I hate this bug, and it has been there since ages already. Does anybody else use this plugin and also experiences it messing up and pasting in import statements when trying to repeat actions? Are there any solutions? @tender shard I think you use it too, any ideas?
anyone here good with java? wanna ask little question
no we all suck
Does anyone know if it is normal that the world spawnpoint chunk is always loaded?
Is there a way to disable it?
uh, ok ty.
good, ill ask
import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
int i = 1;
while(i<=10) {
System.out.println(num * i);
i++;
}
}
}
what wrong with this code?
run it
define "wrong"
can you type in the terminal?
its not stuck you need to enter

ive been trying to fix it for 30 mins now
Wp
lmao
thanks yall lol
input is like the only thing in this program
the worst thing is i wrote the whole code
This is why God invented afk warning messages ๐
"Erm hey buddy its been 10 mins, u gonna put the input in?" ๐คฃ
how do i set the damage AND velocity of an arrow?:
Searched everywhere the only thing I could find was in the API https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#setKeepSpawnInMemory(boolean) but I was interested in a config file
Put a PDC tag with your damage on the arrow, listen for the EntityDamageByEntityEvent and apply the custom damage of your arrow,
i whish we had this
potion drink event?
ItemConsumeEvent
You code it in my dude
its PlayerItemConsumeEvent
Does someone know why this marker appear with this color as I put this rgb(179, 77, 179) ? I can't understand why
wtf
you can make transparent blocks?
"Material.BARRIER"
iirc markers are limited on the colour spectrum
how to unload? yml file in java plugin
wtf even is this
yeah what block is that?
think it got clamped
Itโs marker
can you explain this more in detail
Yes i know, but I want to make it red or blue etc. I know itโs possible
ex) unload yaml "plugins/Skript/SKdatabase/%{name}%.yml" (skirpt-yaml addon)
I donโt really know how to explain sorry. But i would say itโs a thing that can be used for debug, like getting an position to another for exemple ?
oh it see
Never sent, but used to set different debug markers in the world. Does not render for vanilla clients below version 1.16.5.
Yup
I'm afraid that's not related to java development on your end but rather skript's. better check out official document.
Now it is xD
But I donโt get how tf I set the color. I saw it was rgb but it only giving me different type of green
this seems like a cool way
to visualize block selections
in vanilla
or make colored zones
Yes, Iโm doing a funny plugin. But without finding how the color work, itโs impossible to make it
I want to remove the file, but I can't remove the file because the server is using it, so I wonder if there is a way to solve this problem
what event is fired when eating a golden apple?
use linux
Is there any way to do it on Windows?
shut down the server?
PlayerItemConsumeEvent as well...
thanks
Can't I use the plugin?
what are we even talking about
sorry i'm not good at English
rename it
and then delete it
thanks
Yeah
yeah why not you are just wasting memory
ConcurrentModificationException incoming soon
^
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.
State machine. Create an Enum which defines the state of the game.
Could be
IDLE,
LOBBY,
SETUP,
ACTIVE
For example
still
Hm? Why do you need get
why dont you just store booleans in hashset or something?
Are you using the correct collextion for your use? @quaint mantle
???
why not
bc your set will always have 2 values and not more...
but he has only one value in his object
ArrayDeque or similar
so why not just storing it in hashset
i mean i dont get the point of creating object only to store one variable in it
You would obviously not store only one object in there.
But using a collection with floating values is just bad design.
I told you ArrayDeque or similar
im not he is
Itโs made for such stuff
^
Yes this is perfectly fine. Throwing something in a Map<UUID, Boolean> is not.
if i wanted to add speed 2 to a player would the amplifier be 1 or 2
1
kk ty
?tas For future reference ๐
๐
Who will make a light plugin for free?
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
public final void setOnScrollFinished(EventHandler<? super ScrollEvent> var1) {
this.onScrollFinishedProperty().set(var1);
}
The <? super ScrollEvent> just means that it is an instance of a class which is a child of ScrollEvent, right?
This looks like decompiled code...
why
Yes, it is. Am I right, though?
Yes
and where do you store that Game object? in hashset?
how do i get cause of InventoryCloseEvent? like if server made player to close it or player closed it himself
the server doesnt detect opening and closing of the player inventory, for containers and stuff you can keep a variable to see if its opened by a player or not
but there is no existing method to check for it
HashMap?
Guys, who will make the plugin for the design?
Ehh what's this? [16:46:17] [Server thread/ERROR]: Error occurred while enabling ScrapCollection v1.0 (Is it up to date?) java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.JustinS_2006.particles.ScrapCollection.getCommand(String)" is null at me.JustinS_2006.particles.ScrapCollection.onEnable(ScrapCollection.java:7) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[server.jar:3284a-Spigot-3892929-0ab8487] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[server.jar:3284a-Spigot-3892929-0ab8487] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[server.jar:3284a-Spigot-3892929-0ab8487] at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:520) ~[server.jar:3284a-Spigot-3892929-0ab8487] at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:434) ~[server.jar:3284a-Spigot-3892929-0ab8487] at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:619) ~[server.jar:3284a-Spigot-3892929-0ab8487] at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:266) ~[server.jar:3284a-Spigot-3892929-0ab8487] at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[server.jar:3284a-Spigot-3892929-0ab8487] at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[server.jar:3284a-Spigot-3892929-0ab8487] at java.lang.Thread.run(Thread.java:833) [?:?]
That's a you messed up error
rip
bro my internet is going haywire rn wtf
Anyways
why am I getting that error
Show the line that's throwing the error too
?paste
Literally says at me.JustinS_2006.particles.ScrapCollection.onEnable(ScrapCollection.java:7
That's the wrong class
why cant i put Extends EntityZombie in coding 1.19??????
Any idea on whats going wrong?
Check to make sure everything looks right in the compiled jar
Are you including NMS in your project?
Are you using the mappings?
i dont think so. Can you send link for 1.19.3?
?nms
how can I get the output of a command that I run using Bukkit.dispatchCommand()?
You might be able to use a dynamic proxy on the root method for closing an inventory for the spigot api.
Why would you want to do that?
I am adding a feature
cool
dispatchCommand return Boolean. so how can I get the output? :/
Implement CommandSender and dispatch the command with it.
Why am I getting this error? [16:46:17] [Server thread/ERROR]: Error occurred while enabling ScrapCollection v1.0 (Is it up to date?) java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.JustinS_2006.particles.ScrapCollection.getCommand(String)" is null at me.JustinS_2006.particles.ScrapCollection.onEnable(ScrapCollection.java:7) ~[?:?]` ...
I can't find anything strange in my code, nor in my plugin.yml file.
package me.JustinS_2006.particles;
import org.bukkit.plugin.java.JavaPlugin;
public final class ScrapCollection extends JavaPlugin{
@Override
public void onEnable(){
this.getCommand("sc").setExecutor(new AddParticleCommand());
}
}
name: ScrapCollection
main: me.JustinS_2006.particles.ScrapCollection
version: 1.0
api-version: 1.17
description: Adds scrap to blocks
commands:
sc:
description: Adds a particle effect to a block
usage: /sc```
Can anyone give me a good example on how to implement custom block models into minecraft with custom textures, without overriding vanilla blocks or losing any vanilla blocks? I am aware of the armorstand and mushroom block data methods, but I don't know how to implement it into my plugin.
Null pointers, do a try/catch
lol...
because the return value of "me.JustinS_2006.particles.ScrapCollection.getCommand(String)" is null
Yeah, but I don't understand why it's null
NPE is the one exception you should never catch
how do i edit the amount of given xp?
https://paste.md-5.net/gadavarigu.java
I've caught them, and handle them myself by allowing it to print to console where exactly in the code it's failing
Yeah. That makes exactly zero sense... The exception already tells you exactly where it was caused.
Not always
So uhh what should I do
Anyways this is not possible. Best you can do is use spawners, set the entity in the spawner and set its helmet to your custom model.
Then disable the spawning of the spawner.
This is quite expensive for client and server tho.
Why not just use a block that's not available in your world?
I've seen it done with specific blockstates of mushrooms that don't happen naturally, same with specific noteblock instrument/sound mixtures. Just don't know how to implement it
The goal is to keep everything available
Resourcepack predicates
what
how would i begin to make or find a non walkable a* path finder bukkit
Shouldntname: ScrapCollection main: me.JustinS_2006.particles.ScrapCollection version: 1.0 api-version: 1.17 description: Adds scrap to blocks commands: sc: description: Adds a particle effect to a block usage: /sc be name: ScrapCollection main: me.JustinS_2006.particles.ScrapCollection version: 1.0 api-version: 1.17 description: Adds scrap to blocks commands: sc: description: "Adds a particle effect to a block" usage: "/sc [arg1]"
Why not <effect>
what?
Nothing
Does anyone know why armorstands spawned via packets aren't affected by gravity? I didn't change any of its properties, I just called the ctor, passed it to the spawn packet and sent it to the player
The server doesnt know they exist so they dont get ticked and are as a result not affected by anything, including gravity
Do you know how I can handle their movement manually?
Send movement packets for them
So when entities fall, a velocity packet is being sent behind the scenes by the server?
because performance wise that doesnt sound logical
how can i set skull texture from minecraft heads website
Create a PlayerProfile, get the PlayerTextures from it, change the texture, set the PlayerProfile on the Skull.
Skull is a TileState so you need to get the BlockState of your Block and cast it to Skull.
(Dont forget to call update() on the Skull after setting the texture)
i need it on ItemStack
^
The server sends thousands of packets per second for just entities
no
physics are calculated by the server
the only physics that are not calculated by the server are player movement
iirc
Alright, but how do I actually handle "physics calculation" manually for an entity?
there's a move method
Client-side behavior is a bit weird
certain entities have default speeds and all
for example, an Item entity "flies" upwards when spawned, as the client predicts it's a block breaking / entity dying
you can prevent that by sending a secondary speed packet setting all axis as 0,0,0
Now, packet-based entities with movement seem counter-intuitive
you probably just want a real entity hidden with Player#hideEntity (paper) or just send an Entity remove packet
same as other versions
i have not developed plugins in a year and
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version></version>
<scope>provided</scope>
</dependency>
1.19 doesnt seem to exist
not in the spigot-api or spigot artifacts
do you have the repo
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
oops
is it that one
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
yeah seems like it's accurate
use 1.19-R0.1-SNAPSHOT as the version and reload maven
yep
im guessing ij only lists versions on your computer
yeah it does
use 1.19-R0.1-SNAPSHOT anyway and see what happened
the ones that are in .m2
oh shit its because i misspelled snapshot
xD
:D
For my case I simply want to make the armorstand have the levitation effect, do you think this can be done without registering them to bukkit as real entities
I tried sending an effect packet, but yeah, no luck
except with intellij you can use the Minecraft Development plugin
it does everything for you ๐
whats thtat
you can just send movement packets
this one? if so i prob should get it
with a specific offset
yeah
damn crazy
it does everything for you, it'll create a maven project with spigot repo and dep + plugin.yml + main class
tyvm i didnt know that existed
anytime ๐
or is it asking for my project details
project details
yeah this is just your project
alright
yeah
the version doesnt matter except for the file it creates xD
you can configure all of it later anyway
in pom.xml & plugin.yml
this plugin is just a shorthand for creating all of it
it makes it so you only need to change pom
oh i see
yeah it's just a convenient shortcut for you
i see
so you don't have to memorize all the required files, repo, dependency, etc
Is java ever pass by reference?
Like if I have a method to set specific slots in a inventory, and I pass it the inventory
Do I need to make the method return the inventory and save it back? Can I make the method void and it will keep the changes in the original method
it passes reference
you should look into mutable / immutable
setDefaultButtons(inventory);
#saveDefaultButtons
inventory#setItem();
java is pass by value
Player player = ...;
Player player2 = ...;
Player object = player;
setPlayerName(object, "player1");
object = player2;
setPlayerName(object, "player2");
assert !player.getName().equals(player2.getName());
assert object == player2;
assert player2 != player1;
references and primitives are both passed by value
Why do I have 2 different answers
I swore I did read that java is pass by value
But illusion said reference
it is
Objects have references that are passed
primitives aren't really objects so the value itself is passed
Every time you define a variable, you're just creating a new "pointer" to that reference
So then . would work
yea
good luck using . on primitives
?
My code isn't made for primitives tho
It's for an Inventory
I mean usually there arent very many options
?paste
I got a command working that adds specified block locations to a list, but now I want to add a particle effect above all the blocks in that list. How would I do that
What class should I put that in, I mean
Use a scheduler to schedule the particles
And how would I get my locations from my other class, and reference it in my main class? private final Set scrapLocations = new HashSet<Location>();
I want to reference scrapLocations in my main class
do you need them all at teh same time?
surel;y you just need an add, remove and contains check
This is my code: https://paste.md-5.net/taciselovo.js
The problem is everytime i execute my command with a subcommand i get the answer of all below
example:
/astralgkits create
Output inserver:
Create Subcommand
Edit Subcommand
Delete Subcommand
Info Subcommand
idk why if i have the break statement
No? I want to take all the scrapLocations, and add looping particles above them
I want to do the spawnParticles in my main class as well
don;t do it in your main
why
Single responsibility principle
So where should I do it then?
each class shoudl have its own purpose
do it in a sub class of where you have your scrapLocations
The same class where I add block locations using a command?
Seems like an odd place to put it, but if that's what people usually do I guess it's fine
no
....
that class should just be a command handler
That class is also where I have my scrapLocations
each class handles one job
you should create a class just to handle your locations
That class checks for the sc add command, then puts the block loc in the list
with a public method for add/remove and contains
If I do that Ill end up having 5000 classes for a simple plugin
in that class you could handle a runnable to do your particles
My original question hasnt been answered though
it has, your scrp locations should not be accecssed from your main
@tender shard
Hey, you said you don't do config files anymore, no database or yml and just store all the data into pdcs
most stuff could be stored on pdc, a config file is still needed
for quite a lot of things
Alright so I have a particlehandler class, but somehow I need to run the class when the add command is run
Does anybody know whether org.jetbrains.annotations have any effect at runtime? I'm trying to check for the presence of Nullable at runtime, so I know whether or not to set a default value on an item stack I'm automatically mapping using my config mapper. I cannot access the annotation class at runtime tho, because they're not on the classpath. Would shading them into root scope (as I do not want to relocate, for obvious reasons) hurt anything I'm unaware of?
Hey, is anyone available to give a look at my serializable class please
Nevermind, they aren't runtime retained. :(
Hi everyone, trying to get a player head texture but it's just coming through as a regular steve. Any ideas?
ItemStack headStack = itemStack.clone();
SkullMeta meta = (SkullMeta) headStack.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", headURL));
try {
Field profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(meta, profile);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
headStack.setItemMeta(meta);
return headStack;
1.19.3
Because UUID is not easily serialzable into a PDC
Yeah it has a completely different method for UUID
or... that 1 line
Also it's inside of an object so it's not that big of a deal
Cause I'm storing the entire object
very memory inefficient
Could you debug-log the headURL and show me it's value? Please just paste it into the chat.
and haram
switch (subcommand){
case "create": sender.sendMessage("Create subcommand"); break;
case "edit": sender.sendMessage("Edit subcommand"); break;
case "delete": sender.sendMessage("Delete subcommand"); break;
case "info": sender.sendMessage("info subcommand"); break;
}
im getting every sendMessage in case.
Create will execute all below
Edit all below and stuff
Help :(
Yep give me 2 mins
you could use a ByteBuffer to store it as a byte array inside the object
Yeah you're right I could
I mean that's what we were saying
What's so wrong about storing as a string
That's why we need 32 gigs nowadays
exactly
can someone help me?
Most developers are ignorant of the underlying machine and want to just live in abstraction land all day.
36 * 2 = 72 bytes per UUID per object per container
idk if its 46 chars (it wasnt)
forgot
Uhm... yeah, sure, you got my point! xD
which you could store in just 20 with byte array (i assume minecraft stores the length in nbt so + 4 bytes for an int)
How do I loop through this public Set scrapLocations = new HashSet<Location>();?
I want to add particles at all those locations
I tried that
but it gives weird errors
1 sec
It just underlines it in red
Incompatible types. Found: 'org.bukkit.Location', required: 'java.lang.Object'
Locations arent objects right?
Somehow that fixes it. What's the difference?
But now Im not defining what Hashset is right
java doesnt know whats in your set
But HashSet<> <--- the bracket-thingies are empty?
the compiler implicitly derives that
from the declaration
ohh I see
so since your Set has type Location the compiler can derive that the HashSet<> should be a HashSet<Location>
well it knows the type of the field, with actual type parameters but it doesnt know the objects generic type
the actual type args are part of the field signature
JVM?
Hello, I have a problem with getting something from my config. because it makes a map list null when it gets put into the config.YML. That causes this line to make crate null. How would i fix this?
Map<?, ?> crate = (Map<?, ?>) item.get(crateNumber);
ah alright
?paste
Generics of member fields aren't erased
Anyways, onto my next question.
Now that I have this, how can I run this method, let's say every second. I heard about a getScheduler but Im not sure how it works java public void spawnParticles(Particle particle){ for (Location location : scrapLocations) { location.getWorld().spawnParticle(Particle.SCRAPE, location, 7, 0.2, 0.4, 0.5); }
What do you mean by recognize? It doesn't typecheck when operating on those members, no, but the information is still there. Unlike on generics in other parts of the code.
How am I matching on them at runtime then?
That's what I meant
!isEmpty ๐ฅน
Isn't type erasure happening at compile time tho? So if they persist, isn't it wrong to say "they are wiped"?
Would anyone know this?
all fun n games til we get https://openjdk.org/projects/valhalla/
Is there an alternative for schedulers? This shit is weird and messes up my code
Via this chat or dms?
?paste
How would i fix it to not display null, because i cant get it to work when its there.
https://paste.md-5.net/rimugawuti.java ParticleHandler
https://paste.md-5.net/ivezogayit.java Main
private final java.util.Map<java.lang.Integer, me.blvckbytes.headcatalog.gui.UISlot> slots;
descriptor: Ljava/util/Map;
flags: (0x0012) ACC_PRIVATE, ACC_FINAL
Signature: #26 // Ljava/util/Map<Ljava/lang/Integer;Lme/blvckbytes/headcatalog/gui/UISlot;>;
Okay, I must really be misunderstanding something then.
I removed them from the posted code because they didn't work and are probably completely wrong
Well other question then, how would i obtain material?
All I removed from ParticleHandler wasjava private static Plugin plugin = null; private int delayID = 1; and ```java
public void spawnParticles(Particle particle, Plug in instance){
plugin = instance;
for (Location location : scrapLocations) {
location.getWorld().spawnParticle(Particle.SCRAPE, location, 7, 0.2, 0.4, 0.5);
}
Bukkit.getScheduler().runTaskLater(this, this::spawnParticles(Particle.SCRAPE), 20L);
}
so it was PEBKAC
hoping it would work
ezpz
Idk where else to ask but how do i reset where my resultset loops from?
Cause i use ResultSet.next() but the next time it starts off where it stopped
what
i have a database with uuid's of players,
to get the right player i have a resultset with a while loop then check if it the uuid is equal to the selected player, i do this with:
while (resultSet.next())
lets say the last time the first loop result was the correct one, the next time i loop it skips the first entry
FIXED:
i just make a new connection everytime i need the data and then close the connection
What about java public void spawnParticlesEverySecond(Particle particle, Plugin plugin) { BukkitRunnable runnable = new BukkitRunnable() { public void run() { for (Location location : scrapLocations) { location.getWorld().spawnParticle(particle, location, 7, 0.2, 0.4, 0.5); } } }; runnable.runTaskTimer(plugin, 0L, 20L); // run every second (20 ticks) }
Then calling it in main as ParticleHandler particleHandler = new ParticleHandler(); particleHandler.spawnParticlesEverySecond(Particle.SCRAPE, plugin);
bytecodeviewer?
Alrighty, I'm just gonna be real, I'm confused beyond repair, xD.
my event isnt working and not giving any errors.
https://paste.md-5.net/sitigevuba.cs
I have this list of locations, but when I try to print it, it just says '[]'. Does this mean there's nothing in the list, or am I printing it wrong? ```java
public Set<Location> scrapLocations = new HashSet<>();
public void ListLocations(CommandSender sender){
sender.sendMessage(scrapLocations.toString());
}
Hi, im using a library called XParticle (https://github.com/CryptoMorin/XSeries/blob/master/src/main/java/com/cryptomorin/xseries/particles/XParticle.java) to load images
XParticle.displayRenderedImage(plugin, XParticle.renderImage(plugin.getDataFolder().toPath().resolve("test.png"), 20, 20, 20), () -> player.getLocation(), 1, period,20,20,2);
But gives a problem on the XParticle#renderImage return CompletableFuture<Map<double[], Color>>, but XParticle#displayRenderedImage wants Map<double[], Color>, cast it to it doesn't work any work around?
original class was
import java.util.ArrayList;
public class Generics {
public static void main(String[] args) {
var theList = new ArrayList<String>();
theList.add("This is a string");
if (!theList.isEmpty()) {
theList.forEach(System.out::println);
}
System.out.println("lolwat");
}
}```
I really need some help here i would i get "Material" and "Antal"?
var ew
I was talking about fields and method return types, while this is a scoped variable. Maybe the whole reason why I don't get why the JVM doesn't know about these is that I confuse the JVM with what reflection builds upon. I just know that, for parameters - for example - the types are erased, while for member fields and return types they aren't. So they end up in the bytecode. Is reflection directly querying bytecode? Isn't the JVM loading this bytecode into memory and one could thus argue that it does know about them? Again, I'm just massively confused right now, xD
Anyone have a good tool to write item lores
Like formatting, colors, etc, website or something
Cause sometimes lores are big and needs to look good
So no JVM instruction knows of these types, and they are just metadata in the loaded class in memory, which reflect accesses?
How doesn't it? It's in the classpool
that's bytecode
constantpool*
Or is bytecode just defined as actual instructions?
So reflect queries the constant pool while JVM only executes that bytecode ASM, which doesn't reference types within the classpool, but only like Object or whatever
Searching for a Developer for my server must be very good with scipts and be experienced.
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Okay, I think that's exactly what I wanted to get at, because I consider the whole class file bytecode. So it's in there, the JVM just doesn't execute anything related to that information. Reflect then goes into the parsed class in memory and looks up this meta information. Alright, that cleared things up.
I thought you meant they are erased, which is why I thought I am going crazy.
When I run Block block = player.getTargetBlock(null, 7); Location blockLoc = block.getLocation();
I get the location of the player, not the block
The targeted block isn't 37, 66, 14
those are my players coordinates
targetted block is on the right
what?
Even then, it doesnt do what it should
the targetted block coords are on the right of f3
Sorry for spamming, but im about to destroy my screen
Shows, once again, that the targetedblock method doesnt do what it should
yes?
whats the coords then
you sent a ss of your coords
try this instead https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/LivingEntity.html#getTargetBlockExact(int)
declaration: package: org.bukkit.entity, interface: LivingEntity
That fixes it. Time to fix my other 3 methods that arent working
Is it possible to use the Spigot API outside of Minecraft? I want to access the web API on a website to list all available plugins I have uploaded
Generics can be erased (and are erased if you use tools such as proguard correctly) by stripping the signature attribute of the class or class member.
Descriptors (not to be confused with generic signatures - which are optional) are mandatory and cannot be removed.
Local variables (including argument/parameter names) as stored in the LVT (local variable table) can be erased. The LVT may be incomplete.
That being said stackmap is mandatory on Java 7+, which stores the types of the elements in the local variable slots and of the operand stack. It does not store the generic signature of types though
Why does this send nothing? java public void ListLocations(CommandSender sender){ for (Location location : scrapLocations) { sender.sendMessage(location.getX() + ", " + location.getY() + ", " + location.getZ() + ") \n"); } }
Even AI can't spot the mistake
scrapLocations is empty
List<Map<?, ?>> items = configYML.getMapList("casino.crates");
for (Map<?, ?> item : items) {
Integer crateNumber = (Integer) item.keySet().toArray()[0];
Map<?, ?> crate = (Map<?, ?>) item.get(crateNumber);
String blockblock = (String) crate.get("block");
Bukkit.broadcastMessage(blockblock);
}
Why does crate give null? i am so confused
No
It wasn't empty, but it still returned nothing
Thanks for explaining that in detail! Now that I know that the generics aren't even "mandatory" on class members, could it be that we're just lucky that mojang didn't instruct their obfuscator to strip those off, since I often times rely on their existence when using reflect? That literally shattered my view of things, :-:
The more you know! :)
Notch used to back in the old days
Hence my Sl-deobf has limited use in the legacy minecraft modding scene (albeit only as a fork as it was originally meant to aid in galimulator modding)
Ugh why can't this stupid code just work?!?!?!
This is simply supposed to add a location to the list if it doesnt exist. But everytime I type /sc add (which is the command that runs this), it keeps saying "location added to the list".
public Set<Location> scrapLocations = new HashSet<>();
public void AddLoc(Location loc, CommandSender sender){
if(scrapLocations.contains(loc))
{
sender.sendMessage("That block has already been added to the locations.");
return;
}
scrapLocations.add(loc);
sender.sendMessage("Added (" + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ") to the list.");
}```
But I can guarantee, if mojang still stripped generic signatures, the minecraft modding scene would look fairly different
Yep, that's exactly what I thought. Not only that it would massively increase the difficulty of reverse engineering (well, there are mappings nowadays) but it would also break a lot of reflection. I mean... if a class contains two collections, and I can't rely on field order (which I can't), how would I ever get access to the right one, without distinguishing them based on their generics. That would really force people to compile against every single version there is, in cases like these, I think.
the X, Y and Z coords are always the same?
Yes
