#help-development
1 messages · Page 1986 of 1
Yeah, the array object itself is a memory block
Just like in C/C++
Thats also how you would use an array in C++
^
each is, in multidimeniosnal they can be different
multidimensional is array of array though
Or array of pointers that point to arrays better said
Some languages may squish it down to a single array, but java for sure is not one of these langs
anoymous arrays are also not conventional in other languages
I am getting this weird error using 1.18.1 nms trying to make a custom villager entity, 'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
how are you getting Insentient with a villager?
idk
You should be using mojmap
I am doing public class CustomVillager extends EntityVillager {}
Basically the method names have changed
if i set a perm to a player with a permission attachment, how do i make it so commands change with what is available to them?
how?
and why would this not work?
it does work, but your code is invalid
give me aan idea of a library
but its so efficient
eh, it'S always been like that
Scary
it is pretty inefficent. Valhalla is going to improve a lot there
Nah. >= 16 or so is fine
Newer versions are chock-full of crazy features
java lib to create a javadoc website based on the implementation (no annotations, figure out what the code does)
hmmmmmmmm vectors
I miss using Java regularly. I just have no reason to use it
What’s their purpose?
what the fuck
multiple calculations at once
the fact that java.util.Vector exists is confusing
that it was missing for so long is odd
basically same speed as doing 2 * 2, but you can do it 8 times within the same clock cycle iirc
frames without proper vectors is a mess in 3d space
just loosely figure out what it does
like
"returns a new instance of X"
thats useless
that isnt even a documentation
attempting to equal doxygen - where you document and extract your comments and accesses automatically while you code
anyways, this?
anyone has a library idea
you using luckperms?
So… multithreaded computing
no, permission attachments, its a spigot api iirc
no
guys i am new to spigot, I'm running setCustomModelData on an item but it's not doing anything ingame, i think i saw someone say there's another step i need to do to make it work
then it should be in annotations or plugin.yml
oh jeez, i am giving players perms
a permission management plugin
i need to figure out how to make players SEE the commands they can use
= atomically
because rn they show up in red
Isn’t that the whole point of a cycle? To do at least a part of an operation a cycle?
How are you able to run multiple in the same cycle? I’ve heard of instructions taking multiple cycles to complete
oh thats a whole different ball of insanity
But vectors allow to do larger computations atomically
i don't exactly remember, ill send you a link to a vid that wa smade
I’m also not terribly familiar with how processors functions
At least REAL vectors
you use proper math
are you guys helping someone
Nope
this channel is help channel
Meh
Is it more like alternating between multiple things real fast inside that cycle? Somewhat like uhhh
can you move it to general or something
For example adding two int arrays together to get another int array can happen atomically in a single cycle
i can't ask for help here
Why not
Sure you can
yeah i did and it got swamped with your convo
Create a thread
not really
@rough drift there is a big mess around displaying commands and how the client interprets them
Context switches. That’s what I was thinking of
sadly that's the only way to get attention
Sounds like context switching inside a cycle
My bad 😅
welp, protocol lib it is
what is context switching?
Okay, I'd say no after reading the first line from wikipedia
In computing, a vector processor or array processor is a central processing unit (CPU) that implements an instruction set where its instructions are designed to operate efficiently and effectively on large one-dimensional arrays of data called vectors. This is in contrast to scalar processors, whose instructions operate on single data items only...
vectors do not have a fixed point like coordinates do
wha
its hard to explain if you dont know what frames are
Frames of relativity (or however you call it in english)?
frames are the coordinate holders for teh vectors
Very interesting
vectors can be infinitely massive (though have a defined size) blocks of data
Are you talking about vectors in spigot?
arrays for example are more or less vectors
The spigot vector is a physical vector. Which basically contains direction and a value (force for example is a vector)
Ah
However mathematical vectors are just arrays
vectors in programming, frames specifically are used in 3 dimensional flight and space for aircraft and robotics - as they do not have a fixed reference coordinate
In physics I have only heard about frames in relation to relativity
so the frames reference each other for the vector orientation and you use the frames to reference in real space
two frames will give you a orientation and possibly a height, 3 frames will give you movement back and forth, 4 and 5 will give you diagonals
So… mutable relative coordinates? I think I understand a bit better but I don’t see the point
Oh I see
so you manipulate the frames or virtual space
this is where vectors have a huge amount of power
you are not running huge amount of calculations to get coordinates over and over, that data is mostly useless
you only want the vector scalar in the frame
the frame only periodically changes
so you put that in minecraft, your players and entities suddenly drop from thousands of calculations to a few hundred - you know the player is moving forward, there is no need to check/poll unless it is interrupted
One simply moves the proper frame and deals with whatever else the player might be doing
ah yes.. Frustration at its finest level
/// <summary>
/// Thanks to some idiot at Mojang
/// </summary>
private static int DataSlotToNetworkSlot(int index)
{
if (index <= 8)
index += 36;
else if (index == 100)
index = 8;
else if (index == 101)
index = 7;
else if (index == 102)
index = 6;
else if (index == 103)
index = 5;
else if (index >= 80 && index <= 83)
index -= 79;
return index;
}
Use a range map from guava
no idea, i saw it on wiki.vg/inventory
guys on an inventoryclick event, if the type was drop then .getCurrentItem() returns the item stack the dropped item came from. i'm trying to modify the single dropped item if that's possible
is it possible? if yes how do
modify how?
based on the fruit conversation earlier you would need to modify it before dropping it
ok
the problem i've got right now is pressing q on the item stack will change the custom model data of the dropped item, but it does it for the stack it was dropped from too
is this unavoidable
you did drop the whole stack ...
no i didn't ?
oh wait i miss read
this is good idea, if there isn't another solution i will do this
you only threw one item from teh stack
ye
and it's changing the model data of the whole stack
thank u zack
:V that has a getItemDrop() method
that might work :>
question if i want to make custom armor with custom textures how do I add the textures can I just drag the .png files into the IDE im using? (using intellij)
guys i have finished my first plugin :))))))))
Thats so cool, congrats here is a cookie for you 🍪
@quaint mantle for plotsquared— if i modified it and added a class inside, does the license on plotsquared require the class we added to have the header?
i think ur a plotsquared dev
i think
I mean it is
dont u see what it's doing
3d hat models
!!
:)
:))) my own server is now running my own plugin im so cool
Feels nice, right? 😄
@EventHandler
public void villagerCareerChangeEvent(VillagerCareerChangeEvent e) {
System.out.println("village career change event");
}
nothing in console?
i registered the event and im placing lecterns next to the villager
they change outfits
I'm not too familiar with scoreboards, but why does a scoreboard objective have more than one entry (score), I thought they have 1
the objectve is the top bar
the title
the score
is the text
you can set a scoreboard score to a number
what does the "top bar" mean
Did you register the class
An entry is like, your player's name.
like where is the score entry in the leaderboard objective command
ohhhh
sick
thanks
yes
i registered the events
also the LootGenerateEvent isn't working
it just doesn't work
every other event in the class works
except these two
i think it might be bugged
If im trying to get a material from a item name in this example an arrow, I'm calling Material.getMaterial("arrow"); but it seems that didnt work so I tried the adding the minecraft: namespace and that also isnt what it wants. does anyone know what exactly im supposed to pass to it?
Im reading from a config, so that wont work in this case
I'll give that a try and let you know if it works
Can anyone tell me, why there is no Enchantment.FORTUNE ?! https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/enchantments/Enchantment.html
#help-development message search can
ohh 🙈 haven't thought about that ... will do next time
Thanks anyway 🙂
That worked for me zacken thanks!
how can i check if the type of a config value is a specific type?
is it done using
if (getConfig().get("path") instanceof Boolean) {} for example if i want to check if the type is boolean?
basically adding an extra protection step so if any admin accidently changed the config value to an invalid value i can detect it
getConfig().getBoolean(path)??
Why the heck need to check if something is a boolean??
anyone know if i can check if a player is laying down in a bed
right now i have stuff on PlayerBedEnterEvent but it triggers if a player right clicks it and its day tiem
tysm
thank u
Howe woudl i use Function<Supplier<T>, T> with Suppliers.supplierFunction()? So then i can pass a Supplier<String>, execute a void and then return the string of that function executed
how could I create a shapedrecipe that requires multiple items to be in a single slot? For example, invisRecipe.setIngredient('F', Material.ITEM_FRAME); How could I make it so this required 8 item frames?
spent 4 hours trying to figure out why my enchantment book anvil filter didn't work and then i realized enchanted books store their enchantments differently
all that time wasted just to make "flaming boots" incompatible with frost walker lol
lol rip
You should be able to create the recipe then use the PrepareItemCraftEvent to see if there are the correct amount and cancel if not
declaration: package: org.bukkit.event.inventory, class: PrepareItemCraftEvent
how common is it for plugins to iterate through a player's entire inventory?
i don't want to do that because i am worried it will cause lag but if it's quite common practice then hooray
why are you thinking of doing it? there could be better alternatives
how would i get the item a persons holding on the block place event
im trying to cancel players placing certain items
gizmo what i'm trying to do is find any items in a player's inventory with specific custom model data
how common is it though, to iterate through a whole inventory
all of the Inventory methods called like "contains..." iterate internally
so ya, pretty common i'd say, but how often are you planning on doing it? i'd think the frequency of the iteration would have the most significant impact
yeah i wanted it to be infrequent
for example, probably not a good idea to do it in PlayerMoveEvent
i'm going to do it every time an inventoryclick event triggers in a specific slot
which is fairly rare
i wouldn't expect that to be too much of an issue
oky :)
How I can check if player is on ground?
This is buggy in most cases, it can dupe items if you're trying to use stacked item recipes
But instead use craft item event and scan the matrix onced u clicked the result item
PrepareItemCraftEvent is for removing the output if there aren’t enough stacked items
public class InventoryClose implements Listener {
@EventHandler
public void onInvClose(InventoryCloseEvent event) {
event.getPlayer().sendMessage("test");
}
}
I have a code that sends a player a message in that event and i have registered the event in the javaplugin class
but it doesnt seem to be firing
when i close inventory it just doesnt send the message
What inventory
public class Core extends JavaPlugin {
@Override
public void onEnable() {
INSTANCE = this;
getDataFolder().mkdirs();
saveDefaultConfig();
getServer().getPluginManager().registerEvents(new InventoryClose(), this);
}
only concluded the main method to not fill the chat up
onenable method**
wat eror
nvm i got it to work
I had a previous code that checked for whether or not the inventory being closed is a holder of some class I made
i think i was checking the wrong way and stopping hte code before sending the test message lmao
how can i cause an explosion that doesn't harm terrain but harms people/monsters?
(in minecraft)
nevermind i found it
Sorry for using the translation.
I created a custom item using ItemStack.
Implements Geyser for cross-play with Bedrock.
I want to apply a texture to a custom item, but the resource pack method was only valid for Java users.
For Bedrock user, is there a way to import textures directly from the plugins folder into the item?
Doubt it
Anyone know why when I launch myself upwards its so much more dramatic than when I go forward on an angle?
how do I make a custom ban message
do I have to not use Bukkit's ban list and instead just kick the player if they try to join
Because there's no friction with the ground when you're moving up
PlayerLoginEvent and use setKickMessage
Or disallow(Result, message)
i saw some forum saying to use onAsyncPlayerPreLoginEvent
should I?
whats the difference
ok here lemme try to explain
I'm banning the player using this
Bukkit.getBanList(Type.NAME).addBan(player.getName(), horseman, null, "ApocalypseModeration");
player.kickPlayer(horseman);
where horseman is a string
However I want that same string to be used as the custom ban message
if they try to rejoin
You can use AsyncPlayerPreLoginEvent, that might actually be better.
Just set the disallow message to whatever horseman was
wdym disallow
what is that method
It prevents them from joining
oh
@EventHandler
public void onAsyncPlayerPreLoginEvent(final AsyncPlayerPreLoginEvent event) {
if (event.getLoginResult() == AsyncPlayerPreLoginEvent.Result.KICK_BANNED) {
// event.getName() is the name of the player
String banReason = "You have been banned, this is a test";
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, banReason);
}
}
ok look here's what I have
problem is
i want banReason to be whatever horseman was
You'll have to store it externally
damn
speaking of
what's a good way to store data like this
should I be using a huge yml file
or some kind of database like sqlite
hmm ok
A proper database like Postgres may be hard though
because it’ll require the user to install it
I’ll just use sqlite then
also what if I set an expire date here, is it possible for me to fetch that later?
or do I have to store that as well
m!
okay
thanks
Store it as well, if you need data after restarts, your only choice is external storage.
is there an event that handles natural/mobspawner mob spawning?
i want to make monsters stronger
there's EntitySpawnEvent but i don't know if it distinguishes between natural/mobspawner spawns and artificial spawns like spawn eggs, etc
nevermind, i found "CreatureSpawnEvent"
Yep
i'm loving java
Apparently SpawnerSpawnEvent is also a thing, if you only need spawner mobs.
false
and im pretty sure you can modify their src but not publish it as your own
like an unpublished fork
It's under GNU General Public, doesn't that mean they can modify and release it?
I'm not sure tbh but you can definitely modify it
depending on which flavor of gpl they also need to open source it
ya
and oops, i remember now, lgpl is the one that doesn't always require to also make source available
Licensing is confusing 
gpl means source must be public
im glad these summary things are a thing though, otherwise it would be hard to keep it straight
It always throws me off when there’s another Gizmo in the mix
lol
how do I stop a scheduleSyncRepeatingTask?
Use runTaskTimer() instead, that returns a BukkitTask, and then do cancel on the BukkitTask object
ya do that, or alternatively the tasks can cancel themselves under some condition, or you can cancel them via the int id that scheduleSyncRepeatingTask returns.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/scheduler/BukkitScheduler.html#cancelTask(int)
is the cancel method that takes the int id
No point in using that int though if BukkitTask is a thing
is there a way to cancel it if a condition is true?
cant seem to cancel it without being initialized
ofc, im just providing options, some options make more sense in certain cases depending on how the rest of the code is set up
You can run the cancel() method from within the runnable
Just have your condition there
how do i make that only a certain item has a custom texture I know custommodeldata exists but I tried it and it only works with 3d models and not like pixel items yk
new BukkitRunnable() {
@Override
public void run() {
if(true) {
this.cancel();
}
}
}.runTaskTimer(plugin, 5, 5);
You can do this
It works with pixel items, it's all dependent with what the resource pack is doing
runnable.cancel(); seems promising, ill try to see if it works
and it doesn't work with entities/armor
The model can just be a generated model for your 2d texture
i love having to use leather armor as a base so i can kinda communicate what the custom armor is to users who don't have OptiFine
how would i generate it?
please mojang
{
"parent": "item/handheld",
"textures": {
"layer0": "item/whateverpath"
}
}
follow the data structure in the assets directory
okay thank you
This is the format for model jsons
for a regular item not wielded like a tool or weapon, item/generated
for a tool or weapon, item/handheld
works as expected. thanks
armormodeldata pls mobang
I assumed they were doing like a sword or something
how dare you
What's the difference between generated and handheld
¯_(ツ)_/¯
generated makes it show up in your hand not at an angle
also i wish they'd fix attribute text completely getting rid of tool/armor/weapon text instead of appending it
like if you're holding a feather or ink sac
Generated makes the item like, the normal way non tools do

look at yourself holding a weapon and then look at yourself holding a feather
Y'know the thing, its the way you would hold a diamond
yep
Ohh yeah okay I see the angle change now
custom model data for armor, shields, and properly on tridents would be amazing
Its possible through optifine RPs
yes
i saw someone do it for shields but it couldn't use the banner patterns
well, and the fact that items don't support custom durability so i have to use my own
this doesnt work any1 knows what's the issue ?
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/dragon_scale"
},
"overrides": [
{
"predicate": {
"custom_model_data": 999
}
}
]
}
Your predicate value literally only defines the custom model data value
Yes I know, your RP is just saying to override the whatever item when it has the value of 999
But you never say to what model
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/iron_nugget"
},
"overrides":
[
{ "predicate": {"custom_model_data": 3636008}, "model": "custitems/heart_locket"},
{ "predicate": {"custom_model_data": 3636009}, "model": "custitems/totem_of_vengeance"}
]
}```
it should look more like this
without the bottom part, if you're using only 1 item of course
I see thank you very much
I see that you're overriding the normal texture for the item you're replacing
You're replacing the base texture with that, not the custom model data one
the custom model data number doesn't matter though (has to be shorter than 8 digits i think), i just used 3636
it can't be 0
alright
i mean it does matter so you can identify the custom models, but 3636 is just a random number i chose lol
just tried this and it doesnt work
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/prismarine_shard"
},
"overrides": [
{
"predicate": {
"custom_model_data": 999
},
"model": "tutorial:item/dragon_scale"
}
]
}
do you have a model json for the dragon scale
example for the heart locket that overrides the iron nugget file:
well it redirects to the texture
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:custitems/heart_locket"
}
}```
I made a generation tool in Java for this specific task a while ago, im not sure if that'd be useful to you
what is that is that what the other json is suppose to redirect to ?
Thats what your model json should look like
then what is this?
This should be an entirely custom file
(Vanilla model) -> (Your custom model) -> (The texture)
I'll try that
this is how my resource pack is structured:
i have a "custitems" folder in my models and textures folders
the custitems folder in the models folder has the custom model jsons, and the one in the textures folder has the custom textures
How do i get a chunk's local difficulty?
A chunks local difficulty? Do you mean a worlds?
doesn't local difficulty take the inhabited time of chunks into account?
at least according to the wiki
I have no clue what you mean by this
they do, the more time to you spend in a chunk, the harder the mobs get
That is the first time im ever hearing of that
you could getInhabitedTime(), that's really it
but there isn't anything about difficulty it seems
also local difficulty seems to be broken in multiplayer
only goes up to like 3 or 4 instead of 6.7
it depends on the world difficulty
I know
One of the old worlds from past iterations of my survival server was at least 2000 in-game days old, and the local difficulty always stayed near 3
Regarding this question I asked yesterday. I wasn't thinking clearly when I initially asked. It turns out that whether I use the player's uuid, or the cooldown name as the key, I will have to iterate over a list regardless. Unless someone has a way to do this more efficiently, is a complexity of O(n) really that bad? The only data involved is a uuid, a string, a long, and an integer.
My other issue is that I'm now wondering what the key should be. Should I have the cooldown name be the key or the player's uuid?
I wasn’t here yesterday, can you elaborate what you’re trying to do?
Looking at that, with your current system you should store by UUID as the key
Because what if multiple players have the same cooldown?
But personally, I'd just store whatever cooldown in the players persistent data container
Or, the metadata
Metadata would probably be better
I'm working on updating a cooldown system. I currently use this: https://paste.md-5.net/facunipene.java
I want to expand the functionality to allow for multiple unique cooldowns instead of using a blanket cooldown for everything.
That's why I looking into using a MultiMap.
And T are your different cooldowns?
Should really just store the cooldown inside the player
T is whatever object type they're using as the key
Which in my case is the UUID.
Would the PDC allow me to set multiple unique cooldowns?
Then why not use UUID
Yes, you can add more than one identifier via your plugin into the players persistent data
But if its temporary and you dont need it to save across server reloads or anything, you might be fine with using the metadata
Oooo, that's an interesting approach. I didn't even know that was part of the Player object.
Ah, so there is an issue with using player metadata. If another plugin uses/sets the same string/key, problems can arise. While highly unlikely, it's an edge case I just really don't want to worry about. The PDC could work, it's just that I don't really need the actual persistence. 😛 I did find a way to achieve what I was originally wanting, but it feels a little jank.
Current Solution: https://paste.md-5.net/jamagekexa.java
why not make the plugin name part of the metadata key?
Because there are plenty of plugins that are named similarly to mine. (Hugs)
Again, extremely unlikely, but an edge case I don't want to worry about.
The PDC has a JavaPlugin parameter, nullifying that problem.
So for the time being, at least to me, it looks like the better way to go.
is there a way to still have comments in yml files with snakeyaml
not with bukkit's yaml api
Comments are saved by default if you use 1.18.1+
1.18.1 plugin
comments dont save
ok I will try that out
ok yeah It didn't work
this is kinda how I have it in the resources folder
this is what I get when the plugin runs on a 1.18.1 server
the plugin IS made for 1.18.1
no errors in sight in console
I'd recommend trying that first.
no difference
Have you tried with spigot specifically? I can't speak for paper as I don't use it.
How are you saving your config? Can you share more of your code?
literally just this
You can just use #saveDefaultConfig(). It writes your file as is to disk. You don't need to copy defaults.
You will want to use #saveConfig() when you make changes to it with #getConfig().set()
The bug that existed for years was when you called #saveConfig() it wouldn't save comments. However that's been fixed with recent updates.
#saveDefaultConfig() has always preserved comments.
i'm confused
org.bukkit.plugin.IllegalPluginAccessException: Unable to find handler list for event org.bukkit.event.player.PlayerEvent. Static getHandlerList method required!```
did you put the @ EventHandler line
yea
did you register the listener
that line is literally the one that throws the error
Bukkit.getPluginManager().registerEvents(new Protection(), this);```
have you registered any other listeners in your plugin
some
do they throw errors?
not at all
show me the others
When are you registering the events?
^
Any reason why the method is static and getting an instance of your main class instead of just running the function in the on enable?
no i'm not
thats why this registration throws an error 
i never saw that error in my entire life
in my 3 years of spigot dev
https://www.spigotmc.org/threads/unable-to-find-handler-list-for-event-org-bukkit-event-player-playerevent.37930/
ah, now that's something interesting
You can't register PlayerBucketEvent, you have to use one of its sub events.
nice, didn't knew that
Yeah
Same applies to PlayerEvent, Event or any event derivative which does not expose a HandlerList instance in principle
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getItemMeta()" because the return value of "org.bukkit.event.player.PlayerInteractEvent.getItem()" is null
java moment
what do you expect converting air into an item
in what version did you make that screenshot
1.18.1
Ye that’s normal I believe
lemme try in singleplayer
yea...works fine
huh
your minecraft knowledge just sux 
that error should get removed
air IS an item
apparently tho, it just does nothing lol
is there a way to make custom items ie armor with custom textures without use of a texture pack
hey guys how do i retexture the game without retexturing the game
hmm xD true
Client mod perhaps
you can edit those items in the server jar (theoretically) and in your client-mod
and then, technically those textures are not in a resourcepack lol
yea cuz i think its on forge u dont need a custom texture pack if u wanna make custom items so I was wondering if there was something similar
tru
forge mods are loaded on your client
which renders the shit
ahhhh
the server doesn't have anything to do with any rendering
ah ok
so no, without server resourcepacks, it's afaik not possible
ok ty!
Learn sql
@trail pilot I mean give it a week or sth, should be enough to obtain adequate knowledge
jdbc is pretty simple to use
Another db thing u can use is h2, I havent personally used it before but it can be used as a local database, so you dont need to host one
Development logic at its finest
https://cdn.discordapp.com/attachments/667469412776804352/943931483482120262/unknown.png
what's the best way to check if a block is glass? Do a EnumSet from blank glass to a differnt glass and call EnumSet.contains(Material) ?
endsWith Glass?
That’s gonna be somewhat sloppy
And for instance glass pane does not end with GLASS
And so, if you wanna check that you might need to pull a String::contains
However that would generate other issues, as all materials that contain the label glass would yield true
Maybe there's a tag for glass
you can provide some checks
there arent that many items with glass in it
Well at most it’s just so much easier to use an EnumSet and faster
only spy glass, and a glass bottle
there's not i checked
well ig
I have a question about threads and runnables, is having every runnable on a new thread okay?
Ugh
I'm not the best with threads
you cant modify stuff from anything but the main thread afaik
Use a thread pool
You probably wanna lean towards a fixed thread pool or cached thread pool
Yeah, thats what I thought, thank you
There are certain things you can modify asynchronously
As of now, but that won’t scale very well in conceivable versions
How I can check if player is on ground?
Do you need to cache when dealing with data and redis or does it not really affect performance?
what type of data?
Queues, player stats
And for redis in principle no, redis is ridiculously fast, but it might be to your benefit if you did that such that you can make your data model loosely coupled from redis if you in the future would change implementation
how do i check if a block has an inventory or can open a GUI?
and GUI?
?
a crafting table aint holding a inventory
p#openInventory(inventory)
I mean if it has a container, then its always open-able
No moterius
But that’s because the crafting inventory is a special case
As you’re firmly aware of that crafting does not need any persistency data
Thus its actually not a container that belongs to any specific block
And fyi HumanEntity::openWorkbench works everywhere almost
How can I achieve to remove all NETHER_PORTAL block material in an area and then restore them back on after several seconds, I want to do this because I want to prevent player from stuck in a nether portal.
making a work-around for that seems entirely too complicated... i want to only trigger my onPlayerInteract event if they normally wouldnt do something else
like
opening a crafting bench or chest, or flick a lever
Opening a workbench inventory and opening a chest inventory is different as already said
workaround it is
Alr good luck
Cache the coordinates and then after said interval you iterate over the coordinates and set the material back
can i serialize a chest
By simply set the material back to NETHER_PORTAL?
You can pretty much 2hex
Yeah
Might have to save the data and state
In case you wanna restore that as well
Best of luck
conclure do u think its worth to make a library for it
its simpler than with entities so probably not
Depends, but perhaps
btw if u know, can a 1 block structure hold a entity in it
Like, creating libraries usually enhances your pov in regards to the consumer of the library thus your code infrastructure might become more robust (:
1 block structure?
Indeed
uses 3 blocks
Ah
but for stuff like ravengers or what they were called
i cant make a whole big ass chunk
ill just check if it works with 1 block
Lol yeah
I’m not very familiar with features and structures sadly, never got to that point when working on my fabric mods
and cool thing i dont use any nms
😌 abstraction
but not many know about structures api
i know how to spawn one but that's about it
How can I get all of the location of the nether portal block?
I have a feature that you can create portals in any shape.
Yes zacken but that’s merely for glass pane
that probably needs custom implementation
then
make like
actually nvm
Do I need to get like relative block on all sides?
i wanted to say check block relatives
Yeah
EnumSet.range(Material.WHITE_STAINED_GLASS_PANE,Material.BLACK_STAINED_GLASS_PANE)
contains every glass pane except GLASS_PANE (the uncolored one)
same with normal glass
the check isnt that hard
tahts cool
Aglerr you probably wanna set an upper bound in terms of how big the parameter can be
And then get the relatives, and if a relative happens to be the initial block then you got yourself a portal
Might be some edge cases but that’s the gist of it essentially
wait a sec, how fast does PlayerInteractEvent trigger
1/tick when holding right click?
Myes
It has a 20 tick accuracy
im doing a once per tick on PlayerIntearact function setting the player's upward velocity to 0.1
Tho iirc it can be invoked more than one time per tick
issue is they dont move up
But the accuracy won’t be better than what the server ticker allows it to be
they hop up and down
anyone has code suggestions:
https://github.com/2Hex/EntitySerializer
Like code review?
ye
I mean I’d avoid all the static to begin with
But that’s not really an issue for a spigot dev who just makes plugins for fun
Why tho
imma test if it really is once per tick
Because it makes your code tightly coupled basically
so he's supposed to make an object?
When you set plugin does that set a static variable? I imagine that could cause issues
Also the api doesn’t look very abstracted but yeah
it triggers twice per tick (prob due to some uncaught thing i didnt notice) but it does trigger per tick. Can setting upwards velocity to 0.2 twice per tick cause issues?
yea
What issues though
i mean
What happens if multiple plugins reference use it?
shit
But that’s like, not your fault if it happens
but like
The static there is evil due to its vulgarity
its not a library u add as a plugin, so i dont understand why its a problem if many plugins use it
(In terms of design merely)
2Hex yes I assume people are going to shade and relocate it
Lol nw
so
To not interrupt main chat
I should not make those setters and getters static?
I’d just have non static variables
Then the user can create multiple instances of those if they want to
They’d also be able to use the class in their tests much easier
Nevertheless would the user also be able to control destruction and creation of the instances at will (easier than what’s done with the usage of static)
uh
not cancelling PlayerInteractEvent causes a 4-tick delay on the next one
so in conclusion i should make it required to construct an object in order to use the library
Can I check If a task is already running?
Keep a track of id or bukkit task object
Ah okay, there is BukkitScheduler#isCurrentlyRunning, thanks
Is there a way to check who placed a block, or do I have to store that when it is placed?
latter
i suggest storing a HashMap<Location, UUID>
np
its... volume
ok lol
The volume increases the range at which a sound can be heared. It can appear more silent for distant player but will never surpass 100%
So for 122.5F the sound will sound the same for a player that 10 blocks away as well as for a player thats 100 blocks away.
Negative values will be heard across the world.
Heyo,
Are there any ways to send custom-font-ed messages as titles?
I know I can use components in chat for custom 1.16+ fonts but not too sure about titles.
That is good to know
Why is that not in the docs?
how would i go about making a bedwars villager shop gui like hypixel?
Well you'd need to know how to make a GUI first
I recommend looking at the wiki
plugin ideas for beginners?
The bottom of this page also includes some links to libraries you can use: https://www.spigotmc.org/wiki/creating-a-gui-inventory/
oki thanks
just some simple stuff so i can practice plugin development
Implement a multithreaded HTTP webserver ;) /s
Ooh yeah that could be a decent beginner project
Just make sure you use a version that supports PDC (PersistentDataContainer) or you'll have to do a lot of shit manually.
and giving the player items of the same name with different ID's. Though I don't know if items still are like that in the game. For example in the past wool used to be like: wool, id 1; wool, id 2; wool, id 3; wool, id 4;
Ye item IDs no longer exist/are deprecated
They were removed in 1.13 w/ The Flattening
Instead it's more like green_wool, red_wool, etc.
technically mc still contains numeric ids somewhere
i remember seeing a hashmap of string id -> numeric id
we shall access that hashmap from now on
don't remember where it is tho
i was surprised that stone had an ID of 1 though
like when you think of Minecraft you think grass block
I believe dirt is 0
that's air
but stone had the ID of 1
oh
I mean it makes sense actually
wool is 13
since stone was the first block to be added to the game
oh
air was tho
air isn't really a block imo
back when minecraft was still newer
and there werent as many things in the game
like 1.2.5
I still type //set 98 if I want the stone brick
i mean, it was easier to get all the blocks
so I like that they ended up making IDs much easier to use
just use a for loop
and they ruined server performance 😠
good point
whenever you type an id it goes:
string -> string to index map -> blocks/items
which uh, is not the greatest idea
since:
- All blocks have string IDs
- Blocks no longer have variants, e.g. different wools are different blocks
- Brigadier actually autocompletes block IDs
now i wonder something
I was never able to remember the different wool IDs lol so
red_wool is much more straightforward to me
also this system has better extensibility
spigot is sending commands as a single label with a greedy string, why not just... allow parameters?
no more overlapping IDs from mods :)
also theoretically you wouldn't need stuff like NotEnoughIDs just to increase the limit
Because that design decision was made by Bukkit before Brigadier existed
why are enchantment names so weird?
And Spigot doesn't really touch a lot of the stuff Bukkit does
ohk
im assuming DAMAGE_ALL is sharpness
yep
Uhh yeah probably
but why DAMAGE_ALL
and iirc DURABILITY is unbreaking
maybe DAMAGE_ZOMBIES
but we say sharpness, not damage all
for Smite
spagit
spaghetti code :)
yas
I signed the CLA a while ago yet I have not contributed to Spigot in any way
CLA?
we will give em the bonk
?cla
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Oh ok
im just going to presume the enum->block mapping is a bit more efficient than the command version
now i just want to finish my command lib and send it lmfao
its basically a lib to abstract away all the boilerplate/annoying stuff
like figuring out which sub command to run, what the arguments are, are there optionals? etc
you know a thousand of solutions already exist
ig
Why did I get a lot of messages from a task even tho I only run it once.
if(this.getRemainingTime() == ConfigValue.PORTAL_WARN_ON){
Common.sendMessage(this.player, "&cThe portal will be removed in 5 seconds");
return;
}
Full code
PortalRemover.class: https://paste.md-5.net/egiwufihoq.java
PortalRemoverTask.class: https://paste.md-5.net/fiwitadufu.java
RunTaskTimer does call the task after x ticks every y ticks
you probably want to only run it once
/plugins/pluginname iirc
but just do new File(plugin.getDatafolder(), urfilename) as opposed to new File(plugin.getDatafolder() + "/" + urfilename)
Change "/" with File.separator
What do you mean?
I have a check If the task is already running or not
You should use an other method
runtasktimer waits x ticks before running the task the first time and then runs it every y ticks
What method?
Use scheduler if you want delay
Sure but I have a boolean field to set whether the task is "running" or not, does it make difference?
It's will send after X seconds (ticks)
I want a task that runs every tick
Wat?
You can read this for context
scheduler its what's you need xd
Honestly, I'd like to make it so events use method handles instead of regular reflection, if they don't already.
.
I know and that is what I want and also what I use
I mean, that'll eventually become the case when they use method handles for reflection in later versions of Java
but still
do you at least have clear ideas about what you want to do?
Yes
Preventing player being stuck in nether portal
So I want to remove the nether portal when player stay in the nether portal longer than x seconds and then restore the nether portal back after another x seconds
I'm pretty sure nether portal traps don't work anymore in newer versions
Yup
It is a request from my client
Lemme guess, they use 1.8?
...
I don't understand
I mean I'm not telling you to not make the plugin
You should, since money is money :)
But that is an idiotic thing to request in a version that doesn't suffer from issues with portal traps lol
Yes, and I already achieve that
Client???
what do you need then

hello u guys know any plugin that do this? like players will bet a number between 1-100 and at the end of the day or whatevertime u set the plugin will pick a number from 1-100 and the winner will get rewards, like lottery
i tried searching but theres no lottery like this
I want to send a message 5 seconds before portal destroyed but the message is sent multiple times
yeah?
I haven't heard of a plugin like that but I could make one.
he's freelancing
o
show code
ur using runTaskTimer()
how much do u charge
Here's the code (look at reply)
Let's move this into DMs.
The message is inside the runTaskTimer
Yes and that logic is wrong.
yeah u shouldnt do that
Obviously is repeating the message because is in the same method
runTaskTimer runs the code repeatedly
after X ticks*
Okay, what should I do?
an scheduler for message
So like schedule a task inside the runTaskTimer to send the message?
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.scheduleSyncDelayedTask( this, () -> {
player.sendMessage("hello")
}, 20L);```
BukkitScheduler#scheduleSyncDelayedTask
Lol its hard to write thing on phone
same
ya missed 4 tabs
task.runTaskTimer(this.plugin, 0L, 1L);
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
// send message
}, delay);
How i said i writed it with phone lel
lmao
Breh use scheduleSyncDelayedTask
nahh
Then do what you want.
it's the same thing wdym
aint that just sceduleDelayedTask? There are separate method calls for async task iirc
What?
scheduleSyncDelayedTask is the same as runTaskLater just different names
ah
Originally it was scheduleSyncDelayedTask but maybe there are some confusion so they changed it to runTaskLater, and same with other methods too
Les see docs lel
maybe
I'm gonna need some context
different topic, why the 4 tick delay for registering PlayerIntearactEvents?
can u spawn an entity from an entity object
wdym?
Anyone got some suggestions for good Spigot workflow?
I hate having to stop and start the server every time I modify my plugin
But I've heard reloading is like a cardinal sin
and reloading with plugman is a bullet in the knee
live with it
It really slows down workflow tho :p
I'd prefer to just be able to build and then see changes be reflected like snaps fingers
Well usually I have to like, make a lot of minor changes to see what's causing an issue
fair fair
So it becomes a cycle of "Nope that didn't do anything" (small change) "Nope that..." and so on
just get alot of print statements and see where they stop
I mean that just lets me know when something has or hasn't worked
Yeah but I still hear it's not a good idea since it can cause issues
I don't want to be confused by a bug to find out it was caused by reloading
^
normally reloading causes memory leaks and messes up statics
uuuuuuuuuuuuuuuuurgh
can someone explain why
public void rightclick(PlayerInteractEvent e){```
has a 4 tick delay
it hasnt, that's ping probably
There’s dcevm but unsure if it’s implemented for j16/17
(Hotswapping)
Oh yeah DCEVM, I remember that
Normal debug mode w/o dcevm is quite limited but still doable
It didn't work for me when I originally used it
Ah rip
Why does a 4 tick delay matter, exactly?
hey so I am trying to make a ban player command, how can I make it work on both online and offline players?
What aglerr tells you is 100% true
?scheduling Check the bottom btw (:
is that a Java snippet using C# docs?
