#help-development
1 messages · Page 2202 of 1
?1.19
You can build 1.19 using BuildTools https://www.spigotmc.org/wiki/buildtools/
java -jar BuildTools.jar --rev 1.19
if u wanna use nms without scratching your head, use --remapped
wanted to see if java Integer class returned itself if when hashed and this is what i found
why wouldnt it
u cant edit nms classes
if u wanna mess with his ai, extend warden and create your own custom entity
Yah i meant that only i cant extend warden class and when i go to import section there is no warden in monstors file
can u import any other mob like zombie etc?
K, I have PRed the fix for the random issue
for sone reason when i die the deaths is not updating
show the error first
first of all why is there a random bracket in the begining of the runnable
you should and put the runTaskTimer on the curly ones
and why are you putting a throws Exception seems superfluous
public static double randomDoubleBetween(double num1, double num2){
return ThreadLocalRandom.current().nextDouble(num1, num2);
}
private void rewardWinnings(Player player){
Stats.setStat(player, Stat.WINS, Stats.getStat(player, Stat.WINS) + 1);
int eggGain = (int) Util.randomDoubleBetween(25, 50) * Stats.getStat(player, Stat.MULTI_EGGS);
Stats.setStat(player, Stat.EGGS, Stats.getStat(player, Stat.XP) + eggGain);
player.sendMessage(MINI_MESSAGE.deserialize("<#25c22b>+ " + eggGain + " Eggs"));
giveXp(player, (int) (Util.randomDoubleBetween(40, 100) * Stats.getStat(player, Stat.MULTI_XP)));
}
Why is it sending me 0 eggs (MULTI_EGGS should be automatically 1 according to my code)
It requires data
U provided none
If u wanna spawn a block dust particle, how will the server know which block you're referring to?
how would i make it so like only types with sendMessage method can be passed in?
it seems like everything has its own way of sendmessage
and there isnt 1 thing for it
probably commandsender
ur missing a break; at the end of all those cases
💀 just return the value
Anyone know this?
In line 63 I am setting deaths to it like before but minus 1 it’s not working
i dont recommend saving the config every time someone dies
rather cache it in memory and save it every x seconds and when the server shuts down in onDisable()
So the culprit is how I’m saving it right?
i dont really know, could you send the code as a code block instead of an image
its kinda hard to read rn
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
Hi
what is PlayerDeathCountManager
i want to find how many gravel in player mainhandslot can someone help
a HashMap
get the players inventory, get item in main hand, get amount
ok thank you
and so is PlayerKillCountManager a HashMap
firgured it out
i was using return before saving the config
class vanish: CommandExecutor {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
val vanished: MutableList<Player> = mutableListOf<Player>()
if(!sender.hasPermission("serverutils.vanish")) {
sender.sendMessage("${ChatColor.RED}You do not have enough permissions to use this command.")
return true
}
return if(sender is Player) {
vanished.forEach() { plr ->
Bukkit.getLogger().info(plr.name)
Bukkit.getLogger().info(sender.name)
if(plr.name == sender.name) {
sender.player!!.showPlayer(Bukkit.getPluginManager().getPlugin("Mainutils")!!, sender.player!!)
sender.sendMessage("${ChatColor.GREEN}You have been unvanished.")
vanished.removeAt(vanished.indexOf(plr))
return true
}
}
sender.player!!.hidePlayer(Bukkit.getPluginManager().getPlugin("Mainutils")!!, sender.player!!)
sender.sendMessage("${ChatColor.GREEN}You have been vanished.")
vanished.add(sender.player!!)
true
} else {
sender.sendMessage("${ChatColor.RED}You cannot vanish from the console!")
true
}
}
}
whats wrong with my vanish command?
it keeps saying that i get vanished but i cannot unvanish
hey, is PersistentDataType.BYTE in an PersistentDataContainer an boolean? if not how do i create an boolean in the PersistentDataContainer?
Am I too stupid to find it, or doesn't the 1.19 API have a PlayerChatPreviewEvent or something like that?
Or how can I intercept the chat preview?
What is the best way to teleport armorstand nametag above the players head? I mean packet teleport (and no passengers). Doing it with bukkit runnable with 0 delay and 0 peroid is good way? I want to desync the nametag with the player as little as possible.
idk about that tbh but you could always just safe a string with the value of "true" or "false" and then just use Boolean.parseBoolean if there's no other way to safe a bool inside a pdc
Also, just out of curiosity, why are you using "an" all the time?
Hey,
When I try to build my 1.18 NMS Project this error occures. Can somebody help me?
Failed to create remapped artifact, project main artifact does not exist.
i'm not native english so my english not so good.
No problem, I was just wondering
Are you german? I'm just asking because your name 😄
yes :D
Achso hi 😄
hi :P
Could you show your pom?
?paste
^
Use passengers if you don't want it to lag
Otherwise the best you can do is to teleport it every tick
I don't want to use the passengers, because I'm doing multiple lines and when I do it via passengers I can't manage space between the lines
oh well laggy lines is what you'll have then
Finding Chat Preview listeners
I fixed it but now I get an error in my console saying that the specific class doesn't exist
can i implement new particles with a resource pack without overriding vanilla ones?
Make sure it does
Not much we can help with if you give no information
No
why is this game so hardcoded ffs
because this is not client modding
You shoudl have seen it 5-8 years ago
The client in most cases could tell the server what was correct
im sure that was a delightfull experience for hack developers
where are persistent data containers saved on the server?
there's an nbt tag
called BukkitPersistentDataContainer that stores all the data
Using a § to format a chat message will see it formatted properly in game
is is safe to store personal data there? like an hashed password i use in my login plugin?
But in the console, it simply gets a pair of corrupted symbols prefixed
oh okay
just use SQL or something
The data is sent to all clients for certain PersistentDataHolders. So i would advise against that.
^ like itemstacks and other entities
It will also not work if you have multiple server instances and/or a lobby.
Make sure to enforce a utf-8 file encoding for your src code. (via Maven or Gradle)
Nope
Still corrupt
Regardless, it works just fine in 1.18
Go ahead and try to do /say §2Something in the console
Oh are you using an ancient version? I remember this problem being an issue in old versions.
quick question how do i get access to the internal mojang stuff idk what its called
the things that spigot doesnt wrap
like CraftPlayer class
- CraftPlayer is not mojang stuff
- Its called NMS (net.minectaft.server)
?nms
ugh
hi uhh
ah yea NMS
Scroll down to "NMS"
is it possible to get a fabric server to send and read packets from bungeecord?
It looks to me like this is yet another 1.19 bug
What I wonder is, how does this even happen
Sure. There is literally no limit what a fabric server can do. You can even let CS-Go clients connect to it if you really wanted to,
has anyone here actually tried making a custom looking gui using model data ?
is it just applying a texture to a model (in the inventory)?
Yes. There are several ways of achieving that.
okay soo is there a mod that does that or any resources/documentation/tutorial?
These two corrupt characters are U252C and U00BA respectively (§), and happen consistently
Ask in the fabric community
are you doing that by just adding 1 item which covers the entire thing with a texture or does it have to be more specific than that?
I got 0 responses there so I'm asking here
(aside from the cards one where clearly each one has its own texture)
- Approach: Using an ItemStack in the corner or another position which has a model that covers the whole gui.
- Approach: Replacing a unicode character that has a big texture and will be used as the first letter in the gui's name.
ok so approach 1 is feasible then
I was wondering if there was going to be some annoying logic where the texture appears centered or something
@lost matrix Do me a favor and type say §2Something into the console on a 1.19 instance and send me what it prints out
I have a theory
thanks for the hints
One moment. I dont have any 1.19 environment set up atm.
Need to write a docker container real quick.
how does approach 2 even work actually, that sounds hilarious
how can you replace a unicode character with a texture?
so i am currently using Spigot/Spigot-API/target/spigot-api-1.19-etc.....-SNAPSHOT-shaded.jar
is there a NMS jar somewhere in build tools as well?
oooooooh
If you take a look at this you will notice new icons like the logo on top.
You can replace thousands of characters in your resourcepacks font and make them arbitrarily big.
wait is it as simple as remaking a unicode character in the resource pack?
Yes
that doesn't sound like it even requires additional programming if you can name the menu in the first place, right?
God, I wish mojang would just give us a server sided data driven HUD api
It would be so redicilously simple to do
Infact, I have already done it within less than a day
Yeah and blocks. And mobs while they are at it. Then we can basically do anything we want.
Including anchorpoints, resourcepack integration for assets, translation keys and scoreboard integration
And pre-defined layouts in datapacks
It took me like 6 hours
And only required one new packet
You got your instance yet?
BuildTools is just building it
iirc you shouldnt even be able to type the § character ingame...
Not ingame
you can in console
You're supposed to enter that in the console
which of these should i use?
F
Something broke in the component parsing
You cant use the bootstrap jar anymore.
Follow the example in the thread ive sent. Use maven and special sources plugin.
Huh
So I just tried to start a vanilla server to verify the issue
And uh
Apperantly that one is even more broken
could you explain what the bootstrap jar is? like, whats the difference between the 4 jars
i cant upload a screenshot for some reason
oh i see
not verified nvm
Dont use any jars. What do you need jars for anyways?
If you dont use a dependency manager then you will have a lot of trouble with dependencies like that.
so i should just not use buildtools at all and switch to maven instead
You use BuildTools regardless because it install Spigot/Bukkit/Minecraft into your local maven repository so you
can depend on it.
Hello everyone, I recently started developing plugins, so I still don’t know much, so I immediately apologize for the stupid questions.
Is there any way to keep track of when a mob enters and exits (this must be checked) from a certain player radius?
It looks like this is a vanilla issue actually
A vanilla server fails to print colour as well
You mean spawn and despawn?
What is your goal?
No, when the mob enters the radius (you can check .getNearbyEntities) and when it leaves it. I want that when a mob enters the player's radius, he was given a glow effect, and when he left, the effect was removed
Is the players radius a modular value or do you mean as soon as the player sees the mob?
a nice idea, but it would be fairly resource hungry due to you having to check in a timer
modular
You wouild have to check every player with getNearby and track all mobs close to the player. apply/remove effects based upon the last data
and static
Best i can think of is to get all nearby entities every second or so.
or check use entitymoveevent if you wanna kill performance
What should I use for this?
?scheduling
there is no entity move event
Player#getNearbyEntities()
And a scheduled task
Thanks
alright so when i add the classifier line it says it cant find it
was there one in older versions
But how to track when a mob goes out of range?
PlayerMoveEvent is laggy enough. Now imagine that but even worse
EntityMoveEvent is a bad idea
spigot-api doesnt have mapping
only spigot
because spigot-api doesnt include nms classes
Keep a Set<Entity>
When the mob is not in radius in the next iteration then it left the radius.
so change artifactid to spigot
Run BuildTools for that version
how do i do that with maven? i already ran it in a seperate folder
with --rev 1.19?
yes
but its not connected to my maven project in any way
i just ran it from console
i normally just use the spigot api shaded jar
Then the dependency is in your local maven repo. Thats where maven looks for dependencies.
how do i tell it to look in my local repo then
You run BuildTools for 1.19
already did
It should be there then, so long as you didn;t have any errors when building
check your buildtools.log
should be good
then check here to see if it exists C:\Users\%USERNAME%\.m2\repository\ORG\spigotmc\spigot\
if on Windows
that will pull from maven. Means nothing to yoru local
huh?
oh remapped. did you use teh remapped flag when building?
no actually
hang on
can i just use non-remapped
also what is up with eula for that
i read something about remapped not being allowed to share
just for dev
You reobfuscate it ofc
if you are using NMS you want to use remapped and have specialsource reobf after compile
All done by the special sources plugin
how do i set that up?
in your pom
read teh 1.17 post linked in the 1.18
it has all about remapped
mfnalex has a good wiki page about nms
where even is the mave config file
no idea on the link though
@tender shard You got a link to your wiki about remapped nms?
sorry for being such a noob but how do i build my plugin with maven, when running this it doesnt include my source files
How?
oh ok, this is kinda annoying tho, is there a way to make it build and jar at the same time
make an artifact
in ur module settings
right click on ur project and then module setting
oh ok so it just works like normal, thanks
is java pass-by-value or pass-by-reference for objects?
reference
why does minecraft even obfuscate their code if they also release official mappings
wtf
Only pass by value for primitives, and Strings are pass by value, in effect, and immutable as they’re kind of special
They don’t map everything
values arent mapped
right makes sense
They have to do the bare minimum to protect their code to be covered legally if anyone tries to steal/distribute it
java is pass-by-value
?
if they try to sue someone for stealing the code, and its not been even remotely attempted to stop someone from doing so it doesnt prove a good case
Its by reference
no, its pass by value, even if we deal with references
Java is pass by value, yes, but it’s passing the reference as the value. When you reassign a parameter in a method, you don’t reassign the reference of that parameter, but create a new variable overshadowing that and change the reference of that parameter
in fact, we dont really pass references, we technically pass pointers
It’s a mixture of both, that’s why no one seems to agree what it is
However, all the non-primitive types that include objects of any class are always implicitly passed by use of pass-by-reference.```
ok so i managed to get my plugin build working
now what i am wondering is why does it still work even after i deleted all of build tools and also removed it from my local maven repo
does it download a pre-built one from https://hub.spigotmc.org/nexus/content/repositories/snapshots/ ?
it didnt seem like it built it itself because that would have taken much longer than a few seconds
pointers to the references which refers to the object in the heap
the pointer is the value we pass
no
he asked about objects which are pass by reference
they are not
They are
you neither pass the references itself, nor the object.
all objects in Java are pass by reference, Only primatives are pass by value
all you pass is the adress visualized as the reference to a reference
teh address IS the reference
https://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value is very informative here
Yo guys do you have anything activated while coding to go easy on your eyes?
lightmode in a dark room
Java is technically always pass by value.
But the value is in most cases just a reference.
but font size 24
Also very informative https://www.softwaretestinghelp.com/java/java-pass-by-reference-and-pass-by-value/
please help i wanna try learning how this works
XD
And full monito brightness. No blue filter.
exactly, but that doesnt change the fact that its pass-by-value
Is blue filter actually helping to not fatigue the eyes? I never really tried it tbh cause the colors kinda suck with it on
this.goalSelector.addGoal(2, new PathfinderGoalMeleeAttack(this, Player.class, 1.0D, false));This line throws error even tho i have installed nms package with remappings
Which error?
cannot reselve the symbol"PathfinderGoalMeleeAttack"
Im suspecting that those names come from Spigot and not NMS. The remapping has completely different names.
The original ones from Mojang.
oh is there any fix?
Sure. Use the proper class/method names.
: org.spigotmc:spigot:remapped-mojang:1.19-R0.1-SNAPSHOT
how can i find the proper names
Any suggestions on how i would check if the player had been damaged by the wardens sonic boom, as its not an entity
Searching. Look at EntityZombie for example or other classes that use pathfinding and see how they initializer their goals.
In NMS you are on your own. Reverse engineering is all you can do.
EntityDamageEvent -> check cause?
Huh
I dont think its any of these?
Oh it may be projectile, let me have a go, good idea.
Just sysout the cause
I did some digging in the librarries and found mojna remmaping/nms/world/entity/ai
This is what i found in Zombie
@Override
protected void registerGoals() {
if (level.paperConfig.zombiesTargetTurtleEggs) this.goalSelector.addGoal(4, new Zombie.ZombieAttackTurtleEggGoal(this, 1.0D, 3));
this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
this.addBehaviourGoals();
}
protected void addBehaviourGoals() {
this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0D, false));
this.goalSelector.addGoal(6, new MoveThroughVillageGoal(this, 1.0D, true, 4, this::canBreakDoors));
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D));
this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers(ZombifiedPiglin.class));
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
if ( level.spigotConfig.zombieAggressiveTowardsVillager ) this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)); // Spigot
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR));
}
can you tell me the file name so i can just find it aroudn there
net.minecraft.world.entity.monster.Zombie
But your IDE should just know this unless you are using something else than Intellij
i use intelligi
found it thanks now i am getting the idea what to do
is there anyway to like have a function argument as a function that can be called later and returns a value? probably not but i have to try
is this NMS?
ye
finally
Yes
oh?? interesting what should i search for?
No, that is CraftBukkit
Functional interfaces
Okai thanks
whats that and how do i get NMS instead
i thought i did everything right this time
What exactly are you trying to achieve? Because you can also couple them with CompletableFutures for
async stuff
That is teh implementation of Bukkit. NMS = net.minecraft.server
to search for help when opening my server do i place it here?
If you have access to CraftBukkit, you likely have NMS too
in nms package if i want to change a mob completely will it be safe to edit the main files of nms
You will need to patch Spigot if you want to do that
im trying to make a scoreboard system so like there would be a list of functions that update the line, like i would iterate thru that list and get the return value of that function(string) and set the line to that periodically
Supplier maybe?
idk how to explain it but it makes sense in my head
cheers your a legend, its entity_attack which is the most common >.< oh god
it cant resolve these, apart from CraftPlayer
Its likely changed name
Yeah thats a good use case. So either Supplier<String> or Function<Something, String>
Okai
Yeah classes have their names changed
does someone have a little bit of NMS example code that works on 1.19 so i can test if everything worked?
Here is a short example for Function<X, Y>
private static final Map<String, Function<String, String>> converterMap = new HashMap<>() {{
this.put("PREFIXED", input -> "XYZ: " + input);
this.put("SUFFIXED", input -> input + " @XYZ");
}};
public static void main(String[] args) {
String name = "Bob Martin";
Function<String, String> converterP = converterMap.get("PREFIXED");
Function<String, String> converterS = converterMap.get("SUFFIXED");
String nameP = converterP.apply(name);
String nameS = converterS.apply(name);
System.out.println(nameP);
System.out.println(nameS);
}
XYZ: Bob Martin
Bob Martin @XYZ
Process finished with exit code 0
Ohhhh thank you so much!
private static int counter = 0;
private static final Supplier<String> supplier = () -> String.valueOf(counter++);
public static void main(String[] args) {
System.out.println(supplier.get());
System.out.println(supplier.get());
System.out.println(supplier.get());
System.out.println(supplier.get());
System.out.println(supplier.get());
}
0
1
2
3
4
Process finished with exit code 0
Supplier.
You could have a List<Supplier> that fills your scoreboard lines. Each supplier is a function
that gets run every time someone calls it.
Ya but I think for like player-specific values on the scoreboard i'd need to have the player as an input to the function so Function<Player, String>?
if(entity instanceof CraftEntity craftEntity) {
net.minecraft.world.entity.Entity nmsEntity = craftEntity.getHandle();
Component textComponent = Component.literal(text);
nmsEntity.setCustomName(textComponent);
nmsEntity.setCustomNameVisible(true);
}
You can use this with the interact event or smth. entity is just a bukkit entity and text a string
thank you! where is the custom name supposed to show up?
in chat? tab menu? nameplate?
i cant see nameplate in singleplayer
Above the entity
You can for example use that with PlayerInteractAtEntityEvent and then set the name of the entity you're interacting on
Hi, I need to hide my armorstand nametags when player is hiding and showing for a specific player. How can I check when player is hiding or showing for the player?
wait you can define the variable as you check and cast. that's so nice
do you mean sneaking?
Java 14+ 🙂
No, I mean when a player is away, he is hidden from given players, I would like to know when he is hidden to hide the metrics as well. It is the same with spawning when a player approaches
^ When player A move away from player B, player A will be hided for player B
like behind blocks
this
so keep track of the movement and hide player A from player B with #hidePlayer
How to perform an action an infinite number of times?
never ending timer
how can i get inventory's title? Inventory#getView() and Inventory#getTItle() doesn't exist
I don't need to hide it, the server hides it, but I want to know when to hide my nametags with it
To have a delay between executions
#getView()#getTop/Bottom()#getTitle
?scheduling
#getView() on what object?
Don't compare inventories by their title
you are probably in an inventory event arent you?
alright i did that but the plugin is not able to load
as far as i know it is supposed to re-obfuscate it right? but when looking at the plugin file decompiled it still looks the same
i am not, i am comparing them with content, holder and title
You only need the holder
Could you send your pom?
what else
i just want to get inventory's title in a simple method, no events
just using this right here https://blog.jeff-media.com/nms-use-mojang-mappings-for-your-spigot-plugins/
except changed 1.18.2 to 1.19
That would work, how are you building the jar?
jar build artifact that includes "compile output"
it depends from where you get the inventory
someone in this chat said i should use build artifact
as argument?
since if you just have an inventory instance out of nowhere you wont get the InventoryView
ouch, they're probably not very experienced
Are you using Intellij?
yes
There's a maven tab on the right side
open in and find package
Double click that
Your jar will be located in the target folder
still the same result, except now it doesnt include my plugin.yml
Your plugin.yml needs to be in your resources folder
plugin.yml has to be in the resources folder of yoru project to be included
You forgot to change 1.18.2 to 1.19 in the remap part
oof
I have create a class called
public class NewMob extends Zombie {
public NewMob(Location location){
super(((CraftWorld)location.getWorld()).getHandle());
this.setPos(location.getX(),location.getY(),location.getZ());
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, Pig.class, true));
}
}```
and a command class
```java
public class spawnMob implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player){
Player player = (Player) sender;
NewMob newZombie = new NewMob(player.getLocation());
}
return true;
}
}```
To run the class but it says internal error occured
Send the error
?paste
how do i specify where to put the jar file, using build artifact i was able to just overwrite my plugin inside the server plugins folder
instead have your server startup script copy teh jar you want
i am using plugman and autoreload for developing
Make sure you're remapping
Bad idea. That's going to cause issues
i am
good luck with plugman
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier>
</dependency>
why is plugman so popular
yea yea ok thats my problem then, but how do i change the maven output please tell me
Send the entire pom
?paste
No idea I don;t do it. But I know its possible
<outputDirectory>path</outputDirectory> in your build section iirc
So you're not remapping
You're missing the remapping part
Read this ^^ and change 1.18.2 to 1.19
oh actually what is this groupid for?
Can I get all the players on a server in Runnadbel and check them out?
oh on a thread something different was said
its everything by md-5
Yes
How?
Bukkit.getOnlinePlayers()
Thanks
I have done the editing but now it shows error in pom
What's the error
i assume i am supposed to use the remapped-obf jar?
You should be able to use just the normal jar. it should have been replaced
Cannot resolve symbol 'remap'
the normal jar and the remapped look the same, but remapped-obf looks different
should i use display name for teams for my scoreboard or entry?
Did you reload the pom?
run it on a server and see which works
yup
You want the normal jar
yup the obf doesnt work
Could you show your pom
You didn't change 1.18.2 to 1.19 also why did you put maven shade plugin instead of the specialsource-maven-plugin
i blindly plasted the execution part from the website sirry 😦
wait it was maven shadeplugin from the startubg
?stash
??
error message on bungeecord:
disconnected with: DecoderException : java.lang.IllegalArgumentException: No provider for argument minecraft:test_argument @ io.netty.handler.codec.MessageToMessageDecoder:98 what does this mean
for context, what did you do
Update everything
I'm using this to GUI events. But Now I should add 5 red wool on the same GUI. How can I set event 5 of them separately.
do I need to update java?
everything else is up to date
https://www.curseforge.com/minecraft/mc-mods/fabricproxy I believe you need this
loop
soo uhh... 1.18.2.....
wait hold on
it is possible to send mod packets from a spigot server to a fabric client
right?
Yes
okay so I could just avoid this entire mess of fabric server mods by using spigot server
...
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
🤦♂️
also uhh
is it possible to like
run the bungee and spigot servers in the IDE as a run configuration?
you could
because it sucks having to replace fiies a lot
yep. just make a profile for that
k
ok*
...
Hello! I'm trying to add PersistentDataContainer() to an arrow entity, but it doesn't work... here what I have.
(EntityShootBowEvent)
} else if (itemConsumed.isSimilar(TestArrow.getInstance().arrows.diamond)) {
arrow.getPersistentDataContainer().set(TestArrow.getInstance().getKey(), PersistentDataType.STRING, "ARROW");
}```
(EntityDeathEvent)
```java
if (e.getEntity().getKiller() != null) {
EntityType entityType = e.getEntity().getType();
Entity entity1 = e.getEntity().getKiller();
Entity entity = e.getEntity();
if (entity.isDead()) {
System.out.println(1);
}
if (entity.getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.PROJECTILE){
System.out.println(2);
}
if (entity1.getPersistentDataContainer().has(TestArrow.getInstance().getKey(), PersistentDataType.STRING)) {
System.out.println(3);
}
if (Objects.equals(entity1.getPersistentDataContainer().get(TestArrow.getInstance().getKey(),
PersistentDataType.STRING), "ARROW")) {
System.out.println(4);
}```
and only reaches the number 2
what am i doing bad?
i can block plugins command ( this not working pl.getCommand("plugins").setExecutor(this); )
?
and version command?
you can use this event https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerCommandPreprocessEvent.html
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
where is TestArrow assinged
wdym
what is testArrow
the main class
...
uhh
hold on
you have set the instance for TestArrow right?
@acoustic pendant
thanks
Hi, a PR was merged recently for this.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDamageEvent.DamageCause.html#SONIC_BOOM
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
this:
public NamespacedKey getKey() {
return key;
}
key = new NamespacedKey(this, "diamond_arrow");
I notice users are getting java.lang.UnsupportedOperationException: Cannot spoof chat on this client version! with BungeeCord on 1.19 - is this related to the chat changes? I didn't see this API breakage noted anywhere 🙂
not sure.. but you can open a ticket in GitHub for bungee (?
Interesting
It's just odd, surprised me a bit
Feel like it's an undocumented breakage
so what you are testing for with 3 is if the person who shot used the diamond arrow?
I want to check if the entity that killed another entity is an specific type of arrow
ah
ok
and I was trying getPersistentDataContainer() but i don't get it
hmm
you set the data when fired and later when "impact" not?
i set the data fires and then check when a mob died yes
it's the killer, so it's supposed to be the arrow
Is there a way to get an item from specific Item Slot in gui, not specific Item???
maybe can share the code? i remember set data in arrows for make teleport things... then not sure how in your case dont work
check if it is, just in case
this is the code
if (entity.getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.PROJECTILE){
System.out.println(2);
}
I have that
np
have you tried giving the arrow a tag instead?
a tag?
like
the TAG is like the same... this not fix the error... @acoustic pendant you debug if the data is set in first place?
oh
I think so, i wrote 1 before and 2 after, and both got fired
like this
ok and when the entity die all the debug are fired? the killer is a arrow? not a magic thing?
the first and second are fired
strange... if you try in damage event? (added logic for know when the damage can kill the entity) not sure why can happen maybe when entity die the arrow is vanished... not tested
yeah
the problem is
that with EntityDamageByEntity event I can't use #getDrops
i know its a bit a stupid question but, from spigot 1.18 now you can't add as a library the whole spigot file but you have to pick the libraries from the jar file, is that correct or there is another simplier way?
isn't there a maven or smth
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
Thanks
but i mean, now this file doesn't contain nms or craftbukkit, isn't there another way to have every single library in one jar just like the old file?
can you please send me the Maven? i can't find it 😦
man, now spigot became so much hard to prepare, now there are many files to find, miss the old spigot
btw thanks for the link
Hey gaymers, i need some math help. I currently display the player's level (custom to my gamemode) as their exp bar level. I want to also display their progress like I do on my scoreboard, is there some precent way or some funky math I can use to do this ? im really trash at math
All you do is set their level progress
but I want to change the exp bar itself
bc the exp its out of changes each level exponentianly
ohhhhh
Yes
i was overcomplicating it in my head thanks 😛
there are some things that can't be done with spigot unfurtunately
What are you doing
Why player object after reconnect doesn't equal player object before reconnect? (the same player)
ohh, ok, thank you!
how do i get the player that issued the attack from a EntityDamageEvent
You shouldn't be storing a player object after the player has left
That's just wasting memory
Use EntityDamageByEntityEvent
ah thanks
and when I do Bukkit.getPlayer(uuid) it should return the old object or the current one?
Current
Like olivo said you shouldnt really be storing old player objects
Huge memory leak potential
Yeah, but I need to know what armorstand nametags my player has, so should I assign them to uuid?
if i use that and do event.setDamage(event.getDamage()*1.5F) then this value will still be lowered by armor and resistance correct?
Yeah uuid is best choice
Yeah Iirc the value is raw health deducted
After armour calcs and stuff
and when I need player object for the location I do Bukkit.getPlayer(uuid), right?
what is getFinalDamage then
Yeah
Honestly the javadocs are a bit vague
since finaldamage is calculated before you can process the event you should apply multipliers based on final damage
Anyone knows why it's not showing any items when I do this?
Bukkit.getScheduler().runTaskTimer(plugin, () -> gui.setItem(10, new GuiItem(trollz[0])), 1L, 20L);
If I do it without the runnable it works fine
What is trollz 0
@earnest swift, Hey.
an ItemStack from ItemStack[]
Also is gui the current open gui?
yes
Sounds like either you’re not updating the inventory or updating it before the item is set
do recipes or namespacedkeys need cleanup onDisable?
No
aight
Kinda depends. recipes are stored in teh world files
so if your plugin is not loaded and it registered recipes you will see startup errors
Yeah thats true
that should do
why not just add manual check for op?
give it a permission
but shouldnt this just do it
default: op
I mean, if you would like to allow only op execute this command then you may have to add it manually
because the default: op works a bit not as you expect, possibly
default: op will grant access to ops. If it has no permission
also why when i delete all commands
until sell
my plugin just breaks bro
if i delete them
assign a permission and it will be given to ops AND anyone with the permission
when i just join
i dont even use the commands
that i delete
and my plugin just breaks
if i delete them from plugin.yml
Let me see your code, the place where you set the command executor
I love it when stuff just works the way you imagined them
getCommand(x) returns null if there's no that command in the config
so at this place your plugin is going break
how do i get all the enchants on a item (custom ones too)
just wrap the getCommand in a try-catch block
where's it?
if(condition)
{
}
🤮
if() {
}
if()
{
}
facts
I do not see the part of code here
there are 2 type of persons
anyways, bumpy bumpy
i made this instead of try catch lol
so, if your command will have not registered, you'll even don't notice that?
yep
but this wasnt the problem apparently
cus it still doesnt work
if i delete some commands in the yml
how can i just disable or delete them
introduce the exception
oh its probably this
ye
i had one out of the loop that i was deleting
nvm
ty @opal raven
I dont see it?
try updating your POM/Dependencies
What version as i cant find it anywhere on spigot mc
<version>1.19-R0.1-SNAPSHOT</version>
currently using this
Run in my compiler?
eh
Ight cheers dw
👍
Sorry i dont use maven that much where would i be doing mvn clean install -U
are you using gradle ?
wat
oh
I misread
just your terminal
idk if intellij has a button for it ?
but open your shell in the directory of your project and go for it
Hey guys, does anyone know how to spawn lightning that follows player's direction.
So player looks at west and the lightning effect will shoot first at player's location then go further in the direction player's is looking 1 block at a time for max 6 blocks.
This is my current code that shoots always at the same spot.
int thor = 1;
@Override
public void run() {
event.getClickedBlock().getWorld().strikeLightning(event.getClickedBlock().getLocation().setDirection(player.getLocation().getDirection().multiply(thor)));
thor += 1;
if (thor >= 6) {
cancel();
}
}
}.runTaskTimer(KitPvP.getInstance(), 0L, 5L);```
maybe im being dumb xD
oh you just don't seem to have it installed
Ill try to install maven
you could just do it from intellij
on the right side there is a maven tab
find "run maven goal"
and throw the command in there
I got it cheers
Ahh finally yeah it was being weird
Caused by: java.lang.NoSuchFieldError: SONIC_BOOM any ideas?
just got thrown when i got hit by the warden
if (event.getDamager() instanceof Warden && event.getCause() == EntityDamageEvent.DamageCause.SONIC_BOOM) {
@quaint mantleyou only add the dependency in POM not? or run buildtools for update?
I didnt change the pom just reverified maven and it sorted it, was there a update pushed? as i would have thought its the same code
ive not tried to rerun the build tools yet no
i mean i make a update of project for reload dependency or tell IDE for reload cache
Yeah i did that
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
And this is my pom, ill recompile buildtools incase its got something to do with that
Erm, just compiled using the java -jar BuildTools.jar --rev latest and it compiled as 1.18.2? Known bug or?
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.pessulum.plugin.banclass.BanClass.getCommand(String)" is null
at com.pessulum.plugin.banclass.BanClass.onEnable(BanClass.java:30) ~[BanPlugin.jar:?]
what does this error mean
Chinese text exception
nope, in forum not say about latest updated. use --rev 1.19
how do u send a player a message where it shows something when u hold ur mouse on it
like more writings
Is the error report here?
Aye guys, I'm having trouble with PlayerFillBucketEvent. I have a custom item meta defined with a PersistentData byte with a unique key indicating that it is a specific custom item. I do a check on this byte to see if the item is custom in most of my event listeners. For some reason in the PlayerFillBucketEvent when I check the meta it doesn't have my persistent data. Does this event fire AFTER the bucket is actually filled? Thus turning it into a water/lava bucket?
why is thisbeing caused
this is the code
how to get all the enchants from an item (even the custom ones)
commandblock or plugins
plugins ofc
How can I change a player's displayed name in tab so that it shows how many hearts he has?
Add a scoreboard objective tracking health in the player list display slot
ok
Chinese text exception
?paste
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
How to get location x blocks from current location which is diagonal
Well moving diagonally is essentially just moving x in 1 direction and then moving x perpendicular to that direction
If there's smarther solution then adding int to X and Z
yea
I thought of that
but in implementation I think there has to be some way using super cool hacker math like WorldEdit does
How is the direction determined
If the direction is always the same then there is no reason you should overengineer simply adding/subtracting X and Z
prob stupid b ut works so far 😄
Vector dir = new Vector(ship.getCurrentLoc().getDirection().getX(), 0, ship.getCurrentLoc().getDirection().getZ());
newLoc.add(dir.multiply(-1*blocksMoved));
Is there a way to tell if a player has shift held inside a PlayerInteractEvent?
anyone?
ahh you can check if they are sneaking, that will do it
how do i run command as console when using .dispatchCommand
Bukkit.getConsoleSender()
It'll remove the item
tyty
I have this scoreboard:
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getNewScoreboard();
Objective objective = board.registerNewObjective("HP", "health", "Hearts");
objective.setDisplaySlot(DisplaySlot.PLAYER_LIST);
Score score = objective.getScore("HP");
player.setScoreboard(board);
}```
How do I set what's displayed so that it doesn't only display the score. like put a heart near the score or something
What is the Math behind diagonal forward vector?
on player death im issuing /kick player but its doing the command same time the player is dead. How can i make it do the command before the player becomes not available to comamnd
first of all, why in the world would you run the command
just do Player#kickPlayer
second: on deathEvent, afaik you can't do a few things related to the player instantly. add a slight delay to it, something about 5 ticks
Could anyone help me with creating a PlayerHider item? At the moment everyone is hidden while the item is active but when a new player joins while the item still is active he isnt hidden, how can I fix this?
players are automatically set to shown when they join
its how minecraft/spigot works
yes ik but isnt there a way to check "okay, a new player joined, the current player has the item enabled so hide the new player"
same thing as with the displayname for example, which also gets reset
sure, just save the hidden players in a hashmap (if there are specific hidden players) or just add him to a list if it's all players that should be hidden
then on join, you hide them if they're inside the map/list
?paste
I have made a peice of code to summon a zombie made using nms package but it gives this error
https://paste.md-5.net/coranamihe.pl
You're using the wrong remapped jar
but later i joined their discord server and talked about it
anyone here like cryptography, specifically SHA256withRSA signing
after a lot of edition still the same error
i keep getting Signature length not correct: got 256 but was expecting 128
my code:
//Create signature
Signature signature = Signature.getInstance("SHA256withRSA");
//Initialize it with public key
signature.initVerify(publicKey);
//Adding data to be verified (Salt, UUID, Timestamp, Message)
byte[] data = new byte[32];
ByteBuffer buffer = ByteBuffer.wrap(data).order(ByteOrder.BIG_ENDIAN);
//Verify salt
buffer.putLong(signData.getSaltSignature().getSalt());
//Verify UUID
buffer.putLong(uuid.getMostSignificantBits());
buffer.putLong(uuid.getLeastSignificantBits());
//Verify timestamp
buffer.putLong(signData.getTimestamp().getEpochSecond());
//Update this stuff
signature.update(data);
//Verify message content
signature.update(jsonMessage.getBytes(StandardCharsets.UTF_8));
//Verifying the signature
return signature.verify(signData.getSaltSignature().getSignature());```
customizable in which way
the command, btw i fixed it now and it all works
?paste
uhh i see...
what if i put a huge ass Thread.sleep in my code :troll:
but why would you do that, when they automatically get kicked on death anyway
i dont think its wrong since i copied the code from website and did necessary changes
they dont...?
on player death im issuing /kick player but its doing the command same time the player is dead sounded like it
Code isn't wrong. You did that right. You just put the wrong jar in to the server
yea i guess so
i meant the pom.xml
I know
basically because the player is in the death screen they cant be kicked by command
It is correct
i mean, it can be the case that you're trying to kick a player when he's inside the death screen
so how can i put in correct jar?
Yes this
When you package your jar take the one that's your plugin name. Not the one that's -obf something
i'm sure that on the client side, player's are set to null when they die, and re-initialized when they respawn. may be something similar on serverside
oh
Yea that seems to be the issue
yea, not possible
maybe with sending some packet which kicks the client, but idk if thats a good way lol
i dont think it changes anything
yea it is
yea ill use that then
that does require them to have clicked "respawn" before you kick them tho
yea thats not a huge problem
yea, then go for that
as they dont exist to the server when they are in respawn
well... afaik they technically do on the server side
but some stuff like kicking is just not possible
anyone knows?
when i use p.kickPlayer() it works fine just not commands
maybe its an essentials thing
Score score = objective.getScore("HP: <heart-symbol>"); i suppose
oops forgot a char
why not?
because you can use the existing one
Wait nvm you set the scoreboard after
or not?
but it needs to be created by the plugin.
well the scoreboard does already exist in vanilla
it's just not shown
the scoreboard does include the tablist (which is shown), the player name (somehow, dunno exactly about that), and the sidebar, while the latter is just not displayed by default
I have created a custom zombie using nms how can i summon it using a command
so just change it to Scoreboard board = manager.getMainScoreboard();?
basically
but how can i call the nms zombie
uh i guess from whereever you create it?
Didn't you already do this?
I have this now and it doesn't show what I wanted (it only shown the HP value)
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getMainScoreboard();
Objective objective = board.registerNewObjective("HP", "health", "Hearts");
objective.setDisplaySlot(DisplaySlot.PLAYER_LIST);
Score score = objective.getScore("HP: " + ChatColor.RED + "❤");
player.setScoreboard(board);
}
@EventHandler
public void PlayerJoin(PlayerJoinEvent event){
createBoard(event.getPlayer());
}```
i did but my method did not seem to work
uhhhh
Any errors?
nope
can you send a ss from the scoreboard?
NewMob newZombie = new NewMob(player.getLocation());
the nms class?
so what should I do?
afaik you can set the RenderType to RenderType.Hearts
somehow
i suppose Scoreboard#setRenderType?
wait a sec
there is no such thing
turns out because i was using .getDisplayName() it wasnt recognising the player .getName() works fine now
well yea
obvious
it is the command
I did objective.setRenderType(RenderType.HEARTS); and nothing was changed
tf
Looks fine, could you show the entity class?
?paste
here's what i did in a very old plugin, it may still be working
public static void setTabHealth(Player player) {
Objective obj = sb.getObjective("hbn");
if (obj == null)
obj = sb.registerNewObjective("hbn", "health", "hp");
obj.setDisplaySlot(DisplaySlot.PLAYER_LIST);
double health = player.getHealth() * 5.0D;
obj.setRenderType(RenderType.HEARTS);
obj.setDisplayName(ChatColor.RED + ");
for (Player players : Bukkit.getOnlinePlayers())
players.setScoreboard(sb);
}```
That's not the entity class
obj.setDisplayName(ChatColor.RED + ");
wrong use of ""
yea, thank jdgui
bruh i am so stupid
?paste
I am so sorry
https://paste.md-5.net/bizevuyabo.java
i accidently send the main class
@slate mortar ok I just copied it from you and it works
nice
whats the new PlayerChatEvent its apparently depricieated
AsyncPlayerChatEvent
what about PlayerPickupItemEvent
EntityPickupItemEvent
ty
for the future
oh yea omg im so stupid
the classes should tell you why it's deprecated
i should read more before i ask
youre fine
((CraftWorld) world).getHandle().addFreshEntity(entity, SpawnReason.DEFAULT);
You can change the SpawnReason to whatever you want
god, nms is so weird
Not really
lies
How so?
That's unmapped
yea, its just my head
and i'm too dumb to make it work with mapped nms
so i kept away from nms and will probably never touch it again
You just copy paste stuff in to maven?
tell that to my maven/intellij
If it doesn't work you can always share your pom here and we'll help
it was long time ago
no one had any idea lol
it's actually kinda funny how many things i posted in here, which even the devs couldn't answer lol
ok
apparently you're not able to "replace" the reload command for example? like wtf? why only the reload command
I mean that's CraftBukkit and not NMS
yea this was just related to this one
and I assume it has something to do with the reload command overriding the vanilla one
like... using getCommand("reload").setExecutor(executor); instantly errors out with a npe lmfao
Did you define it in your plugin.yml
._.
that question kinda hurts, but yes lol
it was only present with the reload command
all other ones worked fine
You never know with this channel
yea fair
so like that super(((CraftWorld) location.getWorld()).getHandle().addFreshEntity(org.bukkit.entity.Zombie, CreatureSpawnEvent.SpawnReason.DISPENSE_EGG));
No
In your command class put that code under where you create your entity and pass it the entity and world
Hello, Can you show an example code for creating a fake armor stand with metadata using NMS for the player? (1.18 or 1.17!) I have tried many times to find this on google but without success
Tysm For helping me from afternoon 🙂 everything finally worked
now i will be able to make dancing warden tommorrow 🙂
Do you want to spawn an armor stand or a player? also with fake do you mean with packets?
yes, create a fake armor stand at certain coordinates in a packet that will be visible only to one player
Do you want to use Protocollib? or just NMS
NMS