#help-development
1 messages · Page 2214 of 1
Im trying to make a sentry thing on the player, when you stop moving and look around it shoots arrows, but im getting a heck load of excessive velocities and the arrows dont aim towards mobs just shoots diagonally up in the same direction
@EventHandler
public void onMove(PlayerMoveEvent e) {
if (!playerLocations.containsKey(e.getPlayer())) {
playerLocations.put(e.getPlayer(), e.getPlayer().getLocation());
return;
}
Location l = e.getPlayer().getLocation();
Location l2 = playerLocations.get(e.getPlayer());
if (l.getX() != l2.getX() || l.getY() != l2.getY() || l.getZ() != l2.getZ()) {
playerLocations.put(e.getPlayer(), l);
return;
}
List<Entity> targets = e.getPlayer().getNearbyEntities(10, 10, 10).stream().filter(en -> en.getEntityId() != e.getPlayer().getEntityId()).collect(Collectors.toList());
for (Entity entity : targets) {
e.getPlayer().launchProjectile(Arrow.class, entity.getLocation().toVector());
}
}```
unlikely you'll find a OS one. Too easy for noobs to work around it
NoCheatPlus still around?
I'd add some early returns to avoid excessively checking all the logic if possible
You need to calculate teh vector from shooter to target
Add comments
/**
* Pass a Projectile and a destination
* to set its direction and new velocity.
*
* @param projectile
* @param targetLoc
* @return
*/
public void setTarget(final Projectile projectile, final Location targetLoc) {
final Vector velocityVector = targetLoc.toVector().subtract(projectile.getLocation().toVector());
velocityVector.normalize().multiply(projectile.getVelocity().length());
projectile.setVelocity(velocityVector);
}```
imma be real idek how to solve for direction off of 2 locations
oh
that was a method all this time
Well yeah
its not in spigot
oh
copy that method
totally not spoonfed
totally not 🙂
I'm getting a weird case of deja vu. Where have I seen that code before?
what would the starting velocity be then
because in player.launchprojectile you need to pass in velocity too i think
it crops up in here a lot. Myself and 7smile7 wrote it a long while back as an example
Ah gotcha
yo @eternal oxide, can you help me pls? I'm tryna get some customheads using SkullUtils of CryptoMorin's XSeries (https://github.com/CryptoMorin/XSeries/blob/master/src/main/java/com/cryptomorin/xseries/SkullUtils.java).
Do u know how to get some custom heads by the minecraft texture url value by using this lib?
I've never used any lib
so, how to get some customheads by that value without using any Legacy Item?
do you already have the texture as a Base64 string?
yep
I'm wanting to start a server, but idk what server host to go with. What do y'all recommend
VPS
yeah i know, it's just i didn't know what casting meant before now (like i know what it IS but just not the term) so i didn't understand what the red thing said, my bad
like a name of a server host
OVH
how do i get the coordinates of the nearest structure? like the /locate command
(in 1.19 if that matters)
so?
just playign with code to see how easy it is now
uhhh thatsnks
why would you host servers on windows in first place
um, seems you still can;t force set a texture to a profile, even with the new PlayerProfiles
like 99% servers in the world use unix-like systems
I tried Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "execute as " + sender.getName() + " run locate structure minecraft:fortress"); but that doesnt seem to produce any output
do you also have a signature for that skin?
yeah no signature 😦
can you somehow redirect the console stream to somewhere on the server? for example to the chat?
someone know how to add command when you buy item in economy plugin?
Hello everyone, please tell me, is it possible to do something similar with lore at ItemStack? String.format("String1,\n String2 %s", object)
ok it looks possible, but its far from a beginner thing. It uses NMS and reflection
You need to know how to use Mojang mappings
?paste
If you want to get a head you can do that without NMS
This "should" give you a player head ItemStack https://paste.md-5.net/udiweyupiq.java
but thats using NMS
Why not use the new API?
it has no set texture
It does
?
I want the customhead texture
oh yes, if you have a URL or a texture and signature
^^
sorry yep
Yeah you can just use the API
I'm so used to annoying NMS today
what api
And not that much of a pain in the ass to mess with
I don't want to use some legacy items
I've been deobfuscating premium plugins lately
Nms doesn't even bother me anymore
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/profile/PlayerProfile.html
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/profile/PlayerProfile.html#setTextures(org.bukkit.profile.PlayerTextures)
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/profile/PlayerTextures.html
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/SkullMeta.html#setOwnerProfile(org.bukkit.profile.PlayerProfile)
Here's all you need @green prism
all teh setSkin methods take a URL
exactly, which is why reflection to set a custom texture
Let's say you have this. Simply decode the base64 for the url
?paste
?paste
that's it but i don't want to use legacy skull bro https://paste.md-5.net/eloronotow.java
here is a class to set skull textures from 1.8-1.19
Why use legacy skull
What are you talking about
oh you're messing with NMS again
Use the methods I sent
this
and simply decode base64 for texture link
i'll try and let u know
just use String#formatted like "%s has %s kills".formatted("johnny", 2)
https://paste.md-5.net/ukajuzakan.java
Just fixed this class to actually make it 1.8-1.19 compatible
Im trying to find information to read up on regarding remote processing large resource intensive functions remotely... Would you call it an API? I basically want to sent data to another server and process it there and return processed information. What is this called? I cant seem to find the right keywords to search for more information regarding the topic?
cross server communication
u can use sockets, bungee plugin messaging, possibly redis
Question. if i use Bukkit.getServer().unloadWorld(Bukkit.getWorld(worldName), true); and the world it's trying to unload isn't loaded. What will happen?
depends on what ur doing
?tryandsee
Basically just want to perform some logic remotely to reduce the load on my main server. I don't need to communicate with another minecraft server rather just another machine with extra resources available.
Ohh well you can create an api that works over http or something
Thanks but i came here to ask instead because this feels like something people would know the answer to already which would save me time so that i don't have to write code that probably will fail, then package the plugin, put it onto the server, boot the server (which takes like 2 minutes on it's own) and boot up my game and login and test it
Ok thanks, ill dig into some API research 😄
Well 2 mins just passed so?
So i was busy typing that
Could've been typing code and packaging your jar😂
Just throw it in your onenable and put it in a 1.8 testserver which starts up in 10 seconds
Could be done in 1 min
yeah u can use REST, not sure if it's the best for ur usecase
Awesome, Ive heard and seen all these terms just never really used them and tried to learn how they work.
I just tested that code I sent you. it works
@green prism This is using teh texture you linked me to https://paste.md-5.net/rapazotice.java
Basically trying to create a long range pathfinding system without lagging up gameplay, and of course battling thread safety... fun fun
Why are you using reflection 🙃
u can use another thread if u like
hello could someone send me a script of a game mode for the roles because I am a beginner and I would like to know what it looks like ty
and then use a bukkitrunnable to return the the main thread and set whatever
I get so confused when it comes to scheduling and async stuff.
because I see no other way to set a texture
Link. Decode that base64
Using a callback of sorts correct?
yep
. @eternal oxide
Callback<Result>
I need to look into those as well.
I've read somewhere that doing that by link is much slower because of mojang servers speed
one sec, i can show u how it's done in my plugin
Is a callback similar to an api returning processed data?
It's literally the same thing
ah
thanks bro!
is it possible to create fake players using the api?
spigot bad
ProtocolLib
nms good
u will also have to use callback and async stuff with an api
public Callback<EnderChest> getEnderChest(String name) {
CaselessString mcName = new CaselessString(name);
if (this.nameUUIDMap.containsKey(mcName) && this.uuidEnderChestMap.get(this.nameUUIDMap.get(mcName)) != null)
return Callback.withResult(this.uuidEnderChestMap.get(this.nameUUIDMap.get(mcName)));
if (this.nameCallbackMap.containsKey(mcName))
return nameCallbackMap.get(mcName);
Callback<EnderChest> callback = new Callback<>();
this.nameCallbackMap.put(mcName, callback);
Bukkit.getScheduler().runTaskAsynchronously(this.getPlugin(), () -> {
EnderChestSnapshot snapshot = this.dataManager.loadEnderChest(name);
EnderChest enderChest = snapshot == null ? null : new EnderChest(snapshot.getUuid(), snapshot.getName(), snapshot.getContents(), getInventoryNames(snapshot.getName()));
Bukkit.getScheduler().runTask(this.getPlugin(), () -> {
this.nameCallbackMap.remove(mcName);
if (enderChest != null) {
this.uuidEnderChestMap.put(snapshot.getUuid(), enderChest);
this.nameUUIDMap.put(mcName, snapshot.getUuid());
}
callback.setResult(enderChest);
});
});
return callback;
}
look at how u can use callbacks
callback is a class i made myself in this case
one sec while I try a simpler
Ok awesome Ill check them out, thanks for the example!
u create a callback object which u return, u then create an async task which does the heavy stuff and then u create a sync task and set the result of the callback so that the callback result stuff can be executed sync
CompletableFuture lol
and it can be simplified that code
yeah could also use CompletableFuture there
wont i have to use a runnable to return to the main thread?
ah
if i return a completable future, i'll have to use a bukkitrunnable wherever i call the method so that i can return to the main thread
why does player.getWorld().locateNearestStructure(player.getLocation(), StructureType.NETHER_FORTRESS, 10000, true); always return null?
are they in the nether?
yes
Same way you download anything else
Is there a special place to download it for minecraft?
or do I just use this lol
this is not going to be a valid url
ty
I have a method to do this
Just did a quick search on CompletableFuture and it looks like Callbacks are still necessary?
The base64 is a json containing the URL. That's how the client knows what skin it is
none of those return a URL
reason i use callbacks is so that i return to the main thread
last one returns a string
public static String getUrlFromSkull(SkullMeta meta) {
try {
GameProfile profile = ((GameProfile) profileField.get(meta));
if (profile == null)
return null;
Optional<Property> optional = profile.getProperties().get("textures").stream().findFirst();
if (optional.isEmpty())
return null;
return new String(Base64.getDecoder().decode(optional.get().getValue().getBytes())).replace("{textures:{SKIN:{url:\"", "").replace("\"}}}", "");
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return "";
}
eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTlmMTFjMGQ0OTdmMjI3MDg5Y2JmNjE0NjAxMTA5Y2FmNjE1NDUzOTQwZWY1ZjY0ZWJiMTc3OTU3ZTRmYTZlNSJ9fX0=
From the example above gives this
{"textures":{"SKIN":{"url":"http://textures.minecraft.net/texture/a9f11c0d497f227089cbf614601109caf615453940ef5f64ebb177957e4fa6e5"}}}
Simply take that link
Looks like discord did something
just having teh link is no good. I need to generate teh URL with just the texture
Use this link
wdym?
I don't see the problem
You are not following. "just use this link" is no good
you have the link to the textures
Why not
We have an encoded Base64 texture
i dont see what you need
to set that as a texture in the profile we need a URL
convert from Base64 texture to URL =
Base64 -> JSON -> get url
No, PlayerProfile requires a URL. Internally it uses teh Base64
I still don't see the problem?
but u can get the url with this method
Yep thasts what I did. But Olivo seems to be saying I can use this Base64 texture and get a URL
u can
Let me write it for you ElgarL
new String(Base64.getDecoder().decode(base64.getBytes())).replace("{textures:{SKIN:{url:\"", "").replace("\"}}}", "");
like this
ah I didn;t decode
trying PlayerProfile
ok
this gets the url frm the base64 string then
Thanks ElgarL for your work! ❤️
is there any documentation for mojang mappings like spigot api
No javadocs no
Not a valid URL
as that is JUST the texture
wdym JUST the texture?
guys, im in 1.17.1 (i MUST be on that version) and i dont have the hideEntity and showEntity methods so im making these by hand. This is my current code:
NPC.java: https://paste.md-5.net/ixofegafak.java
NPCListener.java: https://paste.md-5.net/quxefatuzo.cs
Configuration.java: https://paste.md-5.net/otoyadecov.php
Basically, when i first create the npc (NPC#spawn) it works fine and i can right click the entity but when i despawn it for the player (NPC#hide) and then show it again (NPC#show) i cant right click the npc anymore.
What can i do to fix it?
can u send the "texture" ur trying to get the url for?
my bad, use this
public static String getURLFromBase64(String base64) {
return new String(Base64.getDecoder().decode(base64.getBytes())).replace("{\"textures\":{\"SKIN\":{\"url\":\"", "").replace("\"}}}", "");
}
🧐 🧑🌾
get url from base64 texture string
replaces? they shoudl not be in teh decoded string
they should, because that's what gets added to the string when u encode it
isn't more easier use split?
probably
still no good
Caused by: java.lang.IllegalArgumentException: Illegal base64 character 3a
That String I posted is JUST the texture
bruh what are you doing
The issue is the : (By stackoverflow)
its teh texture without the {"textures":{"SKIN":
You are getting a String fine. now get a URL from that
{"textures":{"SKIN":{"url":"http://textures.minecraft.net/texture/a9f11c0d497f227089cbf614601109caf615453940ef5f64ebb177957e4fa6e5"}}}
U need that url no?
from decoded
just replace or split by "
and here u go
seems sloppy
Better than reflection
true
actually that shoudl be valid json
That is valid json
sure
I've been saying that this entire time 🙃
How do you detect if an item has been thrown into the void?
That would be a bit hard
check the item a few ticks later maybe
if(e.getItem().getLocation().getHighestBlock != 0)
no?
after a few ticks tho
when the velocity is no longer horizontal
How do I check if a block is a source block for water or lava? Some old answers were saying check if Block.getData() returned 0, but that method is deprecated now.
@eternal oxide, how u doing? did you make it?
still messing with it
Should I just make it instead?
Nah I'd shoot you 🙂
I really should this is the third time I have explained this step by step
I can have an example next time
Your step by step is lacking
can you explain it to me again? lmao
what dont u understand elgar
not enough
u have base 64 string
u decode and get {"textures":{"SKIN":{"url":"http://textures.minecraft.net/texture/a9f11c0d497f227089cbf614601109caf615453940ef5f64ebb177957e4fa6e5"}}}
I'm just having problems decoding the json now
The exact methods to use are enough no?
probably
split("\ "")[6]
nah its json, shoudl process it as such
think its 7 but ye
it starts from 0 I think
it does
so 7
um, not sure I like that
json has keys for a reason
help
who cares if json has keys
^
I care. I'd like to do it properly. no shortcuts
actaully using gson is more inefficient
since ur parsing the string into a json object
from org.Json
Iterator<?> keys = json_array.keys();
while( keys.hasNext() ) {
String key = (String) keys.next();
System.out.println("Key: " + key);
System.out.println("Value: " + json_array.get(key));
}```
whaat
FourteenBrush
if somone has experience with GCP, can you help me out? im hosting my server on gcp linux and my plugin uses mysql but im not sure how i can get a localhosted mysql database on gcp
rock, paper, scissors?
so what do u want?
if json is ugly and splitting is a shortcut
just dont set a skin then
What event should I use for this?
use alex or steve
PlayerDropItemEvent
coded it
Example:
public void onPlayerDropItem(PlayerDropItemEvent e) {
if(e.getItem().getItemstack().getType().equals(Material.SLIME_BALL) {
Location slimy_location= e.getItem().getLocation()
// etc
}
}```
or use the api of skullmeta.setOwningPlayer
has 1.19 broken custom inventories in some way?
mojang probably uses split too lmao
one of my inventories just doesn't open
no error
the function opening it runs
but nothing happens
wtf what does that means case Rock -> this == Paper;
and it looks as if the inventory opens for a split second and directly disappears again
I should clarify, I want to detect if the item is in the void no matter what dropped it (player, dispenser, etc.)
brUH remove the itemstack type if
bRUHHHH
Wdym
takes a deep breath
if othe other is rock and this is paper, it wins
I need it to work for one particular item, not all items
checks if the other did rock then you have to do paper to win
And it may not always be dropped by a player, it could be dropped by something else
public void onPlayerDropItem(PlayerDropItemEvent e) {
if(e.getItem().getItemStack().getType().equals(Material.YOURFAVORITEMATERIALRIGHTTHEREOKAY?) {
if(e.getItem().getLocation().getHighestBlock < 0) {
player.getInventory().add(e.getItem().getItemStack())
}
}```
Why do u need to know if an item is in the void?
I don’t want it to get destroyed, I want it to be returned to a player
Bro i just sent to you the method
That only works if the player himself drops it, right?
What if the player uses a dispenser, or other method
he's a stupid mf
@steep nova Example
public void onDispense(BlockDispenseEvent e){
if(e.getBlock().getType() == Material.DISPENSER){
//Your Code
}
}```
Hello guys, I have an issue with my maven local repo. I am trying to use spigot-api 1.19 but I don't understand this error:
I am using gradle and here is what it looks like in my config:
compileOnly group: 'net.md-5', name: 'bungeecord-api', version: '1.17-R0.1-SNAPSHOT'
that's not 1.19
So I would have to go through every single way someone could drop something into the void, and make a listener for it
wow sorry wrong line
compileOnly group: 'org.spigotmc', name: 'spigot-api', version: '1.19-R0.1-SNAPSHOT'
here is the correct one
Probably
if there isnt a itemdrop event universally then yes you will
Thunderin the best
bump, does anyone know why this could happen
./locate command works
use maven if you like kids
no, just use itemspawnevent
itemspawn isnt the same as itemdrop i thought
Called when an item is spawned into a world
its when an item gets spawned, not dropped
i mean yeah, but if you want to listen for every way an item can appear you would use that
if you only want to listen for when a player drops an item, then theres really only one way they could
OK this is weird. The URL is correct now, but it doesn't set the skin https://paste.md-5.net/evacoxelur.java
im not sure if when a item is dropped (no matter the source), this event would get triggered
only one way to find out!
can i come with?
if somone has experience with GCP, can you help me out? im hosting my server on gcp linux and my plugin uses mysql but im not sure how i can get a localhosted mysql database on gcp
I didn;'t even set the meta 🙂
doesnt look like its setting the texture of the head anywhere
JsonObject json = JsonParser.parseString(jsonString).getAsJsonObject();
JsonObject textures1 = json.get("textures").getAsJsonObject();
JsonObject skin = textures1.get("SKIN").getAsJsonObject();
String urlString = skin.get("url").getAsString();
If you want to use json
Yep I worked that out, then went with replace. was cleaner 😛
Lmfao
apparently locateNearestStructure is just broken? https://www.spigotmc.org/threads/world-locateneareststructure-always-returns-null-for-certain-structure-types.550731/
Hi!
Looks like we wasted our time on this one. @green prism is using 1.16.5 and doesn't have the api
How could I create an event for a custom inventory, I mean how I could detect my custom inventory without using the getHolder or getTitle /Name function?
https://paste.md-5.net/gafamereto.java now working
what would be the best way to append all of the args after an arg to a string
you could use Arrays.copyOfRange to get all the args in a certain range, then use String.join(array, " ") to join them together
don't see why you would need another way to do so
use the instance of it
^
thx
well i need to use getHolder then
no, just need to compare the instance of the inventory to another
this.inventory.equals(e.getInventory) returns true or false
lets say you have a custom inventory, whenever you create that inventory you could add it to a Set somewhere. then, you have a listener for an inventoryclickevent, when that fires you iterate through the inventories in that set, see if theres one there that matches the inventory in the event, and if so you trigger a method in that custom inventory
hey guy so did just bungeecord-chat repo got down? its can't find for me on build :(
the problem is that my inventory is not static and when im using this, its a new inventory is created
like a new instace
separated from the opened inventory
menu = new menu();
yes, so youll want to do something like this where when the menu is created its added to a set somewhere
so that you have a reference of it that you can track
yep, that's exactly what i wanna do, BUT
ok since this apparently doesnt work using spigot api, can someone help me how to get a TagKey<Structure> in nms so i can call ServerLevel#findNearestMapStructure ?
im doing something wrong
wait is this a for loop?
no
@eternal oxide, anyway in the end, I’m in 1.16.5 and I found thanks to Olivo that the method he thought was too advanced for my technology of the twentieth century... now I will use your method thank you very much for your help!
np it was fun to be baffled for a bit
can any suggest a good particle for displaying a region?
bassically a box of particles
wat
I don’t understand if it’s me or it’s that I haven’t slept for a while... I can’t understand ahaha
wait so im confused is array supposed to be the Arrays.copyOfRange thing? last time i checked Array isnt a CharSequence
i might have got the order wrong on the arguments, try String.join(" ", array) instead
is static itemstack a memory leak?
just asking if any1 knows another good particle for stuff like this https://gyazo.com/9334afdc57ffc5022af17a41fda0e5aa
it seems the best xd
hi guys, I added a value that players can change at will.For example, whatever is written as the 1st argument in a command is the value. But when the Player makes a 2nd action, the preset value remains constant. how can i reset the value after it's done with the command
if somone has experience with GCP, can you help me out? im hosting my server on gcp linux and my plugin uses mysql but im not sure how i can get a localhosted mysql database on gcp
does anyone have a good "guide" on how to make scoreboards?
the javadocs
not realy
When was PlayerProfile added 1.17?
probably nms
nah its spigot
they should suffice
it was around 1.17 not sure if before or after
but else there's a wiki
1.19 i think
Is something wrong with my playerjoin class? https://pastebin.com/x1W4C792
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
pretty sure 1.17 yea
its not sending the message when i join
I'll comment it 🙂
See https://www.spigotmc.org/wiki/using-the-event-api/
Your listening methods must be annotated @EventHandler
Hey gaymers, say I have a list of yml inside a container like this. How would I be able to get all the UUID's inside of it?
@ivory sleet nvm ur right
maybe i should not forget the annotation for a eventhandler yes im dumb
ok ty
are those access tokens
or what are those
lol, pulled that one too not long ago
config.getConfigurationSection("guild-list").getKeys(false)
yay ty
U should store those stuff in a db tho
please, has no one here ever used locateNearestStructure before
it seems to just not work at all
Not yaml
but yaml cool
Quick question, can I cancel a player's attack on another entity?
- if ppl want to they can edit it
EntityDamageByEntityEvent
Modifying serialized data can corrupt it
i mean like whos in who
this is the full file
so if ppl wanna edit the players portion they may
You do whatever suits u
alr alr 😛
Personally, I'd use a db
well I tried this way, I add this method in Main class
public Inventory getItemsMenuInventory(int ID) {
return itemsMenu.getInventory(ID);
}
it seems to work, but i dont know if its right way to do it
That'll work
What is a Set
Depedns on the usecase, there may or may not be a better way
Think a list but unordered
ah perfect
So u can't get any specific thing
Just get all and iterate, check if it contains and remove and add
Thanks
if somone has experience with GCP, can you help me out? im hosting my server on gcp linux and my plugin uses mysql but im not sure how i can get a localhosted mysql database on gcp
minion
Hi
^^
i thought u were the db man
thats fine
ubuntu works
i can migrate at any point so if you can help, thatd be great
I setup my db by followong an online guide
yeah me too, i got to the point where mysql-server is installed but im stuck here
just made a quick example on how this could be done, try looking at this to see if it helps at all https://github.com/DeoTimeTheGithubUser/CustomInventoryExample
Gotta set up the root user iirc
Watching a yt vid might be your best bet
do i have to set a password? ill have to make changes to the plugin for that if i do
I think u do
Instead of extending craftinventory
U can implement inventoryholder
And check if the holders match in the listener
It's also not version specific
thanks, i'll check now
That's not the best way sergiu
Using inventoryholder is not the proper way keeping track of inventories, many people use it as a quick way though to see
Why not?
How do I locate the nearest Nether Fortress?
World#locateNearestStructure always returns null, even though the /locate command itself is able to find it
using Bukkit.dispatchCommand to execute /locate doesnt produce a result
And lastly, I cant figure out how to use nms to do it because it requires a TagKey<Structure> and idk how to get that
please i have been trying to do this for so long now i need help
Because that's not what its supposed to be used for, and people abuse it as a way to check what type of an inventory is when using instances is a more reliable way
The post u sent showed how they did it using nms
this was not for 1.19
Should work the same
it seems to have changed a lot
i did that
yea
i did that
but it doesnt work out
how do i get a TagKey<Structure>
See how the command gets it
its a whole bunch of other shit that i dont know how to get
Maybe it isn't but it gives the same result regardless with way less work
Cant help as I'm not at my computer rn
Sorry
You might get the same result for a while, but its using the api in a way it shouldnt be, plus going about it in an OOP way gives you more room to expand, which is what youll see a lot of gui frameworks doing where there are custom item click events and such
It's basically the same thing though as long as your implementation has one holder per inv
You have noted teh javadoc says This will not load or generate chunks. This can also lead to instances where the server can hang if you are only looking for unexplored structures. This is because it will keep looking further and further out in order to find the structure.
Less work != Better
yea but that doesnt help or change anything? what are you trying to say
I'm saying if the chunk is not loaded or not generated it will not be searched
as far as i understand it, it just says that it will not generate chunks, but is still able to search in not-generated chunks
but either way, it still doesnt work when literally standing inside a fortress so that doesnt really matter
ok thats odd
Would it be problematic to frequently check and update player metadata? On playerMoveEvent, entityDamageByEntityEvent, entityLaunchEvent etc.
use PlayerMoveEvent as little as you can
I'm assuming it can cause lag?
one by one
Go to each world and run the command world be the easiest
maybe a shell script?
declaration: package: org.bukkit, interface: World
the 1st image is the id of the entity (Entity#getEntityId) when it is spawned
the 2nd one is the id of the right clicked entity in the event
the 3rd is me getting the entity id inside a packet listener I wrote
I spawn the entity and I can interact with it. Then some things happen and I send a destroy packet to the player and after a few things, I send the spawn packet for the packet listener to work. Lets say the entity id when it spawns is 10. When I right click it, the printed id is 10. When I right click again (after the destroy and spawn packet) the printed id is also 10 but when I try to get the entity based on the id by looping all entities, it never finds the entity I want. Why does this happen?
youd have to write a script to launch each world, change the rule, then close it
Just use the API
seems unnecessary. how many worlds do u have
def unnecessary lol
but no harm in practicing code stuff
gotcha
sooo i need some big brains. say I have a List of locations and 1 location inside that list is an origin point i'm trying to look for a good way to sort that list so the locations will spread from that origin point here is an image of what i'm trying to do in 2d space, i'm looking for an efficient way to do this in 3d space https://gyazo.com/07dadf5b0fa540d5b1b884d877bc8aed
thanks in advance.
i feel like i gave a pretty clear explaination
i might just be small brain
p new to spigot anyway, I hope someone helps find a solution
are these locations connected (ie Blocks)?
yeah like i cant see a pattern
1,2 are on equal distance
why does this remind me of zombie barricade spawning
i forgot -,-
are these locations connected (ie Blocks)?
ah nvm
yes
thought it might be significant
then its simple. I already did a class for that
one sec while I find it. I did it for finding sequential claimed chunks
sure
?paste
I'll post teh whole class and you can pull from it if you need https://paste.md-5.net/deyotakipu.java
this uses a WorldCoord system. Basically chunks
im not sure i understand how i willl use this right away.
getPlotCardinal and getPlotOrdinal get claimed Plots around an origin
getPlotAllConnected uses those methods to tree search all connected plots
yep
why am i getting this error from @EventHandler public void onRightClick(PlayerInteractEvent e) { if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) { ArrayList<Material> materialArrayList = new ArrayList<>(); for (String materials : Kits.getInstance().getConfig().getStringList("blocks")) { materialArrayList.add(Material.valueOf(materials.toUpperCase())); } if (!materialArrayList.isEmpty()) { if (materialArrayList.contains(Objects.requireNonNull(e.getClickedBlock()).getType())) { Player p = e.getPlayer(); p.openInventory(GUILib.getGUI()); } } } } - [21:22:12 ERROR]: Could not pass event PlayerInteractEvent to Kits v1.0-SNAPSHOT java.lang.ArrayIndexOutOfBoundsException: null thats it btw theres nothing else
that code is not throwing that error
yeah it is wdym
Please throw the whole stack trace into a pastebin
Yeah that's not being thrown by this method
... but thats the only event in my plugin
Nothign in that code accesses any index of an array
tf then why would i be getting that error
Also do a null check don't use Object.RequiresNonNull
post the full stack trace and we might be able to tell you. There is more to the error
In a DropEvent, I passed on a method the item dropped as itemStack, in that method, doing taser.getItemMeta().setDisplayName("§6§lTaser §e«1»"); , causes no erros, but it doesn't change the name.
getItemMeta returns a clone
no.. thats all thats in my console
that is it
look in your log file
I've done even that.
how do i just get the number then
You have to set teh altered ItemMeta, not another clone
hello can me wehre help
oh nvm
@sage coral
thats also all thats in my logs
1sec restarting server
tip that people in here apparently hate: you can use plugman and autoreload
so you dont have to restart your server every time
Its fine for dev work, but once things break (and they will) always full restart
plugman was the issue after i restarted my server it sent the full error but i got it now ty
🙂
i need the plugin Jlib and it removed on spigot mc and now i need your help . ITS VERRY IMPORTANT !!!
you mean this? https://github.com/johnkingjk/JLib
YES
Very old. for 1.7.9 Bukkit
is the sure code i need this for plugin
im spawning my entity like this and when I right click it, the entity despawns. How to fix it?
what even is that, it was made 8 years ago and has no description in the readme at all
jlib i mean
some mention about packets
No clue. Never heard of it. That was a DDG search "spigot jlib"
interesting that first thing people do is apparently ask on discord instead of googling
and we work it?
Not sure what you are asking
fair, peoples brains are sometimes better than a search engine tho
for finding a library.... which is literally first google result
I have no idea what you are attempting to do. Just get a hold of the jar?
and how is it
open the project in intellij, build and then package
touche
who can help me to make this a plugin
There are many issues with this code
🪦 rip
can you help me?
you should ask a proper question instead of just "can you help"
JLib
I think the problem is that nobody seems to understand what are you really asking for. Or what are you working with. Makes it very hard to help you.
@sage coral ^
thx
I have no idea if it will work though.
I thought he wanted it removed lol
So many type safety warnings and it used a maven plugin that no longer exist
last updated 8 years ago :P
org.bukkit.plugin.UnknownDependencyException: WastedGuns
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:216) [server.jar:git-Spigot-79a30d7-f4830a1]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:305) [server.jar:git-Spigot-79a30d7-f4830a1]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:205) [server.jar:git-Spigot-79a30d7-f4830a1]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [server.jar:git-Spigot-79a30d7-f4830a1]
at java.lang.Thread.run(Thread.java:833) [?:?]
[22:58:28 ERROR]: Could not load 'plugins\WastedVehicles.jar' in folder 'plugins'
cann any me help
um, 1.12?
there's no dependency found
no way that 1.7.9 JLib will work on 1.12
you have to put the WastedGuns plugin in the Plugins folder for it to work ig
it is
Let me know if you get it all working so I can delete this code from my IDE
hows the plugin called?
dont think that it requires a dependency but cannot be found
I believe couldn't load WastedVehicles because WastedGuns plugin was not found
You need to find the plugin called WastedGuns
JConsole should be included in your Java install
how would I make it so if a player doesn't have a certain permission when they break a block it doesn't break?
Player#hasPermission
!Player.haspermssion -> event.cancel
How do you what
PlayerDeathEvent and check for location
e.isCancelled();?
or if you mean you want to spawn them somewhere do it in the respawn event
if its that I need to put something in the perenthesis
do you want to avoid the death screen, or wait for them to click respawn?
yes
what would i put
?events
no
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
they will only be repawnign if they died
?eventapi
i tried doing e.setCancelled(true); it didn't work
Bukkit.getPluginManager().registerEvents(new Welcome(), this); I did this
and yes i did use eventhandler
show your code then?
wait nvm I forgot to do the listener
Is there a way to detect when anything enters a players inventory?
itempickup event
PlayerPickupItemEvent & Certain instances (not always) of the InventoryClickEvent
Ok I have those, but Inventory click wont detect shift clicking items
1.19
java -jar BuildTools.jar --rev 1.19 => "Version not found"
update your BuildTools I guess
canmn wre my help
How would I make it so when do /plugins it shows a message and doesnt show you the plugins
remove the plugins command from the command map
Else they can still do minecraft:plugins
Update it?
Lmao i didnt know i have to update buildtools
my script auto updates mine, so I never have to
it gets updates and fixes occasionally
make sure to also cancel when they use whitespaces in the beginning, I had problems with that before.
ok
You can also unregister from the command map the minecraft:plugins
that too I guess :P
You can completly unregister the plugin command
Also why dont do they do a explicity getter for it? 🤔
I usually replace the commands using the regex: /\s*(.*:) to blank space, then check if the first word matches because I'm lazy
Its ugly annoying using reflections every time you want to access to CMDMap
And for checking emails?
I had to google it everytime
all good, just jk :P
I didn't get mad, I was just joking because I thought you were, there are a few memes in the dev community about the email regex, all good lol ;)
I think you don't need to use reflection for it anymore https://jd.papermc.io/paper/1.16/org/bukkit/Bukkit.html#getCommandMap()
declaration: package: org.bukkit, class: Bukkit
how can make a surecode to a plugin?
all good bro ;)
You can use an IDE to compile it
I'm too stupid for that
Okay, so how you pretend to get a src into a plugin?
Because there is no other way
can someone help me pls. I've spent like 3 hours on this
The version you have requested to build requires Java versions between
Amazing build tools
Is really that i would have to install 1.17 java for compiling a 1.19 spigot
very good
Is not posible to compile it with the JDK 17, instead of java 17?
i think you just responded to the wrong person
Oh my bad
Is it possible to compile spigot 1.19, with JDK 17?
and about this, I have no idea what are you doing, maybe a video of how does it despawn, but really there's nothing weird with your code
And i have already JDK 17 installed
yes, but is it the default version?
Hmn
I have on my system java 8 + JDK 8 and JDK 17
if you want to change your default you can modify the $JAVA_HOME env variable or manually use the binary file of the Java 17 folder when running BuildTools
I think the JDK also installs you the JVM
I think i can do
java path -jar bla bla
Do you still have to register custom entities like you used to?
How do I make a command with spaces
??
it seems that it was because the entity i was using was a monster
and i was teleporting far from the entity
They are called command arguments, a command they are identified as a String[] which basically an array
Arrays start counting from 0
so let say i run: /command <player> <text>
/command => will be your command
<player> => Your first argument, index 0 in the array
<text> => Your second argument, index 1 in the array
Do i explain?
(make sure to check first the length of the array before accessing on one of their indexes ;))
Yeah, that importants too
Because in case, they run your command with 0 arguments, and you are checking if x argument equals to something. Then you will get an exception
this little code here fixes my problem!!!!!!!!
you shoulndt implement your own inventoryholder at all
vault is a dependency in my plugin and i have private boolean setupEconomy() { if (getServer().getPluginManager().getPlugin("Vault") == null) { return false; } RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class); if (rsp == null) { return false; } econ = rsp.getProvider(); return true; } public static Economy getEconomy() { return econ; } whjcih is called when my plugin is enabled but whenever i use getEconomy() its always null, why is this happening? vault is on my server, its a dependency, so this makes no sense ```depend:
- Vault```
you can use an inventoryholder to check to what an inventory belongs
for example in inventory click event, you can get the inventory's holder and it might be a chest
or it's the player itself, when they clicked in their own inventory
you implement your own inventoryholder but you should not do that. Bukkit interfaces aren't meant to be implemented by plugins
you should rather create some custom object to hold information, and then store it inside a map together with the inventory that you want to associate it with
no. the javadocs explicitly say that the API is designed to "only be implemented by server software" and "should not be implemented by plugins"
i always extends invholder to see if an inv is one of my custom invs 🥺
instead of holding a map
why that?
instead of
if(inventory.getHolder() instanceof MyGuiHolder)
you just do
if(myGuis.contains(inventory))
just in the gui class i have a listener that listens for the specific slots being clicked, im not storing the guis anywhere so i havent made it static
anyways i should really go to bed lol
no
gn 👋🥺
4 hours sleep lmao
If you need this, then sure, why not.
However in stuff like INventoryClickEvent etc, you can always get the player using getWhoClicked or getViewers
so I personally needed to store the player too. I simply store a Map like
Map<Inventory,InventoryInformation>
``` or similar. Where InventoryInformation is just an object that holds all the information I need
gaymers how do I like math yo
like say I had a number 3
how would I get 1, 2, 3
or like number 2
how would I get 1, 2
for loop?
nah int stream cringe
you should simply store it somewhere in a field or so
Where can I download bungeecord 1.8.8
forewhom loop >
yeah depends. If you want to get a String "1, 2, 3" then I'd use an IntStream and then Collector.join
if you only need to loop, then just a for loop
yep 😄
It will be competitive with a normal loop once valhalla is delivered :3
valhalla
sounds like brawhala
can I wishlist on steam?
it sounds like some medieval mmorpg
It’s a java enhancement project lol
i know
Or well the name of one
im being silly
Figures
he was previously called imaginedev
yes lol
the class doesn't exist then
(or couldnt be loaded because of exceptions in <clinit>)
it's no problem, it just makes no sense
send the full stacktrace
90% the class doesn't exist, 10% couldnt be loaded because of errors in <clinit>
anyone know a good gun cocking sound combination
lol
it's when you "load" then gun
well not load
when you "make it ready to shoot"
❤️
lol
I mean I was thinking the clicking note blocks would work but they're kinda lackluster
Hi, how can ı change my plugins version? I made a mistake and made it 1.19 but ı want it to be on 1.18.1
In your pom.xml
uhhh how do i use this? is this a event that i can listen to or...? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryAction.html
declaration: package: org.bukkit.event.inventory, enum: InventoryAction
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>desired verison</version>
<scope>provided</scope>
</dependency>```
you would put 1.18.1-R0.1-SNAPSHOT
yeah the program just fixed it
no, that's an enum
InventoryClickEvent is what you're looking for
well i want to have a message send in the console if the player "drops" the item down in a slot
it only fires when the player picks up the item in their inventory
InventoryClickEvent, then check if the action == DROP_ALL_CURSOR or DROP_ONE_CURSOR I think
wait so how do i do that
you needa check if getCurrentItem() is Air and that the item on the cursor isnt* air
nvrm i think i got how to check for the action
its kinda weird, if you click on a slot in your inventory, if theres nothing in the slot it will say its Material.AIR but if you have like a chest open or separate inventory, it will be null
anyone have a non-tedious way to see if a block can be harvested and dropped by a tool
preferably without having to map the tool directly to a block
wait so if i drop a wooden axe in my offhand slot, why doesn't the console say anything? what did i do wrong in this code here
i want the console to send a message whenever i drop a wooden axe in the offhand slot
Because it's not an InventoryClickEvent
PlayerDropItemEvent
You can't drop things from your off hand
I think with "drop into" the offhand they mean equipping it?
yeah that's what i mean, sorry for the bad wording
Gotcha. You want to check the cursor item, not the off hand item
(which can technically be null too, so yeah)
ItemStack item = event.getCursor();
if (item != null && item.getType() == Material.WOODEN_AXE) {
// Do your thing here
}```
Note however that there's also a SWAP_WITH_CURSOR action you'll want to check for
and number keys could work too I guess
^
there's so many ways to equip something
that makes sense, gotcha
ooh yeah that's another thing i gotta cover, thx for reminding me haha
ty for the help!
also the INventoryDragEvent 😛
sheesh
but I think that should be everything
hopefully lol
Is spigot programming is hybrid of Java and C# or its Java and JavaScript?
wat
it is purely java
or well, any language you can get into the JVM
if you wanna use kotlin, that is possible too
oh bruh, i just know C# very good and i just see that java is almost the same lol.
Well yea the syntax is somewhat close ? Tho that is the case with a lot of c style languages
surface layer they are similar but otherwise completely different
this is disgusting
split it up then
okay
ah
Hello, I am trying to create a custom item plugin and I am struggling with efficently registering the items.
I want each item class to have a registerItem method that creates a new CustomItem object with set properties. (this will be run when the server starts)
If CustomItem contains a constructor, it cannot be abstract therefore cannot have abstract methods. How can I force each item class to have the registerItem method?
If this is not the best way to go about this, what else should I try?
Each class should have this:
public static void registerItem() {
CustomItem STARTER_SWORD = new CustomItem(Material.WOODEN_SWORD, "Starter Sword");
CustomItem.saveItemToConfig(STARTER_SWORD.toItem());
}
abstract classes cannot be instantiated though, right?
I am currently using a Builder to create the item (the code was just an example)
right now my code actually looks like
Item STARTER_SWORD = new Item.ItemBuilder(Material.WOODEN_SWORD, "Starter Sword");
just have a public abstract ItemStack buildItem()
then call that on start
doesnt have to be static
or call in constructor
you can still use that builder in the implementation of the buildItem method