#help-development
1 messages · Page 2124 of 1
you used your command and did /reload
I did a reload before the command because I updated the plugin
And when the player is invalid I get no error message
try {
Player player2 = Bukkit.getPlayerExact(args[0]);
try {
int seconds = Integer.parseInt(args[1]) * 20;
player2.setFireTicks(seconds);
} catch (NumberFormatException nfe) {
player.sendMessage(ChatColor.RED + "That is not a valid number");
}
} catch (IllegalArgumentException e){
player.sendMessage(ChatColor.RED + "That is not a valid player");
}```
xd
???
?jd-s time
you can;t send a message to a null player
oh I see player2
the outer try will throw an NPE not an IllegalArgumentException
It still doesn't work
does any one know how to rotate a beacon?
isnt that client side?
clean up that messy code
So, I want to show an entity’s health as their name. I have gotten it all to work except that the name tag doesn’t update after taking damage, only after hitting it once more. Is there a fix for that?
client side 😭
any idea how MCC did it?
what code
Probably using a custom model
maybe
one that interacts with the computer
i dont think so
i searched a lot about beacons
and everything said
beacon beam is 100% clientside
hardcoded
I think a possibility would be to set an item with the beam model as the head item of an armor stand
it is not possible
or will use armorstands to simulate that?
if so, consider using the guardian beam
armorstands
this?
is it entity?
or particle?
wait particle its not
my bad
oh textur
im dum
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
did someone know gson well?
...read the above
just ask it lol
yes
How Can I send Message Only Admins? I found Bukkit.broadcast but doesnt work
declaration: package: org.bukkit, class: Bukkit
dunno if being op has a permission but you could do it with a simple for loop too
Player.isOp()
i know
What is wrong with it.. Its sending message just 1 op person. I tried Bukkit Broadcast too and It doesnt send anybody I think I enter permission wrong
why is there a return true Inside 🤔
How to add cooldown on player interact event
What Should I write on permission. I writed this and doesnt work
oh changing.
broadcastMessage()
Try just “op” I saw someone use it before
oh okay thanks Im trying
since that fills out a default permission for you contrary to just broadcast()
?
Oh Doesnt work
if someone is an operator, does he have a permission like bukkit.op or smth?
nah
It Was my mistake and I changed
Ah kk then just use a for loop ig
but permissions have default set to op
oh
hence why ops get most permissions
What Should I do rn
anyway ARDA as said I'd suggest using Bukkit::broadcastMessage
oh okay then?
It wont send message to all players?
yeah but it'd mostly be to verify that your code actually goes that far
then just substitute it to the normal broadcast method
okay thanks
I mean that perm node is set to true for everyone I believe
that unless you changed it
my solution is java AdminLog(string Message){ Bukkit.broadcastMessage(string, '*'); }
Where to start learning to make a plugin like dynmap
on a different topic can i access player statistics via a command?
ideally you should use bukkit.broadcast.scradmin for administrative broadcasts
as thats also a regulated bukkit permission
whats that 'scr' short for?
I SOLVED!
is there an event for blocks being broken by non player sources, e.g /setblock and /fill?
i don't think you can use BlockBreakEvent because according to IntelliJ e.getPlayer() != null is always truu
op is every permission tru i believe
if the permissiondefault for it in FALSE that ops wont have it by default
I've set up a listener for EntityDamageByEntityEvent
but it appears to be triggering on EntityDamageEvent
do a cast check
sure, but why is it triggering in the first place?
casting where?
probs bcs of the generics
it works for other things
entitydamagebyentityevent extends entitydamageevent
xd
and generics though
but why is the listener for EntityDamageEntity triggering on just an EntityDamageEvent?
its the superclass of that event it inherits some stuffs probably
hmmm
Question, is there any way I can let people make their own servers when on my server through a command and have it get automatically connected to my Server?
Through Bungeecord , btw
Update on my issue: Its NOT because of interactionEvent.
It has something to do with the event itself, firing twice for 0 reason.
so I have this class
I use the second constructor
Can someone help?
?stash
This function then extends
public class RightClickItem extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final PlayerInteractEvent event;
private final CustomStates type;
public static HandlerList getHandlerList() {
return HANDLERS;
}
public RightClickItem(PlayerInteractEvent event, CustomStates type) {
this.event = event;
this.type = type;
}
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
public CustomStates getType() {
return this.type;
}
public PlayerInteractEvent getMainEvent() {
return this.event;
}
}
Does anybody see a reason for my custom event (VIA Spigots EventAPI) to run twice?
Cause its only being called once, I just checked.
Before finally creating a new listener for the EntityDamageEntity Event
tysm
so the EntityDamageByEntityEvent class is definitely the class which is passed into the function which registers the listener
so it must be some internal weirdness with the events
it gets check in mainhand and offhand
is my best guess
But i already did a check for that.
one sec that happens to me every time
@EventHandler
public void clickEvent(PlayerInteractEvent event) {
ItemStack item = event.getItem();
Block block = event.getClickedBlock();
if(event.getHand() == EquipmentSlot.HAND){
if(event.getAction() == Action.RIGHT_CLICK_AIR){
handleRightClickAir(event, item);
}else if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
handleRightClick(event, item, block);
}
}
}
private void handleRightClickAir(PlayerInteractEvent event, ItemStack item) {
if(item != null){
System.out.println("Hey!");
Bukkit.getPluginManager().callEvent(new RightClickItem(event, CustomStates.AIR_ITEM_OFF)); //Air clicked by Item.
}
}
It calls the event, only once
Yet its running twice
called for each hand
event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getHand() == EquipmentSlot.HAND
if(event.getHand() == EquipmentSlot.HAND){
cant you just do eventClass.cast?
its called twice by default
forgetting either of those checks results in double event iirc
if(event.getHand() == EquipmentSlot.HAND){
if(event.getAction() == Action.RIGHT_CLICK_AIR){
handleRightClickAir(event, item);
}else if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
handleRightClick(event, item, block);
}
}
wdym?
...
lemme check smth
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
well with that chek it only triggers once for me
granted i have a third condition checking the right clicked block but i reay doubt thats the issue
okay well this makes this issue 100% more strange
So, the event itself is running Once
Any issue here?
@EventHandler
public void onRightClickItem(RightClickItem event) {
Player eventPlr = event.getMainEvent().getPlayer();
ItemStack eventItem = event.getMainEvent().getItem();
if(eventItem == null)
return;
PersistentDataContainer itemPerst = eventItem.getItemMeta().getPersistentDataContainer();
if(itemPerst.get(NamespaceKeyList.getKey("coin"), PersistentDataType.STRING) != null){
eventItem.setAmount(eventItem.getAmount() - 1);
eventPlr.sendMessage(ChatColor.GREEN + "Gained 1 coin! Congrats!");
}
}
This is the only reason it would run twice now
Guys i recently wiped one of my pcs and now i'm trying to transfer and existing github project to it and it comes with a lot of errors
i also have a working instance of the project on my laptop
but does anyone know how to properly bring projects from one device to another in IntelliJ?
if so please @ me
i have 1 way, involves a USB and transfering some files
ello! i'm new to plugins, i was wondering how to "mark" a block (like a chest) so i can change it's nbt later, could anybody help me with this?
dumbest mistake of the week: int x = Location#getBlockZ()
mnfalex' block PDC plugin
alternatively store the location in a set somewhere
depending on if you meant to see later on if the block's marked (ie over restarts) or if you want it in some sort of temporary mechanic
I fixed it.
I was generating the coin twice.
So it was running registerEvents twice
:P
thats why you use copious amounts of log messages
i would just do
abstract class CustomItem {
// fields and stuff
@EventHandler
abstract void onRightClick(InventoryClickEvent event);
// maybe even ::onLeftClick too
}```
instead of creating a custom class for it
What is the best way to add a delay to something like when I want to add time between messages in a dialog. I'm using Thread.sleep() but that is giving a lot of red errors.
Back on the issue I was having before
I printed out the class being passed into the listener just to be sure
and it's definitely EntityDamageByEntity event
?scheduling
^
do NOT use thread sleep
minecraft is mostly single threaded
use delayed schedulers
I set up some separate listeners for EntityDamageByEntity event and they won't being triggered on regular damage events
thread.sleep will freez the server very nicely 🤤
yep
only if you are using multiple threads by any chance
but for some reason this one does?
like new Thread
Ok, I'll use scheduling, thanks
also take note that scheduling brings along its own issues, if you schedule too many things it ll cause issues
if you need to set long delays call one scheduler that then checks if something should be ctivatedby for exammple making it check over a set of objcts that contain a activation time field
god i rember 😀 on my first plugin i made a weapon which shot 3 arrows with a one second delay and my entire server froze and i was so confused 😬
lmao
Ok these are different
Event 1
Event 2
With EntityDamageByEntityEvent.class having been passed in as eventClass
why are these not identical??
I'm guessing it's something to do with the generics but how??
i am trying to use https://github.com/dejvokep/boosted-yaml and have the following code to shade it but i get the error groovy.lang.MissingMethodException: No signature of method: build_98ejwwytx8c7e1j7kkucfbrye.shadowJar() is applicable for argument types: (build_98ejwwytx8c7e1j7kkucfbrye$_run_closure3) values: [build_98ejwwytx8c7e1j7kkucfbrye$_run_closure3@3d2ecc65]
shadowJar {
relocate('dev.dejvokep.boostedyaml', 'me.kidneybean.generalutils.shadowed') {
include(dependency('dev.dejvokep:boosted-yaml:1.1'))
}
}```
i think i got it
Also it's triggering on a player interact event???
Anyone have any ideas?
I've somehow made a listener which listens to multiple events at once
what have I donneeee
fourteen brush plz hellppp
How are these situations not identical >_>
idk lol i barely touched generics in java
fffffffffff
but why does it trigggerrr
how does it listen to MULTIPLE THINGGSSS
I am literally shaking and crying rn
there
I have simplified it
so it is easy to see what is going on
and how you can see how these things are literally the same
thats because entityDamageEvent is part of EntityDamabeByEntityEvent. Every EntityDamageByEntityEvent also is a EntityDamage envent and triggers it
Yes but I am listening to entitydamagebyentity event
not the other way around
So EntityDamageEvent should not trigger EntityDamageByEntity event
look
both are registered for EntityDamageByEntityEvent
I print it
in the class of the abstract listener
why the things extend
an entity being damaged by an entity calls a damage event and an interact event
so why does one pick it up and the other doesn't??
If I punch a chicken
both events fire
but if something just gets hurt
like I jump off a cliff
ONLY event 2 fires
but they are identical??
both are passed the EntityDamageByEntity event when they fire
as shown there
so how tf
have I managed to make one of them listen to multiple events
I
do
not understand
seriously? Fall damage triggers EDbE?
there you have it
the entityDamageeEvent gets fired whenever something takes damage
on top of that EDbE gets fired whenever its an entity damaging another entity
and I am not listening to entityDamageEvent
I am listenting to entity damage entity event
They are both the same
the damager is god
ok I'm gonna rename my messages to listener rather than event so it is clearer
I jump off a cliff
I punch a chicken
first time, just the second listener triggers
second time, both listeners trigger
the listeners are listening to the same event
does EntityDamageByEntityEvent#toString provides anything good for debugging?
why reload
the same
because lazy
you can see they are registered for the same event here
which is printed in the constructor of the abstract listener
I guess you gotta handle the event yourself once casted, maybe try doing damageCause checks?
printing the event?
ye
lets check
dunno if it has an impl
But I'm doing the exact same thing in both casessss
why do some events trigger for one and not the other?
probably cuz ur using generics
but you can see that the exact same value is passed to the bukkit function which registers the listener
so why would they fire in different cases?
does any one know why I don't see the guardian Laser?
I see just the water (I'm using guardianbeam)
and the generics are not causing an issue for Listener number 1
yeah cuz ur passing a specific event there
Am I not in the second case?
at runtime the registerEvent() function recieves the same value
for both
How can there be a difference here?
is the abstract listener triggered everytime you get hit or damaged?
the second one is
the first one is not
Even though they are registered under the same EntityDamageByEntityEvent
The first one does what ti should
triggers when any entity is hurt by another entity
the second one is misbehaving
and triggers on any damage event
How would I create a custom textured block? I already have the texture pack btw
And no: I do not wish to have to sacrifice block data, or any of that.
and you have an overloaded constructor there so every time u get hit it registers a new event?
I do not overload the constructor
I overload the trigger function
I am using the second constructor
which registers a listening for the provided class, and will execute the trigger function when fired
oh anonymous
If anyone has any ideas that would be very helpful
with?
this
no idea sorry
I barely have any experience with dealing guardians
cuz I dont spend most of the time in the ocean when I used to play minecraft
oh ok
You probably have optifine installed
yes i do
disable the shaders
Elgar, any idea on the issue I'm having?
i didnt have any shaders on
oh wait
i know what is the prablom
i think
nvm
I've not been reading, somethign about events triggering?
Try without Optifine
You might have invalid handler lists @supple elk but really I do not have an idea
What event is being called when travelling in a minecart?
BukkitAdapter
com.sk89q.worldedit.world.World adaptedWorld = BukkitAdapter.adapt({world});
yeah
Basically I have this class
which registers an event under the class passed to it, which will execute the trigger function when the event fires
That works
If you want to track how far someone has traveled use the MINECART_ONE_CM statistic
It's not recognising BukkitAdapter
I've got this dependency:
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.2.0-SNAPSHOT</version>
<scope>provided</scope></dependency>```
However, if I add the other bukkit dependency, then I run into an error
I then make 2 seemingly identical listeners
The first one fires when it's supposed to, only on entity damage entity events
second one fires on any entity damage event
Depend on world edit bukkit
can't use this, it's an old server -> People have maxed the statistics
I can't reset them, because that will upset the community
You can track start and exit and see the change
they are both being regisered under the same event, that's printed in the constructor of the AbstractListener
Cannot resolve org.bstats:bstats-bukkit:1.7
Getting this^
I used fawe soo
Any ideas on how to handle people leaving in the middle of a ride ?
anyway that's the run down @eternal oxide
I find it strange that PlayerMoveEvent doesn't handle minecart movement, but does handle boat/horses/all other vehicles
just exclude it
How would I have invalid handler lists?
You mean leaving the server?
broken plugins or something
Is the registerEvent() function not passed the exact same thing?
It's just my plugin
maybe it's the function which is passed to the registerEvent function?
The fact that's it's generic??
yeee
but then why would the other one work ;-;
Just treat that the same way you would when exiting the minecart
Olivo perhaps you could take a quick look and see if you can shine light on the issue?
rundown starts here
What events are passed?
to where?
the listener the recieves all events
remove the & Cancellable from your second event and see if that changes things
as the Cancelled state is from the parent event
well, this is meant to be part of a more generic system
where I have a function which needs to take the class of something which is both an event and cancellable
but I shall try it
Yes, but at teh moment you are stuck on finding where your issue comes from
yup
^^c:
which concrete classes?
ok, now trying this
Maven or gradle?
Maven
^
EntityDamageEvent
I think I might have seen an EntityDamageByBlock at one point?
still fires
even without cancellable
odd indeed
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.3.0-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
unlikely
You could just filter out invalid events, but this should be done by bukkit, not you
that's the only difference I could see between them
yeah
it's strange that one listener works fine
but not the other
I punch chicken and hunky dory
but other any EntityDamage event and 2nd triggers but first doesn't
second also triggers on damage by block
somehow I have created a listener which listens to multiple events
or maybe it's listening to any entity damage event
but why if the registerListener() function is passed the same class in both cases
Your second Listener is triggering on all subclasses of EntityDamageEvent
How would I make a spawner, that has a armorstand as its spawn, and has an item model on its head.
The spawner wont spawn anything, and the armorstand doesnt spin.
another weird thing
I get this error message every time an event is triggered which isn't an entitydamagebyentity event
which is saying it can't cast
on the line when it tries to pass to lamda
but then the lambda code still runs??
still prints the event
so yes its your Lambda, Its registering a type erased event
but then why does it work for the first one?
No clue why though
and not the second?
if you only register the second event do you still get the cast errors?
find which of them is throwing the cast error
it's def the second
its not both?
oh snap
wait nvm
second does not through cast error
the first does
shit
that is wack
So the second is ONLY being called when it is an EntityDamageByEntityEvent ?
or sub class
it can;t be called for every event and not have a cast error
they are both called all the time
that is what is happening >_>
it will only accept EntityDamageEvent and its sub classes
what I meant for every event
every sub class of entity damage
yep
so the first is also being called on all sub classes
so its your first Listener thats firing on ALL events
no
Some of which are not children of EntityDamageEvent
both fire on all sub classes of entity damage event
yes
they fire on the same events
no more or less
but the first one generates a casting error
the second one doesn't
but the cast error is from an event which is not an EDE or a sub class
which is why you see the message produced by the second
and not a message from the first
no error message is from ede or sub class
cause it's trying to cast to entity damage by entity event
they are both registered to listener to entity damage by entity event
are triggering on any sub class of entity damage event
You can cast and EDBEE to an EDE
ik
which is why is triggers the casting
but they are registered to only listen to an EDBEE
I only want EDBEE
that is the event class being passed into the registerListener() function
EDBEE
yep. Type erasure on teh lambda
This then causes the first one to cause a casting error when it tries to cast to EDBEE
but I don;t see why
the second one does not create casting error
and also why the difference between the two?
Java is fucking weird
why is type erasure a thing i hate it
how do I fix this 🤔
how would I make a block with CustomModelData?
No clue on this one
doing a third test
just made a third listener
no error
only triggers on required event
that uses the first constructor
and registers it in a differnt way
and relies on the trigger function being annotated
Yep, so Bukkit correctly scans the annotation
However this does not allow me to create a listener by passing in an event class to a function
cause I then have to manually create it
the idea is I can call a function and pass in an event class, creating the same listener for a different event each time
how can i convert a string like "&3String" to show as colored in the chat?
ChatColor.translateAlternaateColorColdes('&', text);
Weird null
adding the annotation to your second Listener will not work?
Bukkit will likely fubar
ok thanks
np
I don't think both are meant to be used but lets try and see
just tried
no changes
makes no dif
a shame
I believe with the current way Bukkit registers event listeners you are out of luck using generics
fnweinfwegewgeg
Bukkit is just not designed for it
so I just have to make a listener for every event
or
I could use the first listener
and manually check cast
summon satan
hmm?
declaration: package: org.bukkit.plugin, interface: PluginManager
the lambda is already the event executor @maiden thicket
can I get the item dropped in blockbreakevent
implement eventexecutor
Listener
for(int i = 0; i < list.size(); i++)
list.set(i, list.get(i) + something);
that won't error right
if something exist, it will work
ok...
public interface CustomEventExecutor<E extends Event> extends EventExecutor, Listener
{
void invoke(E e);
static <T extends Event> void createEvent(Class<T> clazz, CustomEventExecutor<T> executor, EventPriority priority)
{
Bukkit.getServer().getPluginManager().registerEvent(clazz, executor, priority, executor, plugin);
}```
um
extends two classes?
i get this when i try to load my gradle changes in intellij ```Could not find spigot-api-1.18.2-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220408.234706-30).
Searched in the following locations:
https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.2-R0.1-SNAPSHOT/spigot-api-1.18.2-R0.1-20220408.234706-30.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
like so?
it can extend more than one
?
don't you use implement for an interface?
?
then usage would be
CustomEventExecutor.createEvent(PlayerJoinEvent.class, (event) -> {}, EventPriority.NORMAL)
not for interface doing other interfaces
not an eventhandler
ah i left out a part
sec
@Override
default void execute(@NotNull Listener listener, @NotNull Event event)
{
// try catch needed for events with super classes of other events
try {
E castedEvent = (E) event;
this.invoke(castedEvent);
} catch (ClassCastException ignored) { }
}
but yk change the default word
ah
how do I make a skull have an owner using a value and signature? like when setting a skin, I don't want it to be UUID dependent, only value and sig
do i need to exclude spigot api when shading?
yeah iirc
ok so you're just manually checking the cast
sí
ok how do i do it
pretty sure i got that code off the spigot forums
maven?
gradle
are u using the shadow plugin
john rengelman shadow
idk if you need to but your jar will be huge
We basically you had the same issue as me but you manually just checked
change to compileOnly
use compileOnly for the api
well i get this when i try to load my gradle changes in intellij ```Could not find spigot-api-1.18.2-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220408.234706-30).
Searched in the following locations:
https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.2-R0.1-SNAPSHOT/spigot-api-1.18.2-R0.1-20220408.234706-30.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
we did discuss that but were trying to find a way to get it to work without 'cheating' it
i have it like that
and implementation for the shaded stuff
u dont have rhe maven repo added
cuase bukkit should do the checking
mm ic
?
i have mavenCentral()
and it worked before
spigot api isnt on maven central
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
do not want to cast to T
i hope
casting to T will work even if class is wrong cause of type erasuse
mm ic aight
intellij is a java app so it may use certs in the truststore
for ssl purposes isk
idk
i rejected it
doesnt pop up anymore
lessgoo
so good
#rejected
doesn't really solve the underlying issue with it though lol
pretty hacky
very hacky infact
eventexecutor be hacky
but if it works it works
u sure its not caused by using /reload
W
yes
which issue
bump
the listener triggers on more than just the event I passed
passing EntityDamageByEntityEvent
thanks 🙂
meant the listener triggered on any entity damage event
craftskullmeta maybe
ah smh mojang
casting to T also meant the cast worked when it shouldn't in sometimes cause of type erasure somehow
which then meant the event of a wrong type was passed to a lamda and was somehow executed regardless
which sounds dangerous
any hacky solution W
truetrue
IJ's broken certstore moment
hey geol 🙂
its gone now no idea what that was
we 'fixed' it :p
I saw
Hey can someone help me because,
https://github.com/SaberLLC/Saber-Factions
This plugin don't have /f top
But someone made it
https://www.spigotmc.org/resources/factions-top-1-8-1-18-f-top-factionsuuid-saberfactions-kingdomsx.20661/
but problem is,that cost 10$
I don't wanna add 10$ for that
I think this will help so much members
Hello guys
how do I place player head in a location?
player head of a specific user
the api unfortunately lacks the architectural design documentation
is this how to make a mapa in groovy
Did u try googling
Wow thanks you are a big help
Didn't mean to be rude
I googled it and all of them talk about "giving to players i.e. itemStack" not setting block types
^^
you need to make a skullItem and change its meta? and place?
iirc you can cast the head's blockstate or blackdata (one of those) to "Directional", then set the direction
blockSign.setType(Material.OAK_WALL_SIGN);
Directional blockSignData = (Directional) blockSign.getBlockData();
blockSignData.setFacing(BlockFace.WEST);
blockSign.setBlockData(blockSignData);
this is what I did for the sign
I don't want to change the direction
there is a setOwner() method
that is deprecated
wut
This is only api documentation, it doesn't explain how "Blocks" are structured and changed
wait nvm they want to do direction not changing skin
which is the code =-=
I have spigot forked from buildtools and it isnt deprecated?
I'm trying to make command filter, if the command is specific in array list, I will be executable. One problem is that it's not work );
Bruh
get the block's state, cast it to skull, then use Skull#setOwningPlayer(OfflinePlayer)
it says in the docs it is 🤷♂️ https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/SkullMeta.html#setOwner(java.lang.String)
declaration: package: org.bukkit.inventory.meta, interface: SkullMeta
btw this is CraftSkull.java
ig skullMeta its deprecated
I think u need to use e.getCommand
- SkullMeta is not deprecated
- Using String's for player names is deprecated though
- SkullMeta isn't helpful to place skulls in the world
yea
PlayerCommandPreProcess use getMessage() to get typed command. I think the problem is on array list.
Also something's in ur code I'd change
Player cast is redundant
No need to do new ArrayList, just use getStringList
in org.bukkit.block there are many files
?jd-s
Check if list is full & also show config
am I supposed to do something like:
Skull head = new Skull(new Location(...))?
as I already said
- Get the block's blockstate
- cast it to Skull
- use Skull#setOwningPlayer
Set the block to the skull type you wish, and then get it's block state and cast it
Now I understand
thanks!
np
actually you don't have to load it from config every time you execute the command, this may slow your process down, you can load this as a static object(unless you want to change the config file while the plugin is running)
Plugin configs are cached
No slowing down at all
It's all loaded into memory on startup
Well hashmaps have some performance slowdowns, but it is incredibly marginal
You're not going to see any significant improvement whatsoever
Yeah
hey, how can i get an item using its id?
for istance, crafting table's id is 58
I want smth like
ItemStack item = new Itemstack(Material.getID(58))
player.getInventory.addItem(item)
And it would give a crafting table
Doesn't exist anymore
ok I see, thx
If you want to get a Material by its id, Material#matchMaterial(String)
but it has to be a string
Numerical IDs have never been public API and post-1.13 they most certainly never will be
what is the difference between rotatebale and directional?
Rotatable is a sign for instance, directional can only be a cardinal direction, like a log
So, 8 directions vs 6 directions
ok
that makes much more sense
like what i wanna do is give the player an item between ALL items in minecraft.
I thought that the only way of doing it was to get a random number and give the item. IS there an other way?
You can get a random Material if you want
It's an enum, so a random number between the ordinal values
Material[] materials = Material.values();
Material randomMaterial = materials[ThreadLocalRandom.current().nextInt(materials.length)];```
so i get a random element of the enum like if it was a list?
Bear in mind that that may not return you an item. Material#isItem() should be checked. do/while is your friend here
just do sth like
Material mat = Material.values()[ThreadLocalRandom.current().nextInt(Material.values().length)];
Do note that Enum#values creates a clone to the array, so you should prefer to cache it
Enum#values() already caches afaik
I do not think so given that arrays are never immutable
Unless the JDK is smart enough
Mmm, right. Frozen arrays aren't added yet
getMessage() contains the slash iirc
Print getMessage ans things will be clear
Does anyone know how to use breakpoints with spigot plugins
for random obtrainable materials, i'D just do sth like this
private static final Material[] obtainableMaterials = Arrays.stream(Material.values()).filter(Material::isItem).toArray(Material[]::new);
public static Material getRandomMaterial() {
return obtainableMaterials[ThreadLocalRandom.current().nextInt(obtainableMaterials.length)];
}
getMessage is the prefix too ye
You can't. At least not to my recent knowledge. You'd have to attach to the server process because your plugin is already compiled into a binary
Yes
the texture isn't changed neither the rotation:
Block blockSull = new Location(Bukkit.getWorld("speed"), 994.0, 102.0, -1336.0).getBlock();
blockSull.setType(Material.PLAYER_HEAD);
Rotatable blockSullData = (Rotatable) blockSull.getBlockData();
blockSullData.setRotation(BlockFace.NORTH);
Skull inf = (Skull) blockSull.getState();
inf.setOwningPlayer(x);
You could, but it would be a lot of setup. Plus it may not work as expected.
I legit use breakpoints to highlight lines that can be problematic
You have to re-set the state
whenever dealing with an exception I just highlight it to keep organized lol
Did u like it?
I once saw this idea on stackOverflow, but I never did it by myself
try to call inf.update()
well i just tried it out and it worked
dunno whats the point of it
probably debugging from within ij
it isnt a plugin its just a run configuration
processResources {
// replace placeholders for epicness
// (and streamlining) but mostly epicness
// (and other processing)
filesNotMatching([
// media
'**/*.png',
'**/*.ogg',
'**/*.wav',
'**/*.mp3',
// compiled
'**/*.jar',
'**/*.class'
] as Iterable<String>) {
// expand placeholders
expand([ 'carbonProjectVersion': project.version ])
}
}
``` why is this not expanding it in the source files?
no errors
it works in the plugin.yml
or does it only do it for the resources
and literally nothing else
No no, it gave UI etc
If you're trying to process source files, yeah that won't work
but if you're trying to get your plugin version, what's wrong with plugin.getDescription().getVersion()?
Assuming you're already injecting that version into the plugin.yml, yeah?
Y tho?
i could read it from a file lol
Probably would have to read it from your plugin.yml manually, yeah
wdym i dont want people editing my version
but i also dont want them to have the instance
so yeah
public static final makes the most sense
Can read from the plugin.yml's input stream
Oh my bad I thought it was just static
oh
getResourceAsStream(), or just getResource(), whichever you prefer
true
(will likely have to make a method to one-line it)
Do playerheads have access to PersistentDataContainer
I see, I knew ItemMeta can obtain it, but can I obtain it as a block form?
Placed
public static Version readFromResource(Class<?> ref, String path) {
try {
if (!path.startsWith("/"))
path = "/" + path;
InputStream is = ref.getResourceAsStream(path);
Version ver = of(new String(is.readAllBytes(), StandardCharsets.UTF_8));
is.close();
return ver;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
I’m not sure about that. I think blocks now have access to their own PDC, but I could be wrong.
Turns out, you have to use this: https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
Which, to be fair, is a bit dumb
But what can I do about it :P
BlockStates have PDC, but yeah if you want just any block, you can either use that resource or you can use Chunk's PDC
(which is what that resource does too)
Sure thing.
My last question: Ill be generating the area from a ore catalyst, by generating a circle in the area its placed, and converting it to stone.
How would I detect blocks that have a space above it that is open?
only TileEntities have a PDC; normal BlockStates don't
Yeah you knew what I meant 😛
Depends on your build, but you could just check the location above the block to see if it is air.
chunks have a pdc too
Do I check on the Y axis +1 or +2
For 1 block above
+1
Alright lol
Um, yeah. I forgot about that, Now I put slash on the config, but seems like it's still not working....
When I type /ban it's said the cmd is /tell
When I type /tell now it's /ban...
Or should I quit developing plugin XD
im so confused
how did you manage to
do that
How lmao
I'm also confusing with myself...
what are you trying to make?
i have the thing for it though
.
I've been really struggeling placing a bed with both bottom and upper part
Searched in the following locations:
https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.2-R0.1-SNAPSHOT/spigot-api-1.18.2-R0.1-20220408.234706-30.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
```i get this when i try to reload my gradle changes in intellij, but it builds fine.
in 1.8
Im confused why its a loop like you can have a list and use contains() right
Um nope
contains() need to be string
What does getMessage return?
can anyone help me
returns command with /
so if i use toString it will be like "[/tell, /ban]"
An actual command or the string representation of it?
Yes, that’s how arrays work, but you can call #contains() on that list and it will check if what you are looking for is in the list.
i get this error org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: dev/dejvokep/boostedyaml/dvs/versioning/Versioning when i start my server
How can I disable the /plugins command?
um.....
overwrite it with another command
There is a permission node for it.
Since it’s not connected to permissions
I'm trying to see if player's eye direction and the direction he's moving towards the same and java p.getLocation().getDirection().setY(0) == new Location(p.getWorld(), packet.getX(), 0, packet.getZ()).subtract(p.getLocation()).getDirection().setY(0) didn't work how can i do that
Nope everyone can do it
Negate it for the default permission group then?
Okay so i have a boss bar that counts down from 15 (changeable) So what i do is i do 1.0/countdownTime and when i change the boss bar i do bar.getProgress()-devidedTime (not exact code but doesn't fully matter) But of course when my countdown is at 1 then the bar is fully empty and i'm wondering how i can have the bar still have 1 count worth of progress at 1
why is it throwing this error?
its erroring when processing my plugin.yml, which looks like this:
# Main Properties
name: Carbon
main: net.orbyfied.carbon.bootstrap.Carbon1182Bootstrap
version: ${carbon.project.version}
...
add 1
But where
I don't get it. Can you show me an example or something?
like... e.getCommand.#contains() ?
it doesnt recognize the $
Cause i can't add 1 to the boss bar since that would be about 1.06 currently and that causes an error
hm
What’s the permission node then?
do i need to change it to '${...}'
i get this error org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: dev/dejvokep/boostedyaml/dvs/versioning/Versioning when i start my server
check if the command is in the list using contains()
it shows its erroring at something like $$$$$$$
lemme write some code wait
i dont have anything like that tho
its failing to parse a template script
List<String> myList = new ArrayList<>();
myList.add(“hello”);
myList.add(“world”);
if (myList.contains(“hello”) return true;
i dont think thats my file, i think its a gradle thing
'${carbon.project.version}'
Send the full yml
i get this error org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: dev/dejvokep/boostedyaml/dvs/versioning/Versioning when i start my server
@quaint mantle
istg why tf is paper updating every 2minutes or something
u are probably using the full server not just the api
building a custom jar?
ohh
i get this error org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: dev/dejvokep/boostedyaml/dvs/versioning/Versioning when i start my server
hey, i made this code that should make an entity spawn whenever a block breaks. Any idea why it doesnt work?
@EventHandler
public void onBeak(BlockBreakEvent event){
Block block = event.getBlock
EntityType[] mobs = Arrays.stream(EntityType.values())
.filter(type -> type.getEntityClass() != null && Mob.class.isAssignableFrom(type.getClass()))
.toArray(EntityType[]::new);
EntityType randomMob = mobs[ThreadLocalRandom.current().nextInt(mobs.length)];
event.getBlock().getWorld().spawnEntity(event.getBlock().getLocation(), randomMob);
}
okay this isnt an error
but onBeak
id do onBlockBreak
yeah that was just for testing
ah
well i cant see anything wrong tbh
How do I generate a circle btw, and get the blocks inside it
im an idiot ok
can someone please help me
Shadow your jar.
That class isn't loaded on the server
i did
Show your full error log.
shadowJar {
relocate 'dev.dejvokep.boostedyaml', 'me.kidneybean.generalutils.shadowed'
}```
Okay, dont do that
Let me show rq
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}
Use johnrengelmans shadow
25 lines
Then, inside the build thingy
i have it
run as shadowJar
huh
How would I make a sphere, and get blocks inside it?
AKA: Place a block, make a sphere at the location, get all blocks
Math
No.. Cause I remember there was an entire function for it.
Including a square.
wait why do i see someone handling the cmd preprocess event?
iirc only #getNearbyEntities() exists and not blocks
Not what I meant.
There was an entire function to make a square or sphere.
That can get blocks inside of it.
I litterally did it before, I cant remember the name.
Thats the issue.
use worldedit api maybe
No that wasnt it.
by function you mean in spigot itself?
Yes.
there is a getRelative() that gets a block relative to the current block
this?