#help-development
1 messages · Page 135 of 1
ok
apparently theres a this.level should i just use that?
use this when you spawn the entity
nice
yeah this shit happens when you use nms
ive been trying to make an npc move for 4 weeks
💀
make a goal or smth
need to give it some AI
anyways
ServerPlayers dont have goals
anyways
can u send the entire error
i thought it did that on its own
nope
not programming specific but which are the valid responses from a call? Like, accepted, reject, cancelled, etc
what ones does goat use
occupied?
traces back to a ClassCastException
well it depends how the entity was spawned. But typically custom entities don't do anything unless it has some goals which that is what gives it it's AI
says SupremeGoat is in an unnamed module
should i just make it follow players or smth
also that exception traces back to addFreshEntity
you can if you want
anyone know why the npc is spawning so high up?
its spawning at the husks coordinates
but the husk is down there
sometimes the npc spawns underground
and moves as the zombie husk moves
also for some reason the husk is invisible aswell
code
npc.spawn(new Location(this.getLevel().getWorld(), this.getX(), this.getY(), this.getZ(), this.getBukkitYaw(), this.getVoicePitch()));
this is a modified class of zombie
public void spawn(Location location){
final float[] currentHealth = new float[1];
final double[] prevX = {0};
final double[] prevY = {0};
final double[] prevZ = {0};
Logger logger = CustomMobTest.getInstance().getLogger();
ServerPlayer npc = instance;
ServerLevel level = npc.getLevel();
npc.setPos(location.getX(), location.getY(), location.getZ());
Bukkit.getOnlinePlayers().forEach(player -> {
sendJoinPackets(player, npc);
logger.log(Level.INFO, "Sent join packet to " + player.getName());
});```
hm
spawn method
the first four variables are useless
i refactored them somewhere else
what about the location
what about it
the reason it is spawning underground is because the getY is underground
its spawning in random areas
nono
the husk is spawned via a command
so the husk is over ground
and its moving fine
and the npc moves fine aswell
but it spawns in different coordinates
how do i add attributes to my custom nms entity
the Attribute object makes no sense
dont know how to get one
whats the new method for PlayerAttemptPickupItemEvent
i was updating my plugin but it doesn't exist anymore
it might have been a Paper method actually
probably just PlayerPickupItemEvent or smth
that's deprecated
EntityPickupItemEvent then
bump
oh Attributes is a thing
Use the messaging channel
is the spark cpu usage in its api system or jvm orientated?
nvm it literally says cpu system
What are you trying to achieve
wealth, health and happiness
Me2 tbh
Looks like you didn't understand me
does anyone know how to get dynamic unicode characters for playerheads, or if it is even possible
For what reason
trying to make something similar to what mcc island has
Sorry, that was not for you
I hope someone other will help you 🙂
I literally gave you the answer
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
BTW that was the same thing I told you like 12 hours ago
How can i report a plugin developer?
by clicking the report on their profile
lol I can report myself
yooooo
how would i force a goat to ram at something? i originally had a runnable setting ram cooldown to 0, but when i made an nms entity for it instead it doesnt work anymore
@Override
public Brain<Goat> getBrain() {
Brain<Goat> brain = super.getBrain();
brain.setMemory(MemoryModuleType.RAM_COOLDOWN_TICKS, 0);
return brain;
}
it makes the thing always should no cooldown in data but still no ram spam
I've created a random tp plugin and I was wondering if there is a better way to get the highest block in a coordinate without having to load in a chunk
loop from top until you find something that isnt air
you would need the chunk loaded regardless
ik
otherwise how else would you do it?
ah so lag is an issue no matter what
not really that laggy surprisingly
well it depends how you do it
I have it check a radius of 5,000 blocks around the player, the plugin only runs it up to 1,500 times but whenever I run the command and it takes longer than a couple seconds the server lags, and sometimes crashes
So it checks about 1,500 blocks before teleporting the player, checking if the blocks meet the criteria for the player to be safe
So max that it registers is 1,500 chunks per command. Feel like I may have messed up with my code allowing it to run multiple times
cant you just make it choose a random number between -30m and 30m, then do it from there?
in a nested function and return once it finds a good spot and tps
The end user enters how far out they want em to tp
then restrict the random
I basically do that, but with a confined space around spawn
It works fine, gets a place to tp each time I let it run forever, however, it isnt great for server performance
I have the random restricted from example: 5000 blocks in the x and Z coord, so it gets a random spot within the 5000blocks. It then checks up to 1,500 times to see if the block that was randomly selected is safe, and if it isn't it will not attempt to teleport after that.
But in those 1,500 checks if 2 player's run the command at the same time it lags the server alot, and if the server is a low end server it lags it alot
You can, why wouldn't you be able to?
?paste
Peble
I remember you from somewhere else
I think the problem is because you are not shading the HikriCP library into your jar
But let me make sure if that is the issue
Because you normally get NoClassDef... error when you try to use a library which is not already loaded in the JVM
... means its continue the exception name just to dont write the full name
haha
There you have an example for shading dependencies
follow the tuto i sent
It fully explained how to do it
When creating several ItemStacks, should each custom item that I am creating be in a single ItemStack class or should I have a package just named ItemStack & then have an individual class for each item I am creating. What is better optimization wise? I assume one class?
What are u trying to achive?
making a bunch of custom potions.
it's not, which is why it's not needed.
thanks.
Something like:
public class CustomPotions {
private ItemStack potion1;
public void load() {
// intiliaze your potions
}
// Setters
// Getters
}```
I appreciate it 😄
And if you are messing with files i would just do:
An Potion object containing main data for each potion + A repository where to keep all the potions
@quaint mantle im with you know sorry mate
Try this code
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>library.groupId</pattern>
<shadedPattern>${project.groupId}.libraries.library-name</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>library.groupId:library-artifactId</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
replace library.groupId with the groupId of what you want to shade
replace library-artifact with the artifactId of what you want to shade
replace library-name with the name of the library you want to keep it
Also if you want to a dependency be shade dont add scope provided to it
wait
Have you add the code i sent to your pom
After you run the project u will have 3 jars i think
send a pic of target folder
Hmn
Can you send me your current pom
also how are you building it?
hehe
you forget that
Hahaha
shitaa I dropped my stane today when I was welding and it hurts like hell.
wait
how else i can help?
Is there any caveats when using getPersistentDataContainer or limitations? I'm considering using this to store a decent amount of entity state/data and wondering if I should use this or a database/api.
private void updateInventory(Inventory inv, Player p){
// Update ComplexItems
for(ItemStack item : inv.getContents()){
ComplexItemStack itemStack = ComplexItemStack.of(item);
if(itemStack != null) {
Util.sendMessage(p, "Updating Item!");
itemStack.update(true);
} else {
// Update Normal Items
Util.sendMessage(p, "Updating Item!");
ItemMeta temp = Bukkit.getItemFactory().getItemMeta(item.getType());
temp.setLore(List.of("nerd"));
Util.sendMessage(p, "ItemMeta: " + (item.getItemMeta() == null ? temp : item.getItemMeta()));
new ComplexItemMeta((item.getItemMeta() == null ? temp : item.getItemMeta()), item);
}
}
}```
I can't set temp's lore, because temp is null, along with if i use `new ItemStack(item.getType()).getItemMeta()`, despite me using these methods before- is there anything i'm doing clearly wrong?
No
Wait
where do you code?
I would like to see your project
like do you have anydesk just to me see how you compile it?
Lifesteal but with potions
public static String colourize(String message) {
Matcher matcher = HEX_PATTERN.matcher(ChatColor.translateAlternateColorCodes('&', message));
StringBuilder buffer = new StringBuilder();
while (matcher.find()) {
matcher.appendReplacement(buffer, ChatColor.of(matcher.group(1)).toString());
}
return matcher.appendTail(buffer).toString();
}```
this method i have used for a while has suddenly stopped working
anyone know why?
i have one
not the best coded one
but at least it works
<#HEX>
how come this isn't translating?
RankUtil.getLightColor(p) + p.getDisplayName() + " &7has joined the game. (" + getPlayerList().size() + "/" + getMaxPlayers() + ")"
rankutil returns the hex value which isn't translated
and it translates that
but it does this
(same issue before using yours too)
Is there a way I can give an entity Antikb, but still be able to set its velocity.
I need to keep an entity moving forward, but give it antikb to all attacks from players, explosions, everything etc. (It still needs to take the normal damage from anything just have antikb but still be able to set its velocity)
Also is there a simple way to make it face the same direction as its velocity forces it in?
If the player has the permission dune.admin does that mean they also will have all sub perms like dune.admin.setconfig?
only if you gave it
dune.admin.setconfig has no relation to dune.admin to a permision plugin, not unless you clearly define it in your plugin.yml
if you want dune.admin to encompass all sub permissions define it in the plugin.yml as having those children.
so would this mean by having dune.setconfig you also have dune.admin?
permissions:
dune.admin:
description: Allows DuneAdmin command
children:
dune.setconfig:
description: Allows setconfig
im trying to have a single admin command that takes the first arg as what admin action you want to do
be sure your admin nodes are set as either default: false or default: ops
Do you want some admins to have access to some admin commands but not others? or an admin is an admin and gets them all.
https://www.spigotmc.org/wiki/general-introduction-of-packets-nms/ i hope this gets updated
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
That should be deleted. Its terrible
honestly im having better luck just looking up examples and learning how it works. By examples i mean working examples that explains what each line does
just wish there was an updated explanation on packets. specifically spawning entity's using packets
is there a way to change the amount of rows inside of an already created inventory?
Hello, I want to create a plugin which teleports all player to another world when an event occurs.
My question is should I use the multiverse api for just two worlds? (the default and the newly created)
I feel like it's overkill
Thanks
hello, I have make a basic gui menu plugin on 1.19.2 and i want to change the background anyone know how to do that because i dont see anything about this subject on forum or ytb
thanks
How can i give player something in certain World? Like diamond, Iron or something
a
dont forget A
a
obfuscated
i forgot the link but theres a website
which translates it into actual names
fuck okay
knew it was something like that
any pointers? im not sure what to even look up in this senario
ive been googling and its not coming up
im about to make some sad monkey noises
big thank
do u know what mappings you're using?
im about to find out
That's obfuscated so no mappings
I recommend using Mojang mappings in your project. Will make things much easier for you
ahh thanks, will do
What is the jdk version used by spigot?
Depends on what version you're building against
I guess the latest version out there
Java 17 is what you probably want to use then
thanks pal
is there a way to Instantiate an abstract class as a subclass ? reflections
im trying to do it with EntityCreature
?paste
Abstract class can't be instantiated. You have to create a class that extends your abs class, or implement directly the abstract classes while creating an object
Maybe an abuse of static methods. Why don't you create an "Hologram" class which refers to the entity?
Uhhh, it's technically possible but it would be such a pain. I recommend looking on online forums to do so
its static due its an utility
otherwise i would make an DI
you can still use objects for utility reasons
Static only makes sense when you're not dealing with objects
or in an object space
so its pretty bad ;o?
Reasonable usage: Generating a random string
Bad usage: spawning an entity
yeah
thanks ill think about how to improve it
because the issue with HD and other alternatives it wont allow me create some illusions like falling blocks...
PotionSplashEvent#getAffectedEntities() does not work if the thrown potion is a splash water bottle...
So I apparently need to do it manually...
What's the range of potions?
because they're not meant to?
It works with Mundane potions, which are not meant to do anything either, so I thought it would work with the splash water bottle too 🤷
4x2x4
Thank you
found it within nms
actually it's slightly bigger
because it derives from the potion's bounding box
so
X: -4.25 -> 4.25
Y: -2.25 -> 2.25
Z: -4.25 -> 4.25
so it's like 8.5 x 4.5 x 8.5
seems wrong
might be way too big, divide by 2
Hello, what do you recommend me to do in this situation, should I use MiniMessage for better performance?
(I'm updating an item everytime the player breaks a block) https://imgur.com/RA6gteR
maybe don't update the name every time you break the block
How can I do that when a player has an item in his hand after 2 seconds he renames it and if within those 2 seconds he changes the item he sends them a message and cancels the event
I dont think i get it
me neither...
I don't know how to explain it
I think he wants the player to write something into chat in order to rename the item he is currently holding?
I tried to make it, ill' send the code, it isn' t working
Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask(GTaser.getInstance(), new Runnable() {
public void run() {
if (!(player.getInventory().getItemInMainHand() == Items.taser(3))) {
player.sendMessage("§e§lGTASER §8» §7Ricarica annullata!");
return;
}
player.sendMessage("§e§lGTASER §8» §7Ricarica taser in corso...");
player.getInventory().removeItem(new ItemStack(Material.FEATHER));
final ItemStack item = player.getInventory().getItemInHand();
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§e§lTaser §6[4]");
item.setItemMeta(meta);
}
}, (long) (2 * 20));
}```
I don't know how to expain what i want to do
Well if you cant explain what you want to do then you dont actually know what you want to do.
So step one would be figuring out what you actually want.
Who renames it?
relocate issue
No, i mean that i don' t know how to explain it in english. Wait ill find an example
But first of all
player.getInventory().getItemInMainHand() == Items.taser(3)
You should never do this.
Always use the pdc of the ItemStack to check for custom items.
?pdc
This line of code will randomly fail.
Its for 1.14 and upwards
"only"? 1.14 is already extremely outdated
Hi, i want to change my config in game with a gui, but i want to keep the comments in the config file... this is my code
This is for change the config in game
And this for load at begin
Any idea ?
there's an option for it to keep comments
lemme check
getConfig().options().parseComments();
try to call this before saving your config after changing it
oh and call this BEFORE you do .set(path, answer)
What version are you on?
that's too old then I guess
it was added only "recently"
although I think 1.17 should be able to to this
IIRC it was added in 1.17 or 1.16
hmm... so how do i do this 😉
with the builtin YamlConfiguration, you cannot with your current version, it seems
you need to use some third party library
(or manually copy the changes to the .yml file 😛 )
I just checked, it was added in 1.18.1
whats is this ?
it's "stuff someone else wrote"
probs like configurate or something
You can find parser on github that is derived from bukkit one but keeps comments
It's called simple yaml or something like that
The plugin is for 1.12
ok i will check this
thanks
UH can someone give me a guide to make npc player and make npc damgeable pleas
How can i make this in a plugin
what? printing text when someone right clicks with a stick?
No, if you see after it send the first text after some time it changes the lore and removes 1 of ghast tear
hi?
listen to interactevent, then change the lore and remove 1 ghast tear
what version?
And how can i do this, if the player changes item when his reloading in cancel the reload
1.16.5 or 1.12.2
hm I have no idea about such old versions
in mojang mappings, it's easy, but those are 1.17+
do we have any docker experts in here
please just ask
I have World time 1 ( lets say 12000) and I want it to smoothly transition to World Time 2 ( 22500)
How should I do it?
via for loops?
no 😎
I am definitely not a docker expert but I know how to do "most" things 😄
well
I have an issue with a compiled program binding to the host IP
within the container
oh that sucks
and it fails as docker doesn't allow to bind directly to the host IP
I know docker supports stuff like -p HOST_IP:HOST_PORT:CONTAINER_PORT so is there any way to add it
no its the public ip lol
yikes
so is there a way to modify the network parameters for the container
only thing I could imagine is to adjust your docker networking settings and setting up a bridge interface or similar on the host so you can assign exactly this IP as the "internal docker ip" to the container
but that seems like a horrible solution
well I just wanna change the networking settings for that container
not sure how to lol
is there a conf file
or do I need to use the cli like a pleb
you can't just arbitrarily change this per container
it's not docker's fault (although I fucking hate docker)
wait but that says 0.0.0.0, so you're fine?!
yeah because I can listen on 0.0.0.0
not the direct IP that is in the compiled program
(in the program the IP is set to be like 1.2.3.4 instead of 0.0.0.0)
I could re-compile but that will majorly fuck me over most likely yesterday the same thing was throwing errors and today it miraculously works
there's some paths it was using to compile that have been deleted by now so uhh yeah
is it java or something nasty? because changing it in the program itself is probably way easier. otherwise you could "double nat" your stuff but that also seems like a horrible idea
its C
huh not good
you'd need some quite complicated iptables rules to intercept the incoming packets before docker's iptables rules do, then NAT them yourself to the container with a changed destination IP. I don't know how, it's possible, but it's very nasty
that wouldn't help anything
it's not docker's fault when a tool only listens to 1.2.3.4
but docker could pass the IP instead of 0.0.0.0
0.0.0.0 just means "listen to all interfaces"
the 0.0.0.0 thing means "no matter on what IP this is incoming, forward port X to docker port Y"
if you'd set 1.2.3.4 there it would mean "if something comes in for 1.2.3.4 on port X, forward it to docker port Y"
that wouldnt help you, unless 1.2.3.4 is your actual IP
and in that case, 0.0.0.0 would still work fine
it is
its the IP that the server has but within the docker container it seems to uh not work
yeah but you see, docker containers do not directly have the host's interface
they have internal IPs, usually sth like 192.172.0.17
that still requires NAT
bruh
networking is always a mess 🥲
that's why you can literally study this shit at university lol
😂
https://hub.docker.com/r/dreamcat4/pipework/ you could try to use this
although I have no idea on how to do it
and it'll only work for IPv4
ill have a look in a bit tx
how can I make Daylight cycle go faster?
look at the source of my Daytime plugin https://www.spigotmc.org/resources/daytime.102748/
it involves some nasty math, and NMS
Try to remove local repo and download again
Looks like it's corrupted
I also found that stackoverflow post, but that didnt help. I mean what even am I supposed to remove from my repo? It's complaining about classes that are just now about to get get com piled :/
damn wtf I found the problem
I used the wrong group id for one of the artifacts
no idea why it didnt tell me "couldnt find dependency XY"
very weird error message 😄
if you got any further questions, feel free to ask, but first of all, look at my Daytime source
this is basically all you need: https://github.com/JEFF-Media-GbR/Daytime/blob/master/src/main/java/com/jeff_media/daytime/WorldTimeTask.java
How can I access this variable?
Put it inside the BukkitRunnable
new BukkitRunnable() {
boolean randomBool = false;
@Override
public void run() {
// ...
}
}
But what if I want it outside of it?
final int[] tapCount = {0};
addSiteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tapCount[0]++;
}
});
``` I found this, is it a good practice?
Yeah that works
It's alright practise I think, won't effect performance or anything
very specifc question, does anyone know if it's possible to give frost walker to a mob?
Give it frost walker boots works I think. If that's not possible listen to the move event and spawn ice below
you can't listen to move events from mobs but sure, I'll hack something together failing giving them boots
The Tool i use ist bozoobfuscator
If i remember the Name correctly
Oh forgot about that
Has funny Tools Like deobfuscator crashers
Tho those are hacky and mostly shit
Right
:/
So i have been mucking around with plant growth and was wondering more about the general process. And how exactly the spigot.yml growth modfiers actually play into it all.
Ive seen plenty of posts about how it doesnt work, its bugged etc. But where are these modifiers actually used?
if you just want noobs to not be able to open your jar, generally corrupting the BOM is enough
u mean bozar?
what even is a bom
it is two bytes at teh beginning of teh file which specifies what type the file is
Java will still execute it fine but it won;t be openable by many tools
how to do that
Which config entry are you speaking about? Max size of cacti/bamboo?
a simple Hex editor like Hexedit
hello, i created a data file in my plugin folder, but when i reload my plugin, this file clear himself and idk why
Spigot.yml
Growth:
Ah those are use in random ticks to determine if the growth should progress
Indeed I understand this entire
but i want to see where the sausage is made as it were.
Because im doing math as I have a seperate plugin that determines when a growth should fail based on % chance
So want to up the growth values of these modifiers so I can have biomes that grow some crops faster
and some slower, and some at normal minecraft rates
Atm I can do slower and normal
So my plan is increase these modifiers, and then set the plugin to have "normal" rates be a negative modifier in the plugin. If that makes sense
But to do this, I need to know the exact maths behind what these modifiers do and where
And as far as ive seen, the main posts about these modifiers have mainly been "They dont bloody well work"
So i'd like to see exactly where they are utilised
how to get the spigot 1.8.8 R3
This is an implementation question which means you need to start digging
?1.8
Too old! (Click the link to get the exact time)
yes R3
?bt
Is there a good approach to do so?
Go into your IDE and start searching 👍
no 1.8.8 1.8.8R3
1.8 support was dropped years ago
Also, why the heck is it not good practice to have some comments, or list, or something to make clear where config entries are implemented
Also this is not a dev question
Again. Because thats an implementation detail and should generally be no concern to the user
You need to build it yourself
I already have but only get the 1.8.8 normally
ich brauche ja R3
How so? If one doesnt know how a modifier is implemented, how do they know what it does. 110 could boost it by 1000%.
If you are mucking around with say BlockGrowEvent for some custom stuff, how do you know how the config modifiers effect it?
Go into #help-server and dont bother us with your ancient, unsupported version from half a decade ago
F
Its true that there is very little information about the effect of this config value. But the implementation doesnt belong there.
Lets do some digging.
yay haha
Will get cracking
nope frost walking boots on iron golems will not make the iron golems frost walk
And i know you say it doesnt belong there. But I am curious as to why a comment not giving even a signpost to where implementation is utilised is nothing but a boon
Seems like it'd be good standard practice
doesn't work on zombies either
Location of implementation is not a concern for the server administrator
It's info for a developer
You are not separating these two roles
Oh I get that completely.
I guese im asking why we, as far as I know, don't have an easy way as developers to see where config entities are utilised.
As god forbid, we might forget ourselves haha. Is that not the point of comments?
You know sometimes I have a dumb moment
This is one of those moments haha
😅 we all do from time to time lol
How can i make that a player cant drop something if has his inv closed?
You cant detect if a player has his own inventory open or not
i tried using this if (!player.getOpenInventory().getType().equals(InventoryType.PLAYER)) {
I think it was through advancements or a statistic
use == on enums :}
Found it:
net.minecraft.world.level.block.CropBlock#randomTick(...)
Also mentionable:
net.minecraft.world.level.block.CropBlock#getGrowthSpeed(...)
how to make custom npc type player and Player able to damage to npc?
or just use Citizens
TutNetHandler sound funny in german
Last time i used the plugin it burned 20% of the tick with 0 players online and only 5 npcs.
Never had any issues with it
~4years ago
A lot of things can change in 4 years
Yes. Legacy code only gets better with time. Thats a well known rule in development.
how the heck do i do that in intelij? As the jar is compiled
damn it make tps server stink??
Try it yourself. My experience was from a long time ago.
@eternal oxide Uh, do i remove the first two bytes from the left on the jar file?
Just scroll down to your dependencies and look through the decompiled sources.
Or just open spigot as an actual project
UH is there anyway to use zombie goal for citizens npc?
Yeah if you build it then you got the sources. But its less effort just checking like this
I am here to gib my knowledge
Spawn a zombie and disguise it using LibsDisguises.
I dont know a good way to spawn a Player entity with AI other than disguising another entity.
You don;t remove, you replace
usually with NOP
I can;t remember if its the first two or 2 and 3, but replace with 0 and see
hmm where can i have LibsDissguises doc?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
?paste
i get this error
https://paste.md-5.net/pevagatahi.bash
Who want to bet its an npe?
CustomItem line 41
Send the whole method surrounding this line
And mark it
Ah nvm you already send the code
newItemMeta.getLore();
My bet is on this line. It returns null if the ItemMeta didnt have any lore before.
myes nice stackoverflow
ohhhh
looks like i made it work somehow lol
@errant narwhal
at me.libraryaddict.disguise.DisguiseAPI.disguiseToAll(DisguiseAPI.java:295) ~[?:?]
at org.devilcryy.commands.onCommand(commands.java:37) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[server.jar:git-Spigot-79a30d7-f4830a1]```
can someone help please
bruh ij stupid, by not directly throwing an exception in my Validate class, it cannot longer infer the fail contract
Looks like you're casting something you shouldn't be
You shaded Lib disguise in your plugin
Holy crap...
it just hit me
I think the calc is wrong.
shaded?
Player p = (Player) sender;
Location loc = p.getLocation();
Skeleton Vergil = loc.getWorld().spawn(loc.add(1, 0, 1), Skeleton.class );
Vergil.setCustomName(ChatColor.BLUE + "Vergil");
Vergil.setCustomNameVisible(true);
Vergil.getEquipment().setItemInMainHand(new ItemStack(Material.IRON_SWORD));
Vergil.setMetadata("Vergil", new FixedMetadataValue(plugin, "vergil"));
Vergil.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET));
Vergil.setMaxHealth(50);
MobDisguise mobDisguise = new MobDisguise(DisguiseType.WITHER);
mobDisguise.setEntity(Vergil);
mobDisguise.startDisguise();```
Shouldn't it be : (int)(100.0F / (float)modifier *((25.0F/f)+1))==0
Are you sure that's all the code
nope
Then send the rest
what line is commands.java:37
mobDisguise.setEntity(Vergil);
how do you correctly make a sound play for the player in a way that at least feel global and not based on a location?
oh
now i know
there is the error lib's disguises can't set player model for entity
oh
you made that gun plugin?
use a hashmap to store the bulllets dont change item data in real time
it will cause that animation to appear
I want to suprise my friend so:
How do I fit picture to the screen for while? (With resourcepack)
?paste
how to obfuscate with proguard?
full screen?
it wont really help u
everything is reversable if game can run it
so
;l
via packet
in newer versions you can use different pictures as well
idrc
you can put it will remove his real helmet
ah
do u know how to use it or not tho
ty!
i have my own obsf proguard is dogshit
mister java dev
what would be the scope for jetbrains annotations dependency?
can be whatever
i know default is compile but does it actually needs to be compiled into the project?
no
well if you wanne use it for runtime
but thats rarely the case with these documentation types of annots
is anyone who know how to set player skin for libsdisguise??
?paste
https://paste.md-5.net/idirixipax.md Aye, can you check 582
relegions are made for sheeps
its 6 smartass
math priority
because + is first
no no 2 monkey
first is () then its power then its dividing and multiplying and then +-
2+2*2 == 8
because 2+2 = 4
x2
8
kacper i know math logic
but guys it meant to be joke for god sake
guys dont correct me i know math rules
that * :
and etc would go first
in the commutative ring of integers multiplication takes precedence to addition
and () even has more weight
im fucking up my token buffers by going recursive lol
should probably have one per expression brr
how do you verify if String is a valid Integer?
You parse it an catch an exception
guava Ints.tryParse or Integer.parseInt
hmm
just check it
in my old code i found StringUtils.isNumeric
is stringutils a bukkit thing?
String check = "\d+";
if (!args[0].matches(check) return false or true
that one is quite feeble
wont be able to parse too big numbers
will this one be good?
nah my soluation is the best.
oneliner sounds perfect
ah f me thinking String#charAt had poor performance but forgot String has a byte[] field
so what do you suggest him to use instead?
public static boolean isNumeric(final CharSequence cs) {
if (isEmpty(cs)) {
return false;
}
final int sz = cs.length();
for (int i = 0; i < sz; i++) {
if (!Character.isDigit(cs.charAt(i))) {
return false;
}
}
return true;
}
this is what apache does
first of all matches() will recompile the regex every time
just try catch NumberFormatException with Integer.parseInt
or use Ints.tryParse
where does it check for - lol
public static boolean isNumber(String s){
try {
Integer.parseInt(s);
return true;
}catch (NumberFormatException e){
return false;
}
}
bet
tf is this
no idea
@onyx fjord it might be better then my soluation
String check = "\d+"; yourstring.matches(check); is still dope.
me tryin to optimize stuff smh
String#matches still has to compile regex and hence is slow
better use a Pattern
he uses it on command probably
i dont think the ms is big deal
by theory yeah its better
can i modify how much xp bottle will drop easily?
itd have to be "\\d+" but myes, for strict digit parsing thats better
discord ignoring first backslash smh
Material#valueOf can use number id or only name?
name
but more specifically names that match the enum constants only (case sensitive)
One question can a whole server be made with the Skript plugin?
yeah
how ever skript has many limitations
Hey Guys, Is there a way for using dll file from C#?
no
if you hate performance and yourself
oh..
native impl lol
enjoy lag and high maintenance costs
like public native int add(int a, int b); ?
ahh
lol i wasn't just asking
Notepad
I tried it but doesn't work so I think there's no way in a normal
hey how can i do this:
I have a large number, i wanna do a for loop that splits it in smaller chunks and then does something with those
?jira
^^ report it here
You'd probably be best to state it here first to make sure its a bug
can you not load native libs? from a bukit plugnin
if(cfgSection.getBoolean("cost_absolute")) RItemHandler.absCost(droppedItems);
else if(cfgSection.getBoolean("cost_relative")) RItemHandler.absCost(droppedItems,cfgSection.getIntegerList("cost_relative_list"));
else if(cfgSection.getBoolean("cost_material")) {/*implement later*/}
else RItemHandler.absCost(droppedItems);//default
```people always say u shouldnt use else if / chained if, is there a way to optimize this?
probably with Stack, but recursion is probably better there
You could use a ternary operator but nothign wrong with if/else
never done that hmm
Hello,
Is it possible to teleport player to another world under certain condiition?
(the world does change)
And then teleport him back to the exact coords he was before?
as i see stackoverflow its probably possible
i doubt a tenary operator is a good idea because depending on the selected cost the argument changes
doesnt teleportation only work in the same world?
if i make a tenery operator for that it just results in an even bigger mess
it works cross dimensions if u have the loc
huh
howd you make nether portals otherwise
if/else is a boolean test, same as a ternary
in that case ill use the option that keeps my code semi readable
ie if else chains
yep probably best
thats not much context lol
I mean
u can use tenary
but u really shouldnt do it if the code block exceeds one instruction or variable assignment
So... im posting it now... but I think that the growth rates in spiggot have been wrong for like 2 years haha
Posting it in bug reports
I have this code and I want it to make a 5 sec cooldown on all cmds but it doesnt work. I can still use commands as fast as I want. I have it registered as an event listener in the main.
public class CommandCooldowns implements Listener {
public CommandCooldowns(CoolPlugin plugin) {
Bukkit.getPluginManager().registerEvents(this, plugin);
}
HashMap<UUID, Boolean> map = new HashMap<>();
public void onCommand(PlayerCommandPreprocessEvent event) {
UUID pUUID = event.getPlayer().getUniqueId();
if (map.containsKey(pUUID)) {
event.setCancelled(true);
event.getPlayer().sendMessage("§cWait! You cannot execute commands this quickly!");
} else {
map.put(pUUID, true);
new DelayedTasks(() -> {
map.remove(pUUID);
}, 5 * 20);
}
}
}
delayedTasks aint spigot
use an actual sceduler
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
also
common practice is to do a map<uuid, long> for the timestamp the command may be executed again
not a scheduler which adds overhead
;-; ok
I made delayed tasks moterius
package coolplugin.util;
import coolplugin.CoolPlugin;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import java.util.concurrent.Delayed;
public class DelayedTasks implements Listener {
private static Plugin plugin = null;
private int id = -1;
public DelayedTasks(Plugin instance) {
plugin = instance;
}
public DelayedTasks(Runnable runnable) {
this(runnable, 0);
}
public DelayedTasks(Runnable runnable, long delay) {
if (plugin.isEnabled()) {
id = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, delay);
} else {
runnable.run();
}
}
}
cus its a listener
on the code I just sent?
there is No listener in that code
yes there is lol
PlayerCommandPreprocessEvent
its just faster
too many letters
lol
In last code you sent, there is no listener
We are talking about the last one, you implement Listener but its not a Listener
for an event to be processed by bukkit the method it is in - ur onCommand - needs to actually be a method flagged as such. For events that @EventHandler, for commands its @Override
you could just have the class extend bukkit runnable
instead of runnable in constructor
how do you sort tab completes
lets say i have
foo
bar
and current user input is f, i wanna show foo on top, is there an easy way?
how do i move an nms NPC
there any tutorials for it?
i need a way to make the npc go to a specific coordinate
Collections::sort?
If it exists in the world you call its remove method. If it doesn't you send a removeEntity packet
rather than move relative to itself
auto completion has a return value, its a method u can get from implementing commandtabcomplete iirc. use that and give back the possible values
EntityPlayers have no pathfinding
i spawn an entityplayer at one coordinate
and they appear like 10 blocks around it somewhere
floating in the air or underground
idk whats causing this
or how to fix it
an entity will spawn precisely where you tell it to. So you are allowing that randomness
well no shit
im not allowing any randomness
i spawn in a custom husk
the npc player automatically spawns at that husk
and is teleported with the husk to make it look like the ServerPlayer is doing the pathfinding
the npc moves perfectly fine
the head rotation and all
it just appears in random coordinates
its usually close by
You are colliding with the husk
would entity collision make a packet entity fly out into nowhere?
the npc is only visible client side
so i dont think thats it
it can make teh client apply collision
bruh
this is client side as it does not exist on the server
how do i disable collision?
collision still doesnt explain how it can go that far off
are you willing to look at the code
again, you are being very vague, how far is far?
then thats unlikely collisions
I can only comment on the information YOU provide. tell me half a story and thats all I have to work with
As you are using packets your first task is to disable collisions on the husk
?stash
Wasn't PersistentDataContainer for blocks too?
yes
What ever have itemmeta ig
For some reason I cannot find where I can get it from...
Tried the block itself, BlockState and BlockData 🤔
are you refering to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Block.html as block ?
declaration: package: org.bukkit.block, interface: Block
Yes
Oh, I actually thought they were 🤔
Thanks, I guess
https://github.com/JEFF-Media-GbR/CustomBlockData you have this library
Thanks, will have a look
I think my statement still counts true. Executor threads are not deamon threads. Also deamon thread should rarely be used anyway.
Not sure if the Executor API gets updated, but at the moment using executor#shutdown and executor#awaitTermination remains the standard pattern.
And on Spigot a proper executor shutdown is even more important, as otherwise it might silently break data instead of preventing the server shutdown.
not sure what your point was here
in a PlayerCommandPreprocessEvent how do I get the command that they are running?
but most executors are implemented under the management of normal threads, in which you usually have the ability to pass a thread factory that may if wished summon daemon threads
shutdown + awaitTerm is what you use normally, but ExecutorService is going to implement AutoClosable soon hence why close() will suffice in the future
Executor threads can be daemon threads if it is specified. However there isn't really a big difference between the two types of threads. Daemon threads die when main thread does, and non-daemon ones die when their code finishes executing. That is really the only difference.
(And hopefully your concurrency will be structured as well as to avoid dead locks and other unfortunate byproducts)
So question, I'm trying to make a custom config file, I followed the wiki but when I try plugin.getCustomConfig in other files. It doesn't recognize it.
lastly, you usually have to implement some sort of locking mechanism when dealing with file IO across multiple threads frequently as opposed to atomically read and write
in which even if you terminate the executor accordingly you ought to await said locks to be released (or interrupt)
dont get me wrong eko, im not against a proper shutdown design (but usually your executor infrastructure isnt gonna be tightly coupled to your file business logic anyway)
Yes. But I was originally referring to "normal" Executors, which use non-deamon by default.
does apache commons have a method to get closest number from array to given one?
And discovered, that it could be dangerous when forgetting to shutdown. As Spigot by design creates a pitfall there.
what normal executors specifically?
anyway especially in enterprise, following principles like humble object pattern is pretty much a must
True. But that's actually a big difference. Imagine the writing of your file or any other execution is stopped in the middle of it.
Deamon threads are rather a niche thing for housekeeping tasks, like clearing caches and stuff.
more than that
Can you set a direction of an entity while setting its velocity?
(I want to make it always face forward in the direction its velocity is moving it in)
Right now I have this:
//Set Velocity
Vector velocity = target.toVector().subtract(entity.getLocation().toVector());
entity.setVelocity(velocity.normalize().multiply(0.1));
//Set Direction
Vector dirBetweenLocations = target.add(0, 1, 0).toVector().subtract(entity.getLocation().toVector());
entity.getLocation().setDirection(dirBetweenLocations);
but it doesn't work at all, it always faces in the same direction, is there something preventing it from setting direction because of its velocity?
bump
I tried setting its yaw but that didnt seem to work either
what you misunderstand is that hopefully your file business logic is not going to be tightly coupled to your executors lifecycle anyway
just make an entity walk/move from one location to another withought nms
you may (in most cases done so) expose a facade to talk with your concurrency dispatching infrastructure, and then let your file business logic rely on that abstraction
but then that file system can live on its own, hence you ought to be able to manage its life regardlessly
movement wortks good I just need to make it face the direction
also im not sure if I did yaw correctly, how would I set yaw with the vector?
Pretty sure I did it wrong when I tried it
anyone know why its still putting it in the default directory with the default file name
Not necessarily
But iirc the result set’s internal state is changed if for instance the outer scope closes (like the connection)
just cache the results like so:
public static final List<ResultSet> RESULT_CACHE = new LinkedList<>();
thank me later
How do I run an event in a BukkitTask?
I am trying to give potion effect in a BukkitTask
But yeah eko for the so called daemon
A lot more is using it that mere housekeeping tasks
Eventually. If the tasks it executes is capable of being stopped at any moment.
Well any library pretty that provides spontaneously usually opts in for it, fjp framework uses it so parallel streams, completablefuture etc
ok thxx
Can you not set an entities yaw/direction when you set its velocity?
this is why you should have some kind of redundancy in place or some mechanism in place to handle corrupt files
file corruption doesn't go away just because you decided to use something different
So I was wondering if there was a way to make an item not burn in lava similar to how netherite doesn't burn?
Is there not a property I could add to the item?
does netherite not burn when it is an item?
Sorry, what I meant was. Doesn't spigot already have a property for this since netherite exists?
-_-
Thanks, cause I can't really seem to find an example.
You can toss the ingot into lava and it won't burn. Same with debris.
Does an entities yaw/direction get affected by its velocity? And if so how would I add that to its velocity
why am i getting wrong number of arguments
The yaw variable is changing but the mob isnt actually rotating
are you just setting the yaw of the mob's location?
So changing this will prevent it from burning?
?
blocks and items appear to have this
add pdc to your item
it might be sufficient to just modify the metadata of flammable
anyone can help??
since there is an NBT data for such things, you could probably set items and blocks as not being flammable
I think I might just cancel event since I already need to check for the burn event for a different reason.
how do I get the command the sender used in PlayerCommandPreprocessEvent
Might be. Still the task would need to be safe to do so. As daemon work gets dropped when the JVM exists.
Joining a deamon thread would not make too much sense. As described here.
event#getMessage()
ah ok
I think you can then use #split() to also check for args and stuff
k
not really true
so like this if (event.getMessage() == "/spawn")
but yes for the average concurrency user you probably want to avoid it
ok so do I use the .equals thingie
correct
I never cast player to CommandSender without checking
^^
He's talking about CommandPreProcessEvent tho and not onCommand
no
preprocess can cancel event and do stuff before the command executes
oncommand happens after the events of command happen I think
Well. That would be another story again. My focus was just on preventing corruption by improper concurrency.
Aren't those type parameters aka generics?
Idk never done this
yes the params are generics i guess
Is it possible to change an entities pitch and yaw withought teleporting them?
not that I know, at least not without using nms iirc
No,I mean the getParamCount returns the generic parameter count
ok how should i instantiate it
can I make it face a different direction somehow then withought nms or teleportation?
or no
Ugh I'm not at my pc sorry
dont ask me what happened here but got rid of everything lol
Maybe getConstructor getArguments r smth
What would be the point of using a daemon thread over a non-daemon thread when joining it anyway?
And by that making it effectively a non-daemon thread?
No, im not only talking about joining the threads
But tasks that get executed by the threads
@ivory sleet do you know why this is happening?
Is it possible to delay a task, then restart it before it finished if needed?
But you can only join threads? Not tasks?
tasks are runnables?
Eventually were are speaking of different concepts here.
Yes. But you cannot "join a runnable", only it's executing thread.
No you can join tasks also
whats now the dif between a task and a thread? :/
Ofc joining the task will temporarily make said thread await the tasks thread
But thats conceptually a thing
Just look at Future or ForkJoinTask
And yes I am using join and await synonymously right now to simplify things but ofc they are not really equivalent
Yeah. I was referring to thread#join. Runnables don't have such method.
ForkJoinTask might be special case there.
No
CompletableFuture
Its fully possible by implementing a simple lock mechanic
Remember Object has notify and wait
can anyone help me who has like hours of free time to spend on an autistic kid like me? i'd like to make a discord bot, which can make you a role, like a team role, u add peoples to them, add a team name, and the others have to accept it, i have no clue how to code or anything
also BloodEko look at this
gonna be a very nice addition to Java once fully implemented :3
Is it possible to restart a scheduleSyncDelayedTask?
- (I believe it talks about ExecutorService::close)
but for your curiosity, an executor that uses daemon threads joins them if you await its termination post a shutdown request
not the best example
and also for file concurrency
we have AsynchronousFileChannel, and you could even go so far as to use ReentrantReadWriteLock
with Conditions if needed
Alright. Might be rather a Future than a Runnable, but I get the idea.
yeah, tho shutdown + awaitT isnt bad at all
Hello, how do you get At to have what he writes in color in the chat?
I was just saying that it might not be as fundamental always
check out this guy I learned bots from him https://www.youtube.com/c/CodeLyon/videos
bro ong why does Bukkit.getOnlinePlayers() return the wrong amount of players on server once a player leaves
i was just watching his video, i dondt understand anything from it tbh
he isn't watch this https://gyazo.com/265347b9e633cb7a0c7844c8ec26d5db
it legit doesnt change from 2 online players