#help-development
1 messages · Page 67 of 1
how about we disown you for being off topic
im out
anyways saving stuff in a sqlite database is reflected to the file immediately right?
isn't there a cache
thats what im wondering
Getting this weird error when I try to enable my plugin
public class RunnerVSHunter extends JavaPlugin {
public static GameManager gameManager;
@Override
public void onEnable() {
//STUFF
GameManager gameManager = new GameManager(this);
}
public static GameManager getGameManager() {
return gameManager;
}
}
Cannot invoke "com.sinden.runnervshunter.manager.GameManager.getCommandManager()" because the return value of "com.sinden.runnervshunter.RunnerVSHunter.getGameManager()" is null
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
fuck this shit, I'll get the 16 inch macbook
i'll just buy it and stop thinking aobut it
Yeah, neither should be static, but the error is that you're probably calling getCommandManager() in the constructor of GameManager but it hasn't been initialized yet
how do I make a while loop without it running 20000 times a second
How to find who killed Entity?
sounds like you'd rather want to use the scheduler instead
checking for while a player wears a certain armor piece
while(String.valueOf(event.getPlayer().getInventory().getItem(slot)).equals(String.valueOf(itemStack))) {
broadcast("How crash server tm");
}``` current code
I can find who killed Player, but What should i do to find who killed entity like zombie?
this makes absolutely no sense
EntityDeathEvent
what doesn't make sense about it, I just don't want it to crash the server
And then get last damager
Saw it already, getEntity might return dead entity
and for some reason ur making strings of everything
thanks
Yep, then get the Last damager
because checking as an itemstack didn't work
.isSimilar
ItemStack#isSimilar(ItemStack)
is there an event for opening a chest or something similiar?
InventoryOpenEvent
but that's not my problem, how do I make a while loop that runs only once per second
cause if(e.getInventory().getType() == InventoryType.CHEST) in inventoryopenevent might break some other plugins
?scheduling
I seem to have an issue with my UserInfo loader. I'm now running Database operations Async, but it seems they aren't running at all, for whatever reason. to avoid clogging this channel more please DM me with help.
does /reload reload player data files?
dont think so + wrong channel + dont use reload
wdym wrong channel kid
don't I need to loop all players every second using this
im coding a library
Cringe math in equation
lmao
to avoid clogging this channels, threads were invented
and im not using reload for plugins data
I forgot 
create a thread
bro already calling me a kid lmao, its just its more of a help-server than a development
no its not
not a java thread pls
?paste
thread.stop();
But how do I call getGameManager() from other classes without creating a new object of the main class every time?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
How to make backups that include a copy of the server's memory and storage, and use them only fly
how to write data to packet with "Chat" type?, i cant even find examples,
on fly* btw
Is there something similar to break; for this?
yea you can call cancel on BukkitRunnable
lambdas are slow aren't they
premature optimization, and i dont think theyre slow
in some cases they could use more resources tho
why do I feel like this should be red xD
it's not something to worry about
people instantiating bukkitrunnables :(
what's the advantage of using bukkit scheduler over the default one?
alright got it to work ty
default one?
executor one does not work in ticks
ah got it
bukkit one does and why use another one if the api already gives you one
yup makes sense
except for the last part
depends on your needs
Why use the bukkit one (if ticks weren't included)
because it already has a thread pool craeted for you
cuz you shouldnt be thinking about the impl
ah cool
if (Main.instance.lever == true) {
for (String cmdname : Main.instance.args.equalsIgnoreCase(Main.instance.rewardname)) {
//stuff i want to do
}```
hello, i'm searching for a way to verify if an args of my command is the same as a string defined in my main, but i dont find it, can you help me pls?
you dont find what?
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
new Thread(() -> /* code here */).start();
}
});```
the way to verifiy if 2 string have the same values and then execute what i want
i forgot the executor 😩
equals()?
error as well
Pls dont make all your fields public. That just messy af
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I have a Map<Class<?>, List<String>>, how do i add to the map if one is present, otherwise init with a value
i thought there was a nice line
getIfPresent()? or what do you mean
erm
like computeIfAbsent or sonething
computeIfAbsent
Like add to the list or?
computeIfAbsent
very useful👌
map.computeIfAbsent("mykey", () -> new ArrayList<>());
dont you mean add to the list?
thats computeifabsent
ah mb
yeah I edited it
map.computeIfAbsent("mykey", (key) -> new ArrayList<>()).add("word");
nvm me trying to be fancy
ok thanks 
lets go back to debugging smh
nah
ye stupid

Cry some more
and it was a Map<class, list<string>> lol
since when is printing out a map with sysout printing it like this tho :/
PacketContainer pkt = pm.createPacket(PacketType.Play.Server.SET_TITLE_TEXT);
WrappedChatComponent msg = WrappedChatComponent.fromText("123");
pkt.getChatComponents().write(0,msg);
try {
pm.sendServerPacket(p,pkt);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}```
Use Plib 5.0.0. This way you dont need to catch Invocations anymore
title smh
player.sendTitle
actionbar title bruh
lol
ok now i never used generics with class types. The goal here is that you have a handler of type <String> and then that makes the object an instanceof string:
@FunctionalInterface
public interface Handler<? extends T> {
void handle(Player player, Object<T> object);
}
Can i get some help please lol
this isnt valid syntax btw
void <T> handle ...
i try to learn how to use protocollib
Well if the interface is generic then the method doesnt have to be
also ? extenfsd T makes no sense
Object<T>
oh yeah lol
theres no way to do smth like <T extends Generic> void (T<Smth> param) right?
@opal juniper ```java
@FunctionalInterface
public interface Handler<T> {
<T> void handle(Player player, T object);
}
minus the <T>
yeah i saw fourteens message kek
BiConsumer<Player, T> hehe
why that?
dunno where the T would come from but ye
I know it's not needed but I like it for clarification
i hate how java does not have the ThrowingConsumer<T, E extends Exception> and functions and stuff
For the same reason you didnt put public abstract before the method. Its already implied
yo, did someone already worked with the sound system from minecraft?
i would like to know how could i emulate a sound by code without actually playing them
So how to play sound without playing sound...
so like implementing your own sound nms?
I want to enable flight for players in claims.
What event do i use instead of PlayerMoveEvent to not cause lag?
none
no, something like how to get those things
either the move event, or use a runnable and check every X ticks
only way ig, just do very much early returns lol
basically i would like to mix a lot of sounds to create another sound
None. You should just create a performant method for checking if they are in a claim.
Analyze the ogg files
yes but lets say
i mean, checking if X is inside region Y is like 6 math checks, you could do that hundreds of thousands of times per tick without problems
i want to play a music on minecraft
hmm im saving an user to the database but i deleted the database file before, where it it saved then? (sqlite)
convert midi files to noteblocks
i would like to mix existing sounds on minecraft on different pitch and yaw to create a sound near to the music
nearest possible
he wants to do this oscillating thing like piezo buzzers do
is that right? when you go to implement it the object is still of type "Object"
You need very complex math for that and it will take possibly hours to generate those
any ideas?
you can change it to whatever yo uwant
@Override
public void onEnable() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Bukkit.getOnlinePlayers().forEach(player -> {
if (player.hasPermission("crashclaim.fly")) {
player.setAllowFlight(CrashClaim.getPlugin().getApi().getClaim(player.getLocation()) != null);
}
});
}
}, 0L, 20L);
}
Whats the way to broadcast a message to the whole server on newer spigots?
Bukkit.broadcastMessage();
Is decrypted
wdym "is decrypted"?
myeah, i guess it just doesnt work with lambdas
maybe depreciated
Well not only is it not there, #broadcast doesn't work with strings
You are using Paper
Bukkit#broadcastMessage() isn't deprecated.
Ah forgot I was on purpur, which is obv a fork of paper
To get each frequency from a signal you need to transform it. Possibly with a fourier transform or a laplace transform.
You might get faster results if you transform in a discrete space. For that i would suggest a Z-transform.
it might be a stupid solution but i usually always add this to my plugins
public Component color(String text) {
return Component.text(ChatColor.translateAlternateColorCodes('&', text));
}```
in paper, everything is deprecated because they hate strings for no good reason
adventure is cool tho
a function which turns string to text component
hm. and i could compare different sounds with it?
I have something similar, which is a class so I can just do CC.RED or whatever colour
yes, ubt forcing people to use it is not cool
so you would
Bukkit.broadcastMessage(color("Here you put your string"));
in my function you can use &
§ supremacy
I just do
player.sendMessage(CC.RED + "Hello");
No
alt + 2 + 1 = §
isnt that easier
player.sendMessage("&cHello")
§cHello
same effort to do ChatColor.RED then lol
Another reason for java to have extension methods
what are extension method again?
You can analyze the spectrum of each sound. Then you can do a best effort interpolation (O(N^2) complexity) to find
which files to overlay to match a part of another spectrum.
like injecting your methods into another class?
Yeah
when i work with &, i like to use the ChatColor.translateAlternateColorCodes('&', "");
it is cool
Would love to make player.sendmessage translate colour codes
public void onEnable() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Bukkit.getOnlinePlayers().forEach(player -> {
if (player.hasPermission("crashclaim.fly")) {
player.setAllowFlight(CrashClaim.getPlugin().getApi().getClaim(player.getLocation()) != null);
}
});
}
}, 0L, 20L);
}
Does this method look efficient enough to not cause lag?
ah lol no wonder why my database wasnt working, its creating a new user object every time
uhh
its in onEnable so probably doesnt need to be async
ah its started then
i'd do it sync
scheduleSync
runTaskTimer
Isnt that deprecated now
nah
Schedule sync that is
probs
I mean it wont cause any lag but theres probably more efficient ways
It’s only every second anyway
PS: This is also a task you could give to a neural network
lol and next() is returning false every time
its present in the db but it says it isnt :/
Maybe you are connecting to the wrong db?
i just quit the game and saw an entry inserted into the table so no it isnt
lets try to print the preparedstatement::tostring
this is table setup, dont see anything wrong with that
If I want to make a custom model. Do I have to give up an item for it?
For custom items I mean
no
No, you can assign custom model data to any item so long as your resource pack has that attribute tied to your custom item.
you can bind custom items to normal items with custom model data ^^
So like a certain enchantment to bind the model to that item?
For instance, you can have a normal stick and a stick with the CustomModelData:1 tag and it will look different if you have your resource pack setup correctly.
Nice
In the base item's model file, you can specify different conditions to match for the texture to apply
That’s lit I thought I had to give up an item. Thanks for your help
https://minecraft.fandom.com/wiki/Model#Item_models
This gives really good explanation on that
hi is it som way i can hide a plyer body and not remove from tab and other players still can see otnhers and that player, tag me?
I appreciate it thanks @quaint mantle
Yeah with packets
but no other way?
Invis potion ig
no
what packet?
lmao
I wonder if Player#hideEntity() would work for your case.
giggles im in danger
It's removing player from tablist
Hmm, I thought that was the purpose of Player#hidePlayer()
PacketPlayOutEntityDestroy or something similiar
ClientboundRemoveEnity for mojang remap iirc
it hides player from tab and from others
thanks
give invisibility without particles ;)
nah
too easy
must complicate everything yk
Can still interact woth them
no other players can't see you
/*10*/ catch(Exception e){
/*11*/ goto(10)
/*12*/ }
do i need a nother plugin for packets?
ok
Then you'll be able to use packets without protocollib
oh
But spigot uses spigot mappings
It will also make your plugin version specific
but how do i import hole spigot?
and listening to packets might be too hard for you
Get the mojang mappings jar from buildtools
whats goto doing?
On 1.18+ nope
It will
It’s better than spigot defaylt
Assembly syntax. It literally moves program execution to the line you provide.
reminds me of buffer overflow wtf
Since 1.18 nms packet package is net.minecraft.server.network
Without server version
Method names still change
Very rarely
It's less common but it may change at any point
C moment
so it's effectively version specific
Yes, i mean with plugin update
Or you could just abstract your project in the first place. ¯_(ツ)_/¯
Or just use protocollib
If spigot'll ever use mojang mappings, it'll be much easier to use packets
Without protocollib
They can't provide them by default for legal reasons.
It does use it afaik
@EventHandler
public void onLeave(PlayerQuitEvent event) {
Player player = event.getPlayer();
try {
invUtil.saveInventory(player);
for (Player staff : Bukkit.getOnlinePlayers()) {
if (staff.hasPermission("survival.staff")) {
staff.sendMessage(CC.RED + "[Staff] " + CC.GREEN + player.getName() + " has logged out and their inventory was saved!");
}
}
} catch (Exception e) {
e.printStackTrace();
for (Player staff : Bukkit.getOnlinePlayers()) {
if (staff.hasPermission("survival.staff")) {
staff.sendMessage(CC.DARK_RED + "[Staff] " + CC.RED + player.getName() + "'s has not been saved due to an error!");
}
}
}
How would I clean this up where I can reuse the loop and the if statement?
Use a finally block?
try {
// Try code
} catch (Exception e) {
// exception handling
} finally {
// Do something after try block.
}
Yeah ik but if anything, that would make it messier
Or just put your code outside the try catch
Make a method to get all staff as a collection first off
If your code doesn't throw errors, then there is no reason to include it in the try-catch blocks.
Good idea, thanks
Could also make invutil.saveinventory have a try catch
Instead
And return a boolean whether it succeeded
Lmao
I doubt it'll throw an error
Still good to have the try
Maybe, but it's for a small server so it only stores it to as config, not a db so nothing can really go wrong
It'll be like 5 lines if I do db later tho
Yeah fair enough
Is it possible to have a written book that doesnt have the enchantment effect?
Pretty sure theres a flag to hidw the effect
#ItemFlag ?
I don't think ItemFlags can remove enchantment glint.
It also looks like it applies to empty written books, so it might be a hard coded feature.
:troll:
i'll try and see where that leads me
Nested collections. What's the purpose?
it is just thought it was funny that intellij suggests that I add more and more nests
ye it just dies
farmer enjoying thhe place
Just wanted to let u know that, i found a plugin that does this thanks to my dev being a fucking spigot search rat
welp, turns out it's hardcoded
Hello, I am making a plugin for my server, and I want to get each entry from stringList and send it to a player in form of single strings. Can someone help me? Any help is appreciated thanks.
for loop
Iterate over your string list and use Player#sendMessage()
for loop or stringbuiler or send multiple mesages
creating multiple message packets aaa
ahhh i still dont get how neural networks work

Check ur brain
Computer get cookie when good, when more good, more cookie. Computer remember what more cookie and do again
some pretty straight forward math 
in need of serious answers
I mean, the math actually isn't toooo hard
usually its starts with random weights
i think 3b1b has a video on it
mhm
there was a pretty good video from sebastian leauge the other day
it explained the calculus as well
you make multiple copies of it with very slight differences and make them run
you measure their performance
although if you dont already understand the calc, you might not get it
and only keep the one that performs best and make copies of thoses
thats an extremely vague answer, how do they run
repeat and they'll slowly get better and better
"make them run" what do they do
it all depends on what they need to do
and only keep the one that performs best and make copies of thoses
that is generational learning
mutation
not really a basic nn
Basically mutate steps for the best outcome
fair enough
my problem is
Those are all not really a basic neural network tho. Generational learning is one approach but def not the default
"make them run" what do they do
depends on what they need to do
is there a way this might not match? i do the query manually on the database and i get a result
e.g predict if a shape is a circle
for a car racing neural network you just let it drive and see how far the car gets
or another shape
just watch a video on the topic xD
how can a car race from a bunch of numbers???
Exploring how neural networks learn by programming one from scratch in C#, and then attempting to teach it to recognize various doodles and images.
If you'd like to see if the neural network can recognize your doodles or digits, you can download the demo here (windows/linux): https://sebastian.itch.io/neural-network-experiment
Source code:
The...
asking in a discord if you have no idea at all
you give it a bunch of circles and non circles and see how many it gets right
isn't a good idea
^^
Hey
Oh
i watched the first 4 vids in yt
How can I verify?
still got no idea
a sec
Not sure if it matters, but is the semicolon necessary? I have statements without it and they seem to work just fine.
give the 3b1b videos a try
i did
Suchergebnis auf Amazon.de für: reading glasses
Does anybody here know how I can remove this?
got a very weird problem where PreparedStatement#next returns false when the data is present
I don't want it hidden, I just want it to look like the normal one
I think ItemFlags#HIDE_ATTRIBUTES is what you are looking for.
I used sMeta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier(uuid, "generic.attackDamage", 10D, AttributeModifier.Operation.ADD_NUMBER));, Where can you set the slot used?
otherwise if you have on in your main hand and one in the offhand you get double the amount of damage
is it in the UUID?
not sure
sooo i have this code ```java
Zombie bot = (Zombie) botentity.getBukkitEntity();
bot.setCustomName(p1.getDisplayName()+" vs "+p2.getDisplayName());
AttributeInstance dmgAttribute = bot.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE);
dmgAttribute.setBaseValue(p1damge);
bot.setMaxHealth(p1defence);
bot.setHealth(p1defence);
battle_bot botentity2 = new battle_bot( new Location(world, arena2x, arena2y, arena2z), new BotData(p2damge, p2defence));
wrld.tryAddFreshEntityWithPassengers(botentity2);
Zombie bot2 = (Zombie) botentity.getBukkitEntity();
bot2.setCustomName(p2.getDisplayName()+" vs "+p1.getDisplayName());
AttributeInstance dmgAttribute2 = bot2.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE);
dmgAttribute2.setBaseValue(p2damge);
bot2.setMaxHealth(p2defence);
bot2.setHealth(p2defence);```
bot is named the right name but bot 2 is named Zombie why is that?
by the looks of it bot2 is using the entity of botentity and not botentity2
oh im dumb tysm
Just as a side note, you might want to look at java naming conventions because class names should start with capitals
yeah i know its the only class with lower case start
how do i spawn tnt which explodes immediatly?
?
trying to make a nuke of myself
and if you need just an explosion and not the tnt use world.spawnExplosion
a- i asked this before and forgot but how can i make an explosion/spawn firework (one of those gave an error) from a thread?
use a bukkitrunnable to make it synchronous again
I was using a scheduled bukkit runnable?
can't remember
but ok
now what i dont get i
is
this section:
https://youtu.be/aircAruvnKk?t=692
What are the neurons, why are there layers, and what is the math underlying it?
Help fund future projects: https://www.patreon.com/3blue1brown
Written/interactive form of this series: https://www.3blue1brown.com/topics/neural-networks
Additional funding for this project provided by Amplify Partners
Typo correction: At 14 minutes 45 seconds, th...
Only activates meaningfully when the weighted sum is bigger than 10
oh hey an actual good math youtuber
essentiall a boolean function that checks if the sum of the nodes in the previous rown goes above a threshold
here 10
ohh
your inputs times your weights
ever calculated an average for your grades?
sum of input nodes times the connections weights
same thing
yeah got it
flying nuke lmao
just why
so the sum of each node multiplied by each weight has to be bigger than 10
think of it as an average then
see how some grades are worth twice as much as others? well theses have a weight of two
yeah got that
well some nodes have a larger weight in the average
oh this makes perfect sense
hehehe
well if the final average is above 10, then it "triggers"
usually a trigger is connected to a binary action
like "turn left"
Kamikaze?
ye
guys how can i pull a player to a location like the fishing rod
that decides the value from 0 to 1, if that node should be activated or not
setVelocity
yup, so a boolean
that explains a lot
think to note
this node specifically is a boolean node
hehehe
usually most nodes are just doubles
now make explosion power 50 or bigger
fair
how to increase explosionpower btw?
nice lmao
but like
dont neural networks work on probablities
hehhee
so theres usually a probability, not true or false?
What is Main hand?
is it ItemStack? Item?
Can i change it to ItemStack?
getItemInMainHand?
should i just use getinv.getiteminmainhand?
Yes
ok thanks
yes black screen
Not sure if this is the right channel for this, but I want to start developing plugins my own server, but I am not sure where to get started. Any ideas?
https://pastebin.mozilla.org/Wdfq8EfG
No errors, what doesn't work is the @EventHandler, the thing is I have no idea why it doesn't work
you should register commands and events in separate classes i think
why are the holes rectangular lol
I tried but no work
I made a seperate class "Villager" but it didn't work so i moved it here to test
big explosions are always circular
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
i think
is there a damage cause for void damage?
Not sure then
are u sure you registered both classes?
public void onEnable() {
command.init();
getCommand("spawnvv").setExecutor(new command());
getServer().getPluginManager().registerEvents(new villager(), this);```
may i see your villager class?
init
cant find it?
tommy
nvmind im blind
debug your code then ig
@tardy delta u got an idea?
found target - eliminating...
of how to make backups and revert to them on the fly
im making a time travelling machine, sort of thing
i am blind to errors kinda
String userid = config.getString("chat-channel-id");
if(userid != null) {
user = jda.getUserById(userid);
System.out.println("The user has the name " + user.getName());
}
Why user return null?
uhh what im not really lisytening
but it looks ok
alright
ye :/ was wondering that aswell
:D
ye i am sorry
my database still isnt working
just fix the db
How can i choose a random item from minecraft?
Material randomMaterial = Material.values()[ThreadLocalRandom.current().nextInt(0, Material.values().length)];
lol the preparedstatement doesnt find an record but i find one manually
👀 maybe wrong setX call
??
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L);
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -7);
if (buildDate.before(deadline.getTime())) {
System.err.println("*** Error, this build is outdated ***");
System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***");
System.err.println("*** Server will start in 20 seconds ***");
Thread.sleep(TimeUnit.SECONDS.toMillis(20));
}
}```
ahhh i llove thiss
Is it possible to catch Velocity packet when player hit another player?
uhh
that id is parameter is set with ps.setString(i, id.toString())
and its never matching
How is it that people build these custom block/entities?
armorstands
Oh I see, is there a specific name for doing things like these?
well uhh.. die..
BTW are they resource intensive?
and then we have this kekw
you store uuid as string ??
well no, you do binary[16]
something s saying me that you just solved my problem
but w/e. I mean, now you gotta make sure capitalisation is correct
I didn't
more of a "please don't store uuids as strings"
and BINARY[16] is a datatype?
nah should be a blob on sqlite I guess
which wiki.vg Protocol should I use to spawn invisible blocks?
and which to remove them after
ehh I have a whole infra for this
but what happens if there is a block already? it shouldn't replace
which is what it does
sorry updated
wdym shouldn't?
you mean server-side?
sendBlockChange only affects the client world
not the server world
nice thats what I want
you'll have to ensure the player doesnt update the block though
as right clicking a block causes it to update
so you'll have to re-send if that happens
ok
barrier have full block hitbox right?
Yes
👍
Good for you chap
💀
SpoigtMC
Use maven or gradlew lmao
did you add the dependency?
Problem solved
ah dang yk beat me
just paste jar file
best way to add libraries
jk jk
do u use maven or gradle?
Your build tool
💀
not Ide
yes
I gtg
gl
What default value should I pass in for a list in a constructor? Null?
Is there a way to make hashmaps persist through reloads?
can i have a pointer on how to make a web api for my server
Create an empty arraylist
And pass it in
but isn't that just null?
whats the question
No lmao it will prevent errors
Trust me man just use an empty list instead of null
Don't hyper optimize so much it will fuck your code one empty array list object has negligible impact on your overall program
public class CreateMap {
private List<Player> players;
public CreateMap(List<Player> players){
this.players = players;
}
}
public static CreateMap Map= new Map(//default value here)
oh thanks
Wtf is that shitty ass class
Yea I made it really wonky
Don't use that your asking for memory leaks
Player objects in a collection are like memory leak creator #1
store uuids instead?
i dont think CreateMap is very suitable as a class name
jup
Yes or weak reference lol
no I dont think so
is List more memory intensive than Set for storing values?
ye
well, it won't make any significant difference when only dealing with like a max of 16 or maybe 32 stored values anyways
set uses a map internally
No, if you want data to persist across reloads and restarts, it needs to be saved elsewhere, such as a YAML file or database
you should really be caring about memory overhead at collections but just choose what type of collection you need for a specific purpose
that's generally the easiest approach
damn running paper is hot, got so many thread dumps in the last 20 mins
List<Entity> nearbyEntities = arrow.getNearbyEntities(50, 50, 50);
if (nearbyEntities.size() == 0) {
setTarget();
}
Optional<Entity> optionalEntity = nearbyEntities.stream()
.filter(entity -> entity instanceof LivingEntity && ((Projectile) arrow).getShooter() != entity)
.filter(entity -> ((LivingEntity) entity).hasLineOfSight(arrow))
.min(Comparator.comparing(entity -> entity.getLocation().distanceSquared(arrow.getLocation())));
target = optionalEntity.get();
hey i have this issue
where optional is noelementexecption error
in console
nah
Well, that's your issue. get() will throw an exception if the optional is empty
no because i want to run this multiple times so that a target can be found even if not on the first attempt
choco beat me
if (optionalEntity.isPresent()) {
target = optionalEntity.get();
}
would tyhis work
try it
ItemStack stats = new ItemStack(Main.getInstance().getConfig().getItemStack("StatsItem")); ItemMeta stats2 = kits.getItemMeta(); stats2.setDisplayName(Main.messages.getString("StatsItemName").replace("&", "§")); stats.setItemMeta(stats2); p.getInventory().setItem(3, stats);
how i get a item stack changeable in config?
Main.getInstance() 🤮
?
if it is null i have various issues i will try it but lemme send the code first so i can be bullied
public HomingArrowRunnable(Entity arrow, Player shooter) {
this.arrow = arrow;
this.player = shooter;
}
@Override
public void run() {
Projectile proj = (Projectile) arrow;
if (target == null || player.hasLineOfSight(target)) {
setTarget();
ParticleBeam.spawn(arrow.getLocation(), target.getBoundingBox().getMax().toLocation(target.getWorld()), Particle.FIREWORKS_SPARK, 1, 60, 0, 0, 0, 0, null, true, null);
}
if (arrow.isDead() || target.getLocation().distance(arrow.getLocation()) <= 2) {
cancel();
return;
}
Vector newVector = target.getBoundingBox().getMax().subtract(arrow.getLocation().toVector()).normalize();
arrow.setVelocity(newVector);
}
private void setTarget() {
List<Entity> nearbyEntities = arrow.getNearbyEntities(50, 50, 50);
if (nearbyEntities.size() == 0) {
setTarget();
}
Optional<Entity> optionalEntity = nearbyEntities.stream()
.filter(entity -> entity instanceof LivingEntity && ((Projectile) arrow).getShooter() != entity)
.filter(entity -> ((LivingEntity) entity).hasLineOfSight(arrow))
.min(Comparator.comparing(entity -> entity.getLocation().distanceSquared(arrow.getLocation())));
if (optionalEntity.isPresent()) {
target = optionalEntity.get();
}
}
}
i want to change the material and name
do i need to do get target in a loop of some kind
well its the only thing i could think of
i dont know a better way atm
you're asking to crash the server
Does it have any entities?
Let me check..
..
..
NoDOES IT HAVE ANY ENTITIES
🤡me rn
Stack overflow joined the game
well i dont want to cancel the task immediately as i want to continuously search for targets
as the arrow is moving
i know i am a clown
but how become less clownish
return instead of calling the method recursively
it will retarget on the next accept
but wont returning just continue the run function
it will
in which case the target.getboundingbox will be invalid
well
so i have to if else that
ItemStack stats = new ItemStack(Main.getInstance().getConfig().getItemStack("StatsItem")); ItemMeta stats2 = kits.getItemMeta(); stats2.setDisplayName(Main.messages.getString("StatsItemName").replace("&", "§")); stats.setItemMeta(stats2); p.getInventory().setItem(3, stats);
it gives me
a null pointer exception
i have put the statsitem section in config
one can listen to generic events but e.g. PlayerEvent is abstract, hence you cannot listen to this directly
generic events?
wdym
WAIT
how about
listening for Cancellable
????
or will that not work
yeah
technically you can bypass that limitation
by using PluginManager#registerEvent(class, whatever)
Bukkit.getPluginManager().registerEvent(Event.class, new Listener() {}, EventPriority.HIGHEST, (listener, event) -> {
...
}, plugin);
I used it for my client-side tutorial event chain
like a year ago
whats the last parameter
the plugin
callback
what am i supposed to put in it
your processing code
Nope
listener param is kinda garbage but the event param has your event
All listenable event classes must still have a handler list
Which PlayerEvent doesnt, and most abstract events do not
this works tho
what is clazz
POG
Ugh last time I did that it threw me an exception
I might've seen a commission for this
adding an @EventHandler wont work
lol on what server
but this method in specific bypasses the annotation stuff and just calls the callback directly
odd, but convenient!
Myeah, well odd in terms of what Ive read
if this works its gonna be extremely cool
Hi there
I am currently trying to detect when a player is damaged from the explosion of a respawn anchor, and to get that anchors location.
The EntityDamageByBlockEvent is called, however #getDamager returns null, so I cannot get the location.
Is there any reliable way around this? Thanks
I think that event is only caused by certain blocks. Things like Cactus or Magma Blocks. You may want to listen for the BlockExplodeEvent or the EntityExplodeEvent and see if the player was damaged by that instead.
EntityDamageByBlockEvent is called when the player is damaged by the explosion, the damager just returns null for some reason.
The BlockExplodeEvent is when the block physically explodes (before the damage), and there is no way of knowing from that event which player (if at all a player) will be damaged by the explosion
is it possible to cancel player collisions for specific players (I'm open to the use of packets and nms for this)
I basically have a spectator player that I don't want clients to beable to tell exists
I have an ItemStack map and want to give it some uniqueness so I can later check if it's that exact ItemStack,
I always used PDC to store smth like this, but this time it doen't need to be persistent so is there any other way?
or just stick to PDC cause it works?
you could use temporary NBT tags
but like thats basically just pdc lol
and you'd need another API for that
then I will stick to pdc
It's probably because the block is gone by the time the event is fired. If you test with other blocks that damage the player, you'll get a non null output.
That's my guess as well - is there any way to get the Location of the block which exploded then?
Probably going to have to use another event to listen for. Not 100% sure which one would be the best though. Trying to test some of that out as well.
and how can I give a placed block uniqueness?
I use player.sendBlockChange so it takes BlockData
how can I set pdc to that and whats the correct way to get this BlockData?
Material.BARRIER.createBlockData?
The one time i need head database this sh*t is down ffs
hey, I'd like to request some guidance about an error I've encountered for the first time, I failed to find a relevant answer on the forums so I'm looking here
java.lang.ClassCastException: class roeidev1.collectablecreatures.Entities.CollectableCreature cannot be cast to class roeidev1.collectablecreatures.Entities.CollectableCreature (roeidev1.collectablecreatures.Entities.CollectableCreature is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @2489af81; roeidev1.collectablecreatures.Entities.CollectableCreature is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @43192e4d)
as you can see, my plugin throws an error that suggests a cast failed because the instance of the casted class is of different origin or "ClassLoader"
I'd like to mention I'm not using any dependencies and that spigot scope is marked "provided" in my maven config
Side note: the plugin works fine when the server launches, it only produces this error when trying to cast an entity to an nms entity after reloading the server
Well, you really shouldn't be using the /reload command on a production server. It's been known to cause issues for a long time now.
My plan is to release this plugin
so I want to make sure it's stable for most people
and most normal spigot users use /reload
I would just ignore these people, their problem if they use /reload tbh
I'd feel bad if their server will crash because of my resource, it's kind of unprofessional
don't support people who use /reload its prone to cause memory leaks and other issues. Don't revolve your code around idiots bad idea
well, because it seems like a common opinion here I'll have to agree
Using the /reload command is fine for development purposes, but some things can't be solved within a reload. NMS especially since it's behavior is still not well documented.
but on the other hand, whats the fix?
if they run /reload just display a massive warning about how you aren't going to offer support to any issues that occur after a reload
alright, thx
To be fair though, most plugins handle /reload pretty well.
Even if it's not intentional.
it still causes memory leaks over time :P
I mean you can have a static boolean indicating if the jar is initialized
that too
bumb
and check for that onEnable
that's the correct way of doing playerdata
Unfortunately blocks dont store pdc
how can I provide uniqueness?
I'd recommend not using blockData for that kind of stuff, it's better to save the location of the block externally and then access it, it might be less efficient but it's more stable
I def need BlockData for sendBlockChange
whats wrong with sendBlockChange?
so someone with no knowledge of coding, can make one if he somehow has an idea of how to automate the learning
2Hex, Neural networks are extremely simple, the more difficult parts of them are activation functions and back propagation, those two are not mandatory tho
you can use linear activation for most simple cases
ImIllusion you are smart with packet fuckery right now so I might as well ask. I'm making a spectator player for my game, but currently I'm only using the spigot API which means the spectators can push around and block actual players in the games action. I want access to survival mode for the spec due to custom gui's and such so I'm wondering if its possible to stop the spectator from interfering with people in the game. I'm pretty unsure what packets to send I looked at wiki.vg for a bit but still was a tad confused with it
and a static learning rate instead of back propagation
activation functions is what im struggling with
linear activation is pretty useless o.O
well
it's extremely weird
it basically multiplies each node with each of its weights
true but depends on the task
I'd suggest you mess around with the api for the most part
I mean, yea I guess ?
would it even be possible to do that with the API
then sums all of that up and substract a bias from it
It's too hacky to set the target to spectator and send packets for gms and all
you can use scoreboards to mitigate collisions
Player#hidePlayer should take care of most particles and such
yep I got hidePlayer working and such just moreso wondering on collissions and blocking
2Hex you should watch Sebastian Lague newest vid, he explains extremely well most things you need to know about nns
Any tips on chuck downgrading guys? I loaded a world in 1.19.2 but i need to use it in 1.19
can you use the scoreboard to allow mining through the spectator
yeah
hidePlayer should handle that
invis potions don't
if the client isn't aware of the player anymore, it won't consider it
FastBoard is my carry with all things scoreboard usually
Teams I just don't bother I have most of my own API but it doesn't include like collissions and such
since I'm managing everything thorugh events
Also thanks for the compliment in this part, I tend to view myself quite negatively when it comes to work :/
If you're doing scoreboard for the love of God fetch it from the player instead of making a new one every tick. Thanks
same
?
my stupidass decided that comparing myself to 7smile7 was a good idea and now I'm getting depressed
20 years of experience vs 5
Any tips on chuck downgrading guys? I loaded a world in 1.19.2 but i need to use it in 1.19
I mean
yolo
I've been messing with code for the past like
11 years? maybe?
but I was like 6-7 when I started
I first touched code like 2 years ago xD
¯_(ツ)_/¯
same
I been playing video games since 2 :P
I didn't get a pc until 2017 though
I played minecraft on my brothers shitty laptop when he got it in 2010
I used a shitty laptop to make plugins, get commissions
and after a few months of saving, I built my rig
it was like my dad's laptop or something idk
see because I was old enough to get a job last year I just worked made my 2k and bought a pc
well
I've made it all back
making it all back is what matters
I'm actually up on my original investment
I'm still not old enough to work at some specific companies
I use most of my income on stocks and crypto though
I think I paid like 700$ overall to build my pc
then made like 15k with it in a year
I payed 1500
My internet is shit so I have to locally host everything
so I need a nice rig
I got 32 gigs haven't evne considered touching my ram
my old pc was rocking a shitty i5-7400 and a 1050ti with 16 gigs of ram
nah that's too good
I made all my cash on a laptop with a i3-4005u, 4gb ram and a 500gb hdd
graphics? integrated
Integrated graphics are nice
Any clue guys?
#help-server :P)
ah okay
ofc you use linux
wdym ofc lol
i used to dual boot but I just wiped my windows drive seeing as I barely used it
now I use that for game storage
There's a considerable amount of people here that use linux idk why
win10 is solid for development
I wasted like 4 hours reverse-engineering sound files for a game that doesn't run on linux
I had too many issues
I still use it for testing malware and such but outside of that not really using it
windows and large git repos just work so well together 
i have to use LFS nowadays as one of my projects had a 100MB data file
otherwise it refused to clone lmao
oh god, not like this
MCP projects be like
paper forks
docker containers
I'm thinking on working on a server deployment solution
that grabs templates from a folder and creates instances
should I use docker or just ubuntu screens
hm
Amateur
i dont like docker. it usually creates more problems than it solves
i'd use systemd units tbh
and do some fancy communication
docker would be recommendable over screen
I mean
true
