#help-development
1 messages ยท Page 171 of 1
You can also just do 1d and 50d
@echo basalt you banned me for nothing, undo that
anyone...
what's wrong
well
I'm trying (int) (this.getDynamicStats().getMaxHealth() * ((double) (this.getDynamicStats().getMaxDefense() + 50) / 100));
and its still 100
nothing is wrong
"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.
oh I forgot the 1
I'm using java 17 aka version 61
one you specify in properties section of pom.xml on both
there
what's up
yeah it's same
?learnmath when
now its 150
๐
return (int) (this.getDynamicStats().getMaxHealth() * (1 + ((double) (this.getDynamicStats().getMaxDefense() / 100f))));
i fixed it with telekinesis again
this is my formula
uhh can you check
I don't want to initalize a runtime dependecy management for just 1mb
How do i implement spigot doc into eclipse?!
Do not tell me to use ij ide <--(i already know this)
how about intellij
you gotta be kidding
maybe
I dont know my way around eclipse sadly, otherwise I could help
Eclipse does it for you
using Maven?
yes
but idk if i trust my ablities in maven
i will post maven file
?paste
alright gonna check real quick
so uh I'm new to reflection, how can I cast xyz.invoke as an int?
ensure the javadoc is ticked in that menu
You cast it to an int
for (Method m : this.getStats().getClass().getMethods()) {
if (m.getName().startsWith("get") && m.getParameterTypes().length == 0) {
try {
final Object r = m.invoke(this.getStats());
System.out.println((int) r); // I need this to be an int
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
}```
well unfortunately it doesnt work lmao
then right click pom -> Maven -> update Project
ensure force update snapshot/releases is ticked
What exactly doesnt work?=
Exception in thread "main" java.lang.ClassCastException: class java.lang.Class cannot be cast to class java.lang.Integer (java.lang.Class and java.lang.Integer are in module java.base of loader 'bootstrap')
ElgarL: ensure force update snapshot/releases is ticked```
Means the object you are trying to cast is of type Class and not int
but how is it of type class when i used Object as the type
For example getClass() from Object
You can check if the return type is int
ohh wait lmao
for(Method method : methods) {
if(method.getReturnType() == int.class && method.getName().startsWith("get")) {
int result = (int) method.invoke(instance);
}
}
I had a method that I forgot existed in the class
Something like this
didn't do much
you clicked ok and it shoudl have pulled all javadocs from maven
nein
I edited the method
Please dont tell me that you use reflections on your own classes
yes ๐
i cannot be bothered typing all 20 of them out
im converting the stats into NBT and I'm using reflection to loop and get the values and I'll remove get from the method name and add it as an nbt value
You dont have to if you use a proper design... this sounds like a BIG design issue which you
are hackily trying to "fix".
it still won't do
nah impossible
very cursed
did you manually add a jar or something?
What its better for listening to redis message arrive event, using thread or an executor?
executors manage threads. Those two are not interchangeable systems
Oh ok
So its would be the same using thread or executor
Because the executor will create a Thread for each process right?
Depends on the thread factory of the executor
nope, not what i know from looking
on build import
Because with a friend we are doing benchmarks and threads makes the plugin to work really slower
the only reason it would not show the javadocs is if you manually added a jar or messed up your classpath
public List<NBTCompound> getNBT() {
List<NBTCompound> nbt = new ArrayList<>();
for (Method m : this.getStats().getClass().getMethods()) {
if (m.getName().startsWith("get") && m.getParameterTypes().length == 0) {
try {
final int result = (int) m.invoke(this.getStats());
nbt.add(NBT.Compound(Map.of(m.getName().replace("get", ""), NBT.String(String.valueOf(result)))));
} catch (IllegalAccessException e) {
// do nothing
} catch (InvocationTargetException e) {
// do nothing
} catch (ClassCastException e) {
// do nothing
}
}
}
return nbt;
}``` look at this unprecedented beauty
using reflection is pretty convenient so i wouldnt call it a design issue
otherwise youd have a lot of repeating code
[{"Damage":"260"}, {"GearScore":"712"}, {"Rarity":"4"}, {"Strength":"150"}, {"Health":"0"}, {"Speed":"0"}, {"MiningFortune":"0"}, {"FarmingFortune":"0"}, {"AbilityDamage":"0"}, {"Defense":"0"}, {"PetLuck":"0"}, {"BonusAtkSpeed":"0"}, {"MagicFind":"0"}, {"ForagingFortune":"0"}, {"TrueDefense":"0"}, {"MiningSpeed":"0"}, {"Pristine":"0"}, {"CritChance":"0"}, {"Intelligence":"350"}, {"Ferocity":"30"}, {"CritDamage":"0"}, {"SeaCreatureChance":"0"}]```
and this can be used for basically anything
isnt there Map.singleton(K, V)?
seems pretty useful
yeah
Reflections are used for meta programming. They are horribly slow and they are hacky. This is 100% an issue that should
not be "fixed" with reflections.
me who thought that java internally uses reflections
though why arent you just putting it in a compound tag instead of an array of compound tags
//do nothing lol
how slow are reflections?
how are they slow tho
last time i used them it optimized to ~10 ns per method call i think
I mean I have some methods I forgot existed that return not ints but i just pretend they dont exist
using reflection
Not rare to see them take 300ms (6 whole ticks) at times
not for a few calls
*If you use java 8
yeah
on an old vm then
benchmark it
reflections are absolute garbage if you dont properly cache them
Are you considering the JIT for those benchmarks?
jit caches and optimizes method calls lol
mye
might wanna use jmh
well if jit does it here wont it do it in production
no
It may take seconds or it may take hours
Or it wont jit compile ever
All possible
will JIT optimize the actual reflection too
yeah right
until it calls into native or vm code
Yes. It will actually create concrete method calls. They wont be indistinguishable from a normal call then.
*If the JIT think its worth it
you could cache the method handles for a class in a hash map and use those
if youre very concerned about performance
This is what every half decent plugin which is using reflections does.
But in java 18 every method invocation is backed by a methodhandle anyways
Method Handle exists on JVM 8
I cannot be bothered implementing that
however
Total execution time: 14ms
for one iteration
for all methods
including me setting to to NBT and stuff or just the reflection
Thats horrible
just the reflection
14ms is great bruh
im a js dev im surprised when my code doesnt take 2000ms
14ms is pretty slow thats ~1/5 of a tick
Total execution time: 0ms
wonderfuil
one sec switching to nano lol
Total execution time: 33100ns
Total execution time: 33500ns
Total execution time: 19200ns
Total execution time: 21600ns
Total execution time: 21900ns
Total execution time: 19000ns
Total execution time: 35400ns
Total execution time: 16300ns
Total execution time: 16900ns
Total execution time: 17600ns
Total execution time: 17000ns
Total execution time: 17000ns
Total execution time: 16700ns
Total execution time: 16800ns
Total execution time: 34500ns
Total execution time: 18300ns
Total execution time: 17900ns
Total execution time: 17300ns
Total execution time: 29100ns
Total execution time: 17600ns
Total execution time: 16400ns
Total execution time: 29800ns```
Minecraft has 50ms per tick.
If you have a decent playerbase then 20-30ms are taken up
by mc itself and another 1-3ms by spigot.
Then add 10ms for other plugins and you are left with maybe
15-20ms for your own plugin. If a single method call already eats
75% of your entire CPU time then this is very bad.
its uh
variating
well its fine
this call is only used during startup to create an item
after that I just store it in a hashmap and never really re-create it again
Well on startup time doesnt matter
But using reflections like this is a clear sign of faulty design
idk I dont think design gets much better than this
I have like 20 stats and need to access them somehow
Well. Create a stats enum. Then a Map<Stat, Integer>
And getting all stats is as simple as iterating through the enum
for(StatType type : StatType.values()) {
int stat = statMap.get(type);
}
And instead of having one method for every single stat you can
have one method which works for every stat you want:
public int getStat(StatType type) {
return this.statMap.getOrDefault(type, 0);
}
oh yeah that could work too lol
Then you just need to add new entries to your enum and dont have to worry about all the places for your new stat
Very important to respect the DRY principle:
Dont
Repeat
Yourself
If you find yourself copy pasting something or writing something
repeatedly, then its time to stop and think about how to write it more modular.
Will save you literal hours of work
imagine
the fact that this constructor has like 20 parameters alone is weird, the repeating of getStats just makes it a little worse
tho you can send stats to contructor
And use reflection
or enum
who knows
need deep understanding of your entire plugin
ye
Stupid question. I have default values in a config I want to appear if it doesnt contain "path" so I do getConfig().options.copyDefaults(true); but when I reload / restart server it just gives default values again after I changed and saved them
Probably easy solution just havent worked a whole lot with configs
I want to appear if it doesnt contain "path"
what does this mean
like if someone removes the path so path:
blabla:
blabla:
I want it to set the values agian
just so it cant be empty
you set the default
look on stash to see how bukkit does it for their config
But when I change something and restart the server it just sets the defaults agian
again*
then you are not saving yoru changes
I am
Obviously thats why I'm asking forhelp
"ResultOfMethodCallIgnored" iirc
man as it turns out I have a lot of stalkers on spigot
hi , so i have a kit system with permission per kit , so i have a problem if a player have a rank that it depend on another rank , [this 2 rank have diffrent kits] , he will receive both
how would i give him the kit that is the same as his rank
Here is some list of warnings suppression
alright I refactored half my code to use enums thats a few hundred lines gone
ideas?xd
https://hastebin.com/ebocugumag.java this is next aah
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
dont worry you won't even know im there
seems like necroposting mr choco lyrics is taking off
yeah hard to know which part of your extensive stalking activities I was referring to right
I actually had your page open when you sent that message
was checking my notifications lol
I think my beard game has leveled up
I have reached a new power level
a supersayan +2 if you will
merlin wishes he had a beard like mine
๐
does HikariPool ever timeout
I can see [Ms-TickScheduler] [15:58:28] (HikariDataSource.getConnection) - INFO - HikariPool-1 - Starting... [Ms-TickScheduler] [15:58:29] (HikariPool.checkFailFast) - INFO - HikariPool-1 - Added connection com.mysql.cj.jdbc.ConnectionImpl@22d59864 from my old logs but now im unable to connect and all I see is [Ms-TickScheduler] [16:05:23] (HikariDataSource.getConnection) - INFO - HikariPool-1 - Starting... so im assuming the db died but doesn't hikari timeout or smth
meh there's hikari.setLoginTimeout(5); I guess that works
i have the same problem xd
this is my problem
do you know why this hapening ?
dosen't happend on my test server
that's why?
well something is taking ages to respond (it could be due to a firewall as well)
is your sql server on the same box?
no
it works , first 5 / 10 minutes
and after that this the bug happens .
are you certain the ports are open>?
yes or it will not connect me .
remote SQL is never a good idea. Too slow
group.rankname permission probably
ok so from what he told me the owner , he moved the mysql to the same panel of the minecraft servers
if you cna connect to the sql its possible you are running out of connections
using batch updates consumes them really fast
Hello! I'm trying to teleport a player to the projectile location on ProjectileHitEvent, however it seems to teleport to the inverse yaw and pitch; how I can rotate the vector 180deg to literally teleport to the opposite position? (Already tried getting the vector and multiplying it for -1 and 2, as i saw on a random forum)
Thanks.
well i think i'm doing smth wrong as i've already tried that
what exactly is happening?
right X Y Z but wrong Yaw Pitch
not "wrong", just that i want to "invert it"
tho in projectile hit event shouldn't velocity be 0?
use getDirection() not velocity
try setting player YAW PITCH from projectile.getDirection()
basicallyjava player.getLocation().setDirection(projectile.getLocation().getDirection())
smth like this
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
@civic wind
still the same
Vector vector = projectileLocation.getDirection().multiply(-1);
player.getLocation().setDirection(vector);
you don't need to multiply it now tho
why don't you just teleport player
directly to projectile location
player.teleport(projectile.getLocation());
tried that before, and the "problem" happens xD
that shouldn't affect yaw pitch tho
it just copies YAW and PITCH from projectile direction
@noble lantern what's with this guy's hair
tho arrow might bounce from block
so you mean this?
ye
maybe it's causing error
player.teleport(projectileLocation.setDirection(projectileLocation.getDirection().multiply(-1)));```
unbeatable
i will try, thanks
you would be better to maintain the players yaw/pitch though
not use the projectiles
projectiles can bounce or hit top of a block etc
Why is location so strange tho
setters return Location object
what's this pattern name
looks kinda like builder
append().append().build()
you can do .set().set() and have it cleaner
stills the same
its not a design pattern imo, its a design choice
then don;t use the projectile direction
maybe
but really looks like copypaste of builder
will try using player's yaw and pitch
the builder pattern does exist, its probably a variation of it
yeah
It in fact is
that's what i think about
Or fluent interface
player.teleport(projectileLocation.setDirection(player.getLocation().getDirection()));```
well the only problem is that you usually need Location.clone
cuz it's half static half non-static
strange class
Don't like how bukkit made it
the cringest thing is it's basically copying lots of public methods from world
which you anyways pass to constructor
Maybe they wanted to make it fully static but then changed opinion
i've just fixed it by setting the players's pitch/yaw to the projectileLocation
thanks!
made it work!
any way i can make it show more infomation?
It only shows what the javadocs say. but you can click the icon before teh name to open teh actual doc
ok! i were just confusing myself i believe
thought there wasn't enough details for me
but thank you for saving me โค๏ธ
with this mess
Does anybody have experience with text components and hoverable/clickable messages? I've been following a course on udemy about bukkit and thought it would be cool to try this but it doesn't seem to be working. This is one of the ways demonstrated in the course... :/
full error stack?
Sorry,
what is your dependency
It didn't say i needed a dependency for it?
you obv need spigot dependency for making spigot plugin
his instance is probably null
I mean, its class not found
It's a fully functioning plugin lol, course I have spigot dependancy
I think i worked out why
can you show your pom
Hello can anyone make me a panel (minecraft hosting)
Google... SparkedHost, BisectHosting, PebbleHost, etc
(๏ฟฃใ๏ฟฃ๏ผแดดแดนแดน
nah on petyocry or smth
SparkedHost, they will set it up for you too
yes something like that
hmmmmmmmmmmm lemme try
Any ideas?
what your main plugin class?
ddnt work
can you help with the host ?
That's where its saying in the error for the main class 'StaffMode'
have you tried rebuilding/exporting?
Will try this now
and how do you build your jar ?
No luck
also this is bad thing to suggest, after they come crying on ptero discord with 0 knowladge of basic linux administration
Wdym?
maven package
how are you building jar file
with @Ovveride?
onDisable thanks
and that too
bruh
Then I just 'build artifact' and export to saved file destination
you need to compile it using mvn package
Ahh
fucks up dependencies
Ah i see, thanks
hello brush
man making snake lol
I should google how to compile with maven? Never done it
man i made BoobleJump
you should have a maven tab on the right
just double shift and type mvn clean package
if ij
also this ignores pom
cant speak lol
mb
just call
fixed size hmm
no vc
how am i supposed to move
A D
What does "invalid target release: 1.8.0_202" mean?
Basically try to avoid hitting the walls
ah just ad
they have fixed bounce velocity
well done
you pc is infected i know your PP length now
how do you work with mns and maven?
i heard something about mojang mappings?
but i never done it before
umm
when running buildtools use --remapped
tho you just need to add NMS dependencies as far as i remember
Anyone? Maven giving me errors
like maven docs?
there is mojang map which binds a,b,c,d and other methods to their real names
what the hell
on the internet
don't look at the code it's garbage tho
well actually look at it
decompiler
lol
find my code where i get PP length
decompiled code always shitty
it's shitty in general
heyyo advanced binary code? xd
How do you usually name artifactId for a multi module project?
Parent: parent-<project-name>
Modules: <project-name>-<module-name>
mhh gui code always shitty
cough early minecraft
@old jay helped me draw buttons
dont even want to make smth gui based in java
yes he is
why not
wat
i like that very detailed and clean tut
Still same error
Not sure
what java version in pom?
ah
am i using right jdk?
ah it's done it, thanks
Does interactentityevent register two clicks ?
It's double clicking, or is my mouse broke lol
pretty sure it calls twice for the hand and off hand
?handed
Yes. Once for every hand.
lmao what
Does this exist?
there is a command
no
?twohands
a player does have two hands
?handy
damn how can i make it only once?
lmfao
?interact
I checked for item in main hand
only listen for event.getAction() == Action.RIGHT_CLICK or smth
they make the stupidest of commands. Can never remember them
or left whatever
Check for item in used hand instead
?workloaddistro kinda stupid one too
It's entityevent
smh

i even forgot it you see
//check if the action is right_click
if(event.getAction().toString().contains("RIGHT")) {
}
::getHand
I've checked for click, it all works, it's double clicking though
imagine interacting an entity with your legs
lol
@EventHandler
public void onInteract(PlayerInteractEvent event) {
ItemStack usedItem = event.getItem();
if(!this.freezeHandler.isFreezingTool(usedItem)) {
return;
}
// Freeze target here
}
HAND HAND
ItemStack itemInHand;
try {
itemInHand = player.getInventory().getItemInMainHand();
} catch (Exception ex) {
}```
iirc the interact event is also fired when walking on a pressure plate. Then the interaction is caused by the legs.
Yeah. Delete this.
No
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
I remembered
There we go. But my approach supports a freezing item in both hands.
You could as well just only support the main hand with the slot safeguard.
Either way is viable
putting return in {} ๐
Yes. Clean code all the way.
I get the urge to just return in the same line but its technically not clean.
i always return in the same line, except for returning actual values
if (event.getHand() != EquipmentSlot.HAND) { return; } those people are just evil tho
agreed...
I need some help trying to load a classes from a jar
We need more info bro
I mean dont know where to start coding it
Because my goal is to make a simple loading system like does spigot
wait wha
ah yes get_name
might work
and things like Class::forName and Class:newInstance
ok
I cannot use URLCLassLoader since i first need to load only the main class. So if doesnt extends my custom class i dont waste JVM resources
๐ค
is CraftInventoryPlayer still a thing in 1.18.2?
Probably
wha
First of all i need to scan the jar, looking for a json file and get the field main (which keeps the main class)
Second load only that class to the JVM and check if it extends my custom Extension class
Finally if first and second phases are okay, load the rest things from the jar
Is it a good design?
so youre first looking for a json file with the main class name in?
I mean i just need to use JarEntry and other related things to reading the jar
The main issue come to only load the main class into the JVM
Because URLClassLoader load the full jar/file not only a specific class
this maybe?
never done it before lol
and it your main class depends on other class in that jar, it makes sense to load them all ig
faund it in boot file //
Yes you are right
Because i was thinking that doesnt make sense loading the full jar if then when i check the main class doesnt extends my custom class i just load it for nothing
dummno?
Doesnt have translation
neither ig
I wished you could do smth like this:
try (Reader input = new FileReader(filePath)) {
// do stuff
} catch (Exception e) {
// handle exception
} finally {
input.close()
}```
instead of having to declare reader first as `null` so you can close it in the `finally` block
cant you?
Yk you don't need the finally it auto closes when defined like that
ye, but for other thorwable methods, the reader was just a good example
Pry much everything should auto close when defined like that can't think of any exceptions
ยฏ_(ใ)_/ยฏ
Finally kinda useless
Unless you have some weird cleanup work but I've never had to use it
Hello, im using https://github.com/hub4j/github-api and wanna download a jar file from a release in a private repo (download to a specific path). Right now im stuck on the downloading part, I get like an FileNotFoundException Error. Someone said I need to send like the OAuth Token as a bearer to authenticate? Btw: Im using java 8 so i cannot use HttpClient from java 11
is there a way to remap a port of a process using a ProcessBuilder or Process in java
lets say a process listens on port 2000 but i want it to actually open and listen on port 2001 on the host, without changing the configuration of the process
You can use OkkHttpClient or vanilla HttpURLConnection from java
sure
@radiant umbra
public static void main(String[] args) throws IOException {
URL url = new URL("url here");
HttpURLConnection client = (HttpURLConnection) url.openConnection();
client.setRequestMethod("request method verb");
client.setRequestProperty("Authentication", "Bearer token-here");
client.setDoInput(true);
client.setDoOutput(true);
client.connect();
}```
There you have
For getting the responses you have to use the client.getInputStream() and for passing data use client.getOutputStream()
Sorry for ping its just for you to know that i answered
Dont worry, imma try that ty
Whats the request method verb?
Depends what accept the github api
Could be GET, POST, PUT, DELETE
Github rest api have diff endpoints with diff request methods, parameters, etc
alright, trying "GET"
That should be specified on github api
I mean read about the endpoint you are trying to use it will tell how to use it, the parameters, etc
and then can i download it with Files.copy(client.getInputStream(), Paths.get("test.jar"), StandardCopyOption.REPLACE_EXISTING); ?
I'd not use HttpURLConnection as that one is prone to DNS issues from my experience, I'd rather recommend the http client lib built into java these days
This doesnt work (file still doesnt found)
public static void download() throws IOException {
URL url = new URL("https://github.com/ole1011/Newsc-master/releases/download/release/test.jar");
HttpURLConnection client = (HttpURLConnection) url.openConnection();
client.setRequestMethod("GET");
client.setRequestProperty("Authentication", "Bearer [token]");
client.setDoInput(true);
client.setDoOutput(true);
client.connect();
Files.copy(client.getInputStream(), Paths.get("test.jar"), StandardCopyOption.REPLACE_EXISTING);
client.disconnect();
}
you can create a DateTime object or smth from a string afaik
wouldnt essentials code have something similar to that you could look at
Loading API from specific Folder location how so?
hi , anyone know a fix for this ?
HikariPool-1 - Connection is not available, request timed out after 30002ms.
keep spamming this error .. after few minutes of server start
For a combat tag timer, right now i have it for move event, for the timer to expire, but if a players stood still it will keep counting below 0 till the player moves. What better way could i do this?
I made a timer which is on one second for something like this recently
Gives you more control and a surefire way of calling your methods
The event only triggers when you move anything. If youre afk it doesnt
Yeah, I've tested it, Shreb is right
Ye, thats not the question tho
I say put it on a timer instead of an event
I was going to check it with player coords?
Thats what the move event does
dont call both ::contains and ::get too
Why?
I dont see a reason for this, mind elaborating?
.contains is loosely a .get call
You can just call .get and then do a null check on that
if (contains(k)) { get(k).whatever() } is redundant, call get and see if its notnull
Thus avoiding a get call
Ah i see, does it really matter though or?
Though arguably outside of hot code it wont matter that much
Does contains just do get and nullcheck? If so I agree, even tho its not too bad to do it
If you absolutely need to optimise something that is an easy way to get rid of a few opcodes
But I believe that JIT will optimise that method call away anyways as long as you are not using concurrent stuff
readability is often dictated by what you are accustomed to
Valid point on the optimization
private static final Map<ShipType, List<Ship>> shipMap = new HashMap<>();
protected Ship(int size, ShipType type, int coordY, int coordX, ShipDirection dir) {
this.size = size;
this.type = type;
this.coordY = coordY;
this.coordX = coordX;
this.dir = dir;
shipMap.computeIfPresent(type, (shipType, ships) -> { ships.add(this); return ships; });
shipMap.computeIfAbsent(type, shipType -> List.of(this));
}
Is there a better way of doing this?
How considering that the collection itself can be modified between .contains and .get JIT might actually not run
Or do you prefer something like:
if (!shipMap.containsKey(shipType)) shipMap.put(shipType, List.of(this));
else {
final List<Ship> ships = shipMap.get(shipType);
ships.add(this);
shipMap.put(shipType, ships);
}
```?
Simply use .compute?
Yeah, hashmap doesn't do a nullcheck on the value
thanks, I am looking it up now, couldnt earlier cuz phone
CHM probably does though
HashMap::containsKey and HashMap::get does exactly the same
So
shipMap.compute(type, (var10001, ships) -> {
if (ships == null) { ships = new ArrayList<>(); }
ships.add(this);
return ships;
});
oh just telling
shipMap.compute(type, (var10001, ships) -> {
if (ships == null) { ships = List.of(this); }
return ships;
});```
It can only store 1 null key right?
I thought a HashMap canโt store Null keys
List#of is immutable you moron
that doesnt add the new ship tho, right?
does he need mutable
then never use my solution friend
Ye, I need mutability
Thx, almost forgot about that
true actially just realized
not exactly teh same
null value != null node
A node is a key -> value pair for reference
hey guys
(though for the reason we came to this discussion a null check on .get is actually better than a .contains call)
void process(Object o) {} can basically eat every object right?
Object, yes
what if i want the method to eat every object BUT not objects of Object class
At least until LWorld comes along - at that point I do not know
One could also use a functional approach
Player player = event.getPlayer();
UUID playerId = player.getUniqueId();
Optional.ofNullable(combat.get(playerId))
.map(cd -> cd - System.currentTimeMillis())
.filter(remaining -> remaining / 1000 <= 0)
.ifPresent(remaining -> {
combat.remove(playerId);
player.sendMessage("Something");
});
T extends Object ig
Or T super Object idk
void process(T extends Object o) {}``` would it look like this
is this even possible
T will always extend object
Yeah, LocalDateTimeFormat will do the trick
No, generics
true but if i want everything but not object itself
<T extends Object> void process(T t) {}
uhh explain me
the easiest solution is like if (o.getClass() == Object.class) return;
i need void method tho
which eats everything except Object
Does not exist
Thats a void method
Use DateTimeFormatterBuilder, which does actually work for parsing too
In this format T has to extend Object. Only Object does not extend itself.
new DateTimeFormatterBuilder().appendValue(ChronoField.SECOND_OF_MINUTE).toFormatter().parse("15");
Typed method
how do you check that tho
that object doesn't extend its own class
You dont check that. This is a compile time statement.
i mean instanceof would return true
You cant extend yourself...
I mean yeah you cant but
that's what i already suggested to myself here
i mean instanceof would return true
cuz object is object
The answer is yes if you couldn't tell
so youre restricting an Object from being passed in?
If you meant what I hope you meant
Didn't work tho
Yes, thus use .getCell
i guess not technically possible
basically Object does extend itself xD
Somehow
weird oop i guess
i tried T super String and passed anonymous CharSequence
still not possible
not for typed method at least
so i guess the only real way is to use
if (o.getClass() == Object.class) return;
cuz objects do extend their own classes
for some reason
Mye
Signatures are only a recommendatikn anyways
Nothing the JVM/other Classes need to uihold to the letter
Hence the only safeguwrd is Javac itself
what does Mye mean tho
this would work instead of move event and just remove combat if it goes below 0?
mmyes
u
I just did this for location (Don't hate on me if it's dumb i not really worked with tasks lol)
where early returns
Hello :
Connection leak detection triggered for com.mysql.cj.jdbc.ConnectionImpl@2eac3147 on thread Thread-41, stack trace follows
java.lang.Exception: Apparent connection leak detected
nested ifs go brrt
"Yes, but I have concerns that I an too lazy to Formulate as of yet"
Help please!
bad?:O
bro english please
true
howcome?
"Why This is Bad. Deeply nested conditionals make it just about impossible to tell what code will run, or when. The big problem with nested conditionals is that they muddy up code's control flow: in other words, they make it just about impossible to tell what code will run, or when."
ahhh
I don't Like writing Long elaborate sentences If under pressure
i wish java had something like a LazyValue<T> which could be treated like a T instance but couldnt been computed yet ๐ข
im bored
I'm tired
Which language has that? Sounds like it breaks type safety
Yeah then use the instance millis chrono field
is having a public static final map or set in a class that uses it, and for some other related classes to use it as well, static abuse
Or Epoch millis whatever you should get the gist
Yes
just had to make sure
Prime static abuse even
There ๐
*If the map is immutable then the story is different
I want to say Kotlin has a lazy keyword? Could be wrong though
is anyone aware which animation ID golem uses for attack
HELP : Connection leak detection triggered for com.mysql.cj.jdbc.ConnectionImpl@2eac3147 on thread Thread-41, stack trace follows
java.lang.Exception: Apparent connection leak detected
how i can fix this?
well basically want something like
LazyValue<Location> location = LazyValue.wrap(this::computeLocation);
location.setX(20);
so you can call methods on the object without knowing if it needs to be computed first or whatever
no need for null checks and stuff
man i always read hikari as hikaru (as the chess grandmaster hikaru nakamura)
rate mine
atleast use a Set.of().stream().allMatch for that lol
what
L @tardy delta
trolled
Set.of(flag1, flag2, flag3, ...).stream().allMatch(t -> t)
boolean b = 1 smh
would work in c++ ig
so it doesn't have the orange underline
in the if ()
just why not error before it haha
aka this
csharp just bothers me
Instead of using network libraries, I decided to make networking for my game with sockets... WOOO
it was fun tho
time to play coc
in what language
For games development yes, and if you want to make simple-ish type games without being in a large company
Damn it didn't work
like it's good for beginning
no cap
I do games dev in college and we do Unity
I did start using unity when I was 11-12 tho
instead of get != null => remove check if remove
yeah idk
boomer
im honestly just bored
what the fuck
bro I don't make babies, I get no girls ๐ญ
which idk why im doing ๐
I'm not a baby boomer!
?
I didn't understand what you said
?learnjava @remote swallow L
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.
vouch
if (contains()) { remove() }
//is the same thing as
if (remove()) { // object is removed, do other stuff }```
you confuse me
i confuse myself
fairs
YO your toe bones are so fucking long wtf\
lmao
wanna know the dumbest thing i did like 3 or 4 months ago
its a desktop startup that does a macro u record (routine) and select
look at how long those bones are
that doesnt look exactly healty
e.g u record a macro that launches chrome once ur device starts and youtube, as well as discord
exactlyyy
i hate that that feels true
then u can select it
anyone got an axe
should be working on java stuff but school gives me webdev appointments smh
get one or ill chef you up bruv
im in birmingham
ill pull a map up one sec
me
telling me to go to birmingham when your like 3 years away
looks like your just off the m1
lol it's crazy tho that we think it's such a big distance
but people in america travel across states
takes days
๐ญ
F
ikea had no large desks near me
I getting new SSD 
Why when I update the value in the scoreboard it adds a new line ?
what company and is it sata or m.2 and what size
WD Black SN850 2TB gen 4 NVME m.2
look at you
It's doing what i want it to do, but getting this error i need a null check right but where
Anyone maybe?
like if its null, do what?
can we get line numbers on that screenshot
Then the player has not entered combat ยฏ_(ใ)_/ยฏ
Probably should end the task then
I need the task to keep running, as its checking all players
can someone help me ?
then just do an if check. I don't see a check, if the player is in combat in your code
eat and take a short break, often helps
I cant seem to figure out how to get rid of these boss bars. They appear when a mob which has a boss bar attached to it by my plugin is still alive when I stop the server completely. doesnt happen on reload
trying to handle it like this, its not working, the boss bar remains even when the method was called. The bottom part of the method is probably the one thats not correct --SOLVED--
https://github.com/EthanGarey/BetterCommands
Main.java lines 50 through 55
It does not seem to do anything even though it reloads the plugin (It doesnt really reload it)/
i dont think its possible to fully reload your plugin by itself
?main
you could make a method to reload all necessary values and clear all maps/lists
main.java doesnt even go to 55
whys everything public
still last commit 14 hours ago
make a commit and push
maybe wrong branch?
commit then press commit and push
comitted
you have to push it to remote aswell
still no update
got it
53 and 54 are the main probloms
Bukkit.getPluginManager().disablePlugin(this);
Bukkit.getPluginManager().enablePlugin(this);
they will just mark the plugin as disabled not actually turn it off
how can I reload the jar
depends, do you only need it for testing or just to reload some values in the pluign
whats the difference between plugwoman and plugman
plugman is more resource intensive
ohhh
thanks
now I dont have to reload any more ๐
also another question, I have my alt+s keybinded to build the project, any way I can make it control s because when I set it to that it just doesnt work
I want it to do both
crtl s is probably mapped somewhere else
save and build
ill check one sec
also another question (lol) every time the plugin reloads is there a way I can add a 1 to the version in the .jar file and the console ([BetterCommand] version: 1.0.0)
wait not the jar file
nvm
just the console
may anyone tell me how to let code go off on exact times of the day? like everyday at 7 am for example
depends if the server turns off and on again
probably will
like inbetween you mean
yeah
probs will yeah
do you have build or rebuild mapped
Can you go down a line for a gameprofile name like this?
dyk how to


