#help-development
1 messages · Page 2296 of 1
it's smth like "item.minecraft.potion.effect.night_vision" that
/give @s stone{display:{Name:'{"translate":"item.minecraft.potion.effect.night_vision"}'}} this command works just fine
I believe I forgot "display:{Name:'{"
bruH
Yeah idk, i don't get it :(
but I have to go now. If I find a solution imma update you
how can I make this work using velocity?
when I tried setting velocity, it launched me way too far from the ship
Location tpTo = p.getLocation().clone();
tpTo.setPitch(p.getLocation().getPitch());
tpTo.setYaw(p.getLocation().getYaw());
Vector direction = prevLocation.clone().subtract(newPos).getDirection().multiply(-1);
double movedBy = prevLocation.clone().distance(newPos);
tpTo.add(direction.multiply(movedBy));
Gizmo.createSphereGizmo(tpTo,5,Color.RED);
p.teleport(tpTo);
prevLocation - ship's previous location
newPos - ship's new position
damn its a ship ladies and gentlemen
i dont think a real pirate would see a difference
Explain what you are trying to do
soo I just made so player rides together with ship
but I just teleport him and it doesn't look smooth at all, also can't look around
but if I would setVelocity,it would be smooth and nothing would be blocked for player
but when I tried setting players velocity to tpTo.getDirection().multiply(somethings idk)
I just got launched away
Wait your ship does not consist of falling blocks but actual blocks that move together with a discrete distance?
yes
im using world edit api for that
by not smooth I mean seeing teleportation
yeah
youre ship is moving by 1 block
without interpolation or anything
thats what is causing the sudden movement
I think i would try lerping the distance of the player.
that wont solve the issue
how?
the root of the issue is the ship not moving smoothly whereas the player is
So if the ship moves one block in 5 ticks you simply teleport the player 5 times while the ship only moves once.
oooh
but then youre not always in the same spot on the ship?
you can move
and it works fine
just not interpolated
Yeah it will still look a bit weird
and that will also cause the sudden movement to appear
the reason its looking weird is because youre frame of reference (the ship) is not moving at the same rate you are
lerping the player position wont solve the issue since youre frame of reference is still going to change relative to you
couldn't I just convert Location into Velocity?
smhw
Well... if you find out the proper magnitude then sure.
But this will be quite hard to get right.
asVector(target - base) * C
Where C is some constant which is directly proportional to the speed of the ship
maybe
sNewLoc - sOldLoc .distance?
This is for sure too fast
imma try settings C to ship speed
maybe it will work ?
No it wont
nvm
no
config.getBoolean("Power_Button.cool")
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I mean... that depends on the setup. Yes, you can send a player to another server that is connected to the same bungee proxy without using Bungee API
But if you're wanting to send a player from your server to, say for example, Hypixel, no that's not possible
if the other server is on the same proxy, you can use plugin messages right?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
it was somewhat possible on minecraft bedrock
idk if it still is. havent played
This is Java edition ;p
how can I get data from one server to other one
basically I have one server which is kinda like the hub, now I want to show the player count of a DIFFERENT server (which is the minigame server)
Generally you’d use something like Redis
You can use an SQL database but Redis is probably faster for that sort of stuff, especially given that you can make use of pub/sub
Send the entire line pls
Send the whole line
This so desperately pisses me off and no matter what I do I cant fix this shit:
Theirs: https://paste.md-5.net/moqejabotu.xml
Mine: https://paste.md-5.net/qazimulewo.xml
(Do note ive upgraded maven special source and re-ran build tools)
I am trying to import a module from CitizensAPI (Theirs) but for some FUCKING reason, even when compiling the source LOCALLY on MY OWN OBFUSCATION JARS, Objects from "Theirs" gets remapped differently to mine
In the screenshot, I have CitizensNPC's src code open, and its ServerPlayer but when i import it through maven (Wether its repo, the mapped jar, unmapped jar, etc) The ServerPlayer (And many other objects) of the imported module go to shit (See screenshot)
is using
Bukkit.getServer().getPluginManager().getPlugin("Wired");
a viable way of getting my other plugin to use it's methods?
if so is it the same way of registering events? just from another plugin
yes. thats what i wanted
and here is src code, on my machine perfectly fine as ServerPlayer, yet when imported via maven no matter what the mappings are fucked
forgot to ccomplete it mb
new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
ItemStack item = player.getInventory().getHelmet();
if(item == null) {return;}
if(item.getItemMeta() == null) {return;}
if(item.getItemMeta().getDisplayName() == null) {return;}
ItemMeta meta = item.getItemMeta();
String ItemName = item.getItemMeta().getDisplayName();
if (ItemName.equals(ChatColor.RED + "Dctr's Space Helmet")) {
Random r = new Random();
int color = r.nextInt(colors.size());
Material material = colors.get(color);
item.setType(material);
item.setItemMeta(meta);
}
}
}
}.runTaskTimer(this, 20, 20);```
the .size and .get is showing an error
There isn't any variable declared with name colors
there is
@Override
public void onEnable() {
getCommand("spacehelm").setExecutor(new SpaceHelmetCmd());
getServer().getPluginManager().registerEvents(new SpaceHelmetListener(), this);
byte[] colors = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
ItemStack item = new ItemStack(Material.STAINED_GLASS, 1, (byte) 0);
ItemStack item1 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 1);
ItemStack item2 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 2);
ItemStack item3 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 3);
ItemStack item4 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 4);
ItemStack item5 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 5);
ItemStack item6 = new ItemStack(Material.STAINED_GLASS, 1, (byte) 6);
new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
ItemStack item = player.getInventory().getHelmet();
if(item == null) {return;}
if(item.getItemMeta() == null) {return;}
if(item.getItemMeta().getDisplayName() == null) {return;}
ItemMeta meta = item.getItemMeta();
String ItemName = item.getItemMeta().getDisplayName();
if (ItemName.equals(ChatColor.RED + "Dctr's Space Helmet")) {
Random r = new Random();
int color = r.nextInt(colors.size());
Material material = colors.get(color);
item.setType(material);
item.setItemMeta(meta);
}
}
}
}.runTaskTimer(this, 20, 20);
}
}```
colors is an array, not a list
so what I do
You have to use colors.length
do I do dis or what tomasan told
Both
Use colors.length to get the size and colors[int] to get Xth element
so this will be
int color = r.nextInt(color.length
General design question:
So I've implemented a kind of design that loads and unloads player data into memory, similar to this: https://www.spigotmc.org/threads/working-with-data.562421/
But my question is how would I create a command to paginate through all player data? I can't just query the database because it won't be up to date all the time.
yes but I want to paginate through all player data
loaded and unloaded
Load all
dont think you want to create a new random for each player
isnt that a bad idea
And then paginate
Do it in chunks
huh
Or query the database for three pages ahead
my bad
And query the next on the go
hmm
okay I'll try to see if I can do that
i just feel like i'm gonna run into a logic issue
i'll see
public void onPlayerRespawn(PlayerRespawnEvent event) <- why doesn't this code fire when someone respawns?
public static void AsyncChatHookEvent(AsyncChatHookEvent e){
plugin.getLogger().info("Got event");
Player p = e.getPlayer();
String s = e.getChannel().toString();
p.sendMessage("You spoke in: "+s);
}
``` can anyone see why this wouldnt work
its using the `import com.palmergames.bukkit.TownyChat.events.AsyncChatHookEvent;`
Best way to check if an ArmorStands block on head is colliding with something?
implement & register?
Its in my Main class
oh
ok, thanks for helping
ListenerClass can't be resolved in a type
do I have to put Listener in there?
so that I have only one this?
"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.
oh
"this" doesn't work
provide your plugins instance
but it is my main class
Bukkit.getPluginManager().registerEvents(new Main(), this); but this does work
well that explains it
why does it work now ._ .
?main
Bukkit.getPluginManager().registerEvents(this, this); like this it works
yeah because you properly registered the event that way
how can i redirect to another bungee server within my network using spigot api?
bump on this
Material material = colors.get[color];
I kept code as this
Cannot resolve symbol 'get'
another question
lets say I just wanted to get the data of one offline player (unloaded data)
is it proper to load the data and then unload it later on a certain interval when it all gets flushed
but wont that break the use of the plugin?
like
AH
well then wont it break the plugin? like the glass needs to be an armor
a helmet
I did
sooo
wat I do for the lasrt part
last
I think in 1.8 its somethign like setTypeandData
or setType(Material, data)
I forget, its years ago
teh data being a byte
got it
Created sub module and then install sub module to .m2 then imported it via local repo
when can special source be for gradle
im tired of this
Maven love 😄
hell no
not after today and its bs i put up with
hoever i did learn maven modules
so something good came out of it
Go on... You know you want too... Just a little Maven
It OK, its not addictive, honest... Just one little taste.
maven 😆
use maven come on do it just use it just once
why yall love maven so much 
It not really love. We just don;t need Gradle. Its not because we are addicted twitch honest.
I just don't need gradlew Maven has everything I need I can stop any time and convert anyways
Yep, we can stop any time we want
yea
yes
I'm sure this would be easier with maven
Wtf even is EntityPlayer remappings from???
it is sadly
strokes his maven
is there a way i can bukkit.dispatchcommand as an opped player. not consolesender, but opped player
declaration: package: org.bukkit.entity, interface: Player
you would have to check if the player is op yourself. Otherwise he will simply get a "no permission" result
Does the player have permission?
It's probably not gonna work, because it can't communicate with bungee
a l t e r n a t i v e s ?
You know it simulates executing the command on the Spigot server, but on on bungee
You'll have to use plugin messaging
And send a message to the bungee, to move the player to different server
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thanks
The best would be to learn what static actually is.
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
it shares variables and voids to other classes ig?
It ties functions/variables to the class and not to objects
cool
Meaning, you cannot reference instance variables in the static context
is there any way with i can use getDataFolder() in static context whithout setting plugin to static?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
what if i have bungee plugin?
whats the problem?
Yeah. Bungee = proxy events. Bukkit = server events (like block breaking)
my problem is: i want to make String url static but i cant use getDataFolder() then
All bukkit events are handled server side already...
Variables are initialized before the constructor is being run
and??
Bungee doesnt know about events or spigot... it doesnt know what kind of server is on the other side.
Should be more than enough information
is it recommended to update loot tables with spigot or should I just make a datapack instead?
its not
how to reverse that?
Hi there, I was interested in getting into minecraft development. Have been trying out a few random things just to see how it works etc. Already know my ways around java a bit, but never touched spigot plugins. Would anyone have a guide for complete beginners, or at least point to one where i can get started on how this all works?
youtube: how to make minecraft plugin
me too buddy. I've been slowly going through this giant playlist by a guy called kody simpson on youtube
i know how to code just how the basics of getting started work. What people would consider a good place to get started in spigot development
i know minecraft itself plenty enough too lol
clearly since you don't understand it you should learn some java. Java isn't python its not run from top down at run time
If you know at least the very basics of java then this is more than enough information
can i initialize plugin in main and use then use it in other classes?
as someone who doesn't know the very basics of java, I can confirm that isn't enough information for me
do you mean that making a custom recipe just stores it in memory when you start the server up?
i set my static plugin instance after i initalize all my main class variables
yeah I'll play around with it just wasn't sure if it was going to be the best course of action, but it looks like there is this LootGenerateEvent I can use so that's a good start
thanks 😄
was mostly looking for some guide on how to set up your environment, get your basic package structure etc. Can't find this on the spigot website itself (unless i'm completely overlooking it)
already found the api docs themselves
can you link me a thing where this is explained
getting instance
ah yeah nah i use IDEA
You can have a bungee plugin and a spigot plugin in the same .jar, if that's what you mean. Though if your plugin is installed on Bungee, no, you're not able to handle anything Bukkit-related because it doesn't exist on the proxy. It has no concept of worlds.
How can I use functions of other classes (from another plugin of mine) in my new plugin? Because when I just add the Economy plugin as a dependency and use DatabaseUtil.getBalance(String uuid);, Maven wants to stab me
I've just started making plugins, but a lot of people say I should learn Java before even trying. Is MOOC Helsinki a good guide (if anyone else here has experience with it).
Same but people tend to be unwilling to help you. In my case it was fine ig, because I already had experience with a lot of other languages tho
already had java classes in uni so that's not the order i can take haha
I honestly think that learning by doing is a great method to learn programming languages
true
I'd appreciate any help I can get.
Maven says the following btw: package me.probablydiary.caveeconomy.util does not exist
I find that works the best me. I can't remember much from what I'm reading 😂
Arraylist is super easy to learn and super powerful too 😄
store the inventory somewhere
are you saying you can store an entire inventory with its' exact contents as a value on the hashmap?
sure
Not sure about the HashMap, like i said
save the inventory somewhere else
if you add contents and close it, the items are there still
true
could
I think my buddy said hashmaps are only stored in memory so you would have to redefine the inventory on startup every time too
ArrayList or HashMap should do the job. Regarding resources and efficiency, idk
that's crazy I didn't know you could use such complex values
the only examples I've seen were like UUID's and strings lol
Not sure it's smart to store such complex Objects in a hash map though. But idk
I'm not familiar with the Space complexity of Hash Maps
wdym
ofc, i think storing the whole inv does that though.
is there not just an already defined vanilla minecraft grindstone inventory you can access without all this hashmap work, or are you making your own new version of a grindstone?
Because it's basically an ItemStack[]
May I ask what you're trying to do? Cause it's hard to follow rn
InventoryCloseEvent
close event
ye
ElgarL, do you have any idea why Maven tries to kill me when I access a function of Class from a dependency (Economy plugin of mine). package ..... does not exist
what scope did you add yoru eco plugin as?
okay so thats the problem. Uh, how do I add it as a dependency in Maven?
I'm betting you manually added teh jar to your project
one sec, you need to install it as a 3rd party jar to maven
im still stuck on this. can anyone.....
I thought it's gonna be a problem but I didn't think it was going to be this early
oh, are you building yoru eco with maven too?
did, yes
if you are building it with Maven just run install
that will add it to your local maven
you can then add it to your other projects pom
if I want to deploy it on the server, will it work or will I have to configure anything so that it works?
you just have to have both jars on your server
nocie
*noice
Appreciate it
Cannot make a static reference to the non-static field plugin
you mean this? private final Main plugin;
still red
class is public?
wdym
i can move plugin instance to static
i actually cant
😄
exatly
im not doing configuration
i just need db
to use db
i need this string
shared in other classes
so i need static
but it goes red
Do I have to add it to my pom.xml too? Because right now it doesn't seem to work
yes
Oh, makes sense lol
you add it as you would any other dependency
how?
Can you make both static or both not static?
i cant
you are trying to make a reference to an instance member from a static context
lol
i need this string static
im not doing config file
is it working on bungee?
why not? Does it give you another error?
what
DI follows through all java programs ._.
you can do it on a basic helloworld program without spigot if you so please xD
Bruh i told you not not make it static
Make a method for it
since DI is not an option for some reason
Bruh i told you i need it static
method values? wdym
ill try DI
Then init it in the constructot
that means making it not static
You really dont. You should try to not use static for the first few plugins.
what
how can i share it to other classes then?
by passing an instance to other classes
tutorial?
after trying to add github to intellij, a all files have a red name. i then disconnected github but the changes are still there
type git add * in your terminal
will this work? i heard someone saying variables are initialized first
So first url is initialized. This will call getDataFolder() on your plugin variable.
Then the constructor is called. The constuctor initializes the plugin variable.
Spot the problem.
i cant use public in it
only static variables are initialized first really, as you noticed with your previous error, unless its in the constructor
now it's green for some reason. is it possible to change it back to how it was originally?
a
so i can use this with no problem?
Yes now everything is added to git. You can remove git from your project if you want. Intellij has some features for that.
Are you for real?
perhaps
what
So first url is initialized. This will call getDataFolder() on your plugin variable.
Then the constructor is called. The constuctor initializes the plugin variable.
Spot the problem.
i dont know english good so if i say something that sounds like a troll dont see it as troll
why would constructor call?
plugin is already plugin
A non-existing car
ye
And the same occurs to you.
- initializing url calls plugin.getDataFolder()
- plugin is initialized by the constructor
To fix this:
Learn the very basics of Java
It does not take long
i was on some java basics urls several times
are you sure i will find fix of that thing?
link me "java basics" which contains explanation of that thing
.
Any java basics tutorial explains this.
Just sit down for 2 weeks and learn them.
oh god
JUST
tell me how to fix it
i promise i will learn java
after
making this plugin
Ok. Make sure you dont rely on un-initialized variables. Initialize them in the right order.
i already know i have to initialize variables on right order
BUT HOW
hm this is interesting. Whilst setting up my environment to get going with plugin dev, i was doing the buildtools thing to get the spigot.jar, but apparently the git part of it doesn't work?
Rebuilding Forked projects....
Resetting Spigot-API to Bukkit...
HEAD is now at 6a039faf #745: Expose more information about advancements
Applying patches to Spigot-API...
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'MYNAME@DESKTOP-68O5DT1.(none)')
Something did not apply cleanly to Spigot-API.
Please review above details and finish the apply then
save the changes with rebuildPatches.sh
Error compiling Spigot. Please check the wiki for FAQs.
If this does not resolve your issue then please pastebin the entire BuildTools.log.txt file when seeking support.
java.lang.RuntimeException: Error running command, return status !=0: [sh, applyPatches.sh]
at org.spigotmc.builder.Builder.runProcess0(Builder.java:973)
at org.spigotmc.builder.Builder.runProcess(Builder.java:904)
at org.spigotmc.builder.Builder.main(Builder.java:703)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)
Even after doing the git config commands to set email it refuses to work with the same error
We are not going to literally write the plugin for you.
This is not a spigot related question. Its purely a matter of basic java knowledge.
The constructor is called before the variable initializers.
"write plugin for you" fix will be max 10 lines ig
are you gonna help me or not
yes
and if your struggling just with this
your gonna REALLY struggle once you start on that
thank you for telling useless thing
of course
Interesting. Did you take a look in the faq? This looks like a problem with your git setup.
either i'm blind or the faq has nothing more than this
git has always worked fine for me this far
have used it for quite some time with no issues
Try setting your credentials in the global config
already tried
oh nvm found the right faq
bump
I ran into a logic error trying to the method mentioned
all variables are initialized first? i mean if i use it in event or something would constructor called before?
i'll try running with git bash to see if that works
apparently that did the trick. Seems like something is wrong with cmd's git config
git config --list returns correct user.name and user.email but the applyPatches uses the wrong one anyways so idk. Ah well it works now
sorry for the ping @lost matrix but I am using the data scoping thing you showed me so i need some clarification on this

lmfao
Sure whats up
does that means yes?
why cant i use custom emojis i would really like to use one now
bruh
i can give you a gif instead if you like
no i will not be treated like a peasant
that works
i call pay2win
@lost matrix rn in that gif
about who
i wonder
hello how can i directly input main method in intellij
Main
when creating the class
bump
Dude
I was having the same issue
What did u do
I just said fuck it and downloaded paper
use git bash and not cmd
To run the buildtools?
for some reason cmd screwed up on the git credentials when running the applyPatches
git bash just worked fine
yeah buildtools
if you look in the error you see fatal: unable to auto-detect email address (got 'MYNAME@DESKTOP-68O5DT1.(none)'), and i very much know that i have user.email set correctly in git config (so nothing auto-generated/detected from some registry values). Even verified with git config --list
this part didnt had error before
i added this in listener
no no no
im making discord bot
in plugin
why are you sprinting before learning to run
SQLlite, discord bot
all in a mc plugin
for your first time ever learning java
i coded several plugins before
so its not first time
If youve coded several plugins you would of known what was wrong here
sorry simple truth
hey how do I teleport a player to a different dimension? I've tried googleing it but cant find anything
but i dont know
You just teleport them to a Location in that dimensions world
World#getSpawnPoint is a method you can send them too iirc
declaration: package: org.bukkit, interface: World
it is
Bukkit.getWorld(someWorld).getSpawnLocation();
thx
and just tp them to that Location
oh gotcha, ty
plugin is null?
Good evening I would like to know how to block the bungeecord command (server) because I am creating a login plugin for my minecraft server. Players can connect without registering or logging in because of the command. Can you please tell me what to do please?
How To Force It To Run Constructor?
You dont need to force it lol you just initialize the class with the given constructor parameters
eg new ThatClassName(AnyParamter, GoInHere, AndHere);
where to do that
sorry i dont know much about bungeecord
in main?
it depends
Thats something you should really know, its your code after all
Does it need to get initialized on the plugin enabled? If so it likely goes in onEnable
mike the bungeecord ninja
Sounds like cracked MC stuff to me 🤮
huh it doesnt seem to be working...
my JDABuilder already registers that class so i may interrupt it?
or not maybe?
Whats it doing?
Okay
the constructors already regsitered by doing that
the new keyword initializes the given constructor for said class
nothing
send the code your using
Any errors? Is your server thread stalled? Try /tps
sigh
its your constructor
so whatever your constructor is, you pass the needed variables to the class constructor
server's fine, here's the code:
Location worldSpawn = Bukkit.getWorld("world").getSpawnLocation();
and what are you doing with that variable
you should be passing it to Player#teleport(Location);
and it does nothing?
yea
sec
ive done some basic troubleshooting and the code is running, its just that part that isnt working
whats the return value of that method
it returns a boolean
log it if you can, should be false if its failing
wha
can i use constructor as a variable?
no, your constructor is a constructor
@true shuttle i got an idea if its false so lmk
you pass arguments (Variables) TO your constructor
i dont need to pass variable in other classes
Yes you do if your constructor requires it
wdym
sorry typo
class Something
public Something(String str) {
}
}
new Something("A String");
An example of passing arguments to a class constructor
a
ok so i figured it out:
it was in a listener for portal teleport, so basically when u enter a nether portal it teleports you to a different dimension. However, cuz it was doing the teleport code when they were being tp'd to the nether, the nether tp code took priority or something. I fixed it by running the tp on a slight delay
General design question:
So I've implemented a kind of design that loads and unloads "families" to and from memory, similar to this: https://www.spigotmc.org/threads/working-with-data.562421/
But my question is how would I create a command to select a family at random (either loaded or unloaded)? I can't just query the database because it is not always up to date.
thx for the help tho
ahh yeah gotta let current teleport event finish first haha
you mean something like this?
yep. I just had to do a delay of 1 lol
Why is the database not always up to date?
Sounds like some type of design flaw
Yes but with an actual variable instance
how to get plugin?
dependency injection, or if your in your main class already, the this keyword
You should really go learn some java basics
its gonna help you so much
uhum
so
it will run constructor now?
i will after this plugin.
no not really
its intended
I need to rapidly access certain parts of data
hold on brb
umm
why does this returns me a nothing? System.getProperty("user.dir"))
when im trying to print this System.out.println(url + " " + System.getProperty("user.dir")); it prints
ok
i need to rapidly access the data
so I'm basically storing whatever is in use in ram
and then every 10 or so minutes I'm flushing it, saving the current state to the database
bump pls
hmmmmmmmmmmmmmmmmmmmmmmmmm
forgive me, as im not very familiar with JVM languages
but
whats the best way to check if a Player stored in a variable is equal to CommandSender sender?
if(sender.equals(player))
dont flush just push and keep your data in memory
your memory should act like a buffer between your server and your database engine
Yeah I push all the data to my database, but then also unload any data that isn't needed anymore
such as players that aren't online anymore
You should only read and set from in store memory values (Unless say a player joins, then you call a get to the database)
Then every 5 minutes in a async task timer save all the data thats currently in the map
Just unload it when the log off
yeah i do
unload and async save
but if I want to access the data of an offline player (which is not too common)
I'll load the data for it to be unloaded later during the flush
or just dont store it if its not too common
get it use it forget about it
only cache things that you want to stay in memory long term eg your player data thats active
for offline players 100% you can use async calls, youll have 0 lag if you do it right, and you can call your database multiple times for the players
can I use async calls for a command?
yes
just
when you access anything on bukkit
eg sendming messages, getting blocks, whatever
throw it un a runTask/runTaskLater BukkitRunnable
but like what if the message I'm trying to send relies on the results of the database query
itll throw it back to main through for you that way
create a callback function on completion
or a CompletableFuture
sorry im lost lmfao
Im not too familiar with multithreading on java, i come from other languages
since your not gonna be storing the OfflinePlayer when you get them you save yourself loads by not having to deal with persistance between threads
I would look into CompletableFuture its a really nice class
and has exactly what you need, runAsync then back onto main thread
Youll have to google guides about those or ping conclure, im abt to take a nap haha
maybe hyper knows

wait so heres the thing
so what you're saying is that I need to make a seperate method to retrieve unloaded data and not store it right
i think?
yes and make sure the call is always async (Just the database call)
when you get the result, you can supply is synchronus with CompletableFuture
if no one shows you how to do it while im gone i will
i rly gtg now tho
so what If I have command that uses this method, but the data actually is loaded? Wouldn't it cause desync problems?
alright
I just don't see how this whole structure works
let me draw something rq
before you execute the async call you can check your cache (on main thread, its super cheap after all it should just be map.get()) if the data happens to exist
at least i hope your datas stores in a hashmap
its not a structure
its logic
HashMap is typically fine
idk how to explain this ima just draw something lmao
you can nap if you want im not gonna hold u hostage here
even with the multithreading at hand
You're not interacting asynchronously with your cache so concurrency won't matter as it's not across threads
even then
HashMap is decently safe on its own accross threads
(iirc)
no its not
only for a few minutes, have to get ready to go do more things with tires 😛
yeah, they are harmed everyday where I work
ffs i dont even know how to draw what im trying to say
IMO
Anyways, hashmap is fine across threads so as long as you are not writing to it while reading especially from multiple threads. If all you are doing is just reading then yes it will be fine. Otherwise use ConcurrentHashMap
that was mojangs doing
api wise tho, you can ban via UUID and it sucks
What's the event when a player right clicks an entity (in this case a zombie)?
yeah he prolly does want that then
since hes gonna load data in AsyncJoinEvent then shove it to cache
PlayerInteractAtEntityEvent
iirc
might have scuffed the name a lil
There is no Methods for it
Its just name and IP
I think you pass a uuid as a string to the name one
declaration: package: org.bukkit, interface: BanList, enum: Type
But I could be wrong
this is correct
this is literally the spigot discord
thanks. Looked it up and there's also the one without "at" that has no location
thats the same thing
declaration: package: org.bukkit, interface: BanList
BanList has 2 types
names and IPs
always has
but idk if uuid is handled in names
for like years
so i always avoid that api
true, but ide prefer a ban directly by uuid
and when checking if the player names changed it wont show in banlist
if you use a player name the server will lookup their UUID
not sure if the ban list automatically syncs it
i wish the docs gave more info
like target of the ban is generic asf
when you have 2 list types
instead of guessing from the method, should look at how it is implemented instead to get a better idea what it does o.O
the ban api is pretty basic, but you don't need it to be anything super advanced either lol
i just make my own list, i dont trust that entire section of bukkit xD
dont you have to kick the player one tick later
or was that finally fixed
and can just call it directly
have you tested?
I did the exact same plugin in like uhmm
1.12ish
i got an exception with banning then kicking without a runnable
lemme see if i still have that project
doubt it tho
sadness i lost that src
yep thats true
and when they leave/rejoin they cant do it
is net.minecraft.world the same as net.minecraft.server? I'm trying to learn NMS stuff but all my imports end in .world instead of .server
would I use the PlayerInteractEvent if I want something to happen when you R-click another player?
No Bukkit World is Level in MC
ah i see, how would i use NMS imports then with spigot?
EntityInteractEvent
You don;t unless you have a very specific need for NMS
here
Always use teh Spigot API first. Only use NMS if there is no API for it
unless there is a way for an entity like a zombie to target a skeleton in the spigot API, i believe i need NMS
my question is, what if the data method 2 is trying to retrieve is cached? if it instantly updates the database, it'll get overriden
setTarget is only for players though (or atleast ive been told)
I'm wondering if it's possible to save the contents of a chest to a gson file
even if the items inside are custom items
Yes, all ItemStacks are serializable
yes, I was told here that it was pretty much only possible with NMS
yeah I've got to that part. I've tried setTarget in the past with problems but I guess I used Entities instead of LivingEntities
wait r u modelling data transfers and accesses here?
i want to basically have a admin shop area where i can sell stuff that you can't find in vanilla like spawners, etc. And have enchanted stuff for sale, etc. My idea was to have a command to create a chest and if you're the owner you can edit the contents of the chest, and when a player clicks an item inside, they buy it but it doesn't move from the chest itself
kinda but in a horrible way
do you think this is the best way to go with this
im having trouble explaining it
No, PlayerInteractEvent is correct
I'm storing online players and families in cache. All changes will be made to the cache, and every 10 minutes the database will update whatever is in the cache
entityinteractevent is called when you right click an entity?
No
But there are some cases where I need to access offline player data, but I'm not sure how to go about that
Yes but you may have issues with gson as I believe it will have issues with enchantments as you can;t instance ItemMeta
Right now I just have it so that whenever I access a player or family, it stays in the cache until the 10 minute interval happens when its removed
yaml works fine though
oops yeah forgot it was playerinteractentity
sorta
and you're asking about the accessibility of offline users?
yes
well one thing first
you should not let your online players be invalidated our timed out from the cache
I'm storing a bunch of PlayerData and Family objects in the cache. I can retreive these objects and modify them, so that when the next interval happens, it'll update the database
wdym
think about it rationally
if x amount of players are playing on the server
there is ever little reason to remove a dto that represents the data of a player
however
for offline players
you might wanna load a dto for them with an expiration
since else you might run into a memory leak
with the block break event how do you see if player broke it using favorable tool
(i know ive seen it somewhere i just cant seem to find the method)
What would be the code to make a spawned zombie entity not catch on fire? it is invunerable and no AI, but it still burns in sunlight/lava
what is a dto
im not removing it
put a skelly skull as a helmet
i'm just simply updating the database
and removing any players that still aren't online
i don't have any experience using yaml, do you have resources where I can learn how to use yaml with minecraft?
declaration: package: org.bukkit.entity, interface: Entity
i think
there's also setVisualFire but I've never used it
i tried that and from what i saw it just vanishes current fire but not future fires
create a loop then
and this is just how long an entity should be burning for
just put a helmet on it
you can set it to 0
it won;t catch fire then
yeah i'll give it a skelly helmet
Hi y'all, i need help, i was trying to recreate the Mjolnir (Marvel Thor's Hammer) in minecraft just for fun, and i wanted to an ability where you could hit the ground and launch the mob in the air (as if they where hit by a punch bow), i managed to do the particle animation but now i have no clue on how to 1) check if the mob is inside or not the shockwawe and 2) launch the actual mob, any ideas?
i mean technically i could check the location of the mob by the location of the particle as they are spawned
what do you tyhink about using this library to serialize enchanted items
man im bored
this works well with custom/enchanted items?
yes
im so lost idk what to do
Can I just post all my data management classes for someone to review
.
Hi I have problem I try update my plugin to java 17 but I have problem java public static void addDependency(File file) throws NoSuchMethodException, MalformedURLException, InvocationTargetException, IllegalAccessException { Method addURL = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); addURL.setAccessible(true); addURL.invoke(URLClassLoader.getSystemClassLoader(), file.toURI().toURL()); } old method to load libraries from external jar stop working and I don't have any idea how fix it 😅
if your library is on maven central you can use the libraries entry in the plugin.yml
Data management pain
Really? How? 😅
@eternal oxide this is using paper which uses a different method to serialize and deserialize
upon converting to the alternative method that works with spigot, it's asking for a map
libraries:
- com.squareup.okhttp3:okhttp:4.9.0```
You can fairly easily copy the paper method into your plugin
But it does require NMS
I don't do Paper
It just uses NBT to serialize to a byte array
what do I do with this library
oh nvm sorry
You don't, it wasn't to you
so what's your idea for the hashmap its asking for
#999803116243406929 bump
I'm having trouble getting the contents of a barrel
Cast the BlockState to Barrel and get the Inventory
Show your code
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Using a stream just to pipe it into a forEach is really bad
It's just for testing
I'm also having trouble clearing Container's inventory contents
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I tried using Containter#getInventory#clear but nothing
This loop is really inefficient
I did Container#update afterwards aswell
Get the TileStates for the chunks
Don’t update after changing inventory
Why not?
Thank you, it seems to work now
With packets you could
Anyone knows why would this happen?
Be careful with the number of spaces you leave, it should be 2 and try this softdepend: [PlaceholderAPI]
softdepend does not control load order
Hey @lost matrix could you have a look in #999803116243406929 whenever you’re free
And how do I ensure my plugin loads before another one?
depend affects load order.softdepend just says load me anytime but I'd like this other plugin to be around
if you are not full depend you need to setup your access of any other softdepend after it has loaded
delayed from your onEnable
Well, it makes softdepend mega-ultra-useless I'd say
pretty much. but at least you don;t get any warnign messages about accessing a plugin you are not depend or softdepend on 😦
Mkay, whatever, thanks anyway
Can you show more of the log
Are you talking to me?
just show a different item to different players?
more context would be good
just listen for the pick up event, check a boolean, boom change it
Can use PDC to guarantee its the right item, etc
?pdc
Would you even needs to use packets for that Coll?
Woulden't using the event of the item leaving the inventory (one of the inventory events, cba to remember what one) be enough to do it?
PacketType.Play.Server.WINDOW_ITEMS, PacketType.Play.Server.SET_SLOT
You don’t need to use packets, no
But it does make it easier
For having the same item in one chest viewable by two people and them looking different you'd prob need to use packets
Why not lock items to a team on pickup and never change them? Much simpler
Yeah so you would want to use the packets Coll sent as far as I am aware; I'm not a person that messes with packets lol
Is there an easy way to set a tile block's PDC to a PDC object?
like, I have a container, set some values on it
then gotta update the block
basically a for loop to loop through the keys of one pdc and set the other ones keys
How can I check that a BoundingBox will fit in somewhere?
Lets say I have a 3x3x3 BoundingBox and I want to check if it can pass the door, how can I do that?
It's reading the last line from the textfile as "null", how do I fix it? @eternal oxide
Can I get the slot of an itemstack in p.getInventory().getContents()?
or whoever is available
yes. The array index
How?
the getContents returns an ItemStack[]
You’re reading a line, checking if it’s not null. Then you read the next line to append. You then read another line to check for not null. Read the next line for appending
You’re constantly alternating between reading a line for not null and reading a line for appending
So in that case, should I do (str = bufferedReader.readLine()) != null)
Yes
I ended up using .ready() like this
it's a good method
thank you though @ripe urchin !
Anyone know if its possible to make bees work at night and in rain with remaps?
?nohello
Help 🙂
String content = "";
String line;
while ((line = reader.readLine()) != null) {
content += line;
}
ur reading 2 lines at once in ur code
u were also losing half of ur lines
bump in #999803116243406929
pls my brain hurts lmao
StringBuilder
humorously enough, compiler usually converts it to that anyway
or at least it does for me
Not for older versions
How would I add combat tag to my plugin?
Trying to add a spigot build to a architectury project:
> Configure project :
Architect Plugin: 3.4.138
Architectury Loom: 0.11.0.275
> Configure project :common
architectury's common() is deprecated, use common(String... platforms) instead
> Configure project :spigot
fabric-installer.json not found in classpath!
> Task :spigot:compileJava FAILED
warning: Supported source version 'RELEASE_8' from annotation processor 'org.gradle.api.internal.tasks.compile.processing.TimeTrackingProcessor' less than -source '17'
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':spigot:compileJava'.
> java.lang.NoClassDefFoundError: org/objectweb/asm/tree/MethodNode
the only documented case of this error was using some weird forge bukkit hybrid which I suppose has a bad mixed classpath but it probaly should be different in this case
Bukkit.setCombatTag(30); // 30 seconds
oh
Fake news
Your question is pretty vague
If you're asking how to implement a combat tag feature, you can use a map to track the last time each player was damaged
Every time they are damaged, associate their UUID with the current time in a Map<UUID, Long>
Then when they log off you check it that timestamp in the map is <30 seconds ago (or whatever your combat tag duration is)
If it is, you kill them
thank you, I ended up just using .ready(), much simpler
oh, its that simple?
how could I get a material object from a string? 🙂
Material.valueOf
Material.getMaterial(String);
ty uwu
use getMaterial valueOf is a build in java method
oh
and you need to catch an exception to detect it was invalid
@waxen plinthwhat if they get damaged again?
is there a command here to see docs? xd
also for combat tag you may wanna do packet listening for certain player actions
like ?docs something ?
?jd-s
ty
it doesn't throw anything (?)
I thought it would xd
It throws NoSuchElementException if it's invalid
oh alright that's what I was wondering xd
You can get it as a string list
so I did
this.crafteables = new ArrayList<Material>();
for(String s: (List<String>) plugin.mainConfig.getList("Crafteables")) {
Material m = Material.getMaterial(s);
if(m != null) this.crafteables.add(m);
}
Then do this
you would getStringList on your config then forEach((line) -> Material.getMaterial(line));
null check before adding material
I'm still messed with forEach xd
true ty
List<Material> materials = list.stream().map(Material::getMaterial).toList();
hey burchard do you think you can help me with my problem from earlier
edited
is it possible to add filter for null values?
been banging my head against a wall for awhile
if so that would be poggers
.filter(s -> s != null)
List<Material> materials = list.stream().map(Material::getMaterial).filter(Objects::nonNull).toList();
bam
get codegolfed
one liner
I also have a config library you could use
for wut?
You just define a List<Material> and the library handles the rest
#999803116243406929 bump
RedLib comes with a hell of a lot more than just the config library
ty, might use it for another project, this thing is for tomorrow and I don't wanna mess the code more than needed hehe
But the config library is certainly very nice
Feel free to DM me if you need help with it, I also have a support discord server linked in the readme
just noted the link, will do c:
Can somebody critisize my new plugin, cause i needa fix my shitty code
https://github.com/horizonstudiosmc/horizon
just dm me some stuff. so i wake up and say, ya know what time it is
whats with these static variables in your main class
convert to dependency injection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Thx, btw
Will Player#setBedSpawnLocation() set the players default spawn?
Has anyone had an issue using line breaks on yaml files? xd
I got
regreso-iniciada: >
&e¡Bienvenid@ de vuelta &a{PLAYER}&e a SpainMC WW1!
\n&cSalir del juego durante la guerra puede hacer que no vuelvas, te quedan
but that \n is sent on mc literally as "\n" and not as a line break
wdym?
it shouldn't be a string?
Sooo im setting the honey level of a beehive, right
im setting it to its max and calling #update, it doesnt work
hiveData.setHoneyLevel(hiveData.getMaximumHoneyLevel());
enteredHiveBlock.update(true);
The code using that is...
event.getPlayer().sendMessage(Utils.color( joinStringReplace(plugin.mainConfig.getString("General.regreso-iniciada"),event.getPlayer())));
and joinStringReplace returns a String, what should it return then?
tbh I haven't worked with that but for some other stuff like item data and such you usually do Item.setMeta(myUpdatedMeta) or something like that, maybe you need to do that with the hive object you got (?) not sure tbh
The easiest way:
p.sendMessage(line1);
p.sendMessage(line2);
literally just said that 🤡 xd
I mean... yeah I guess
close enough
but that can have issues when the user gets the messages as
- my p.sendmsg(l1)
- someone sends a message in this right milisecond
- my p.sendmsg(l2)
show us the entire stack trace
not sure if glass was called STAINED_GLASS on 1.8.X

