#help-archived
1 messages ยท Page 79 of 1
what's flyway
database migration tool, makes updating your schema super easy
it basically versions your DB
@frigid ember You can code it but other stuff might break
guys
I have a problem
simple question
public static Block getFirstSolidUnderPlayer(Player p) {
return p.getLocation().clone().add(0, (ACMethodsUtils.getGroundDistance(p) * -1), 0).getBlock();
}
How would I make this run synchronized when calling it from an async event
now using a runTask
won't work here
because it needs to return a value
CompletableFuture?
and calling it from a runTask also wont help
you have to use futures
futures?
if you want to use a value which must be retrieved from the main thread in an async task, make a future of the value and call get() or join() on it
depending on whether you're using plain Future or CompletableFuture
well the latter has a lot more stuff
I find that Future is useful for beginners to understand the main idea of a Future
it's more intuitive that get() throws a checked exception because it helps new programmers understand how the exception is propagated
Any devs here?
otherwise they glance over the unchecked exceptions in join()
we already heard you say so
General wasnt the right place Ik
no it was
this isn't either
Ah yes, a true man of culture.
Scratch programmer
Oh sorry
wdym Scratch is real hard
sadly spigotmc.org is down otherwise I'd tell you to go to the plugin request section
I'm finishing my PhD in HTML programming tho
Is SpigotMC downed?
If I cast a block (which i know is a chest) to Chest then do openInventory then will it give me the whole inventory if it's a double chest if not how will i access it?
getInventory vs getBlockInventory
oops
I can't remember which one is the double chest and which is the single chest block
i meant that
check the javadoc
just that there are two things DoubleChest and Chest in docs
and if I cast a doublechest block then also it casts it into a chest for some reason
So if i do getinventory
guys
so thats what I did
public static Block getFirstSolidUnderPlayer(Player p) {
CompletableFuture<Block> complete = CompletableFuture.supplyAsync(() -> {
return p.getLocation().clone().add(0, (ACMethodsUtils.getGroundDistance(p) * -1), 0).getBlock();
});
try {
return (Block) complete.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
but there is only a supplyAsync option
woohoo
and I need to run it sync
ehmmm
supplyAsync and specify the Executor
CompletableFuture.supplyAsync(() -> value, executor)
but I need to return a value
use the scheduler in this case
It takes some time to understand how Future work
with a scheduler I can't return a value
you can...
Future<Type> futureValue = Bukkit.getScheduler().callSyncMethod(plugin, () -> {
return value;
});
you complete the future
then you can call #get on that future
ohhhhh
A248
CompletableFuture#completeAsync is only available in jdk 9+
if you do get it can block the thread
obviously
you're blocking inside an async thread
all that does is make the async thread wait on the main thread
no big deal
the user asked how to get a sync value in an async thread, and this works fine for most purposes
He could return a CompletableFuture of block, then use thenAccept
nothing wrong with blocking
since Bukkit API is not thread safe
I mean as long as you won't block the main thread its ok
I don't really know exactly what is doing so I can't really help that much
making my AntiCheat multithreaded
,-,
from what I can tell, Nort is inside an async task and waits a sync value
its very hard
its very hard even to do a proper anticheat
you can do this in 2 ways:
its very hard even to do a proper anticheat
@sturdy oar also true
use a CompletableFuture and specify an Executor, the Executor actually being an executor which runs tasks on the main thread
oh I see now, he's in a complete different situation than what I was thinking
I've recently used CompletableFuture for database connections, but since I'm not interacting with Bukkit API i can just do all async
but I guess he can't there
whats the difference between future and completefuture
it's like comparing Bukkit with Paper API
specifically related to acting when the future is complete
๐
you can't add a completion listener with plain Future
you can with CompletableFuture
you can also chain logic with CompletableFuture
that looks about right
yes
should now not destory my life when called async
yep
InterruptedException happens if the async thread is interrupted while blocking, so this shouldn't happen unless you interrupt your own thread
ExecutionException if the computation inside the lambda threw an exception
just don't
you can do Thread.interrupt() if you're working with raw threads
but you should be using the BukkitScheduler or your own thread pool
so interruption really shouldn't be happening
oh btw ty , I managed to serialize\deserialize my yaml config objects
if someone is interested in how I did it I can provide code
A248, you were saying about my static SQL method. Is there something wrong with it?
I'm still new to Java so I don't always have the best project structure, if you can tell me why I should change that I might
I though about that
I could make a singleton i think
but like utils should be static
Ok I think I got a better way
Also if go to the object orianted approach
then how would I like choose a method
lets say I have a 100 methods
what
and I want to summon one of them
you should not have 100 methods in any class
my PlayerUtils class has like 30 methods
are they all related to your database?
there is no database xD
yeah he was talking to me about databases
lol
If I want to check the change in items between chest open and chest close event then what's the best way to do it? ArrayLists?
what do you mean 'the change'
Like I have 2 stacks of stone when openchest is called then there's only 1 stack when closechest is called
the difference in inventory contents
so i want to get the data that player took 1 stack
public static Block getFirstSolidUnderPlayer(Player p) {
Future<Block> futureValue = Bukkit.getScheduler().callSyncMethod(GodsEye.getInstance(), () -> {
return p.getLocation().clone().add(0, (ACMethodsUtils.getGroundDistance(p) * -1), 0).getBlock();
});
try {
return futureValue.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
return null;
}
Server seems to freeze when I run this
oof
currently its called in a position packet listener
you are calling that entire method sync
that's why
if you're sure to call it in an async thread, you'll only make the async thread wait
you can debug with Bukkit.isPrimaryThread
(any ideas)
[18:18:24 ERROR]: ------------------------------
[18:18:24 ERROR]: Server thread dump (Look for plugins here before reporting to Spigot!):
[18:18:24 ERROR]: ------------------------------
[18:18:24 ERROR]: Current Thread: Server thread
[18:18:24 ERROR]: PID: 19 | Suspended: false | Native: false | State: WAITING
[18:18:24 ERROR]: Stack:
[18:18:24 ERROR]: java.lang.Object.wait(Native Method)
[18:18:24 ERROR]: org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftFuture.get(CraftFuture.java:54)
[18:18:24 ERROR]: org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftFuture.get(CraftFuture.java:42)
[18:18:24 ERROR]: me.nort721.godseye.utils.PlayerUtils.getFirstSolidUnderPlayer(PlayerUtils.java:330)
[18:18:24 ERROR]: me.nort721.godseye.listeners.PlayerDataListener.onSlime(PlayerDataListener.java:145)
[18:18:24 ERROR]: sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[18:18:24 ERROR]: sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[18:18:24 ERROR]: java.lang.Thread.run(Unknown Source)
[18:18:24 ERROR]: ------------------------------
[18:18:24 ERROR]: Current Thread: Snooper Timer
[18:18:24 ERROR]: PID: 15 | Suspended: false | Native: false | State: TIMED_WAITING
[18:18:24 ERROR]: Stack:
[18:18:24 ERROR]: java.lang.Object.wait(Native Method)
[18:18:24 ERROR]: java.util.TimerThread.mainLoop(Unknown Source)
[18:18:24 ERROR]: java.util.TimerThread.run(Unknown Source)
[18:18:24 ERROR]: ------------------------------
[18:18:24 ERROR]: Current Thread: RMI TCP Accept-0
thats the error
reeeeeeeeeeeeeeeeeeeeeeeeeee
if (logger.isDebugEnabled()) logger.debug("Primary thread = {}", Bukkit.isPrimaryThread());
one-line debug statement
why the debug if?
so you don't call Bukkit.isPrimaryThread() if debug is disabled
it's a small distinction which would only matter in extremely performant code
oh my dumbness, ok
so if I call it from the async normally I'll get erros because it uses none thread safe methods, but if I call the methods inside it sync then the server freezes
what a time to be alive
usually the idea with logging is to not create new objects or call computational methods (getters for example are fine) needlessly
Nort,
you either need to run your code sync, in which case, there's no need to use a Future
or you need to run it async, and use a Future for every sync value you need, as well as ensure thread safety
so you say that if my method can only be run sync
then it should only be called from a sync source
like the whole check need to be sync
if it's not thread safe, you shouldn't call it async
you told me it wasn't thread safe
and if you're calling it sync, you shouldn't use a Future
Can anyone help me
yes
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
How can o dowload the Minecraft server spigot?
You can't download a JAR except from third-party sites
You have to build it yourself using BuildTools
Link?
Can you please form a more coherent question?
No i will a minecragz setver
thankyou
just follow the instructions, if you have any problems, feel free to ask
yep
we should move to DM because other languages than English are not appreciated in here

I was wondering in version 1.8.8 if the donkey is under the EntityType.HORSE because EntityType.DONKEY doesnt exist
I've spent a while on this and I cant seem to figure it out. I'm using luckperms and yesterday the ranks were working fine and everything was normal but I found out that every rank had every perm so i removed '*' from every rank besides owner but now for some reason only the owner rank shows a prefix even when a person only has moderator or another rank and doesn't have the default rank it will still show the default [member] prefix
@marsh nova sorry for ping, anyway I just refactored my project and I think it's now much more clean
I avoided about 200 lines of duplicated code
Ty
for making me notice
No problem
I still have some static methods
Keep this in mind: Never write the same code twice
methods which don't and never will rely on the context in which they are called
precisely, you have given all of the state as parameters to that static method
Do u gus know a way to get a minimap in the top withoyt using a mod
minimap?
Yes
I don't think you can replicate that with vanilla features
In the top? What do you mean in the top?
Left corner or if u press m
no not possible, you need a mod
^
Aghh
if you really want it tell players to get a mod xD
but I highly doubt they'll add it
The priblem is i cant insatll anything other than normall mc
It says crashed every time
Forge has been working without any issue for me on 1.15.2
dont use the latest use reccomended always works flawlessly
I've spent a while on this and I cant seem to figure it out. I'm using luckperms and yesterday the ranks were working fine and everything was normal but I found out that every rank had every perm so i removed '*' from every rank besides owner but now for some reason only the owner rank shows a prefix even when a person only has moderator or another rank and doesn't have the default rank it will still show the default [member] prefix
@old elk
still need help?
yeah
I was wondering in version 1.8.8 if the donkey is under the EntityType.HORSE because EntityType.DONKEY doesnt exist
anyone know the answer to this
Really helpful and sometimes refreshes ur knowledge
the hell no
I've finished that 1 year ago
it's for beginners ๐ , I already bought more advanced courses from Udemy
๐ this is fun
is there a constant under EntityType that equals all entity types?
no
they're configuring
ah
wait that could work, because it could just cast the string to the enum
no.
try it out
is that only a c# thing
it won't work
it's a method
yeah
guys help please how to make the WILD go to overworld and not the world they currently in
wild is making them do wild in spawn and go outside border
same for warp pvp and nether end
Hey. Anyone can help me with maven?
I got this error when i try to build my plugin: https://pastebin.com/usjTuTKA
hey can someone help me setup a default joining world
Does crafblock has default particle name or id in its class?
@frigid ember just get world world i think its that easy prolly wrong but whatever prey sure thats it
you basically send them to world world and not the worrld they are currently in
yes bt the spawn is in world spawn
when they do wild
they wild in world spawn and die outside border
so i do setwarp wild in overworld in a 5x5 box
and they dowild
here ?
well idk what to do im stuck here for 2 or 3 days
public void onEnable()
{
File log = new File(this.getDataFolder() + "log.txt");
if (!log.exists())
{
try {
log.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
new ChestOpenListener(this);
new ChestCloseListener(this);
}
I'm making a log text on enable doesn't seem to work
@frigid ember this is your own /wild plugin? correct
Will this code work if I haven't created data folder with config.yml
public void onEnable() { File log = new File(this.getDataFolder() + "log.txt"); if (!log.exists()) { try { log.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } new ChestOpenListener(this); new ChestCloseListener(this); }I'm making a log text on enable doesn't seem to work
Anyone got any idea?
are you getting any errors?
Well, no
I haven't created the data folder by config.yml though
could that be the issue or will it create the data folder for me?
By createNewFile()
well where would it print the information if there is no where to print it
formatting code isnt hard
ik this is a very dumb question : is doing a simple plugin time consuming and hard ?
just the basics
for (final String e : dropSection.getKeys(false)) {
if (e.equals("default")) {
continue;
}
EntityType eType;
try {
eType = EntityType.valueOf(e);
}
catch (IllegalArgumentException ex) {
this.log.warning("No entity named " + e);
continue;
}
final ConfigurationSection entitySection = dropSection.getConfigurationSection(e);
final EntityReward reward = parseReward(defaultAmount, defaultChance, worldsNonexistent, defaultWorlds, entitySection);
this.entityRewards.put(eType, reward);
}
How would I go about making every type just use "default"
how can I set "e" (even though it's a temp variable)
i'm so not fit for this lol
ok
can I just set eType to EntityType.value()?
so every entity is equal to default
oh lol
for(EntityType etp : EntityType.values()) {
this.entityRewards.put(etp, reward);
}
I got it
hi all i dont suppose anyone knows why i might have got this ? https://gyazo.com/6b56d5ca27155e662f6a00fa18505b27 all i have done is created the connection using jedis and that is it
i know the redis server is up and working fine
this is how i am going about connectiong to my redis server https://gyazo.com/d6ec2e4d999e23652a72f37a7946df29
https://paste.md-5.net/zegusatinu.java setCancelled isn't working, ie i can move items in the inventory
how
my brain
because you're stripping "SHOP MENU" which doesnt have color
you should strip the clicked inventory's title of color
o ok
if (ChatColor.stripColor(clickedInventory.getTitle()).equalsIgnoreCase("Shop Menu")) {?
didnt work
although you could of just entered the exact inventory title you set it as
i can still change items
can i compare inventories?
so like
if clicked inventory is the main menu?
Is there an event which is called when a stackable item breaks (when the block under it is removed?)
E.g. a flower on top of a dirt block, player breaks dirt block, do I need to manually get the block above it or is there a nice event for it?
https://paste.md-5.net/ufirohovov.cs like that is my menu manager, why cant you just enter the exact name of Shop Menu which you set before?
or something and secondly is it registered
o ye
Is there a way to keep chunks permenantly loaded?
If so do I do:
@EventHandler
public void onUnload(ChunkUnloadEvent e) {
e.setCancelled(true);
}```
Chunk#setForceLoaded
seems like a good way to kill your server lol
We have a minions plugin and it breaks whenever a player leaves the radius of the chunk
if (clickedInventory.getTitle().equalsIgnoreCase(ChatColor.BOLD + "" + ChatColor.GOLD + "Shop Menu")) didnt work
wat is this
but rather check where minions are located / pause if chunk unload happen
what does setForceLoaded do
you shouldnt be using inventory titles to check for inventories
what should i use?
How do I "pause if chunk unload"
instances
?
Edit this to change the output of the command!
yes
wat
instances
clickedInventory.equals(theInventoryYouOpened)
Is there a way to keep chunks permenantly loaded? [1.8.8]
yep
e.getChunk().setForceLoaded?
i'd bully you but same
I love how people are like "We hate 1.8.8 but we still code with it"
the e.setcancelled doesnt run
Yeah setForceLoaded is only 1.15
yeah, it does not exist
@idle zodiac https://www.spigotmc.org/threads/inventory-gettitle-alternative.360350/ ig its ok to check for the title
I do not hate 1.8.8
I actually use 1.8.8 myself
So do I just use e.setCancelled() whenever it unloads?
which is one reason I build against it
that's what you will have to do
Okay
ah
make sure to do the required checks tho
i see why it doesnt work now
or you'll run out of memory in a heartbeat
What would happen if I never unloaded chunks that a player generates, this is for a prison server btw
oh ok
then you run out of memory and ur server dies
my brain hurts
you're going to have to comprehend a lot more complicated concepts if you want to be a good developer
Chunk c = e.getChunk();
Set<Entity> en = new HashSet<Entity>(Arrays.asList(c.getEntities()));
for (Player p : Bukkit.getOnlinePlayers()) {
for (Zombie z : Minions.zombies.get(p.getUniqueId())) {
if(en.contains(z)) {
e.setCancelled(true);
}
}
}
}```
huh
oof
I can't tell if you're being sarcastic
i hope people cant have as many minions as they want, otherwise they can just use them as chunkloaders lol
and that they despawn when the player logs out
i'd heavily advise against canceling chunk unloads, but if thats the only way ig u'll have to
Is that code actually good or?
no
it's expensive
3*n
but it;s clunky and horrible
but i mean it works
so i wont change itf ro the time being XD
I start code for functionallity too :D
if you want to use hashset speed
after its working i start making it good
why don't you just add all entities manually if getEntities isn't compatible
could just make it good from the first time
With some kind of preperation yes
you should also return after you cancel the event
yeah break sorry
return would be faster tho
lmao
cuz it can cancell nested loops
yes, but then it would only work for one player
tht's an event
I see, break the loop
if you cancell once
yes of course, in that specific code
that chunk unload for the others
public void onUnLoad(ChunkUnloadEvent e) {
Chunk c = e.getChunk();
Set<Entity> en = new HashSet<Entity>(Arrays.asList(c.getEntities()));
for (HashSet<Zombie> z : Minions.zombies.values()) {
for (Zombie z2 : z) {
if (en.contains(z2)) {
e.setCancelled(true);
break;
}
}
}
}```
I thought you were saying that adding a return statement at the end of a method made it faster lol
hmmm
you'll have to do more than just break once
since you have multiple loops
return is fine
you can also name the outer loop
and then do break <name of loop>;
that's a rarely-used feature of java but i don't think you need it
public void onUnLoad(ChunkUnloadEvent e) {
Chunk c = e.getChunk();
Set<Entity> en = new HashSet<Entity>(Arrays.asList(c.getEntities()));
boolean doBreak = false;
for (HashSet<Zombie> z : Minions.zombies.values()) {
if(doBreak == true) {
break;
}
for (Zombie z2 : z) {
if (en.contains(z2)) {
e.setCancelled(true);
doBreak = true;
break;
}
}
}
}```
oh
I accedentally
I can just do if(doBreak)
that like what a return would do
lol
Return breaks all loops?
yes
yes
yes
oh ty
it ends the method right there
so you did want a return
jesus fuck the spam
lmfao
public void onUnLoad(ChunkUnloadEvent e) {
Chunk c = e.getChunk();
Set<Entity> en = new HashSet<Entity>(Arrays.asList(c.getEntities()));
for (HashSet<Zombie> z : Minions.zombies.values()) {
for (Zombie z2 : z) {
if (en.contains(z2)) {
e.setCancelled(true);
return;
}
}
}
}```
Is that good code?
hmmmm
then add them in a loop yourself
you can just iterate over the array but ok
directly in hashset
there are many ways to write the same piece of code
entities are already unique i think
oh nvm
I use HashSet
mhm
public void onUnLoad(ChunkUnloadEvent e) {
Chunk c = e.getChunk();
Set<Entity> en = new HashSet<Entity>(Arrays.asList(c.getEntities()));
for (HashSet<Zombie> z : Minions.zombies.values()) {
for (Zombie z2 : z) {
if (en.contains(z2)) {
e.setCancelled(true);
return;
}
}
}
}```
So would that be efficient
at all
probably the best you can make it tbh, you could also just track the minions directly and then you'd only need to check the entity without getting all players etc
like if player joins, check if he has minions, if so add them to a list or whatever
Well I didn't get all players in that one : P
Thats what I do
And when the player leaves, remove the minion from all lists
cant you just get the chunk from the entity?
instead of getting all entities in the chunk instead
Lemme change the code
not sure if thats the best way tho
public void onUnLoad(ChunkUnloadEvent e) {
Chunk c = e.getChunk();
for (HashSet<Zombie> z : Minions.zombies.values()) {
for (Zombie z2 : z) {
if(e.getChunk().equals(z2.getLocation().getChunk())) {
e.setCancelled(true);
return;
}
}
}
}```
wait
public void onUnLoad(ChunkUnloadEvent e) {
Chunk c = e.getChunk();
for (HashSet<Zombie> z : Minions.zombies.values()) {
for (Zombie z2 : z) {
if(c.equals(z2.getLocation().getChunk())) {
e.setCancelled(true);
return;
}
}
}
}```
converting an array to arraylist and then to hashset is inefficient, just using the arraylist would be better
i think so yeah
Okay I'll try it
how about this:```
for (Entity entity : e.getChunk().getEntities()) {
for (Set<Zombie> zombies : Minions.zombies.values()) {
if (zombies.contains(entity)) {
event.setCancelled(true);
break;
}
}
}
return konsolas
you being dum
oof
Minions cost irl
seems like extra
So people wont have as many
So would that code above be more efficient would everyone say (that konsolas send)
Is everyone seriously having code competitions, the most efficient code wins
for (Set<Zombie> zombie : Minions.zombies.values()) {
if (zombie.getchunk == chunk) {
event.setCancelled(true);
return;
}
}
jeez stream it instead
i meant return
yeah thats a lot more efficient if you ask me
why not?
wait wut
Look at his code
^^^^^^^^^
Edit this to change the output of the command!
public void onUnLoad(ChunkUnloadEvent e) {
Chunk c = e.getChunk();
for (Set<Zombie> zombie : Minions.zombies.values()) {
for (Zombie z : zombie) {
if (z.getLocation().getChunk() == c) {
e.setCancelled(true);
return;
}
}
}
}```
Correct?
idk, i'm not a compiler
or:
for (Set<Zombie> zombies : Minions.zombies.values()) {
if (zombies.contains(entity)) {
event.setCancelled(true);
break;
}
}
}```
Which one would be more efficient
"A" i think
wait
he iterates over all the chunk entities tho
well its one or the other
normally a chunk wouldn't contain more than a few entities
Defo B then
you'll have to test and see tbh
just pick one because this doesn't matter
in most cases not no
yeah he is gonna rewrite this project a few times lol
?
Edit this to change the output of the command!
why don't you just extend chunk and have a custom chunk that only holds your entities only
this way, when you have the chunkunload event, all you need to do is just compare the chunk in the event with yours
if the chunk in the event matches your, get all the entities you have in your chunk
no need to iterate lists in that manner to see if your entities are in said chunk
@paper compass
did you try debugging to see if the event is being called and the zombies are being found correctly?
can uh someone tell me how i get rid of this
@frigid ember nice ide you got there XDDDDDDDDDDDDDDDDDDDDDDDDDDD
that isnt, its something in eclipse i somehow turned on
of course
We hereby sentence you to bucket kick.
@frigid ember control + .
whitespace characters
XD
or
took me 5 seconds to google btw
gg
what am i meant to write: how do iget rid of these weird characters that appeared out of nowhere
:/
that
you write that
but mirgnit oij jio found a fix
so i mean
*mini digger
fuck
*minidigger
my typing tho
mirgnit oij jio
and then one last thing
if (!pd.swings.isEmpty()) {
pd.swings.forEach(l ->{
if (TimeUtils.passed(l + 1000, System.currentTimeMillis())) {
pd.swings.remove(l);
}
});
}```
when I do it in a loop it throws concurrent modification on the forEach line
you cant remove while iterating
use removeIf
this is one of the most common beginner mistakes: modifying a collection while iterating over it
you can use removeIf or an iterator to avoid the issue
Show us an example so the beginners understand ;o
Well I am the most latest beginner so yeah ๐
latest beginner*
collection.removeIf((element) -> element.isSomethingYouDontWant());
that's removeIf
yes it was meant to be an error but yeah
And definitely no need to check if its empty since for each will just do nothing if the collection is empty.
You'd have to stream it first?
Its on collection not on stream
you're thinking of Stream#filter, which is similar but for streams
Well if you removeif on stream, it would remove from the steam, not from the collection...
Stream*
Thats if it existed on stream.
well you could use collect
yes, that's a good distinction, modifying a stream created from a collection would not change the underlying collection
And make a new object?
so you would have to re-assign the collection if that was your approach
Then might as well just use an iterator...
I mean it depends what you're trying to achieve
no you can use removeIf just fine
using streams is worse for readability and performance
I don't think the performance hit of using a stream is really the same as cloning a massive collection
but I mean if you use new lines for it I'd say readability is just fine
but sure
I am not a fan of lambdas
lambdas are the future of java
true
doubt it
No point in arguing, we'll see soon enough ๐
yeah who are we to blame
to have lambdas you need the normal methods
lisp.
so, can't have one without the other
False-ish
no need for methods with lambdas.
Static class functions work just as well
I mean pretty sure kotlin will takeover java once they get all the functions java has
kotlin sucks
cuz rn iirc no inner classes etc
all those java-derived sublanguages are a fad and will go extinct soon enough.
They don't bring anything new
not so sure
that is massive enough to warrant their existence.
I dislike kotlin, but to have lambdas you need the underlying structure. And I doubt java is going to remove everything about it to just be nothing but lambdas.
Kotlin has to run on a kotlin jvm, not java jvm
^
but java can run on kotlin jvm
...since kotlin is an extension of java it makes total sense.
oh yh but I mean it runs as java in the end
kotlin jvm is not a thing
Tell me honestly about one thing that kotlin provides that java doesn't.
has to be to have kotlin because Java JVM doesn't know kotlin
Or scala, or any of those sublanguages
kotlin translates to java byte code
^
it's just another way to write java code
That's what I thought. I saw a plugin sc having 1 kt rest java
it is
Depends what you define as java now
in this case is
i can open your compiled project
with a java decompiler
it looks computer made
man kotlin's website is just garbage
And I can open a javascript code compiled into C bytecode
could they make it any worse o.O
but it's java nonetheless
and it will render proper C code
you can run kotlin Bukkit plugins without a "kotlin jvm"
but it's NOT javascript
Weby wordwise kotlin will never be java
The only important thing is :
Tell me honestly about one thing that kotlin provides that java doesn't.
@sick citrus
Well despite your question @sick citrus many languages continue to get created regardless
because somewhere someone wanted it done differently
Created and forgotten.
That's my point. Kotlin will never replace java, and will not hold the test of time.
Depends on whether or not the developers keep developing it
They will if Kotlin offers something no one else provides. Otherwise...
Well as kotlin kind of is java it will never replace it.
But it might get the majority of the java developer audience later. Idk who knows?
Never know, but it isn't going to magically go away either
Yeah
only way it goes away is because it is stopped being developed
I believe it will stay as there is some big companies using it right?
Some android stuff is built up by that iirc.
JetBrains are the ones that make IntelliJ
Yeah right
It seems to be popular for android developers when doing a quick internet search.
But as far as lambdas go, it is cool java finally supports them, just call me old school as I don't use them ๐
My modifications to the plugin worked yayaya
yes, but you know how long it took to add it to begin with XD
is there a plugin that forces players to join a certain world when they join the server
Edit this to change the output of the command!
Idk if you can use the event that fires before the player joins
@frigid ember do you use bungee? and if you do did you directly connect to the server?
I am a fan of new things being added to Java, and I am quite accustomed to Java's conventions as far as working with Java goes. I would hate to be forced to use lambda's though lol
mainly because you can't always tell what is going on with lambda's
I feel like lambdas sometimes is very useful but yeah it's preferences ig.
Yes I would agree they are useful especially if you are seeking for shorter code where it doesn't matter
to me, I don't mind if my method is 10 lines and can be condensed to 1 line, because overall, it doesn't mean it will run faster because it fits on 1 line vs 10
Anyone know the proper way to register custom Recipes with the Server, so that a player can โdiscoverโ them on Join? (Using the Api). Iโve only been able to get this to work by requiring a player to connect, disconnect and reconnect after the server starts
I prefer having more classes than longer ones.
Just add the recipe to the server recipes?
Or am I wrong?
Using the Api?
This is for a plugin that allows for the creation of new recipes, through config or commands
?jd
Yeah frost I c
Thanks, Iโm familiar with the docs and the api
Good because not everyone is unfortunaly
I know the recommended approach for defining Recipes and registering them. The problem seems to be related to the timing
anyways that should be the relevant api
intressting it has to be stored in a knowledgebookmeta
thought it was a player property
I mean rn working with an abstraction hell
so kind of paused my research in the api
at least it isn't Dependency Hell
maven is weird sometimes in that regards
sometimes when I want to shade something, it will out of the blue try to shade spigot in
and then I have to tell it not to do that
other projects it isn't an issue
It's just so much simplier in my opinuion.
Hmm yeah shading in gradle is also very smooth
maybe that's a version issue
I think it is an issue with those that use depedencyreduced pom
when they shade their projects and push to a repo
if you use a dependency reduced pom and deploy to a repo, that pom will replace your default pom in the repo
Its only an issue on first join after server restart
so try waiting a tick or two after the event has fired to do that then
if you want to be sure not to shade spigot, just ensure it is provided scope
@keen compass when I connect to Bungeecord, I am redirected to the login, and then when I log in, I am redirected to the lobby.
or, better: specify the artifacts you want to shade explicitly
this is what I do for all my projects which have shading, and it ensures I never shade anything I don't want to
If Im using nms at all, I have to shade spigot or paper, I cannot just build against the api
BukkitTask :p
@marsh nova the problem was transitive dependencies. But it is weird because there is no way to know what transitive dependencies have
So, like I said its not always a problem
Well, in this pluginโs case thatโs irrelevant
but every now and then it is and then I have to tell the shading plugin to not shade in certain things XD
you can use the effective pom
Exclusions are fun
or I think
it's called dependency hierarchy
either way, you can view your transitive dependencies
Migrate to Gradle ;]
Yes you can view them, but that doesn't mean you know what they have shaded either. If they shade a dependency themselves, and then you have a dependency that depends on it, and then you shade that dependency you can end up with spigot or its related things it has shaded, into your shaded jar
quite fun when you are trying to track down where some of things getting shaded in are coming from
You can filter or use an artifactSet exclude
Yeah I had to use exclusions in one of my projects
You can check the dependency tree with maven
its how I got to learn about transitive dependencies more ๐
I don't just learn how to resolve something, but try to understand why it even happens in the first place
That seems like a good method
Otherwise itโs just whackamole every time youโre trying to figure it out again
So, if a transitive dependency has shaded artifacts you won't know about them in the dependency tree. Especially if they make use of dependency reduced pom
dependency reduced pom, removes dependencies in the pom if they get shaded in
Well I mean how do you even go about modulation in maven?
good news is, that the shaded plugin works on package names and not the dependencies themselves only
Ideally your dependencies haven't shaded spigot into themselves.
The fun one for me is a mulitmodule project for different mc versions that wonโt all support the same version of another lib I want to use
Otherwise the libraries you are relying on may not be designed the best.
You go about modularisation in maven simply, by doing it.
@marsh nova well this was in the past, I don't have issues with it no more. Just the odd occurrence here and there of certain things being shaded in that I didn't realize were being shaded in and don't have a direct dependency on the things being shaded in either.
You use a parent pom and multiple sub-modules.
So pretty much the same as in gradle?
don't ping please, it makes messages harder for me to read
I wanted to use Guice 4.2 with all my modules, but an older version of spigot wouldnโt play nice with it.
To be honest I do not know enough about gradle
I should be less quick to cast my opinion in Maven's favour
Although, the reasons why I do so are clear
I prefer maven over gradle
Maven in most cases will perform the same as Gradle
in fact, many people don't know that maven can build in parallel ๐
you can even give it more resources as well
i took the time to get a vague understanding of gradle and it was worth it. it looks like shit from a distance, but it's actually fairly structured
Gradle can do more advanced stuff though
Itโd take me quite a while to get as comfortable with gradle as I am with maven, and Iโve only scratched the surface of using Maven
Tbh yeah it's so much less work
I really don't need or want parallel builds. My machine only has 2 cores so it wouldn't help much anyway.
Gradle config is much cleaner too
@obtuse rose I don't doubt that Gradle can do some advanced things, I mean technically maven can too. I think a better thing to say would be that Gradle allows more advanced things more easily.
I can do complex builds with just using maven only, just comes down to what you know and how to use what you do know
Hello was wondering if anyone is able to help me on my server, suddenly yesterday or 2 days ago, non-opped players freeze for like half a second once in a while, and it's really annoying. I tried deleting some plugins that might be causing it, but I can't pinpoint it, if anyone would like to help me please @ or msg me thx :d
i mean if you ever want to use forge, fabric, or sponge, you're gonna have to use gradle
You can make fat jar with only some script in gradle, you need shade on maven.
Chick
Not saying it's practical
you're subject to whatever mapping plugin the platform offers
don't actually need shade to make an uber jar.
It's hard to know exactly how he did it
you could always use the Jar plugin
True
But it can be by packets or just having hacked items
oh well the sponge API doesn't require any mapping I suppose but then you can't use "NMS" stuff
so maven is available
but just note one of the things maven can do, that most don't realize is that you can have maven run arbitrary commands and you can even make maven plugins as well if nothing fits for you.
Or you could just switch to Gradle
I have no real need for switching as I am just fine with using Maven. I agree Gradle does making doing some things easier for some.
do you use maven @keen compass ?
Yes I do
Then use maven then!
Maven is not bad
Just get with something you can work good with and it should be fine ๐
^
I don't use any dependencie management... should I?
YES
using maven or gradle makes it easier to manage dependencies
Imo Maven would be much better if they use something else other than XML though
create a maven plugin that allows that
whats wrong with that
I am pretty sure a maven plugin already exists that does that actually
@timber barn there's lots of markup clog up my screen real estate
Loool
but at least they didn't go with a weird xml setup though
True
my precious xml ๐ฅ
Xd
I was turned off from xml by some projects that used it in odd ways that made it hard to do things with
what about json?
Json is nice for server payloads, not so much when it comes to config files though since it wasn't designed for human readability in mind
json too is designed for being human readable actually
well thats what the authors said
well from what I have seen in how it is implemented reading it is quite difficult sometimes
well ok, its quicker and dirtier than xml
the only thing I dislike about Json, is the infinite arrays
its shorter and dont use end tags
as far as I am aware JSON doesn't put a limit on arrays inside arrays
oof
and there is no way to know how many arrays an object has either
nested arrays till infinity
just have to keep looping until there is no more
That's a hell acc
I don't see the problem here
xml supports arrays, they just look like shit
๐
ok this might be an unpopular opinion but I actually thing yaml is disgusting. i just had to say it
very important that everyone knows
thanks mr trapped
yaml is really atrocious
Well it's readability is good
no it's awful and hideous
indeed
yaml?
except the lines
you dsrve this