#help-development
1 messages · Page 307 of 1
i saw something about Handlers
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
point 3 explains about custom event stuff
that class gotta have a handlerlist field
anyone know how i can convert the Generation ordinate back to Generation in bookmeta
syntax surprise
private static final Object LOCK = new Object();```
i didnt know you could create a raw object till a few moths ago either
as it has no state and wouldnt make much sense instead of using smth like Boolean.TRUE
what can you do with a raw object?
an object with nothing in it lel
synchronized (LOCK) {}```
a hashset used an Object internally to associate it with keys
all keys are mapped to the same value
even in all hashset instances i believe
you can cast it to just about anything
only if its null
he proobably means Object o = new Something()
except being an object
you are an object too
i will garbage collect you
/dev/null
how does it look https://paste.md-5.net/ifonuniluv.java
lets actually call data word
looks broken to me
seems to happen when i insert the max function lol
wtf have i done
thats a nice toString
Hey Guys,
is there a way to get the remaining delay of a BukkitTask until it will be executed, which was scheduled with Bukkit.getScheduler().runTaskLater(myPlugin, myTask, 2400L); ?
store how many ticks have passed or smth
it wouldn't be accurate because there is no guarantee your task will execute exactly after however many ticks you specified
just that the scheduler will try to execute it after that time period
Object lock = new Object();
Synchronized(lock) {
}
I never could understand how doest work or what does
well I do not mind if it is not 100%
then the best way is to get the task id, and the time you specified and put them into a hashmap at creation of the task since you know you have the delay time then
it only allows one thread at the time to acquire the lock and enter the synchronized block
to avoid race conditions and stuff
then you can use the task id to see if it has been executed or not, and since its in a map you can check how much longer it has left
Transpiled to a friendly lang?
okay thank you I will try it 🙂
Well it's a virtual things where process are executed
Only one thread at the time can read/write inside of lock
Okay i really get mess about that tho
.
Because from what i know on every read/write thread Is temporally paused until it's finishes. At leas thats how I/O operwtion works
That is why multiple threads exist
But threads in what context?
Because idk why i think threads related to processor ones
It's really common that mistake that why i ask the context
Lik running things asynchronous in any context
Let me ask the next if i have 2 one with 2 threads and another with 4, both having Java. The first JVM will support executimg More pocesses or not?
depends on how thread are mapped
Defintly i think i Will fully understand Sync and async theory once i Start university. Cuz we have OS arquitectura
university lol
?
why would you need university to learn that
I'm not university tho, i have 16y
learnt it on my own
Because there you have a subject wherethey fully explain you the "arquitectura de ordenadores" and there you learn about Sync and async I/O operaritions
Well I hope your country's universities are more useful than America's.
id just look at indian java tutorials
Well my country used to export 70% of software to US
just read a book
I know but I'm weird to learn
Because i can read something 100 times but i dont understand it
;-;
I know because i tried many times to learn how async works on java and neve understand it
I mean what do you not understand about it
Async just makes stuff not stop main thread in simplest wording
I just understand that:
Sync is running múltiple process in same thread, so on each I/O operation Is blocked until finish
Async Is the oposite from what i have said
Yeah basically, what more do you need to know than that? 
I dont understand the fkg way of Java
huh?
im trying to find the book i read but all covers are different
There are few apis in java for async programming
CompletableFutures are a godsend once you figure out what their terribly documented methods do
Because you have threads, runnables, executors and completable futures, tasks
Most used ones are completable future and executors
Runnable is just funct interface
I only use supplyAsync and thenAccept lpl
And never use pure Thread
I've used thenRun a few times 
Shity Java have many ways of Async which C# doesnt clntain for example
doesnt C# have the async keyword?
Yikes, you're being mean to Java. That will not end well for you. It will not be nice back.
or dotnet in general
i read this book but cant find the english version lol
it tells alot of concurrency, atomicity, locks etc
How does completable future works internally? Because i know it's take a generic param which is the object that Will return. But them for getting it you habe ti call CompletableFuture#get() which caused thread being blocked
No, thats when you start using thenAccept()
dont try to figure that out
dont
it uses a threadpool
whatever you do, dont look into the code
So do you recommend me to read about OS arquitecture and then give a try to Java Async
You don't really need to read os arch to understand concept of async actions
just concurrency in general
Coroutines my beloved
what are that
English English please?
arent those kotlin lambdas or smth?
Please don't mix kt and Java, totallt diff impls
Kotlin 
syntax 🤡
Coroutines are not stricly kotlin
How can i Fix?
key is char
I mean this
You can basically for example
scope.launch {
delay(20000)
Sout("hello")
}
And that code will execute after 20 seconds without blocking anything
It's deprecated
by looking at the docs
And it's super lightweight
ok just a fancy async wrapper
Cause he did the other par of it wrong
Couroutines are much more https://en.m.wikipedia.org/wiki/Coroutine
Coroutines are computer program components that allow execution to be suspended and resumed, generalizing subroutines for cooperative multitasking. Coroutines are well-suited for implementing familiar program components such as cooperative tasks, exceptions, event loops, iterators, infinite lists and pipes.
They have been described as "functions...
Kotlin just have an implementation of it, wouldn’t surprise me if java also has one in the future
So for understanding Async i Will need to start reading Completable future, executors and concurrency right? Smth else i miss
Concurrency first
im not waiting im just wondering what advantages it will bring
Theres many advantages google it
Ok i Will do that first, concurrency oriented to Java Right ?
They’re lowcost for one
You can read a book demonstrating concurrency using java sure
advantages that like really have impact
It is a high impact you can have literal millions of co routines running
Threads not so much
im wondering how they are implementating those virtual threads
a different thread to os thread mapping maybe?
Google it
yes mr google
what happened with wikipedia
screaming sandles
or use moj maps and special source
?screamingsandals
ah platform threads an os threads are mapped 1:1
who came even up with the name screaming sandals 💀
😱 👡
"two guys from Czechia and one guy from UAE"
Those 3 did
guys can I add ench to an item that's not capped to 255
#addUnsafeEnchantment(Enchantment.SHARPNESS, 5000);
since 1.17.1 or something like that no
zero workarounds?
you could probably do attribute stuff
but that would require loads of math to get the right damage modifier
is this the correct way to send data to bungee?
@tender shard i used your code its shows Player: sheduxdev Joined IP: 193.35.154.47:2556525565
@EventHandler
public void onJoin(PlayerLoginEvent event) {
String hostnameUsed;
String[] splitByColon = event.getHostname().split(":");
hostnameUsed = event.getHostname().split(NULL_CHAR_STRING)[0] + splitByColon[splitByColon.length - 1];
System.out.println("Player: "+event.getPlayer().getName()+" Joined IP: "+hostnameUsed);
if(getConfig().getString("host").equalsIgnoreCase(hostnameUsed)) {
if(event.getPlayer().isOp()) {
getLogger().warning("Player: "+event.getPlayer()+ " Joined IP: "+event.getHostname()+" Is Op: true");
List<String> lines = getConfig().getStringList("kick-message-op.");
for (String linestring : lines) {
event.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', linestring));
}
}
}
if(!getConfig().getString("host").equalsIgnoreCase(hostnameUsed)) {
System.out.println("Player: "+event.getPlayer().getName()+" Joined IP: "+hostnameUsed+ " Joined with numerical ip");
List<String> lines = getConfig().getStringList("kick-message-host.");
for (String linestring : lines) {
getLogger().warning("Player: "+event.getPlayer()+ " Joined IP: "+event.getHostname()+ " Not joined with "+getConfig().getString("host"));
event.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', linestring));
}
}
}
how i can delete after :
i trying delete after :
Why doesn't the Lore appear?
@quaint mantle
but its shows 25565 or 255652565
okay sorry
to where
to wheree
String hostnameUsed;
String[] splitByColon = event.getHostname().split(":");
hostnameUsed = event.getHostname().split(NULL_CHAR_STRING)[0] + splitByColon[splitByColon.length - 1];
event.getHostname().split(NULL_CHAR_STRING)[0]
public RepeatingTask(JavaPlugin plugin, BiFunction<RepeatingTask, Integer, Boolean> task, long delay, long period) {
super(plugin, null, delay);
this.period = period;
this.task = new RepeatingTaskFunction() {
@Override
public boolean tick(RepeatingTask task, int iteration) {
return task.apply(task, iteration);
}
};
}
how can I make task.apply() inside the tick method refer to the argument of the constructor?
wrapper classes go brr
I did that, but I was wondering if there was another way
RepeatingTaskFunction has other methods you can override inside it
but yes i guess i could override biFunction now that I think about it
abstract class
Hello how i can do this
?
kick-message-host:
- "&e&l● &6&lIUMGUARD &e&l●"
- ""
- "&aLütfen sayısal ip ile girmek yerine &eplay.demirium.com &aadresi ile gir."
- ""
- "&6Support: &edeniz@foudrestudios.com"
List<String> lines = getConfig().getStringList("kick-message-host.");
event.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', lines.toString()));
its not kicking player
what event?
PlayerLoginEvent
declaration: package: org.bukkit.event.player, class: PlayerLoginEvent
if I want to catch data from a channel, do it need a bungeecord plugin or can do it from spigot plugin?
ArrayList#toString wont give you what you expect
it will give you smth like ["line 1", "line2", "line3"]
so how i can do that
ok guys this seems like a silly question I never thought of this, anyway
public class Main {
@Override
public void onEnable() {
getCommand("stick").setExecutor(new Stick());
}
}
```how can I make this command case insensitive? if other class is like this
```java
public class Stick implements CommandExecutor {
@Override
public void boolean onCommand(bla bla) {
Player p = etc etc.
}
}
``` now the command only works when typed all lowercase how can I fix it? (no args, only a single /stick)
easiest way is lines.stream().collect(Collectors.joining("\n")) or smth
someone check this pls :)
why would you even allow that
?pluginmessages
blame staff
this one is the best
?learnjava!
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. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
thanks to imajin
List<String> lines = getConfig().getStringList("kick-message-host.");
lines.stream().collect(Collectors.joining("\n"));
event.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', lines));
like this?
no.
so how
it returns a string
String s = lines.stream().[...]
use that
OH
List<String> lines = getConfig().getStringList("kick-message-host.");
String lineStrings = lines.stream().collect(Collectors.joining("\n"));
event.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', lineStrings));
i fixed it
let me try
oh
it has a notnull contract iirc
its not kicked me
i also told you to use what i said
.
Does anyone have any advice for me to solve this problem?
people not knowing you can set lore to an immutable list
I think I've ruined everything now :C At first, maven emptied my entire plugins folder of my server and now maven doesn't even compile anymore
pom.xml: https://paste.md-5.net/caqamoboga.xml
Can someone maybe just write me the pom.xml code that will compile my project into a jar file in the path C:\Koner\projects\minecraft\konercraft\plugins\konerutils.jar. Thank you!
I didn't do one, didn't think I could destroy the compiler that easily 💀
Is my project now lost?
i can smell that?
create a new project and just steals its pom
or find a project online and copy the format
And can someone help me maybe to write a pom.xml code that will compile my project into a jar file in the path C:\Koner\projects\minecraft\konercraft\plugins\konerutils.jar? Because the
<outputDirectory>C:\Koner\projects\minecraft\konercraft\plugins</outputDirectory>
```didnt't worked
What would be the best way to spawn blocks in a boundingbox depending on its probability. The materials are mapped to their probability in a hashmap.
Right now im doing cumulative probability for each block in the bounding box.
where you put that
but I feel like there is a more optimized way
Look here https://paste.md-5.net/caqamoboga.xml
Line 20
you should add it under configuration in maven-compiler-plugin
okay i'll try that thank you
kick-message-host:
- "&e&l● &6&lIUMGUARD &e&l●"
- ""
- "&aLütfen sayısal ip ile girmek yerine &eplay.demirium.com &aadresi ile gir."
- ""
- "&6Support: &edeniz@foudrestudios.com"
if(!getConfig().getString("host").equalsIgnoreCase(hostnameUsed)) {
StringBuilder sb = new StringBuilder();
for(String kickmessage : getConfig().getStringList("kick-message-host")) {
kickmessage = kickmessage.replaceAll("&", "§").replace("{HOST}", getConfig().getString("host"));
sb.append(kickmessage);
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, kickmessage);
}
}
why its shows just "&6Support: &edeniz@foudrestudios.com"
lmfao i just spend an hour trying to figure out why my plugin is pulling english values from the chinese lang.yml
turns out i didnt translate some of the keys
what is this .iml file doing?
https://i.postimg.cc/J4FvJWK2/image.png
being intellij probably
?tas
oh no
I deleted my whole plugin, what can i do?
https://i.postimg.cc/9fNHxqBc/image.png
right click the pom and import it as a maven project
https://prnt.sc/yAx3MsFhD2FW
how i make new lines i will kill my self
kick-message-op:
- "&e&l● &6&lIUMGUARD &e&l●"
- ""
- "&aMerhaba, salak griefer kardeşim. Senin böyle bir salaklık yapacağını tahmin ettiğimiz için böyle bir sistem geliştirdik."
- "&a&lHAA! &aSakın unutma Port Açığı gibi şeyler deneyeyim dersen onlar kapalı zaten sana iyi denemeler enayi. :D"
- ""
- "&3Bir kez yürünmüş bir yola düşenlerin sayısı çoktur, hedefe ulaşan az..."
- "&b- Friedrich Nietzsche"
- ""
- "&6Support: &edeniz@foudrestudios.com"
without \n
bro wtf
can i undo my changes with that
i fixed it
put the method to strip the hostname into its own method lmao
its works now
have you ever heard of using methods? 😄
i fixed it
yeah but still
you shouldnt embed logic like this into a listener
you should write a method like java public static String getActualHostName(String givenHostname) { ... }
How can i take a colorized string and convert it to a nms IChatBaseComponent?
kick-message-op:
- "&e&l● &6&lIUMGUARD &e&l●"
- ""
- "&aMerhaba, salak griefer kardeşim. Senin böyle bir salaklık yapacağını tahmin ettiğimiz için böyle bir sistem geliştirdik."
- "&a&lHAA! &aSakın unutma Port Açığı gibi şeyler deneyeyim dersen onlar kapalı zaten sana iyi denemeler enayi. :D"
- ""
- "&3Bir kez yürünmüş bir yola düşenlerin sayısı çoktur, hedefe ulaşan az..."
- "&b- Friedrich Nietzsche"
- ""
- "&6Support: &edeniz@foudrestudios.com"
StringBuilder sb = new StringBuilder();
for(String kickmessage : getConfig().getStringList("kick-message-op")) {
kickmessage = kickmessage.replaceAll("&", "§");
sb.append(kickmessage);
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, sb.toString());
}
how can i make new line without \n
way too much whitespace
I tried taking the colorized string using the bungee chat, convert it to json and then convert the json to IChatBaseComponent using the Serializer subclass
why would you ever need an NMS component?
to change nms inv name before sending
Hi I was looking at making custom items and was following this video as a guide https://www.youtube.com/watch?v=5npPUMrYaYE
But for the event handler when it checks for the item meta, if the player has renamed the item in an anvil, won't that have changed the meta, so it wont work as expected?
?pdc may be your answer. You can add a tag to the item
Thanks ill look at that
hi can someone tell me how i can make 2d icon in inventory but 3d model in hand for item ( like spyglass is)?
BaseComponent[] component = TextComponent.fromLegacyText("&cRed text");
String json = ComponentSerializer.toString(component);
Component nmsComponent = CraftChatMessage.fromJSON(json);
Note, this is using Mojang mappings as of 1.19.3
For example "Component" is the proper name of IChatBaseComponent
oh no
Yeah I'm doing that
I'm even sending the BaseComponent[] to myself and its working
wait i see the problem 💀
for(Class<?> clazz : new Reflections(plugin.getClass().getPackage() + "listener").getSubTypesOf(CakeListener.class)) {
try {
CakeListener<T> listener = (CakeListener<T>) clazz.getConstructor(JavaPlugin.class).newInstance();
Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
} catch (Exception exception) {
Logger.error("Failed to load listener from " + plugin.getClass().getPackage());
}
}
}```
why am i getting NoClassDefFoundError(second line)?
when calling newinstance you gotta pass plugin
like Constructor#newInstance(plugin)
where's the problem if it's working?
none of the formatting is applied to the inventory
it only works in chat
i'm still getting that error
can you tell us which line gives the error?
not first or second
paste the line itself
shouldn't you have a . before "listener"?
dont create a new Reflections object every time
or paste all the code and the stacktrace
still second
this one for(Class<?> clazz : new Reflections(plugin.getClass().getPackage() + "listener").getSubTypesOf(CakeListener.class)) {
What are you doing?
library for my plugins
from the i code i can assume that he is trying to register all listeners in the listener package via reflection
i'm still getting that error
Oh right
for(Class<?> clazz : new Reflections(plugin.getClass().getPackage().getName() + ".listener")
.getSubTypesOf(CakeListener.class)) {
try {
CakeListener<T> listener = (CakeListener<T>) clazz.getConstructor(JavaPlugin.class).newInstance(plugin);
Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
} catch (Exception exception) {
Logger.error("Failed to load listener from " + plugin.getClass().getPackage());
}
}
}```
code now
could you send the full stacktrace?
?formatting
?paste
Why are You doing that tho
stacktrace?
the entire error
Sorry for asking but hacen You learnt Java before coding? - It's a questions don't get mád
not just one line
yes
Lol really weird tho
ok
Because stractrace are the most basic thing You have
I mean when You ask for Helo most of the time ppl Will answer really theorical so should know the correct mames
and now i know thanks
do you shade Reflections library?
it might be the issue
(if you don't)
Are
if compilers are so good at finding errors in my code, why can't they fix them for me? who cares if i forgot a semicolon, put it in for me.
Would registering listeners like that cause issue? Because what about if tour listeners contains params on the constructor?
shade library?
i personally do similar thing and instead of constructor i inject it in field
Eclipse ppl be like:
do you use maven or gradle?
maven
How? Static 🤢
you need to shade reflections library'
no
ok but how?
How so?
setting private non-static field via reflection on instantiation
how to shade library
From what i know di is based on passing isntances thru constructors
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.10.2</version>
</dependency>```
no neccesseraly through constructor
How would that knkectil. Works
Can i seeM
I'm really mád with this Shity Word cellñhone it change eceythung i type ok English
yeah you add it as dependency, but it won't be present at runtime, you need to shade it via https://maven.apache.org/plugins/maven-shade-plugin/
I'm not wondering to be maf but i woudltn code without learning how depdencies nor stractrace works and most other things
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>```
i have sth like this
yeah, does it work or not?
no
fuck

pom.xml was always the same
can you please send full error?
but how do you use fileds to register events?
should probably assume the user wants to insert the whole word
wdym?
When i created a namespaced key, how should i name it, is there a convention/ a way it should be named or can it just be anything
lower_snake_case
but for the actual name of the key
no, i said i was passing plugin directly to field instead of constructor
like variable name?
okay then
thats all ty
wait I mean, could i just call it 'key' or is there anything i would want to call it in particular
wha
?paste your code
you could be more specific by adding the key's actual name in camcel case (like eampleKey for "example") if it is in global scope (like field or constant) but otherwise key is fine
jdks in da home folder?! madman....
bruh moment when doing maths with chars
?
i keep mine in Program Files 🙄
Why do you mix the channel with yours math things while someone is trying yo get helped?
i keep mine whereever the package manager installs them
Mmmm cuz math is programming
scoop install java/openjdk 💪
a lil bloat innit?
so?
Ik but it's fuck a Lot when someone wants help because u get eceythung mixxed
Sorry Im not explaining very well. There is an example of creating a namespaced key on a Spigot resource and I have attached an image. I want to know what i should put in place of "our-custom-key"
which contrary to what i just said about installing JDK to home folder, will install the JDK to the home folder
Use threads then
Lol what happen to you i2k
dont you like fuck?
the name of your key
i dont fuck :(
Can that be anything or should it be anything in particular?
it can be whatever you like
if you want to store a name, use "name"
if you want to store the age of a user, use "age"
it's like a variable name that this key represents
okay thanks
talking to verano
well you may only use lowercase letters, numbers and _
Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.
NamespacedKey are just a key-value for entities, You just put a name and assign a value to it
no, the keys are, as the name suggest, the key
and what does it have to do with entities?
literally only thing copilot is good for is to write good javadocs
a NamespacedKey is simply a "namespace:key" thingy.
"minecraft:unbreaking"
"myplugin:username"
"minecraft:sound/music_disc/stal"
how is a world an entity
it's just a string that has a namespace, left of the :, and a name, right of the :
and the namespace is used so that different plugins / data packs don't get naming conflicts when both use the same name
some sort of cosmic being?
ohh so should i name it "pluginname:name_of_key"?
the NamespacedKey.toString will be "pluginname:name_of_key" if you do it like this:
NamespacedKey myKey = new NamespacedKey(myPlugin, "name_of_key");
neither worlds nor items are entities
Wait i thoguth he was talking about PDC, NamespacedKey are for recipies
in minestom a world is an Instance :kekw:
NamespacedKeys are used for many things
these are all entities, and nothing else
So if i were to make several custom swords, I could set the namespaced key to 'sword_type', and then the persistent data value would be a value corresponding to which sword it is
exactly
okay tyy
another custom items plugin? \👀
I think you áre not talking about the same context for entities
private final NamespacedKey swordTypeKey = new NamespacedKey(myplugin, "sword_type");
public ItemStack getCoalSword() {
ItemStack item = ...;
ItemMeta meta = item.getItemMeta();
meta.getPersistentDataContainer().set(swordTypeKey, PersistentDataType.STRING, "coal");
...
like this @grim oak
Oh the problem Is that i treat entities as api related. Like discord treat User, Guild, etc as entities
awesome, thanks!
if you ever need to store arrays, lists, maps or custom objects in a PDC, check out MorePersistentDataTypes: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
ill keep that in mind. thanks again!
what am i supposed to do here? https://github.com/sVoxelDev/spigot-plugin-template#quickstart-setup
"Then execute the Server run configuration and the template will run the Spigot BuildTools to download and build spigot or paper for you."
i am using intellij as my IDE
@tender shard turns out 1.8-1.13 uses ChatComponentText for inventories
which is basically strings with chatcolor chars
huh wrong ping?
nah
then no idea what you're talking about
?paste
when 2 foreach and when 2 for loop or theres no difference
and which one faster
What IDE are you using?
probably no noticeable difference
it's the same except that in foreach you cannot see the index
im guessing foreach lets you do oneliners
Let say i have the next code for working with mongo
class StorageManager {
void open();
void close();
CompletableFuture<Model> find(UUID uuid);
}
Why would server get blocked until the future is completed?
so does fori
rly?
let's see the implementation
for(int i = 0; i < myArr.length; i++) { Object o = myArr[i];
// do stuff
lol
you can always put everything into one line
anyone can tell me whats wrong here? its not sending data
I really don't remember talking about changing EnderChest's titles in 1.13 or below lol
dont use your own channel
you gotta use the bungee channel
how do i disable every player appearing on the player list?
unless you create a bungee plugin which registers your custom channel and forwards the data
umm
User user = storage.find(uuid).get();
cuz your're calling get();
get blocks the thread till the result is returned
use the whenComplete methods
how do i hide everyones names
is there any docs about creating custom channel on bungee?
But why thread is blocked ir Async doesnt work like that
i love it when people think "futures are so great, it will never lag" and then they ALWAYS call get()
a future does things in the background, so to say. However when you call get, they do it now
???
i did a good job
dw
Not sure but do you mind creating a bungee and spigot plugin? If you do mind then dont use custom channels
- "&6&l----------"
- "&6Welcome To..."
- "&6we don't have a name yet lol"
footer:
- ""
- "&6no players for you :)"
- "&6&l----------"``` this is what i have and players still appear
Intellij
Ok, but i read that Completable Future has a thread pool, so why the heck si blocked? Does it make sense?
okay, what is the format of bungeecord channel?
Calling get() forces the thread to wait for the future to complete
just dont call get
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Doesnt make sense if the Completable future has his own thread pool, the thread can't be blocked. Because he is ezecuting the future on a diff thread
🤔
Yes but when you call get()
it tells the thread you called get from
to wait
their docs are extremely detailled
it's so detailled, even with 2560x1440 you cannot even see the first method without scrolling
to accept the result async
I read the get and just said that get method Will block the thread, but if You read before that they use a thread pool, then it cannot be blocked it's like really 🤡
wondering what i was doing
Well, do you expect whole internal logic of future to be written in docs
but if you tell your current thread to wait till the result is ready(by calling get()) your main thread will wait
Yeah but Docs don't tell that
💀
Just tell that Will block the thread
It's not specific
Isnt it logic?
yes it does
google it
it says it waits
if necessary
No, because if they first.told that they use a thread pool, they telling indirectly that i will never block Main thread
I mean how else would you expect it to even work
should it just get your data out of nowhere RIGHT NOW without waiting?
through magic
would be nice if that'd work
no?
what does the one thing have to do with the other?
While doing io operation, that thread is already tehnically blocked, so only thing that can be blocked is the one get is being called from
Oh lmao Java Async is definitly so shity
lmfao dude
It's really not
I would love to have C# Async just a keyword and no messe with blocks nor nothing
fun thing to use an async keyword if you dont know what it does
Why would i care? If it works
Doesnt make senses
im not laughing
.
fun thing about designing a database library is that you don't have to care about speed :)
Yes ofc i would talk without doing it
And you say that only if you write async keyword, function will be async?
is there smth like
async {
Console.WriteLine("this got executed async");
}```
kotlin looks already cursed enough
but it has some interesting features that java needs
Take as example Javascript too, really well and proper designed Async system
That is not answer to my question
what even was the question
.
Bro you can't ever expect an async value to return sync
heeheehee
Ik that, so they Docs are wromgly
now steal the site
Gotta remove that rn
how are the docs wrong?
without blocking
isnt () => console.log blablabla valid here too?
the current thread must always wait for the other thread to finish up
Yap, totally
So how does the spigot Schedule system works without blocking nor using Completable Future
You don't have to block to use async 💀
You just can't return a value
Tf that is cursed af
here you go with the new pfp
Why? That is My end question
cuz that value is computed async and the sync code doesnt wait on the async code to return
thats where completable futures come in
From i what know threads queue each process, then execute it, wait for result and finally return it
🤔
If I go to make you coffie, while you are programming, can you take coffe before I'm finished, or you have to stop programming and go to kichen to take it?
ask your gf
oh right..
🤡
You don't ever get a value returned from a scheduled task
You schedule a task async
Beat me to it lol. I was just about to reply to that
Scheduler doesn't return a value
When you get your result, you schedule a sync task
You can use the scheduler to process something asynchronously and return a value, but you'd need to create and return a CompletableFuture
this feels like the same conversation i had two years ago
wait the whole jvm uses the same common pool for cfs right?
unless you pass in an executor
I believe so, yes
Yeah that is okay, but is not how async works over threads. Because the result is computed Async and returned the value. So when you get the value is already sync, because the future ended
hmm i was just thinking about optimisations but whatever
imagine geol joining this conversation now, he would freak out
i am making you coffie async while you are programming
So, I need to delete a world, however spigot doesn't let me if there are players, I figured that sending players to the hub using bungeecord works, just to make sure, does Player#sendPluginMessage have some sort of block or do I have to wait until the world is empty?
if you want to go and get coffie, you would have to stop programming
CompletableFuture.supplyAsync((Supplier<String>) () -> {
//return something here
}).thenAccept(s -> Bukkit.getScheduler().runTask(plugin, (Runnable) () -> {
//use string sync here
}))
if you want me to get you coffie when im done, you use something called callback
No, because you (Async) bring me the coffe to my current thread
🤔
?
give the thread some coffee
You have a slow task to do like getting something frm a db
You dont want to wait so you want to get it on another thread
No no i mean i must understand Async un Java because in future i Will make Big projects
Which Will need Async
You do CompletableFuture.supplyAsync(() -> { return "DB Value here"; })
that will get the db value async
you understand this much?
Yes that i understand
Yeah this i know
if you have code after the compleablefuture
maybe something like 1+1;
that code will continue executing on your main thread while the completable future is working on your db
but what's the point in getting something frm the db if you cant do anything with it?
That's why compleablefuture has methods like thenAccept
which allows you to do something with the result from the compleablefuture
Ok
where did my boo go to
Just don't understand the diff between returning the value itself and future itself, if both of them You have the value
Both dont have the value
i probably have to add a hook to it
damn
Okay def won't touch the project until i Start unicersity, we're we have OS Arch and programming
@sterile token wanna see a simple version of what compleablefuture looks like interannly?
look at this class
it's similar to a compleablefuture
i also made it before i knew compleablefuture wasa thing
Someone of them use Executors, others Threads, others Completable future, and a few CompletableFuture with an executor
did you look at the class i sent?
aha thats your plugin
Yes
i looked through that whole plugin back in the days
Right so a Callback is kinda like a promise
so is a compleablefuture
lmfao
Oh right i understand promises
ok so basically
Cuz of Ts
when you get something using a compleablfuture its like saying im gonna get this and i'll get it to you in the future
so when you do CompleableFuture.supplyAsync(), a new CompleableFuture is returned to you
the supplier is then run on a separate thread
and when the result is gotten on the thread, compleablefuture.complete(result) is called
Promises takes an I/O operation, queue each thread, compute each thread and return the result
it returns a new CompletableFuture object and in the meantime it starts executing the code you gave it and when its finished it places it in the future and runs thenAccept, thenRun hooks etc
once made my own cf
it was a piece of shit tho
does anyone know how to setup pterodactyl?
i do
Also really sorry for how i refer to You all, i was a bit stressed because i want able to understand how it works
its not that hard if you know what are you doing, if you need any help feel free to hmu
#1 int rightArmX = plugin.getConfig().getInt("rightArm", 1); int rightArmY = plugin.getConfig().getInt("rightArm", 2); int rightArmZ = plugin.getConfig().getInt("rightArm", 3);
#2 List<Integer> rightArm = plugin.getConfig().getIntegerList("rightArm"); int rightArmX = rightArm.get(1); int rightArmY = rightArm.get(2); int rightArmZ = rightArm.get(3);
I'm trying to get the config values for "rightArm" which are integer values I've tried these metods above and they don't work? the #2 gives an error when run but shows nothing in my parser.
The config:
x: 270
y: 0
z: 0```
thats not a list
bump (intellij is my IDE)
You should use config section
i have to be honest but the spigot wiki about config files absolutely sucks
Yeah
The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...
ok thanks
Not even try to use bungee one
That it's completly fucking stressin to read
lol
Yeah because you can't extends the config
Like You do on bukkit with YamlConfiguration
plugin.getConfig().getIntegerList("rightArm").get(1);
something like this would work right
Use a section
Yeah
so stringList?
an int list would be ```yml
path:
- 1
- 2```
or
path: [1, 2]```
you need the child node of rightArm
Should I use the IntelliJ Build Artifacts Option or should I compile with marven, or is that the same?
Use maven
alright thanks a lot 😄
Is there a reason?
This are list
MyList: [1, 2, 3]
MyList:
- 1
- 2
- 3
If it's a maven project you use maven to compile. It's really that simple
I think he havent learnt correctly maven
If it isn't a maven project you're free to use artifacts
but I would still recommend maven or gradle as it makes managing dependencies easier
If not a gradle nor maven project, You must artifact
mf read the chat
people are blind
Lmao stop laugthing at me
Well i dont care it's simple if someone fuck i just ignore that ppl
whos pol?
Yes, but if I wanted to create a spigot plugin I had to use either Maven or Gradle, I couldn't use nothing
No?
But thank you :D
Before i learnt maven i used to compile with Ant
Scoreboard#getTeams()#forEach(Team::unregister); should work right?
How to remove an offline player from an ArrayList
Lol another one
?
list.remove(player)
OFFLINE Player
What happen to you werent like that
so you can pass in a player or offline player
do you want to filter your list and remove all offline players ?
though you should store UUIDs and call Bukkit.getOfflinePlayer(UUID) or Bukkit.getPlayer(UUID)
I want to remove a certain player from the list when he is offline
Look, if i want to create a spigot plugin i need to select either maven or gradle, i dont have the option to use nothing
https://i.postimg.cc/gcXWY6Qf/image.png
Yeah
I'm pretty okay, just a bit upset because i don't understand Async on Java
then just get player for event or whatever, and do as ikevoodoo told you
You can't not use it
that is if you use plugin for intellij
you shouldn't use just java or intellij to compile anything
a build tool is way better
^
Yeah that si true, i just told that as an example
oh okay thank you so much guys
im like so stuck on this 😭😭, 0 clue
how does this look qua code design? https://paste.md-5.net/etowelewoj.java
When you've setup the project run the Server configuration. You can find it on the top right
If I iterate over a scoreboard's teams and call unregister on each team, does that cause a CME?
Sounds like a try it and see moment
does that annotation do anything
Hi, how do i get the Vanilla Chunk Generator, or the code of the vanilla ChunkGenerator?
lets just use di
ok got rid of that NodeFunction and made it a Function<IntPredicate, Node>
does anybody know why NMS world doesn't change for a server player after a world switch
what
?permissions
Syntax: ?permissions
canrun Check if a user can run a command.
explain Explain how permissions works.
This cog extends the default permission model of the bot. By default, many commands are restricted based on what the command can do.
This cog allows you to refine some of those restrictions. You can allow wider or narrower access to most commands using it. You cannot, however, change the restrictions on owner-only commands.
When additional rules are set using this cog, those rules will be checked prior to checking for the default restrictions of the command.
Global rules (set by the owner) are checked first, then rules set for servers. If multiple global or server rules apply to the case, the order they are checked in is:
- Rules about a user.
- Rules about the voice channel a user is in.
- Rules about the text channel a command was issued in.
- Rules about a role the user has (The highest role they have with a rule will be used).
- Rules about the server a user is in (Global rules only).
For more details, please read the official documentation.
okey did not help....
okay so hello sharks i have a question i have been trying to work with permissions but it no work
public void onPlayerFish(PlayerFishEvent event) {
if (event.getState() != PlayerFishEvent.State.CAUGHT_FISH) {
return;
}
Player player = event.getPlayer();
if (!player.hasPermission("Fishing.Fish")) {
System.out.println("no bitches");
return;
}
String region = RegionManaging.getRegion(player).iterator().next().getId();
FishingRegions fishingRegion = FishingRegionManager.getFishingRegion(region);
if(fishingRegion.getStatus() == FishingStatus.NO){
event.setCancelled(true);
return;
}
if(fishingRegion.getStatus() == FishingStatus.OFF){
return;
}
event.setCancelled(true);
FishHook hook = event.getHook();
FishingItems randomItem = fishingRegion.GetRandomItem();
ItemStack rItem = randomItem.getItem().clone();
rItem.setAmount(randomItem.getRandomAmount());
Entity droppedI = player.getWorld().dropItem(hook.getLocation(), rItem);
player.giveExp(Math.round(randomItem.getRandomxp()));
hook.setHookedEntity(droppedI);
hook.pullHookedEntity();
hook.remove();
}
as you can see here it should cancel if player does not have permissions
but it does not. cus i dont have permissions and it still lets continue's on the code and gives me a random item
what does this error mean:
@Override is not allowed when implementing interface method
No clue because that's blatantly false given no context
What's your code look like?
oh sry i forgot 😅
package com.koner.konerutils.nickname;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class NicknameCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
String nickname = args[0] != "default" || args[0] == "" ? args[0] : player.getName();
player.setDisplayName(nickname);
player.setCustomName(nickname);
player.setPlayerListName(nickname);
player.sendMessage("Display Name: " + player.getDisplayName() + " Name: " + player.getName() + " Custom Name: " + player.getCustomName() + " PlayerListName: " + player.getPlayerListName());
return true;
}
}
and it underlines the @override
yellow or red?
Either way it shouldn't be underlining lol. That's correct
red
Only thought would be that you're compiling against Java 5 or something
Are you using Maven? Because J5 is the default
yes
dou you mean that <java.version>19</java.version>
Yeah, though that does nothing unless you use that property elsewhere
If your Maven is using Java 19, then make sure your project is also set to use language level 19
choco could you also help me with a problem im having?😅
yes it is selected
how can i change the maven java version in the maven-jar-plugin?
cause <source> und <target> is not working
what is your source and target now?
array[char] being a thing smh
uh?
i dont have source and target because it underlines that lol
my pom.xml: https://paste.md-5.net/gujehofufa.xml
where do i need to add the source and target?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<outputDirectory>C:/Koner/projects/minecraft/konercraft/plugins</outputDirectory>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
^ Yeah, you're missing the thing that actually uses those properties
do you need to install minecraft development plugin in intellij for it to work
(though remove the outputDirectory from that example above. Rest is fine)
No, you can write plugins without it. It does greatly simplify things though
Note it's unofficial however
could someone pls help me with this?
uhm outputDirectory can stay as it was in his pom.xml anyways its up to konor
Oh, sorry, thought that was yours lol
nope i copied konor's pom.xml from pastebin XD
what happens if a server has 2 of the same plugin jar but different versions?
iirc it's just whichever one is loaded first
Depending on your OS, file system, and other factors, that will vary from server to server
Can I change the default world chunk generator without changing bukkit.yml, like to run from first-setup without touching anything?
oh okay, cause im naming my jars with its corresponding versions and I'm worried some people might just put the new jar in the plugins folder and forget to delete the previous. and this way miss out on the new update features and then be mad 😂
😢
how does 'C' match c -> c >= 'a' && c <= 'z'
its an IntPredicate so maybe it does some weird internal conversion from char to int
does this make sense to any one?
x == 3
A capital 'C' will not match this predicate
Even in an int predicate because chars are literally just ints
🤔 is there a way to call out an event?
im doing a breakNaturally(tool) on a list of blocks but unfortunately this doesn't drop any experience. so i was thinking to try to "call" an event like new BlockExpEvent(block, experience).
is anythign like this possible?
Bukkit.getPluginManager().callEvent(Event)
my logic is broken then
Yes
please do me a favour and change that background
No
i guess people get used to it
alright
will test, ty
nope, not working
no error
what not working?
it's not dropping any exp
i guess i will remove the block the player actually breaks from the list of blocks to break with code and then sum up the experience of all the blocks that will be broken into this main block's experience dropped since this has a setExpToDrop function
🤔
ig just calling it doesnt drop xp
idk
doesnt block::breakNaturally already fire a blockbreak event?
no
Something is completely wrong with my server, and I can feel it. Command Suggestion Blocking might have killed the tab completion feature of my lobby server, with me not knowing how to fix that. 🤣
Also I love how only certain commands are available even tho I do have the perms for them lol
I have been using this PlayerCommandSendEvent
they are automatically implemented in the command list
im kinda wondering what happens when you call ::toLowerCase on things other than letters
seems to return the same thing for number
@EventHandler
public void onSuggest(PlayerCommandSendEvent e) {
List<String> ownerCommands = new ArrayList<String>();
List<String> managerCommands = new ArrayList<String>();
ownerCommands.add("restart");
ownerCommands.add("stop");
managerCommands.add("luckperms");
managerCommands.add("lp");
if (e.getPlayer().hasPermission("rank.owner")) {
e.getCommands().addAll(ownerCommands);
e.getCommands().addAll(managerCommands);
Bukkit.getConsoleSender().sendMessage("§aOwner");
} else if (e.getPlayer().hasPermission("rank.manager")) {
e.getCommands().addAll(managerCommands);
Bukkit.getConsoleSender().sendMessage("§aManager");
}
}
This entire code sucks. Not just it, but the feature itself.
wheres the Arrays.asList
- oh and btw even without this code all my commands... are just gone xd -
is this some kind of sick trick question
why does the ascii code matter lmaoo
or will it print the ascii number in that case? lol
should work ig
Won't that give an error?
Nah it won't
Not letting the plugin use this code seems to unwork. I love this shitty enginereed feature.
what about ABac
Like the value
the answer
left is a string and every string += gets added to it
so then ABac yea?
this cant be compiled
System.out.println("AB" + ('a' - 'c')); is the correct syntax which wuld give "AB-2"
so it was a trick question then lol wow
If you put them in brackets
everything works fine, then it sees the C and it fails to detect it lol
System.out.println("AB" + ('a' + 'c'));
AB196
yeah, just like
Assume that horses can fly. How long will a pig take to reach the sky?
interesting
Using
@EventHandler
public void onSuggest(PlayerCommandSendEvent e) {
e.getCommands().remove("settings");
}
removes the /settings command. How can I readd ALL the commands to remove the commands I want to "hide"?
not even sure if theres specific bytecode to work with chars
like there isnt bytecode for booleans either
just uses a byte
You just wouldn't remove it
The commands list can't be added to. It will always contain all the commands on the server (given no other plugin is modifying it)
If you want to show the player all the commands again as though you never removed them, you can call Player#updateCommands() which should re-send them to the client
lol it works here and in my impl it doesnt :/
This is weird in one or more ways. Suggestion blocking is done using PlayerCommandSendEvent, isn't it?
what isnt working?
Yeah that looks like it's working. You're doing assertTrue() but the condition is false
Therefore, error
mk well your test you just sent there is correctly throwing an error
Doesn't seems to readd them. 🤔
where's your code that isnt working?
I mean as long as you're aware that the PlayerCommandSendEvent is called when you call that method
In what type of storage is "removed" or "hidden" commands are stored in?
So if you have some command removal in that event, yeah, it's going to remove it still
The actual thing I want to make, is that if you for example have a admin rank, you should be able to see /ban, /mute, etc, but without an admin, you should not.
I've tried a plugin for that, but it didn't work so I am making a custom one . xd
But even tho using player.updateCommands(), commands are still not shown.
just use permissions?
uhh thats it basically
Only certain ones.
Yes I could, and I would, but not all plugins does that, and thus, I can't or don't want to support it.
which calls putChildIfAbsent which calls checkChar and assures c -> c >= 'a' && c <= 'z' matches wih 'C'
Lemme see checkChar and putChildIfAbsent
once I gain OP I will see all commands. wtf is going on
UpdatE: doesn't shows anything anymore XD
im probbaly doing smth stupid
Welcome to the beauty of programming
500IQ, negate the predicate and don't ask questions
Question. I'm trying to follow this tutorial to learn how to do NPC's and such. I can't find the updated version of PlayerInteractManager for NMS. Can anyone help me? https://www.spigotmc.org/threads/how-to-create-and-modify-npcs.400753/
its probably true but how
Aight I realised I fucked my server
poor server
Like... How tf did I made /lp be unknown to players but /gm not?
myes
Time to reset every fucking possible file
hmm thats probably root node fucking up
oh nevermind I all did shittly was another plugin blocking shit 🤣
its like playin around
FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUCK
how long does the spigotmc api takes to update a plugin's version? I'm using it to check if the server is using the latest version.
just for curiosity
I think it updates every 6 hours, though that's based on rough information I vaguely recall from a couple years ago
just noticed it's not automatic so was asking just for curiosity