#help-development
1 messages · Page 1395 of 1
thanks
But what if multiple players are dead?
As he is not classed as online the event I listed should fire after the respawn event triggers https://hub.spigotmc.org/javadocs/spigot/org/spigotmc/event/player/PlayerSpawnLocationEvent.html
Kick them if they have the audacity to die when someone else is already dead.
^
maintain a list of dead players by listening to death and spawn events :pepega:
Guys does it exists an API method to retreive the plugin.yml? Or do I need to use getResource()
i think someones nitro expired
getDescription()
I worked out how to sort this. I activated instant respawn and delayed the function by 1 tick
thanks
declaration: package: org.bukkit.plugin, interface: Plugin
if i have
config.set("cells."+player.getName()+".level",1);
i return value with
config.getInt("cells."+player.getName()+".level")
?
use UUID not name
*retrieve. Yes. But UUID > name in this case
then stop
ok
Is yaw always negative? I am trying to work out a players rotation
User changes name -> loses everything
names can easily be changed UUID is unique
i've never had nitro
i seem to get from -0.0000001 to -360
and the longer you wait to change to UUID the harder it gets.

towny only took half a decade or something
Towny no longer relies on another plugin to tell when a user changed his name
LOL
Hey, is there a way to detect when the player stops breaking a block? I looked through events implemented by Spigot and found nothing that seemed like it. I know it can be done by inspecting player packets but I'd like to stick to Spigot only solution.
How would I make a ClickEvent execute multiple commands in one click?
Dont use Dispatch use any API
i don't think there is an API way of detecting that
No no I'm trying to make click events on messages
you would make it execute a command that prompts the player to execute several commands
beyond that, the function of the click event is simple; it forces the player to run a command
nothing more, nothing less
Well that won't work because I need like a message in chat that you click on several times to alter the value in a database
anything else you want it to do you need to cobble up and string together yourself
Then, if I were to make a PR with a new event that supports that, how long would it take to get it in a new version? Would I have to wait for the next Minecraft version?
on spigot? probably never lol
you wouldn't need to wait for the next minecraft version, you'd need to wait for someone to accept and merge your pr
it all depends on its likely uptake
which may happen quickly or take ages or may not happen at all
and its additional load on teh server
I've seen questions relating to this kind of event a few times in here
Well, then I guess that means I'm better off hacking my own solution... Sorry if some of my questions seem dumb but I came back to plugin development after ~5 years and I have no idea how the community has changed.
If I were you I'd make the PR. The only way the API expands is if suggestions are made
do both
Yeah, I know but at this moment I'm really questioning which server mod should I be using. I'm having a fresh start with a new project and I'm wondering which community (Sponge or Spigot) is more active and which API do I want to go with and be less frustrated.
there's a chance you'll die of old age if you wait for the pr
so make a pr and get yourself a hack and use the hack until it gets merged
Hello , so i want to make a plugin that open a gui , and you could put your item and click on the enchanting book and its will give it to you , anyway i made it work with InventoryClickEvent.getCursor() but when the player click on the book he need to click again with the book , i guess that makes sense , but what i can do to get the enchants from the book and apply them with only one click, thank you in advance
and i, tried getCurrentItem() i just replace it but its return a null exception
paste, not dump
i have it when i use getCurrentItem()
then whatever you are calling getcurrentitem on is null
or the return value of getcurrentitem is null
and you're trying to call a method on it
i know this
we know this too
Use Java 15+ it'll explain you in full detail on where the issue is with NPEs
and that's all we know
because you deleted the code and didn't give us an exception
we're more in the dark than you are
you said post it on paste no ?
?paste
In relation to the exception
yes but I was looking at it 🕋
why is that an emoji
search it in google
and now the exception
I know what it is, just not why it is
my guess is that e.getCursor returns null
no , alright you don't get it
can you paste the exception or not
ITEMINHAND is null
i'm sure its not
I was just saying random things
lmao
now can we know what the 55th line of your class is?
and next we need line numbers
itemtoenchant.addUnsafeEnchantments(map);
yup , alright
Just note that asserts are stripped at runtime unless a JVM flag is added
oh
Which is why they are usually used with unit testing
yo
I realized why I was getting an error while compiling with maven so I fixed it, but uhhh I have an error which I'd like help with
That is too much info, cannot help you with it
client = new MongoClients.create();
create is not resolved
Could you delete some sentences?
anyone know why i get this error
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at live.freedommc.cloud.main.sql.MySQL.connect(MySQL.java:34)
at live.freedommc.cloud.main.HostInstance.<init>(HostInstance.java:65)
at live.freedommc.cloud.main.HostInstance.main(HostInstance.java:39)```
when i do this
```java
try {
con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
System.out.println("Connected to MySQL");
return true;
} catch (SQLException ex) {
ex.printStackTrace();
return false;
}
Because no suitable driver was found for this jdbc url...
yeah I know lmao but what really confuses me is that i use it twice in the same project, using the same sql server and even the same MySQL class but one time it works and the other time it gives me this
Are you creating the instance in your onEnable?
Also make sure to mock the driver class first so it is forced to register itself.
well the instance where it doesnt work and gives me this error is in a class that is started from a public static void main(String[] args). The time it works is when I do it using onEnable on my bungee plugin
wdym by that i'm stupid lol
Class.forName("com.mysql.cj.jdbc.Driver");
oh yeah i tried that but it gives me ClassNotFoundException
does the main method even fire in a spigot/bungee plugin?
If its not a spigot application then you need to provide the mysql driver yourself
yeah i did
idk if i did it correctly though
i have a lib folder and the jar file for the driver inside it
i tried maven dependency as well but it gave me a NoClassDefFoundError
using maven, shade it
i have question lemme write it
i have this
and i have this
why does this happen?
what can i do to prevent this
You using maven?
Needs to be in the resources folder
Okay, thanks
<resources>
<resource>
<directory>/src/main/java/plugin.yml</directory>
</resource>
</resources>
Like such?
i got around to setting values in config, but how can i create new values?
for example the path example.path with value int 1
src/main/resources exists
i tried config.addDefault("cells."+player.getName()+".level",1);
plugin.getInstance().saveConfig();
plugin.getInstance().reloadConfig();
I just put it there?
does this still exist? Because I cant find it nor use it
yes
should be working
package me.TheWood.org;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
public class Main extends JavaPlugin {
@Override
public void onEnable () {
}
@Override
public void onDisable() {
}
public void EntityDamageByEntityEvent(@NotNull EntityDamageEvent.DamageCause cause,
double damage) {
}
}
?paste
please ^
How I can make what only reference to one entity
Try not to use performCommand unless you have no other option
If i register a command on the SimpleCommandMap when the plugin is already loaded, will it works?
thank you so much it works now
You need @brave glenHandler on your event, your class needs to implement Listener and you need to registerEvents(this,this);
Did I just get auto bot?
rip @brave glen
..?
sod @brave glen silly choice of name
ok stop pinging him
never
I'm guessing he has notifications muted by now 🙂
He's been getting pinged for many months
Lol
Guys?
sup
Yes empee
dont ask to ask
So long as you are using Lifecycles to build it should be included. Unless you are using some multimodule poms
.
.
.
I'm using the adventure api now and did this:
Component message = Component.text("Hallo "+this.getPlayerName(id)+",\n"
+ "Du wurdest zur Gilde "+this.getMailSender(id)+" eingeladen. Möchtest du beitreten?");
Component accept = Component.text("Annehmen ");
Style acceptStyle = Style.style().build();
acceptStyle.decorate(TextDecoration.BOLD);
acceptStyle.color(TextColor.color(255, 180, 0));
acceptStyle.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, "/invite "+this.plugin.getGuildAPI().getGuildInviteCode(this.getMailSender(id))));
acceptStyle.hoverEvent(Component.text("Einladung annehmen"));
accept.style(acceptStyle);
Component refuse = Component.text(" Ablehnen");
Style refuseStyle = Style.style().build();
refuseStyle.decorate(TextDecoration.BOLD);
refuseStyle.color(TextColor.color(255, 180, 0));
refuseStyle.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, "/mailbox delete "+ id));
refuseStyle.hoverEvent(Component.text("Einladung ablehnen"));
message.append(accept);
message.append(Component.text("|"));
message.append(refuse);
bookMeta.addPages(message);```
Wrong Server for Adventure
Does anyone know a possibility for this? Creating a new file with just file.createNewFile() gives me java.io.IOException: No such file or directory
Does anyone know how I can perform an operation more than 20 times per second?
My plugin has the plugin.yml in the resources folder but this pops up, do I have o add it to the pom.xml
You could run it on a separate thread
Like send particles for an arrow trail, more specifically
How do I do that, I'm not too familiar with threads
You shouldn't need to be sending particles more than 20 times a second
But for threads
How do I make an arrow trail then?
Could call the method twice or 3 times and use some randomness
Or summon the particles a few times
Then ray march the velocity vector of the arrow and spawn particles in fixed steps
Add to it's motion
I'm sorry, I don't quite understand
Ill write you an example
Sorry for bump, but does any1 know
By default maven will copy everything from your projects resources folder into your plugin jars root.
okay but I'm still getting the error
interpolate the points where arrow is at each tick and draw a line along them
Then you are either building using Artifacts and not lifecycles or your plugin.yml is not in your resources folder of your project.
How do I add multiple TextComponent to spigot().sendMessage() as in
sender.spigot().sendMessage(base + t_10_ + t_10_ + t_1_ + current + t_1 + t_10 + t_100);?
I am using lifecycles -> package
and also it is in the resource folder
?paste your pom
you merge them into a single component
you can't + them together; they're not numbers, they're not strings
they all have ClickEvents tho
that's fine
shove them into the extra of a text component or something
iirc there's a method that takes a BaseComponent[] and gives you a textcomponent with all of the given components in its extra, or something
try <phase>package</phase> instead of deploy
worked... fine I guess?
I put them all into a seperate TextComponent and then into the sendMessage
I have no idea why this doesn't work, it worked fine a while ago, changed nothing, and now is being utterly stupid, I have this simple code:
FileManager.writeFile(new File("SpartanSkyblock/Players/" + uuid.toString() + ".json"), toPut);
The writeFile function is this
public static void writeFile(File fileName, String toWrite) {
try {
fileName.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
MagmaCore.getInstance().getLogger().info(String.valueOf(fileName));
try {
FileWriter fileWriter = new FileWriter(fileName);
for(int i = 0; i < toWrite.length(); i++) {
fileWriter.write(toWrite.charAt(i));
}
fileWriter.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Now I do not understand, the directory existed so I made a check for fileName.mkDirs() before creating a new file, AND NOW IT DECIDED TO MAKE ANOTHER FOLDER WITH THE EXACT SAME name
Mongo seems unable to find a database to connect to
Without the mkDirs call I kept on getting an IOException
oh yeah the server needs MongoDB support?
Do I have to mark them in a special way?
I have this thing
?paste
noob
Enlighten me
Is there a limitation on the resolution?
i don't think so
@lost matrix This will work on 1.8, right?
Don't worry about the particles, I have an API
How do I fix this?
No idea. I dont work with ancient versions.
I don;t use Mongo
mongo bongo web scale reeeee
sharding is the secret ingredient
I'm working on a project that was started in 1.8, and it wouldn't be worth it to switch the version all the way up to the latest
Q&A discussion discussing the merits of No SQL and relational databases.
dev null is web scale
you are supposed to do the opposite technically
lol
its not like java versions
pipe everything into dev null. Its really fast
where you start early
What do you mean?
Do bukkit runnables cause lag
depends
When run asynchronously
well what is being ran async
Sprint detection
There is an event for that
^
I calculate the position every 2 ticks
PlayerMoveEvent
And find the distance
every 2 ticks?
don't slap async on shit just for the sake of making things async
declaration: package: org.bukkit.event.player, class: PlayerToggleSprintEvent
Yeah
you sure you want to do that..?
calculating the position is like 3 double subtracts and 3 powers and 1 sqrt operation
literally free
I need to know if the player is sprinting
use the event
jumping to a separate thread is going to take 100x the time
sqrt -> "free"
.is sprinting always returns false
literally free in comparison to swapping threads
Ok I still avent figured this out. How do I combine multiple TextComponents into one?
Any reason why you dont want to use the sprint event?
adventure or bungee component
ummmmmmm
are you using the one built into bungeecord?
With the sprint event will I know when a player is sprinting?
or the one in adventure?
It only calls when the player starts sprinting am I right
store it
it's fired whenever a player toggles their sprint state
does any1 have a guide for using custom config files? (to create new paths in the config etc)
Sorry I dont know, how do I check
Are you using any component library
store the present state in a map and you can access it reliably at nanosecond costs
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Is it called "PlayerStartsSprintEvent" or "PlayerToggleSprintEvent"
oh yeah the bungee chat api
Does player toggle sprint event also fire when the player stops sprinting
gee i wonder
ok thanks tho
K
i don't think it says how to create new paths
does a light switch only work when toggling it on?
It fires when the player toggles his sprinting state
like create a path for when a player joins the server for ex
ah ok
or adventure 😄
Tbh I am too new to java to understand most of that -.-
I have multple TextComponents each with a ClickEvent and want them to be displayed in one line
then look at teh second link. It has examples
When would I run this?
is there a way to send the red world border vingette to a player?
You can send the fake information that he is outside of the world border.
I think you can set the warning blocks to a very high number
Or set the border wall 200 blocks away so its not visible and the warning size to something like 400
@lost matrix Do you know where I should run the code you sent me?
You could probably leave the border alone and just set the warning size to Integer.MAX_VALUE
The code ive sent is a complete plugin. You need to disect it and scrape the pieces you need.
the higher the blocks the redder it is
Yeah, I know. I'm wondering about how exactly the marchRay() method functions. If it's called every tick, will it display properly? How often is it called normally? Will the entire arrow trail display before the arrow has run its course? @lost matrix
march ray just takes a vector and splits it into smaller vectors then spawns a particle at each of those sub locations.
This only makes sense if the arrow is REALLY fast. Speaking several blocks per tick. Otherwise spawning just a particle each tick at the arrow location is enough.
Anyone know much about what makes spiders climb walls, I’ve tried messing with the AI goals and navigation controller of mobs, but haven’t had any luck
Dont they always climb walls if they touch them?
no I dont think so
another word for that is interpolation
you are interpolating the position of the arrow between the two ticks
Small question how do I prevent a command from showing up in autocomplete when you enter the beginning letters?
Yeah, a plugin we made has an unlockable set bonus that makes arrows go faster
Also, is there any way to make a custom name ALWAYS visible on non-armor stand entities?
how would i set the owner of a bed?
And when an arrow hits a player, does it die?
it's not a living entity, it can't die
..
quite frankly, can players even own a bed?
i don't remember beds storing ownership information
players do store the last bed they slept at, though
and villagers store their bed as a record in their brain iirc
the player class has a method for getting their last bed iirc
well what im looking fort is the function that happens when you sleep in a bed
it sets your spawn point
so i wanna call
that function
I just sent you it
thx
How can I set a players health to a config value?
I want to make a command, that sets the players health to a value, that is specified in the config
well i have this, but this kills the player for some reason player.setHealth(Main.getInstance().getConfig().getInt("health"));
how do i remove path from config?
and i have this in the onLoad java getConfig().set("health", "20"); saveConfig();
that doesnt work
use set("health", 20)
Because you want to do that as a default
lol i think i mayve found a bug
there is only one set method; the type of entry added depends on the type of the parameter
if you give it a string "20", it will write it as a string
Also, don't bother setting it programatically, do it manually
if you give it an int 20, it will write it as an int
those ordinals go from 0 to 5, not 1 to 6... right?
This is the switch table though
wait what am i looking at
Switch tables behave a bit different and the result of the switch table != the enum ordinal
ill try that, ty
you are passing the ordinal of the enum constant to the switch block
so you want a zero in there
It's not a bug, it's a feature
but its correct in craftbukkit
as the first enum constant has an ordinal of 0
All switch on enum code does this
lmfao i know how enums work
i just was confused about this whole switch table thing
ripcord can't zoom on images so I can't really see shit
hmm i did this but it doesnt seem to work
protocol lib also says that the packet is sending with the correct amount of warning blocks
ACTUALLY ignore that it was just an optifine issue
Optifine, breaking rendering since whenever optifine came out
is there a way I can get a spigot server's name from bungeecord? I searched it up and there was this whole thing about 'channels' that I couldn't understand...
Plugin channels? They are pretty much the only option for this
you have to either use protocallib or nms
neither can the default client, issue for everyone
i worked with channels before
Sb knows how to build the artefact of the plugin and force replace the oldest one with maven ? (because Windows doesn't like to replace running java stuff
I beleive the NMS packet is called PacketPlayOutCustomPayload
all the things i can find about channels have like player.sendPluginMessage but is there a way i can do it without a player?
ok sorry if im dumb i do not get this at all lol
i just want to get a spigot server's name from bungeecord
let me find it
correction, you dont always need player. but a lot of the channels do use it
Ok so I have an opinion question
I have made a plugin which dynamically adjusts prices of an item based on the items in stock
selling and adding increases and decreases the stock
now I want to add a command to sell all items
But I do not want all items to be sold on the current price
but adjust every time an item is sold
whats the best way of doing that?
can someone help me?
my config isnt working
i keep trying to set nerf mob spawners false
#help-server is where you will need to go
how would i change the args for a command to make it so its /(command) [playername]
just define args[0] as playername
where would i set that
i just wanna make a command that takes the args /(command) [playername]
how can i do it when i hold an item it gives the player a potion effect
make sure you check that its a valid player
how would i do that
umm
if(sender instanceof Player){
Player t = p.getServer().getPlayer(args[0]);
thats checking if the sender is a Player, he wants to check if argument is player
oh ok
does anyone know how i can get item held event for custom item
getOfflinePlayer(args[0]).isOnline()
?
whats p
is this really that complicated?
i just want to be able to have a player in the command that i can then use
what am i reading
idfk
get the argument the command sender gives you
then call getOfflinePlayer with that argument
replace p with sender
k
literally 2 methods
so this checks if the player that was in the command is actually a player?
sec ill show you
it gets an offlineplayer that corresponds to the given playername
and then checks if they are online
why would i want that when i dont care if they are offline nor offline
if you get a player who doesn;t exist or is offline you will get a null.
that puts a guaranteed player into playername
ah ok
getOfflineplayer will always return an offlineplayer
if you use offlinePlayer you will always get an object
online works then
again, only works for online players
thx
if the returned offlinePlayer name == null then its an invalid player
there is no way to check if a given username corresponds to an existing player if you want to also include offline players in the search
because players are able to change their names
if the name is not null an disOnline() then they are logged in
so however you go about it, it'll only be true for online players
ok thanks
you could check the mojang user database
i suppose
you'd need to query mojang api with the name, get the uuid, and see if that uuid has played on the server
@wraith rapids what do you think about that
about wut
that
or Bukkit.getOfflinePlayers() returns every player who has ever joined your server. You can search in there
nonono
Bukkit.getOfflinePlayer(playername)
yeah, but the names of the offlineplayers as returned by that method are not necessarily up to date
about this
then the only thing to do is to query the mojang user database
pretty much yes
Shift+enter exists
As he is only interested in online players the offline will be upto date
myeah, assuming he only wants online players
he did seem a bit confused about it though
ok i really need help im not getting any help in the server section
you loop over the inventory anyways, so just sell the item one stack at a time and have the price adjustment happen everytime an item is being sold?
I need it to adjust for every single item being sold, not per stack
well then do it one at a time xd
Loop or have a method that approximates the price based on the items sold. Like, you probably have a function somewhere with which you adjust the price, so just apply that on a larger scale
yeah the function atm is rlly simple
i could use an integral i just realized
#mathkicks
omg that makes so much sense, just do an integral for x amount of items in their inventory
You could create an event for selling the items? And update the value every time the amt decrease
do you know what integrals are?
They are literally exactly what I need in this situation, making me able to sell all items at once for the price itll be if you sold them one by one @crisp iron
So was that helpful? 😂😂I got a missed impression from that message
Sb knows how to build the artefact of the plugin and force maven to replace the oldest one ? (because Windows doesn't like to replace running java stuff
Do not replace jars that are currently running on the server.
I mean, it does work, but you should not do that without a proper environment that is prepared for this
you can put jars in an update folder and they will be copied to the plugin folder on server start
My only other concern is that you mentioned building Artifacts with maven
you dont need to manually rebuild it
you can just recompile the current class?
i think thats how it works
with devcm
but not sure
where is it ?
Thx 🙂
I hotswap with /reload a lot in dev >:D
you cant do that in windows tho lmao
You can
Don't know, windows just lets me replace it
maybe you can replace but not delete
that is
quite weird
lmao
i dont get why windows has the stupid
"you cant delete"
so dumb
I try to design anything I make to handle reloads, or at least make it obvious when it doesn't
How do I convert CommandSender to Player?
if (sender instanceof Player) player = (Player) sender;
tyyyy
note that you aren't converting anything
the CommandSender is already a Player
you're just casting it
myes
but remember, the object is already a Player
casting it doesn't change the object
it only changes how you are interacting with it
Trying to use the Bukkit.getScheduler().runTaskLater() method, what do I put as the first input? It just asks for a Plugin but I'm not sure how to get my plugin, how do I do that?
yea
ty
Just note that is could also be the console sender
If you are using Java 16 there is an easier syntax, idk it though
or literally any of the dozens classes that implement the interface
You have to pass in your main class from the plugin
so you can either use di or a singleton
not your main class; an instance of your main class
So I'd just say 'Main' if my main class is called that?
no
no
nonono
Okay
i guess i wasnt noob talking enough lol
Your instance of your JavaPlugin class
if you are in your plugin's onEnable or something, it will be this
because onEnable is a method declared by the main class of your plugin, and is not static
therefore this refers to the current instance of this class
I can't use 'this' sadly bc it's in my listener class
then you need to pass the this to your listener
pass your main instance class into your listener class using di
usually in its constructor
so you can store it in the listener and give it to the method later
or you can use a static singleton, but we will hate you
so use the constructor method
(di)
does this work?
probably not
return this;
}
like this?
that's going to give you like an ItemStack{STONE x 23} or something
no, not quite
class MyPlugin extends JavaPlugin {
onEnable() {
new MyListener(this);
}
}
class MyListener implements Listener {
MyListener(MyPlugin plugin) {
Bukkit.getScheduler().runTaskLater(plugin, );
}
}
like this
- you are using a deprecated method (that has a replacement)
- use better naming conventions
- why are you doing String.valueOf
yeah then I can use Material
What?
you pass your MyPlugin instance to the MyListener
which then passes it to the scheduler method
is .getItemOnCursor the new method?
oh .getMainHand
then getItemInMainHand()
OOOOOH
It shouldn't have taken me this long to understand
noob moment
this is object oriented programming 101 so make sure to commit it to memory
ik I just haven't had much practice with actual coding yet
just remember that everything is always an object
Yep
Is it normal to have like 20 imports for one small class or is there a better way to do it?
I'm using all of them*
This is the right way to reset a bossbar if it's value is over the max? I'm having this repeat every second and I want it to reset if the bossbar (10 segments) reaches it's max amount:
if(myBar.getProgress() == 1) {
myBar.setProgress(0);
}
myBar.setProgress(oliviaBar.getProgress() + 0.1);
Having many imports is fine. No problem.
if it's unused imports chuck em
myBar.setProgress(oliviaBar.getProgress() + 0.1); <- this will overwrite progress from resetting the bar.
If you want the bar to reset then make sure thatoliviaBar.getProgress() returns 0
but i've seen hundreds of imports before
I meant to write
if(myBar.getProgress() == 1) {
myBar.setProgress(0);
}
myBar.setProgress(myBar.getProgress() + 0.1);
I have no idea where tf oliviaBar came from LMAO
Solves all the problems: import java.*; import com.*; import org.*; import net.*;
granted that doesn't mean you should aim for a shit tonne of imports
dear god I hate wildcard imports
btw pls dont
Yeah this looks alright.
cool thanks
probs not
I think you need to edit some compiler settings. Then it works
import *
Luckily that is not how java works
Not with that attitude
anyone know a way to give a player spectator mob effects? like the ones you get when left clicking them in spectator mode
it'll probably be quite hacky but idm
Set them in spectator and let them spectate the mob 😄
You mean applying a shader?
yeah well i need to remove the mob and make the player keep it ig
Oh you mean the visuals only?
ya
thanks, i'll look into that
You'd likely make the player spectate the mob, but that will cause a few other issues
ig ill have to use protocollib?
Or NMS
ah ye
Create a dummy player, delegate all packets to the dummy instead of the player. Set the actual player in spectator mode and let him spectate/control the dummy.
Reflections also does the trick
I'm not very familiar with this part of plugin development so i'll have to do some research 😓
However you'd need to make the client assume that they are controlling a creeper/enderman/etc
This is very advanced. You need to create a fake player npc and do a lot of packet intercepting. If you are not experienced then you should
probably refrain from approaching this.
:/
well he's not wrong lol
public Entity getClosestLoot(Location l, double r) {
Entity e = null;
for(Entity entity : l.getChunk().getEntities()) {
if(entity instanceof ArmorStand && l.distanceSquared(entity.getLocation()) < r) {
e = entity;
}
}
return e;
}```
is there a simpler way?
r, l, e ...
then name it like that 😄
That won't work if the entity is across a chunk border
the chunk thing is not really viable as a location can be on the corner of a chunk.
thanks for that statement, then i need get all entities in world
something that makes me agonized
public Optional<Entity> getClosestTo(final Location location, final double radius, final Predicate<Entity> filter) {
return location.getWorld().getNearbyEntities(location, radius, radius, radius, filter).
stream()
.min((e1, e2) -> (int) (e1.getLocation().distanceSquared(location) - e2.getLocation().distanceSquared(location)));
}
might need to swap e1 and e2. Im not 100% sure if this returns the farthest or closest one.
Or in simpler terms:
public Entity getClosestTo(final Location location, final double radius, final Predicate<Entity> filter) {
Entity closest = null;
double shortest = Long.MAX_VALUE;
for (final Entity entity : location.getWorld().getNearbyEntities(location, radius, radius, radius, filter)) {
final double distSq = entity.getLocation().distanceSquared(location);
if (distSq < shortest) {
shortest = distSq;
closest = entity;
}
}
return closest;
}
streams 👀
Sb knows the way to set daylight detector on/off ?
where have u been
i'd try looking into Powerable but idk
or AnaloguePowerable i guess would be more appropriate
i was taking a break while I spawned in a horde of alts to hide in paper
i've been to the paper serbur occasionally but spigget gives me pimples so I've been avoiding it
not to be a total noob or anything, but the tutorial I'm following has this I assume to import the spigot API but it won't work for me. Note is I'm pretty sure he's using 1.15.2 or something and I
'm using 1.16.4
sent message early lol
Are you using maven or gradle?
paper discord is shit
you're probably not depending on it properly
not sure tbh with you
If maven, send you pom.xml, if gradle send your build.gradle
paper discord is alright if you can get past the horde of noobs that ask dumb questions
Do you have a pom.xml or build.gradle?
Yes, DaylightDetector interface extends of AnaloguePowerable
But which thing I need to cast ? (i have b my block)
I assume you use neither, in that case, use one of them
..how?
i dont have intellij idea i'm using eclipse
get fucked then i guess
alright ty
It is severely outdated though
most eclipse related things are
like nobody uses eclipse these days, except the old beards
First of all use Java 11 or 15, Java 7 is outdated af
or at the very least 8
eclipse is great
Then, use org.spigotmc as the groupId and spigot-api as the artifactId; bukkit is no longer published since 1.16
@worldly ingot
I also use it lel
i think it is 15
there are like 4 people that I know that use eclipse
Then use Java 15
wdym
Just note that you have to specify it in your maven config
i just said i think im using java 15
Read the guide first
Then follow all the changes I proposed
I also will edit that guide soon (TM) once I find out what my credentials are (and hopefully I have edit perms there) to update it to 2021
doesn't make it bad, just makes it subjectively worse
https://maven.apache.org/download.cgi which do i download
I already did the Screenshots (surprisingly there are absolutely no changes outside of look&feel despite the screenshots being over 6 1/2 years old)
Eclipse has maven built-in
oh
So far I always blamed gradle since it does not want to run newer versions of java
Eclipse is trash in general
nah
IDEA for the win
eclipse is objectively just fine
Eclipse is not trash
Eclipse is great. Its all personal choice but to state one is better is very subjective.
IDEA also has issues (very poor performance) that could render it unusable for a few people
i personally prefer eclipse over ij by a large margin
ij just has more features and is less clunky so i'm forced to use it over eclipse
which is a travesty
ij is too heavy and too full of eyecandy and useless shit
very true
If i was programming for a living I'd be using IDE. As a pass time its Eclipse all teh way
I can't even test plugins anymore because of intellij
in conclusion everything fucking sucks
Ah, it's JFX that causes this?
Words to live by
Good to know
looks nicer tho
How update light use ChunkSection?
You should word your question better...
I've replaced a bunch of blocks using NMS but the lighting needs to be recalculated. How would I do that for a specified area?
how update light use chonbk section!!!
wut... why?
You know there is a slightly slower method that does update the lighting?
maybe depend on worldedit and let their api worry about it for you 👀
I use 3 metod with this link but this metod don't update light
isvalidenum is removed?
Why not use the slower method and not have the lighting issues?
I use chunkPacketEditor and better use PacketMultiBlockChange
Method 2 is still a LOT faster than vanilla but it handles lighting
realy?
vanilla 60k. method 2 2.19 million.
how do i damage entities in a radious?
I got nearby entities
but now i want to damage them
loop through them
spawn a tnt at their feet
but this metod update light?
or an anvil above them
Yes it updates lighting
give me moment I must check this xD
@eternal oxide but problem I use 1.12.2 and this metod don't work on 1.12.2 maybe you have metod to update light with ChunkSection?
There is an issue :
if (!(b.getState() instanceof DaylightDetector))
return;
When I'm clicking on the daysensor, it returns (I've printed things for each step to make sure it's here that function returns)
find the correct method its no longer data
did you try it with block data instead
Tested it - it throws java.lang.IllegalArgumentException: Progress must be between 0.0 and 1.0 (1.0000000953674317)
Floating point math 🙃
are you sure you're importing the correct DaylightDetector class
Wait so e.damage(20) works?
One where I can set power : import org.bukkit.block.data.type.DaylightDetector;
idk it says cannot resolve damage in entity
org.bukkit.block.DaylightDetector is the state one
use getBlockData or whatever it was instead of getState
cast to damageable
there are some weird instance relations in bukkit
like all ItemMetas being damageable despite damageable being a different interface
@eternal oxide I used the chunkSection method and I have now in so many place no global cord (264, 50, 50) I have local cord in section (14, 2, 2)
That looks like English
yea I know my Enlish is terrible ;/
Yeah, I have no idea what you were saying 😦
Huh it says cannot resolve symbol entity
I have code for sections all over the place
in all place (x&15 , y&15 , z&15)
will change it for a long time; /
is this allowed? @EventHandler public void onPlayerHit(EntityDamageByEntityEvent && EntityDamageEvent e)
I can check if the lighting works with this method and latter copy this
you register this?
Won’t even compile
like if I wanted to delay an event for 20 ticks
for example if I hit something, 20 ticks later the hit event would happen
moment what? (EntityDamageByEntityEvent && EntityDamageEvent e) it is posible? xD
You mean your code would run 20 ticks later?
yes
Use the BukkitScheduler
ok ty
Bukkit.getScheduler().runTaskLater(plugin, () -> {
}, 20L);
ok ty
You tried to create a new instance of your plugin
instead of making new
just make it this
so like dasymaManager = this;
wait
no
im dumb
it says Main line 10
its cause i named it main
In either your listener or your command you use new Main
oh
whtf?
[23:19:58] [Server thread/WARN]: [RutbeSistemi] Loaded class net.turkgamerz.main.Main from BossBar v1.0-SNAPSHOT which is not a depend, softdepend or loadbefore of this plugin.
it about BossBar v1.0-SNAPSHOT?
would I put the thing I'm delaying in brackets?
Bukkit.getScheduler().runTaskLater(null, () -> { /* Do I put the event I'm delaying here? */ }, Knockback.getInstance().getConfig().getInt("delay-of-kb-players"));
or, you have two jars of the same plugin in your plugins folder
Are there any built in placeholders?
you can not pass null as your plugin
your plugin instance
this?
yes if its in yoru JavaPlugin class
kk
ty
Would I put the event that I'm delaying into these brackets? Bukkit.getScheduler().runTaskLater(this, () -> {/*event go here?*/ }, /* Int goes here*/
ok ill try
what is your api version?
sorry, Im new to coding plugins, is that the version of my spigotmc library?
That line is not producing that error
all you are doing there is getting teh Material of the item in hand
Would I have to make a bungeecord plugin if I wanted cross-server teleportation?
are you trying to remove teh item in hand?
no, all items in the inventory
with the same type as that in hand?
Bukkit.getScheduler().runTaskLater(this, () -> { p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getInt("knockback-of-players")))/*/It expects a ";" here*/}, Knockback.getInstance().getConfig().getInt("delay-of-kb-players")); what do i do it expects a ;
Yes, if your Spigot is the correct version
if it is what youre looking for, I have Spigot 1.16.5-R0.1-Snapshot
else use remove(new ItemStack(sellitem_material));
wouldnt I need an amount then?
is there method to update things (each tick) during all period server is online ? Or I need to use Bukkit runnables ?
but since its an itemstack its only gonna remove the stacks in the inventory that are exactly the same, including name and stack size
wouldnt it?
runnables/scheduler
Could u show all ur lambda function ?
it won;t care about stack size
ok but I still need all items of the type, not depending on any other metadata, only type
then remove material is the one you want
ok and its not working. how do I check my api version if its not this one ^^
actually no, you can use material or ItemStack. It only matches on Material for both
It seems really dirty no ?
It's to update Custom block TE
hmm okay
I'll try one sec
The API will be whatever you set in your pom
1.16.5-R0.1-SNAPSHOT
no, he's trying to do Material#remove
then remove material shoudl be good
lol, you need to do Inventory remove
I can;t see his code too well. He uses screenshots that I can;t read
How get chunk with chunkSection?
nmsWorld.getChunk()
but with chunkSection?
What is chunkSection
I have no idea what you are calling chunkSection
class ChunkSection xD
Bukkit.getScheduler().runTaskLater(this, () -> { p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getInt("knockback-of-players")))}, Knockback.getInstance().getConfig().getInt("delay-of-kb-players"));
whats the nms path?
?paste
then I have to change the constructor
Lambda are functions :
For example, if u're lamba is function f(x) = 2x
it would be :
(x) -> { return 2 * x; }
@wide current Here is the entier thing: https://paste.md-5.net/ifozezecuq.coffeescript
oh ok so
x -> 2 * x 😔
so would I not use a lamba?
lambda methods with 1 line dont need {} and ;
but lambda methods with 2+ lines needs
Yes, but who care when u're not doing maths
what I'm trying to do is have a delay on someones knockback
rubbish
Bukkit.getScheduler().runTaskLater(this,
() -> { p.setVelocity(e.getDamager().getLocation().getDirection().multiply(getConfig().getInt("knockback-of-players")));
});
how do I easily get the total amount of items matching a Material in the inventory of player?
It's only more clear, but it works in 1 line
that's true
runTaskLater says it can't resolve expressioon
Yes, too much )
Put only 1
Is it normal for the onEntityInteract event to double fire?
Because it looks like it's double firing
You can only access fields outside the runnable if they are final
I am confusion