declaration: package: org.bukkit.util, class: BoundingBox
#help-development
1 messages · Page 1939 of 1
ty guys it worked
In confuse you can use this for developing plugins? Or you need jdk?
I ask because im helping a friend to setup intellij idea
jdk is java development kit
Oh im an idiot
and he already has that
Thanks!
np
no
define multithreading
It uses multiple threads
Chat is a thread, there’s the main thread, and several worldgen worker threads
Probably more
How come people shit on it for being single threaded? Or is that not true anymore
Probably because a lot of stuff is still on that main thread
or people they're misinformed and believe everything they read on the internet as fact ;p
Are you saying it’s not all fact
How can I push a player backwards
backwards relative to what
to player
Well, basically grab the vector from player B to A and scale it
if you want A to be knocked away from B
could someone help me out here? im trying to manually set world spawn with a /spawnset command, but the coordinates dont save whenever i try to /goToSpawn
plugin.getConfig().set("spawn.world", location.getWorld().getName());
plugin.getConfig().set("spawn.x", location.getX());
plugin.getConfig().set("spawn.y", location.getY());
plugin.getConfig().set("spawn.z", location.getZ());
plugin.getConfig().set("spawn.pitch", location.getPitch());
plugin.getConfig().set("spawn.yaw", location.getYaw());
this is my config.yml vv
==: org.bukkit.Location
world:
x:
y:
z:
pitch:
yaw:
You can just save the location directly
set("spawn", location);
Also did you call saveConfig
well then you dont need this
but im tryna figure it out the other way
i wanna set them all manually
would that be a lot more work than i think it is
lmao
why would you set them manually lmfao
cause im tryna make a home command aswell
... not understanding why that would change things lol
Is there a way to refresh the command tab list that the client sees? When I change a player's permissions it doesn't update that list until the player relogs or the /reload command is used (which obviously I won't use, but it proves that the list can be updated without relogging). Specifically this list
https://i.imgur.com/L3ymJuz.png
I've tried permissible.recalculatePermissions() but that doesn't update it
Thanks
how should I go about speeding up spawn rates of a single spawner
I don’t want to change the spawn delay because it limits the amount of spawners that can be stacked at once
How can I make a block object an itemstack?
Increase the count
wdym increase the count?
the count of what
mobs that spawn?
ok
so
i thought setting them manually would let me define them in the config.yml
im new to all this so idk much about it lmao
could you help me figure out how to save the location to the config?
or anyone really
Yes
String homeName = args[0];
plugin.getConfig().set(homeName, location);
player.sendMessage(ChatColor.GREEN + "Home: " + ChatColor.YELLOW + homeName + ChatColor.GREEN + " has been set.");```
How would I do that? Listen to the spawn event and then spawn x amount of entities?
Does the javadocs have jt
ion maybe
I'll check ig
thought I saw a thread though and it said you couldn't actually edit the property
could i save a new location into the config by doing set("location", location);
Yes
@young knoll why is this not adding anything to the config
Did ya save it
Its possible to iterate over a Stream, replace some text and them return the replaced text string (in-line function)?
Is it a stream of strings
The stream is from a map
you could do forEach
or smthing
and then map
wait
no
Can’t you just do stream.map.collect
im braindead rn
i have to go to sleep
but yeah thats what i thought, could you turn it into a data struct
and iterate over that
and then modify and replace as needed
Would work with this Map<String, String>
and then a String replace(String text) { return}
Cuz its telling me that its a void
Like this?
Map<String, String> palceholders = new HashMap<>();
String toString(String text) {
return this.placeholders.entrySet().stream().map(text::replace);
}
Probably not
Because the entryset stream won’t be a string
It’ll be Map.Entry<String, String>
But i want to do it in-line
Both because i wanna do text.replace(key, value) from placeholders and return an string (in-line)
You're probably not going to get that in-line
Take at look a this
public String toString(String input) {
return this.placeholders.entrySet().stream().reduce(input, (text, entry) -> input.replace(entry.getKey(), entry.getValue()), (s1, s2) -> input);
}```
What do you think?
Some things really just don't need to be streams lol
But would work or not?
Probably not because strings are immutable so I doubt that would work at all
but I've never used reduce so I don't know if that is a BiFunction or a BiConsumer
just use a for loop man
streams are pretty inefficient aswell
Not at least on Java 8
Yeah the idea behind streams is to make your life as a dev easier
If you spend more time worrying about how to use them
instead of using them
then you defeat the purpose of using them
Yeah im trying to do a lambda loop that replace something using key,value from map and return the string
I believe it was Sun Tzu who said “lmao streams are wack”
Omg if you see my history, you will get tired of seeing stackoverflow links
I went through all stackoverflow and did not find a garbage
I don't recall Sun Tzu saying that. Very wise of him. Very ahead of his time
That suggests you should try something else :)
I cannot develop without using lamda
How do you think people did it before streams existed? .-.
I need that meme format. When were java streams added? (March 2014), People before March 2014, Idk wtf I'm doing.
image circa March 2014
I think I started java back then
It was literally unusable
I couldn’t even make a hello world program
Using a map for this is already slow
This is about the slowest way you could possibly implement something like that
So what i can do?
How performance critical is it?
I dont understand your questions
Its for a plugin
...
That doesn't answer anything I asked
You're in #help-development of course it's for a plugin
Im trying to make a String replacer based on map key-value, for text message
I understand that
So like papi
You still did not answer either of my questions
I dont udnerstand your questions it too OP
OP?
I am just asking how often the code will be run
I feel like that's not a hard question to answer
Then assume it is very performance critical
Do the placeholders have a pattern, like are they surrounded in %% or {} or something?
Or are they just plain strings in any format?
Using the {}
Then you should use a regex for matching
I have literally this:
public Map<String, String> placeholders = new HashMap<>();
public String toString(String text) {
// I cannot figure how to return the replaced all in-line
}
Yeah the simplest way to make it fast is to use a regex to match the placeholders
That way you're not just blindly calling replace for every possible placeholder
Imagine if there are hundreds, or thousands, of placeholders registered
It would be iterating over thousands of placeholders and trying to string replace every one of them, that could be extremely slow
So you can find the placeholders in the string, then get them in the map and only replace the ones that are actually in the string
You can take it a step further using a StringBuilder if you want to
I tried with forEach() but its a void
There is a better way still
for (Entry<String, String> placeholder : placeholders.entrySet()) {
text = text.replace(placeholder.getKey(), placeholder.getValue());
}
return text;```
Is there a way, either with maven or with java, to automatically increase the version number every time you export the project?
This is the most obvious way to implement it but it is going to be very slow
I’m somewhat curious
I'd personally implement the placeholder parsing myself.
java 8 streams were literally infamously slow werent they
It's not too hard.
Oh my eyes herts
I do this: String stoString(String text) { return this.placeholders.forEach((key, value) -> text.replace(key, value)); } But its a void so i cannot return it
Im trying to do it as this in-line code
A new thing to research, exciting
How?
@young knoll can i pm you quick?
Sure why not
I mean, I could ask to pm you too if you want, but I dont know you that well...
I always wondered how papi maintained performance with 1k placeholders
I don't know if papi uses a prefix tree
But I'm pretty sure it is the optimal solution for a multi replace
My brain didn’t even think of the regex method
I literally gave you a solution
I dont support not using lambda
A bad one, but still better than what you're trying to do
Ok then have fun making a terrible solution
Oh lol?
Because this is not a good use case for lambdas and streams
Everything must be a lambda
The solution I gave you is already really slow
And your way of implementing it will be even slower
Lambdas can also increase code complexity and class file size! :)
They are a great tool in moderation, however.
Arrays.asList(“Hello World”).forEach(System.out::println)
I personally really love lambdas but there are cases where you don't use them
Stream.of(1).forEach(System::exit);
Lambdas are great 
Lambda everything
Exactly
Yeah idk why no one agree with me so
Actually I think we just discovered Lisp
EssentialsXLambda fork coming soon
They're just saying your use case for lambda's isn't right
No we like lambdas you're just using them poorly
I like lambs
thats nice coll
Oh i will definitly get around making an own api so
With the level of competence you've shown I'll steer clear of it
Im not native speaker
lmao
That too
Not English competence, code competence.
RedLib? 
VeranoLib? 
heresy
MaowLib is actually good though
Fuckin redlib isn’t even red
What's it got
See, I code stuff that's on par with the stdlib
Nothing cuz I can't think of any ideas
lol
huh
yes that's my github
Allright i will check your stream implementation
What stream implementation
I dont wanna be 30 years and dont have no more brains cuz of java
We reimplementing streams now?
I can do that 🖐️
I'm too lazy
Nice mistakes repo I learned alot
shush
Rust fan behold
Don’t let your fan get rusty
Hey Redempt
Probably a no brainer but I want to ask anyway, is a world populater the best way to generate ores
hi
if I had a nickel for every time I had been called a nerd I would probably have well over $10
Nerd
I'm glad I just made you $0.05
umm actually it was hypothetical
you calling me a nerd does not net me any additional income
Exactly
I am inside your home.
You'll have exactly 1 dime in the morning
Just write a bot to spam it over and over again. Infinite money glitch
I am raiding your pantry for caffeine and Doritos.
you will find it barren
Redempt and maow lovers confirmed?
😳
(Not clickbait)
Oh sure
kkk
Nah sorry I already have someone
🥁
You may be inside my house
So there is no lambda expression for executing a void and returning a string?
But I’m inside your brain
Walk through that logic. You are running a void method. Therefore it won't ever return anything. You could set an object that exists outside the method, but just use a method that returns a string in the first place.
@waxen plinth Now its your turn haha, do you use maven?
gradle
Would anyone be able to tell me what I am doing wrong here?
if (p.getUniqueId().toString() == "8d129761-4315-4c33-904d-19df65eb1d43") {
event.joinMessage(Component.text("Test"));
}
You could also do a UUID comparison.
if (p.getUniqueId().equals(UUID.fromString("8d129761-4315-4c33-904d-19df65eb1d43"))) {
event.joinMessage(Component.text("Test"));
}
that will also not work
== compares instances
which clearly, these two are two different instances
I found that this works which is what redempt suggested
if (Objects.equals(p.getUniqueId().toString(), "8d129761-4315-4c33-904d-19df65eb1d43")) {
event.joinMessage(Component.text("Test"));
}
== is for object comparison
How so? It would be comparing UUID objects, not strings.
okay ?
that is the entire point
comparing objects using == will not compare their contents
and then return true
it returns if the identify of the two objects are the same, e.g. they are the same instance (in the case of objects)
the reason you can use == on primitives is because they don't have the concept of identity beyond value
UUID.compareTo() wold probably work
My bad. You're right.
Hi guys I’m just wondering is the Minecraft old hurt sound still exist in the client / server or not anymore ? (The old before mc 1.2) when you fall and things like that — can the server send that packet sound or does it need a resource pack: thank you.
adding enchantment to an item with addUnsafeEnchantment(ench, n) does not work using this little bit of code I whipped up in 20 minutes java for(Enchantment enchantment : Enchantment.values()) { item.addUnsafeEnchantment(enchantment, 255); event.getEnchanter().sendMessage(enchantment + " " + itemMeta.getEnchantLevel(enchantment) + " added to " + item.getType().name()); }
it does say the enchantment is added but with level 0
I did add the enchant to the itemMeta before but it would only add a max level of 255, this doesn't even add that
I tried to add the level 32767 of every ench
nevermind I was setting the item meta still like an idiot after the for loop
still adds enchantment level 255 though, nothing more
what
for(Enchantment enchantment : Enchantment.values()) {
int level = 32767;
item.addUnsafeEnchantment(enchantment, level);
event.getEnchanter().sendMessage(enchantment + " " + item.getItemMeta().getEnchantLevel(enchantment) + " added to " + item.getType().name());
}```
This says the item has an enchantment level of 32767 but hovering over the item says 255
you check the amount of level inside the item by dumping it ig
Wasn’t the enchantment cap at 10?
for unsafe enchantment its not
Ah I see
but if you're talking about vanilla enchants, the max supported is 10 ig
in terms of mechanics
Yea didn’t know spigot has an own cap
idk why they (mc) changed it to byte
but it make sense ig when anarchy servers try to use unsafe enchantments in their lores
i somewhat managed to do what i wanted using NBTAPI. i still need to learn how to modify NBTContainers so that the entity doesnt respawn at the spot he was snatched
same goes for the unique id being the same, using the get command with a restored mob outputs no entity found message
You’ll need a resource pack i guess
Does anyone know if it's the same with the normal online Player ? (when using Player.setStatistic())
No
What do you want to do?
if enchantments are saved as bytes why does adding an unsafe enchantment with any level above 255 still have that level you added in the meta? does the enchantment still behave as powerful as a level 32767?
Resource pack
I don't think those numbers behave like they supposed to be since vanilla mechanics has its own enchantment limit unless u do ur own custom enchants with its own functions
I never understand the obsession with stupid enchantments
sharpness 500 countered with protection 500 may as well be sharpness 1 countered with protection 1
but big numbers shiny I guess
Impossible in 1.18 at least. MC wiki disagrees with you too https://minecraft.fandom.com/wiki/Enchanting
Minecraft Wiki
The glint animation applied to an enchanted iron pickaxe.
Enchanting is a mechanic that augments armor, tools, weapons, and books with one or more of a variety of "enchantments" that improve an item's existing abilities or imbue them with additional abilities and uses. A special "glint" animation appears on items that are enchanted.
'When enchanted with the /give command, the maximum enchantment level is 255[Java Edition only].'
Store entity data in a file and load it in another world, basically a way to transfer your pets between worlds without the hassle of admin commands such as world edit
what I mean is if you use ItemStack's addUnsafeEnchantment method, the item's meta stores the enchantment as a short
from the wiki
' lvl: The level of the enchantment, where 1 is level 1. Values are clamped between 0 and 255 when reading.'
return MathHelper.clamp(nbttagcompound.getInt("lvl"), (int) 0, (int) 255);
}```
client will have the same code, it can't be overriden
I see, wonder why that change was made
because stupid enchants are stupid
sharpness 500 countered with protection 500 may as well be sharpness 1 countered with protection 1
stupid enchants are stupidly fun as well
and there's no meaningful difference between say sharpness 500 and sharpness 5000
both are instant kill
you know what they say, the bigger the better
looks like limit was added in 1.15
huh, so even when it said 32k in the tool tip it was really only behaving like 255 for a while then
oh well, you're right about 255 being enough anyways
anyone got a GUI Library/Resource with Action mapping to Items. About to create my own unless someone has one.
GitHub
Contribute to FourteenBrush/MagmaBuildNetwork development by creating an account on GitHub.
That's how i did it
im not very good with inventories, is there any event for changing an item in inventories ?
dragging them in the inventory to seperate their stacks & etc ...
i want players to be able to only move items in an openned gui
and not place the items in their own inventory
i want it to be only moveable in this open gui and not player's inventory
this is what i tried and failed
May be a lil much to ask but does anyone have a working example of a block populator on 1.18?
inventoryclick event, you gotta do checks for it
just cancel them if their trying to move items against the GUI, from checking the view and holder
great
how do I make a falling block's texture another block?
I have that error message but i don't know what is wrong with my code.
[10:01:17 ERROR]: Error occurred while enabling BetterFishing v1.0 (Is it up to date?)
org.bukkit.plugin.IllegalPluginAccessException: Unable to find handler list for event org.bukkit.event.player.PlayerEvent. Static getHandlerList method required!
at org.bukkit.plugin.SimplePluginManager.getRegistrationClass(SimplePluginManager.java:724) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.registerEvents(SimplePluginManager.java:661) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at com.placek.betterfishing.BetterFishing.onEnable(BetterFishing.java:16) ~[Lowiarka.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:564) ~[paper-1.18.1.jar:git-Paper-186]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:478) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:727) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:503) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:313) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1202) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-186]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
here is my code:
package com.placek.betterfishing.Events;
import com.placek.betterfishing.CustomItems.CustomArmors;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class PlayerEvent implements Listener {
@EventHandler
public static void playerEvent(org.bukkit.event.player.PlayerEvent e) {
Player p = e.getPlayer();
if(p.getInventory().getBoots().getItemMeta().getDisplayName().equalsIgnoreCase(CustomArmors.createJumpBoots().getItemMeta().getDisplayName())) {
PotionEffect potionEffect = new PotionEffect(PotionEffectType.JUMP, 160, 1);
p.addPotionEffect(potionEffect);
}
else if(p.getInventory().getBoots().getItemMeta().getDisplayName().equalsIgnoreCase(CustomArmors.createSpeedBoots().getItemMeta().getDisplayName())) {
PotionEffect potionEffect = new PotionEffect(PotionEffectType.SPEED, 160, 1);
p.addPotionEffect(potionEffect);
}
}
}
Unable to find handler list for event org.bukkit.event.player.PlayerEvent. Static getHandlerList method required!
this will not work
what should i do?
use the right event
Do you know which event?
whats your goal?
are u making ur own event?
to check if player has speed boots and if true then give him speed 2
no
no he's using PlayerEvent
Aight
so then depends on when you want to check that, you either need the InventoryClickEvent, a timer, PlayerMoveEvent or anything in that direction
i'll try
PlayerMoveEvent, it gets triggered many times, optimize ur code for it
Hello, I have a small question, I am developing a logging plugin for my server, so I use apache poi which allows you to create excel files to make the reading easier to understand.
The problem is that when I build my plugins it can't use the apache poi classes, I have tried different ways but without result, does anyone have a solution for me?
have you shaded it?
is there a way to specify a primary key that consists of all the columns without writing all the columns
when writing a create table statement?
are you talking about sql?
yes
could you elaborate on what you mean by "consists of all the columns" not sure what you mean by that
A Panel Making Plugin with subcategories I need a GUI for custom recipes
someone know that Plugin
?
create table A (
a integer,
b integer,
c integer,
primary key (a, b, c)
);
oh a composite primary key
In my build.gradle I put in implementation.
is there a keyword or sorts to signify that the primary key consists of all columns
no, not that im aware of
implementation group: 'org.apache.poi', name:'poi', version: '5.2.0'
i've got no clue about gradle sorry
How would I make a custom villager GUI? Is that possible with spigot?
Such as hypixel bedwars shop
theres a few apis out there for that
check out villagergui api
if you want to do it without an api check out https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/MerchantRecipe.html
and
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/Merchant.html
but that requires spoofing of a villager and can get messy
declaration: package: org.bukkit.inventory, class: MerchantRecipe
declaration: package: org.bukkit.inventory, interface: Merchant
OK
What's spooof
like you have to hide the villager with trickery or use workarounds
Just open a normal chest GUI then
Guys quick question. Is there an event like PlayerDropItem but that returns the item dropped location?
If I get the item and then I use getLocation it returns the player location -.-
Hum, I see. Does it exists an event for that or do I need to wait some ticks before checking location?
I guess you could do a bukkit runnable the runs every set amount of ticks and checks if the item is grounded, and if it never gets grounded or doesn’t exist just cancel the runnable
I'm doing a runnable that runs after 5 ticks the player has dropped the item. If it meets certain conditions the item is teleported back to the player
alr cool
Hi just came to the server :)
I needed an answer that I couldn't find on google
I noticed in the Material enum that there was quite a few materials with the LEGACY prefix.
My question was why when iterating over the materials is it NOT selecting them when using the enum method .contains(String str) ?
Here a bit more context, I had a ArrayList<Material> sourceMaterials list that I was using to select materials with LOG in them using a for loop and if statements.
for (Material material : Material.values())
{
String matName = material.name(); // convenience variable
if (matName.contains("LOG")) // FILTER: log types
sourceMaterials.add(material);
else if (matName.contains("STEM"))
if (matName.contains("WARPED") || matName.contains("CRIMSON")) // FILTER: stem types
sourceMaterials.add(material);
}
I got concerned when I saw all those LEGACY materials that I'd have the rework my selection code but it turns out the for loop doesn't even detect the LEGACY materials and on my IDE they appear as dashed over?? here's a screenshot: https://prnt.sc/26q3l8f
Can someone explain this to me?
I only started java about 4 days ago and spigot yesterday so I'm a bit confused there
It's a weird hacky workaround with a library called ASM. So long as your plugin declares api-version in the plugin.yml, those constants don't even exist at runtime for your plugin
You can disregard them, really
It's so that plugins from pre-1.13 can work with the new 1.13 Material names (because a large chunk of them were renamed), but Bukkit tries its best to keep forwards compatibility
alright thanks for the clear answer
if I understand correctly those LEGACY values basically aren't even in the enum when the plugin runs at startup?
Pretty much, yeah. A plugin compiled against 1.12... for example referring to Material.WATCH, would then be ASM'd to refer to LEGACY_WATCH on a 1.13 server and mapped to CLOCK
for 1.18
Though for 1.13+ callers, they're not included in things like values(), valueOf(), or matchMaterial()
Don't refer to these constants at all in source either. Really, just pretend they don't exist ;p
ASM?
It's a library that allows bytecode manipulation at runtime
oh is that similar as bit manipulation stuff for c++
because I still haven't really touched that subject yet
I still have a lot to learn
Probably not quite the same. Java is compiled down to bytecode which is understood by the JVM. It's how things run
bytecode manipulation is very complex and in most cases you won't ever use it
^
alright
In my 8 years, I've never used it
anyway thanks for the help, nice to see the community is active
o/
Hello does anyone know this kind of plugin ?
Oh
i cannot send
It's related to enchant thingy
oh
here
The line thingy
can someone help me ?
also the enchants what's the name
are you asking how to do that or what plugin?
idk what the plugin is but its just a custom lore for the item
like how to code it?
you just get the item meta and set the lore
it's not a lore i think
it is
are you french?
.
Hi
How to create itemstack of custom color concrete powder?
Can someone help pls
Google your question before asking it:
https://www.google.com/
You could probably find it there
Oh
is there is any event associated with killing mobs
EntityDamagedByEntityEvent
its an unicode symbol
How do i set it? Does it need plugin?
Block Elements is a Unicode block containing square block symbols of various fill and shading. Used along with block elements are box-drawing characters, shade characters, and terminal graphic characters. These can be used for filling regions of the screen and portraying drop shadows. Its block name in Unicode 1.0 was Blocks.
yes it does
np
thx
I want to move a group of blocks simultaneously as if they have velocity
I imagine having an entity for each would cause lag is it posibble to do this with resource packs or soemthing
no. how many blocks?
uninstall the minecraft plugin
then it'll work
How i generate 50 chunk around player
say 100
set the server's view distance to 7 and it will automatically generate 50 chunks
ahh thank
this stupid plugin is totally broken. whenever you have intellij problems, just uninstall it and now everything will work automagically lol
hm that's not really very much. if the server can't handle 100 entities, RIP
I don't see any other way then to summon falling blocks or similar things
Hi, how can I get the player entity using a varable?
what?
which player?
I am making a tpbow plugin
@EventHandler
public void onBowShoot(EntityShootBowEvent event) {
}
use event.getEntity()
check if the entity is player then cast it to player
ok thanks
tyyyy
How can I make the player teleport to the point where the arrow falls?
there's something like ProjectileHitEvent or similar
then just get the arrow's location and TP the player there
okay thanks
but how can I have the player entity and have access to player.sendMessage?
you have to store it somewhere
for example:
oh wait, doesn't Arrow have a method like getShooter?
ProjectileHitEvent
you realize that getEntity returns the arrow?
it works
Projectile.getShooter() returns a projectilesource. Check if that is instanceof Player, then cast it. Now you have the shooting player
that does NOT work
it will throw a ClassCastException because you are trying to cast a Projectile to a player
^
i didnt understand xd
I've done this for now:
public void onBowShoot(EntityShootBowEvent event) {
if(event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
}
}
but I got stuck for a while because I don't know how to continue ahaha
?
ok
done
yes
what I wanted to do was: "when the player shoots the arrow, teleport him to the point where it falls".
the entity is the shooter
how can i do that
in EntityShoowBotEvent yes, in ProjectileHitEvent, no
isnt there a projectile hit event
yes. something like this. but of course don't blindly cast to player in the first line - check if it's actually a player beforehand
yeah you had BowShootEvent first bro
Location location = event.getEntity().getLocation(); dont work
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
cannot resolve simbol "location"
import it?
and make sure its uppercase Location
yes it is
ah ok then it should work now right
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
people keep laughing about the "Does not working" sentence
but that's actually what most people write, see here lol
"no working" is also common
yes
I'm a maven maven
lmao
("maven" means expert)
show your pom.xml pls
?paste
I am not working
which .jar is imported locally?
locally = <scope>system</scope> ?
please
- paste your pom.xml
- dm me the api .jar
and 3. tell me which package it can't find
?help
*Red V3*
**__Admin:__**
selfrole Add or remove a selfrole from yourself.
**__Cleanup:__**
cleanup Base command for deleting messages.
**__Core:__**
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
**__Downloader:__**
findcog Find which cog a command comes from.
**__Mod:__**
names Show previous names and nicknames of a member.
userinfo Show information about a member.
**__ModLog:__**
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
**__Permissions:__**
permissions Command permission management tools.
**__Trivia:__**
trivia Start trivia session on the specified category.
Type ?help <command> for more info on a command. You can also type ?help <category> for more info on a category.
It just wont work
?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!
what is the event name for projectiles being fired also how do i know what kind of projectile it is?
making custom projectile trails
so i would need to summon ittems and clear them need help with that too\
hmm i want to make a new itemstack is dust by bukkit coding but i want to when i place and break it it will drop an item stack how to do this
check for the block to be broken and placed in x amount of time then summon a item stack
or give it to the player
?pdc
but when doing this every block same id when break it will drop that
i only want for this block ;-;
EntityShoowBowEvent i guess
to know what kind of projectile it is: instanceof Arrow, instanceof Trident, etc
you need my library CustomBlockData
what if i want eggs
entity shoot event?
go to the fridge
lmao
ProjectileLaunchEvent or sth
thankyousomuch
alr tysm
np & np 🙂
is ther a way to make a class for event handlers
do you know how to use maven?
just to make the code clean
yes
Asynchronous tasks should never access any API in Bukkit. Great care should be taken to assure the thread-safety of asynchronous tasks.
is there a workaround for this
true
not really good with multithreading
yes. doing stuff synced
like the way u can create commands in a diff class can u do the same with events?
i dont wanna lag main thread
sure, why not?
hmm
what are you trying to do?
and at this
PersistentDataContainer customBlockData = new CustomBlockData(block, plugin);
is the block is itemstack?
im lazy ill do it in my next prject my main class is so ugly
im looping through every player, and doing other stuff every 20 ticks
no, no. the block is the block you have placed, to store information about what it should drop when being broken
im looking to do this without affecting performance
how would that create lag?!
you can loop over all players hundred times per tick without any problem
o
the server itself loops over EVERY ENTITY EVERY TICK
ok fine then
and it also does way more other things every tick
do you have a guide for install maven? i search on google but i don't understand ;-;
one sec
so um, i need to check if a text is a command (any command), since I have a configuration section for commands to execute and if a command that is inserted isn't a valid command it sends Unknown command. Type "/help" for help. in console, and I'd like to avoid that
listen to this https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerCommandPreprocessEvent.html
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
then cancel it if it's one of your commands
wdym
and do your stuff
add commands: in plugin.yml
what didnt you understand?
I don't need to check my commands
i need to check if its a non valid command
such as passing "hello world" as a command in the configuration
is there anyway for add maven for esclipes?
commands:
- say hi # valid
- hello world # invalid
```how can i check if a command is invalid
yes
u don't understand
there was a plugin for it
what don't i understand exactly
@rough drift u don't have args sub command
Yes?
then
this works right?
only add one lettle not 2
oh god... that is in the config.yml, its command to be specified to run at certain times
like edit say hi to sayhi
oh
can u show ur plugin.yml?
why... would i need?
My commands work, i need to check if commands inputted by the user are valid commands the console could do
such as /say or /gamemode
those are valid
yup
but /thisisanonexistingcommand aint
oh i think u need a someone better than me 😄
well thanks for trying to help :D
can you give me a guide please
also yes, you can use maven on eclipse
there was a plugin for it
lemme find it for ya
because i am not good at config file XD
ok thank you
is there a plugin that disable elytra?
pretty sure there are ones that exist if u google it
you need to confirm your profile to post images
just make one, not that difficult if u try
a plugin to provide a webpage with those stats ?
List<String> emojiList = Config.getStringList("emojis");
for (String i : emojiList) {
List<String> list = List.of(i.split("\\|"));
String replacement = list.get(0);
String syntax = list.get(1);
String noColorSyntax = "!" + syntax;
String permission = list.get(2);
if (requirePermission &&
(!p.hasPermission("server.chat.emoji." + permission) && !p.hasPermission("server.chat.emoji.*"))) {
continue;
}
str = str
.replaceAll(noColorSyntax, ChatColor.stripColor(Misc.colouredNoEmoji(replacement + "&f")))
.replaceAll(syntax, Misc.colouredNoEmoji(replacement));
}
return str;
``` how can i make this more efficient
yeah or what's the name of this ?
i don`t know how to cod
welll... idk who the hell knows every page and every plugin in the world O.o
not a reason to try
for disabling elytra and you dont know how to code java you can take a look at the skript thing that exist
skript is not recommended on live servers
no just the name of this systeme it's an uptime checker or downtimer checker ?
no its not recommended if you are using it for something except small things
like idk a playtime command or /gmc commands
I guess if he knows what he's doing, worth a try
hello guys, I want to create a custom potion which makes the player double jump, how can I do so?
place a block when player tried to jump in the air while he has the potion effect (could be either through pdc with some effects)
I have an alt idea, whenever the player tries to double jump the PlayerToggleFlightEvent (iirc thats what it is called) is called and then I can track if the player has the effect and if he does I can give him a lil boost
so I need to learn how to
- Check if the player has my custom effect
- Give the player a lil boost
Might be a stupid question, but how would I actually check if a player has an inventory currently open?
Player#getOpenInventory never returns null, so does InventoryView#getTopInventory and InventoryView#getBottomInventory never returns null either...
The boost is just velocity. PlayerToggleFlightEvent is only going to be called if the player has setAllowFlight set to true, which does carry with it some important side effects, like no fall damage
is there is any good libraries to make custom enchants easier
private void groundUpdate (Player player) {
Location location = player.getPlayer ().getLocation ();
location = location.subtract (0, 1, 0);
Block block = location.getBlock ();
if (!block.getType ().isSolid ()) return;
player.setAllowFlight (true);
}
@EventHandler (priority = EventPriority.HIGH)
public void onPlayerJoin (PlayerJoinEvent event) {
this.groundUpdate (event.getPlayer ());
}
@EventHandler (priority = EventPriority.HIGH)
public void onPlayerDamage (EntityDamageEvent event) {
if (event.getEntityType () != EntityType.PLAYER) return;
if (event.getCause () != EntityDamageEvent.DamageCause.FALL) return;
event.setCancelled (true);
}
@EventHandler (priority = EventPriority.HIGH)
public void onPlayerMove (PlayerMoveEvent event) {
if (event.getPlayer ().getAllowFlight ()) return;
this.groundUpdate (event.getPlayer ());
}
@EventHandler (priority = EventPriority.HIGH)
public void onPlayerToggleFlight (PlayerToggleFlightEvent event) {
if (event.getPlayer ().getGameMode () == GameMode.CREATIVE || event.getPlayer ().getGameMode () == GameMode.SPECTATOR) return;
event.setCancelled (true);
event.getPlayer ().setAllowFlight (false);
event.getPlayer ().setVelocity (event.getPlayer ().getLocation ().getDirection ().multiply (1.6d).setY (1.0d));
}
DOUBLE JUMP
Bro
yea?
Have you done your daily prayers yet?
Why?
It's the daily prayers, it should be done daily obviously
bruh
Yes
H O W
Trying to make an EnumMap with Material as key and ArrayList<String> as value
tried this but it's telling me it can't resolve the constructor and I can't see why
EnumMap<Material, ArrayList<String>> recipesMap = new EnumMap<Material, ArrayList<String>>();
any idea?
you need to pass the enum key class to the constructor afaik
https://hatebin.com/psbwrfqctq
I run this class everytime a player dies using the PlayerDeathEvent, when it gets triggered the server lags a lot and I immediately or eventually get a ticking world exception and the server crashes (I’m using Mojang mappings)
I mean, the other is just generic argument specification
not really passing anything
Ohhh
yea no worries then 😅
thought you had some experience as you are using an enum map
yeah I know C++, did a bit a C, python and some other
I'm still not used to EVERYTHING being classes lol
it's also super fun because it's the first time I actually make a development project
These past few years it's only been learning, learning and learning...
without even applying what I had learnt to a real project
Hello guys I want to make a custom potion, how can I do so, I want to make a potion which gives u ability to double jump (I have the double jump worked out) but dunno how to do the tracking if playuer has the potion effect
You would need to keep track of it yourself, you can't add your own potion effects
oo
You can do that with a map like coll said
Thanks
You could also use a scoreboard tag or pdc
Both of those would be persistent, not sure if you need that
Nah i can use a HashMap for it, dont need any permanent storage
Hey I was trying to build a Minecraft plugin and used the Minecraft Coding Plugin template for Spigot and I don't know how to implement the main class in "src/main/me.cit.PluginLoader". In Manifest.mf it says "Invalid main class"
is there a way to get players nearby a player in a specific area
?jd
I want to get players in the 3x3 area where the player is in the center
declaration: package: org.bukkit.entity, interface: Entity
so
There’s one that even accepts a filter iirc
how am I supposed to use it in my case? not sure
Player#getNearbyEntities(1.5,1.5,1.5)?
4.5, 4.5, 4.5?
The numbers are radius iirc
?
You dont need a Manifest file for spigot plugins. Could you send a link to this "Minecraft Coding Plugin template"?
What plugin template are you using?!
There is a command map that contains all commands. It however is not exposed. This means
you either need CraftBukkit or reflections to access it.
(Paper)
It's the Minecraft Dev Plugin for intellij and chose spigot there
I see. Have you worked with a dependency manager before?
Then the mc dev plugin i not for you
Wait what you mean by dependency manager
maven/gradle
Ah yeah I made it in maven
How do you compile it?
Building it with the artifact I made so I get the .jar file
So you just ignore maven and everything in the pom.xml
Dont use maven if you dont have quite a bit of experience with plain Java.
Here is a guide on how to build a spigot plugin from scratch without maven/gradle:
https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-intellij-idea/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@lost matrix its an intellij plugin, they just choose "spigot plugin" and it generates everything for them, then all you do is go to maven -> LifeCycle -> package
I was so stupid that I built the plugin to .jar with an artifact and didn't remember I can do the same thing in maven lol
But I think my console is still saying that "can't find main class"
can you send the built jar file
I know. But he should not use mc dev without prior maven experience.
That’s the issue
Exactly
Don’t use a tool which simplifies processes for you if you don’t know the process
Usually when the main class can't be found it's a plugin.yml issue
fair
Thanks for helping :D
however if they want to make plugins only they should focus on learning plugins then maven imo
I had wrong file in plugin.yml
How to give the player 40 hearts for 10 minutes?
ig give them a health boost effect lmfao
By giving them 40 hearts for 10 minutes
LOOKS LIKE THE FLOOR HERE IS MADE OUT OF FLOOR
Nah its made out of health boost
yeah use health boost effect
and how do I turn it off after 10 minutes?
By giving them 10 minutes of the effect?
oh
forgot
NOW I KNOW WHY U GUYS WERE TALKING LIKE THT
i thought u couldnt specify time
Hi i have register a custom enchant but i have only the glow effetc on the item, is there any way to display the new enchant in enchant vanilla list ? or did i need to handle this by myself with lore ?
manually
hmmmm
custom enchantments are unsupported
do I come here for help on essentials not hooking into my project?
'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
public class CustomMob extends EntityZombie {
public CustomMob(Location loc) {
super(EntityTypes.be, ((CraftWorld) loc.getWorld()).getHandle());
this.b(loc.getX(), loc.getY(), loc.getZ());
}
}
that version doesn't exist on the repo anymore I believe (bstats 1.8)
is there a way to check if a player is "still" mining a block?
PlayerInteractEvent fires when a player starts mining
BlockBreakEvent is called when it's done
but if they keep pressing the mouse button...
you MUST use mojang mappings
yes
So theres no fix for it sadly?
right?
sorry pls repeat your question
Do not understand it. I'll search on it
I was replying to someone else
read the blog post pls
whoops sorry
thanks but I need it to work without packets
hm
Store a hashmap of players when playerinteractevent is sent, on blockbreakevent or on cancel remove the player from the hashmap
and when they leave also remove them
yeah but that won't help
why not?
but we dont know how to detect cancel
okay wait I'll try to explain what I need it for
at least without packets
yeah that might be best xD
so tl;dr
my plugin switches to the proper tool when attempting to mine a block
it should switch back to the previous when a player is finished with mining
uhhhhhh
if I just switch back on blockbreakevent but they are still mining, I'm fucked
why cant you use packets
well I COULD and it would be the last resort
lemme think, because i know there is something to detect it
but I'd love to do it without
because I don't want to have protocollib as dependency
i think it might be the only option
you technically dont have to
yeah sure, it'd be just "either install protocollib or not have that feature"
register a channel listener to the netty channel pipeline
its easy ish
and have no idea about how netty works
lemme send you the code for it
that would be nice
ike make sure to tag him cuz hes in #bot-commands lmao
ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object obj) throws Exception {
// Obj is your packet, you need NMS to get the packet list
super.channelRead(ctx, obj); // Remove to cancel the packet
}
};
((CraftPlayer)player).getHandle().playerConnection.networkManager.channel.pipeline().addBefore("packet_handler", "your_handler_name", channelDuplexHandler);
```On Join ^
```java
Channel channel = ((CraftPlayer)player).getHandle().playerConnection.networkManager.channel;
channel.eventLoop().submit(() -> {
channel.pipeline().remove("your_handler_name");
});
```On Leave ^
IIRC its that
@tender shard
Also I have a question, how'd you put hyperlinks in your signature? (so not https://website.com but Website)
signature?
Am i seeing bootleg protocollib?
oh on spigotmc
You are seeing the most epic of protocol handling in action
awesome, thanks!
np
what signature?
the thing in the spigot forums
under your post
there's a DISCORD image with some other links
isn't there a button to add links?
Yeah but for me they always appear as full links
There is only one external plugin in use for my projects. And that protocollib. I think its well written.
I just click on the one right of the A
if that doesn't work, click on the "wrench" symbol and use BBCode
e.g. my signature is this:
[CENTER]Author of [URL='https://www.mfnalex.de']ChestSort, AngelChest and other open source 1.13+ plugins[/URL].
Check out my development resources: [URL='https://www.spigotmc.org/threads/powerful-update-checker-with-only-one-line-of-code.500010/']UpdateChecker [/URL]- [URL='https://www.spigotmc.org/threads/custom-block-data-store-any-information-in-blocks-without-databases-or-files.512422/']CustomBlockData[/URL]
[URL='https://discord.jeff-media.de'][IMG]https://api.jeff-media.de/img/discord1.png[/IMG] [/URL]
[/CENTER]
np
yay it works
now show it to us
i can't post pics xD
