#help-development
1 messages Β· Page 513 of 1
private static final Material[] allowedMaterials = Arrays.stream(Material.values()).filter(Material::isItem).filter(UtilClass::isBlacklisted).toArray(Material[]::new);
i think that will work
Does anyone know how to write inside a SQLite database using HikariCP?
.filter(Predicate.not(BLACKLIST::contain)) 
what part
theres not even a reason to use hikaricp with sqlite cuz its file based
only one thread can write to the file at the time
public static Material getRandomMaterial() {
Material returnedMaterial = MATERIALS[ThreadLocalRandom.current().nextInt(MATERIALS.length)];
List<String> items = new ArrayList<>(Main.getConf().getStringList("blacklistedItems"));
for(String item : items) {
materialList.add(Material.getMaterial(item));
}
if(materialList.contains(returnedMaterial)) {
return getRandomMaterial();
} else {
return returnedMaterial;
}
}
public static List<Material> materialList = new ArrayList<>();```
couldn't that work
could also just use a static block to populate your arr
whut the heck
idk!!!!!
yeah
I dont need to populate the array every time
I want to write a new entry, specifically, all the content inside here:
@Getter
@Setter
@AllArgsConstructor
public class AuctionData {
private UUID id;
private String buyer;
private long timeStamp;
private double price;
private String seller;
private ItemStack item;
^
do it like this
:chad:
for(String item : items) {
materialList.add(Material.getMaterial(item));
}
}```
serialize it?
probably want to normalize your table so itemstack is another table
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.
learning streams*
I did watch like 20 episodes into a learning java course and then forgot it all
and I haven't slept
Unfortunately, I can't find anything about writing inside a table with HikariCP
I'm going off my knowledge of other languages to hopefully carry me through this
its
not working
hikaricp is responsible for the connection, thats all
you just ask it a connection and thats all, for the rest you just write to your db as any other normal db
typescript is the language I'm most proficient in
why would you use hikaricp for sqlite
told him that
considering the fact it doesn't work with it
sqlite doesn't have connections
just file handles
but its useless
it does work, but its kinda useless
i just have hikaricp as an impl detail
there is nothing different that hikari does for sqlite
actually i have a boolean useHikari <sniffs>
so why would you use a library method that isn't anymore efficient then just creating a file handle
third, hikari is pointless if both server and db are on the same system
ever since java 17 unix sockets are now native to Java
which is far better then any tcp socket
even windows 10 can handle unix sockets as well
its pointless if said implementations don't even use it to begin with
sqlite nothing in hikari is touched, can't use hikari for unix sockets because hikari doesn't support that
so that only leaves tcp socket implementations only
do you have examples of unix sockets?
I don't really feel it's worth it to make a separate system for local and not local dbs
Where can i learn the basisc of using an api like placeholder api or vault to get the group and how to import it into the pom.xml as rn the pom is as it generated on default
API's docs or webpages
tcp doesn't come anywhere close to the efficiency of a unix socket
so it would depend
isnt tcp just the protocol that runs on the socket?
I'm deleting this and doing it the simple way
Just rewrite hikari to use native sockets π
it's basically just a file where you can "write to" or "listen to"
:o
in the pom.xml it appears red the dependecy
its for exchanging data between two proccesses on server
jdbc:mysql:///?user=test&password=test&socketFactory=<classname>&<socket>=/tmp/mysql.sock
you are going to need to create a socket factory
https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html
https://code.google.com/archive/p/junixsocket/wikis/ConnectingToMySQL.wiki
https://github.com/kohlschutter/junixsocket
thats a short article lol
I'm tired of explaining this over and over again
Thanks sorry i now nothing about the pom.xml
np lol
I'm just tired of explaining it twice a day, so I put it into a blog post
did reloading maven work?
Yes thanks
frost sockets 
I could go with a play on words
Hot Sockets π
If i put a soft dependecy should i disabled the example code that gives placeholderapi that if you dont have the placehodlerapi plugin it disables the plugin right?
you could design your plugin in a way that it isn't crippled just because of a dependency missing
in this manner it shouldn't matter if they have it or not
depends, do you want your plugin to also work without PAPI?
or does your plugin REQUIRE papi to work?
without also, as in the config they put whatever they want, if they want a placeholder they put it, if not they dont
then you should have e.g. a field in your main class "isPapiInstalled", set it to true if it's installed. Then when you later wanna parse placeholders, only call PAPI methods if that field is true
otherwise, use the string as it is
Oh yeah thanks
e.g. sth like this should work just fine
public class NMS extends JavaPlugin implements Listener {
private boolean isPapiInstalled = false;
@Override
public void onEnable() {
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
isPapiInstalled = true;
}
}
public String parsePlaceholders(Player player, String textToParse) {
if(isPapiInstalled) {
return PlaceholderAPI.setPlaceholders(player, textToParse);
} else {
return textToParse;
}
}
You can also just use isPluginLoaded rather than getPlugin != null
or that
that didnt exist back when I started with plugins lol
wait, it still does not exist
so this should work? hasPapi = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
I wouldn't do that
because of cyclic dependencies, your plugin could get enabled before PAPI
so it would return false even though PAPI is installed (just not enabled YET)
Oh yeah right, its better to do getplugin
getPlugin("PAPI") != null is definitely always working - isPluginEnabled will only work if PAPI actually gets ENABLED before your plugin, and you can never be sure about that, unless you depend on it
but since you only softdepend on it, the enable order can be random
Yeah amma use getplugin in case
while this is true, you could check for false or null in one go. But if it is false you could just easily make a check to run again in the future to check to see if it finally got enabled. If its null, the plugin doesn't exist or you got the name wrong.
yeah but why check it all the time instead of just checking it once
oh its soo cool like with the PlaceholderAPI.setPlaceholders() it automatticly sets the placeholders that you putted %% here
why would you check it all the time?
what kind of checks are you creating?
yeah that's the purpose lol
you would only need to check at most 2 times, anymore then that is pointless
but, everyone always assumes that there can never be outside interference
and therefore loves making assumptions of everything
is it null if the plugin exists but disabled?
then your check requires 2 checks, where as the one above that was stated you can check for all 3 states
in a single line
you can make a ternary from it π
if its neither true or null then its false π
i dont get how it works lol ``` public final Simples plugin;
public Chat(Simples plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event){
Player player = event.getPlayer();
if(plugin.hasPapi == true){
PlaceholderAPI.setPlaceholders(plugin.getConfig().getString("Config.chat-format"));
}
}```
ok here's the absolutely, overcautios, quite funny rock-solid solution lmao
@Override
public void onEnable() {
Plugin papi = getServer().getPluginManager().getPlugin("PlaceholderAPI");
if(papi != null) {
getServer().getScheduler().runTaskTimer(this, task -> {
if(papi.isEnabled()) {
isPapiInstalled = true;
task.cancel();
}
}, 0, 1);
}
}
note, it's meant as a joke. just check if it's != null is the usual solution
oh i get it
first i need to get to wich player purse the papi
is it good to use a BlockData[] instead of BlockData[][][]?
if you need a one-dimensional array of BlockData, yes. If you need a three dimensional array, no
referencing a whole chunk?
I just want to create a simple copy and paste system
i hate passing my plugin and my scheduler around everywhere
to schedule things
like im fine with passing around my scheduler
Are you talking about a flattened array vs a regular 3D array
passing around your scheduler?
yes i guess
I would use a Map<BlockVector,BlockData> or sth where the BlockVector is the offset of the origin
Why do you even need to pass around a scheduler
there exist di frameworks
because I have things that have to schedule stuff
but thats just a rabbithole
Bukkit.getScheduler?
yo ucan always get the scheduler through Bukkit.getScheduler() or through yourplugin.getServer().getScheduler()
plugin.getServer().getScheduler() oh god dont
see I'm fine with passing around the scheduler
that is the preferred version π₯²
its passing around the plugin that makes me feel yucky
NO
then why does the JavaPlugin take a Server object in the constructor and make it accessible to subclasses
in my case that would not work because I have a
public record Schematic(int xSize, int ySize, int zSize, BlockData[]/*or [][][]*/ blocks) {
public void paste(Location location) {
//paste
}
}```
i much prefer getting the server from my plugin rather than using Bukkit because its better for testing
getServer().getScheduler()
alright well there is no alternative unfortunately i guess
i mean idk what it would be anyways
a plugin scheduler lol
maybe I should just make my own
exactly
does anyone else have the idea they re talking to theirselves?
yeah
package events;
import chiru.simples.Simples;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class Chat implements Listener {
public final Simples plugin;
public Chat(Simples plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event){
String chatformat = plugin.getConfig().getString("Config.chat-format");
Player player = event.getPlayer();
if(plugin.hasPapi == true){
String chatformatpapi = PlaceholderAPI.setPlaceholders(player, chatformat);
event.setFormat(chatformatpapi);
}
else {
event.setFormat(chatformat);
}
}
}
``` I dont get why this doesnt work when you dont have papi installed
whoa
none of the suggested solutions actually answer my question
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
but it makes sense because there is none
THE BIBLE π
we did. just pass around your plugin instance, then you can always do myPlugin.getServer().getScheduler()
oh man im outta here
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
like i want to at least have it said %player_name% >> MESSAGE
and instead it appears the default minecraft format
because you misunderstood what setFormat is
wait i think is my fault
have you ever used String.format?
no
The default format looks exactly like this:
%s: %s
the first %s automatically gets replaced with the name
the second %s is the message
yeah
what did you set it to instead?
#Simples - The only plugin you need
#Made by Chiru
#Placeholders will work if you have PlaceHoldersAPI installed :)
Config:
chat-format: "%player_name% >> %message%"
SimpleServerWelcome:
enabled: true
welcome-message: "&e&kI &a&lWelcome %player_name%! &rThis welcome message, has been created with &6&lSimple Welcome&r!, change this on the &4&lconfig.yml &e&kI"
your "chat-format" contains exactly 0 %s, and so it won't work
at least IIRC, it should throw an error
Probably does
o i understanded the api web it said to get the players name and get the message
imagine this:
String myFormat = "%player_name% >> %message%";
System.out.println(String.format(myFormat, "Jeff", "Hello world!"));
String.format now sees "Ah, there's a %p"
there is no "p" datatype though in String.format
so you get this cute stacktrace
if PAPI is not installed, you manually have to replace %player_name% etc with %1$s and the %message% with %2$s
oh yeah i get it
in theory, you could also just ignore the %s stuff and just manually insert the whole formatted thing into the format
when it worked i did this
System.out.printf cmon
but in that case, you gotta escape % signs with %%
event.setFormat(player + event.getMessage());
don't forget to replace % with %%
oh yeah in this case player is = event.getPlayer()
that was when it worked, then i changed the code idk why
quick and dirty, ugly solution: ```java
if(!papiInstalled) {
String formattedFormat = formatFromConfig
.replace("%","%%")
.replace("%%player%%", "%1$s")
.replace("%%message%%", "%2$s");
event.setFormat(formattedFormat);
}
formattedFormat lmao
yeah well how would I call it lol
I would just encourage people to use %1$s by default in the config instead of manually parsing player_name and message
1 question how can i get the message sent with papi like in the config
i have this rn ```java
String chatformat = plugin.getConfig().getString("Config.chat-format");
Player player = event.getPlayer();
if(plugin.hasPapi == true){
String chatformatpapi = PlaceholderAPI.setPlaceholders(player, chatformat);
event.setFormat(chatformatpapi);
}
else {
event.setFormat("%s: %s");
}```
in the config i have the same as before chat-format: "%player_name% >> %message%"
question, why would you use papi for that ?
if i dont have papi it works and sets the format to that, but wiht papi not as it doesnt get the message sent
why not just setFormat("%s >> %s")
for placeholders
if i want to display the group of smone or their kills idk
amma do a replace
private static final String DEFAULT_CHAT_FORMAT = "%player%: %message%";
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
String formatFromConfig = getConfig().getString("chat-format", DEFAULT_CHAT_FORMAT);
// If the format contains % symbols, we gotta escape those
String percentagesEscaped = formatFromConfig.replace("%","%%");
// No need to use PAPI for the playername - we let Bukkit do it. Note, we use %%player%% instead of %player% because we escaped % earlier
String playerReplaced = percentagesEscaped.replace("%%player%%", "%1$s");
// Same for messaage
String messageReplaced = playerReplaced.replace("%%message%%", "%2$s");
if(isPapiInstalled) {
// Now we can replace the remaining placeholders (everything that's NOT %player% or %message%)
event.setFormat(PlaceholderAPI.setPlaceholders(event.getPlayer(), messageReplaced));
} else {
// ... or not
event.setFormat(messageReplaced);
}
}
@tall saffron
Thanks, i question i donmt get the % why 2
note that placeholders could again mess up the format if they themselves contain %
%s is a special "string" used as placeholder for "any string"
now a player types "I have 20% of HP", it would throw an error
so you have to turn % into %% to tell String.format "the following % is NOT a placeholder, but it's really just a percentage sign"
you don't have to do it, it's just the way it's intended. PlayerChatEvent.setFormat is NOT there to declare the exact thing shown in chat, but just what bukkit throws into String.format
you could in theory ignore the %s stuff and replace it yourself, but it would give everyone nightmares who knows how the chat event works
also players could then still type %s themselves and mess up everything
imagine you set the format to "mfnalex: I'm mfnalex, I got %2$s money"
then bukkit throws it into String.format, then in chat it'd look like this:
mfnalex: I'm mfnalex, I got I'm mfnalex, I got %2$s money money
can anyone tell why im somehow getting this error https://paste.epicebic.xyz/sowiyigadu.sql from this yaml ```yaml
questions:
Doug Engelbart was the inventor of what computer accessory? The first one was made from wood.:
answers:
- Mouse
THINK was this company''s motto for more than 40 years.:
answers:
- IBM
True or False. The platypus is a mammal.:
answers:
- "true"
if this confuses you, you really gotta learn what String.format is and how it works
because the dot is unescaped
Yeah, thanks allot amma see how can i understand this better
how would i escape the dot?
If I'm storing player homes, should I rather use a proper database or just another config file? I'm lazy to make it work with a database but if it is critical, I will
hm I don't think you can. You can either choose a different symbol as path separator that you normally don't use (e.g. NUL, BEL, etc), or use snakeyaml)
it is snakeyaml
note, it's valid YAML, but spigot splits key names by "." and hence you get that problem
oh
it is not. it's Bukkit's MemorySection, built on top of SnakeSYaml
declaration: package: org.bukkit.configuration.file, class: YamlConfigurationOptions
you could set this to e.g. \u0001 BEFORE loading the config
or you do it properly, like this:
questions:
- question: "This is the question"
answers:
- First answer
- Second answer
- question: "This is another question"
answers:
- Another answer
this would be the proper way (using MapLists), because you don't rely on the key name
then you can get it with getConfig().getMapList("questions")
only problem i have is needing to update the config to use the new format
yeah but that's the only proper solution
how many questions do yo uhave? if it's more than 20 or so, just write a regex or awk script
is there a function to get a material from a namespaced key
this is what most peoples configs will look like atm https://paste.epicebic.xyz/gulabidiro.sql
I realized like idk essentials uses like a set amount of prefixes, that are with {} so they must be like custom with replace, should i do that like do a set ammount of prefixes that people could use, like displayname , group and else?
yeah as said, you can easily parse this using SnakeYaml directly, but bukkit's yaml stuff on top will be confused by the dots being path separators
as said, a dirty workaround would be to use a weird symbol as separator
to use snakeyaml directly would mean i need to recode the entire game system and i really dont want to do that
would this format work with dots?
my quiz files look like this https://github.com/JEFF-Media-GbR/QuizBot2/blob/master/src/main/resources/categories/minecraft-crafting-recipes.yml
RedBot uses the weird format that you use https://github.com/JEFF-Media-GbR/QuizBot2/blob/master/src/main/resources/categories/red/games.yml
I figured it out, without doing alll that dumb stuff
yes, sure
it'll work with any string
could I just do Material.matchMaterial(key.getKey()) as long as the namespace is NamespacedKey.MINECRAFT?
looks like im writing a config updater for it
yeah that should work fine
anyone know why this is not working?
the dependency has been downloaded and is on the compileClasspath, yet intellij shows it doesn't exist and when i try to compile it also gives me the errors
the project is a fabric mod with gradle
the build.gradle
alright appreciate it
what's the import for the OkHttpClient
I ended up using this, as i think it would be better ```java
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event){
String chatformat = plugin.getConfig().getString("Config.chat-format");
Player player = event.getPlayer();
event.setFormat(chatformat.replace("{DISPLAY_NAME}", "%1$s").replace("{MESSAGE}","%2$s"));
}```
i will add idk 5 more
okhttp3.*
its in okhttp3.OkHttpClient
but intellij doesnt recognize it
Hi I have a custom config file which is located in my resources folder in my plugin in a folder called βrewardsβ, how do I make the config file/ rewards folder automatically copy across to the data folder when the plugin is run on the server?
you talking about plugin.saveResource i believe
Okay thanks ill try it in a minute
yk what
I got the same problem in IJ on maven
hm
I found the issue
when I switched the scope to "compile", it found all the dependencies
which makes little sense, as that's the default scope
seems like IJ is borked
try to set the scope to implementation, reload gradle, does it show up now?
If yes you should be able to change it back afterwards
I also tried with gradle but your build file throws a million other errors for me lol
ij has been fucking up the last time
Still working on my shop, does "Warped Stem" count as wood?
how would i go about returning values from listeners?
i essentially want to make a reaction type minigame within a gui and i want to know when someone clicks the item
is there a better way to go about this?
it's tagged with log
Make ReactionManager > increment given reaction in event if all conditions are met
Thanks, that is what I needed. I did not know I can see that in the F3
(it could in theory be changed through datapacks though, so if you wanna be sure, use Tag.LOGS.isTagged(Material.WARPED_STEMS)
explain that a little more please
What exactly is not clear?
I cannot do that with my shop but thanks, I will use that when needed. Maybe my future plugins
what scope? the okhttp dependency is already implementation
oh wtf
it just fixed itself
iβm just confused as to what you mean by all of it
when the item is clicked, add that to a variable then check if that variable is the right value or something else?
Check if it's your inventory, check reaction type etc
That is what I meant with check conditions
ah yeah
would i be able to check whether all those conditions are met from another function?
not within the actual listener
Why?
What's wrong with doing it inside of listener
I mean you sure can
Just pass inventory event as method argument
when the item is clicked i want to change the inventory so that the item moves to a different position
which is why i would want to know from a different function when the item is clicked
hello, I have a problem with maven and NMS where when I try to package my plugin, the "remap" goal does not get executed and when I try to directly run the remap goal I got an error saying that the srgIn param is invalid or missing. Any idea why this happen? my pom.xml file https://paste.md-5.net/asemusuyed.xml
so it can signal it to shuffle the position
Shop section in my shop plugin
https://paste.md-5.net/lahaqubine.makefile
You see why I asked if "Warped Stem" is wood?
remove the whole specialsource-maven-plugin part, then copy/paste it again from here:
?nms
If I'm storing player homes (/sethome), should I rather use a proper database or just another config file? I'm lazy to make it work with a database but if it is critical, I will
Just how I programmed the plugin
do you need to access the homes of offline players?
They might have a API to use for this
Maybe sometimes, in rare cases
if you wouldn't need to, I'd use the player's PDC.
You can easily access offline player's PDCs but it requires 2 lines of NMS.
If you don't wanna use PDC, I'd go for either YAML + optional MySQL, or SqLite + optional MySQL
Hmm, I'll think
PDC is easiest to use and requires zero setup
I don't know if this means anything but I found this. https://github.com/EssentialsX/Essentials/search?utf8=β&q=setlastlocation&type=
Oh you could also use the worldβs PDC
Thatll do! Use that @shadow night
I mean, if a world gets deleted, the homes are gone anyway. Perfect solution
Just replace setlastlocation to gethome
You can use my lib to store eg map<uuid<list<location>> for the homes in eachβs worlds pdc @shadow night
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
not much different from default
That looks a lot better than what I was using
I hate that it's so close to the left though but easily changable
Thanks!
Sometimes I feel like the IJ formatting doesn't actually work anyways
Like it doesn't change stuff it should
so i have followed the steps on the blog but I still have the same issue, the remap goal is still somehow not executed :( https://paste.md-5.net/ojicicexow.xml
here's a tiny example of how you could store homes in each world's PDC using MorePersistentDataTypes. The example only lets you query existing homes, but ofc you can also just easily add to that. It will also work for offline players, as the data is stored in the world.
Alex your styling makes it hard to read methods with many parameters
how do you compile?
Or do you actually side scroll
I got a resolution of 3456x2234 pixels on my laptop, and three 27" monitors next to each other on the desktop lol
So you actually like it being all in 1 long line?
I actually don't care
Even though 70% of the stuff above will be empty
the issue is that whenever I change the settings, they are again gone in the next project
Why is that? There's a default thing for all projects
π
I wanna see more xml files
You have options. Unsure if you were answered properly.
@NotNull Material material = Registry.MATERIAL.get(key); // Exact key. e.g. minecraft:stone
@Nullable Material material = Registry.MATERIAL.match("mInEcRaFt:SToNe"); // Case insensitive string where 'minecraft:' is optional
If anyone feels like sending their own would appreciate it a lot
#match() only having been added in 1.19.2 or something
Choco you've been doing this for years you probably have a tweaked style file π
IntelliJ java style xml file
I use Eclipse but I use a modified version of Bukkit's Checkstyle file
Unsure if IJ uses Checkstyle
That seems almost same as default
Yeah my standards tend to adhere 1:1 with default styling guidelines
IJ has a checkstyle plugin
Interesting
maven has one too :3
I just find some stuff
So hard to do with
legible code formatting
Alex's system is like 1 super long line cause he has 12312 ultrawide monitors so he has a electric chair to spin around
can you show me any example of any of my "super long lines"?
But I've done some exploring and I find it so hard to find something that actually looks nice
because I actually don't think they are overly long
protected InventoryButton createUpgradeSlotsButton() {
return new InventoryButton().creator(player -> getButton(Objects.requireNonNull(Config.getStringMaterial(ConfigPath.GUI_MAIN_MENU_UPGRADE_SLOTS_ITEM)), TextUtils.color(" "), PlaceholderUtils.replacePlaceholders(Config.getStringListLore(ConfigPath.GUI_MAIN_MENU_UPGRADE_SLOTS_ITEM), ultraChest))).consumer(event -> {
Bukkit.getScheduler().runTask(plugin, () -> {
plugin.guiManager.openGUI(new SlotUpgradeInventory(ultraChest), (Player) event.getWhoClicked());
});
});
}
lmao
creator in a return
That's why
Are these not the same, I only seeing one in the shop? ANDESITE: purchase: 20 sell: 2 DEEPSLATE: purchase: 20 sell: 2 COBBLED_DEEPSLATE: purchase: 50 sell: 5But it exists somehow when typing this command/give MrnateGeek cobbled_deepslate
this is the longest I've written today, I don't think it's too long. it's maybe 50% over the normal limit lol
what happens with the top one if its an invalid key
since its notnull
does it throw an exception?
thank you so much for the help btw
yeah that's hella ugly
wdym? it's nullable
i have maven installed on my computer and i just do mvn package, I have also tried mvn clean compile before doing mvn package but this did not solve the issue
yea I just realized, in the snippet choco sent they wrote the wrong thing
?paste the full output of mvn package
brr
for libraries / public code, I try to keep parameters like this
ultrawide monitors, meanwhile my screen
That looks a lot better indeed
still a small screen
alex probably got a tv
...
you're all just noobs. this is only 2.5 screens in width btw
the right one is in portrait mode rn so that's why it's 2.5 screes
i can give you a
What are you using if you don't mind me asking?
man why is that line so long
I'll check in a minute
hm paste the pom again pls
Maybe it's time for a ultrawide
just buy a smart tv
I have a sick monitor setup now
i have an old monitor
as I said, 3x27"
your pom is wrog
you put all your plugis into <pluginManagement>
they belog directly into <build><plugins> as mentioned in the blog post:
?nms
btw 90% of your plugin declarations are kinda useless
e.g. maven-install-plugin, why?
I tried searching it and it showed 2 editors from Linux command-line and Notepad from C:\Windows\System32
Spezifikationen: Display-GrΓΆΓe: 27 Zoll AuflΓΆsung : 2560 x 1440 Pixelabstand: 0,265 mm Helligkeit (max.): 300cd/m2 Bildschirmtechnologie: VA Reaktionszeit: 1ms MPRT Bildwiederholrate: 144Hz AnschlΓΌsse: 2 x HDMI, DisplayPort 1.2, KopfhΓΆrerausgang Audioeingang: 3,5-mm-Miniklinke KontrastverhΓ€ltnis...
I talking about the Text editor
You use Atom, bracklets or what editor?
the screenshot? IntelliJ.
as normal editor I got notepad++ and sublime on windows
np
I'm losing my mind
File just isn't reformatting until I set it myself first
And then it keeps it
Its not any of these, I know these icons. I don't see any of them open on taskbar, you using another text editor. Did you change the exe icon?
Alternatives to IntelliJ formatting? I getting annoyewd
which icon are you talking about
I would never bother about changing any icons lol
Its red and blue border with black box
That's IntelliJ
yeah that is IntelliJ
on macOS, the icon looks sooo beautiful
whats the space doing there
seperating most important from middle important
All the community edition jetbrains tools use the square icons.
PolyMC
ah i thought i heard smth about a new icon
Prism Launcher is better
dunno any of those things
what's the difference?
It's the same thing, but the devs from that got kicked from PolyMC work on it.
I prefer the polyMC icon, it looks like minecraft and not like some photo editing software lol
also the name is much more descriptive
"poly mc" literally means "multiple minecrafts"
MultiMC also fits that descriptor.
i like prism more then
...
Yes sure, but prism doesnt
I prefer descriptive names, i mean look at my plugins⦠ChestSort, Drop2Inventory, MorePersistentDataTypes, etc lol
I'm giving up
I guess, but I'm sure you get the idea though. Prisms refract light resulting in the entire infinite spectrum.
I'd also rather use the PrismLauncher just to avoid the repo drama with PolyMC.
^^
As long as the spectrum does not contain 1.8, i am fine with that
wat
Line length
Wait, you made these plugins?
Yes?
please dont put that into production
Check your indentation rules.
Can I speak to you privately?
I'm not, I'm trying to fix it
Sure but im in the bathtub
Woah where is this going
As I said line length setting
this is definitely a long shot in the dark, but is anyone here experienced with minecraft core shaders/glsl?
?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!
What's your Wrapping and Braces settings look like?
omfg
Yes
2 of those were selected
Holy sht
Now I can actually make my design...
tbh changing those code style settings takes so much time and is so much not worth it imho
I just stopped caring about it, I only changed it to not use * imports
which is only possible by setting the threshold to 999 btw lol
In the imports section?
IJ resets it for every new or already existing project anyway from my experience, especially if you use it on two or more PCs
yes
Code Style -> Java -> CLass count to use import wit h* -> 999
Gotcha, ty
otherwise people complain when you PR to bukkit lol
lol
Alright still can't figure out good settings for these weird methods but I'll just commit to fixing it and exporting the xml
yeah they also complain about missing spaces between function name and brackets
you're making it worse with every screenshot
whats even the problem? rewrite it?
It's literally unreadable
copy/paste that code here once
variables my man
private InventoryButton createSettingsButton() {
return new InventoryButton().creator(player -> getButton(plugin.gui.getString("main-menu.settings.material"),
TextUtils.color(" "),
PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"),
ultraChest)))
.consumer(event -> {
Bukkit.getScheduler()
.runTaskLater(plugin,
() -> {
plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest),
(Player) event.getWhoClicked());
},
1L);
});
}
Beautiful format
Absolutely gorgeous
Too many tabs man.
Absolutely abhorrent.
discord fucking it up even more
private InventoryButton createSettingsButton() {
return new InventoryButton().creator(player -> getButton(plugin.gui.getString("main-menu.settings.material"), TextUtils.color(" "), PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"), ultraChest))).consumer(event -> {
Bukkit.getScheduler()
.runTaskLater(plugin,
() -> {
plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest),
(Player) event.getWhoClicked());
},
1L);
});
}
the only thing I'd put on a new line is the consumer
private InventoryButton createSettingsButton() {
return new InventoryButton().creator(player -> getButton(plugin.gui.getString("main-menu.settings.material"), TextUtils.color(" "),
PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"), ultraChest))).consumer(event -> {
Bukkit.getScheduler().runTaskLater(plugin, () -> {
plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest), (Player) event.getWhoClicked());
}, 1L);
});
}
Still kinda hard to see the parameters
I wish they would just be like, 1 parameter per line, evenly
im still wondering, why dont you rewrite this?
What does TextUtils.color(" ") even do
Placeholder, replacing it right now
The method is literally smiles gui implementation
That looks a bit better
Actually that's pretty decent
Lastly maybe the consumer() down 1 line
Really? lmao
Builders are cool, but sometimes it's easier to just use setters
I usually use builders when it's not too long, and in the code directly, not representing the whole method
Example: /punish <Player> I want to have multiple categories. So I would need to create another gui from my knowledge. But I want the GUI Title to say be the display name of the player throughout using the gui.
remove {}
private InventoryButton createSettingsButton() {
String materialName = plugin.gui.getString("main-menu.settings.material");
String name = TextUtils.color(" ");
String lore = PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"), ultraChest);
Button button = getButton(materialName, name, lore);
return new InventoryButton().creator(player -> button.consumer(event -> {
Bukkit.getScheduler().runTaskLater(plugin, () -> {
plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest), (Player) event.getWhoClicked());
}, 1L);
}));
}
Did you... just 1 up him in the bathtub?
I only refactored it a bit lol
Now noob question
Doesn't delcaring those variables just to be used in the creator
You'll have to be more precise
"waste" of memory?
Not really
Is it the same as doing inline?
They are local variables
what's more important? that your code does not look like shit, or 0.0000002% of your RAM?
But then GC
Does GC even touch local variables
What if 1000 players using this
It's supposed to.
they are gone when the scope ends
Is it still not noticeable?
I though they just get discarded after the method is over
So using a lot of local variables is for the most part, good
A local variable isn't even really put in memory isn't it?
It is.
Alright cool, thanks for clarifying
Any variable you declare is reserved a space in memory.
It's just up to the GC to un/deregister them.
Local variables go on the stack
gui = Bukkit.createInventory(new GUIHolder(), 54, playerName);```
the argument <Player> would be set to the GUI Title. Now if I selected a category. How could I pass the playerName variable to it.
Bukkit.createInventory(new GUIHolder(), InventoryType.ANVIL, playerName);
depends on how you manage the "select a category"
How I only see one of these in my shop? DEEPSLATE: purchase: 20 sell: 2 COBBLED_DEEPSLATE: purchase: 50 sell: 5Are these not the right names?
private InventoryButton createSettingsButton() {
String materialName = plugin.gui.getString("main-menu.settings.material");
String name = TextUtils.color(" ");
List<String> lore = PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"), ultraChest);
ItemStack button = getButton(materialName, name, lore);
return new InventoryButton().creator(player -> button).consumer(event -> {
Bukkit.getScheduler().runTaskLater(plugin, () -> {
plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest), (Player) event.getWhoClicked());
}, 1L);
});
}
There you go
Much better indeed
Thanks all
Well how could I go about managing it?
Those are the right material names. Are you not iterating over your config list?
it all depends on what you need to do when selecting a category ^^
But I guess you want to open a new gui
wdym with "category"?
So just create a method
I just need to pass the playerName
and input playername as argument
pass to what?
Are you opening a new inventory every time?
If so, pass it in there.
Alright.
All the items in Wooden and Stone shows. But the Deepslates is what I have issues with
What's your code look like?
I think I see what I did
but wouldnt you get any console errors if it cannot find the material?
how do you even turn the string into a material?
idk if i should ask here since its not really code related
but i recently got some code from github, and it refuses to compile
I don't think the LEGACY_ prefix gets applied to newer blocks.
Its not that, I set it if it cannot find the material to skip the entry
did you set an API version in plugin.yml
Who?
you
I got the 2 blocks to show up but not the stairs and slabs
When it comes to Deepslate
do you have a api version set in plugin.yml
When it comes to materials, it's just a matter of names.
he earlier claimed that deepslate isn't working at all, that's why I keep asking for api version, but sadly, no answer
Does api-version do anything other than prevent legacy material loading?
No. But legacy material support means you dont see the new materials
Ok, only Cobbled Deepslate Stairs is showing DEEPSLATE_STAIRS: purchase: 40 sell: 4 COBBLED_DEEPSLATE_STAIRS: purchase: 100 sell: 10
Ah, but if he has the Deepslate and the Cobbled Deepslate showing up, then it's another issue.
Nobody knows, we have no code nor answers about the api version
I wont ask a fifth time
The api version is set to 1.19
for(String section : this.data.getKeys(false)) {
if( !this.data.isSet(section+".icon") ) { continue; }
if( Material.getMaterial(this.data.getString(section+".icon")) == null ) { continue; }
ShopGroup group = this.manager.add(this.data.getString(section+".name"),Material.getMaterial(this.data.getString(section+".icon")));
if( !this.data.isSet(section+".items") ) { return; }
Set<String> items = this.data.getSectionKeys(section+".items", false);
for(String item : items) {
if( Material.getMaterial(item) == null ) { continue; }
if( this.manager.hasMaterial(Material.getMaterial(item)) ) { continue; }
List<Integer> prices = Arrays.asList(
(this.data.isSet(section+".items."+item+".purchase") ? this.data.getInt(section+".items."+item+".purchase") : 0),
(this.data.isSet(section+".items."+item+".sell") ? this.data.getInt(section+".items."+item+".sell") : 0)
);
if( prices.get(0) != null || prices.get(1) != null ) {
group.add(Material.getMaterial(item), prices);
}
}
}```
Add debug outputs into every if / before every return
Looks like you return instead of continuing or sth
Hard to read that code on the phone
If I use return, it will exit the for loop
No, itll end the whole method
Also, can you paste your full config?
break ends the loop, continue goes to next iteration, return ends the method
return immediately jumps to the end of the method
break jumps to the end of the loop
continue jumps to the next entry in the loop
Gotta love the get methods with defaults
Facts
Why not just utilise plain old fileconfiguration rather than creating a wrapper in datamanager?
This song here, weird as f***. Anyway, I know how these for loops and all that works
Class I made
What song? I want to listen
A weird one
yeah, why create a class instead of using built in bukkit stuff
Sounds like it's good stuff
Freak Nasty - Bounce 2 This (Groove)
I can also make weird songs https://m.soundcloud.com/le-crochet/brush1ng-t3eth-brushing-teeth-schizophreni3-remix
Stream bRu$h1nG t3eTh (Brushing Teeth ScHiZoPhReNi3 REMIX) PSYCHOSE-GARANTIE by mfnalex & Le Crochet on desktop and mobile. Play over 320 million tracks for free on SoundCloud.
Less code
Oh, fire π₯
how
Bruh
this song isnt weird as fuck
I show you, one second
https://paste.md-5.net/kimajubifo.java <- DataManager.java
Why why why is there no formatter on the paste site. :3
But that code is working perfectly. Its just the material names
Just use bukkit methods and declare stuff
Instead of adding like goofy functions
yeah that doesnt seem like it would be less code
it would save you a few seconds to type it
Holy shit, what is this indentation? You've got a gap and a half of whitespace.
tf?
The code gets claustrophobic
That's normal.
Why change it when it works?
You don't have to change it, but that's not going to change the fact that I'm bothered by it.
Well it's your decision not us
Relax, he used pastebin and it probably reformatted it
?nms
what happened with yalls fonts
sniped
I was so close too. :3
is there an api to download the mappings
Also, I found my issue. There is no Deepslate stairs and slabs. They called DEEPSLATE_TILE_STAIRS
i need the raw mappings
Spigot mappings only exist for class names btw
ik
Methods and fields are obfuscated
ik
What'd I say. It's all about the names.
i need an api to download the raw mappings for spigot
spigot mappings are just what you get if you have the spigot dep instead of the spigot-api dep
I'm not using the mappings for development
i need the mappings to map all the spigot remapped class names to the original obfuscated names
Use paperweight
also I need to have it automated
And reobfJar task after build
so is there an HTTP API i can get the raw mappings from
And somehow maven does it
?nms
Maven does it with the special source plugin
No, there is only local mappings.
Which the special source jar can convert.
does buildtools generate the mappings?
What are they trying to bounce?
why does it matter?
Buildtools will install the remapped stuff to your local maven repo provided you use the --remapped flag.
^
does that include the mappings file
It includes the mappings as files
alright
org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang
Its a txt file in your local maven repo
Are you guys working as dev / SE or do you do something completely different?
Iβm a SE
Makes sense
hey guys i need help for a plugin i try to furnace an entier inventory but i don't find how to do it if someone can help me it's can be really usefull for me
Furnace an entire inventory? What do you mean ?
I think they want to smelt stuff?
?paste
here's how I smelt items in Drop2InventoryPlus: https://paste.md-5.net/cedixuqufo.java
I just generate a Map<Material, Material> on startup for that
Granted if you want to handle the xp and whatnot you need to store a bit more than just the output material
i already got a furnace for item in hand but i try to imrpove it with another command for all item in stuff
(sorry i'm french my english is not very good)
just loop over the inventory, and do the same thing for every item inside
how i can create a loop for check every slot ?
for(ItemStack item : player.getInventory()) {
// Do your stuff for "item"
}
Inventories are
Uhh whatβs th- yeah that
they've been iterable at least since 1.8, idk about before
hi, good bye
mf can i send u my furnace plugin and tell me what i need to change ?
why don't you just send it here?
how i can do it
upload it to github
in IntelliJ you can do VCS -> GitHub -> Share Project on GitHub (or sth like that)
Is there a way to get the loot for an animal kill with an item stack?
you gotta make it public, it's a private repo
On the repo, go to Settings -> scroll down -> Change Visibility
I have the loot table, but how do you get the context?
You make one
done
it's empty?
LootContext has a builder
no why ?
Granted you canβt just stick an item in the loot context
But you can stick the items level of the looting enchant
C'est vide π
attend parce aue je l'utilise pas souvent git xD
ben j'ai tout perdu je sais pas pourquoi
π«¨π«¨
Il faut que tu aies une fonction qui prend en entrΓ©e un ItemStack, et qui te donne l'ItemStack "cuit". Une fois que tu as Γ§a, tu l'applique Γ tous les items de l'inventaire
ben je l'avais mais plus maintenant xD
oh pire je le refais et je t'envois en privΓ© ?
oui oui bien-sur
je suis un Baguette
I am a long bread
I can say weird useless things in at least 10 languages
imma keep quiet
In turkish i can ask the bus driver to stop at the insurance company
Dont ask me why
lawyer things
Nah that was a personal thinf
How safe is it to store player inventories using persistent data versus something like files/databases?
why
I wouldn't use the PDC for that. Putting too much info in the Player object just makes performance worse.
Meh
Not really
It might making loading it a tiny bit slower, but thatβs done async anyway afaik
^ and it's done once
im trying to add a player to an sqlite table if they arent already in it. how can i check if the table does/doesn't contain an entry (their uuid)?
Ever made sql requests ?
admittedly no
ill look into it
I advise you to checkthe basics first
And chatGPT does know SQL really way if you need help with requests
thats true actually, i should be using that
Well, we're still here to help you
But SQL is really simple and it's a great skill to learn
We don't want to spoonfeed ya
@agile anvil c'Γ©tait ou que je devais te mettre la class ?
?paste
no english?
c'est good
I need someway to temporarily store player inventories when they join/leave a world. I figured using PDCs might be more convenient than files
I'll do the bridge for you
now we get a combination of french and englush π
We call it franglish
oh no dont do that in pdc
as safe as their normal inventory. PDC is just an NBT tag, just like the regular player's inv
serializing a whole item state is already terrible enough, dont make it worse
sorry it's easier for me to speak in french with him :/
We need the link of your paste ahah
kekw
https://paste.md-5.net/aqikohohaf.java this one ou un another one ? xD
As the rules say you should continue in dms if you want to speak french
This discord is english only
For real?
Yes
πππ
bruh turns out if you read a file line by line, the \n character is gone
been looking at overflow bugs for two hours now
Would it be advisable though? Like FourteenBrush was mentioning?
Could you please just have a look on the code guys? L3onis wants to "furnace" all of it's inventory
that sounds funny though
Isn't there a cheaper way to find the furnaced result of an item?
I would always use the PDC for stuff like this
it's the easiest way, it has no leftover files or any database needed, and it automatically gets loaded when the player joins
it's perfect for this
but can you serialize an itemstack directly to a pdc or is there some tricky mess?
loop over all existing SmeltingRecipes
I need to finish that PR for offline PDC access
does that involve loading the player files?
There is no PDC adapter for ItemStack
I do it through ConfigurationSerializable -> byte[]
Hello, why is Player.getVelocity() returning 0.0,-0.0784000015258789,0.0 While i am walking?
Yes
I mean, you'd have to do the same for DBs or yaml files
meh i should just save it to a file then
The -y velocity is basically gravity
but x or z should be non-0
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/

Well, no built in one*
Why are they 0 then?
well my version of ItemStacks is just throwing it at BukkitObjectOutputStream and then you got byte[] which is builtin
idk, show your code
System.out.println(player.getVelocity());
show more code
NMS has a system to serialize them but meh
NBTItem weaponNBT = new NBTItem(weapon);
JSONParser parser = new JSONParser();
JSONObject weaponTag = (JSONObject) parser.parse(weaponNBT.getString("usbus_item"));
String weaponType = String.valueOf(weaponTag.get("weaponType"));
System.out.println(player.getVelocity());
GenericRangedWeapon tmp = new GenericRangedWeapon();
}```
well here's the full code for "itemstack in PDC" (or any other ConfigSerializable) https://github.com/JEFF-Media-GbR/MorePersistentDataTypes/blob/master/src/main/java/com/jeff_media/morepersistentdatatypes/datatypes/serializable/ConfigurationSerializableDataType.java
That's helpful thanks
when are you calling that?
how to make tab completition
Does anyone know how I could spawn a mythic mob in code? Or know how I can compile with an error in intelliji
on PlayerInteractEvent
show the whole event code too
here
- using their API
- fix the error, then you can compile it o0
private static void weaponRightClick(ItemStack weapon, Player player) throws ParseException {
NBTItem weaponNBT = new NBTItem(weapon);
JSONParser parser = new JSONParser();
JSONObject weaponTag = (JSONObject) parser.parse(weaponNBT.getString("usbus_item"));
String weaponType = String.valueOf(weaponTag.get("weaponType"));
System.out.println(player.getVelocity());
GenericRangedWeapon tmp = new GenericRangedWeapon();
tmp.shoot(player.getLocation());
}
/** FCT: function that runs on left click with weapon
* @param weapon -> item with which the player has executed the action
* @param player -> the player that executed the action
* @return void */
private static void weaponLeftClick(ItemStack weapon, Player player) {
}
@EventHandler
public static void playerInteractWithWeaponEvent(PlayerInteractEvent event) throws ParseException {
if(event.getAction() == Action.RIGHT_CLICK_AIR) weaponRightClick(event.getItem(), event.getPlayer());
else if(event.getAction() == Action.LEFT_CLICK_AIR) weaponLeftClick(event.getItem(), event.getPlayer());
}```
printing out the last char of each line, what happens on the empty line lol
I found this on a spigot post they say this works but MythicMobs.inst().getAPIHelper().spawnMythicMob("name of mythic mob you want to spawn", <location>);
this causes an error thats why im having trouble
The issue is I can't pass it sense I'm using a listener to open the new menu.
yeah, same happens for me
You'll have to store in a variable somewhere that info. Or use the inventory name of the listener
and what does this error say?
so should I calculate it by subtracting locations over a defined period of time?
that'd definitely work
Since I got the deepslate issue fixed, I been driving at 100 mph around GTA SA
How could I store the variable exactly?? Cause dosen't it reset after using it or?
java: cannot find symbol on MythicMobs
Any idea why is this not working? as subtracting won't work well because I need it to execute action imediatly after player interract.
I know my ways around GTA SA, just like me with programming. I keep repeating this, there are times I needed help but I should have looked in the creative mode
DEEPSLATE_SLAB -> DEEPSLATE_TILE_SLAB
Use inventory name it's easier
Please donβt identify inventories by name
idk why this is not working, but why don't you just save the last two locations
Because I need it to execute with as little latency as possible
It will be accurate, as the timer always runs at the start of tick. first, we create a class that can hold two of any, where you can push one object in, and get the previous one out, I called this PairBuffer
public static class PairBuffer<T> {
T current;
T previous;
public void push(T value) {
previous = current;
current = value;
}
public T get() {
return previous;
}
}
then we need a runnable that keeps track of the velocities in a map<UUID,PairBuffer<Location>> (or use a Vector instead of location, doesnt matter)
public static class VelocityTracker implements Runnable {
private final Map<UUID, PairBuffer<Location>> lastLocations = new HashMap<>();
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
lastLocations.computeIfAbsent(player.getUniqueId(), __ -> new PairBuffer<Location>()).push(player.getLocation());
}
}
public org.bukkit.util.Vector getVelocity(Player player) {
Location locNow = player.getLocation();
Location locLast = lastLocations.computeIfAbsent(player.getUniqueId(), __ -> new PairBuffer<Location>()).get();
if (locLast == null) return new org.bukkit.util.Vector();
if (!Objects.equals(locNow.getWorld(), locLast.getWorld())) return new org.bukkit.util.Vector();
org.bukkit.util.Vector velocity = locNow.toVector().subtract(locLast.toVector());
return velocity;
}
}
computeIfAbsent because the return value could be null, ofc
and then just use it
private final VelocityTracker velocityTracker = new VelocityTracker();
@Override
public void onEnable() {
getServer().getScheduler().runTaskTimer(this, velocityTracker, 0, 1);
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (event.getHand() != EquipmentSlot.HAND) return;
player.sendMessage(velocityTracker.getVelocity(player).toString());
}
works for me, and it also doesn't show the gravity that you probably don't want to have
value is also always the same if I walk as straight as possible
How can i keep them dying till the time elapsed? ```java
package commands;
import chiru.deathconsequences.DeathConsequences;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import java.util.HashMap;
import java.util.UUID;
public class Death implements Listener {
private HashMap<UUID, Long> deathTime;
public boolean canSpawn;
public Death(DeathConsequences plugin){
deathTime = new HashMap<>();
}
@EventHandler
public void onDeath(PlayerDeathEvent event){
Player player = event.getEntity().getPlayer();
deathTime.put(player.getUniqueId(), System.currentTimeMillis());
if(deathTime.containsKey(player.getUniqueId())) {
long timeElapsed = System.currentTimeMillis() - deathTime.get(player.getUniqueId());
long timeElapsedS = timeElapsed / 1000;
if(timeElapsedS > 50){
deathTime.put(player.getUniqueId(), System.currentTimeMillis());
canSpawn = true;
player.sendMessage("Respawn!!!");
}
else {
canSpawn = false;
player.sendMessage("Wait : " + (50-timeElapsedS));
}
}
}
@EventHandler
public void onSpawn(PlayerRespawnEvent event){
if(canSpawn == false){
event.getPlayer().setHealth(0);
}
}
}
hey, i am getting this error:
at java.base/sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:339)
at java.base/sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:281)
at java.base/java.util.jar.JarVerifier.processEntry(JarVerifier.java:321)
at java.base/java.util.jar.JarVerifier.update(JarVerifier.java:234)
at java.base/java.util.jar.JarFile.initializeVerifier(JarFile.java:763)
at java.base/java.util.jar.JarFile.getInputStream(JarFile.java:846)
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:173)
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144)
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:381)
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:224)
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:928)
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273)
at java.base/java.lang.Thread.run(Thread.java:831)
and these are my dependencies:
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.NuVotifier</groupId>
<artifactId>nuvotifier</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>com.jeff_media</groupId>
<artifactId>CustomBlockData</artifactId>
<version>2.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230227</version>
</dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.3</version>
</dependency>
<dependency>
<groupId>com.github.theholywaffle</groupId>
<artifactId>teamspeak3-api</artifactId>
<version>1.4.0-SNAPSHOT</version>
</dependency>
</dependencies>```
you didn't sign the .jar
wym
which plugin are you trying to compile?
the reason is this:
<groupId>com.github.theholywaffle</groupId>
<artifactId>teamspeak3-api</artifactId>
<version>1.4.0-SNAPSHOT</version>
</dependency>```
since i have added this, i am getting this error
are you shading it?
wym with shading?
?scheduling