#help-development
1 messages · Page 1998 of 1
thank you very much I found world.dropItem
nice :D
Are there any rules that state whether I'm allowed to track which active servers have my plugin that gets published on spigotmc installed?
Like save the server ip and port (since it's unique) and amount of current players that refreshes every hour?
I'd be interested in statistics like that when releasing more plugins.
I saw some premium resources have graphs on their resource page - so I wanna know whether there's any kind of limitation to what data I'm allowed to collect
it would be kinda weird as a server owner
bstats does this but keeps it anonymized
I thought about anonymizing it. The problem is I still need a "unique key" per server. I would say hashing the ip does the job. But since an ip is 32 bit it can easily be bruteforced and "unhashed". Any idea on how to actually keep it anonymized without mixing up data from different servers?
Or in other words: How does bstats do it?
bstats generated a UUID for each server I believe
you could hash the string of the IP instead of the IP itself
does it do that by unique details about the server or is it simply doing #randomUUID() and storing it somewhere?
not sure, but it saves it into plugins/bStats/config.yml
it probably generates a random one I would assume
can you elaborate what you mean by that? From what I understand I could still form all possible ip strings and hash them in a matter of minutes (or probably hours but it wouldn't take long)
Yeah if it saves it then it's probably a random one. Guess I can do that, too. If the server owner decides to delete that file I'll have some messed up data but I guess for the sake of keeping data anonymous that's worth it
You could use some kind of salt/pepper to avoid having the same IP produce the same hash
You could make the salt the hash of the main world UUID
That idea also isn't bad. I probably won't use the worlds name since that's 90% "world" but I can probably find something that is more unique. Maybe the seed of the world
Oh worlds have a uuid? Didn't know. That's great for hashing. Guess I'll do it that way. Thanks a lot!
👍
The world UUID is also more unique than seed
You could in theory do something with the UUID of all the loaded worlds
So that way even if they download a map for the overworld, nether and end would probably be different
But there's still enough possible seeds that I don't have a way to salt every possible ip with all seeds in a reasonable time. But I think UUID is the better choice
Yeah
Also it’s important to note that your plugin has to still work if your backend metrics server goes down
yeah I mean if they swap out a map it will look like a new server. But I can't prevent that without storing it somewhere on the server
Yeah that’s the downside with a somewhat ephemeral fingerprint
ofc. I will keep everything async, won't do it too often and will obviously let it fail silently
There isn't an optimal solution. But I'll think about which of the more or less optimal ones I will take. I really don't need to know which server has my plugin. I just wanna know "how it is used", if that makes sense
Am I allowed to ask questions about coding plugins here or is this channel only for developing the spigot/bungeecord framework itself?
Feel free to ask anything about coding Plugins. That's what the channel is made for
It’s for questions about coding plugins
You could store the hashed value in the config and do error correction on it
So if they modify the fingerprint in the config for whatever reason, you can perform the fingerprint algorithm again and figure out if the change was caused by a world UUID shifting or just randomly editing the key
Since the IP:port would still be the same
All depends on how much you care that the fingerprint is accurate
Since I don't know the old fingerprint after they changed it in the config I can't really determine why it changed. I can only recognize that it doesn't match the one from the fingerprint algorithm for whatever reason
(unless it was changed while the server was running but I don't have to read it multiple times during runtime anyway)
Noticing that it changed (for any reason) gives me the possibility to set a flag inside the database that it might be innacurate atleast. Might implement that aswell
@EventHandler public void onMove(PlayerMoveEvent e) { Block fromB = e.getFrom().getBlock(); Block toB = e.getTo().getBlock(); if (fromB == toB) return; Player pla = e.getPlayer(); //rand is a number generator if (rand != null) { if (rand.nextFloat() < 0.1) { pla.sendMessage(fromB.toString()); pla.sendMessage("To:"); pla.sendMessage(toB.toString()); } } } for some reason the messages are sent even when I don't really change the Block my Location is at
don't compare objects with ==
You have to use .equals() instead
(did i format the code correctly on discord?)
in other words:
change
if(fromB==toB)
to
if(fromB.equals(toB))
unless comparisons with enum constants
You should probably use ```java in the future.
I want to make certain effects when using a totem
this is my code but it doesn't work :(
@EventHandler
public void totemMessage(EntityResurrectEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (player.getInventory().getItemInMainHand().getType() == Material.TOTEM_OF_UNDYING || player.getInventory().getItemInOffHand().getType() == Material.TOTEM_OF_UNDYING) {
for (Player all : Bukkit.getOnlinePlayers()) {
all.sendMessage(ChatColor.GRAY + "¡El Jugador " + ChatColor.DARK_AQUA + "" + ChatColor.BOLD + player.getName() + ChatColor.GRAY + " ha consumido un tótem!.);
player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 300, 1));
This occurs on the entity resurrect event
which is after the player consumes a totem and it saves their life, right?
If I'm right about that, why would you be checking their inventory for a totem that is already gone?
I might be wrong
and looking at the docs, it appears I just might be
I would recommend putting some debug lines before and after every if statement to see how far it gets
You can compare what’s in the config to a newly generated fingerprint at runtime and use that with some error correction to figure out if the world UUID changed or if the whole thing is scuffed up
you're right
no need to check for the totem, it was already removed
unless the event is cancelled
The totem will still be in their hand when the event is fired.
hm but then their code should work
anyway, there is still no need to check for the totem. it's enough to check whether the event is cancelled
Called when an entity dies and may have the opportunity to be resurrected. Will be called in a cancelled state if the entity does not have a totem equipped.
This is interesting phrasing
You're calling that method right
Send the command class
Hm, add some print statements and see where it's not reaching.
That's fine
Where'd you put it

The java doc for that method seems to imply that those are the same. Did that get overridden in spigot or bukkit?
^ this applies to strings too btw
And uh UUIDs
It does not apply to enums since enums are static and therefore only have one memory location
https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-
this method returns true if and only if x and y refer to the same object (x == y has the value true).
Could you give me your link? This one was the one I was using
That's referring to the default implementation
By default, equals is the same as ==. Classes must implement it themselves.
That kind of thing is hard to tell since I've only been looking through the docs
The stdlib's javadocs are more
intelligent than understandable
ig it's fair
They pack a lot of precise information
(Just not easy for newcomers to read, imo, although most of the time I fail to understand programming docs bc of their big words)
hello, I am writing a plugin to add functionality with boilers to dispensers, I need help because when a redstone is supplied to a dispenser, the item is not removed, it is thrown out of it and I don’t understand how to solve it
public class EventsList implements Listener {
@EventHandler
public void Cauldron(BlockDispenseEvent e){
Block dispenser = e.getBlock();
BlockState blockstate = dispenser.getState();
Dispenser dis = (Dispenser) blockstate;
Inventory inv = ((Dispenser) blockstate).getSnapshotInventory();
if(dispenser.getBlockData() instanceof Directional){
Directional dir = (Directional) dispenser.getBlockData();
Boolean flag_lava = Boolean.FALSE;
Boolean flag_water = Boolean.FALSE;
Boolean flag_empty_lava = Boolean.FALSE;
Boolean flag_empty_water = Boolean.FALSE;
if(dispenser.getRelative(dir.getFacing()).getType().equals(Material.CAULDRON)){
ItemStack item = new ItemStack(Material.LAVA_BUCKET);
for (int i =0; i < inv.getContents().length; i++) {
if (!inv.contains(item)) {
//flag_lava = TRUE;
inv.remove(Material.LAVA_BUCKET);
inv.addItem(new ItemStack(Material.BUCKET));
blockstate.update();
dispenser.getRelative(dir.getFacing()).setType(Material.LAVA_CAULDRON);
break;
}
}
}
if you don't need item to be thrown out (need the event to be cancelled), put e.setCancelled(true); somewhere
also why are you using Boolean object type instead of primitive boolean
When making a set method for an integer in a specific range for a custom object, is it better to throw an exception if the integer is out of bounds or to simply adjust the integer?
e.g.:
// Throwing an exception:
public void setUses(int uses) throws IntegerOutOfBoundsException {
if(uses < 1 || uses > 1000) {
throw IntegerOutOfBoundsExcetion;
return;
}
maxUses = uses;
}
// Adjusting the value
public void setUses(int uses) {
if(uses < 1) {
uses = 1;
}
else if(uses > 1000) {
uses = 1000;
}
maxUses = uses;
}
I believe an exeption is the correct way
um, normally 64
this question really depends on the use case.
I have a client side entity, how do I listen when its clicked?
depends on the material @silver shuttle
listen for packets the client sends
I am pretty sure it is changeable, yet I cannot find any info on how to.
There is a plugin called StackableItems which allows for any item to be stacked to any amounts, even unstackable items
either protocollib, packet events or just ur own packet injector
yea. but i don't think this is done with api methods
asm , asm , asm , asm (yoke tho)
yea i wish alot of thing too about minecraft
just write ur own server software
there is something like that no?
still does not make everything possible. because certain things are handled client side
write ur own client
:D
this ur own server software?
wip but yes
we currently generating the 1.8 to 1.18 classes from json to kotlin files
so build in multiversion support
interesting
the protocollscraper.kt generates rounda bout 500 classes
if i recall correctly
the funniest thing is, to get native bukkit plugins to run on that piece of garbage
if(dispenser.getRelative(dir.getFacing()).getType().equals(Material.WATER_CAULDRON)){
ItemStack item = new ItemStack(Material.BUCKET);
for (int i =0; i < inv.getContents().length; i++) {
if (!inv.contains(item)) {
//flag_empty_water = TRUE;
inv.remove(Material.BUCKET);
blockstate.update();
inv.addItem(new ItemStack(Material.WATER_BUCKET));
blockstate.update();
dispenser.getRelative(dir.getFacing()).setType(Material.WATER_CAULDRON);
e.setCancelled(TRUE);
break;
}
}
}
item dont remove
please format it
how
put 3 of these ` on each side of your code
ItemStack item = new ItemStack(Material.BUCKET);
for (int i =0; i < inv.getContents().length; i++) {
if (!inv.contains(item)) {
//flag_empty_water = TRUE;
inv.remove(Material.BUCKET);
blockstate.update();
inv.addItem(new ItemStack(Material.WATER_BUCKET));
blockstate.update();
dispenser.getRelative(dir.getFacing()).setType(Material.WATER_CAULDRON);
e.setCancelled(TRUE);
break;
}
}
}```
so now whats it supposed to do
if there is a bucket of water in the dispenser and an empty boiler opposite, then replace the boiler with a boiler of water, remove the bucket of water and add a bucket
so bassically, the dispenser shoots its water into a cauldron?
Be a bit more descriptive than "item dont remove" when describing what's going wrong.
That's kinda funny.
first of all
Anyway:
if (!inv.contains(item)) {```
This makes no sense.
You're looping over the inventory nine times just to perform the exact same check every time.
Moreover, due to your check, you're only attempting to remove the bucket if the inventory doesn't contain a bucket.
im pretty sure all of your for loops are useless
Remove the loop and invert the bucket check and you'll probably get some better results.
I am working on a program that once it moves it never stops again. I added Velocity to X and Z and it stopped falling, so I tried adding Velocity to Y but it doesn't come close to minecraft's behavior. I would appreciate if you could help me.
Here's the code now.
Location loc = p.getLocation();
loc.setPitch(0);
Vector vec = loc.getDirection();
p.setVelocity(vec.multiply(0.4f));
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,10,10));
if (!fallMap.containsKey(p)) {
fallMap.put(p,Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
@Override
public void run() {
if (p.isOnGround()){
time = 0;
fallMap.remove(p);
fallMap.get(p).cancel();
}
time += 0.25;
p.setVelocity(p.getVelocity().setY((Math.pow(0.98, time) - 1) * 3.92));
}
},0,1));
}```
So i am trying to reload my recipe, however i get "Duplicate recipe ignored with ID"
even if i call Bukkit.removeRecipe before
so... just making something float?
are you sure you removed the correct recipe?
hm I doubt it
i am
I always loop over all recipes and remove ALL recipes that match my plugin's namespace in onEnable
the brightest idiot there is
print out the recipes you are removing and also the ones you are adding
i have a recipeKey and a headKey, guess which one i was using
the wrong one, as I said 😛
how
Remove the ! from the if statement which checks the inv for a bucket.
you are removing a bucket from the inventory if the inventory does NOT contain a bucket - that's probably wrong, isn't it?
i removed ! and code dont work
Then there are more bugs you need to find.
you also need to completely remove your for loops
its useless to do the same check 9 times.
How do you check inventory then?
You're doing that here:
if (!inv.contains(item)) {
^
You'd only need to loop over the inventory if you were going to use the index to individually check the item in each slot of the inventory.
But you're not checking each slot yourself, you're using the InventoryHolder#contains method to do that check for you. It will return true if any of the slots in the inventory contain the provided item.
Downside of that is you don't know which slot contained the bucket and which slot you removed the bucket from, but that's probably unnecessary for your purposes.
ItemStack item = new ItemStack(Material.LAVA_BUCKET);
if (inv.contains(item)) {
inv.remove(Material.LAVA_BUCKET);
blockstate.update();
inv.addItem(new ItemStack(Material.BUCKET));
blockstate.update();
dispenser.getRelative(dir.getFacing()).setType(Material.LAVA_CAULDRON);
e.setCancelled(TRUE);
}
}```
Is there a way to prevent EntityDamageByEntityEvent from responding in entity.damage ()?
Or is there a way to reproduce the damage?
what do you mean with "preventing" it "from responding"?
exit
I want to skip the processing of the Event caused by damage()
I don't think you can do that
you can instead directly set the health
entity.setHealth(entity.getHealth() - yourDamage);
ok thanks
How can i setup a blank plugin in vscode? I read the tutorial thing on the spigot website but i dont understand anything.
quick question
why not use intelli
it has the mc dev plugin and it allows you to auto setup
i just prefer vscode
everything smh
Have you set up a project in vscode before?
yeah i do python on vscode but i have never do java
I use vscode for dev, and I think you may need some understanding of maven commands
i mean i know java but i dont know how to setup a blank project
mvn generate:archetype iirc
oh i havnt install maven im smart
can you check if an item has been renamed in an anvil? (so the input's name does not match the output's name)
What i am trying to do:
Whenever my custom skull is renamed, it will set its owner to the name of the skull, now this works, however after a couple times you do this it will go crazy and kick the player for too many packets, here's my current code:
@EventHandler
public void on(PrepareAnvilEvent event) {
ItemStack result = event.getResult();
if(result == null) return;
if(result.getType() == Material.PLAYER_HEAD) {
SkullMeta meta = (SkullMeta) result.getItemMeta();
OfflinePlayer player = Bukkit.getOfflinePlayer(meta.getDisplayName());
meta.setOwningPlayer(player);
result.setItemMeta(meta);
}
}
```(I still need to add the check for my skull, however its just easier to test without it)
by going crazy i mean the skull keeps changing its owner as soon as i add it to the anvil slot (note: this is for every skull in the inventory, they all keep changing between steve and alex and i have no clue why)
does anyone know whether the premium resource placeholders also get replaced in normal .txt files, or only in java class files?
wdym
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
.java only from what i read
as it replaces in strings
:<
anyone?
how fix?
what's the problem?
yeah I saw it. what's the problem?
I want distributors to be able to take and put water and lava into cauldrons
just like they do it without a boiler
Hey there, any idea what am I doing wrong here?
TextComponent comp = new TextComponent();
player.sendMessage(ChatMessageType.ACTION_BAR,comp);
when a dispenser is in front of a cauldron, check if the dispensed item is a bucket or a lava bucket. if it is, check whether the cauldron already contains lava or not, and then cancel the event and manually add / remove lava and exchange the bucket with a lava bucket or empty bucket inside the dispenser
ItemStack item = new ItemStack(Material.LAVA_BUCKET);
if (inv.contains(item)) {
inv.remove(Material.LAVA_BUCKET);
blockstate.update();
inv.addItem(new ItemStack(Material.BUCKET));
blockstate.update();
dispenser.getRelative(dir.getFacing()).setType(Material.LAVA_CAULDRON);
e.setCancelled(TRUE);
}
}```
my code
how does that even compile? wtf is TRUE?
You are sending an empty component? Also this type of sendMessage is on present in Player#spigot()
did you actually import java.lang.Boolean.TRUE ?!
lol
Sorry for not including the error, but it says : 'Cannot resolve the method', is that an import issue?
Also this type of sendMessage is only present in Player#spigot()
What does that mean?
declaration: package: org.bukkit.entity, interface: Player
the method is called Player.spigot().sendMessage
and not just Player.sendMessage
https://pastebin.com/LYwsm0Kj all code
why the fuck did you import java.lang.Boolean.TRUE ?
why don't you just use the primitives?
Ahhh, yeah that works, thank you! :D
?learnjava pls
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.
"the program asked you to" because you used TRUE instead of true
print out some debug statements whether it actually cancels the event. I bet one of your if statements returns false
do you suggest replacing the former letters with small ones?
yes of course, but that won't fix your problem
how fix
^
i want make player can't break specific block event that can be turn on/off by command
can someone check?
https://pastebin.pl/view/7fdbba19
the event still going on even i run /enabledisable disable
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
Is there a way I can display a message lower in the screen than what ChatMessageType.ACTION_BAR does?
The Minecraft client has limited positions available for displaying text.
Without modifying the client, displaying text outside of those positions isn't feasible.
I see, thanks for the help!
does anyone have a good understandable tutorial about protocollib packets for beginners?
?
i mean protcollib beginners, like someone who hasn't really used it before
i know like half of the java basics and i'm learning
https://wiki.vg/Protocol or wiki.vg in general
i'm currently watching this tutorial [https://www.youtube.com/watch?v=2FcnwD2MHOA&t=1491s&ab_channel=KodySimpson]
but it's a bit hard to understand cause he kind of explains words and expects me to understand it as if i know what it means
In this episode, I show you how to listen for and create packets using ProtocolLib. I explain what packets are, how to extract and set data in packets, and more. #Spigot #SpigotTutorial
Packet Reference: https://wiki.vg/Protocol
ProtocolLib: https://www.spigotmc.org/resources/protocollib.1997/
Code: https://github.com/Spigot-Plugin-Development...
not all tutorials help or perfect
Don't know if this is necessarily spigot related or java related but it there a way I can schedule a task and cancel it without having the object I used to schedule it in the first place?
(when I reload the plugin I lose the object so I won't to have a command that cancels previously created tasks)
Reloading the plugin already cancels them
sending packets with ProtocolLib is like 17 times more complicated then using NMS imho
there are a lot of different opinions on nms vs protocol so idk which one to choose but i'll pick protocollib ig
It doesn't do it automatically, from what I tested
if the plugin gets disabled, tasks are cancelled
if you only reload it yourself, of course they won't get cancelled
just cancel all your tasks in your reload method
I deleted the plugin and the tasks are still running, I know I can reset the server but I want to create an in-game solution to this
I want to spawn npcs using my plugin, but for some reason my intellij doesnt give me any imports from net.minecraft. These are the dependencies of my pom.xml:
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
</dependencies>
what classes do you want to import?
obviously class names are different in remapped-mojang
MinecraftServer
that's the correct name, yes
did you click the "maven reload" button?
yup
what import are you using for MinecraftServer?
it should be "net.minecraft.server.MinecraftServer"
That import doesnt exist for me
do File -> Invalidate Caches, check all boxes then click on "Invalidate & Restart"
ok, I'll try that
it might take a few minutes after restarting until it works again
ok
Still not working
amnd on the right side it gives me an error but doesnt tell me why
you did run buildtools for 1.18.1 using --remapped though, right?
I ran them using ```
java -jar BuildTools.jar --rev 1.18.1
You must add --remapped behind it
ok, give me a sec
Yeah, the entity should get removed the next tick if everything goes as it should (I believe)
Works now tysm
Np
Anyone knows how to approach this?
its better restart than try a ingame solution using plugman for load a plugin for cancel a task for a deleted jar.
if (sender instanceof Player && cmd.getName().equalsIgnoreCase("loottes")) {
Location loot1 = new Location(Bukkit.getWorld("neweventbow"), 9, 43, -8);
player.getWorld().getBlockAt(loot1).setType(Material.CHEST);
new BukkitRunnable() {
public void run() {
Block block = player.getWorld().getBlockAt(loot1);
if (block.getType() == Material.CHEST) {
Chest chest = (Chest) loot1.getBlock().getState();
Inventory inv = chest.getBlockInventory();
inv.addItem(new ItemStack(Material.STONE, 2));
}
}
}.runTaskLater(this.main, 1);
}```
any problem with my code? i want set a chest at specific coordinate with item inside
but i got error` Cannot invoke "org.bukkit.World.getBlockAt(org.bukkit.Location)" because the return value of "org.bukkit.Location.getWorld()" is null`
you don't have a world called "neweventbow"
i do have
"neweventbow" != "eventmapbow"
also why are you waiting a tick?
ya i just remove it, i was copy it from onBlockPlace event and i need a tick so there is no error
hello
anyone?
uh
how do I find item textures?
like
aaa
nvm
oo
found it
material: PLAYER_HEAD
texture: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTdjY2QzNmRjOGY3MmFkY2IxZjhjOGU2MWVlODJjZDk2ZWFkMTQwY2YyYTE2YTEzNjZiZTliNWE4ZTNjYzNmYyJ9fX0='
the part below materials
where do I find it?
Is there an event that allows me to check if a player is holding an item or do I have to use a runabble for it?
What version?
1.8.8
iirc just a runnable
ah yes, 1.8
its good men 🔫
This version is half a decade old and support was dropped years ago. In newer versions there is a LOT of api that you are missing out.
So for you its SkullMeta -> GameProfile -> use reflections to get properties
If I run a check on every online player every half a second would that be really heavy on the server?
or use nbtapi
No its not and nobody uses it. Update to a supported version or live with the horrible drawbacks like having to use reflections to get textures from a skull.
it is
trust me
no, it shouldn't
I trust the statistics and they state 7%
Oh ok , thanks!
imagine using 1.18 to play bedwars
imagine developers playing minecraft
But if you want to squeeze out every last bit of performance then you should try evenly distributed runnables.
but... jumping around lobby
What do you mean by squeezing every last bit of performance?
Like shown in this article:
https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
Ah, this is a smart sollution for that
How to change the skin of a player?
packets prob
You can change the textures of his GameProfile. You just need to make sure that the other players receive this change somehow.
can I just do a For-Loop?
for(Player p : Bukkit.getOnlinePlayers) {}```
To achieve what?
that the other players receive the change
jafreili
wait, you are german? xd
lies and deception
this is gold
Hi, I have a NPC made with packets, i want to move this npc realistic ( not teleport, walking ), if anyone can help me create a thread thanks.
use A*
wdym " use A" ?
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntity.PacketPlayOutRelEntityMove(entity.getId(), (short) (x * 4096), (short) (y * 4096), (short) (z * 4096), true));
A* is a pathfinding algorithm
Was about to post a link to the protocol. This should be used for letting a fake entity walk.
Although i see a lot of other packets that might be needed for predictive computing by the client like velocities and player position/look
I almost certainly has. 20TPS would look scuffed otherwise.
it does look scuffed tho
^
Is it possible to change the fade out time of the player.spigot().sendMessage() method?
You mean of a title?
that still wont work
...
chat will keep displaying new msgs
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,new TextComponent(""))
like so
well, you can try resending it after a bit
But it will take time to fade out
Action bars dont have a fadeout timer. You need to send a new one if you want to replace or remove it.
Ohhh I can send a clear one to remove it, that will work, thanks!
can i uh, can i get help with this?
yes
Yes
say nextInt(400) its 0 to 399
how come?
Thread contention and a lot of utility methods
Could someone tell me how to spawn a fake player using nms, found some resources, but they were for different versions
you can try using the Citizens api
^
How would I implement that in my intellij project
Maven or Gradle?
maven
What do you advise to host a public repository ? (What type of service is good to use ?)
caugh citizens has abyssmal performance and i consider it a borderline virus
I always go with nexus
Nexus okay thanks i will check this
There is also Artifactory and something called frogged (or something similar)
There is so much things, this is why i ask. For which is the most use and the most documented
What does this question aim at? Why the performance is abyssmal or why i consider it a borderline virus?
https://github.com/zelytra/Histeria/tree/master/src/main/java/fr/zelytra/histeria/managers/npc check this code if you wanna do it your self with nms and packets
thx, I'll try that
try to understand it, before using it
- I dont know why the performance is so bad. Ask the citizens devs.
- I consider it a borderline virus because the performance is so bad. (20% tick time with 0 players online)
wtf 20% ??
of course
Its been a while since ive used it (about 3 years) and back then it just hogged all the cpu time it could get.
btw there is a lot of feature with path finding etc so maybe there is some justification
(ore just very bad code optimization)
@lost matrix sry for the ping just a question, is Nexus free ?
yes. You just need a host and some time to set it up.
Dabbling with nginx and ssh key for https connections is really a hustle.
okay, but i wanna make my repo public (so any password and user to set for the user) is it possible and secure ? Or did i need to make it absolutely private ?
It has quite a bit of security features and is also used by bigger companies. You can make public repos with it.
But you can also check out jitpack.io
Its a really simple way to host maven dependencies. You just provide a github repo and
its automatically compiled and hosted there.
hooo well quite nice solution too
okay thanks for all infos
what is it called when someone does something like "void hi();" in an interface
is it a function or somethin? idk what it is
method. And in interfaces all methods are implicitly public and abstract.
So its a public abstract method with no return type and no parameters called "hi"
Nope. Google the words.
gee thanks
it is not really a serious programming question - kind of surprised you got an answer
forgot for a second how annoying everyone is here
"annoying" vs not wanting to teach java concepts to people because you should already know them
No offense, but if you want to write a whole plugin, learning basic programming concepts might be a good idea
im fine with them not wanting to teach me, im annoyed by how they said it
and im annoyed on lowonespresso
What would you like for me to make it up to you? - codeacadamy has pretty simplified explanations
You're annoyed that someone said no they're not going to dumb down important concepts you should know and you're annoyed someone directed you to a page to learn said concepts. I don't know what to tell you
https://www.rcsdk12.org/cms/lib/NY01001156/Centricity/Domain/4951/Head_First_Java_Second_Edition.pdf
https://gyazo.com/af2dbcc0feb315f73b77a63e679d99fd
This is one of the books I started out with. I appreciated how it broke things down, and while it's a bit dated, I think it's still relevant.
hey how to get a location object with a specific coordinate that I have
sample code please
final double x = 10, y = 20, z = 30;
final World world = ...; // Whatever world
final Location location = new Location(world, x, y, z);
Are there any downsides to having a lot of methods in a class? Say an average method in a class has at least a runnable in it, and there are like maybe 3000 lines of code worth of these methods. How does that affect the program?
The computer doesn't care, but it makes it look awful and hard to debug.
And your mouse's scroll wheel :(
It makes this code really unclean and hard to maintain. And i would assume that it makes it unmodular as well.
Pretty sure that there is no chance that you can write code like that without violating clean code principles at least several dozen times.
I would argue having a ton of functionality inside 3-4 methods is harder to read
Than having the code broken up into small units
^
sorry to interrupt guys
you can answer after the current queries have been resolved
how to summon a mob at a given location
World#spawn(Class<? extends Entity>, Location)
ohk lemme try it real quick
also is there any way in which entity size can be increased?
Not programmatically
just saying that in future @quaint mantle you should use javadocs for simple stuff like that
Only for slimes. Minecraft doesnt support that for anything else.
hmm alright thankyou
have a good day guys
thanks for helping me
Byyeee
why is he ignoring me
Hmm, I see. So follow-up question, how would one efficiently and optimally write/store multiple unique instances of an object? Basically like enums, but for objects. I'm planning to write my own GUI lib and I figured I'd be creating a lot of items as buttons of these GUIs with their own trigger methods (runnables I mentioned earlier) and that was my earlier concept, multiple methods that return a specific itemstack. I figured if I were to create a new item, I can simply add another method
how can I stop the sitting animation?
So the current best practice for that is creating a wrapper class that contains
A) An ItemStack to display or a Supplier<ItemStack> or a Function<Player, ItemStack>
B) A consumer for the InventoryClickEvent which i called when the ItemStack is clicked.
Lets call this class UIButton
Then a GUI contains a mapping slotID -> UIButton.
So a Map<Integer, UIButton>
Ill follow up with an example
stop? like stand them up or like they sit but stand?
sit but stand one with packets
The button class:
@Builder
@AllArgsConstructor
public class GUIItem {
@Getter
private final Function<Player, ItemStack> iconCreator;
@Getter
private final Consumer<InventoryClickEvent> eventConsumer;
}
Then inside your GUI object there should be something similar to a
private final Int2ObjectMap<GUIItem> buttonMap = new Int2ObjectOpenHashMap<>();
Then you can fill this map with buttons
GUIItem item = GUIItem.builder()
.iconCreator(player -> new ItemStack(Material.RED_WOOL))
.eventConsumer(event -> event.getWhoClicked().sendMessage("You clicked red wool"))
.build();
buttonMap.put(10, item);
There is quite a bit more to that but those are the core concepts.
Okay, I'll look into this further. Thanks for introducing it to me!
my goal is to make player unable to move
keep teleporting them to the same position every tick or 2?
or just set their movespeed to 0?
that would enable them to be moved by others with knockback I assume
true
I thought i could just make them sit on something
that wouldnt seem laggy too
because if they dismount, thats no problem for me
Oh so you want to cancel them dismounting? Just cancel the EntityDismountEvent then.
Hi.. I'm trying to update an old abondoned plugin and it has these import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack; import net.minecraft.server.v1_13_R2.NBTBase; import net.minecraft.server.v1_13_R2.NBTCompressedStreamTools; import net.minecraft.server.v1_13_R2.NBTTagCompound; import net.minecraft.server.v1_13_R2.NBTTagList; ... trying to find the right imports for gradle.. for 1.18.. not even sure that stuff is in the same place in this version now though
no I want to cancel the sit animation
In 1.18 the v1_13_R2 stuff was removed, try it without it
If you want them to sit down without showing the animation then you would have to intercept the backets.
This looks like it should be re-written using pdcs
so import net.minecraft.server.NBTTagCompound (might not be exactly like that I'm a 1.8 dev)
I know I tried it using packets but couldnt
@torn yarrow
you want to make a player sit down without sitting down?
And in 1.18 there are not spigot mappings anymore. So you need mojang mappings which have a completely different package
structure and naming. So what Macho suggested will 99% not work,
The try again or use a different approach.
what is the gradle import for net.minecraft.server. ... I can't find even that
in every other version its buildtools spigot but it mightve changed
You need to install spigot into your local maven repo and depend on it just like you would do with maven.
yes so they just wont be able to move Ive been looking for a wayto do it for soem time now
Actually ive only done 1.17/1.18 with gradle by using the userdev plugin from paper.
For spigot i always used special sources.
The most trivial approach is to just cancel the PlayerMoveEvent
why do they have to be sitting down?
repositories {
mavenLocal()
mavenCentral()
// Spigot
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
// maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
// maven { url = 'https://oss.sonatype.org/content/repositories/central' }
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
// Spigot Annotations Support - Replaces plugin.yml
compileOnly 'org.spigotmc:plugin-annotations:1.2.3-SNAPSHOT'
annotationProcessor 'org.spigotmc:plugin-annotations:1.2.3-SNAPSHOT'
}
because if I cancel the playermoveevent or loop teleport it seems too laggy
cancel the move event like smile said, make them fly about 0.01 blocks off the ground, make it so they cant disable it (PlayerToggleFlightEvent) and set their fly speed to 0
Either that or set their walkspeed to 0 and give them negative knockback to kill jumping
so canceling the sit animation isnt posibble?
wong ' char and the file type is not java but groovy. Unless you are using kotlinDSL
aha
not effectively, how would a player just randomly decide they want to sit?
unless you're doing it through packets
Just for the surrounding players. You can just make them think that the player did not sit down in the first place.
but not the player himself?
thanks then Ill just loop set walkspeed 0
can you write a plugin that will allow dispensers to pour liquids into boilers?
I mean you shouldn't need to loop it, their walkspeed wont increase on its own
that worked.. i can import import net.minecraft.nbt.NBTTagCompound; now
wat
boilers?
modded?
I'm tired my code doesn't work in practice
cauldron
oh ok
In order to grant a specific permission to a player, should I do it in my own plugin , or find a plugin that will handle that?
Or it doesn't matter
Sure. Should be as simple as just listening to the BlockDispenseEvent
you can just do that in a permissions plugin unless you have your own perms plugin
Usually you would go for Vault
How would I do that?
If I want do to it on my own, that would require a vault?
no but Vault makes other plugins communicate with eachother properly
so its recommended
Ill give it a look
how to get intellij to build my plugin
Ah, thank you I'll look into this
I'm getting this error msg when loading my plugin.
java.lang.NoClassDefFoundError: net/minecraft/server/level/ServerPlayer
at de.firecreeper82.naruto.TestPl.register(Naruto.java:27) ~[?:?]
at de.firecreeper82.naruto.TestPl.onEnable(Naruto.java:17) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:521) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:435) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:262) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at java.lang.Thread.run(Thread.java:833) [?:?]
It says it couldnt find the ServerPlayer class but I imported in my code
import net.minecraft.server.level.ServerPlayer;
And in my pom.xml arent any errors but on the right hand side it gives me an error at the dependencies
check if the class is inside your compiled jar
how?
open it with something like winrar
is there an event when a player clicks on an item and it goes to cursor? so far InventoryClickEvent#getCursor only returns the item in the slot after it clicked
ok, gimme a sec
Try this and show me the result:
@EventHandler
public void onDispense(BlockDispenseEvent event) {
Block block = event.getBlock();
if (!(block.getBlockData() instanceof Dispenser dispenser)) {
return;
}
Block target = block.getRelative(dispenser.getFacing());
if (target.getType() != Material.CAULDRON) {
return;
}
ItemStack dispensedItem = event.getItem();
if (dispensedItem.getType() == Material.LAVA_BUCKET) {
event.setCancelled(true);
Levelled levelled = (Levelled) target.getBlockData();
levelled.setLevel(7);
Inventory dispenserInv = ((BlockInventoryHolder) block.getState()).getInventory();
dispenserInv.remove(Material.LAVA_BUCKET);
}
}
I didnt put the class in my project but imported with my pom.xml I think (if that makes sense if not correct me xD)
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
If you’re using remapped nms you have to apply the mapping to your plugin to make it reference the obfuscated code in the compiled jar
You’re trying to reference the deobfuscated class
That doesn’t exist in the server
?
iirc there is a maven plugin that auto remaps to obfuscated code
Patterns in 'instanceof' are not supported at language level '8'
You are on spigot 1.8.8 arent you?
sorry if thats a dumb question but how would I do that, I never worked with nms before
idk
woudl that help with this ``` NBTTagCompound tag = new NBTTagCompound();
//tag.set("Items", itemList);
tag.("Items", itemList);``` .. the commented out bit , is what used to work in old version.. trying to update but tag. just has stuff a,b,c etc names
i dont know
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.18-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.18-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.18-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
i have this in my pom and the code works fine at runtime with a remapped jar
i don't remember where i got it tho
spigot 1.18.1
ah i've set things up with gradle
i work in 1 18 1
oh then i don't know sorry
Then set your language level to 17
^ 1.18 doesnt even run on java versions under 17
@haughty storm
so no point in using old versions
thx
oh yea that's where i got the maven plugin
Cannot resolve method 'getFacing' in 'Dispenser'
add it the normal way in gradle
wrong import
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Dispenser;
import org.bukkit.block.data.Levelled;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
How can I check the name of a block?
you mean the type?
Done a bit of testing. This is the resulting code that works.
@EventHandler
public void onDispense(BlockDispenseEvent event) {
Block block = event.getBlock();
if (!(block.getBlockData() instanceof Dispenser dispenser)) {
return;
}
Block target = block.getRelative(dispenser.getFacing());
if (target.getType() != Material.CAULDRON) {
return;
}
ItemStack dispensedItem = event.getItem();
if (dispensedItem.getType() == Material.LAVA_BUCKET) {
target.setType(Material.LAVA_CAULDRON);
event.setCancelled(true);
Inventory inventory = ((BlockInventoryHolder) block.getState()).getInventory();
Bukkit.getScheduler().runTask(SpigotSandbox.this, () -> inventory.removeItem(dispensedItem));
}
}
bucket gone
no the name
what should i import?
Should it just be empty?
Then you can just add an empty bucket
get the type and make it into a string, remove the caps and the _
BlockData dispenser
don't think theres another way
Blocks dont have names
incase you mean the name of a chest/shulkerbox i think you can just get the blockstate and the inventory
and from the inventory the name
Inventories dont have names
but if I place a renamed player head and break it it still has the name. So it needs to remember the name while it is placed somehow
Thats a property of the metadata. The Skullmeta. Its something completely different.
oh right now it belongs to inventory view?
or something similar
kinda weird
give me plz all your imports
my pom.xml now looks like this but I am still getting the same error
import org.bukkit.block.data.type.Dispenser;
This is what you are missing...
dont work
hey guys, does someone know how to shorten this code or make it cleaner?
somehow i don't like those tower of dooms with else if else if, ...
Help would be appreciated!
if(!(sender.hasPermission("CustomVersionSeedCommand.allowtabcomplete"))) {
if (buffer.startsWith("/version")) {
e.setCancelled(true);
} else if (buffer.startsWith("/ver")) {
e.setCancelled(true);
} else if (buffer.startsWith("/icanhasbukkit")) {
e.setCancelled(true);
} else if (buffer.startsWith("/?")) {
e.setCancelled(true);
} else if (buffer.startsWith("/seed")) {
e.setCancelled(true);
} else if (buffer.startsWith("/about")) {
e.setCancelled(true);
}
switch,
make an array and loop over
Cannot resolve method 'getFacing' in 'Dispenser'
So how can I get the name of a placed skull then?
'org.bukkit.block.Dispenser' is already defined in a single-type import
Get rid of that import then
can you can me a quick example?
This is not working:
switch(buffer.startsWith()) {
case "/version":
etc.
Don't just copy paste your errors here without any thought, pay attention to what it's telling you
You already have a Dispenser import
There are two Dispenser classes
One has the method you want
The other doesn't
You can't import two classes of the same name
thank
code done
Redempt will answer that. If not you should ping him. Dont let up. Just once a min should be fine.
He loves being pinged, im not sure once every min is constant enough.
i think every second would be better
dont stick the slash in there ...
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.Levelled (org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData and org.bukkit.block.data.Levelled are in unnamed module of loader java.net.URLClassLoader @2e5d6d97)
at me.leizd.pluugin.EventsList.onDispense(EventsList.java:28) ~[?:?]
thanks!
np
@lost matrix
Yes dixlafozz...
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.Levelled (org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData and org.bukkit.block.data.Levelled are in unnamed module of loader java.net.URLClassLoader @2e5d6d97)
at me.leizd.pluugin.EventsList.onDispense(EventsList.java:28) ~[?:?]
Look at the corrected code ive sent above the gif
Cannot resolve symbol 'SpigotSandbox'
https://mclo.gs/Qjb3O73 the coarse reference I keep kicking around
You should be able to figure that one out
?
Looks like it should be put into a map.
I hate switch case and i love maps.
The new Case L Switch still has some quirks I dont quite understand
idk
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
how fix
Pass the right objects to the method call
what object i need to pass i don't understand
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
my pom.xml now looks like this but I am still getting the same error
Does anyone know how can i make a lib?
tell me exactly what i have to do
Elaborate?
You using gradle? Maven?
Maven
what's special about an Int2ObjectMap?
nah, I need an argument inside that switch thingy
for example:
buffer.startsWith("/test"); //returns a boolean
switch(buffer.startsWith(someCommand)) {
case "someCommand1": //do stuff
case "someCommand2": //do other stuff
//and so on
And add it locally from another project
If you want to not need to add it locally then you need to publish to a repo
Ok
I don't really know if it is possible to change it or it needs to be an ugly if else tower
Prevents auto (un)wrapping. Smaller memory footprint and better performance.
Isnt for now tho
You pass an instance of your class that extends JavaPlugin as the first parameter of the method call.
Use a map
Bukkit.getScheduler().runTaskLater(plugin, () -> {
// Stuff here
}, delay);```
yeah, thats what i showed you ... - specifically a Case L Swicth
import org.bukkit.plugin.java.JavaPlugin;
public final class Main extends JavaPlugin {
@Override
public void onEnable() {
System.out.println("Plugin NewDispensers enable!");
getServer().getPluginManager().registerEvents(new EventsList(), this);
}
@Override
public void onDisable() {
System.out.println("Plugin NewDispensers disable!");
}
}
Ok
and now
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
what should i do in the code to make it work?
what should i do in the code to make it work?
?main too
Hello, could someone help me understand how I can create a custom entity using the NMS with armorstands in 1.18.1? I have several problems: The name of the fields with the obfuscation are difficult to identify, and for example is it possible to change the size of an armorstand, if so what is the property to modify?
and if you know an api that could simplify all this?
you should use remapped spigot to get unobfuscated names
and for the size: you can only set an armorstand to be a marker or sth like that to make the hitbox smaller, I think there's nothing else you can do to its size
Ok thank i try it
lmao
I can't use PlayerProfiles
because required methods of the PlayerProfile are depreciated and marked as error
but if I remove them the full PlayerProfile is marked as error
update them to the new method?
So, how do you assign a non-primitive Short in java?
Short.valueOf("1");?
No like
This is a PlayerProfile:
PlayerProfile profile = new PlayerProfile() {
};
But between the brackets there are a lot of methods like This one:
@Override
public @NotNull PlayerTextures getTextures() {
return null;
}
or
@Override
public void setTextures(@Nullable PlayerTextures textures) {
}
But 2 of them are depreciated. Without them the PlayerProfile is marked as error and with them the methods are marked as error
These methods are implemented
@Override
public @NotNull String setName(@Nullable String name) {
return null;
}
``` and ```
@Override
public @Nullable UUID setId(@Nullable UUID uuid) {
return null;
}
Are marked as depreciated
update()
where do I have to put that?
hmm, creates new profile does not change existing ...
no i am wrong, those two you can no longer change without creating a new one:
"A player profile always provides a unique id, a non-empty name, or both. Its unique id and name are immutable, but other properties (such as its textures) can be altered."
So what do I need to do now?
either use update to async create a new player profile or clone - UUID and name are now immutable to prevent conflicts?
why is it calling those two specifically, and are they actually doing anything with them? - if it is just a check, you could replace with isComplete()
Can someone tell me how I can disable a player losing HP when they get hit, they are still supposed to be able to hit someone n the person who gets hit needs to take knockback but without losing any hp.
entityDamageEvent, give the hp they lose back to them
not sure if they would take knockback when you cancel that event
give lib ideas uwu
Hmm, its quite unfortunate the comment pr to the configuration api was directly merged into FileConfiguration and such
If anyone has any suggestions on how perhaps one could handle sth like JsonConfiguration with the existing api, please lmk 🙂
how to import some .java file from work/decompile-XXXXX/ to CraftBukkit/src/main/java/<...>?
I know there is dev-imports.txt on forks but I don't see anything like this on spigot
can someone explain to me how to make a player hold an item like a loaded crossbow with protocollib packets? like when you hold a crossbow it is held up, and i would like to make that but with non crossbow items
I'm getting this error msg when loading my plugin.
java.lang.NoClassDefFoundError: net/minecraft/server/level/ServerPlayer
at de.firecreeper82.testpl.TestPl.register(TestPl.java:27) ~[?:?]
at de.firecreeper82.testpl.TestPl.onEnable(TestPl.java:17) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:521) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:435) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:262) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3443-Spigot-699290c-2c1e499]
at java.lang.Thread.run(Thread.java:833) [?:?]
It says it couldnt find the ServerPlayer class but I imported in my code
import net.minecraft.server.level.ServerPlayer;
And in my pom.xml arent any errors but on the right hand side it gives me an error at the dependencies
You need to remap using 1.18.1 not 1.18
Replace every 1.18 with 1.18.1 in the second screenshot
thx
Also make sure to actually use maven when compiling
can some one make a smal thing that do so i can't shot arows on others i overworld? and not nether and the end? pls and tag me
do u wanna code it urself
Can't shoot arrows at others at all? What
Other can,t code it yet
No
then who is supposed to code it
I Ask if sone one want to do it
dont expect people to make stuff for free
which better
String.format StringBuilder MessageFormat.format
or default like
"LOL." + player + ".IDK"
"LOL." + player + ".IDK" compiles to some efficient concats, only reason you'd use StringBuilder would be in a loop
wating for cool answers
String.format() is slow but readable
I will make for 200 dollars ahaha
oh, so default its the best option?
depends on situation
i need to return player location
world x y z yaw pitch
what does that have to do with string concatenation and string formation
and utils classes need to have all static methods?
basically for any utility function, given the same input, the same output
thats useless
as its stateless and pure
so having an instance of it would just be useless
alright
int square(int i) {
return i * i;
}
this is a utility function
regardless of circumstance
if I send in 2, I always get 4
oh
hey, I had to shade some more things into my plugin and because of the file size it won't let me? What should I do?
tho these would be stateful functions thus cant be utility functions:
Object getOwner() {
return this.owner;
}
void setOwner(Object newOwner) {
this.owner = newOwner;
}
use a downloader
?
oh i get it
for instance whenever calling getOwner you really don't know what you'll get
it depends on some state, right
and then we have methods like
Collections.shuffle()
and they are not utility functions either
just static helper functions
yea
as they manipulate state
whats that mean?
i dont know how it would work exactly but maybe create a file libs.txt with urls, parse it and download all jar files from the urls and then load them dynamically
there should be a library for that
but I use gradle
people are saying that obfuscating it makes it smaller but I don't wanna do that
xnotro, that was a question concerning this
you just leaped from strings to sth completely else
ill try to make an example
my bad google translate is sht
I can't even set a 3rd party link
leap = jump
i mean to download and load the libraries at runtime
concatenation means basically joining/merging
i meant on spigot you can't even specify a link
?
so "a" + "b" is string concatenation as you're joining/merging strings
like you can't say download the jar from test.com/file.jar
aaa got it
when i set their hp back to 10 on entitydamageevent, the zombie is still able to put me to 9hp n only then it doesnt go lower
like it gets me to 8.5 then it stays there then i regen to 9 then it goes back to 8.5 etc
while he keeps hitting me
just put it back to the Attribute.GenericMaxHealth.getBaseValue() maybe?
if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
}
so j like that?
well dont really need the variable but anyways
the easiest way i've thought of making a bedwars plugin is using a togglable event handler, but i don't know if that is the way to go (i have started this). any suggestions??
an other question
what's is the best option:
HomeUtils.saveHomesFile();
or
import static dir.HomeUtils.saveHomesFile;
I never understood what changes
@crimson terrace wait how do i set it after getting the value
dont import static
usually it causes a lot of confusion as you don't see the caller
alright thanks, love you dude
Conclure can you help me out?
Sure, what's the issue?
I need a player to take knockback on a hit but to not lose any health
can't you just set damage to 0
But i can't just do sethealth 20 on entitydamage event
Just set the damage to 0
Alrighty
an other good question how i can save data when player quit in this case his home
so the server dont need to debug always
^ @ivory sleet ping for help :)))
PlayerQuitEvent -> save his data
xnotro yeah tho I'd suggest to eagerly save data if possible
because this plugin create home when you do the command and instaly save it
hmm, I mean could just have a boolean which decides whether your logic is going to be executed
any lib idea
hey, how can I only compile certain modules fro mthe XSeries?
because of the method
saveHomesFile();
I would honestly try to always register listeners once and then use control structures to define where the events are needed.
public static void saveHomesFile() {
try {
yaml.save( file );
} catch (IOException e) {
e.printStackTrace();
}
}```
really simple
OrlaDev of course you could unregister and re-register the given listener
but that comes with some drawbacks
mainly that you probably want to rebake the handlers after re-registering to achieve better performance
Sorry, but which event do i need to use for that
Just EntityDamageEvent?
EntityDamage Event
which if there are many listeners and event executors registered will probably halt the server
@EventHandler
public void onDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
Player p = (Player) e.ge();
p.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).setBaseValue(0);
}
}
Can u tell me what i'm forgetting
so go with what smile said
you need to setdamage
how can i make a function in java ?
i dont understand the articles in the internet :/ i want to teleport a player to a location, but thats too many code to use everytime. so i want to create a function like "player.resetlocation()" :D
oh oops
e.setDamage() iirc
oh okay
@elfin steppe
so no need to do attribute
I find it hard to keep track when listeners are registered or not. Its dangerous because you might end up with multiple registered listeners.
cos all my listeners will be for the game anyways
?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.
Spigot is not beginner friendly
so they're all gonna be off or on either way
how would I make a ServerPlayer behave like a dog, so it would follow you around and attack enemies
Maybe if you pay him enough. There are weird people out there.
OrlaDev do it like
boolean shouldRunSomeEvent;
@EventHandler void onSomeEvent(SomeEvent event) {
if (shouldRunSomeEvent) {
//TODO: ACTUAL LOGIC
}
}
void shouldRunSomeEvent(boolean toggle) {
shouldRunSomeEvent = toggle;
}```
tho ofc that design isnt particularly scalable
but you get the gist of it
what kind of currency do you think he would accept
DogeCoin
works, thank u
I'll try that
sounds like you need to deal with packets here
or at least nms
ServerPlayer doesnt have any AI logic implemented. So this will be quite hard.
Means you cant just throw all the AIGoals of Wolfes at it.
could I maybe just give it motion in the right direction to follow and make it seem like its attacking stuff or is it not possible to give them motion
IJ IDEA its suggest to add @NotNull to my Utils Methods
What you could do is use LibsDisguises if you want the easy way out.
whats i need to do? ignore it?
Just disguise a Wolf as a player.
how would that work
You can but nullabillity annotations can be nice
i just google it and yea its cool to add it lol
ty :)
How can I change the radius and damage of a fireball's explosion thrown by a custom item?
yea but i wanna turn them on and off with a command
custom item?
well we don't know anything about your custom item
what item is it?
Should be able to modify the explosion power of it directly
Fireball is what they said
Not charge
Wooden hoe with custom data that fires a fireball.
for example
Fireball fireball = (Fireball) world.spawnEntity(new Location(world, 0 ,0 ,0), EntityType.FIREBALL);
fireball.setYield(yourValue);
How would I implement that
Hold on, lemme see if it does the trick. Thanks for the input, by the way.
anyone have a good tutorial on creating a 1.18.2 plugin with maven? i usally use the Minecraft Development plugin in IntelliJ but it doesn't have 1.18.2
just set the version to that
Looks like the method call you need is setYield() and should be able to run that off any explosive thing
huh?
Does anyone know if there is an event for when a shulker box, as a dropped item, is destroyed and then it vomits out its contents?
wait is fireball an actual entity?
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
i didnt know that
Do you happen to know how to change the damage dealt by the explosion?
yea, ofcourse
well setYield is how big the explosion is. i don't think you can modify that directly
you would need to listen to EntityExplodeEvent and set the damage yourself probably
Why would a fireball not be an entity? In mc space everything is either a block, and entity or a particle
Thank you very much, this helped a lot
And it sure isn't a particle (those are usually smaller) and isn't a block at all
lol i didnt know
well, its like geol explained
lmao i just realised that ghasts throw fireballs 🤦♂️
i thought that they didn't exist in vanilla
im dumb :)
Pretty sure the dragon throws them too
dragon throws other things
yea
not sure the name is rn
Yeah idk
they throw particles
ok
Well, close enough ;)
didn't realise that
public interface DragonFireball extends Fireball {}
which is. well... haha
being the idiot i am
lmaoo
how do i open buildtools to look at all the craftbukkit, bukkit, spigot stuff? i forgor
it's basically a fireball
yup
maybe google?
?stash
i think its purple instead of flamy
Sorry for the immediate-reask, I got kinda drowned but also guessing this is just not a thing:
Does anyone know if there is an event for when a shulker box, as a dropped item, is destroyed and then it vomits out its contents?
when does this even happen?
if you throw a shulker box in lava is the easiest way
how can I generate something like this? https://i.imgur.com/9kQeucX.png it was used on featherboard but idk how he did it
but also if it explodes while dropped
but... then the items will be destroyed too?
like from a creeper or fireball or whatever
no
well yes, in lava
unless they are netherite
but in the creeper/fireball/explosion case, the items inside the box survive regardless
it's a very specific/weird behavior I only just learned about but is causing me some dupe exploit headaches.
It seems like there's no real way to catch it
in what version?
1.18, but I think it's been like this since 1.17 or maybe 1.16
@eager sapphire you could test if EntityDeathEvent is fired
I want to say Mojang changed it specifically to avoid netherite tools burning when inside a shulker box thrown in lava 😐
I could, but then I have to .. wait a tick and scan the surrounding area for dropped items? Very messy at the least
im not sure. but i think it should be called when a shulker box item gets destroyed
you can get the item being destroyed
& get its contents?
true, then again scan for the dropped items, check if it was something in the shulker box, etc
still very messy, an event would be nice but I'm guessing it doesn't exist
It's interesting as I have never heard about this feature, but is plausible and it makes fully sense that this would yield exploits
well, no dedicated event no.
I had never heard about this feature either, until someone came complaining to me about exploits 😂
yea i never heard of this either
It should def. get an event however
Well entitydeathevent has a list of drops you wouldn't need to scan anything they would be in there
hmmm well that is a good point, if it really shows as drops like that, I will check.
public static final GameEvent BLOCK_DESTROY should fire as a shulker is listed as a block
Hi ! 😄
There is a way to set nbt to an item without use NMS ?
Bukkit unsafe
Persistent metadata
If you want to use NBT to store your own custom data
true
not to hack up vanilla tags, there will probably never be an API for that 🙂
But beware, the bukkit unsafe is ... unsafe - better use NBT APIs
or just use this https://www.spigotmc.org/resources/nbt-api.7939/
very good api in my experience
Possible X/Y problem why do you want NBT access? 😄
You use the PDC if you're using a modern spigot version
Oh, I want to change vanilla tags ^^
Just note that there is literally 0 documentation on this method so you are on your own when using it
What tags? ItemMeta should cover just about evrything
Really better to use the API unless you have an extremely exceptional case
CustomModelData
Or may be i'm wrong and it's not a nbt ? 😛
Ah good old xy problem strikes again
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
😄
its the same line which is moved to the left for two blocks so maybe you could do something with that?
Ah, i'm confusing meta and nbt then ^^
Thanks for your responses 😛

Yeah, i'll try that ty
To be clear, ItemMeta is really the NBT API.
All data on items is NBT. The ItemMeta API wraps this data, giving you safe access to it.
In case you were curious, I just tested and it seems like EntityDeathEvent does not fire for dropped items
ah really
then try GameEvent BLOCK_DESTROY will be noisy though
continue;
X: 358.2213934122428
uhm why its save like that?
