#help-development
1 messages ยท Page 2113 of 1
x'D
Gonna look into it
Why do you wanna benchmark btw
Its a shame that for a little performance test you gotta take minutes installing thousands of things
in js u can just Time.now() and Time.end() or something like that, and boom, performance test
cuz js is pretty shit
xD
ive heard js is always slow
D:
not rlly
it doesnt matter ur skills
JS is super fast compared to Python
dunno tho im not a js dev
js is pretty easy to learn
its still very unorganized
true that
go get typescript idk
xD
ts isnt that much better
it is
just null safety
but i h ate it
and some other stuff
have you used ts to its full potential?
I wanted to test if its faster to count the duplicates of an int-array
- by creating a set, filling it with the items of the array, and then comparing the length of the set to the length of the array
- by sorting the array and then simply looping over the items, increasing a counter everytime two equal items follow each other
cuz someone said Set is better cuz its O(n)
and i said that below 100k items, the sorting is probably faster, although its just O(n*log(n)). Cuz no overhead for creating a set.
so yeah, i wanted to quickly test that
but i dont wanna install a thousand tools and librarys for testing that lol
that sucks
is there anyway i can use org.reflection without having my jar size start at 1mb
Does anyone have any good resources to explain how to create a custom dimension?
I know that you can do it with datapacks now, but I can't seem to find anything for spigot other then a few mentions of it being possible
auto-downloader
@zinc mist this might be a good place to start. since dimensions are essentially worlds with custom biomes https://www.spigotmc.org/threads/how-to-create-custom-biomes.512105/
I will take a look there then.
I am not wanting too complicated of a world, just might have it be filled with stone or something.
Hello! I have a problem.
Build tool exit code: 0
Looking for pom.xml in build directory and ~/.m2
Found artifact: org.example:TheAlternativeAPI:1.0-SNAPSHOT
Exit code: 0
โ ๏ธ ERROR: No build artifacts found
Expected artifacts in: $HOME/.m2/repository/org/example/TheAlternativeAPI/1.0-SNAPSHOT
I get this error on Jitpack when i try to access my api on github.
https://github.com/Will0mane/TheAlternativeAPI this is the github page. I don't understand why do i get this error
Seems like most of the things in that don't exist anymore.
Namely CraftServer, DedicatedServer, BiomeBase, MinecraftKey, and a few others
do you have access to nms?
I am not sure
there classes are not normally in the api
Ah, that could be why
what version ru developing for
1.18.2
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
read this then
Will do XD
Hello, does anyone know how to import a dependency idea in intellij idea?
maven
what event do i need to use if i want to control player right clicked a block
i used interact
if(e.getClickedBlock().getType().equals(bank.getBank())){
p.sendMessage("ilk ife giriyor");
if(p.getInventory().getItemInMainHand().isSimilar(cash.getCash())) {
p.sendMessage("2. ife giriyor");
int amount = cash.getCash().getAmount();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "money give " + p + " " + amount);
}
}
well idk what dependency you want. but most for most public things you will be able to find a repository and dependency which u can place inside ur pom.xml
Could you help me with one thing?
if you want to detect when a player right clicks a block the interact event is the correct one
sure ?
I want to import GriefPrevention plugin dependency
And I import it from this button (I think I've seen it in videos)
if(e.getClickedBlock().getType().equals(bank.getBank()))
it does not enter this
File -> Project structure
yea. but if you use maven, you dont do that.
on the griefprevention github you can find this https://gyazo.com/72882784d927f930998a256e3c848e60
which you simply add to your pom.xml and that will do it
im not sure i understand what you mean
one of the if statements returned false if it does not enter that
<dependencies> <dependency> <groupId>io.papermc.paper</groupId> <artifactId>paper-api</artifactId> <version>1.18.1-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.github.TechFortress</groupId> <artifactId>GriefPrevention</artifactId> <version>16.18</version> <scope>provided</scope> </dependency> </dependencies> </project>
It gives me an error
which error
alr i made it but
if(p.getInventory().getItemInMainHand().isSimilar(cash.getCash())) {
int amount = cash.getCash().getAmount();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "money give " + p + " " + amount);
}
did you reload maven?
its not executing the command why can it be
emmm, I think not, how could I do that?
on the right of your ide
should say maven
open t hat
then click the reload button
the item in the players hand is not similar to cash.getCash() then
the left button right under maven
no
the circle thingy
its entering if, but not dispatching command
player
a Player object?
oh
hey so i have this code
System.out.println("1");
ItemStack itemToModify = Objects.requireNonNull(coldInv.getItem(15)).clone();
ItemMeta meta = itemToModify.getItemMeta();
List<String> lore = new ArrayList<String>();
lore.add("test");
meta.setLore(lore);
itemToModify.setItemMeta(meta);
inv.setItem(15, itemToModify);
setintMethod(block, getintMethod(block) + 100);
player.updateInventory();
and it just...doesnt work. Idk why, donc ask me why i just dont know !
the item isnt modified
(ps this is the 15th item)
hit that baby
hey hey easy dude we wont ask.
did you add the repository?
ur talking to me?
no talking to arthur now
oh k
If you mean the pom.xml yes https://prnt.sc/tq9FvZZ05_aV
https://gyazo.com/205d57a6502d153d83a910adfc76fbbc did you add this as well
oops, no
ya need that
Wow, it worked and let me compile it! thanks ๐
Can you tell me why this comes out in red?
https://prnt.sc/utyP8MuWgeOi
hover ur mouse over it and it might give you some more info
if(e.getClickedBlock().getType().equals(bank.getBank()))this is not working again @tall dragon
is there any wrong on method?
@kindred valley to check if an item is your custom item you should use PersistentDataContainer to add a custom tag to the item
Nothing comes out https://prnt.sc/S_enTCbOob7S
?pdc
using this ^
@mystic vale well im pretty sure that doesnt do much harm. i dont rlly know why it does that. i have had it before as well and it would compile fine
Ok, the server starts successfully, and the plugin loaded
Thank you very much for helping me @tall dragon
I'm new to Spigot plugin programming and would like to make some :3
๐
Did the NMS change for 1.18.2?
[ERROR] symbol: method send(net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity)
[ERROR] location: variable connection of type net.minecraft.server.network.PlayerConnection
why do i need data for?
to check if its your custom item.
I am not sure what I need to do in order to get this NMS thing to work.
I copied the mentioned configs over to a new project however, it is telling me that 1.18-R0.1-SNAPSHOT doesnt exist
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
I cant get what is Block State, can you explain it short quick.
uhh BlockState contains some data about the specific block. like for example a chest contains data about whats inside it.
what a normal block contains
uhhh nothin
so getState returns null
it always returns a State snapshot of teh Block at that time
what would it return on a cobblestone block tho
A BlockState of the cobblestone. You can uise that to fetch teh states BlockData
you can have multiple States stored at teh same time, but they are snapshots and only one will represent teh actual Block in game
yw. but it has to return one of these no? https://gyazo.com/d07a6917b3cbb28671c4bc902a89005e
No, its not an Abstract Interface so it can return just itself
Which sound should I play to show the player that they did a mistake (Which one would you pick?)
villager no ๐
vine boom sound
Should I not use it?
Aight
just play with that a little. find something you like
Ill just keep it one ig
ye
well volume refers to the reach the sound you play has
1 == 16 blocks iirc
oh
and 2 would be 32 etc
would world.getName work for multiverse worlds?
pitch is the pace
mye iirc player.playSound would allow that
Ohh, I just need to pass the Player as an Entity
ye
Aight
What if I ear-rape the player with the highest pitch
yikes
I mean pitch wont "ear rape"
frick
the client kinda limits it
;( my plans of damaging someone's ears
so you cant play it too low nor too high
Does anyone know why spawning holograms with packets turn into floating horses for 1.7 clients on a 1.8 spigot
probably some funny business by viarewind / viaversion ?
Possibly seems to work fine though when using holographics displays
ye but hd doesnt use packets im pretty sure
^ since world name returns a string, or how does multiverse worlds work?
they spawn the actual entity and hide it or what?
Hey someone have alibrary or api for link a java plugin to a discord bot ?
not actually sure how HD does it
I'm talking about 1.7 clients
discord srv
or ?
what do u need exactly
I want to try to do a plugin linked on discord for rank,chat,...
Just confirmed, it's an issue with viarewind or viaversion, just threw in protocolsupport and works flawless
yea thought so
so u wanna make discord bot?
I wonder what versions of these support holograms for 1.7 players correctly though
a discord bot can add a rank on minecraft ?
so I don"t want make a discord bot
I don't how thats work, i just want learn
if u wanna learn u gotta work :)
if the player be MVP on minecraft that automatically put him mvp on discord
oh ye that ok
no problem, it for that I want a docs or library
or u can always get someone to do it for u
?paste
use luck perms API + JDA
I'm not sure why its giving me this error. It gives me no information about why my code throws this error
https://paste.md-5.net/geniqixusa.apache
LuckPerms is a permissions plugin for Minecraft servers. It allows server admins to control what features players can use by creating groups and assigning permissions.
Java wrapper for the popular chat & VOIP service: Discord https://discord.com - GitHub - DV8FromTheWorld/JDA: Java wrapper for the popular chat & VOIP service: Discord https://discord.com
thx ๐
np and gl!
hey, how do i create an Inventory variable like this :
Inventory name;
But i want it so that the name of the inventory is the name of the player. How do i do that?
hello when i provide console to dispatch a command it always dispatch it twice why can it be
just parse player name to the inv?
how?
probably because the interact event runs twice
for your main hand and you second hand
can you show ur code?
there is no special code all i want is create an inventory with the name of a player
hmm how can i prevent
check if the event is fired on the main hand
for instance like that
@EventHandler
public void onBlockPlace (BlockPlaceEvent event){
Block block = event.getBlock();
Player player = event.getPlayer();
Inventory name;
}
name = player.getName
doesnt work like that
player.getDisplayeName is a string
and my variable is an Inventory
ok and inv name would also be a string?
Can I somehow deploy jar to multiple folders using sftp? (intellij deploy tool)
well that's never gonna work then :)
@steel swan do u know how to create an inv?
bro
ik how to do that
my only question is how to create an inventory with a specific name
like the display name?
why would u want that tho?
long story
that is 100000% impossible for java
also explain the story and maybe people could help u more
no idea sorry
sftp is just ftp via ssh, should be easily doable
Probably I have it! I created a group of servers
Just read the manpage of sftp and create some batch file for it
@tall dragon how can i reach TileState on 1.12 spigot
Alternatively use scp, it does a similar thing but is even easier to understand and use through scripts
I ended up finding WorldCreators but I am having a slight issue trying to understand how to set the generator settings. The post that I had found has this: wc.generatorSettings("2;0;1;"); but from what it says in my IDE the parameter for it needs to be a JSON format with valid biomes, structures, etc.
Is there a way to give each block an inventory
like i already did the whole "when right click it opens"
Can I cahnge the variables of an enum at runtime
so anywhere accesing that enum's variable will get that value
instead of the hard coded one
The variables of an enum instance yes, create enum instances - yes - with a catch (the compiler will not allow it unless you trick it into thinking that it isn't an enum)
But generally if you have control over an enum and want to arbitrarily create instances of it, you might as well use a registry
What is the best way to check the length of args
args.length
u dont get it
you mean how long the string inside the arg is?
How can i reach tilestate in 1.12.2 spigot?
anyone know anything about this?
If you want to edit something at runtime, you should absolutely choose registries over enums or abandon the idea of editing at runtime
actually nvm just found it. it is however giving me a weird "Invalid name or UUID" error. and no information with that
If someone knows how to trick the compiler to do stupid stuff, they wouldn't be asking this question in the first place, so I believe that my advice is justified
i mean
cant he just have a variable in the enum
Yes that is possible, but I am afraid that that person is not asking that
They probably want to edit the internal values array
what version persistentdata came with
If you play around with ASM too much stuff like that will get natural
how to update a plugin version?
You might want to specify your question further
Right now it is too ambiguous to answer
no like
my plugin version is 1.18.1
so i want to upgrade it to 1.18.2
i had changed my pom.xml <version>1.18.1-R0.1-SNAPSHOT</version>
this to <version>1.18.2-R0.1-SNAPSHOT</version> this
but still its not working .-.
Not working as in?
o
why cant u use reflection tho
And do you mean plugin version as in the version declared by the plugin.yml or the version of spigot-api?
im pretty sure enums did have an array of values in it didnt it
when you crash your server with a loop...
That array is final iirc
Either way, it isn't of good use if you cannot obtain an instance in the first place
ah i think plugin.yml one
Think or know?
lemme change it
its possible
ig
It's possible in Java 7
yeah pretty sure the module system strongly encapsulates the enum class
Compiler does not allow it
fuck
That is extending enum directly
technically altering bytecode could allow some bizarre stuff but thats a nono
Which would get rid of the enum flag and thus allow to extend the enum to thus create instances of the enum
That is as soon as you use ASM to get rid of the enum access flag, you can use that hack
ye
I use this actively when modding other games written in java
dayum
asm looks cool
but i dont get anything about it and it seems that i have to be some type of genius with a degree to learn its basics lmfao
oo lol plugin.yml ones is my plugin version
i was telling about spigot version of plugin
i had this in my maven
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
but it 1.18.2 server its telling that my plugin is up to date
Are you sure that you need to do what you want to do?
yeah
And what is it for?
Updating the version of the spigot-api you bind into has only moderate effects unless you need some shiny new API
i just want to update it
anyone got a "preferred" heuristic for A*
I know that in 1.8 you can edit the nbt of an item. In 1.17 is this possible / how?
Update what? If you think that this will magically get rid of some warning message you are mistaken
Probably yes through NBT API and others. Though PDC is recommended for 90% of actions
https://paste.md-5.net/amuwalesek.bash why do i get this error . I call initialize in the main class onEnable();
hey, so i have a hashmap to apply an inventory to a block, but idk how to create AN inventory FOR the block. Like i know how to create an inv but idk how to do it for the block
and plugin supported the server version is 1.18.1
so i want to update it to 1.18.2 for my server
thats it
How would I send a message to the chat? (Not via command, just send a message)
Bukkit.broadcastMessage();
this will send the message to everyone
if you wish to send it only to few players, use Player.sendMessage();
what
you wish to add an inventory to the block so that when you click on the block it opens?
what do you mean? Just create a new Inventory using Bukkit.createInventory
Theres only broadcastMessageEvent
weird
how is that weird?
you need to do Bukkit.broadcastMessage(), not just broadcast
you didn't even enter Bukkit
ah
0/1/-1 (as a way to show SWI)
?
nvm then
so that the user can know the result of the method
if it succeeded or not
how do I color text again?
ChatColor.translateAlternateColorCodes
just use a boolean? sorry i didn't follow the whole conversation
what's SWI?
obviously if it returns an int, it's not a void? ๐
Ehy does anyone know which craftbukkit file https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/entity?at=refs%2Fheads%2Fversion%2F1.17.1 holds the player gameprofile?
Software Interruption
idk what to call it so i called it what i heard in an ASM tutorial
since 1.18.2 there's "PlayerProfile" in Bukkit
or maybe also late 1.18.1
before that, there's only GameProfile from mojang's authlib
yeah but i'm wondering for 1.17
com.mojang.authlib
yes so where is any detail about the skin stored in craftbukkit?
I heard that .getItemInHand is bad, what is the best way to get the item in a players hands?
well ig so, but u might have special cases
like -1 for example
so i'd stick with short
somePlayer.getInventory().getItemInMainHand())
you could use an enumerator
u dont need a i32 for stuff between -1 and stuff eitherway
like EnumReturns
yeah, use enums instead of weird numbers ๐
what about off-hand
Makes sense
obviously it's getItemInOffHand then
but i wouldnt say
theyre weird
anyone would understand them
its like saying u dunno what 404 means
well it's weird to say "-1 is this, 0 is that, and 1 is something else" if it doesn't actually have something to do with numbers
i mean it makes sense that 0 means success, 1 means fail, -1 meaning invalid input or some type of unexpected error that should not happen
hm not really, that's basically what enums are for
1 could as well mean invalid input and -1 could mean fail
Not imo
then go for it
Im sure java used that system in some methods
but its documented
in fact many methods
probably because enums were added pretty late
I don't know any tbh ๐
ive seen some though i cant get one of the top of my head
@tender shard
so if I change it I can technically change the player skin e name?
you can only change the skin if you also have a valid signature for it
Ok
CraftPlayer has a public method getProfile()
anyone?
First of all you need to pass the instance of the main class as the first argument.
Then you need to do new Runnable(); and inside that part write your code
scheduleSyncDelayedTask(plugin, new BukkitRunnable() {}, delay);
code inside the {}
you can expand it into multiple lines like a method
You shouldn't need to do anything I don't think there were any nms changes even
you should probably validate that is the correct block before removing it
They update the methods idk lol
Sometimes you don't have to do anything all depends if your using nms or not
can someone help me decipher https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/attribute/AttributeModifier.Operation.html
declaration: package: org.bukkit.attribute, class: AttributeModifier, enum: Operation
this doc is poorly written, don't really know the difference between them
Cuz technically if you use 1.8 you can automatically support up to the latest without changing anything granted you don't use nms
Anyone got a better way of doing this? this was the best way i could think of
How can I convert a chunk to a location?
a chunk covers a lot of locations
u dont need to do new Object[0] if you have no arguments to give
oh nvm
i see u have a thing
make an AbilityManager
And how can I get one of the locations of a chunk?
But z and x is a coordinates for chunk, no for location
wha- what are you doing?
This code only produces Check 0, I assume It is because of the first If statement. How would I be able to check it correctly?
if you want to get a Location object from a x y and z, use the location constructor
And what would that change?
learn java
what is that Ability class even supposed to do?
I have the x and z coordinates of a Chunk object and I want to be able to teleport to that chunk.
Uh to execute abilities
To be called by items and such
- Your "customConfig" class shouldnt be named like that.
- You only use L For Long literals
- Your class name should be more descriptive
- Your event name should be more descriptive
- you dont compare blocks with ==
- you're static abusing
it took me a moment to realize customConfig is a actually a class u made
and get() is a static method
theres no difference between 1 and 1L only a few bytes more space used on your disk
There is, its convention
and its 1 byte
its 1byte?
also
Isnt that 8 byte difference
why would it make difference
Look at my newest code I dont even have an L there anymore?
i should make a abilitymanager but idk if i should
the math aint mathing
Oh i meant memory wise
and 8 bits
nope
What are you on about with the L?
fourteenbrush i dont really see a point in making a separate abilitymanager since well it will only have like 2 functions
lol if you dont need the zeros dont add them
i meant
and i am not understanding what that class is supposed to do
void o(long x) {}
o(9223372036854775807);
this will error
However
o(9223372036854775807L);
will not
should i just show a use of it?
since as i said the compiler's gonna read it as (int) 9223372036854775807
without the L
yes
working with an object array kinda hurts
@EventHandler
public void onJoin(PlayerInteractEvent e) {
Ability.call("test_ability", e.getPlayer());
}
ah yes
on join and player interact event
im amazing
- 2 methods are enough for a class of its own
- methods*
kinda statis abuse
methods are functions tho
function pointer where ๐
Not the most correct term though
hm?
depends
I mean
methods are just syntactic functions where first argument is the object itself
also an ability isnt supposed to call one of its instances
so thats why i would make an ability manager
thats not how to think in oop tho
java isnt only oop
it has functional style as well ik
i see okay
oh well that's true
redesign the whole thing lol
can you tell me about the static aboose part?
hadn't really thought about that
we have tags on this discord?
I mean not using statics seem like a waste to me
since abilities will only be loaded once
technically everything only gets loaded once
that doesnโt mean you should use static for everything though
it's not about that, it's about design
lets code the whole plugin static then
ideally only utilities are static, because they have no state
yea
a bunch of abilities is state, you don't want that static
So do i just need to make it not static and find a way to get an instance from somewhere
ye
make an abilitymanager and instantiate it
Is there anything else?
i wanted to code but i forgot my disk was full and i counldnt install intellij smh
Can someone awnser my question?
you should be ashamed
vscode
:p
vscode isnt properly highlighting my errors
i think you need to save for it to update
notepad ide on top
btw so i should try to not use statics as much as possible right?
yes
and when is it acceptable..?
if you want behaviour that works for the whole class instead of a single object
or a variable thats shared with all instances
How to equal the block on interact event and a custom item block
Okay so um I have a debug class that is just a easy way to log debug info, it needs a logger instance without being tied to an object so do i just make a static logger and initialize it at the start?
How do you compare them?
you probably want to use == for enum types
enum types should be compared with ==
people are saying not to use equals because the Material enum might be changed to a class
?
why lol
like in a later version?
i heard that ye
so this should work right? if (event.getBlockPlaced().getType() == (ItemManager.disappearingBlock.getType())){
whats not easy about the java.util.Logger?
well in the case that happens use .equals() i guess but i sort of doubt itโll happen
besides it would break a ton of other things of that did happen
So like I have premade templates?
templates?
Nope
u werent doing that
at the start
u compared two objects with ==
but with getType() its two enums
I dont think it would be possible without the use of statics
@red sedgewat u wanna do
hey why is this throwing a nullpointer exception?
User user = essentials.getUserMap().getUser(player.getUniqueId());
String nickname = user.getNickname();
if (nickname.equalsIgnoreCase(player.getName())) {
return "None";
} else {
return nickname;
}```
essentials api
tryna make a debug class
it needs a logger
pass one to it then
null check it
^
"without being tied to an object so do i just make a static logger and initialize it at the start?"
wat
i would create my own logger class and let it override the getLogger method in JavaPlugin
Use your plugin logger
thats what im trying to say but he doesnt want to listen
Ugh
why
essentials might be null -> essentials plugin not installed
user might be null -> user not joined
nickname might be null -> essentials thing
to atleast use most of the plugins logger functionality
Is CraftPlayer.getProfile(); returning a clone or the actual profile?
What will be better way to communicate between proxy and servers, plugin message channels or sockets?
@EventHandler
void hoeLand(PlayerInteractEvent e){
Player player = e.getPlayer();
if(
player.getInventory().getItemInMainHand().getType() == Material.WOODEN_HOE ||
player.getInventory().getItemInMainHand().getType() == Material.IRON_HOE
|| player.getInventory().getItemInMainHand().getType() == Material.GOLDEN_HOE ||
player.getInventory().getItemInMainHand().getType() == Material.DIAMOND_HOE
|| player.getInventory().getItemInMainHand().getType() == Material.NETHERITE_HOE
){
if(e.getClickedBlock() instanceof Farmland){
Farmland land = (Farmland) e.getClickedBlock().getState();
land.setMoisture(7);
}
}
}```
Why doesn't this make my farmland wet so I can plant crops ?
Hello everyone, I come to ask for your help because I am stuck. I need to use NMS for my server under 1.17.1. I work with intellij idea. I have run Buildtools to get the 1.17.1 version as well as the remapped version. When I ask intellij idea to run the compilation of my plugin, it tells me this : Unresolved dependency: 'org.spigotmc
jar:1.17.1-R0.1-SNAPSHOT' (I modified the name of the files before to see if it came from that but no) I used the remapped mojang classifier but nothing to do. Help me please ๐ฆ
please make that main hand item a variable
or switch it
if(player.getInventory().getItemInMainHand().getType().name().endsWith("HOE"))
instead of what the heck ur doing
doesnt matter
lol
Hi, how would I define plugin ? I get this error. currently I am just doing Plugin plugin; because I don't know as what I would define it
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
you would define it... as your plugin?
you mean something like Plugin plugin = this.plugin? or this.plugin = plugin?
read the wiki link
Probably should learn some more Java then tbh
your plugin should be the reference to the instance of your class that extends JavaPlugin
Where can I configure the maven build target folder? ( where it'll output the .jar file )
using the maven jar plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>Start</mainClass>
</manifest>
</archive>
<outputDirectory>../out</outputDirectory>
</configuration>
</plugin>
this is what i got
Ok I'll try thanks
It puts the class files there not the jar itself
Trying to see why
Nope, still doesn't put the .jar
Ahh now it works, it was in the wrong plugin
The problem is, it's not working.
Wow seems like you helped him a lot :/
The problem with this code is that it doesn't execute it.
When I till a dirt block, it tills it, and then doesn't change the wetness of it.
You need to update the blockstate
Okay I figured it out.
Now the problem comes when I want to use MoistureChangeEvent
I use this
@EventHandler
void moistureChange(MoistureChangeEvent e) {
Farmland land = (Farmland) e.getBlock();
if (land.getMoisture() != 7) {
land.setMoisture(7);
e.getBlock().setBlockData(land);
} else {
e.setCancelled(true);
}
}```
And it won't set the moisture.
well
Farmalnd land = (Farmland) e.getBlock().getBlockData();
land.setMoisture(7);
e.getBlock().setBlockData(land);
e.setCancelled(true);
Is there a way to check if an inventory can actually have space for specific item ( it includes amounts, stacked items non stacked items all of that )
Hi I was trying to send a title to a player since on the jar I use there is no player.sendTitle ("") I saw that packages are used but it gives me an error. https://paste.md-5.net/etahamotux.cs
@EventHandler
public void onMoistureChange(MoistureChangeEvent moistureChangeEvent) {
Farmland landChanged = (Farmland) moistureChangeEvent.getBlock().getBlockData();
landChanged.setMoisture(7);
moistureChangeEvent.setCancelled(true);
moistureChangeEvent.getBlock().setBlockData(landChanged);
}```
Hi,
I need help with my BukkitRunnable(). If someone want to help just dm me and I will tell you what is the problem.
I don't want to spam here ๐
just ask here
lol
I changed to LongValueOf. Thats correct. But the plugin is still underlined
idk. Its what was written in BukkitRunnable examples
so what is the problem with "plugin?"
you never set your plugin instance
so what i should do instead of instance
like me..... Main?
or what?
i kinda dont understand runnables
@grim ice
?
@EventHandler
void replantCrop(BlockBreakEvent e) {
e.getPlayer().sendMessage(e.getBlock().getType() + "");
if (e.getBlock() instanceof Ageable) {
Player player = e.getPlayer();
player.sendMessage(e.getBlock().getType() + "");
Ageable blockAge = (Ageable) e.getBlock().getBlockData();
if (BetterFarming.crops.contains(e.getBlock().getType())) {
if (blockAge.getAge() == 3) {
if (
e.getBlock().getType() != Material.NETHER_WART
||
e.getBlock().getType() != Material.BEETROOT_SEEDS) {
if (!player.isSneaking()) {
e.setCancelled(true);
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("You cannot break this baby crop!"));
}
}
} else {
if (!player.isSneaking()) {
e.setCancelled(true);
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("You cannot break this baby crop!"));
}
}
}
}
}```
It never stops you from breaking baby crops, why ?
how would i calculate a kdr from 2 integers?
i want something that looks like 4.02 or 1.57
do i just kill/Math.max(1, death)
for some reason that gives 'integer division in floating point context' and outputs 0.0
kills/deaths
If I have a blockname as a string, how do I compare that to a block
block name as in?
someone can help me?
A string that is for example "STONE" how do I compare to a block
I know how to do with material
there is a method in Material to find them by name
you can do Block.getType()
could you tell me why i cant divide integers
from a base level
whats the difference between
8/2 and 8.0D/2
First one won't have any decimals
yeah but instead of 4 it returns 0 when dividing non factors
like 7/3
nvm i ge ti tnow
Do I have to import all the methods
bruh why
You shouldn't do that
use a constructor or a method of some kind to get a block
wtf is that
World#getBlockAt#setType might be something?
how do i get drops of a mob without actually having the mob class?
Like i only have the EntityType, is there a way to get the default drops of that mob?
Not with just the type, no
D:
what event should i use for when a falling block dies because i need something that triggers before it removes the entity, and EntityDropItemEvent is after
please use variables holy
But the same thing would happen
it would be easier to read what is going on
ok
nvm it does, but cancelling it and breaking the block below it doesnt seem to be working
Here
ItemMeta can't == another
At least more often than not it will not be referentially comparable
.equals() check it
Though I'd advise just doing ItemStack#isSimilar() instead so you're not cloning the ItemMeta each time
does the equals method clones it?
owh that
how would i check if something is on the perfect positioning that a block would be on
Ok so that fixed that but now...
Caused by: java.lang.UnsupportedOperationException: Use BukkitRunnable#runTaskLater(Plugin, long)
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.scheduleSyncDelayedTask(CraftScheduler.java:517) ~[server.1.17.1.jar:3284a-Spigot-3892929-0ab8487]
at me.oakswingzzz.customItems.Events.RemoveBlocks.removeBlock(RemoveBlocks.java:45) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.1.17.1.jar:3284a-Spigot-3892929-0ab8487]
... 21 more
it tells you what to do
@EventHandler
void moistureChange(MoistureChangeEvent e) {
Block block = e.getBlock();
Farmland land = (Farmland) block.getBlockData();
if(land.getMoisture() != land.getMaximumMoisture()) {
land.setMoisture(land.getMaximumMoisture());
block.setBlockData(land);
} else {
e.setCancelled(true);
}
}
For some reason, this is not working?
well add sysouts
??
system.out.println on place where you want to check that the code did execute
If you are tryign to keep it at max moisture you need to also cancel the event or you are being overwritten
show code
@EventHandler
void moistureChange(MoistureChangeEvent e) {
Block block = e.getBlock();
Farmland land = (Farmland) block.getBlockData();
if(land.getMoisture() != land.getMaximumMoisture()) {
System.out.println("Changed block's wetness.");
land.setMoisture(land.getMaximumMoisture());
block.setBlockData(land);
e.setCancelled(true);
} else {
System.out.println("Didn't change the block's wetness.");
e.setCancelled(true);
}
}```
looks fine
put that cancelling outside of the if else rrr
a hoe doesn't change the moisture level
hmm
hoe ground next to water, then remove the water. let the land dry out
a single block of water
It tells me to Use BukkitRunnable#runTaskLater(Plugin, long). Can someone give me an example?
?scheduling
All of that uses runTaskLater(Plugin, BukkitRunnable, Long) not runTaskLater(Plugin, Long)
same thing
use runTaskLater with a plugin, a lambda and your delay
Caused by: java.lang.UnsupportedOperationException: Use BukkitRunnable#runTaskLater(Plugin, long)
?xy
Asking about your attempted solution rather than your actual problem
If you are scheduling from the BukkitScheduler you use (Plugin, runnable, long)
but since you already have a runnable and you are running the task off that instance you just input (Plugin, long)
github amazes me sometimes
one time I had to commit a file that was never even changed, and it even said it wasn't even changed in my IDE. Smh.
?
it's supposed to look like that if you remove the whitespace ๐
oh
on intellij it shows no difference
Your IDE (or local git) might ignore whitespace changes in the diff
Honestly, GitHub might have a toggle for whitespace
if your test server doesnt look like this then you're a certified chad
"cool worldgen plugin"
it even introduces blocks that will get you sent to the backrooms
lol is that like 7 minutes behind
3
same thing
and yes this is glitching around everywhere why not
theres also sussy ghost block holes
anyways can someone help me with "a little" debugging?
its not like a bug in my code but more a bug with falling blocks
and im not sure how to avoid it
basically, when i yeet a lot of falling blocks, they bug out
What is the reccomended way to grab Materials. I'm just curious as I know with Entities I've been using Namespaced keys I'm wondering if a similar approach is good for materials
getType?
materials are still a regular enum
but that's supposed to change in the future, maybe soon
md_5 said it'll be bytecode compatible, so I guess it'll be static final fields
like the Enchantment class I guess
what are you trying to do?
making a inventory lib for some personal use stuff and I don't want to come back in and have to change it later
if you wanna get materials by their name, just use Material.valueOf. That will 100% work in future versions too
okay
hmm I wonder wat the difference is
right now it's the same
yeah but Ctrl+B on the Material class takes a while ๐
my intellij crashed when I tried to decompile it
because of this fucking "minecraft dev plugin"
I don't use intellij lol I just go on the website
fair enough
yea its the same atm it seems
@Nullable
public static Material getMaterial(@NotNull String name, boolean legacyName) {
if (legacyName) {
if (!name.startsWith(LEGACY_PREFIX)) {
name = LEGACY_PREFIX + name;
}
Material match = BY_NAME.get(name);
return Bukkit.getUnsafe().fromLegacy(match);
}
return BY_NAME.get(name);
}```
yep a normal lookup table
neat
yea I'm not sure with this newer stuff because I recently switched from 1.12.2 from a while back so I got all this new crap too experiment with
pain
my first public plugin was for 1.13 and that's already 5 years ago lol
yea man server owners are wack
I think I'll make my obfuscator add some rick roll links into the code
that'd be funny
yea I'm sure you'd love to here the time I sold my premium plugin from 1.12.2 too a guy who used it on a 1.8 server and complained to me when it didn't work
like bruh I told you it was 1.12.2
lmao
no refunds hehe
I was hoping someone could help me with a plugin... it's perfect and works, but the language it uses when executing commands is broken english at best... all I need is for someone to help me edit the plugin to have better grammar... could someone help?
lol custom string encryption is fun
ugh
what a jerk lol
hm I would have refunded them
nah I was pretty explicit with the version requirements
I mean sometimes people are just blind and forget they have to watch out for the version
Its on them
Hey Y2k or mfnalex
yes of course but might as well be friendly and refund them. at least that's what I'd do ๐
do you think either of you would have a moment to help me?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
probably not the right place to ask
idk if anyone here would be willing tbh
Where should I look? not really sure where to go.
do you have no english friends?
I figure it should only take a few mins, I just am not tryna learn and setup eclipse for a simple issue fix
is that plugin open source?
Yessir
well you could probably pay someone a tiny amount to help you with this, but:
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
I'm also not trying to have it say MYSERVERNAMESPLUGIN IMADE IT
I just want it to not use "you paided PLAYER $100"
lol
yeah the guy knew java...not basic grammar.
paided
hehe this is why I put everything in a config I suck at grammar
that's going in my vocabulary
yeah I have to add this to my "SpigotMC <> English" repo
The idiot has permissions to make it work right?
Yeah all the permissions are not visible or listed. you gotta open the plugin to even view the code that adds the perms to find them out
I mean A+ genius programming but cmon why fall short on the simple stuff.
ehh you might be better off tryna figure out a alternative then
Sadly are none ๐ฆ
what type of plugin is this?
MultiWorldMoney seems to be a dead project/idea
it has way too little entries
multi-server?
or multi-world
thats very easy? you can do it with things like essentials?
Essentials doesn't support a perworld economy that I know of.
Yea I mean don't judge me... it's a long story.
bungeecord?
But it works for what I need it for... and it's the only option I can find.
if you want multiple servers get multiple servers
Spigot
@limpid pebble Do you have any IDE installed, like IntelliJ?
dont have 5 servers on one server
nah, I don't work on java stuff I'm a SQL and webcode like CSS/HTML kinda guy
ok
if you know basics of sql and css/html you are also able to change strings in java code ๐
yah im not an idiot I just need a nudge or help something lmao
Man I can even see the text I need to edit when I open the jar as an archive, i just can't touch it w/o breaking things cus it's not the right kinda editor.
Downloading Intellij rn
- Install IntelliJ
- Copy the URL of the github repository
- in IntelliJ click on File -> new Project -> from Version COntrol
- Insert the Github URL
- Go through the files, adjust the messages
- come back here to ask us on how to compile lol
nope you cannot just open .jar files, they are "compiled"
you said it's open source?
All I got to work with is a jar, his "sourcecode" link is to a game he made.
ugh
Yeah, I guess he's switched source code link to his shitting 2d gameengine game advertisement.
well if you only have a .jar file, it's way more complicated
Fuck.
you'll have to decompile it, then setup a proper classpath / environment stuff etc
then compile it again
not really complicated but quite annoying
Yeah, that sounds fun.
you got a link to that plugin?
Like I said it works great, I just wanted to remove the "TheMultiWorldMoney - TMWM" tag on every message, and fix the grammar
Are there any? I have no clue what I'm lookig for so after 4 pages of google I concluded it was a lost cause and this was the only one
hm well if you just wanna replace some strings - I today wrote a tool to replace strings inside .jar files
you're kidding, really?
Do I just enter my bank info and SSN and then click "run"?
exactly
Lmao I'll try it, I don't need anything fancy!
yeah well let me have a look at the source of this plugin
All you man. Thanks for your help alex.. really.
This is literally THE FINAL PIECE of my puzzle that has been the past 4 weeks of my life.
why is the grammar of that plugin page so horrible lmao
Man, I have no clue. I think English is his fifthenth language judging by quality.
they are even using bash color codes
And he has a tag for EVERY MESSAGE THE DAMN PLUGIN SENDS
And it's a FOOTBALLFIELD LONG
"TheMultiWorldMoney - TMWM: you paided player $69"
Lit.
You're my hero.
if it means anything guys
This community has shocked me. Most of my programming discords are full of entitled assholes. myself included.
I appriciate the info and help
if y'all weren't would you be good at programming? 
You can use this and do the following with my tool:
java -jar JarStringReplacer-1.0-SNAPSHOT.jar nameOfThePlugin.jar output.jar '[33m[TheMultiWorldMoney][0m " ""
this should get rid of all the "tags" / prefixes and save the file as output.jar
I am not allowed to send it here though because it has spigot shaded into it
I can DM it to you. do you have git bash installed?
I friended u so u can dm it
no I don't
and can I fix the grammer with it at all?
hm well
look at this
you'd have to enter exactly "Group<weird symbol>[0m" to replace that part, for example
so tbh
I'd just look for a proper multi world eco plugin instead
Reading Java is like doing a line of crack and trying to do calculus with a 5th grader...

