#help-development
1 messages · Page 1647 of 1
how do I check which hand the item was clicked into?
context?
how can i check, if a button was pressed by an arrow?
Hm. Depends a bit on what you are trying to do. ProjectileHitEvent and BlockRedstoneEvent are both fired there.
Hmmm okay. I want players to shoot a target and hit a button in the process.
And then do what? You dont need a plugin for players to hit a button.
How do you spawn elder guardian laser particle?
Thats a bit complicated. Not sure if there is an API way of doing it now but last time ive done it, it involved a ton of packet sending.
Thx
Hey, I would like to clear an empty glass bottle if dropped in the PlayerDropItemEvent
But so far the only way I got this working is by caching the entityId of the itemDrop and to cancel it's spawn in the EntitySpawnEvent but i'm pretty sure I could avoid using the EntitySpawnEvent
(I got nothing working properly in the PlayerDropItemEvent, setting the item to air, canceling the event...) any ideas ? 🙂
getItemDrop().setItemStack(emptyBottleItemStack)
does anyone knows if worldguard lets region members do all the things by default?
String kits = "";
for(String key : plugin.getConfig().getConfigurationSection("Kits..").getKeys(true)){
kits += plugin.getConfig().getString("Kits.") + " , ";
}
p.sendMessage(ChatColor.GOLD + "HERESY " + ChatColor.GRAY +"| kits: " + ChatColor.YELLOW + kits);
This is iterating through my config file and im trying to make it get the KIT.* path , my config file is here , i want it to get the "PVP" from the Kits path
PVP:
armour:```
I dont want it on the floor, I would like to kind of disappear instead of dropping
getItemDrop().remove();
👍 ur the man, working well thanks
does someone have a good gen script for me? to make a gen server?
What is a gen server? And thats probably one for: #help-server
can i dm u?
.
nevermind , i got it
im very slow my bad
final String[] kitNames = plugin.getConfig().getConfigurationSection("Kits").getKeys(false).toArray(new String[0]);
final String kitListString = Arrays.toString(kitNames);
player.sendMessage(ChatColor.GOLD + "HERESY " + ChatColor.GRAY + "| kits: " + ChatColor.YELLOW + kitListString);
You can also just post here 😄 more ppl can help you this way
are minecraft bans by name or by uuid?
uuid
changes name, gets banned

hmm
so
can i get an Entity object from id
cause i need to be able to persist after a restart
or do i delete it and start again
ok… so can i do it with uuids?
You can get an Entity by its UUID if it is currently loaded.
If its in an unloaded chunk then not,.
You cant get an unloaded entity in the first place
You should save on ChunkUnloadEvent and load on ChunkLoadEvent
wait - i mean if i have an entity that i am teleporting down a line in a certain direction and then there is no player nearby - what happens
Why i can't set spawn with simplespawn plugin?
[5:19 PM] Secret_Rojs: i can't /setspawn
[5:19 PM] Secret_Rojs: i'm on version 1.16.5
it'll unload at some point
Hey guys, i was doing some research on physics events, and found something weird.
There are some physics events being triggered by DIRT, and they are affecting STONE, next to them.
I went to the place of the physics event and ther is flowing water above the dirt that triggered the event, which probably moved during chunk generation/load, but the dirt block shouldn't have triggered anything in my opinion.
Anyone know what causes this akward physics events?
Do you think this might be a spigot bug?
ps: went to the java docs and the description was:
"Thrown when a block physics check is called. "
myeah - but will it throw an error or just do nothing
this may be a try it and see moment
Hey,
I have a problem with MongoDB,
I cannot save information, however I do manage to retrieve it
Anyone know where this came from?
public Document getDocument(String databaseName, String name) {
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.append("pseudo", name);
return this.getOther(databaseName).find(searchQuery).first();
}
Error: ```
Caused by: java.lang.IllegalArgumentException: Invalid BSON field name pseudo
at org.bson.AbstractBsonWriter.writeName(AbstractBsonWriter.java:532)
at com.mongodb.internal.connection.BsonWriterDecorator.writeName(BsonWriterDecorator.java:193)
at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:211)
at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:154)
at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
at com.mongodb.operation.BulkWriteBatch$WriteRequestEncoder.encode(BulkWriteBatch.java:403)
at com.mongodb.operation.BulkWriteBatch$WriteRequestEncoder.encode(BulkWriteBatch.java:375)
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63)
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29)
at com.mongodb.internal.connection.BsonWriterHelper.writeDocument(BsonWriterHelper.java:77)
at com.mongodb.internal.connection.BsonWriterHelper.writePayload(BsonWriterHelper.java:59)
at com.mongodb.internal.connection.CommandMessage.encodeMessageBodyWithMetadata(CommandMessage.java:147)
at com.mongodb.internal.connection.RequestMessage.encode(RequestMessage.java:138)
at com.mongodb.internal.connection.CommandMessage.encode(CommandMessage.java:61)
at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:247)
at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99)
at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:450)
at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:72)
at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:226)
at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:269)
at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:131)
at com.mongodb.operation.MixedBulkWriteOperation.executeCommand(MixedBulkWriteOperation.java:435)
at com.mongodb.operation.MixedBulkWriteOperation.executeBulkWriteBatch(MixedBulkWriteOperation.java:261)
at com.mongodb.operation.MixedBulkWriteOperation.access$700(MixedBulkWriteOperation.java:72)
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:205)
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:196)
at com.mongodb.operation.OperationHelper.withReleasableConnection(OperationHelper.java:501)
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:196)
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:71)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:216)
at com.mongodb.client.internal.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:1053)
at com.mongodb.client.internal.MongoCollectionImpl.executeUpdate(MongoCollectionImpl.java:1037)
at com.mongodb.client.internal.MongoCollectionImpl.updateOne(MongoCollectionImpl.java:622)
at com.mongodb.client.internal.MongoCollectionImpl.updateOne(MongoCollectionImpl.java:617)
reeeeeeeeeeeeeeeeeeeeeeeeeeee
I dont understand how so many libs manage to get such a huge stacktrace depth
my assumption here is that you forgot to register a field
ok i go test it ^^
?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.
Thats not a problem regarding java fundamentals.
And you should not use a ODM unless you have worked with the database and fully understand how it works.
Does anyone know the crackshot plugin? what is the energy projectile? is it #getTargetBlock?
what ?
Morphia is a object document mapper. It reduces a lot of boilerplate when working with mongodb but it can screw you over really really fast if you dont
fully understand the implications of it regarding mongodb.
Ohh, okay
pff worldguard goes brr
how can i set a specific gamerule in a specific dimension
// Get your world by some means
final World world = Bukkit.getWorlds().get(0);
// Apply a GameRule to it
world.setGameRule(GameRule.FALL_DAMAGE, false);
how did you guess my gamerule
and uh, how do i change the dimension
what do i change from the final thing?
index 0 is the main world
index 1 is the nether
index 2 is the end
every index above that are custom worlds loaded by a plugin
Sure. Or you write a method like this to set a gamerule in all default worlds:
public static <T> void setGameRuleInAllDefaultWorlds(final GameRule<T> gameRule, final T value) {
final List<World> loadedWorlds = Bukkit.getWorlds();
for (int index = 0; index < Math.min(3, loadedWorlds.size()); index++) {
final World world = loadedWorlds.get(index);
world.setGameRule(gameRule, value);
}
}
ty man/woman/other <3
7smile is a woman
ok
Triggered. I identify as a vintage military compass from the soviet union.
oi im so sorry for misgendering you
7smile, what do i need to do to disable it in all worlds with first method
this seems not to work
public static <T> void setGameRuleInAllWorlds(final GameRule<T> gameRule, final T value) {
for (final World world : Bukkit.getWorlds()) {
world.setGameRule(gameRule, value);
}
}

🙄
uh oh, someones getting angry at me for asking :(
thats not a good sign
ik spoonfeeding isnt good, stop screaming at me 🙄
how do I get then entity the player is looking at?
What version?
1.17
Ray trace in the players direction
hm ok
Example:
Player player = ...; // Get player from somewhere
World world = player.getWorld();
Location start = player.getEyeLocation();
Vector direction = start.getDirection();
double distance = 5;
Predicate<Entity> filter = entity -> !entity.getUniqueId().equals(player.getUniqueId());
RayTraceResult rayTraceResult = world.rayTraceEntities(start, direction, distance, filter);
if (rayTraceResult == null) {
// No hit
return;
}
Entity hitEntity = rayTraceResult.getHitEntity();
if (hitEntity == null) {
// No hit
return;
}
// Use entity here
why if (rayTraceResult == null) {
// No hit
return;
}
cant you do if (rayTraceResult == null) return;
is there any way to check for an entity (ender pearl) which is still alive (not hitted a object yet) thrown/summoned by a player at the current time?
I'm looking for a friendly method
.-.
Idm really
5*
so im playing a particle effect
Clean code principle. Thats why
but it plays on the blocks corner every time
block.getWorld().spawnParticle(Particle.DRIP_WATER, block.getX(), block.getY(), block.getZ(), 10);
depends
this just spawns 10 water droplets in the corner
if you would go for the CCP you would have to format your code too
and for now its just a giant block
Not for the specifications ive read. Always use code blocks.
what one did you read?
Eg Clean Code by Bob Martin
also there are no real specifications. there are just recommendations to make your code cleaner
wdym lmao
how is wasting lines making code clean
2Hex shut. you cant even jump in this discussion
You dont waste lines your are solidifying your scopes
yes but this is common sense
i dont need to be great at java to know that
Not like one or the other gives runtime benefits
Clean Code by Robert C. Martin Series f.e. recommends to seperate your code so its not just a giant block
the scope is defined and visualized by the brackets
aaaa
particle no work
How would i place them randomly in the block
but maybe its just your own code guidelines
So you have to use brackets on every 1 line or what
and everyone has their own
Cause Random doesnt let you set a maxDouble
and mine seems to be annoying. ask @opal juniper lmao
no. im doing the exact opposite
I do. Thats what all the companies specified ive worked with and thats how i clearly separate my scopes.
o
ok then ill use your style
I also always use brackets
but just doing oneliners without brackets if its not connected to anything f.e. try catch, if else
Especially inlining everything into a single line will result in some code gore - not a fan of that
nerd
you really should develop your own style
and not just switching every 2 weeks because some people do it otherwise
tbh
2hex the only reason when I would not use squiggly brackets even if I can would be a lambda expression, turning it to a lambda body would certainly add more verbosity.
at some point ill change everything about how i code
wait wtf
wdym verbosity
Many words
o
if (condition) {
// OP
}
``` - readable most of the time
```java
if (condition)
// OP
``` - mostly readable
```java
if (condition) // OP
``` - unreadable for large ops
```java
if (condition) {/* OP */}
``` - if you really need to streamline things
i only use the 3rd way for return; and stuff
tbh ill just do what i find good
all that bs is confusing
For instance
ThreadLocalRandom.current().ints()
.filter(i -> i % 2 == 0)
.mapToLong(i -> i*3)
.peek(System.in::println)
.count()
This would be a lot more verbose if we would use lambda bodies for the lambda expressions.
Yall should really make a development discussion channel
while(condition) {
// OP
break;
}
- really strange shit
...
whst
why would u even need that
continue
Hi, i just made automatic dependecy injection api for my purpose.
it works greate and make development time a way shorter. I wonder why
this desing pattern is not so popluar in spigot community. Can someone
told me disadvantage of using it?
java doesn't have a GOTO outside of bytecode, so sometimes you will need to improvise
Magic is prone to breaking
it’s true guys - this dude is a code control freak
perfectionist af
It's incredibly useful actually
The break keyword that is
Sometimes it makes more sense to do a while-true with a conditional break than a while with a proper condition
think he was referring to the non-repeating while loop
i.e. a glorified if statement
^
do { } while (false)
Better than commenting out your code block 👍
do {}while(false) is basically {}
r/ProgrammerHumor: Dedicated to humor and jokes relating to programmers and programming.
this
amp, yikes
sorry am on mobile
im trying to get the block a dispenser is facing, but this throws ```java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_8_R3.block.CraftDispenser cannot be cast to class org.bukkit.material.Dispenser (org.bukkit.craftbukkit.v1_8_R3.block.CraftDispenser and org.bukkit.material.Dispenser are in unnamed module of loader java.net.URLClassLoader @37a71e93)
```java
e.getBlock().getRelative(((org.bukkit.material.Dispenser) e.getBlock().getState()).getFacing())
any ideas?
Don't do that
Do this
BlockData data = block.getBlockData();
Directional d = (Directional) data;
BlockFace face = d.getFacing();```
Make sure you import the Directional in the right place
org.bukkit.block.data.Directional
Not org.bukkit.material.Directional
i dont have blockdata :/
im on 1.8.8
bruh
i dunno why people actually use super.onDisable()
Well then cast to the other Dispenser
because they don't realise it doesn't actually disable the plugin
Not the one in the material package
The one in the block package
org.bukkit.block.Dispenser I think
tried that
that doesnt have the getFacing
hey dude how i update crazy crates plugin
what is difference between Class<?> type and Class type ?
One is generified
The other is not
They're more or less the same but the left one won't give warnings
But you should always parameterize classes that have type parameters
ye i have notice that
Javac will shout at you for latter
But it will work even in pre-generics java (which you will unlikely use)
lmao
“don’t touch my code it’s beautiful”
yeah and then some guy named ollie comes in and "fuck it, just want it to work" it
that does sound like me
"just want it to work" is such a bad mindset
Your goal isn't to get your code to work
i feel like i have been taken out of context
"refactoring it later" - quits - "hey gtg, you'll do that"
I did get a patch into forgeflower that had the "just want it to work" mindset active
I take RedLib plugs as payment
That's because you're using DRIPPING_WATER
Use FALLING_WATER for immediate gravity
I am shouting
Enums are just very assertive variables
i do refactor later - it’s just i had a vacation smh and no laptop
i read that as gut lmao
Alternatively, use Github's editor and edit one file per commit at a time
this godcipher dude sees a large method and is like
“this needs to be split into at least 5 sub methods immediately”
it is… lemme have a look
big bren
thats the spirit
you can get the full version for free since you're a student
e
can u give me an example of submethods?
it does diff of code from the camera???
looks ok tbh
but i probs won’t bother cause i’m home soon anyways
it's great if you're one of those weirdos who use ipads for some reason
ipads always seem handy but for their price there are better things
i was thinking about swapping my pc for a laptop and a thunderbolt gpu dock but those things are expensive af
laptops are way better than u expect
theyre reallllly useful
u can take them wherevent u want
if you're going to do that then whats the point since you're going to be tethered to a desk by the gpu dock anyway
i mean - the gpu would only be for like if i was at home wanting to play games
you have a pc for that
swapping
yeah
public void fatMethodLikeYourMo() {
fuckThis()
doThat()
dontForgetAboutThat()
}
get a gaming laptop
what
so i have a laptop that i can take idk yeah probably
instead of blowing your money on a gpu dock
yeah i use interfaces only
yeah well i will now
is it sarcasm
but like i was naïve and unaware of the price
no
i think you blew their mind godcipher
thats what a god is supposed to do

exactly
so u wanted them to make sub methods so theyre organized or wat
submethods
Is there a public repository for spigot compiled including the net. minecraft package?
no
splitting your large method into several smaller private methods
o
NMS is ARR
look up "Extract Method refactoring pattern" @grim ice
Rehosting it would be illegal in most countries
ok
oh, i used water_splash thank you tho
oo
when do i do that tho
like at what amount of lines
if it gets too complicated to read and understand like a book
Can i have a int in a config, and also allow people to set it to false?
int.. to false?
well yea
Like could i check if its a boolean first
And if it isnt, check if its an int?
thats easy
I personally extract instruction sets into proper methods only when I find (or expect) that I actually rewrite parts of the code. I would say that a method size limit would be pretty arbitrary here
if(!plugin.getConfig().getBoolean("lolol"){
// do smth if its false (remove ! to check if its true)
if(plugin.getConfig().getInt("lolol") == 10) {
// do something
}
if a boolean is not true or false it will return false
so like if there is a number in like lolol: 69
it will return false
but if its not a boolean wouldnt it give me an error?
i just said
if its not a boolean it will return false
I think im just gonna add a enabled in the config
if(!plugin.getConfig().getString("lolol").equals("false"){
// its false
}
if(plugin.getConfig().getInt("lolol") == 10) {
// do something (its an int)
}
U’re trolling right
getString("lolol").equals("false")
Yes i know i can use a boolean
I currently have the issue that a integral part of my config.yml isn't getting created even though it is in the config.yml template in the IntelliJ Project. Any Ideas what the issue could be
Well
use isSet then and getBoolean == Boolean.FALSE
yeah thats one too
If i update my plugin to work on a newer version, which number would i edit in terms of semantic versioning? (Current plugin version is 1.3.1)
my solution is still good if he doesnt have anything better :3
How does the config look and what method are you using to copy it
What does the "newer version" include?
getConfig().options().copyDefaults();
saveDefaultConfig();```
Changing the spigot version in the pom.xml from 1.16.4 to 1.17
Feels like a patch version for me
if u want new config updates to roll out
without deleting the config.yml from ur plugins folder
and restarting the server
I did delete the config.yml and it still happens
I deleted the whole testserver and it still happens
I saved it for sure, since IntelliJ Auto-Saves and compiled it multiple times and made sure that i used the new jar
check if the config is correctly formatted
The weird thing is that it appeared in the config.yml earlier, I didn't change anything about it and for some goddamn reason it suddenly doesn't work anymore
hi i just make piano plugin and have trouble with raycasting piano keys. There is some option to create custom hitbox?
My exact reation
Now, play music on it
all is base on armorstand but they are too close to eachother to detect colistion
it would be cool
wait thelooter what build tool do you use? Was it the copying from jar to data folder that doesn't work?
So i guess yeah copying from the Jar to the Datafolder
so how to create custom hitbox?
BUT HOW IN THE FUCK DID U DO THAT WITHOUT RESOURCE PACKS LOL
idk but its possible i saw it on a server
its with texture pack
o
ye
but how did u do that? do u know a tutorial for that
what excatly i created custom 3d models in blockbench and then place them at the armorstand
do u know a tutorial for that tho
nope there is not
rip
i can record something for you
hmm what if you call it in reverse order?
https://www.spigotmc.org/resources/⚡-jw_piano-⚡.89857/ here is current version of that plugin but it generate piano from block :_
Let me try
o
Hello guys, is there the way to use TextComponent with HEX-colored messages besides using ChatColor.of(#xxxxxx)?
im so sad this only has 200 downloads
well there is not much people interested in piano and MIDI
and this plugin is mostly useless
That actually fixed it thank you
Would it be bad practice to have multiple of the same listener but for different things?
Like multiple BlockGrowEvent in the same class. But with different code inside
aight
Usually you want to have one listener per plugin per type. Listeners are only used as a link between minecraft and your code.
If possible you should listen for the event once and pass it to other classes that need it.
Example:
public record GUIListener(GUIManager manager) implements Listener {
@EventHandler
public void onClick(final InventoryClickEvent event) {
this.manager.handleEvent(event);
}
@EventHandler
public void onClose(final InventoryCloseEvent event) {
this.manager.handleEvent(event);
}
}
what is benefit of using records?
It just reduces a bit of boilerplate. There are also some implications regarding the memory structure but thats secondary.
ok thanks
That's not the sort of thing I would have thought to make a record
It also seems kind of pointless to just wrap those events
Yeah records are usually just for pure data classes. Was just an example.
And this perfectly makes sense because you want separation of concerns. And this listener just listens and does nothing else.
You could have multiple manager classes to which you pass your events.
It probably is in two different instances
Hey can someone show me why my HashMap is empty eventhough I have added to it https://pastebin.com/RLMucLZ7
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
how do you know that it is empty?
what is the .toString() implementation of your HashMap?
hm
where is cpa coming from?
apparently AbstractMap implements an interesting toString method. Can't complain
HashMap<Player, ColourProcessor.Colours> inCaptchaA = cpa.getInCaptchaA(); what is cpa?
forgot to copy that bit https://pastebin.com/SpNk2amZ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
do you ever insert anything to the map?
so where do you add a player to cpa?
You only use containsKey, but not put or something like that
the constructor is called on a PlayerJoinEvent
you can;t call the contsructor on an already created object
Change CaptchaA cpa = new CaptchaA(); to final CaptchaA cpa = new CaptchaA();
change the public Captcha(Player p) to a method
that would prevent my first suspicion
Yeah, doesn't make a difference.
is your Join event in your InventoryListener class?
I'm so close to recommend the forbidden keyword
volatile? transient?
no, strictfp
goto 😄

That one is doubley-forbidden
no
Then you are not putting players into cpa
cpa is a field within your InventoryListener class
Ahh ok, yeah sorry
Two different instances
why is there no armor equip event?
yes
There should be
Not in Spigot
theres not
Doesn't Inventory click event solve it?
theres more to it that that
lots more
you can get it equipped from dispensors
yea, mobs
hotbar
I see
like, interacting with armorstands, hotbar, drag/drop, shift click
theres a pr for it?
there is a branch
?stash
how to make dropped items at a player feet
To make them pickable you simply reduce the pickup cooldown to 0
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerPickupItemEvent.html
cancel this? or does this void the item
declaration: package: org.bukkit.event.player, class: PlayerPickupItemEvent
To make them not pickable increase the pickup cooldown to 4452414
You can also cancel the event but the server will keep spamming it forever in that case
I don't speak 200 lines per message
Hey so since we were speaking of missing API...
I've got component-based chat, action bars, item lore (via NMS sadly) - is there spigot API for sending component-based titles?
doubt
report it
update it
You can delete it after you've uploaded a new one
probably update it and upload a new jar
don't need to report it, I think, there's a delete button in the Version history tab
but you can't delete the most recent version .. for some reason
^
it’s so that there is always one version
Where
Hmm so its all on one instance by I keep getting java.lang.StackOverflowError errors
ohno
when trying to access the HashMap
what kind of witchcraft did you do now?
How can I add premium plugins to spigot?
how do i get access to the stash?
sign the CLA, somewhere
?cla
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Hey, Im trying to make a staff that launches you into the direction youre looking in. Its working pretty well but Im missing the part where I remove the "NoFallDMG" Tag from the player who used it. Im running into issues because theres a good possibility that the player doesnt take falldamage I can negate when they have the tag and they could just save the tag for later by not taking fall damage after using the item.
Cannot resolve method 'runTaskLater(me.powerbutton.kaboom.Kaboom, <lambda expression>, boolean, int)' yo guys why
That means you are calling something thats calling itself.
private CaptchaA() {}
public static CaptchaA getInstance() {
return CAPTCHA_A_INSTANCE;
}```
Bukkit.getScheduler().runTaskLater(Kaboom.getInstance(), () -> Bukkit.getWorlds().get(2), world.setGameRule(GameRule.FALL_DAMAGE, false), 1310);
Personally I solve this by also having a time limit on the fall prot
(so if they don't take fall damage in, say, 20 seconds it won't apply)
How can I upload premium plugins?
could you also paste the stack overflow?
not by asking more than twice in 3 minutes
Yeah, you are creating a new instance of itself in the field so its a repeating loop
I also ran into problems by using scheduledelayedTask for removing
How so?
currently I have a timer that runs all the time that ticks every 6 seconds to check wether the player is standing on a block or not...
its static final and the ctor doesnt refeer to it
His captch_a_instance is a field inside CaptchaA
Hm I just put some data on the player that says when their fall prot expires (a timestamp), then in the damage event if it's not yet expired I cancel the damage. No timers required.
🥺
👉 👈
is this something?
Your lambda expression makes no sense
instead of
#help-server message
Im currently doing my first plugin and havent seen all the methods yet. sorry if Im asking too many questions, but how would I put such a stamp on a player?
You probably meant to use () -> Bukkit.getWorlds().get(2).setGameRule(GameRule.FALL_DAMAGE, false ...
() -> Bukkit.getWorlds().get(2) would be a Supplier<World> but it expects a Runnable
just use getNearbyEntities
ty
?paste your whole class
and/or the stacktrace
Well that is a great question - myself and I think most plugins make a separate class to store our custom player data, then have like a Map<UUID, PlayerData> (or maybe WeakHashMap<Player..>)
But there is the persistent metadata api now, you could probably store it directly on the player with that:
The API is a little intimidating TBH but it's actually not hard to use
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
I ment ty to you
how would i go about creating an entity lets say pig with specific properties
you should probably not use the PDC to store player data like that
World
(proud to have PR'd that method! 😄 )
nms
example:
depends on which properties
for some property altering you dont need nms, for others you do
I will try reading my way through it, thank you very much 😄
well it works... so it probably exists
?pdc
ooooooo perfect 😄
might make your life a bit easier than the javadocs
PDC is a bit complicated
Im guessing the location class is imported?
Importing the loc class has no effect here
If you don't have an entity to work with as the center of the query, you have to use World (loc.getWorld()) then pass the location back in.
There maybe should be a method on Location but there is not
or that
You could use getNearbyEntites and filter out all non-living entities
There is an easier way afaik
Use the Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z, @Nullable Predicate<Entity> filter) one
too many parameters, shutting down
lmao
Which would be e -> e instanceof LivingEntity
it’s fairly obvious what is what
is there some kind of (mostly) sane way to have a Map<String[], String> implementation where as the key object can be discarded/uncached after the put operation? I have the issue that the get operation returns null if I use a new string array (even if it has the same contents) however it returns the expected data if I reuse the instance
what does this mean for the people living under the rock?
😳
I don't think I've ever tried using an array as a map key but that feels like kind of a strange pattern TBH - I think List has hashCode and equals and so might work better
Use a wrapper class for your String[] and implement a hash method
The issue is that I'm calling the get method ~500k times per second
Then use a Object2ObjectCustomOpenHashMap from Fastutils and implement your own key hash method
yea, that's what I have been thinking about using
I'm trying to cancel the event when a player tramples a crop, and when a farmland dries, is that even possible?
playerinteractevent
phyisical interaction
and as for farmland drying you might be able to use BlockFadeEvent but im not sure on that
Is there a Material. for farmland?
damn
^
thanks guys
no problem
🙃
is there an inverse of PluginManager#registerEvents? To unregister listeners or clear listeners for a plugin?
yes
yes
yes
yes
yes
well i shall help you out of misery and tell you, you should check out the HandlerList class 🙃
spoil sport
thx got it! I feel like a beginner now
I love how 5 people across the globe just sat at their PC laughing at everyone saying "yes"
well technically thats what he asked for :)
Yes
is unregistering event by event the closest to this
so if a block underground is mined, its replaced by cave air?
use == to compare a Material, but if the block is air it could be AIR or Cave Air, it all depends on worldgen
I guess Ill just stick with my complicated setup then
so you are telling me i need to actively think about this from now on
or just use .isEmpty() i guess
Can use isAir
I still don't get why they added cave air but it's probably for some weird mechanic I'm unfamiliar with
bats maybe?
Nah
maybe they feed on it
Bats are 1.4
xD
Don't think they've been touched since
same
It's something 1.13
I was gonna write something but then self control kicked in
that would be a rare case of me being right, so it cant be that. keep thinking.
maybe just something they are planning on doing?
why over engineer when you can just add a different type of air
It causes its own problems and is a very hacky solution
i.e. what if a player digs their own cave
It's more useful during worldgen
How do they use it?
hey is there another way to register event method. I need to make method 'onPluginStartEvent' private but because of that Spigot can't register it
there isnt really a confirmed use, but i think its only generated when the world is created in caves and some of the structures
Why must it be private?
Yeah I was wondering what the purpose of it was
yea i have wondered as well
no to be overridden in class that will be inherit EventBase
You want it impossible to override or just not overridden by default?
i mean to make sure that someone accidentalny not override it
final will do that
public final function
Oe protected final
Idk if protected works with events tho
Nice it works thank you 😄
:)
protected should not work with events
How do I add an external API to Intellij. I added it as a library but when I build my plugin with maven, I got this error: package (a package, example: package.package.package) does not exist
add it to the pom
yeah i know that but h o w
<dependency>
<groupId>javax.sql</groupId>
<artifactId>jdbc-stdext</artifactId>
<version>2.0</version>
<scope>system</scope>
<systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>
i found this on googogol
but idk how to use it
normally the api will give you what you need
it doesnt
Are you sure that it isn't hosted on some maven repo?
link?
maven sucks for having local deps
use redlib
👀
they have an armour change event iirc
<systemPath>${java.home}/lib/rt.jar</systemPath> actualy, wth
Yeah PlayerChangedArmorEvent
why do you want to add the rt.jar
I am summoned whenever anyone says redlib lol
If the event is all you need I wouldn't recommend using RedLib for just that though
true
Since it'd be a plugin dependency for just one event
Feel free to copy the code for it though
u can use jitpack to use github projects are libraries @grim ice
bro
Just please credit me if you use my code 🙂
Yeah every tick
myeah, i mean there is no better way to do it ig
so thats it?
until the branch gets merged
i just click maven and do what they tell me?
yup
@waxen plinth woulnt it be better to use multiple other events to determine armor changes?
Nope
he didnt compile it
That's impossible
why not
Because other plugins can edit a player's armor
Without sending events
For example, /clear
Checking every tick is the only way to be sure
yea you are right
Could not find artifact com.github.Arnuh:ArmorEquipEvent:pom:Tag in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
@tall dragon
lmaoooo
did you add the jitpack repo?
no
@grim ice did you add the repo
yes
Also, replace Tag with the correct version
yea
ok
the plugin wont work?
is it broke?
or what jer of java do i need it to run on?
is it 1.17
but i will investigate thx for report bug
wait i just removed the old one it works now i think
go to private chat
@grim ice that should indeed work
@gleaming grove you'd have to implement your own raycasting algorithm
- Vanilla raycast to see if the piano is blocked
- Custom raycast against nearby pianos with max distance equal to the vanilla raycast's distance before hitting a block
If you don't care for perfect accuracy you can just step along the ray and do AABB tests (assuming your piano is orthogonally snapped)
First check against AABB covering all keys and then check whick key you hit based on the sideways position
how can i set the text of a sign and the facing of the wall_sign? (spigot 1.8)
For now i made sth like this. Player shoot ray towards keys and getting closest key to ray destination
@dense goblet what do you think of this?
Why cant you just use the exact hit block of the players ray trace?
becasue there are no blocks
Search in old forum posts. 1.8 support was dropped ages ago.
Ah i see
only armorstand that are too close to eachother
This looks like you should use the position + angle of the player to calculate what key the player is looking at
wow... that helps me a lot -_-
Using ancient software is your choice 🤷
you maybe know some one good with python
or any one here good with that language
Ive had a python course last semester.
- What do you need
- Why tf python?
my friend has problem I think building project with it
and I am looking for some one to help with her problem
xd
you want to run python code by spigot plugin?
no not me
but this is the case?
this is let me show u
nothing to do with spigot plugin
she got school project and follows this turorial
so make ask this question on Python discord?
well I am for long her
so asked if some one is good maybe with python
u get it
but yeah
will look in to that
Can you format this error in a readable way pls? This looks more like a c++ error of a backing library than a python error
what stretch window
give me a few men it is on my friend need to wait for them
holy macaroni
Hi everyone. I'm currently in the works of coming up with a functional design definition for a future plugin. I was looking for some kind of guide/resource that outlines how test-driven development could be applied to Spigot plugins. I found this: https://bukkit.org/threads/how-to-unit-test-your-plugin-with-example-project.23569/ using the Mockito and JUnit, but this guide is over 10 years old at this point.
Is anyone aware of any other resources and/or libraries that might be more Minecraft plugin specific for test-driven development?
Alright... for super small projects I don't think it makes a ton of sense to unit test a project, but for some bigger ones it can be very helpful....
oi listen up fellas, I need the name of the common "pling" sound yeah?
note block bell?
int x = 5;
ItemStack item = new ItemStack(Material.STICK, x);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Test");
ArrayList<String> lore = new ArrayList();
lore.add("123");
meta.setLore(lore);
player.getInventory().addItem(item);
When I run this, all i get in my inventory is a stick with no lore and the display name is still stick. Also note that item.hasItemMeta() returns false
that's proll it mate, cheers.
It is really hard to do true test driven development in spigot because you need to mock actual live objects like Entities, Blocks, Worlds and players for full coverage.
There is one project that started implementing all spigot interfaces with mock objects but even this is quite limited.
oh yeah i renamed some of the variables jusst to make it look nicer
mb sorry
You need to set the meta back on the ItemStack
Oh cool, thanks for the info!
how do i do that do i use
Bukkit.getItemFactory().getItemMeta(item.getType()); ?
no just ItemStack#setItemMeta
No. You just set the ItemMeta back on the ItemStack
this
I have been writing plugins for about a year for fun and have been looking something just like this. I'm an enterprise java dev irl ( 😦 ), but I'm going to be doing a ground up development with Agile and want to see how realistic the methodology is with TDD 🙂
this might sound dumb but why do you say ItemStack#setItemMeta with "#" insted "."
Go away with your agile. Next thing you come up with are spigot plugins for jira and kanban boards 
that's how javadoc function notation works
if you write javadoc and want to reference a function
you use Class#FunctionName
I love kanban! My current client uses it!
Yeah. The concept is nice but too many companies are doing some weird stuff and calling it "agile" even when its not. So im
a bit sceptical at first every time i hear that word ^^
Hey everyone, I’m trying to make methods that return data from servers on the BungeeCord network (using plugin messages), but got stuck on this part... Does anyone know how can I make the method halt until the other server responds with the information?
If you make the method halt then your server will just crash
Or at least lag out
You need to use delegation to react on async responses. I just wrote an example for someone 2 days ago. Let me see if i still have it.
Here is an example:
https://gist.github.com/Flo0/98db6edc1fc77ed4b8eeeb80f2c91282
Thanks, I'll try that
I cant use EntityVillager or CraftWorld , i heard i need to use buildtools but what do i have to do to get these
You need to use the artifactID "spigot" instead of "spigot-api" in your pom
After you ran BuildTools once
?stash
and where do i find my "pom"
Pom.xml
Do you use maven?
Its created when you make a maven project
no i don't use maven
What are you using
That's the thing , i dont know what the fuck i am using
Um
its confusing me and i have been trying to see for an hour
Well
Then you don;t need Craft anything
First learn Java, then how to make a basic plugin
i know basic java and how to make a basic plugin
ill search into it more then
If you dont use maven then you have access to craftbukkit and NMS right away
Personally i use gradle
Is Magical crops your plugin?
no
Anyways. Update to java 11
ok 🙂
or 16
Reminder: Its quicker to use int x = 3, y = 2, z = 5
Quicker than what?
int x = 3; int y = 2; int z = 5;
it does
it doesnt matter the way you declare them
its not interpreted
its a constant value at runtime
a = 1, b = 3, c = 9
no matter the way you declare these, theyll end up as 0s and 1s
how change player inventory without send packets?
Just... add/remove itemstacks
yea but without send packet to player
Use protocollib to listen for outgoing packets and intercept them
But you know that this will lead to ghost items and weird behavior?
but that's not the point
Then what do you want
I don't want to create these packages
If you don't want to intercept packets then fork spigot and remove the packet from being sent
Trust me this is not worth it
oke
Yep, it takes the most recent
Yeah I agree with you. I'll be doing user stories and sprints, etc for my plugin which is exciting
is there some event triggering after player press F to switch item between hands?
Yes there is! Lemme check the plugin that I have that uses it.
Yup that's it lol
thx guys
np
in my spigot plugin how do i access kits that were made with essentials?
I need help with names, I am trying to select a block, melon block for example, I used MELON and LEGACY_MELON_BLOCK, both don't work and when I do MELON_BLOCK, it gives an error... How do I do this?
Same with wheat
and mushroom blocks
Cannot resolve symbol 'MELON_BLOCK'
lemme check
yes
title:
1: "\xa77/cb editline"
enabled: true``` ( the 1 is suppose to be the hasgmap value)
and it stores that weird thingty
instead of the string
@sly trout thats an unicode character isnt it
@sinful egret https://prnt.sc/1qcq9i0
What does that mean?
❤️
I'm coding in 1.8 btw
1.8 for warriors
is that?
only og are on 1.8
neither do I lmao
what happened Bram?
^
that is the issue
@fervent gate "MELON_BLOCK" doesnt exist for you in the Material class?
It does not
that is the main problem
how
using maven?
what do I do wrong?
show pom
Where is that?
are you using maven


