#help-development
1 messages Β· Page 2223 of 1
since all plugins are loaded from the same place
I think your only problematic ones which are rare to see, are ones that are not actually plugins
and are strictly API's
yeah, and jar file name should be easy enough to find I guess
if you have a plugin that extends PluginBase I think it is, spigot will not attempt to load any classes from it π
yeah, I have my own PluginBase class that extends JavaPlugin
but those are really rare to see since most people who make API plugins really don't make use of that as they should lol
mainly because they don't know they can do that lol
I'm working on my own plugin library in Kotlin, and I try to solve as much of the repetitive stuff within the library π
anyways, hopefully you find a work around for your problem. At least you came out with a greater understanding then you did before instead of just still not knowing what it is going on π
yeah, that is true! thanks for confirming that for me π
Alternatively, if anyone knows how to make a projectile pass through solid blocks, let me know.
What's a way to separate items from one another? I would assume their name but it's not working. I have a Listener that waits for the arrow to hit something then it would TP me to the arrow location. That's the Teleport Bow.
But,
I have another bow called the Lightning Bow, As you'd assume it summons Lighting onto the arrow striking it. But that bow blinds me and slows like the Teleport one does.
They all have different names, which is how I was setting up the listeners. could the be conflicting with eachother?
@zenith gate post listener code here plz
wait wrong
if (e.getEntity().getShooter() instanceof Player p) {
ItemStack itemInMainHand = p.getInventory().getItemInMainHand();
if (itemInMainHand.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GOLD + "Lightning Bow")) {
Location location = e.getEntity().getLocation();
p.getWorld().strikeLightning(location);
p.playSound(p, Sound.ENTITY_LIGHTNING_BOLT_THUNDER, 1.0f, 1.0f);
}
}
Use the PDC instead.
?pdc
Alrighty thanks.
ugh dont remind me
i need to change all my metadata to PDCs
Someone let me know if you figure out how to give a vex's properties to a snowball. I just want to make it so some projectiles pass through solids Dx
how do people create lists in configs that are prefixed with a -
Example?
You mean like
thing:
- "value1"
- "value2"
?
wurdd
like it is prob possible, you can have the vex invisible with no ai, then launch the vex with the same velocity as the snowball, then make the snowball tp to the vex's location every tick, and make it so the snowball only breaks things when it hits an entity
Or⦠just set the snowball as a passenger.
can you have snowballs as passengers?
But that may not even work.
I mean, you can put players on arrows. I donβt see why it wouldnβt be possible for other entities/projectiles to also be the passenger.
look the docs just say a passenger is an entity so I think it might be possible
The issue is, if it's a passenger, then it is just wholely noncollidable.
I'd be interested in having it collide ONLY with entities, and not blocks.
for some reason my java decompiler canβt decompile the getTarget function in the Zombie class
which other decompilers can I try? I need to figure out how to tell if the entity can reach a particular location or not
well are you looking at Zombie or CraftZombie?
because Zombie is an interface and CraftZombie is the implementation
but even so you still might not find setTarget in the CraftZombie class because it could be a default method
you often won't see a method that a class offers defined explicitly in the class due to inheritance
I have figured out the part of being able to shoot the snowball and it pass through walls, however it uses vex's physics and gravity so it is more like a straight shooting spectral shot. It doesn't include the collision detection but it should be to hard to add a check to see if the snowball has another entity in a small radius then hitting that entity and removing the vex and snowball @EventHandler public void onShoot(ProjectileLaunchEvent e){ Projectile pro = e.getEntity(); if(pro.getShooter() instanceof Player && e.getEntity().getType() == EntityType.SNOWBALL){ Vex vex = (Vex) pro.getWorld().spawnEntity(pro.getLocation(), EntityType.VEX); vex.setAware(false); vex.addPassenger(pro); vex.setVelocity(pro.getVelocity()); vex.setInvisible(true); vex.getEquipment().clear(); } }
or you could kill the vex which would cause the snowball to behave normally and hit the entity
You can try #getNearbyEntities while the projectile is in mid air
By doing a repeating task
To check for entity collision
yea i was just seeing if the spectral snowball was possible
everything else shouldnt be too hard to figure out
Once it hits an entity u can cancel the task
ok nvm scrap that
Spectral like once it hits it gives glow?
I'm trying to look at the getTarget method in NearestAttackableTargetGoal
this is the method I need but my decompiler can't figure it out π
I really need to figure out how to tell if a position is reachable
well spectral as in can go through objects, forgot that the term is used in mc for something completely different
Yeah I thought it was like spectral arrow
howw
in every case the mob knows where to go
even though the villager on the right is closer to the zombie, the zombie goes to the villager to the left because it can actually reach that one
i'm trying to implement the same thing but I have no idea how
Can someone help make a free plugin
final ItemStack result = new ItemStack(Material.DIRT);
final ItemStack ingredient = new ItemStack(Material.DIAMOND);
final StonecuttingRecipe recipe = new StonecuttingRecipe(new NamespacedKey(this, "testing"), result, new RecipeChoice.ExactChoice(ingredient));
Bukkit.addRecipe(recipe);
Anyone have an idea why this recipe doesn't work in-game?
running that in my onEnable for testing purposes and the recipe doesn't work in-game in a stonecutter.
Can someone help make a free plugin
bump
You should speak to 7smile7 when they are about (its 7am over there at the moment). They messed around with path finding a lot a while back
well if its 7am there im gonna be sleeping when they're awake rip
10:30pm here
you think its fine if i ping them rn so they can respond later
7smile7 is usually around in another 5 hours
yeah ill be sleeping in 5 hours
They are not online at the moment so a ping would be fine
alright
@lost matrix I have heard you have the knowledge to answer this sorry for the ping
I've created a custom path finder goal to make horses drink water from the nearest water source
problem is the horse cant tell if it can actually reach the water source
so it ends up hugging the wall with the water on the other side until it dies of thirst, even though there's an available water source 10 blocks in the other direction
level.getNearestPlayer
level.getNearestEntity
That goal is for finding an entity to attack, not pathing
here's what I've got right now:
https://mystb.in/RevelationHealthForbes.java
https://mystb.in/WannaIndiansTired.java
the horse is trying to go for a water source not an entity
oh wait
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
yes but the method you were trying to decompile isn't for that
nvm i didnt see what u were replying to my bad
it looks like the entity is smart when pathfinding to other entities
but not to blockpos's
@wild marten what i can do
is use a bukkitrunnable which repeatedly gets previous locations of the balls and does a raytrace
for collision detectio
detection
how to get any player that has not logged on to your server before?
query Mojang
what is it
only if u let me open source it and let me host it on spigot
i think OfflinePlayer has a method that checks if theyve logged on before
not sure
that
yeah
how do i remove this warning?
Not annotated parameter overrides @NotNull parameter
Its giving on onCommand interface
add org.jetbrains:annotations:23.0.0 to your pom or gradle build file
then let quick fix do the work
okay
where do I add it tho
dependency
kk
you need to create your own pathfinding mesh
and then with said mesh, iterate their intended path and look to see if their path is blocked by 2 blocks above
if it is, tell the horse to go to the other water source instead
what is a pathfinding mesh
sry im really tired i think ima sleep rn and get back to this tomorrow
there is different kinds
mesh is another way of saying matrix, but matrix isn't really an accurate term to use since a mesh is generally malleable
you can use BFS or DFS for this problem of yours
BFS is breadth first search and DFS is Depth first search
then you have Dijkstra and then A* which basically builds on Dijkstra. Then you also have random walk or also known as walktrap
each one is good at doing something π
navmesh is another good one
D* can be used too but most freelancers are unaware of it
?paste
useful if your route can vary over time
This was a pathing algorithm I wrote and was playing with https://paste.md-5.net/yenemuhaka.java
I never put it into use but it gives you an example
this looks something similar to DFS
it is, a tree search
@ornate patio pinging you so you know where to come back to read π
Just a note, run it async
Iβve saved the message link thanks
I want to make command to auto complete /command target2 /command target1 target2. I'm confused
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
Bukkit.getLogger().info(notPlayer);
return null;
}
if (args.length == 1) {
List<String> playerNames = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
playerNames.add(player.getName());
}
return playerNames;
}
else if (args.length == 2) {
List<String> playerNames = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
playerNames.add(player.getName());
}
return playerNames;
}
return null;
}
if (args.length == 0) {
player.sendMessage(IridiumColorAPI.process(prefix + notCorrect.replace("%command%", label)));
return false;
}
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
first of all
it already does player names by default
so if ur gonna autoccomplete player names, just return null or something
That error does not come from that code. You never access args
Okay nvm, then how to check if there's only one argument or two? i used args.length but it works only for two-argument command if i check for arg.length == 1 it returns false
well arg.length == 1 will only be true if there is /command <somethinghere>
if u have /command <something> <something> else, arg.length will be 2
and not 1
Why is the Racing plugin not public ;w;
I really need it
welp i just assigned target before the if nvm
are u trying to autocomplete player names?
if so just return null, because the server does that by defualt
unless you've disabled that
i doubt servers actually turn that off
Love you ;)
What would yours do that others don't already?
nice to know
Hi there, I come with a question. Overall I'm doing a plugin and I'm having a little problem with it. I would like to change the color of the player's nickname only above his head and I don't know how to do it. If anyone could help by sending an API or showing the code how to do it, I would be very grateful
says ur a likely spammer
use scoreboard teams
if u wanna set player x name green, u get all players, get their scoreboard, create a team, add x to the team, and then set the team color to green
Can any one give me java Learning resources
?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.
?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.
rekt
ez
how do I make a reload config command?
BukkitRunnable.
just use super.getTaskId
or this.getTaskId
doesnt matter
but the method is getTaskId
you dont need to do super right
nah
make a command that does plugin.reloadConfig();
I did but nothing happens
Well, but I want to make some people see the player's nickname in green and others in red
Oh yeah, I thought the opposite.
do u save your config values to variables
use packets then
Sorry.
uh okay
send certain scoreboard team packets to one player, and other packets to another player
well make sure each player has their own scoreboard
oh
which they should already
no I dont
Thats just Teams
well your'e fine
by values u mean in YAML ?
What am I supposed to do now?
i personally would use packets for nametags and use the player scoreboard for sidebar
no i mean like in ur code do u have any variables/feilds that store config values
Why does it keep saying this guy is a spammer?
no
well you're fine
then what should I do
maybe account got hacked
my old account got hacked and someone used it for botting people
inviting them to servers
if u set the team color for a player x in player y's scoreboard, player y alone will see that color for player x if player y is the only player with that scoreboard
and it said that for me
just call plugin.reloadConfig
he got reported few times probably
ah
just don't know how to use it and would love to find out here
I'm pretty sure I already did that, I didnt call plugin tho because I'm using it on my main class
what u should do is use a bukkit runnable
when u schedule with the scheduler, it returns the task id as well
well use this.reloadConfig
Wdym "it returns the task id as well".
wait i just re read what u wrote, do you mean it doenst work
yes
int taskId = Scheduler#scheculeSyncDelayedTask(stuff);
?paste your code
okay gimme a sec
You even semplified my code, love you so much.
np
doesnt a bukkit runnable return a BukkitTask?
ye
should use that
do you see the config reloaded message?
yes
can i see where u use your config then?
like?
where you do getConfig.getStuff
reading/writing to config
oh
@Override
public void onEnable() {
Metrics metrics = new Metrics(this, 15492);
// Plugin startup logic
Bukkit.getLogger().info("[MOD] MeltedOresDrop Enabled");
saveDefaultConfig();
new OreBreak(this);
new BlockBreak(this);
}```
Actually I need to repeat 4 times the scheduling of a task delayed for each time of the loop, then in one of those task, I might need to cancel the following scheduled.
Actually IntelliJ sucks.
u can use bukkit task
I'm kinda confused what that means xD I get those in my events using the getPlugin
u do BukkitTask task = new BukkitRunnable.schedule();
But I didnt do getConfig
then task.cancel
so if you're not using your config, what;s the point in reloading it?
Maybe is better, I'll give a try.
Ohhh
doesnt matter
damn! I'm dumb Wait
bukkit task is just more convenienrt
String tool = plugin.getConfig().getString("Breaking-tool");```
you can use the int to get the BukkitTask
I use like this in my events class
can you please paste the entire class?
yes sure wait
oh thanks! will it work now?
here instead of just doing orebreak
make an orebreak variable in your main class
something like this
I see okay, I'm still learning so I was practicing by making this plugin
and make a getter
so in your command class, you do plugin.getOreBreak.loadValuesFromConfig
there is a better way of doing this tho
making a class that has all the config values in it, and let the other classes get the values from that class
ah well I'm a beginner lol so I want to keep it as simple for now
for now u can do the first way
so in u command class after reloadconfig
you do plugin.getOreBreak.loadValuesFromConfig
the changes i made to orebreak, you'll have to make similar changes to other classes that read from the config
?tryandsee
okay
yes why is your command MANAGER a command itself?
huh??
pretty sure u have to do bukkitCommand.register(commandMap)
if that doesnt fix it, you may have to put the command into the knownCommands map yourself
Sorry if it is in a wrong channel but i want to help with maven.
I have a system where I active a "install" lifecycle and this will build and upload it trough FTP, now i want to create a own lifecycle or if profile is active. Is it possible ?
#JavaPlugin.getLogger() would return plugin's logger which has plugin's name always appended as a prefix to the specified message
yes I know that
whats the arg to get jdocs from buildtools again?
--generate-docs
thanks
im asking that every single time
well just do --help once π
I wasn;t fast, you were like molasses
but
I didnt know it myself
and had to check it first
and then I not only attached a fancy screenshot, no
I had to open my build script to copy/paste π
I also selected the argument in question
it would be nice if it did actually make the jar the help says it will
correction, they should really add the --remapped flag to the spigotmc blog
im aware theres one arg thats not in the buildtools list there
but i always forget which one
quite a few IIRC
hey
i am getting this error
https://pastecord.com/ovaqokocyw.cs this is my full code
public void onBlockBreak(BlockBreakEvent event, LivingEntity livingEntity, PotionEffect potionEffect)
ig here something wrong
but dunno what
event handlers only take the event they're calling as arg iirc
you cant pass them extra args
a listener method can only take exactly one Event as argument
since they have a set structure
I mean, how would spigot even know what to pass as livingEntity or as potionEffect?
Youl cannot just add new parameters and expect spigot to know what to pass there lol
then what to do?
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
I'd suggest grabbing the block PDC library and storing the entity in that
and what about livingEntity?
neither I, nor spigot knows what living entity you expect there
^
so what living entity is that supposed to be?
if you mean the entity that broke the block theres a method in event for that
PDC?
persistent data container
why do you need NMS for that?
the one which are spawn
like see
here i want to do this
no entity will be spawned in a blockbreakevent
especially not a living one
unless he's talking about silverfish
when player break a block then random mod will spawn(even blocks)
oh yeah, true
can't you intercept right clicks and use vector math to see where on the sign you clicked
and i want to add potion effects on only living entity which are spawned
this is getting confusing. you should take a look at a basic java tutorial @west crag
?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.
ik java
;-;
you don't. you have added new parameters to your event listener just because, idk. The error message clearly explained that this won't work and you didn't understand that.
if there's one thing i learned about spigot is that the only thing it wont register are right/left clicking with an empty hand at nothing
ie air
you can definitively grab a right click on a sign
and lastly, I still wonder where you expected this magic livingEntity and potionEffect object to come from
you cannot just add parameters to your method signature and expect that some black magic will pass exactly the objects you were looking for
anyone has a coding idea?
a sign input GUI lib without NMS
hey, i have that error when i start the server, anyone knows why?
mojang screwed up id say
it looks like mojang auth servers are down
only does that to this server
are all other servers you tried cracked?
nope
check if you block outwards request
then idk
if anyone has an idea, tell me !
π³ he divulged me
check which port mc servers use for auth requests, then unblock outwards port in your firewall settings
why is this not working? it only reaches the second if
Id use .equals :)
;-;
which knowing java how i did completed my project?
check if the key exists
@EventHandler
public void onShoot(EntityShootBowEvent e) {
if (itemConsumed.isSimilar(TestArrow.getInstance().arrows.diamond)) {
arrow.getPersistentDataContainer().set(TestArrow.getInstance().getKey(), PersistentDataType.STRING, "ARROW");
}
}
}
making a circle in an inventory maybe?
making circles with squares? that is always fun
theres a much simpler solution
what is wrong with it, is that there is a maximum size an inventory can be, thus making your code inefficient since the dynamics are just not there really
just hard code the three/six possible circle numbers
my thought exactly
doing anything but addition is an 'expensive' computation
so hard coding it might add what
1 kb
for doing it 90% faster
well in this case, there is really no reason for dynamic code since its not like the inventory sizes are just going to be some arbitrary size lol
its literally a list of how far it's shifted, and limitations for where that list can start
for example
the starting slot of a size 6 circle in a double chest
must be a) modulo 9 between 0 and 3 (inclusive)
and b) lower than 3
first is so that the circle isnt split
second so that it is fully present
for 5 numbers would be 0,4 and lower than 13
moterius is on a role here in proving why dynamic code isn't efficient in this case π
also i worked a lot with trigonometry back in school
hi, is there a better way to do this?
private Rank convertToRank(RankType rankType) {
switch (rankType) {
case OWNER:
return ranks[0];
case ADMIN:
return ranks[1];
case MODERATOR:
return ranks[2];
case HELPER:
return ranks[3];
case MVP:
return ranks[4];
case VIP:
return ranks[5];
default:
return ranks[6];
}
}```
unless you have a rank->number in another place i dont think so
switch is the best option for 'multiple ifs on same condition'
so there isn't a way?
there is always another way
just not a better one
well you could use the ordinal
you can pull a yanderedev ofc
you could also use a linkedlist or even a normal list as long as you have a way to guarantee the ordering
'ordinal'?
I do
return ranks[number(rank)] then
yep
so that is 2 other ways that are probably just as efficient
but the switch method is just as good though
so really down to preference or what they are comfortable with
return ranks[rankType.ordinal()];
what is this?
what ordinal() method do
look at what elgar linked
its the index of the enum
enum{ BLUE, RED}
blue = 0
red = 1
oh nice
show us RankType
yea
public enum RankType {
OWNER, ADMIN, MODERATOR, HELPER, MVP, VIP, DEFAULT
}```
the only downsides to ordinal and switch is you lose dynamicity
yeah, OWNER has the index/ordinal 0
ADMIN has the ordinal/index 1
etc
thats why ranks[rankType.ordinal()]
would work
Is this better than switch thing?
how would you do this dynamically anyways
yes
I see, thank you for help
id say its better than his switch
but
be careful if you change your enum
or your design
thats when it could have downsides
like frostalf is pointing out
a list has an index, as long as you have a way to guarantee the order you put something into said list, which is not difficult then you can use the index
i think i know what you mean
so, when pulling from a config, as long as you always read it the same way, the order is guaranteed to whatever the order in the config is
i dont think a config is always handled in the order its written though
arent lists read in from config random
yep
expand what you are asking
i remember i did
um, you have a texture and want a skull with that texture?
not a player uuid
i have a skin
yes the value of it
i have the file
there was an api for it iirc
no clue what you mean by "value"
skull has something innate, where the texture is saved
thats the reason skulls dont change if player skin does
he probably wants that
yea that. I dont have my ide open right now so i cant be more specific
nvm i will set it to a premium user
We have no idea what "texture value of a skull" means
of a skin
its the url of the texture and some json encoded in base64
you have a skull and you want to pull the texture?
are you trying to set the skull texture?
?paste
that a 1.19+ thing?
yes
i know its possible in 1.16 tho
that works for items, does it persist if you place it as well?
and a texture eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTlmMTFjMGQ0OTdmMjI3MDg5Y2JmNjE0NjAxMTA5Y2FmNjE1NDUzOTQwZWY1ZjY0ZWJiMTc3OTU3ZTRmYTZlNSJ9fX0=
yes its placed as well
cool
I have code for both, guess I don't need the other anymore π
well maybe I still do
in case I am just changing blocks and not items XD
This is pre 1.18.2 https://paste.md-5.net/otezulenib.java
1.18.2+
yep, the new one is the preferred way. No reflection
do u have a blog about that somewhere too?
Nope, I'm too lazy to blog
that would be mfnalex
ah right
search github for Jeff media
k
who? what?
he was looking for your blog
how do i upload my plugin to spigot resources section? there's no "add resource" button or anything
there should be one though
if I remember it was annoying to find the upload button
you are logged in, right? π
i try to go to the "resources/add" link but it says i do not have permission
yea lol
how old is your account?
not even a week old
maybe they now require a minimum age
well i would be grateful if it could be actually known lol
dunno i could upload quickyl
isn;t there a minimum post count to upload or soemthing?
I pinged optic in #general, lets see what he says
thx
I don't think so
I uploaded mine with no posts
have you verified your mail address @coarse adder ?
there is a min post count to upload premium resources, though
bleugh
then idk
and added 2FA
yea i saw this post https://www.spigotmc.org/wiki/adding-plugins but it says nothing about adding normal plugins
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Wait only 80 posts and 3 resources? Wasnt that higher at some point? You get that in like a week by just spam updating your 3 resources...
hello my plugin is runing commands and i dont want them to show in chat is there a way to hide them? and cant use the api coz i have a text file with commands in them
it was the same limit when I uploaded my first premium plugin (about 1.5 years ago)
only players with the defined permission will see it
what permission?
unless you are using dispatchCommand
the permission you have defined for that command
i am...
then its better to use teh API than issue commands
ok tysm guys
yes
Spigot just hates you then
π
try asking in general. and perhaps ping Optic in there
mr optic has been pinged
well i cant coz i have a text file with commands in it that the server will run
so am now sad
are you wanting to hide commands from the console?
not console just chat
then you can expect both accounts to get blocked now
having multi accounts isnt allowed
i haven't created a new account
well this is spigot so i guess i can't delete my account right
you could message support to get your account deleted
ok ty
anyone gota fix for this
don't give your players permissions for those commands
but its running base minecraft commands
then check out this event https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerCommandSendEvent.html
declaration: package: org.bukkit.event.player, class: PlayerCommandSendEvent
ok tysm
how would i use this i cant seem to find a exmpale
Killer is a Player or null
oh
not an Arrow
and how can i get if the killer is an entity?
so it can check if it is an arrow
but that wont mean he died by it btw
its entity death event
EntityDeathEvent
oh mb i read that
so this is not going to work, as i'm trying to use #getKiller() to see if it is an arrow... how can i solve that?
why wouldnβt that work
getKiller returns a Player
yea
one simple question, can multiple players interact with the same villager at the same time?
and i want to return an entity
check getLastDamageCause and then see there what entity it was
getLastDamageCause, see if its instanceof EntityDamageByEntity, cast it and getDamager()
village, yes. villager, no
but
Entity entity1 = e.getEntity().getKiller();
also you donβt need to Objects.equals for enums, just use ==
i need this to be an entity
a Player is an Entity
Killer is always a Player or null
i mean
if one is currently trading, second player couldnt right?
yea
I already told you to use getLastDamageCause()
correct
try as I just showed above
that's a bummer, but i think i know how to fix this
if the arrows still exists you should be able to get it
getLastDamageCause, see if its instanceof EntityDamageByEntityEvent, cast it and getDamager()
if (Objects.equals(entity.getLastDamageCause().getCause(), EntityDamageEvent.DamageCause.PROJECTILE) &&
entity1.getPersistentDataContainer().has(TestArrow.getInstance().getKey(), PersistentDataType.STRING) &&
Objects.equals(entity1.getPersistentDataContainer().get(TestArrow.getInstance().getKey(),
PersistentDataType.STRING), "ARROW")) {
Check entity1... that is supposed to be the arrow
why the heck are you using Objects.equals
idk
and do not nest all your if things
@EventHandler
public void onDeath(EntityDeathEvent event) {
EntityDamageEvent damageEvent = event.getEntity().getLastDamageCause();
if (damageEvent == null) return;
if (!(damageEvent instanceof EntityDamageByEntityEvent) return;
EntityDamageByEntityEvent damageByEntityEvent = (EntityDamageByEntityEvent) damageEvent;
Entity damager = damageByEntityEvent.getDamager();
if(!(damager instanceof Projectile)) return;
Projectile projectile = (Projectile) damager;
// Do stuff
}
some guy told me not to use ==
okay, thanks
You should not use == for strings
why not?
because if you do this:
String firstString = "asd";
String secondString = "asd";
assert firstString == secondString;
then it MIGHT work, but it also might not work
yep
== basically checks if that object is the same, Strings are objects so comparing them with == would compare they objects not the contents of the string
in theory, this should fail the assertion
because both strings are different objects, and only their content is equal
but yeah the JVM caches a certain amount of strings
strings are pooled, but if they're dynamically created in your code this would never work
so you will get weird, random behaviour when comparing different strings with ==
but its faster!
Hey, I am making a spigot plugin with multiple listeners listening on the InventoryClickEvent.
If I try to access the clicked item with e.getCurrentItem() I am getting random null errors, even though I am checking that the item isn't null (like this: if (e.getCurrentItem() == null) return;)
The plugin is a custom enchantment table and I have lots of InventoryClick listeners, but they all ignore cancelled events with @EventHandler(ignoreCancelled = true)
Full Code:
https://github.com/PixelAgent007/easyenchantments
Which class, which line?
listener/ArmorEnchanter
listener/ToolEnchanter
listener/WeaponEnchanter
listener/GuiSetups
listener/GuiInvSetup
it affects all listeners
This line will NPE if you click air https://github.com/PixelAgent007/easyenchantments/blob/main/src/main/java/global/oskar/easyenchanting/listener/ArmorEnchanter.java#L35
This is a bad idea
I know, I should remove that
but it checks if the current item is null before?
oooh
AIR is not null
Anyone could help with garbing ip of bungee server thru player on spigot side
(clicked.getType() == Material.BLACK_STAINED_GLASS_PANE || clicked.getType() == Material.ENCHANTED_BOOK || clicked.getType() == Material.BOOK || clicked.getType() == Material.BARRIER)
Make a set instead and check contains on it.
private static final Set<Material> clickableMats = Set.of(
Material.BLACK_STAINED_GLASS_PANE,
Material.ENCHANTED_BOOK,
Material.BOOK,
Material.BARRIER
);
// also some helper methods should be usefull
public boolean isCustomInventory(Inventory inventory) {
}
// laster on
if(clickableSlots.contains(clicked.getType) && e.getSlot() != 40 && isCustomInventory(inv)) {
e.setCancelled(true);
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASEDRUM, 3.0F, 3.0F);
}
Like can I get bungee ip and domain which player used to join
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I'll clean it up later, but thanks
wait will this not return me actual player ip
yes
getWorld can return null
That is not the code you asked about
if you got the world from a Player it will not be null, unless the player is dead
yes
well, mid respawn
well what I am trying to accomplish is to get ip of multiple bungess
from which player has joined
or if they used specific domain like play.servername.com or mc.servername.com
This is not how java works. What are you trying to do in the first place?
World world = Bukkit.getWorld("aaa");
if(world == null) return;
if(ready.size() == world.getPlayers().size()) {```
How can I get equipped/worn items? I want to make a "setItem" if 4 pieces of my custom items are equipped you get another buff..
public static void SetItems(Player player) {
if (player.getEquipment().getHelmet() == IronHelmetUtils.createIronHelmet() && player.getEquipment().getChestplate() == IronChestUtils.createTankChestplate()
&& player.getEquipment().getLeggings() == IronPantsUtils.createTankPants() && player.getEquipment().getBoots() == IronBootsUtils.createTankBoots()){
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 1, 1));
}
This no works, do i need an evenHandler/Listener?
compare with isSimilar or .equals
Use the pdc for that
you are comparing ItemStacks
let me write you an example
Okay
So the simplest PDC based approach is this class:
public class ItemSetManager {
public static final NamespacedKey ITEM_SET_KEY = new NamespacedKey(JavaPlugin.getPlugin(SpigotSandbox.class), "item-set-typ");
public boolean hasItemSet(Player player, String name) {
for(ItemStack itemStack : player.getEquipment().getArmorContents()) {
if(!isPartOfItemSet(itemStack, name)) {
return false;
}
}
return true;
}
public boolean isPartOfItemSet(ItemStack itemStack, String name) {
if(itemStack == null) {
return false;
}
ItemMeta meta = itemStack.getItemMeta();
if(meta == null) {
return false;
}
PersistentDataContainer container = meta.getPersistentDataContainer();
String setType = container.get(ITEM_SET_KEY, PersistentDataType.STRING);
return name.equals(setType);
}
public void applySetType(ItemStack itemStack, String setType) {
Preconditions.checkArgument(itemStack != null);
ItemMeta meta = itemStack.getItemMeta();
Preconditions.checkArgument(meta != null);
PersistentDataContainer container = meta.getPersistentDataContainer();
container.set(ITEM_SET_KEY, PersistentDataType.STRING, setType);
itemStack.setItemMeta(meta);
}
}
(Spam intensifies)
Usage examples:
// Creating an "iron-skin" helmet by using the itemManager
public ItemStack createIronSkinHelmet() {
ItemStack helmet = new ItemStack(Material.IRON_HELMET);
// <- Do some naming and whatever here
this.itemSetManager.applySetType(helmet, "iron-skin");
return helmet;
}
// Listening for damage events and reducing everything for "iron-skin" wearer
@EventHandler
public void onDamage(EntityDamageEvent event) {
// Check if damaged entity is player and cast
if(event.getEntity() instanceof Player player) {
// Check if he has the "iron-skin" set
if(itemSetManager.hasItemSet(player, "iron-skin")) {
// Reduce damage by 10%
event.setDamage(event.getDamage() * 0.9);
}
}
}
Hi there. I'm currently porting a forge mod to spigot. This mod is enabling interaction with minecraft from an HTTP interface. One of its endpoints can be used to modify material and blockdata. I'm able to do that with CraftBlockData.newData(material, string) & Block.setBlockData(blockData).
My issue is that the original api let the user select exactly how the block is updated. It's not doable with the spigot/bukkit API, so I was looking for the actual implementation of bukkit's setBlockData so see if there was something I could put together with NMS, but I couldn't find the source code. Any idea?
If nobody got an answer ready, I'll create a forum post
You can get the source code by running BuildTools. This will install everything into your local maven repository.
If you use the --remapped flag then you will even have the original mojang mappings
Thanks! I forget about that. As for the original mojang mapping, it can be used for a better comprehension of the code structure, but the standard spigot jar is not using it right?
why are the ItemSetManager class
methods
not static
Okay, I think I'm understanding this a little better, Do I create my set in here some where then? after I make a listener for the onDamaage, do I make a iron-skin
is there an example project.xml for maven somewhere?
do you mean pom?
ah yes
there should be heaps online. The main thing you need to know is repositories, dependencies and plugins
eh fair enough
Location.setBlock()
oh
or some shit like taht
setType
thats the one
does anyone know the name of the 1.19 import?
Cannot resolve org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT
that depend is fine. you forgot to add repos?
dunno
compiling server and then adding the dependency worked before
hence me doing it with all three args
(docs, source, remapped)
So you probably don't have the repository in your pom
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>```
i have this?
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
i copied over a old pom.xml then changed 1.18.2 to 1.19
you didn;t update the version in the specialsource plugin
I'd suggest making a Maven property so you don't have to remember to update everywhere, yeah ;p
still the same error tho
i dont have to change the pom that often
im more worried that what worked in 1.18 stopped working in 1.19
where in .m2 was the spigot stuff again?
C:\Users\%USERNAME%\.m2\repository\ORG\spigotmc\
oke thats weird
the 1.19 files are there
why would it recognize 1.18 stuff in .m2 but not 1.19
have you run Buildtools with --remapped ?
yes
how do I check if a block is broken by it's appropriate tool in BlockBreakEvent?
should be possible to grab the tool its broken with
both spigot and spigot-api folder contain the 1.19 spigot jars
bit of a pain but there's a list that each tool can break
You might be able to use NMS
Or this file I fetched from the minecraft client and converted to yml
T_T
I guess you can do reverse search with mine
No clue
isn't there a way to check if breaking a block with a tool gets any drops?
getDrops(ItemStack)
oh thx
recipe.getResult()?
Bukkit getRecipesFor
oh
Can any help me
?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!
Having some err in bungee
Wrong channel
I try make java/pe bungeecord he says online mode
declaration: package: org.bukkit, class: Bukkit
argh
restarting my computed didnt help either
the files are there
so why doesnt it read them in from .m2
Did you tell Intellij to use another .m2
Try building your project outside of Intellij
how am i supposed to build when the pom xml is the file with the issue
'this command cant be recognized or found'
You need to add maven to your path
First I recommend downloading an up to date version of maven
I assume you're on Windows btw
Then open environmental variables > path
And add the path to the bin folder of your maven install
one second
i looked into my project structure
apparantly it finds the file
but refuses to build with 'cant resolve'
theres another weird thing
i built the server with --generate-docs but there's no javadoc present
That --generate-docs didn't really work for me
So go to Spigot > Spigot-API and run mvn javadoc:javadoc
wait theres jdocs in build.bat-folder\Spigot\Spigot-API\target
π
but no jdocs for the remapped stuff
ah
how do you guys learn nms
welp copying them over seemed to fix it
how do I check if an item has durability at all?
like a pickaxe would have durability but an egg wouldn't have
NMS has no documentation which is why you need to have the knowledge to digg around and figure out stuff your self
something something isdamageable i think
k
Is there no advice how to get going?
theres some blocks online
for example for placing millions of blocks
but nothing concrete
also
use remapped so that it doesnt break completely upon version change
if an item has no durability it's durability is 0?
remapped?
if you use --remapped in build.bat it gives you two folders, spigot-api and spigot
the latter is the remapped stuff
- Learn Java
- Setup remapped spigot
- Then start digging around the code to find what you need.
I already know java.
you HAVE to add the remapped plugin from md_5 though
I just haven't touched NMS before.
some legal thing about not publishing deobfuscated mojang code
You shouldn't post the obfuscated one either
Don't upload code you don't have the rights to
I can help you if you want
I don't have access to a pc right now but I can guide you with the general process
I mean, I wanna work out how to set blocks and such, there's tutorials out there but it's complex π
Most tutorials are out of date by now
I mean, I sadly can't use the latest version so that helps slightly i guess
u building for an older server?
Use setType without applying physics updates and then do it async in batches. π
slightly older yes
i thought you cant place blocks async?
block#setType doesn't allow async
Huh? You can do absolutely everything async...
not setBlock
Yes
Nope
What do you mean?
I've tried before it throws a warning.
"You can't update blocks async" or some shit
Ah i see the problem. You think async is equal to multithreaded.
Ive done it and even wrote a forum post about it.
If you split setting 1M Blocks over 1k ticks then you are
doing this task async.
https://proxy.spigotmc.org/129901ab83197a591a755d2a0b26cb32cb287152?url=https%3A%2F%2Fimage.prntscr.com%2Fimage%2FDnUqaEl1TA2v6qF8IpVNSg.png this is the error what it comes up with, not my code but someone elses same error though
You just have to do it async on the main thread.
why not use nms and set the blocks in one tick
Bad phrasing from spigot
that's the issue
I don't know nms
ah fair
Because its only marginally faster.
uh i dont think so
I'd learn it but idk how to do it
iirc it was around 25k/tick for spigot and around 14M/tick for nms
Everything thats faster than setType without physics updates can easily lead to corrupted chunks.
*If you place blocks directly into the nbt data of the regions. This needs a lot of additional work
like reloading the chunks and sending the chunk data again to players.
arent packets nms stuff?
Ive read this. There is nothing too useful in here if you dont want to have a ton of additional work.
yes they are
whered you find that
Packets are part of internal NMS
Technically packets are part of IP. You can read them by injecting a packet handler into the netty pipeline or by using ProtocolLib (which does it for you).
Problem is interpreting the protocol.
Do you want to do updates on blocks that are hot? (Players are nearby and they can witness changes live)
or do you want to do cold changes (change blocks in preparation for certain events or restoring a map after usage)
I want it to be changed so people can see it happening, it'll be for an enchantment plugin
cant you use the normal setblock then? I'd guess you wouldnt want to change 50k+ blocks
Then use the spigot method. All the nms stuff comes with heavy visual drawbacks.
Just do it async π
I was using FAWE what was fine but the other dev's ego is too big thinking using nms is "better" and is forcing me to use it
Let him join here so we can whoop his butt.
Spigot calls nms. There is literally no reason to use raw nms unless you want to additionally trigger light and physics updates or even manually send packets afterwards.
I use world edit to set the blocks normally isn't that fast enough...?
93 milliseconds to set 754 blocks
Sure. One of the most important rules in programming: Dont reinvent the wheel
just tell him that the fastest way would be editing the file
Thats harsh...
Slow or?
Yes
hm
very slow
it usually speeds up
This sounds like you are loading a schematic file from disk before pasting.
1k Blocks should be <5ms max.
Depending on your CPU
it says 98ms now but I wonder if i'm calculating wrong
lemme make another thing 2s.
Show some code pls
What do you think guys will that google AI invent time travel?
it's saying 0ms now lol
Time travel is already discovered. We just need to find out how to produce enough energy or how to distort space.
well do you thin will that AI be able to figure it out
Astronauts travel 10min into the future on average in their lifetime.
well it's saying 0 nanoseconds so I'm sure that's fine
This sounds like its not fine. Even adding 2 numbers takes several nanoseconds.
!paste
so by that logic at the end of there life they should be able to do a bet 10 min before games finishes and make some big $$$$
I think we have a different understanding of what "logic" means
was jk
^^
π€£
iirc theres a package that does that
plugin message
constantly saying 0ms idk what else to do lol
You mean via spigot or via bungeecord?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I don't know what else to do, it's setting the blocks but it keeps returning 0ms
1.8 is legacy and should be avoided at all costs
Your friend sounds smart
https://i.imgur.com/kJ4c3ss.png so I legit can't go any faster lol that's world edit session#setBlocks and it works
use system nanos then
Instant does not have nanosecond resolution
You would need to use a NanoClock
private static final NanoClock NANO_CLOCK = new NanoClock();
public Duration measure(Runnable action) {
Instant pre = Instant.now(NANO_CLOCK);
action.run();
Instant post = Instant.now(NANO_CLOCK);
return Duration.between(pre, post);
}
so that 0.68ms or 1.36% of the tick. Thats more than fine.
ok, so I can keep using this method with no problems then?
Unless this is spamable and 10 players can do it a thousand times a second you should be fine.
it's only 0.068 ms
unless google is lying to me π
It's a factor of 1000000, since you have:
sec -> millis -> micros -> nanos
each a step of 1000 to another
68,300ns = 68.3us = 0.0683ms
looks about right to me
I mean, it'll be impossible for it to happen thousands of times a second
Then keep doing what you are doing
well are you new?
programmers have either imposter syndrome or a god complex
no in between
Yeah that can be a problem. But im of the same type. I just use ProtocolLib and write absolutely everything myself.
Ive gotten this way after reading some of the code of more popular apis that i where using.
*Oh and i use Crunch when im doing calculations for experience formulas for example @waxen plinth
ProtocolLib is gangst
I mean redempt is a cool dev he helps a lot with coding
just becuase you're having a god complex doesnt mean youre a bastard
?
?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.
How to get Player class from event? ```
public void playerFall(EntityDamageEvent event) {
event.something
}
Hey all,
this is probably a message you will skim over.
However me and my mate have an amazing idea for a project
however we are in need of a developer.
if this is something you are interested in then the idea can be
further explained in DM
there is a slight catch. me and this mate are both students.
money is not the easiest to come by. however we are devoted to this server
and would love to have someone join the team. and once the server has launched etc
money that we receive we will aim to provide you with money worth your time (dependent on server growth)
any questions or possible discuses the offer please DM me
mmmm development on the basis of a promise
ik its not ideal
event.getEntity
check if its player
cast
whateve
nvm got it
i just forgot to cast π
Is there a better way to do this without NMS?
String advancementResourceLocation = event.getAdvancement().getKey().getKey();
if(advancementResourceLocation.startsWith("story/")) {
//Is there a better way to do this??
String advancementDisplay;
switch (advancementResourceLocation) {
case "story/mine_stone" : advancementDisplay = "Stone Age";
default : advancementDisplay = "";
}
}```
i mean the better way would be to use NMS
Thing is these achievements are localized
but i don't want to*