#help-development
1 messages · Page 150 of 1
That's where you're mistaken. ProtocolLib operates on the fields in the packets, not the contents of the packet over the network
There are no short fields in the packet you're trying to write to
You'll have to open it up with a decompiler, or just browse through BuildTools, to look at the source of the packet you're trying to send
cc @tranquil stump because I should have pinged you in the reply but I didn't out of habit
so i think i saw somewhere instead of this i could use PacketWrapper right?
Not sure how up to date that is, but in theory yeah. Those are more object-friendly
how come there aren't any short fields in the packet? is the wiki wrong ?
the wiki definition talks about how the packet is serialized
not its internal fields in the nms class
I keep saying this time and time again
ok so packets seem a lot more complicated than i used to think, should i learn what nms is before using protocol lib?
Hey! Does anyone know of a good Plot Shop plugin for a prison server? Been trying to find one for ages.
so i'm working on damage indicators and they don't work on players- what's going on? the important code starts on ln 49, but i included the rest just in case. https://paste.md-5.net/oqosaxopav.java
oki ty
I know EntityInteractEvent and PlayerInteractEvent are called separate, it could be the case here but I'm almost certain it's not
it's entitydamageeventt
https://paste.md-5.net/tugayuheri.php everything prints, but it's not summoning the armor stands
Well, it's spawning, but you're removing it 1 second after the fact
`yes, but it shows up for monsters
with the same exact code
hello
im trying to compare 2 itemstacks but because of a random plugin the enchants taken from creative menu has a lore=[] in their itemstacks that breaks this this, any possible solution to remove lore=[] from itemstack
neither of these are working
@EventHandler
public void onPotion(PotionSplashEvent e) {
MinigameManager mm = MinigameManager.get();
if (e.getEntity().getShooter() != null && e.getEntity().getShooter() instanceof Player p) {
if (!mm.isInMinigame(p)) return;
Minigame throwerMinigame = mm.getMinigame(p);
for (Entity entity : e.getAffectedEntities()) {
if (entity instanceof Player attacked) {
if (!mm.isInMinigame(attacked)) continue;
if (throwerMinigame.equals(mm.getMinigame(attacked))) {
if (throwerMinigame.getMinigamePlayer(p).getTeam() ==
throwerMinigame.getMinigamePlayer(attacked).getTeam()) { // getTeam() is enum
e.setCancelled(true);
}
}
}
}
}
}
@EventHandler
public void onPotion(PlayerItemConsumeEvent e) {
MinigameManager mm = MinigameManager.get();
if (mm.isInMinigame(e.getPlayer())) {
if (e.getItem().getItemMeta() instanceof PotionMeta) {
e.getItem().setAmount(e.getItem().getAmount() - 1);
}
}
}```
1st is meant to disable splashign teammates with poison
the 2nd is meant to remove the empty bottle when drinking a potion
Hello I need help with an erro. I'm trying to make threads that teleport the player
Code:
@Override
public void run() {
Player tfreezzmy = Bukkit.getPlayerExact(player2);
tfreezzmy.sendMessage("test"); -work
Location loc = tfreezzmy.getLocation();
int y = (int) (loc.getY() + 50);
tfreezzmy.teleport(new Location(tfreezzmy.getWorld(), loc.getX(), y, loc.getZ())); -dont work
}
Erro:
Exception in thread "Thread-236" java.lang.IllegalStateException: PlayerTeleportEvent cannot be triggered asynchronously from another thread.
You are attempting to teleport a player via another thread. To fix it, place the runnable on the server thread.
?scheduling
thanks
I am getting "unsupported class file major version 62" when trying to remap my maven project with nms, any help? The project is running java 17
Just to check
Maven properties compile version
Check the location of jdk
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
these are my project settings
@EventHandler
public void equip(ArmorEquipEvent event){
final String CustomName = "&c&lAde";
Player p = event.getPlayer();
int amountOfArmor = 0;
for (ItemStack i : p.getInventory().getArmorContents()) {
if (i == null)
continue;
if (i.getType().toString().contains("GOLD") && i.hasItemMeta() && i.getItemMeta().hasDisplayName() && i.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',CustomName))) {
amountOfArmor++;
}
}
if (amountOfArmor == 4) { // player has 4 pieces of diamond armor on
event.getPlayer().sendMessage("full armor");
} else if(amountOfArmor < 4) {
event.getPlayer().sendMessage("Not all armor");
}
}
hi something strange im using an armor event and works but only when i remove the last piece the message for full armor is flag but when i have all the armor the event is not flagged full armor but the not all armor one
Convert and extend?
never mind got everything to work
someone can help?
i have figured out generics have something like that late
I didnt get it
when i have the full armor it says i don't have the full armor but if i remove a piece then says i have a full armor
but i removed the piece
and its not full
Try to start amount of armor 1
int amountOfArmor = 0; to int amountOfArmor = 1?
the code works but I think the event is delayed because if I take it off the last piece is full for him but it's not if I have a gold armor and I remove the helmet it says I have all the piece but i don't have all of them because the gold helmet is not there
How can I make a bungee command able to be used in spigot servers from other plug-ins like chestcommands, deluxemenu... etc?
I have permission based perks with a gui, if the user doesn't have the permission i want it to display red stained glass, how can i do this?
This is my inventory class
If statement
ItemStack stack = Player.hasPerm ? yourDefMaterial : Material.RED_STAINED_GLASS_PANE
Yeah, some if statements
buoobuoo is right
@drowsy helm could you help me please?
Ahh kk
Java Assertion - Assertion is a statement in java. It can be used to test your assumptions about the program. Let's see its advantage and example of assertion in java.
how would i do it for each permission though, as they are seperate thats what i don't understand
I've got like 6 permissions to check for
if (player.hasPermission("ranks.admin") || player.hasPermission("ranks.mod")) {
could do it like this?
for all 6?
or is that dumb
Personally, I would make an InventoryBuilder class that contains an ArrayList<Element> and an ItemStack<Element> default if the player does not have permissions.
At that point, a very easy for-cycle on the InventoryBuilder items and, before putting them in the inventory, check if he has permissions. If it does not have permissions, set the stack default (element.getDefault()) at position element.getSlot()
Try also using XMaterial if you want multi-version compatibility and MiniMessage's Components for gradients etc directly from the config\
I'll take a look at all this, thanks man
np
Right now, I'm doing something very similar, by Element I mean something like this 🙂
Yeah i'm fairly new to java not seen this before, i got some learning to do lol
search for lombok, it will make your life easier
This?
is it theoretically possible to create commands in game
Explain “commands in game”
/createcommand hello
and add a commnad /hello that does nothing
Sure
is it possible to generate overload method signatures without having to write out all possible method signatures?
ie
method(a,b,c) can be called via method(a) or method(b) etc, and sets a,b,c to default values if not in the method call?
Trying to add the head to change to whoever opens the gui
how would I see what command was used in bungee?
Depends
if a b and c are different types then lombok might, otherwise manually
if there is one type that's the same then no
Bungee console helps you
since it would be ambiguous
that is the worst thing intellij could ever reccomend
You can try using @urban grotto annotation from JetBrains if you have
^
since the commands have to be ran from an mc server, you can listen for bungee commands there, otherwise you are going to be listining for chat event on the bungee server itself
bro who calls themselves that
sounds like too much effort i'll just try the easier way
uuum
why cant i null check int
so if i call method(..., null, ...) how do i check if the argument is null or not
because int cant be null
check if == 0
i think
so if i do method(null) it turns into method(0) ?
why are you putting null into a method?
are you referring to an if statement, checking if it is null?
im having a method signature with like 8 values 7 of which have default values and i dont want to do every possible overload signature manually
int cannot be null as it is a primative. Integer can be null tho as it is an object
I do somewhat prefer default values in other languages over overloading
thanks for clarifying this a lot better then the previous, was about to say this lol
Idk, you could always just make a custom class with said defaults and then pass that to the method
all primitives can not have null values
i suck at explaining
Hi a question im trying to make sort of GKit for my server but i want apply in case someone have a full armor of a gkit an effect i tried doing a task and works fine but can lead to lag on checking more than 100 player another method is the ArmorChangeEvent but with this one i can't for some reason check if the player has a full armor or change it any other way to do it clean?
Code i made currently that doesn't work https://sourceb.in/Pz7OwfLyzK
You should be able to check each armor slot in said event
Granted idk where that event comes from
https://github.com/Arnuh/ArmorEquipEvent this is what im using as lib
for example if i have full armor it says the armor is not full but if i remove a piece it says the armor is full
what event is called when an item is put in the chest from hopper
InventoryMoveItemEvent
in the chat or action bar @quaint mantle
spaces would be the non 3rd party method, there might be a formatting api somewhere on github
thank you
hi guys does anyone have an idea how should i find player head in inventory of player and then remove each head
im stuck at looping through inventory as i dont know how to get material of head in api version 1.19.2
i dont remember if theres a contains on a players inv
nope it is not
spigot doesnt support 1..8 anymore
show your code
Me? I have
do you already have the item in the gui?
@remote swallow how would i loop through inventory to find those heads to remove them
ill pull up ij one sec
I’m trying to get players head in the gui
Not just PLAYER_HEAD but the actual players head who is opening gui
you will need to set some kind of meta i think
SkullMeta#setOwningPlayer(Player instance)
Did i not already set owner ?
Bro ur pfp freaks me out
if your setting it from the player name that should work
just get the playername from the event or sender
Hi all! How to fix error in console pic?
change it to setOwningPlayer() with just the player instance
thats for offline player though right?
Works on both
Still the same error
remove the offline player annotation
(That’s a cast)
Cast should be fine
It doesn't work
How come your passing player as HumanEntity not Player
Remove the short from new ItemStack
Amended both, removed short and made it Player not HumanEntity, still same error :/
Which line is the error
26 and 51
that formatting ij has done is something
?paste
@young knoll any ideas
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setDisplayName(ChatColor.WHITE + playerName + "'s Head");
meta.setLore(Arrays.asList(ChatColor.GOLD + "Decapitated by: " + killerName));
meta.setOwningPlayer(p);
skull.setItemMeta(meta);
Is the basic premise you want
Im getting this warning, not sure how to get rid of it. I already excluded the jar it tells me, not sure what else to do
https://paste.md-5.net/isanoyozay.xml
ignore it, doesnt mean anything anyway
its just ugly tho
Eyy thanks mate
Does anyone know how I can, if player doesn't have specified permissions for each perk, change the item in the gui to red stained glass? I could do it if i was based off levels (int) but not sure how when it's permission based
theres probably a better way but
if (player has permission X) {
set item
} else {
set red glass
}
Yeah, I got 5 seperate ones though, do i just do if statements for each?
yeah
Okay sounds good
if you have 5 permissions yeah, if its one permission for 5 items, for loop through them
Yeah 5 permisions for the 5 perks in the gui
doesn't need to be clickable its just display
then you do have to do an if for each of them
No problem 🙂
@remote swallow Do you know how would i make for each other slot that has itemstack == null i set it to stained glass
where would it get the item from
so i have a inventory created and there are some items set in it and i want for every slot that doesnt have any item to put stained glass
No need for == true
ItemStack glasspane = new ItemStack(Material.valueOf(this.kozperks.getConfig().getString("Perks.Inventory.Fill")), 1, (short) 0);
int slot;
while ((slot = perksInventory.firstEmpty()) != -1) perksInventory.setItem(slot, glasspane);
Set every slot to glass and then set the slots you want to not be glass.
Or better yet iterate through each slot and do an if else based on if it's an item or glass
This does exactly what you are after
Anyone know why this is happening?
Im setting my skin to a full white skin and then using mineskin.org to fetch the texture and signature, and setting it to my npc using GameProfile. However, in game the character just appears as black? This does not happen with skins downloaded from sites like minecraftskins.com
I added if statements and command no longer working
ugly ahh code
ever heard of ||
Already tried
and why are all of the ifs inside the other ifs
if (perm1) {
do
}
if (perm2) {
do
}
ectect
not all inside each of the higher
basic java bro
I did ctrl alt l and it did that
gotta love the staircase
like how you don't learn c++ through opengl 🥲
Like how you don't learn how to not be a virgin through watching hentai right wihy?
dunno but works for me
its better than what ever that fuckery was
If we taught every person who came here asking for help with basic java instead of helping with spigot questions we could rebrand this channel as #help-java
That took you about 5 hours to type that
I just don't get these people
I thought about what I was writing
How do I make an npc walk (with animation) to a spot?
You mean typing? Guess you didn't think after all
you'll have to do some trickery, ServerPlayers don't have pathfinders
Yeah I'm aware
the easiest way, which I do is just make an invisible zombie and teleport the player to the zombie every tick
does this also include animation?
yep
moving the player's hand and stuff
It appears you also can't understand English either.
movement animation is clientside
Ok, thanks
What? That made no sense lmfao
Should i make a class which extends zombie or just create one?
You don't make sense
Not a virgin and you've never seen me.
is there a goal to just walk to a spot?
I beg to differ
ive seen code for it before but i forgot the link
Head ass virgin
Yeah go ask your Mom
That’s a new one
nah you have to make your own goal iirc
pretty straight forward anyway
use a try catch then
Nah use the method that was made for that
Or just never input a material that doesn’t exist 🧠
Yes
yep
Damn immature child virgin loool
You're the child in this situation
Mum jokes?
No, this is Patrick
you have anime as your pfp quiet down little boy
Talking shit when someone talks about how this channel is not for their inability to code in java
I'm trying really hard to imagine that
You're probably like 15 lol
Bullshit how can a 21 year old be so immature
Ok im lying
if you say im not 21, i cant be 21
I'm immature? you said mum jokes lmfao
Cause I can? You're the dude getting upset people telling you to learn to code
Learn to code? That's exactly what i'm trying to do
Why would i be upset LOL
cap
I'll learn how i like
And that is not something you should do here, this channel is for helping with spigot api, not basic java questions
I have interest in this, it helps me learn
lombok is hacky but it works and I don't have any problems with it
I didn't ask a java question
I'd hardly call it hacky
No one asked about java
Lol
more advanced lombok annotations are hacking
playing with sun.misc.Unsafe on production code
but simple getter setters are fine
Well when your issues are related to a lack of java knowledge or your code is super unreadable it becomes difficult to help someone
Then don't help. Simple as.
I still use guava's Optional sometimes
Guava's Joiner is pretty sexy
Are you okay? I'm trying to learn... Lmfao
I'll learn however I choose to learn, i've been doing it about 3 weeks and i'm doing pretty decent so thanks for your input but im going to carry on switching between the api and normal java.
y'all are bashing too hard on kilocodes compared to all the other noobs that ask for basic help on this chat
just let the mf breathe, we all wrote shit code in the past
Ikr lmfao
and some of us still do
I did what i got told to do, yeah i fucked up the } indentation but i was literally doing what i got told to do, if statements for it all...
It's the way he responded to me 
You get what you preach, arsehole
attitude as good as their code ¯_(ツ)_/¯
https://sourceb.in/hsTfaZX8pV Hi this config method is not reloading ||probably because i m using enum but not sure|| any get arounds?
🍿
I didn't say anything rude or offensive. You started it
"YoU StaRtED iT" says every 5 year old kid
you gotta store the file, reloading requires you to re-parse the YAMLConfiguration
I have a YMLBase class that holds both the file and the configuration
how i can do this?
I'm not the one trying to fill empty slots bro
You said I get what I preach but you started preaching first so you're only getting what you preach.
I have a gui with perks, per permission, I wanted to make it so if they don't have the perm then they only see red stained glass pane instead of the itemstack for the perk, but i think i've done it now
basically load your config again
public void reload() { this.config = GKit.plugin.getConfig(); } like this?
itreid that but doesn't work
I absolutely despise your static variable
oh ok now i understand thanks
you gotta mix both
plugin.reloadConfig();
config = plugin.getConfig();
ternary operator so fancy!
My teacher recommended nesting them for my C# class as a solution instead of an Enum
incorrect, the bytecode for tenary and if else is different. We had this discussion like a day ago already
The end result is the same
thats true
school teachers often don't know wtf they're talking about
I mean
half of them don't
the other half made the fucking internet
thats not true
my programming teacher's entire career is just
study programming, study teaching, become programming teacher
never worked as a developer
Then I have my networking teachers
I think my teach had 20 years? He started teaching a year ago so his most common phrase is
"we don't use this in the industry but"
mans setup the entire school's network, preached about cisco and taught about the TCP stack
/shrug I had one that went off on a tangent about the Covid vaccine…
new teacher manages tons of hospitals remotely
one of my teachers wrote the hotel software that half the country uses
I think my current one worked on collecting telemetry data on fighter jets. Only reason he got the job was he knew one of those awful COBOL like languages
that once again is true
man wrote pascal code or some shit
Yeah can't remember the name for the life of me
He gets paid bigly cause he's one of the few who knows it
and because I already hate myself, so nothing much will change
my comp architecture teacher wanted to teach assembly in class
to a bunch of kids that didn't know what an int was
My friend learned both assembly and C and C++ and he still doesn't know good design patterns
like
class has been learning how to code for the past 2 years
mf went to the teacher
"wtf is an int, I'm hella confused"
I feel that on a spiritual level ngl
I'm glad I skipped that class because I'd punch the shit outta him
Java? Isn’t that just a posh word for coffee?
I had a kid in Highschool bio class high asf the whole time ask me at the end of class what page we're on. Like bro class is over
we did python and c#
I don't think we have any smokers in our class
we had a guy that pulled a cig out during class but that's a different breed
Uh, sure.
Soon to have Rust tho 👀
pretty sure that torvalds approved the usage of Rust
Ye
Next big update will see the first native Rust apparently
Imagine not having memory issues. Couldn't be me
😢
who
Free java lessons, just DM md_5
Where is that noob? They'd love to be taught I'm sure
Scroll up
yes
omagaad
how to increase tickrate to 21
tick_rate = tick_rate + 1
help me i'm getting Unsupported class version (52.0) when i play need for speed mine crafted
Amateur!
where do i put this?
tick_rate++
in onEnable()
I think in your hair
Don’t put ticks in your hair
is it connected to YamlConfiguration somehow
nms
put it in a while true
mns like NTB
alright
what the fuck paper actually has an item rarity api 💀
public class BiggestProjectEver extends JavaPlugin {
public void onDisable() {
}
}
}
while (true) {
tick_rate = tick_rate + 1 { System.out.println("Hello, world") }};
}```
why doesn't it work
pretty sure it's like
underlined red
paper? I hardly knew her
Yeah it just determines the color of an item name
sadge
And uhh… I think that’s it
The error is 403 forbidden
it doesn't compile @vocal cloud
help me solve this puzzle
I imagine not enough {}
maybe
add a few hundred
changed
nest some if's while you're at it
hey
Unnecessary primitive wrapper usages
shit
just change the bytecode to say you have class version 99
Add a PR to spigot telling them that it's not your code that's wrong it's them.
Okay maybe don't do that but it's funny to see it happen irl
we should make a plugin bundled within spigot
so that when you put spigot on your plugins folder
it actually just crashes your server
it just starts another server and creates another setup so you can nest servers in the worst way possible
and also fix my annoying habit of putting the plugin jars outside the plugins folder
automatic instancing 👀
not my fault that I patch plugins and spigot itself too
Spigot can now load spigot as a plugin
and also check deep into world nbt data
Spigot can now load forge as a plugin
Yes
thought you were talking about MagmaGuy for a second
lol
we bash at each other a lot
Question why this code doesn't work im trying to achieve to remove the player some durability to the armor he is wearing
Player player = ((Player) event.getDamager()).getPlayer();
short durablity = (short) (player.getInventory().getHelmet().getDurability() - 5);
player.getInventory().getHelmet().setDurability(durablity);
if i instantiate a class extending the nms Zombie, do i need to do anything to spawn it in? or does it do it by itself
because I like tricky problems with neat solutions while he prefers making huge blocks of statements that just call different methods
add it to the world
Custom mobs aren't persistent so make sure to recycle
is your listener/commandExecutor registered
yes
Isn’t that the legacy way to set durability
you can do something hacky
like they don't stay alive after server restart?
Proper one is in Damagable which is a subclass of ItemMeta
They'll be alive just not your custom class anymore. You'll need to recycle them
durability is inverse
true @grizzled oasis
example?
good to know, thanks
OH
@young knoll isnt ur spigot name jishuna now
you can always add a tag and do some hacky stuff to respawn the entity with the same uuid
why with - heal the item but with + damage it?
nvm UUID is not final lol
Hence the recycle bit. Might be a bit expensive though
ask spigot devs
durability should be replaced with Damage honestly
not us
can i make it so entities don't push other entities?
setDamage etc
it's a mojang thing afaik
I guess numbers set as 0 are slightly easier to compress
disable ai
disables gravity too
pretty sure entity pushing is defined in the move tick
and im assuming serverplayer doesnt either?
yada you're pretty much just asking us how to do every single step on your way there
Vector[] vectors = new Vector[value2];
for(int i=0;i<value2;i++){
vectors[i] = //marked
corners[i]...
can someone explain to me why it says IndexOutOfBounds in the marked line of code?
java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3
maybe it can be modified in spigot configs or smth
Entities have a setCollidable
umm basically you messed up corners array i guess
bukkit entity?
I'd rather have full code
And also a addCollidableExemption or something
you're having a very basic issue given you know anything about bytecode
Location loc0 = player.getLocation().add(0,-10,0);
World world = loc0.getWorld();
Vector addVector = new Vector(value1,0,0);
double angle = 360.0 / value2;
Location[] corners = new Location[value2];
for(int i=0;i<value2;i++){
corners[i] = loc0.clone().add(addVector);
addVector.rotateAroundY(angle);
}
Vector[] vectors = new Vector[value2];
for(int i=0;i<value2;i++){
vectors[i] = //error here
corners[i+value3%value2].toVector().subtract(
corners[i].toVector()).
multiply(.05);
}
it errs in the line before
How can i schedule a task for running every few days changable in config?
do corners[(i + value3) % value2] instead
u sure it's here and you didn't remove/add a random whitespace
rest of the code looks fine, this should fix it
umm basically you'd better not do it
well it says error in line 45 and that is in line 46
nvm, extended it to LivingEntity and it worked
ill do once it works
name the variables better and you won't need to 
I tend to go insane with commenting code whenever it's something complex
also while nuker and imillusion were right i dont understand why it would give the wrong line
but i need to because every 3 days a player needs automatic withdrawl and some people want to change the days in config
well server might restart at least once in 3 days
also i fucked up the math but idk where
self-explanatory code is good enough
so you better store the millisecond timepoint irl in config when your task should be executed
but sometimes you gotta go the extra mile when doing trig
and run a task timer which stops at given milliseconds time
vector math is really annoying to debug
vector math is really annoying to do on paper last day before exam
Thanks i will try that!
fun thing I do
I actually visualize and debug vector math on math class
with pen & paper
no no im trying to get a triangle
hella useful
point 1 point 2 point 3
you're trying to make a triangle?
lines between
just make 3 points and make a line between each point
it gives me a triangle but not in the shape i want
what
just do like
triangle
the vector math should give a even triangle
you probably forgot to use doubles instead of ints
so your shape is inaccurate
🙂
actually I know what you're doing
rotateAroundY takes the angle in radians
you're passing degrees
stupid shit but it happens
angle = Math.toRadians(angle)
apparantly yes
guys I can't figure out what this does:
public static void main(String[] args) {
System.out.println(1 + 1 * 2)
}```
help
ew static
it prints 3
if you run that it kills your parents
ahaha
oh no 😭
Main methods are static abuse
why you passing an array, lists are more useful
ahahah
?
My tv likes static abuse
what about hair dryers
fork java and remove all the static
make it so you have to instance the class
like "System"
ty zacken ❤️
ily too
boon
they can find zero width spaces now
fork java remove semicolon
make java, except you can only type in brainfuck
make java run on chinese
im just testing shit
apparantly someone forgot theres more than one ZWS
❤️
remove arrays from java
welp ig normal spaces work too
make java only ever need 1 class
Remove collection interface
isnt the overhead of a list bigger than that of an array
++++
that would end up like 200k lines long in the end
++++
can be
but like Collections.ArrayList is basically a wrapper for a normal array
yes
wait so
yeah fluent naming
they look cringe
^
adding an element to an arraylist just creates a new array and copies the old one then inserts the new element
fork java except you type like its skript
and records mess it up
myes there is the debate whether functions should be verbs or nouns
yes
verbs kinda more connected to irl
well personally I believe get doesnt really add anything
Hi how can i prevent falling blocks to place themselves?
sure writing get on some object provides u with getters only as suggestions
cancel blockphysics event
but its shorter and still as expressive if not even more
and piston weirdness
let me see
basically quit the game while block is still falling
and delete the world folder
so you prevent blocks from placing
would i be able to do like
Class::x
so i call x() method
if i use records
well then probably not so bad
yeah and not to mention record like getters have became the standard in java std
like ReadWriteLock::readLock and ::writeLock
no but it returns a read write lock's read lock respectively write lock
yeah i will definitely use this method as it is so much efficient and quick
usually implemented in a reentrant fashion
😐
you are welcome
make a c++ program connect to mc process
get memory adress of the event
how does it work?
anyway nukerfall Id say not having the getter prefix makes the abstraction more powerful as it tells u less about how the function behaves whilst usually keeping what the function does
?
it's better to have an external variable
instead of calling stream.sort(yourComparator).get(0);
but wouldn't it prevent other stuff?
or find some event of block place from entity
well i'm sure there are 10000 getters
of what actually happened
so you get if it's caused by falling block
and if it is cancel the event
yeah i made that but the event doesn't have a getEntity() method or anything
this sucks
there's nothing like that
small pp event
it works!
How do i get all the regions a player is owner of with worldguard?
yes found it! thanks!
for(int i=0;i<value2;i++){
vectors[i] = corners[(i+value3)%value2].toVector().subtract(corners[i].toVector()).multiply(1.0/20.0);
}
Particle.DustTransition particle = new Particle.DustTransition(Color.WHITE,Color.BLACK,1f);
for(int i=0;i<value2;i++){
for(int j=0;j<20;j++){
world.spawnParticle(Particle.DUST_COLOR_TRANSITION,corners[i].clone().add(vectors[i].multiply(j)),4,particle);
}
}
value2 = 9; value3 = 1. Why does it produce 9 points instead of a nine-sided polygon
ah
forgot a clone again
Is there a way to spawn an interactive dead body?
no
you can spawn armor stand with skull on helmet
99% of vector-related threads on forum
you can spawn a serverplayer lying down can't you?
put it in the position as if its sleeping
only with packets
i tried it once for 1.16
you can make player walking while lying
and when player flies up from the hole in dirt it looks like resurrection
Lmao
yeah
was laughing too
used ProtocolLib for that
package me.carefall.etalon;
import org.bukkit.plugin.java.JavaPlugin;
import static me.carefall.etalon.util.Colorizer.colorize;
public class Etalon extends JavaPlugin {
public void onEnable() {
saveDefaultConfig();
send("&aPlugin enabled!");
}
public void onDisable() {
send("&cPlugin enabled!");
}
public void send (String s) {
getServer().getConsoleSender().sendMessage("["+ getDescription().getName() + "] " + colorize(s));
}
}```
what do you think about this code
i hate it
why tho
is logger not good enough for you
As long as it isn't production code, I'll let it slide
Or just use ANSI?
explain
ANSI color codes for logger
what should be in send {}
Java.util logger supports if afaik
isn't sedning message to console faster or smth
Idk tbh
and like no shit with translating &code to ansi
public static String colorize(String input) {
return ChatColor.translateAlternateColorCodes('&', input);
}```
my paint method
basically just replacing & with §
so console eats it easily
also should i have a method where i register listeners
or it's better if i leave them in onEnable
or it depends on amount of listeners i want to register
production code (in a sense of it being publicly available) should never use coloured logging, big no-no
unless your luckperms
Luckperms also has no rights for that
its luckperms
They even use ASCII art, another big no-no
a lot of plugins do colored logging
wonder what there bstats islike
see no problem with it
also isn't creating a painter class and using it's static paint method in all of the classes a static abuse
should i switch to colorizer instance instead
Why would it be
This is the reason I am against colored logging - warnings and errors are much more intrusive if they aren't in a see of colors
It's literally utility, no need to be instance method
bro i only print onEnable
and onDisable
And for my plugin's errors which i handle
i make red color
and sometimes disable plugin/server
So what, errors tend to happen there more than anywhere else
if plugin is critical for it's performance
why dont u just color warnings and errors
and nothing else
color errors
slf4j does it by default
Or well, log4j
i still have a question about listener's registry
no idea how my errors look like to be fair, I only know that errors are colored. Could be just that paper has the log4j config in a saner fashion
maybe
i run spigot mostly
im running spigot so that my plugins run on spigot
so i don't remember
then that is defo is issue, paper does a lot of logging changes
Which is why on paper you'll often see epic fails like this one
well lp apparantly works under spigot so idk why that wouldnt wokr
what do you mean?
Don't get me wrong: All your proposed stuff (partially) work on both spigot and paper
colors under spigot in console are possible
Is pdc safe for storing secrets? (ie no other plugin can access it)
I am talking about paper though
And can you see value when thread/memory dump?
not completely but its unlikely that other plugins will
not at all
Thanks 👍
what do you want to store even?
if it is easier to just store them in the pdc, just encrypt them
hashing would do, probably
Yap, encrypting them anyway
and store the salt in some random chunk
package me.carefall.etalon.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import me.carefall.etalon.Etalon;
import static me.carefall.etalon.util.Colorizer.colorize;
public class ChatListener implements Listener {
private Etalon plugin;
public ChatListener(Etalon plugin) {
this.plugin = plugin;
}
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
event.setCancelled(true);
String format = colorize("&b" + event.getPlayer().getName() + "&f -> " + event.getMessage());
if (!plugin.getConfig().getBoolean("log-chat")) {
plugin.getServer().getOnlinePlayers().forEach(p -> {
p.sendMessage(format);
});
} else plugin.getServer().broadcastMessage(format);
}
}```
what about this
Violating the contract of AsyncPlayerChatEvent#getFormat
setFormat is shit
How come?
Due to performance or what?
no since way longer
due to it's eating regex
Good thing https://openjdk.org/jeps/430 is a thing soon
for no reason
format doesnt use regex?
it does now
Yeah, format shouldnt use regexr
ugh what
so if you have % or $ or some other symbols
it crashes completely
you have to \\ them now i guess
I think you just didn't read the String.format documentation
there were topics about setFormat already
i used it back when i coded for 1.8-1.12
and it was working perfectly
now it's trash
I.e. String.format("%s's percentage points is %d%%", "John", 100) would print "John's percentage points is 100%"
event.setFormat(colorize("&b" + event.getPlayer().getName() + "&f -> " + event.getMessage()));
anyway I do agree that the choice of using Formatter format specifications for the async chat event is somewhat undesirable but not for your reasons, yes String.format() delegates to Formatter() which uses regex iirc under hood however its pre-compiled
You'd need to use event.setFormat(colorize("&b%s&f -> %s")))
you can also use setMessage
but there are a lot of plugins that just cancel the event and broadcast their own message
well prepend a placeholder parser before the formatting maybe?
have to write entire method instead of just sending own customized message
so?
if you are that lazy, just use skript or something, then you dont even have to compile
alr let's change it
event.setFormat(applyPH(colorize("%vault_prefix% " + event.getPlayer().getName() + "&f -> " + event.getMessage())));
now if for some random reason vault is not loaded or i have no PAPI extension it's gonna crash
check for it onEnable
and if i send custom message it will tell server owner that extension is not installed
by literally leaving %player_prefix%
in message
As said, you can just cancel and send your own message
That is what every other chat plugin does
this way i have to check every extension which is in API
Which is not the greatest solution
How to check if player is shift-clicking on a block?
But due to the design choice of async pce
and every plugin which supports it
so if at least one is not loaded, i should not even create a chat listener
that's the problem
Player#isSneaking iirc
Then just check if they right clicked q block
when right click if player.isSneaking() == true then they definitely shift-click
Yk you don't need to do == right
It's just extra typing for nothing
bro just to clarify
if (!plugin.getConfig().getBoolean("log-chat")) {
here
i don't use == true
But if the player select sneak: Toggle in setting. it will also called
No
it would be shift-click
But it will literally detect of they are sneaking
There's nothing wrong with the isSneaking method it does what it says in the name no exceptions
I am not too sure if shift click on a block is diff to sneak click on a block
Either way, use the respective PlayerInteractEvents
declaration: package: org.bukkit.event.inventory, enum: ClickType
bro
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
INVENTORY
oh i see
what does shift click on block even do
like placing torches on crafting tables?
?
Ignore chest opening and just let place block
just check if player is sneaking
isn't it gonna work
None the less seems you ignored what was earlier do above
Location[] locations = new Location[1];
for(Location l : locations){l = exampleLocation.clone().add(0,1,0);}
after this does locations[0] contain null or exampleLocation + 0,1,0 ?
Probably typed it too fast for discord to handle
why would locations contain anything
why don't you do
null
Location[] locations = new Location[] {exampleLocation.clone().add(0,1,0)}
wanted to know if i can do it without the int stuff
for (var x : arr) is basically a for (int i = 0; i < arr.length; i++) {var x = arr[i]; wrapper
do this instead of int stuff
lol
Any reassignmets to X do not result in any ASTORE instructions
Location[] corners = new Location[polyNumber];
Vector[] connectors = new Vector[polyNumber];
double angle = Math.toRadians(360.0 / jumpNumber);
for(int i=0;i<polyNumber;i++){
corners[i] = center.clone().add(examplePoint);
examplePoint.rotateAroundY(angle);
}
still doing vector stuff, i dont know the value of polyNumber
Basically foreach will always only produce a single XLOAD insn, but not a XSTORE insn (unless told otherwise)
yea that makes sense
im a bit suspicious of java after all this stuff where calling vector methods edits the vector and returns the reference
bukkit vectors and locations are sus
use stack instead of array
))
wdym
Don't use Stack
or something which supports adding
As in a FIFO queue or just a normal list
yeah
yeah to what?
public List<Location> getPolygonPoints(int pointCount, Location center, double distanceFromCenter) {
double angle = 360 / pointCount;
List<Location> list = new ArrayList<>();
for(int index = 0; index < pointCount; index++) {
double angleOffset = index * angle;
double radians = Math.toRadians(angleOffset);
double x = Math.sin(radians) * distanceFromCenter;
double z = Math.cos(radians) * distanceFromCenter;
list.add(center.clone().add(x, 0, z));
}
return list;
}
to list
then just draw a line betwene each point
Then at worst use java.util.Vector, at best use ArrayList or CopyOnWriteList (if concurrency is needed)
I mean you started by suggesting Stack, which is a thread-safe implementation of a LIFO Queue
i just said first collection on my mind
for example
hey guys
i can wrap setFormat
into FormatException try catch
and if caught one just send unmodified message
public List<Location> drawParticleLine(Location start, Location end, double offset) {
// offset = 1 / particlesPerBlock, so 0.2 means 1 particle every 0.2 blocks
Vector one = start.toVector();
Vector two = end.toVector();
double distance = one.distance(two);
Vector offset = two.clone().subtract(one).normalize().multiply(offset);
Vector current = one.clone();
List<Location> points = new ArrayList<>();
World world = start.getWorld();
for(double index = 0; index < distance; index += offset) {
current.add(offset);
points.add(current.toLocation(world));
}
return points;
}
and log error
@smoky oak should solve all your particle shenanigans
so now you just make the list, cache it and render the points as you go
since i dont want to have to do weird math if i have a non-north aligned polygon
public List<Location> drawParticleLine(Location start, Location end, double offset) {
// offset = 1 / particlesPerBlock, so 0.2 means 1 particle every 0.2 blocks
Vector one = start.toVector();
Vector two = end.toVector();
double distance = one.distanceSquared(two);
Vector offset = two.clone().subtract(one).normalize().multiply(offset);
Vector current = one.clone();
List<Location> points = new ArrayList<>();
World world = start.getWorld();
for(double index = 0; index * index < distance * distance; index += offset) {
current.add(offset);
points.add(current.toLocation(world));
}
return points;
}```
or just feed it through 7smile7's code to distribute it
sure you can do squared stuff
just faster