#help-development
1 messages ยท Page 1400 of 1
just a little flex
And you can expand on that plugin for learning json messages to scroll through your history.
And writing it first without a persitence layer and later adding flatfile and then database support...
Ah yeah you could hook up clickable components to /damagehistory <page>
What does this do when I try to implement listener it sometimes adds this aswell @Override public @NotNull Logger getSLF4JLogger() { return super.getSLF4JLogger(); }
you probably clicked something or told your ide to override a method
which it then did
o well
huh... ok this is going to sound stupid but how can I uh save smth on the player
sry im new
like store a value on a player
get the player's PersistentDataContainer
like a varuable
Probably the wrong listener
if you don't care about the data poofing when the server restarts
create a Map<UUID, yourdata>
and then hold that in your main plugin instance of whatever
if you want to save something simple, like a single String, make it Map<UUID, String>
but if you want to store lots of stuff
nah I need to save it
like first join date and other things
then create a class that holds each of those things
and make it Map<UUID, that class>
I just need to store 1 thing
hi
for the damage history
if you want to persist it, use the persistent data container
how i can use event uhc
Player implements PersistentDataHolder
PersistentDataHolder declares a method getPersistentDataContainer
?
for large amounts of data you'd probably want to look into a db but that's probably excessive by this point
^
how i get customitems
what custom items ?
/give me customitems
lol
can someone call me pls ๐
Storing damage history does seem like a bit much for pdc
in discord
๐
It would fit well into sql, but json is another option
bukkit config api is the obvious choice
can y
Is there a better method for loading a datapack from a plugin jar than copying it to the world's datapack folder?
i haven't really screwed with datapacks, but tbh, probably not
i don't think bukkit really acknowledges the existence of datapacks quite yet
can someone pls pm me ๐ฃ
I guess a method to register tags at runtime would also work
that sounds like something that might exist, but I haven't really looked into it at all
Ya I noticed it while looking for solutions
So yeah, copying it and reloading data packs is probably the best option
how to use spingot 1.14
lmao
??
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
and also the wrong channel
I guess my next question than is, is there any not painful way to copy a directory from a plugin jar to the world folder =[
Hey, I am using Packets / nms, and I've heard that using :
```<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>```
Is so much better than using :
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>```
But when trying to use the spigot one it doesn't find it
Pretty sure mc can load zipped datapacks
there is extract all resources, but that will extract all resources
Ya...
and yeah, the server can handle zips
Which I imagine you can copy quickly with plugin.getResource
Oh well ok that helps
What's the โ
So I'll just zip it on compile and than extract that
You can't use the api for nms either way
sounds about right
I know
You need to use spigot over spigot-API for NMS,
To use spigot you need to run buildtools for that version
real men just reflect into everything
only reason to even depend on spigot-api is that you can't reflectively extend a class
I've ran buildtools, do I need to add the spigot jar that it generats to the libraries?
No
What then
It should be in your local maven repo
I don't think it is
you can always just path into .m2 manually and check if it's there
Ya thats also a good idea
Restarted, but still the
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project> ``` Doesn't work with the error : Dependency 'org.spigotmc1.12.2-R0.1-SNAPSHOT' not found (line 70)
Line 70 is the :
<artifactId>spigot</artifactId> btw
I assume you ran buildtools for 1.12
I am running build tools for 1.12.1
Well there's your issue
i've sometimes had an issue with ij where I had to manually declare the local maven repo as a local repository
which was weird as fuck
You're trying to use 1.12.2 but you've built 1.12.1
Wait it works..
Yes
Literally works, but I've ran another buildtools for 1.11.2, When I try to use : <version>1.11.2-R0.1-SNAPSHOT</version> it doesn't work, basically doesn't find the version
I've added a 1.11.2 jar to the libraries, while the version in pom is 1.12.1, will it still work in 1.11.2?
if you use your ide's libraries, maven can't build it properly
because your ide is not maven and maven is not your ide
I am using Intellij
yes
if you use your ide's dependency management, that is, import libraries with your ide, you need to build it with your ide
if you use maven for depencency management, that is, import libraries via pom, you need to build it with maven
intellij has a fancy button to build it with maven
but if you add a library with your ide, maven won't know about it, and can't then build the project
I am adding libraries from : Project Structure > Libraries and then I add the jar
yes, that is adding libraries through the IDE
maven does not know about those libraries
it can't build your project
How do I add it via pom?
you add the dependency information to your pom
as you would with any other dependency
NNY do you know any easy way to get the particlepackets
the what
why do you need packets
since like for sum reason doin other stuff does not generate particle pacekts
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>``` This is how do you import the libararie via pom?
you can spawn particles through the api
yes but I need to remove the particles
yes, that is how you add a dependency to your maven project
not all particles are server-side
the client spawns some of the particles on its own
same with sounds
you shouldn't need the repository here, since it should be in your local maven repository
check whether it is there; open up your .m2
Yes but, There's only 1.12.1, and If I do <version>1.11.2-R0.1-SNAPSHOT</version> It doesn't find it
then you need to build 1.11.2-R0.1 shapshot blah blah
you can't depend on something you don't have
String[] sword = { "DIAMOND_SWORD", "IRON_SWORD", "GOLDEN_SWORD", "STONE_SWORD", "WOODEN_SWORD"
+ "DIAMOND_PICKAXE", "IRON_PICKAXE", "GOLDEN_PICKAXE", "STONE_PICKAXE", "WOODEN_PICKAXE"
+ "DIAMOND_AXE", "IRON_AXE", "GOLDEN_AXE", "STONE_AXE", "WOODEN_AXE", "DIAMOND_SHOVEL"
+ "IRON_SHOVEL", "GOLDEN_SHOVEL", "STONE_SHOVEL", "WOODEN_SHOVEL", "DIAMOND_HOE"
+ "IRON_HOE", "GOLDEN_HOE", "STONE_HOE", "WOODEN_HOE", "BOW", "FISHING_ROD", "BLAZE_ROD"
+ "STICK", "BONE"};
for (String string : sword) {
LootManager.items.add(string);
}```
NNY
Build 1.11.2 snapshot?
LootManager.items is a Set, yes?
public static Set<String> items = new HashSet<>();
if you want to depend on 1.11.2-R0.1-SNAPSHOT, then you need to build 1.11.2-R0.1-SNAPSHOT
if you want to depend on 1.12.1, you need to build 1.12.1
I would like to use at least the end of SWORD to not have to define each type of item
How do I build the snapshot?
What do you use
You use the :
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>``` right?
you can iterate over all Materials and check name().contains("_SWORD") if you want all swords
or you can use one of the material tags
that is how you add paper API of version 1.12.2-R0.1-SNAPSHOT as a dependency, yes
Yes, that's what I use too, but with paper you can't use packets / nms right?
for nms and packets and shit, you want paper instead of paper-api for 1.12.2-R0.1-SNAPSHOT
and the only way to get paper instead of paper-api is to build paper locally
read their github readme, clone the repo, and run the build script
same principle as with spigot, but instead of buildtools, there's a build script
What's the difference between coding in paper or spigot?
paper is better
its working xd
I code in paper too
paper contains everything spigot contains, but has more utility methods and stuff that makes your life easier
But when trying to build the project while using packets, It gives me errors and doesn't build
yes, that is because you haven't imported paper
my view of the paper and that it has methods that spigot doesnโt have
you've imported paper-api
Yeah I use paper-api
which does not contain NMS or packets
#Block.getHitBlockFace();
#OnCollideEvent etc
Yes but, when I build artifacts the plugin works good
Only build against a fork if you NEED some method from that fork.
but is there a way to make a projectile not collide with another one in the spigot?
server owners who want your plugin to perform well will probably disagree with the concept of 'NEED' though
Build against Spigot and it runs on everything
Yes but, how do you use paper instead of paper-api?
Oh
and then change the paper-api text in your pom.xml to paper
Just like BuildTools?
Yeah but how do I build paper locally
Where do I find the readme
on the fucking github
Ok that's enough acting dumb XD
you'll have to select a 1.12 branch of the github repo
assuming they even have one
is there something wrong here?
(Main.get().getConfig().get("tiers." + currentTier + ".items." + (itemCount + 1))) == null
depends on your definition of wrong
yes
is arraylist's setting reference implementation atomic?
select the 1.12 branch
is the branch you want
anyone?
you build paper locally by checking out the repository and running ./paper jar in a bash environment
define "setting reference implementation"
i get an error like this
list.set(index, objectReference);
I don't find the readme..
it's the page you land on
the readme is the text you see on the "front page" of a repository
what do you mean by atomic in this context
there are no two actions happening concurrently
or two actions happening at all
you are just setting data
at some index in the underlying array
How can I give a mob an enchanted armor?
if you mean the retrieved value that set method returns, no, it's not atomic
nah like
mob.getEquipment().setItemInMainHand(new ItemStack(Material.DIAMOND_AXE)); this<
there is setHelmet ?
Do I need GitBash to build paper locally?
yes
yes
yes
uh
create an enchanted item stack
to make it enchanted
and pass it in there
So the code is :
./paper jar
in the gitbash right?
uh that was kinda my question on how to do it
google returns: https://bukkit.org/threads/add-enchantment-to-item-stack.163913/
how would I add an enchantment to an item stack? ive been trying to figure it out but cant here is what i haveItemStack stonesword = new...
public E set(int index, E element) {
Objects.checkIndex(index, size);
E oldValue = elementData(index);
elementData[index] = element;
return oldValue;
}
``` it seems setting data to array list index is atomic, since primitive arrays need synchronisation for multiple threads to see results properly, but their setting is atomic but i don't care for that, since i don't need to synchronise it in orderto work
am i right?
probably not
Well array index write according to my sources is atomic
I mean, is it guaranteed tho that the entire set call is executed at once ?
write is yes
i mean, there isn't anything to be atomic with
it's a single operation
I need Paper jar in a File and gitbash in that file?
that's what matters for me
im getting problems :
bad mafs
true that. yes your return value might maybe (don't think ever) get messed up with a concurrent write
but the write itself is fine
i don't use the returned value
eh
To build paper locally Is it just like BuildTools? Paper jar in a file and gitbash in that file?
well... ArrayLists can shuffle and shift elements
so if someone does like insert in the middle of this, the index you're writing to might be inaccurate
this possibility is impossible in my case
if no one can do that, why care if it is atomic xD
well no one can shift the array or extend it
but set index of it
its like primitive array
ah. well in that case you should be fine then
atomic is when multiple operations behave as if they were one operation; they can't be split and their execution order can't be changed, and they will either all fail, or all succeed
I don't get it
i was just asking if i do write arraylist with async runnables without sync wouldnt i get undefined results
you know how you run java -jar BuildTools.jar
Yes
in the folder you downloaded buildtools in
yes
instead of downloading a jar
you clone the paper repository
using git
clone the paper repository?
well, arrays aren't volatile
yes
How..
๐
so yes, you may get memory visibility issues if you are both reading and writing
I don't think so
and there is no guarantee that a write on thread A is visible on thread B
basically somewhere on your file system you run git clone https://github.com/PaperMC/Paper.git
well fuck then
what're you doing though
Wdym somewhere on my file system?
just. wherever you want the project to be located
i guess i would need to synchronise the writes with the main thread
It's not like download paper jar and place it in a file then run the code : ./paper jar right?
no
no, do not download paper jar
there is no "build tools jar" for paper
Yes sadly
just download paperclip
I didn't do, but what then
And how do I do that
he needs the nms install into the repo
paperclip doesn't work
step 1
basically somewhere on your file system you run git clone https://github.com/PaperMC/Paper.git
but, but I literally send you the command
well i do it differently
this clones the repository
๐ญ
then, you run ./paper jar
i import the build to the maven
Somewhere on the files?
I need to gitbash somewhere in the files?
you store the server build in a maven repo?
in my local one, yes
and then you run the paper jar command in gitbash
Oh
it's not rocket science
and how did you get it there ?
via maven command?
and did you have to clone paper for that ?
maven:install-file
ik
lol
im just lazy
that file contains the patch
Cloning into 'Paper'...
remote: Enumerating objects: 71857, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 71857 (delta 5), reused 12 (delta 4), pack-reused 71839
Receiving objects: 100% (71857/71857), 31.92 MiB | 5.78 MiB/s, done.
Resolving deltas: 100% (62283/62283), done.
This is right?
๐
im lazy
lol
look how much time he spent just for importing it to the repo ๐
I mean, if you know any form of git this should not take that long
Then I must do ./paper jar right?
also since when is slowmode enabled o.O
you open the git bash inside the cloned Paper folder
and then yes, run ./paper jar
I need a Paper folder, inside it GitBash and then use the code : git clone https://github.com/PaperMC/Paper.git then use the code ./paper jar
Then done right?
You already cloned paper right ? You ran the git clone command
my aggression towards a 5 second slow mode is immeasurable
This is right?
Why is slowmode on? Tf happened
well no, git clone https://github.com/PaperMC/Paper.git creates the paper folder
So is yatopia
why does
//gets the material of the item
mat = Material.valueOf(Objects.requireNonNull(material).toUpperCase().replace(" ", "_"));
getServer().getConsoleSender().sendMessage(ChatColor.GOLD + "test3 material: " + material + "mat: " + mat + "items: " + items);
} catch (Exception e) {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "Fatal Error: Item Type Not Found");
}```
run, shows test3 with no errors but fatal error still prints? doesnt that work when theres an error?
If I already had a Paper folder and gitbash in it then run : ./paper jar
yes
What exactly are you trying to do
Yeah but looks like It doesn't work : bash: ./paper: No such file or directory
install paper into the local maven repo
Are you inside the Paper folder with your git bash ?
Yes
the file definitely exists ยฏ_(ใ)_/ยฏ
Which version are you using?
Olivo 1.12.1
Omg why
What
At least use 1.12.2
What's the problem If I use 1.12.1
Am trying to do it so I can use paper instead of paper-api
In the pom
Security issues
Having an armor stand "ride" the player and show a chest, would that require NMS or can spigot support that?
Use 1.12.2
Yeah
This is my pom :
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>```
you need to cd into the cloned directory before running ./paper jar, iirc
You can spawn the armorstand and use player.addPassenger
He does but on the other hand:
18:05] LynxPlay: Are you inside the Paper folder with your git bash ?
[18:05] Poreyy: Yes
owo
Change paper-api to paper
did you build it
No I didn't
I am already trying to build it
my man can't find the paper script
But It's kinda not working
What does it tell you when you try to build it
run ls and send the result lol
I basically made a Paper folder, right click gitbash then I ran : ./paper jar
And it says : bash: ./paper: No such file or directory
it is created through git clone https://github.com/PaperMC/Paper.git
I already tried that
and ?
Are you inside the folder that it generated
Generated a folder with some files in it
yes
are you inside this folder
and then you open the git bash inside of it
yes sir
mvn` command was not found in the path and is a required dependency
do you not have maven installed ?
Maven installed on my PC?
Doesn't look like you have maven
did you forget to read the thing I told you to read
no
To compile Paper, you need JDK 8, maven, and an internet connection.
does not have maven
I got jdk 8
maven is not a part of jdk 8
seems easy enough
I know
So do I need to install Maven now?
yes
Yes
Download it from the 'Link' section right?
Yeah
apache-maven-3.8.1-bin.zip?
Yes
are you able to do anything without several people instructing you for every single step
no i can't read
๐
Lol
can't wait for him to have to modify system path to include the mvn bin folder
kekw
Do I need to extract the zip folder?
Life is much easier while using Eclipse
There's no pom on eclipse
What
gsand
this is entertaining
ok
@mellow crest
Stop tagging random people
what
nothing
I don't want that anymore, I am okay with paper-api
F
lol
Thanks for help everyone
what help you neeed itv
What's the problem
@Override
public void perform(Player p, String[] args, HCFPlugin plugin){
Faction f = plugin.getData().getFaction(p);
if(f == null) {
p.sendMessage(ChatColor.RED + "You must be in a faction to use this command!");
return;
}
if(!f.getLeader().equals(p.getUniqueId())){
p.sendMessage(ChatColor.RED + "You must be the faction leader");
}
}
}
``` So i have like a lot of these classes and some of them do both of these checks, just one, or none what other ways could I shrink this down? I keep repeating this check in like 70% of my subcommands
you could have static methods in a class like Preconditions
MyPreconditions.hasFaction(plugin, player)
if you want you can also include the error message as a parameter so you don't need to send it manually
if (MyPreconditions.hasFaction(plugin,p, ChatColor.RED + "You must be in a faction to use this command!")) return;
ok thanks
if you want to shrink it down even more, you can create a class to hold your localized strings and give it that instead
if (MyPreconditions.hasFaction(plugin,p, Messages.MUST_HAVE_FACTION)) return;
if you want to shrink it down even more, you can make the preconditions class throw an exception that will be caught by the code that invokes your perform method, so you can drop the if and return
MyPreconditions.hasFaction(plugin,p,Messages.MUST_HAVE_FACTION)
if you want to shrink it down even more, you can make specific methods in your data retriever class to throw do it for you
@NotNull Faction f = plugin.getData().getFactionOrError(player);
i like that one
and the strings too are gonna be config. im just saving that for the last thing i do so i can just end up not doing it
lol
throwing exceptions willy nilly is kinda expensive but it should be fine for stuff that is as infrequent as commands are
How can I make armorstand always in the player's place when he walks? Tried with PlayerMoveEvent and teleportation, but then this armorstand is late for the player
so basically im setting the elements inside the list implementation which is crucial for NMS. This makes it thread unsafe right? It can be read anytime and it could lead to faulty server gameplay due to that the array elements are not threadsafe or the list implementation is not concurrent type.
the player will always see themselves moving before your server can react to it and move the armorstand
i should synchronise this with server main thread right?
the only way would be to mount the armorstand to ride the player, but that kind of fucks with teleportation
the list impl absolutely has to be arraylist?
you could always sneakily replace it with some class that extends arraylist ๐
or is that final
i don't rememer
well yeah
but i don't want to modify it
it could lead to bad consequences both for gameplay and for the plugins
I did it, and more precisely on the player is riding slime, and on slime is riding armorstand, only slime is in the place of the head and if you click the right mouse button, you cannot place blocks, etc., and if the left one is slime it dies, can i change this?
uh
do you need the riding player to be able to see the armorstand?
or is it for other players
you can hide the armorstand by intercepting and dropping its packets sent to that player if so
Couldn't you just send the EntityDestroy packet to that player
slime hitbox
i'm not sure what the client does with entity update packets and shit that are sent for a nonexistent entity
hmm, good point
it might just ignore them or it might shit itself
I remember doing it with snowballs in the past, that seemed to work fine
yeah, i haven't really fucked with entity related protocol at all
can i run buildtools to build a spigot jar without decompiling mc again?
paperclip reigns supreme
also you can cancel stack trace filling so exception throwing is a bit faster
fair point
to be honest, I don't quite understand how to use it (I'm a beginner)
How to change the Itemstack enchantment visibility?
declaration: package: org.bukkit.inventory, enum: ItemFlag
declaration: package: org.bukkit.inventory, enum: ItemFlag
does potioneffect implement hashcode
Check the source
@vagrant stratus nice constructor
Ye
anyways
constructors not needed, however it runs sooner โบ๏ธ
i just came up with that idea before inspecting your plugin
your plugin would still get dealt with, just by loading before it i believe
It'll probably still be easy to deal with, it just loads sooner :p
also im adding the option to run standalone too
incase you want to add it in a startup script
I wonder how easy it would be to abuse that ๐ค
public class ChatCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender.hasPermission("ducky.chat")) {
if (args[0] == "enable") {
UI.setChatDisableTrue();
sender.sendMessage("ยงaChat is now ยงcยงlEnabled.");
}
} else if (args[0] == "disable") {
UI.setChatDisableFalse();
sender.sendMessage("ยงChat is now ยงcยงlDisabled.");
}
return false;
}```
when I do /chat disable or /chat enable, nothing happens
.equals is ur friend
- Check to make sure you have the permission
- use .equals
You know what's amusing? Having a List you can just easily clear ๐
gonna be fun OwO
loadbefore: */s
I do that ๐คฃ
wait that works?
Nah, i do loadbefore: SpigotAV
however if there's a standalone option, I'm very certain i have ways to fuck around with that
I've done this since 2019, pretty sure i can think of some ideas ๐คฃ
replace spigot jar
just get every spigot plugin and add it to an array on plugin.yml's loadbefore
don't need to actually
who wants to be the first to point out the issue?
the username
thearcanebrony
https://gitlab.com/TheArcaneBrony/SpigotAV/-/blob/master/src/net/thearcanebrony/spigotav/HumanInterface.java and this gets the results
totally not the > "Debug.Log Debug Info"
it's asking for manipulation 
exactly
for some reason i really really hate the naming of the methods
it looks so fucking wrong
probably because it's not following conventions?
just check for net.thearcanebrony.spigotav.RuntimeStore, get the ScanResults list and empty that bitch every tick
abuse what?
oh lol
clear it constantly and their golden ๐
obfuscation 100
Just override the empty method
Depending on the obfuscation, they'll just report you :p
You think obfuscation has stopped anyone before?
report me to who?
Do you know what game we are working with
true
also... they could just update shit every update..
the cyber police
It'll be fun abusing the shit outta SpigotAV
or better yet, you know what you could do? Corrupt one of the SpigotAV's class files
I can find ideas
I've got a few hundred jars to work with if I'm gonna abuse an AV ๐
hey how can i make intellij idea to build artifacts and then upload the jar to the sftp?
Wait, is spigot AV an antivirus powered by a spigot server?
How to get the IP of a player (for a ban)
create a run configuration, dunno if it can actually upload files to a remote server though but it can run commands in a shell
https://gitlab.com/TheArcaneBrony/SpigotAV/-/tree/master
It's just a spigot plugin, however it'll go external at some point.... with how this dev is though... it's not gonna be that secure
Player#.getAddress().getHostName()
Gogle exist ! first page say Player#getAddress().getHostName()
thanks
ty
Perfect
does synchronised block work outside the codeblock itself, for example in one thread it locks the object using monitor inside synchronised block but in other thread the object was used inside another method?
1st thread:
public void bar() {
synchronized (#Object) {
#code
}
}
2nd in parallel:
public void foo() {
#code...
#Object is used...
}
can probably still find a way to abuse it โบ๏ธ
fine time to fill it with integrity checks
go ahead, a challenge is always fun ๐
what is the most performant way of detecting if a player entered specific coordinates?
PlayerMoveEvent, check cords
if he continues to move, that event is fired each tick?
shall I throttle it so it doesn't check each tick?
should be fine
might make some of your plugins funky so just make sure it doesnt fuck stuff up
what do you mean?
ok :D
?paste
https://paste.md-5.net/uwiduyilid.cs
Can someone tell me why this is just setting the config to {}
use File.separator for different os separation pretty sure that will only work on windows
nah / works fine in Linux
i need to know why the config is not setting correctly
show us saveFile code
this.configuration
try making a local FileConfiguration variable and save that instead of relying on the information from that class as it won't be updated
so FileConfiguration config = this.worldConfig().getConfig()
config.set("blah", "blah");
this.worldConfig().saveFile(config);
nvm
it was working earlier though... i had to move things around though because it was throwing a NPE and i changed not one thing. I just don't get why it won't work. My worldConfig is a personalized Config class so the information is being updated...
is there a way to write a method that may return out of the method from which it is called
prob not
like a null check basically
but i use it a lot and dont want to repeat it so many times
I mean you can return a boolean and then do if (!method()) return;
Java? use optional?
the method returns an object, but if the object is null then i want to return from the method which i called it from
ok
yea, when using Optional and the result is null, return Optionl.empty()
I wonder what kind of integrity checks you'll do ๐ค
Inb4 signed jar
inb4 finding a way to bypass it
java, as a programming language, is the most insecure thing ever
I'll probably find a way around it in some way, shape or form
then imagine using a computer
I mean: holy smoke. data in the RAM?
imagine what you could read if accessing it
Inb4 i make a linux service to scan for bukkit malware
are we still talking about anti malware
yes
why
no fucking clue
ever heared of Internet?
anti malware is like the most useless thing ever
well... unless it's good
like mine
I've found almost 400 malicious plugins since 2019 after all...
so.. i wouldn't really call it the most useless thing ever
the only people who use anti malware of any kind are a) people who don't know what it does b) employees using it because the insurance company mandates that the employer use one or they won't reimburse data loss costs and shit
@hidden torrent should I let the NoSuchElementException handle breaking out of the method or is that bad practice
most useless and redundant software ever invented
depends
While true, Anti-Malware can still be useful @wraith rapids
For example.. me mass-scanning with my Anti-Malware found malicious resources from 2016
active anti malware, anyway
i guess virus scanners that you can run after the fact are useful
@olive lance is that question legit? I mean, I feel trolled ^^
whoever is dumb enough to get infected by dumb shit deserves to get infected
as of the first release of my Anti-Malware
383 malicious plugins have been found
73 different malicious devs get automatically banned
257 different checks have been implemented
again i wouldn't really call it useless
@hidden torrent sorry it was dumb
it wasn't.
and anything that gets past a not dumb user won't be caught by anti malware anyway so it's redundant
Gimme a sec
@vagrant stratus i mean, if you want to fix my structure go ahead
Who said I'd give away everything i find ๐
this is a prime example of dumb shit
they're obviously hiding something; don't use it
that is a prime example of a dev uploading malware long after first release once they're trusted by the community
only trust open source and look at the changelog and changes whenever you update
good practice to begin with
i don't update something unless I know what's been changed
Inb4 only binary release has the malware
That's usually the case actually
If it's open source only the binary release has malware
That would be lying, everyone knows you can't lie on the internet
so if I call get() on an Optional object in method A, then proceed to call methods on the retrived object(which may be null) would the NoSuchElementException already have stopped method A
@olive lance ok, sorry. I have time now :D What was your problem? if it takes longer and this channel is too active, pm me
yes, it would have stopped it
with a huge explosion
an exception being thrown stops everything
and everything explodes one stack frame at a time
@olive lance When using Optional, you can check if there is some value present with isPresent()
until something catches the exception
if nothing catches the exception at all the server dies
oh ok lol
also @solemn shoal if anything, I'd just show proof that i bypassed your shit without revealing how
if (optValue.isPresent()) {
// do something
}
If you really go that far
optionals are gay anyway
if you like to use lambda, you even have ifPresent(Consumer<T> consumer)
don't hate 'em, just don't like 'em
simple as
I've got way too much free time
optValue.ifPresent(value -> {});
i feel like this may just end up making my code longer
what are you doing, anyway
depends. wanna share your code?
wat
@Override
public void perform(Player p, String[] args, HCFPlugin plugin){
Faction f = plugin.getData().getFactionOrError(p).get();
if(!f.getLeader().equals(p.getUniqueId())){
p.sendMessage(ChatColor.RED + "You must be the leader to use this command!");
return;
}
if (f.hasClaim()) {
p.sendMessage(ChatColor.RED + "Your team already has a claim!");
return;
}
if (!plugin.getData().hasSelection(p)) { . . . . ```
Why are you using the minecraft namespace
the getleader check is next on my list
Is it possible to send the Totem-Animation to a player?
getFactiononError() returns your optional?
yes
are you trying to implement that throw fast return shit I talked about earlier
yea, do not call get()blindly on an optional
and if it return optional.empty it sent a error message
it is not designed for that
ok
create a new exception called BreakCommandParse or something
capture it in a variable
make it a checked exception
then, whatever code invokes that 'perform' method
make it catch that exception
and then make perform throw that exception
@Override
public void perform(Player p, String[] args, HCFPlugin plugin) throws BreakCommandParse {
Faction f = plugin.getData().getFactionOrError(p); //throws the exception
```
public class ClaimCommand implements SubCommand {
@Override
public void perform(Player p, String[] args, HCFPlugin plugin){
Optional<Faction> optFaction = plugin.getData().getFactionOrError(p).get();
optFaction.ifPresent(faction -> {
if(!f.getLeader().equals(p.getUniqueId())){
p.sendMessage(ChatColor.RED + "You must be the leader to use this command!");
return;
}
if (f.hasClaim()) {
p.sendMessage(ChatColor.RED + "Your team already has a claim!");
return;
}
});
if (!plugin.getData().hasSelection(p)) { . . . .
and then in your subcommand handler or whatever
try {
subcommand.perform();
catch (BreakCommandParse) { return; }
that that is hard to format
thank you guys for this major help seirousky
that way you don't need to fuck with optionals
you will also have to declare the getFactionOrError method to throw BreakCommandParse
and then do the if condition of the player having a faction there, and if not, throw new BreakCommandParse()
you may also want to create a string based constructor for the exception, and have that string being sent to the player in the catch block
that data object is probably not responsible to throw exceptions associated with a command.
that it's an exception associated with a command is irrelevant
it is simply an exception that breaks the operation that is being performed
and happens to be used in command parsing
Responsibility pattern. always teach it properly
indeed.
probably their own
mine
towny is one plugin that uses, or used, this approach
that is, instead of checking everywhere whether a location has a town block or something
instead of returning null and checking for null
the getter method throws NotRegisteredException
which saves them a bunch of nullchecking
yea. I prefer the Always return something approach as well.
but comes at the cost of fucking bullshit code because the exception is checked and there is no nullable alternative
so they end up having to try catch shit everywhere constantly for no reason
they're currently in the process of reverting that design approach
i guess i could send the player a message within it but prob not necessary, just better to do it before i throw it?
optionals are gay
Isfirs null would accomplish the same thing roughly?
what a bullshity argument to make
not only roughly. but far less error prone
you can send it before throwing or you can throw the exception with a message argument and then send that message
either works
what do you even mean error prone
Elaborate error prone
the data either is there or is not there
whether it's wrapped as an empty optional or a null pointer reference is not relevant
null can throw NPE when operating on an absent value while Optionals (when used correctly) will never do that.
Wat
yeah, well, see, there's the catch
"when used correctly"
references, too, "when used correctly" don't throw NPE
then what's the point
so both have the same caveat
In regards to prefer Optional argument then?
don't have null values
optional is literally just a reference wrapper
it's still null, you just don't call it null
null is great tho
it literally even throws a fucking exception if you try to access it without null-checking it first lmao
you could still set up code on it. I do it all the time. if the value is missing, yea well it will not run anything.
that is, get throws nosuchelement if the optional is empty
but my chains and streams are set up and run perfectly fine
yeah, streams are pretty much the only argument for optionals
that said, streams are also gay
so your argument is invalid
Java is gay. don't use it then
i agree
go back to assembler.
Is there a way to add Advancements with a plugin or should I just use a datapack>
or even binary code
dang so i have to add the throws statement in every method override
it should be able to know if it throws in the interface
your IDE should insert the throws statement to the method declaration automatically
That sounds wrong in every conceivable way
you can add and remove advancements with plugins yeah not 100% sure how but it's better than a datapack
you can also make it a runtime exception so you don't need to add throw clauses and declarations anywhere ๐
but that's probably not a good idea
@Override
public void perform(Player p, String[] args, HCFPlugin plugin) throws NotInFaction {
Faction f = plugin.getData().getFactionOrError(p);```
```public interface SubCommand {
abstract void perform(Player player, String[] args, HCFPlugin plugin) throws NotInFaction;
}```
```public Faction getFactionOrError(Player p) throws NotInFaction {
if(!fPlayers.containsKey(p)){
p.sendMessage(ChatColor.RED + "You are not in a faction!");
throw new NotInFaction();
}
return fPlayers.get(p);
}```
heres what im working with i think it looks right?
NotInFaction is an odd name for an exception but I guess
oh yes you see I am going for world record of least bytes in my jar
exception too many letters
Lol ok
big brain
just kidding but besides that lol
getFactionOrError feels kinda contradictory to your goal then
all my method names will be hex values
wdym though it throws the error if not in faction
Well, if we for instance take a look at java you wonโt find something like
getAppropriateClassOrLinkageError, getDeclaredConstructorOrReflectiveOperationException
lol
there is already a getFaction method
the orError is there to make it distinct from the nullable alternative
it's a poor name I agree
but I couldn't come up with anything better on the spot
Hmm yeah well thought he only had one method for it
he definitely wants to keep the nullable alternative
otherwise he runs into the same issue as towny
where he has to wrap literally every fucking get in try catch ignore
Yeah which is horrific in every way lol
yeah, it was absolute cancer
they even had performance issues because of it
they had like a entity spawn listener somewhere that tried to check if the town area had mob spawning disabled
but because the get town area method wasn't nullable, it threw an exception that was caught every time instead of just returning null
lmfao
so for all of the thousands of mobs spawning outside town areas, it'd constantly spam like 400 element stack traces
and then try printing it with the logger. gg performance
nah they were caught at least
but just getting the stack trace in the exception ctor is expensive enough
was like 5-10% tick time just from fillInStackTrace or whatever that method was in when I looked at it in spark
ill probably get around to testing this in like a week and then nothing works at all so i just go afk for months then decide to come back and try to fix it
i made and use a really strange command framework
Hey
it was originally something I'd call oop purism
can anyone help me out with tabcompletion?
i made a tabcompletion, but it only completes arguments when i type something
Yeah but example when you type /give
with just a space
it gives you automatically a list of args[1]
you dont have to type any letter as args[1]
if you get what i mean
i mean
argument after the main command
example /kill Player
I mean the player as the argument
Ill show my code
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 1) {
ArrayList<String> autoComplete = new ArrayList<>();
if (!args[0].equals("")) {
if (main.eventStatus) {
if (!main.confirmation) {
autoComplete.add("disable");
} else {
autoComplete.add("confirm");
}
} else {
autoComplete.add("enable");
}
}
Collections.sort(autoComplete);
return autoComplete;
}
return null;
}
thats not right
args will be length 0
/kill has no arguments
it's just the command label
args.length == 0
you present a full tab complete List depending on what arg length is
so i should replace 1 with 0
/kill n
will create the first argument at args[0] with the value of "n"
depends on what you want to do i guess
If i need to put 0 there then i understood
try <= 1
aight will do
if you set it to 0, it will stop auto completing once you write the first character
since /kill n will have 1 argument, but /kill will have 0
so you need to return auto complete lists for both 0 and 1 arguments
should singleton instances be final
an instance can't be final
oh ok
a field that holds a class can be final
a class that the object is an instance of can be final
a class can be final
but an object itself can't be final
so in that case i need to return the list under every if statement?
i mean where im adding it to the list
i tried just changing == to <>
<=*
just drop the args clause
clause?
remove the if args length condition altogether
public final class Foo {
public static final Foo INSTANCE = new Foo();
private Foo() {}
}
final instance
that's not a final instance
best we can get
that's a final field holding an object
but like yeah i guess that is what he meant
singletons by definition should only ever have one instance of them floating around
so it only makes sense that the something holding onto that instance is final
best practice for singletons iirc is to make them enums which makes the jvm enforce the singleton property
I want to open a menu in a protocolLib event, but I have this error.
java.lang.IllegalStateException: InventoryOpenEvent may only be triggered synchronously.
The menu works correctly (tested with commands for example)
According to my research, protocolLib would handle all incoming packets asynchronously. Does anyone know how to solve this?
public void onPacketReceiving(PacketEvent event){
if(event.getPacketType() == PacketType.Play.Client.USE_ENTITY){
try {
event.getPlayer().openInventory(................);
} catch (Exception e){
Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "ERROR");
e.printStackTrace();
}
}
}});```
yeah to be honest i don't know if you can do that with the tab executor
that onPacketReceiving method isnt called on the server thread
it kinda seems like you can't
alot cmds have it
probably need to wrap it in a sync task (runs on server thread)
since the new argument only appears in the args[] array after the player starts writing that argument
it doesn't appear as a "" in it after they press a space i don't think
could be wrong, never used the tab executor
but example
if i do /kit<space>
then it gives me a tabcomplete with kits
without typing any args
that's from essentials; they probably use something more robust than the tab executor class