#help-development
1 messages · Page 2040 of 1
go to yamllint.com
oh wait
you are right
it's actually valid without a value
nevermind
why is the if statement not being called?
it is called
just the body is not called
beause api is string with a value of "null"?
Because it’s null. Your check returns false
i thought it said == for some reason
oh lao
don't use ligatures for code
nah thats not the reason
well I didn't see it either lol
i was just being stupid
Maybe his ide automatically does that
In spigot is there a way to catch Chuck generation events? Like if I wanted to replace a block with another one while it’s being generated?
still weird
but better than what the dude above posted
red/orange should catch attention
i.e. for errors etc
Redish variable names always looks like something is wrong w ur code
yeah but's basically every IDE's default
sure, if you prefer errors to be green, why not
Like something isn’t imported correctly
it just confuses everyone else
exactly
My keywords are blue
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/world/ChunkPopulateEvent.html there's this
declaration: package: org.bukkit.event.world, class: ChunkPopulateEvent
That's why my vars are blue
My global ones are purple
get rekd
Light mode users should be banned from programming
light mode when the sun is shining
dark mode when the sun is rising
I can’t imagine staring at a flash bang for hours while trying to code something
you guys really need to see an eye doctor
that's not bad but also not good
get a "Gleichtsichtbrille" and you spend 3k
lol
for just 1k?
not bad
decent price
I’m shortsighted as fuck
I'm also at 2.30€
german prosecutors already try to fuck the big gas station companies for doing "illegal" prices
but it'll probably take 2 years until sth happens lol
hi, im trying to work with bungeecord's plugin messaging channel, but im receiving multiple messages back even if i only sent one. this is causing eofexception because its reading the bytedatainput multiple times
console: https://paste.md-5.net/ritozawowe.makefile
plugin sending messages: https://paste.md-5.net/afunewuqod.java
api receiving messages, then completing a completablefuture:
https://paste.md-5.net/cagosayiba.cs
which of those classes/methods sends the message?
createSignUpdater
so even if only one player joins one server, iget sends multiple times?
it sends one, but its receiving multiple messages
then it's a bug in your BungeeMessageAPI class I guess
where did you get this class from?
seems like this "BungeeMessageAPI" is actually meant to broadcast to the other servers instead of just to the proxy
(just a wild guess)
?paste (for me)
https://paste.md-5.net/ajiyemoquz.cpp anyone got any idea what's the problem in line 44?
this also won't work
fuck this whole type erasure thing
java generics and arrays will never become friends I guess
I guess it'll have to be a Object[] instead that people must cast to D[]
but then I can't make it a generic PDC type
FML
I need some smart people
@worldly ingot
sorry for ping but I know you're smart
Valhalla <3
go see a doctor
I'd Wrap the Array, but idk what your exact issue is
returning a T[].class from a generic class that only has T as generic type
Actually
Could't you treat the Array as a Java lang Object?
It should be possible to Cast int[] to Object and the other way around.
It's hacky but May work
unfortunately, no
even if an Object[]contains only ints, you can't cast it to int[]
I am talkimg about Object, Not Object array
Create one of Just read one?
I need sth like
String[] array = myMethod.getArray(String.class, ...);
WITHOUT casting or anything
and without having to pass String[].class
but yeah I guess it's not possible at all
I can instantiate a T[] from just having T.class but that won't help me in actually infering that as type argument
Ah yeah you would have to have Specialized Methods for that
but it needs to be generic
ever wondered why List.toArray() requires an empty array? this is the reason
Or just require the use of Valhalla. But idk If they have already Preview builds for that
idk what valhalla is
It does Not iirc
it does
you have to at least once call a method with your class instance
or your class class instance
Basically a lot of rewrites in the core of javas type system
ACF works like this:
PaperCommandManager acf = new PaperCommandManager(this); // Als oworks on spigot, although it's called Paper...
acf.registerCommand(new MyCommandClas());
They have a subproject for "Universal Generics" iirc
But it will still Take years until we can make use of it. Sadly.
Because Backwards compat et al
would adding an entry to the ban entry of type name add the player's uuid or the player's name?
Ban entry, type name.... probably the name, I GUESS?
it says it will return a uuid iirc
oh are you talking about spigot API?
please tell us exactly the method you're talking about
its in bukkit class
Bukkit only has a method to ban the IP
Bukkit.getBanList(BanList.Type.NAME)
it says "banned names"
iirc in newer versions it returned a uuid
so I am pretty sure it actually uses names
lemme check on 1.17
if it indeeds bans UUIDs, it shouldn'T be called "Name" but "OfflinePlayer" or "UUID" or sth like that
but yeah doesn't mean I'm 100% right, maybe the bukkit names are just cursed
but if it explicitly says "name", I guess that does mean "name"
hold on loading a 1.17 plugin
also bukkit keeps track of "old" player names
so if you ban "mfnalex" now, and I now change my name to "mfnblex", the server knows I was mfnalex beforehand
erm wtf did you get that from
declaration: package: org.bukkit, interface: BanList
in 1.18.X the words "no longer supported" don't even appear anywhere
1.16.5
https://helpch.at/docs/1.16.5/org/bukkit/BanList.html it's not stated here neither
declaration: package: org.bukkit, interface: BanList
I have no idea where you got those javadocs from
THIS is 100% not the wrong place
well, idk if md was drunk but how are peopole suppose to use a UUID ban list if it doesn'T exist?
maybe create an issue on the stash, asking that
?stash
the docs say "don't use name, use UUID" but the API doesn't provide a UUID ban list
so yeah I'D definitely consider this a bug
yes? tf you think this is
@sullen marlin the docs tell people to use UUIDs instead of names to ban players, yet there's no BanList.Type.UUID ?
ohk
alex, do i drop support for 1.16 and get hate from all the kids that can't install via version/backwards?
tbh I don't really care 😄
like, they are so fricking annoying
"hey add 1.16 support ples"
1.16
ADD
SUPPORT
LES
AASADAS
do you sell plugins?
DAS
or are they free?
if your plugins are free you must support more versions to not get hate
i might sell something in the future, but for now everything we make is free and open source
I currently do 1.16.X+
well imo atleast suppor 1 version behind, thats what i'd want to do (since some people might have not yet updated to latest)
once 1.19 comes out, it'll be 1.17+
^
yes
intellij tells you
hover over mined data
and it will convert it to a record
yes?
more actions
public record MinedData(Material block, Location blockLocation, long minedAt) {}
done refactored it
yes
ofc
everything inside it
this is the equivalent of above
(only thing is getters are .block() .blockLocation() and .minedAt())
I fucking hate generics when it comes to arrays
how is it possible that I managed to make Lists, Sets, Maps, etc possible but not simple arrays, smh
you know what? fuck arrays
if people wanna use them, you gotta use a list and use toArray
won't work
i told you
because of type erasure
arrays need a lot of work haha
yeah I could easily make it work by requiring people to pass an empty array
but that just doesn't look right
I mean
DataType.asArray(DataType.ITEM_STACK, DataType.ITEM_STACK[])
no
then people should just use a list instead
I want this to work:
PersistentDataType<?,ItemStack> type = DataType.asArray(DataType.ITEM_STACK));
they shouldn't be required to give both, T and T[]
you know what, fuck it
I just consider it done now
it supports Map<ItemStack,Date> and other weird stuff,I guess that's enough
just an example lol
it takes everything for which you have a PersistentDataType
You could even do a List<List<List<ItemStack>>>
and stuff like that
it supports basically everything
for example even HashMap<String,HashMap<List<Integer,ItemStack>>>
the only thng currently on my todo list is to add a DataType for Enums
right now you still gotta use strings and parse them manually
Does it store all this as bytes
you cannot believe how happy I am
PersistentDataContainer pdc = player.getPersistentDataContainer();
Map<String,Integer> map = new HashMap<>();
map.put("mfnalex",27);
map.put("mfnalex's Father",67);
map.put("md_5",31);
NamespacedKey key = new NamespacedKey(this, "persons-to-age-map");
pdc.set(key, DataType.asMap(DataType.STRING, DataType.INTEGER), map);
Map<String,Integer> storedMap = pdc.get(key, DataType.asMap(DataType.STRING, DataType.INTEGER));
@waxen plinth I finally got something that's worth stealing 😛
I’ll take that as a yes
somehow my DataType library got some hate on spigot
I mean, I get it, it wasnt exactly revolutionary
but once I post this update and people still claim it's "not useful", then they simply didn'T understand what it does, smh
I am actually really proud of me right now lmao

❤️
Liziscute
v2 is just making everything final 
Yeah I made it so my gf can't use it against me
lol
?
only thing left for me is to add an Enum data type
Am I the only one who learnt on how lambdas etc work by letting IntelliJ convert my old code?
Who’s Liz anyway
404
i was an eclipse user when i learn so i assume yes
what is this music
lol
did you already switch to IntelliJ?
very dramatic
not useful
that must have been "I dont like Mondays"
a song about a real life school shooting
Epic
:/
you stink like used tennis socks
Nice
fuck you
Excuse me
riht
or at least that's how you smell like
My gf I said this already 
Who’s Liz
hetero? disgusting
Sorry I'm taken~
What's hetero
Yeah sadly eclipse doesn’t do that

Is she an anime

it's not hetero if you so "no hetero" after fucking a girl (or a boy if you're a girl. if you're trans, it get it gets a bit more complicated)

...
I'd date you
if you don'T like me, ask jokni out
jokni is definitely bi-curious
Anyways time to record a spigot tutorial and fail miserably 
Provide all the tutorial code in the description 
"Hey wassup thanks 4 watching my shitty tutorial, pls sub & leave a comment bla bla" and after 38 minutes it starts
ASMR coding
?ben
I've found that kody simpson offers pretty good tutorials
nice and concise, links other resources sometimes, and shows what his code does periodically
Hi, i wonder if its poseble to use this ** translateAlternateColorCodes** and do that to a list i have i config?
i use now
ChatColor.translateAlternateColorCodes('&', "messages");
Tag me 😄
What's the easiest way of predicting where an arrow would land? 🤔
I have no idea of how fast they are or how they fly 😅
Can anyone help me debug this?
Please @ me if so.
You can use this to determine where the arrow has landed:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/ProjectileHitEvent.html
Just run each list entry through the method
So you say that its not poseble?
I just told you how
How would that imply it’s not possible
You could do it with a stream too if you wanted
send the link
i cant imagine something you make being useless so I automatically assume they're idiots :)
oh the More persistent data types thing
its awesome, ignore anyone saying it sucks
Something like this ```yml
Armorshop:
Slots:
1:
material:
action: SELL, BUY
sellprice:
buyprice:
But yeah
For each slot in a shop
The arrow may or may not fly though my target.
So I'd need to know before it hits
how do i do it in a list? is it like
messages:
- "&7[&aTips&7] &eAh er en 24/7 åpen shop"
- "&7[&aTips&7] &eBruk /report grunn on man finner en feil"
- "&7[&aTips&7] &eHusk vi har et kar bruk /map"
- "&7[&aTips&7] &eMan kan lage shop se i spawn"
- "&7[&aTips&7] &eMan kan søke om warp på /report eller på en ticket i discord"
- "&7[&aTips&7] &eDet er av og til events på servern med spill penger og rank"
is it 1-2-3-4...
loop through it
yep
by learning java
what?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Do you mean if ur checking whether it hits ur target? If so then check whether its a entity by doing #getEntity and checking if thats null or not.
@sage dragon what are you actually trying to do
u dont know how to loop thru a list u should learn java
Trying to use falling blocks as a new enemy and my experience was that arrows fly through them without problem.
But I think I found a better way which does include the ProjectileHitEvent and barrier blocks
Phone
you could probably do it better by messing with NMS
making arrows hit falling blocks
that's where a lot of my spigot patches have come from lol
i needed minecraft to behave differently so i made it so
W
I swear that little line, he probably got it right from google
That would work too
i am not some one ho codes but my friend send it to me and he does but now he is on holyday
use getStringList() on the config and then iterate through and call that method on each String in the list
Now we need to allow plugins to do controlled patching of internals
huh?
like this? this.messages = instance.getConfig().getStringList("messages");
That's fine if this.messages is a List<String>
How can i add stuff to a message before all the content
aka
somethingiadded name: <message>
if u use the event basically event.setFormat("somethingiadded %s: %s")
ye but i dont wanna change format
i just want to include "my thing" to existing message
huh
thats not how it works tho
then how do plugins like interactivechat do that
I'm still unsure what you're trying to do and why you're trying to avoid setFormat
is there a simple way i can make certain players not appear in the tab list?
per player ofc
packets?
is there any benefit to using protocol lib for packets opposed to nms itself?
protocol lib does it for you. That's about it. If you want to not require a library then do it yourself
oh, alright!
anyone know how to control/restrict/supress ProjectileLaunchEvent event ? LaunchProjectile seems to call it and creates a bad loop that crashes servers - canceling the event doesnt work
Use a simple Boolean
Toggle it before and after you call lauchProjectile
And ignore the event if it is set
already tried that, it doesnt work either
sort of wondering if it re-fires the event after exit
oh, and any idea how to remove a few thousand arrows short of rollback? - it seems the server doesnt suppress the event itself either
/kill @e[type=minecraft:arrow]
nope, cant do that if not in the chunk and loading the chunk crashes the server trying to tick the arrows
Delete chunk data
yeah, that was my other possible thought
Hi i need help with this, i need to have colors on my messages but its in config.
this is my code and it's not working
for (String i : instance.getConfig().getStringList("messages")) {
ChatColor.translateAlternateColorCodes('&', i);
pls help and tag me
result.append(ChatColor.WHITE);
"&f" + i
du i need to change it to that, does it work on more then one color?
It works with every color, it was just an example
works just fine was long as the client understands the code
i did but not works in game but with the f its not
You are translating the string
But not storing it to a variable or anything
So you can’t access it later
how do i do that?
omg
You do that by learning java I imagine
ur not even sending the message
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
player.sendMessage(Chatcolor thinh); that simple
Learn java please
ok
but it's not to one player
you need to get the player first 🙄
might just be a general broadcast
either way, he isnt sending anything with his code
yall have an idea why
button.addExtra(msg.toString());
prints
this crap?
msg is a ChatMessage btw
looks like youre printing an object
so how do i get raw text from ChatMessage?
yep
you might have to override toString and tell it what you want it to print
public ChatMessage(String player, String message) {
this.player = player;
this.message = message;
}
this is what chatmessage is
^
okay i just did a 1000iq thing
thank yall for help
i have to say
nevermind
i kinda f up
how do you get like entire message formatted in the chatevent?
glue it together - or do you mean catching it?
lets say my message looks like this: [Somerank] somename: somemessage
i want to get that entire thing
setMessage() is the one to be sent
setMessage(String message)
Sets the message that the player will send. ```
you really are being a pita
@NotNull
public String getMessage()
Gets the message that the player is attempting to send. This message will be used with getFormat().
Returns:
Message the player is attempting to send ```
chill guys 😛
"i want to get that entire thing"
ye thats what i want
bro yk what
i think ima recode that shit
i cant live with those alphabet variables
which i didnt make additionally
idek
probably the one with higher priority on event
is format.toString() gonna not print weird shit
garbage in = garbage out - it will convert whatever you give it to a string
that includes what you already tried to do
o.o
I am using 1.18.2 for my plugin and im trying to place beds
It works if I use Material.RED_BED
But if I try any other colour the bed doesnt spawn
Can anyone help?
Please ping me
public void setBed(Location bedFootLoc, BlockFace facing, Material material){
BlockState bedFoot = bedFootLoc.getBlock().getRelative(facing).getState();
BlockState bedHead = bedFoot.getBlock().getRelative(facing).getState();
Material mat = Material.RED_BED;
bedFoot.setType(material);
bedHead.setType(material);
byte data;
byte data1;
if(material.equals(Material.RED_BED)){
data = 0x3;
data1 = data;
data1 |= 0x8;
} else if(material.equals(Material.GREEN_BED)){
data = 0x0;
data1 = data;
data1 |= 0x8;
} else if(material.equals(Material.BLUE_BED)){
data = 0x1;
data1 = data;
data1 |= 0x8;
} else {
data = 0x2;
data1 = data;
data1 |= 0x8;
}
bedFoot.setRawData((byte) data);
bedHead.setRawData((byte) data1);
bedFoot.update(true, false);
bedHead.update(true, true);
}
It only works for Material.RED_BED
I've tried passing through Material.GREEN_BED, .BLUE_BED and .YELLOW_BED but they do not work
if I change the material to RED_BED for all of them
Material mat = Material.RED_BED;
bedFoot.setType(mat);
bedHead.setType(mat);
it works perfectly
I am using 1.18.2 and ive declared api version 1.18 in my plugin.yml
so I dont know why its not working for Material.<COLOUR>_BED and only works for Material.RED_BED
:/
like this?
ItemStack item = player.getInventory().getItem(i);
if(item.getType().equals((profile.getRefill() == Refill.SOUP ? Material.MUSHROOM_SOUP : Material.POTION)))
player.getInventory().getContents()[i].setType(Material.AIR);
break;```
whats wrong with for (int i = 0; i < inv.size(); i++)?
also there's a inv.setItem method
how do I show particles to all players but a specific player?
would I use the show particle thing, and use a for loop? or is there something easier (and possibly faster)?
wasn't there that other method that shows it to everyone? is there a way to uh, stop them from seeing the particle?
it will stop when you stop sending them
oh.
World#spawnParticle shows it to everyone but you can't exclude someone afaik
You should just use Player#spawnParticle as Zacken suggested.
oh well, alright! thanks!!
hmm dont you need to set the block rather than the blockstate that way?
is that my error? becos it works for Material.RED_BED
bedFoot.setRaw type or data
Could you please give an example?
you sort of have two combined methods that would be unpredictable
Hi, anyone got recommendations for storing persistent data on blocks, was originally storing data in a flat file along with the co-ords but it seems impractical?
you use bedFoot.setRawData() use bedFoot.setRawType() instead of bedFoot.setType()
setRawType or setType?
bedFoot.setType() is to be used on Block I believe, unsure what happens if you try to use it on BlockData
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Block.html contains .setType()
Ah
Thanks
But then how do I cater for the bed head and bed foot
Are they separate blocks?
they are now
handle them both the same way, for color I dont think you can specify different ones
you already handle the data for both:
bedFoot.setRawData((byte) data);
bedHead.setRawData((byte) data1);
Do the same for your Type
Ahhh i think i understand
im stupid
Sorry to keep bothering you but I dont see .setRawType()
Hold on ive just seen a method for setting colour
there is an interface for it yeah
hmm, I guess we are not supposed to use setRawData() any more
is this the same?
Math.log((distance * (Math.pow(Math.E, minDamage) - Math.pow(Math.E, maxDamage)) / maxDistance) + Math.pow(Math.E, maxDamage));
And
does java handle certain things differently
setData(MaterialData data), setType(Material type), and then update() the BlockState seems to be what the api suggests now or you can setBlockData(BlockData data) and then update()
log is not ln
Have you tried running a test case for both ways to calculate said formula?
Yeah it’s just log with base 10 probably
ill do some tests
im using saveConfig() in the onEnable() to create a config file if theres none, is there a better way of doing this?
or whats the proper way of doing this
hey guys how can i make a compass to teleport in onother world (no extern plugins)
yes
How do I use a vector for locations
idk
uhhh, check if the compass was interacted with, and if it was teleport them to the world
idk how
do you want to use interact event?
Does anyone know why this doesn't work?
So I want to replace Mushroom soup or potion with air in the player's hotbar (first 9 slots of inventory). Only one mushroom soup or potion not all.
But it doesn't seem to work.
for(int i = 0; i<player.getInventory().getSize()-1; ++i) {
ItemStack item = player.getInventory().getItem(i);
if(item.getType().equals((profile.getRefill() == Refill.SOUP ? Material.MUSHROOM_SOUP : Material.POTION)))
player.getInventory().getContents()[i].setType(Material.AIR);
break;
}
}```
should i give a shit about this?
no
you cannot get T.class
you need to provide a class object to the method/ constructor
How do I use a vector for locations
Like I want a vector to be a location but it gives errors
i know, but this is different situation i think
Location loc = new Location(player.getWorld, vectorName)
There is no such thing as SomeGenericClass<String>.class
this isn't C++ where each <T> gets compiled to its own class
when java compiles it just converts T to Object at runtime
well that's sad, anyway thanks for deep answer
library idea i beg
yo, in spigot, what is the packet that corresponds to ClientboundSetPlayerTeamPacket (remapped)?
PacketPlayOutScoreboardTeam?
that isnt spigot api
VSCode for java 🤮
how can i make a item spawn in random chests like stronhold chests?
declaration: package: org.bukkit.loot, interface: LootTable
Thanks
any example? xDDD
quite difficult to understand through the methods xD
how can i enable the lootTable i create?
its Intelji 😄
ugly theme
Nope
well if you were work everyday with C# you would get use to this theme
orange
yes.
plzz
@quaint mantle i@ for help if you're able please answer xD
if not its fine
idk how it works either
Ohw
😦
i can't find any tutorial
may its not even possible with Bukkit api but only with nms
because i only found that lootTable is used for mobs
how do i turn a getUniqueId into a users username?
Just wondering
tysm
im making a discord verification thingy
so yea xd
LootGenerateEvent
to check if the loot comes from a chest i can just do if(loot.getEntity() == null) right?
hp
ok
1 hearth = 2
do emojis work with Player.sendMessage()?
now i don't use json anymore
these ones 😂
ok
only like this
d.sendMessage(ChatColor.AQUA + p.getDisplayName() + "is on " + p.getHealth()/2 + "❤️");
so this is fine?
wait what?
ykw ill just do HP
never tried that
people have told me not to make an instance of my main class, so what should i do instead?
use dependency injection where possible
whats that
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
😐
json bad
haha
extends ConfigurationSerializable
No need for a library
ur mom
im jk
The lib I'm working on could probs do that lol
Although it'd be annoying to setup probably
Eh maybe, depends on what parts of the meta you saved ig
Is there a function to delete something from the config?
so i just set the object to null
or
so just do this
getConfig().set(id, null);
kk ty
yes
why does this happen? if its null then the first condition would run, otherwise it cant be null
suggested solution: player.sendMessage(Objects.requireNonNull(config.getString(playerId)));
but i dont understand the point of doing that
lol
you dont need a lib for that either actually
My Lib stores any object in Json/Yaml format so
configurationserializable
It doesn't only apply to ItemMeta
make into json
then make into yaml
Jackson:
public String asYaml(String jsonString) throws JsonProcessingException, IOException {
// parse JSON
JsonNode jsonNodeTree = new ObjectMapper().readTree(jsonString);
// save it as YAML
String jsonAsYaml = new YAMLMapper().writeValueAsString(jsonNodeTree);
return jsonAsYaml;
}
got from google
public String convertYamlToJson(String yaml) {
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
Object obj = yamlReader.readValue(yaml, Object.class);
ObjectMapper jsonWriter = new ObjectMapper();
return jsonWriter.writeValueAsString(obj);
}
use the second method when serializing with ConfigurationSerializable
save it into the file u want
when u need to, change it to json again
as its using the same library it prob will work correctly
hopefully
anyone
what design pattern should i use for island generatzion?
Generate random characters and use a StringBuilder to concatenate them into a string
UUID.randomUUID().toString() kekw
He wants random strings of 5 chars long :p
Any idea as to why this crashes my server?
@EventHandler
public void onPlayerUse(PlayerInteractEvent event) {
if (p.getInventory().getItemInMainHand().getType() == Material.PAPER && event.getHand() == EquipmentSlot.HAND & (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
ItemStack item = p.getInventory().getItemInMainHand();
p.getInventory().remove(item);
}
}
(its not the entirety of the method but just the code i think is responsible for this)
.substring(0, 5) kek
ok ill paste this in a different place this is unreadble
?paste
It's inefficient to use a random UUID -> toString -> substring
My solution is much less hacky
ye :c
Paste the crash report as well
I happen to use the same thing, what are you doing?
Show me an example?
Will do
Code: https://paste.md-5.net/zeqigohega.cs
Crash Report: https://paste.md-5.net/rizifenubi.cs
private final Random rand = new Random();
public String generateString(int length) {
final var str = new StringBuilder();
for (int i = 0; i < length; i++) {
final char c = (char)(r.nextInt(26) + 'a');
str.append(c);
}
return str.toString();
}
It's something to do with the removal of the item from the player's inventory, but I don't know why does it cause a crush
Why is this better then generating a random UUID?
what is the 26?
The random char is a bit hard to follow if you don't understand it but it basically
- Generates a value between
0and25(sincenextInthas an exclusive upper bound, we use26as the upper bound) - Offset it by the value of
'a', which allows the value to be between'a'and'z' - Cast the integer to a char
You can’t remove the item on interact without cancelling the interaction because then the server tries to interact with a null item
Because it's faster and UUID should not be used for what Fourteen wants to do, even if it's "easier" to understand
always start with the cheapest check
makes ur code faster but not that much in this case since theyre all cheap
but just an overall suggestion
What do you mean by cheap?
opposite to expensive for resources
@crude loom cancel the event and it will fix the crash
Ah, I see
computer resources
(Also my version can have strings larger than the max length of a UUID)
Oh, didn't know that, I will try to cancel the event
wdym allows it to be between a and z
36
?
is it possible to pop up "open link window" with out need to click on the TextComponent ?
It’s 5+'a'
its client side so no
No
how does the 'a' make anything
ok
char is basically an int
Because the character value of a (it's codepoint) is not 0
I'm not sure if it uses ASCII or UTF-8 but yeah
0 as a character would be NUL
i dont get how adding a number to a character makes a character
This worked
Thanks for the help! :D
because a character is really a number @grim ice
Yeah
what
So you can add a number to it and the character produced will be whatever the equivalent is for that number
Look up ASCII and UTF-8
you're a number lol
I mean technically he is just text on my screen rn so
yeah Alex
you are a number
I’m number 1
Just out of curiosity, what language is this coded at?
pure java
Ah, then mine isn't updated
ik that
but like i dont get how adding a
codepoint to a random number
makes a letter
‘a’ is just a number
it would produce some random character
There's essentially a range of characters that represent a to z in ASCII
‘a’ = 97
how is it a letter
If we were just to generate 0 to 26, then we would end up with special characters and not letters
you’re adding 5 to 97
So we add the value of a onto our generated number, resulting in it ending up in this range
You understand that characters are just numbers yes?
oh so if we used 97 instead of a it would do the same
And sequential letters are sequential numbers
Although I actually need to check what encoding Java characters use...
Well you have to tell the language that it’s a character
The char data type is a single 16-bit Unicode character.
Okay so it's actually UTF-8 and not ASCII, but the same applies still
You can do char a = (char) 97; iirc
cool
uh but
a is 61 in utf8
but 61 doesnt work
however 97 works
That's because a is 0x61 and 97
Character tables show the hex value
Hexadecimal (0x61) is different from decimal (97)
?=@EU,BSOP>,G?RNJ,KBIKF,NUIAU,AVFF@,JVACE,KJHOG,T=C?>,NLTFE,KHSIJ,QVJU@,MME>S,BQ>CM,@KJQH,B=HGS,UNQNV,=TORU,NUJFA,RRATD,HAEBV,NTIVO,KPGH>,GQU=L,>PKV>,DG=OC,N=UEV,ULTR@,?EMBJ,PSLVF,FMOMU,ALJPQ,Q@BUN,B>APN,VL@R>,EQACJ,V@J=P,CNEB?,FTOA=,@CCFP,LLGO>,=ABTQ,HOBAS,R?CRL,TMIFJ,?SNLG,E?G?=,ILJNS,OOH=U,TPIIN,MCJNU,CCDNG,DHOBA,UCG@R,@S=BJ,FIKLV,DBKBQ,TD@M>,B>NA?,CHB@Q,OOVFF,CF@N?,@?EVD,OKR@H,B>>PD,BGC=>,?JEBS,?GOT=,>I>DG,DAFSG,GTP?R,@DNKR,JNJ??,@LPGI,O=COT,EDS>U,FARKF,EDEBQ,NKFAC,LNH=V,D?>EC,AHVCF,JTNUT,GQ@N@,CGCOH,KA?TL,VILJT,KCDIC,JMG>G,GKFL>,QGG?N,?FKVU
Oh okay
thats the result with 61
.
o
so it used the decimal value not the hexademical
Anyway so a in ASCII is 45 iirc
45 is hyphen as far as i remember
im awesome i still remember it from 12 days ago
kek
How can I remove the respawn menu from ppl who die, cuz instead of showing the respawn menu I want them to go into gamemode spectator instead
wdym
ohhh
I see
and then just respawn them
yeye
https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-vs-code/
here's what i'm following to try and set up a spigot plugin for the first time on vscode
unfortunately i got to the "right click the workspace directory..." part and i'm already having problems
wait how can I completely remove the respawn screen
right clicking the workspace directory doesn't do anything
Highly recommend a proper IDE like Intellij
nevermind the plugin finally loaded wth
LMAO
so scuffed
🤦♂️
i havent been convinced of its advantages
feel free to shill it to me if you want
i just havent heard much better of it than vscode
Intellij has much better support for Java and better syntax completion. It's also what most of us use here so you can get better help
If you have a weak machine you can continue to use VSCode since Intellij is a bit heavier on your system
wait
so is it gonna still show the respawn screen?
cant I just cancel out the last damage and put them in spectator that way
Probably wont be visible either way, goes VERY quick
You probably won't even notice the respawn screen
It's a 20th of a second
(if you delay it one tick at 20tps)
If you don't want this you can use the doImmediateRespawn gamerule. I think the client can handle that one, not 100% sure
Pro tip, you can just use runTask for a tick delay
Player player = e.getEntity().getPlayer();
player.setGameMode(GameMode.SPECTATOR);
new BukkitRunnable(){
@Override
public void run() {
player.spigot().respawn();
player.setGameMode(GameMode.SURVIVAL);
}
}.runTaskLater(Otib.getInstance(), 3 * 20);
}
how lmfao
3 seconds? They’ll see the respawn screen
So i got ${project.basedir}, but how can i get the parent directory to that
oh
I thought it happens after 3 seconds
like they die and respawn
I think I'm just gonna cancel out the last damage and just set them in spectator
that's how most minigames do it
idk how to cancel it out tho
do I have to use EntityDamageByEntity event?
Yeah thats true
you can also make them click respawn sorta
idk how they work
breh
there is a way to remove respawn screen with packets
What is your goal tho?
most minigames just cancel out last damage so they dont actually die and just say they died
that's what I wanna do
e
is anyone able to help with maven shading, I have added a dependency/repository and configuration to maven shade in pom.xml but whenever it tries to run something related to the library it says ClassNotFoundException?
Make sure to use the shaded jar
is that outputted somewhere different?
No there should just be 2 jars in the target folder
jiohjkg fghvhghghg
I make it output directly to my plugins folder, only 1 appears in there
One with the suffix -original and one without. You need to use the one without suffix
Could you show your pom
?paste
https://paste.md-5.net/irakegunes.xml everything is working fine other than MorePersistentDataTypes
it gets everything fine while im developing, but compiling I guess its just missing it out
Why are you compiling with Java 9
Also where are you changing the output folder?
I am using intelliJ and I just have it in my build configuration to output when it builds
What's the configuration of that
of the artifact?
Yes
you can see it has the MorePersistentDatatypes in it
ah I see so you're not even using maven
Which is why you're having issues
Maven can't shade if you don't use it to make your jar
oh, how can I make it use maven, I kind of assumed it was beforehand, where can you see its not using maven?
the screenshot tells those who know
Configs
this
Anyways click the + in the top left and add a new maven configuration
and tell it to run package
i am trying to make a sword apply wither effect to entities it damages and i included lore shown and using eventhandler listener also shown, but the weapon does not give wither effect can anyone help me with this?
Also avoid deprecated methods
ok
even tho its not recommended, if i removed the deprecation, would it work theoretically
no, make sure to read why its deprecated
its not always deprecated for removal
oh
no?
sometimes methods get marked deprecated simply because they are thread blocking
simply to warn you
deprecated methods should be avoided. That's the whole point of the annotation
if i undeprecate it would it work maybe?
Not really
They get marked because there are alternatives that should be used instead
You don't add a deprecated annotation just because something is blocking. You add it because there is a non-blocking variant that should be used instead
Or if you use it like mojang it can mean "don't call"
Not “has been replaced”
Deprecation is typically a warning that a method or class is being removed soon and so you should stop using it
Not necessarily
i disagree
take a look at Bukkit#getPlayer(String)
pretty sure even spigot has had a deprecated method simply because it was blocking
yes
Or RecipeChoice.ExactChoice. Deprecated because its draft api.
it just tells you to use another method but sometimes there is not other way
If you see something deprecated it means you should not trust that method to work in future versions unless it is explicitly said that it will continue to work.
you have to be fucking kidding me
nO yOu nEeD tHe eXaCT tYpE oThErwISe iM goNNa crY
just refactor :D
yeah but then it introduces more complexity somewhere else
then it needs some other shit in some other place
it can never just work without conflicts
?jd
have anyone used C++ or C from here?
anyone?
public <C extends ConfigurationSection> ConfigurationHelper<S> child(String key, Supplier<ConfigurationHelper<C>> supplier, Consumer<ConfigurationHelper<C>> consumer) {
ConfigurationHelper<C> helper = (ConfigurationHelper<C>) createChildren(key, supplier);
// ...
}
yeah
If i dereference struct pointer
will it make a copy of the structure inside thel local variable
is Player#displayName supposed to not be persistent?
if a player is offline u cant use Player iirc
Player objects get stale
only OfflinePlayer
after they log off from the server
Use UUID's instead
Yea but a structure is a weird type
its like a pointer ot many variables
like an array
maybe the imports are messed up?
I guess that answered my question?
To recap: Player objects do not save displayName anywhere, so you just have to re-assign that for every onJoin
And when saving the displayName, save it as like, UUID:displayName
How can I make an arrow one shot no matter what, without using enchants
why would you save displayname at all
for nicknames?
if its username of the player you don't need to save it, if you have custom name you should.
ah thats what u mean
it's custom username
I don't have exacts, but if you make a check for if an arrow is the damager, you set the damaged's health to 0.0
1s
i havent touched api for a long time so i cant really tell you
just set the damage done to a big number ig
it really does
use the arrow operator people
i wonder what happens if you declare rvalue reference as a variable
it's in Kotlin but that's the gist
that wouldnt kill it if the entity has > 99999 health
just set entity health to 0
can't
to kill it
I looked in the javadocs
tf
no I mean there's no setHealth(0)
sorry used to kotlin
declaration: package: org.bukkit.entity, interface: Entity
no health though.
ye thats what I'm saying
I want an insta kill no matter what

