#help-development
1 messages ยท Page 1789 of 1
packets, but there are probably libs online
apache commons is still included as far as I cna see
I use it and I even downloaded a mod that shows nbt tags for all items
I tried like 5 of them
maybe but the location changed
none did anything
and there are no my nbt
unlikely, its just shaded
so it basically breaks all plugins that rely on apache commons being located at org.bukkit.craftbukkit...
did you ask support to the developers?
yeah, he couldnt help
Well that mod doesn't debug your code does it
no, it's gone now. at least from the original location
I mean, relying on implementation ๐๐
org\apache\commons\ is where its always been
yeah, u r right, but I can't understand why doesn't it work even when debugged it, ig I do everything right
NBTManager nbtManager = new NBTManager();
nbtManager.setNBT(itemStack, "twd_customItem", name);
If you depend on the server jar, that jar is now a bootstrap jar
Obviously the libs are not going to be plain shaded in
There seems to be two in the jar org\bukkit\craftbukkit\libs\org\apache\commons\ and org\apache\commons\
can you show your full code? like when you're calling the methods
when a player dies, does it create a new itemstack for the drops? or does it reuse the itemstack from when they were in the inventory
it creates entities
the instance?
yeah
yeah, let me create a thread in order to communicate
i have no idea then
alright
I do
e.getDrops().remove(itemstackPlayerHadInInventory);
But it doesnt remove it
so idk if i do something wrong or if its a new itemstack instance thats just a copy of the old one
NBT tags doesnt apply (NMS, 1.17.1)
which event?
^
PlayerDeathEvent
i want a specific itemstack to not be dropped
oh wait, maybe it works, might have something else wrong
done, #913810710532882453
There is no setDrops so it should be a mutable list
ok yeah it works, my bad :D
Can you change player pitch without teleporting him?
as teleporting him causes him to freeze
even player.teleport(pos.add(player.getVelocity())); doesnt work
oh wait, do i have to re-set the velocity
Can someone help me?
I'm very new on plugin development and im getting the following error
he error comes from private void commandRegister ig but i dont really know what is happening
The command "discord" is null
Are you sure you have added that command in the plugin.yml?
yes
Show me your plugin.yml
oh xd
Nope,
Location pos= player.getLocation();
pos.setPitch(45f);
Vector vel = player.getVelocity();
player.teleport(pos.add(player.getVelocity()));
player.setVelocity(vel);
doesn't work either.
How can I do it?
that was typed by intellij
getBoolean then?
learn java then
no
relying on auto complete with no clue what its giving you is a fools path
i love when people wanna use a java library and refuse to learn java
i know lol
Is the config value a Boolean
autocomplete doesn't mean right
Dude, we dont give a fuck about the auto complete
your logic is completely incorrect
the auto complete is just going to make it worse
yes already fixed
That's the problem. the teleporting to change the pit makes the player float. Anyone got an idea how to fix?
or != false
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f);
whats wrong?
weird
np mine too
how to make a addon for bedwars1058 using the api of thet plugin
can i use Location#getBlock async? i wont change the type
just use it
Yes you can
So long as you don;t trigger any chunk loading
yea but data might be unsyncronized afaik
but i doubt it'll happen
just make sure to not load any chunk
i will use it in a plot so the chunk has to be loaded already
kk
are you meant to pass the entity id for a destroy entity packet constructor?
that i get with myNmsEntity.getId()
wait... does creating a new location instance trigger any chunk load stuff
no
if the chunk is already loaded no
aight thanks
makes no difference
oh anyways in case you need to get the state you can't do it async
just creating a Location object will cause not chunk load
when you getBlock() it will
btw
is there an api for relative teleporting?
or would i have to make the console run the command?
because relative teleporting keeps the velocity, and theres no way to do that with spigots normal teleport function
store the velocity of the player before teleporting them
and then restore the velocity
doesnt work
not even when i restore it via scheduler
if (now.getPitch() < 45f) {
now.setPitch(45f);
Vector vel = player.getVelocity().clone();
player.teleport(now.add(vel));
Bukkit.getScheduler().runTaskLater(Main.instance, () -> player.setVelocity(vel), 0);
}
spacing 100
was too busy to remove xD
if (now.getPitch() < 45f) {
now.setPitch(45f);
Vector vel = player.getVelocity().clone();
player.teleport(now.add(player.getVelocity()));
player.setVelocity(vel);
}
doesnt work like this either
0 tick scheduler?
yeah lol
um, teleporting to a Vector?
maybe nms teleporting?
oh adding the vector
yea
but it sounds unnecessary
why? you are teleporting the player at the most 1 block
wym why
so he doesnt freeze when i reset his pitch
teh Velocity Vector will have a length
and
its a unit vector
yea
thats what its supposed to be
my problem is, that player.teleport makes him lose his velocity
why? when all you are trying to do is fix his pitch
because to set the pitch you have to teleport the player
and doing that removes his velocity
allowing him to hover in mid-air if the pitch constantly gets fixed
are you doing this in a move event?
nope, in a scheduler running every tick, and then in an if that checks if the player pitch changed
ok
if you did it in the move event you could simply adjust the pitch
changing teh getTo() location
u sure that can be changed?
i think not very reliably, thats why i use a scheduler checking every tick
but i can try
it should not
it deletes the velocity/momentum?
oh wow, what a shitty implementation
huh ? how so
you have to actively tell the client their pitch changed
the protocol does only allow you to do that through a teleport
interesting
yea, but using the teleportevent removes any momentum
which you dont expect when changing the to location
again, as already stated to you in paper, you need a relative teleport
which is not a thing
and concerning that there is no API for it either a) use NMS or b) execute the tp command
besides using the command
is using the tp command every tick for ~10 players a problem?
performance-wise
cuz it sounds very ineffective
it obviously has some overhead yes
but presumably you don't actually call it every second
didn't you have an if check
to only teleport if needed ?
Well try it
alright :D
if it lags too hard, you'll have to use NMS
yea
just make sure to ensure you call minecrafts tp command
(tho directly using NMS is probably be better)
if i send the github link of a private repo will people be able to see it?
no
is there any relative-teleport api proposal for spigot?
how can i make one
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
I've not looked at teh nms code for teleport, but check the code used for nether portals
it preserves velocity
its in yoru latest folder in buildtools
Or just use intellij decompiler
EntityPlayer has a teleportTo and enderTeleportTo method
maybe one of them preserves momentum?
preserves momentum ๐ค ?
Yeah, normal player.teleport() doesnt preserve momentum. @tardy delta
ill try
what is momentum?
he was basically saying im big nerd for saying momentum
velocity
velocity
movement speed
why not say momentum lol
๐
im not even english and i know that word
i've learnt the english word before my main language one
xD
which is pretty stupid since it's almost the same
momento in italian, momentum in english ;-;
xD
btw what's the difference between List.of() and Arrays.asList()
else than the first one always being in my autocompletes even if i'm using java 8
Arrays.asList returns a mutable list while the list returned by List.of is immutable
Arrays.asList allows null elements while List.of doesn't
contains behaves differently with nulls
Arrays.asList returns a view of the passed array, so the changes to the array will be reflected in the list too. For List.of this is not true
Arrays.asLists creates a wrapper around array
List.of, returns, just immutable list
yea i should've probably googled it :p
so if i change a list generated with Arrays.asList it will change the array too
interesting
i assume enderteleportto is what happens with enderpearls, therefore cancelling velocity. Will try the other one tho
only takes a blockposition so no way to change the pitch :/
probably gotta use nms then, idk
Yeah Arrays::asList is actually really cheap as it requires no extra array to be created. Since List::of has to be immutable it also implies that it has to loop through the var arg at some point.
command classes should be singletons right?
uh who said that lol
I just instantiate them and store a ref in my main class
even then it's not necessary to store the ref as likely you're not calling any of the command code from your classes
Yeah, its the around the lowest level component in the system, so hopefully nothing depends on it.
How do you change the direction a powered minecart is going? Like the direction its engine is going
a singleton is something where only one instance can be created right?
Yes
Singleton pattern:
- Ensure only one instance can be created at (mostly) compile time.
- Provide a global access point to the instance (actually not always but 99% this is the case)
i've stored an instance somewhere because it has non-static method which should be accessed over time ๐ณ
i usually use singletons for classes that store data (like player profiles)
๐
I mean I guess singletons are a bit too hated
thats not a singleton, thats staticabuse
i don't really like it as a solution but i'm not aware of a better way
sure i can make them classes that are normally constructable but what's the point if instanciating them again is pointless?
Pass your data transfer instance / data access instance through constructors or methods maybe
Unit tests
general reusability
yea for a while i did that too
classes should as reusable as possible smh
it's a class that holds player data in a player, integer hashmap
or something similar
so a DTO which is easily passable through your constructor, named DI
util classes hate this trick
Util classes are fine unless they have mutable state ๐
I recall some people used to use static singleton to lazy load stuff, when that stuff was necessarily not going to be needed such as specific storage implementation.
But now when we have Suppliers, and other design patterns which can be written cohesively thereโs less need for static singleton.
something else i do sometimes is make a wrapper class for players that has a private static map with all the instances of the class and a static method that calls a private constructor of the class and adds the constructed object to the arraylist
not sure if this is a great approach either tho
whats good tuturial series i only see part 1 like 100 times then they all quit after that
that doesn't really look like a great approach
a plugin is also a software optimized for another
so dont say that
- Constrcutor should construct object and do nothing else
- SRP blablabla
class shouldnt hold its instances, thats a task for another entity
point is i don't know how i should do it, i've changed many times how i store player data or data in general in my 3 months of spigot dev, but i've never found a way i like or think is good
I wanna do some stuff with json
create a repository class for your wrapper
Thing is maybe the module is still in its implementation phase in where itโs totally fine to do whatever you want to get it to work.
Itโs mostly impossible to write perfectly clean code from the start, as it will often lead to extreme refactors and major implementation changes which just slows the process down, so usually you get it to work, then clean the code.
i agree, this is the standard. nevertheless, you should make sure from the beginning not to throw any bullshit into your project.
Indeed, guess this also depends on the approach you take if its strictly tdd with unit tests or something else
i did sometimes something like:
Data.java
public class Data {
//private Hashmap<Player, PlayerWrapper>
//Constructor taking plugin instance as parameter for schedulers or whatever
//Utils methods
//Nothing static
}
PlayerWrapper.java
public class PlayerWrapper{
//Variables for data
//Constructor taking player as parameter
//Getters and setters
}
tdd actually helps you with that
i try always not to, else i would've not started testing with different designs at all
Yeah but tdd has some downsides (also)
and how your tests looks is irrelevant
what's tdd
test driven design
you test your things before implementing them
thus you give a certain behavioral pattern
*if your company doesnt have any standards other than that the tests shouldnt have any other logic
If you go all in with tdd it usually results in a lot of tests as you want to make sure you cover all cases. When we write unit tests it usually leads to a lot of mocks since we want to isolate things. Problem is when you want to refactor like extract classes and change implementation details you might end up with a lot of tests broken. So then youโd have to go back and fix them. But yeah as you said it helps with the decoupled design.
so what about this approach
How can i run a command in spigot without spamming the console/chat ?
first of all the naming is misleading
i just came up with it, those were not the names i used
//Utils methods those are not util methods
that sounds like factory design pattern
any good tuturials that go past part 1 xd
there aren't any i guess
?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.

why ChatColor.intCode is private
now i need to use ordinal and trust bukkit api that it wouldnt change the order
because there's no getter for that
i think you can trust ordinal, otherwise md_5 wouldnt have made it that way
but it makes no sense to use ordinal when there's predefined integer values for each enum
in the constructor
he also deprecated some other similar functions and you now have to use ordinal instead
cant u do valueOf
Dont use magic numbers
easier said than done
i need to convert Bukkit ChatColor value to hex value
so i need to get int value of the chatcolor
to set it via bitmask for a field
ordinal seems like the way to go
yea
can you get what player loaded what chunk with api or do you need packets
is there no getSource or something in the chunkload event?
how would i update my placeholders after registering them?
and you wanna make that urself? or why u asking this in #help-development
You should ask this in #help-server
sorry.
No problem ๐
this.task = new BukkitRunnable() {
int seconds = 30;
@Override
public void run() {
if ((seconds -= 1) == 0) {
seconds = maxTime;
runnable.run();
} else {
bossBar.setProgress(seconds / 30D);
}
}
}.runTaskTimer(chaos, 0, 20);
Any way to make this smoother?
I could lower the amount of ticks it takes, but wouldn't that be a bit much or is this light enough to just have run every 10 or less ticks?
Look a pretty light to me
It's a repeating countdown, hence the re-run
I wonder if you can update boss bars async
Gonna throw it on 1 tick and see what happens lol
Oh I see now. yeah
I could have it cancel, but that's pointless for what I'm using it for ๐
Already got a 1 tick build compiled, gonna see what happens lol
can you get the player that loaded a chunk with the events api or do you need packets?
I mean itโs gonna run fine
๐
The game already does much much more each tick
Yea i figured, but seeing as a lot of this will end up configurable and maybe have a lot of players I want the default config optimized as possible hence the testing and question
Yeah it won't really have a significant impact anyway, it's not like you're executing a ton of things in that method
sounds good
lol didn't even seem to update, weird ๐ค
Anyway I'm making a small NPC class that's working fine, but when the player goes too far away and it respawns it only becomes visible for like a milisecond, if anyone wants to take a look here's the link https://gist.github.com/HardstylesDev/10ed39027feba3d1328837a1a64618ac
Nevermind, simply hiding them and then reshowing them seems to work.
that's weird though
Can someone tell my why this does not work?
Vector vel = player.getVelocity().clone();
player.teleport(new Location(...));
player.setVelocity(vel);
I really don't get why. It does not set the velocity back.
is it a bug?
Maybe wait a tick?
nope, doesnt work either
I'll need to modify the actual duration and max time it seems lol
Hello everyone, can two bungeecord register the same server for bungeecord messaging ?
and both receive / send messages to / from it ?
Unsure probably not
You might have to setup a custom server socket system
Where one of the two instances runs the server socket
So the spigot server is not allowed to have two bungee ? because from a config standpoint is the bungee that do know the spigot server
but not viceversa
thats why i was wondering if by simply adding more bungee the spigot server would just send to multiple bungee
if you have for example
test1
test2
in your arraylist, and use the contains method for test
what will it return ?
hmm well
afaik bungee doesn't support it natively
but it might very much be possible
false
assert Lists.newArrayList("test1","test2").contains("test") == false
:p
Hello, does anyone know how I could send a player to a different server in a spigot plugin? I've tried using the dispatchCommand but it wouldn't recognise the /server command because it's a bungeecord command.
plugin messaging, i think
Thanks for the help
Does anyone happen to know how to rotate an NPC? I can rotate the head just fine but I can't figure out how to rotate the body
doesnt that rotate the body too?
honestly for npcs I just use libraries
The body does rotate to an extent, but the body rotation compared to the head rotation seems a bit off here
PacketPlayOutEntityHeadRotation rotate = new PacketPlayOutEntityHeadRotation(entity, (byte) (location.getYaw() * 256.0F / 360.0F));
Here's a gist if you're wondering https://gist.github.com/HardstylesDev/10ed39027feba3d1328837a1a64618ac
playerHeart.addUnsafeEnchantment(Enchantment.LURE, 1);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
playerHeart.setItemMeta(meta);``` anyone know why this isnt making it shiny :/
Thanks you!
Do you know how I can make a plugin compatible with different spigot API versions? Like 1.8-1.17
iirc as long as you don't use nms you can already do that
There is a guide or smth?
because you're supposed to add the enchantment to the meta, no?
Well now you're adding an enchantment and then setting the meta
effectively erasing the previous enchant
rlly?
Pretty sure that's how it works
what
You can add the enchantment via meta or the stack itself
like
However if you are already editing the meta, use the meta
ok ill try
Player player = event.getPlayer();
or
event.getPlayer()
is it good practice
to set variables
If you are reusing it several times set a variable
Itโs cleaner and easier to read
alr it works
public static void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (!(event.getAction() == Action.RIGHT_CLICK_AIR && event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
return;
}
ItemStack item = player.getInventory().getItemInMainHand();
if (!item.hasItemMeta()) {
return;
}
ItemMeta meta = item.getItemMeta();
assert meta != null;
if (!meta.hasDisplayName()) {
return;
}
if (!meta.getDisplayName().equals(ChatColor.RED+"Extra Heart")) {
return;
}
if (!(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue() < 20.0)) {
return;
}
if (player.getInventory().getItemInMainHand().getAmount() == 1) {
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
} else {
player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
}
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() + 2);
}``` now im stuck on why this is not working lol
any errors
nah
command-sound != sound
what?
lol yeah
do u know why it nto working
Ah I see
Well debug it, clearly one of your conditions isn't met
uh
Still, Config.command-sound is not the same as command-sound
I dont know what's wrong, sorry.
Unless you have that key in a section called Config
?scheduling
I see
You see
Having a section named Config is weird, but alright
Is the right file present at runtime
1L or 1
Yes
Both work
or 1 tick
that doesn't matter i've "config" and "message" sections
yes
lol
?
You donโt need that
In the code I mean
nothing I just didn't know that was a thing
thanks you
Lamda are nice
what's lambda
() ->
I
doubt you don't know what a lambda is
considering Coll said lamda but you said lambda when asking about it :p
๐ญ
how do i set an item's default damage?
getDefaultDamage()
hmmmmm
how can i add more attack damage to a sword item without changing its attack speed?
Change the attributes
i tried
The attack_damage attribute
it makes the sword attack like 1.8
maximum attack speed
when i only changed the attack damage
does anyone know how to make a command cooldown
Listen to when the command is run. Save timestamp to a map and then check map next time player runs the command
does it reset after server stops
Yes
i want it to save
what about yml
That too
I mean, itโs not really meant for data
essentials uses yml tho?
It will work though
yk how (args.length == 0) checks if they entered /command <argument> how do i check if they didn't enter /command <argument> <second argument> the second argument part
args.length < 2
?
i set the attack damage to 12 and attack speed to 1 but i still had the 1.8 attack speed thing
How can I run Bukkit.dispatchCommand(console, command); without it logging to console and chat?
You can't
i tried making my own ConsoleCommandSender with empty sendMessage functions
but that didnt help
Unless you mess with one of the gamerules perhaps
the thing is
if i set them back it gets logged in chat too
turning a gamerule back on gets logged
I mean the proper way to do it would be to not use that method
Think you can by registering your own logger and hiding certain..
centred messages w/ hex.... how?
i have the centred messages method all done and good, but with HEX codes it doesn't add as many spaces, as it sees each HEX value as legit text
is there any alternatives?
to run a command
No
:/
Plugins generally should not be running commands
Unless they are something like a crate plugin
but its too hard to implement with nms :c
..if you register your own logger you can choose to hide certain things..
What are you trying to implement
changing the players pitch while keeping his velocity
spigot's teleport() removes any velocity
Ask on the fourms to see if anyone knows
Or open an issue/feature request on the jira
alright, will do that
also im still having issues with formatting
will also report this as a bug
i think it is one, isnt it
Not sure if it's intended or not
List<String> members = new ArrayList<>();
members.add(leader.getUniqueId().toString());``` isnt there a way to create a list with starting values instead of adding them afterwards?
@fast onyx what ide you using? if a method doesnt exist it should definetly have warned u
Formatting Issues & HEX in centred messages
intellij
and that part of the code is not underlined red?
no one, anything of my code have errors
but when is executed yes
sad
it'd just be gray iirc
hmmmm
You are likely developing against a newer api than your server is using
and ur server is on 1.17.1?
hmmm. i know sendTitle wont work on 1.8 servers, but i dont see a problem on a 1.16 server. idk. anyone else?
making a broadcast command Bukkit.broadcastMessage(Color.translate(args[0])); if i do /broadcast i am cool it doesn't broadcast the whole text
sendTitle is only +1.9 true?
isnt it 1.11+?
๐ค
not sure
It's certainly in 1.16 is the point
anyone?
Hmm?
this
args[0] will only be the first argument
so, alright, im fixing it
how do i make it broadcast everything
is possible to autochange this string to another sound if the server is +1.13?
String.join
You can do it in the code
oh
Just use String.join(" ", args)
what's String.join
is it possible to make console execute a command through the code
can someone look at threads pls
no :)
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), String.join(" ", args)); would this work
i thought you were open to teaching and helping with Java
I'm open to your mom ๐
bruh
bruh v2
?jd
Using a "for" or "forEach"
ty
Examples:
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
p.DoSomething();
}
Your welcome
p.sendMessage("[Server] kek");
You declare an object player then do what ever with that object
How do you kill a player?
Let me check
No i dont know
Do i need to use reflections for example, to check in class what methods it contains and if it contains param?
Setting their health to 0 or inflicting 100000 damage will work
This question is really hard to understand, could you be more specific?
does this return how many players are online Bukkit.getServer().getOnlinePlayers().size();
Yes
I recommend you learning more about Java for then using the Spigot API
If not it will be really difficult for you .
yes, i'm still learning sorry
Hey guys, ive made this in a event:
if(p.getInventory().getItemInMainHand() == condenseWandCommandClass.condenserWand.getItem())
and the condenserWand is a NBTItem from the NBTapi and it doesnt seem to register
Im doing a event-listening, so i have created some events and a listener (that implement my listener class). So i have a list with all the listeners. I have loop it and i want to check every method that it contain and check if it has parameters
comparing items with == is (as with most objects) pretty useless
use ItemStack#equals or ItemStack#isSimilar
still doesnt work
Yeah I know but, an example? xd
if(p.getInventory().getItemInMainHand().equals(condenseWandCommandClass.condenserWand.getItem())) {}
the condenserWand NBTItem is from another class and referenced using CondenseWandCommand condenseWandCommandClass = new CondenseWandCommand();
idk if you can check if a NBTItem is in ur hand
is there another way to check if an NBTItem is in your hand @eternal night
@eternal night do you have any idea on how i should implement HEX codes to centred messages
easiest would be to give the nbt item an nbt tag with a unique id, e.g. the nbt with a custom key, e.g. MyCustomItemType and value condenserWand
what are centred messages ?
do you mean the action bar ?
atm the unique nbt is condenserWand.setString("Condenser Wand", "Condenser Wand");
How can i make a bukkitscheduler run at the start of each tick and not at the end?
can anyone help me with this method? [https://paste.md-5.net/suxenewugo.cs]
basically, i'm making a gamerules gui for easier access for gamerules,
and what i want to do is have like a lot of these methods that will set the items in the gui
and those items could be clicked to turn on and off gamerules (i'll get to the int gamerules later)
Player target = (Player) args[0]; doesn't work
one is a string the other a player
oh and i want help with making it more lag friendly
so like p.getInventory().getItemInMainHand().getItemMeta().serialize().containsKey("Consender Wand")
yeah ik that but how do i fix it
You can't
Sounds like an xy problem though
and no, why are you serializing the item meta
you should have some random trashy nbt methods around already no ?
to set and get values
you talkin to me?
no
wym by that?
What is your actual goal
setting a players pitch without cancelling his velocity
I see
My code works when i run it in the PlayerMoveEvent, but it doesnt when i run it in a scheduler
Vector vel = player.getVelocity().clone();
now.setPitch(45f);
player.teleport(now);
Bukkit.getScheduler().runTaskLater(Main.instance, () -> player.setVelocity(vel), 0);
You can just set their velocity after calling teleport, no?
you cant if you run it in a scheduler
cuz that gets run too late
player movement calc and stuff is before that i assume
but im not entirely sure
i need to run it in a scheduler tho, as the playermoveevent doesnt trigger everytime the player moves their head
Might need packets sadly
thats not a problem
but im failing to do it with packets too
trying since 5 hours
Do you know so? Talking about what i asked before
And how
what method of the ChannelDuplexHandler should I override to listen for inbound packets(client to server)
no
well you have one to set
ye
so making one to get the value of an item stack should be easy
just do nbti.getKey();
p.getInventory().getItemInMainHand().getItemMeta().getAttributeModifiers().containsKey(condenseWandCommandClass.condenserWand.getKeys())
would that work
no that dosent
can anyone help me with making this better and less laggy since i gotta do a lot of these methods?
nothing i do works
p.getInventory().getItemInMainHand().getItemMeta().toString().contains(condenseWandCommandClass.getNBT())
idk
nothign
im using NBT-API
what
nbt api is very gud
IIm using it
wait why r u doing that stuff
then you have getter methods
what are you tryna do
NBTItem condenserWand = new NBTItem(new ItemStack(Material.STICK));
then create a new nbt item with the item you wanna check
and get the nbt values from that
condenserwand.setString(key, value)
or whatever java primitive you need
there's also support for some objects
then you need to get the item back
p.getInventory().getItemInMainHand().equals(condenseWandCommandClass.getCondenserWand().getItem())
?
condenserWand.getItem()
i do that
or you need to put as the second argument of the NBTItem constructor true
public NBTItem getCondenserWand() {
return condenserWand;
}
yea that works fine, but if you want to get the itemstack
you need to do this
i do that
and what's the issue?
oh don't compare like that
@EventHandler
public void onPlayerRightClick(PlayerInteractEvent e) {
Player p = e.getPlayer();
Action a = e.getAction();
if(a == Action.RIGHT_CLICK_AIR){
if(p.getInventory().getItemInMainHand().equals(condenseWandCommandClass.getCondenserWand().getItem())) {
System.out.println("Hi");
}
}
}
check for nbt tags
oh
also what version are you on?
i saw but idk how to do it
I would assume new NBTItem(p.getInventory().getItemInMainHand()).getString
or smth
idk never used nbt api
yea
Oh i love java its amazing btw. The connection its being opened but the stream not. Or at least im not receiving anything. :P
how ORB_pickup sound is called on +1.13?
I dont really now what happening. Because the connection its stablish
String key = "mykey";
String value = "myvalue";
String expectedValue = "expectedvalue";
String toolTag = new NBTItem(p.getInventory().getItemInMainHand()).getString(key, value);
if(toolTag.equals(expectedvalue))
if(p.getInventory().getItemInMainHand().equals(new NBTItem(p.getInventory().getItemInMainHand()).getString("Condenser Wand")))
No
or smthing similar
would anyone know why this case "invites": return String.valueOf(data.getInvites(player).size()); placeholder isn't working in game?
thanks @misty current and @eternal night it works now!
np
https://media.discordapp.net/attachments/551613805176815655/913896880298143784/unknown.png
How do i get the TaskId?
yep
Store the BukkitTask object
iirc when you create the task, it returns the int that is the id
so just store it when you create it
hmm
this.
yea exactly
what do you mean?
?scheduling
oh, ty!
Adri that wiki page I wrote actually goes over cancelling
all my other placeholders are working, but that ones just showing like this
wait really?
it does
ty!
sorry can't use placeholders :<
what
never needed them
Wally
yus
Send entire class (:
k
That line doesnโt tell us very much
wait are you using PAPI or did you make your own
package me.wally.guilds.GUI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
public class Placeholders extends PlaceholderExpansion {
Data data = new Data();
@Override
public String onRequest(OfflinePlayer player, String params) {
switch (params) {
case "guild": return data.getGuild(player);
case "role": return data.getRole(player);
case "memberCount": return String.valueOf(data.getMemberCount(player));
case "memberCountCap": return String.valueOf(data.getMemberCountCap(player));
case "level": return String.valueOf(data.getLevel(player));
case "exp": return String.valueOf(data.getEXP(player));
case "invites": return String.valueOf(data.getInvites(player).size());
} return null;
}
@Override
public @NotNull String getIdentifier() { return "Guilds"; }
@Override
public @NotNull String getAuthor() { return "wally"; }
@Override
public @NotNull String getVersion() { return "1.0"; }
}```
papi
you wrote guild_invites while ur switch has invites
Btw
oh nvm
different jar
Ah okay
i registered this class in my main
well if the other placeholders work i don't see how would this specific one not work
U cant use capital letters
Wait you donโt need to register it in main if its an expansion jar
should be fine
the other placeholders work
huh?
i just did new Placeholders().register();
in the placeholder's plugin folder?
is 3 a double
can be
i mean
it could be
3.0 is
depends on where u store it
the expansion jar
.
wait what was your question for that
You said you kept the placeholder expansions class in a different jar than your plugin jar
Anyways
If itโs in the same jar
Override persists method inside the placeholder expansion class
and return true
Also override canRegister
And make it return true
i dont have a persists method
no i remember it from the api docs
how do i convert arg1 arg2 arg3 (x y z) to a location
just thought i didnt need to add it
you do if its in the same jar
parse the args as integers and use the Location constructor
due to class loading shit and other hackery stuff
new Location(world, x, y, z, optional pitch, optional yaw)
pass as world player's world
what method of the ChannelDuplexHandler should I override to listen for inbound packets(client to server)
yea sure
Guys how would I best link a placed block with an inventory? (sort of creating a new chest but without a container as the chest item)
Inventory GUI = Bukkit.createInventory(null, 27, "Guilds");
wait what are you asking
to like open the inventory of a chest item in your inventory with nbt?
send ChannelDuplexHandler also if you can decompile it that is
yea sec
Well I created a inventory on death and want to store that inventory inside the metadata of a placed block
is that block always going to be a storage block?
Actually never going to be
cus if so, you could just clone the inventory into the block's inventory
(Double) args[0], (Double) args[1], (Double) args[3] doesn't work
don't think you can make non-storage blocks have inventories
kinda confusing class :p
Well I know you technically can I dont know exactly how to execute it tho
But I could store metadata from a block and data from the inventory
@ivory sleetbut i have practically the same as in the guide but getting errors
And compare those on an onInteract event
screen shot the errors
hmm looks fine
Just the relationship with the block and inventory I cant really wrap my mind around
the canRegister method is for placeholders outside the plugin
@ivory sleetwell, now it works but can't access from other scope
is it?
idr everything but maybe thats true lol
wut
send more code, caye
tells me nothing
Double x = ((Double) args[0]); doesn't work
Double.parseDouble(args[0])
i can't access from the else if
is this the right one for my situation?
try-catch it since it throws an ex
maybe idk, but yeah probably
anyways i guess i'll go trial and error for duplex channel
to cancel, you'd have to call task0.cancel()
player.teleport(```
how do i tp them to that location
i love when people listen
but, i want to cancel it here:
@misty current
Also you need to assign that location to a variable
yea?
Currently you are creating it and then yeeting it into the void
player.teleport(new Location(player.getLocation().getWorld(), Double.parseDouble(args[0]), Double.parseDouble(args[1]), Double.parseDouble(args[3])));
as it prevents the super.call() if any of the functions fail
also
use Predicate
(which returns a primitive boolean as opposed to the boxed type)
You need to learn about variable scope
how i can solve this problem?
Declare reload outside the if
i already do that
no?

