#help-development
1 messages · Page 2240 of 1
plugin.getDataFolder()
plugin being an instance of your main class
To pass that around you can use di
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
is there a way i can get around the fact that its nonstatic
🙃
This
Is NMS imported to your project
Also if you're on a modern version you can just use p.getPing()
it doesnt help?
Look at this @feral prairie
It does. It tell you how to pass around your plugin instance so you can use to get the data folder
?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
?nms
im blind or something
So it does go neg?
Yeah I think it turns red when it's negative
if u get them in 1.8
dupes
hm on the server its an int
It's patched as far as I know
Not in the packet iirc
nah prob not
Inventory.setItem?
so after getDataFolder() what do i put after to make the file with a name i choose?
that's because they didn't bother micro-optimizing the server
also tf is color
in the data folder?
it says TAG_COLOR = "color" but tf does that do
for the name or smth?
im trying to create a config folder
File file = new File(datafolder, filename);
Inventory::setItem
they should
if theres one thing to optimize the most its the server
Either leather armor or potion
They aren't making money on it
probably both
well otherwise noone would play
multiplayer pretty important
Bump
I mean of course a non functional goal in any production is speed performance and space performance
But usually it’s only worth to optimize something to the extent that you’ve reached the non functional goal as a functional goal
yeah but especially in game servers i feel like its a pretty important goal
its a good design choice other than it being an abstract class you lose nothing by implementing that as an interface
so with File file = new File(getDataFolder(), "about_us.html"); where would it make the file
I dont know if my database class should be creating player objects or there shpuld be a separate class for that
it makes it easier to support multiple types of databases that is a win any way you cut it
Yes
Depends
you can store common data in there and create abstractions for base methods so it could be a good choice
where is yes?
not everything should be an interface
you need to do .createNewFile for it to actually exist
I mean the most actual significant optimizations will come from java itself
the way he has it implemented there is no reason in it being an abstract class it has 0 implementation
Like project loom, panama, valhalla etc
true, but maybe in the future
where do i add this
I mean you do want to depend on abstractions and be able to unit test stuff
if it doesnt need to be multiinherited id leave it as an abstract class but it doesnt really mmatter
You call it on the file object
how do you end a scheduler
?scheduling
BukkitTask::cancel or BukkitRunnable::cancel
mainmenu.setItem() instead of Inventory.setItem()
Get the taskid and cancel or get the bukkittask and cancel
Bruh
im so lost
Ofc you need to call that method on mainmenu
I have a feeling your knowledge of Java is lacking. You might want to consider taking a java course to learn the basics
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Nice timing on that one
That was for someone else too😂
😹
i understand a bit i have made mods with fabric but im brand new to spigoit/bukkit
you said that very kindly lol
im trying to port my mod to spigoit
what
Instead of Idot. Learn java
some people just say learn java first
which i guess is ideal
Java isn't Spigot specific
You set the meta after putting it in the inv
but i didnt have motivation to learn java without spigot additionally
didnt have full positives
You should learn it before starting with Fabric and mods too
but many are like that
yes but i dont understand a thing about spigoit i know how to code with fabric
i ended up only learning what i needed for basic plugins at first
fabric isn't a programming language
Spigot is very near just Java classes when it comes to managing files
idk if fabric is that as well
but you'll eventually have to implement your file management system using File, Files and Path
You should be passing around objects when using Fabric
i do, maybe because im more familiar with it
Can you please explain, describe, complete your question?
Like to know that the player have set the 2 corners
Yeah
But there is no difference 🙃
java is java no matter where you use it
It's the same programming language
A map
For pos 1 and pos2
Item with index 6 is null, why?
Im doing a wand (an axe) for claiming. So you select 2 corners and them via a cuboid a region its generated
you could also use an array for storing pos1 and pos2
Save the pos in a map
I have a class tyat does this
But I'm not at my computer rn
And for creating the cuboid i need the 2 locations already
Actually, you need to put ItemMeta item2_meta = item2.getItemMeta();
simply use a array with 2 slots then
You should only save the two corners, it's way more light
verano basically you wanna map a player to the pair of locations
That's what i said
ye
No i just want to kno how to keep the locations for them building the claim/region
and for that you need to store them in relation to said players
which ends up requiring a map like structure
or well if you dont want to manage the map yourself, use PDC or Metadata
if (plugin.hidePlayersFile.getcFile().getBoolean(String.valueOf(player.getUniqueId()))) {
player.getInventory().setItem(8, LobbyPlugin.getInstance().items.hide);
for (Player pl : Bukkit.getOnlinePlayers()) {
player.hidePlayer(pl);
pl.hidePlayer(player);
}
} else if (!plugin.hidePlayersFile.getcFile().getBoolean(String.valueOf(player.getUniqueId()))){
player.getInventory().setItem(8, LobbyPlugin.getInstance().items.Visible);
for (Player pl : Bukkit.getOnlinePlayers()) {
player.showPlayer(pl);
pl.showPlayer(player);
}
}
Why is this not working and always giving me the second item?
Ok Verano:
-
- Do you need to save the two locations?
-
- Do you want to save them in memory or storage?
My cuboid constructor is: Cuboid cuboid = new Cuboid(Location location1, Location location2)
myes
now perhaps define a field in your player transfer class that caches a given cuboid
And them i have a claim object which save the id, owner, cuboid, etc
let me send code
idk, perhaps share the config
@sterile token ask your question pls 😂
the config seems to be working
myes but if the value is false or well strictly speaking not true then its by definition false
BukkitTask taskID = Bukkit.getScheduler().runTaskTimer(plugin, new Runnable(){
@Override
public void run() {
System.out.println("a");
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(counter[0] + "/" + String.valueOf(cooldown)));
if (counter[0] == cooldown) {
taskID.cancel();
}
counter[0] += 1;
}
}, 0, 20);
this doesn't work what is going wrong
who knows
hence why it probably fails your first if statement
mind showing us a bit more code? like where you defined the counter variable
What happens when you run it
but when the value is true, it doesn't do what i defined
I mean, I would trust your code more than what I'd trust you in this case
it says
Variable 'taskID' might not have been initialized
What's the problem
wdym
oh yeah tapwatero
ok so would this create the file?
you probably wanna go with Consumer<BukkitTask> instead
mwell, you ought to pass the datafolder of your plugin
Yeah but be aware of possible memory leaks from the input stream
Also you probably want to place your files in your plugin directory
Consumer<BukkitTask> taskID = Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
like so?
no
memory leaks? so a file would be created in the server area right?
Why are not using yaml or json?
int id
Bukkit.getScheduler().runTask(plugin,task -> {
task.cancel();
});
Not consumer
nah simpler to streamline with the rest
simpler with the other versions also was supposed to be .html
like this
I dont understand what are you doing tho
im making a website
You need to close the input stream or you will have a memory leak
thats for backend tho
Use try with resources
^^
Its allow to render views
Imagine using SpringBoot in 2022
server sided rendering Id assume?
yeah
SpringBoot is quite popular
ktor :3 (frontend tho but still)
so .close()?
It’s heavy is what it is
Use try with resources
You can look eveyr methods on the javadocs they are free!!
FactoryFactory says hello 
LMAO
FactoryFactoryFactory
oo
I wouldnt built websites on java, instead i would use NextJS (javascript fullstack framework)
AbstractMediatorFactoryBaseImplFinalizableConcurrentFacadeFactory
Nah wtf
yeah altho with that being said
java has a html framework
iirc
but its pretty shitty
Yeah i know
Yeah go and see the oracle website and told how great its
HAHA
now how do i run the server, i only ask cause this is maven and i have only used gradle before
yuh, I mean it was pretty cool when size mattered, but there are definitely better alternatives today
“Pick a bad example of a website as proof that the language it’s built with sucks”
I can build a shitty website with js
Java has great performance and with the right framework can be an exceptionally good choice
Java is not the best for websites, websites league are between Python and Javascript
the same way you'd run any other server 👀
the spigot server has nothing to do with neither maven nor gradle
^even the future of Java looks unorthodoxly bright
If you’re using python for a web backend you have no interest whatsoever in it performing well lmfao
on gradle theres a button that says run server this isnt here
lol
And Java and JavaScript are not mutually exclusive
should have stayed w/gradle imo :3
You can have a Java backend serving a JavaScript frontend
no fabric preconfigured a test environment in their gradle build
it was gradle including it
bruh just do
HttpContext context = server.createContext("/");
context.setHandler(website::handleRequest);``` done
o so i need to build the jar file?
your plugin != The server
so you need to build the jar and run the server unless you configure something yourself
so which one
Have you seen how works maven atleast?
Try to guess
why are you using maven if you don't know how to use it
Agree
Also that are the maven things for building
cause it was the default
and idk how to change
They should be package, compile, install, deploy
👀 intellij legit gives you an option to use gradle with java
^ take the opppurtunity
Wouldn't surprise me if they don't know Gradle either
they kept talking about gradle so I figure they atleast must be semi-competent with it
I'm surprised you survived using fabric
so which setting do i use to change this
Fabric is way harder than spigot
And gradle as well
you only say this because you weren't spoon fed a test environment and haven't the slightest clue on basic compilation and servers
you need build tools
run it
get the server jar run the server
maven > gradle
ye on gradle its easy
no it has nothing to do with gradle
its how fabric set up their environment
how many times do I have to say that
ok
maven has package and clean
yankees
all you’ll ever need
you can use paperweight (gradle plugin)
but that means fabric is easy
and everyhing becomes extremely easy
can someone answer this
Change what
what does setlevel do?
nvm
it sets the xp level probably
Well it's easy to consider smth we know as easy, as well that smth we don't know is hard. Spigot is quite simple to handle quickly, and has a pretty detailed wiki which explains how to make your first plugin. You should take a look at it before put the blame on the difficulty ;)
Also knowing the programming language you're coding in helps
knowing gradle or maven helps a lot too
ok thx
I'm confused why you opted for maven
how do i switch it to gradle
Best advice: restart from scratch
no clue how to on intellij I'm sure their's some easy way
hard to restart from scratch when you are trying to port something
You need to hook PlaceholderAPI if you want placeholders from it
I have a maven project with 3 modules, core, spigot, bungee. Bungee and spigot depends on core. how do i build a combined jar?
I imagine their page has documentation on how to reference it
i tried shading spigot and bungee into code but that leads to issues sine spigot and bungee depends on core
you dont shade spigot and bungee into core, but shade all 3 into the root project ig
one sec
cant do that
<groupId>me.saif</groupId>
<artifactId>AltLookup</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
packaging is pom
i cant make it jar
so creating a module to have the output jar is the way to go?
i thought that was hacky
Wait why are you shading Spigot and Bungee 👀
I hope you're using the wrong word there
those are the module names
I've seen a lot of people do that
shade spigot and paper 😎
what happens if i send a client chunks they've got no business rendering, then teleport them there after a moment?
do they retain those chunks?
Try it and see I guess
?tryandsee
third is ?paste
ye for sure
?main
We need command for https://offlinemo.de
true
yeah lolw
I have that one in my quick copy patse though
thats not how youre supposed to use domains
for (Player pl : Bukkit.getOnlinePlayers()) {
player.hidePlayer(pl);
pl.hidePlayer(player);
}```
how can i make so when a new player connects, it still hides?
i was thinking in offlineplayers but that doesn't work
do the same thing in onPlayerJoinEvent
^
may I suggest: 👆
HELP
i just deleted my entire project with maven
AHHH
how to undo
i accidentally set the wrong build directory and it cleared everything
omg
so when is onEnable(); run?
FUCK IT DELETED ALL MY PROJECTS
WAT
safe delete i hope
but the problem is when the player join, the people that were already in the server can see them
you can supppress the messages
i dont know which of the join events you need to manipulate though
for (Player pl : Bukkit.getOnlinePlayers()) {
if (plugin.hidePlayersFile.getcFile().getBoolean(String.valueOf(player.getUniqueId()))) {
player.hidePlayer(pl);
pl.hidePlayer(player);
} else if (!plugin.hidePlayersFile.getcFile().getBoolean(String.valueOf(player.getUniqueId()))) {
player.showPlayer(pl);
pl.showPlayer(player);
}
if (plugin.hidePlayersFile.getcFile().getBoolean(String.valueOf(pl.getUniqueId()))) {
player.hidePlayer(pl);
pl.hidePlayer(player);
} else if (!plugin.hidePlayersFile.getcFile().getBoolean(String.valueOf(pl.getUniqueId()))) {
player.showPlayer(pl);
pl.showPlayer(player);
}
}
I tried this, but didn't work
theres like three
?
It's ran after onLoad(), it's where you'll want to register your events and commands. you use onLoad() to check if you're reloading or if the server is starting up
You're probably missing the plugin.yml or smth
can u give us a screenshot of your project tree
its not that the files are missing then
what about the console, are there any errors there?
?main
;/
How did you build the jar
im assuming you use maven if your tree looks like this
the highlighted one
Use package
?
Above
run button
the one named package
Might not be set
point
Yes
what are the folders for
ok
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
What's ANSI
lemme guess you cancelled the drag event
what should my package be named
no
Nms
yes
still shows 0 plugins
he meant static classes
of these events
what's a good "fail" sound
ghast cry
uh-
no like
for example a user searches for a player with a command
and the command couldn't find any player with the provided name
anvil breaking
😦
my files are curropted
k thanks
yeah that sounds better actually
@feral prairie can you hit the run button - the green arrow to the right?
k
still didnt work
Or Map<Key, Object>
NONONONONO
whats your maven config? @feral prairie
i'm legit done
You could, but that would be somewhat inefficient
you want me to send my pom.xml
Why would you recreate the spigot API when you could use the one that’s already there
or build.xml
The map won’t be any different under the hood, it treats everything as an object anyway
ah no. lmc my project
What are you trying to do
?paste actually that might be useful. What did you do to make your maven tab look like that though? Mine is just a line above my files
@feral prairie i suggest using this website, its much less painful for everyone involved
actually thats a good point
what version do you want to compile for
1.19
remove the 1.13 part then and try compiling again
also
post your plugin.yml
and please use the paste website
Then why are you throwing any argument exceptions
The map shouldn’t be accessible to the end developer
ok
You shouldn’t make your exposed methods take Object
There should be a version of the method for each chat event, which is what spigot does
The underlying map doesn’t matter
THOSE two share event at the very least as superclass
No
No they don’t
They aren’t events as in things you can listen to, they’re the chat events
public void a(ClickEvent event) {}
public void a(HoverEvent event) {}
still didnt work
plugin yml please
There is no superclass they both extend that isn’t too generic for your use case
Throwing a bunch of exceptions is not desired behavior
net.web.plugin is a package, not your main class. While not suggested to use main as name, if you do change that entry to net.web.plugin.main.
You should ABSOLUTELY fix the way you name your stuff though
i have no clue but apparantly its a naming convention
thats not the important part though
if you dont point your plugin yml to the class extending javaplugin it cant load
what should i change it to then
i said afterwards
for how you named your stuff
the right way to point is net.web.plugin.main
then whats worng with my current name
not wrong per se
so like this
yea
any message in console?
you definitively fixed AN issue, apparantly it wasnt the only one
That’s fine?
no
You have can both methods with the same name that take a different parameter type
try replacing your weird version string with 1.19 tho
[Server thread/ERROR]: Could not load 'plugins\bukkit-sample-plugin-0.5.jar' in folder 'plugins': uses the space-character (0x20) in its name
maybe thats the issue
@feral prairie @smoky oak @quaint mantle you don’t name your main class “Main” because of the Java naming convention, that dictates you should be specific as to what your program is in the main class. If every piece of code had their main class named “Main”, it would be extremely confusing as to what was what
Why not
in other words it failed to load because the name has a space in it. I know the reason for that actually
ah ill change it once i get stuff working
it's because spaces in minecraft separate strings
in other words if you refer to your plugin you cant
because it thinks the words after the space dont belong to the name
JDBC is not an ORM.
And you believe the distinction to be what?
remove the space and recompile
So yea, you get to "relate" your tables as much as you could with SQL
that is all that JDBC does for you
SELECT and JOIN
sender.sendMessage(MiniMessage.miniMessage().deserialize("<rainbow>Hello world</rainbow>")); Is there an import to make MiniMessage work? I'm getting an error that it can't resolve the symbol... I'm very new to java, so if this is super dumb, I apologize 😅
minimessage and components are paper-api land
if you want to use it on spigot you will have to use the spigot platform adventure offers
I see, how would I use the paper api? (My server is indeed paper)
you would switch the dependency. Tho you might be better off on the paper discord 🙂
so the plugin loaded but it did run and thing onEnable();
it be there on /plugins now`?
You can store all the information about the message but you still have to make a new object whenever a message is “sent” to a player containing that information anyway
yep
k
It’s not memory inefficient, Java can churn through millions of objects without any difficulty
dont know if this will help ```[13:38:55 WARN]: Legacy plugin Website-Plugin v${1.0.0} does not specify an api-version.
[13:38:55 INFO]: [Website-Plugin] Loading Website-Plugin v${1.0.0}
The issue arises when you leak memory, or retain attachments to objects you no longer need
replace what?
Is there like a page that shows all the different imports and uses for Spigot?
Java is designed to support the constant creation and destruction of objects
make §{1.0.0} into 1.19
o
its the version identifier
Even if you just stored each message as a static string there would still be a new object created to send them whenever you tell the api to send it to a player
no
just major version
1.19 is applicable for all 1.19 version (1.19 as well as 1.19.1 and 1.19.2 if they were to be made)
i thought it was plugin verison
thats the version number in your pom, that 0.5
There’s object oriented languages and runtimes where you aren’t supposed to dynamically allocate objects and let them get destroyed often
For example, C# in unity
But Java isn’t designed to restrict you in that way
Heck, whenever you get an item stack from an inventory it’s a new object
You’re mutating your copy of the item, that’s why you have to set it back into the inventory when you’re done modifying it
careful with vectors though
those dont duplicate when you do math on them
I'd say ask in the intelliJ discord but since they've got that stupid 2FA requirement ill just say i have no idea
still didnt fix the main issue
and that would be?
what does the console say?
just [WebsitePlugin] loading or something or does it still give an error
it says it loaded
but after everything
java.lang.NullPointerException: Cannot invoke "java.io.InputStream.readAllBytes()" because "is" is null
at net.web.plugin.http.website.inputStream.main(inputStream.java:17) ~[?:?]
at net.web.plugin.main.onEnable(main.java:32) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:479) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:520) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:434) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:582) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:401) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:255) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:966) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:291) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at java.lang.Thread.run(Thread.java:833) [?:?]
you forgot to assignt 'is'
Where do you declare inputStream and file ?
the highlighted part?
The only part of the code called is the onEnable and onLoad that your overwrite
in other words your InputStream isnt properly registered for some reason
So you have to declare your variables there
strange
There isn’t one
its probably because you're not using JavaPlugin#getResource but InputStream.class.GetResource
yes?
Save what
that is the line with the issue. That method throws an error because the inputStream isnt assigned
you need to assign it properly
the way you do it it gets set to null which causes an error
Ohhhh sorry I thought inputStream was a variable but it's a class (Always put an UpperCase in front of a class name)
o opps
@feral prairie Just read the errors, it says where the error is and most of the time tells you how to correct
Here it's the way you get the inputstream that didn't work (maybe the file isn't found..)
the file isnt there
but its supposed to make the file
No, you're just reading it
o
i understand
so it would read the file
from resources?
right
i forgot to copy the resources
Well how you're doing it is : it will check if there is a folder html and a file main.html WITHIN THE JAR (not a directory outside the .jar). And if there is one, it will read it as a Stream
So check in your jar if there is that html file (you can open it as an archive)
But are you actually packaging it into the jar?
So in your IDE, under the resources folder, create a html folder and put your file in it
Have you checked?
it works now
ye i did
Perfect
is this structure good?
java is the src folder meaning that maven is going to use that to compile the plugin right?
it was going good until there were about 15 classes in just .skywars
yes
alright, all these errors appeared as soon as I set java as a src folder
imagine minecraft
I'm just figuring things out
alright, all these errors appeared as soon as I set java as a src folder. Why is that?
whats the error
if ur using maven (or gradle even), all ur java source code goes into src/main/java
../Documents/cock/ lmao
shhh
this part looks good from ur screenshot 👍
Serialize it's location (world_name, block_x, block_y, block_z)
I love Adventure API
it makes debugging easier
just plop Component.text
and any typed value
and bam
its instantly serialized to string
without specifying to do so
and it works with primitives too
I'm getting errors such as: package com.shampaggon.crackshot does not exist
Bukkit#getWorld to get a world by it's name. Then World#getBlockAt if my memory is good
errors that I had before I supplied my pom with dependencies. Maybe I have to do something similar again? @buoyant viper
Because OfflinePlayer has it
How would I remove or change the UUID sent on a chat event?
Update Protocollib. Also use #help-server next time
Just cancel the event and announce <username> message
No, I want to support chat formatting plugins
Or I could just make my own chat formatting plugin lol
Yup, most plugins support PAPI
Why are you trying to change the UUID? To prevent those chat reports?
Yep, chat reports
Or, e.getFormat();
Event#getFormat(); not sure.
its not out yet who tf knows
how would anyone know how to remove it if its not even in the API yet
I thought chat messages have always included uuid
Not always
no they haven't always been signed
Like forever
Right now all messages are sent as system messages. So you can't report them. Until this is fixed it's fine
My first pub plugin gonna be disabling that lmao I just want a plugin to get downloads ahaha
If you want to be extra safe use Protocollib and change the UUID in the packet
lol
whats the weird "unsycronized chat error" ?
There's gonna be plenty of plugins that do that
only cuz fabric is so damn crazy fast at updating
I thought it only supported fabric servers
fabric is literal crack at updating
fabric is cool
They have the most goated modded API
I've never made a fabric mod but I've heard it's easy
In Liveoverflow videos, I think he used fabric
I personally didn't stick with modding because I prefer making plugins
Forge isn't hard though
dude liveoverflows series is amazing
nah but its more annoying imo
forge gives a good testing environment too ig
I've tried both but it was a while ago I just remember forge being annoying and also I heard it was annoying to update
if the update tools are so good honestly I'd like to know why it takes so long for lots of mods to update if its a CLI app
Because updating from versions older than 1.13 requires a full rewrite
no wonder it takes so long for all the good mods to update lol
too bad a lot of creators abandoned their projects too
Personally I just play with a few fabric mods and prefer to write server side plugins
Plugins are universal
I think fabric might outpace forge eventually 🤷♂️ but it might take a super long time
And have been around for longer than server side mods
when did this got added in intellij
neat feature
no more right clicking into context menus
i guess
I disabled it as it mainly came in the way imo
But ye might be useful in case you don’t wanna use keybinds for whatever reason
This is the latest version
Dev builds
whats easier for server to process? sending a window items packet with full inventory itemstacks (like cancel event), or iterating through inventory view and sending set slot packet
does it make any difference
in terms of performance
is it harder to send bigger packets than to iterate and send a smaller one
What means this error: "only whitespace content allowed before start tag and not \u0 (position: START_DOCUMENT seen \u0... @1:1) " it happens when im doing mvn install
Well if it's always the entire inventory the performance difference is negligible as far as I'm aware
Yeah ^ if you’re always sending the entire inventory it’s roughly the same traffic either way
Might be a tiny bit faster to pack it all together into one, but it’s not likely to be a significant difference
You have a bad character in your pom
getPlayer().getPlayer().getPlayer().getPlayer().getPlayer().get<dies>
when adding a default config how can i create default sections
like
config:
hello: "world"
for example
If you're using the built in system you can just add that to the config in your jar
sorry?
How do you give a player HASTE effect
like every other effect ig
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
FAST_DIGGING should be HASTE but im not sure
So, I keep getting a message saying my Inventory is null, and I can't figure out why.
Command Executor:
https://paste.md-5.net/axipugomec.java#
Inventory Class:
https://paste.md-5.net/xoqifotiri.java
Main:
enchantmentclick.createInventory();
(I have this running)
Most of it you can ignore, but I have a feeling it has to do with an error in my creation of the Inventory, (or that i have multiple instances of the same inventory accidentally) If you see the error, please let me know! im knew to this
you are never setting invCTF
beyond that, your listener is eh
well
those methods should not be static
you are missing the @EventHandler annotation as well
yeah, its not fully done yet, but i know theres a lot wrong with it lol
how would I set it? cause i thought i did that
Welll ```java
Inventory invCTF = Bukkit.createInventory(null, 9,"invCTF");
it creates a method scoped variable with the same name
ooooh ok, so how would i set it?
just invCTF = bla bla bla
oh, well thats simple enough lol
generally speaking, the further you progress when learning java the less static state you want like this
that makes sense
So I'm trying to place a block that's in my off hand through throwing a snowball, but the off-hand item is an ItemStack. This is a problem because in order for me to place a block using location.getBlock().setType(), the "()" inside setType() need to be a Material. How would I do this?
Call getType() on the ItemStack
Would I check if the type is a block and then go from there?
Yes
I tried that but it never seems to be a block even when it clearly is
What material is it
Stone
nvm i just did getType().isBlock() == true
thx
== true
lmao
i dont wanna hear it rn 😭
if true == true
Hey guys !
I was wondering if it was somehow possible to change the range of certain sounds ? 🤔
lower the volume or something
you can also just not play it for people outside of the range
but that messes with packets a bit
does this class name make any sense? "EvenlyQuestionDistributor" -> https://paste.md-5.net/akokajagut.java
It's used to stop my quiz bot from asking the same question again unless all other questions have been asked too. But "Evenly" doesn't make sense since it's an adverb and there's no verb in the class name, right?
Mh I just want to make so everyone in the map can hear the goat horn, not sure how to process then
Play the sound at each individual player’s location to each individual player
Yea that's what I thought I could do, but then players wouldn't be able to track where it's from I guess
what about QuestionDistributionComparator 😼
this.buttons.entrySet().stream().sorted(Comparator.comparingInt(Map.Entry::getKey)).map(Map.Entry::getValue).map(MenuButton::getItem).forEach(this.inventory::setItem).reduce(this.inventory, (a, b) -> a);
Randoms things that copilot suggest me
yeah that sounds good. Thanks
You could play it with an offset relative to their position to the actual sound that’s just closer
you can do some normalization type thing
Let's say that the goat horn is generally to the left of the player, you can play the sound ~ 5 blocks left of the player, for example
something like difference = playerLoc.subtract(sourceLoc).normalize().multiply(5)
how do i convert a material to a string?
nvrm
how do i like
"extract"
the id from a material
like i have this: Material.DIAMOND
return after doing something like mainhandItem.getType()
mainhandItem.getType().name()?
and if mainhandItem.getType() == Material.DIAMOND, will this ^ spit out DIAMOND?
wait i just realized a better solution to my problem, nvrm
thanks for the help anyways lol
aight back with another question
so if i enter valid material IDs in my config file like so:
- DIAMOND
- DIAMOND_SWORD
- EMERALD```
and hit the reload command for my plugin, everything works fine
but if i mess up the id of one of these elements (say, instead of `DIAMOND` i type `DIMOND`) and reload my config, the plugin still happily tells you "Config reloaded successfully" and there aren't any errors in the chat, until the code actually has to use the material IDs which then outputs the error to the console
how do i make it so that the plugin straight up tells you the error you made in the config when you reload and send an error message like "An error occurred in the config"?
When ur plugin loads, convert each string from the list to a material
If you get an illegalargumentexception, that string is not a valid item
What's the easiest way to convert a list to a String... ?
how do u wanna convert it
the easiest way? 🤔
but well, String::join is always viable
^ that's the easiest
unless you want some special functionality, then just use a StringBuilder and loop it
sounds good, thanks guys
Anyone got some good ideas for my spigot-api quiz? https://github.com/JEFF-Media-GbR/QuizBot2/blob/master/src/main/resources/categories/spigot-api.yml
No
👍🏽
Thanks!
what would be the best way go about modifying the essentials /warp command
i want to make sure that if a player warps while riding a horse, the horse gets teleported with them
forking essentials is the proper way
you can also just do some funky command map injection
can't really do that for reasons
you could listen to the PlayerCommandPreprocessEvent or whats it called. Then add the player's uuid to a set. and remove the entry on thje next tick. Listen to PlayerTeleportEvent and if the player is in a set, check if they are passenger of a horse, and if yes, teleport the horse too
honestly this annoys me
oh there's a typo anyway
but what if another plugin has registered a /warp command?
well I mean in the spigot API, not the quiz itself xd
don't you want to teleport the horse too, then?
well yeah
oh. yeah it's indeed a bit weird lol
it probably has some good reason
but like what if the other plugin did it in a weird way
or does something completely different
i guess its fine doesnt matter
don't ever assume that about spigot kek
there's a reason, but it's just anti-OO
and the only contract for that method existing is presented at runtime
which is not the time it should tell me, my IDE should tell me (but it can't because it's not a proper contract)
i also wonder why ConfigurationSerializable allows three different ways to specify a deserialize method lol
you can either do static deserialize(...), static valueOf(...), or a constructor lol
why not just one
legacy reasons maybe?
idk
really?
it is
but material auto corrects to having a uppercase M
this is the full thing
yeah nesting ew
someone has a blog post on this
@tender shard was it you
@daring egret would recommend reading that post for a better code style
much more readable and maintainable
also you don't need to verify the command name in the class
if you set an executor, then the command is already guaranteed to be /give
I'm curious what youtube tutorial people pick that up from
i originally did that but this guy told me too
that guy is not smart
what was his reason
hm
he told me on the lines of
"if you need to add more commands to 1 class" or something
like a gamemode command
gmc gms gma
that was his reasoning
In that case then yes, you need it
so why'd he tell me to do it here lol
yeah i got rid of it
you right
do u have a solution for the give command not working tho?
also, use Material.matchMaterial(args[0]) instead of valueOf
ohh okay
yeah ik
good aha
i'm gonna rewrite it with the better indentations now
cause if this is how bad it looks for a simple give command o-o
😄 best of luck man
Hey, could someone help me setup my git in Intellij?
I'm honestly lost and can't really figure out how to push/pull/commit
that is scary
does exiting a vehicle count as a teleport?
lol
Trying to make the horse teleport with the player when the player warps
I've already verified that onWarpCommand and onWarp are called correctly
yet nothing happens at all when i try it
ok I've almost got it now
I'm just having weird client-server desync issues if I force the player on the horse too fast after a teleport
so my solution is to spam-teleport them onto the horse 20 times with a tick delay between each attempt
yowza
only issue is
how do i cancel a task from within the callback
int attempts = 0;
Bukkit.getScheduler().runTaskTimer(SuperiorSteed.getInstance(), () -> {
horse.addPassenger(player);
attempts++;
if (attempts >= 20) {
// cancel?
}
}, 0, 1);
well actually, incrementing the attempts doesnt even work
how would I even do this
you ask what's wrong with the code, then people tell you and then you tell them to leave you alone? So why did you ask?
well for the incrementing part, you need an AtomicInt object
primitives & lambdas don't work well together
as for cancelling it within the task
you can use the Consumer method
ye or use a monotonic array
I've never really figured that out, I've done so much bullshit to try and fix that
int attempts = 0;
Bukkit.getScheduler().runTaskTimer(SuperiorSteed.getInstance(), (task) -> {
horse.addPassenger(player);
attempts++;
if (attempts >= 20) {
task.cancel();
}
}, 0, 1);
since atomic int does use volatile memory effects by default
ignore the copy pasted "int" part
I only wanted to show that you can use a consumer instead of a runnable so that you cancel the task
oh i did not know it can take a task argument
AtomicInteger attempts = new AtomicInteger(0);
Bukkit.getScheduler().runTaskTimer(SuperiorSteed.getInstance(), task -> {
horse.addPassenger(player);
if (attempts.incrementAndGet() > 20) {
task.cancel();
}
}, 0, 1);
this is what i got now
no
wdym no
whats no
just use an int array like int[] = {0}
no
?
literally Atomic* class is meant for things like this, when you need a wrapper
no its not
using an array for nothing is just silly
i don’t even know what atomicint is lmao
AtomicInteger is made for when you need to manage an int variable across multiple threads
Isn’t that what I’m doing here?
yes but an int[] is more performant
i'd just use an anonymous class
Oh
since volatile memory effects will force to flush registries
and it disables jit and compiler from doing certain optimizations by specs
It does feel kinda goofy to use an int array tho
I'd do this lol
Bukkit.getScheduler().runTaskTimer(SuperiorSteed.getInstance(), new Runnable() {
int attempts = 0;
@Override
public void run() {
if(attempts++ > 20) {
cancel();
}
}
}, 0, 1);
no wait
I-
1 sec lol
does that even work
yes
alex do u have a blog post for setting up a multimodule project?
new BukkitRunnable() {
int attempts = 0;
@Override
public void run() {
if(attempts++ > 20) {
cancel();
}
}
}.runTaskTimer(plugin, 0,1);
This is what I'd do
with maven*
honestly this looks cleaner
whatever~ that, atomicinteger, or 1-element int[] works
does the first one work? since it's inside a runnable and not bukkitrunnable
I don't think so. You could look at my JeffLib github thingy but it's probably more confusing than helpful lol
just use whatever you think is more readable
i accidentally deleted my entire projects folder with maven today 😄
now the recovered files are curropted
the thing I sent that uses "Runnable" instead "BukkitRunnable" will not work, because RUnnable has no cancel() method
yeah, I mean in worst case just go with a raw BukkitRunnable
check the full error
by clicking the uppermost thing on the left side
you have the lowest one selected
selected the highest one
do you have unit/integration tests

