#help-development
1 messages · Page 666 of 1
ctrl + shift + k >>>>>
minimizing mouse movement = less problems with ur body
like back, neck and sholder pain
I claw my mouse so do very little arm movement
i have a colleague that wrote his master exam in vim lmao
there's soooo much free space at the top, why do they just remove buttons from there? an empty space is wasted space
it's about the movement to and from the mouse
but looks less crowded
well but an IDE is not some fancy furniture or a piece of art that you want to look at, but a tool
Something like this? (first line)
I like my Jetbrains furniture and have a screenshot of it as my desktop background /s
Functional over pretty
i generally agree
professional tools should be cramped with buttons and stuff lol
steve has a point, use early returns / guard clauses
When you read this, chances are high that someone saw your code and decided that you did something that is considered horribly bad: using the arrow anti-pattern. What the arrow anti-pattern is Look at the following code: It looks like a huge arrow (>) symbol. It’s ugly, unreadable and hard to maintain. Now, let’s say...
Also, use ChatColor instead of §
||Or better yet, components||
why?
You don;t need to check the event type at all as you are preventing death
far more work
because you're hardcoding a magic value that might change anytime
vanilla doesn't even use § anymore
whats a recommened way to store userdata? e.g i am making a report plugin and need to store user reports.
depends - do you need this data to be accessible even for offline players?
but i also have this tho
yes
depends on teh amount of data
(which i could now put into the other method tbh)
then use a database (mysql, sqlite, ...) or files (json, yaml)
i was thinking sqlite
just use early returns
are there any good tutorials?
what the frick does that mean?
so if (dont want this) return; u mean?
public void onSomeEvent(SomeEvent event) {
if(!(event.getEntity instanceof Player)) return;
if(!somethingElse()) return;
...
}
bro my whole project is based on that verbose aah code
exactly
that would be a massive damn refactor
Then you better start now :D
i mean i did have this in mind at some point
well if it works now, keep it. but for future stuff, better make it right
but it's a LOT of work...
no. lol
i hate if my code (in 1 project) is not in the same pattern
why the tab completer for a command doesn't work? i registered the custom command tab completer but it just auto completes to my username
i know the verbose code doesn't help with readability but since it's gonna be open source, it's supposed to be as readable as i can make it
?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.
did you add a list?
with options?
the command itself also doesn't work, wait i'll share my plugin.yml
yes
gotta get rid of that mindset. Or you'll end up maintaining/refactoring 200 projects each time you learn something new
because the default tabcompletion return onlineplayers
but i'm a perfectionist lmao
I'm creating a reward system and you can get items but each item has it's own chance so you have a set chance to get a certain item. The way I'm planning to do it right now is that I'll make a list of 10 items, generate a random number between 0 and 9 and then you'll have 1-10 of getting whateveritem, then if the item you got from the list has it's getting chance set to lets say 1%, I'll generate another number between 1-10, and if it matches the old random number generated between 1-10 I'll give it to the player. Anyways idk if ya'll understand everything I just said, but I'm just asking if ya'll have any better ways I could do it?
name: TikTok
version: '${project.version}'
main: org.shalevc1098.tiktok.Main
api-version: '1.20'
commands:
tiktok:
description: "TikTok Command"
usage: /<command>```
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.
now how do you use it in code ?
here
@Override
public void onEnable() {
// Plugin startup logic
config = new Config(this);
config.saveDefaultConfig();
if (server == null)
setupWebServer();
}
private void registerCommands() {
TikTokCommand tiktokCommand = new TikTokCommand();
tiktokCommand.registerSubCommand("reload", new ReloadSubCommand());
this.getCommand("tiktok").setTabCompleter(new TikTokTabCompleter(tiktokCommand.getSubCommands()));
this.getCommand("tiktok").setExecutor(tiktokCommand);
}```
random question, does yaml care about the amountof leading whitespace ?
idk
so where is registerCommands called
your not calling ^^^^
lol, happens
some projects should just stay dead once they are, don't bother keeping everything up2date if it's unusued
my bad
oh lmao
you have a fitting profile pic
lol
and then u run into the classic developer problem, where you have to read some of ur old code and try to understand it for 10 hours until you give up
btw another question: when rebuilding the plugin and reloading the server, i get alot of errors. i'm using jetty. is there a way to reload the server even after hotswapping the plugin without all these errors?
what kinda errors?
If your code is that horrible, it should not be reused anyway. Usually it's just bad design but still understandable
i don't think my code is horrible... just... verbose :|
like... that's a part of one of my commands
for the love of god
burn this
throw this into a blazing volcano
okay
also some of that is in progress of refactoring
you do know && exists, right
errormessage-handling
paper
lemme test with a brand new spigot server
I am not saying that's the issue, just pointing out that you're asking in spigot DC server while running a paper MC server
can probably ask chatgpt to improve it with guard clauses - it might be able to get a decent result and save you some time
ye but i'm making a spigot plugin
How would I code so if you have a list of 10 items, you have 0.1% of getting a specific item out of it
Like Ik do have 1/10 chance I'll create a list of 10 items and generate a random number between 0 and 9
that's what i meant
either sepearte ifs or checking the clauses twice just for the message
which is dumb
idk what jetty or whatever is, but I think you have to close some connections or something ?
probably just wait for someone who knows what that is
if i reopen the server it works just fine
then your reload might be wrong
so u do the checks seperately at the beginning and then begin to make the actual functionality
hmm makes sense tbh
maybe
take a look at weighted random to achieve that
I don't want to get burned alive here but
I use plugmanX to reload specifically my plugin
have not had any problems yet
plenty of resources on google
oh god that's a lot of stuff to do... well i did similar large refactors (if i use it in the future i want the current stuff to be the same pattern.... for this project at least... because this is really important to me)
this project is pretty much how i started coding
and not only doing a little here and there but actually coding
what's that
googling hard for you?
https://www.spigotmc.org/resources/plugmanx.88135/
besides metaspace memory going higher and higher, but occasional restart fixes that
why would u get burnt alive for that? lmao
check their inventory
Does anyone know the progress on moving Material and other to classes ?
The feedback post has not had any activite in like a month and idk any other place for it.
@EventHandler
public void onDamagePlayer4(PlayerInteractEvent event) {
if (event instanceof Player player)
if (player.getInventory().getHelmet() == SH || player.getInventory().getChestplate() == SC || player.getInventory().getLeggings() == SL || player.getInventory().getBoots() == SB) {
if (player.getEquipment().getHelmet().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Stone Helmet")) {
if (player.getEquipment().getChestplate().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Stone Chestplate")) {
if (player.getEquipment().getLeggings().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Stone Legging")) {
if (player.getEquipment().getBoots().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Stone Boots")) {
if (player.isSneaking()) {
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 60, 2));
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 2));
}
}
}
}
}
}
}
will it work @pseudo hazel
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
oh there's a command for it lol
will it work is a weird question
you should ask your server if it will work, not me
my guess is no, since you're comparing ItemStacks with ==
also onDamagePlayer4 as a name makes me worried you have 3 others
also, please, use early returns
so many arrows today
And check isSneaking like second
better performence wise
or the fact that its an interactevent
😒
oh god, I haven't even noticed that, I assumed it's the damage event XD
lol
or the fact its being checked if the event is a Player object
this wouldnt even be something you do in an event, but rather a runnable, assuming its just a passive effect
lol the more you look at it... xD
okay so in short, no the code wont work, on many levels
hehe
ikrr
ykw fine i'll do it. i'll rewrite every single damn command lmao
And the world thanked you
is that php ew
if thats the only thing you're alarmed by you need a new set of brains
you have a set?
idk
depends on how you say it i guess
brain or brains
it sounded more fun than "a new brain"
🧠
if (!config.getBoolean("reports.enabled", true)) {
reporter.sendMessage("§c§l(!) §cReports are disabled!");
return true; // ???
}
should i be returning true if i want this message to be sent then the command to end?
yes
Based on docs:
true if a valid command, otherwise false```
can i not just return true at the end of the command?
if i handle everything like not enough args, etc
Does getFullTime() in World class returns tick?
most people handle their own failed command messages so if you do that, just return true
?tryandsee
The docs on that one are not the best
ima try rn
:D sry
Okay my Idea is you can make /duel than for example 1b then someone can accept your duel like a Coinflip and you fight in an arena with the loot you have in the inventory winner gets all the money. Could anyone create an plugin like this ?
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
xD
I can’t Create an forum
Well then work on your reputation. This is not the place for commissions
I think you need a small amount of answers on threads to post there
Uh guys, I use this code to increase the speed of a player:
AttributeModifier speedModifier = new AttributeModifier(
"speed-boost",
2.5,
AttributeModifier.Operation.MULTIPLY_SCALAR_1
);
player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).addModifier(speedModifier);
I made an error by putting 2.5 because yeah that doesnt make the player 2.5 times faster but alot faster. And i wanted to remove this from the player but its not happening anymore. I tried the same code but with .removeModifier. Nothing happend, rejoining, nothing happend, restart server, nothing happend. I even tried /attribute and it says its set back to 0.1 but i keep having a huge amount of movement speed, Does someone know how i can reset this?
delete your player data file :D
There is no other way?
it is definitely a way
no idea if there is other way
p 😭
Ill try thgat
valid values are between -1.0F and 1.0F
How can you develop plugins in js?
Good to know
and yes, negative numbers invert controls lmao
Thats kidn good to know for some special debuff in a minigame haha
The player.setWalkSpeed() also doesnt fix it
i mean deleting the playerdata is mandatory anyway
since the attribute is saved there
but for the next time you can just use setWalkSpeed and setFlightSpeed
Yeah i think thats better haha
these are the default values btw.
so i recommend having an argument like "reset" that does what is shown in the screenshot
bad advice, harder to stack modifiers
Ah okay
I assume i just only the delete the playerdata in the world where this is happening?
i don't think .dat_old really matters in this case but i've never done that really so yeah
Anyone?
question about mongodb, how can i create a sub category, json example
{
"buildinfo": {
"Hellow": "hello"
}
}
i tried searching on the internet without answers
i assume you use the official mongodb java driver?
you just insert that into the collection as a bson doc
you can simply nest bson docs
thank you, I did and got a decent overview so I can implement it now.
yes and no, im using a wrapper called Milkshake
i'd do it like this
Document topLevel = new Document()
.append("Foo", "Bar");
Document nested = new Document()
.append("Foooo", "Bar");
topLevel.append("Nest", nested);
it might be similar dont know that particular wrapper
https://github.com/sammwyy/milkshake if you want here the link
looks like that library just does it for you. so if you start nesting objects it would probably store them like that as well
yeah
never heard of nesting object if you can explain
looks like it should be roughly supported
just add a field to your class or record ur inserting/updating
record A(String foo, B nested) { }
record B(String bar) { }
the library should convert that to
{
"foo": ...,
"nested": {
"bar": ...
}
}
yea that ^
@Serializable
public class User extends Entity {
public UUID uuid;
}
like this?
yea for example
yeah
uuid will probably be stored as a byte array
yes uuid is not nested
i hope it is
its just to make it clean
i don't understand one thing how can i integrate it on the code tho?
it should do it automatically
well you can wrap the uuid in ur own object and then it would probably be nested but that makes ur code... questionable xd
already tried and just not written
i guess they still looking to improve the library in the area ur looking for ;s
yh but that should mean its already roughly supported
probably never added the api is not got an update for about 5 months lol
i'd just depend on the official library and make it myself tbh
made an overengineered in the wrong place odm in typescript and never used it again
but it was fun at least
worth it!
i enjoy making systems more than writing content
honestly, same lmfao
bro ima spend like a month reinventing the wheel 26 times and then quit the project lol
but at least u learned shit right!
definitely
serializing/deserialing with mongo rlly isntr that difficult
just takes some looking at their docs
which are pretty good
well the asm shit i did for a serializiation library to generate serializers (which was slower than using Unsafe lol) i just did some cool shit with (the knowledge, not the lib)
mixed feelings abt bytecode analysis/transformation
sounds like perfection 😂
but GETFIELD is legit slower than Unsafe.getObject(...)
prob due to some stupid access checks
just do that while linking
yea Unsafe prolly just skips those and says "ayo if shits goes south, ur on ur own"
yeah
doesnt even check the pointer lol
you can cause some native errors with that
EXCEPTION_ACCESS_VIOLATION
love that
i have while writing a graphics library
how is opengl so unstable
that when you pass a byte wrong stride
it crashes everything
didnt even use unsafe
but just do unsafe.getObject(0)
ah nice
so yea totally not reinventing the wheel either haha
lmao
opengl is quite interesting to learn though
yeah
but it does work very weird in java sometimes
since its not rlly a java library haha
its not that difficult if you understand the order of your calls and some weird parameters which dont have like any documentation for some reason
pretty sure it doesnt use native calls, rather some hacky shit for performance
scuffed foreign memory api
honestly no clue
look at all the shit u need to get something proper on the screen xd
lmao
magic numbers
nice
nah but i think i had some kind of VertexFormat and VertexBuilder or smth
so you can dynamically change the vertex data format
which was a pain
oh yeah i remember this lamo
lmfao ye i just saw
someone gonna develop a broken jvm to get that
yeaa this is a real piece of art isnt it
3d is just some shader modification
but 2d for testing
3d wouldnt be difficult tho you can pass values to the shader and shit
if only i knew better how glsl shaders worked
i know the basics but the rest is black magic to me
this is what it looked like
mine were called .glsl with vertex and fragment shader
still waiting for an intellij plugin that can preview my shader code like visual studio can
i could throw it on github sometime tho
these are all acceptable i guess
ahh yes documentation
lmfao
?paste
thanks
What's a better way to give other classes access to the plugin class? Dependency injection or a public static instance?
id say DI
What are the benefits?
I've used dependency injection in some other stuff.
a public static instance of the plugin seems a lot easier to manage.
Issues with creating custom worlds
it might seem like that in the beginning
private Main main everywhere and in the constructors too.
but using di is a lot cleaner and easier to work with in the long run imo
?main
Thanks!
i got the most annoying code error ever
public void addAllQueuedCommands(List<String> queuedCommands) {
Bukkit.getLogger().info("QUEUE IN MODEL" + this.queuedCommands.toString());
queuedCommands.forEach(command -> {
if (command == null || command.isEmpty()) return;
Bukkit.getLogger().info("ADDING COMMAND " + command + " TO QUEUED COMMANDS");
this.queuedCommands.add(command);
});
Bukkit.getLogger().info("QUEUE IN MODEL AFTER" + this.queuedCommands.toString());
this.changed = true;
}
result:
[14:00:23 INFO]: QUEUE IN MODEL[]
[14:00:23 INFO]: ADDING COMMAND give %player stone TO QUEUED COMMANDS
[14:00:23 INFO]: ADDING COMMAND give %player stone TO QUEUED COMMANDS
[14:00:23 INFO]: QUEUE IN MODEL AFTER[, give %player stone, give %player stone]
somehow it adds an empty entry
are you sure it does not contain this empty entry in the beggining ?
either sysout the size of the list or iterate and print all elements
I would suggest looking into how it got there in the first place
ah i know why
it's better, but for example the death thingy is still duplicated
A tad bit ig
Btw, I think IntelliJ is yelling at you that you have some duplicate code
instead of doing almost the same thing for enabling/disabling death, why not just reuse the same code
💀
you've got a lot of duplicated code, move ifs on top and return
rather than the nested ifs
shut up
my honest reaction
fun fact, you can do
if (!(object instanceof Player player)) return;
player...;
GlobealBooleanUtils.setDeathEnabled(deathEnabled);
String message = deathEnabled ? "msg enabled..." : "msg disabled...";
for(Player player : Bukkit.getPlayers()) {
player.sendMessage(message);
}
oh u can?
Yes!
i thought u can't that's why i nested that one
huh right
you def can, just make sure you don't return code that is below an if else
i've seen this pic 3x today now
third time today
i'm getting sick of it
so fix your code some more XD
if you make your code more readable it's easier to fix 🙂
usually stuff can be improved whenever you see the same line more than once
the functionality is (mainly) okay
dont talk
I also wonder why you're checking the command's name in the first line?
right
yes, but your later you will be unhappy when he has to remember what the code did haha
that's a thing that for some reason i learned when i started and never thought about. that line is useless lmao
Just asking the same question about https://github.com/sammwyy/milkshake, i tried adding support to it but java wont help me,
trying making a nested inside requires me to user the class User for example to access it
public static void CreateUser() {
User user = new User();
user.name = "Test";
user.uuid = 0;
user.test.uwu = "Hello World!";
user.save();
}
public class User extends Entity {
@Prop
public String name;
@Prop
public int uuid;
public static class test {
public String uwu;
}
}
IntelliJ: Static member 'no.database.mongodb.example.User.no.database.mongodb.example.User.test' accessed via instance reference
yandev?
.
bro is actually annoying
are ppl allowed to ping staff here
just block them
to deal with him
good point tbh
dont make the class static ?
im trying on a public static void main(String[] args) to start the code
so it needs to be static
Classes don't need to be static to access them from non-static context
I put static everywhere
yes, i forgot about that, but know new error "Expected class or package" on user
oh right, i have an else for that though. the stuff that happens in console goes in the else so i need that
its wrong, its called static abuse and cause problems about performance lol but i forget too lol
its called clean code
thats right
thats a joke right
so about this nested class giving unresonable errors
a static class means that it doesn't need an instance of the declaring class
for (int i = 0; i < 100; i++) {
if (p.getInventory().containsAtLeast(new ItemStack(Material.DIAMOND), 9)) {
p.getInventory().removeItem(new ItemStack[]{new ItemStack(Material.DIAMOND, 9)});
p.getInventory().addItem(new ItemStack[]{new ItemStack(Material.DIAMOND_BLOCK, 1)});
}
if (p.getInventory().containsAtLeast(new ItemStack(Material.EMERALD), 9)) {
p.getInventory().removeItem(new ItemStack[]{new ItemStack(Material.EMERALD, 9)});
p.getInventory().addItem(new ItemStack[]{new ItemStack(Material.EMERALD_BLOCK, 1)});
}
if (p.getInventory().containsAtLeast(new ItemStack(Material.GOLD_INGOT), 9)) {
p.getInventory().removeItem(new ItemStack[]{new ItemStack(Material.GOLD_INGOT, 9)});
p.getInventory().addItem(new ItemStack[]{new ItemStack(Material.GOLD_BLOCK, 1)});
}
if (p.getInventory().containsAtLeast(new ItemStack(Material.IRON_INGOT), 9)) {
p.getInventory().removeItem(new ItemStack[]{new ItemStack(Material.IRON_INGOT, 9)});
p.getInventory().addItem(new ItemStack[]{new ItemStack(Material.IRON_BLOCK, 1)});
}
if (p.getInventory().containsAtLeast(new ItemStack(Material.NETHERITE_INGOT), 9)) {
p.getInventory().removeItem(new ItemStack[]{new ItemStack(Material.NETHERITE_INGOT, 9)});
p.getInventory().addItem(new ItemStack[]{new ItemStack(Material.NETHERITE_BLOCK, 1)});
}
}
why does it lag?
16 tps
this is not a serious question, right
why are you checking 100 times for that?
yepo
Do that when item enters the inventory
And only until they don't have the items
I use it in BlockBreakEvent
here's my ingot condenser https://paste.md-5.net/iwiyabecep.cpp
but why 100, am i missing something???
it looks worse than my, too many lines
to not check once, I want to remove as many as he has
my fucking eyes bro
sure
But you don't, you do it 100 times instead
What if player has only 9 ingots, then you iterate 99 times for no reason
well you're using it in a BlockBreakEvent, right?
that dude is obviously trolling
This is fired EVERYTIME you break a block anyway
so checking once is def enough, no?
probably tbh
correct? (since i joined this discord, i question everything i do when coding java lmao)
well do you need player for the else ?
? ? ?
hold on
https://pastebin.com/beWhqLQc
this is my corrent code
and i don't get how i'm gonna get around that instanceof nesting
????
How could I calculate the locations to get into a player?
where is the else for the if
I can't be bothered counting brackets
line 28
use pathfinding
I can't use pathfinding
I just want to make the entity slowly rotate into the players position in real time
Uuhhh
hmm
Honestly... there is a shit load of duplicate code
why differentiate between Player and CommandSender
All you do is send message and test if it is in OnlinePlayers
It is literally the same result, doesn't matter if it is Player or CommandSender I think
ok, you test if player has permission, just make a method that takes in CommandSender and do the toggle there
the original reason for me putting that instanceof there is for the permission check
istg fuck you
xD
I'd rewrite it for you, but im at work and I get home in like 2 hours :D
honestly, if you don't have a single useful thing to add, not typing anything might be the better tactic for you there noobdog
man
what do you mean
like
you're expecting people
to help you fix your code
when you have no idea what you're doing
BRO
then you're the one saying fuck you?
lol
no need to flame people when others were trying
thanks lynx
i was actually re-writing his code to show how to properly do it
when ALSO commenting that he should learn programming before asking stuff
but i guess you're learning by asking every possible there is, even if it's a google search away
: D
They have a point, developing a plugin as a first project is not a good idea
yall gotta see: i started writing this when i had no idea about coding. legit 0. i did stuff from tutorials.
yes i learnt a lot in that time but i obv didn't learn everything. also because there was a lot of pause between coding sessions (e.g. bc of me graduating and stuff)
tell that my like 14 year old self
man
lol
whatever
im the human trash
enjoy learning code by fucking begging others to help you on the most basic thing
yeah, you're trash talking
then why tf are you spamming trash talk?
begging
we essentially got him to improve his code lol
but did he understand why? If not, it was useless
also the only thing i was acc asking is how to get my code style to be proper... code style
ofc i did
well you learn basic logical programming:)
that's how i learn. i let people explain ONCE, make notes and then know
you won't always be able to rely on other people for learning
a lot of programming involves reading documentation and guides on your own
GlobalBooleanUtils.setDeathEnabled(!GlobalBooleanUtils.getDeathEnabled());
Bukkit.getOnlinePlayers().forEach(loopPlayer -> {
if(loopPlayer.getUniqueId().equals(player.getUniqueId())) {
return;
}
loopPlayer.sendMessage(ServerSystem.getPluginPrefix() + "§b" + player.getName() + " §7has " + (GlobalBooleanUtils.getDeathEnabled() ? "§aactivated" : "§cdeactivated") + "§3noDeath§7.");
});```
"people" as in discord, youtube, or idk bro, stackoverflow
thank you. and all that without trashtalking in the same message, gaw damn
Don't use §
Use ChatColor instead
one thing i wanna say: i didn't use forEach bc idk i don't like it. idek why but i just don't lol
it doesn't really matter in ur case
that's why i used the enhanced for loop
if (sender instanceof Player player && !player.hasPermission("therave.activate.nodeath")) {
sender.sendMessage("Permission");
return true;
}
if (args.length != 0) {
sender.sendMessage("Syntax");
return true;
}
GlobalBooleanUtils.setDeathEnabled(!GlobalBooleanUtils.getDeathEnabled());
Bukkit.getOnlinePlayers().forEach(loopPlayer -> {
if (loopPlayer.getUniqueId().equals(player.getUniqueId())) {
return;
}
loopPlayer.sendMessage("[Prefix]" + "§b" + player.getName() + " §7has " + (GlobalBooleanUtils.getDeathEnabled() ? "§aactivated" : "§cdeactivated") + "§3noDeath§7.");
});
}```
here
is ur properly structured code
commandSender is Permissionable
no one uses forEach if you can use for each
that's just prefecence whatever
whats the point of the instanceOf
ur not using anything inside the lambda that's outside of the lambda
just refactored his code ¯_(ツ)_/¯
ah
hold on it is? why tf do beginner tutorials do that damn check then??
yea, if you dont care for that to be a player, hasPermission is a method available on all CommandSender
I suggest you start liking it
If you ever need to filter values from a list, then sort it and then do something with those values then you'd use streams.
welll
usually you won't want anyything but a player to execute your stuff
given you might need their uuid later
I want to execute myself
real
i've used stream, yeah. just not as much
streams are powerful
but why? wouldn't it be kinda inconvenient to not be able to execute certain commands from the serverconsole?
A server console doesn't have e.g. a UUID
think about a gui
then go for it
a console can't open a gui
so you'd need to check if the sender is a player or not
or entity rather
but if your command needs stuff like a gui ^ or you want to do stuff based on the location etc
Say a command that teleports you somewhere, wouldn't make sense for a console to be able to run that
yeah, hence the "telports you somewhere"
🫢
let's teleport commandblocks or real servers
teleport the server files around the drive :D
In command, you can do:
Brain : { memories : { "minecraft:dig_cooldown" : { value : {}, ttl : 1000000L } } }
How can we do this in spigot? Or should I just call the command through my plugin, is that easier?
what is this
Huh?
lol
Causes warden to not dig
use events
LivingEntity#setMemory(org.bukkit.entity.memory.MemoryKey,T)
yeah obviously. not all commands are console executable
is the method you are after
yes it would
but only /tp player player
okay
not teleport yourself
tho it looks like spigot is missing that memory key 
but acces the tp command to teleport other players around
also what u can do
oop noobdog already said that
to make everything easier
😭
yea
use aikar's command framework
open an issue on their tracker
should be a terribly easy fix
vanilla command handling sucks
Tho
Actually not, they don't have the concept of a MemoryKey<Unit>
I guess EntityPoseChangeEvent is your friend then
ugly but works too
I just went on google again and I stumbled upon an NMS method, should I use that or pose event
((CraftWarden) warden).getHandle().getBrain().setMemoryWithExpiry(MemoryModuleType.DIG_COOLDOWN, Unit.INSTANCE, Long.MAX_VALUE);
can just do that yea
Okok
if you already use NMS
I never touched nms tho
then maybe not the vibe loil
Ok
why not
I'll use pose event lol
overcomplicating things is my specialty
I mean, you do you
Does anyone know the progress on moving Material and others to classes ?
The feedback post has not had any activity in like a month and idk any other place for it.
welp that even isn#t cancellalbe
so yea
NMS it is
and pls open an issue on the jira so someone can implement proper API for this
What’s not cancellable
EntityPoseChangeEvent
Yeah no one will give us feedback :(
I just found
Ah
hope that doesn't mean that it's cancelled
There’s been talk of making some new apis that leverage the changes to get people more hyped
that sounds interesting, where
I'm wondering, what kind of texture packs with x ray? Is not it
is there x ray or is it just texture packs
texture pack with x ray
yes, what is with that?
i don't think this is really the right server to ask this on, but anyway:
if you mean if using an x-ray texture pack is considered cheating, i'd say yes. at least for most servers. depends on the server rules of course.
And if you mean if x-ray is made using texture packs: yes. mostly. there are mods where you can make adjustments while the game is running but that's modded minecraft only
you basically have transparent pngs for most textures.
I mean in the texture pack itself there is a cheat or is it a regular texture pack that works and SIMULATES x ray
there are both x-ray texture packs and clients that give you x-ray without a texture pack, if that's what you're asking
you can use both, and both are considered cheating my basically all servers
I'm just wondering, you can't make the blocks transparent even if you put the glass texture, because only the texture changes and not the transparency property
but there are such texture packs, which means there is a cheat inside, yes
?
@Override
public void setTag(ItemStack stack, String tag) {
ItemMeta meta = stack.getItemMeta();
PersistentDataContainer pdc = meta.getPersistentDataContainer();
pdc.set(KEY, PersistentDataType.STRING, tag);
stack.setItemMeta(meta);
}
@Override
public boolean hasTag(ItemStack stack) {
return stack.getItemMeta().getPersistentDataContainer().has(KEY, PersistentDataType.STRING);
}
why hasTag is returning false on a tagged item
I've found out that whenever I generate a world using this custom generator the server freezes.
@Override
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
ChunkData data = Bukkit.createChunkData(world);
data.setRegion(0, 0, 0, 15, 0, 15, Material.BEDROCK);
data.setRegion(0, 35, 0, 0, 60, 0, Material.STONE);
data.setRegion(0, 61, 0, 0, 64, 0, Material.DIRT);
for (int x = 0; x < 15; x++) {
for (int z = 0; z < 15; z++) {
for (int y = 1; y < 35; y++) {
double noise = random.nextGaussian();
if (noise < 0.1) {
data.setBlock(x, y, z, Material.DIAMOND_ORE);
} else if (noise < 0.3) {
data.setBlock(x, y, z, Material.LAVA);
} else if (noise < 0.5) {
data.setBlock(x, y, z, Material.GOLD_ORE);
} else if (noise < 0.9) {
data.setBlock(x, y, z, Material.IRON_ORE);
} else if (noise < 0.95) {
data.setBlock(x, y, z, Material.LAPIS_BLOCK);
}
}
if (random.nextGaussian() < 0.1) {
world.generateTree(new Location(world, chunkX * 16 + x, 64, chunkZ * 16 + z), TreeType.BIRCH);
}
}
}
return data;
}
}```
No, these change the block model instead
are u sure you're calling setTag? can u check the tags of the item separately?
world.generateTree(new Location(world, chunkX * 16 + x, 64, chunkZ * 16 + z), TreeType.BIRCH); don't do this
what?
Why?
Sorry for the ping, but I figured out why my values were off in the web-editor.
It's cause JS converts everything to floats/doubles, meaning it legit had rounding errors with large long values like the ones I was trying to calculate/display.
Could that be causing the issue?
what are you talking about they are my own methods
why am i calling a method that i made?
bruh what
u guys know pdc? why this isnt working
as i said
It should, are you correctly updating the item afterwards tho?
have you checked that the item actually has the tag you're trying to apply?
obviously, if the method returns false, then the tag is not being set
what do you mean by that
im tagging an item
and giving it to a bunch of players
should i clone it or something
show us how
Would be nice to know why and also know ways I can improve this.
public void giveItem(Player player) {
player.getInventory().setItem(slot, stack.clone());
}
perhaps show the full code?
what about the full code
no one will be able to help if you're not showing what what you're doing
idk what part should i show
the setTag and hasTag methods should work, so there's something else that you're doing wrong
i tag an item
all relevant parts?
show where u initialize the item, how you initialize it, when you give it, what tag u use
it will try to load the chunk that's not yet generated, making it call your chunkgenerator again in an infinite loop
Thanks!
public ItemBuilder modify(Consumer<ItemStack> consumer) {
consumer.accept(item);
return this;
}
ITEMS.put(name, new Item(
new ItemBuilder(type)
.setDisplayName(display)
.setGlowing(glowing)
.setLore(lore)
.modify(stack -> identifier.setTag(stack, name))
.build(),
slot,
actions,
sound,
message
));
the second one is called onEnable
ok i got whats wrong
nvm
lol
this texture component too?ъ
https://www.spigotmc.org/threads/disable-dirt_path-turning-into-dirt.615457/ can anyone help me here?
is it possible to manually register a listener without the @EventHandler annotation?
What's a good way to populate a custom world with trees?
take a look at lucko's helper and its event handler
it is possible
of course it is
everything is possible in Java
there's an array of RegisteredListener[] or whatever inside of HandlerList
just reflectively insert into that
uh maybe it's not there
it's somewhere, I did this before
hmm okay ill have a look
Or use PluginManager::registerEvent along with ur own EventExecutor
I'd start by making a basic abstraction
oh
And a shitty impl
there's literally support for it
Yeaa (:
first W of the century for spigot api
btw my "I did this before" was not exactly registering an event
but instead moving it to a different spot in the pipeline
I did something weird
I can't even remember
that (T) event cast was working strangely to me
why would it not work
generally ive noticed that generics have some issues
what?
It works, it's just that the for some reason that method doesn't use generics and just passes an event
i need the getDroppedItems() function
Most likely because it's a stupid separate interface
EntityDamageByEntityEvent registered as EntityDamageEvent for whatever reason
one extends the other
yea its extended
Is there an event that works when a player opens a chat?
Anyways to create connection between python and server ?
except RCON cause it isn't secure ?
asm for events wut
yeah
doesnt look fun
Guys does this function still exist? .getDroppedItems()
it seems it moved
it was previoiusly in org.bukkit.block.Block;
?
Just use a messaging service like RabbitMQ or Redis' PubSub
Bukkit.getScheduler().scheduleSyncDelayedTask(main,
()->{
world = Bukkit.createWorld(new WorldCreator(worldName).generator(new ArenaChunkGenerator()));
world.setSpawnLocation(0, 64, 0);
world.setKeepSpawnInMemory(false);
});
}```
This ain't generating.
How is rcon not secure
Anyway you can really use anything to connect
Websocket, http endpoints
Raw socket 🤢
Whatever is suited for your use case
rcon isn't the best
but yeah u literally have every option
idk what that question is LOL
Put a shell script on a usb key and give it to the python
Then send the python on its way
thats too easy
Yeah it's probably most optimal
print the data, take it where python is hosted. scan it and import
Pythons are just more robust carrier pigeons
i tested 1 texture pack x ray but it shows nothing except cobblestones next to how ati X ray i works lol with the client
how peuple do this anti x ray
?
Why doesn't this part of my chunk generator work?
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) {
ChunkData data = Bukkit.createChunkData(world);
data.setRegion(0, 0, 0, 15, 0, 15, Material.BEDROCK);
data.setRegion(0, 35, 0, 0, 60, 0, Material.STONE);
data.setRegion(0, 61, 0, 0, 64, 0, Material.DIRT);```
Pretty sure opening chat is purely client side, there's no way for the server to know that a player has simply opened their chat
Started yes
Working no.
Working can't be sure.
Maybe it works maybe it doesn't
test it.
How is Bukit supposed to know if your plugin is working?
Hi, the méthode server.getinfo.sendata() send a plugin message to all players in the server ?
How many runtaskasynchronously’s can I have running at one time, really
An order of magnitude
Would be great
100s? 10s? 1000s?
10,000s?
depends on how good your cpu is
you can benchmark it yourself and see how it performs
How many threads do you have?
Like 12 cores
can be infinite but leave some CPU for you computer
I don’t know how many threads I have
How do we find out the #
I have also heard about this thing called a virtual thread
Idk what that is
maybe 32?
How many of those you have?
I don’t KNOW
If you have 16 cores you might have 32 threads
Runtime.getRuntime().avaibleProcessors()
Thanks
then just make it *2, threads in processors are usually cores x 2
it returns number of cores
Also subtract 3 for server and OS
Thread.activeCount()
this returns number of active threads
The server and OS is probably using more than 3 XD
Depends on OS.
can someone help out with this lol, its annoying
I mean the server has the main thread, chat thread, netty threads, worker threads, etc
File is not called java.exe
wait why is it in programdata and 0kb
how do i fix this
this looks scuffed
By using right path..?
unless it's normal for oracle installations
Also are symlinks a thing in windows lol
i have custom installation paths so for me it's "C:\JDK (1.16)\bin\java.exe"
i did
Isn't it shortcut in windows
oh right
i think so
Hi, (in bungeecord) the méthode server.getinfo.sendata() send a plugin message to all players in the server ?
How did you install java
I hope you haven't just xp it from some linux server
Why do you have symlinks
Why not just use real path to put in paths variable...?
how do i do that?
reinstall java and just let it create appropriate folders and put itself into path
there's no way the java installer made those symlinks for you
how do i reinstall then
delete it and install lol
like i need to use a uninstaller?
well yeah
No.
why not
Maybe yes.
go to the control panel
I'm not a Windows user.
and uninstall
so why did you respond
You don't need an unisntaller on Unix
Good for u
this convo sounds like you want to flex using unix
go to programs and components or whatever it's called
you never uninstalled shit before?
i didnt understand you meant to uninstall as a program lol
...
okay so i install the development kit or what?
or the runtime environment @icy beacon
do not ping me
cold
tbh i have not installed java in a while but you need both iirc
an installer should cover both, no?
dont think so
I think standalone runtime env isn't even thing anymore
choose the x64 installer for windows
it should install jdk and with that the jvm should also come
what does that mean
hmm imma do it
it means exactly what I said
PlayerJoin -> load user async -> cache user in memory and fire an event
What do the 3 ints here mean in:generateChunkData(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biome)?
no clue where you're seeing 3 ints
after 1 day of self hate it finally works, ty ZBILL and Goksi ❤️
rule of thumb, if shit spontaneously stopped working and you can afford to reinstall it quickly, do it (jk this is a bad advice)
though it did help me today
i had to reinstall the entirety of wsl
for cargo to work again
me with my 19 jdks in my ide
i don't remember i changed it with winaero a while ago
i love me 4 jdk 1.8s
i have no further questions
2 ints*
Alright so x and z
i assume it's the chunk x and z
yay i was good for something!!!!!
This seems to work in 1 chunk.
data.setRegion(chunkX*16, 35, chunkZ*16, chunkX*16+16, 60, chunkZ*16+16, Material.STONE);
int absX = x << 4;
int absZ = z << 4;
🥲
wait isn't it just multiply by 16?
something something negative numbers
well shit
Bitwise Left Shift Operator (<<)
multiplying by 16 works I just remember there were some edge cases
i'll have to learn bitwise operations one day won't i
I still don't know them all
Gives me C++ vibes. I hate C++
i know none
shift really hard
I know << and >>, & and |
The unsigned right shift operator ">>>" shifts a zero into the leftmost position, while the leftmost position after ">>" depends on sign extension.
that tells me nothing
me neither
isn't & and | just && and || that evaluates both conditions
no
& is a bitwise AND
well fuck me sideways i always thought it was to evaluate both
So
0001
0011
&
0001
this somehow makes sense to me
yeah
i thought it wouldn't
| is a bitwise OR
so 0001 | 0011 would be 0011?
0001
<< 2
0100
| is non-lazy or
oh
so 0001 << 3 would be 1000?
so i was right?
it serves as a * pow(2, value)
yes
yayyyy
<< 4 is the same as * 16
it returns returnTrue2() although returnTrue1 is already true
because 2 ^ 4 = 16
ye but for && you had it wrong way around
not really
& is basically non-lazy AND, which means it runs the second thing even though the 1st is already false
and to me this now makes zero sense in the regard of chunk X to real X
because you're evaluating more values
yeah i meant that
evaluates both
So in binary
basically: && or || stop when it can't be true anymore while & / | definitely runs both
yup i meant that 😄
yup i took a cs exam this summer so i unfortunately remember that
2^0, 2^1, 2^2...