#help-development
1 messages · Page 2265 of 1
Problem here.. My PlayerJoinEvent can't be triggered, because the @urban grotto is not working in PlayerJoinEvent.java I wanted to fix it, but the file is readonly
happens when you view the files sometimes if you use the minecraft plugin to set it up, it shouldn’t cause an actual issue though
Annotations don’t enforce anything tho
your event not being triggered has nothing to do with that
They well… are not needed at runtime unlike other stuff
is your listener registered
package smpmenu.smpmenu.events;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import smpmenu.smpmenu.util.keys;
public class giveItem extends keys implements Listener {
private static final NamespacedKey protectedKey = getProtectedKey();
@EventHandler
public static void onPlayerJoin(PlayerJoinEvent e){
ItemStack i = e.getPlayer().getInventory().getItem(8);
System.out.println("here");
if(i == null){ //Possibility of main lobby
ItemStack item = new ItemStack(Material.COMPASS);
item.addUnsafeEnchantment(Enchantment.LURE,1);
ItemMeta m = item.getItemMeta();
/*Hiding Enchantments*/
m.addItemFlags(ItemFlag.HIDE_ENCHANTS);
/*Changing name*/
m.setDisplayName(ChatColor.BLUE + "SMP-MENU" + ChatColor.BOLD);
/*Modifying Persistent-Data-Container*/
m.getPersistentDataContainer().set(protectedKey, PersistentDataType.INTEGER,0);
/*Setting Item-Meta*/
item.setItemMeta(m);
System.out.println(item.getItemMeta().getPersistentDataContainer());
e.getPlayer().getInventory().setItem(8,item);
}
}
}
This is my code. I'm pretty sure it is
?conventions
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
and
do you register the listener with the plugin manager anywhere
for example
Bukkit.getPluginManager().registerEvents(new giveItem(), mainInstance);
ofc, sec
getServer().getPluginManager().registerEvents(new giveItem(),this);
In the main file onEnable
uhm
try making the onPlayerJoin not static
not sure if that changes anything but ight as well try
and please
name your classes with UpperCamelCase/PascalCase
Sure will. It's been a while since C#
Java != C#
ik
They are similar but far from identical
Since naming conventions are very different in the two of them
Java is more like a child shooting itself in the knee if you compare it to C#
Not really but C# does have a great set of features Java doesn’t have
Which is both advantageous and disadvantageous
Did that and got this one
Error occurred while enabling SmpMenu v1.0-SNAPSHOT (Is it up to date?)
java.lang.ExceptionInInitializerError: null
at smpmenu.smpmenu.SmpMenu.onEnable(SmpMenu.java:17) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:479) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugin(CraftServer.java:523) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.enablePlugins(CraftServer.java:437) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.reload(CraftServer.java:922) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at org.bukkit.Bukkit.reload(Bukkit.java:801) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand(CraftServer.java:831) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchServerCommand(CraftServer.java:816) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at net.minecraft.server.dedicated.DedicatedServer.bg(DedicatedServer.java:419) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:395) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1197) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:1010) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:291) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3545-Spigot-475f600-4230f8f]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.0.1-jre.jar:?]
at org.bukkit.NamespacedKey.<init>(NamespacedKey.java:72) ~[spigot-api-1.19-R0.1-SNAPSHOT.jar:?]
at smpmenu.smpmenu.util.keys.<clinit>(keys.java:11) ~[?:?]
... 18 more
😭
@hot wolf what's in util.keys, line 11
Send your SmpMenu class
Do you have NuVotifier on your compile class path? Also, is this a VoteListener or a VotifierEvent Listener? Also funny seeing you here.
package smpmenu.smpmenu.util;
import org.bukkit.NamespacedKey;
import org.bukkit.plugin.Plugin;
import smpmenu.smpmenu.SmpMenu;
public class keys {
private static final Plugin plugin = SmpMenu.getPlugin();
private static final NamespacedKey protectedKey = new NamespacedKey(plugin,"protectedKey");
public static NamespacedKey getProtectedKey(){
return protectedKey;
}
}
the
private static final NamespacedKey protectedKey = new NamespacedKey(plugin,"protectedKey);
i actually just tried to dm you,, can you dm me about this so that we aren't interrupting @hot wolf ? 😄
package smpmenu.smpmenu;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import smpmenu.smpmenu.events.giveItem;
import smpmenu.smpmenu.events.noInteract;
import smpmenu.smpmenu.events.openMenu;
public final class SmpMenu extends JavaPlugin {
private static Plugin plugin;
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("[Menu] Starting SmpMenu...");
getServer().getPluginManager().registerEvents(new giveItem(),this);
getServer().getPluginManager().registerEvents(new noInteract(),this);
getServer().getPluginManager().registerEvents(new openMenu(),this);
plugin = this;
System.out.println("v0.0.6");
System.out.println("[Menu] Started SmpMenu!");
}
@Override
public void onDisable() {
// Plugin shutdown logic
System.out.println("Stopping SmpMenu...");
System.out.println("Stopped SmpMenu!");
}
public static Plugin getPlugin(){
return plugin;
}
}
Here you go
The static portion of this class is probably being initialized before the plugin, which is throwing the NPE
Your fake singleton is null
As you never set the mono state to the plugin instance
You need in the beginning of onEnable plugin = this
Or well anytime before getPlugin() is used
public SmpMenu() { plugin = this; }
if you want that to work in the static portion, but that might not even work
Friend request me
oh, silly me
No you need to return as well in that case
"compile class path", i have NuVotifier in my pom.xml, and this is a VotifierEvent listener... i tried to import VoteListener but for some reason that isnt a valid import?
And it would be unnecessary initialization
Appreciate it. Gonna try that
why would you need to return from the constructor
You can't this in a static declaration
You can change bytecode to make a static variable with the same name altho that fucks up some stuff
And constructor is probably the best place to do that so you can init stuff before onLoad or onEnable are called
Well using a mono state is dirty to begin with anyway
Thanks guys! It worked now, should've seen that I used plugin even though it was null @ivory sleet xD
Well I’d partly blame Java for this
As nullability sucks in Java
But it’s nice that it’s fixed now :3
Null was a billion dollar mistake
Indeed
Don't even get me going on undefined lol
Isn't Optional only fully in the java official packages since like Java 17?
8
I think it was hanging out in javax before that
Hmm
Let me check the since tag
Ah ye since 1.8
Altho they did add a few more methods in more recent jdks
Maybe that's what I was seeing in the release notes.
bukkit inventory api would like to know your location
Oh don’t get me started lol
Yeah dw Optional still is kinda wacky (unless Java for some reason would magically fix the flaws of Optional)
Anyway Optional is good but Java didn’t really think when they added it so
They should pull the Scala model for Optional but functional programming is still scary to some Java folks.
As an aside, what's the consensus on opening PRs to add utility methods to bukkit/spigot?
is this channel for help with developing on the spigot/bc source tree or developing plugins for them
I think the answer to that is "yes"
lmao
whats the actual benefit of using Optional over != null?
cannot access com.google.gson.JsonDeserializer
class file for com.google.gson.JsonDeserializer not found
```Why is this happening? Shouldnt bungeecord depend on it?
It's more explicit about the fact that something can either be there or not
Maven shade gson it if you're using maven
ok then I shall ask away-
how do I configure maven to build two individual plugins with different main classes, etc. but while also sharing a common set of classes
eg. this would be ideal
📁 common
♨️ MyDataClass
📁 pluginA
♨️ PluginAMain
📁 pluginB
♨️ PluginBMain
where the output is two jars, PluginA & PluginB, where both have access to MyDataClass
🤔 alr
I can show you how to do this with subprojects in gradle
ye maven
alright I'll learn gradle that's fine
seems like the better build system anyways
shade common into both pluginA and B, mvn clean install common every time you make a change and then package the other 2 normally
I guess maven also has subprojects, you want a dependency on the common bit in each of the other subprojects.
https://maven.apache.org/guides/mini/guide-multiple-modules.html
what spigot/paper thing allows you to get the tier of the raid? I know there's something like spigot's RaidFinishEvent but i'm wondering how you get the tier of the completed raid
Create 3 modules and let PluginA and PluginB depend on / shade in common.
Then either create a script that goes into module A and B and builds them or use your parent pom to build those modules
event.getRaid().getBadOmenLevel()?
alright I need to do a lot of reading, thanks for the help everyone
I'll look up how to shade my own dependencies
ty
I mean non of my classes are importing gson at all - I call a method of bungeecord which does and the build fails right away
Is there a fuller error?
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project someproject: Compilation failure
[ERROR] someclass cannot access com.google.gson.JsonDeserializer
[ERROR] class file for com.google.gson.JsonDeserializer not found
not really a lot info ig
Do you have gson added to your project
wait ill run -e
no since bungeecord should
and bungeecord is provided later but i guess maven doesnt get that
i'm quite new to spigot, how would I get the player through this for loop?
and if i'm doing something wrong (which I probably am) please tell me
I dont think bungeecord has gson
Your variable name is plr not player
Your variable is plr
I tried plr but it didn't work either.
net.md_5.bungee.chat.ComponentSerializer
Also your loop is useless. It wont do anything ever because its closed right away
It still gives the same result.
@lost matrix
^ because of this
you don't open your for-loop with {}
it ends immediately with a e.getWinners());
Thats not part of bungeecord. Thats part of bungeecord-chat
And that will be provided later if I am writing a bungeecord plugin, will it not?
Lets see if you realise it ^^
Ok here is the solution: Depend on bungeecord-chat in your pom.xml
yea
alright
whats going on with NuVotifier's maven repo
i just got that bruh, thankyou 👍
🧠 moment
Well you explícate the nullability in types rather than the values of variables
You know in Java virtually everything can be null
if(Java == null){ return; }
If we strictly only allow Optionals to represent maybe values we can much safer guarantee the correctness of our program’s behavior
Optional gives you another way to handle null values.
If done right it will prevent almost all nullpointer exceptions.
But you have to be very consistent.
The main issue with Optional is the fact that there’s no subtype for guaranteed present optional contra guaranteed absent optional
And it great for functional programming
Which kotlin for instance have incorporated
Or well if you look at sth like Haskell they have iirc a Maybe monad or sth
Or rust with their Option thing
Scala has a really cool functional Some/None.
Yeah
Yeah in java you would have to do runtime assertions like
public void someStuff(Optional<String> optName) {
Preconditions.checkArgument(optName.present());
}
Yeah
Not as cool as compile time checks
Guess it suffices
Are there jetbrains annotations for that? Let me check.
Tho in Java having Optional in parameters is considered an anti pattern
I bet you could come up with a subclass-based optional that you can do compile-time checking on
Mainly because it’s suboptimal due to concepts like type erasure which collided with method overloading
Optional is final
Build your own Optional
That's what the Arrow libraries did, it seemed to work out for them
And throw away any compatability with javas built-in methods
.toJavaOption() 😉
The error still appears 😕
Hm... Show your pom pls.
working with bungee is a bit of a mess sometimes
Hm. Invalidate caches, restart, and try again.
I really can't work with maven well... is it possible for someone to make/link me to an example of this with a minimum working pom.xml?
And then generate a dependency diagram to see if gson is in there
If you get the minecraft dev plugin for intellij and generate a new spigot plugin then it generates a clean maven/gradle (your choice) plugin.
wdym?
Are you using intellij?
no
Ok. Then both of those proposals wont work out for you...
indeed
Does you IDE support generating a dependency tree? Or at least reinitializing your maven project?
let me check
Btw why do you have spigot and bungeecord as a dependency?
Also spigot provides gson at compile time
Because its a plugin both for spigot and bungeecord
Your exception makes no sense then...
Here is the tree: https://paste.md-5.net/hijicehaba.rb
yk what else makes no sense? the NuVotifier maven dependencies
im heated about this
Whats wrong with them?
I dont see gson in there... But why?
second line
they just dont work?
Oh i see
i cant necessarily explain it (not an expert).. but their developer documentation is completely wrong, and it seems other people also have issues with their maven stuff
Did you try a mvn clean install?
You know what they say about code compilation. 10001 is the charm
Well this sucks. Have you tried turning it off and on again?
'it' referring to everything. Your IDE, your pc...
well if I remove that one line of code it indeed works
Which one
could restart my pc tho
the line accessing ComponentSerializer
Well with all due respect they always end up being suboptimal, not that it always matters but yeah, if Java ever would add something like trait interfaces doing this could be a viable solution
Lets not overwhelm oracle. I wanna get valhalla this decade.
Lmao
Yeah once we get valhalla and loom fully delivered the world will be in full harmony
Done. The error is still present. Probably going to quit programming at this point :kappa:
You have only one pom, right?
yes
Add a line
Class<JsonDeserializer> ignored = JsonDeserializer.class;
Somewhere in your code.
JsonDeserializer cannot be resolved to a type 😶
Your IDE is trolling you...
This error:
[09:42:59 ERROR]: Error occurred while enabling GeneralPlugin v1.0-SNAPSHOT (Is it up to date?)
I was told that this was cause by messing up the commands but I get this error and I have no commands
(Sorry for butting in)
Its right there
Full exception pls
Run mvn dependency:list -X
Build success
You need to shade in the discord bot library you are using. Or you tell spigot to download it in your plugin.yml-
Any warnings?
no, clean install still fails
You are using the terminal, right?
yep
And ls shows your pom
where?
cries in Windows
I made a macro for ls... whats the equivalent again?
dir
Does anyone know, how I can get a Player, in a listener. If the player is defined in a command?
powershell aliases ls to dir, but normal cmd nah
Never define a listener in a command
yes
I merged the two pom.xml so it should work but I'll test it
no, i dont mean that
I mean i defined a player in a command and wanna get the player in a listener
Well... the last thing i could think of is that your heap is not big enough.
Define a bigger one:
export MAVEN_OPTS='-Xms384M -Xmx512M -XX:MaxPermSize=256M'
store the Player (or MUCH rather their UUID) to a field and then access that field from the Listener
How do i do that lmao?
This sounds like someone needs to visit the basics again. Did you jump right into spigot or did you learn the java basics first?
where do i put that?
In your terminal?
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.
dont have export lol
Usually you have a common singleton class.
And both your command and listener class have the singleton instance.
This way both have a common space for modifications.
hi, in the plugin i am making, my config.yml file would look something like this
thing1:
key: 1234
thing2:
key: 12345
thing3:
key: 123456
where the user and add as many "thing" configuration sections as they wish with unique names. How would I iterate through all the present configuration sections and add the name of each section (e.g. thing1, thing2, etc.) to an array / list ?
idk... Use SET instead of export.
you get the layer the things are in then just do for(String s : section.getkeys(false))
alternatively just use the getKeys(false) set
yeah windows is SET
I created too many aliases...
Well i got wsl2 because of docker... could actually use it
hmm
Where can this type of data be stored?
List<List<Block>>
I want to store it in Map, because I need to get an array by key
Define "stored". Memory or persistent space?
I've that yet I still get the same error
If it is possible to store not in RAM, then I want to hear how to do it please
Ima just give up lmfao
convert object to string, save string to file
You cant persist blocks. Only BlockData and a Location.
idk why i was expecting this diagram to be a lot more intense but its literally just do u need key value pairs? no? will it have duplicates? nah? okay
Invalid initial heap size: -Xms384M -Xmx512M -XX:MaxPermSize=256M @lost matrix
fuck
theres a library tho
Just tell us your overall plan. Im thinking this is a xy problem.
?xy
Asking about your attempted solution rather than your actual problem
How are you compiling your plugin?
"im building artifacts" incoming
there will be a lot of blocks
xdddd
unless you need to access the data outside of whatever functionality includes the blocks you should use this
For once I'm not, I double tap Ctrl then mvn package
im so happy i finally switched to actually using gradle and maven
about 1000 in one array, and there are 20 of them. But there will also be several such arrays of 20, about 100
Instead of handling the event how about you handle some bitches
good
I learnt lmfao
hm, do players get sent block PDC? I dont think so right?
Then show us your pom pls
do you know this 7?
Is there any other way that is better than doing this, seems a bit unnecessary
maven is 💜 bc u dont need a gradle wrapper in each project
Yes they do. They get the full nbt data which contains the pdc.
does anybody have any ideas on how to do this? ^^^
ah uh oh
yesterday they tried to help me on different discord servers, they checked for null objects, debugged the code and in the end did not help
i need to rewrite stuff now
- get section 2) do section.getKeys(false) and use that set
i already told you that tho
Generation and the server stupidly freezes when I try to pull something out of the block or print it, the same thing if you print any of the arrays
oh sorry i didnt see your message
You could create a generic proxy class for this.
Pls explain what you are trying to do.
Gives me Unrecognized VM option 'MaxPermSize=256M' and if I remove MaxPermSize, the error is still there. @lost matrix
Copy random from 20 chunks by coordinates and paste it during generation
Oh yeah MaxPermSize was removed from the jvm.
say what now
Where are the 20 chunks coming from?
from world "build" it is loaded and these 20 chunks too, before using
annoc.setConfiguration(this.getConfig()).wrapClass(Config.class).load();```
😎
still need to think about how i would handle memorysections but i think i generalized it enough
I cant make any sense of that sentence.
So you have a world called "build" and you select 20 random chunks from this world.
And the generator you use on a different world uses those 20 chunks?
is there any way to set motd's mark like this?
Looks good. Should work.
Do a mvn clean install and try again.
No, I choose a random chunk out of 20 loaded and the generation should be use him
o.O?
Ok so you have a world "build"
The world "build" uses your custom generator.
Your world "build" already has pregenerated chunks (somehow)
Your custom generator chooses several of those already generated chunks and copies them.
Right?
yes
Yes, and uses when generating the second world
But I myself build these 20 chunks in the "build" world. I just load the world with another plugin before generating the second world with my generator
Oh ok. So there is a second world involved.
Thats new information. So the world "build" does not use your custom generator. Only the "second" world.
u probably already answered this but, are u sure u used the uberjar'd plugin on the server?
Yes!!!
(typically called like -fat, -uber, -full, -shaded, etc)
Uberjar?
how
basically the jar with ur dependencies shaded in
I didn't use the shaded
its usually the larger jar in target/ folder
I was told to never use the shaded or original
yeah the bigger jar is the one that actually has ur depends included
dont forget to relocate them :3 conflicts suck
Ok. Then lets do this step by step.
The first thing you need are those chunks.
I would suggest that you get the ChunkSnapshots when the server starts.
List<ChunkSnapshot> snapshotList = new ArrayList<>();
World world = Bukkit.getWorld("build");
Preconditions.checkState(world != null);
for(int x = -4; x <= 4; x++) {
for(int z = -4; z <= 4; z++) {
snapshotList.add(world.getChunkAt(x, z).getChunkSnapshot());
}
}
You need to do this after your world is loaded.
I outplayed maven with reflections now. Still, this error is really dumb
PlayerServer
hmm, okay
It is. Never had this before. But im also using an IDE that is half decent.
ty
I agree
Ah yes. Why not just call it p. Much shorter and even more ambiguous.
made.
p is Player already
bukit player 😛
🤦
cheese pizza and sausage pizza
LOOOOL
how?
ok, what next?
@old cloud sorry im very lazy and dont like looking up in chat, can u summarize ur maven issue rn
missing Gson right?
Create a method that you can use which randomly chooses one of those ChunkSnapshots
how do i get the player who thrown the projectile from ProjectileHitEvent
?jd-s
Projectile#getSource()
And check for instanceof Player
getShooter no?
can i send picture in dm?
Im taken
Well I have one line in my code that accesses ComponentSerializer from bungeecord-chat. When I do mvn clean install, it gives me an compilation error because gson is missing, which is in bungeecord-chat tho, which is in my pom.
witches
Dispenser
does throwing items count as a projectile
public ChunkSnapshot getRandomChunkSnapshot() {
return snapshotList.get(ThreadLocalRandom.current().nextInt(snapshotList.size()));
}
what about the player the projectile hit
getEntity()?
Yes
according to bukkit just about anything can launch a projectile
spider??
Those are all projectiles
WaterMob, what a fuckin class jame
i just woke up 
ok, i modifed it and sended you
i mean if want everything that naturally can launch a projectile its a lot less
llama spit 😰
player, wither, dragon, shulker, skeleton, snowman, llama, illager, dispenser
Create a plugin that has a /spit command so you can assault other players by spitting on them XD
off the top of my head at least
when my projectile hits a player it keeps returning false
Code pls
do it on sneak
event.getEntity() instanceof Player
LOL
added to my todo list 😂
PlayerToggleSneakEvent if sneaking, spit
Well the projectile is for sure not a Player
So this is expected to be false
or if sneaking and swings arm, spit
oh wait getEntity is the item im throwing?
howw?
nah do it with head movement
Its any projectile that every hits anything
what head movement is a spit
how would i get the player it hits or something
something something ServerListPingEvent
?jd-s
Why do you need a map for that?
I will have several worlds, not only "game"
i know that event
but how to change it?
declaration: package: org.bukkit.event.entity, class: ProjectileHitEvent
But they all use the same chunks, right?
dangerous
mods pls delete
well, not really, there will be ~20 chunks for each world
but all chunks will be taken from the "build" world
But those 20 chunks will all be taken from "build", right?
yea
And they will be the same?
Not
Ah oke
Ok your code looks good so far.
All you need to do now is use the snapshot in your generator.
You can iterate through the snapshot (x, y, z) and get all the block data from there.
how to do it right?
ProjectileHitEvent doesnt have getHitEntity after i type event
Pls dont type ProjectileHitEvent.getHitEntity()...
no i was typing event.getHitEntity()
No problem then.
by the way my map looks like this
Wrong event probably
?paste ur class
No comment on this. I would follow GodCiphers actions and quickly add a spoiler before a mod sees this.
I'm 99% convinced its possible to place shulkers off-axis. Can anyone give me a hint as to how?
I'm an idiot?
No. Just lacking a bit of experience i suppose.
what happens when u control+click on ProjectileHitEvent in ur ide
takes me too projectileHitEvent.java
only has getEntity getHandles and getHandlerList
does that have a getHitEntity
Nop
hm
It looks usable. Now go into your generator and get the ChunkSnapshot in your "generateNoise" method implementation.
Not possible.
I cant send a ss or i would
interesting missing package
i think when i started the project i put it to 1.19
Also
event.getEntity().toString() == "CraftSnowball"
This will always be false.
- Never compare objects using
==unless they are primitives or enums - Dont use a String here at all. Use instanceof or
getType() == EntityType.SNOWBALL
it works for me
(I do have to applaud the concept of a backrooms generator plugin btw)
only logged something when i threw a snowball
No it doesnt
It is suitable?
Yeah looks fine
wym i just installed it default
ok, I am building a project
well it did for me only logged a msg once i threw a snowball
if i do Bukkit.reload(), will it reload every plugin? or only the one that this line is in
i think that reloads the server, why in gods name do u need to call that
It will slap you in the face because reloading is not supported and even strongly discouraged.
I'm not sure if bukkit.block offers anything more effecient than a triple for loop. But what you have should at least work yes.
XD
well, because for some reason i cant reach an new added part of the yml, unless i reload the plugin
so therefore i will have to realod it
Most plugins break on reload. You can get a plugin manager and try enable/disable individual ones though
JavaPlugin has a method for reloading your yml
.
and that is?
BeeMe are you using someone else's plugin or making your own?
making my own
They are just entities, right? What happens if you just place them at a random location. Do they snap in the grid?
https://paste.md-5.net/aboxucokad.java weird, i have the full event in my spigot-api
when i installed i put the version to 1.19 is that why
In your main file, you want this.saveDefaultConfig then this.reloadConfig
JavaPlugin#reloadConfig()
This will reload the config you are getting with JavaPlugin#getConfig()
Just make sure to actually call getConfig() so you get the updated one.
loc.getWorld().spawnEntity(loc, EntityType.SHULKER)```
unfortunately yes
i mean i could do some insanity with boats but i really dont want to do that
thnx, i will try that
This might be hard coded in nms. You might need to extend the nms shulker and edit it.
is it possible to get the skin texture and signature of a player without referencing the mojang api?
Well you can extend every entitiy and overwrite any method.
Everything hangs on line 22, the "game" world is generated first than the "build" as you said
Yes
but the server would still consider it a nms shulker entity and snap it back right?
How?
no im also on 1.19 spigot api
Extended entity would still have same namespace id correct?
PlayerTextures textures = player.getPlayerProfile().getTextures();
oo
amazing, this works like a charm
Sure. You still need to overwrite the vanilla entity in the Registry
CraftPlayer right?
7smile7?
Nope. Just plain old spigot Player.
Buu….tt == is faster
Do you get an exception?
No
oh well could of it been where i installed the spigot jar file from
What do you mean by "hangs" then?
I dont see any methods for getting the signature and texture?
server freezes
Create a gist or paste pls. You are probably using a world before it is loaded.
What do you need the texture and signature for?
Yes, I do. Did you tell me so?
Adding a skin to a custom game profile
Then just get the PlayerTextures and call PlayerProfile#setTextures() on your custom profile...
funny story
I'm using game profiles
public PlayerProfile copyWithTextures(Player player) {
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID());
PlayerTextures textures = player.getPlayerProfile().getTextures();
profile.setTextures(textures);
return profile;
}
where was it from?
Why?
u should always use the official spigot nexus repo
well
tf
If you keep posting this site you gonna get banned soon
soooooooo i now have a completely different issue. I want to get the shulker nms instance but i also need to stop its ai, but i cant import both bukkit shulker and nms shulker at once
GENERATION WORKS! THANK YOU BROOOO!
I LOVE YOU!
It is completely illegal
good
oh is that why it doesnt exist then probably
tf is this ide background.
How do you even make a new PlayerProfile
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i mean in the end it still doesnt make sense as to why your event was bare
but definitely use the official source
Through Server/Bukkit
ive seen better worse
talkin some big anime tiddies in the background
:?
Server::createPlayerProfile or sth
so anyways imports blocking each other?
i see
Bukkit.createPlayerProfile(UUID.randomUUID());
if u supply a registered uuid does it just use a real profile lolz
im not dumb enough to have a background like that where people could see it
please what argument is 'pp'
PlayerProfile
oh player profile
oh wait
peppa pig
its okay im just here to bully everyone while i actually secretly write the worst code someone could ever lay eyes on
lmfao
for gods sake does ANYONE here know how to solve this
pick one or the other
gonna have to use one the obnoxious way
aka fully qualified path to it every line u use it on
that still wont help if i cant import it
yes it will
it does
u wont need to import it then
you dont actually import it
If you want to use Both you have to use teh fully qualified name in code for one of them. You can;t import both
org.bukkit.entity.Shulker shulker = //whatever;
works
probs want to use the bukkit as fully qualified as it's shorter
k noted thanks though now i want to know how imports work
id say whichever one is used less should be used as FQN
java is fun
(literal torture)
theres also static imports, theyre something.
well think about it, if you have two imports with the same name, and you try to do something like:
Shulker shulker = new Shulker();
how would it know which one to use
getHandle() ?
big mistake picking it as my first language
ha, same
Java and JS are my top 2 languages, please kill me
i learned js for the web developement phase
id rather be it support
than a web developer
oh what u think i learned it for Node? fuck no
only reason i used node was for discord.js 
might need more context here
i used it once for a minecraft bot
OO that framework is rlly cool
ive never worked with NMS, i was just taking a guess
well i remember using get handle for this once but i cant recall what i actually wrote
i need org.bukkit.entity.Shulker to net.minecraft.world.entity.monster.Shulker
so cast to craftshulker first?
(Bukkit)Shulker -> CraftShulker -> (NMS)Shulker
so like Shulker nmsShulker = ((CraftShulker) bukkitShulker).getHandle().
i think
is there a way to use Components within a container title?
I know Paper supports
idk if spigot does
as long as it can be converted to whatever format spigot needs id imagine so
takes string
yea that works
translatable components can be converted to string?
i feel like thatd break
ill try tho
idk
so im basically trying to create a method which i can use like
anyEquals(x -> x < 5)```
But the operator < can't be applied to a generic. how can i do something like T extends Number
Now I have a problem, my lamps are activated by the redstone block, but they are turned off when generating
update physics when placing them
eh, additional load on generation
to my knowledge setting the state is faster than updating physics
LFMAO
rotation got applied twice
reverse worm?
smt like taht
jesus fuck
i just tried to make a dead body
uh tf is this error
- [Sat 13:11:10 ERROR Server/PlayerConnection] null
i didnt even know u could put entities horizontal
didn't also what the neck to be dead
npc.setPose(Pose.SLEEPING);
ok, but how do i activate the lamp?
:smart:
bump lol
get block as RedstoneLap and do lamp.setLit(true)
any clue why this works in code but not on the server
java.lang.NoSuchMethodError: 'net.minecraft.world.entity.monster.Shulker org.bukkit.craftbukkit.v1_19_R1.entity.CraftShulker.getHandle()'
wrong version?
im on 1.19
honestly no clue, maybe u need to remap the plugin jar on compile?
that part i dont know how to do at all
wait
is this bad? java for (ConfigurationSection configSection : ConfigUtil.getConfigurationSections(config)) { for (String configurationSection : configSection.getKeys(false)) { if (!config.contains(configurationSection)) { Logger.warn(configSection + " is missing an entry: " + configurationSection); } Object value = configSection.get(configurationSection); configSettings.put(configurationSection, value); } } return new TweakData(tpsHaltAt, notifyAdmin, mobCap, allowJoinWhileHalted, maxSpeed, configSettings.get("haltExplosions"), configSettings.get("haltRedstone"), configSettings.get("haltChunkLoading"), configSettings.get("haltMobSpawning"), configSettings.get("haltInventoryMovement"), configSettings.get("haltCommandBlock"), configSettings.get("haltProjectiles"), configSettings.get("haltEntityBreeding"), configSettings.get("haltEntityInteractions"), configSettings.get("haltEntityTargeting"), configSettings.get("vehicleCollisions"), configSettings.get("blockPhysics"), configSettings.get("use_mail_server"), configSettings.get("mail_server_host"), configSettings.get("mail_server_port"), configSettings.get("mail_server_username"), configSettings.get("mail_server_password"), configSettings.get("recipients"));
hu
seriously its not that big
it took up my whole phone screen 💔
lol saw it coming
it took up my entire monitor
stop using the iphone 2
It took out a small city
bruh what do you all have such small screens
smh
My screen thicc but your text thiccer
cuz we want to read the text from further than 10 cm away
yes
anyways
yes
BlockRedstoneLamp / RedstoneLamp doesnt exists
how can I optimise that?
how bout CraftRedstoneLamp
but I kinda hate it
The code is unreadable tbh. It's a headache to put together
use more variables
same
?
doesnt exists
more variables, sounds like a great solution
1.16
it's probs set material to REDSTONE_LAMP_LIT or something then
LEGACY_REDSTONE_LAMP_LIT
but it deprecated
in that case, get block data, cast to lightable and set it lit
uh which remapped file was the right again? remapped-obf or just remapped?
another bump 😔
do <T extends Number>
Operator '<' cannot be applied to 'java.lang.Number', 'int'
What exactly do you want x to be? An integer?
BigDecimal value = new BigDecimal( inputNumber.toString() );
ok lemme explain better:
I want the method to allow for any type of numeric value that i can apply the less that operator to
Number#doubleValue
wait
why dont u just use normal anyMatch
Yea, then instead of T just use either Double or still <T extends Number> and you do x -> x.doubleValue() < 5
whats the point in creating anyEquals
its not equals i just didnt rename it
its applying a condition to a list of numbers
so... anyMatch?
ye
np lol
okay so slightly more in context, should i do this in any other way?
bit of an xy
well i would do <= 0 if ur saying 0 or less
some people might say dont use streams api but idk looks fine to me
they mean the api
when they were released in java 8 their performance was kinda crap
did you get your skins sorted?
i think thats java and not guava yeah
god i just realized guava rhymes with java
I've just been playing with them myself. Just got an NPC to spawn with a two layer skin. Is nice
i hate google
how do i gett the current nms version, ie 1.19_R1
lmao
show me your ways
mine only have 1 layer

one sec
pretty sure bukkit or something has a getVersion u can use
?jd-s
?paste
bruh
For this code, what can I do to make it more optimized? https://paste.md-5.net/oyijozeveg.cs
?stash
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
?selfrole Admin
Role "Admin" not found.
I worked from thsi thread I found quite useful. Its not quite right but it got me there https://www.spigotmc.org/threads/nms-serverplayer-entityplayer-for-the-1-17-1-18-mojang-mappings-with-fall-damage-and-knockback.551281/
how do i even remoevd the nametag of an npc
can you ban an npc lol
https://i.imgur.com/XuqRj2k.png
this is what happens when i try to convert a component to a string in the container GUI
nolol
So I can spawn an NPC as simply as NPCFactory.createNPC(loc, "ThisIsATest", NPCFactory.skin);
lemme try
Have you tried with the custom name?
lmao
pretty sure player nametag will always try to draw something
rip
yucky
maybe move the nametag somewhere else
is that possible
idk how teams work but scoreboard teams can remove the
yeah
you can add the npc to a team
ohh
i see
Yeah that would work
yup
hi guys, i have such a method and it returns true for OP, even if the OP doesnt have the perm. i was hoping it to be false
public boolean hasPermission(Player player, String permission) { return player.hasPermission(new Permission(permission, PermissionDefault.FALSE)); }
op has all perms
you can check if they have op
so default: false wont help?
and do stuff accordingly
I didn;t have to do your delay ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER
I have to delay it 5ticks
or no skin
😦
all I did after creating and spawning is ```java
private static void showAll(Npc npc) {
ClientboundPlayerInfoPacket playerInfoAdd = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc);
ClientboundAddPlayerPacket namedEntitySpawn = new ClientboundAddPlayerPacket(npc);
ClientboundRotateHeadPacket headRotation = new ClientboundRotateHeadPacket(npc, (byte) ((npc.getBukkitYaw() * 256f) / 360f));
ClientboundPlayerInfoPacket playerInfoRemove = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER);
for (Player player : Bukkit.getOnlinePlayers()) {
ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection;
connection.send(playerInfoAdd); // Inform client this Entity exists.
connection.send(namedEntitySpawn); // Spawn this entity on the client.
connection.send(headRotation);
connection.send(playerInfoRemove); // Remove from servers tab list
}
}```
mmm yes i understand
I commented each packet
mmmmmmm
lmao
in your Fake PLayer this.getEntityData().set(Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0xFF);
byte oh god
enables the second texture layer
public void setSkin(String[] skin) {
String texture = skin[0];
String signature = skin[1];
this.getGameProfile().getProperties().put("textures", new Property("textures", texture, signature));
// Enable the second layer of the ServerPlayer's skin
this.getEntityData().set(Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0xFF);
}```
org.bukkit.scoreboard.Scoreboard scoreboard = player.getScoreboard();
Team npcs = null;
for(Team team : scoreboard.getTeams()) {
if(team.getName().equals("npcs")) {
npcs = team;
break;
}
}
if(npcs == null) {
npcs = scoreboard.registerNewTeam("npcs");
}
npcs.setNameTagVisibility(NameTagVisibility.NEVER);
npcs.addEntry(npcName);
this is @carmine nacelle 's code but this maybe work
are thses mojang mappings
how to activate redstone lamp in generateChunkData?
yes
get object and update state or something
Why use a custom set skin method? Doesn't PlayerProfiles do that now?
very slow
use it in the class which extends ServerPlayer
how many are you doing ?
im not doing that
Currently this is early 1.18 code for Fake Players thats still alot of NMS
getBlock().setType(Material.REDSTONE_LAMP_ON) ? idk how you're generating the
so are the lamps already there beforehand
Material.REDSTONE_LAMP_ON doesn't exists
This isn't tidy but it will show you how I got it working
potentially dangerous smhsmhsmhmshms
ill check it out later
i wanna see how it works too
Was for @subtle folio but anyones welcome
lol
mine now
heha
i javadoc my private plugins
¯_(ツ)_/¯
I do a bit as I go along
full detail
The only bit thats not quite workign is the combat blocking code
as? if the chunk is only being generated
For what purpose
ive had too many times i come back to unfinished stuff i couple months later and forgot what tf i was doing
You can not get blocks while generating noise. This will lead to server crashes. We've been through this already.
I put javadocs for some of my private code, mostly my big ass parts of it
I cba to remember what every line of a 500 line class does lol
i only put javadocs in my plugins when im coding a core or a spigot fork server jar
I simply write self describing code... never needed docs or comments.
I would only document apis
then how do i activate the light for the block?
anyone have a tidy little class to grab CraftServer, CraftWorld and CraftPlayer at runtime so I can bin these version dependent imports?
I can write it but I'm feelign lazy and I have seen it posted here before
By setting BlockData instead of a Material
declaration: package: org.bukkit.block.data, interface: Powerable
You mean through reflections? Because otherwise you simply cast the spigot interface... Not sure what the benefit of such a class would be.
yes reeflection
Ah. Yeah i know what you mean then. I think NBTapi has something like that.
If you obtain teh class via reflection you can avoid having to have multiple version dependant classes
I find the multi module approach cleaner.
it is if it was only these 3 classes I need fo my class to be version agnostic
everythign else is API
guys, in onDeath event, i randomly add items to player's inventory by:
player.getInventory().addItem(event.getDrops().get(randomIndex));
then when i run this to check if player has an elytra in his inventory:
player.getInventory().contains(Material.ELYTRA)
it returns false, even if i actually added an elytra to the player's inventory with the previous line
i also tried updateInventory between these two but it didnt help
No you can not get anything from the world or chunk.
Wait is "chunk" the snapshot? because then its fine.
@misty current I ended up to make my system with this: https://github.com/TheDarkSword/CustomBlockBreakSystem
This project is a good base for the system, of course I had to modify it a little bit because the author had forgotten to put the time a block should take to break and put the time spent in the block
Thank you for your help 👍
The unconditional cast is the issue I suppose
yes
Alright. Just make sure to check for instanceof before you cast anything,
ever
ok
Well, it turns out that BlockData = CraftBlockData
but how do i get org.bukkit.block.data.Powerable
Of course. Same goes for every spigot interface
craft bukkit is the implementation of spigot interfaces
teams are annoying asf
if (x instanceof Y yInstance) {
// variable "yInstance" is an instance of y
}
how did u do it
sleeping pose
Teams
In this episode of the Spigot MC Plugin series, I start a new plugin called Bodied. This plugin makes it so when a player dies, an NPC is spawned using NMS and is made to lay down and have no nametag. In the next parts of this plugin's development, I will show you how to put items in the body once the player dies, and if no one claims it after a...
this guy shows how to do it
how to cast CraftBlockData to Powerable?
im gonna scream
its like 3 hrs with the other part(s) not? xd
breh
it has chapters
just skip to the part where u need help with
1hr 50m
nvm it doesntg have chapters
lmao
i thought it did
oh sorry then
how do i give a player an item
#addItem(ItemStack);
to their inventory
In the end, I still did not understand how to activate the glowstone in the generation of chunks using BlockData
Can i put maven modules inside submodules
if you just want to active glowstone, no
And there are additional performance complaints
How else?
Check the material of the block
...
what?
// [...]
if (blockData.getMaterial() != Material.GLOWSTONE) {
continue;
}
// [...]
is what I meant
what for?
