#help-development
1 messages · Page 319 of 1
well
I made that engine in like
2-3 hours?
I had a clear idea of what I wanted tho
I'm still thinking on how I'll do my new imageboard system
I nuked my old one except for a couple classes
and made it a standalone project
got this far
doubt I'll be making 3d games (on minecraft item frames and maps)
so there's probably no point in making projections
You are a big nerd
I have some travelling to do next week and need the cash
And I'm lazy
so I decided to nuke stuff and redo it
How can I get the block the player is looking at at the moment of typing a command?
getTargetBlock
or raytraceblocks and add filters :)
you can also raytrace to see if there's an entity in front
very advanced
although I find annoying always having to filter the player itself because it always hits itself if I don't
Ok yeah I didn't think so
just so i dont need to code it, any way to turn off end gateways?
All I see is maxDistance and FluidCollisionMode
and I can't just include certain shapes as others in the raytrace
cancelling the event
How can I null check that
How can I make sure the player is even looking at an item before getTargetBlock
Or do I not need to check?
break your problem down
example:
- When the player runs a command
- We check if they're holding X item
- If they aren't, well good luck
- Now that they're holding X item, we can check if they're looking at Y block
I need to get a block a player is looking at at the moment of running a command and make sure if it exists it's a chest
Not holding, looking at
I'm just asking if player.getTargetBlock can return null
Do I need to check if it exists?
middle-click it and read the comments?
does UTF8 support »?
should do
uhh
no guarantees
but it should
utf-8 should support most things afaik
» is actually a very nice character for messages
i'm sending a message to a discord webhook and converts the » to ?
glad I have it on my keyboard
then it doesn't
dafuq
if youre having issues with encoding, make sure your compiler is configured to compile to UTF-8
kinda forgot how to do that though
any idea how?
maven or gradle
I'd use StringEscapeUtils#escapeJava if you have apache
maven
folow this
Oh wait no it shouldn't be null I lied
Ok this is gonna sound noob so I apologize. I wanna make sure I'm reading this correctly
/**
* Gets the block that the living entity has targeted.
* <p>
* This method considers all blocks as 1x1x1 in size. To take exact block
* collision shapes into account, see {@link #getTargetBlockExact(int,
* FluidCollisionMode)}.
*
* @param transparent Set containing all transparent block Materials (set to
* null for only air)
* @param maxDistance this is the maximum distance to scan (may be limited
* by server by at least 100 blocks, no less)
* @return block that the living entity has targeted
*/
@NotNull
public Block getTargetBlock(@Nullable Set<Material> transparent, int maxDistance);
Parameters refer as to "settings" for the method.
Returns: States what it returns, in this case a Block that's targeted,
@NotNull means it can return null meaning it does the checks on it's own?
Oh
Then another question
How do you know the default is gonna be air?
If it doesn't say in that part of the docs
why would they change it
If they're looking straight up into the sky, what blocks are there?
That's not what I asked, I wanna learn
I'd say its null
because for it to not be null, it must be fully functional
as a block
actually nvm it says NotNull
so what, it returns the player loc?
its annotated as Notanill
Any tutorial for pagination in general, not menus, mainly for paginating commands let say
notanill yes my favtorite annotation
No, it returns the AIR block at the max distance.
Yeah yeah I get that. I'm just trying to understand that usually in these cases just use logic? And should be right?
I understand there
there's air in front. I just wanted to learn how to know what the default would be if @urban grotto was specified.
Gotcha
Weird
Perfect
Thanks for explaining ❤️
Now, would this be the most efficient way of doing this?
if (!(player.getTargetBlock(null, 5).getState() instanceof Chest)) {
sender.sendMessage(translateChatColor(getPrefix() + "&cYou must be looking at a chest!"));
return;
}
Chest chest = (Chest) player.getTargetBlock(null, 5).getState();
Or is it better to Block block = getTargetBlock()
Then check what it is
Then assign to chest if valid
I'd reuse the variable
You can use pattern matching to only call getTargetBlock once
I gotta read on patternMatching
basically
Basically just makes a variable and auto casts from instanceof
@quaint mantle 🙂
if(state instanceof Chest chest) {
chest.doSomethingWithChest();
}
instead of
if(!(sender instanceof Player)) {
...
return;
}
Player player = (Player) sender;
->
if(!(sender instanceof Player player)) {
...
return;
}
...
java 14+ I'd say
helpfull
It won't assign it
is it in your downloads folder?
That's really cool
duh
is your server web hosted or locally hosted?
hosted on a vps
right so go to your vps
actually nvm
go to your dowloads folder
and right click the plugin
press copy
then go to your vps
then go plugins folder
then right click and press paste
Is there any prefer naming convention for static methods
wont work if its not in file explorer
just the typical camelCase convention
just said it was in the dowloads folder
tnx
didn't changed the problem
did you reload maven
just get a list of commands and show from (page-1)*page size to page*page size - 1
ofc
?paste ur pom
int start = pageIndex * elementsPerPage;
int end = Math.min(elements.size(), start + elementsPerPage);
Isnt a way of doing it using List#subList() ? Because using for ints give me 🤢
then loop between start and end
or sublist
but that'd make a copy
not sure how much I like
yeah but a parametized list, its faster because its never resize
I'm more concerned about memory than cpu time in that case
maybe a fixed-size array 🤔
yeah that i was wndg to say
Question, if isValidTargetBlock(player) returns either a Chest object or null
How can I simplify the declaration?
if (isValidTargetBlock(player) == null)
return;
continue
Is this the best way?
Chest chest = isValidTargetBlock(player);
if (chest == null)
return;
So no idea?
build with package
that method should be renamed getTargettedChest
Even if all it's doing is checking for stuff?
why does it return a chest then?
it shoudl return a boolean
if your method name starts with "is" your method should probably return a boolean
is the thing in the file or are you adding it after?
it is in the file
im very confused about that lol
but i'm using new String(String.getBytes(), StandardCharsets.UTF_8)
does this cause any problem?
well
cant say ive ever seen that
is it red on ur screen? @sage patio
you should probably just be able to read it normally
if yes then yes its error if no then no error
i'm not sending that in the game
i'm sending that to a discord webhook
is it in a config or something?
config?
the arrow
yeah
yeah
you should probably change the pom.xml and make it fix ur dependency
thats what i did and boom it works
it might be that causing issues
doubt thats the issue
i've installed that
maven weird
k
and it still says not found
all the issues should be fixed
idk bro
it worked for me
try uninstalling it
and re installing it
dafuq is that
are you a high school it guy
no
saiyng "uninstall and reinstall it"
just a dude that doesnt understand jack shit of whats happening
i probably have less brain cells then the stuffed animal in my pfp
do i need that plugin anyway?
if you have no sources to distrubute probably not
dont remove spigot
Brutal
but you can remove all the side hoes aka random ass dependencys
focus on your main queen
doesnt even use spigot 
lmfaooo
not as brutal as my inability to code
?learnjava might help
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.
Hey,
Lets say I want the user to be able to type any item in minecraft as a command argument.
For example as in a /give <item> command
er
but @sage patio maven is weird and i have got a clue what is not encoding that with utf8, apologies im not more help
honestly
Is there any way to get all the items and the variations, is there a db
tab complete?
EnumSet iirc
np bro actually you helped a lot
Yes!
u too iCalling thanks
make it the values of the Material.values class
just skid from https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/main/java/com/earth2me/essentials/commands/Commandgive.java
god
did i actually 🤣
one second
ive got code for it somewgere
no bro, yall need a ?learnKotlin
what the fuck is kotlin
fuck kotlin
:kotlin: :stonks:
java but typed like python or something
explain what kotlin is
Java++
Because I didn't understand the ess.getItemDb()
ew god no
here
mf thats called skript
which you can learn here
?
You know what? that is not my problem who gonna use » characters or anything causes this problem, i'm disappointed
preach bestie
Kotlin is a programming language that is fully compatible with Java. It was developed by JetBrains, the company behind the popular Java IDE IntelliJ IDEA, and was officially supported by Google as a first-class language for Android development in 2017. Kotlin is similar to Java in terms of syntax and structure, but it also has some features that Java doesn't have, such as null safety, extension functions, and data classes. It is considered to be a more modern and powerful version of Java.
It compiles to the same bytecode as java but with a better syntax and some nice-to-haves on top of that
Go decompile my chat plugin
It uses a »
i aint reading allat
public class ClassName {
private List<String> MATERIALS = new ArrayList<>();
public ClassName() {
for (Material material : Material.values()) MATERIALS.add(material.toString());
}
}
Awww
its 3 lines :bruh:
Thanks epic
It's jvm language same as java
and you had my problem before?
Yeah but I fixed it
it might be toml or something
here's the tl;dr:
It compiles to the same bytecode as java but with a better syntax and some nice-to-haves on top of that
i know java
which one
there is a lot related to chat plugins in you profile
ok listen
i have a staffchat plugin that sends every staff chat into discord via a webhook
it gets a message format in a toml file and replaces something
its all working but if player write any » it gets replaced to ?
In discord or ingame
Ohhhh, that's discord then I can't help
Sorry
I thought you had the problem ingame
no, thanks anyway
different char
ew
Epic can you explain this
Yeah no idea, making it work ingame is already interesting no clue about discord
i don't know chose this a long time ago
which page
you create a list of the material names, and when the class is initalized it adds all the values in the Material class to that map
ow Twitter?
your twitter
mainly so you arent looping of the entire class each time you want a command
it seems it's not changed in my connections
wait so
Yes buy
lemme send you the right one
But
wanna do a collab?
Ok wait I think I figured it out
when you type new ClassName() you initalize the class
there for adding the values to the list
what
lmfaooo
lol
sorry hot chocolate for pinging you
btw its Sinaw69
I want to add a section of lore to every crafting recipe, and using tutorials I found online, this was the best supposed method. It doesnt work as intended, and nothing changes on the crafting result. ```java
List<Recipe> recipes = new ArrayList<>();
for (Iterator<Recipe> it = Bukkit.recipeIterator(); it.hasNext(); ) {
Recipe recipe = it.next();
if (recipe.getResult().getItemMeta() == null) {
System.out.println("Skipped recipe");
continue;
}
ItemStack item = new ItemConstructor(recipe.getResult())
.setLore("", ChatColor.translateAlternateColorCodes('&', "§8§lCOMMON"));
if (recipe instanceof ShapedRecipe shapedRecipe) {
Bukkit.removeRecipe(shapedRecipe.getKey());
ShapedRecipe newRecipe = new ShapedRecipe(shapedRecipe.getKey(), item);
newRecipe.shape(shapedRecipe.getShape());
shapedRecipe.getIngredientMap().forEach((character, itemStack) -> {
if (itemStack != null) {
newRecipe.setIngredient(character, itemStack.getType());
}
});
recipes.add(shapedRecipe);
}
if (recipe instanceof ShapelessRecipe shapelessRecipe) {
Bukkit.removeRecipe(shapelessRecipe.getKey());
ShapelessRecipe newRecipe = new ShapelessRecipe(shapelessRecipe.getKey(), item);
shapelessRecipe.getIngredientList().forEach(itemStack -> newRecipe.addIngredient(itemStack.getType()));
recipes.add(shapelessRecipe);
}
}
for (Recipe recipe : recipes) {
Bukkit.addRecipe(recipe);
}
Do you? Im wondering to meet ppl for creating things together
Is there any advantage of returning with any of them, or they are different usages and reasons for them?
Optional<Something> getSomething() {
return Optional.ofNullable(list.stream().filter(() -> {}));
}
Optional<Something> getSomething() {
return list.stream().filter(() -> {}).findAny();
}
from my understanding they do the same thing. They just have a different method to reach that conclusion. I could be wrong, but I do believe they are the same.
both are the same
talking to me?
oh ok
I asked because i have seen then in many plugins and i was wondering to know if they where diff way for implementing Optional
that returns an optional of a stream right? Not of a item in the list?
In that case for finding something, for example you have a List<User> to find then via UUID, and return the Optional<User>
That is how i understand optional, i didnt used to use it that why and i find really interesting
oh, so like the method name it just finds a random element in the list? Is it truly random, since if it wasnt it wouldnt be any different than findFirst right?
yeah, there is something extra findFirst() because its return the object itself not an Optional<Object>
@Command(name = "deepstorage")
public void mainCommand(CommandArguments args) {}
@Command(name = "deepstorage.item")
public void getUserSubCommand(CommandArguments args) {}
@Completer(name = "deepstorage")
public List<String> mainCommandCompleter(CommandArguments args) {
return Arrays.asList("item", "user", "admin");
}
@Completer(name = "deepstorage.item")
public List<String> itemCommandCompleter(CommandArguments args) {
return Arrays.asList("add", "remove");
}
findFirst returns a optional
The suggestion never changes. any ideas why this could be
ItemStack cool_item = new ItemStack(Material.COAL_BLOCK, 1)
Is it possible to use a variable instead of Material.COAL_BLOCK. I have a config and would like this to be editable, but I need to either convert a string to a material type or use a material type variable in my config, both of which I don't know how
@remote swallow ❤️
Wait im mix, because if its return an optional, how im able to do?
Object obj = Stream.of().filter(() -> {}).findFirst();
Material.matchMaterial(String)
becuase an Optional is a object
ive got no idea, never seend that type of command sys lol
But the type are different?
thanks ❤️
just do something like this: Material.valueOf(config.getString("config.x-material"))
from my understanding everything extends Object
polymorphism
Yeah that i know, but how dont ask you to cast it?
Just wondering to understand the why haha
those docs are awful lol
Yes that why, i try to read them but are really worst
i would probably say just use built in command sys from bukkit
Mannn it works so easily and well just this 1 completer thing with issues
I think you can go down the stream, but you cant go up without casting. Like, you can go downwards into what it extends, but then it requires casting to go up. Like ShapedRecipe -> Recipe doesnt require casting, but Recipe -> ShapedRecipe does.
https://discord.com/invite/rVkaGmyszE might be better
just spotted it on their git
just edit the source if you really have issues with it
Yeah but
I don't know what the issue would be lmao
Like why tf would it do that
well it might be the fact that the autocomplete is for the base command, so it will appear for the whole command, no matter the subcommand
maybe you can check the args on the main command to know if to send the autocomplete
Lmao prepare the doctor bill, because working with spigot command api its, really overkilling
hospital is free in the uk
best command api I found was https://github.com/JorelAli/CommandAPI
it is super simple and straightforward
Im gonna lose it
according to @tender shard acf is googl
oh nice, here too, i mean everyone who join our country is protected by public hospitals in case you haven accident, not like some countries where you must pay for medical attention
ha, in the US its like 3 grand just to get to the hospital
ratio bozo
but from what I know taxes are lower
and supposedly healthcare has more innovation and overall quality because companies compete over clients, instead of the government doing it all, but idk, its all tradeoffs
show your pom.xml
Hello where could I find a great documentation/tutorial/video to explain to make great commands (with custom sub commands) thanks
boring
?conventions
This rather large tutorial aims at getting you started with plugin development in Bukkit. It is in no way a complete tutorial of all possibilities in Bukkit, but rather a general overview of the basics. It starts with making sure you understand Java, sets up your workspace in an IDE, and introduces the essentials of most Bukkit plugins. These tu...
you are looping over the players plural on the server, and checking if they have that permission
uhh doesn't really tell
it does
what fuckin Mac user wrote the bukkit docs
mac > your shitty OS
trademenugui.setItem(1,new ItemStack(Material.STAINED_GLASS_PANE));
player.openInventory(trademenugui);
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NoSuchFieldError: STAINED_GLASS_PANE
at BetterTrades.Menu.Menu.openTradeMenuForPlayer(Menu.java:23) ~[?:?]
at BetterTrades.Command.Trade.onCommand(Trade.java:25) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.19.3-R0.1-SNAPSHOT.jar:?]
... 23 more
>```
set an api-version in plugin.yml
to?
for everything older than 1.13, set it to "1.13"
tysm
np
1.8.9 only exists as a client
then show the full stacktrace
usage?
did you restart the whole server after changing the api-version?
and if so, does the server say anything about "legacy material support" during startup?
but then it wouldnt have compiled
COLOUR_GLASS_PANE or GLASS_PANE
probably old api version
not necessarily you can get away with a lot of crap if you force it through
im bored
ill try glassp ane
gonna write a mc server
why you using 1.8 api and testing on 1.19 lmao
ooo hwtf 1.8.8 api
thats your issue
💀 1.8.8 api
?main again
lower case package names
the main problom never affects me
in proper versions, it's called BLACK_STAINED_GLASS_PANE, GREEN_STAINED_GLASS_PANE etc
good practise be like
should i use netty if i'm writing a mc server or is there something better?
^
pff make your own
nah wtf
technically i can
just create a serversocket and a new thread for each client
what's funny
you gotta change the durability to change the color
no you don't
?
just use Material.BLACK_STIANED_GLASS_PANE
1.8.9
what do you even need 1.8 for
I want to support 1.8 in my plugin though
why
who tf uses 1.8 gross
fuck the people that still use it
people like that version
not your problem
only 9 year olds
all the business I have conducted is 1.18+
6%
can i have some plis
also if you love the PVP make a proper pvp porting plugin and get people to use their brains and get off that old ass version
bro some ppl that hire devs are so cheap
i can't ever find work cuz they don't want to pay well
Lol really
my first job was for a server they payed meh, but better than most clients would
i'm in a few commission teams
Lol weird, in my case is the oppsite those comissions which take 2 weeks are more paid, than working a month in a network
some comissions are for an entire mininigame for 30$
i've always wanted to be payed for my work
its because some dumbasses value their time so little that people start thinking its the standard
yeah and then i quote then a few hundred and i get a response saying they guy that usually does my stuff said 25$ but he isnt availiable
like who's making minigames for 25$
bruh I charged $65 for a system that you mine blocks to gain levels
I'd kill myself before charging $25 for a whole ass minigame
i charged 60$ to change 1 line of code
there was a bug, in an obfuscated plugin and they didn't have the src
byte code???
decompiling gave a ton of errors so i had to recreate abt 6 classes and methods with empty ones
how do you rename a item?
change meta
setDisplayName
set item meta
don't you won't get any meaningful money
everyone on services undercharges
^^
good luck finding any clients
no wtf
😭 wtf
its alreayd too low
ah you'll charge 30 for a minigame
Agree, also comissions are weird cuz small comissions get more paid rather creating big mini games
that's way more than what people in services charge lol
Inventory trademenugui = Bukkit.createInventory(player,45," " + player.getName() + " Trade Menu");
ItemStack bsgp = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
Objects.requireNonNull(bsgp.getItemMeta()).setDisplayName("Sup");
trademenugui.setItem(1,bsgp);
player.openInventory(trademenugui);
It just returns the normal glass pane.
meh
its minimum wage so
tough shit
yep i always look for commissions where i have to fix/update/change something
you cant set the meta back
correct
Yeah mainly the simpliers one, which pay you lof of money for fixing some shits
Bro do you want to see my acf design?
Inventory trademenugui = Bukkit.createInventory(player,45," " + player.getName() + " Trade Menu");
ItemStack bsgp = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
ItemMeta bsgpMeta = bsgp.getItemMeta();
bsgpMeta.setDisplayName("sup");
bsgp.setItemMeta(bsgpMeta);
trademenugui.setItem(1,bsgp);
player.openInventory(trademenugui);
How can I shorten this?
ty
Honestly item builder should be part of the spigot api by now
Just wondering, why didn't you just extend an itemstack instead of having a build method?
does this not support spigot-api?
o
i need to update my item builder
im still using stuff like
totally not stolen off illusion
Is there something wrong with that tho? Genuinely curious cus that's the way I do it
fundamentally the server won't save any data you add to an ItemStack that's not native, so it can be kind of miss leading to API users etc
its more clear to wrap it or make a separate Builder Object
perfecto
I guess that makes sense
sup
why would you extend itemstack? what's the advantage of doing that?
Internationally confirmed crime I'm telling you (jk)
xD
wow that texture is light
thats what im sayinh
When glass transcends reality
do you all like my naming scheme lmao
you can use iterable dans method removeIf or make copy of list
i see
no luck
Is the netty instance being run async?
packets r processed concurrently p sure so most likely
Concurently its really open, explain the specific context
I know what its conrrency, but you have many types, parallel, etc
That why i asked u the context
If im not wrong Netty internally performs I/O operations async in the channels
I havent already really worked with netty
But i know its designed to performs I/O operations single thread and async
Are you french? because you spelled logic in french x)
If yeah me too
You must speak english on public channels - Thanks for understanding
Yeah don't worry i was just making sure
Oo nice
oh right
That only makes sense because somethings can be done parrallel in regards to networking
Also it doesnt need to do I/O itself necessarily since most of it is done on the nic.
Nio* ?
Right its perform NIo operations i know, but the events are push async if im not wrong
No i meant nic
I dont know there
Nic = network interface card
I just know that nety do NIO operations and events are pushed async all single threaded
Most of the packet processing is done on the NIC only time netty has to do anything with the packet is because you told it to.
Where netty is handy is its events when packets do come in or get sent as well as setting up queus/workers etc
Also you dont have to worry about packet headers all that much and just mainly worrying about the body of the packet as well
Yes i know how basic netty nowkrs
?paste
give us code
Also this
Doesnt make sense to show just an error and not code 🤔
https://paste.md-5.net/uzowebarel.cs
When pressing esc on a inventory that happens.
1 sce
What code do you want I never use InventoryClose event?
the close inv event code
are you using an inventory framework
are you relocating it
Yes
?paste ur pom
Wait I think I found out
Provide your inventory link
<pattern>dev.triumphteam.gui</pattern>
<shadedPattern>me.tomisanhues2.deepstorage.gui</shadedPattern> <!-- Replace package here here -->
</relocation>```
oh trimup gui, really nice framework
whats the dep look like
gui.setDefaultClickAction(event -> event.setCancelled(true));
It had to do with that line
does the dep in pom.xml has scope provided?
Thought so
how you building and what jar do you use
GuiItem item = ItemBuilder.from(new ItemStack(Material.matchMaterial(itemName))).asGuiItem();
item.getItemStack().getItemMeta().setLore(List.of("Amount: " + im.getAmount().get(i)));
gui.setItem(i + 9, item);
Help me out with this
Lore isn't getting changed
Probably my getItemStack.getItemMeta.setLore isn't ideal xd
Alright I'll just deal with it for now lol
This project already got a lot more massive than I had hoped
i should fix that item builder
?paste
help D:
Error: https://paste.md-5.net/ihijaxinik.rb
Command being run: https://paste.md-5.net/izokutuxaq.bash
It works fine in command prompt, but it fails in the ProcessBuilder.
ProcessBuilder builder = new ProcessBuilder()
.directory(mavenExecutable.getParentFile())
.command(windows)
.inheritIO();
The "windows" variable is exactly the second paste link I sent
@tender shard
I gotta tell you
Your persistentData thing
Is nuts
I just stored a Map<String, Object> in it
?
Perfectly
oh is nuts a good or a bad thing
😄
when my new macbook arrives, I never have to leave my bed again
BUT THATS ONLY IN 2 WEEKS D:
how are you gonna smoek
withdrawals
damn
i would never get out of bed just for a cigarette lol
wait about going to the toilet
we dont have toilets in europe
when did the uk leave europe
we just sweat it out
Hi i need some help
ask away
@tender shard resident acf
acf is my own library 😂
ah
Im coding my acf = alexito command framework
Right
aikar's command framework
kk i will do that
VCF
annotation command framework i thought
So im confuse writting the sub command logic
oh right
but made by aikar
lol
I have make the next designed 2 classes, called SimpleCommand (Extending this class you will be able to create simple commands with/without arguments), in the other hand **SimpleExecutor ** (Extending this class you will be able to create an executor, where then you can register arguments (extending SimpleCommand) or sub commands (extending SimpleExecutor))
I having some troubles to code the sub command logic
This my command proccessor class
@remote swallow i finished writting the whole question
Another error, this is exactly how my Commands.java file is organized.
https://paste.md-5.net/buronajuma.java
case: /ds
-> mainCommand() is called
Expected output ✅
|
case /ds item
-> getItemSubCommand()
Expected output ✅
|
case /ds item add
Without the ability to recreate exactly when or how it happens:
-> Sometimes getItemSubCommand() wrong method
-> Sometimes addSubCommand() correct method
Completely at random. sometimes it'll start working and do the right one, most of the times it doesn't.
I am beyond confused
Yes that command framework you are using its pretty bad documented
Yes Im aware of that but it's insanely simple and it works (Sometimes)
I'm just lost on why sometimes
That why you should only use proper documented libraries or create your owns, like my case
I appreciate the advice but doesn't really answer the issue at hand.
aware?
What?
@remote swallow I hope you didnt write your itembuilder without copilot lol
alex can you give a little glimpse at my issue please
i didnt write it
Just off the top, don't wanna take too much of your time
what does @Contract actually do
it tells your IDE stuff
If imt not wrong helps the IDE, so he knows about telling you warnings, like NPE, etc
whats the problem
@tender shard
e.g. if you have this contract:
@Contract("!null -> null")
that means that when the first parameter is not null, the method returns null
so IntelliJ would show a "this will throw NPE" warning for this:
myMethod("asd").somethingElse();
sorry I got no clue about that lib. I always use ACF
Why should return null, if the parameter is given? Doesnt make sense
bruh its obviously an example
It's alright, thanks anyways. ACF has way more stuff that I don't need
I just need a single goddamn thing
Like what a stupid problem
I'm reading through the api but still nothing that would be a flag
you could probably use the built in spigot cmd system instead
Yeah that why i m doing my own command framework because most of them are shity or have shity docs or have weird implementations or etc. So then i dont depend on 3rd parties to update them
probably easier lol
@remote swallow I was doing it but it's more writing
Like if I solve this 1 problem
ACF has a quite good documentation, if you know what you're looking for at least
Im done
But it's a problem that doesn't even make sense
Why does typing a command think i'm refering to the parent command of itself
I mean Aikars is okay, but has too much shit bundled on it. Only the jars takes around 1.2 or 1.4 mb
?paste
Long code use paste please
their appears to be so much un-needed stuff on that command
If I can see what's wrong I can just override it
Why dont make the simplier one, extending abstract class
Will be easier that swear about annotations
Something like mines you can do
you can shrink pretty much all of this
324kb in total
I'm new to a lot of this stuff
No because it uses annotations for that
Yeah really heavy for spigot pupouses
@Command(
name = "example",
aliases = {"firstAlias", "secondAlias"},
permission = "example.permission",
desc = "Sends an example message to sender",
usage = "/example",
min = 1,
max = 5,
cooldown = 10,
senderType = Command.SenderType.CONSOLE
)
hm all my plugins are at least including 1.5 mb of libraries
so I dont care about another 300kb
All the available parameters @remote swallow
tbh don't need half of them
But I don't think taking the code I need is the right way of approaching this
Alright I'm decided
I'll make my own
But if possible I do need some resources to read
All I need is to have @Command
automatic registering
Any reads about that much appreciated
I need a small hand here, im confused with the sub command part
This code is inside my SimpleExecutor class
How do you all deal with so many colors
hahaha only me
What were you going to say? You are my only life solution because none of them answer - Hahaha
What are you confused abt?
How to write the sub command logic in the parser
why Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.OfflinePlayer.getName()" because "p" is null
OfflinePlayer p = Bukkit.getPlayer(uuid);
try (ResultSet rs = Main.database.query("SELECT * FROM "+Type+" ORDER BY level LIMIT 5 ;")) {
while (rs.next()) {
i++;
Integer level = rs.getInt("level");
UUID uuid = UUID.fromString(rs.getString("UUID"));
OfflinePlayer p = Bukkit.getPlayer(uuid);
ItemBuilder guiItem = ItemBuilder.from(Material.PLAYER_HEAD).setSkullOwner(p);
guiItem.setName(p.getName() +" - #" + i);
guiItem.addLore("Level: " + level);
gui.setItem(info.sokobot.skills.guis.Main.get(i), guiItem.asGuiItem());
}
} catch (SQLException ex) {
}
Must be: Bukkit#getOfflinePlayer()
i think so to but prob not
Player os nkt online
thats why its OfflinePlayer
Bukkit#getPlayer() returns null if the player is not online*
That looks completed?
Wait let me send full code
makes sense getOfflinePlayer
What's wrong with what you sent?
..
getPlayer i need getOfflinePlayer
What i told you at tbe begining before arguin...
can I get rid of that warning somehow without just suppressing it?
oh i dont read sometimes
You can't underestimate when they give you recommendations, because they do it for a reason.
players are offline players
I mean you cannot form an OfflinePlayer from Bukkit#getPlayer() because will be null
Yeah i told him that haha
i wana stream dev work but i got nothin to stream to 
cant do twitch bc its technically cheating...
wdym its cheating?
its an experiment im just toying with and twitch bans cheater streamers
There's always YouTube
true
just say it's for educational purposes
also true
^ That usually gets you safe as well
it is for educational purposes
educating myself on mojangs inner workings of their game
you can say that you demonstrate how cheating works so that server owners can protect themselves or sth, idk lol
I have written the next code for parsing normal and sub commands https://paste.md-5.net/mavusunuxa.java
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) { sender.sendMessage("Player only command!"); return true;}
Player player = (Player) sender;
if (!Linking.IsLinked(player.getUniqueId())) {sender.sendMessage("You havent linked!"); return true;}
sender.sendMessage("You have now been unlinked!");
Role role = Bot.getShardManager().getGuildById(948866484912922704L).getRoles()
.stream().filter(r -> r.getId().equals("1064763344596246619")).findFirst().orElse(null);
Bot.getShardManager().getGuildById(948866484912922704L).removeRoleFromMember(
Bot.getShardManager().getGuildById(948866484912922704L).getMemberById(
Linking.getLinked(player.getUniqueId())), role).queue();
return true;
}
Caused by: java.lang.IllegalArgumentException: User may not be null
at net.dv8tion.jda.internal.utils.Checks.notNull(Checks.java:82) ~[skills-0.0.1-SNAPSHOT.jar:?]
at net.dv8tion.jda.internal.entities.GuildImpl.removeRoleFromMember(GuildImpl.java:1585) ~[skills-0.0.1-SNAPSHOT.jar:?]
at info.sokobot.skills.commands.Unlink.onCommand(Unlink.java:30) ~[skills-0.0.1-SNAPSHOT.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more
It's basically saying the player.getUniqueID() is null meaning that the player you're passing into the removeRoleFromMember doesn't exist.
hmm
what's line 30
i think im returning the same object which is the mcuuid
called it
wait nvm
idk y
Maybe conventions? "lolng" 💀
i want long but cant name it that
thats also always my naming conversions
i have like lol
yep
Also you should use generic types
and some others
ik
I dont see it? You musnt be using Long
funny thing is i use it in the other 1
As for the main issue, Are you sure the user actually exists in the linkedUsers database?
they do
4 times
Why dont you priting your ex?
hmm good idea
LMAO 💀
Add a debug message and see what the getLinked(player... is returning
First thing i would do is to check the all the exeptions, that why yo ucatch them
ye
But i understand because you are new to Java and we dont born with knowledges
Oh weird so it seems like you are new, because you dont follow the conventions, you dont use generic types, basic debugging, etc
how?
[01:19:06] [Server thread/INFO]: TSans_ issued server command: /ds item
[01:19:06] [Server thread/INFO]: Command: org.bukkit.command.PluginCommand(ds, DeepStorage v1.0-SNAPSHOT)
Arguments: []
Sender: CraftPlayer{name=TSans_}
[01:19:09] [Server thread/INFO]: TSans_ issued server command: /ds item add
[01:19:09] [Server thread/INFO]: Command: org.bukkit.command.PluginCommand(ds, DeepStorage v1.0-SNAPSHOT)
Arguments: [add]
Sender: CraftPlayer{name=TSans_}
>
/ds item add thinks add is a argument
When in reality it's another registered command
Fua bro, if you're going to have this attitude to be a programmer I think it's not the way to go. To be a programmer you really have to do your best, you can't just do it like that. Because you look like an inexperienced rookie.
That's not just me saying that, that's how society works today, I really mean that from my heart.
I agree from my heart
@remote swallow
What you should do,
Get the output from player.getUniqueID(), then get another output from the getLinked() and maybe print out all of the linked users or check the database manually to double check that it's looking for the correct thing and that it exists
In other words, primary debug
nothing from the getLinked
wait i forgot about caching
lol
im trying to make mcmmo a soft-dependency for my plugin and have it that when a player gains xp for a skill it checks which skill and sets a scoreboard that displays some of the variables from mcmmo (skill level, skillxp, and skillxpuntilnextlevel). It doesnt need to be my own plugin BTW, especially if its easier to just modify mcmmo's source. anyone willing to help me? (I also have a plugin that can control scoreboards through commands, so i could really just have the plugin run a command based on which skill just gained experience.)
could anyone point me in the right direction ?
Yo
I figured out this part
How to understand why it thinks it's a argument and not a separate command
why the heck does mockbukkit force to use paper
Show the code.
I had to add paper-api with <scope>test</scope> for it to even create a server mock
final Map.Entry<Command, Map.Entry<Method, Object>> entry = this.getAssociatedCommand(cmd.getName(), args);
if (entry == null) {
if (anyMatchConsumer != null) {
anyMatchConsumer.accept(new CommandArguments(sender, cmd, label, args));
}
return true;
}
final String[] splitted = command.name().split("\\."), newArgs = Arrays.copyOfRange(args, splitted.length - 1, args.length);
if (args.length >= command.min() + splitted.length - 1 && newArgs.length <= (command.max() == -1 ? newArgs.length + 1 : command.max())) {
try {
entry.getValue().getKey().invoke(entry.getValue().getValue(), new CommandArguments(sender, cmd, label, newArgs));
return true;
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return true;
}
} else {
sender.sendMessage(SHORT_OR_LONG_ARG_SIZE);
return true;
}
@jagged monolith
this was it
why the heck does github ALWAYS ask for 2fa codes
cant it only ask for this when logging in, ugh
Are you clicking "Remember me"?
yes, I mean it asks it for certain actions
e.g. when transferring a repo from my account to an organization
Any idea @jagged monolith ?
use a command lib ezpz
I am lmao
looks like a hard one lol
@drowsy helm
It's inconsistent too so even harder
what the heck is that lol
ACF would make this so much easier
it handles everything you are doing manually there
e.g. checking the args
This already does that
The problem is
Whenever it feels like it
A arg becomes a command
idk you are manually checking the args length, shifting the array, etc etc
Just hear me out
Sometimes, /ds user add TSans_
Will think the command is /ds user and other times /ds user add
Like the add can randomly become a argument instead of command
Just use acf, dont over complicate if you need to fast code
