#help-development
1 messages · Page 2258 of 1
allows you to get access to stuff that mojang doesn't let you
anyone?
Not just Mojang but many internal things
there's already a lot of resources about it and utillities that can do the hard lifting for you
This is for Spigot/Java development
So could you help me?
Nah I literally can’t read the code samples
I have to like swipe the screen 20 times
Oh sad
It’s impossible to read
Yes i can undertand
Its really ugly reading from cellhpone
Dont worry man
Thanks tho
?pdc
I should learn all the bot commands
Sounds good, doesn't work.
It doesn't allow me to modify minecraft's default nbts
I
O
U gotta use nms
But it breaks per version
The easiest way is probably WorldEdit
U recommend usin' an api or the plugin and just sending commands ?
Okey thx my guy
you could listen for the Entity Event packet and cancel it
the conversion event has a byte value of 16
OR
@lost wolf you could make the entity silent
How can I silence the Entity just long enough to silence the sound?
you should be good enough to do soemthing like
setSilent
setConversionTime
setSilent```
if that's too much for you, you could try doing the packet thing
you may need to delay the second setSilent by a tick or so, unsure
Alright, I'll give it a try, thanks 👍
any way to get intellij not stuck on analyzing
Alright im confused why I cant import WorldServer, its just not showing as an option. This code was working previously in 1.17
public void addBeeToHive(CustomHive customHive) {
CustomBee customBee = new CustomBee(customHive.getHiveLocation(), ChatColor.YELLOW + "" + ChatColor.BOLD + "Bee");
customHive.addBeeName(customBee.Z().getString());
WorldServer craftWorld = ((CraftWorld)customHive.getHiveLocation().getWorld()).getHandle();
craftWorld.b((Entity)customBee);
Bee bee = (Bee)customBee.getBukkitEntity();
bee.setHive(customHive.getHiveLocation());
customHive.getBeeUUIDs().add(customBee.cm());
customHive.setCurrentBees(customHive.getCurrentBees() + 1);
}
any idea?
are you using maven?
yes
what does the dependency look like?
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
hmmmm...
it would be nice if i didnt have to use nms at all for this
but i dont think its possible.
what is it youre trying to do?
setting a bee's "home" hive
hmm... sounds like an interesting PR idea
pr?
pull request for spigot
oh
here's a nice tool if you're using NMS https://nms.screamingsandals.org/1.19/
a beehive
ok
well
#setHive is a location
/**
* Set the bee's hive location.
*
* @param location or null
*/
void setHive(@smoky tinsel Location location);
so the location of the hive
right... so what's different about what you need to do ?
I forget why I was even using mojang mappings when i originally made this
maybe i can do without, who knows
all i know is
mojang mappings are better
I dont have a clue what bee.c is.
because using the obfuscated mappings can cause a lot of problems
alrighty then switching back
woah
wait... do you even know what mojang mappings are?
spigot mappings are the obfuscated mappings. e.i. EntityBee, WorldServer, etc
that's the nice thing about that site
not rlly
mojang mappings are not obfuscated; Bee, Level, etc
havent used them much all ik is theres a weird disclaimer about using mojang mappings..
the mojang mappings you need to be careful becasue you need to add a build step in your pom
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-mojang
</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>
${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-obf
</remappedDependencies>
</configuration>
</execution>
</executions>
this?
yes
also just noticed that also needs to be updated to 1.19
ya
we call it "nms" because the package name
public CustomBee(Location location, String beeName) {
super(EntityTypes.g, (World) ((CraftWorld) location.getWorld()).getHandle());
this.e(location.getX(), location.getY() + 1.0, location.getZ());
this.a((IChatBaseComponent) new ChatComponentText(ChatColor.translateAlternateColorCodes('&', beeName)));
this.n(true);
this.c(20.0f);
this.b_(-32768);
}
is there a an easy way to de-aids this
net.minecraft.server
probably with the website
i actually found out about this the same time as you
previously i used MiniMapper or whatever, but it broke
this site is a bit confusing to me
im working on a project where i need 100% full control of the entities, so i also am opting for nms
otherwise i woould need a ton of hashmaps/wrappers
id rather just stick with some painful updating here and there
id also like to do custom pathfinding at some point.
make sure you're on the right version from when that nms was used too
PathfinderGoals are tricky but fun
also, be careful when using reflection
any strings/names need to be spigot mappings
so like getDeclaredField("")
idk how to use reflection, also something ive avoided like the plague
Lol I use Unsafe to set fields XD
yea definitely avoid at all costs
oh just change 1.18.2 to 1.19
should be fine
the specialsource plugin is mostly unrelated to minecraft
you just need to adjust its parameters
alright cool
the main thing now is
what is EntityTypes.g lol (assuming bee)
like i said its been a bit since i wrote this
Do we still gotta use the getHandle stuff?
that's fine
so here, the EntityType serves as what model the entity is
what dimensions it has
etc
the world, well, serves as the world it's in
and remember you need to use level#addFreshEntity for nms entities
this.e is the spawn location buttttt
and entity#moveTo
ahh
this.moveTo(location.getX(), location.getY() + 1.0, location.getZ());
so that should be fine then
well
gotta spawn it first though
cause im currently doing CustomBee customBee = new CustomBee(customHive.getHiveLocation(), ChatColor.YELLOW + "" + ChatColor.BOLD + "Bee");
actually you should use level.addFreshEntity at the end of modifying it
yes, so you have that
Keep the absMoveTo?
MyEntity entity = new MyEntity(...);
entity.absMoveTo(loc.getX(), loc.getY(), loc.getZ());
level.addFreshEntity(entity);```
like that
yes, that is a requirement of extending classes
ok gotcha, move it in the main class not the object class
typically, you should opt to spawn the entity outside the constructor in a controller class/method
yes
gotcha
sweet, next is setting its name
Which is an IChatBaseComponent but its not resolving IChatBaseComponent to anything
right so here's something you should know
@glossy scroll can we dm
make a thread
bee movie
For Player#hidePlayer(), does the hiding persist when the hidden player disconnects? For instance if I hide player a from player b, then player a relogs or the server restarts, will player b then be able to see player a?
It does not persist
How do I call a method of an indirect superclass
for example I have a custom Horse that is trying to call Animal's aiStep method
without calling AbstractHorse's method
nah that doesnt work
static reference
((Animal) this).aiStep(); I've tried this but it led to infinite recursion
Doesnt work
try this
Try using reflection
Copy the code kekw
Thats disappointing that java doesnt allow that
Every other language does
Java is so last decade 😒
i hate java
i love rust
i might learn it some day
Ill teach you
pythons my main language tho
Bro's main language is the slowest mainstream language to exist
it gets the job done idc
Python is just for learning
Whenever i see people learning how to program I recommend them Java
and im proud
gross
Doing 1,000 loops in Python is devastating
"The best way to iterate in Python, is to not iterate in Python"
I don't prefer Python but if you like using it then go for it
Doesn't change my life any
🤷♂️
also
whats going on
with my stack trace
i got the most stupid error
hold up
what have i done
moveTailMethod = AbstractHorse.class.getDeclaredMethod("fy");
moveTailMethod.setAccessible(true);
eatingCounterField = AbstractHorse.class.getDeclaredField("cw");
eatingCounterField.setAccessible(true);
animalAiStepMethod = Animal.class.getDeclaredMethod("w_");
What is SuperiorHorseEntity line 139
thats my custom horse
Send that entire method and send which line is 139
its in here
animalAiStepMethod.invoke(this);
There must have been some exception in that method
The animalAiStepMethod
You set it accessible right?
i'm trying to basically do a super call to Animal but completely skip AbstractHorse's method
Just a minor thing, !this.level.isClientSide is always going to be true. Minecraft shares a lot of code server & client side, but you're obviously only writing on the server, so this value is never going to be true
alright
well i just copy pasted the code in AbstractHorse
i just need to delete one part of it
Yeah I'd figured lol
Hi im bck after some hours of reading i cannot figure how to save a pojo object into mongo db
Could someone help me?
bump
also can mobs pathfind if its nearby chunks arent loaded?
Can I use reflection to access other plug-ins, if so how?
I wanna change the prefix forcefully
Cause there's no config
What plugin? If it's not configurable dev probably has shit code no reason to not just redo it
Mine, but the configuration got bugged and I can't modify it
So why wouldn't you just fix the bug
I don't have the code anymore
Decompile
Copy paste
I can think of a billion better ways to solve this than reflection
I mean I could, but I really want to invoke methods on external jars for some reason
Also get and use github so this doesn't happen in the future
is it possible to keep chunks loaded around a mob and not just a player?
I know how invoke methods on a class, but not on an external jar
If you wanna learn reflection find a decent use for it or make a test project to fuck with that isn't spigot
One more thing, if I'm loading a jar inside an addons folder using reflection how could I let that jar run spigot stuff I'd that's possible
Maven with provided dependency
If you aren't using maven or gradle you might as well cut both of your arms off and call it a day
You want to use a jar as a dependency?
No like, I want to load a jar from my plug-in, then have that jar execute code on the server
Like an add-ons system?
Yeah
Reflection iirc you can grab jar files
I'm not spoonfeedjng you use your brain and the great wide web
I did that, but I can't find anyway to allow the method to grab stuff BACK on the server
Huh?
Grab the stuff back on the server,?
If you set it up correctly should be easy as hell to do whatever the fick you want given yoh know how to use interfaces
Okay so let's say the plug in invokes a method on an external jar, then I want that method to access the server and run code on it as a plug in that's not there
You can't run code on something that doesn't exist
Ik
Just like you can't jump off a tower that doesn't exist or ride a train that doesn't exist
Can I like have the method access the main plug in and run code from the method on there
Huh I guess you could in a round about way. But as I said earlier don't use reflection to fix your shitty code
Just fix it
You should learn reflection when you actually need it not to abuse your horrible design
Yeah that's diff. Um I'm making a new plug in that runs addons
Your asking the same thing in a round about way as for me to help you
Addons are easy reflection
Little research can yield yoh a proper result
I did research. I didn't find anything
I found that, I've done that. But I need to have the class that accesses and have that access the main plug in and inject code to run
So basically just basic reflection to fix your shitty code instead of fixing the project gotcha one second I'll speedrun finding you how to reflection tutorials
https://www.geeksforgeeks.org/reflection-in-java/
https://www.oracle.com/technical-resources/articles/java/javareflection.html
Java Reflection Tutorial and Example with java.lang.reflect package classes and interfaces such as Field, Constructor, how to get objet of Class class with example, Method and Class class with lot of reflection examples in java.
No not that
Bump
I'm making a mini game api in a way, and I want addons to add mini games but I don't know how to inject code into a plug in that's on another jar and run it
Who deletes my stack overflow post I'm sure there's. A decent reason dm please
?
Someone deletes my link to stack overflow curious why is all
Aigbt I'll just post it again I guess
Okay
Nobody is deleting your links
Maybe this will make more sense
Either it contained the word "black" followed by "spigot" or "get" followed by "bukkit"
Get
Look at the JarFile class
Is in the link
Is java code injection a thing?
Idk how tf to do that in Java I'm sure you could though just seems like a round about way to achieve something
Especially add-ons
Injections are definitely a shitty way to do add-ons
I've gotta go as reccomended just fix your code ;)
what i need to use if RecipeChoice.ExactChoice is deprecated?
ItemStack invisibilityPotion = getConfig().getItemStack("recipe");
ShapedRecipe invisRecipe = new ShapedRecipe(invisibleRecipe, invisibleItem);
invisRecipe.setIngredient('P', new RecipeChoice.ExactChoice(invisibilityPotion));
[23:38:11] [Netty Server IO #0/ERROR]: Error receiving packet 77
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Byte (java.lang.Integer and java.lang.Byte are in module java.base of loader 'bootstrap')
at net.minecraft.network.syncher.DataWatcherSerializer$1.a(SourceFile:30) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-S
getting this error its not specifying where but..
for (int curHoloLine = 0; curHoloLine < hologram.getHoloLines().size(); ++curHoloLine) {
PacketContainer packet = this.protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
Optional<?> opt = Optional.of(WrappedChatComponent.fromChatMessage(hologram.getHoloLines().get(curHoloLine))[0].getHandle());
WrappedDataWatcher metadata = new WrappedDataWatcher();
metadata.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), 32);
metadata.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true)), opt);
metadata.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(3, WrappedDataWatcher.Registry.get(Boolean.class)), true);
metadata.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(15, WrappedDataWatcher.Registry.get(Byte.class)), 25);
packet.getWatchableCollectionModifier().write(0, metadata.getWatchableObjects());
packet.getIntegers().write(0, hologram.getHoloIDs().get(curHoloLine));
try {
this.protocolManager.sendServerPacket(player, packet);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
only places im using bytes
@river oracle i used this, it works right. i ran a method that does nothing yet. but that method, i just dont know how that method can run code on the plugin... thats the part im really confused about
Bump
Bump
hello, im making a guns plugin, but i don't find the way to set the projectile speed
they don't give errors just not change the speed
google it
tried
learn google (:
You tried multiplying the velocity?
yep
whats the code u used
wait
why?
I would advise against using entity projectiles like snowballs or arrows. Minecraft has quite a few limitations regarding their speed.
Using virtual projectiles gives you far more flexibility regarding:
- Velocity
- Bullet drop
- Material penetration
- Projectile size
true, its just harder
classic
You should not use the name or lore of an ItemStack to determine if its a custom item.
Always use the PDC for that.
?pdc
thanks
Many bumps later… bump
Simple: Your method invocation calls itself again. You basically made a recursive infinite loop.
yeah i know, but like how would I achieve what I'm trying to do then
@lost matrix?
🤷 Dont have the will to read this right now
First, disable mentions. Then, reply to my message.
Demonstration
^^^
is it possible to let entities pathfind outside of player render distance
how can i cancel the projectile slowdown with PlayerInteractEvent?
(googled and found nothing)
Whats the max entity id?
The PlayerInteractEvent doesnt slow down projectiles. No idea what you are asking.
im doing a custom guns(?), but im using another materials (diamond hoe) and i need spawn a projectile that has X speed and doesn't slowdown
Just set the velocity of the projectile. Projectiles dont slow down. They keep their velocity (they might get faster from gravity)
thanks
?ban
Syntax: ?ban <user> [days] [reason]
days is the amount of days of messages to cleanup on ban.
Examples:
?ban 428675506947227648 7 Continued to spam after told to stop.
This will ban the user with ID 428675506947227648 and it will delete 7 days worth of messages.?ban @Twentysix 7 Continued to spam after told to stop.
This will ban Twentysix and it will delete 7 days worth of messages.
A user ID should be provided if the user is not a member of this server.
If days is not a number, it's treated as the first word of the reason.
Minimum 0 days, maximum 7. If not specified, the defaultdays setting will be used instead.
@lost matrix is it unethical as a programmer to name things as literal, but as complex-sounding as possible?
Like this enum im making in rust
I could call it "ValueKind"
instead i went with pub enum DataAcquisitionMethod {
Calling an enum DataAquisitionMethod would be deceiving. Its not a method and it doesnt acquire anything...
But that being said: You should strive to be as precise as possible. Even when it means that you need to add
more complex words.
No but it is a data acquisition method
pub enum DataAcquisitionMethod {
Local(Box<[u8]>),
Query(usize)
}
actually
Jeez dude i suck at naming shit
This looks more like a Data(...)Type to me.
DataPointerKind
eh...
Yeah see i suck at naming
?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.
ReadOperation
Was about to worry. I thought "Is Verano actually going to learn the language now?"
Too good to be true
ReadOperationType
hahahaha
Kind sounds kind of stupid...
yeah i would just go with ReadOperation
which is what i will do unless you convince me otherwise
Nah sounds good
pub const LATEST_COMPILE_FEATURE_VERSION_HEADER_LENGTH: u32 = 5;
What does this variable stand for?
No it was a joke
Was it?
Currently
its this now
/// The header length of the current compile feature version.
/// See [super::CCFV].
pub const CCFV_HEADER_LEN: u32 = 5;
I wouldnt have noticed because this seems like a reasonable name. Just a bit obfuscating because you wouldnt know what this variable stands for.
sarcasm off
Is this for your vm?
yes
How are you going to handle garbage collection?
free
?
@eternal oxide is there garbage collection in assembly
7smile7 feel free to answer
No... there is certainly not.
Ok then there will be none
Wait. You are writing a vm without a gc
Ok so you are just writing an instruction set. Not an actual vm.
Sure
just implement the intel x86 arch ezpz
Sounds like a cool project
does anyone know the InventoryHolder representing a chested boat?
Can't test it myself on this shitty laptop
and haven't found anything in the docs
Dont spoil
declaration: package: org.bukkit.entity, interface: ChestBoat
I shall compile the instructions bit by bit to save file size
thanks, somehow couldnt find that
it's like a normal diamond, but rarer
Raerer
...but with increased rarity
How does one get a players rank with the LuckPerms api?
Perfect thank you, I was looking for this
?
I tried chunk.load() but apparently it only works for some events
there’s a difference between forceloaded chunks and ticking chunks, how do make make a chunk a ticking chunk in spigot?
Just because it shows you an alternative way to do it, doesn't mean its better
im still interested in whatever old-style means/looks like
for loop using a value index
How to fill 4 slots?
public void fill() {
List<ItemStack> itemStacks = new ArrayList<>();
items.add(new ItemStack(Material.STONE));
items.add(new ItemStack(Material.STONE));
items.add(new ItemStack(Material.STONE));
items.add(new ItemStack(Material.STONE));
fillBetweenPoints(2, 2, 5, 8, itemStacks);
}
public void fillBetweenPoints(int rowFrom, int colFrom, int rowTo, int colTo, List<ItemStack> itemStacks) {
int minRow = Math.min(rowFrom, rowTo);
int maxRow = Math.max(rowFrom, rowTo);
int minCol = Math.min(colFrom, colTo);
int maxCol = Math.max(colFrom, colTo);
int rows = gui.getRows();
for (int row = 1; row <= rows; row++) {
for (int col = 1; col <= 9; col++) {
int slot = (col + (row - 1) * 9) - 1;
if (!((row >= minRow && row <= maxRow) && (col >= minCol && col <= maxCol)))
continue;
inv.setItem(slot, itemStacks.get(slot));
}
}
}
for only 4 slots you dont even need a for loop
I need to fill the slots
If there are 5 in the sheet, then 5 items should be inserted
like a pagesystem?
Yes
and what doesnt work?
If there are 4 items on the sheet, there will be an error
dont be shy, tell us which one
?paste the stacktrace
Caused by: java.lang.IndexOutOfBoundsException: Index 10 out of bounds for length 4
You never check how many items are in your itemStacks So you keep trying to pull items which don;t exist.
Yes
Then don't?
I'm trying to pull a slot
But it's a slot to put in the inventory and it starts at 10
you keep counting up slots for the whole page, no matter how many items you have
public void fillBetweenPoints(int rowFrom, int colFrom, int rowTo, int colTo, List<ItemStack> itemStacks) {
int minRow = Math.min(rowFrom, rowTo);
int maxRow = Math.max(rowFrom, rowTo);
int minCol = Math.min(colFrom, colTo);
int maxCol = Math.max(colFrom, colTo);
int rows = gui.getRows();
for (int row = 1; row <= rows; row++) {
for (int col = 1; col <= 9; col++) {
int slot = (col + (row - 1) * 9) - 1;
if (!((row >= minRow && row <= maxRow) && (col >= minCol && col <= maxCol)))
continue;
System.out.println(slot);
}
}
}
yes, but you only have FOUR items
and they are not stored in the List starting at index 10 inv.setItem(slot, itemStacks.get(slot));
I give up
itemStacks.get(slot - 10) but that will still explode when there are no items
and when it runs out of items
I want the objects to be inserted like this
I'm not writing it for you
You need to loop over the itemStacks not the slots.
int count = 0;
for (ItemStack item: itemStacks) {
int slot = calculate slot;
inv.setItem(slot, item);
count++;
}```
you fill in the "calculate slot"
It fills all the slots
Theres no way you completed that Math
Yes
BungeeCord
I have TabExecutor
but I dont want players to "tab" and send the text it suggests
any ideas how to do it?
I want to make objects inserted from a sheet
If there are 4 items in the sheet, only 4 will be inserted
how would i go about converting a arraylist of itemstacks to a base64 encoded string?
int slot = 9 + 1 + (count % 7) + ((count / 7) * 9);```Something close to this
Thats not going to do exactly what you want but its as close as I'm willing write it for you
you work out where its missing a +1
read up on these two classes
ByteArrayOutputStream
BukkitObjectOutputStream
I need to start with 1 index in the sheet
I've given you all the code you need. Its literally missing a single +1 and a pair of braces ()
I don't get it
ty
if you get stuck just ping me 😄
alright xd
bump
@short jewel gonna be completely honest and say that i have no idea where i should start. all i have is this: ```java
public class Backpack {
public Backpack(ItemStack... stacks) {
}
}
Make a field lol
There are different approaches to backpacks. Do you want to have physical backpacks (An ItemStack for example)
or do you just want a /backpack command?
so basically, im remaking the backpacks from hypixel skyblock (basically /backpack but with multiple backpacks in a gui) and i have to store every item in a database. i thought that i could convert the arraylist of itemstacks into a base64 string to be able to not have to store as much data
A base64 string will have about 30% overhead.
But i would approach it this way:
When player joins -> load all backpack data into memory
When player leaves -> save data from memory into database
yes, but how would i actually make that?
code
What part exactly?
saving to the database?
Thats the very last thing you should worry about
or more what data to save
Just program against an interface like that
public interface BackpackDataLoader {
List<Backpack> loadBackpacks(UUID playerId);
void saveBackpacks(UUID playerId, List<Backpack> packpacks);
}
And worry about the implementation later.
Any good reason for an immutable final field to be private?
Is the field immutable or the object as well?
immutable, as in primitives and String
Then the only reason is consistency. So access should be given through getters and setters.
Exception being constants of course.
or any immutable object actually since you brought that up, but say we generally cannot make that assumption
ah ok
This makes the code more modular.
Imagine if you decided that the field needed to be modified after all.
Then instead of adding all the methods you simply have to change the final modifier.
just worry about making it work first and saving data later
yes but the thing is, i have no idea what to save and load. idk how to store it
yea make sense
the backpack itself will just be a collection of ItemStacks right?
You save and load backpacks. Thats all. Just use the interface and forget about it. Separate your concerns.
The interface can be implemented with Files, an sql database, mongodb or whatever floats your plane.
what 7smile7 says is correct but it is assuming you have some knowledge of abstraction. so the better question is do you know what an interface is?
yea i know what an interface it
ok look
thats how i store it in the database, i was hoping that i could store some kind of encrypted string with all the data i need in it to keep the database as small and clean as possible
you can
using the classes I sent earlier you can make something that serializes an array/collection of itemstacks
yes but i dont know how to use them
if you want I can write a short example for you
google it out
but I am not a big fan of spoonfeeding so I would recommend you to write it yourself
yes please cause i little to no knowledge when i comes to using outputstreams
Isnt it the usual "ItemStack goes in, base64 String comes out" method?
yhea
Well... then he just has to call the methods...
he does not have the method
me neither but i feel like writing it myself wouldnt go very well
its not like spigot has the serializes build in right or does it now adays?
Oh dang. I wish there was a way to copy text. I guess he has to reinvent the wheel now 😕
Bruh
Sure. Spigot can serialize an ItemStack into a Map<String, Object>
Then you can throw this into Gson and let mongoDB translate it into bson
Just google convert inventory to base64
mongodb is heaven
yes but like
public static void itemStacksToBase64(ArrayList<ItemStack> itemStacks){
try {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOut = new BukkitObjectOutputStream(outStream);
dataOut.writeInt(itemStacks.size());
for (int i = 0; i < itemStacks.size(); i++) {
dataOut.writeObject(itemStacks.get(i));
}
dataOut.close();
return Base64Coder.encodeLines(outStream.toByteArray())
} catch (Exception e) {
e.printStackTrace();
}
}
i dont want to save the entire inventory
They are a bit ugly and i would rewrite them but they work.
Well save what items u want
not sure if it works as I wrote it in notepad no IDE at work 😦
ill check it out, thanks
its an example
he should use it and write his own not copy and paste cause then you dont learn a thing
Which Java version should I use for 1.19 plugins? I mean does this version already use java 18 or still 17?
ok, thx
bump
So you have tab completion but you dont want the player to complete the text?
yee
I just want to display the text above but not complete it into the command
Not possible. Text completion works like that:
You sent the player a list of Strings and then forget about it.
You have no control over what the client does with those Strings.
i think some plugins does that
Which one?
CMI
heyho guys, have a question: i wanna do a sound what repeats every 5 minutes on a specific coordinate, but how do i do that the best way? i thought putting a schedulesyncrepeatingtask but where do i put it?
About the only way I think it could be possible to prevent a Tab Complete is cancelling https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/server/TabCompleteEvent.html
Even then I believe that event fires before teh complete, so no good
t
This can be done with a repeating task. If you want a real time precision (seconds instead of ticks) then you should
use an executor service or timer.
I would def create a data class that contains the sound and location together with a manager that holds this information.
i have
fb.setVelocity(targetLocation.getLocation().toVector().subtract(baseLocation.getLocation().toVector()).normalize());
targetlocation is the location the blocks should be going to and baselocation is the location the blocks spawn at, both the locations are taken from the position of these armorstands in this picture
https://imgur.com/a/462PQjL
the bottom one is the base top is target, the green arrow is what the falling blocks are doing and the red arrow is where they should be going, x and z works fine but the y axis doesnt go any higher then in the pic
but where should i put the repeating task in? in what kind of class? listeners dont get refreshed all that times i guess
You start the task when your plugin is enabled. Then on runtime you can add locations / sounds to that task.
okay
Looks like gravity pulls the block back down. Do you set the velocity only once?
yeah
Well... then i think this is clear. Gravity simply pulls them back down.
yeah ik but i need a way to stop that and im not sure what the best thing to do is
.setGravity(false)
when i do that the blocks just go flying way above where the armorstand is
no gravity means constant velocity
either stop the block when it gets where it needs to be, or fight gravity
So you want them just to shoot higher but still in a parabola? Then increase the length of your velocity vector.
fb.setVelocity(targetLocation.getLocation().toVector().subtract(baseLocation.getLocation().toVector()).normalize().multiply(1.75));
its kind of hard to explain what it does ill get a pic 1 sec
https://imgur.com/a/tNEUmLe then it just goes way too high
it also still doesnt have enough power if the armor stand is higher then a certain point i didnt know if there was some kind of equation or smthn?
So you want it to shoot up, get slower as it approaches the armorstand, then 'tips' the armorstand and falls back down?
Hello guys, i have a question: im trying to make a minecart constantly move the to the facing direction of the player, if the player is in it. I tried doing it with velocity but i failed lol, any ideas?
Pretty simple. Just calculate the delta between the block and the armorstand and apply an initial velocity based on the distance.
Gravity is applied like in real life but only in discrete time intervals. So no differential equation needed.
Just find out the gravity constant for falling blocks and sue 8th grade physics/math.
Do it with velocity
thats already what im doing isnt it?
how?
No. You are giving the block a velocity of exactly 1
No matter how far the block is away.
oh
sorry i dont 100% understand how would i find the grabity constant and wouldnt i then need a runnable constantly adding velocity?
Get the direction the player is looking in and set the minecarts velocity.
you can't change the direction using velocity, you have to set the Yaw.
alr, gonna try that
However
setting Yaw requires getting the Location of the Minecart, which will be a clone, so setting the Yaw will do nothing
you would have to teleport the Minecart to teh adjusted Location, or use steer packets
No. You simply calculate the velocity needed to reach a certain height and set it to the falling block.
In physics class you had such a task for sure.
Bob wants to throw a ball 20m in the air.
How fast does Bob have to throw the ball?
Assume that the gravity (acceleration in -y) is 9.8 m/s^2
You simply have to find out the gravity constant g in minecraft and then do some math.
I can help you find out the constant if you want.
yeah please if you could
https://minecraftbedrock-archive.fandom.com/wiki/Gravity would it be 32 from here?
falling blocks have 16
id also need a mass though right?
No. You already have the gravity.
A mass is only needed if you wanted to calculate the
acceleration caused by two masses.
And for games this is too expensive. So your acceleration is just 16 m/s^2 (for falling blocks)
ah
In Minecraft 1.13+ the command line was reworked including colors, is it possible to use the feature?
You mean colors for tab completion?
If you want all features then you would need to use Brigadier.
I mean colors like here for the selector and the coordinates
I dont know any command framework that supports those features so im assuming you would have to use Brigadier.
^
Alright, thanks
would Luckos lib support it?
im trying to find an equation online for calculating that and i cant find anything i dont know the specific name assuming you need one? because multiplying it just by 16 wouldnt really work
ye
when making a new command, is it posible to have these auto suggestions?
Sure. Just implement a TabCompleter.
someone know why i got this in the console
Cannot invoke "java.util.Optional.isPresent()" because "optional" is null
but it appears and it has its custom name, and the worst is that when I try to display the variable it is displayed correctly
TFW the optional is null. Is it your optional because optionals should never ever be null.
Just measured the velocity of a falling block that was shot straight up
wdym
the most logical explanation is that the value you put into the optional is null
can you post more of your code?
cause with that one line its hard to see what is actually going on 😅
yes 2s
np take ur time
i added @NotNull before the Optional but it doesn't change anything
sorry for the ping x)
the not null does nothing cause the optional itself isnt not null the value inside the optional is null
what is the line that gives the error?
i dont have any lines in my code that give error
in the console i dont see any line of my code
huh
https://paste.md-5.net/oregisikek.bash (error code)
and i tried to replace the p.getName by a string and it doesn't change anything
a Spigot jar using adventure?
i tried of and ofnullable
me ?
You have no variable named "optional"
This exception is not thrown on your code. You forgot to provide a field somewhere.
Spigot tried to serialize your packets and was thrown off because you forgot some value.
it can be a protocollib error ?
how do i check if there are no arguments in my command
i check multiple things, and the only thing that works for me is if( Arrays.toString(args).equals("[]") ) and I feel like this is more inefficient then wiping your butt before you're finished
(things that i tried that dont work are "args == null" "args.length == 0 " "!(args.length >= 1)" )
lol
if args.length == 0 then no arguments where passed
either that or you are not giving all the values that are needed
but
it does it has always worked and always will work 😅
are u sure there were no arguments passed
Show us.
?paste
Never know. Could be a spigot fork called spigot-but-commands-are-fused
spigot but command arguments always include the command name as the first index element
the fuck
does that font mean == or just =
this is why i dont like those weird powerline fonts that merge characters
I tried to add
if(name.isPresent()){
System.out.println("OK PRESENT");
}
and according the documentation "Return true if there is a value present, otherwise false."
So if the value is null i wouldn't get the message but i get it
its == (but that font makes it 1 long =)
and even if it was just a single =, it would then give an error
take a look at the elements your packet needs and see if ur missing anything
You are using the wrong serializer.
Optional<Object> chatComponent = Optional.of(WrappedChatComponent.fromLegacyText(this.text).getHandle());
dataWatcher.setObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true), chatComponent);
WrappedDataWatcher.Registry.getChatComponentSerializer(true)
true -> optional
anyone know how to do this?
so i need to remove the true ?
no im stupid
Have anyone an idea how "MinecraftEncryption" works? I want fix that:
"new ClientboundPlayerChatPacket(chat, Optional.of(chat), 0, ChatSender.a(chat), Instant.now(), null);"
I must replace null with the "MinecraftEncryption" instance!
Why do you want that?
What's your objective? Are you trying to remove message signing?
wtf is this packet even?
I dont have that
I want to send a clickable message
Uhm, ok..?
try replacing Instant.now with null as well
Then use the spigot api
iirc that's only sent with signed messages
alright
but yeah no reason to not use api
Oh i see. Im still on 1.18...
I don't think you'd want to use player chat message anyway? for sending a clickable message
you'd want to send a system message
my brain went brr by looking thro the chat
How can I make it faster then?
increase the velocity by increasing the length of the velocity vector
How?
anyone?
raycasting from player location returns player
RayTraceResult result = p.getWorld().rayTrace(p.getLocation(),direction,range,FluidCollisionMode.ALWAYS,false, 0.5,null);
Add a predicate to filter out the player
Predicate pre = new Predicate?
entity -> return entity.getType() != PLAYER;
Best tutorial for plugin development? (Spigot)
hes good for beginners
yes I know Java fair bit
mwe
exactly
which is why i said learn java before
he has bad coding practice
but explains api well
i've came to the conclusion that there arent advanced spigot coding tutorials online :(
oh that sucks :(
its not a particularly big thing
not everyone plays minecraft, not everyone wants to make plugins
im just loooking at gh now
good discord servers for spigot development?
There are really only 3 things you have to know to get started.
- Events and listeners
- Commands
- Scheduling
After that you just need to dig in and discover everything
how do I filter all players in list?
oh lol
okok
What are you raytracing to find?
entities/players
by googling how lambdas work
but want to exclude players if they are at same team
all entities? just mobs? just Players?
Event API:
https://www.spigotmc.org/wiki/using-the-event-api/
Command API:
https://www.spigotmc.org/wiki/create-a-simple-command/
Scheduler API:
https://www.spigotmc.org/wiki/scheduler-programming/
yep
thanks alot!
those questions are mutually exclusive
Is the ball red, green or blue
-> "yep"
all entites
except some in list
then don;t use a predicate
switch 😍
You should use a set instead
die 💀
entity -> return !set.contains(entity.getType)
however you want to handle your exclusions
Set<UUID> possibleTargets = new HashSet<>();
Predicate<Entity> filter = entity -> possibleTargets.contains(entity.getUniqueId());
Wait am i missing a !?
@subtle folio intellij crashes every time when updating to 2022 edition lol
F
Why?
send logs
what are ur specs
well uhh its smth with plugins
disable them all
i only use copilot rust and github theme plug-in
and minecraft development ofc
Gh copilot is the best thing that was ever invented, besides booze
All other AI code completions are utter bullshit but gh copilot is actually useful
ah
If you wanna see something funny, try code4me
ye ig but i never installed it
i’ll have to check it out when i get home
Code4me is a parody of copilot ig
lets see, its downloading patch files now
It always only suggests totally random nonsense things lol
is it good
oh lmfao
nvm
pretty sure amazon is making their own copilot
you have ultimate right alex?
Yes, i have unlimited university email addresses
If you are a student or a maintainer of a popular open source project, you can get it free
Im not sure if im allowed to use all this free stuff for work but… noone would ever find out anyway
wait rlly
lmao 😉
anyone know how to do this?
i’m a student how do i get it
Erm tbh no idea lol
do i need a .edu email
No you just an email of an approved school / university
im a student next year lmao
Do you just want the block to fly from A to B or does it need to fly in a parabola and only 'touch' location B
high school better count 😂
i guess not lol
fly from a to b
omg then you need a totally different approach. Scrap all that gravity stuff.
No
i can do parabola
And I’m guessing student developer pack
But .edu gets accepted automatically
Should be fine, I’m in high school too
huh
Before we go any further: Explain exactly what you are trying to do.
get the falling block from point A to B using a parabola or just touch the point it doesnt really matter
Take one more step back an explain your overall idea
creating a fountain
aaaa
Gross
how do ij makme a minecraft plugin
none of the tutorials ive watched
actually worked
u extdend jabba ploogin
atleast the updating worked
without crashing smh
This ^
You want to create a fountain with falling blocks as the water.
Does the height, the water is flying have to be precise or do you intend to just
use one height that never changes?
the player can move the target of the fountain so the velocity would be different whenever the player moves it
Ok so it has to be dynamic and precise. Then be prepared for quite a bit of math.
👍
I found out that the gravity is non-constant and directly proportional to the velocity of the object.
ah
Wait let me double check. This looks a bit weird.
Ah i need to use a discrete approach. Brb.
cringe i need to wait till school starts
download it
Bukkit.getScheduler().runTaskLater(Swords.getPlugin().getInstance(), new Runnable(){
Swords.getPlugin().getInstance()
how do i return my plugin?
sigh
i'd rather you didnt help if you're going to have a negative attitude
?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.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
i don't need to learn java... lol
if you think this has anything to do with java and not the library idk
maybe you need to click those links
Passing around an instance of your class is deffinetly basic java
Its just... this question together with "how do i use my variables in another class"
get asked almost every day by people that just jumped into spigot without learning
the very basics of java.
Plugin is not the same as my main class though?
I mean... traditionally speaking, a main class and your plugin class aren't technically the same thing, but plugin developers will refer to it as the "main class" lol
nah i've been programming for years
True
Bukkit.getScheduler().runTaskLater(Swords.getPlugin()
it requires you to parse "clazz"
“years”
i primarily use c#, so i'm not sure what clazz is
Ah ok.
Your JavaPlugin class gets instantiated once and is a singleton.
You can simply create a static reference in your onEnable() and get it with a static getter.
Should explain everything then.
Your "Main" is a singleton so as you are referencing Swords statically just get an instance
?di or inject
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
public PlayerListener(PlayerStatsPlugin plugin) {
this.plugin = plugin;
},
i had this exactly but i was getting a weird issue, maybe i'll take a look
at what i did wrong
thanks guys :)
This should cut it as well
We forgot to answer this one. clazz is simply a way to reference a class as a variable as class is a protected name. Something which uses/asks for a clazz is asking for Main.class or this.getClass()
ah okay, thanks :), i opted for going with this method btw. thanks guys :)
Hey
Trying to connect to a MariaDB database
but its not working
Getting this error
No suitable driver found for jdbc:mariadb://127.0.0.1:3306
Included MariaDB jdbc driver in my classpath
but still not working
you probably have to load it
how would I do that
still not working
What spigot version?
1.8.8
ts
ij loves me writing yml
did you load it? java this.driver = "org.h2.Driver"; Class.forName(this.driver);Thats for H2
me when typing :/
shut up
ye
I did Class.forName
Class.forName("org.mariadb.jdbc.Driver")
Im close to finding out how gravity works but im just not completely sure on how to interpret this.
Looks like movement with drag.
ah yes i will shut up
great news
He is a 1.8 user. What did you expect?
What IDE version are you running on and which OS?
IntellIJ latest
hello, i have problem whit bstats
Windows 10
- META-INF/MANIFEST.MF
maven-shade-plugin has detected that some class files are
present in two or more JARs. When this happens, only one
single version of the class is copied to the uber jar.
Usually this is not harmful and you can skip these warnings,
otherwise try to manually exclude artifacts based on
mvn dependency:tree -Ddetail=true and the above output.```
Not you...
i think i fixed it by removing some stupid yaml plugin :)
when i build
ignore that
ij has yml support integrated lul
ah nice so this would be the parabola thing?
ok
idk ig i installed that for syntax validating or smth
in the main class i need to put only this 2 string?
int pluginId = 1234; // <-- Replace with the id of your plugin!
Metrics metrics = new Metrics(this, pluginId);````
Yes. The constructor of Metrics does the rest.
it work
Which is a flawed design but meh
Hello, I want to loop a .yml file. But:
List<ItemStack> bestellingenList = (List<ItemStack>) main.getSpelerbestelling().get("Bestelling");
if(bestellingenList == null) bestellingenList = new ArrayList<>();
for (ItemStack bestelling : bestellingenList) {
bestellingen.addItem(bestelling);
}
doesn't seem to work.
Anybody know why?
Use getList() instead
yeah it doesnt seem to be in my classpath
how do I add it
Alright.
dutch kek
this is my pom
