#help-development
1 messages · Page 103 of 1
Slash commands are easier to search through
ofc
but on my bot, you can just do ;help <command>
and it outputs an entire fancy embed message with all yu need to know
which only you can see
Well with slash it also allows for the ability to not need a help command as all that info is built into discord.
it costs me more time to rewrite the sytem than it costs me to use ;help <command>
so i won't change except they really force me
wasn't your name like celina or smth not long ago?
possible
Yeah but for the spigot bot it'd be nice
I'm using it
it's ?cc
The NMS methods change on some versions.
what has this become if even mods don't tell the truth
Reported
Ppl spam them so ssamjh removed a lot of perms

It's my commands and I want it now
//instance extends JavaPlugin
InputStream inputStream = instance.getResource(path);
if(inputStream==null) throw new RuntimeException("Input Stream <"+path+"> doesn't exist.");
NPE: Caused by: java.lang.RuntimeException: Input Stream <structure\ritual_struct\amethyst\amethyst_01.dat> doesn't exist.
where tf did my file go
I would've rioted if it worked for you and not me
i'm clearly a trustful person
Ppl are asking for help here so go to another channel for your discussions
on the topic of needing help
Isn't there like
'non static method cannot be accessed from a static context'
Check the path in the jar to be sure
well it works with the same path and the test command
resource path is good in the built jar too
i want to know why the SAME method call does work on one occasion but doesnt on the other
Where is the one that returns null called from
//This is an eventHandler class
Echo instance;
public EventHookPlayerInteract(Echo echo){
instance = echo;
}
//...
Structure struct = RStructHandler.findStruct(instance,event.getClickedBlock().getLocation());```
calls, through a loop that gives some more args, and passes down instance
```java
public static MultiBlockStructure getMBS(Echo instance, String path, String name, Boolean strict, Boolean ignoreAir){
try{
InputStream inputStream = instance.getResource(path);
if(inputStream==null) throw new RuntimeException("Input Stream <"+path+"> doesn't exist.");
can someone help me a bit ? how should i add this to my project so i can use it in my plugin classes that i create https://github.com/NoSequel/TabAPI
The issue is that you probably need to find someone hosting that artifact on maven
orrr jitpack
update: rebooting didnt help
nobody is probably hosting it on maven
if it would be on maven i would easily do it already
Apparently jitpack fails
it does?
I'll see if I can publish an artifact
wow sure yeah
oh jesus that repo is a chonker
i am able to look it up tho https://jitpack.io/#NoSequel/TabAPI/main-c51f5f5b3f-1
that is probably the only api that can sort of be used and that has some sort of example how to use it
make your own 😄
Oh yeah, jitpack works
tabapi that is on spigot is 1.12 to above but i plan on 1.8 to above so that is not really a option
well 2 guys told me NMS or packet wrapper but i dont know how to use either
You probably want to depend on that shared dependency, but given that I have never used it so idk
time to learn then
well from where
[WARNING] Some problems were encountered while building the effective model for io.github.nosequel.tab:v1_17_R1:jar:1.1-SNAPSHOT
[WARNING] The expression ${parent.version} is deprecated. Please use ${project.parent.version} instead.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
NOICE
[ERROR] Failed to execute goal on project shared: Could not resolve dependencies for project io.github.nosequel.tab:shared:jar:1.1-SNAPSHOT: Could not find artifact com.github.ProtocolSupport:ProtocolSupport:jar:f188eb2ea8 in jitpack (https://jitpack.io) -> [Help 1]
Yeah sorry, fails to build for me
so i should learn NMS ig
okay
well then
can SOMEONE explain what im supposed to use in place of File.separator, because that doesnt work
[21:50:10] [Server thread/INFO]: [Shards] Trying to access: structure\ritual_struct\amethyst\amethyst_01.dat
[21:50:10] [Server thread/WARN]: [Shards] Tried to access a non-existent resource file: structure\ritual_struct\amethyst\amethyst_01.dat```
second doesnt work
It should
?paste
And ProtocolSupport is a gradle project, so yeah that is where it ends I guess
And WTF, why is that project AGPL
what ru even tryna do in the end
no i dont
URGH
so apparantly file.pathSeparator is a ';' for some reason
so neither file.separator nor file.pathseparator allows me to create a functional path
any ideas
It's probably something with how you are using that value. You have value 1 acting as a double in a string format. Your second value is the string representation of null. You then try using value1 for the player name and value2 for something else. So value1 is most likely null as there will never be a player named 20.0
How can i make spawn a armorstand looiking at the player who spawned it?
What are you trying to do?
trying to find out why file.separator isnt working
redemptd dmd me to just use / which SEEMS to work
what does it return?
a NPE
lol
What about
FileSystems.getDefault().getSeparator()
but yeah you can add the slashes as a string aswell
refer to this for nonsense ig
also returns a backslash
which is kinda the issue here
spigot wants a forward slash for some godforsaken reason
yea thats what im doing now
Well a forward slash is the most common since 90% of the internet runs on UNIX based OSes.
It's also pretty much the standard when it comes to zip files as well.
probably cuz unix is free
Also, regarding this, how do you define your path variable?
how should i go about tracking this
When dealing with internal resources, you just start at the parent directory.
im thinking about mojang statistics
and checking the distance difference every 10 seconds or something
but im not sure how to get those stats
via a loop but you can see at the screenshot its existing
theres a event for when statistics change but i dont recall what it was
Wdym with a loop? Are you saving multiple resources? If so, are you modifying the path all before using it in a loop? How is that variable defined?
declaration: package: org.bukkit, interface: OfflinePlayer
also works for Player. No need for OfflinePlayer
Every few seconds you check how much the statistic changed *since the start of the quest
yeah thx i got it
thats a much better idea than playermoveevent tbh
Hey, sometimes my GUI closes randomly, without me doing anything
Why would that be?
not sometimes, it's consistent, in the first seconds of it being open
You close the GUI through code somehow
then you have some issue in your code
Is there any specific reason why you are using Paths#get() instead of the more common File.separator? There's a number of ways you can get a much more accurate path than that method. One of them being just making a new file object and passing the path of that file instead. Or you could write the string manually and use the File.separator to make your path, since it's basically the same as what Paths#get() does.
I open that same GUI through a different command, and that issue doesn't happen tho.
both fuck me cuz theyre both backslashes and produce a npe as a result
hence me now using a forward slash character in place of file.separator
Can't really help much, show code if you want or check it by yourself if there's something closing the GUI
Hold up. Are you only accessing internal resources? Not ones that have already been written to disk?
yes
Will do, thanks.
Oh, then yea. You'll have to use forward slashes. Internal resources are treated differently. If it was on the disk, File.separator would work as expected. But when traversing internal directories, the behavior is different. I'm not 100% sure why, but the internal spigot methods like #saveResource() automatically convert backslashes into forward slashes.
You could also do your scheduler and check the distance from the last location. Sure it wouldn't account walking in circles correctly but it would be fine for the most part.
yeah thats the problem
its for long distance stuff, so if they make a turn with an elytra or something it wont account for any of that
the mojang ones are pretty accurate so imma do that
it helps to know that spigot has a universal file separator in the form of a forward slash
Well if you do it every second it would :p
ill just never bother with file.separator in spigot ever again
well yeah but i feel like that would be more resource intensive than just checking every 5 seconds
and theres no point since theres an easy way anyway
This is not a spigot issue. I also use this and never had any problems. Neither on windows nor Linux.
yeah then just add up the different ones you need
AVIATE_ONE_CM
I think that's an overreaction, but to each their own. It's not really an issue with spigot, but the way things are handled in memory.
got it
Distance by Elytra The total distance traveled by elytra. minecraft:aviate_one_cm
It's Elytra
I guess I should be a little more specific with this. Some of the internal spigot methods, not all of them, convert to the forward slash. It depends on the context that you use them. For instance, when saving resources from your jar file, you need to use a forward slash with #saveResource(). If you found another way to get the file from your jar, you would likely use File.separator to preserve the directory structure.
Either way, it's not going to hurt anything or anyone if you use the methods as they are intended.
Is there a way to set server motd without using the ServerPingEvent or whatever its called.
i thought so
server.properties
😂 thats my fault for not being descriptive enough
I'm doing it with code
ServerListPingEvent
😢 static here I come
Why?
hmmm actually 🤔 I might beable to do this without breaking oop gotta think
eh figured it out without static just going to be a pain to implement
but i like static 🥺
god no
in a good 90% of cases its just used wrong and makes code unbearable to maintain
the exception being an Actual Singleton class
Distance Flown Distance traveled upward and forward at the same time, while more than one block above the ground. minecraft:fly_one_cm
Ok, now do it with the whole armor stand, not just the head.
Then make every body part spin 360 constantly.
?paste
In case you still need it
https://paste.md-5.net/abuhuzatew.cpp
If I develop a plugin for 1.19 using JDK16, and have it technically still be runnable in previous versions code-wise, will I be able to run it in servers that use a lower JDK?
so, 1.16.5 and older?
if u compile it on a lower jdk
But then I won't be able to run that on higher jdk's will I?
thats not true
Oh?
almost all java code runs on higher java versions flawlessly
parts of minecraft 1.19 still have java 1.8 code
I see, thank you.
Can anyone help me? I get this error: Error occurred while enabling Testing v1.0-SNAPSHOT (Is it up to date?) java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics at me.jones.testing.Testing.onEnable(Testing.kt:14) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.19.2-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.19.2-R0.1-SNAPSHOT.jar:?]
How can I fix this? I am initialising the Listener like this:```tk
var manager = Bukkit.getPluginManager()
val joinlistener = JoinListener()
manager.registerEvents(joinlistener, this)```
Did you shade the needed kotlin lib?
Wdym? It worked with an easy msg to the console until I added the Listener...
You need to shadow the kotlin std lib into your plugin jar so you can use it on runtime
How can I do this?
Any reason why you want to insist on using kotlin?
Can I develop plugins for, say, 1.16.5 with the 1.19 spigot pkg?
Probably. But thats a bad idea.
What's the problem with Kotlin? It should be about the same
You develop for a version and hope that newer versions still support the plugin.
So there's no way to make a universal version?
I was going to use reflection on a lot of things for it, but I remembered that we need to download the api and yeah
Get the shadow plugin and shade in the kotlin std lib. Thats what you need to do anyways if you write kotlin for the standard jvm.
You can make your plugin support multiple versions, but don't expect it to be as easy as just using methods from the latest version of the API. APIs are constantly changing, so methods like reflection will only get you so far. If you want a plugin that'll run perfectly on every version, you need version specific code.
But it worked until I used the plugin Manager. And the code is in Kotlin in the main. Or do you think that in this case I have to change the listener of the other program to Kotlin separately? In that case, I'm surprised that intellij doesn't do it itself
So I am making a custom items plugin using YML as the source for making the actual items. I'm using this code for left click actions, https://paste.md-5.net/axiwoqadub.cs
And it is saying that value1 is "null", not sure why. Here's the yml file i am using```yaml
id: "test_item"
name: "&bIt is a diamond!"
material: "DIAMOND"
enchantments:
- "minecraft:loyalty;1"
shape1: " "
shape2: " D "
shape3: "O O"
ingredients:
- "D;DIAMOND"
- "O;COAL_BLOCK"
laction:
- HEAL;%holder%;10.0
raction:
- KILL;%holder%```
||Yeah, I don't expect it to be easy. My only real deterrent here is the API that I have to import to be able to actually code it, I've got no idea how to get one that I can use for all of them/...|| Wait, the API that we use to code is provided to the plugin at runtime right?
Thus why we don't shade it
Show your whole JavaPlugin class pls
oh crap i forget the player
thats exactly why, it was my mistake in the YML
wait no i didnt
That's why multi-module projects exist. Yes, the code is provided at runtime, but if you are using the wrong version of the API, then you'll run into problems.
yeah true, but the problem i am having is that i set it in my config to %holder%, that gets replaced to the player that is holding the item's name. the thing is it isnt using the value i set in the YML item file??
package me.jones.testing
import me.jones.testing.listeners.JoinListener
import org.bukkit.Bukkit
import org.bukkit.event.Listener
import org.bukkit.plugin.java.JavaPlugin
class Testing : JavaPlugin(), Listener {
override fun onEnable() {
// Plugin startup logic
Bukkit.getConsoleSender().sendMessage("§bPlugin was loaded §asuccessfully§b!")
var manager = Bukkit.getPluginManager()
val joinlistener = JoinListener()
manager.registerEvents(joinlistener, this)
}
override fun onDisable() {
// Plugin shutdown logic
}
}```
and the listener:
```package me.jones.testing.listeners
import net.kyori.adventure.text.Component
import org.bukkit.Particle
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.player.PlayerJoinEvent
class JoinListener : Listener {
@EventHandler
public fun onJoin(event: PlayerJoinEvent) {
var p = event.player
var msg = Component.text("§aWelcome " + p.displayName())
event.joinMessage(msg)
p.spawnParticle(Particle.CLOUD, p.location, 30)
}
}```
Where are you setting it in your code?
@lost matrix does this help?
Yes. Solution didnt change.
ok.... and how can i do it?
Wtf?
https://pastes.dev/XRctKLFXl3
player.getStatistic(statistic);```
there are only 2 other parameter types, this is for the walk_one_cm statistic
Material and EntityType
do i need to supply entitytype.player or wht
java.lang.IllegalArgumentException: This statistic does not take an EntityType parameter
damn ok
what the hell
healthy boi
public void rightClickAction(PlayerInteractEvent event) {
List<String> actions = configuration.getStringList("raction");
for (String a : actions) {
a = a.replaceAll("%holder%", event.getPlayer().getName());
List<String> ac = List.of(a.split(";"));
ActionType type = ActionType.HEAL;
String value1 = "imnobody";
String value2 = "5.0";
int index = 0;
for (String acString : ac) {
if (index == 0) {
type = ActionType.valueOf(acString);
} else if (index == 1) {
value1 = acString;
} else if (index == 3) {
value2 = acString;
}
index = index + 1;
}
switch (type) {
case KICK -> {
Bukkit.getPlayer(value1).kickPlayer(value2);
}
case HEAL -> {
Player target = Bukkit.getPlayer(value1);
double amount = Double.parseDouble(value2);
target.setHealth(target.getHealth() + amount);
}
case KILL -> {
Player target = Bukkit.getPlayer(value1);
target.setHealth(0);
}
}
}
}```
i dont understand- how
You don't understand what
why am i getting this error
20 is the max and you tried setting it to 30
its set to 5.0
set their max health first of ur going over 20
im not-
target.setHealth(target.getHealth() + amount);
Im getting the following error, can anyone help?Error occurred while enabling LorePlugin v1.0-SNAPSHOT (Is it up to date?)
Error occurred while enabling LorePlugin v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.vaindev.loreplugin.LorePlugin.getCommand(String)" is null
at me.vaindev.loreplugin.LorePlugin.onEnable(LorePlugin.java:18) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:479) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:520) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3537-Spigot-56be6a8-622dbe6]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:434) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3537-Spigot-56be6a8-622dbe6]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:582) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3537-Spigot-56be6a8-622dbe6]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:401) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3537-Spigot-56be6a8-622dbe6]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:255) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3537-Spigot-56be6a8-622dbe6]
at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:966) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3537-Spigot-56be6a8-622dbe6]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:291) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3537-Spigot-56be6a8-622dbe6]
at java.lang.Thread.run(Thread.java:833) [?:?]```
ohh right i have to be low
target.setHealth(target.getHealth() + amount);
this will set. their health above 20 right
forgot to add the command to plugin.yml
im being a dumbass
your command probably isn't in your plugin.yml
If my plugin yml was in the wrong directory would the plugin not work at all or could that be a possible readon?
reason*
It wouldn't work at all
Okay so at least ik its in the right directory
okay so now the problem i am having is that a input from the YML file isnt working
heres my entire class, the problem lies within the leftClick part (end) https://paste.md-5.net/mohunimaro.java
Here's my YML left click config```yaml
laction:
- HEAL;%holder%;10.0
raction:
- KILL;%holder%```
why are you destroying the yaml format so badly? ;-;
i just figured out the issue
by you saying that
there not in strings ;-;
okay turns out it was in the wrong directory, but there was also a plugin.yml in the correct directory
how should i do it then?
not like this man
with actual yaml? Multiple fields?
laction:
task: HEAL
target: %holder%
value: 10.0
something like that
yeah the problem with that is though that i want them to be able to use multible actions
okay now let me change my entire yaml reader
yeah
Just use YamlConfiguration class 💀 It does everything for you
i am mate, i meant like how it reads.
what it reads
what methods
Oh
etc.
yeah do it right then xD
what method would i use to get this section thingy though?
YamlConfiguration#getStringList(path)
thats what im using though
also please let me keep this 🥺
no owo. What does the letter even mean
i-
i just couldn't take another for loop
i hate using for loops this much
💀
public void rightClickAction(PlayerInteractEvent event) {
List<String> actions = configuration.getStringList("raction");
for (String a : actions) {
a = a.replaceAll("%holder%", event.getPlayer().getName());
List<String> ac = List.of(a.split(";"));
ActionType type = ActionType.HEAL;
String value1 = "imnobody";
String value2 = "5.0";
int index = 0;
for (String acString : ac) {
if (index == 0) {
type = ActionType.valueOf(acString);
} else if (index == 1) {
value1 = acString;
} else if (index == 3) {
value2 = acString;
}
index = index + 1;
}
try {
switch (type) {
case KICK -> {
Bukkit.getPlayer(value1).kickPlayer(value2);
}
case HEAL -> {
Player target = Bukkit.getPlayer(value1);
double amount = Double.parseDouble(value2);
double c = target.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
target.setHealth(target.getHealth() + amount);
}
case KILL -> {
Player target = Bukkit.getPlayer(value1);
target.setHealth(0);
}
}
} catch (Exception e) {
Bukkit.getLogger().severe("There was an issue using this item.");
}
}
}``` do you see all these for loops???
for(String str : cfg.getString(path).split("\n")
you can put .split after o:
ofc you can
im an idiot
lul
also shouldn't be getStringList not getString?
but your code is messy :x you should have a class that reads config values
Up to you. Either String list or one single multiline string
how do i get the way the player died in a playerdeathevent?
and why cant i just use what i am using?
still yaml
plus its cleaner
if there's no e.getReason() you can get the Players lastDamageCause
more room for more actions
is lastDamageCause an option in PDE
found it :P
e.getEntity().getLastDamageCause();
what does that return
it's not cleaner. That's like using json and doing
"Abilities":["HEAL;%holder%;10.0","TELEPORT;%holder%,%spawn%"] instead of actually using a decent json structure
what does e.getEntity().getLastDamageCause(); return?
Something from the DamageCause Enum
ENTITY_ATTACK, PROJECTILE, CUSTOM etc
what i mean is there is more room for more actions, i have no reason to make it better. my goal is to make it functional
with a valid yaml structure you can also put more actions? I don't get your point.
And while making it functional might be enough for you know - you'll just get used to bad practices that you have to adapt later. Instead you should start doing it right directly. Will make it more understandable for everyone else aswell
im not sure how to redo my code to match that tho :/
Also lets say you wanna add 2 lists of unlimited length to your actions later? How you gonna do that?
Split them with ;; instead of ;?
you limit yourself for the future
is there a way to see all causes?
Well you basically use the functions from YamlConfiguration
getInt
getString
getStringList
and you will probably also have to loop
getConfigurationSection().getKeys(false)
Ctrl+space in your ide on the enum or by checking javadoc
google for "DamageCause spigot docs"
ehh ill do that tmr
if(!(e.getEntity().getLastDamageCause() != DamageCause.ENTITY_ATTACK)) {
causes error
how do i fix
fixed
yeah add getCause()
i fixed with
👍
if(!(e.getEntity().getLastDamageCause().equals(DamageCause.ENTITY_ATTACK))) {
that won't work 💀
rlly
getLastDamageCause returns the last EntityDamageEvent
so you need getLastDamageCause().getReason()
then you can do != again
getCause() sorry
if(!(e.getEntity().getLastDamageCause().getCause().equals(DamageCause.ENTITY_ATTACK))) {?
==
!=*
yup like that with != since you are comparing 2 enums
Although .equals() would default to == anyway. It's an avoidable extra method call
can you use colour codes &4 in ban reasons?
Also keep in mind that entity attack will not be the cause for skeletons arrows
i mostly want it for players
You have to translate them but yes I guess you can
aaaa how would i translate them
ChatColor.translateAlternateColorCode('&', yourString);
returns a string with translated colors
tbf i cba
cba?
it's quarter past 11
cant be assed
wow
mans got a very good sleep schedule
But I'm driving since 14 hours so might aswell help people in here instead of being bored
very developer unlike
True. I'm usually awake till 5-7 when I don't have to work
is there a specifit type of DamageCause for player-inflicted damage?
No you would have to track it using the entitydamagebyentityevent
wait
cant i just use getCause.getEntity
e.getEntity().getLastDamageCause().getEntity()
if it's a DamageCause.ENTITY_ATTACK
Yeah but there's no entity attached to it
How would I give mooshrooms invisibility? (No particles)
oh
LivingEntity#setInvisible iirc
1.16+
mooshrooms
the red cows
the cows
Ooh
👍
is a drop considered a LivingEntity?
alr
just wondering :P
but how would i get the entity from the DamageCause.ENTITY_ATTACK
That's the neat part: You don't
aaaaaaaaaaaa
funny cause ive got a question in the same vein
Track it with EntityDamageByEntityEvent
Yes
in EntityDamageByEntityEvent, event.getDamager() refers to the entity that shot projectile in the case of a projectile damaging
ive got an entire class for listeners so yeah
no it refers to the projectile
does it? u mean i dont need to have this jank solution that checks the shooter of a projectile?
but you can do projectile.getShooter()
ah yeah thats it sorry been a week since i worked with my code you know how it is lmao
you actually need that
😔
You can make a Utils class for it tho
this doesn't get the shooter, it gets the actually arrow/projectile
or more like 1 function in a utils class. Or just add the function to the listener class
honestly at this point probably makes sense for me to do a damageByPlayer event or something and check that
how do i see if EntityDamageByEntityEvent#getDamager is a player or not
getDamager() instanceof Player
ty
That's basically what you would achieve when using the EntityDamageByEntityEvent anyway
just with extra steps
yeah im doing it in like 4 separate listeners wonder if I just create my own class
like own event
keep in mind that a player shooting an arrow will not return true on instanceof player
also not wolves, tnt or anything else where you can get source
yeah why not
welp guess im doing that first lmao
Yup that's why I usually have a method that checks all the cases where a player is involved. Never added tnt tho
aaaaaaa lifesteal plugin go brrrrrrrrrrrr
should i do a method or rather create a new event, cause i already have the premise set up for some of my other listeners
That's up to you. An Event will have more boilerplate than a simple method
would want this to be robust but never set up my own event
I mean instead of simply continuing to do your code after the method call you would then trigger an event just to have another listener that reacts to the event
But if you need it in multiple plugins you could actually make a plugin for additional events or core features or libs or whatever and add it there. That way you would only have to change it inside there instead of changing every plugin
thanks chief
Config:
Hello: "hello"
List: []
Code:
public static List<String> lista = GMDIBank.plugin.getConfig().getStringList("Lista");
lista.add(target.getName());
GMDIBank.plugin.getConfig().set("Lista", target.getName());
GMDIBank.getInstance().saveConfig();
When saving the list it deletes the string Hello, how can I solve?
¿paste
close
¿help
?paste
ok
I wanna create an array list that contains a whitelist of material but for some reason this doesn't work in the server
?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.
How are you adding the Hello string?
do you ever save the default config? Is it ever in the plugins directory on the server with your hello?
no no
the plugin doesn't do what it have to do anymore
What is it supposed to do?
i get this
You're making a new instance of your JavaPlugin class, don't do that
ahhh, so i can't make an object of my main class
in your onEnable, just do yourInstance = this; to initialize it, instead of yourInstance = new YourPlugin();
spigot initializes it automatically
Or you could use built in spigot method
wdym
Im assuming he is initializing it to get access to vars/ methods
most likely
so getPlugin will do the job
if you mean using getPlugin(Main.class), yes it's possible, but kinda ugly/long
yap, just gave another example how instance could be pass ^^
hi what is the type of splash potions, are they considered projectiles?
how do i use NamespacedKey? what am i supposed to use as my key?
do i use different keys for different types of data?
What are you using it for? Your key should always be your plugin name, but Spigot should generate that for you since the only non-deprecated constructor requires a Plugin instance.
This isn't really about spigot, but yeah
I had a multi-module maven project, and I loaded it up now, and reloaded maven... and this happened
everything kinda broke apart and now it's not a modular project anymore? and yeah
How would I fix this...?
I'm clueless
It can be whatever String you want it to be.
It depends on what you're using NamespacedKeys for.
PersistentData
For example, Minecraft uses them. minecraft:diamond for example. minecraft is their namespace, and diamond is the key they use.
ohh i see
thats what those are
well i just want to store some data on an item
do i just call it data and be done with it
You could but I would name it something more meaningful to what you're actually storing.
so i do use different keys for different data
Yes, so if you were storing 2 ints and a String onto something, each would have their own unique key identifier.
level, damage, and name, for example.
I know Gradle does this if the names don't match in my settings.gradle. Could be something similar?
I'll check
for some reason i thought you needed the key to get the data container, not as an actual key for the data
how do i get the plugin instance? do i use the plugin manager or is there some convenience method to get the current plugin
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Is there a way to make the icons not be replaced? Or at least be consistently replaced?
Disable the plugin thats replacing them
It's probably the mc plugin one
thanks
Thought that was default behaviour in some way
im trying to add a dbfile to the datafile but i keep getting this error, dont worry about the warn, also its the sql part of the java code
[23:38:37 INFO]: [Genesis-network] Loading Genesis-network v1.0.0
[23:38:37 INFO]: Connection to database
[23:38:37 INFO]: [Genesis-network] [STDOUT] [INFO] SQLite file "DONT-TOUCH-THIS/database.db" not found, creating file...
[23:38:37 WARN]: Nag author(s): '[Jonathan_Nathan]' of 'Genesis-network' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[23:38:37 INFO]: [Genesis-network] [STDOUT] [ERROR] Error at creating database connection: path to 'DONT-TOUCH-THIS/database.db': '/home/container/DONT-TOUCH-THIS' does not exist
[23:38:37 INFO]: [Genesis-network] [STDOUT] [ERROR] Database connection failed. Continuing without database.
public Database(DBType dbType) {
try {
if (dbType == DBType.MySQL) {
con = DriverManager.getConnection(
"jdbc:mysql://" + mysql_hostname + ":" + mysql_port + "/" + mysql_database
+ "?autoReconnect=true", mysql_username, mysql_password);
Gen.getInstance().getLogger().info("[INFO] Successfully initialized database connection.");
} else if (dbType == DBType.SQLite) {
File sqliteFile = new File(Gen.getInstance().getDataFolder(), filePath);
if (!sqliteFile.exists()) {
Gen.getInstance().getLogger().info("[INFO] SQLite file \"" + filePath + "\" not found, creating file...");
sqliteFile.getParentFile().mkdirs();
Gen.getInstance().saveResource(filePath, false);
}
con = DriverManager.getConnection("jdbc:sqlite:" + filePath);
Gen.getInstance().getLogger().info("[INFO] Successfully initialized database connection.");
}
} catch (Exception ex) {
Gen.getInstance().getLogger().severe("[ERROR] Error at creating database connection: " + ex.getMessage());
}
}
try to use jdbc:sqlite:// + file path
thats what i have
/**
* SQLite Data
* Set this data if you use DBType#SQLite
* <p>
* field filePath - This can either be a relative or absolute path.
* ex: sokobot.db
* or: C:/sqlite/db/sokobot.db
*/
private final String filePath = "DONT-TOUCH-THIS/database.db";
/**
* MySQL Data
* Set this data if you use DBType#MySQL
*/
private final String mysql_hostname = "";
/**
* MySQL Port
* Set this data if you use DBType#MySQL
*/
private final int mysql_port = 3306;
/**
* MySQL database
* Set this data if you use DBType#MySQL
*/
private final String mysql_database = "";
/**
* MySQL username
* Set this data if you use DBType#MySQL
*/
private final String mysql_username = "";
/**
* MySQL password
* Set this data if you use DBType#MySQL
*/
private final String mysql_password = "";
/**
* the connection
*/
public Connection con = null;
/**
* the database type
*
* @apiNote the dbType set in Bot.java
*/
not according to your screenshot
con = DriverManager.getConnection("jdbc:sqlite:" + filePath);
you have this
change it to jdbc:sqlite://
might be bc i dont have the driver
idk ill try with the driver
so
its creating the db but
i get
[00:21:37 INFO]: [Genesis-network] [INFO] SQLite file "plugins/Genesis-networkDONT-TOUCH-THIS/database.db" not found, creating file...
[00:21:37 ERROR]: [Genesis-network] [ERROR] Error at creating database connection: The embedded resource 'plugins/Genesis-networkDONT-TOUCH-THIS/database.db' cannot be found in plugins/GenNetwork-0.0.1-SNAPSHOT.jar
[00:21:37 INFO]: [Genesis-network] [STDOUT] [ERROR] Database connection failed. Continuing without database.
have you actually tried what hyperdefined said?
no bc i have used the same exact thing in a diff project and it worked ill try it tho
// is defining a new path
- [00:26:12 ERROR]: [Genesis-network] [ERROR] Error at creating database connection: path to '//DONT-TOUCH-THIS/database.db': '/DONT-TOUCH-THIS' does not exist
is there a way to damage a player without applying knockback?
Player.damage(double) does exactly that but the damage is absolute and ignores armor which isn't what i want
It seems that maven is hiding the version names for my modules. How would I make it not hide them?
i create a file the same way with
private void createCTConfig() {
ctConfigFile = new File(getDataFolder(), "minigames/Color-Takeover.yml");
if (!ctConfigFile.exists()) {
ctConfigFile.getParentFile().mkdirs();
saveResource("minigames/Color-Takeover.yml", false);
}
ctConfig = new YamlConfiguration();
try {
ctConfig.load(ctConfigFile);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
is there a tool to obfuscate code at compiling time with gradle?
ok i fixed it all i need to do was con = DriverManager.getConnection("jdbc:sqlite:" + Gen.getInstance().getDataFolder() + "/" + filePath);
unless you are on an old sql driver you need to use getDatafolder().getRelativePath()
newer drivers don't allow that
it might need absolute. I'll check. One sec
ide slow opening
needs absolute getDataFolder().getAbsolutePath()
is there a list of metadata that bukkit already has for items somewhere/
the namespacedkeys?
are there any good forms on how to send an actionbar using nms
why do you need nms
just use spigot api
?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!
Wdym it doesn't work
Do they just ignore it?
I don't really understand what you mean by the last part honestly.

The Endermen teleports instead of walking when you call moveTo?
What are you setting speed to?
does NamespacedKey#minecraft have to be a default minecraft key?
or can it be anything
Aren't you talking about walking though..?
It can be anything. It just uses the minecraft namespace
I mean you just said it yourself. Speed affects walking. If your speed is too high it will look like they're teleporting. moveTo alone isn't going to teleport an entity afaik.
Let me try something.
Well I've broken Minecraft
getNavigation().moveTo() works for me
public class CustomZombie extends Zombie {
public CustomZombie(Location location) {
super(EntityType.ZOMBIE, ((CraftWorld) location.getWorld()).getHandle());
this.setPos(location.getX(), location.getY(), location.getZ());
((CraftWorld) location.getWorld()).addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
}
@Override
public void tick() {
super.tick();
this.getNavigation().moveTo(this.getX() + 5, this.getY(), this.getZ() + 5, 15);
}
}
I'm constantly reminding him that he needs to get his ass moving
Every tick
Just uh
Just make sure you call super.tick() or you get the broken guys that dont leave
Because if you override tick() without calling super then nothing happens when the server ticks the zombie
Which means no AI... no anything. It just does nothing
He'll stand there I assume
You need extra logic to prevent him from going there permanently
Or a Goal
You can do it in the Goal's tick method then
That way he'll only move there when the Goal's canUse() method returns true.
Want him to move? Let him use the goal. Don't want him to do that? Return false
Guys can someon help i have vault,luckyperms and prefix wont show
do you super() in teh tick method of your mob?
this is in my NPC```java
@Override
public void tick(){
super.tick();
doTick();
}
@Override
public void doTick() {
super.baseTick();
moveWithFallDamage();
}```
calls teh local doTick
for movement
I guess
I dont even have doTick
That is for ServerPlayer. I've not messed with mobs
Ah
But I'd assume its close
Mobs dont have doTick
then probably just super in yoru tick method
So you just need tick()
Yes
@quaint mantle https://paste.md-5.net/finerugute.java
Something like this, if you want to use goals.
Look at what mine is doing, might give you hints as to what you're doing wrong.
You should be adding the goal when you create the Zombie, for instance.
Also 10 is an insanely high speed
I did 3 earlier and he was the god damn flash
You can do both of those things yes
Lower the speed, and then re-work your goal properly.
Call moveTo in the Goal's tick method and use canUse() in the goal to determine when he should be moving towards your target.
Like I said, something like this.
You don't, thats fine.
Yes, if that returns false then the goal's tick() method won't be called.
So he'll stop moving.
Well in my case it's just toggling his movement every 100 ticks. You can decide when yours moves and doesn't move.
I dont know what constraints it should have
Stop moving when he reaches the block or something I guess?
Then yeah stop the goal once he reaches the block
Make canUse return false
Mhm
thats a local field in his class
FarmShop.setItem(1, carrot);
ItemStack potato = new ItemStack(Material.POTATO);
FarmShop.setItem(2, potato); ```
For some odd reason neither the carrot or potato show up in the gui any ideas?
Show the code for opening the inventory
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
if (p.hasPermission("necon.shop.use")) {
Inventory FarmShop = Bukkit.createInventory(null, 36, ChatColor.GREEN + "Farm Shop");
ItemStack wheat = new ItemStack(Material.WHEAT);
FarmShop.setItem(0, wheat);
// ItemStack carrot = new ItemStack(Material.CARROT);
// FarmShop.setItem(1, carrot);
// ItemStack potato = new ItemStack(Material.POTATO);
// FarmShop.setItem(2, potato);
ItemStack pumpkin = new ItemStack(Material.PUMPKIN);
FarmShop.setItem(1, pumpkin);
ItemStack melonBlock = new ItemStack(Material.MELON);
FarmShop.setItem(2, melonBlock);
ItemStack melonSeed = new ItemStack(Material.MELON_SEEDS);
FarmShop.setItem(3, melonSeed);
ItemStack returnShop = new ItemStack(Material.BARRIER);
ItemMeta returnShopMeta = returnShop.getItemMeta();
returnShopMeta.setDisplayName(ChatColor.GRAY + "Return to " + ChatColor.RED + "Main shop");
returnShop.setItemMeta(returnShopMeta);
FarmShop.setItem(31, returnShop);
p.openInventory(FarmShop);
}```
They're commented out
The other ones work? Wheat and pumpkin etc?
yea its weird ill send ss
not that, i changed it so that it wouldnt be missing 2 slots
Change it back, I'm guessing it'll work.
maybe ill try and send ss
Uhh you might be able to move it outside, putting it in the tick method just makes 100% sure it doesn't lose interest for some reason.
is there an api method for reading the action bar?
ad a method so you can set shouldMove
public void setCanMove(boolean value) {
this.canmove = value;
}```
no, you don;t want a listener per mob
with that above method you can enable or disable the mob movement in your listener
yes
yes, no clue why you are nesting
Goal has nothing to do with PlayerEvents
the Goal should be its own class or nested in the mob itself
The mob should not have its own listener
Its an action of your Player not teh mob
it affects the mob but its an activity your player is doing
teh Goal should not implement Listener
Ok, single responsibility principle Your one class is currently a Player event listener, a mob spawner and a Goal creator.
your Player Listener class shoudl ONLY listen to player events.
I go a step further and only listen to 1 player event per class :p
only so I don't get distracted thats a bit overkill
you don;t
you call a toggle to enable/disable the mob from moving
in your MyMob class you have a Field for canMove, or whatever you want to call it
you have direct access to that when you get a mob instance in yoru single responsibility PlayerListener
you can set the mob to moving or not.
You are literally just moving public boolean shouldMove; into your MyMob class.
add a getter/setter for it.
and move your MyGoal out of your listener
Trying to replace the CustomModelData of an item in an item frame.
I tried frame.getItem().getItemMeta().setCustomModelData(newvalue); to no avail, next I tried:
ah yep you put the item back
no need to do that, just apply the meta back to the item.
It came up now 😄
fingers crossed!
Looks like it needs both, but it's (sort of) working!
Hi a question im trying to make a config where the user can add more level
ActionPercentage:
enabled: false
level_1:
percentage: 10
Behavior: "{Behavior}, Replika doesn't love user but like him as friend"
i tried using a for but without result any solution?
not the chatbot that you think i made a chatbot plugin with AI related chatbot
no
if(Main.getInstance().getConfig().getBoolean("Replika.ActionPercentage.enabled")) {
for (int i = 0; i < Integer.parseInt(String.valueOf(Main.getInstance().getConfig().getStringList("Replika.ActionPercentage.level_" + i))); i++) {
System.out.println(i);
}
}
.
Loop getKeys
use getConfig().getConfigurationSection("Replika.ActionPercentage").getKeys(false)
with integer parseinit and string value?
for (int i = 0; i < Main.getInstance().getConfig().getConfigurationSection("Replika.ActionPercentage").getKeys(false); i++) {
in this way?
yes then i loop a it as string
not with that for loop
foreach?
for (String key : getConfig().getConfigurationSection("Replika.ActionPercentage").getKeys(false)) {
and then with another loop i get the numbers?
if (split.length == 2) ... //test if split[1] is a value```
also check split[0].equalIgnorecase("level")
if (split.length == 2 && split[0].equalsIgnorecase("level"))...
the code done should be
String[] split = key.split("_");
if (split.length == 2 && split[0].equalsIgnoreCase("level")) {
Main.getInstance().getConfig().getInt("Replika.ActionPercentage.level_" + split[1]);
}
already done
no because its a section not a value
from in there then i can get the values inside
for (String key : Main.getInstance().getConfig().getConfigurationSection("Replika.ActionPercentage").getKeys(false)) {
String[] split = key.split("_");
if (split.length == 2 && split[0].equalsIgnoreCase("level")) {
Main.getInstance().getLogger().info(String.valueOf(Main.getInstance().getConfig().getInt("Replika.ActionPercentage.level_" + split[1])));
}
}
get teh section, then get the keys beneath
this is the code done
no
why not?
its not an int
parse int?
getConfigurationSection(key).getint("percentage")```
ok thanks now should work fine or other things?
nope thats all
thanks for the help
no problem
getConfigurationSection("Replika.ActionPercentage." + key).getint("percentage")```
Who cann help with custom mc plugins and server setup i Will pay.
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Has anyone written load balancing logic? Right now I'm just prototyping and I've made one that is based off of the amount of online players, but it feels very basic. (Get all online servers, sort by lowest player count, then send to the smallest player count server).
Is there a smarter way to balance players? What other contexts should I be considering when it comes to servers?
what's the best way to communicate between plugins without using bungee plugin messaging
is redis good for that? idk i remember someone saying it is but i'm not sure if it was in this context
Heavily context dependent.
If it is different plugins on the same server, the APIs of the plugins are the best approach.
If it is the same plugin on different servers, a shared database is the best option.
If it is different plugins on different servers, it would be a miracle if you could get them to work together properly.
well i'm trying to make a server create-on-demand system thing
like that of bigger servers
Then a shared database would likely be your best bet. You'd just need to setup the proper credentials in your server creation tool.
i'm using pterodactyl
i'm making a standalone java app to run in the background which processes requests (through a shared database)
will that work?
So long as your on-demand servers are able to connect to the proper database, everything should be fine.
hi im making a command and im wondering if i want the format to be like this editlore {newlore} what arg would i use to set the lore, because if i use args[0], if the lore is more than 1 word it will only use the first word
Use the entire array instead of just the first element.
is there a better way of doing it than this?
String.join(" ", args)
Paper is better
Go to the paper discord then. lol
Paper is spigot
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
Paper is literally built on spigot
google what fork means
I know what a fork is lol
what is not clear then ?
Paper has Location.getNearbyEntities but it looks like getNearbyEntities doesn't exist on Location in Spigot, what's the best way to get entities surrounding a central point?
Nothing, what?
Entity#getNearbyEntites()
¯_(ツ)_/¯
Can you explain that a little?
or World#getNearByEntities
I'm not familiar with #
It's Javadoc style, and way more sexier. Grab the instance of you world or entity, and entity.getNearbyEntities()
its just an instance method
Okay, let me look at the docs. This happens after an item frame is removed, so there's no entity to work off of. Lessee
Then work on the world
You could spawn in an armorstand temporarily if you don't want to use the world object, but either way, methods exist.
Thank you
is this in some event?
Yeah, an event I'm trying to have implemented into Oraxen 😄
which event? if its cancellable then teh ItemFrame will still exist. You can use that as the origin
I think Oraxen might have problems with Spigot but I'm coding my add-on on Spigot in case Oraxen fixes their stuff.
It's cancellable, but based on how the OraxenFurniturePlaceEvent works it might delete the items first and then replace them if the action is cancelled
and I misspoke, I created OraxenFurniturePlace not OraxenFurnitureBreak, that already exists.
Interesting, Entity.getNearbyEntities returns a List<Entity> but World.getNearbyentities returns a Collection<Entity>
I mean, maybe incremental things like sending players to servers that aren't full, but have the most amount of players may be a better approach, but I feel that load balancing is very dependent on the context of the servers.
Perhaps things outside the scope of server gameplay should be considered? Maybe servers with high CPU load should be considered as well?
You're loadbalancing inside a bungee ?
Trying to, but for now it's all "artificial" logic as I don't have large amounts of servers and players.
Well, loadbalancing inside a bungee is quite useless. Of course hypixel loadbalance lobbies for instance but that's only to allow players to see something because there are too much of them.
However, loadbalancing become essential when you start having too much players for one bungee: then you'll have to balance the incoming network in multiple bungee instance.
For that don't program your loadbalancer, but use one existing (to be clear, it's not a bungee that redirect to multiple bungee)
I don't see how it would be useless to load balance internally. Sure, externally, 100%, but internal balancing can help with individual server load. That's what I'm trying to target at least.
Also, what's the upper limit for bungee? I thought it could handle something like 2500+ connections pretty easily.
What kind of server do you loadbalance ?
how can i make a Playerhead itemstack with a customhead?
It really depends on many many levels. The easiest to see is the modules and plugins usage, then there is the quantity of packets you send. What I mean is if your servers are vanilla there is no "extra packets" to send through, but when you start playing with particles, animations, quick updates, you're increasing as hell the number of packets. Each packet go through the bungee. So it can even become laggy as soon as 500 players for instance
You should use the SkullMeta of the Itemstack
ok
That's the thing. I don't know what types of server it would be balancing. I'm trying to make it dynamic/flexible enough to handle most cases, or hell, even make it configurable enough down to each individual grouping of servers.
Does that still hold true when certain bungee settings like ping_passthrough or ip_forward are enabled?
just generify both to collection and you are fine
what do the DisplaySlot BELOW_NAME, PLAYER_LIST and SIDERBAR look like?
Playerlist is a number after name (in tab)
Below name is a number below the name
Sidebar is scoreboard
I have some code that I want to reuse across all Minecraft versions, but I have no idea how to do it because it uses code existent in the spigot api. Is there a way to do this?
ah aight
I don't think there is a direction tied to it. It's a coordinate based system, so it just returns the coordinates you are asking for.
fair
on a different note, is there a simpler way of turning a Collection<Entity> into an ArrayList<ItemStack> than looping through it?
Those are incompatible types no?
They are
im getting them with a predicate
So you'd have to get the ItemStack from the entity somehow
all entities are itemstack
That doesn't sound right.
You mean the Item entity?
yes
well droppeditem now ig
Do you mean allowing your plugin to run on all existing versions of spigot?
Nope, I mean having one utility class be reused across all mc versions of my project
copy paste
Yeah, no.
Well, that would depend on what your utility class contains. I feel like I said this earlier today, but I'll reiterate. If you are wanting to use code across multiple generations of an API, you should really abstract your codebase. Make a multi-module project and write version specific code. There is no guarantee that the API you are using will have the same methods available in the future, nor the current functionality of existing methods being the same.
You did say that yesterday, yeah, but I must not have misunderstood because I thought you meant something completely different, it was very late in the day lol.
Issue with that though, wouldn't that work for only 1.17+ projects?
Since java modules were only introduced in JDK9
Also for the non-version specific code; What spigot lib would that use?
I'm guessing just the latest
No, you can have multi-module projects in Java 1.8. It's not a java specific thing, but a project setup thing.
Also, yes, you would use the latest for everything else that isn't version specific.
org.bukkit.craftbukkit.v1_19_R1.entity.CraftItem cannot be cast to class org.bukkit.inventory.ItemStack
welp
how do i cast e instanceof Dropped_item to ItemStacck
CraftItemStack#asBukkitCopy
well the dumb part is
im doing this entirely in bukkit api code
so where does the nms come from
The server provides it to you I believe
So we're not talking about Java modules then? I'll look it up anyways because it's confusing me a little
why does OfflinePlayer#getStatistic() require more than one parameter for the something_one_cm
No, we are not talking about Java modules. I'm referring to maven multi-modules and or gradle multi-modules.
I wasn't aware those existed, thank you.
how can i add a armorstand a tag?
with pdc
whats pdc
?pdc
PersistentDataContainer. AKA, one of the best additions to the API to date.
Bukkit's implementation of nbt ig
thx
I set my logging level to all. a getlogger().fine(message) did not get printed to console
why
Because the logger is configured in a way that it does not log fine messages?
fine is kinda like SLJF4J's trace level - one of the lowest you can have
and a level ALL that can be used to enable logging of all messages.
Does anyone have any example of a spigot multi module project?
the standard one? (class extends JavaPlugin).getLogger()
should be java.util.logging considering it wants a java.util.logging.Level
?jd-s
Yeah, it's java.util.logging.Logger
so whyd it not log fine if the level was all
Anyone know how to retrieve a player's mojang statistic?
mojang stats?
OfflinePlayer#getStatistic() requires additional params, and does not take either EntityType or Material like specified
you mean Player#getStatistic?
I'd guess the underlying SLF4J logger prohibts such fine loggogin
followon from this btw
You can set the logger level fine, you just have to make sure you are using the same logger you set.
the level stays though?
i set the level and later if i check the level it says the level i set
if(strings.length == 0){
commandSender.sendMessage("Please specify a Logging level. Current level: "+instance.getLogger().getLevel());
return true;
}
try{
Level level = Level.parse(strings[0]);
instance.getLogger().setLevel(level);
}
//catch and log test
"Mojang changed it. Its best for plugins to not assert that the statistics are static. Any Minecraft update can change anything."
Does this mean i have to find another way of calculating my stat
or another way of getting the statistic
What I mean is that the java.util.logging logger delegates all logging to the slf4j logger
Or better said the log4j logger
so youre saying i have to use the log4j logger if i want my logging to work
meaning that the way of getting that specific statistic may change?
i.e. additional parameters
yeah but is there any way to even get it
reflection or sum
i dont know much about that
pff
i love completable futures
same, only hate the overhead they have with f.e ::join
and the annoying exception handling
mwoa i love that way of handling them
its a black hole
lets me think of the rust exception handling
Exception handling in concurrent environments is hard to do
if i have a string like "ZOMBIE 10/20 ❤️" where 10 and 20 are green whereas the / is white and the name is some other goofy ahh colour, how do i get the 10 in the string? (10 and 20 are variables)
use String.splt or something
10 and 20 could be 69 and 4 morbillion
strip color first
you should be storing the variables elsewhere anyway
^^
trying to decode a string is just inefficient
get the health and max health then?
put it on the mob itself
its being stored as a mob's name
use pdc or something
tf is that
or health/max health/scale
nbt wrapper
haha
i thought abt that aswell
plus i dont think mobs are persistent data holders
oh wait
they are
i could just do mob.gethealth 💀
sorry went afk what do you mean by this
is that a problem? im not sure how i use that ss lma
also another question do chatcolours become § when you print them as a string
yes
that solves my entire problem
no stupid indentation now
just use translatealternatecolorcodes
i recently cleaned up some of my classes, i feel like it's better to do a negative check and return, and then continue code, instead of nesting like 7 checks
bruh my rabbit escaped and had to catch it
yeah so much nicer to read
just use a leash and speed 3 potion
it ran back into its cage smh
for instance
if (!something) return;
doSomethingElse();
instead of
if (something) {
doSomethingElse();
//more checks
}```
yeah early returns
i thought i saw my cat running but no
are much nicer
bruh whats wrong with the Player#getStatistic
thats literally how you get stats
it just throws errors
that it expects another param?
which statistic?
does it say what one? i forgot tbh
check impl i'd say but impl sucks
all just say
what does it say when providing it with nothin?
yes it should just be the stat enum
Wait which version are you ?
OfflinePlayer#getStatistic(Statistic.WALK_ONE_CM)
myes
no clue what that is
I'll test it
whats the Statistic.WALK_ONE_CM.getType()?
works just fine
System.out.println("Walk one: " + Bukkit.getOfflinePlayer("ElgarL").getStatistic(Statistic.WALK_ONE_CM));
idfk what i did wrong then
extra params can only be of those types
Put on database and get it?
?
genuis
Hello, can anyone help me with that one, i'm trying to make a command send all the players to another server before closing the server they are on (basically, replace the /stop) cause right now it's just disconnecting all of them without giving a warning, a message, or sending them to another server (the hub basically), so what i'm trying to do is that when an authorised user does "/stop" it broadcast a message, if they add a parameter like "/stop <arg1> <arg2>" (where the first one would be a message and the second one the timer (like 10s) it would say "server will close in 10 seconds" and then, tp them and send a message to them (all the tped players) saying "The server you were previously on has been closed, you have been moved to <name>"
public T await(AbsPacketManager packetManager, int timeoutSeconds){
packetManager.sendCallbackPacket(this, timeoutSeconds);
try {
CompletableFuture<T> future = CompletableFuture.supplyAsync(() -> {
while (response == null && !timeout){}
return response;
});
return future.get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
return null;
}
}```
anyone know what i can do instead of this while loop? Just trying to wait until either is satisfied
compiler just removes it if i dont have a body
make it synchronized and use wait() and notify()?
ah didnt even think of that lmao
is this in the context of spigot or whatever?
yeah spigot but async
