#help-development
1 messages Β· Page 115 of 1
log4j is from apache, yes
yeah i was thinking of that, wanted to know if there was any other way lol
Apache things always give problem
Doesnt apply sending an arrow entity when you right click on the how?
i've never had any issue with the apache resources
does infinity work when not having arrows?
me neither
maven, log4j, all working perfectly
No
or even apache itself lol
in creative you dont need arrows
I'd like the players to be able to charge up the bow and aim it properly still
You need atleast 1 arrow with infinito
I would just give them an arrow ghoul and cancel the event for firing
Ok so then if you want to meses go ahead
π π
I cannot said much
or kick them when they try to shoot it π§
even better
my plan was to let players use the bow if they had torches in their inventories
you can basically adjust the whole Log4j config at runtime
e.g. with system properties
or by doing getConfiguration() and adjusting that
I dont to harcoded it
Dont over complicate mate
I mean just do it as simple as you can because u will only lost days and days
I can tell you as personal
Would having a repeating runnable take up your memory usage on the server after you leave it on for awhile?
I realised that something is taking up memory usage on the server after leaving it on for awhile but when I reload it seems to disappear
not unless you do weird stuff
Would you count having a runnable that checks if a list has a certain length weird?
no, not at all
but what does the list store?
if you add more stuff and never remove it again, then obviously that's weird
Player uuids and itβs more of a hash map
well a UUID is tiny
It resets after it hits a certain length
then it shouldnt cause any problems
Sounds like an odd way of doing things
yeah agreed
but having a few hundred UUIDs in a list shouldnt cause any memory issues
Hmmm but I find it odd that my memory usage is increasing the longer I leave the server on even without logging on
Ram usage goes in spikes
Nope just increasing
I have been experiencing IntelliJ crashes even though Iβm not running anything on it lol
The only thing Iβm running is the server and itβs a fairly recent thing and Iβve been getting weird spigot errors after closing the server sometimes
I hope I didnβt install anything bad π
Is there a way to check how many runnables are running though?
Java question: The best way to compare two identical strings but with different bytes?
they are not identical if their bytes aren't the same?
yeah, 1 sec
You mean different objects
?
String.equals
?
BukkitScheduler.getActiveWorkers() returns a list or set or whatever of BukkitWorkers
which are basically scheduled tasks and stuff
Thanks!
Same bytes == same string
String.equals doesn't compare the string, compare the bytes
if the bytes are different, the strings are different
are different bytes
No
Same string
different bytes
i think its charset
Then it's not same string lmao
So it sends the list of the active runnables?
show me two strings that are the same but have different bytes pls
well not active, but scheduled
if you schedule a runnable to run in 10 minutes, then the list of active workers will contain it
Ah ok
it's not the same string, it only "looks the same". let's check those bytes manually. send them as text pls
Hello !
I have a little question
I'm creating a plugin where I have to deal with player's inventories.
Here is something:
if (onlinePlayer.getInventory().firstEmpty() == -1) {
IntelliJ tells me that onlinePlayer.getInventory(), but how can this be null ?
Should I ignore it ? It's weird...
(onlinePlayer is a Player)
Yeah, its only looks the same, but what do you mean with send them as text pls?
.toString()?
it probably tells you that "getInventory()" could cause a NPE. How do you declare onlinePlayer?
no, I meant copy/paste the text from your screenshot
ooh ok wait
Here is the whole method:
@Override
public void give(@NotNull OfflinePlayer player) {
Player onlinePlayer = player.getPlayer();
if (onlinePlayer.getInventory().firstEmpty() == -1) {
onlinePlayer.getWorld().dropItemNaturally(onlinePlayer.getLocation(), this.getAttachment());
} else {
onlinePlayer.getInventory().addItem(getAttachment());
}
}
getPlayer() will return null if the player is not online
so onlinePlayer can be null if "player" is not online
yeah, so basically just do sth like this
@Override
public void give(@NotNull OfflinePlayer player) {
Player onlinePlayer = player.getPlayer();
if(onlinePlayer == null) return; // or drop the contents at their last online location or sth
if (onlinePlayer.getInventory().firstEmpty() == -1) {
onlinePlayer.getWorld().dropItemNaturally(onlinePlayer.getLocation(), this.getAttachment());
} else {
onlinePlayer.getInventory().addItem(getAttachment());
}
}
if(!compound.hasKey("text")){ return;
if material doesnt exist in an list
of many materials around 20
???
thats the exactly that ive received
?
there's also BukkitScheduler().getPendingTasks()
not sure what the difference is
yeah sorry I meant please send the byte array as text π
The player cannot be offline, so i'll just return or throw an exception I think
Thank you
ooooh ok sorry
Yea I found it but you canβt use them?
48, 46, 48, 46, 48, 46, 48, 58, 50, 53, 54, 48, 52
49, 54, 55, 46, 49, 49, 52, 46, 50, 49, 51, 46, 49, 52, 58, 50, 53, 54, 48, 52
Because it is an interface?
Everything is interface inside of spigot api
the getPendingTasks() is probably what you're looking for
no idea what the Workers are
Ah
"almost" everything π
My bad I guess π
But you canβt use it as BukkitScheduler.getPendingTasks()?
Yeah, already tried new String, String.valueOf(), .trim(), + "", chars(), ALL
i cannot compare these moms
:,C
@final monolith
yo
π€
thats weird, why it is printing two same vars when i use .toString()?
that's a good question lol
π
the only way I can imagine this happening is messing with the byte array using reflection
Idk, but I thought I could just do player.sendMessage("Total Runnables: " + BukkitScheduler.getPendingTasks()); but there is no option for .getPendingTasks()
π€
oop replied to wrong message, sorry
xD
kamasutra.yml hmmm
works fine for me
oh wait
you used it as static method
you gotta use Bukkit.getScheduler().getPendingTasks()
the 0.0.0.0 represents my Bukkit.getIp()
Ohhh ahhh alright
i think can be this
its just part of my quizbot category files lol
that's the IP your server is listening on
0.0.0.0 means "listen on all public IPs"
the first one
its a public hosting
oh
how i can get my hosting ip then?
π€
I do it like this
I just ask checkip.amazonaws.com
there simply is no reliable way to get the actual public IP without doing something like this
Since your ISP provide your public IP, you can't get it directly without asking another computer
Or you can have a static public ip but you'll have to refer it somewhere
yeah but that's unreliable
π€
just imagine you're behind a router, and your local IP is 10.0.0.2
that's obviously not your public IP
i think thats not gonna be a problem, im working with my rest API, requests aren't a problem
thanks guys
np
i will take a look
But the Bukkit.getPort() are safe, right?
π€
e.g. all my servers run in proxmox on 25565 but they get NATed to a different port on the host
but I guess shared hosters dont usually do stuff like this
Bukkit.getPort() is the only source you have, anyway
e.g. my servers all think that they run on 10.0.0.X:25565 but they are ACTUALLY reachable e.g. through <publicIP>:30006
how can i delete my resource from spigotmc?
click the tiny "report" button and tell staff to remove it pls
how long does it takes to remove resource?
a few hours I guess. Or you ping OpticFusion and hope that he's so nice to delete it rn
he's even online now π
but you definitely need to report it yourself too
:D
1 hour later: my account got removed instead of plugin
lmao
k
it's quite hard to get banned from spigotmc lol
you really have to fuck up to get banned there π
lemme do ban speedrun :D
btw
this is the resource https://www.spigotmc.org/resources/ultimate-anti-swear-block-swearing-in-chat-commands-signs-books-on-item-names-and-player-nicks.102807/
why do you wanna remove it anyway?
no'snt
ye
btw your donation link is broken
you entered your discord name there lol
usually people toss in their paypal link or similar π
xD
i tried to serialize and deserialize spigot object(location/itemstack) and this happens why ?
Can you show actual error/your code
gson needs a type adapter to serialize a Location
why are you using gson?
Location / ItemStack etc already implement ConfigurationSeriazable which means they have a serialize() method that returns a Map<String,Object>
Also, from experience, you should serialize ItemStacks using base64 and NMS. Bukkit does an awful job on serialization w/nbt.
gson doesnt know what to do with the WeakReference<World> within the location
oh i was forgot about that
[Reposting]
I have added my dependency into a module of mine, with the shade plugin, but it for some reason isn't getting added to the final jar. I have done this 10 other times in the same way and it has worked... what could be the issue?
Working Project POM (MC 1.16) https://pastecode.io/s/qwg0zbf3
Current Project POM (MC 1.17) https://pastecode.io/s/qfxx389r
"worldgen plugin"
damn
missing scope
i didnt even think that was possible to do without updating one of them
Still doesn't work with scope.
it needs scope compile
your example of the working one has the scope
Oh yeah, my bad there, I added it yesterday as a test
Without a scope the shade plugin has no clue what to do with it, unless you provide a filter
Interestingly, scoping it doesn't seem to make a difference. I added the scope to the working one as a test yesterday to check that
Double-checked with compile scope, still doesn't work.
Imaging making a worldgen plugin
Ah, the dependency is the Commons one, btw.
did you try using the -X flag and reading the whole output?
Oh, I think you did tell me that yesterday? It was 2AM though so I left for the day. Let me try
yep, it will print a TON of useless lines but mostly it also has 2-3 useful lines π
e.g. mvn clean package -X
.setVelocity
i googled
found nothing
what should i pass in the params
I can't find anything incriminating
Here's the output, incase I'm missing something
π https://pastecode.io/s/4kj1asrq
there is no entityvelocityevent so i can multiply the knockback dealt to the entity
i have to cancel the damage event and deal the knockback myself
but like the entity going in the right direction
i found no code
can someone give me one ?
i know its spoonfeeding but im not good at the maths
is there a way to get custom enchants to appear in enchanting table?
Found the issue, it's something with artifacting. Sorry for bothering.
What do you mean ?
so i have this in my api, i'm trying to add a feature that can check if the command failed or not
https://paste.md-5.net/juganelawu.coffeescript Why would ide suggest that defender is always null when 4th line is reached?
Depends on what you mean by "failed"
Depends on the context. Can you send the whole method ?
and the only way around that would be to read the last message a millisecond or something later, and check for keywords which is unreliable and hacky
i thin k my ide shit itself im retsarting i will see @agile anvil
Yeah exactly
Which IDE ?
intellij
think about it
if the entity isnt a player I return
sorry was afk
what's the class it cannot find, and what's the dependency of that called?
thanks! I like it too π
especially the maps, collections and arrays part
yess
bro i am feeling like i had a stroke LightFury it still looks fine to me no matter how many times i read it,...
read it
tell me what u dont get
i might be missing it
if the entity is not a player, then the first line will return the method
so ofc casting it to player is fine
Oh, don't worry about it, it was an issue with artifacting. Maven is working correctly, and when I package my project, it works flawlessly; However, when I created an artifact of it to perform remote debugging, it broke apart, and I hadn't noticed that was what was happening. I created loads of artifact builders ahead of time without setting their dependencies in the POM, so it broke because it wouldn't jar the files.
but yeah intellij will still say that
still doesnt mnake sense why intellij thinks defender will always be null tho, i guess it doesnt really matter
you can add an inline variable
oh yeah that's normal
you HAVE to use maven, otherwise it'll break
using intellij artifacts will break it, that's normal
if (!(e.getEntity() instanceof Player player)) return;
defender = player;
Well, no. I fixed the dependencies and now I can use them as usual.
inline will remove the intellij warning
oh okay, good π
In order to perform remote debugging I have to use intellij artifacts, so yeah.
Actually it's not remote debugging, it's Jar App. Debugging, but even with remote I still need jar artifacting so yeah
But for the final version, for sure, packaging is the way
"worldgen plugin"
isn't there contains method ?
Bukkit.getScheduler().cancelTask(archerTagged.get(p));
}``` i wrote this a while ago and now i regret
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/configuration/MemorySection.html#contains(java.lang.String) yap there is
declaration: package: org.bukkit.configuration, class: MemorySection
not even i can read my code
i wanna do tab completions but it seems like a bitch
just do config.contains("rarities." + args[0])
isSet
is it same as #contains("value",false) ?
only if you have copyDefaults set to true
Just implement TabCompleter
TabExecutor ftw
Hello everybody, who know, how to change max water lvl in cauldron? For example, so that 15 bubbles of water intervene in the cauldron
nobody has told me that unittesting sucks so hard
just put it into a method
public void expectThrows(String term) {
assertThrows(InputMIsmatchException.class, () -> parser.parse...(term));
}
@Test
public void testThrows() {
expectThrows("1 +");
...
}
same thing lol
its more like the amount of invalid expressions that i need to test lmao
why do you consider "1. + 1" as invalid though?
yes
doesn't 1. usually mean 1.0?
cuz nothing follows behind the comma
also .1
ah nice nothing thrown for "1 +"
well that should throw something though lol
i made handling invalid expressions a pain by implementing operator priority
i mean uhh https://paste.md-5.net/ebatesoxuh.cs
what happens if you have stuff like "1.2.3 + 2" ?
lol why did they include the floor in the address
made some nice exception handling for my operand class
ah oki
how can i add lore to a held item?
Get the item in the player's hand. Get the lore, add to it, then set it back to the item.
Building shared by a few companies/organistations
ItemStack item = player.getInventory().getItemInMainHand();
//adding an enchantment to it
item.addUnsafeEnchantment(customEnchants.Telepathy, 1);
//getting its meta and then initiating a lore variable
ItemMeta meta = item.getItemMeta();
List<String> lore = new ArrayList<String>();
//adding lore to the variable so the new enchant is before other lore
lore.add(ChatColor.GRAY + "Telepathy I");
if(meta.hasLore()){
for(String l : meta.getLore()){
lore.add(l);
}
}
//setting the lore to the item
meta.setLore(lore);
item.setItemMeta(meta);```
this should work right?
the adding enchantment part works but i cant get the lore to appear
is there any method to display String in level bar ?
Why not just add to the lore directly?
if (!meta.hasLore()) {
return;
}
List<String> lore = meta.getLore();
lore.add("");
//etc
you mean actionbar?
if teh item has lore i want the enchantment to be ontop of it
the one display your minecraft level
i dont think you can write on that
But you would still end up with the same result. The lore is added after your enchantment. Plus, #add() adds to the end of the list anyways, so any preexisitng lore wouldn't matter in that case.
You mean your XP bar?
i seen people create custom name with colored-background characters
AFAIK, you can't change that without a resource pack.
How do you store information about a player (tp requests) in an array?
Help plz
You have a screenshot of what you are referring to?
bump
what's the actual question anyway? how to use arrays?
using arrays for this seems weird in the first place though. a Map or Collection would seem way more useful than a fixed-size array
i found a thread for this
isn't this PLAYER thing just a custom char in the font?
it is custom font
Oh, that's just custom characters with a resource pack.
is there a way to set the max durability of an item?
yeh i just found that out
I thought you were referring to the XP bar, which you can do some stuff with, but I don't have practical experience with it specifically.
i am still looking forward for a way to deal with it
i read some nms source code but nothing work
I mean, I believe that it's the same as any other modification. Mostly just custom characters tied to texture files.
However, it might be even easier for the XP bar considering it only accepts integer values. You could just map the values of the level to a certain texture and work off that. At least in theory.
XP bar accepting integers? it's using floats, doesn't it?
Uhhh, let me check
oh the level
I thought the "bar"
because that one is either 1 for full or 0 for empty or sth inbetween
Added a condition to an if statement and it stopped my entire plugin from working...
Why I am getting null when accessing a file made with str concatenation?
send full stacktrace
there's no stacktrace
I am using YamlConigurator
if I use YamlConfigurator.loadConfigurator(new File("foo"))) without any string contatenation in the path it works fine
store player data
someone sent me a link here a while ago
but i lost it
but when I add string concatenation for modifying the path to the file it doesn't work
why would u use that bs just do +
I thought u meant .concat()
I mean
I did
ty
name.toLowerCase().replace(" ","_") + ".yml"
"Hello" + " world!" will concatenate the strings together.
Use a db π
If I do this it works fine
// name = "John Smith"
name = "jhon_smith.yml"
If I do this it returns null
name.toLowerCase().replace(" ","_") + ".yml"
works for me
That should work.
A potential issue I see is that if the name already contains a ".yml" at the end, you will add an additional .yml to the string. You should check to see if it already ends with it.
String path = "./plugins/EcoEnchants/enchants/aquatic.yml";
YamlConfiguration yml = YamlConfiguration.loadConfiguration(new File(path));
System.out.println(yml.getString("display-name"));
String concpath = "./plugins/EcoEnchants/enchants/" + enchant.toLowerCase().replace(" ", "_") + ".yml";
YamlConfiguration concyml = YamlConfiguration.loadConfiguration(new File(concpath));
System.out.println(concyml.getString("display-name"));```
clicked.getItemMeta().getDisplayName()) this is the name
Hi is it possible to start a function / datapack without command I could not find anything on Google. I usualy start the function ingame by command /function functionname:play now I have the problem that Players on my server not have permissions on the function command and I tryed things like this to execute the command for the player player.getServer().dispatchCommand(player.getServer.getConsoleSender(), "sudo JacksaYT function functionname:play");
you should be using File.separator instead of /
Also, why are you using the full path?
and dont hardcode plugin path
You have #getDataFolder()
^^
or #getDataFolder().getParent()
what does this gotta do with my issue?
Nothing in particular, just some advice for cleaning up your code. As for your issue, I think you should re-read my initial reply.
which one?
This one right here to be specific.
That still doesn't change what I said though. What guarantee do you have that #getDisplayName() doesn't end with ".yml"?
Yeah, I'm pretty sure
Still doesn't change the fact, but alright. Assuming that your input is valid, what part isn't working as expected? Does it only work for specific items?
wdym it doesn't change the fact
I am getting that name
You're clearly missing the point. If for any reason, your displayname has the String ".yml" at the end, and it runs through your code. You will end up with a string that ends with ".yml.yml". Now, your current inputs may not end with that specific string, but if it ever did, you would more than likely get an NPE when it tries to retrieve the file.
String path = "./plugins/EcoEnchants/enchants/aquatic.yml";
YamlConfiguration yml = YamlConfiguration.loadConfiguration(new File(path));
System.out.println(yml.getString("display-name"));
System.out.println(path);
String concpath = "./plugins/EcoEnchants/enchants/" + enchant.toLowerCase().replace(" ", "_") + ".yml";
YamlConfiguration concyml = YamlConfiguration.loadConfiguration(new File(concpath));
System.out.println(concyml.getString("display-name"));
System.out.println(concpath);```
now you see the issue?
I love that you are ignoring the other legitimate issues that we have been pointing out, but I might be wasting my time.
If it isn't clear by that output, it's clear that enchant isn't what you are expecting it to be.
Hate it when it happens mate, shit is annoying af
π’
what did you point out, I showed you the output why that wasn't the issue
I am literally trying to send you the most debugging stuff for you to help me with the issue
Except you haven't. You keep showing me what you expect, but what you are getting is clearly different. Everything you have shown leads back to an issue with your input. Print out enchant and maybe you'll start to understand.
Do you know java?
I am pretty sure they dont
i tried to add this custom font but something wrong
this cannot possibly return null
String#replace simply cannot return null
Look, maybe we need more code being shown. Cause from what you have given me in the forms of screenshot don't exactly line up with what I would expect to see. When do you print out enchant in relation to the second block of code that prints out the paths?
Hello! I've got a question, I want to delete every item that does have a specific NBT Tag on the Item when the player dies. Does anybody know how to check if the item that got dropped by death has a NBT Tag?
Oh no, it's not that. It's most likely the YamlConfiguration being null since it can't find the proper file name.
public static Inventory enchantInventory(String enchant) {
Inventory inventory = Bukkit.createInventory(null, 54, enchant);
fill(inventory);
String path = "./plugins/EcoEnchants/enchants/aquatic.yml";
YamlConfiguration yml = YamlConfiguration.loadConfiguration(new File(path));
System.out.println(yml.getString("display-name"));
System.out.println(path);
String concpath = "./plugins/EcoEnchants/enchants/" + enchant.toLowerCase().replace(" ", "_") + ".yml";
YamlConfiguration concyml = YamlConfiguration.loadConfiguration(new File(concpath));
System.out.println(concyml.getString("display-name"));
System.out.println(concpath);
System.out.println(enchant);
return inventory;
}
Ok, I do hope you understand that the output screenshot you sent doesn't line up with that code.
If it did, Aquatic would be at the bottom of the console and not the top. This is partly why I am so confused about this.
Okay nvm found it out with getDrops
and Aquatic is at the top because of System.out.println(yml.getString("display-name"));
how to get server time?
With java you can get the nano time or the milliseconds time
System.currentTimeMillis()
Well, considering the first case passed, there should be no reason the second one shouldn't so long as the file actually exists on the disk.
ty
What can be the issue then?
The only thing I can think of is a missing file. What does the contents of the enchants folder look like?
Is it possible to add an itemstack custom NBT tags in 1.8.8?
I already thought of this but you can see that the path on path and concpath are the same, so why would it be missing
Yea, I just realized that.
Ok
I doubt this would be the issue, but what happens if you remove the first case?
[19:37:43 INFO]: Akex06 issued server command: /enchants
[19:37:44 INFO]: [EcoEnchantsInterface] null
[19:37:44 INFO]: [EcoEnchantsInterface] ./plugins/EcoEnchants/enchants/aquatic.yml
[19:37:44 INFO]: [EcoEnchantsInterface] Aquatic```
this is what happens when i try to use a free host for beta testers to try out my server lol
which packet is the brand in
which brand
?
should still be a custom payload packet
Hmm, maybe try restarting the server? Weird shit like this happens sometimes when I develop. I'll have things that I know work, start act weirdly and it throws me off because there shouldn't be any real reason for it.
Then they never happen again once it fixes itself.
still null
yes.
What Feels like using Bukkit
not Getting a Joke
Feels like have 0,05% of a i3
can someone help me with this
i shouldnt need to
i had to remove dynmap just to run this server and i can barely even join
with that speed maybe you do need it
the whole point of this was supposed to be a lazy workaround to portforwarding for beta testers to do their thing
but the server can barely sustain one person
even though i removed like half of the plugins
try changing the jar
to Something Crazy Fast
Is it possible that ConcurrentHashMap#entrySet will return an empty set even if ConcurrentHashMap#isEmpty is false?
I guess I'll move to ConcurrentHashMap#forEach, hopefully that one behaves better
i unknowingly replicated that chunk bug from that one themisterepic video
how tf did i just upload 95 mb i dont have nitro
Server is boosted
oh
Anyone know how to spawn a falling block via protocollib? I kind of got it half working... problem is the falling block is invisible and I can see its hitbox flashing on/off with f3+b. Super weird.
cant you just spawn one without protocollib?
Not really, as the falling block needs to have no gravity or collisions
I know that the no gravity part is easily doable in standard API, no collisions I am not too sure
Though I am fairly certain that someone on the IRC channels managed to do exactly that with standard API
i accidentally did no collisions
the snowballs lol
they completely ignore collision checks
on both client and server
Looks more like the chunks are considered non-ticking for the server to me
it seems like just the entities are behaving weirdly though
blocks still work fine
in the surrounding chunks
Mostly because nonticking chunks mainly affect entities
If I have a class Something<T> which has a method public Something<T> doStuff() and I have a class Somethong extends Something<String>, and a method public someStuff(Somethong somethong), how could I make it so I can call someStuff(mySomethong.doStuff())
or did I just forget how inheritance works
yes
however if it extends the method should just be there without
super is to call a methodf in the parent with the same name as the one calling (usually)
do i have to try catch if i do #getMaterial(String) when string isnt a material?
null check
k
how could i have a block be placed for, say 5 seconds and then canceled?
scheduler
thanks ill search that up
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
You can use BukkitScheduler#runTaskLater for example to do something after a specific period of time is up
?scheduler
ing
Hello elgar
Whats the best way to make a lootbox that gives multiple things
store the items in a list and get a random thing from it?
exactly
π
how coudl i summon particles in an area?
Depends on the particle. Some of them can be spawned in bulk with the x, y, and z spread arguments
Though all particles are different
alright thanks
My current loot system builds on a single interface which can be implemented to add loot to
chests, entities, achievements etc.
public interface Loot {
void applyTo(Player looter, Location location);
void applyTo(Player looter, Inventory inventory);
default Loot withCondition(Predicate<Player> predicate) {
return new ConditionalLoot(predicate, this);
}
}
But its quite extensive
This is how ItemStack loot looks like
For multiple loot elements i used the compound pattern
you are tryign to register a listener you already registered
You tell me, its your code
i really dont know where that could happend
send code where you're loading listeners
on a player joining I'd guess
yeah i found where i mess up
public void kitsGui(Player player){
Inventory gui = getServer().createInventory(player, 9, getConfig().getString("MainColor") + "Β§lSelect a Server");
List<String> kitss = new ArrayList<>(kits.getConfigurationSection("Kits").getKeys(false));
for (String kit : kitss) {
ItemStack stack = new ItemStack(Material.valueOf(kits.getString("Kits." + kit + ".Item")), 1);
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(getConfig().getString("MainColor")+kit);
stack.setItemMeta(meta);
gui.setItem(getConfig().getInt("Kits." + kit + ".Slot"),stack);
}
player.openInventory(gui);
}
but i really dont see anything that could trigger that thing ?
when player joins it runs this method
and it will run this method when player respawns
delay it a tick or two
so they can choose kit
oh okay
how should i delay it ?
?scheduling
for (CustomCryptGhoul mob : CustomCryptGhoul.mobs) {
if (e.getEntity() != mob.getEntity()) return;
if (e.getEntity().getKiller() == null) return;
mob.getDrops().forEach((k, v) -> {
if (ItemUtil.calculateChance(v, 100)) {
e.getDrops().add(ItemUtil.createItem(k, "DROP_CRYPT_GHOUL"));
if (v <= 5) {
e.getEntity().getKiller().sendMessage(SkyblockBasics.replaceChatColors("&6&lRARE DROP! " + k.getName()));
}
}
});
}
for (CustomSkeleton mob : CustomSkeleton.mobs) {
if (e.getEntity() != mob.getEntity()) return;
if (e.getEntity().getKiller() == null) return;
mob.getDrops().forEach((k, v) -> {
if (ItemUtil.calculateChance(v, 100)) {
e.getDrops().add(ItemUtil.createItem(k, "DROP_SKELETON"));
if (v <= 5) {
e.getEntity().getKiller().sendMessage(SkyblockBasics.replaceChatColors("&6&lRARE DROP! " + k.getName()));
}
}
});
}
rather than duplicating this code for each class type of Custom...MobType is there a way I would be able to refactor this code into a method? is this something possible with generic Class<T>?
How do you make it so that when you click on a message it runs a command in the mc chat?
its just a Mob so use that as a generic
BaseComponents/TextComponents
TextComponent tc = new TextComponent("") // message
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "")); // command
player.spigot().sendMessage(tc); // send player message
ty
CustomSkeleton and CustomCryptGhoul are classes I've written with a static variable mobs to keep track of the different iterations/entities of the custom mob in the world, so that wouldn't work would it
those mobs are basic extensions of Mob?
sojava public void doStuff(Collection<? extends Mob> mobs) {
or something close
not using an extension, although is that a suggestion that i should rewrite this class in a more inambiguous way?
I just spawn the entity, and keep track of them in a reference.
you could have both your Custom... classes extend a base class.
Why not tag the entity with PDC instead
put all teh duplicate code in teh base class, then just have the static list in the actual class
tagging them is better
No need to track them then
Just check for the tag on death and handle the drops
i could incorporate this to clean up the code in all my custom mob classes, and use a pdc to replace my static mobs list, that's best yeah?
much better
how do i check if a string is the name of a Player? i'm trying to do a party command
Bukkit.getPlayer(string) != null
Dont check custom items for equality by checking the ItemStack or ItemMeta.
Always use the PersistentDataContainer to check for custom items.
How could i make a player take falldamage without falling?
You fire a damage event and set the cause as fall damage
can i do that directly onto the player or do i have to get a LivingEntity
how can i set the cause?
raising an event won't cause damage
you have to throw an event and check if its cancelled. if not then player.damage or setHealth
Sadly that doesnβt seem to affect the death message
hm
so no way to give cause? i wwanted featherfalling to make the player take less damage
You can easily do the math on that
Wait that's completely different from what you were asking before 
Was just thinking is there a reason spigot doesn't have a method to accept a List<Pair<EquipmentSlot, ItemStack>> instead of just 1 slot and 1 item for player.sendEquipmentChange().
Doesn't seem too complicated
Then just listen to the EntityDamageEvent, get the cause, check if its fall damage and reduce the damage.
Is there a way to cancel a scheduler?
call cancel() from within it
?scheduling <- all covered there.
Itβs just how the packet is
You can just locally cache the stuff if you really want it to be easy
I was just curious as public PacketPlayOutEntityEquipment(int var0, List<Pair<EnumItemSlot, ItemStack>> var1) { accepts multiple so I wondered why not but I see
Reason why is because it's an awkward API
Maybe, maybe, a Map<EquipmentSlot, ItemStack>, but it seems awkward
When I initially added that method, I didn't really consider the fact that someone would want to send multiple equipment changes. I wanted to kind of mirror the existing APIs that send client-sided changes, like sendBlockChange()
that's cool and all but when are we having a full client-sided block api
if I add/remove/move item in enderchest, it's "InventoryDragEvent" right?
with chunk support, maybe allowing entities to collide with client-sided blocks
so even entities have their own client-sided blocks
InventoryClickEvent too
I wonder if it's possible to mask real blocks as air blocks if I modify all the collision code π€
mostly for players really
server seems to rubberband
I mean literally none of that made any sense. You have a client-sided block API. The sendBlockChange() method. Sending chunk changes used to have an API but it was never updated past 1.13. It used byte data, which was removed later iirc. Though if you want the block to collide with entities, you would put it on the server.
what if I only wanted some blocks to collide with some entities
I mean
I ended up achieving what I wanted with tons of nms
Then you're in a perfect position to draft up an API for us π
uhhhhhhhhhhhh
I had to go full on custom fancy entities
and override move methods
grr
it needs A TON of internal changes
but sure I could try forking spigot and doing that
by A TON I mean either modifying the block accessor to provide an entity, which breaks nms
or make each entity have its own map / cache
doesn't have any entity code
as I'm not gonna paste like 600 lines of nms
for 1.18.1 paper, in specific
Looks like sendChunkChange() was removed in 1.16 alongside other deprecated API removals, but it can definitely make a comeback
I use multi block change for now
some annoying things are like
sending a fake block SOLID -> AIR will actually cause banding issues
can be fixed on the collision checking code for all entities
which is what I did
but I also had to modify the navigator to treat fake blocks as real
I'd end up burning like 20 hours on this api change
and maybe worry about persistence
I want to do work with inv add item. which event should I use?
But which event get called when a player put item on chest?
uhh
InventoryClick some times
Other times it's InventoryDrag
it really depends
Shift / regular click? Inventory click
If you drag an item across slots (even if it's just starting a click outside the inv, and dragging 1 item in), then it's drag
oh. got it
Ah ok I see, Its just useful if you want to fully hide someone without using the hideEntity method so you can still hit them just not see them, some minigames need that. There is an easy work around but would be a nice shorter way
I guarantee you that #sendChunkChange() could be easily reimplemented with some sort of parented class to ChunkData using BlockData instances. The packet still exists
https://wiki.vg/Protocol#Update_Section_Blocks
let's see if I can hack together some code
because I don't want to post a PR
I wonder how the ChunkData class would do tho
maybe something similar to ChunkSnapshot ?
is it possible to apply night vision without giving a potion effect?
No no, we have a ChunkData interface already
From the world generator
Can create one with Server#createChunkData(World)
wtf copilot
All that would really need doing is adding a few methods into Player, sendChunkChange(int chunkX, int chunkZ, ChunkData chunkData, boolean updateLight)
Then we would have to account for the fact that that packet updates chunk sections, meaning 3D chunks. So it would probably have to send multiple packets
Should also account for,
Servers should avoid sending block changes in unloaded chunks [on the client] and clients should ignore such packets.
Which short set? Is there one in ChunkData?
(I've never looked at its implementation)
ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section, boolean noLightingUpdates)
Curious as to why that's a short. The serialized data is an array of longs
SectionPos - position of the chunk section to update at
ShortSet - set of indexes of updated blocks
LevelChunkSection - The section, where the blocks will be fetched from
noLightingUpdates - self explanatory
looking at the packet impl on 1.18.1 (version I have at hand atm, shouldn't differ), apparently the position is part of the serialized long
So the first 12 bits are position, then the other 52 are the blockstate itself
Other way around
it's 3:23am have some slack
I was about to say 22 bits before I realized it was a long
I'm the kind of guy that uses a calculator to do 100-5 just to check out my trig math
But yeah, you can send that update sections packet, for only a few blocks
and have a much smaller packet
so the shortset is important
the constructor fetches the states at the positions from the shortset
Mhmm
and if the section is null, it just assigns the state as air
So thinking about how to do it the bukkit way, we could have a map of offsets within the chunk
or make a chunksection api
or at least a chunksection location api?
Again, I'd be inclined to reuse ChunkData
we still need to be able to indicate what section we're dealing with
if you want to send for the entire chunk, it's 1 packet per section
what if we're only changing 1 block? is it really worth it to send 4096 packets per chunk section
That's fine. Create a child class that extends CraftChunkData that tracks changes to the underlying data, then you can get the modified sections by just dividing by 16
Sections are 16 tall, aren't they?
Ye
Maybe a ChunkChangeData class
that just has like
set(int x, int y, int z, BlockState state) type deal
or BlockData
set, get
maybe make it concurrent idk
I'd just say edit the existing ChunkData ;p I really don't see any reason to not use it. It exists and mimics exactly what is needed
maybe make a wrapper with the chunk section pos or something?
Would probably just update the existing implementation too. No reason for a child class
Sure we have the ChunkData, we still need the position where to display it at
what if you want to send the same data across multiple chunks
Yeah. Track those changes in CraftChunkData when they're made
Store an array of longs
we can store that yeah
like a Map<Short, BlockData> changes maybe?
So we have both a ShortSet as the key
but also a matching set of blockdata
Not sure how CraftChunkData is implemented. Haven't looked
I'm sure it can be altered slightly to support what's needed
I figured it didn't modify the world, but perhaps it does for chunk generation
you try to send a fake chunk and end up breaking your world
Anyone can tell me how can I make this
if player open echest, and player try to put more then 5 shuklerbox in enderchest from his inv, it will block on 5
brother are you trying to ask us to code a commission for you or something
I am trying to do this. But its not blocking on player inv move.
And am trying to add a feature in my open source plugin ;-;
Anyone know how to get a blockstateID for a given block?
For what reason? Might already be API for what you're doing
if you want to dismiss choco's argument, Block.getId(nmsState) does what you want
tankz
You can get the nmsState by doing CraftMagicNumbers.getBlock(MaterialData/Material/Material&byte)
if you want to dismiss choco's argument
π
don't have nitro to use :eyeszoom: unfortunately
@worldly ingot I'm making a projectile that looks like anything, including falling blocks
need the blockstateIDs to send the packets for falling blocks
the base projectile is actually a trident
we should make a full client-sided api for spigot
blocks, entities, players, behavior
just because
Then PR it, promise to maintain it and just vanish
Client-sided entities is hard. How do you represent an entity on the server that doesn't yet exist?
by sending packets
it's not too hard
I mess with client-sided entities all the time
Right... but there is no concept of packets in Bukkit
mf I made clash of clans with client-sided entities and blocks
pasting schematics as client-sided blocks
all in 1 world
There was API that did attempt to introduce an entity before it was added to the world, but it fell through. I think in 2017
When I send the packet for the trident, so long as I change the initial packet to be what I actually want it to look like, I don't have to change the other packets.
E.g. I change it in the first packet to be an ocelot
I don't have to change future packets at all.
All players will see an ocelot flying through the air
they'll receive movement packets
we should make a game show where we grab like 3 funky developers
but nothing that actually updates the appearance back to being a trident
and see who comes up to the most janky solution to a problem
why make minigame map management when you can make all maps and entities client-sided
that way you don't load maps, they're all in the player's imagination
it's like advent of code, but horrible
and we just give a participation trophy to the winner
Yeah, there was a World#createEntity() API being proposed on 2018, but the author has since vanished
Virtual entities, he called it
@echo basalt IRegistry.BLOCK.a(CraftMagicNumbers.getBlock(Material.ACACIA_SLAB));
so this gets me the int I want?
Yes
(acacia slab being an example)
uhh
ty
i mean this would just be the 'default' acacia slab im sure
yeah
lolwat
registry returns -1 if it doesn't exist
but it should only return positive ints?
oh
yeah
ty
@ancient plank give props to this guy
wot
i'll show you once i've got this worked out @echo basalt
i am going to make an example cmd so i look like the avatar
uh okay
man's making an image -> block thing or something
nvm I'm tripping
you explained your concept lol
imagine if I made a spritecraft clone but as a plugin
i need a method for name above head :l without changing playername
π€
armorstand
bruh
make like
armorstand that moves along the player with packets
onPacketIn -> if id is playerId -> send packet for stand too
idfk
hey illusion
you might know the answer to this to
can i send multiple packets all of the same player to someone and make it look like that player is in multiple places at the same time?
lol wtf
No because each packet would overwrite the last
I'm thinking on what can I do to make this better
hum
well there's some way to do it, though
like i can have multiple players all disguised as the same player
using a /disguise plugin
Or you can make fake players yes
yeah fake players in that case
might be offtopic, but what would u all consider laravel or express (both from different stack)
currently doing laravel but express is a pain in the ass after making my first app on it
thanks copilot
is it possible to display cpu and ram usage ?
so i'm trying to implement parties into my plugin, but i want to make them custom SO i decided to handle it with a hashmap
but i don't know if this code is efficient
How do I add players to a team? The .addPlayer is deprecated
addEntry(String)
Still addable
Teams don't require players anymore. It can be any string
So is the string parameter the playerβs name?
Yeah
Ah ok
Why the name grr
Memory usage, yes. You can get this run Runtime.getRuntime(). There are some methods in there pertaining to memory available on the JVM. Regarding CPU use, it's iffy. You can get it with the OperatingSystemMXBean which can be one of two implementations, both of which are internal. You would have to access them with reflection.
var os = ManagementFactory.getPlatformMXBeans(OperatingSystemMXBean.class);```
Then you can use reflection to get some of the methods in implementation
https://docs.oracle.com/en/java/javase/18/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html
Doesnβt seem to work, itβs player.getName() right?
Yeah
how would i do this? i have my current code up here, instancing this in the javaplugin class, and using a getter to get it in my other classes
What you have is fine. Though you're probably going to benefit from a Party object at one point or another
(you could also take advantage of a Multimap in this situation, but if you create a Party object like you should then this is no longer relevant)
Heya π
I have a really weird problem that I can't seem to find anything helpful about.
I want a command color that I have registered in my plugin.yml like this:
commands:
color:
description: Changes the color of your name in chat.
usage: "/color <color> (type only '/color' to see the list of colors)"
However, when I try to register it in my onEnable(): getCommand("color").setExecutor(this); I get the error that getCommand is returning null.
(yes, I know I should be making a separate class as an executor, but it's just a really tiny plugin so I don't really care)
Is there something obvious I'm forgetting? I've googled this a bit and seen like half a dozen forum posts that seemed to have this problem, but all of them were either fixed magically with no explanation or had causes that I've already checked.
Fun fact: you don't have to set the executor if it's executing in the JavaPlugin class
You can remove that line entirely lol
I know, I didn't have that line there originally, but the command wasn't showing up in the server so I thought that was missing for some reason.
Possible that it's failing for some other reason then. What's your full plugin.yml look like?
No other errors on startup?
No errors whatsoever.
Full plugin.yml:
main: com.cicadacastle.minecraft.core.Core
name: CicadaCastleCore
version: 1.0.0
description: "The core plugin for the Cicada Castle server."
api-version: 1.19.2
load: POSTWORLD
authors: ["Kanashimi"]
commands:
color:
description: Changes the color of your name in chat.
usage: "/color <color> (type only '/color' to see the list of colors)"
api-version: 1.19
The minor versions don't exist
Also, POSTWORLD is default so you can remove that line as well. Though that's more of a minor detail
Yeah, I had that phase where I wanted to have everything in there explicitly, I just kinda carried that over from an older plugin of mine, should probably get rid of it lol
The command is still not showing up.
Does your plugin show up in /plugins at all? And does main point to the correct class?
It does show up in plugins. And yes, main does point to the correct class.
Do I just save and then post the link?
Yep!
I was hoping for something more fun
I'm not entirely sure why your plugin's command isn't registered.
What's your command's implementation look like?
https://paste.md-5.net/welawupebe.js
Not that it matters much lmao
Oh believe me, so was I.
I uh π I think I'm out of ideas. Implementation looks fine too
I've exhausted my list of "things that usually go wrong"
Yeah, and I don't think the implementation makes any difference anyway since the command itself just doesn't get recognized lol
Hey, you could have had a return false in there with a condition that always returned true!
I mean yeah but that would only appear when the command gets executed. It wouldn't result in the command not showing up anywhere or in getCommand("color") returning null lol
I'd just hack into the command manager at that point
I'd gladly do that if I had any idea how lmao
how can I use gradient color in my plugin? Do I need to import some third-party plugins or can I just use the original spigot API to do that
Gradient color for what?
for chat, player prefix or messages
Minecraft is limited to 16 chat colors, there's no gradient possible.
Pretty sure that not even third-party stuff could do anything about that. Adding more chat colors would likely require the game to be actually modded.
so how this plugin make it work?
1.16 introduced RGB colours in text components
Huh, that's fascinating. Never seen something like this.
But why don't you just use this one then?
There are probably some frameworks to do gradients, though MiniMessage is probably the best. Note however it makes use of Adventure
cause I am was wondering if I can do this by original spigot API
Use minimessage
Disgusting
Paper better
Sometimes
im wondering guys
i got an idea but not sure how should it be correctly to do
how should i move data from 1 plugin to other plugin
(no sql.)
i was thinking to move it thru chat
so it will output it into chat meanwhile the other plugin read the data i transfer
okay! so how would i make a party command that uses a hashmap and instantiated class
By calling methods?
Depends on if you have made them yourself, you can simple get an instance of a loaded plugin from another and read its fields with getters or public parameter
You can just depend on your plugin. Plugins can use each others methods and classes.
If this is on a proxy you should create a class which handles/stores parties, then you can reference this class in your command class, that way you can have multiple command classes all accessing one instance.
m1 is kinda op
Gets crushed by so many CPUs in minecraft and other java applications but ok
Rip
Are you using MXBeans to read this?
M1 is brand new. It should be better than a potato
m1 is like 2 years old now
Still pretty fresh
i mind spent some one a dedicate m1 server :d instead of some x86 types
What
Yeah probably spending quadruple the price for the same performance if something like this existed.
m1 would be a horrible choice for a dedicated server. Makes the efficiency cores pretty much useless.
still waiting for dedicated minecraft server hardware to optimize stupid stuff like chunk loading
just have a dedicated chip to run all the chunk processing
Just get one with a fast nvme, a ton of ram and then set the unloading cache to 20mins
I mean yeah but where's the fun in that
why make developer's life challenging and fun when you can just make a dedicated chip for managing chunks
let's say you want to host a minecraft server but you're a mac user
The first mistake is using a mac
you grab makeup as white as the mac mini chassis and get to work
There is no trick. This is client side.
thanks
thank u too
its client side...
you can do a packet of different number
not really remove the red number
