#help-development
1 messages · Page 1994 of 1
gnoogle it
my brain stopped working sorry
The new type?
everybody says that I shouldn't use nms if I don't need to
which is true, but depending on what exactly you wanna do, you WILL need NMS
Is it a particularly bad idea to make a new type?
no
it's perfectly fine
depending on what information you wanna store, you can use my lib (MorePersistentDataTypes) or Redempt's lib
e.g. my lib allows you to store FileConfiguration/YAML stuff inside a PDC
For context, I'm currently in the process of writing a plugin that overhauls difficulty in Minecraft without making mobs damage sponges. I'm trying to assign mobs that spawn some behaviors from a pool, as well as some stats that do not exist for entities. So I guess a couple integers, doubles, and some enums
yeah use the existing ones
So just throw it in a string and parse it out?
yeah sure
but that seems filthy
or just store it as a int id
this option is not available. I have thrown out all plugins now, the error still persists
just create a new PDC type
not really
Sorry lol. I appreciate your advice but I will ignore it
oki
sorry alex there is nothing you can do or say to make me use your library
I dont care whether or not you use it lol
but I will steal from it without hesitation as I see fit
in fact it's better for me if you not use it
because it might save me a bug report / github issue
how can i get what plugin it is?
public void timer(Player player){
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
player.sendMessage("Exploding");
}
}, 0L, 20L);
}```
wdym?
what class?
do you need your own or another one
my own
their own
check the blog post I sent
I recommend method 1 because it's easier
some people say it's bad practice and to use number 2 instead. I totally disagree with that though
but just choose whatever you like more
alex, can u help me with nms
no
I mean
I gotta go now
with installing
if not, I can't help, I have a three course meal booked in 8 minutes
or maybe this: https://blog.jeff-media.com/using-nms-classes-with-maven/
how do i fix it
how do i use [] in a string without it throwing me some error
its a private one im in
i just want to split a string at '[]'
and i used intelij vcs
Then you are unlikely to have accidentally started a merge. You can try to re-clone (not pull, CLONE) the repository which may solve it (make sure to fully delete the old folder beforehand to prevent any chance of accidentally pulling) but the bigger chance is that the author forgot to reconcile a merge conflict.
What exactly is you input string
yea i deleted dir and re cloned and still same
Something like [StringA, StringB]?
Then you need to manually reconcile it, or just contact the author and hope they fix it
how do i manualy reconcile
Uh, explaining the basics of merge conflicts will be a bit complicated to explain
would this work?
Regexes do not work
https://regexr.com see this
'work' as in be treated as a [
Then just #substring?
it isnt giving a very useful error
That is because the IDE does not know that it is a merge conflict
could work
idk what i did but i fixed it
You probably just removed the line, but that MAY not solve it
it built fine
You may have dependencies declared multiple times or what, send me the pom
is it possible to make particles move?
Basically if you have a file X with the contents Hello and you change it to Hello World and commit it with the commit Id of let's say 48574646.
Now, if someone else modifies the contents of X to Hello Everyone! and commits it it will get a commit Id of let's say 457433.
If you then pull 457433 onto your main branch (which will be tracked at 48574646) you get a conflict.
Upon trying to merge it, git will say "whoa hold on" and will modify the file to something like
<<<< HEAD
Hello World
======
Hello Everyone
>>>> OtherBranch
You have to choose between one of the two variants, or just change one of them to fit the current state of the repository
if yes how can i make it, i couldnt find anything
Is log4j safe to use now?
yea
how can i fix this error: ** Inner Exception: io.netty.handler.codec.DecoderException: java.io.IOException: Bad package ID 83 **. the bug according to various forums is caused by forge, I personally only use bungeecord / servers and paper servers. the second error is a cracked launcher. Personally, I use a premium launcher and the nickname does not exceed 11 letters error: **Internal Exception: io.netty.hadler.codec.DecoderException: java.lang.IndexOutOfBoundsException: Index 83 out of bounds for length 5 **. I am asking for a hint where the error may be. the servers are on my home server they are not a lease.
do you use protocollib?
hey, i am trying to disable mongo logging by using
((LoggerContext) LoggerFactory.getILoggerFactory()).getLogger("org.mongodb.driver").setLevel(Level.WARN);
But i'm getting a classcastexception:
Caused by: java.lang.ClassCastException: class org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.apache.logging.slf4j.Log4jLoggerFactory is in unnamed module of loader java.net.URLClassLoader @504bae78; ch.qos.logback.classic.LoggerContext is in unnamed module of loader 'cosmicsky-1.0-SNAPSHOT.jar' @3ae0ea7b)
at me.kill05.cosmicsky.mongo.MongoManager.<clinit>(MongoManager.java:40) ~[cosmicsky-1.0-SNAPSHOT.jar:?]
... 12 more
yes, but only on the paper servers
i have also tried to put it in a clean project and it worked just fine, the only difference with maven imports is the spigot one
do i need to put some exclusions in the spigot dependency or something? im very confused
ok, guess what the error might be
although I don't know how to fix it, I think it's because of protocollib
i hate regex and intelliJ string highlighting
but i will admit it's useful
on a different topic
when i open a nbt file in intelliJ it gets parsed into something closely resembling json
size: [
5,
1,
7,
]
entities: []
blocks: [...```
does anyone know if i can automatically parse that? Or do i need to open the file and do strg+a, strg+c, strg+v
what is v v1 v2 v3?
doesnt the javadoc say?
X, Y, Z, Amount.
oh so its the amount of particles?
If you need more than that, there is a method that has particle offsets.
x y and z should be the particle spread compared to the location
Moving as in using the same particle instead of spawning new ones?
depends on how you want the particle to move
hi,
Is the mcmmo plugin still supported for Minecraft Server 1.12.2?
spinning around the player
IIRC, there is only one particle that has the ability to move from one location to another. It being the Vibration particle.
Otherwise you would have to spawn each particle individually.
what do i use to build the plugin to a jar
you can also direct certain particles in a particular direction but you can only do that for one particle at a time
yea ill try to do this
ill have to know the maths tho
package
There are some resources on the forums about particle math. Finnbon is the author of the posts.
i just get Fatal error compiling when compiling parent
Use package
well what is the error?
when i compile just the plugin name one i get [ERROR] Failed to execute goal on project ServerNPC: Could not resolve dependencies for project com.isnakebuzz:ServerNPC:pom:1.14.0-DEV: The following artifacts could not be resolved: com.isnakebuzz:ServerNPC-Main:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_8:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_16:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_17:jar:1.14.0-DEV: com.isnakebuzz:ServerNPC-Main:jar:1.14.0-DEV was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
with no plug or with plug still there is a bug. : / after ignoring the minecraft version in the lib configuration protocol the function is unchanged. generating from a new plug-in does not do anything either
Hello, i am trying to make a gun system in Minecraft and at the moment i iterate throught all the online players to check for the hit player.
This is kinda heavy and i was wondering if there is a better way to do it, here's the code:
Location playerLocation = player.getLocation();
Vector direction = player.getEyeLocation().getDirection();
for (int i = 0; i < range; ++i) {
// Display particles
for (Player p : Bukkit.getOnlinePlayer()) {
double d = playerLocation.distanceSquared(p.getLocation().add(0, p.getEyeHeight() / 2.0d, 0));
if (d <= 0.85d) {
// Damage player
}
}
}```
Try invalidating your caches and refresh your maven poms.
There should be a button for it in IntelliJ
yea in file menu
bump
tells you its not possible to do (LoggerContext) on a LoggerFactory
maybe there's a method doing what you need
There should be a method called getNearbyEntities you can use instead. You would just need an extra check to see if the entity is a player.
where'd you get that info?
if you read what i wrote, trying it in a plain java project works fine
Vector collision detection question
getnearbyentities iterates through all the entities too iirc
still happens
i have problem with plugin mcmmo who can help?
i use MC Server v1.12.2 Magma with plugin mcmmo v1.5.10
have log ERROR Spam. if i use Extra Utilities 2 Quantum Quarry
u can error reproduce
a stackoverflow page
i do get this tho
Oh, I didn’t realize you have a multi module setup. There should be a button for turning on offline mode for maven. Toggle that and then try clean package
can who help, pls?
i'm pretty sure you are not running a spigot server if you have extra utilities 2
i have no clue why it wouldnt work
also
anyone a better idea on how to do this?
String[] split1 = structString.split("size:|entities:\\[\\]blocks:|palette:|Data");
String[] dimensions = split1[0].split("\\[|,|\\]");
String[] position_objects = split1[1].split("\\[\\{|\\},\\{|\\},\\]");
String[] palette = split1[2].split("\\[\\{Name:\"minecraft:|\"\\},\\{|\"\\},\\]");```
Alternatively, you could always run the command directly. mvn -o clean package
@misty current
The mod, however, supports via Magma Server.
Don't use fucking regex as a parser lol
Regex is not capable of parsing recursive data
no luck when going offline
[ERROR] Failed to execute goal on project ServerNPC: Could not resolve dependencies for project com.isnakebuzz:ServerNPC:pom:1.14.0-DEV: The following artifacts could not be resolved: com.isnakebuzz:ServerNPC-Main:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_8:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_16:jar:1.14.0-DEV, com.isnakebuzz:ServerNPC-v1_17:jar:1.14.0-DEV: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact com.isnakebuzz:ServerNPC-Main:jar:1.14.0-DEV has not been downloaded from it before. -> [Help 1]
Do you want an nbt parser
I will literally make you an nbt parser if it means you don't use regex
It'll be easy too
i need a structure.nbt -> Material[][][]
bump
Easier than regex
essentially
Wait
I have a library for something very similar to this
Why don't you just use my MultiBlockStructure library
can i find it online?
imma take a look at that thanks
hmm
You may want to compile each module so that it gets installed to your local repo. Then in your parent module, run clean package.
I gotta get back to work, but it looks like your modules aren’t being found in your local repo. I’d look into that.
@waxen plinth assuming im reading this right, I can scan in a structure, and scan for that structure at a location. How does your library handle Air, VoidAir, deepAir and StructureVoid ?
You can have it ignore air
And you can have it ignore specific materials as well
So you could have it ignore structure void
You can easily change how it builds anyways
wdym?
You can call forEachBlock on it and just skip building blocks of certain types
It's super easy
mbs.forEachBlock(location, b -> {
if (b.getType() == Material.STRUCTURE_VOID) return;
b.update(false);
});```
ez
I'm going to assume you have javadoc in the code, then?
Yes it's all documented
One moment
declaration: package: redempt.redlib.multiblock, class: MultiBlockStructure
I think I'll just throw it into my project. Strg+Q is a thing in intelliJ, luckily...
To credit that library, how exactly would i go about it?
It's under MIT so technically no credit is required but putting "thanks/credit to redempt" anywhere is always appreciated
ah well i was planning on doing that anyways
last question
how can i compile my plugin so that the library does not get baked into it, and makes so that it still works when your library is also loaded as a plugin on the server?
I'd like to keep unnecessary inflatation out of my projects
maven
Feel free to DM me if you have more questions on how to use it
sure thanks
1.18.2-R0.1 or something like that
not that one
it's just changing the 1.18.1 (or 1.18, idk) part to 1.18.2, anything else can be kept as-is and without warranty, whether express or implied
server version string
the one where the version for 1.16.5 is 1_16_R3
you may know it as nms version
(MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 1d7a6a0) this thing?
or do you mean the craftbukkit package ver? But in this case your IDE auto-completes it
Really, it's just 1.18/1.18.1->1.18.2, there is no second revision or anything like that for the imminent future
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Refer to "NMS version"
Hey, guys! Got a question, sorry if it's stupid.
I'm developing a library I'll use later in a plugin and need to log, to the plugin's logger. I wan't to avoid adding the Spigot API as a dependency of this library, as I want it to be "General purpose", so passing the plugin or it's logger is out of the table.
You know how could I have logs from a external library logged into my plugins Logger? I'm trying with slf4j, but I can't wrap my head around it.
What the fuck is nms version
[mcMMO] Platform String: 1.18.2-R0.1-SNAPSHOT this thing?
Click into the link I sent
and search in page "NMS version"
you probably won't know what it is
It is the package prefix for cb classes, but that one should be auto-completed by any IDE
so you are not searching for that one
So I am a bit confussled
there must be a reason why I am asking here, I am building 1.18.2 jar as we speak
How do I make an alias in my plugin (I use ACF) that runs another plugin's command, including arguments.
but its ok, I got this
org/bukkit/craftbukkit/v1_18_R2/
can't you make that alias just call that other plugin's command? iirc plugin commands onCommand functions are forced to be public
But how do i get subcommands to work?
🤷♂️
as passing in too many arguments would give an error wouldn't it
(context, i gave up with MyCommand so i'm just doing it custom)
well depends on the plugin
& command
some commands just ignore args[]
others discard any extra args if there's too many
it is possible through spigot when a player has the inventory open to see which slot the mouse cursor is in or if it is over a certain item
no
that's not sent to the server
what you can get is the slot it is over on Inventoryclickevent
It's quickShop's base command
i haven't really worked with subcommands yet
chat never was of great interest to me in the first place
Hello, where should I put my program(not a plugin)'s configuration file?
Same if the player hás cursor item?
i actually dont know that one
it might be worth looking into the spigot docs on the inventory
is it possible to make a runnable run for x ticks, then a 2 seconds delay?
run for 20*5 ticks, have a 2 second delay, repeat
include a counter
reset after 20*5 ticks + 2 secs, only run when equal or less to twenty
ok
how
make a runnable class with a int counter = 0 variable
then have it count up every time run() is called
only execute if less or equal twenty
and if it goes over twenty plus i believe four
reset
(to 0)
int counter = 0;
for(counter=0; counter=20; counter++){
do thing?
}
kinda
No for loop
the thing you have to keep in mind here is
well yes that too
but the counter needs to be declared outside the run() function
hence you need to make a class extending BukkitRunnable
class Example extends BukkitRunnable{
int counter = 0;
@Override
public void run(){
if(counter<21){
doSomething();
}
counter ++;
if(counter>24){
counter = 0;
}
}
}
im trying to do this, spawning particles in a circle around player
it runs for 5 seconds (the time it takes to make the full circle), 2 seconds delay
ok
why dont you adjust particle lifetime then
so that once the first particle despawns a new one is spawned there
how do you spawn them exactly?
spawnParticle
for (int degree = 0; degree < 360; degree=+10){
double radians = Math.toRadians(degree);
double x = Math.cos(radians);
double z = Math.sin(radians);
location.add(x, 0, z);
location.getWorld().spawnParticle(
Particle.END_ROD,
location, 1, 0, 0, 0);
location.subtract(x, 0, z);
}
Location location = p.getPlayer().getLocation();
hey, i am trying to disable mongo logging by using
((LoggerContext) LoggerFactory.getILoggerFactory()).getLogger("org.mongodb.driver").setLevel(Level.WARN);
But i'm getting a classcastexception:
Caused by: java.lang.ClassCastException: class org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.apache.logging.slf4j.Log4jLoggerFactory is in unnamed module of loader java.net.URLClassLoader @504bae78; ch.qos.logback.classic.LoggerContext is in unnamed module of loader 'cosmicsky-1.0-SNAPSHOT.jar' @3ae0ea7b)
at me.kill05.cosmicsky.mongo.MongoManager.<clinit>(MongoManager.java:40) ~[cosmicsky-1.0-SNAPSHOT.jar:?]
... 12 more
executing the exact same code in a normal java project works fine
it's annoying that the javadoc does not specify what the other numbers are used for
yea
i have put a main method inside a class and ran that code with all the same imports in the same projects and no errors
it just says v 1,2,3,4,5,6 t etc
java.lang.OutOfMemoryError: Java heap space
i did something wrong lol
also nevermind, particle lifetime is handled client side
sad
just use my method, it'll probably work
that is because minecraft sets it's own logger (log4j)
this one?
idk why BukkitRunnable and not Runnable tho
tldr bukkitRunnable works much better than runnable
probably the code was different
i dont even know if runnable would work
Try not to use logger-specific code
what do you mean?
Well, if the implementation changes the used logger your code will break if you specifically cast it to log4j's logger factory or logback's logger factory. The best would be to only use slf4j especially because mojang appears to be paving the road to employ their own logger framework
i haven't found a way of disabling mongo logging in any other way
which is kinda sad
i guess i could use nms code to get the logger factory somehow unless spigot already has the option to
and why 24?
as far as i understood you it is supposed once every five ticks for twenty times then pause for two seconds
also oops
it should be 28
20 ticks * 5
5 seconds
no
once per tick for five seconds?
k then the numbers are
less than 101 (For five seconds)
and above 140 (for seven seconds)
at which point it resets
What prevents you from running https://www.slf4j.org/api/org/slf4j/ILoggerFactory.html#getLogger-java.lang.String- without the cast?
do you happen to know whats the implementation and how can i get it
int counter = 0;
@Override
public void run(){
if(counter<101){
doSomething();
}
counter ++;
if(counter>140){
counter = 0;
}
}
?
you mean something like
Logger logger = Logger.getLogger("org.mongodb.driver");
logger.setLevel(Level.SEVERE);
No
it doesnt matter too much if you have a single duplicate imo
That resolves the java.util.logging logger
I mean LoggerFactory.getILoggerFactory().getLogger("org.mongodb.driver").setLevel(Level.WARN);
Then how the hell does your code compile in the first place ...
it was compiling with the cast
it was able to find the method
i guess LoggerContext provides an implementation of the Logger class when you call getLogger instead of a Logger
i could try casting the Logger that getLogger returns but not sure what to cast to
i want the chunk first position and second position
lmao logger stupid, it uses the color codes of the end of the previous message
there's a bunch of them
is
final int minX = chunk.getX() << 4;
final int minZ = chunk.getZ() << 4;
final int minY = world.getMaxHeight() - world.getMinHeight();
final int maxX = minX | 15;
final int maxY = world.getMaxHeight();
final int maxZ = minZ | 15;
fine for getting the first, second positions of the chunk
int counter = 0;
@Override
public void run(){
if(counter<101){
for (int degree = 0; degree < 360; degree++ ) {
double radians = Math.toRadians(degree);
double x = Math.cos(radians);
double z = Math.sin(radians);
location.add(x, 0, z);
location.getWorld().spawnParticle(Particle.END_ROD, location, 1);
location.subtract(x, 0, z);
}
}
counter ++;
if(counter>140){
counter = 0;
}
}
um
that spawns three thousand six hundred particles every tick
is that supposed to happen?
don't attempt it, it will lead to the same issue
*360
no, i put the wrong numbers
yeah thats what i expect
yikes
still
how do you do that?
I'm trying to find some native SLF4J way of setting the log level, but apparently we live in a world where everything is dictated by config files
edited, check it
you spawn three hundred sixty particles every tick, for five seconds
ctrl alt b
oh
what is the two second delay for then?
is there any way to convert container slot to raw view slot back
then what i do
well that code would run but im not too sure what you need the delay for
still needs help kekw
its going to be configurable if have delay or nah
for case server owners see people dont like particles spawning everytime
Logger logger = LoggerFactory.getILoggerFactory().getLogger("org.mongodb.driver");
if (logger instanceof org.apache.log4j.Category cat) {
cat.setLevel(org.apache.log4j.Level.OFF);
}
something like that I guess, and then continue with every other logger framework
wouldn't you need to make the delay configurable too, then?
so just a trial and error
if(args[0].length() > 0) {
Player p = Bukkit.getPlayer(args[0]);
assert p != null;
if (p.hasPlayedBefore()) {
} else {
sender.sendMessage("This player has never played before.");
}
}```
its telling me that its null (yes ive tried without the assert too)
its not running
can you get with reflections all implementing classes of an interface somehow
i could brute force it
i dont need
anyone know whats going on
Nyes, just a chain of if-else should suffice
well you need to instantiate the class and call .runScheduledTask(0,1) on it
Brute-forcing doesn't help either given that every logger framework is going to implement it different
are you doing that?
so what do i put? all the implementations of ILoggerFactory in instanceof checks?
I'd do the instanceofs at the Logger layer
i'm pretty sure the if (args[0].length() > 0) will throw a npe if the length of the args is 0
the args length isnt 0 tho
also dont assert
no
it will throw an arrayoutofbounds
:)
im defining a player in the command
idk all the same lmao
You may need to try-catch all the if statements in case some class is missing at runtime (some hosts are known to cut down on available classes at runtime), but ¯_(ツ)_/¯
i found someone catching npe and index out of bounds on his commands
dont think you can get worser than that
i mean, it was running before the counter thing
not working 😔
?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.
catching REs:
what are that
seems like it's an instance of Log4jLogger
Which in turn is an child class of Category
whats the import for it? i doubt any of these are the right one
oh probably not
Bukkit#getOnlinePlayers()
but idk how to do that
nono, i mean with bungee
(why are there so many slf4j<->log4j bridges?)
i have no idea, i barely know what log4j is
plugin messaging channels
yep, how can I do that
do any one know how to remove npc from tablist using packet?
copied my other lib (https://github.com/2Hex/EntitySerializer)
but made it for chunks
LOL
Apparently log4j 2 API has no way of disabling a logger outside config files
Which honestly is just stupid AF but what can you do I guess
Pls help
I stuck at this step for 2 days
hold on Log4jLogger has a field which has some implementation to set the logging level
imma try to get it with reflection
that's sketch af but what u gonna do about it
Hm, that may be actually better. It is hacky but far better than what I would otherwise propose (Invoking LogManager.getLogger("logger name") and casting that to SimpleLogger to have .setLevel available)
it didn't throw any exception but it didn't do anything either
doesnt log4j depend on config files for some reason
try {
Log4jLogger jLogger = (Log4jLogger) LoggerFactory.getILoggerFactory().getLogger("org.mongodb.driver");
Logger logger = (Logger) FieldUtils.readDeclaredField(jLogger, "logger", true);
logger.setLevel(Level.WARN);
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Done.");
} catch (IllegalAccessException e) {
e.printStackTrace();
}
Logger is org.apache.logging.log4j.core.Logger;
setLevel(Level) - Method in class org.apache.logging.log4j.simple.SimpleLogger
setLevel(Level) - Method in class org.apache.logging.log4j.status.StatusConsoleListener
setLevel(Level) - Method in class org.apache.logging.log4j.status.StatusLogger
You could try either of these three methods
Actually you need to try all three
this is the field i am trying to get
how can the Log4jLogger have all 3 inside it tho
unless im missing something
guys can someone help me? I have a plugin but to upload it to spigot I need it to weigh 4mb, I already managed to compress it to compile it but the problem is that I use an external jar (and when compressing it only compresses the pom stuff and not external) that is not in maven-central a guy was helping me to be able to put that external-jar in the pom.yml but it is not possible, I have used mvn commands with that and still nothing.😢
You can obtain that instance via LogManager.getLogger("org.mongodb.driver") already
ah
where as logmanager is org/apache/logging/log4j/LogManager
three different implementations of log4j's logger
did you publish to maven local and include it as a repository
this is getting stupidly complicated just to disable mongo from flooding my console
Just fork mongo at that point
lol
it completely makes no sense that mongo devs have not added a way to set the logging level in all the years it has been out
since its one of the most annoying things of it
Also, if you want to change the mongo log level for only your own server, you can already do that via the log4j2.xml or something like that
Never tried it, but I know that setting your own logger settings is certainly possible
if i wanted to go the reflection way i was trying before what am I supposed to get
im a bit lost
no idea either
anyone know why when i do this i can give the other player hearts when i dont have enough hearts for the inputted integer
whats the point of send
it gets the bukkit name of sender
aka im lazy and dont feel like putting in a long method
u made it longer tbh
and ur not following java conventions
and ur static abusing as well
aight, thanks for all the help
i'll try a bit myself i guess
im just trying to figure out how to do all of this
in what way?
a field name starting with a capital letter
this code is never going to meet public eye once im done
You mean this right?
mvn install:install-file -Dfile="KOTHAPI.jar" -DgroupId="KOTH-API" -DartifactId="com.benzimmer123" -Dversion="2.4" -Dpackaging="jar"
its being thrown out and replaced with better code
Also, your first Integer.parseInteger is pointless
an inner class that implements a map?
How can i get a vector for moving an entity towards another entity?
maybe
Doesn't need to be a map
final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS);
final Runnable runnable = new Runnable() {
int countdownStarter = 10;
public void run() {
System.out.println(countdownStarter);
countdownStarter--;
if (countdownStarter < 0) {
System.out.println("Kaboom");
scheduler.shutdown();
}
}
};```
how can I make it so when i do
scheduler.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS);
I can parse a player so in the void run i can do sum like player.sendMessage?
Could just be a map-like singleton with static mutators
bump @Moterius#2597
public static HashMap<UUID, Integer> Hearts = new HashMap<>(); this is your answer
you know bad code when you see it
e.g when i see my code
i know its bad
I do stuff like that quite often
Lol
Yeah. No.
Good thing hes storing uuids though lol
its not a singleton maplike thing or whatnot, its a map. a singular map. thats all it is
now i just need an answer to my question not to have every single thing but what im looking for nitpicked
And it violates a bunch of clean code principles. Make it private final non-static and write proper mutators
please
yeah cause im not that dumb
Honestly, I'd use Map<UUID, AtomicInteger>
Makes incrementing/decrementing much easier
direction from one vector to another is
target.subtract(base)
if i made it a private nonstatic map then i couldnt access it in other classess
lock overhead. Just use a MutableInt from apache
so i should have target.getLocation().getDirection().subtract(base.getLocation().getDirection());?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
which means id have to refactor all these classes by a lot
Yeah that’s pretty much the point
atomic integer does not lock... that is the whole point of the atomic series of objects
To be able to control the dependencies of yours
Which singletons aren’t very great at
?scheduling I recommend using the scheduling api. Anyways you will need a player instance. You can either loop all online players or have a map with UUIDs that you get the player instance with
I would suggest learning java
Not that you should not loop over Bukkit#getOnlinePlayers outside the main thread
Well it's in an event
like player hurt event
what is runScheduledTask
isnt even a singletone
there isnt a static getter
i cant find it in org.bukkit
?scheduling
only a public static field
are you just going to nitpick every last thing of my code except the thing im actually looking for
No
True, tho some of their methods have the CAS locking impl, and volatile is a bit more expensive isn’t it.
To go back to your original question. You need to have if (map.get(sender.getUID()) > finalValue * 2)
And? If you want to prevent duplicates keep a map of them
I’d call it a singleton, not a proper one as it doesn’t follow the pattern the slightest
However at this point you could simply just leave it at a multiplier of 1
But just to make stuff a bit simpler
forgot the math
I would call it static abuse, not a singleton
Idk
calling it a singleton makes singletons look bad
That is a singleton if you pull it off right
Having a static map isn’t probably the greatest idea
Sure but still. volatile inner field and compare + swap
but it isnt pulled off right
But well, if you’re aren’t doing something scalable, then it probably doesn’t matter
so it isnt a singleton
We do not know the impl
okay, perhaps...
Oh btw conclure
What about a public static final volatile transient native map?
can't i like some how pass it in?
Anyways, iirc smile, atomic framework classes allow you to with VarHandle read variables as normal non volatile ones if needed
scheduler.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS, player?);
Also maps have a bunch of methods like compute and computeIfPresent that are a good alternative to mutables
Which eliminates most of overhead you might encounter
oh my java complicated brainspaghetti of methods
i cant find it here
checking my github:
https://github.com/2Hex/ (i privated a lot of shitty repos btw)
do u think my code would be accepted as a premium plugin?
Im not making one, just had a thought
oops ping
?scheduling Please use the scheduling api. And yes you could pass it in but that will not prevent duplicates, keep that in mind
2Hex send me the repo you’re most proud of
the 4 repos prob include my profile config
Ok thanks
Im not proud of any since i know my place but okay a second
Im open for criticism btw
even the smallest mistakes, I want to learn
No, be open for feedback, not criticism
same thing kekw
This will only work for 1.17.1+
1.12 compat please
lol
This library sux
1.17.1- would require nms kek
Idiot
Criticism can be anything, whilst feedback usually is more constructive and criticism in a kind way 2Hex afaik but yeah let me check now
this is the only way that wouldnt require nms, and its required to use 1.17.1+ for it
You can use my lib and you do not have to use nms
Oh
lemme see
can u link it
So what’s the point of the first class
It's called imagination
which one
would be better
Where the initialization logic also takes place
This would allow you to completely refactor away your private init method you for some reason have
Then again, the api package doesn’t really contain an api
You probably can get rid of cases such as https://github.com/2Hex/EntitySerializer/blob/main/src/main/java/me/hex/entityserializer/EntitySerializer.java#L51 by making the class a singleton and hiding the methods in an interface that is not exposed to the public
Or well, not an api which is particularly abstracted
o
how would i achieve better abstraction?
Yeah, lovely methods, would be dead if those didn’t exist
I don't use them for some reason
Let the consumer only talk to interfaces and enum state representations
Hide actual implementation
Easiest example I can find as of now is probably vault api, or just spigot api itself lol
Ok well can i just parse it in?
if i get any spam in console
ill just add some try catches
Oh, well for normal maps they’re not particularly different, tho I believe Java is cool enough as they made sure to make those atomically safe
For impls like the skip list map and concurrent hm iirc
it was a singleton before
but
what if multiple people use it at the same time
I’d argue for that keeping it non static is more scalable, but really depends on how you’re gonna scope the library
just have it be locked behind an AtomicObject
shouldnt i just move it
Oh actually
to some other place
Yeah I see what you mean
Can some one help with this pls? <3
Then you should employ a factory pattern
Especially given that #setPlugin is mandatory
uhhh can u give an example of like, what to do and what not to do
And if you make use of sealed classes you will still avoid the risk of internal API exposure
o
Hmm, 2Hex, hide concrete classes behind interfaces
And let consumers only ever be disclosed to the interfaces of yours
As Olivo told you million of times use the Bukkit scheduler, anyhow you’d have to keep track of iterations
Is it possible to find the amount of damage just done by a player?
And also
Don’t shutdown the executor like that
instead if you wanna cancel the task, use ScheduledFuture::cancel or sth
im done with figuring out the 95745 log4j classes implementing an extending eachother, how do you do it with config files or whatever
anyone know why this error occurs?
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.clonkc.vlands.kitpvp.vlandsinterfaces.CustomItems
wdym?
Did you import the class?
https://wiki.vg/Debugging probably
ah oki welp i wanted to see if there was an easier way
\
thats the class
and in my command class i imported
import com.clonkc.vlands.kitpvp.testinterfaces.CustomItems;
and you do have the library/dependency?
like how did u import the class?
.
no...
Something like
public abstract class BuilderFactory {
private static BuilderFactory field;
public static BuilderFactory get() {return field;}
public static void set(BuilderFactory factory) {
if (field != null) throw new InternalError();
field = factory;
}
public abstract Builder getBuilder(JavaPlugin plugin);
}
public abstract class Builder {
public abstract EntitySerializer build();
}
Where as you set the instance of the builder factory somewhere in your API implementation
tbh i dont get it
ooo
full stacktrace please
one sec
NoClassDefFoundError is ALWAYS caused by another error
wha
yed
And no stackraces before this one?
@sacred mountain let’s see the code for the command
should i create a thread for that
Nah
(also, the stacktrace will be at startup)
I'd rather like to see the code for CustomItems
They sent that before
idk why its an interface
@quiet ice
the error is in that class
I want to see the command anyway
Either
A) The class is not compiled
B) You are unable to find the stackraces
C) Java classloading moment
the command code?
Yes
welp
Since I am very sure that it is B, send me the whole log
plugin is null
You are loading the class before your plugin loaded
@quiet ice take a look at the command classes in the thread and you’ll see why I wanted to see them
sneakythrows?
A reflection snake
lombok
I know all too well what it does
ok
It could be that sneakythrows it supressing the NPE
but eh, I always avoided any form of sneaky throws so I do not know for sure if that is the culprit
There’s so much reflection everywhere it’s hard to see what’s going on
What is the reflection even used for?
A lot
@sacred mountain do me a favor, make CustomItems a class and make each of those variables public static
Just for now
And see what happens
The issue that they encounter is caused by an NPE in the CustomItems interface
Then my request won’t fix it
Which is good
More information is always better than less
There’s no multithreading
The clinit of two classes could be referring to each other
nvm
That seems unlikely
It would throw a gigantic stack overflow exception, but given that we do not have the exception at hand it is the most probably for me
And all it requires is either the clinit of Main, Main#getConfigUtils, Main#getTfbConfig, Main#getTtntConfig or Main#getGhConfig requiring CustomItems
Actually, wouldn't that result in a null value?
where can i find runScheduledTask()?
Bukkit#getScheduler
nope
is it acceptable to have 2 listeners for the same event in a plugin?
Yes
probably what you are searching for
^
@Moterius#2597 troll me 😠
ItemStack item = new ItemStack(this.type);
final ItemMeta meta = item.getItemMeta();
meta.setDisplayName(this.name);
meta.setLore(this.lore);
meta.setUnbreakable(true);
item.setItemMeta(meta);
item = Nbt.setNBT(item, "gun", parent());
if (!Nbt.hasNBT(item, "gun")) {
plugin.sendMessage("tem");
}
item = Nbt.setNBT(item, "ammo", "8");
if (!Nbt.hasNBT(item, "gun")) {
plugin.sendMessage("tem");
}
return new GunItem(item);```
why when i add a new nbt to an item the nbt i had put removes ?
https://paste.md-5.net/ukozupebak.cs Nbt class
bruh
how would I disable chat for specific person so they don't receive messages
Hello, how can I make it so that when a player has 10 stones, for example, they are deleted?
AsyncPlayerChatEvent
well there I can disable sending message
I mean I can cancle event
getRecipients()
something like this
if(p.getInventory().contains(new ItemStack(Material.Stone), 10)){
code to remove
}
public void addArcherTagAndRemoveLater(Player p){
if(archerTagged.put(p, new BukkitRunnable() {@Override public void run() {archerTagged.remove(p);}}.runTaskLater(plugin,ConfigManager.ARCHER_TAG_LENGTH).getTaskId()) != null) {
Bukkit.getScheduler().cancelTask(archerTagged.get(p));
}
}``` any better ideas for this
formatting
shit
thx
Looks like it’ll do the job
thanks
i wanna do computeifAbsent but dont know how it works. Would it even be useful there?
Map<UUID, BukkitTask> archerTagged = new HashMap<>();
public void addArchertagAndRemoveLater(Player p) {
BukkitTask newTask = Bukkit.getScheduler().runTaskLater(plugin, () -> {
archerTagged.remove(p.getUniqueId());
}, ConfigManager.ARCHER_TAG_LENGTH);
BukkitTask old = archerTagged.put(p.getUniqueId(), newTask);
if (old != null) {
old.cancel();
}
}
I'd use something like this
if i run the function twice on the same player before the tag_length will it ensure its not deleted until after the new cooldown?
what is 0
ight. also if im checking to see if a player is in the set is it cheaper to get the uuid and then check that or is it not really getting much more because the uuid is in the player alr
well the runScheduledTask takes the delay and the period of a task
as such doing (0,1) at the end means
this method doesnt exist
runTaskLater?
ight, changed it
Run task timer?
ok
But in this case I do not think that you need a repeating task
#help-development message should do it "good enough"
actually, you'd need to null check it
the armor is not doing what it should and the plugin didnt load the things
now it should work
I'm sending a title where the title is "" and the subtitle is the text i wanna show, however it aint showing up
why's that
thanks @quiet ice
using
Player#sendTitle(String, String, int, int, int);
Does someone know if there is packet for LeashHolder?
kinda worked
but ```java
runTaskTimer(this, 20L2, 20L5);
did 5 seconds delay
delay is run after 5 seconds
oh, nvm, it makes sense
every period
yes
that adds a 2 second delay on first startup
ye u can just do 0
now i need to know how to make it show 1 particle every 2 tick
making a "spinning" animation around the player
EntityDamageByEntityEvent.getDamager returns what if its an arrow?
or is it another event
or will it be both
i think it returns Entity.ARROW
@NotNull
public Entity getDamager()
/*Returns the entity that damaged the defender.
*Returns:
Entity that damaged the defender.*/
Ah ok ty
?
Check if the damager is an arrow, cast it to arrow, from there check if arrow shooter is an player or any other entity u want, cast again
it spawns the entire circle in 1 tick
use a scheduled task
and cancel it when its done
?scheduler
?scheduling
Read that also, there are self cancelling examples there ig, if u pass an parameter to ur consumer, use it to cancel the task by condition
i tried looking finnbon's math tutorial but its too confusing
cant i do
for (int degree = 0; degree < 360; degree++) {
double radians = Math.toRadians(degree);
double x = Math.cos(radians);
double z = Math.sin(radians);
location.add(x, 0, z);
Bukkit.getScheduler().runTaskLater(ObsidianExpansion.i(), ()->{
//particle
Bukkit.getScheduler().runTaskLater(AlchimiaVitae.i(), () -> {
//more particle
}long
}long
}
```?
guys can someone help me? I have a plugin but to upload it to spigot I need it to weigh 4mb, I already managed to compress it to compile it but the problem is that I use an external jar (and when compressing it only compresses the pom stuff and not external) that is not in maven-central a guy was helping me to be able to put that external-jar in the pom.yml but it is not possible, I have used mvn commands with that and still nothing.😢
I already published it to local maven and it still doesn't work
then i keep stacking Bukkit.getScheduler().runTaskLater() and spawning particles
so same thing but replace runTaskLater with runTaskTimer?
and change parameters
it worked but big circle
gtg
tomorrow i continue it
hey im still having a problem with my configs
stacktrace
Main plugin = Main.getPlugin(Main.class);
TFBConfig tfbConfig = plugin.getConfigUtils().getTfbConfig();
?paste please
if you are online tomorrow ill send it then. icant be on today any more
💀
sry
does anyone have a clue about how can I disable mongo logging? I have tried getting the Logger with the getLogger method, using the IloggerFactory but nothing worked since minecraft does something weird with the default logger
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
Logger rootLogger = loggerContext.getLogger("org.mongodb.driver");
rootLogger.setLevel(Level.INFO);
Works for me though you need ch.qos.logback
How I can get client source? to see how the player e.g. processes and sends packets
You build it via buildtools and import it into maven with spigot instead of spigot-api
no no I want get client side
no server side
Um for that you'll need to find someone who's decompiled the client source
?paste
or maybe there is already a solution on the internet?
Maybe but you'd have to find it
So i haven't found a way to convert inventory's slot index to raw slot one, so i've made one myself and i decided to share it if you guys need it
it converts your container slot to raw slot, that way you can convert slots back and fourth
not particularly useful, but in rare cases it is
green is inventory slot
yellow is raw slot
and orange is raw slot converted from inventory slot (green)
Sorry kind of a late reply but i have tried this method and it throws a classcast
1.18 spigot
Iirc it worked for me on a 1.8 server
No idea why it wouldnt now
I need a dev that can do work tonight dm me if you can


For free?
You're high af if its free
Nope
i don't think this channel is meant for that kind of stuff.
Oh
Spigot site has a subforum for this
I've been looking for ages how to get my armorstand from another method into my new method. I am making an FFA plugin and i'm working on a /kit remove beast command, which will remove the armor stand containing the custom name (ChatColor.RED + "Beast"). I've been looking for hours but I just can't find a way to get the armorStand of the spawnBeast method into my removeBeast method. Can someone help me out?
well you are probably gonna need to keep a reference somewhere.
public void spawnBeast(Player p) {
ArmorStand armorStand = (ArmorStand) p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
armorStand.setArms(true);
armorStand.setBasePlate(false);
armorStand.setCustomName(ChatColor.RED + "Beast");
armorStand.setCustomNameVisible(true);
ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
armorStand.getEquipment().setHelmet(helmet);
armorStand.getEquipment().setChestplate(chestplate);
armorStand.getEquipment().setLeggings(leggings);
armorStand.getEquipment().setBoots(boots);
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
armorStand.getEquipment().setItemInMainHand(sword);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSuccessfully spawned Beast armor stand!"));
}
public void removeBeast(Player p) {
}
this is the code i got
I have been trying to work with so much things, i think ive been looking for a solution for 4+ hours now, but i just can't find anything.
I feel like it's not even hard to do it
But i just can't manage to get it
all you need to do is keep a reference when you created it
I'm sorry, but can u maybe tell me how to do that?
I'm not a beginner in Java, i've followed multiple courses but there are just a few things that are still hard for me to understand
I've done a lot in this plugin already that works exactly as how i expected it to be, it's just this that i can't achieve.
well first off. tell me what exactly are you attempting to achieve
Okay so
when a player runs a command it should spawn a armorstand with some armor im guessing
I'm currently working on an FFA plugin, the spawning will be supported by armorstands. If i do /kit (kitname) it will spawn an armorstand with some armor and a custom name (in this case ChatColor.RED + "Beast"). Now I want a command to be able to remove these armorstands, f. ex. /kit remove beast. I am using the spawnBeast method to spawn the Beast armor stand but I just don't know how i'm supposed to get the Beast armorstand in my removeBeast method so I can get the armorstand removed (despawn it).
so in theory every player could have their own beast armorstand correct?
Yes
okay
It will just look like this: https://imgur.com/7VXqFLo . An ffa spawn where you will be able to select the kit that u want to spawn in with.
But if i misplace an armorstand or i want to move it to somewhere else i need a command to remove that armorstand
So i did /kit remove (kitname)
Oh oops i'm sorry yeah
U can spawn as many as u want tho
But i'll prob only need one
okay one second
alright
this is one way you could do it
public class ExampleClass {
private final List<ArmorStand> beastStands = new ArrayList<>();
public void spawnBeast(Player p) {
ArmorStand armorStand = (ArmorStand) p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
armorStand.setArms(true);
armorStand.setBasePlate(false);
armorStand.setCustomName(ChatColor.RED + "Beast");
armorStand.setCustomNameVisible(true);
ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
helmet.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
chestplate.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
leggings.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
armorStand.getEquipment().setHelmet(helmet);
armorStand.getEquipment().setChestplate(chestplate);
armorStand.getEquipment().setLeggings(leggings);
armorStand.getEquipment().setBoots(boots);
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
armorStand.getEquipment().setItemInMainHand(sword);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aSuccessfully spawned Beast armor stand!"));
beastStands.add(armorStand);
}
public void removeBeast(Player p) {
List<Entity> nearby = p.getNearbyEntities(2, 2, 2);
beastStands.removeIf((stand) ->
{
if (nearby.contains(stand))
{
stand.remove();
return true;
}
return false;
});
}
}
bassically removeBeast() will look in a radius around the player for any beast armorstands and remove them
Hmm, it looks like a good solution indeed.
Only thing is when i execute it it's not doing anything, but i'm not catching an error in the console either.
How do I fix this issue?
are you within 2 blocks of the armorstand?
Yeah
I'm just trying to figure out where you got 'stand' from
Shouldnt it be 'armorStand' ?
its just a variable name
Oh okay
if (args.length > 0) {
if (args[0].equalsIgnoreCase("remove")) {
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Please specify which kit armor stand you want to remove.");
return true;
}
if (args[1].equalsIgnoreCase("beast")) {
Player p = (Player) sender;
new Beast().removeBeast(p);
return true;
}
Maybe i did do something wrong in here
But i don't think so
It runs the removebeast method
i can send you the entire /kit command if u want
It contains /kit name and /kit remove name
yea so i know whats going wrong
you are creating a new Beast class and calling remove from there
what you need to do is keep a reference to your beast class
one second
Hmph?
tyt
https://paste.md-5.net/ameherepap.java check this out.
Ohhh, okay I understand my mistake now. I haven't really worked with references before tbf so I didn't really know that I had to use that.
Thanks a lot for your time, appreciate it
yea bassically you were creating a new reference every time. meaning the arraylist in there would be empty
while now. it will hold the same one. so you can access it
I see. Again, thanks a lot for your help!
no problem.
If I would reload my server the ArrayList would be empty again and I won't be able to remove it anymore right?
correct
so you will need to store the locations to the armorstands & remove them when the server stops then respawn them later
If you reload everything is basically like the server just turned on
Alright, will do that, thanks guys :)
why isnt my plugin enabling? i have the enable thing
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("loging on to servr");
}
do you have an error?
yes
show me
it says that string a null so cannot work
ye, show me the stracktrace
no thx
im worried you could hack my computer with it
do you know what a tracktrace is?
no
its bassically information so you can track in which line of your code went wrong