#help-development
1 messages Β· Page 1106 of 1
but, you say on join add the player to a hashmap and load their key count from file to that map, then on leave write it to yaml and save?
Yes something like that.
because saving the file each time a player clicks the crate would be bad?
whichever is faster. because sometimes 10 ppl will be opening crates at the same time
sometimes 20 ppl earn a key at the same time
I think it's mainly because of performance issues.
which is why im not doing auto save timer
It's better than to modify the file everytime the key count changes.
sounds fair
I mean even mojang itself uses saving every 5 minutes.
yea not good, i turned that to a longer time
waaait, saving the file each time a player leaves would be just as bad cuz i have join/leaves every few mins, sometimes multiple at a time lol
but ig i could store all of the joins into a map, and eventually when the server stops then save it to the yaml
I'm saying if you want to keep the HashMap size smaller, then you could do that.
Yes, imo that's better than modifying the file every time there is a change.
Hm. fair idea thanks
and so if say 300 players were in a hashmap, it wouldnt be bad? to write each of those uuid -> key values into the yaml
sorry for the extensive questions, just want to make sure before I complete it
if I'm having a player shoot snowballs and I want each snowball to shoot a bit to the left of where the player is looking, how would I do that?
is there a vector method?
vectors use x, y, and z so if I just add a vector it wont depend on where the player is looking
float yaw = player.getLocation().getYaw();
double D = 1.0;
double x = -D * Math.sin(yaw * Math.PI / 180);
double z = D * Math.cos(yaw * Math.PI / 180);
Projectile snowball = player.launchProjectile(Snowball.class, player.getLocation().add(x, 1.25, z).getDirection().normalize());
snowball.setShooter(player);
Vector dir = player.getLocation().getDirection().multiply(4);
Vector recoil = new Vector(-10, 0, 0);
dir.add(recoil);
snowball.setVelocity(dir);
this is my current code and it only works when the player is looking a specific direction
Good day, I am trying to figure out how to make a system in which I can store millions of blocks called "BuilderBlocks" which essentially are just blocks that require a certain permission to interact with. The current system I am using does the following:
Stores blocks in a json file (file gets too big)
Loads on server startup into a hashset (laggy)
Then, when I start adding or removing blocks, gets laggy as well.
Lastly, I have a task that runs every minute that saves all the blocks.
I also use FAWE API.
All the code will be sent below.
https://github.com/YesNoBruhbruh/BuilderDelight
profiler (tested with 2 million blocks)
https://spark.lucko.me/IfmrJgvI7S
It will be okay. I have a HashMap with over 300k at some point
I haven't looked at the profiler nor the code, but from your message, I can tell that this kind of approach won't be able to scale at all
storing anything in the range of the millions in a single file is generally a bad idea
using json for storage when it is pretty simple data is also kind of an overhead at this point, I'd consider a proper binary format
as for the file, you could split them up by chunks, so it'd be more easily index-able
Yeah, at first I thought I would start small and go up from there, but it didnt work out
What do you mean by that?
for millions? use a db
I mean, that isn't necessary per-se, but that's also a good option
SQlite would work right? Or would using mongoDB better for performance
no but its better than a custom binary format
JSON is a whole format which has a bunch of characteristics you don't really need for storing block locations, which is 3 ints and an UUID for the world
I see
I really wouldn't go with a binary format
reinventing the wheel
dbs are made for scaling
Also, in regards with the DB option, would just having it all in one table be a bad idea?
I mean, you could but why
Eh, custom binary formats are fine, it isn't reinventing the wheel but using only what is ultimately necessary, but given that people here don't work in an ecosystem that is used to this kind of thing and would probably not account for all the things that a custom binary format needs anyway so yeah, it is kinda over the top
What even is a custom binary format? Is it like the file extension .txt, .json, .yml stuff?
those are human-readable formats, aka text formats
a binary format would be one that is only made to be read and written by a machine, so it'd just be serialized binary data of some kind
say, zip is a binary format, jpg and mp4 too, as they are only ever read and written by machines (though these examples specifically are interpreted/read by a machine, only then to be displayed to the user)
Oh I see, so another example is that one world format .slime? But anyway, wouldn't making a custom binary format be too much work?
if you want to do it properly, maybe
Hmmmm, also apart from loading and saving the blocks, another issue I'm having is when actually adding and removing blocks using a hashset. Whenever it gets to 2m blocks or onwards, it starts failing on me, though I'm not sure if having multiple hashsets would solve the problem.
the general gist is, you define a header which needs to contain:
- a magic number - this is used for identifying the file since the extension isn't enough as you could always just change the name
- the size of the data
- any other metadata of the format, varies depending on the format itself
then just the data serialized into bytes, for primitive types this is easy since you can just use a ByteBuffer or a DataOutputStream
the adding and removing, size and contains operations of a hashset have a O(1) time complexity, so that shouldn't be the case
well, there might be a ton of hash collisions with that kind of data though so it can happen
Hmm, Ill try to stress test the current plugin again and send a profiler link
(O) (O) complexity
don't worry, I believe you lol but as said before, you aren't storing your data effectively
just putting everything on a collection isn't gonna do it for this amount of data
Oh, hmmm, then just getting rid of the set, and just going for the database the reliable solution?
Schematics?
I mean, sure, if you don't want to think about it, just let a database deal with the problem, they're built for that
Alright, I'll start coding the stuff up and ill be back here for an update. Thanks for all the help π
if I'm having a player shoot snowballs and I want each snowball to shoot a bit to the left of where the player is looking, how would I do that?
Is there a vector method? I basically want to add a vector relative to the direction of the player. Vectors use x, y, and z so if I just add a vector it wont depend on where the player is looking
float yaw = player.getLocation().getYaw();
double D = 1.0;
double x = -D * Math.sin(yaw * Math.PI / 180);
double z = D * Math.cos(yaw * Math.PI / 180);
Projectile snowball = player.launchProjectile(Snowball.class, player.getLocation().add(x, 1.25, z).getDirection().normalize());
snowball.setShooter(player);
Vector dir = player.getLocation().getDirection().multiply(4);
Vector recoil = new Vector(-10, 0, 0);
dir.add(recoil);
snowball.setVelocity(dir);
this is my current code and it only works when the player is looking a specific direction
Use the direction from the player's eye location.
Also, I used a library from somewhere that I believe is something that you're looking for.
private Vector rotateAroundY(Vector vector, double angle) {
double cos = Math.cos(angle);
double sin = Math.sin(angle);
double x = vector.getX() * cos - vector.getZ() * sin;
double z = vector.getX() * sin + vector.getZ() * cos;
return new Vector(x, vector.getY(), z);
}
So basically you can apply it like
Vector leftDirection = rotateAroundY(player.getEyeLocation().getDirection(), Math.toRadians(-10));
Snowball snowball = player.launchProjectile(Snowball.class);
snowball.setVelocity(leftDirection.multiply(2)); // Feel free to apply the speed multiplier
How add plugin in repository online. If this possible add in global maven repos
good evening, can someone help me? I'm doing the hcf modality with core azurite but I can't find the permissions for this plugin to configure the ranges.
Most people use sonatype
This is part of Vector and doesn't need to be remade
immutability is nice though
this possible create module in global project without parent connection?
i just have 2 parents....
2 dads?
nah omg
https://maven.apache.org/repository/guide-central-repository-upload.html
Or host your own repo or use some public thirdparty one
?paste
Hello, SUGAR_CANE is considered as Ageable
But always return:
Age = 0
AgeMaximum = 15
Someone know if there is a reason to get these info, or is it a bug ?
are you sure it always returns 0?
i making a shell script to quickly deploy SMPs for people but i have a problem here:
apt update && apt upgrade
apt install openjdk-21-jre-headless
i also added the freedom of choosing the version but idk if java 21 will be able to work with all versions. whats the case for java versions and minecraft versions? like what version will be able to work with what java version
A guide to help you get the java version you need
thanks
Np
so 1.17 wont work with java 17?
No I donβt think so
alright thanks!
Does anyone know how to turn the default overworld generation to void using the configuration files?
or if this is possible with plugins without manually removing every block after after it is generated
I set it to flat and I think I can use generator-settings: to remove the last few layers of the world but I have no idea what to put there. I tried the official void preset but it doesn't work
The easiest way is just to copy over the world from singleplayer
or this (needs manual editing) https://misode.github.io/worldgen/flat-world-preset/
This worked thank you π€
is there a way to stop my hand from swinging when i click on a note block?
outdated server
its 1.21
outdated build
alright
π
buddy got rejected over on paper bc hes using offline mode and now comes here π₯²
are you using offline mode per chance
if so https://offlinemo.de
they are
is it possible in bungeecord to get the server name of the player that's logging in in LoginEvent
normally you can do ProxiedPlayer.getServer().getInfo().getName() but LoginEvent.getConnection() is not ProxiedPlayer
no, that first happens in the connect event
yeah figured out after rummaging through all the variables available
but you can get his name with UUID using mojang api
yeah i mean if you ignore the original question, you can get an entirely different piece of information

doesnt connection have UUId
i mean you have the whole ProxiedPlayer object
but even still that's an entirely dfifferent thing from what they were asking lol
how on LoginEvent get their name or not
mb
are you able to set the size of text on a map? what does MapFont do?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/map/MapCanvas.html
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/map/MapFont.html
Oraxen is open source
Other than that I'm not sure how big the diff really is
hi everyone
how do you have that tag next to your name
guilds
next stupid discord feature
i like how i cant even see it lmao
i am cute, that's how
how do i get all classes of a package? (with a classloader)
I might js quit discord bro
discord is ass now
lets all get back to teamspeak
just go back to real letters
going back to smoke signals
also
going back to googoo gaagaa
mood
?irc should be removed
IRC Chatroom: https://www.spigotmc.org/pages/irc/
Java 11+ maven artifact:
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.1.0</version>
</dependency>
In their documentation
you might need an older version of hikari for java 8
why use j8 anyway
Hikari 4 should still be receiving security updates
Hey guys i'm curently making a plugin allowing to build a structure that only you can see and then letting you place it or cancel it. It basicly add your modification to a hashmap<Location, BlockData> and then intercept packets regarding the desired block. My issue is that when trying to place a block on a block (they both dont actually exist), it replace the block that was previously placed. How could I make it possible to place a ghost block on a ghost block

Well you are on the ancient version, you have to use ancient software
i wasn't sure at first since offline mode
name says "I'm cool" or whatever the swear word equivalent is
default pfp, brand new acc
1.8 and knows a lil about coding
Can you use still the net.minecraft libraries with spigot plugins for developing since 1.18.+? I can't implement anything from net.minecraft anymore since I have to build my library with BuildTools.
@ivory sleet
fuckin ell
dar
?ban @hardy jewel ban evasion
Done. That felt good.
who are they
i was already wondering when we're gonna see him back
what did bro do
aka ola
not sure ab the initial ban but this mf resells premium plugins on his website for like 4$
someone write down all the names this individual goes by lol
?nms
runs cracked servers n shi
lmaoo
black market?
from lisbon but operates in brazilian real
kinda yeah
and keeps joining here and asking stupid questions overall
i got this https://paste.md-5.net/igedagerun.js, but it throws java.nio.file.NoSuchFileException: D:\Other\Test%20Server\plugins\??.jar, even tho it does (i am sus of the %20 tho)
For example, yes
gongas
reeachyz
(i call him freeakyZ)
ola
zaugusto
soufoda
some others too
%20 would be space innit
he was zaugusto too
hi, iwas wondering what is the name of those menu things
doesnt surprise me tbh
but for paths i dont think it should be there
soufodazy
alr
lmaoo
hhow would i remove it?
scoreboard
also cracked network 
alr thnx!
how does he have so many alts and why doesnt he just realise he isnt wanted here
bro's back already
he just makes a new one
That was a command for the guide on how to access it
Oh hahaha I've misread it cus of the other messages. But do I have to use Maven/Gradle for it? There is no direct API what includes this?
I think it's called a scoreboard
Hey can someone tell me how to get the spigot api from the new buildtools gui? I can't figure it out, it keeps generating me the server jar
If I use this with Maven, will I still have to add an external API spigot jar?
Hello, can someone explain to me how exactly I can use NMS to code a sheep that, for example, rotates in a circle, can't find anything about it and would like to learn to code with NMS
Or does anyone have a nice site where you can see everything?
You don't need the build tools for API
Is the API available to download from somewhere?
?maven
I'm not using maven, i'm using eclipse
so go to the url it specifies as the repo
Does anyone know how to check if an evoker summoned a vex?
I'd guess it's some sort of listener event on evoker but that's all I can think of
are you able to set the size of text on a map? what does MapFont do?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/map/MapCanvas.html
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/map/MapFont.html
i need to scan an area for the contents of certain chests, how do i make sure that double chests aren't scanned twice?
probably easiest is to go by inventory
scan if that inventory has not already been scanned
.
While coding the plugin with Java, I added a right click action to Armorstand, but the Armorstand colored name
And right click doesn't recognize this name either
import com.gmail.nossr50.util.platform.Platform;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
public class LaserPointerCmd implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use this command");
}
Player player = (Player) sender;
ItemStack wand = new ItemStack(Material.STICK);
ItemMeta metaWand = wand.getItemMeta();
metaWand.setItemName(ChatColor.GREEN + "Magic Wand");
wand.setItemMeta(metaWand);
player.getInventory().addItem(wand);
return true;
}
}
```p1
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Particle;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.util.Vector;
public class pointerParticles implements Listener {
@EventHandler
public void onPlayerRightClick(PlayerInteractEvent event) {
switch (event.getAction()) {
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
break;
default:
return;
}
ItemStack item = event.getItem();
if (item == null) {
return;
}
if (!(item.getItemMeta() == null)) {
PersistentDataContainer dataContainer = item.getItemMeta().getPersistentDataContainer();
if (dataContainer.has(new NamespacedKey(CowCannon.getInstance2(),"metaWand"), PersistentDataType.STRING)) {
shootParticleBeam(event.getPlayer().getLocation(), event.getPlayer().getLocation().getDirection(), 15);
}
}
}
private void shootParticleBeam(Location startLocation, Vector direction, int length) {
direction.normalize();
length = 15;
for (int i = 0; i < length;i++ ) {
Location currentLocation = startLocation.clone().add(direction.clone().multiply(i));
startLocation.getWorld().spawnParticle(
Particle.DRAGON_BREATH,
currentLocation, 1, 0, 0, 0, 0
);
}
}
}
when i give myself the wand it doesnt shoot the particles
(ping me on response)
how do you grab the point a vector ends at from the location its origin is defined as?
a vector has no origin, but if you use a point you could use the vectors length to calculate an end point
oh so like
given location [x y z] + vector [a b c] = resulting point
yes
most vectors are unit vectors. so only a length of 1
1 unit = 1 block in game
hey, is there a way to prevent a world from doing a world save
I thought setting autosave to false when initializing it would do it
I have now imported the API with Maven, but I still doesnt have access to net.minecraft. etc. only to net.md_5.bungee etc.
?nms
Ye thats what I mean with imported with Maven. But how can I get access to net.minecraft then?
read that link
bump on my world autosave question
I wonder if it's bugged
it's causing problems
I don't want to overhead of world saves for some of these worlds
I did, but Im not smarter some how
if you can't understand that you should not be trying to use nms
Its not just NMS.. its complete net.minecraft what I cant use
What should I call a class that represents a duration and has the ability to be infinite?
counter
Okay thank you, Im stupid lol
Net.Minecraft.Server, N.M.S
Your two suggestions conflict with other framework classes, should I just ignore the conflict and use the names?
is there a reason you cannot use the existing classes
^
I want a method called isInfinite()
Hey guys i'm curently making a plugin allowing to build a structure that only you can see and then letting you place it or cancel it. It basicly add your modification to a hashmap<Location, BlockData> and then intercept packets regarding the desired block. My issue is that when trying to place a block on a block (they both dont actually exist), it replace the block that was previously placed. How could I make it possible to place a ghost block on a ghost block
question I should of asked with this one (sorry)
I wanna spawn a particle in terms of some arbitrary location instead of the player, so apart from Player, how do I spawn a particle in terms of a Location?
The name sounds like it implies the duration is always infinite
yeah, you use that when you want something inifnite
otherwise use duration
you can probably ask gpt for other names
How would that work from a consumer stand point
like this:
1:
- abc
- def
- ghi
2:
- jkl
- mno
- pqr```
but as long as those things arent in your packages why are you worried about the same name
google got like every class that exists in the world
I'm just going to use Timespan since in the jdk framework it is an annotation
already found out, nvm
hey guys, is there an event from when the player uses the wind burst enchantment?
Hey just wanted to say thanks for this! I got it working with gradle in eclipse and now my plugin is updated!
Not that it's wrong to use Eclipse because I've used it too, but personally I'd suggest using Intellij
IJ has it's flaws once you are familiar with eclipse
how would i get the ip of a player with bungeecord cuz all the things are deprecated
At this point just use the Deprecated lol
yeah thats kinda what i was thinking
but i just wanted to make sure there isnt another non deprecated method
Try hovering hover the deprecation
In intelij it shows the replacement
hey guys
Hey guys
how do i spawn a double chest?
i tried to change the type of the chest to left or right but couldnt manage to do it
?doublechest
I tough it had every commands π
Havent read it all but I saw that md_5 responded
Oh i was reading this forum rn haha
The Chest type doesnt have the method setType to Chest.Type
If it does, my ide is trolling me
Do not
use ProtocolLib
Use PacketEvents
wrong Chest import?
what happens when i set the inventoryholder to something else than null on Bukkit#createInventory()?
Not recommended
it'll work but keep in mind that any calls to getHolder have horrible performance when the check does fail
Because the vanilla impl copies the block state or whatever
okay, but what exactly happens? what does this even do?
In short it's more of an internals thing
Lets you track that "this inventory belongs to this block" so that when 2 players open the same chest they see the same inventory
Spigot exposing it makes no sense and it's only around because legacy stuff
if (this.hasKills(playerName))
return this.playerKills.get(playerName);
return(0);
}```
how do i use this function in another class?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
this doesnt really help me understand it
this is using 3 class files
im just trying to transfer a function to another
or make it accessible
whatv
yes for this you need to use dependency injection
im assuming you want to access your kill tracker in a command?
just do int kills = Main.getPlugin(Main.class).getKills(playerName); in any other class. Main = your main class name
im just making it so that when they run /kills command it shows their kills
thanks
How can I make a text display be on top of another? I want to make a text system that is under the player's name, but it doesn't work for me. I tried it like this. I want to posicionate them under the player name but the second one is buggued with the player skin
you probably need to set the height or smth
Of an item?
yeah
Hi whats the best way to get a value in main thread from async ?
Callsyncmethode? runtask? Using completable future ?
how do i trace where a method is called? (debugging purposes)
Like get future data? Use βthenβ methods and pass lambda. It will be called after future task is completed.
use a debugger
you can do that when working with spigot plugins?
you can attach a remote debugger yes
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
will it shutdown the server at breakpoints btw
i believe it does on paper
dam
if watchdog is enabled at least
thats not enabled by default right?
if you are on paper (?whereami π‘) you can disable it in your paper config
i am not sure about spigot
βthrow new Exception()β πΏ
i don't want to stop code execution
it works
it's boo'iful
how is this thing supposed to work
local
then just add those flags to your startup command
ok
and use the 1. guide
and it's supposed to magically work
yes
debug mode would prob be better
getDamage
Istg discord mobile is the worst
I agree
Plain Target: {@event-player}
Before Target: {{@event-player} @held-item}
public static String resolvePlaceholder(String placeholder, ParsedElement parsedElement, SyntaxParser syntaxParser) {
ParsedElement parsedPlaceholder = syntaxParser.parseElement(parsedElement.getEvent(), parsedElement.getSection(), placeholder);
System.out.println("Plain Target: " + parsedElement.getPlainTarget());```
```java
@Override
public ParsedElement parseElement(Event event, TurboSection section, String element) {
Pattern targetPattern = Pattern.compile(TARGET_REGEX);
Matcher targetMatcher = targetPattern.matcher(element);
String target = null;
if (targetMatcher.find()) {
target = targetMatcher.group(0);
System.out.println("Before Target: " + target);
element = targetMatcher.replaceFirst("");
}
String[] split = element.split(" ");
return new ParsedElement(
split[0],
event,
section,
target,
this,
ArrayUtils.fromIndex(split, 1)
);```
how in the world does this make sense, getPlainTarget() doesn't do anything, it just returns ``this.plainTarget``
why did it just strip out the rest of it
oh crap, i'm doing parsedElement not parsedPlaceholder
500 iq right there
not me
juts look at the jar
i'm trying to implement checksum validation but ig thats just pointless and most obfuscators are crap
do I really need to spend 500 bucks for a premium obfuscator
is it gonna be any different
Zelix KlassMaster
skull
if i'm spending 500 bucks for an obfuscator, it better be more secure than gta 5's obfuscation
is the max damage an item can have equal to the item material's max durability
(before it breaks)
Why
just don't obfuscate
^
scrambling the names and removing debug attrs with proguard is enough for minecraft plugins if you really want to
plus you're not trying to hide top secret code
the best you can do is Β©οΈ, since people can still copy paste your obfuscated plugin into their server
βBro I stole your codeβ
βItβs not my codeβ
People will decompile it no matter what you do
The only time you should obfuscate is if you have a commercial product. Then you are required to make (some) effort to protect your IP.
Just as Mojang/MS do. Its not really to protect the Minecraft code, it's to comply with legalities so they "can" sue poeple if they want.
How do you make certain things tick/update less often, for example making arrows tick once every 2 ticks?
You can't checksum match on spigot as spigot modifies premium plugin jars
whats the difference between me only throwing a runtime exception vs also adding throws to my method?
adding a runtimeexception or a subclass to the throws clause is redundant
it's always unchecked
hey does someone know how this plugin works?
https://www.spigotmc.org/resources/random-mob-scaler.117982/
i cant find and spigot documentation on mob scaling
I mean if Im async and I want to get players online list for exampne
wdym players online list? Bukkit.getOnlinePlayers()
Yes (its an example)
is there a library that is able to modify region files
It's much better
doesn't break for no reason unlike ProtocolLib
it's faster
it's cross-platform
it's much more intuitive and clear
there's absolutely no reason to use PL
Even if I am lazy?
precisely if you're lazy
Hey, if getConfig().options().parseComments() is true for default why aren't my comments saving when using this?
getConfig().options().copyDefaults(true);
saveConfig();```
It is saving the comments that are inside a line but not the comments that are alone (#Level needed to prestige is saving)
Take a look at the remapping plugin for gradle
It tells you what to add
1 sec let me find link
hey, i wanted to make it so if a value was not found in the config, it would automativally create it and save it. my first idea was to extend the FileConfiguration but im wondering, is that even possible and are there any better ways?
getOrDefault
what is that
you can provide a default value if the entry is not found
but it will not save it to the config file
Correct
handy lil thing
You'd have to test it to see if it adds it as a default
options().copyDefaults(true)
if value in your plugin config is not present in server config, its added
so you can make changes to your plugin config and have em updated on servers too
alright thanks
im wondering, using Player#breakBlock(Block) frequently(ish) seems to cause a lot of lag. Is there a method of breaking blocks naturally that doesn't cause as much lag
im confused by this regardless because with my current setup im using that method about as frequently as players break blocks themselves, yet that isn't lagging
having a bunch of players on the server break blocks in this way is using up like 15% of server tick
Try getting a spark report
The API does have some overhead but it shouldn't be that bad
unless your server is a potato
Or you're breaking a bunch of blocks in unloaded chunks
Causing a bunch of blocking chunk loads
does PlayerInventory#getItemInMainHand return a copy of the item, or the actual item instance
how do i break an item
Actual item instance as far as I'm aware.
alright
You can set the amount to 0
i want the animation
You can do Player#playEffect(EntityEffect) i think
some of the effects play the equipment break animation
how do i save minigame maps in 1.21, I heard about SlimeWorldManager, but it doesnt seem up to date
A zip file
Or a tar file if you're really crazy
just saving the world in its plain format?
i heard slimeworldmanager is the way to go
how?
Delete regions that have nothing in them
Or that were loaded on accident
can i do this automatically?
No clue
We always used void world at my work
So the maps didn't really take much space
ok
Il what case its better to call runtask() than callsyncmethod() ? (From async)
not much difference
if u dont need a result, runTask
Callsyncmethod its same that
Completablefuture f = new CompletableFuture():
Runtask(f.complete(value))
int myvalue = f.get();
?
future.get will block the thread until the thing runs
its aite if you're doing it async but even then you could just do a thenAccept
So its same that
Callsyncmethod its same that
Completablefuture f = new CompletableFuture():
Runtask(f.complete(value))
int myvalue = f.get();
Or f.thenaccept(myvalue -> ())
f.get will block, f.thenAccept will run the task later
properly name your variables pls
and read my guide
parse Bukkit.getVersion
what format is getVersion
Thenaccept will be executed in the thread where its completed ?
Correct
The callback concept (with functionnal interface) was replaced with completable future in java 8 or its again usefull on certain case ?
well, it's still a form of callback
but yes, there is no reason not to use CompletableFuture
coroutines
yo
guys
Is it possible to have a spigot server running and create a seperate server (in the same java process), just on a different port and redirect the players to that server?
talkin' about a custom server implementation here
yeah there's minestom, NanoLimbo, packetevents' graphene, or I could remake limbo api
a lot of possibilities
even minestom scratch
Yeah
but I mean here
whether it's a viable option to redirect the player
so the spigot server doesn't know
I know how to make the spigot server never see the player's connection
but not sure about how the redirecting would work
No idea
What you're doing should really just be handled by a proxy anyways so π€·ββοΈ
i would also need to save the packets the player sends and then resend them to the spigot server when I'd like to have the player join the spigot server
I'm the one making a proxy
just without Velocity, Bungee or Gate
on an already working spigot server
what the hell do you think a full proxy is?
a separate server process?
A regular proxy will run in a different process
It won't inject itself in to the targets
inject what into what?
a proxy server is an entirely separate process that could be running on an entirely different machine
god forbid the vm crashes on the server because then the proxy goes down as well
you could in theory have a proxy running on the same vm as a spigot server, but not more than one because spigot relies on global static state
but it's also gonna overload the GC eventually and you lose the ability to split servers across separate machines if needed
there is just no good reason to do it
They're doing a login auth plugin for offline mode servers
So the player count wouldn't be that different
but still it's a bad idea
Overly complex and intrusive for no reason
yeah you can't just make that s plugin lol
Dear,
I got a problem with my POM.XML, which is never finding the spugot dependencies.
Here the file:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yourname</groupId>
<artifactId>autoreplantplugin</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>AutoReplantPlugin</name>
<description>Un plugin qui replant les plantes automatiquement lorsqu'elles sont cassΓ©es.</description>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spigot.version>1.20.4-R0.1</spigot.version>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://repo.spigotmc.org/nexus/content/repositories/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
pretty sure 1.20.4 requires java 21, not 17
Your spigot.version is missing -SNAPSHOT
It's 17
1.20.5 changed that I believe
ah
yep
There's actually a lot of very good reasons for this
I've been developing my auth plugin for 2 years now
ew offline mode
it's not even an Auth plugin lol
I got the same error with the SNAPSHOT.
and I always come to the same conclusion: I need to separate the spigot server from the verifying user
it's an "everything for cracked people" plugin

You have the wrong spigot repository url ?
Did you use ChatGPT to generate your pom or smth
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
is the correct one
For the URL yeah, I tried with the SNAPSHOTS' but didn't work. Thank's.
i have this line of code to load my json objects
List<Area> loadedAreas = gson.fromJson(reader, new TypeToken<List<Area>>() {}.getType());
however if one element is null during deserialization Gson just freaks out and throws an NPE instead of skipping that element
how can i make it skip null objects?
well it can't skip null objects, at best it will put a null in the list
do you have a custom TypeAdapter for Area?
Hey. So I recently came across a little feature that the newer versions of spigot have that the older ones do not. When cancelling events, the server seems to cancel them, but the client packets like sound or potion effects don't and they get sent to the player.
For example: If you cancel the event for spawn eggs in 1.8 they will also cancel the sound. But it newer versions like 1.21, it will not cancel the sound and still send the packet. This isn't a huge deal as you can just cancel the packet using something like ProtocolLib which I ended up doing, however this happens with thinks like suspicious stew.
If you cancel the consumed food event and it has custom potion effects, it wont stop the packets being sent to the player that gives them the potion efffects. This creates a weird situation where they have the potion effect but cannot use milk to get rid of it or any commands as its on the client. (Yes, rejoining gets rid of it but thats not the point).
Im just wondering why this change was made.
if you can replicate that in current version you can open a JIRA ticket.
since many versions things like "playsound" maybe was moved and the event forget handle that changes.
Okay, thank you. I will.
not problem.. in another cases (i hope dont) the sound/particle its client side and mojang dont suppose to think you can cancel them but its strange that happen now... then its most probably that things and handled in another way where the event currently cant or can cancel things like sound/particle
Yeah I did think it was weird that recently it just stopped cancelling on the client.
Do you happen to know where I can submit this at?
?jira
whats the event for wind charge pushing a player?
the damage event maybe?
Before I make one, do you think this could be a paper issue? The spigot plugin isn't using any paper dependencies or the paper appi, however it is running on the paper 1.21.1 server and could that be causing these problems?
Can spigot manipulate oxygen underwater?
declaration: package: org.bukkit.event.entity, class: EntityAirChangeEvent
thx
for that you need first test that in spigot then if the same issue happen here you can report (try just one event report) if cannot replicate then its a downstream issue and you need report to paper
@coarse linden don't report to paper, let them figure it out kekW
Just tested it on a spigot server and it looks like it's not the server.
I am going to make a JIRA ticket now, thanks.
awww okay
god forbid paper staff read this chat
yeah the point was
let them find the bug
on their own
not from this chat
:Clueless:
If you are from paper staff, man I'm sorry
?
otherwise, I know there is paper staff in this dc
I dont see the issue in that
why does ItemStack#setType not automatically change the item?
(if the instance is not a clone)
Because we still need to send a packet back to the client saying the item has changed
?whereami
the whole point of submitting a bug report to spigot is to reproduce that bug on a spigot server π
If you guys would read it
I said i tested it on a spigot server aswell.....
same results...
report it for spigot
not for paper
specify the spigot version
not paper's
lmao
Its the spigot api
then at least put the spigot /version on the version lmao
I'm trying to set everyone on the server to have 1 bubble to breathe underwater. Can someone explain to me why it keeps showing me two even though I want one?
@EventHandler
public void onEntityAirChange(EntityAirChangeEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
int oneBubbleAir = 20 * 2;
if (player.getLocation().getBlock().getType() == Material.WATER) {
event.setAmount(oneBubbleAir);
} else {
event.setAmount(player.getMaximumAir());
}
}
}
it immediatly changes blocks tho
because
you're multiplying by 2
I mean
paper is better anyways
I ain't no genius
on the server
Uh... where?
?whereami
Please, if they fixed all of the game breaking glitches, have fun
???
heated a bit
holy
im just trying to fix something
let someone have an opinion
what are you trying to fix
You are on spigot so report spigot not paper
its a bug
yes I know but yeah Paper is objectively worse lol
with spigot api
okay
If your logs are paper it will likely be ignored
I got a problem with my imports. My plugin is saying cannot find symbol carrot etc.
heres my imports packages:
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Crops;
import org.bukkit.block.data.type.Beetroot;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.entity.Player;
Too long to send there
?paste
you are no help to anyone
stop fighting
Keep whining
Huh ?
not you
what IDE are you using
π€¦ββοΈ
Maven
no I mean like intellij?
I think so
what program do you use to code in
VSCode
Do you have an api version in your plugin.yml?
interesting choice I guess
Yes, 1.20.
name: AutoReplantPlugin
version: 1.0
main: com.yourname.autoreplant.AutoReplantPlugin
api-version: 1.20
?paste your config
carrot not carrots
Same error
can you show the full error?
what's the default walk / fly speed?
1
that's way too fast
0.1
.1 iirc
for walk or fly
are you usre the import isnt just org.bukkit.block.BlockType?
they aren't using BlockType at all though?
?
ok
well I assume thats what they want, since thats where the CROPS and CARROTS are
Nah, still the same error..
but those aren't classes
right..
update the version of the maven-compiler-plugin and maven-jar-plugin
there is Crops, but thats deprecated
hello, is it possible for me to make connected blocks like redstone?
there is no such class as Beetroots or Potatoes or Carrots though
yeah idk they're coding in notepad or smth?
is the only way is to just check each block(source) and assign status to that block manually? wouldn't that be too bad for performance?
I mean how do you think redstone works
its probably gonne be less performant since its in a plugin
but like
I dont think the difference would be that big
Hod do I change my IDE?
Who can help with setting up weaknesses. I would like to make sure that the damage inflicted on the mob using a snowball is large. Who can help implement this (Mythic Mobs)
?services
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/
download Intellij Comunnity edition and open the project in there
Hey guys can someone tell me how I can change Playernames I already tried changing GameProfile throuth reflection and then send the appropriate packets but this doesnt helped
Okay, doing it right now
can someone help me with the correct air removal system because I have a problem that when I should have 10 bubbles, I have 7
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
UUID playerId = player.getUniqueId();
int bubbles = playerBubbleCount.getOrDefault(playerId, 10);
bubbles--;
if (bubbles > 0) {
playerBubbleCount.put(playerId, bubbles);
player.sendMessage(ChatColor.RED + "StraciΕeΕ jeden bΔ
belek oddychania. ZostaΕo Ci " + bubbles + " bΔ
belkΓ³w.");
} else {
playerBubbleCount.put(playerId, 0);
player.sendMessage(ChatColor.RED + "StraciΕeΕ wszystkie bΔ
belki oddychania!");
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
UUID playerId = player.getUniqueId();
playerBubbleCount.putIfAbsent(playerId, 10);
}
@EventHandler
public void onEntityAirChange(EntityAirChangeEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
UUID playerId = player.getUniqueId();
int bubbles = playerBubbleCount.getOrDefault(playerId, 10);
int maxAir = bubbles * 20;
if (player.getLocation().getBlock().getType() == Material.WATER) {
if (event.getAmount() > maxAir) {
event.setAmount(maxAir);
}
} else {
event.setAmount(player.getMaximumAir());
}
}
}
}
Something's wrong with my bubble system
these bubbles is your own system right?
yeah i see
there's just something wrong with it
what is the EntityAirChangeEvent?
when does this happen?
Hod do I compile with Intellij then ?
int bubbles = playerBubbleCount.getOrDefault(playerId, 10); shouldnΒ΄t that be 10 anyways or any other count but not null? is this maybe unnecessary?
an int is a primitive which is impossible to be null
Integer can be null, int can not
then how can I make it so that every death the player loses one bubble
player.setMaximumAir(player.getMaximumAir() -1)
Hey, I'm running into an issue. In Spigot 1.20.2 this was working perfectly. Now that i've ported it to 1.21.1 latest snapshot my plugin is failing to retrieve itemMetas from items like crossbows, tridents, and netherrite items. Was there a change to how itemMetas need to be retrieved in the latest spigot?
sounds like it could be a bug
could you provide the snippet of code causing errors?
This seems like it may be a spigot bug please do the following steps
- Create a Minimum plugin to reproduce the error (Simply retrieve item meta of the problematic items)
- Create a Jira account for spigot if you don't already have one (A link to the jira will be posted below)
- Report the bug on jira with an explanation of your issue and the minimum code needed to reporduce the issue.
Your code should look something like this if I'm understanding the issue correctly
public void MyIssue extends JavaPlugin {
@Override
public void onEnable() {
final ItemStack item = new ItemStack(Material.TRIDENT);
item.getItemMeta();
}
}
then post the accompanying stacktrace
?jira
Thanks I'll work on this
Can someone tell me how I can change Playernames I already tried changing GameProfile throuth reflection and then send the appropriate packets but this doesnt worked i am using 1.20.6
i think you have to do -30 not -1
-20 it looks like
its in ticks
I'd assume each bubble would be 1 second
but whatever math works
I can't add spigot in "JRE System Library", "external jars" is not clickable
Eclipse?
yeah
use maven
I'm using gradle for eclipse
if you decide to go that route I can help you set up a project
?maven
DefaultMaxAirSupply is equal to 300 / 10 because of 10 bubbles = 30
is there a way to create a datapack through spigot code?
I want to be able to edit an already existing dp, but the developer told me it might be better to overwrite it's values with another datapack so idk
host it?
I think you are mistaking datapack for resourcepack
datapack is server sided, unless it has textures or something the player needs
no you can't really make datapack features through api
api is severely outdated in this regard
how do terrain generators use datapacks then?
that's what im trying to figure out
datapacks are server side
not clientside
You're thinking of resource packs
ah okies, I was getting them mixed up then
yup yup
Dear,
I need your help. I have a plugin that need sto use a command when a player use an item. I've my code there, the plugin should add the player to a LuckPerms group, but nothings happening, and I have no error
Do you have an example of such a plugin?
In which case, yes you can create datapacks from a plugin, but you'd have to restart the server after
https://www.spigotmc.org/resources/iris-dimension-engine.84586/
iirc this used datapacks to do it's stuff
yeah I don't mind that, just want to know how to create the datapack through code
its mostly json https://minecraft.fandom.com/wiki/Data_pack
did you already check that your if is getting through?
(i.e. make sure that the code gets to line 59)
Found, thank's
so I guess I'd have to worry more about how to zip a folder through code?
and just write the json as any json would be written
yes but zipping is easy in java
so any zipping method for java works fine for spigot deving?
yes
nice, ty
it also seems you can enable them without a restarthttps://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html#getDataPackManager()
Minecraft ships with data generator code
Any modding environment should have them easily accessible
perhaps not. only ones the server already detected. so yes a restart
The Minecraft Worldgen discord might also be of interest to you
yes, I think so xd
i didn't understand that, wdym?
I'm not in a modded env btw
Hey guys ! I would like to use TranslatableComponent (like this https://www.spigotmc.org/wiki/the-chat-component-api/#translatablecomponent)
But ... I have this error : Cannot resolve method 'sendMessage(TranslatableComponent)'
It's like sendMessage only accept String
I use : 1.21.1-R0.1-SNAPSHOT
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I was just saying that you can use one to help generate the required json files
I'm not entirely sure if they allow datapack gen but I'd assume so
Use player.spigot().sendMessage()
Yes I saw that just now thanks π
https://www.spigotmc.org/threads/sending-an-textcomponent.149487/
But it's not possible for setDeathMessage right ?
I have to do something like :
event.setDeathMessage(null);
for (Player player : getServer().getOnlinePlayers())
player.sendMessage(message);
?
You should use Bukkit.spigot().broadcast()
if you want to send to all players
but yes you'd have to something like that
When it comes to components Paper does have a lot better API
so if you plan on using that I recommend depending on their API instead
okok thx : )
Bruh, now I got this xD
com.google.gson.JsonParseException: Failed to parse either. First: Failed to parse either. First: Not a string: {"with":[{"translate":"entity.minecraft.polar_bear"},{"text":"LeWeeky"}]}; Second: Not a json array: {"with":[{"translate":"entity.minecraft.polar_bear"},{"text":"LeWeeky"}]}; Second: No matching codec found
my code : ```Java
target_player.spigot().sendMessage(message);
EDIT:
## Solution :
Default constructor doesn't create starting string
```java
TranslatableComponent message = new TranslatableComponent();
Add "" inside constructor to do an empty string
TranslatableComponent message = new TranslatableComponent("");
I'm having some trouble tracking a star over time with a particle effect. Does anyone know why this might be the case? I have a vector for the star at time = 0, and then I rotate it on the z axis by player.getWorld().getTime()/24000.0)2Math.PI, but it seems to drift.
it lines up at 18000
Bukkit.spigot() kek
should I do argument checks inside a CompletableFuture, or outside?
what
public @NotNull CompletableFuture<@NotNull Saved<PlayerMutePunishment>> mutePlayer(
@NotNull UUID target, @Nullable UUID issuer, @Nullable String reason, @NotNull Duration duration
) {
/*Do Preconditions#checkArgument*/
PunishmentService punishmentService = this.noonieManagement.getDatabaseManager().getPunishmentService();
return punishmentService.getPlayerMuteHistory(target)
.thenAccept(history -> {/*Do Preconditions#checkArgument*/});
}
Inside?
Ok thanks
attacker.sendMessage(Killstreak.killStreaks(attacker.getName())); why does this have a problem?
it says implement method but that doesnt work
method call expecte
Dear, I got a problem, here my code there : world.playSound(spawnLocation, Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 1.0f);, but this is not working. Is this sound even in Minecraft?
Anyone have any ideas for this?
Is rotation not measured in in 2pi or something?
Is killstreaks a String?
Any reason why you can't create a PlayerMutePunishment and pass it as a param
and then just have the future return the punishment object after it's done saving
No, but I think this is better
I'm not a fan of polluting the method params when it can be nicely wrapped in a reusable data class
I mean
Hm
I also have this method
public @NotNull CompletableFuture<@NotNull Saved<PlayerMutePunishment>> unMutePlayer(
@NotNull UUID target, @Nullable UUID pardoner, @Nullable String reason
) {/*...*/}
Yeah returned value is Integer, it's expected a String
can i just do like (String) infront
just call .toString()
How do i spawn a mob in a BukkitRunnable
How do i even spawn a mob
doesnt do anything
public void joinEvent(PlayerJoinEvent e) {
Player player = e.getPlayer();
new BukkitRunnable() {
@Override
public void run() {
// Spawns a cow at the player's location after 1 second
player.getWorld().spawnEntity(player.getLocation(), EntityType.COW);
}
}.runTaskLater(YourMain.getPlugin(YourMain.class), 20L);
}
```thisll spawn a mob, you need a event or to pass a location. 20L = ticks so 1 second
Sorry i wasnt being more specific but this is the code that i have right now and i ment to do it every 10 seconds not when a player joins.
private void SpawnCustomBoss(){
int delay = getConfig().getInt("delay");
Location location = getConfig().getLocation("location");
new BukkitRunnable() {
@Override
public void run() {
}
}.runTaskTimer(this, 0, delay);
}
Where do you want it to spawn
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if (sender instanceof Player){
Player player = (Player) sender;
Location location = player.getLocation();
plugin.getConfig().set("location", location);
} else{
sender.sendMessage("This command can only be ran by a player");
}
return false;
}
Got a command for that
new BukkitRunnable() {
@Override
public void run() {
if (location != null) {
LivingEntity themob = (LivingEntity) location.getWorld().spawnEntity(location, EntityType.COW);
themob.setCustomName("ScareCow");
themob.setCustomNameVisible(true);
}
}
}.runTaskTimer(this, 0, delay);
```oh then youll go this route. and use it in the main class. or fill out similar info to my last msg
When spawning a mob that you want to modify use the spawn method that accepts a consumer
Thanks β€οΈ
what if it spawned a spider
expected behavior
Hey guys i'm curently making a plugin allowing to build a structure that only you can see and then letting you place it or cancel it. It basicly add your modification to a hashmap<Location, BlockData> and then intercept packets regarding the desired block. My issue is that when trying to place a block on a block (they both dont actually exist), it replace the block that was previously placed. How could I make it possible to place a ghost block on a ghost block
use packetevents
otherwise I refuse to help
okay i will
also, WHAT IS THAT STATIC ACCESS
wher
Average packet manipulation code
sounds like someone doesn't do much packet manipulation
HOLY WHAT IS MAIN.GETINSTANCE
HOW DARE I
I SHOULD REPEND
I AM SORRY IF I OFFENDED YOU, I DIDNT MEAN TO DO SUCH A THING
Can someone tell me how I can change Playernames I already tried changing GameProfile throuth reflection and then send the appropriate packets but this doesnt worked i am using 1.20.6
its the public static hashmap
after you call getInstance()
its not really normal or safe
Can someone help me i am trying to add a potion effect to a living entity i've red the docs but nothing seems to work
new BukkitRunnable() {
@Override
public void run() {
if (location != null) {
LivingEntity Boss = (LivingEntity) location.getWorld().spawnEntity(location, EntityType.WITHER_SKELETON);
Boss.setCustomName("Ghost prime jr.");
Boss.setCustomNameVisible(true);
Boss.setGlowing(true);
Boss.addPotionEffect();
}
}
}.runTaskTimer(this, 0, delay);
The boss.AddPotionEffect dont give me anything else then this wait
Constructor
you have to create a new PotionEffect
new PotionEffect
Ohh
new PotionEffect(PotionEffectType.Whatever)
if you need help make sure to look on spigotdocs
ex c# dev right there
package index
wow super
how can i make it non static
whre
but i didnt find how to not make it static
like constructor aint working
@coarse linden
That's fine
You just can't access a variable like that outside of a method/variable declaration
You do not
The error is from that floating plugin at the end of the image
no i mean
buddy
Do follow naming conventions
That the plugin is not defined
what was it
The hashmap
yeah?
HAshmap is fine
Well
When i log off, my server crash if i have a session enabled
Basicly a session is when every time i place or break a block
it just adds it to a hashmap
And overwrite the packets (blockupdate)
yeah
let me try to crash it to show log
And i was thinking the problem came from the getInstance()
the singleton is fine
(not rllyyy but fine)
tf is singleton
gosh i forgot everything
Anyways, the reason why i asked help here is for placing a ghost block on a ghost block
@coarse linden could i maybe show a ss of what i mean
was there some other maven rep back then used?
wait, no, it does work
nice
it is lmao
what other way are you going to get the plugins instance
Di
does setStorageContents in playerinventory also count slot bar?
how do i make my arguments an integer instead of a string in a cmd?
update, apparently removing this one bit of code fixed my issues entirely. Why is completely beyond me but yay??? Player player = (Player) sender;
ItemStack item = player.getInventory().getItemInMainHand();
if (item == null || item.getType().isAir()) {
player.sendMessage("Hold an item in your hand to add a signature.");
return true;
}
Result of 'Integer.parseInt()' is ignored
why is that
Because you receive a string Array?
How are you? How would you do to create an instance of an object by reflections but knowing that each class to initialize could have any constructor with parameters. The problem here is that to initialize you have to know the parameters, something that I would not know. That's why I need to find a way to initialize objects without knowing the constructors using the one that doesn't have any parameters. But I understand that if you don't specify an empty one, java doesn't create it by default. I know that some libraries already handle these, one of them is Gson
i mean, it really just depends on what you're doing exactly and why
there's something called DI and it's really useful just sayin
anyone knows how to make strays give you the freezing effect from 1.17 when hitting you
not sure we are seeing the same dependency injection
?
you do not need it imo. a singleton works great and a di just makes things more complex and adds more code for no reason. is it more flexible? yes, but there is no need to be flexible with a class that can only be instantiated once. unless you are creating a hierarchy with the javaplugin class, a singleton is better.
here is an example of how a di should be used
when there is flexability; not when there is none
spring boot makes this easier, but there are no disadvantages with using singletons for this example.
singleton for plugin instance makes sense
unless you want to go pure DI which is a literal nightmare
I'm making a Minecraft java class that going to communicate with a website with socket.io when they are in a WorldGuard region it'll read a config file named audio.yml made by the main class, made regions in the config looks like below and when it see if they are in a valid region that has audio linked it'll take a audio file from the websites side and play it through the webhook using socket.io, each player will be in different regions and each player has a link generated for them using there UUID, the link looks like: https://www.mcilluminations.net/audio.html?user=3fc8ef6d-420e-4b5b-91ae-e625e9bb2fe7 all of the audio is stored in the website under the Audio folder path
Regions:
wdw: main.mp3
epcot: entrance.mp3
singleton and DI are not mutually exclusive βοΈπ€ they can work together perfectly fine, it's global static access that's the arguably bad part
yes
but you do not need DI to get the plugin's instance
if there is i would love to hear it
they are mutually exclusive you dumb idiot why else would I need
class Player1 {}
class Player2 {}
class Player3 {}
class Player4 {}
class Player5 {}
class Player6 {}
class Player7 {}
class Player8 {}
class Player9 {}
class Player10 {}
Nice thing about this is I know I'll never have a memory leak and no errors will occur because there is no chance I get more than 10 players anyways
I think its pretty fair to just use DI if you only use it in one or two places
otherwise I'll usually make it a singleton
or again if you want to go pure DI approach and feel the burn
with proper design, your plugin instance isn't even needed outside of platform hooks (listener registration etc)
Bukkit scheduler is knocking on your door right now
and its not very happy
lmao