#help-development
1 messages · Page 241 of 1
well, first delete your config.yml in your plugins folder
then try it again
saveDefaultConfig() simply writes your included config.yml to a file, unless it already exists
but if in the future I wannt to update the plugin, they have to remove their config.yml to make the updated one?
erm well, yeah
empty
Take a look at this https://www.spigotmc.org/threads/config-updater-include-comments.359358/
I believe for updates you would want to check with config.contains("key") and then use config.addDefault()?
is there something in src/main/resources/config.yml in the project
yes it is
this is how I update config files
where are you calling saveDefaultConfig?
in onEnable method
check that the config.yml is in the jar, it might be the compiler not including the config
it is
are you using maven?
yes
?paste
looks good. how did you compile? "mvn package"?
do "package"
not "compile"
"compile" only compiles the .java files but it doesnt put it into a .jar file
"package" is like "compile + put it into a .jar file"
how does this even work lol
why would it not work lol
i mean how does it actually save the new config
tbh I have no clue, but it works lol
I've written that a few years ago
iirc it cant copy stuff into a file that already exists
yeah
because the config it is trying to make already exists and it wont overwrite it
I'm removing it just to see if the comments displays in config.yml
But I'm deleting them and creating new ones
saveDefaultConfig() is nothing more than
if(!new File("config.yml").exists())) {
saveResource("config.yml", true);
}
and still
are you on windows?
yes
and that's also what it saves, right?
if so, everything's working?
looks fine to me
what mc version
1.19.2
im more confused
it's empty
because the spawn one appears once I create the spawnpoint
that works good
I Just want to know how I can put the #
show your onEnable() method pls
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
@Override
public void onEnable() {
Bukkit.getConsoleSender().sendMessage(name + ChatColor.GREEN + " It's now working correctly!.");
registerConfig();
registerCommand();
saveDefaultConfig();
thanks
what does "registerConfig()" do?
remove the registerConfig() method then see if it works
Sorry I deleted just the ko-fi thing just for preventing
there was a kofi link?
public void registerConfig(){
File config = new File(getDataFolder(), "config.yml");
configPath = config.getPath();
if (!config.exists()){
this.getConfig().options().copyDefaults(true);
saveConfig();
}
}
yeah, remove the call for that in the onEnable then see if it works
yeah
nice
the problem was that you saved the empty config before calling saveDefaultConfig()
And sorry for making probably dumb questions, but I'm try to learn java and minecraft dev at the same time
And since im newbie I have this dumb questions
Yeah, but sometimes when I ask
they do
?spoonfeeding
i dont remember the command
but ye
or ?learnjava lol
?spoonfeed ?
?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.
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
there you go
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. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
it mostly depends when you ask
spoonfeeding is indeed not that good, but you just asked a valid question, so if anyone uses this command, they are a jerk, lol
Because I'm not asking for a full code, I'm trying to manage by myself with that
Just little details that I don't know
to impove
btw
all good
to test more versions of the plugins
I have to create servers 1 by 1 and test them?
or there's another fastest way
test on the lower version you want to support
spoonfeeding is like
"how can I check if the block is a valid chest location?"
A valid answer should be "Just check if the block is air, if the block above is air too, and if the block below is solid."
A spoonfeeding answer would be
private static boolean isPossibleLocation(Block block) {
if(!block.getType().isAir()) return false; // Block above must be air
if(!block.getRelative(BlockFace.UP).getType().isAir()) return false; // Chest block must be air too
if(!block.getRelative(BlockFace.DOWN).getType().isSolid()) return false; // Block below must be solid
return true; // All good
}
and it should just be good to go
if theres nms you would need servers for each version
I have to add something in pom.xml to make it run in other versions?
no
if you want to support lets say 1.16 and higher just add 1.16 api and everything is backwards compatible
if you only use the API (if you have "spigot-api" in your pom instead of "spigot"), then it usually runs in every version just fine
For the moment I don't want to try with blocks and guis, looks very hard lol
Where I can find it?
in your pom.xml,. check the <dependency> section
and then check whether it says "spigot" or "spigot-api"
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Find it
looks good
yes, I was looking for it
it will probably run in every version
Okey okey
or did you specify an "api-version" in plugin.yml?
if you need or have multiple servers , i would recommend putting them all in separate folders in a central location with a bat looking something like
@echo off
set /p "param=Server: "
cd %param%
java -Xmx2048M -Xms1024M -DIReallyKnowWhatIAmDoingISwear -jar server.jar nogui```
and just name the folders versions
pls also show your plugin.yml @mystic terrace
name: SimpleSetSpawn
version: '${project.version}'
main: mrstreeet.simplesetspawn.SimpleSetSpawn
api-version: 1.19
authors: [ MrStreeet ]
description: A simple set spawn plugin.
commands:
simplesetspawn:
aliases: "sss"
permission: "simplesetspawn.admin"
description: Main command
setspawn:
description: Set world spawn point.
spawn:
description: Teleport to the world spawn point.
oh ok
you have "api-version: 1.19"
change that to 1.13 and then it will magically work in every version (even versions older than 1.13)
okey, thanks for that!
np
I don't know in which versions I want to make it, because it'll be my first plugin that I want to post
It's simple? yes
could be useful for ppl? I think so
And I want to add like particles and stuff
but idk
spigot will always check "is this server currently running a version that's equal or newer to what the plugin suggested in plugin.yml?" And if yes, it will try to run the plugin - if no, it will not do that. But before 1.13, it didn't read the "api-version" anyway. So yeah, just set it to 1.13
i have to learn a lot
we've all been at that point, all good lol
usually, you either want to make it work in "latest" or in 1.8 - latest
if you do not care about 1.8, then just go for 1.19.2
one tip ill give, dont say or want to do thinks you know you cant, do things you can then work up to them
+1
I will take the tip
https://blog.jeff-media.com/ and take a look at my blog lol
There's any possibilitty to add more than one permission in one command?
to make it like
you need this or this
in plugin.yml no, in code checking yes
if (sender.hasPermission("simplesetspawn.setspawn"))
for example
I have that one
there's any way to make it
you have this one or this one?
if (player.hasPerm(perm1) || player.hasPerm(perm2)) run
|| = or
&& = and
if I want to remove all of the mobs in a specific world on the start of the server or when my plugin enables, it gives me an error saying that bukkit cannot get world "nether" cus return value of bukkit.getworld("nether") is null this works in any other method besides the onenable (havent tried ondisable but that is not what i want)
how can I get this to work
nether isnt a world
does the server know that
if (p.hasPermission("simplesetspawn.setspawn") || p.hasPermission("simplesetspawn.admin"))
and it works in any other class
yeah
I dunno why I'm creating 2 permissions, only admins it's going to put setspawn commands
XD
I'm gonna make it more simple
oh also follow DRY
?
DRY = dont repeat yourself
might happen on some methods
because they have 2 different ways to be called but run the same code
I tested it on that but I am not using it
but im just saying how can I remove all mobs in a certain world on the enable of the plugin
the world does not exist
hi all help
cus I made it
it's usually called "world_nether"
[01:10:35 WARN]: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.RuntimeException: Unable to access address of buffer
at io.netty.channel.epoll.Native.read(Native Method) ~[patched_1.8.8.jar:git-PaperSpigot-445]
at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.doReadBytes(EpollSocketChannel.java:678) [patched_1.8.8.jar:git-PaperSpigot-445]
at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.epollInReady(EpollSocketChannel.java:714) [patched_1.8.8.jar:git-PaperSpigot-445]
at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe$3.run(EpollSocketChannel.java:755) [patched_1.8.8.jar:git-PaperSpigot-445]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) [patched_1.8.8.jar:git-PaperSpigot-445]
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:268) [patched_1.8.8.jar:git-PaperSpigot-445]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [patched_1.8.8.jar:git-PaperSpigot-445]
at java.lang.Thread.run(Thread.java:831) [?:?]
IK, I MADE IT LIKE THAT
is this the full stacktrace?
I renamed it
but you didnt load this world
help me plss
is this the full stacktrace?
I use a plugin called multiverse core to do it
pls wait translating your message
it seems like you try to access this world before it got laoded, right?
example being
command class without following dry:
public boolean onCommand(Stuff go here) {
if (sender.hasPermission(perm1) {
sender.sendMessage("You are sus");
}
if (sender.hasPermission(perm2) {
sender.sendMessage("You are sus");
}
}
Command class with following dry
public boolean onCommand(Stuff go here) {
if (sender instance of Player player) {
if (sender.hasPermission(perm1) {
sendSusMessage(player);
}
if (sender.hasPermission(perm2) {
sendSusMessage(player);
}
}
private void sendSusMessage(Player player) {
player.sendMessage("You are sus");
}
maybe idk
idk when it loads the worlds
I put it in on enable
yes
are you doing stuff regarding "nether" in onEnable() or onLoad() ?
yes
ok then you have 2 options:
- Either add Multiverse as "depend" in your plugin.yml
or
- Simply delay what you are doing by one tick
option 1 is probably better
yea, I tried delaying it, it did not work
but I delayed it like 4 secs
same thing
hmmm show your code pls
ill try to do depend
I tried it a while ago I dont have code from when I tried it but I could try it again
yes can i help ?
please show your onEnable() code
I have no clue about 1.8, your server version is literally 7 years old
I can only help you if you use a recent version
this is it rn
Holy
lmao
?paste ftw
ok so it complains about Bukkit.getWorld("nether") being null
show your plugin.yml pls
server for bedwars when ping the server Then it gives an error
problem for minecraft version ?
as said, I can not help you unless you upgrade your server to 1.19
okay try to add this:
depend:
- Multiverse-core
ok thx
a depend means your plugin will only load after that plugin has loaded, if that plugin does not exist your plugin will not load. If you use a soft-depend it means your plugin will load if that plugin does not exist but if that plugin does exist it will load after that plugin has loaded
ok thx
hm okay, gimme a sec pls
k
caps count xd
what would happen if 2 plugins depended on eachother
then you're fucked
lmao
it won't work, it will complain about "cyclic dependencies" or sth like that
wouldnt it just throw 2 errors and shut up
they would have to send them both like nanoseconds apart
[Plugin1] Could not load plugin 1 because of cyclic dependencies
[Plugin2] Could not load plugin 2 because plugin 1 isn't loaded
sth like this
I am not 1000% sure though, I never experienced this problem
yea uh this did not give any errors but does not kill
hm?
you cannot simply kill entities in unloaded chunks
that was not today
idk lol
was like a week ago
oh well then I was talking to someone else today
but I tried the thing that loads them
anyway, you either have to load the chunk, or edit the .dat files directly
oh wait I gotta load them in on enable xd
I loaded them 20 sec after server start
or plugin start
do you know the location of your piglins that you wanna kill?
yes
oki then you can just add a "plugin chunk ticket"
yep
declaration: package: org.bukkit, interface: Chunk
oh thats what I do
Example:
Location loc = new Location(Bukkit.getWorld("nether"), -21, 70, -69);
Chunk chunk = loc.getChunk();
chunk.addPluginChunkTicket(WildGamesSkyMining.getInstance());
Yeah wait
u gave me that like a week ago xd
getChunk() already loads the chunk
so you're already fine
you can simply delete the "chunk ticket" line
sure, but it will only work if you only need the chunk for like 1 tick
if you need to keep it loaded for more than one tick, then you indeed need the "chunk ticket"
🤨
I am like 99% sure that it should work just fine
should™️
if theres something im not 100% sure on i just say iirc or im pretty sure but i might be wrong
same, but in this case, I am really like 99% sure
that's why I said "I'm 99% sure" lol
ive only saidit like 61 times
n00b
and the first breakdown i had from it was about 12 hours later
whose?
bds
because I'm only in like 4 other discords
ya what
it broke on the 27th of september because discord changed typescript compiler
it didnt add anything that I need
I don't use plugins
I've never even installed one
I just wrote my own CSS from a template
all I miss from "normal" discord is to shut up messages from people I have blocked
it makes discord run somewhat quciker
doubt
also allows you to disable auto updater
well that's not an issue for me
yea discord optimization for me is not really a worry either
my cpu is pretty unaffected
my PC is quite beefy lol
My PC > MFnalex PC
maybe
alex is your name alex or jeff or something completely different
I can top this
fuck
who wants to guess the bottleneck on my pc
its not what you expect
yo thats your server
not a fair comparisson
🥲
its disk maxing out
next time please
damn
why do you use packets to send titles
are you using a 7 year old version of spigot?
what version do yo uuse?
this code looks 7 years old tbh
spigot has a method to send titles using the API
you can send titles directly
spigot has a method to send titles
no need for any "titles api"
declaration: package: org.bukkit.entity, interface: Player
this ^
this ^
this ^
I see, but what is the packet that is being sent behind the scenes, because I am trying to listen for that packet on a forge mod (unrelated to this server).
depends on your mappings
"PacketPlayOutTitle" in older versions
I don't know the name for recent versions since packets aren't needed anymore
ClientboundSetTitleTextPacket in 1..19
Where are you finding this information if you dont mind me asking? A link would be appreciated
tbh I simply googled "title spigot" for the 1.8 name,. and for 1.19 I just entered "Title" into my IDE and then checked it through
HOWEEEEVER
if you already know the old names, you can just check the mappings
?switchmappings
damn I didnt know
I just wrote those blog posts for fun, idk
its been sent in total 152 times
haha
nice
whenm I wrote thi sstuff, I never realized that other people will actually read it
lul
I send your nms blog all the time
lol
cuz I cbf to explain when someone already has
maybe I should add some ads lol
ublockorigin is the best adblocker
i have 4 adblockers
i have it
than delete the others
UBlockOrigin is super effective
I've not seen an ad in years
btw I just snacked some clonazepame so I might just pass out in the next few minutes lol
if i ever see ads i get another adblocker
some what
clonazepame
benzodiacepines
its a tranquilizer
drugs against anxiety
do you need them or just for the hell of it xD
Wtf are you using benzos for
Oh anxiety
But ur abusing them tho😂😂
Its not a tranquilizer lol
Benzos are addictive
most anxiety drugs are addictive
yeah, but I also drink every day, so......
and when I snack benzos, I always only take a tiny dose
Lmfao
you say snack when talking about medication lmfao
e.g. the normal pill for clonazepame is 2mg, I only took 0.5mg
haha yeah but maybe that's just "language issues"
I've never taken my anxiety meds
which ones did you get?
Xanax
i got prescribed melatonin but it wasnt enough and i cant swallow pills i managed to take it like 3 times
i havent used it since
haha I know that feel
you cannot snack it because you're afraid of suffocating and stuff, right?
why? My doctor didn't seem too concerned. I don't hold my meds
xanax is extremely addicting, and whenever you realize that you MIGHT be addicted, it's already too late
2:10am seems like a great time to sleep
xanax is horrible, pls don't use it
🤷🏽♂️ never had to so its whatever
you can keep it as "backup drugs" but just don'T use it every day
thats what they are for
I don't have a daily med
good :3
I am very aware of the medication. My younger brother takes it for muscle spasm. At low dosages it works as a muscle relaxer. Higher dosages for eplilepsi which he does have.
only time I've gotten close to taking them was when I was about to go to the ER, but I calmed myself down
xanax is alprazomale right?
yeah just keep it in the closet. as long as you don't take it everyday, everythihng's good lol
Baclofen works better for muscle relaxer then clonazepam does
whut
ahaha I'd never take a daily med for anxiety. I'd have an identity crisis
haha please tell this to "younger mfnalex"
I feel like i wouldn't be myself anymore even if its my anxious self
I literally cannot leave the house without being drunk or on drugs
it sucks D:
(and not in the good way)
Easy fix, don;t leave the house
Elgar is so smart
oh I was gonna say easy fix become unaddicted
but
I guess not leaving the house is easier
why did I even snack those drugs
so unnecessary
I dont even have to leave the house for the next 1.5 days
yeah anyway I'm going to sleep now
have a nice day everyone ❤️
bruh just knocked himself out
click on DamageCause in the javadoc
you will see them there
Thank you
I'm making sort of a packet log thing
for my server
and I need to save whether a player needs to be sent a certain packet
that they can toggle off with /filter
but im not gonna make like 20 different lists
and store players
idk how i would do it
There’s a good way?
Bro takes xannies tf u need help
Is there a way to see if a player is drinking a potion? I want to detect when they start drinking a potion, and ensure that they are still drinking the potion after x time. I tried to use the PlayerItemConsumeEvent and PlayerInteractEvent, however, neither of these can accomplish my task. When drinking the potion the player interact event only fires once, and the item consume event only fires after the potion is consumed. Any help would be greatly apperciated
I have the distinct feeling that someone somewhere would vehemently object to how I am building this code
You could use both
Whenever the interact is fired register in a map the player
Then whenever the consume fires remove it
If you continously register ticks in that time
You could get the drinking time
is there a way to make a furnace smelt faster for certain players?
declaration: package: org.bukkit.event.inventory, class: FurnaceStartSmeltEvent
#setTotalCookTime(int)
from this event
and the int should be in ticks
@quaint mantle
though this isn't a player event
it'll be a bit weird since a furnace smelting is not player-specific
its a block
ah ok
I'm getting a java.lang.IllegalStateException: zip file closed when making a reload command for my plugin
This is my code
Plugin pl = Bukkit.getPluginManager().getPlugin(Main.getInstance().getDescription().getName());
if(pl == null) {
player.sendMessage(UChat.component(error() + "&cUnable to reload plugin. Invalid plugin."));
return true;
}
Bukkit.getPluginManager().disablePlugin(pl);
Bukkit.getPluginManager().enablePlugin(pl);```
pl isn't null
I have a check for that
I guess I could add an attribute to the itemstack when the player places it in the furnace and check it on smelt
Full stack trace: https://hastebin.com/uvafizawuh.properties
Stay in #help-server
Multiple jars that you are shading contain the same file
It is Safe to ignore, in the worst Case you need to exclude those files
But don't ask how exclusions work - I am Not at my PC for a LONG (~6 hours) time now
i fixed the problem , ty
Any problem?
Hello , how i can check if a player recieve an item , iam not talking about PlayerPickUpItemEvent , iam talking about getting items from [chests all actions (Right click , left click , shift right click , shift left click), and pickup]
include me as author when taking over big parts pls
brr what was i doing: private static final Map<Class<?>, ThrowingBiFunction<Object, Connection, PreparedStatement, Exception>> STATEMENT_PREPARERS = new IdentityHashMap<>();
can anyone give me ideas xd?
Inventory drag event
are you sure xd?
ye I made something similar
bit simpler
you seem to abstract it a bit too much
Your whole Result class is just a stripped down optional
or a weird future
why the fuck is this erroring with ProtocolLib
Stole gif
erroring?
yes it was giving a nasty exception
pretty sure it was just my connection cutting out in the middle of packet sending
because working on 2G+ data
isn't the best
About the pojo thing
Could someone explain me how to properly shadow apis? ```plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java'
}
group 'pl.botprzemek'
version '0.1-REMASTERED'
repositories {
mavenCentral()
maven {
name = 'sonatype-oss-snapshots'
url = 'https://oss.sonatype.org/content/repositories/snapshots'
}
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
implementation 'net.kyori:adventure-api:4.12.0'
}
jar {
actions = []
dependsOn('shadowJar')
}
shadowJar {
relocate 'net.kyori:adventure-api:4.12.0', 'shadow.adventure-api'
minimize{
exclude(dependency 'org.spigotmc:spigot-api:.')
exclude(dependency 'org.spigotmc:spigot:.')
}
}```
Right now it's not working
Yooo guys SwapEvent doesn't called when player Press "F" in Inventory How can I cancel it?
on relocate 'net.kyori:adventure-api:4.12.0', 'shadow.adventure-api' you need the 'shadow.adventure-api' to be a package in your project like pl.botprzemek.libs.adventure
not that i last remember it doesnt
Yeah
the item swaps from main hand to off hand while an inventory is open?
Wait I'll upload the code with
@EventHandler
public void onMove(PlayerSwapHandItemsEvent e) {
Player player = e.getPlayer();
System.out.println("TEST");
if (!SkyExcelNetworkCosmeticMain.guiUtil.pageMap.containsKey(player) || !SkyExcelNetworkCosmeticMain.guiUtil.typeMap.containsKey(player)) return;
e.setCancelled(true);
}
It doesn't work
well is the player in pageMap or typeMap
does the client not like having air as the cursor item or smth
can it even get air on the cursor
im trying to and its ignoring the fact I tell it to set it to air
💀
so I have a shmol dupe issue
its probably because air isnt an actual item that can be obtained anywhere
try setting the cursor to null
I fixed it by setting that button ItemStack to air and telling the client not to cancel the click
now I created a button duper
AAAH
Ok
Ok
have the button their untill they click something in their inventory then set the button to nothing so they can put the item there
hmm the issue seems to only have been with shift clicking
easy fix
whenever I was holding a cursor item and shift clicking it stole the button
I just disabled shift clicking
dont have the button in the first place
[13:29:03 ERROR]: Could not load 'plugins\ZMP.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:178) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:155) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.loadPlugins(CraftServer.java:421) ~[paper-1.19.jar:git-Paper-81]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:278) ~[paper-1.19.jar:git-Paper-81]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1122) ~[paper-1.19.jar:git-Paper-81]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:303) ~[paper-1.19.jar:git-Paper-81]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more
i cant load my plugin
i have a plugin.yml tho
plugin.yml needs to be in resources
still needs to be in resources
yay now it works!
tysm
i have one more question tho
how do u make a book and quill gui open for a player?
i have nms
^^, the book and quill writing is client side
noo
but cant u open it and like save the text if u press done?
and how to do that?
Hi, I have a problem with my event not recognizing a player when creating a nether portal. The documentation says getEntity() returns the portal creator but it doesn't work
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Entity.getName()" because the return value of "org.bukkit.event.world.PortalCreateEvent.getEntity()" is null
event.getEntity() : Returns the Entity that triggered this portal creation (if available)
My code:
@EventHandler
public void createPortal(PortalCreateEvent event) {
if (event.getReason() == event.getReason().FIRE) {
Bukkit.getServer().broadcastMessage("Un portail a été allumé ! " + event.getEntity().getName());
}
}
declaration: package: org.bukkit.entity, interface: Player
== PortalCreateEvent.CreateReason.FIRE
and the Player is not always available in the event
bruh
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.
bruh but u can fr not do that??
there must me a way
I did not proofread myself sorry for my mistake
I just wanted to detect when a player creates a portal
basically what i wanted to do is create a profile system: u do /profile and it opens a writable book where u can put in ur profile, and then press done. another player can now do /profile <urname> and then see what u wrote there via a written book
Hello friends , what does InventoryDragEvent exactly do ?
declaration: package: org.bukkit.event.inventory, class: InventoryDragEvent
This event is called when the player drags an item in their cursor across the inventory. The ItemStack is distributed across the slots the HumanEntity dragged over. The method of distribution is described by the DragType returned by getType().
so just to be sure , this is a code i made to ask some questions :
1- from what i understand from this event i can use it to check for the inventory that i got items from ?
2- check for the specfic items ?
3- check for the amount ?
what iam trying to achieve , is a bit tricky to do :
when ever a player get 8 ENDER_PEARL , and he got 8 of it . the quest should be done , but only 1 time per game .
didn't we like have a discussion of this yesterday or day before?
I am pretty sure this was discussed already
yes but i didn't really understand the best way of achieve this
i hope you can explain the events i would need to use , one by one .. this quest is required ..
its the hardest one yet xd
all other quests , event side is done and its working
well it doesn't help that you seem to be a help vampire -.-
yes it seem , i didn't give a chance to other people to get help
iam sorry about that ..
That isn't what a help vampire is
oh dangt i need to to go out for 30 minutes xd
help vampire is someone who continuously asks for help and solutions from a community without giving anything in return
how do i make itemstack enum
anyways point is, you have been asking for help since 2021 from a simple search, have you not learned how to get over obstacles such as this or learned anything from the api that is at your disposal? o.O
Like try to attempt to solve your problem instead of continously asking for help till someone gives you code XD
killer you would not get hired anywhere
i am trying to slove it , but i want to know other people prespective ..
about how to do it diffrently
there is about 20 different ways you could solve this all with varying degrees of efficiency and what not
E
i feel like this might help https://www.spigotmc.org/threads/custom-itemstacks-with-enums.150158/
Enum.valueOf(itemStack), silly 😏
maybe? But like it might be better to ask why they need an ItemStack enum to begin with
like, you could just create your own Enums if you really need to lol
thats the smart thing to do
enums are kinda normal "final" classes, aren't they?
Records can too
kind of, they are more similar to constants if I remember right
Fun fact you Cant explitly extend Enum class
Learnt about arrays today smh
In essence, yes. It compiles down to this:
public final class MyEnum extends Enum<MyEnum> {
public static final MyEnum FIRST = new MyEnum("first", "second", 69);
public static final MyEnum SECOND = new MyEnum("third", "fourth", 420);
// etc.
}```
Im dissapointed that you cannot extend Enum<T> directly
Wanted to write a generic enum
why doesn't it get fired?
its custom inventory that Im placing that items into
Yeah but it just checks if there's an enum modifier and if the class extends Enum
InventoryMoveItemEvent is Called when some entity or block (e.g. hopper) tries to move items directly from one inventory to another.
you want inventory drag event
ah thx
I can't get Inventories from that event
I already do, but with failure
ofc you can
oh bcs im dumb
the InventoryDragEvent has a method getViews() or sth like that
oooh
then just get the upper inventory from that
the lower inventory is ALWAYS the player inv
I was checking for instance of Contairner
nvm
Buttons pressing would count as Action.RIGHT_CLICK_BLOCK in the PlayerInteractEvent right?
upper one is always the "actual" inv you are looking for
yes
Okay thx
np
sure but only if they clicked the top inv
after all, the player might also just click on the bottom inv
show the full stracktrace pls
?paste
Right here
that also wont reload your plugin
Well, how can I?
your .jar file is broken
does it work fine when you "properly" restart the server?
There’s no error when the server starts
okay then this is the issue
the /reload command is horribly broken and you cannot fix this from your end
just setting the plugin as disabled then enabled wont do anything
you should simply stop using /reload and instead always "properly" restart the server
that's all I can tell you
alex they have the code on their reload command on the message with their error lol
where? I havent seen it
this one
I can really the plug-in fine with plugman
Everything works
I'm wondering how intensive SQL is. If I'm storing player balance in a db and I'm updating it every time a player spends/earns money. Would that be slow?
this cannot possibly work. the PluginManager will return "null" when you try to get your plugin
https://ci.dmulloy2.net/job/ProtocolLib/lastStableBuild/
compileOnly group: "com.comphenix.protocol", name: "ProtocolLib", version: ?
how can I get the version for this build?
Well, how can I then?
If you wanna keep an instance of your plugin saved somewhere, do it like this: https://blog.jeff-media.com/getting-your-main-classes-instance-in-another-class/
latest on their github is 4.8.0
Oh right, Main.getInstance() is from a library I’m using
check their github or any other offical source
but thats not for mc 1.19 iirc
It’s returning the plug-in name fine
Who’s GitHub?
Oh you’re not talking to me
you would probably have to build it locally and use mavenLocal repo
or switch to maven which is way easier 😛
maven simply works, gradle always causes problems 😛
is it possible to make player see hitbox of light block without holding it?
Ah ok, every form of reloading my plug-in causes no errors except mine, and we already know what I was doing won’t work
thank you so much for that information ! 😄
Would it be possible to make a “anti air cannon” that detects a flying machine entering a designated area and spawns primed tnt on it? If so, would it be difficult to implement and would it potentially cause lag?
A lot of land protection plugins protect against pistons already. Spawning primed TNT on a flying machine would be more difficult, though.
?jd
oh my god
thank you xD
Can those plugins differentiate an incoming flying machine from, for example, an automated sugar cane farm in the claim?
Pretty sure they just don't allow pistons to push past claim borders.
usually they can only do it from within actually
Making a plugin is easy compared to releasing it
i would hope so
Creation is fun, publication and maintenance is not
or you dont give a shit and just place it on the forum
Open source gang
everything is open source if you try hard enough
Stadia moment
Hi, do you know if is it possible to "cancel a command event" to other plugins? (for example) if a user health is < 20, other plugins wont receive his chat commands
Yes, use the PlayerCommandPreprocessEvent.
declaration: package: org.bukkit.event.player, class: PlayerCommandPreprocessEvent
Sounds like something that giving a permission or removing it would solve
Right
Create a permission group for players below 20 health and create a check to assign players to that group when their health drops
Thanks!
I think using the event would be a lot easier than using permissions, not sure if one is objectively more efficient than the other though.
+1
Easier? Yes. Better? Depends on the application. If you want all commands cancelled sure. If you want only specific commands then no.
How long do you think it takes to become proficient with the spigot libraries and coding plugins?
They are entities
yeah it doesn't
but apparently we can do it in spigot ig
welp
life changing trust
me on my way to ?notworking you
Hey, how can I use a Java application to check if a new entry has been added to a MySQL database, or how can I generally communicate between Java applications? (pls ping)
That's only a headache because a for-loop solves that
add a timestamp to the table
Well you make an array and use a for loop to determine position.
The other number can be determined by powering
Idk if you can do 1e(3 * i) but that'd work
Ah no you'd have to .pow
Yeah, that
if you want more headaches look at the Math.pow impl

any 1?
fif sgsftds; the mdybiard lookx cool, ancjt us dcefijjtfely a henad turner
Don't take drugs kids youll end up like this mother fucker
hey, gibberish sentences are trademarked by me
Hello , i was thinking somethine like this might work ? check when i close the inventory ..
if the item is not ender pearl , return , if the player inventory dosen't have 8 pearl return
tried to do bubble sorting in college :{
we couldnt use Arrays.sort :(
so no clue what i was doing
++ we did have a computer subject in our college ,first stage , welp the doctor information was very old
like 2007 old ..
imagine that they still use windows 7 , in our college xd
our teacher is using smth ubuntu alike
that's really noice
v should just be i*3 not j. J doesn't need to exist.
you can then check if amount / v < 10 to know when you're good to format
Am i able to change block type inside a scheduleSyncDelayedTask?
Bukkit.getScheduler().scheduleSyncDelayedTask(JavaPlugin.getPlugin(Plugin.class), new Runnable() {
@Override
public void run() {
System.out.println("Block respawned");
block.setType(blockMaterial);
}
}, l);```
hi, basically what i wanted to do is create a profile system: u do /profile and it opens a writable book where u can put in ur profile, and then press done. another player can now do /profile <urname> and then see what u wrote there via a written book
is there a way open a writable book for a player with nms?
there is probably a better way but the only way i can think is give the player a book and quill and tell them to write in it in chat then listen to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerEditBookEvent.html and set the itemstack to null and get the data from inside it
declaration: package: org.bukkit.event.player, class: PlayerEditBookEvent
For the /profile command, I would save the data from a listener into a hashmap were the key is the player UUID and the value is a string. When you run the command it converts args[0] into a UUID and gets the string.
isnt there a lib for this?
How do I spawn boats of different types, such as acacia, spruce, etc?
wrong person to ask lol
no, i wanted to store the players profile in a perststent player data container
its easier lol
Yeah probably
What do you mean by this
Oh nbm I see
Each boat is it's own material type iirc
It is
Tho as usually my dumbass misunderstood
Unless there is some new api the type is in the nbt
AH! Thank you
That is it indeed!
Wait, no it isn't
I need an entitytype, not a material
,_,
@river oracle
then EntityType.BOAT
Guys, simple question. Can I have 2 different objectives in a single scoreboard method?
does anyone know why my plugin is not recognized in minecraft?
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
console sayin anything?
i do it on the server plugins folder but nothing happens
org.bukkit.plugin.InvalidPluginException: Cannot find main class `de.Matti'
Caused by: java.lang.ClassNotFoundException: de.Matti
cant find my class
thats not a valid path
why not
it needs the path after /src/main/java
it is
main: in your plugin.yml is wrong
how is it right
by not being wrong?
my plugin.yml is main: de.Matti
What is your package structure?
my bet you called your class Main and as such in your plugin.yml it would be yml main: de.Matti.Main
I also assume you upper cased your package
i once did that and since then ij refused to fix it
Package - path.class
How do i get the client version a player joined with? like 1.17, 1.19 etc
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: de/Matti/Main has been compiled by a more recent version of the Java Runtime (class file version 63.0), this version of the Java Runtime only recognizes class file versions up to 52.0
i have too new java?
What's your package name?
server is running outdated java ver
And Main
it is 1.8.9
Wtf
(in response to myself) or protocol versions
you built on a new version of java but your server is running 8?
idk
might just google number smh
1.8 moment
this?
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
is this it
maybe something like this? https://paste.md-5.net/yafefutino.cpp I haven't really tested it that much but I think it works
your server is using java 8 and youre trying to run a plugin compiled with java 19?
It's in the NBT of the entity. You might need an nbt api. However, you should prob further look around the api
dunno if mc 1.8 even supports jdk19
its home hosted
so the error is the jdk
right
Read the error
either compile your plugin with java8 or run your server with java 19 which i dont even know is possible
or 3) dont use mc 1.8
there is only 1.8 to 19
if you must use 1.8 set your java version to 1.8 or 1_8 in pom.xml
just 8
i thought 8 was major minor
thx
player.getInventory().setItem(0, new ItemStack(Material.IRON_SWORD,1));
im tryna make an item stack with a custom name
how would I do that?
Either work
this is my code so far
ItemMeta
itemmeta
no need for 1
ItemStack myItemStack = new ItemStack(Material.IRON_SWORD);
ItemMeta myItemMeta = myItemStack.getItemMeta();
myItemMeta.setDisplayName("my name");
myItemStack.setItemMeta(myItemMeta);
player.getInventory().setItem(0, myItemStack);
how do I use chat colors?
ChatColor.GREEN + "my string name" // This will be green
ChatColor.GREEN.toString() + ChatColor.BOLD + "my string name" // This will be green and bold
makes sense
thank you
im switching from visual bukkit to normal coding (if you know what that is)
so its a little bit difficult
whats visual bukkit
like visual coding its cool
so its like scratch?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I want to run a commend when a users clicks on a message in chat.
But this isn't clickable:
TextComponent line1 = new TextComponent("Test");
line1.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/say Hi"));
player.spigot().sendMessage(line1);
BETTERDSCORD