#help-development
1 messages · Page 1946 of 1
Do not override the constructor
thats based on the directories ?
what is your package name
so for
src
--Base.java
plugin.yml
it woukd be src.Base ?
why are you not using a package?
didnt know that i needed too
you should
and why do you have the constructor in the main class that is literally empty
cause i got the error message "no public constructor" so i tried adding one ^^
i put it in a package now but now im again getting the "no public constructor message"
try making the class public
hey, can I send the same packet twice?
Why not
oh awesome, yw!
it was just fine without a package
I want to cache a "clear equipment" packet set for a certain player and send it when I need to
will that work?
I figured it would of be fine without being in a package but just wanted to double check
is there a way to detect (without injection) when a player will rerender another player (eg. sendEquipmentChange will be reverted)
like, what's the "faraway" distance?
70 blocks?
is there any way to know?
nah
ahhh because of render distance?
just use protocollib
ok
honestly i've learned my lesson after being stubborn against these big changes so many times before haha
just gonna switch over so i don't have to deal with it later
Packets are not the best idea either and i rarely recommend messing with them.. But in this cass it seems reasonable
I think there's API for that
No need for packets there
oh you were using that originally. Not sure what you're trying to solve by using packets. Bukkit just sends that same packet so you're going to do the same thing just with ProtocolLib instead. You'll run into the same rendering issues
1.8 :/
ic
what happened to all the numbered packets
ohh nvm, that's not protocollib
also where is the maven address for packetwrapper?
lol
choco dissapointmemt
we put in effort to provide a sick api
and people use 5+ year old versions
I made my first Listener in bungeecord, but how can I register this listener in my main class?
Thanks EventHandler
ty
thats like seeing people use code you wrote when you just got in highschool and now you’re entering uni
i know the pain of people using your outdated stuff
😢
trust me. if it was easy to switch at this point i would
Um, how do i write my class name in there
wdym by that
im knee deep in like a 3 year project that was started when me and my partner both knew nothing
Cannot resolve symbol 'listener'
how is it hard to switch
complications
make a new instance of your listener class
huh
bruh
No offence
but it will help you further in your career
@alpine urchin im trying to do it inside of @Override
public void onEnable() { } so i need to mention the class name of the other file to enable the listener
cant just write "this"
Its like trying to write english essays when you don’t know englis that well
knowledge needs to be applied
well maybe that's how you LEARN english
lol
in coding, writing essays is how you learn english
it's pretty much the best way there is
Yes, and i’m guiding him to search up his question.
asking stupid questions is how you learn tho
If he doesn’t know what an instance is, I can’t give him a crash course in java
you learn by googling
just tell him to do new X() and it'll click later
too
this is referring to the main class
and “listener”
replace that with
new X()
X is name of class name(the listener)
Yeah
make sure it's public too
also where's the maven adress for PacketWrapper?
Hello! I'm having issues using the ItemStack.deserialize function. It seems that item meta is not being deserialized
public static KitContents from(String s) {
String[] contents = gson.fromJson(s, String[].class);
if (contents == null) {
return null;
}
ItemStack[] inv = new ItemStack[41];
Type type = new TypeToken<Map<String, Object>>(){}.getType();
for (int i = 0; i < contents.length; i++) {
if (contents[i] == null || contents[i].length() < 1) {
inv[i] = null;
} else {
inv[i] = ItemStack.deserialize(gson.fromJson(contents[i], type));
}
}```
However it is being serialized correctly, here is an example of a serialized ItemStack string:
{"v":2730,"type":"DIAMOND_SWORD","meta":{"enchantments":[[{"target":{"a":["MAINHAND"],"b":"RARE","e":"WEAPON"},"key":{"namespace":"minecraft","key":"fire_aspect"}},2],[{"target":{"a":["MAINHAND"],"b":"UNCOMMON","e":"WEAPON"},"key":{"namespace":"minecraft","key":"knockback"}},2],[{"target":{"d":0,"a":["MAINHAND"],"b":"COMMON","e":"WEAPON"},"key":{"namespace":"minecraft","key":"sharpness"}},5],[{"target":{"a":["MAINHAND"],"b":"UNCOMMON","e":"BREAKABLE"},"key":{"namespace":"minecraft","key":"unbreaking"}},3]],"attributeModifiers":{},"repairCost":0,"hideFlag":0,"unbreakable":false,"damage":0,"placeableKeys":[],"destroyableKeys":[],"unhandledTags":{},"persistentDataContainer":{"customDataTags":{},"registry":{"CREATE_ADAPTER":{},"adapters":{}},"adapterContext":{"registry":{"CREATE_ADAPTER":{},"adapters":{}}}},"version":2730}}
id use pastebin
i can't find it anywhere, I'm probably just not experienced enough with maven
to not flood the chat
what project?
if you can find it please tell me
afaik there isn’t, its common for projects to just copy what they need from there
I’m sure many projects just copy the packet wrappers they use
There is no official maven dependency for those
hmm ok
Or atleast its not on their page
they only link to protocollib
I think it might be possible somehow using JitPack.io
idk if you are familiar with that
Lets you get maven/gradle dependencies for open source projects
Looking at https://jitpack.io/#dmulloy2/PacketWrapper all builds have failed
so thats not good news
So yes, copy them into your class @woeful crescent
when i build my bungee it just says
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing C:\Users\x\IdeaProjects\Bungeeproxy\target\core-1.0-SNAPSHOT.jar with C:\Users\x\IdeaProjects\Bungeeproxy\target\core-1.0-SNAPSHOT-shaded.jar
but there is no jar
got it
@neon minnow where are you looking

in target folder
its gone
nothing shows up
i cant even build bungee anymore..
what build command
built output says build finished up to date but no new files
ctrl+f9 i press
build green icon
screenshot
how do i just straight up download the file on github
actually click edit @neon minnow
edit the run task
and show me what it really euns
runs
what command
you can only download the whole zip of the project
zip
ok
i dont know how to do edit
screenshot this green button
what
cant open ur ss
one sec
no
getProxy().getPluginManager().registerListener(this, new testListener());
click the arrow down
ye
edit configurations
yeh
screenshot
did this work
hmm why isn’t that working
ok
close it
its probably cause your plugin doesnt compile
did the error fix with the snippet i showed you
ye
Hey guys, quick question. Is there a way to find out when the weather will change? Like is it a thing to randomly happen or is it more like, on day 3 it will rain, on day 5 there will be a thunderstorm and it's stored / calculated somewhere?
I believe it used to be a bug
build
okay, thank you
idk
i havent used it
cant comment on it
but i heard it supports minecraft clients as old as 1.4
the jar is empty
Lol
wtf
java.lang.ClassNotFoundException: server.bungee.core.Core
at net.md_5.bungee.api.plugin.PluginClassloader.loadClass0(PluginClassloader.java:103)
at net.md_5.bungee.api.plugin.PluginClassloader.loadClass(PluginClassloader.java:59)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at net.md_5.bungee.api.plugin.PluginManager.enablePlugin(PluginManager.java:340)
at net.md_5.bungee.api.plugin.PluginManager.loadPlugins(PluginManager.java:250)
at net.md_5.bungee.BungeeCord.start(BungeeCord.java:271)
at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67)
at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
meta inf and bnungee yml
Hey someone know how I can get the number of Zombie I have killed with player.getStatistic() ?
or another method without config
bump
@alpine urchin is the command supposed to be clean package???? cus thats what it runs.
shouldnt it be compile??/
Yeah
clean package
You basically have to manage the ItemMeta yourself
:pain:
clean package is fine
Yeah lol
No pre built stuff out there? Smh
@ivory sleet an idea ?
MattMX, well Idk, I believe there is but I don’t know any sources
Anyhow it’s not complicated
That’s just the static analyzer
How so
my jar build is empty, only meta inf and Bungee.yml
It's probably not but sounds grueling
declaration: package: org.bukkit, interface: OfflinePlayer
this is bs
I mean Gson is pretty good at creating type adapters or whatever it’s called
Yeah i found that but I don't find the Zombie I can honly get KILL_ENTITY or MOB_KILLS
wtf
java.lang.IllegalArgumentException: Plugin already initialized!
what the hell does this mean!
Uh
you have 2 plugins
you have 2 jars ?
with same name
No i only have 1
in error it says
at bungee.core.Core.onEnable(Core.java:10)
which is my line where i enable my listener
??
Like that ? p.getStatistic(Statistic.KILL_ENTITY, EntityType.ZOMBIE) (not working)
What’s not working?
Oh no sorry its good I'm just attard
I believe there is a method to retrieve a type adapter for whatever type you use
Like without manually implementing
you sure you’re finding jar in target folder
getProxy().getPluginManager().registerListener(this, new testListener());
there is 2
original core and core jar
use core
have you been using core
on bungee server
as bungee plugin
not on spigot
on bungee
it wants me to make core implement listener
getProxy().getPluginManager().registerListener(new testListener(), this);
at bungee.core.Core.onEnable(Core.java:11)
23:35:51 [WARNING] Exception encountered when loading plugin: Core
java.lang.IllegalArgumentException: Plugin already initialized!
@past vapor basically you do the map thing
When you serialize it:
- get the map of the ItemStack instance from ConfigurationSerializable::serialize
- get the ItemMeta instance
- get the map of the ItemMeta instance
- put the map of the ItemMeta instance back to map of the ItemStack instance
basically map the map
Ya
and please use proper Capitalization for classes
Believe you can figure out the other way around Matt
?pastebin
?pastebin
?paste
nice
@alpine urchin https://paste.md-5.net/rewasibeke.java
what then
you cant have both classes extend Plugin
why
only one can
let Core extend Plugin
Ok so how do i add listener
and remove it from other
so i can listen to the event
ohh
in core when i want to register event listener
it wants to make it plugin......
getProxy().getPluginManager().registerListener(new testlistener(), this);
Ok
.
and once again, use proper capitalization, e.g. testlistener should be TestListener
ok build it
@tall dragon yea i wanted to mention, but i think t will lead to more issues at this rate XD
😉
how would you "add" a texture onto a placed player head block
texture?
yeah for ex, a player head and applying a corn texture on it
I think that you can use https://minecraft-heads.com/ to find a head
On Minecraft-Heads.com you can find more than 30.000 custom heads, which can be used to decorate your world! The collection is seperated into two databases: the first contains custom heads, which never change their texture, using the Give-Codes from Minecraft 1.8+, the second one includes player heads which can be used in all Minecraft versions.
and then apply it to the skull
We already solved how to apply custom textures to heads:
https://www.spigotmc.org/threads/custom-head-texture.74387/
But I don't know how to apply the...
much appreciated
does the EntityDamageByEntityEvent got fired when calling LivingEntity#damage(double, Entity)?
Is there any way to check how much cpu usage the server is using
It’s always ram that is talked about but how much cpu does spigot use
Is this really important?
Like in game like a /cpu command
Hm, maybe ?
I’d like to know your thoughts
Because the TPS is what you actually want to know.
The server will take 100% of a single core if it needs to.
Is there a way to limit how much a spigot server can use in cpu
If you want to get some information about the system anyways then you can look into
the OperatingSystemMXBean.
hey, I rewrote my speed calculation from calculating it on PlayerMoveEvent to only when interacting with the slime (soccer ball) but when comparing methods (new and the old one) I'm getting lower values on the new one
So your question is if you can limit the jvm regarding its cpu usage.
The answer is no. You can limit the memory usage with the xmx and xms jvm arguments
but the only thing you can do regarding the cpu usage is changing the priority of the jvm threads.
Okay thanks
// old method
@EventHandler
public void onMove(PlayerMoveEvent event) {
Location to = event.getTo();
Location from = event.getFrom();
double x = Math.abs(to.getX() - from.getX());
double y = Math.abs(to.getY() - from.getY()) / 2.0D;
double z = Math.abs(to.getZ() - from.getZ());
this.oldSpeed.put(event.getPlayer().getUniqueId(), Math.sqrt(x * x + y * y + z * z));
}
// new method
private double getSpeed(Player player) {
return player.getVelocity().setY(player.getVelocity().getY() / 2.0).length();
}
old: 0.34 new: 0.21
it's so close so I'm wondering if the new method is just more accurate and thus the difference
or is it because the old one updates when the player moves so it has more up to date information?
do someone know the value for each armor piece for the DamageModifier?
Hm not too sure about that one. The length of a vector is calculated the same way as in your "old" method.
It could be that the new method is already slowed down because of a collision.
basically i want to set the defense of each armor to the defaults
The... picture literally tells you the exact values
link pls
thanks
because of a collision? I should mention that it's only used to calculate the "kick" vector java kick = player.getLocation().getDirection().normalize().multiply(total).setY(0.3D);
total being (0.4 + (Player#getSpeed * 2.0) + 0.4 * ..
I don't see a big difference though, it's mostly ~0.15
I might have it but looking at the ItemStack#serialize() class, it seems to be able to handle item meta?
However its not working for me
Oh wait i think its deprecated
Anyone know if this should still work?
Why would you want to call that method? It should work for ItemMeta.
Important typo i meant ItemStack.deserialize()
You usually dont want to call that method either
Why is that, i cant see a reason not too
Only found out through testing that it doesn't work very well
Are there any alternatives?
What are you trying to do?
Just be able to serialize and deserialize items to and from json
BukkitObjectOutputStream
Or by using NMS itemstack
Thank you so much 🙏
how would you invoke a method without a parameter and get the returning object/class using reflection, ex clazz.getMethod("methodHere").invoke etc
should I do some calculations async since they are per player?
How do i get the number of entities on a location
what calculations?
just a second
use World#getNearbyEntities
declaration: package: org.bukkit, interface: World
looking at following methods:
private double getSpeed(Player player) {
return player.getVelocity().setY(player.getVelocity().getY() / 2.0).length();
}
public double getDistance(Location start, Location end) {
start.setY(-0.25);
start.subtract(end).setY(-1.25);
if (start.getY() < 0.0) start.setY(0.0);
return start.length();
}
first one on every EntityDamageByEntityEvent hit (for one entity only)
second one?
it's used again with the second one in a runnable
Doesn't subtract create a clone? Not actually update the original location
wait really?
eh you're not really using it super often
Thought so, as it returns a location
it should be fine
Not sure to be honest, I somewhat remember it creating a clone but I cant find anything specific saying that
If it works as is, then it must not
it works as intended
rather in a runTaskTimer, 1L, 1L
Guess it doesn't create a clone then, I might be thinking of a different object
oh every tick?
yep
yeah might be a good idea to do it async
depends on the context
what is it used for exactly
getSpeed goes on to be added to another calculation down the line in the EntityDamageByEntityEvent to calculate a "kick" vector, and in the scheduler to get reduced and used in yet another calculation, getDistance is used twice in the scheduler to compare distances
isn't length taxing?
oh yeah thats sqrt isnt it
yep
what do you mean?
sqrt(x^2 + y^2 + z^2)
yep, going to do it
are you asking what casting is or?
thank you
clazz.cast() ?
can you give an example
?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.
MyClass obj = (MyClass) reflectionstuff.invoke();
Hey there, I've got this event here, I'm trying to create custom blocks with NOTE_BLOCK but whenever I break the block the octave of the instrument changes by 1 (Because I've interacted with it), I've tried running PlayerInteractEvent with event.setCancelled(true) although this prevents breakage of the block entirely. What is my best course of action?
set the octave back by 1 when the hit it
give me a bit and i can see what i did with my code
@EventHandler
public void PlayerInteractEventNoteblock(PlayerBlockInteractEvent e) {
FactionClaimManager claimManager = ClusterCore.getInstance().getFactionClaimManager();
if(!claimManager.canInteractBlock(e.getBlock().getLocation(), e.getPlayer())){
e.setCancelled(true);
return;
}
Block block = e.getBlock();
if(e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if(e.getPlayer().isSneaking()) return;
if(block == null) return;
if(block.getType() == Material.NOTE_BLOCK){
e.setCancelled(true);
}
} ```
give PalyerBlockInteractEvent a try
thats my code and i dont remember it failing me
Alright thanks I'll try it out
is PlayerBlockInteractEvent a custom event?
oh coudl be actually lol
lemme see
yeah it is im dumb gimmie a sec
@EventHandler(priority = EventPriority.HIGHEST)
public void PlayerInteractBlock(PlayerInteractEvent e) {
if(e.getHand() == EquipmentSlot.OFF_HAND) return;
if(e.getAction() != Action.RIGHT_CLICK_BLOCK && e.getAction() != Action.LEFT_CLICK_BLOCK) return;
Bukkit.getPluginManager().callEvent(new PlayerBlockInteractEvent(e.getPlayer(), e.getClickedBlock(), e.getAction(), e));
}```
thats all it is
just only passes block interactions
Alright sweet
if you're going with noteblocks i'd suggest making your own block breaking system
especially if you are doing custom blocks
I'm only using Noteblocks as I saw plenty of examples. its a pretty useless block, and has plenty of different states.
Is there any other block you suggest?
nah noteblocks are your best choice
it's just if you want to integrate them into survival play you'll need to handle block breaking
for example if you have an ore, you have to make it break faster with picks etc
Pretty sure cancelling the interact event will stop block breaking? I don’t remember
yeah i dont remember getting that effect
Yeah it does
Yeah I haven't gotten to this just yet
does it completely change the texture if you dont cancel it?
It’ll change the note
I haven't even applied a custom texture yet
Which will change the texture
yeah my only idea is change it back to it's original state
Okay thanks
pretty sure interact event is called before the block change so you will need a delayed task
I wonder how something like ItemsAdder does it
try just cancelling NotePlayEvent
I'm reading through my old code trying to figure out how i did it
I think that’s only for right clicking
i should start commenting on shit
But you can try it
yeah could be actually
Will try
oh also don't forget noteblocks update their state when the block underneath them is changed aswell
Yeah you gotta cancel a lot of events and send packets and whatnot
when you cancel NotePlayEvent?
No just in general
I think you have to resend a packet for that
I remember trying to just cancel the physics event and it didn’t seem to work
Might be client side?
If you just want to handle the block underneath being broken you can use the break event
But pistons and stuff exist too, so you could listen for a bunch of events or you could try the BlockPhysicsEvent
However that event is quite intensive
I hope Mojang does data driven blocks soon™️
i would love them forever
i just want to see more features that allow us plugin creators to do more creative things
The changes in yesterday’s snapshot look promising
you have to do REALLY hacky methods to do some stuff
haven't had a look yet
would be really nice if we could apply nbt to anything
Like what
like right now we can only apply nbt to container blocks
just any block would be cool
Well yeah, having normal blocks hold NBT would take a lot of space
yeah
ou i've never seen that before
It’s a nice wrapper for using the chunk pdc for block data
I've been contemplating making a resource for easy custom block & item creation which generates a resourcepack automatically
but sounds like alotta work aswell lol
and inventory menus
It is.
I've done it.
like i have all the code for it, its just compiling it together and making the api easy
This... Exists?
I should have checked before I started trying to make this lmao
yeah oraxen is great
Yeah, that can be a little difficult. Mine is still fairly infant so it's definitely got some stuff that needs to be fixed/added.
Is it all pre-made blocks & items or can I configure my own?
And my mental sanity
I always wondered why so many servers had the same custom rank badge
It's Oraxen doing that lol
only downside i see is you wont have as much customisability as you would if you coded it yourself
but i wouldn't doubt it if oraxen had an api anyway
i think you are wrong
Oraxen and ItemsAdder are pretty customisable and mature
and it is not an easy task to achieve such extendability
It is actually a downside if you code it yourself
Ello friends is this the proper place to ask about problems in coding plugins?
Generally, yea
yeah i could be wrong, never actually used it myself just speculating
Alright in that case, trying to do a GUI thing in my plugin right now but when I have the createinv method for my new GUI included in my main, the plugin ceases to work completely
Ah i tried ItemsAdder before and I was really impressed
If I comment out the create inventory method though everything else works again
It even has custom mobs
and when do you call createInv()
In the onEnable of my main class
do you get a stacktrace?
Just checked and it says the problem is at line 31 in createInv()
"lore.set(1, ChatColor.GRAY + "Click to close the menu.");"
Maybe the problem is that I used 1 as the index instead of 0?
Why set and not add
Hi i need recommendations about this:
Im doing a simple http library. Im a bit mixed or i dont know how i should return the response
It depends on the response's encoding
Do you wanna see full code?
Sure
Wait me because there are many classes
https://paste.md-5.net/ohetuqolex.java - This is the full code
https://paste.md-5.net/vusibabuxa.java - Doing a request
I need recomendations how i would do the request itself
why does your full code look like java's http api
Hmn i follow the format because looks really great
then why dont you actually use it
Java 8 != 17
I use Java 8 that why im doing it
is there a way to install NMS with mojang mapped on a GRADLE project?
I can't figure out why I keep getting the error Could not pass event PlayerJoinEvent to AltAlerter v1.15-SNAPSHOT org.bukkit.event.EventException: null
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @2a642394 and has something to do with gson
couldn't find anything online except for a github issue that was closed by the repo owner saying gson comes with minecraft 1.18
https://paste.md-5.net/besimivedu.java this is the class that uses gson
Wait have you add the dependency to your project or you are using the one that come on spigot jar?
I've added a dependency
the 2.8.9 version of gson but the console uses 2.8.8 so it uses the one that comes with spigot
I only did this in an attempt to resolve the issue but the dependency changed nothing
guys
rewards:
- if:
group: Premium
commands:
- eco give %player% 2000
broadcast-message: "&a%player% voted and received $2000."
- if:
default: true
commands:
- eco give %player% 1000
broadcast-message: "&a%player% voted and received $1000!"
how would I make this SuperbVote give people with the premium rank 2000?
it just seems to give 1000 to everyone anyways
https://github.com/astei/SuperbVote/wiki/Configuration
its supposed to work with essentials through vault
but "group: Premium" seems to be a valid command, but now what im looking for apparently
my rank name is called premium
Could it possibly be case sensitive group name? Try with "premium" instead
premium
omg yay
it works
1 problem
so yes
the if statements work
but
broadcast-message
won't work
no errors
got any ideas?
here's the configuration with the default settings aswell https://github.com/astei/SuperbVote/wiki/Configuration
Is your broadcast setting enabled?
yes
it worked before
tahts why its strange
like
before i changed out all the default stuff
strange
here's that part of the script
Configs can be very sensetive to spaces and tabs, make sure that all is correct
my script
# Rewards. This is the main section you will need to edit. Ordering is important.
rewards:
- if:
group: premium
commands:
- eco give %player% 1000
broadcast-message: "&a%player% voted and received $1000."
- if:
default: true
commands:
- eco give %player% 500
broadcast-message: "&a%player% voted and received $500."
# Whether or not players need to be online to vote. If set, offline player votes are queued for when the player next logs in.
require-online: true
# Whether we should queue votes if players aren't online. Requires the above option to be set to true.
# If this is disabled, the user won't get any rewards if they aren't online, even if they login afterwards.
queue-votes: true
# Broadcast settings:
broadcast:
# Should we broadcast votes at all?
enabled: true
# Should we tell players if they voted?
message-player: false
# Should we broadcast queued votes?
queued: true
antispam:
# Should we add a minimum time in between global broadcasts to prevent spam in chat?
enabled: false
# How many seconds should be between broadcasts?
time: 120
does it check out for your eyes?
Does the broadcast message work if you're not in the premium group?
yes
just tried it
then it gives me 500
what ive learnt about yml files
is that it just doesnt care abotu code it cannot run
and stops there
so
everything is running
just not
the broadcast lines themselves
super weird
Can you please type your message in one go? 😄 It's really annoying watching 200 messages going with 1 word xD
Haha sorry, if you knew xqc, then you'd know why haha
But yeah, I am super bummed right now :/
Just copy the working broadcast message to the non-working and see if it works.
u mean the default code?
Copy the defaults broadcast message and put it in the premium broadcast message, just to make sure it works.
yeah
it works
the defauly works
default
it broadcasts :/
im gonna try to reedit the default
Perfect. Then you're good to go?
From what I can see, all you did was change 500 -> 1000?
what is the different between sending a PacketPlayInDestroyEntity packet vs CraftPlayer.hidePlayer
really interesting me lately
Nothing
hidePlayer is jusr easier
really?
there's got to be a difference
Yes. Thats right.
hidePlayer is more reliable, yoy dont have to listen for packets to re-hide player
yea ok
i used packets to destroy the player and then in a runnable respawn the player, but the player's custom gameProfile username will not appear above their head
it only appears if you use hide and show player
very weird
I hope player profile api will be added soon
yea
do you have any idea why the above happened btw?
im trying to work out logically why packets won't update the player's username but hiding the player and reshowing it with CraftPlayer will
idk
To change name, you actually need player_info packet
HidePlayer also sends that packet5
yea fair enough
i'll try again later
thanks for your help 😄
to spawn in a player npc would it be NamedEntity?
thanks 😄
Anyone 😢
I'm running 17 SDK and trying to write basic 1.17.1 hello world minecraft plugin...
However I encounter this error:
Error:Internal error: (java.lang.IllegalAccessError) class com.intellij.util.io.FileChannelUtil (in unnamed module @0x4034c28c) cannot access class sun.nio.ch.FileChannelImpl (in module java.base) because module java.base does not export sun.nio.ch to unnamed module @0x4034c28c
java.lang.IllegalAccessError: class com.intellij.util.io.FileChannelUtil (in unnamed module @0x4034c28c) cannot access class sun.nio.ch.FileChannelImpl (in module java.base) because module java.base does not export sun.nio.ch to unnamed module @0x4034c28c
at com.intellij.util.io.FileChannelUtil.setupUnInterruptibleHandle(FileChannelUtil.java:26)
at com.intellij.util.io.FileChannelUtil.<clinit>(FileChannelUtil.java:18)
.....
Any help?
How are you running it?
Through artifacts
Are you not running it on your MC server?
Whats the rest of the stack trace
at com.intellij.util.io.ReadWriteDirectBufferWrapper$FileContext$1.execute(ReadWriteDirectBufferWrapper.java:42)
at com.intellij.openapi.util.io.FileUtilRt.doIOOperation(FileUtilRt.java:945)
at com.intellij.util.io.ReadWriteDirectBufferWrapper$FileContext.<init>(ReadWriteDirectBufferWrapper.java:42)
at com.intellij.util.io.ReadWriteDirectBufferWrapper.create(ReadWriteDirectBufferWrapper.java:27)
at com.intellij.util.io.DirectBufferWrapper.getBuffer(DirectBufferWrapper.java:24)
at com.intellij.util.io.ReadWriteDirectBufferWrapper.getBuffer(ReadWriteDirectBufferWrapper.java:16)
at com.intellij.util.io.PagedFileStorage$StorageLock.createValue(PagedFileStorage.java:631)
at com.intellij.util.io.PagedFileStorage$StorageLock.get(PagedFileStorage.java:558)
at com.intellij.util.io.PagedFileStorage$StorageLock.access$500(PagedFileStorage.java:466)
at com.intellij.util.io.PagedFileStorage.getBufferWrapper(PagedFileStorage.java:407)
at com.intellij.util.io.PagedFileStorage.getReadOnlyBuffer(PagedFileStorage.java:375)
at com.intellij.util.io.PagedFileStorage.getInt(PagedFileStorage.java:155)
at com.intellij.util.io.ResizeableMappedFile.getInt(ResizeableMappedFile.java:217)
at com.intellij.util.io.PersistentEnumeratorBase.<init>(PersistentEnumeratorBase.java:212)
at com.intellij.util.io.PersistentBTreeEnumerator.<init>(PersistentBTreeEnumerator.java:73)
at com.intellij.util.io.PersistentEnumeratorDelegate.<init>(PersistentEnumeratorDelegate.java:47)
at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:149)
at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:138)
at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:129)
at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:121)
at com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:114)
It doesnt seem like youre running it on a server
Could this be that my intellij does not support SDK 17?
Show your code but I think you're trying to use a class that isn't available anymore
?paste Also please
oh ok
Are you trying to use PersistentHashMap in your code
nope, it's litterally just onEnable and onDisable.
Have you exported it to a jar file and running on your MC server?
That error does not come from your plugin
Yeah are you running it on a server
I've done some research, and it says that my intellij could be outdated to support SDK 17
It certainly looks like you are trying to run/debug it in Intellij
Is it while building the jar
Yes
Ohhh
It's not even compiled 😄
🤯
With intellij
Highly recommend Paper Userdev plugin for gradle. It works great
So I just need newer version of intellij?
I dont know if newer versions support newer java but you could use gradle 7.3
I use Eclipse, There's a bunch of alternatives 🙂
I only use IntelliJ 😛
Why packets
Maybe so the server doesnt have to process the entities idk
Eh just put a no ai tag on it should disable the most intensive stuff
setMarker(true)
setCanTick(false)
There was even benchmarks
Oh wait setCanTick(...) is a thing?
.
Idk at least on papwe there is
Ah
Any idea why java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "argus10q.qol.QOL.getCommand(String)" is null ?
nvm my dumbass didnt put it in plugin.yml
spigot.yml?? what
muscle memory typo
Guys, why I can't see a normal green color but instead I see this in my console:
[09:58:01] [Server thread/INFO]: ºaHello Minecraft!
The code:
Bukkit.getLogger().info(ChatColor.GREEN + "Hello Minecraft!");
huh wut
probably a console window thing
okay? Then what should I do?
what lol
shh didnt see anything
don't use Bukkit? lmfao
😦 no result...
I use paper so I never had this issue D:
It's probably just the terminal window you're using that doesn't have the support. The code itself runs, that's why you get a "a" infront of it
I'm sure that if you'd use ChatColor.GREEN in-game it would work
Yeah, it is console thing..
I remember this problem when I was using multicraft
Do bukkit getconsolesender sendMessage
I have a problem where my plugin spawned a mob and it multiplies over night even though there should only ever be one. I set the option to remove the entity when no player is nearby to false, could that be it?
I respawn the mob by checking inside the entityDeathEvent. Could that get called randomly?
U using bukkit.getconsolesender .send message?
Nope, but I realised already that its console problem, not code. It would work with consolesernder I assume.
Ye
https://paste.md-5.net/miwekokake.cs
Got this code, problemo is, it adds blocks backwards, so light bottom right is the "newest" added, and not the top left one, any ideas?
omg
I set it all up literally
And then it just stopped working
so sadge
@crimson terrace When I type /vote, the plugin just won't be responsive and print everything. Yet it is installed perfectly fine.
how to set player yaw and pitch? without teleporting the player
i am trying to do whan you step on the emerald block it YEET you and set your yaw & pitch to like: (yaw: -89,ptich: -2)
i did all the YEET staff
?paste
thanks bot
You have to send PacketPlayOutEntityHeadRotation and PacketPlayOutEntityLook packets when whenever that specific circumstance changes (when u step on the emerald block) Though modifying packets would be enough
Pretty sure you can do so with protocollib
try {
byte yaw = (byte)(int)(player.getLocation().getYaw() * 256.0F / 360.0F);
byte pitch = (byte)(int)(player.getLocation().getPitch() * 256.0F / 360.0F);
Constructor<?> EntityLookConstructor = NMSManager.getInstance().getNMSClass("PacketPlayOutEntity$PacketPlayOutEntityLook").getConstructor(new Class[] { Integer.TYPE, Byte.TYPE, Byte.TYPE, Boolean.TYPE });
Object EntityLook = EntityLookConstructor.newInstance(new Object[] { player.getEntityId(), Byte.valueOf(yaw), Byte.valueOf(pitch), Boolean.valueOf(true) });
Object PacketHead = NMSManager.getInstance().getNMSClass("PacketPlayOutEntityHeadRotation").newInstance();
NMSManager.getInstance().setField(PacketHead, "a", player.getEntityId(), true);
NMSManager.getInstance().setField(PacketHead, "b", yaw, true);
NMSManager.getInstance().sendPacket(player, PacketHead);
NMSManager.getInstance().sendPacket(player, EntityLook);
} catch (Exception e) {
e.printStackTrace();
}
hey why is the setsomedata method returning a new snapshot too?
Trying to implement it rn
what is the NMSManager?
It's a Network Management System
NMS is undocumented. It's decompiled server code. The closest you'll get to documentation is reading methods / class names for yourself.
uh ok
it didnt help me lol
its way to complicated
but nvm
uh
teleport him
to his location
but with a different pitch and yaw
theres nothing wrong with teleporting the player
then set the velocity back to what it was
^
Hi, what's the best way to set an element out of bound into a list ?
actually i dont think it does
Quick question what MC protocol can I'll use to remove a player from a client side armorstand?
Its a packet spawned armorstand with a Player on it and I’ll want remove the player from the armorstand.
with a player on it?
you mean a player head?
or like a player riding the armor stand
not good
Player riding the armorstand
Ohh okay
Because we avoid mutability that way
@tardy delta
nvm i think i got it
i dont know the name in code for it
but its something with passengers
and you can look at how to construct the packet there
in the wiki
Ok
what the fuck is that
Hmm I’ll guess this more for setting the passenger then dismount him
Custom recipe issue
nah i think you can set the passenger amount to 0 to dismount it
that would make sense
it sets them, not adds or removes, so if you set the list to empty it should dismount it
and i cant find a dismount packet
can spigot plugins access files outside jars, comp. files
wouldnt making non-final fields be easier instead of making new objects instead
probably
yes, at the first look it seems better and easier. But mutable objects
- Not thread-safe
- Not free from side-effects
- Requires explicit cloning
- Harder to cache or use as keys in map
How do you import net.minecraft.world using gradle? I've tried craftbukkit and just spigot but no luck 🤔
Other entities can modify the object as well and may leave it in broken or unexpected state
oh, right..
but if you construct a new object with weird parameters isnt it broken too?
Yes; the problem is agout objects which were created normally but after get broken
ah i see
Not sure if I'm dumb but the 'missing package' isn't missing?
maven or gradle?
Maven
pom.xml?
Want me to pastebin it?
yep
i don't see you include anything beside spigot in your pom.xml, do you use alternative method for including jar?
Just added it to the libraries
uh oh
you'd better use it via maven, isnt there a repo for this lib?
The plugin I posted above ^^ I use that because I have no clue how Maven works..
yep thats the right way
just reload pom.xml
there is an icon at the top-right in intellij
Yeahh I don't see that.
I reloaded the maven project from another panel and got this
isn't it supposed to be an elephant?
if your using gradle
if your using maven it's M
oh
btw, does anyone know a way to set per player world borders? I tried using an api but it won't work because I set my spigot version to 1.8 to support 1.8 -> 1.18 and the dev won't help in the slightest
worldapi?
worldapi?
border
If you mean this one https://github.com/yannicklamprecht/WorldBorderAPI the dev isn't helping make it useable on 1.8 - 1.18
Still getting the error above- ideas?
Should I just ditch the setup plugin and do it manually?
lemme check it locally
If anyone could help me out in the thread that would be great! 🙂
https://discord.com/channels/690411863766466590/941665462062829588
uhh, i guess the repo isn't valid anymore, where did you get jar you put in intellij?
From Spigotmc
Am I able to use local jars?
probably it's changed
Found this and it works
yeah, the repo just changed
Thanks for your help! Wasn't aware I needed to edit the pom.xml
np
is it a good idea to work with profile classes for my users?
like thishttps://github.com/FourteenBrush/MagmaBuildNetworkReloaded/tree/master/src/main/java/me/fourteendoggo/MagmaBuildNetworkReloaded/user/profiles
yep, fine. Composition over implemetation inheritance
heh is it still there?
how could you tell
but why would that even happen???
ohh
If anyone could help me out in the thread that would be great! 🙂
https://discord.com/channels/690411863766466590/941665462062829588
I tried looking at the spigot forums for advice, but the responses appear to be using depriciated methods.
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getMainScoreboard();
Objective objective = board.getObjective("lives");
Score lives = objective.getScore(player.toString());
player.sendMessage( ChatColor.GREEN + "" + lives + ":");```
I'm trying to get and set the player's value of the scoreboard `lives`, but I'm not really sure how to do that. The message that the game is sending appears to be the memory location and not the numerical value of the score. What have I missed here?
I understand there are better ways of storing data than a scoreboard, but I need the scoreboard method atm.
best way to make 1.8-like combat in 1.18? (with specific weapons)
oldcombatmechanics
don't want to depend on plugins, i mean with code
so read the source code and work from that?
oh ok
I was just wondering if when you cancel a chat message (sent by a player) would other plugins get that message?
depend on how they get it
depends on if they're using NMS or api, and on event handler's priority ig
cuz if they're interacting with protocol directly they will probably get the message even if you cancel AsyncPlayerChatEvent
oh thanks
other plugins will get the event regardless
the cancelled field will just be set to true
Actually, whats the difference between the Score class and the Scoreboard class?
Does someone know why this error happens I'll try to set an entity a Head with Packets
https://www.toptal.com/developers/hastebin/ojupetatir.properties
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
?paste
Java 9 moment
Going to?
I want to prevent the player from getting hunger but when I cancel FoodLevelChangeEvent nothing happens. Help?
Hi all, I can't understand why the itemMeta of non-damageable objects triggers my println. If I break a block with a bedrock block in my hand, I can see my System.out.println.
Why?
@EventHandler
public void onBlockBreakEvent(BlockBreakEvent event) {
if (!event.isCancelled()) {
ItemStack itemInMainHand = event.getPlayer().getInventory().getItemInMainHand();
if (itemInMainHand.getItemMeta() instanceof Damageable damageable) {
System.out.println(itemInMainHand.getType());
}
}
}
Why Damageable damageable if you don't use it
I have removed lines of code to make it easier to understand
Is it a bug or im fogotting smth? Builder its a inner static class from Message
Builder its a inner static class from Message
Idk
remove new
Oh lol its what that. Im confused
the new keyword
that statement didnt make sense
you create a new Instance of.. method??
The Message class was not static, the inner class yes
Makes no sense
Quite simple. You are getting a Pair and are tying to cast it to an Item. Which doesnt work because Item does not inherit from Pair in any way.
Yeah, I know... from console I can see "BEDROCK"
Does this happen with any other block? AIR or STONE?
Obviously
your score is being casted to string
there should be a method for getting an int value from it
I cant believe most people actually use java 17
well java 8 from oracle is paid right?
thats prob why
nah
or not idk
maybe the support is paid
Why would I not use 17
With AIR no
But with STONE, BEDROCK, GOLD_BLOCK and DIRT (so on..) yes
Java 17 its not supported on multi server version
Let say you cannot use Java 17 to compile a plugin for runnint it 1.8x to 1.12x for example
Yes but why would you want to compile a plugin for those versions?
Plugins in theory should be multi version
Are blocks just damageable in general? Are other items like Sticks fine?
They should generally aim to be written for the supported versions.
Is there an event called when a player lands?
?jd
Blocks should not be Damageable as the definition of the class itself.
Same error with STICKS
Go to package org.bukkit.event and you will see all the events
isnt the Damageable for all items just because ancient versions had items with durability that were different items then ?
ok thanks
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/meta/Damageable.html
Should not
"Represents an item that has durability and can take damage."
GOLD_BLOCK has no durability and cannot take damage
If such method exists that I forgot to check for, then I think I'm coding dumb. Thanks for the pointer
Don’t ask me, that’s just how it is
What version are you on?
1.18.1
Maybe Blocks are damageable for legacy reasons 🤷
This code snippet was written in the past and it worked. So it's not for legacy
for this I think it is a bug
Got your API version set
YEah, 1.18, why?