#help-development
1 messages · Page 1409 of 1
inb4 SOLDIER.JAVA
LMFAO
its unnecressary anyways
@glossy scroll
when i run a command on my server nothing happends what could cause this to happen
Idk how eclispse works but its always nice to have javadocs in ide
just use maven
what plugin provides this command
Perfect
You have no idea how little that narrows it down
now what?
Idk
oh i understood wrong
now we sit down
i am reading the javadocs in the classes directly
and start to contemplate the futility of human existence
I'm using java player.openBook(book); and for a second or something the book is popping up with the text and closes. Why this intervall so short?
something could be calling player.closeInventory or something
and with maven you can just hover over your object and get the javadoc comment
@hybrid spoke
Okay.
I like to look at src code and see javadocs above i
Should I use bukkit ChatColor or bungee ChatcColor?
@glossy scroll how do I use maven?
I'm using it in the inventoryclikevent
Can this produce the error?
Quick question, I’m making a custom item, just an item with some special meta, and I want to check if another ItemStack matches it. What is the most reliable way to? Testing the metas’ .equals() doesn’t sound right because, say, a player could change the item’s display name in an anvil and it wouldn’t match. Not sure what to do. I wish I could do something like give it a custom Material type
what if you delay the opening?
by 1 tick or smth
I want to use like in this way as an example ChatColor.RED
isSimilar
What will happen?
Alright, I’ll look into that
it delays the opening by 1 tick 🤔
that one guy linked it recently but I don't have it in my browser history for some reason
could i provided a latest.log to narrow it down
Sorry. Stupid question
@wraith rapids what should I do?
@unkempt ore use persistent data container
equals is the same as issimilar, it just ignores stack size
Nvm i misread
Right, Where I put plugin.yml?
write a tag in the PDC in the item's meta and use that for comparison
in the resources directory
Use persistent data container like NNYajcjsojfkeke said
with your config.yml
ok
https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse)
@quaint mantle
arigatou
Eclipse tutorial using maven https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse)
i can't find any properly navigable trie impls either
i guess my level of expectations for "navigable" is just too high
and this is why you should always use a dependency manager
your dependency might depend on other dependencies which might depend on yet other dependencies
a dependency manager will just grab and import them all
And give it an ID of sorts?
Yeah, sounds perfect
in the plugin.yml is there a way to put variables such as this in other areas such as permissions or smtn?
yes
anything that you have declared as a filtered resource can use them
<resource>
<directory>resources</directory>
<filtering>true</filtering>```
or wherever yoru resources are
speaking of
how do you people infer the main package of the plugin to use in these vars
like if I want a variable for the permissions, id just stick that in the pom or something along those lines right?
i just have a project property for it but it feels kind of crummy
This is my generic plugin.yml ```yaml
name: ${project.artifactId}
main: ${project.groupId}.${project.artifactId}
version: ${project.version}
api-version: ${project.bukkitAPIVersion}
author: ElgarL
website: ${project.url}```
You can;t do that
mmm
Yushu ❤️
It measn replace with your Artifact name
You must replace it by your group id and your artifact name
keep trying. You know the saying about moneys and a typewriter.
doesn't that involve using a different group id for each plugin, though
Mine? no
when i run a command on my server nothing happens what could cause this to happen should i provide latest.log
main: includes the class name
the last element of your main is the artifact id
which would make your artifact id the class name
yes
class = project name
which it can't unless you specify a different group id for each plugin
give an example for groupId
<groupId>com.palmergames.spigot.homestead</groupId>
<artifactId>Homestead</artifactId>```
so you do change the group id for each plugin
I don;t have to
well I don't "have" to have a plugin package either
i can just have my classes directly under main
but I should have an unique package for each plugin
which means that you should change your group id for each plugin
I guess I could include the lower case ArtifactId on the GroupId which would make it fully dynamic
lowercase artifactId is what I do
or, would do, if I knew how to make things lowercase
🙂
do you know how to make things lowercase?
What should I do?
You should look in to basic Java before making your first plugin
you shoudl be able to use ${artifactId.toLowerCase()}
remarkable
how basic?
Is my code not alright?
well i mean
you have an empty class
but it's no longer on fire and all red and exploding
so that's progress
seems not
there's like a maven plugin that can do it I think
but I've never bothered to set it up
Can someone tell my, why this doesn't work?
if(e.getView().getTitle().equalsIgnoreCase(WINDOW.MAIN_NAME)) {
if(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§c✘")) {
e.setCancelled(true);
}
}
it doesn't cancel
Looks fine
Oof thats not a good way to test items
^^
what's better then?
If you have an instance of that itemstack anywhere, use that and call itemStack#isSimilar
ok
ItemStack GLASS = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
ItemMeta GLASS_META = GLASS.getItemMeta();
GLASS_META.setDisplayName("§c✘");
GLASS.setItemMeta(GLASS_META);
if(e.getView().getTitle().equalsIgnoreCase(WINDOW.MAIN_NAME)) {
if(e.getCurrentItem().isSimilar(GLASS)) {
e.setCancelled(true);
}
}
still not working
Is it possible to access the config in a static? Here's my code: https://paste.md-5.net/iyofuligob.cpp
Error: Cannot make a static reference to the non-static method getConfig() from the type JavaPlugin
Wheres the item you use to put in the inventory
Use that item
Sooo, Following Situation: I want to add an Membersystem for my worldmanagement plugin (each player it's own world), but have no Idea how to save and remove the members of the world, I already tried with a config in the world but it not really helped, any ideas? the code I tried to use for that: ```
fun addmember(world: String, uuid: String): Void? {
val ccfg: File = File("world//" + world + "//world.yml")
val cfg: YamlConfiguration = YamlConfiguration.loadConfiguration(ccfg)
cfg.set("- ", uuid)
try {
cfg.save(ccfg)
} catch (e: IOException) {
e.printStackTrace()
}
return null
}
fun delmember(world: String): Void? {
val ccfg: File = File("world//" + world + "//world.yml")
val cfg: YamlConfiguration = YamlConfiguration.loadConfiguration(ccfg)
cfg.set("- ", null)
try {
cfg.save(ccfg)
} catch (e: IOException) {
e.printStackTrace()
}
return null
}```
but if I click on that item, I can still get it
so it doesn't cancel
I would probably call IntventoryView#getTopInventory
Im not sure what InventoryView.getTitle does
it get's the name
I dont think it does apparently
that's the only thing I found for 1.16.5
ugh i just wouldnt realy do it this way so im not sure whats wrong
but I have to do it in 1.16.5
@quaint mantle id just recommend debugging
ItemStack GLASS = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
ItemMeta GLASS_META = GLASS.getItemMeta();
GLASS_META.setDisplayName("§c✘");
GLASS.setItemMeta(GLASS_META);
if(e.getCurrentItem().isSimilar(GLASS)) {
e.setCancelled(true);
}
this doesn't work either
and it doesn't spit any errors
Same frankly
Was it eventhandler?
Hi everyone, I've been trying to code a plugin that allows an entity to follow me for a long time. With all the research I've done I still can't do it. Could someone help me?
any ideas what i could can do here instead?
LOL i used to make that mistake all the time
Save it as a list instead
Unit? Why nullable Void
Also uh I mean the type is inferred for val so Idk why write it out but that’s a preference Ig.
Also btw iirc kotlin has string interpolation
How to replace player inv?
Do u mean Java Map or what do u mean?
List != Map
define "for a long time"
is this going to work?
Inventory player2inv = player2.getInventory();
player1.getInventory().clear();
player1.getInventory().addItem((ItemStack) player2inv);
Pls help @wraith rapids
no
you're casting an inventory to an item
So how to do it?
learn java idk
Inventory player2Inv = player2.getInventory();
player1.getInventory().setContents(player2.getContents());
declaration: package: org.bukkit.inventory, interface: Inventory
thx
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandss implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
player.getInventory().addItem(me.mrpiedot.PantsThatPoopTnt.items.items.TntPants);
return true;
}
} ```
no
i have a error in line 14
check instanceof before cast
same, looking 5mins why it not works and then "oh, I haven't done X for it to work"
Reload maven project
aight
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandss implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = (Player) sender;
player.getInventory().addItem(me.mrpiedot.PantsThatPoopTnt.items.items.TntPants);
return true;
}
} ``` I'm getting a error in line 14 whats causing this problem
didnt fix it
Uh weird, restart and invalidate caches
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>compute-plugin-package</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>plugin.package</name>
<regex>.*</regex>
<value>${project.artifactId}</value>
<replacement>$0</replacement>
<failIfNoMatch>false</failIfNoMatch>
<toLowerCase>true</toLowerCase>
</configuration>
</execution>
</executions>
</plugin>
ended up with doing this
it seems to work
I think its gonna work its indexing
but is a bit excessive for just lowercasing a single fucking value
Ah nice zoi
didnt work
but im trying smth else rn
which will
and
it worked
🙂
the thing I needed to do was add it as a maven project
Pog
gradle init 🤡
grandle is so shit
and ugly
idk how people use it
I tried it today
and rubish
hot 💩
Pea brain yessir
Would it be a good idea to store an ItemMeta for when I want to create an item stack and just assign the meta right there with the stored data? I assume I should clone it, right?
if I were using gradle I could've done what I did there in like 1 line
gradle is definitely better in some ways
maven is pretty inflexible and archaic
all item metas are clones
True
mvn package 😋
every time you call getItemMeta, you clone the item's meta
mvn clean install
i literally hat eintellij rn
Good, so setItemMeta copies?
I meant -e
let me check I suppose
Thanks
-e shows more info on an error
Yeah, man IntelliJ has been screwing me recently like sheesh
Having more than one item refer to the same meta sounds like it could be catastrophic, so I'm expecting it does defensive copy
same
I had an issue with one of my plugins where it wouldn't want to compile my plugin.yml so I had to add it manually each time
it depends
works with every other plugin
bukkit handles items in a pretty convoluted fashion
mvn clean install
Yeah, it couldn’t find the dependencies onetime so I had to yeet .m2 and reinstall BuildTools for different versions which was a painful process
boom
Hmmmmm
if you're setting the itemmeta of a craft item stack, it always clones
because craftstacks hold nms meta, not bukkit meta
all bukkit stacks are also converted to craft stacks and then nms stacks when you insert them in an inventory
which clones the meta into nms meta
so unless you are holding them as raw itemstacks in an array or something, it won't be an issue
Nice
itemstacks are fucking cancer because you can literally not do anything without tripping a million clones
a simple isSimilar clones the item meta of the associated items 2-4 times
and considering the meta size of shit like books and shulker boxes, that is a fucking shit fest
didnt know it cloned it so often
some plugins like slimefun that do a lot of issimilar comparisons and set items in inventories will literally make your server shit bricks
it doesn't help that they are using a fucking retarded "optimization" which actually just increases the number of meta clones per comparison by a factor of 4
?paste
Lmao
i rewrote myself an itemstack impl that is more sane with the way it handles itemmeta and cloning and comparisons
i've been working on a live-view itemmeta on and off for a while
hmm so by convenience writing our own itemstack comparison methods might be a good optimization
WTF
slime fun has changed SO much
oh
uh that sucks
im just looking at screenshots
there are just more items now
not code
that's the only difference
you don't want to, either
i'm currently in the slow process of rewriting slimefun from scratch
but whatever these pipy things are look cool
i have even decided on a name
idk what they doi
i shall call it shrekfun
or what the plugin is about
i feel strangely accomplished now that i've managed to automagically lowercase my artifactId
how magical
lmao
can someone help me with making custom config files
its easy
I cant understand from the tutorial
its easy tho
new YamlConfiguration
I cant understand tho
config.save(file)
then understand
config.load(file)
do I put those on load?
yes
you put them where you need them
load the config when you need to load it
save it when you need to save it
how to reload it
can I have multiple?
reload is just re-loading it; calling load again
yes
keep in mind that .save nukes all comments
because nobody has bothered to update bukkit to use the new snakeyaml versions that don't explode with comments
public static List<Loot> loadAll(){
List<Loot> loots = new ArrayList<Loot>();
try {
String query = "SELECT * FROM loot";
ResultSet rs = stmt.executeQuery(query);
while(rs.next()) {
Loot loot = new Loot(rs.getString(1), Utils.itemStackFromBase64(rs.getString(2)),
rs.getInt(3), Utils.deserializeLocation(rs.getString(4)));
loots.add(loot);
}
} catch(SQLException e) {
}
return loots;
}```
because it is a law of nature that literally everything in bukkit must stagnate and be at least 5 years out of date
because otherwise, what would happen to those poor, poor plugins written for 1.8 that nobody fucking uses anymore
what is line 48
well its other method because spaces,
???
but i think is this List<Loot> loots = new ArrayList<Loot>();
something is null
WTF is that red terminal
red terminal ?
that is so ugly how do you see
It hurts
let me show you some red
?
yes ?
what does this mean saveResource("name of file in jar here", replaceIfAlreadyExists). and where am I suppose to put it
this is alot easier to read
ok so ?
literally the virtual boy
its null
a class cannot be null
@vast quest you put it in the resources directory
maven will then package it into your jar
and that method will pull it out of the jar
ok then
maven or whatever dependency manager you're using
how can I use it?
what do you mean use
like get smth from it
you call the method
it shits out a file into the plugin directory
then you access that file
as you would any other file
it wants me to make public FileConfiguration getCustomConfig() {
return this.customConfig;
} static
d e a d.. code ???
Means it can't be reached
im reading from this but it doesnt say it needs to be
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
you don't need to put the config in the jar, no
but then you need to write it with code
config.set("key", value)
config.save
so i dont know
Your flow of control won't let that code be reached, that's what it means
That implies loot can't be null
do I need to write it in the plugin cant I use config.yml in resources
where did you get that from? his if is missing braces and only executing 1 statement
I forgot to get instance
usually that would highligh the if clause itself though
Why?
dang, yea I didn't see immediately that it is pointing towards that if-code
But I mean, dead execution means the same thing, true
oops wrong discord
my client keeps all deleted images
i will now dox you using this image you accidentally sent
looks fancy though
Hmm, ok, but how save a Map list into a yamlcfg?
config.set("key", map)
all of the elements in the map should be ConfigurationSerializable
iirc
reload after saving to have the Map convert into a MemorySection
and the keys should be strings
i think there might also be an util method somewhere to create a memorysection or a configsection out of a map, but I'm not sure
Are NamespacedKeys reusable?
Good
and you should always at least try to reuse them
constructing them on the spot is relatively cheap but is a bit of a code smell unless doing that is actually necessary
yes
that's what saveResource does
it takes the file out of the jar
if there's nothing to take, it can't take it out
put it in your resources directory in your ide and it should be automatically packaged into your plugin
like config.yml
and plugin.yml
config.save deletes comments
oh
only way to have comments is to write them in the yml file in your ide
and then save it with saveResource
that keeps comments
ok
okay ```vb
List<Loot> list = ConnectionSQL.loadAll();
if (list != null) sendMessage("is not null");
}
public static List<Loot> loot; i need add it to
split every deference onto a new line
welp imma recode my entire plugin cuz im changing from normal config to custom config
and try again
for events adn stuff
a thing that does configurations
Uhm
i guess bukkit's config api is beginner friendly
the jar
what is its name
events.yml
what is the line of code you're extracting it with
how many ticks does this delay the action?
Bukkit.getScheduler().runTask(Main.get(), () -> player.teleport(loc));
private void createEventFile() {
Events = new File(getDataFolder(), "events.yml");
if (!Events.exists()) {
Events.getParentFile().mkdirs();
saveResource("events.yml", false);
}
customConfig = new YamlConfiguration();
try {
customConfig.load(Events);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
this is what I have
thats
not how u java
at all
well actually its pretty similar
minus the incorrect naming
I just looked it up from https://www.spigotmc.org/wiki/config-files/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
o
ok
how does that even compile
i guess "Events" is a field you've declared earlier with a type of File
stick to the conventions please
variables and fields should be lowercase
trying to read code that throws the conventions out of the window is cancer
that said
events.yml will never exist
although you are extracting it if it doesn't exist
dunno
public static List<Loot> loot;
List<Loot> list = ConnectionSQL.loadAll();
sendMessage(list.get(1).getName());```
is working but tho define all i need cast it ?
that looks haram
i hate the antichrist
??
me too
can someone tell me what im missing/
Is it possible to access the config in a static void? code: https://paste.md-5.net/otinoxodut.cpp
how to do you set the amount in an itemstack
itemstack.setAmount
ok thanks
it's fucking rocket science, I know
is there a way to cancel the next event happening by a player or update a gui without closing and reopening the inv?
i have a gui with a listener that sends you to a location if you exit the gui, but i want to be able to delete the beds without sending you to the default location , when you click an item it sends you to that location
mark the player in a set or something when you close their inventory
in your listener, check if the player is marked, and if they are, ignore the event
then unmark them
super hyper technically you don't even need a set or anything, just a single boolean
wdym
but a set would probably be a less fragile solution
so how can I make a custom config generate?
i could save them in the yaml file with false, and then if getIsUpdating cancel the event
or something like that
right?
strip out all of the ifs and shit and see if the saveResource call works
you don't need to save them in an yaml
you only need to mark them for 1 tick
yaml and files are used when you need to remember something after the server restarts
and how do you mark a player? do i save the uuid?
try {
if(Economy.hasEnough(p.getDisplayName(), 300)) {
try {
Economy.subtract(p.getDisplayName(), 300);
p.sendMessage(Main.PREFIX + "Du hast erfolgreich §e1 Netherite §7gekauft.");
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 2F, 2F);
} catch (NoLoanPermittedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else {
p.sendMessage(Main.PREFIX + "Du hast nicht genügend Geld!");
}
} catch (UserDoesNotExistException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
it doesn't work
how do I broadcast message in server?
why are you using display names
you should be using the player name, not the player display name
google how to broadcast a message in minecraft ajva spigot
Bukkit.broadcastMessage(STRING);
player display name can be changed with shit like essentials /nickname
lol
you probably don't want that
@wraith rapids I found no way to lowerCase so this is the best I ended up with ```yaml
<groupId>com.palmergames</groupId>
<artifactId>homestead</artifactId>
<name>Homestead</name>
<version>0.0.1-SNAPSHOT</version>
<description>Homestead land claim and protection system.</description>
<!-- Project's website -->
<url>http://palmergames.com</url>
<properties>
<project.bukkitAPIVersion>1.16</project.bukkitAPIVersion>
<project.javaVersion>1.8</project.javaVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jar.finalName>${project.name}</jar.finalName>
</properties>
name: ${project.name}
main: ${project.groupId}.${project.artifactId}.${project.name}
version: ${project.version}
api-version: ${project.bukkitAPIVersion}
author: ElgarL
website: ${project.url}
description: >
${project.description}```
it's my server
with my homies
not public
ok, UUID then?
Ok
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>compute-plugin-package</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>plugin.package</name>
<regex>.*</regex>
<value>${project.artifactId}</value>
<replacement>$0</replacement>
<failIfNoMatch>false</failIfNoMatch>
<toLowerCase>true</toLowerCase>
</configuration>
</execution>
</executions>
</plugin>
I also came up with something @eternal oxide
this little plugin thingy converts the artifact id to lowercase
it's giving me error on enable
https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-intellij-idea/
or
https://www.spigotmc.org/wiki/creating-a-plugin-with-maven-using-intellij-idea/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
but i guess it is pretty excessive just to convert one string to lowercase lmao
oh so you gave up on the eclipse tutorial now
and now you want to switch to intellij
and want a tutorial for it
no but a frand told me to use intellij
I did see that but GitHub is now blocking anything but lower case ArtifactId So I've gone with the name field
How to make own BreakBlockEvent?
you know, you're going to run out of things to give up on at this rate
wait could you give me an example? i have no idea what you are talking about and cant find anything in google or autocomplete
public class Broadcast implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
if (args.length > 0){
Bukkit.broadcastMessage(String.valueOf(args));
}
else {
player.sendMessage(ChatColor.GRAY.toString() + "Usage:" + ChatColor.AQUA.toString() + " /broadcast <message>");
}
return false;
}
}
why its giving error
cuz args is not 1 word
you have to use for string in args
add that to a list replacing _ with " "
i think
String.join(" ", args)
i mean it takes the artifact id, converts it to lowecase, and writes it as the value of the "plugin.package" property @eternal oxide
the actual artifact id remains capitalized
public class Broadcast implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
if (args.length > 0){
Bukkit.broadcastMessage(String.join("", args));
}
else {
player.sendMessage(ChatColor.GRAY.toString() + "Usage:" + ChatColor.AQUA.toString() + " /broadcast <message>");
}
return false;
}
}
like this?
Yep, that will be blocked by GitHub
why? the artifact Id remains capitalized
They started enforcing lower case on Artifacts a while back
very
well fuck github i guess
I had to move GroupManager to groupmanager to be able to install
i thought you meant they enforced not having them as lowercase
it worked for years, but all of a sudden gave a wierd error that tells you nothing
github is going down the shitter
one step forward, two back
What packet
public class Broadcast implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
if (args.length > 0){
Bukkit.broadcastMessage(String.join("", args));
}
else {
player.sendMessage(ChatColor.GRAY.toString() + "Usage:" + ChatColor.AQUA.toString() + " /broadcast <message>");
}
return false;
}
}
good thing I don't really use github actions or anything
or really use github at all
I have my own private git locally hosted, but public goes on GitHub
they don't actually block like your entire repository if they sniff out you have a not-lowercase artifact id in your pom somewhere, do they
it's just for like, actions and all of the other build magic and shit
no, only if you use install
general hosting works fine
everyone is just going to use jitpack if they made things any more difficult.
or just not deploy to github
i've found the github packages support work really terribly anyway
tried to get it to work for a good few days at one point and everything just kept blowing up one by one
with a space between the " " so it puts a space between each word, if it still doesnt work you should send the error
@hexed rover
[20:59:09 ERROR]: Error occurred while enabling Demo v0.0.1 (Is it up to date?)
java.lang.NullPointerException
at me.nix.demo.Demo.onEnable(Demo.java:22) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:407) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:359) [patched.jar:git-PaperSpigot-"4c7641d"]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:318) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:408) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:372) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:327) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:267) [patched.jar:git-PaperSpigot-"4c7641d"]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:563) [patched.jar:git-PaperSpigot-"4c7641d"]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_51]
[20:59:09 INFO]: [DEMO] Disabling Demo v0.0.1
Did u register the command in plugin.yml
oof
lmao paperspigot
package whyhax.proje;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
public class Proje extends JavaPlugin {
private File customConfigFile;
private FileConfiguration customConfig;
@Override
public void onEnable(){
createCustomConfig();
}
public FileConfiguration getCustomConfig() {
return this.customConfig;
}
private void createCustomConfig() {
customConfigFile = new File(getDataFolder(), "custom.yml");
if (!customConfigFile.exists()) {
customConfigFile.getParentFile().mkdirs();
saveResource("custom.yml", false);
}
customConfig= new YamlConfiguration();
try {
customConfig.load(customConfigFile);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
}
``` I copied from <https://www.spigotmc.org/wiki/config-files/#using-custom-configurations> word by word and it STILL DOESNT GENERATE
do you have a custom.yml in your src folder
get rid of all ifs and shit and just test the saveResource call
yes
do I put that onEnable
yes
just delete literally everything
and add only the saveResource call to onenable
if (!file.exists()) {
if (!file.getParentFile().exists())
if (!file.getParentFile().mkdirs()) {
// error
}
plugin.saveResource(file, false);
}```
this is usually what i do
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
public class Proje extends JavaPlugin {
private File customConfigFile;
private FileConfiguration customConfig;
@Override
public void onEnable(){
saveResource("custom.yml", false);
}
}
``` deleted litteraly anything
imma tst
does it give you any errors if that doesnt work?
Nope doesnt work
and you have a custom.yml file in the root of your plugin jar
next to your config.yml and plugin.yml
Yes
no ;-;
i told you to open up the jar
what did you think I meant by that
open it with like winrar or whatever
the config.yml is IN the compiled jar
and custom.yml?
Yes
they're in the root of the jar, both in the same directory
yes
just when I open it
[18:37:34 ERROR]: Could not load 'plugins\Proje-1.0.jar' in folder 'plugins'
and what's the exception
use some paste site
Cannot find main class `whyhax.proje.Proje'
no wonder nothing is happening, your plugin isn't even enabling to begin with
open up the jar and check whether the path bukkit is looking for is exactly the same as the path of your main class
restart your server instead of using reload
https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-intellij-idea/
or
https://www.spigotmc.org/wiki/creating-a-plugin-with-maven-using-intellij-idea/
Which one should I use?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
whichever
error has gotten shorter
it still can't find your main class
idk
show a screenshot of you looking at your compiled main class in your jar
should I try to open another project?
i guess
I created Custom Enchant from net.minecraft.server.v1_12_R1.Enchantment but in minecraft I don't see EnchantName I
Can you help me?
;_;
You can't get the client to render it
@sick ravine I also tested creating custom enchantments recently and had the same problem. Perhaps some custom datapack with translations for your enchantment would do it. At least that was my hypothesis but I haven't tested that.
on 1.16.5, client is able to render custom enchants names
um okey
how unfortunate that you're using a version that is like 4 years old
BTW you should not need to access classes from the net.minecraft package.
does bukkit let you register custom enchantments through the api now?
last I checked you still needed nms
I did it by enabling org.bukkit.enchantments.Enchantment.acceptingNew private field through the reflection API.
But as I said, the name still did not render...
lol
how can I access the config in a static void? code: https://paste.md-5.net/otinoxodut.cpp
plz help
oh
static is static and shouldn't depend on the data held by your plugin instance
such as your config
how can I access the config not in the main class then
normally
pass your plugin object to the object you want to access it in
and then just call methods on it
If you have a piece of code that depends on the config then just pass the config instance.
public class CustomEnchantment extends net.minecraft.server.v1_12_R1.Enchantment {
}
CustomEnchantment customEnchantment = new CustomEnchantment(...
net.minecraft.server.v1_12_R1.Enchantment.enchantments.a(100, new KeyMinecraft("customEnchantment"), customEnchantment);
CraftEnchantment craftEnchantment = new CraftEnchantment(customEnchantment);
org.bukkit.enchantments.Enchantment.registerEnchantment(customEnchantment);
Passing the plugin instance is also ok but then you'll not be 100% truthful about what your code depends on.
no refection
legal 😳
IMO reflection dependent on the Bukkit API is much better than code dependent on decompiled classes...
This will break on different versions.
depends
the best way is to have version-specific submodules
but that is usually only for large projects that require a lot of diddling with the internals
reflection is fine for small things
It gets repaired sometime with reflection
I think that in case of enchantments we already rely on some stability throughout versions. Otherwise we would not have that in the Spigot API.
issue with reflective code that it's not as maintainable as directly programming against existent things
of course that's not an issue for something as simple as setting a single field somewhere
what I usually do is either have version specific submodules + a reflective fallback impl
or for smaller projects, just build against the latest version of nms and have a reflective fallback impl
.getCustomConfig().load;??
you would want to create a method like reloadCustomConfig
which would just do customConfig.load
and what do I put into that
in the class that manages your custom config
and remembers the YamlConfiguration that represents the config
and the File that specifies where your config is on the disk
so it can call config.load(file)
I just use the main class for config
then do it there
no
im just so confused
make your main plugin object remember the File
make your main plugin object remember the YamlConfiguration
but like getCustomConfig is ALREADY the file
public FileConfiguration getCustomConfig() {
return this.customConfig1;
}```
yes
YamlConfiguration is a kind of FileConfiguration
it's not a File
it's a Configuration
Out of curiosity @wraith rapids how do you manage state that needs persistence and atomic writes in your plugins?
getCustomConfig().load("config.yml")
That a server crash in the middle of a state modification does not corrupt it.
Main thread only.
depends on how robust it needs to be
the most robust way is to piggyback off the atomicity of the filesystem
That's the way I want to go right now.
uh also
But have you tried out some local no-sql DBs?
or if you are using a database, your db probably has atomicity guarantees
how can I delete the old config whenever I update the plugin
then how do you serialize your state?
i serialize it and then send it to whatever persists it
it's the job of the thing persisting it to make the underlying write atomic
if it's a database, I rely on the writes being atomically implemented there
if it's like a raw file or something, I write and replace
What serialization do you use? I wanted my state to be readable so I serialize it to JSON. Having that Mongo seems like an obvious choice for storing it when it comes to a DB.
with raw files, usually I just hammer everything into raw bytes
json is fine for readability I suppose
i'm not so sure about nosql but in most sql cases, hammering shit into json and storing in a text column is kind of frowned upon except for specific cases
I asked because I was wondering whether there is some tried and tested solution to that.
the meta is to have a table with columns for each of the keys your json mapping would have
Or perhaps that you've managed to do some performance analysis.
and then store a reference to that row in the column you'd store your json in
Yeah, I know how to use an SQL DB 😄
but, well, my point is that the atomicity should be provided by the database
can I disable my plugin?
it shouldn't be handled on your end
like make it red on /pl
One more question. Have you compared doing file IO on the main server thread vs offloading it to a different thread and then scheduling a continuation to go back to the main thread?
i generally design everything so that doing io on the main thread is not necessary
jumping to an off-thread and having the off-thread do the IO and blocking the main thread until the IO is done will obviously be slower than just the raw IO
because you get overheads from hopping your data between threads and all of the scheduling overhead
@vast quest in SBT there is a plugin for that but I don't know how Maven deals with that. I'd guess there is something similar.
Yeah, I don't mean blocking the main thread.
Your version shoudl be in yoru plugin.yml so can be read using pluign.getDescription()
o
if you absolutely have to have your main thread operation not resume a tick later or something, you can do your work on the main thread while the off-thread IO happens
so plugin.getDescription("version")?
and once you're done with your MT work, you start blocking on the completed IO result
that can be faster than just doing the IO on the main thread, but not necessarily because of the concurrency overhead
its getDescription().getVersion()
I know
it's best to design things so that your MT work can be put on hold and allow the server to resume for a tick before checking whether your off-thread resources are ready, and then resuming if they are
of course that's not always possible, with things like events
What do you mean by "MT"?
main thread
ok
what???
replace == with equals()
don't compare strings with ==
read the description of the warning
more actions -> show description
also should I put objectnonull thing
if the string you are calling .equals on can be null
use Objects.equals(a,b)
instead of a.equals(b)
if a is null and you call .equals on it, it explodes
Objects.requireNotNull hides the warning but still explodes
on the if statement?
What I considered is something like that:
modifyMinecraftWorldBefore()
Bukkit.getScheduler().runTaskAsynchronously(plugin, () => {
saveStateFile()
Bukkit.getScheduler().runTask(plugin, () => {
modifyMinecraftWorldAfter()
})
})
yeah, that is a pretty standard way of doing some mt work, then doing off thread work, and then resuming work on the main thread
there are some libraries and things that simplify it and reduce the indentation madness, like Aikar's TaskChain
I'm writing in Scala so I considered using the builting Future class
NNY is there anyway I can catch a empty null error
futures don't really play well with the main thread
there are surprisingly few cases where you can use them
basically, your future must be completed on the MT if you want to use any of the thenX methods to do bukkit stuff
since the thenX methods are called by the thread completing the future
I mean scala.concurrent.Future
i haven't worked with those, but I'd assume they run into the same restriction
jist of the issue is that there isn't really any good way to tell a future to run on the main thread
since bukkit doesn't provide any executors or anything that futures could hook into
there's just the scheduler
Bukkit.getScheduler().runTask()
but I'm not sure I'll get enough value from that to justify the additional overhead
do whatever is easier to maintain
without using libraries or whatnot, the simplest and easiest to read way would probably be to create a class for each of these kind of tasks, and then declare a method for each of the phases
and then use the bukkit scheduler to invoke the methods either on an off-thread or the main thread
and have each of the methods schedule the next one
and then you basically have taskchain
but, for simple things, you can just nest scheduler calls and lambdas
That's the idea. The rest of the code is supposed to be organised into neat functions already so it should still be readable. If I get into a situation where I need to nest state updates then I'll probably go with the "for-comprehension" notation from Scala and try to implement an ExecutionContext based on the Bukkit Scheduler.
Should be easy enough.
there is no getPlugin
why do i get that i dont get it
read what I said
real men write for loops
so
this?
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null || Bukkit.getPluginManager().getPlugin("ProtocolLib").isEnabled()) {
😄
If anything use List#forEach
and use &&
Streams have an overhead of their own, not worth it
you want it to be not null and enabled
but... but... you said OR
@quiet ice I think what you're suggesting is premature optimisation.
yeah you wouldn't believe how much extra performance paper has squeezed out of the server by just replacing streams with for loops and shit in mojang code
it's absolutely insane
like a third of the server's tick time is streams overhead
It will use an iterator either way, using the iterator directly is a lot better
I said if it's null or if it's not enabled
Plugin protocheck = Bukkit.getPluginManager().getPlugin("ProtocolLib");
if (protocheck != null && protocheck.isEnabled()) {
so then
@sharp bough I can try to get you a code snippet. Give me a moment.
if (protocheck == null && !protocheck.isEnabled()) { this will trigger if its NOT installed
right
Now it is
yes
Ok
note that you shouldn't import any protocollib classes in the class you're checking that in
interacting with classes that don't exist will cause the entire class to blow up before it even gets to your condition
Well, it might work, but sometimes will not work
yeah, imports are kind of a rule of thumb
It has always been a gamble for me
im just making it so the plugin does not work when protocolib is not installed
I did
and not enable your plugin at all if it isn't enabled
instead it will throw some arcane and fucking unintelligible exception
which is going to result in 300 1 star reviews on your resource page
@sharp bough
IntStream.range(0, totalLimits)
.map(index -> Main.get().getConfig().getInt("bedLimits." + index + ".limit")
"plugin doesn't work"
uh
In NMS its called PacketPlayOutFlying i believe
But its the movement packet
that looks even worse than what im using lol
in md5 mapped nms yeah
its fine i can figure it out thanks tho
md can't name things
It doesn't involve mutating a list...
And basically i just always set the onGround boolean to true with jump boost 128
Every opportunity to avoid mutating state is worth considering...
I wish we just go to mojang mappings lol
Jealous but im loyal to spigot
why eat next to a clown when you could dine with a king
LOL
I'll stay loyal to not using nms
Paper is the clown
you're the clown
xD
:(
What if i said everything uses NMS mwahahahaha
LOL
and entityJoinedWorld
I don't care about the impl
we can't even change it
because it would break backwards compat with the 1.8 plugins
Yes exactly
Maybe deprecate and just add a new one unless that breaks something, not checked l
But it’s definitely top 10 worst names
the enchantment and potion effect names are also cancer
iirc they're cancer because those used to be their internal names or something at the time
The entire material enum
yeah the material enum is a fucking travesty
Yea material still is cancer
And yes, Mojang had some strange internal names
Accept Choco’s pr when?
we changed the material enum to conform with vanilla item and block names
Until emerald was added, diamonds were emerald internally
and look at all of the hoops we had to jump through to get there
the entire fucking plugin bytecode of a plugin running a legacy api version is rewritten prior to plugin load now
just to weed out some legacy material names
it's fucking ridiculous
But backwards compat
it breaks a hundred times more shit than just changing the material names alone would have