#help-development
1 messages · Page 400 of 1
Just an array I once used to calculate the length of text lines in books in order to wrap them manually. I forgot why I needed that, xD. I think this data came from the minecraft fandom website.
I want to create a plugin where when a player dies about 20 bones explode outwards from where they died
but I want to bones to despawn after 1 second and not be able to be picked up by player
how do I make items fly basically
I don't think that there's an armor equip event. Somebody once asked about this already, so it might be worth investigating and making a minimal public library, which accumulates all cases of (un-)equipping armor.
how can I spawn an item on the ground
Use alex's ArmorEquipEvent class.
https://github.com/JEFF-Media-GbR/ArmorEquipEvent
Item itemEntity = location.getWorld().dropItem(location, item);
itemEntity.setVelocity(...);
Then you just need to calculate random velocities by picking random points in a sphere of radius 1 around the point of death and creating a vector through subtracting that point (end) from the death point (beginning). You can multiply each of those with a random double in a range to make it look more organic.
chess in minceraft when
Somebody forgot a sneaky little debug print in there, xDD
If only I'd know how to play, xD. But I wouldn't recommend rendering that in chat, as it'll probably be spammed away by other players. Either holograms or maps would be an even better fit.
Thank you
3 black backticks work
Thank you
Would you mind to share this array though? I want to do some experiments on it
I have an idea to emulate alpha channel using these characters
Sure thing, here you go: https://paste.md-5.net/ofuyumefaj.java
Great! It's sadly not full transparency, but at least like 80%, xD
Very thank you. If I ever make something useful out of it (it's unlikely but anyways), I'll credit you
No worries, I'm happy to help! :).
https://github.com/GorgeousOne/NetherView
I found it again, damn, that's so inspiring, :D. Such a great idea, using raytracing and fake block updates to simulate this effect. I'm just pretty sure that it can be pretty expensive, both for the client and the server.
Yeah, it's based on SethBling's POC done with command blocks
anyone have a significant amount of experience w plib
plib is easy
gotta find the function im tryna reference
didnt expect an answer soq uick lmao
can i get away with just spawning an entity and giving it the base meta from WrappedDataWatcher#fakeEntity
am tryna make entities solely packet manipulatable and tick on the netty thread
but they keep spawning invisible >:(
So basically
You don't really need much to spawn packet-based entities
You just need to send a SPAWN_LIVING_ENTITY packet
and the entity should appear
You can create metadata packets with that WrappedDataWatcher entity, and send them under your packet entity's entityId
aware, spawn entity packet is spawning it in invisible for no reason at all
bout to say fuck it and just move to a diff version to test it
Pretty sure I know why
1.8 version that i had to regress to test just for fun
was also happening on 1.18
sidenote why do spawn packets on 1.8 just have int fields
not even rotation is a double / float ??
WrappedSpawnEntityPacket packet = new WrappedSpawnEntityPacket();
packet.setEntityId(this.id = PacketServer.handleEntityId());
debug("handle packetid " + packet.getEntityId());
packet.setType(type.get().getId());
packet.setX((int) location.get().getX());
packet.setY((int) location.get().getY());
packet.setZ((int) location.get().getZ());
packet.setYaw((int) location.get().getYaw());
packet.setPitch((int) location.get().getPitch());
packet.setData(data);
packet.setDx((int) velocity.get().getX());
packet.setDy((int) velocity.get().getY());
packet.setDz((int) velocity.get().getZ());
return packet;
packet gen
just being sent to a list of players i've confirmed i'm on
Okay so here's the thing
I'd advise against packet wrappers as they're auto-generated
ProtocolLib wraps the fields on the NMS packet class
Not what's written to the buffer, which is what wiki.vg shows
How would i detect a packet entity click? ( using for my hologram system ). I can't figure it out
Since the entities are packets
Client sends packets
With protocollib, you register a packet listener
with nms you register a listener on the netty thread
I dont use Protocollib
Okay
Ty
Which packet would that be exactly?
If you dont mind
iirc holographicdisplays checks for arm animations and ray traces to the holo
The client sends a packet usually containing the entity id hit
https://www.spigotmc.org/threads/all-you-need-to-know-about-nms.582651/ - If you want to learn about how to listen / send packets, both NMS & Protocollib
I made my own system
Ty
Ahh, okay ty
it does
ever noticed how you can't place blocks if you have an invisible entity at that location?
try it with an invis armorstand
I delete the packet entity whenever i hide the hologram
Because i thought that was the best way without any issues
Ive been trying to figure out how to get custom enchants to work for a little would it be a bad idea to give my items PersistantData with the key being the enchant name and value being the tier then just adding a lore to it? Is there a better way to do this or should this work fine?
uhh
Probably a wrapper class that converts Legible Data <-> PDC
Honestly your idea isn't really that scalable?
I'd just store a whole tag containing all the data, and a data version for the tag
NBT data would look like
<enchantment-data>:
\-> data-version: 1
\-> enchant-type: SOMETHING
\-> enchant-tier: 123
you might end up adding data in the future, hence the data version
You'd make a converter that just
public CompoundTag process(CompoundTag original) {
...
}
and do a for loop that converts old data into new data
I might just be overengineering
ngl im kinda lost I do have some code I was following from a tutorial that just didnt work. Not really sure where it went wrong no errors and I threw some debug messages and it seems to be going through everything my only guess is that what I did is outdated would you mind taking a look?
ehh tutorials
Its more to just play around with it has me make an Enchantment Wrapper extending the Enchantment class and creating them through that
crying i just tested the base wrapper outside of that code
it don't work at all
now i gotta make separate nms impl's for every version this is gonna be used on
packetwrapper 😭
Nah
writeSafely is king
The problem you're having
is that you're setting the entitytype as an id int
just set it as the bukkit object through the wrapper and it'll do its thing
wrapper.getHandle().getEntityTypes().writeSafely(0, EntityType.ZOMBIE) for example
If you have time this is what I have
https://pastebin.com/TbH3df9h
https://pastebin.com/rhZZNKD8
and im running the register onStart
oh god you're not following package naming conventions
nor naming conventions
mfw i didn't know writesafely was even a thing
i'll screw with that in a bit ty 😄
readSafely is a thing too
Is there a guide of what to follow or something
bout to rewrite every wrapper i have lolol
hey, is there a way to stop the end portal particles from showing up? the end result should look something like the second picture, but im not sure where to start for this
I don't think that's something the server can control.
Those particles are client-side for that block
CONSTANTS_ARE_NAMED_LIKE_THIS
ClassesAreNamedLikeThis
packages.are.named.like.this (reversed.actually.is.it)
methodsAndVariablesAreNamedLikeThis
Packages are named as a reverse domain, so google.com -> com.google.someproject
If you do not have a domain, feel free to use me.whatever.someproject or com.github.whatever.someproject
To get rid of them you'd either need a core fragment shader that discards particles of that color
or retexture that particle to an 8x8 nothing
so something like a resource pack to disable it?
Yes.
alright cool, thanks
That is helpfull ill be sure to try and use this in the future
How did you take the second picture, if it's not easily hidden? :-:
for some reason f5 will set the angle to hide the smoke
by turning particles off ??
It might
I wonder what the convention on underscores in package names is. Should only be a concern on the name of the software, but anyways: there are not many sources on this.
new MC rendering is weird. Particles behind glass are invis
and in water
so, it very well may be like that
So after creating an enchant using the Enchantment class and I register it is there something else that needs to be done because I did both and its still not in my game.
I'd love to check if the server sends particle packets and thus prove if the particles are rendered client-side, but I'm too stupid to get a portal up, lol
so I'm, listening to a blockplaceevent and I want to get the item in their hand
get the player then Player.getInventory().getItemInMainHand()
however when the player places the item successfully and only has one item in their hand, BlockPlaceEvent#getItemInHand() returns an itemstack of air, not the itemstack of what they placed
get the block they placed
get the block and get type, if you need more you might need player interact event
that'll return the block not the itemstack which contains the nbt that's in the item
thought I tried this and it didn't work but I'll give it another go
hmm it works now
I'm not complaining 🤷♂️
I followed a tutorial about adding custom enchants and when I print out a list of the enchants in game my enchant shows up but I cant use it in /enchant or apply it with my plugin in the itemstack any ideas as to why?
?nocode
It’s hard to answer a programming question without code. In order to help, helpers are going to have to see what the code is. (source: http://idownvotedbecau.se/nocode/).
Please share your code! If it's short, wrap it directly into Discord. If it's long, use a third-party service (e.g. ?paste).
?nocode @remote swallow @rotund ravine
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
thanks imajin
Thx @quaint mantle
How can I know how to correctly hook into a plugin dependency if they don't have a API usage page but I have the public repo with the API
https://github.com/Crazy-Crew/CrazyEnvoys
I have it added as a dependency already but I assume I need something to initialize because the events are not getting triggered
it should initalize themselves because its a plugin, so you probably want to join there discord and ask
i think you want PlayerInteractEntityEvent
Non-Spigot-Related question
Circulating around Lombok
How do I define String array varargs via lombok @AllArgsConstructor or @RequiredArgsConstructor?
Anyone knows?
no but you can have @Builder and @Singular
Yeah I know that, already surfed around StackOverFlow and Lombok's github
they won't implement anything with it due to older java support
i mean why not just have a varargs constructor that calls the lombok one
@Getter
@RequiredArgsConstructor
class Person {
private final String name;
private final Identity[] identities;
public Person(String name, Identity... identities) {
this(name, identities)
}
}
looks pretty sexy to me
No reason for the @RequiredArgsConstructor then
ohhh
I see what you did there
still uglyasf
🙂
take it on a note
😦
How can I make custom mob? I just wanna make custom vehicle (riding system)
Custom resource pack + custom model mob implementing some NMS code
Is there any tutorial for nms?
don't hate on me 😭
It was so hard 😦
lookup on yt, I have a friend who self taught himself in like 4 days creating the whole NPC system of Citizens that is 200x more stable than Citizens.
And more customized aswell
built in denizen?
no.
Side coded API that he himself created for our network
took him about a month to manage the exceptions though.
he is so genius lol
what the
I am 21 and I do not want to take any work on NMS cuz it sucks a lot, ppl require multi version support and then I need to go ahead use Reflections with caching otherwise memory god om nom nom nom nom
😿
Alexa play All codes are the same by Juice World
For person who don't know eng
Everything is so hard 🥹
How old r u
im 18 years old
Time to find an English girl to teach you everything lol
I did that when I was 14 and all of my English was taught from her
OMG It's impossible lol
And listen to Dubstep 😎
@Getter
private final int defaultMaxEventTime;
@Getter
private final String[] broadcast;
DemoEventType(int defaultMaxEventTime, String... message) {
this.defaultMaxEventTime = defaultMaxEventTime;
this.broadcast = message;
}
@quaint mantle ugly ahh code istg
API > NMS
although if you're looking for performance and advanced customizability NMS > API
My principle is that the less code i need to manage, the better, so I prefer to use API whenever I can
Imagine
I just ran into a plugin
That I made a addon for. As a dependency. And in the version I tested (latest) the plugin name is "ThisPlugin"
But in the version the client used. the name is "ThisPluginS"
What kind of dev changes the plugin name randomly in the plugin.yml of their plugin. What an idiot
Bro he just added an S to the end. That's it
i feel you
i would be annoyed too
Agreed
API requires 1/4 of the actual code
I am most fund of the way entities are able to be hidden from players now.
is a static boolean field?
or is it an instance field
lemme remind you that if you set the game active like this
boolean gameActive = plugin.gameActive;
gameActive = true;
this wont work
why? because boolean is primitive type and its not passed by reference like non primitive objects
its passed by value
so you're essentially setting gameActive local variable as true
If you used Boolean instead of primitive this would work, but its not recommended for such a simple case. doing plugin.gameActive = true would work tho
If I put a plugin in the plugins/update folder, will it check for plugin name or file name
I need to loop through this list adding each value which is gotten from user input to sql table, my issue is the first paramIndex is an id i generate. So I need to to start from param 2 but I need the first index of the list... I tried a nested loop but didn't seem to work
Ouch

Same
also that checkUpdate has a couple issues
updateDirectory == null || updateDirectory.isFile() is a better way to check (it does some extra useful checks such as existance check and dir check)
updateFile.delete() should be replaced with like
try {
Files.delete(updateFile);
} catch(IOException e) {
// Log the exception, it has better error messages
}
and should use plugin descriptions
Error messages from Files.delete
Well
I am making a pr

Oh god
this is actually insanity
you need to iterate over every loader that matches the file
reeeeeeeeee
indeed
package net.md_5.bungee.api.connection does not exist
why
do i have this
i did this
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/817/overview
I made a pull request LETS GO
Me
sus
Yes
Sus
Git bullshittery
It only allowed me to push with a space there lmao
Intellij just seems to have optimized imports
shit
Make a new commit fixing that
The development profile
ah
Hey, i've never used gradle. How do I change the project output to be able to auto export to my servers folder
Another notable point, the update dir is configurable
Oh
It's parent is not guaranteed to be the plugin die
Welp
Dir
I don't really know how to get the plugin folder
Why do you even iterate over the plugins dir the fuck
Well I had no other idea how to find a matching plugin
since it runs before loading it
check outputJar task. im not sure how to do it though
You also get a update directory
👍 thanks
Hi, I'm using Jeff-Media ArmorEquipEvent but when I use the Number key to move armors the event only fires for the first armor piece i take off, its like the other ones become like a ghost and then i need to move them again to make the event fire, has anyone ever had this problem or someone knows how to fix this?
Gradle is so meh
Which has a bunch of files that may or may not be plugins
They have a support discord for their lib
oh really?
I hath found the solution to my problem
Yes
i didn't knew
@eternal night
File pluginDirectory = file.getParentFile();
File updateDirectory = new File(pluginDirectory, Bukkit.getUpdateFolder());
And iterate over the update dir to find matching?
Note I still do not know how to get the plugin dir
since I am editing checkUpdate I don't have enough ctx
Anyone got ideas on how I can do it?
its literally a field what do you mean

Hi, im trying displaying an image and works just fine for north and south but for the other it wont rotate
public static BukkitTask displayRenderedImage(Plugin plugin, Map<double[], Color> render, Callable<Location> location,
int repeat, long period, int quality, int speed, float size) {
return new BukkitRunnable() {
int times = repeat;
@Override
public void run() {
try {
displayRenderedImage(render, location.call(), quality, speed, size);
} catch (Exception e) {
e.printStackTrace();
}
if (times-- < 1) cancel();
}
}.runTaskTimerAsynchronously(plugin, 0L, period);
}
public static void displayRenderedImage(Map<double[], Color> render, Location location, int quality, int speed, float size) {
World world = location.getWorld();
for (Map.Entry<double[], Color> pixel : render.entrySet()) {
Particle.DustOptions data = new Particle.DustOptions(pixel.getValue(), size);
double[] pixelLoc = pixel.getKey();
Location loc = new Location(world, location.getX() - pixelLoc[0], location.getY() - pixelLoc[1], location.getZ());
world.spawnParticle(Particle.REDSTONE, loc, quality, 0, 0, 0, speed, data);
}
}
the code to load it is
displayRenderedImage(plugin, image.get(), () -> player.getEyeLocation().add(player.getLocation().getDirection()), 1, period,1,0,0.8f);
@eternal night Updated, did I do it correctly this time lmao

can someone send the github link of the plugin creator
like where you can add dependencies while creating the plugin
?
much confusion, im guessing i need to clear the permission table and fix some syntax?
shadowJar category if you have one
before doing something stupid, look at what you have wrote
XD
Hello, how can I make a beam of particles in the direction where the player is looking at 2 blocks?
Loops and MySQL
hmm
chatgpt recommended me to use ```java
Arrays.stream(StatTag.class.getDeclaredFields())
.filter(field -> field.getType() == Tag.class && Modifier.isStatic(field.getModifiers()))
.map(field -> {
try {
return (Tag<Integer>) field.get(null);
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
}
})
.forEach(tag -> System.out.println(tag.getName()));
is there not a cleaner way to loop over ```java
public class StatTag {
public static final Tag<Integer> HEALTH = Tag.Integer("health");
public static final Tag<Integer> DEFENSE = Tag.Integer("defense");
public static final Tag<Integer> STRENGTH = Tag.Integer("strength");
// ... you get the jist
}
?pdc
(for me dw)
Why the hell for some reason with my code does it still store the arrow in the world item PDC?
class InventoryClickListener(private val parentPlugin: TestPluginWMaven) : Listener {
@EventHandler
fun inventoryClickEvent(event: InventoryClickEvent) {
val playerUUID = event.whoClicked.uniqueId
if (event.inventory == TestPluginWMaven.guiMap[playerUUID]) {
if (event.currentItem == null) return
when (event.currentItem!!.type) {
Material.ARROW -> {
event.isCancelled = true
val itemsToDonate = event.inventory.contents
// Put the items in the admin-only accessible NBT storage medium
val key = NamespacedKey(parentPlugin, "itemsForDonation")
val pdc = Bukkit.getWorlds()[0].persistentDataContainer
val items = pdc.get(key, DataType.ITEM_STACK_ARRAY)
if (items == null) {
pdc.set(key, DataType.ITEM_STACK_ARRAY, itemsToDonate)
} else {
val itemsToStoreInPDC = mutableListOf<ItemStack?>()
val inventoryItemsList = itemsToDonate.filter {
it?.displayName() != Component.text("Donate to Admins") && it?.type == Material.ARROW
}.toCollection(ArrayList())
val itemsInWorldPDC = items.toCollection(ArrayList())
itemsToStoreInPDC.addAll(itemsInWorldPDC)
itemsToStoreInPDC.addAll(inventoryItemsList)
pdc.set(key, DataType.ITEM_STACK_ARRAY, itemsToStoreInPDC.toTypedArray())
}
pdc.set(key, DataType.ITEM_STACK_ARRAY, itemsToDonate)
event.inventory.close()
}
else -> {}
}
}
}
}
💀
Like surely the filter means that it should not add the arrow - but it for some reason still has it?
?
filter only adds things that match
Is that not what I'm doing already?
?
I've seen that
And I'm also using the com.jeff_media.morepersistentdatatypes.DataType library to store item stacks
But for some odd reason, the arrow is still in the PDC data after it was clicked?
@rough drift Is there like an on take out of inventory event or something?
InventoryClickEvent is the only thing
That I can listen to and then make sure items aren't duped by not being removed from the PDC?
Hmm
Because the other issue I have is when I have a command to view the items in that world item storage PDC thing - I can take shit out but ofc it doesn't remove it from the PDC also
So I was wondering how I'd attempt to do that 🤔
what are you doing
what are you try to build?
Do mvn package instead of plain mvn
Would anyone know why in this code block, there is still one item left over even when I take all of the items out of the custom inventory?
else if (event.clickedInventory == TestPluginWMaven.OtherGuiMap[playerUUID]) {
val inventoryGUIItems = event.clickedInventory!!.contents.filterNotNull()
val key = NamespacedKey(parentPlugin, "itemsForDonation")
val pdc = Bukkit.getWorlds()[0].persistentDataContainer
val itemsInDonationPDC = pdc.get(key, DataType.ITEM_STACK_ARRAY)
if (itemsInDonationPDC != null) {
// Compare inventory items to PDC data
val itemsInPDCNotNull = itemsInDonationPDC.filterNotNull()
if (inventoryGUIItems.any { it in itemsInPDCNotNull }) {
println("Fixing inequality!")
pdc.set(key, DataType.ITEM_STACK_ARRAY, inventoryGUIItems.toTypedArray())
println("New inventory length: " + pdc.get(key, DataType.ITEM_STACK_ARRAY)!!.filterNotNull().size)
}
}
}
Because when I take out both of the items I have put in previously, it still says "New inventory length: 1".
And I am doing this code by the way in the InventoryClickListener.
It is basically removing every item but one?
Yo I got a problem, in a project I was able to use PDC but on a new one I can't, when I do player.getPersistentDataContainer(), it say that getPersistentDataContainer doesn't exist
show from where you get player variable
and what spigot version are you using
Version 1.14
Don't you have to get their meta or something first?
also its not an int
Oh 1.14.4 that's why
Would any of you know why my code is not indeed removing the items that have been taken out of the custom inventory out of a PDC array?
Here's my paste: https://paste.helpch.at/dayelezozu.kotlin
ikr I just wanna do something like an old project that look like that
@hazy parrot would you know?
me wondering what all those bools mean
the better question is why they aren't a bitset
heehee i was thinking about that too
Does anyone know why when I'm adding Vault on my pom.xml, I can't use PDC (Spigot 1.16.5)
vault might be adding a transitive dependency
Uh
I wish maven had something similar to compileOnly and implementation
Would anyone know why with my code, after clicking on an item and moving it from the custom inventory to my new inventory - why the item still after being removed is kept in the array stored in the PDC?
I'm really lost for ideas
it does?
isnt it just compile and provided?
Conclure, would you know?
cuz provided adds to compileClasspath, and compile adds to both compileClasspath and runtimeClasspath
you never remove it?
maybe transitivity is a bit different tho
What do you mean?
i dont understand kotlin man
Wait hold on
you never modify that array?
💀
Hold on
Does anyone have any ideas how i can advertise my plugin coding service and get more customers?
?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/
What's a good way of allowing multiple databases and letting the user pick which one. (Java not spigot :))
@safe ibex contents returns a copy
polymorphism I'd say
Where the problem at?
and then you might wanna switch on some string input that decides which implementation to use
no in general Inventory.contents returns a copy
Yeah thought of using a switch, got an example of anyone doing this with polymorphism at all? if not thats cool
Yes I know. My logic is supposed to check if anything after an interaction in the custom inventory is clicked/picked up/moved out of the "inventory", it should then update the world PDC array with the items in so that it doesn't have that item in any longer.
Like a chest emulation, basically
ah I c
So my code should be working, but it's not removing properly
Like if I have 8 items and remove one, it'll still have all of the items in the PDC still, even after removing
fuck does a !! in java do
asserts non null
Kotlin not null assertion
and its kotlin
Yeah
basically it allows for NPE in worst case
Like look:
cookernetes idk
I removed an item, but in the PDC it is still there
ye sure
Oh? That's the one provided by "jeff_media"
not sure
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
question. Why dont you just make a extends inventoryholder class, and check on inventorycloseevent if the inventoryholder is of that class
by that
You don't?
Are you saying it could be an issue with the lib, or does my code just look dodgy?
Because in theory my code should be fine
no it could be the lib
but also ur code
cuz Idr if contents returns Array<out CraftItemStack> or Array<out ItemStack>
This is contents
let me look that uo
If that helps
CraftItemStack is an ItemStack derivative
maybe he means that bukkit itemstack is a nms itemstack wrapper
bukkit is an api to make mojang code easier to interact with
Thanks
instead of every single plugin only bukkit has to be updated in lots of cases
Yeah, I know
ah nvm it doesnt cookernetes
maybe try for testing sake
and use one of the standard ones
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/persistence/PersistentDataType.html for instance any of those
declaration: package: org.bukkit.persistence, interface: PersistentDataType
if it still does not work, then its probably ur code
How can I use a standard one for an item stack???
Are there other libs I can try?
@tender shard Do you know if this is a your lib issue or my code issue?
Are you able to show me the example 🙂
I think it's a me issue - but idk if the lib's ITEM_STACK_ARRAY type is borked
writing vexx
Yeah ok I'll try this library instead quickly 👍
database:
type: PostgreSQL
# ADDITIONAL stuff
settings:
password: ...
interface DatabaseSettings {
ConfigurationSection configuration();
}
interface Database {
void bootUp(DatabaseSettings settings);
PlayerTransfer loadPlayer(UUID id);
}
class DatabaseFacade {
Database delegate;
DatabaseSettings settings;
DatabaseFacade(Database database, DatabaseSettings settings) {
delegate = database;
this.settings = settings;
}
void bootUp() {
this.delegate.bootUp(settings);
}
CompletableFuture<PlayerTransfer> loadPlayer(UUID id) {
return CompletableFuture.supplyAsync(() -> {
return delegate.loadPlayer(id);
},executor);
}
}
class DatabaseFactory {
public DatabaseFacade createFromConfiguration(ConfigurationSection section) {
var type = section.getString("database.type","")
switch (type.toLowerCase(Locale.ROOT)) {
case "postgresql": {
return new DatabaseFacade(new PostgreSQL(),section.getConfigurationSection("settings"));
}
}
}
}
class PostgreSQL implements Database {
@Override void bootUp(DatabaseSettings settings) {
//load stuff
}
@Override CompletableFuture<PlayerTransfer> loadPlayer(UUID id) {
return CompletableFuture.supplyAsync(() -> {
//TODO
});
}
}
//onEnable
var factory = new DatabaseFactory();
var database = factory.createFromConfiguration(...);
database.bootUp();
heehee
Is it possible to have a plugin that lets you change the colour of an object? For example, you get a custom item called a canvas (just a white block), then the plugin lets you choose a specific colour which automatically gets the texture and changes its hue?
Or would you just need a lot of different model textures with pre-applied different colours?
just give them another color block 💀
?
white wool -> black wool
yeah but the canvas was just an example
I guess it's possible with resource packs
It's a more detailed model Im using, such as a vehicle
Yeah that's what I mean. So a plugin in combination with a resource pack, without having 100 textures in the resource pack. So the player can use the plugin to change the hue of the texture to anything they want
Probably just easier to have multiple pre-applied colours
Ok actually, I don't know what I did with my code @ivory sleet but now when I remove an item from the inventory - it removes all of the items, not just the one I took out of the custom inventory, from the PDC 🤔
@quaint mantle
just an example but ye
and if u wanna do it more dynamically, use a hashmap instead of a switch
does any of you know how does cpp templates work
i have a bitset
std::bitset<N>::reference
and i want to make a template
with N as a std::size_t
?
this server is for java/kotlin - specifically for spigot dev
I'd say go to the programmers hangout?
na
Oh?
any programming stuff is fine here
oh ok
its same as generic in java, just have template <typename T> T before your function
but like, its likely people wont know a pertinent answer yk
would anyone know why this is happening
but using func like:
template <std::size_t N>
void Bar<N>::foo(std::bitset<N>::reference ref) {}
errors out
chest emulation with pdc
(in a nutshell)
why would you use template if you already have type ?
For simple things such as custom foods and custom recipes, what's better: datapacks or plugins?
i want to have literal integers
you already know its gonna be size_t
its an outside class declaration
so would you know?
so thats during clickevent right?
and u wna update whether an item got removed or added
yeah
i just dont know how to declare this properly
when an items is removed: do something
and I'm trying to also remove that item removed from the PDC
I see
How can I make items not merge without turning item merging off
oh, can you have like
template <std::size_t N>
void Bar<N>::foo(typename std::bitset<N>::reference ref) {}
it probably doesn't work because cpp doesnt know that std::bitset<N>::reference is type
That's a good point, but I don't understand why this isn't working. I also need it this way so that it can be like a true chest so that if more than one people are looking at the items in the PDC via the inventory-style GUI viewer, it will update like a real chest.
uh oh Our mutual friend, Conclure, highly recommended you.
I need the true-est chest emulation possible
dude you're a lifesaver
that actually works
but im not sure why
Кто добрый человек
Кто добрый человек
yeah, my friend was looking for a dev or sth, so ye
екый о довек до
there isnt any good people here @quaint mantle
Шо
ah fair
because compiler will think std::bitset<N>::reference as an value, you have to explicitly tell that its type
well Idk, if event.clickedInventory.contents would display the recent change
I've seen a lot of people use ACF
Yeah that's what I'm thinking
since its cancellable
its stupid, but whatever ¯_(ツ)_/¯
Like I was thinking, is it even removed from the inv if it's just clicked/attatched to the mouse?
You know?
ok, but usually i dont need this keyword (except in template declarations), so it must be something because of that templated N value right?
yeah most likely because N is not type, but an actual value
i don't understand that completely too, but had same issue while ago
yeah cookernetes was thinking that too
@ivory sleet It'd be really helpful if there was an actual like itemMovedOutOfInventory event, but there's not 🤔
Or there is one, but it's for hoppers (and observers?)
yep it works
yea
when items jump between hoppers
Yeah
you saved me so many hours of frustration. thank you ❤️
I really need to fix this though or else this is gonna drive me absolutely fucking crazy 🤣
Like oh my
If anyone knows a way to reliably listen for an item being removed from an inventory, I'd be so happy
hmm Ican test sth rq
inventory click event
Ooh nice thank you
What I'm doing mate - but it's not reliable
Or I'm doing it in an un-reliable manner
how is it unreliable
#help-development message @mortal hare
Not actually the event
It's me getting the items after the event is called and something is clicked on/removed
How would that help
TL;DR - I am making a virtual chest system which basically has the following features:
/donate-itemscreates a temporary "inventory" attached to the player which also has a "button" in which when clicked, runs the inventory click event which stores the array of item stacks in a PDC stored on the world./test-show- reads all items currently in the world PDC, then makes an inventory like in the donate items command (minus the button) - and displays all those items in the array ("donated" by the other command)
Very specific, and is simple in theory but isn't in practice for some reason
english only
Нет
?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/
First time diving into MC Plugin dev. I'm using VSCode and following tutorials to setup my spigot plugin. Does the spigot-api dependency version have to match the spigot server version? VSStudio Maven/Minecraft plugin setup with version 1.15.1-R0.1-SNAPSHOT.
yeah like e.g. I am targeting 1.19.3 and mine in my pom.xml file is 1.19.3-R0.1-SNAPSHOT
full snippet:
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Cheers that's what I thought. Thank you!
can someone explain why this only removes one ladder instead of two
inv.setItemInMainHand(new ItemStack(Material.LADDER,inv.getItemInMainHand().getAmount()-2));
@ivory sleet you getting anywhere? 😭
Because, @ivory sleet I definitely don't think the contents are being updated/the thing is being taken out of the inventory - as I modified my script like this (in image) which is even simpler WITH an explanation and it's still not working
It just doesn't remove the items 😭
?scheduling
Hello, how can I throw all the inventory with spigot in front of me please ?
no my ide is mucking up
oh
get the inventory and pass the items to world.dropitems, also clear the inventory afterwards
Thanks👌
Get the user's inventory contents, then like player.getWorld().dropItem(player.getLocation().add(0,1,0), inventory_item);
Kinda thing
Thank you 🙂
TIL you can use in in kotlin for contains
yo wtf
this removes one item
inv.setItemInMainHand(new ItemStack(Material.LADDER,inv.getItemInMainHand().getAmount()-2));```but this removes two
```java
new BukkitRunnable(){
@Override
public void run(){
inv.setItemInMainHand(new ItemStack(Material.LADDER,inv.getItemInMainHand().getAmount()-2));
}
}.runTaskLater(plugin,1L);
???????
what in the world... it removes two even if the task timer is set to 0L
how do inventory work man
so clicked inv wont include updates from the click itself, aka depositing or looting
isnt java pass by reference? Couldnt you just update whatever inventory youre using when you change it?
then why do i call clone on vectors
What calls this? A bit more context couldn't hurt.
0L still means next tick, btw. You register in the scheduler, and it's earliest queue processing is at the next tick
its sure not cuz i want to type extra 5 chars
blockplaceevent
Okay, I guess I know why then, haha
the method is called additionally it doesnt replace the event tho
uhm what was the formula for degrees -> yaw/pitch rq?
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
cuz u mutate the value inside the value
like its still pass by value
Is there any solution then, @ivory sleet? And I really appreciate your help btw lol
I need to open my laptop, not gonna type this out on my small ass phone keyboard
something like 360 / or something
Pass by reference is a lie anyways, xD. You're always passing a value, but sometimes, that value is a memory address.
Like is there an alternate event?
I bet that the block place event saves the item in main hand before it's called, then calls the event and then, if not cancelled, sets the item in main hand to the saved item minus one. So no matter what you set it to in the event, it will be overridden to item - 1 afterwards. If you go into a scheduler of 1 tick (0L is still next tick), you effectively override this.
Isn't there a way to change the hand item through the event?
i mean maybe delay
by using bukkit scheduler
so just wait a tick then?
and then do it?
because it'd be better if there was like an after event
interesting
if you overwrite the inventory in the event the handler from the event itself doesnt run
turning the 2 into a 3 removes two additional items
How do I do it then? And will perf be shite?
And I can put that anywhere?
Hey guys, I need a way to "tag" a block or take note of it so I can do some custom logic on it when its interacted with. My initial idea was to use PDC, and store a bit that's basically a flag saying "Hey, this is a custom block". But blocks don't have a PDC :O. So then I was thinking I would just maintain a set of Block, and check to make sure the interacted with block is in that set. But THEN I found this old MetaData api, and figured I could just store the "tag" as a metadata value on the block, but this seems to be an old (and often abused) api. Any suggestions on which route I should go?
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/ using this little lib they do
Did you try it like this? What did that yield? I'm still searching through the CB code to find out how and when they decrement it, I guess experimenting would be quicker.
technically their stuff is then stored in their chunks pdc. but to you u work on a per block level
I mean ye, u're basically appending a function to the server which will be invoked next tick
well setting the two to a three removes, in total, three items. i dont know why but i dont need to know why lol
I did actually stumble upon this library yesterday. I was wondering if maybe this is overkill though, since all I need to do is store a simple bit to tag a block. Using the metadata api would also allow me to provide support for pre 1.14 versions. Hmmmmm.
Yeah this fucking works flawlessly
It's so dumb that I have to fucking do that though
well its your own decision then depending on what u need. but i would go for the lib
Yeah 1 million percent
I do see its a compile time dependency so it won't require another plugin to be installed, I may just go for the lib 😉
You guys are very helpful, thanks a bunch
can I move armorstands async?
AFAIK you can't even change anything about the world async
You can read a lot if stuff about it just not make changes
Ok well thanks so much @ivory sleet 👍
making async interact with the server is such a pain in the ass
well what I wanna do is basicly just move an armorstand, but it would freeze the main thread when doing that over time in a normal task
you need to make a queue of changes to be made and ensure you dont get race conditions
Uhm, alrighty, sounds great! xD
- 256 / 360
might be late
just woke upo
How would moving 1 entity freeze the main thread
not with that attitude
wait what? Never seen that one
bascially yaw and pitch are represented as a byte iirc
Are there a ton of hacks to do this shit async without changing the server?
can I yeet you off a cliff in async?
you can play with palettes async
I just wanna move an armorstand over time basicly lol
with reflections
Oh ik it's just not fun to do that
But ig
on that topic, is runtaskasync in the current or in the next tick?
Honestly if you want to have such fine control, you can play with packets async
You'd face exceptions
Async timer and then resync to move it?
ah seems like it would be pretty easy to bruteforce then
what do you mean with resync?
If brute force hasn't worked in the past it is only because you have not applied enough force.
- MagmaGuy, future leader of humanity, 2023
say that again and imma buy your neighbourhood
Brute Force: Allied Strategy and Tactics in the Second World War (published 1990) is a book by the historian John Ellis that concludes that the Allied Forces won World War II not by the skill of their leaders, war planners and commanders in the field, but by brute force, which he describes as advantages in firepower and logistics.Ellis describes...
not in this context
you didnt provide one
also i just realized you implied you would dare to touch grass
how could you
youre a coder
someone who understands it XD
Yaw and pitch are degrees, so dividing them by 360 will give you a number ranging from 0 to 1, which you then scale to the range of a byte by multiplying by 255. Yaw, for example, ranges from -180 to 180, resulting in a byte value ranging from -128 to 128 - a signed byte. Pitch ranges from -90 to 90, yielding -64 to 64. This conversion works, because the values are always <= 180. Otherwise, you couldn't interpret them signed.
I mean... the stack doesn't care about values or references, it's always going to be a value. It's about how the program interprets these values.
so I just use degrees * 256 / 360 in my code to convert the degrees to yaw right?
true
To convert the yaw to a byte, you meant, right? Yes.
I mostly manage my team nowadays
no, im converting degrees -> yaw/pitch
Yaw and pitch are already in the unit degrees? :-:
oh what?
Location#getYaw and Location#getPitch are values ranging from -180 to 180 and -90 to 90, respectively.
aint they doubles in .1 steps
Do you mean how to convert 0 to 360 to -180 to 180? xD
They are exactly what F3 mode shows you
ye
ok imma make this clear rq: If I input "rotate by 210 degrees", it should rotate by 210 degrees
why do you have time for this again
get your 2014 acoustic panels outta here
because I just finished writing the changelog and dunking on illusion was next on my todo list
mans so old his pic's in black & white
it is
ok I got the loop up, its ASYNC. Now, as.teleport is async tho
oh no he's gonna get caught
I was literally streaming this morning
I used to be paranoid like that when I was 14
💀
just because you have acoustic panels doesn't mean you're a youtuber
I'm not an assassin, I don't need my face to be unknown
no I am not a youtuber because I am currently releasing 1 video a year lol
You gotta make a sync call with bukkit scheduler
there goes your oportunity to say you've murdered the competition
So it syncs up
all my 'videos' are entries in a competition i really shouldnt have been in lol
I don't need fake online fame to cheer myself up, so I just don't upload stuff
I don't need online fame either, but I could use some advertising
new BukkitRunnable() {
@Override
public void run() {
as.teleport(new Location(as.getLocation().getWorld(), as.getLocation().getX() + xPT, as.getLocation().getY() + yPT, as.getLocation().getZ() + zPT));
}
}.runTask(LoopCityScript.plugin);
``` just like that?
IN my async loop?
Tbh, I'd need to test this myself, lmao. But isn't it just a case decision to convert between the two? angle if angle <= 180 else angle - 360. You should also make sure that you catch < 0 and > 360 beforehand and normalize them. Other than that I cannot provide much input, I'm afraid.
hmmm
O(n²) enjoyer ?
oh btw have you ever worked with databases?
whats the smartest way to make an npc move like an real player
We're talking about converting 0-360 to yaw, so how's either of that gonna solve it? You need to end up with a negative number in "half of the cases", but you're inputting a strictly positive one.
At least that's how I interpreted the question
have someone play the npc
Capture real movement packets, store, replay them, xD
great idea
yaw can be negative
Yes, that's what I was getting at
So how is yaw %= 180 gonna cover the cases where you're looking into negative yaw direction
if yaw ranges from 0 to 360, as that's what DaFeist wants to input
yeah but why tf aren't you using lambdas
you could shrink that code so much
tbh i also completely forgot u can lambda a runnable
wait is it just Math.toRadians actually lol?
Bukkit.getScheduler().runTask(() -> as.teleport(new Location(as.getLocation().getWorld(), as.getLocation().getX() + xPT, as.getLocation().getY() + yPT, as.getLocation().getZ() + zPT));```
because it looks 10x more ugly to me
Waat
Have you tried to just input the angle as is yet? Could be that due to the signed nature of bytes, this conversion is done automatically for you anyways. It would just be reversed, likely, as it's 256 to -256 instead of -256 to 256. But then, again, I'm rusty on that kind of topic. I'd just play it save by using my formula if it was me.
@ivory sleet Strannnggee issue - for some reason now when I add logic in the scheduler (highlighted in image) for managing items being put in it, it makes all of the other logic just not work... would you know why?
eh I have not tested anything(just building kind of an API around armorstands rn) but imma put a note there so I know whats wrong when it does not work
Uhh, im not at my pc but let me see if I can spot anything
💀 what
Coolio
In SS yeah I’m doing that
But under no circumstances should it modify the other logic
Like the one I tried for hours to do
Think of it as adding all the items in the other array to an array
But that’s really not the issue
Yeah but did u write it, or is it a std method?
Stdlib for kotlin
@ivory sleet do you know why it fucks up the rest of the logic!?
Like it shouldn’t
What do you mean
I’m checking if an item is added by checking if there’s an item in the inventory that’s not in the PDC, then I’m making a new array that consists of the old PDC items and the item that’s not in the PDC currently, then I set it to the PDC
I'm trying to create a brush that will "paint" a biome. This takes the biome given by the player and should change the blocks to the given biome, but instead just changes them to an ocean. Is there anything I'm missing here?
this.selectedBiome is the correct biome, I checked with a console log.
final double xSquared = Math.pow(x, 2);
for (int z = -brushSize; z <= brushSize; z++) {
for (int y = 0; y < 256; y++) {
if ((xSquared + Math.pow(z, 2)) <= brushSizeSquared) {
this.getWorld().setBiome(this.getTargetBlock().getX() + x, y,
this.getTargetBlock().getZ() + z,
this.selectedBiome);
}
}
}
}```
are there proper velocity docs ?
Would anyone else know?
Is there a way to check if player has shulker box in his hand, i mean no matter what color of the shulker is
if (player.getInventory().getItemInMainHand().getType().toString().contains("SHULKER_BOX")
anyone know how stop the countdown , if players in arena are less than in current players?
i have this check but ti does not work
How can i get the nearby players and entities like from 20 blocks away?
player.getLocation().getWorld().getNearbyEntities(location,20,20,20).forEach(entity -> {
});
you can use stream
Wither wither = location.getWorld().spawn(location, Wither.class); wither.setCustomName(ChatColor.DARK_RED + "Wither" + ChatColor.WHITE + " ( " + ChatColor.GREEN + "4000" + ChatColor.WHITE + " )"); wither.setCustomNameVisible(true); Attributable witherAt = wither; AttributeInstance damage = witherAt.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE); AttributeInstance health = witherAt.getAttribute(Attribute.GENERIC_MAX_HEALTH); AttributeInstance speed = witherAt.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED); speed.setBaseValue(10); health.setBaseValue(4000); wither.setHealth(4000); damage.setBaseValue(100);
I'm trying to set a wither that spawns at max hp of 4000 and has attack damage of 100 but it doesn't work in game and returns errors anyone know how to work with withers?
what errors
when I summon it in it says an internal error occured
basically it spawns a wither that says 4000 health on the bossbar
but it spawns with regular health and 1/3 hp
it counts player too? or only entities?
what?
?paste
Player is entity
can somebody tell what went wrong in the plugin? https://paste.md-5.net/bozitefiqu.md
a duplicate?
what?
there might be 2 of the same plugins present in your plugin folder
well it is not
you tried to do new Customthington() in your plugin at line 8
no i dont think so
or hes trying to create another instance of the main class? not sure if that can throw that error too
i did not create a new customthington
?paste your Customthington.java
one of yoru other classes also extends JavaPlugin
Only your main class can do that
btw this is spigot support server
you can do that yourself , do entity intsanseof ArmorStand
or smth
anyway ,
is there a way i can check if the task is canceled?
BukkitTask#isCanceled() ?
man i feel soooooo dumb
cmon
i've been working on bitwise operations
and wondering why that wasnt working
so i did two different algorithms
which only partially worked
turns out you just needed one, by executing it twice
I wrote that algorithm knowing that it would work for that case, but somehow i forgot that I can use it
and here I am, after 8 hours of sitting and wondering what's wrong
feeling dissapointed with my lack of intelligence for a such a simple thing.
thanks but that is not avvilable in the version iam working with
¯_(ツ)_/¯
what kind of api do you use
probably pre-1.8 lol
it surely exists in 1.8
pre 1.8 era minecraft versions are not safe
due to log4j exploit
iirc
that is why i say pre 😄
Come on, we all have days like these, xD. You don't want to know how much time I've wasted over stupid mistakes already.
1.7 with relocated netty stuff, lets go, xD
using 1.8.8
maybe you can use reflections
to find some private field that states if the task is active
inside implementation
too much work
is there taskid?
Bukkit.getScheduler().isCurrentlyRunning(taskId)
alr
does anyone know how to get bukkit.yml on a fabric server?
what iam doing is :
now if 2 players in arena , and one of them leave the arena , it will stop the countdown so this is fixed , but if the same player who left join the same arena again , the countdown will not work .
ideas?
if it doesnt find the task in the scheduler it returns false
Looks like they use a period of -2 as some sort of sentinel value to mark cancelled tasks. So checking it's period for < 0 should be the same as modern isCancelled
Yep, indeed
alright thanks 😄
The task has to be async, just saying
If not async, always return false
if task == null async statement check will not be invoked
You get false if the task is not async. Period.
Only issue is that this period value is not accessible through the API, it seems like...
if task is running and task is not async do the code nested inside else return false
where tf do you see that it would return false if task is async
False if the task is sync.
if task is not running it will return false
if you cancel it
the task is not running
Would anyone know of a cleaner way to write the following?
https://paste.md-5.net/ogoletetin.cs
And the section I am talking about is the one screenshotted as this (while scuffed) is the only way I have gotten my logic semi-working 🤔
a quick question: how do i give a player a tag and how to remove?
((CraftTask) task).getPeriod() < 0 means it's cancelled.
can I make passive mobs target a player
task != null && !task.isSync()
If the task is null, it will not enter the block and thus return false. If the task is not null, the second condition is resolved. The block again is only entered if the task is NOT sync, thus async. So this check only works for async tasks and will yield false for all sync tasks.
But it's completely useless to check if a sync task has been cancelled...
While the sentinel value comparison always works out
iam cancling the task here , so if the player join the arena again the task will be canceled
but its version dependant
so i need to make new task right?
It's not? The sentinel is -2L from 1.8 all throughout 1.19
You shouldn't access CB without reflection anyways. But that one reflective access shouldn't be too hard, even for beginners to reflection.
Hii, do you know any good tebex theme for free?
Hello, I have a problem that the connection breaks down after a while and "?autoReconnect=true" doesn't work eithertxt [08:31:17 WARN]: com.mysql.cj.jdbc.exceptions.CommunicationsException: The last packet successfully received from the server was 33,554,299 milliseconds ago. The last packet sent successfully to the server was 33,554,299 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. ```java
con = DriverManager.getConnection("jdbc:mysql://"+data[0]+":"+data[1]+"/"+data[2]+"?autoReconnect=true", data[3], data[4]);
Sorry for shadowing your questions, I'mma be silent now, xD.
its oky , i was hoping to get a fix xd
well you're kinda right for async tasks, cancelling the task wouldnt immediately shutdown the task
thus there's a risk that it would still find the task in the scheduler
hey slightly offtopic, is there a quick and easy way to encrypt a string (a mysql database connection link) without having to obfuscate my jar?
You asked how to check if a task is cancelled, that's all I can currently help with, sorry. I really need to work on a project right now, so I cannot get into the mindspace of your project. I could only provide a solution for that. If it's about some state machine or on how to architect things, I'm currently not able to provide help :/
because i'm trying to create a connection without people decompiling and logging into my db
alr no worries i think i fixed it .
are you using Spigot API or the buildtools version as the dependency?
no db should be publicly accessible
If your plugin knows enough to access the DB at runtime, anybody can hook into that information and access it too. Impossible request.
If it's about logging, send the logs to your server through a socket, then access the DB there.
My guess is you are trying to implement some authentication system for people who have purchased your plugin. Not allowed on premium resources
easiest way to do this imho
is to not do it
LOL
@eternal oxide
https://paste.md-5.net/ogoletetin.cs
Would you mind taking a look at my code and this section and telling me if I can do anything better?
kotlin :O
Not touching kotlin whith a 10 foo tpole
To improve your code you could write it in Java
It's more maintainable in Kotlin
?
no
no it's not
That's the pastebin one
What do you mean?
The industry is settled in java

