#help-development
1 messages · Page 493 of 1
isnt that just custom implementation??
what even do people mean with "completion colors"?
idk lol
im not even talking about completion
im talking about color while typing in console
can you show a screenshot of what you mean?
he means how to change color of unknown commands in console (red)
like if you type an unknown command, then it becomes red in jline
"line highlighting functionality"
i guess
oh
found it
BrigadierCommandHighlighter
its handled by minecraft
builder.append((buffer.substring(pos)), AttributedStyle.DEFAULT.foreground(AttributedStyle.RED));
your console is not colored or something?
thx a lot
LineReader lineReader = LineReaderBuilder.builder()
.terminal(terminal)
.completer(new MyCompleter())
.highlighter(new MyHighlighter())
.build();
where did u found it? can u maybe give link?
are you even using spigot?
i mean in minecraft code
You mean java
just type the class name and see where is it
holy crap, just realised paper doing this color thing
no, they mean using spigot. obviously you can create your own CLI interface in java, but good luck doing that using spigot, where you are supposed to just "listen" to incoming commands and not just try to handle any console input yourself
io.papermc.paper.console.BrigadierCommandHighlighter, that is a paper feature
I already said that twice lol
my brain
^
show your config.yml
LIne 189, 205 include if they have no entry in PlayerDropConfig
and 222 etc
I'm assuming PlayerDropConfig doesn't have any entry for a player by default.
?nocode
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.
any way i can tell if block is a shulkerbox without making an if for every color?
so spigot uses a list where you can't add anything, when it comes to block drops, is it possible to add more entries to this list anyway using reflection or something
How can I make my npc attack a player?
block.getType().toString().contains("SHULKER_BOX")
kinda a solution
or check if the block is an inventory holder and see if that type is of a shulker box
BlockDropItemEvent#getItems()
yeah yeah i know i more meant that you cant add anything to it
but what if you want to add something anyway
can you do it with reflection
Why not just drop it yourself?
doesnt play nice with other plugins
this isnt an issue on paper or purpur or whatever, can add things to them just fine
i dont remember what my solution was
cant you just use block instanceof ShulkerBox?
I'm not sure why you couldn't be able to add items to it. It says it's mutable. Meaning it should allow you to add new ones.
right, but it still throws an IllegalOperationException when you do
i have no clue why spigot has this restriction still
ill try thanks
getBlockState() instanceof ShulkerBox
as ShulkerBox extends block state
it extends Container, Lidded, and Lootable
it is a blockstate though
if you look at its superinterfaces
oh damn thats weird
it extends container which extends tilestate which extends blockstate
how to hide a player nametag just for some players, and other player can see it?
scoreboard Teams
yes, but how can I set the visibility just for a player
How do I make this calculation for the NPC to look down like a goblin instead of looking normaly at me? (byte) ((pitch%360)*256/360)
Someone nows about log4shell?
I'm sure most active devs do
Hello, i got a little question.
I am trying to download JDK 8 for making a plugin, and i dont have an account on oracle and i dont have to make one because i need to input all my information
So i want to hear if anybody who has a account couldt send it to mee
Don't use Oracle. OpenJDK or Adoptium
I don't get why oracle did that tbh
like why do you need my information to download jdk 8 💀
I believe there is a tiny link to download without an account still, but it's hard to spot
Where do i download it?
I cant send a screenshot
OpenLogic provides free OpenJDK Java downloads for OpenJDK 8 and OpenJDK 11. Get your JDK download today. Plus, get answers to your FAQ about Java development and download Java JDK 8 and Java 11.
What is best or is it just the same?
it makes no real difference which you pick
.msi or .zip?
Okay thank you so much 🙂
I try to find a way to hide players' nametags, and I know you can do that with teams, but I want to make a plugin that hides all players' nametags, but some players who are "friends" can see their nametags, and at the same time, each player can see other players' nametags if they are at a certain distance from them, what would you recommend me to try to do?
hey how do I update my spigot server to current version? I cant find any helpful videos?????
Why do i have this boring menu while creating a new projekt where other people have a cool looking menu?
Everything for me is on the same page and for other people its split out in around 5 pages or something
hello
i need help
what is the name of sharpness in ItemStack?
Enchantment.DAMAGE_ALL
declaration: package: org.bukkit.enchantments, class: Enchantment
Sry for @
But when i try to put in the JDK its dosent work, i cant see it when im trying to add it
Why do I getting this error? error: package org.bukkit does not exist import org.bukkit.ChatColor; ^ dependencies { compileOnly 'org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT' compileOnly 'org.projectlombok:lombok:1.18.22' }
Enchantment.PROTECTION_ENVIRONMENTAL
and Enchantment.DURABILITY
For building the bold method, do they use some sort of functional interface or what?
GuiItem clickItem = ItemBuilder.from(Material.GOLD_BLOCK).asButton().action((InventoryClickEvent event) -> {});
GuiItem dragItem = ItemBuilder.from(Material.IRON_BLOCK).asButton().action((InventoryDragEvent event) -> {});
I mean is that even posible?
yes ``` public Main asButton()
{
return this;
}
public Main Action(Consumer<Player> arg)
{
return this;
}``` ```new Main().asButton().Action(player -> {
});```
Right, but would allow to change the object being consume?
There is where i get stuck, im not sure if i will allow to do exactly that
Why cant i find my jdk when im trying to put it in my plugin? i cant see it when i am going to its location
Example with functional interface public interface CustomEvent { void onExecute(Player player, int age); } ```
public Main asButton()
{
return this;
}
public Main Action(CustomEvent arg)
{
return this;
} ``` ``` new Main().asButton().Action((player, age) -> {
});```
Right really thanks Jace, so definitly i will did what i mention
.
I have thought that i can make a MenuEvent and them sub events for clicking and dragging. To finally make the Consumer<MenuEvent>
Because my main goal is to allow the end user, to decide if the action will be for the click or drag event
I think if you want to have more then one parameter in lamda then use functional interface so there could be as much parameters as you what. In case of passing single object better to user Consumer<T>
Something like?
like here there are 2 parameters
oh ok
thanks man
I will write the logic and publish it here, so you tell me your opinion or give suggestions
sure
tbh I've never seen syntax like .action((MenuClickEvent event) ->... mostly I see .action(event ->...
Yeah me too
But i have thought that why adding 2 method for the actions, if you can just change the event of it
I didnt know you could do that tho
what about generic type?
like .action<MenuClickEvent>(event -> {})
then you can register as many events of different types using only one method as you want
you broken my braisn with that, i didnt thought even you can do that
Java has so sweaty things i didnt know
My originally question started wheen i seen this example of on open source menu. So far it called my attention if i can adapt it to my use. Making you using the same action method, but changing the type (either dragging or clicking) of it
TIL you can have typed lambda parameters in java lol
Really rare but I've used it before
i will read about typed lambda, first time i listen that tho
okay i understand what they are now, seems pretty nice to have that feature
how can i make custom furnace recipes (like smelting a nether star with namespaced key "item")
Mostly used to resolve ambiguous signatures but yea
Oh conclure!! You are still alive haha
?
Yeaa
Really happy to see you 🤙
ok i have found a solution to create menu
but is not centering have any idea to centering it ?
starting to love c++ syntax
depends on what you did
i found solution
looks like a resource pack then you need to ad negative spaces to the title
i had negative ttf
nice
and use unicode to make padding
damn enum class
now i need to remove inventory txt
no problem i think i can add z-index 😂 as same as css
what blockdata do saplings have?
look in the docs
do you mean Sapling or do you actually mean young tree?
wtf is a young tree
sapling as in oak_sapling
a tree that is not grown
wut
yeah thats a sapling is it not
cool that its different for crops 🙏
as far as I know there are only 2 stages for trees in mc, saplings and trees
I was trying to determine if he was just referring to the specific Sapling or trees as the material
I see
I didnt even know that was still a thing
its been deprecated to hell though
its a complete mess in there
ie https://hub.spigotmc.org/javadocs/spigot/org/bukkit/material/Sapling.html completely deprcated, however the new https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/type/Sapling.html doesn;t apply to saplings at all
even though teh Material for Sapling links to it
I guess Bamboo and Mangrove Propagule are special cases
yeah
they just have extra features ig
declaration: package: org.bukkit.block.data.type, interface: MangrovePropagule
or not
the propagule is apparently an empty interface
lol
Hello, I have a problem with changing the player pose. I would like to send this packet to set the swimming animation for a specyfic player so that it looks like crawling. I have seen that this can be achieved by sending ENTITY_METADATA packet, but unfortunately I don't know how to send it correctly. Currently, nothing is happening and there is no error.
CODE:
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
PacketContainer packet = manager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
packet.getModifier().writeDefaults();
List<WrappedWatchableObject> wwo_list = new ArrayList<>();
wwo_list.add(new WrappedWatchableObject(6, EnumWrappers.EntityPose.SWIMMING));
packet.getIntegers().write(0, p.getEntityId());
packet.getWatchableCollectionModifier().write(0, wwo_list);
for(Player target : Bukkit.getOnlinePlayers())
{
try
{
manager.sendServerPacket(target, packet);
}
catch (Exception e)
{
Bukkit.broadcastMessage(e.toString());
}
}
doing c++ and then back on doing java scares me whenever i see 'new'
real
can do new int(98) in c++ and that triggers me
hi guys, i'm new to plugin development and i was wondering if there's a way to avoid restarting the server every time i want to rebuild the plugin
put the plugin in plugins/update/ and reload server, it will automatically replace the old one
You can use the /reload command in your test environment. You should never use that command on your production server though.
every time i build it will go to plugins/update?
and then it will replace the old one
no you have to put it there yourself
i mean if my jar directory is plugins/update
ye
does it have to be in /plugins
Yes?
is there a way to hide the /commands from players that arn't op?
no well
i mean
is there any way i can use spigot in a plugin that runs on the bungecord main server
well the problem is there are many limitations in bungee
for example i cant change people gamemode with means i would need to load the same plugin on every single server instead of just on the bungee main server
wich kinda seems like a waste of resources
What resources
1 megabyte of memory and 50kb of disk space?
thats just a small example its a bigger plugin
Ok 50mb of memory and 2mb of disk space
stacked on 10 different spigot servers thats still half a gig used
On vs 20gb overall... 2.5%
It's not like memory is expensive these days
I don't suppose there is some magic method to load my plugin before the game loads datapacks
I'm not sure. Are datapacks loaded before or after the world gets loaded?
If it's after then yes there is
Datapacks are hardcore baked into the server as of 1.19
Sadge
I'm trying to inject custom stuff for use in datapacks, but I have no way to do so early enough
Reload the datapacks?
The server refuses to start if the datapacks have an error
At least in terms of worldgen stuff
Add the new datapack later and then reload
Worldgen datapacks don't work with reload
Rip
7 chunks or 7 blocks?
7 branch depth
Can I somehow cancel IvnetoryClickEvent only in GUI and not in player inventory? I need let player put some items in specific slots.
Yes. Inventories implement equals and hashcode so you can hold your instances in a list or HashMap (depending on usecase)
Oh I suppose the question is how to not prevent clicks in the bottom inventory when a gui is open, right?
In that case check for the rawSlot
I just want cancel event only if is clicked in slots of the red area
Im just checking clicked slot now, But is canceling in player invnetory too thats the issue.
You can determine those using the raw slot number. It's unique
getSlot() does return the same number for some player inventory slots aswell
Why dont you check the inventory type? So
if (InventoryType == InventoryType.PLAYER) return;
// do logic here and cancel event
What do you mean with that? I mean im interested to learn tho
Type is based on top invnetory isnt it? Im dump thats why xD
Also if you only working with custom menus, get the top inventory
Depends what you are doing
Since mojang was selled its a completly shit, Dont you agree?
are nested try/catches and if statements normal in plugin development?
The up inventory is custom (just menu) idk how I can grap that tied this :
if (p.getInventory().equals(e.getInventory())) e.setCancelled(false);
Wait what you wondering to do?
e.getClickcedInventory(); should be the right method probably.
why are you comparing player inventory with event one?
Shouldnt compare your event inventory against your custom inventory instance?
to detect if player clicked on custom or player inv.
Something like this could probably work.
if (event.getView().getTopInventory().equals(event.getClickedInventory()))
Exacctly, was going to send that
i was going to suggest you could have a hashmap but that might be a better method.
wait! What if the top inventory is null?
you probably cannot use .equals(); on a null object. Just use == operator.
Just do a null check beforehand then.
When you are coding you have to evaluate all posibilities i mean
You should already take i ncare that while coding
This is what I was loking for! Cnannot figurate out how to compare that. I know u can do something like this, but idk hwo.
Dont you have a instance of custom inventory? 🤔
Are you saving your inventory instance anywhere?
if its an inventory gui, it may have a hashmap or hashset of inventory objects, if it does not, create one then checked the clickedInventory against that hashmap or hashset. Might be one way to do this though probably.
I have that
Inventory custom;
onClick(InventoryClickEvent event) {
Inventory inventory = event.getView().getTopInventory();
if (inventory == null || !inventory.equals(custom)) return;
// your code here
}```
Well, you can actually just use an == check if you are comparing instances.
Its recommend for inventories tho? i alway make that question to myself
If you are comparing instances, yes.
If you are comparing contents, no.
so my code is correct tho
you not only compare instance, you need conten tto be compared too
No you don't.
the == operator just compares references?
You just need the instance.
Why?
What if the instance are the same, but the content doesnt match, will returns as your custom inventory - thats a fail, isnt it?
i mean i want to nderstand not wondering to be rude just to clarify because them ppl say im trolling or those weird things
That shouldn't be possible.
what are you even talking about?
About comparing event inventories against custom inventories, how you would check and make sure its your custom inventory
Look, let me give you an example of how the comparison works. Just give me a sec.
why would two of the same instances have different contents?
you are storing a reference to the object, just compare that.
if it references the same object, the contents should not be different.
i dont think its that simple
a friend had a case of using == to compare 2 objects, which were exactly the same. But when debugging it showed that they were not the same, when they were. His solution was to use equals().
Inventory inv = Bukkit.createInventory(blah blah) // This is a new instance lets call it Instance1
@EventHandler
public void onClick(InventoryClickEvent event) {
event.getClickedInventory(); // This will return the inventory instance that was clicked.
// Lets say that it doesn't match and the inventory we clicked is Instance40
// it doesn't matter what we do from this point on, the inventory doesn't match.
}
Now lets assume that the instances do match.
@EventHandler
public void onClick(InventoryClickEvent event) {
Inventory clicked = event.getClickedInventory(); // Lets say that the clicked inventory was actually Instance1
// If Instance1 == Instance1
if (event.getClickedInventory() == inv) {
// Check succeded, do your stuff.
}
}
Well yes, that's how it works. Those two objects are separate instances. They may be equal in terms of content, but not in terms of where they got assigned in memory.
right, but when you exactly check via instance and via content ?
That depends on what you need.
I am bored.
Because also when working with custom inventories you dont want only the instance matching, you want both of them. Where if the instance is the same but content is different, then is an issue. Because you want the exactly inventory with the exact contnet
🤔
Your inventory will have the correct contents if you are using the correct instance.
That's why we need to save those instances we create so that we can use them later.
there will never be a case where instance is same but content different
this has less to do with minecraft inventories and more so with java basics though.
So this if is okey?
if (e.getView().getTopInventory() != null && !e.getView().getTopInventory().equals(e.getClickedInventory()))```
Im kinda lost now in int 😄 Or just should I have used inventory in variable like this variable? ```java
inv = Bukkit.createInventory(this, getRows()*9, ChatUtils.format(getTitle())); ```
you might not know java properly if you don't know how instances and references work.
So intance checking does internally check for contnet? Becuase then you can replicate a fake instance and they will be the same. refering to inventories ofc
When we compare instances, we are really just doing a reference check. == really just compares memory addresses. It can't ever compare contents.
If you need to compare contents, then you'll need to use .equals().
yeah you might wanna check if its the inventory you created or it may end up triggering everytime a player uses a top inventory like any normal chests or ender chests probably.
1m i will translate to english and see because i think im explaning really bad
My question is how do you really make sure that both inventories are identical, that is: name, size and content is the same. Because there are vulnerabilities to replicate inventories, that's what I want to get to.
Both == and .equals() will achieve that.
So the if is okey, perfect! I just need cancel event only if player click on first in last line of custom inventory (I managed that by checking clicked slot) and I dont rly care what player click in his inventory. I just want him he can put items on slots 8-44. So probably that if is fine.
um.
you still might wanna make sure that inventory clicked is not just any random inventory though probably.
Make a constant with the none clickeable slots number and the compare it by looping each number from the constant set/list to the clicked slot
I makeit like this:
int slot = e.getSlot();
if (slot > 8 && slot < slots-9) {
e.setCancelled(false);
}
if (e.getView().getTopInventory() != null && !e.getView().getTopInventory().equals(e.getClickedInventory())) {
p.sendMessage("yep");
e.setCancelled(false);
}```
and before that Im chcecking if is instace of menu or not
Mby I shloud use .getRawSlot insted of .getSlot
This is all well and good, but you don't actually need to compare slots when comparing instances. The inventories you see are two separate ones. So that check you have to make sure it's the same inventory should suffice.
I need. I need to first and last slot not be clickable. There are some items what I dont want player to grap.
Oh, are you making the top inventory useable?
Acctualy.. If I use rawSlot method (first if) I don need the second one. 🤔
Items in red have some function
But you want people to move items from their inventory to the available space in the top inventory corrrect?
Yep on slots from 9-44 (all rows expect first and last)
Ok ok. Usually people don't want anything to be moved in their custom inventories.
Your check that you have is just fine then.
Sometimes mojangs code is... questionable
List<Pair<Function<StructureTemplatePool.Projection, ? extends StructurePoolElement>, Integer>> elementCountsByGetters
Somewhat
what is it doing?
Do you not enjoy a list of pairs of functions
hm.
Perfect hthanks a lot! I can't think about these things properly sometimes. Its kit editor thats why I want that
Oh nice
I have done a kit editor and i understand the pain of it
Idk is not that hard to save and load items from file (using .yml for now, DB will be later). Gona make some plugin probably public soon. Something kinda new.
nice from hearing that
Also making public plugins make you learn a lot of experience while coding
I hope so. I get one ide about plugin what is not done yet, at least not knowing about.
anyone knowing why the armorstand-teleports are soo laggy?
How do you create a block in spigot?
if (event.getBlock().getState() instanceof Sign) {
Sign sign = (Sign)event.getBlock().getState();
if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player2]") || sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player1]")){
Location loc = sign.getLocation();
TimeUnit.SECONDS.sleep(1);
Block block = Bukkit.getWorld("world").getBlockAt(loc);
block.setType(Material.OAK_SIGN);
logger.log(Level.INFO, block.getType().name());
}
}
}
}```
This does not work
im trying to create a sign
This really comes down to how you are teleporting them. Specifically how often and by how much.
just using ArmorStand#teleport, calling on PlayerInteractEvent
You need to call BlockState#update() if you make changes to it.
curiously why you throwing interruptedexception o.O
by how much is not easy to say, its a Vector calculated with the player Direction lol
You can teleport using vectors?
nah I just made that myself
its just getting the Location of the AS and then adds the offset of the vector to it
am I delusional for wanting this to be possible?
you mean char[] = new char[6}?
no
an array is still an object and not a primitive
I want to declare that "hex" is always a 6-length char
and can never be 5 or 7 lengh long
Oh
You can literally initialize it as an empty array
well I do not really care, I just started typing this, then realized it won't work lol
that's has a fixed length of 6
huh?
You'd need some way to ensure that it's always filled with content. Maybe a default value would work, but I can see why we use the up to approach.
nah I don't need that
all I needed to do was to declare the length in the field itself, and I know it's not possible, and I never asked for it to be possible, all I want is this to be possible 🥲
I responded to that earlier.
#help-development message
Ah ok
?blockstate#update
Do you have any resources?
for it
You just have to call that method. You already set the type, now you need to update the block.
I don't see why that would lag
Wait so I leave the part where I change the type, now I need to update/upload it using that method?
TimeUnit.SECONDS.sleep(1);
Block block = Bukkit.getWorld("world").getBlockAt(loc);
block.setType(Material.OAK_SIGN);
block.getState().update();
logger.log(Level.INFO, block.getType().name());```
is there any redundancy?
Why are you sleeping for a second
That should work.
Wont that freeze the server? Since server is single threaded
yes lol
imho they aren't sleeping long enough if you are going to freeze the server you might as well crash it
TimeUnit.SECONDS.sleep(Integer.MAX_VALUE);
the code should be adjusted to reflect this change ^
Directly you should never use sleep()
And less with single threaded softwares
pizza good
nvm didnt think it thru
uwu
so confused on why this is making the duration 7 seconds.
public cItemStack SetTippedArrowEffect(PotionEffectType potionEffectType, int amplifier) {
ItemStack arrowItem = new ItemStack(Material.TIPPED_ARROW, this.getAmount());
PotionMeta potionMeta = (PotionMeta) arrowItem.getItemMeta();
assert potionMeta != null;
potionMeta.setColor(potionEffectType.getColor());
potionMeta.setBasePotionData(new PotionData(PotionType.UNCRAFTABLE));
potionMeta.addCustomEffect(new PotionEffect(potionEffectType, 1200, amplifier), true);
arrowItem.setItemMeta(potionMeta);
return new cItemStack(arrowItem);
}
use assert for tests only!!!!!!
^ just null check instead of asserts
imagine people claiming "gradle is so much faster than maven", meanwhile you had a smoke, took a shit, and drank a beer, but gradle is still not done with setting up the project you cloned 17 minutes ago lmao
slow pc or what (or big project)
i7 9700K, not THAT slow
SuperiorSkyblock2
gradle is kind enough to let you do that
how many cigarettes am I supposed to smoke before it's done finishing its job
time to find out
Yeah they are prefeences, but ofc Maven >>> Graven
oh damn it's done, only 20 minutes
It does not work
Location loc = sign.getLocation();
TimeUnit.SECONDS.sleep(1);
Block block = Bukkit.getWorld("world").getBlockAt(loc);
block.setType(Material.OAK_SIGN);
block.getState().update();
logger.log(Level.INFO, block.getType().name());```
This does not create a new sign
do you wanna replace a sign with an empty oak sign?
I'll add text to it later
Yes
When its broken it should come back
and does sign.getLine(0) equalsIgnoreCase "[Player2]" in dark aqua?
does the logger print out "DARK_OAK_SIGN"?
Just OAK_SIgn
what's the output of /version ?
also why are you lagging the main thread by one second?
or are you running this inside some runnable?
I run "/version" in console?
Because I dont it to be too soon that it htinks the block is still there
but if you just sleep, nothing inbetween happens anyway
all it does is cause useless lag
[02:43:07 INFO]: This server is running Paper version git-Paper-519 (MC: 1.19.4) (Implementing API version 1.19.4-R0.1-SNAPSHOT) (Git: 936205b)
You are 2 version(s) behind
Download the new version at: https://papermc.io/downloads/paper
Previous version: git-Purpur-1907 (MC: 1.19.3)```
Wait so there is no chance its too soon that the program thinks the block is still there?
Ok i deleted the delay
@quartz gull that doesn't change the fact that it's setting the duration to 7 seconds and not 60 seconds
now what is my code missing?
depends
are you running it in some kind of thread / runnable?
how slow would it be to loop through every single inventory in the server by loading every chunk and getting the tile entities
A blockbreak listener
very quick for tiny maps, to "crashes your server" on big maps
public void blockBreak(BlockBreakEvent event) throws InterruptedException {
if (event.getBlock().getState() instanceof Sign) {
Sign sign = (Sign)event.getBlock().getState();
if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player2]") || sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player1]")){
Location loc = sign.getLocation();
//TimeUnit.SECONDS.sleep(1);
Block block = Bukkit.getWorld("world").getBlockAt(loc);
block.setType(Material.OAK_SIGN);
block.getState().update();
logger.log(Level.INFO, block.getType().name());
}
}
}
}```
?paste the whole class
ughhhh but I don't feel like setting up sqlite just to track all the inventories
?xy
Asking about your attempted solution rather than your actual problem
that's so much efforttttttt
waaaaaahhhhhh
okay here's the problem
on our server we wish to modify the attributes of all armor
so for example every iron chestplate will have different stats than vanilla
but
ocasionally the attributes we want will change
so my idea is a /upgrade command that will loop through all tile and player inventories and """upgrade""" the items
loop, e.g. every second, over all player's invs, and do the changes then/there
it's like 125 times more efficient than looping over all, and loading all, existing chunks, though
- why do you use getBLockAt instead of using the block provided by the event?
- why do you use getBlock().getState() instead of the state provided by the event?
you are updating the blockstate of another block instance, from what I'd guess
the whole code is quite messy, tbh
okay but like if I'm running that command once a day
Wait so is that whats stopping me from creating a block
Well. First I wanna fix the fact that a sign is not being created
no, you first wanna fix your code using three different blockstates, and recreating block instances manually through coords although you already got the block instance
why the heck do you do "Bukkit.getWorld("world") although you already have the world
Umm, is there a example?
and then you call getBlock(Location) on that, although you already got the block
event.getBlock()
Block block = Bukkit.getWorld("world").getBlockAt(loc);
why not just use event.getBLock()
Yes I get your point
Anyways, so, what were we talking about.
Right, umm, do you have a example
of someone creating a blockk that will work
@EventHandler
public void blockBreak(BlockBreakEvent event) throws InterruptedException {
if (event.getBlock().getState() instanceof Sign) {
Sign sign = (Sign)event.getBlock().getState();
if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player2]") || sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player1]")){
Block block = event.getBlock();
block.setType(Material.OAK_SIGN);
block.getState().update();
System.out.println("asd 123 test");
event.setCancelled(true);
}
}
}
So this code will create the block?
"blocks" do not get created
check whether this prints "asd 123 test" to console when you break a sign
System out does not work, the console asks me to use the plugin logger
it WILL work
I tried system.out. it works for like, a min, then it gives me warnings
ima change it to the logger.
also you are supposed to cancel the BlockBreakEvent, otherwise there will only be air at that block anymore
yes because you're using deprecated server software
paper is still able to print out messages from stoud, it just loves to complain about it
but yes, sure, use the logger instead
the logger is ofc better, that's correct
once again, paper loves to complain about normal spigot features. if they'd want plugins to stop using STDOUT, they'd just make those messages vanish. Or just proxy it to the actual logger. Instead, they rather proxy that message, just to show a warning, instead of just proxying it properly to that plugin's logger
[02:59:33 INFO]: [com.onutillities.Main] [oNUtillities] OAK_SIGN
[03:00:20 INFO]: [com.onutillities.Main] [oNUtillities] Granted
[03:00:21 INFO]: [com.onutillities.Main] [oNUtillities] OAK_SIGN
[03:00:24 INFO]: SpiderUnderUrBed lost connection: Disconnected
[03:00:24 INFO]: [voicechat] Disconnecting client SpiderUnderUrBed```
The block does not recreate
you obviously did not copy/paste my code
public void blockBreak(BlockBreakEvent event) throws InterruptedException {
if (event.getBlock().getState() instanceof Sign) {
Sign sign = (Sign)event.getBlock().getState();
if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player2]") || sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player1]")){
Block block = event.getBlock();
block.setType(Material.OAK_SIGN);
block.getState().update();
logger.log(Level.INFO, block.getType().name());
}
}
}```
This is the code
i put in
why does that method even declare "throws InterruptedEx"?
I told you to print out "asd 123 test" for good reasons btw
Ima remove it, but i doubt it was the issue
ok ill add it back in
also where does "granted" come from?
but I doubt itll log
if it would not log, you'd know where the issue is - the if statement fails
Oh it was a testing message for another event
which was btw the first thing I suggested was the problem
No, thats because system.out logs dont work on this server software
only plugin logs
I know paper and how shitty it is, but sout's work fine
only issue is that it prints a warning every 100 messages
For the first few seconds, the people im helping by making this plugin for, idk what server software they are using, or whats happening, but it's just acting weird
anyway, if I send you code, and ask you to try it out, you're better off copy/pasting exactly what I sent, instead of adjusting and changing it all the time again, because then we both have no clue what's going on
ok ill add the whole thing
but you just sent the output of /version so we know exactly, they use paper 1.19.4, 2 versions behind
I'll probably need to ask their backend developer questions about their server console and stuff, idk why this issue is there
I dont have much access over the project, mainly plugin related stuff
Anyways, it seems like the stoudout issue only occurs mid startup
which is so very weird
anyways everything works
thank you
It recreates the sign with the text
which is weird because I did not set text on it
Is there a modern alternative for createInventory?
?
it says that createInventory is deprecated?
?whereami
paper deprecated it
^
why not just make it harder?
do u have a link to what to use instead?
doesn't that sound fun
idk ask paper
this is spigot
Any efficient way to run a task once a week?
Like execute a piece of code every saturday at 3am or whatever
Without using a 20L tick
Store an epoch, do some sanity checks on startup and once in a while
if i plan on putting something on spigot.org, should i use spigot instead?
Yes
I'd approach this with a semi-safe approach like
If you depend on paper you can't post on spigot
I mean you could people just might get angry your plugin isn't working
this is where the calendar api will be helpful
Well
use the calendar api to determine the day of the week
not sure what you mean
scheduleNextTask:
- get current epoch
- get target epoch
- subtract to make a difference
- calculate the ticks until that difference (difference * 20)
- call scheduleNextTask in half that time, that way any tps drops will be fluctuated
- if current epoch == targetEpoch, run task, scheduleNextTask
calendar stuff wouldn't need to go into a tasj
on startup, use it to get the day of the week, then look at the clock for time
if its sat 3am then execute whatever code
What if there's no startup
onEnable ??
That implies the server is restarted
What if it's not restarted once a week when I need it to run
not sure what you are talking about here, if the server isn't on its a moot point
the onEnable just calls scheduleNextTask
you can call it manually
Just a lightweight recursive scheduler type deal
Ok what I'm saying is I still need to make a task that runs what, once every second? once every minute?
Instead of making it repeating
do it dynamic in a way where tick fluctiations don't do stuff
What you meant
Let's say your task runs at 1pm
You're saying
if it were me I would just use an event in MC that sedomly gets called
Schedule the task to run
and it's 1am now, so 12h difference
The specific day I want
like day night cycle. I don't like using tasks unless I really need to
12h / 2 = 6h
yup got it
I would run a task at a fixed frequency (every minute) that does simple check: if (shouldExecuteNow) execute(); else return();
fixed frequency also works
with the calendar api you could get the time until you want it to run and then schedule the task for that specific time too
if the task is once per week, then just schedule it every hour
Hmmm damn
if you don't want the ticks to affect the timing, you would need a separate thread and exclusively use the system clock
Sure it'd run a bunch more times the closer it gets but you can just hardcode a threshold
I mean
or just make a fixed executor and move on
When you say unreliable
Do you mean
3pm saturday could be between 2:55 - 3:05
Or like
I mean if you server lags for a minute so does your delay
it would still be attached to the ticks
3 hours
no?
If the server is lagging for a minute that should be looked at no?
newScheduledThreadPool(1).whatever
true but sometimes you just have that 1 tick that takes slightly too long
you don't need a whole new thread pool for this lol
and one of those every second start adding up
Alright thanks
There's probably a stupid alternative that I can't bother remembering because it's 2:30am
I'm only awake because my dad gotta wake up at 4am and I'm usually gaming at that time
nice
If I have a scheduled task
And i unload/load the plugin but not the server
I assume the task gets cancelled
how do you reload the plugin, using /reload?
no
plugman so yes
that is something you will have to handle
wait what are we scheduling?
Once a week task
okay
what exactly does your code do btw?
well assuming the server will always be on in that time, I would save that timestamp to a file
runTaskLater()
takes the delay as a long. I see that ZonedDateTime would return a long but I assume it's not the same value
No need
I found a better solution
and then just schedule a task for that time when you enable the plugin/start teh task
I'm scheduling a task for "next saturday" on plugin load
If the server restarts
It'll just update the task with the next scheduled
Otherwise, it'll keep the task going and do some adjustments
to do that you will need to save the task id so you could cancel the phantom one and reschedule a new one
but what does your task do though?
Resets some data for all players recorded
Class reset
So all players will have their classes removed, and if online sent to the class selector
so I imagine the reset is mostly just interacting with a DB?
Sort of
Cache but yeah
Eventually written to db
Since the server doesn't need to restart for it to update
Considering
I'm using MassiveCore
I can't
Don't ask why
Just how it was when I got here
use a chron job to reset the data in the DB, add a column that is a boolean so you know data has been reset
now it doesn't matter if the server is on or not it will always run
and no need to worry about scheduling anything in the server itself
okay so then you would just poll the boolean until the end of time
the long delay from runtasklater
no
it would be part of the cached data
Is it the same as ZonedDateTime
its only purpose is to just make it super easy to know they should go to class selector instead of doing null checks
Like what do I get from ZoneDateTime to get the long value for task
for the scheduler the delay is in ticks
And I assume getLong is in seconds
well yes but it would be hard to do something in the server at the exact time it gets reset though right?
so you would need to convert the time to millis and then to ticks
so seconds * 20
or seconds I mean
yes
yes 20 ticks per second
Yeah threw me off
imo by far the easiest way is to just deal with it on plugin load
or chron job lol super easy to create a bash script to interact with the db
and chron time isn't hard at all
but the advantage of the chron job is that even if the server is off
the data can still be reset
Another question
doesn't need to wait for the server to be started
runTaskLater
if just resetting db info is enough then def go for the chron job
has a method that returns void and BukkitTask
What do I edit to make it return the BukkitTask
Needs a Consumer<BukkitTask>
Or a runnable
well, to return a bukkitTask you would just stuff the bukkittask into a bukkittask object
similar to how you would obtain the id
Should I use Scheduler or Runnable
task = Bukkit.getScheduler().runTaskLater(PrisonCore.get(),task -> {
ProfilesModule profilesModule = PrisonCore.get().getModule(ProfilesModule.class);
},nextSaturdayAt3PM.getSecond() * 20L);
"Stuffing into bukkittask object"
wym
@wet breach
to get the task you supply the runnable
Oh
unfortunately you have a singleton so I'll have to wipe you from this planet
😦
doubt
lmao
😂
no
Ok ur mean
girls like baddies
Well, don't worry others here support you 😄
what about emotional code
why not
new Emotion()
Human.getEmotion(EmotionFactory.emote.yeet())
Can I not pass it the runnable without making a new class?
public void blockBreak(BlockBreakEvent event) {
if (event.getBlock().getState() instanceof Sign) {
Sign sign = (Sign)event.getBlock().getState();
if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player2]") || sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player1]")){
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Block block = event.getBlock();
block.setType(Material.OAK_SIGN);
//((Sign) block.getState()).setLine(0, ChatColor.RED + "LOCKED");
block.getState().update();
event.setCancelled(true);
}
}
}```
How can I change/set the text of a sign upon creation
not without nms iirc
That for him or me
you can use an anonymous inner class
wdym by making a new class
runnables require a class, but you can instantiate them with anonymous ones
oh
SignChangeEvent iirc
because it can mean like 20 things
they probably just forgot to add the anonymous class at the tail end or something
the client sends a packet with the sign's contents
took me a minute to load it up, had to index stuff
nah
modules -> core -> modules do be hitting hard
Considering how little ago I started and how bad it was before
meanwhile im half crying trying to get my one feature to work xD
How to remove ersistentDataContainer from item? This is not working.
@Override
public void handleMenu(InventoryClickEvent e) {
ItemStack item = e.getCurrentItem();
ItemStack clearItem = new ItemStack(item);
ItemMeta meta = clearItem.getItemMeta(); meta.getPersistentDataContainer().remove(new NamespacedKey(PersoKits.getPlugin(), "function"));
clearItem.setItemMeta(meta);
Pretty proud of my progress I must say
Wouldn't have been possible without the people that are no-life in here 24/7 helping out
I think you need to apply the new datacontainer to the item meta do you not?
nvm
you dont
I did in last line
hey, is anyone avalible to help me rn? or should I ask later?
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
At least you have progressed and learned some good habits along the way 
ummm, only "function"
okay, and how did you check if its been removed?
I have tried, like I said, a lot of it is possible due to you guys here
don't you love it when you've dedicated like 6 years of your life into a craft just to see some 15 year old kid from sudan write you a tutorial after coding for 2 weeks
Im printing that item
Bad organization
public void blockBreak(BlockBreakEvent event) {
if (event.getBlock().getState() instanceof Sign) {
Sign sign = (Sign)event.getBlock().getState();
if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player2]") || sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player1]")){
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Block block = event.getBlock();
block.setType(Material.OAK_SIGN);
//((Sign) block.getState()).setLine(0, ChatColor.RED + "LOCKED");
block.getState().update();
event.setCancelled(true);
}
}
}```
How do I change the newly created signs text? it just recreates the sign with the text before it
-1
lmao
Wut
uhh no
ive changed how mining speed works because the server im trying to make uses different detection for speed and which pickaxes break what block using this code
if (tool.getPickaxeTier() < main.getMiningEvent().getPickaxeLevelRequiredForOres().get(block.getType())) {
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1, 0);
player.sendTitle(Utils.color("&4YOUR PICKAXE IS NOT GOOD ENOUGH TO BREAK THIS BLOCK"), null);
return;
}
}
task = new BukkitRunnable() {
@Override
public void run() {
if (!blockProgress.containsKey(block)) {
blockProgress.put(block, 0);
}
//player.sendBlockDamage(e.getBlock().getLocation(), blockProgress.get(e.getBlock()) / 10f);
Location location = block.getLocation();
sendBreakAnimationPacket(player, new BlockPosition(location.getBlockX(), location.getBlock().getY(), location.getBlockZ()), blockProgress.get(block));
if (blockProgress.get(block) < 0L || blockProgress.get(block) >= 9) {
Bukkit.getPluginManager().callEvent(new BlockBreakEvent(block, player));
blockProgress.remove(block);
player.sendBlockDamage(location, 0f);
this.cancel();
return;
}
blockProgress.replace(block, blockProgress.get(block) + 1);
}
}.runTaskTimer(main, 0L, (long) (((10 - tool.getMiningSpeed()) + (Math.round(hardness / tool.getMiningSpeed())))) - (efficiencyLevel * 2L));```
the issue is whenever you break the block the block still has damage visually
oh god just make a class for that runnable
its not that baddd
mans doing math in the param 
shhh
illusion said to use the SignChangEvent, maybe that works
Steaf what is he trying to do
thanks for telling someone to read my message
Change a sign while it's already placed?
ask him directly damn
Faster asking the person who knows a bit more
like this:
I only want signs created at that instance to have text created on it
the sign change event encompasses all changes
filter them
How? i would need the two instances or the instance and event to communicate with each other
I tried getting the sign at its position
the sign is passed on the event
if you need 2 classes to communicate with each other
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ah, you create a copy of the item stack instead of just editing the one you got from the event
which seems deliberate so maybe I am missing something
they are in the same class file
the instance creation and the event
Before that I tried editgin item from event instead idk what is wrong.
show the code you use to print the pdc in chat
like the whole method
instead of just the pdc part you showed before
then you already have the right sign do you not?
Bukkit.getScheduler().runTaskTimer(main, new BlockBreakRunnable(block, player), 0L, delay);```
that better
it looks more complicated than it is
which I would argue might be an issue
i mean
but you used nice names so its fine
yes I am nitpicking
that wasnt my problem tho
basically i am sending block break packets myself
instead of minecraft doing it
and whenever a block is broken it will break as normal but not reset the damage of the block
what damage, isnt the block already broken?
but in the plugin it sets those blocks to bedrock and they respawn after 3 seconds
and when they respawn they are still damaged'
Hmm if I tried this:
p.sendMessage(meta.getPersistentDataContainer().get(new NamespacedKey(PersoKits.getPlugin(), "function"), PersistentDataType.STRING));
message is empty WTF 😄
yeah so print the whole container right under it and see if its still there or not
wtf is this
code
eeeh give me sec xD
fist line should be before remove and last after it
i mean like you showed before xD
this?
p.sendMessage("function: " + meta.getPersistentDataContainer().get(new NamespacedKey(PersoKits.getPlugin(), "function"), PersistentDataType.STRING));
ou get it
Same as one for maven
Didn't you create one for maven with my help?
hmm is gone but.... in that if I save item to list is it still there idk why
public void blockBreak(BlockBreakEvent event) {
if (event.getBlock().getState() instanceof Sign) {
Sign sign = (Sign)event.getBlock().getState();
if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player2]") || sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE +"[Player1]")){
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Block block = event.getBlock();
block.setType(Material.OAK_SIGN);
//((Sign) block.getState()).setLine(0, ChatColor.RED + "LOCKED");
block.getState().update();
event.setCancelled(true);
}
}
}```
Since sign change event does not work for server created signs, how can I change the text for the newly created sign?
When dealing with MySQL, should I be making the queries execute immediately from a function, or should I be making an object/cache that I can modify and have a scheduled task that executes update queries with the current state of the cache/object?
I FOUND IT! I was thinking my ItemBuilder is returning new ItemStack but is not. So in setMenuItems() method I have this
if (page == 0) {
for (ItemStack persoItem : varaintItems) {
inv.addItem(new ItemBuilder(persoItem)
.function("removeItem")
.make());
}
}
and If I click on item its run that method again so it editing ItemStack in the list...
There is anyway to store a method or something ?
i mean for example i dont wanna store the return of ...getHealth i wanna store the getHealth itself
ik what i said is a bit confusing bc i'm confused myself , but i hope someone can help me
ty
anyone knows what all of this does?
like, what are the ifs for, if the java version is obv 17
why does gradle always turn so simple things into 14 lines of code
in maven you just say "target 17, source 17", done lol
Well you can do that too
targetCompatibility = sourceCompatibility = javaVersion
yeah but why does the mvdev plugin then create this huge clutter
I mean, if it's already set to 17, why would anyone check if it's >= 10
and why does it check for 10 in the first place
it is checking the current JDK being used
so, yeah target is set to 17, doesn't mean the JDK is 17
it could be higher or lower
yeah IK but it's a fresh project, apparently generated by the mc-dev plugin, with setting "17" from the beginning, it wouldn't work below 17 anyway
so why would anyone check if it's >= 10
Probably just a template
yeah but shouldn't a template be there to get rid of redundant things
I mean, if it's not even "adjusting things" one could also just copy/paste the same file again and again
well it is probably a dynamic variable. Just happens on this specific version of things, it isn't necessary but its code that can be left there once new versions come about etc
maybe I'm just too picky about what I expect from a proper build tool 🥲
probably
FOR EXAMPLE; SUPPORTING ARCHETYPES duh
What's the event that gets called when a player takes damage from another player
As in, to apply a 5% damage reduction
EntityDamageByEntityEvent
And if I want to make the eventhandler always be priority I set it to monitor right?
if you want to CHANGE anything regarded to the event itself, NEVER use Monitor
monitor is used to monitor only, hence the name
Highest it is
use LOWEST or HIGHEST
Why lowest
usually you wanna go for lowest
Wait
LOWEST is the first to get executed
Lowest is the one that gets called last?
Oh
So if I want to apply damage reduction
Do I want it first so then stuff like enchantments
just use normal priority tbh
Can also apply over it?
sure
I guess it's my decision if the 5% should apply before or after enchantments
i usually make my event priorities confirubale
configurable*
and if there's a bug with another plugin, I just tell my user to change the priority of my own plugin
Pretty good idea
I do it like this usually
LOWEST,. LOW, NORMAL, HIGH, HIGHEST, MONITOR
That is a pretty cool thing to add
it's a bit of a dirty hack but when you gotta support 19273 other plugins, then it's sometimes the only solution
that's me
I remember, I spammed ?learnjava a few times to you
that means you're improving. When I look at code I wrote like a week ago, I still think "wtf is that"
Yeah I actually changed a lot
you dont do that for everything?
Quite proud of myself I must say
yeah well yes ofc
that is great
wanna see something nasty?
Yes
anyone know how i could convert smth like 0xde73af to its # hex varient
https://github.com/JEFF-Media-GbR/InvUnload one of my very first plugins. haven't rewrote it yet
substring it with 2 as starting point
ikr?