#help-development
1 messages · Page 1608 of 1
but itemmeta is null for air stacks
or is this for entities? I guess this is for entities
Yo, any ideas?
entities
a player is an entity yes
but
jesus nnya how have you already been banned and already come back in this short amount of time
how many accounts have you even burnt through at this point
Simple things. Check if its null.
less than 50%
if(e.getRightClicked().getPersistentDataContainer() != null
no.
ok
get is nullable
no, the get call is nullable
not getPdc
e.getRightClicked().getPersistentDataContainer().get(key, PersistentDataType.STRING) != null
use Objects.equals
ok
or call equals on the hardcoded string
Can I store an inventory to a string somehow?
why
so that i can store kits easier in configs
ok that will fix it right
if(e.getRightClicked().getPersistentDataContainer().get(key, PersistentDataType.STRING) != null && !e.getRightClicked().getPersistentDataContainer().get(key, PersistentDataType.STRING).equals("handcuffed")) {
use Objects.equals
or call equals on the "handcuffed" string
that way it doesn't matter if the get method returns null
oh, that is so long in one line
could also just create a variable before the if that could be null
much easier and quicker conditional then
"handcuffed".equals(e.getRightClicked().getPersistentDataContainer().get(key, PersistentDataType.STRING))
Objects.equals("handcuffed", e.getRightClicked().getPersistentDataContainer().get(key, PersistentDataType.STRING))
thanks ig
Quick question, when compiling a plugin, what's the difference between the jar and the master jar?
why is NamespacedKey key = new NamespacedKey(Handcuffs.INSTANCE, "handcuff"); throwing an npe
tf
use dependency injection
how in the world can it be null
static getter bullshit like what you're doing there runs into these issues
Like build.jar vs build-master.jar
because you haven't set it to a value yet
I did
you did, but not yet
instance = this or something probably runs after this new NamespacedKey
execution order is key
which is why you should use dependency injection to guarantee it
pass the handcuffs instance in the constructor
and use the passed object instead of the static field
which is called dependency injection
or make sure that that initialization happens only after the instance has been created
which you could have googled but were too lazy to
especially with those NPEs, those were simple
but still stupid questions
ok ill just google it
Wait so borat, what would the difference be?
depends on the context
what are you compiling with
where are these files
in the libs folder
showed you a screenshot
i'm not seeing a screenshot
I dmed you it
that screenshot doesn't tell me anything
again, what are you compiling with
I'm compiling with gradle
are you using any gradle plugins
No, I just built from Intellij
But it's more of a general question, since when I compile plugins I always receive the plugin's name and the plugin's name + master . jar and I wondered what the difference was.
No I'm not using any plugins.
just gradle build
When using ./gradlew build
it will execute build.gradle
and in that file
there might be plugins declared
So it doesn't matter from where you run it
It matters what you configured in your gradle buildscript
It'd probably be best if you pasted that
If somebody places a bed down, how can I get both locations for that bed?
`public final class Handcuffs extends JavaPlugin {
private Handcuffs INSTANCE;
public Handcuffs(Handcuffs handcuffs) {
}
public JavaPlugin Handcuffs(Handcuffs getHandcuffs) {
return INSTANCE;
}
final RecipesManager recipes = new RecipesManager(this);
@Override
public void onEnable() {
INSTANCE = new Handcuffs(this);`
i think you might have to ghetto it by looking at the player's facing direction
is this dependency injection
wtf are you even doing
learnjava
just learn java already my guy
Bed#getPart and Bed#getFacing should get you started.
yeah but the block isn't placed in that event yet
this is a bit janky but would hashMap.keySet().stream().iterator().forEachRemaining((key)-> key.remove()); work? (pseudo-logic here obviously)
you can't get the state or the blockdata yet iirc
Ah yeah, if its the BlockPlaceEvent, you'd have to do it 1 tick later
Just like Double chests n shit
does it actually modify the hashmap keys or would this somehow do a deep copy
No, use removeIf()
i'd be placing my bets on a CME
but muh iterator
yeah, it'd be a cme
Ok thx
just use removeIf
what do you need an iterator for
and even if
iterator usually bypasses cmes
@maiden briar Remember, do it 1 tick later.
Why 1 tick later?
removeIf also "bypasses cme's"
What’s key here?
Because the other part of the bed only gets placed the next tick iirc
player object
Double chests also only connect 1 tick after
Ah good idea
the keySet returned by a map is also a live view of the map's contents
removing elements from it causes them to be removed from the map itself
so getting the keyset and calling removeif on it should be fine
Why not just keySet().forEach(Type::remove) magma
also a thing but won't remove them from the map
mostly because i wasn't aware that would work tbh
which, I'm not sure if that's what he wants
I've never really played too much with the hashmap methods
noob
🤷 gotta start somewhere
new RecipesManager(this) that part is
your variables don't make too much sense though
nor does anything else
yeah I'm sure that foreach call tipped the scales
actually damn it I do need to do more than just remove
If I have the beds saved on their location, and I place at both 2 locations a bed, will it combine?
then use an expression lambda and do the things in it
or just use a for loop instead of foreach, that is less gay
What's wrong with being gay? 🤔
thiccness thiccifies
who said there's anything wrong with being gay
seems like you're homophobic if you're automatically defaulting to a negative connotation
perhaps you should check your priviledge
Haha yeah, just kidding, it's 2021, so anything has to be equal.
oh no
java 2020 pride update: change the implementation of Object::equals to final and always return true
finally, true equality among all
Should have said among us 👀
brah code
//Remove players that have stopped
bossBars.keySet().removeIf((iteratedPlayer) -> {
if (!trackingPlayers.contains(iteratedPlayer)) {
bossBars.get(iteratedPlayer).removeAll();
return true;
}
return false;
});
this is what maintenance nightmares are made of
use an entryset
is entryset an instrument
brah code
//Remove players that have stopped
bossBars.entrySet().removeIf((entry) -> {
if (!trackingPlayers.contains(entry.getKey())) {
entry.getValue().removeAll();
return true;
}
return false;
});
entryset is kind of like the keyset, but contains both keys and values
so you don't need to do a redundant .get call with the key
that doesn't sound right
you are iterating over bossBar keys
then, if a condition is met, you want the value that corresponds to the currently iterated key
is this not the case?
public OnUse(JavaPlugin plugin) {
this.plugin = plugin;
}
private final JavaPlugin plugin;
this isnt DI either right]
it is
that's closer to DI
but cant you just google shit
though you should change JavaPlugin to the actual plugin type
okay
you don't want it to be any javaplugin, you want it to be your plugin
if the condition is met I want to remove the key, but first I need to access the value because bossbars hold player data in them and if I don't clear it out it'll stay fucked
TheSourceCode YT Tutorials 101
yes
this is why you call entry.getValue()
this gets the value corresponding to the given key
you can then call removeAll on the returned value
oh i see what you mean now
entry.getValue() is the same as map.get(key), except that it doesn't have to do a full map query
because the entry already stores both the key and a value
Guys
public OnUse(JavaPlugin Handcuffs) {
this.plugin = Handcuffs;
}
private final JavaPlugin plugin;
like this?>
no
o
public OnUse(Handcuffs plugin) {
this.plugin = plugin;
}
private final Handcuffs plugin;
Handcuffs
change JavaPlugin to Handcuffs
well they just sent that
o so as i did rn
o
i don't know I might be going blind
must be all the red
This one uses Handcuffs as both types
so id guess its fine
yeah the last one they sent is fine
public Handcuffs getHandcuffs() {
return plugin;
} is pointless right
yes
yes; you are only using the field inside the class
i think mojang just solved a millennium prize problem
okay
so you don't need a public getter for it
poggers
they would've solved it before 1.0 then
oh is it that old
what are you nerds talking about
splash messages
and me remembering old mc versions
ah, yes, if statements
bossBars.entrySet().removeIf((entry -> {
entry.getValue().removeAll();
return true;
}));
I feel like I've really been leveling up my laziness lately
?paste
google "java how to read stack traces"
ik how
sorry I'm in write-only mode
ok im just lazi il read it my self
maybe they don't even know what are stack traces
i know
what is it? 😄
its a backtrace
which part of the document you just sent is the stack trace
that took awfully long for someone who knows how to read a stack trace
you could just open this
https://paste.md-5.net/jibukiyeha.java rate my pasta
ik java but not everything in it, im missing on some stuff
Ok so anyone know how tf A* works
you're still programming against the implementation, not the interface
private final HashMap<Player, BossBar> bossBars = new HashMap<>();
should be
private final Map<Player, BossBar> bossBars = new HashMap<>();
same for the HashSet, the field should be Set
is this a pathfinding algo or sth
Yeah
yes
the wikipedia article for A* is good enough iirc
don't know lol
oke ill give it a look
yeah I guess I'm still doing it
bad habits die hard
the removeTrackingPlayer impl can be improved
you are doing 3 map queries where you could do one
Map::remove returns the value that was removed
get and null check?
if there was no value, it returns null
remove the value, nullcheck, and then call removeAll on the value
Location bottom = null;
Location top = null;
List<Location> toTry = Arrays.asList(block.getLocation(),
block.getLocation().clone().add(-1, 0, 0),
block.getLocation().clone().add(1, 0, 0),
block.getLocation().clone().add(0, 0, 1),
block.getLocation().clone().add(0, 0, -1)
);
for(Location location : toTry)
{
if(location.getBlock().getBlockData() instanceof Bed bed)
{
if(bed.getPart() == Bed.Part.FOOT)
bottom = location;
else if(bed.getPart() == Bed.Part.HEAD)
top = location;
}
}
Why does this not work? I run this 2 ticks later
the BukkitRunnable in start can be a Runnable or a lambda which would be more readable
instead of casting the location components to int in createBossBar, call getBlockX and so on
public void removeTrackingPlayer(Player player) {
trackingPlayers.remove(player);
BossBar bossBar = bossBars.remove(player);
if (bossBar != null)
bossBar.removeAll();
}
?
there's no method shortcut for a remove that has a not null check built into it right
super technically computeifpresent does that but that is probably overengineering things
and not any cleaner
if (bossBars.remove(player) != null) if you wanna reduce that one line
code golfing my way to a half line plugin
The problem is that both locations are null, and if I place the block it only places one part
he needs to perform an action on the returned value so he needs an intermediate variable for it
is it fine to use assert e.g. for null checks where the variable being null means I really fucked up
since it reads nicer than e.g. if(meta == null) return;
intellij != intelligent
yea it is overly protective at times
you should always avoid a NPE instead of catching it
bump
wrap it in Objects.requireNonNull()
Optional
optionals aren't the solution to everything
nah it is logically impossible for my var to be null in the calling context of the function
or are you responding to that bump that I can't see the original of because ripcord doesn't show replies
yes then just wrap it in Objects.requireNonNull()
im responding to this
haha
kind of slow but yea
or just use your eyeballs to ignore the warning
or be hardcore and disable npe warnings
I don't like having my code full of yellow
so is it better to use assert or requireNonNull
asserts are generally not used in production
I just need it to scream at me if by some gamma ray miracle the var is null
requireNonNull does that
it throws a NPE or something if it does by some chance end up being null
so calling it once at the start of the function is fine
yea but only once per var not once per access
assuming the var isn't changed in the interim, yes
@Override
public void onUpdateStack(ItemStack stack) {
ItemMeta meta = stack.getItemMeta();
Objects.requireNonNull(meta);
if(hideAttributes)
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
else
meta.removeItemFlags(ItemFlag.HIDE_ATTRIBUTES);
stack.setItemMeta(meta);
}
meta is effectively final here yes
looks good ty
then what is wrong with using assert notnull?
Does @NotNull even stop null from happening or is it just to signify that it isn't null
that it's not going to blow up
unless the environment has a specific startup flag set
honestly finding ideas to make is harder than making them
that's just an IDE thing that has caused me issues w/ compiling if used manually
asserts are entirely ignored by the runtime by default
neither is requirenotnull useful in runtime
Has anybody actually found a use for the Unsafe class
making things easier to debug if something does go wrong
in this case it makes zero difference, but generally
my friend said he had to use it to do some stuff w/ a custom server backend
for example, if you store some input in a field, and don't call requireNonNull on it or check it otherwise, it will only explode once that value is accessed
at which point it's probably impossible to tell where that invalid value originated from
I heard it's pretty unsafe using it and it shouldn't be used I think I also heard it's only there because some things need it
ok i get what you meant here
yeah its just there to allow people who know what they're doing to bypass some safeguards
ignore the unsafe class
I heard it from some where idk when
how to disable fishing particles
Well I mean you could always disable particles in your settings?
That's not what I want
Aren't particles just entitys?
🙈
no
anyone know why whenever i hit someone every click is 1 hit in pvp without any delay
[14:57:15 INFO]: Location{world=CraftWorld{name=Amazon},x=80.0,y=65.0,z=33.0,pitch=0.0,yaw=0.0}
[14:57:15 INFO]: Location{world=CraftWorld{name=Amazon},x=81.0,y=65.0,z=33.0,pitch=0.0,yaw=0.0}
location.getWorld() returns java.lang.NullPointerException?
stacktrace?
its already like that i wanna add a delay
[14:57:15 INFO]: Location{world=CraftWorld{name=Amazon},x=80.0,y=65.0,z=33.0,pitch=0.0,yaw=0.0}
[14:57:15 INFO]: Location{world=CraftWorld{name=Amazon},x=81.0,y=65.0,z=33.0,pitch=0.0,yaw=0.0}
[14:57:15 WARN]: [BedWars] Task #22583 for BedWars v1.0.0 generated an exception
java.lang.NullPointerException: Cannot invoke "org.bukkit.Location.getWorld()" because "first" is null
at org.mineacademy.fo.Valid.locationEquals(Valid.java:324) ~[?:?]
at org.mineacademy.fo.settings.YamlConfig$LocationList.toggle(YamlConfig.java:1858) ~[?:?]
at org.mineacademy.arena.tool.eggwars.ToolBeds.lambda$handleBlockClick$0(ToolBeds.java:106) ~[?:?]
at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100) ~[patched_1.16.5.jar:git-Paper-783]
at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468) ~[patched_1.16.5.jar:git-Paper-783]
at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1427) ~[patched_1.16.5.jar:git-Paper-783]
at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:436) ~[patched_1.16.5.jar:git-Paper-783] at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1342) ~[patched_1.16.5.jar:git-Paper-783]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1130) ~[patched_1.16.5.jar:git-Paper-783]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-783]
at java.lang.Thread.run(Thread.java:831) [?:?]
?paste
?paste
holy fuck
Don't use 1.8 simple
anyways, there is a variable called first that is null at org.mineacademy.fo.Valid.locationEquals(Valid.java:324)
Yes I know, but I have never put a null location in
well you did
how can i make it also in 1.8 with a delay
nvr doubt the error
Why
A plugin
Just update
This is the method from his foundation:
public boolean toggle(Location location) {
Iterator var2 = this.points.iterator();
Location point;
do {
if (!var2.hasNext()) {
this.points.add(location);
this.settings.save();
return true;
}
point = (Location)var2.next();
} while(!Valid.locationEquals(point, location));
this.points.remove(point);
this.settings.save();
return false;
}
Well yeah also you could update
do u know any plugins
Nope
Because most try to stop the cooldown
For newer versions
Because people like that better for some reason tbh idrc
i use 1.12.2 server
where is line 324 in Valid.java
Then you have delay already
Sounds like you use 1.8
Linenumbers do not equal, but this is the method:
public static boolean locationEquals(Location first, Location sec) {
if (!first.getWorld().getName().equals(sec.getWorld().getName())) {
return false;
} else {
return first.getBlockX() == sec.getBlockX() && first.getBlockY() == sec.getBlockY() && first.getBlockZ() == sec.getBlockZ();
}
iam
I can't modify this code
i hit like 800 times when the first hit didnt finish
... are you using 1.12.2 or 1.8 decide
Then why did you say you use 1.12.2 server
1.12.2 for the server but im playing on 1.8
If your using 1.8
viaversion
Your confusing
Viaversion should make it so you can't do that fast
You sure you don't have 1.8 server
no
Also where did you get your jar?
then find out why point is null
bukkit
Bukkit?
Ok, but I also can't change that method
So illeagal upload then
Bukkit doesn't sell jars
get bukkit*
Yeah illeagal upload
where am i supposed to get it from
Delete that get official jar then move to #help-server
then too bad, you have a problem you want to solve but you can't change the method
Yes, have to contact the author
?paste
Server ran out of ram
lmao
you know why we can tell that your server ran out of memory?
why
because we read
dang dude didnt know
yea man
java.lang.OutOfMemoryError: GC overhead limit exceeded here line 43
BTW I'm currently creating a way to create plugins in C++
why tho
what's the point
Practice C++
with JNI or what
yep with JNI
but like... ok
brooo
my plugin keeps crashing the heck out of the server
lmao
how do i make it less ram heavy
oh lord
you might be having a lot of recursion or sth
wdym
he does
cant say anything without seeing your code
oh no
while (true) 💯
garbage collection cant even handle his memory leak
x)
if my code bad?
no
it must be java that is inefficient
fix it
it is in his stacktrace
and how
by learning java
make the bad code not bad
ah ye
i didn't want to say that but bro cmon
Really? I don't see it
gud advice
please if ur gonna say that just dont respond
but it true
@lusty cipher
its not gonna help even by 0.1%
Yes I know that. Thought you might've seen the reason for that in the stacktrace
GC = garbage collector = memory leak
this is like you are trying to run but you don't even know how to walk
The GC takes too much time to do its work
Whats the problem? 😄
you don't even know how to ask for help lmao
either send code or dont ask for help
exactly
ok
There must be somewhere in your code where yo reserved a ton of memory that you did not free
do you guys also get hundreds of chinese users asking for support?
there's so many chinese servers
did you upload your resource to mcbbs or sth lol
why do u need infinite loop
is that like chinese spigot/curseforge?
so i can tp a player contiounsly to a player
that's why you avoid using while loops
use bukkit schedulers
yea, a chinese mc forum
no god please no
I just send them pictures of winnie puuh
i thought about schedulers
I didn't but people reuploaded it there regardless
while (true) will just keep collecting memory
you could have a few TB and it will crash at some point
The thing is that minecraft runs on one single thread.
This means that while your code runs everything else has to wait.
So if you run something like
while(true)
The server just stops right there.
If you do something like
Thread.sleep(2000)
The whole server just stops for 2 seconds there
runTaskAsynchronously go brr
i actually wonder how is it 1 threaded lol
i mean what about console reader
runTaskAsynchronously go CME
isn't it uses another thread
its not just one thread. there's quite a few actually
but the thing is that "most" stuff in bukkit runs on the main one
which is what they're referring to
did worlds ever get relegated to their own threads?
bukkit is 1 threaded then
no worlds use 1 thread
1 for all worlds right
yeha
(kinda)
there are some small parts which are offloaded
but for the most part, yes
this is the reason for shit like DimensionalThreading existing
you'd think they would've moved each world to a different thread by now
Location currentLocation = e.getPlayer().getLocation();
Vector Direction = e.getPlayer().getLocation().getDirection();
Location target = currentLocation.add(Direction);
Bukkit.getScheduler().runTaskTimer(plugin, e.getRightClicked().teleport(target), 20L, 20L);
is this right
Cannot resolve method 'runTaskTimer(me.hex.handcuffs.Handcuffs, boolean, long, long)'
you use some kind of IDE?
Well it would show you what methods exist on the scheduler
And then you would know what to call
Instead of asking here
you need to create an instance of your main class
disregard that comment
In case you still haven't figured it out
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
the docs
this is a help - development where else he supposed to ask 💀
It's a stupid question because its simple to search up what the methods are that exist
And they have asked a bunch of other questions and seem to know very little Java
Don't respond if it clearly annoys you 😂
lmfao
Well no
Because your comment was blatantly false
They have a instance of their class
nvm
You'll need to do something like this
Bukkit.getServer().getScheduler().runTaskTimer(plugin, () -> {
player.giveExp(100);
}, 100L, 100L);
return false;
}```
Their issue is them calling a function instead of referencing it in a Runnable lambda
i figured it out
Bukkit.getScheduler().runTaskTimer(plugin,() -> e.getRightClicked().teleport(target), 20L, 20L);
don't spoonfeed @quaint mantle
i wont use it anyways
still
yeah good
something like this
aw hell yeah only 100 more compile time errors to go
which I suspect is the limit before it gives up lol
I’ve never understood people who try to help but are impatient and get angry at the people they are helping…
exactly
bro
if u dont like helping
just dont help
It's a fact
like im not forcing u to help me
He's asking a question in a public discord asking for help lmfao
just try it
😉
if no one minds helping https://paste.md-5.net/bexabojuje.cs
why does it send both the messages
do you know why you can write a lambda here?
I thought you could'nt use bukkit API outside of main thread
You can but some of the stuff (specifically Inventory and more) are discouraged and can lead to undefined behaviour
Some stuff isn’t thread safe but not all
Conclureee, we need to call at some point ❤️
But a lot of stuff is actually totally fine to use async
Yeah toby in a car rn 😐
Okay ^^
ow okay
e.getPlayer().sendMessage(ChatColor.GREEN.toString() + ChatColor.UNDERLINE + "Successfully Removed Handcuffs " + ChatColor.LIGHT_PURPLE + ((Player) e.getRightClicked()).getDisplayName());
and
e.getPlayer().sendMessage(ChatColor.GREEN.toString() + ChatColor.UNDERLINE + "Successfully Handcuffed " + ChatColor.LIGHT_PURPLE + ((Player) e.getRightClicked()).getDisplayName());
it executes them both
I'd simply assume the event this function is in is being called multiple times
Maybe clicking the item 2 times by accident?
okay ill retry
add a cooldown
to prevent things like that
like you have to maintain click to be able to hancuff or remove handcuffs
Also make sure you haven’t registered the listener twice
wdym
how am i even supposed to register it twice though
It's possibly to do pluginManager.registerListener(new OnUse()) twice, by accident
Yea but some people just tend to do that sometimes, just making sure
try {
RandomObject object = new RandomObject(); <- this constructor may throw an exception
map.put(i, object);
} catch (Exception e) {
e.printStackTrace();
}```
Is there something wrong with putting `map.put(i, object)` in try {}? (it can't throw any exception in this situation)
Should I do it right this?
```JAVA
RandomObject object = null;
try {
object = new RandomObject();
} catch (Exception e) {
e.printStackTrace();
return;
}
map.put(i, object);```
Yes latter
But ftr some map implementations can throw unchecked exceptions when passing unwanted arguments. Although you seem to return if any exception happens so allg.
Okay this prob isnt related to spigot
but what are maps and hashmaps (ik its simple java)
yes it is but what do we do with it
its like a List but instead of an index you use a String or a UUID or something
o
Well to put it simply, we use HashMaps for its efficient contains, put and remove time complexity
But it’s a data structure that maps key to value which are called entries
o
If you know JSON, this is a Map:
{
"key": "entry",
"key2": "entry"
}
The values are keyed so you can easily access them
You would use map.get("key") to get the value "entry"
Map is considerably higher level than HashMap which means we can use it to decouple and increase reusability in our code architecture.
Plus it’s an interface 😌
So, does a method which can never throw an exception, in try {}, hurt the performance?
exception and performance are not related
you can do watever you want in try (don't), and that's ok
Interface is good
throwing and creating exceptions are mostly performance taking
as in doing sth, which will not cause exceptions, in try
Because you have another call inside of the try block, it already exists. Adding another function makes no difference at all, (or so little, nobody really cares).
Yeah tho not really that much of a difference solar, moreover you just don’t want to catch something which you haven’t intended to catch
I think that correctly handling exception is one of the hardest things to do
yea, hence the (don't) XD
(:
when you are dealing with files and IO exceptions etc.
all r
try not to try
hey if anyones familliar with the "bedwars rel" plugin can someone give me the modern hypixel shop.yml code
What is the best way to compare two Locations
isn’t equals good enough?
.equals() ?
ye
or ==
.equals
?
lol
xD
java.lang.NullPointerException: Cannot invoke "com.jeff.spigotsandbox.astar.Node.getLocation()" because "currentNode" is null
bruh
well then youd just use Objects.equals
Objects.equals
ah right
lets give it a go
forget Objects exists at times
did that same shit
while (!Objects.equals(currentNode.getLocation(), startNode.getLocation()))
I smell lagspike
Bukkit.getScheduler().runTaskAsynchronously()
😎
😌
i think that cant save you from GC overload, ok maybe not gc but yea
Consequently, if both arguments are null, true is returned and if exactly one argument is null, false is returned
so it shouldn't really throw a NPE
i think it is the fact that i do
null == null 
#getLocation()
Correct
but idk how teh location is null cause that is literally all that is in the constructor
so
it should be defined no matter wat
but it do be null
tell me why
every time I doubt java, java proves that I'm the shithole
?paste
what is node, an inner class that you implemented?
yeah you think i could implement A* by muhself???
I dun think you have to
i couldnt find shit
lmaooooo
he said jk, he didn't expect anything from you
But yeah I’d have went for the first stack overflow page myself so shouldn’t be the one talking
i used the second page of google and didn't find anything
i think the problem is that the first Node has no Parent
cause it is obviously the source
so a quick null check should do the trick
hey if anyones familliar with the "bedwars rel" plugin can someone give me the modern hypixel shop.yml code
people have immitated them
ik but i need some help with the item shop
if u dont mind can u help me with the item shop
i think there was a vid tutorial somewhere that had the code
oh i dont remember
sorry
this is like 3 yrs ago
uh do u remember what u searched
i have no clue
probs just a tutorial installation
kk
hmmmm
WTF now it dont error but it just doesn't do shit
wuts that
system.out.println
ok i really need help, im making a plugin and it says something about an error on line 14 in the console in the server when it is trying to start but i cant find the error.
ERROR Error occurred while enabling HelpfulAdditions v0.2 (Is it up to date?) 30.07 14:11:32 [Server] INFO java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.ej.HelpfulAdditions.EJessentials.getCommand(String)" is null 30.07 14:11:32 [Server] INFO at me.ej.HelpfulAdditions.EJessentials.onEnable(EJessentials.java:14) ~[?:?] 30.07 14:11:32 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.17.1.jar:git-Paper-138] 30.07 14:11:32 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-138] 30.07 14:11:32 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-138] 30.07 14:11:32 [Server] INFO at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:527) ~[patched_1.17.1.jar:git-Paper-138] 30.07 14:11:32 [Server] INFO at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:441) ~[patched_1.17.1.jar:git-Paper-138] 30.07 14:11:32 [Server] INFO at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:639) ~[patched_1.17.1.jar:git-Paper-138] 30.07 14:11:32 [Server] INFO at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:306) ~[patched_1.17.1.jar:git-Paper-138] 30.07 14:11:32 [Server] INFO at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1126) ~[patched_1.17.1.jar:git-Paper-138] 30.07 14:11:32 [Server] INFO at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[patched_1.17.1.jar:git-Paper-138] 30.07 14:11:32 [Server] INFO at java.lang.Thread.run(Thread.java:831) [?:?] 30.07 14:11:32 [Server] INFO Disabling HelpfulAdditions v0.2 30.07 14:11:32 [Server] INFO HelpfulAdditions is shutting down. Have a good day!
oop sry
did you put the command in the plugin.yml
Yea jeff I believe it does
Idk if it’s actually thread safe
Should probably use loggers btw but ye
i- i didnt. i swear i did xD apperantly not
it probably works
its just nothing is getting printed
though yeah, im quite sure log4j's Logger is thread safe
tysm :D
try Logger.getLogger().info("wirdifs");
Believe paper supports async logging, spigot is still stuck with java logger framework right?
will do
just use paper already
wait
it may be not finding a path
and just running still
that is very much the case
Is there a way of adding an attribute modifier to an item without clearing the default ones?
e.g. adding an attack speed modifier to the iron sword without clearing its damage
Hmmm, anyone see anything wrong this this:
https://paste.md-5.net/agonusigic.cs
it gets stuck in an infinite loop
wait thats cause it adds duplicate location nodes back to the List
hmm
Is it possible to use scoreboard to add a prefix or a suffix to a players name-tag above there head but they cant see it and only certain people can?
are you trying to reimplement an A* algorithm yourself
you 100% want your list to be a LinkedList
arraylist needs to be resized each time it goes past a certain size and that is very expensive
plus removals in the middle of the list involve shifting all of the subsequent elements
if I want to go from
@Override
public void test(){super.test();}
to
@Override
public void test(){
new BukkitRunnable(){super.test();}...
}
but am limited by the fact it's inside of BukkitRunnable, how can I bypass this issue?
will this actually work?
@Override
public void test(){
ParentClass parentClass = this;
new BukkitRunnable(){parentClass.test();}...
}
why wouldnt it
because it's really dumb
the only thing you need is for it to be effectively final, so yes any variable final and outside of a interface declaration would work
I mean technically the test method of this is the method it is getitng declared on
why are you inside a bukkitrunnable
has to run later
nah
why the new account
i keep telling you to use lambdas
i have a bunch in stock
might as well use them
ok
is that nny? xd
use a lambda; if you for some reason can't, use OtherClass.super.method()
but just really, use a lambda
it's more readable and less gay than anonymous runnables or bukkitrunnables
i've been around for a few days
with several accounts
despite peoples best efforts
discord ban evasion is poopoo
yeah, on discord, mods are pretty much powerless to do anything about ban evasion
having the servers hosted by a third party is a double edged sword
aight
lists are mutable in map correct
depends on the list
arraylist
some lists are mutable, some aren't
arraylists are very mutable yes
mutability is a property of the object; it doesn't matter where it is
Bukkit.getScheduler().scheduleSyncDelayedTask(MetadataHandler.PLUGIN, () -> {
customBossEntity.spawn(silent);
}, ticksBeforeRespawn);
you know this is way more of a pain in the ass to declare
in a field, in a map, in a variable
mutable is always mutable
that is significantly less boilerplate to write and far more readable
you still have to read it
alt-enter go brrr
i know you like to disagree with me as a habit but for this once just believe me
nobody who has worked with the scheduler for longer than 5 days uses anonymous runnables
hey now that's unfair, the only thing I've not budged on is class names
I've been working with the scheduler since 2016
and by extension with java
yep
and yet you aren't familiar with maps
yep
,```[12:12:05] [Thread-7/WARN]: Exception in thread "Thread-7" java.util.ConcurrentModificationException
[12:12:05] [Thread-7/WARN]: at java.util.HashMap$Values.forEach(Unknown Source)
[12:12:05] [Thread-7/WARN]: at vinnydgf.deanloader.bukkit.scheduler.async.TPS_60.update(TPS_60.java:43)
[12:12:05] [Thread-7/WARN]: at vinnydgf.deanloader.bukkit.scheduler.async.TPS_60.run(TPS_60.java:28)
https://paste.md-5.net/yehukeliya.cs
why i get this exception and how i can solve this
read what I said
but how i modifing this
?paste
????
pretty sure its gotta be synchronized to update asynchronously
GunManagement.recoil.remove(player);
remove modifies the map
GunManagement.recoil.values().forEach
values().forEach iterates over it
what would be the best option to remove this
use the remove method of the iterator
or use values.removeIf() and make value::update return a boolean
you know too much
or clone the values into a different collection and iterate over that collection instead
someone can give me a example of how to use packets?
unless you're using protocolAPI its gonna be self taught most likely
i dont want to use any api
tá bom danielzinho
kkkkkkkkkkkk sai daqui br
🇵🇹
long lost friends
já não te devolvo o teu ouro
😡
gastei tudo em fortnite skins
devolva nosso ouro português
english plz 
we took it fair and square
-_-
o
How?
block is broken, if the block on top is the same type then include that in your event
and recursively go though each block on top
The problem with that is that it does not work with pistons
Or if water or lava was to break it
I don't know but I am talking about anything that breaks indirectly from something else
I really feel like there should be a proper event for it
there should be proper events for a lot of things, but there aren't
i feel like i could pr one 🤔
what are we talking about though
but i dont feel like doing that stash stuff
#help-development message
This is what we are talking about
@shadow pulsar basically you want someone to make the whole thing for you
ripcord doesn't support message links
No
i saw
there are things like block destroy event or something like that but I don't think they catch all of the reasons why a block might be broken
That error usually came up for me when using an offline account or cracked account
I'm not really sure how you would make an event like that
i want to set player's display name to player's prefix - player's nickname
i told you
listen for block break, if blocks are above it add them to the list until they are no longer the same type
you'll also want to check for piston events
block explode events
That only includes if a player breaks a block
maybe the entity block pickup event
needs use an armor stand to set player's nick?
and maybe some block decay events as well
and probably the block disappear event for good measure
maybe physics event too
glhf basically
on piston, get the block and see if the block relative to the direction is a sugarcane or whatever, then call the method to go though and get every block and add them to the event broken list
BlockPhysicsEvent was the closest thing I could find but in order to see if a block was broken, you need to use a runnable and if you do that, you can't cancel it
myes
the whole thing about causality with block breaks is a pain in the ass
and the api doesn't really have any good way of getting around it
Hey, sorry for interrupting. I'm going to develop a custom plugin for my costumer. It's my first time developing a custom plugin. Can someone help me about pricing?
the only way to listen for this is to make it yourself
you basically just end up listening to all of the block related events and trying to cobble together some sort of logic for what's actually happening
Alright. I will try that
is that the right way?
I had to do something similar once for my rewrite of the slimefun blockstorage
the listener class turned out at 500 lines and with 11 event handlers
man I wish I could go to bed just about now instead of working on this
nah that's well done and dealt with at this stage
refactoring your horrible class names?
I'm writing a spawn method that either spawns an entity or pretends it does
automatically
is it safe to await a consumer but never receive it?
if you intend to await forever, sure
ok
specifically it pretends it does so for unloaded chunks so it doesn't rely on loading them, and instead queues a spawn for when the chunks actually loads
it's a bit of a pain
so at the end of my function, i have to accept null or it will freeze the main thread
especially since I woke up at 10 pm, yesterday
how are you going to handle them later
i mean, I'd assume your code makes the assumption that if the spawn method call doesn't fail, the entity exists and is spawned and its data can be accessed
or do you doublecheck the entity's validity everytime you're accessing it
entity validity gets sanitized early on as much as possible and tries to gracefully prevent any further operations from being done
this system will primarily be used by entities in a very specific setting in the first place, where failing to spawn is a misconfiguration issue
and the locations come preconfigured correctly to prevent these issues from popping up in the first place
one annoying thing is that this actually allows worlds to be unloaded / loaded during runtime so I also have to take that into account
Hello, I have a problem with my plugin. When I try to connect My database with Class.forName("org.mariadb.jdbc.Driver");,
That happends:
If that helps, here is my pom.yml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>Coinsystem</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.2</version>
</dependency>
</dependencies>
</project>
discord staff is offering a bounty on finding a way to make him not be here
GodCipher told me to use a for loop and a linked list
instead of a while loop
but
idk how i can add to the for loop while it is iterating
i'd use a while loop and a queue
four more hours and I can go to bed
while queue.hasNext() type shit?
or i guess if you want heuristics a depth first solution is better
?paste
is this for chunk sections or physical blocks or what do the nodes represent
tryna do some A* shite
https://paste.md-5.net/inibefamum.java Why Is my code not working, there are no errors too
but the tutorial was also shite
So can anybody help me?
have you shaded it in
what do you mean
I took it as a dependency
😉
