#help-development
1 messages · Page 1762 of 1
for my problem
oh ok sorry, my bad
your problem is that you are trying to check if the player is a material
i have sorted that
thank you I am gonna look at this
does minecraft use netty?
debugging might help
You need to run createConfig
i have fixed my issue
i'm doing that already
Look where error is from
He's not
why is it so pixelated
so in the interface CommandExecutor the only method is on command
you meant the font?
yea lol
Check the TabManager class
anyways
i just changed it to the minecraft font
which of those parameters do you have to set yourself
why
it runs the loadconfigmanager method first, which creates the file, and only then it calls tabmanager, which means the file is created before i call tabmanager
You're creating a new instance which means it isn't set anymore
So you either need to set it again or use the same instance
i'm not sure what you mean, i do not know how instances work
?learnjava Time for this
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.
so can anybody help?
question for curiosity sake, if i make a plugin's database logging log someone's uuid and username on join, and a server is running in offline mode, and a cracked player joins the server, what happens? do cracked players have uuids assigned to them by the server or naw
no you told me to learn java
which you should know by now is offensive to me and you should also know that i have my own way of learning
@lean gull
Run it again
In TabManager
wdym
hey olivo, i'm trying to create a command
i'm implementing CommandExecutor as one of the interfaces of my plugin
the onCommand function has some parameters i'm confused about
can you offer any explanation?
i want the server hoster to be able to set some properties in the config file through the console
what are the params of the function you are confused about
^
onCommand(CommandSender sender, Command command, String label, String[] args)
which
so i don't know how to set CommandSender
i want it to be a command sent from the console only
CommandSender is the sender of the command, whether thats console or instance of a player
server hoster should be the only one be able to set it
Then check if it's an instance of ConsoleSender
okay, so let me try to describe this.... is the sender passed in by the api ?
kinda like an event ?
yes
okay cool thanks
CommandSender is passed in
well there are some commands that can only be sent in the server console
so i wouldn't think so
@lean gull if you look up and gain an understanding of how instances work in java i think you will see what is wrong w/ your code
that's why @chrome beacon linked those links, not to insult you
Not instanxeof player
a lot of people here know that i get insulted by the learn java command
trust me i get it
and you don't even need to know me to know that, that command is just insulting to most people
i'll give you a brief explanation of what an instance is... an instance is just when you create an object of a class
lol go learn java first
craftinc i don't know what an object is yet
there are a lot of things i don't know in java but i like my way of learning
i think it'll help you
i'm guessing you want to send me a link to a resource about learning java or whatever?
nah it's a server i'm in where the people will help you with the basics
then you can come here for spigot stuff
that's not that different from the learning java thing
@tardy delta i don't think so but i suppose if it works that way you could just if(sender instanceof Player)){ sender.sendMessage("This command can only be executed from console.") return false; }
i dno't mean to be rude man. a lot of servers and people don't want to explain basics
i don't mind it personally
do return true, or the command will be shown back to the sender again
i'm not really looking to learn the basics, that will just get me unmotivated
i want to learn the basics along the way
yes, it's in-efficient and will take longer but it has a lesser chance of me quitting java and getting fustrated
true
@last ledge i always like printing usage back when someone uses something wrong but i suppose it doesn't really help anything in this case so yeah might as well return true;
instances are kind of a difficult thing to like fully fully explain
in a text chat like here
i hear ya. well, at the very least you should learn the basics of what applies to what you're doing
it will make it a lot easier
you don't have to go learn all the basics. that's too much as well
i'll try googling it and i will probably come back immediatly with questions about it lol
they won't want to answer here
https://www.youtube.com/watch?v=eIrMbAQSU34&ab_channel=ProgrammingwithMosh Just get the basics, which will be enough for bukkit coding
@lean gull think of instances of classes as VM's if that makes sense to you, thats kinda what i did/do and it gives you the base idea
its a bad analogy but it works
idk what or how the virtual machine is/works
ok very tldr here so for you hawks out there dont correct the small stuff
the base idea is
i get this error evertime someone clicks in the game not in the gui
how can i fix this
think of minecraft. you have the game and the game has several other games(worlds) with many blocks n Monsters
it goed deeper and deeper
ah common problem
please don't use metaphors, those just confuse me
wait
@lean gull dm if you want me to explain
...
universe BOOM -> clusters who have clusters who have clusters who starts to have galaxys and so on
the boom is your application start
until we get to earth and earth is the player f.e.
can someone help me with this:
https://www.spigotmc.org/threads/check-if-the-item-has-the-specific-nbt-tag-or-no.532759/
how can i fiz @last ledge
return;```
ty
can someone help me please
ha bhai bolo
.
theres a lot of documentation abotu nbt tags
what did you try so far?
waiting for someone to 🥣
ye
yo choco you got a girl in your pfp
I do
i know how to use them, but im using the plugin to modify an item from a datapack
where did you download it
Ah. Existing third party NBT. Guess your hand is forced
yeh ;-;
that did not work
There are some APIs for that if you really want
?paste
send ur code
for?
we are so proud of you
hmm, if only they were usable in datapacks
idk wht this statement means and no, im using a datapack made by someone else
just modifying one of its items
why are you using titles to check invs?
plus idk how to do loot tables in spigot
The purpose of PDC was to avoid polluting the root NBT of an item and hide everything under Bukkit's namespace. Ideally nothing on the root NBT should be added/edited by a plugin because we have ItemMeta for that
That's the reason you can't access any tag from there, only ones defined by plugins
why using titles dude
(though obviously data packs have no concept of that)
OK, so. now i can ask my question
what question
mhm
so how would you do it
api is nice and all, but how would i do it myself
check the entire inv
you shouldnt use titles, check the holder instead
ok here it goes: how do i create the custom Command to pass in to my commandExecutor function?
i want to learn to make them myself
onCommand(CommandSender sender, Command command, String label, String[] args)
what?
you mean how to create a basic command?
yeah i guess so.
watch a tutorial?
in the function check
if(label.equals(<yourcommandnameasstring>) {
//stuff
you dont need that if you register it properly
and if you are using a class for a single command then you dont need to check if label is the command name
this method will be executed if the command for what the executor was set gets executed
yea i know
Hello and welcome to TheSourceCode,
Here at TheSourceCode, our main objective is to have people learn to code alongside me. We are not professional coders by any means. But we have gained lots of knowledge throughout our years and we hope to share it with you! We hope to teach you something new and we hope you guys teach us something new!
real help right here
dont use the label for that
go over the command
the label is for being very specific
i know u can use command.getString() as well
getName(), yes. The preferred way
ah yes getName() : )
The label is useful for command feedback and label-specific execution
i just prefer to make individual classes for each command and define aliases
again, idk what that means
e.g. you have a command with aliases "foo", "bar", and "bazz". I write "/bar" but my command tells me "You wrote foo!". No I didn't. I wrote "bar" 😛
btw, ik i can use apis to ease up my work too much but if i were going from scratch, how would i check if my stick that's hitting an entity has the nbt "stick:1b"
ahhh
i get it
now
same functionality
different messages
or may have other uses
right?
The link above mentioned how to do so
https://bukkit.org/threads/get-nbt-tag-from-an-itemstack-in-a-player-inventory.486133/#post-3620714
Yeah definitely
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
HAH
i'm happy i was doing it the right way lol
without looking at the tutorial first
ye the thing is, even tho i gave myself the item with an nbt that i added, when i run it, it says that the nbttagcompound is null
nms.ItemStack#getTag() will only return null if the item has no NBT at all
@EventHandler
public void OnBottleBreak(ProjectileLaunchEvent e) {
Projectile projectile = e.getEntity();
if (projectile.getShooter() instanceof Player) {
Player p = (Player) projectile.getShooter();
ItemStack item = p.getItemInUse();
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
NBTTagCompound nbtTag = nmsItem.getTag();
for (String string : nbtTag.getKeys()) {
System.out.println(string);
}
}
}
this gives that nbtTag object is null
btw, what does # mean?
in java ofc
Javadoc notation. Methods are referred to using #
oh
getItemInUse() is the item being consumed by the player (i.e. food, or a potion)
You probably want player.getInventory().getItemInMainHand()
(if you want to be really fancy you can account for multiple hands by doing a null/air check then grabbing the other hand)
ItemStack item = player.getInventory().getItemInMainHand()
// If there was no item in the main hand, get the item in the off hand
if (item == null) {
item = player.getInventory().getItemInOffHand();
}
// There wasn't an item in the main or the off hand. Don't proceed
if (item == null) {
return;
}```
what about quickly switching hands
like sword swap maybe
I have no idea what is happening here
Won't be any issue because the item will be in the same spot when the event calls
It's called on launch so ye
hmm
What are you doing in your leave listener? 
what about projectile hit event
when i try to drop a specific item of my plugin with the creative inventory open it dont drops
Hit is a bit different. But to work around that you could just keep track of the arrow on launch then compare it in the hit method
I just remove the player from a list and there I unregister the scoreboard
There's no way that that alone would cause that large of a performance hit
Wanna analyse the code?

@Override
public void onEnable() {
this.getCommand("setDiscordIDs").setExecutor(this);
}```
is this valid
since my plugin is the one implementing the CommandExecutor
this doesn't return an error but using the class where my onCommand is does
Then you are not implementing the code right
weird.
Show us the rest of the code
yuh
public class BroadcastReader extends JavaPlugin implements Listener, CommandExecutor
{
public Socket clientSocket;
public PrintWriter out;
@Override
public void onEnable() {
this.getCommand("setDiscordIDs").setExecutor(this::onCommand);
saveDefaultConfig();
getConfig().addDefault("guild-id", 0);
getConfig().addDefault("channel-id", 0);
try {
clientSocket = new Socket("ip", 8080);
out = new PrintWriter(clientSocket.getOutputStream(), true);
} catch (IOException e) {
e.printStackTrace();
}
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPlayerChatEvent (AsyncPlayerChatEvent event) throws IOException {
out.println(event.getMessage());
}
@EventHandler
public void onPlayerCommandPreprocessEvent (PlayerCommandPreprocessEvent event) throws IOException {
out.println(event.getMessage());
}
@EventHandler
public void onDisable (PluginDisableEvent event) throws IOException {
clientSocket.close();
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(!(sender instanceof ConsoleCommandSender)) {
ConsoleCommandSender console = (ConsoleCommandSender) sender;
return true;
}
else
return false;
}
}```
Your IP is showing
oh yeah this works
Create listeners and command classes
LMFAO
This is really not OOP
mhm
he edited it
xDD
"this" will work since the onCommand is in the same class as "extends JavaPlugin"
yea
Yep and creating bigger projects
Not able to find mistakes
Rewriting code over and over
well, feel free to make it more efficient 🙂
;D didn't think so
unless u wanna come work for me
@formal dome what is this plugin for
it's gonnd be basically discordSRV with one bot instead of making hosters make their own
so i can yoink it with context hehe
dam
xD
maybe i shouldn't say
@worldly ingot are you able to find the problem, or should I DM you the full plugin?
you dno't have the backend still lol
too late
agre
how
What about the thing at the bottom? the rubies I mean
Textures
Almost anything can be added with textures
Well that's obvious but which textures
Could be bubbles IDK
and the number?
settings or prefences or whatever
yeah that was a dumb question on my part tbh
it is, when I go underwater the ruby count disappears. my only problem is idk how to add the number
ok so i now know what an instance and what an object is, and from what i understand, you mean that in the main class i have an object of config manager, and in tab manager i have another one?
i tried doing this in main:
public ConfigManager getConfigManager() {
return cfgm;
}```and this in the tab manager class:
```java
public TabManager() {
cfgm = MangaTab.getConfigManager();
cfgm.reloadTab();
FileConfiguration tabConfigFile = cfgm.getTab();
tabConfigFile.set("banana", "yes");
cfgm.saveTab();
}``` and this is what i got:
what are the various options for command permissions?
in the plugin.yml?
commands:
setDiscordIDs:
description: Sets your desired Guild and Channel for interaction
usage: /<command>
permission: BroadcastReader.
the example from spigot
# Replace "kit" with the name of your command.
commands:
kit:
description: Your description
usage: /<command>
permission: yourplugin.yourcommandpermission ```
craftinc could you help me with this? ^^^
whats wrong with it
thats not a singleton
now it sends me an error and says that the plugin is already initialized
can you press the power button on your computer for me rq? thank you
what do you have right now?
i would need some code to overview it
can someone just warn godcipher? that'll be great thanks
seems like someone cant take a joke
You can't instantiate the class that extends JavaPlugin
You're getting that error above because you're trying to access a non-static method from static context
Sorry for the late reply.
I would like to try again with a delay, but I don't know how. Can you please tell me how to do it?
what's the best way to put comments, keys and values, and sections in a yml file and also later making it so it sends you an error if you did something wrong like deleting a key or something
?scheduling
Hello, I'm currently trying to change the amount of items certain recipes give, but and just set up custom crafting recipes, hoping they'd override the vanilla ones, but that didn't seem to work. Does anyone know of a method I could use.
(Notes: I am new to Java; This is for Spigot 1.17.1; I have tried google, but I didn't find anything (although that might just be me not using the right keywords))
what is the code?
or didnt you attempt it yet
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
otherwise try that
I have attempted updating the amount by creating custom recipes with the same crafting table input, hoping it'd just override the vanilla recipes.
public class ___ {
public void ___() {
ItemStack result = new ItemStack(Material.ACACIA_STAIRS,8);
NamespacedKey key = new NamespacedKey((Plugin) this, "___");
ShapedRecipe recipe = new ShapedRecipe(key, result);
recipe.shape(
"X ",
"XX ",
"XXX"
);
recipe.setIngredient('X', Material.___);
Bukkit.addRecipe(recipe);
}
so the first in the list gets recognized first
minecraft recipes are first so you will have to either put yours before it
or remove the other one
How do I remove a recipe though?
no clue
Me neither, and I've tried googling. :/
maybe using Bukkit.getRecipe()
to get the vanilla recipe
and edit it?
what item craft are you trying to overwrite
ohk acacia stairs
try ```java
((ShapedRecipe)Bukkit.getRecipe(new NamespacedKey("minecraft", "acacia_stairs"))).getResult().setAmount(amount)
idk if it will work
/* get recipe and cast to shaped crafting recipe */
ShapedRecipe recipe = (ShapedRecipe) Bukkit.getRecipe(
new NamespacedKey("minecraft", "acacia_stairs") // key, same as "minecraft:acacia_stairs" in text
);
/* set amount of result */
recipe.getResult().setAmount(amount);
Imma test it out now.
public void ___() {
String item = "";
Bukkit.getRecipe(new NamespacedKey("minecraft", item)).getResult().setAmount(_);
}
Bukkit.removeRecipe
obj.___();```
-_-
Is that a valid method name
Lol, I put that as a placeholder.
yesh
I usually store stuff like that in an external file so I can store it for possible future projects. All I have to do is copy/paste, and replace the underscores.
wew
I don't even know if this'd work, decent chance it'd give an error imo.
it compiles so i guess i doesnt
How can I create a custom World, for example a plot world
i still need help with this btw
it depends on how you saved those keys and values earlier
Is there any event for when a player enters an end gateway?
if (command.getName().equalsIgnoreCase("stats")) {
Inventory inv = Bukkit.createInventory(null, 9, "§aChosse a player");
for (Player players : Bukkit.getOnlinePlayers()) {
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
ItemMeta meta = skull.getItemMeta();
meta.setDisplayName("§e§l" + players.getName());
skull.setItemMeta(meta);
inv.addItem(skull);
}
p.openInventory(inv);
}```
How can i change the texture of the skullitem
Does it fire PlayerEnterPortalEvent
doesn't matter, i can change it
Can I post a Gyazo link here?
@tardy delta the specific end gateway block, not the portal block
you shouldnt build you plugin around your file file but in reverse
hmm I'm not sure if it does
if you save data in a specific way which makes it difficult for your code to use in some scenarios..
just depends on the context
what are the various options for command permissions?
commands:
setDiscordIDs:
description: Sets your desired Guild and Channel for interaction
usage: /<command>
permission: BroadcastReader.
the example from spigot
# Replace "kit" with the name of your command.
commands:
kit:
description: Your description
usage: /<command>
permission: yourplugin.yourcommandpermission
currently i just have a simple <config manager>.set thingie, it's not used for anything and it's just for testing
show me that class
public void ___() {
String item = "_";
Bukkit.getRecipe(new NamespacedKey ("minecraft", item)).getResult().setAmount(8);
}
The constructor NamespacedKey(String, String) is deprecated
Can I ignore this warning?
XD
no
Yeah, I thought so
doesnt "namespace:key" works as only parameter?
so only one string?
not sure
ah nvm you need to provide your plugin
It wants your Plugin instance
Bukkit.getRecipe(new NamespacedKey ((Plugin) this, item)).getResult().setAmount(8);
``` Certainly works.
btw what i'm trying to achieve here is a tab plugin that has a footer and a header, each of them has 5 lines
what is the purpose of a TabManager instance?
also a constructor is the way to do it
public void getPluginConfig(MangaTab plugin) {
this.plugin = plugin;
}
and all of that is stored by something like this:
# each line is stored from line 1 to line 5, top to bottom
header:
line1:
line2: aa
line3:
(etc etc)```
so a comment, a section, and 5 keys and their values
and if the value is not set then it will not count it as a line
and what exactly are you trying to achieve?
^^^
so just saving a header & footer into the config file?
wdym
the header and footer of all players' tab would be what you set there, and if a value is empty then it won't be counted as anything
you're saying your plugin has a footer and a header so probably you're going to save them somewhere
So what is the issue, Derpy?
this is an example for what i want the config file to look like
why not just using the FileConfiguration class?
to get values from config
like plugin.getConfig() -> return the config.yml fileconfig
and just set your things there?
Are you saying I have to call "Bukkit.getRecipe(public NamespaceKey(@NotNull Plugin plugin, @NotNull String key))" then, cuz I'm pretty sure that 'aint gonna work. I'm trying to edit an existing recipe, and need the "minecraft" namespace keys, not my plugins'.
just a Plugin and a String as parameter
btw the minecraft namespace isnt tht just ```java
var key = NameSpacedKey.minecraft("stone");
stupid me
i think its just
Finally, thank you. No errors
i have to read questions better...
How can I create a custom World, for example a plot world?
Can I use Java 16/17 SDK for compiling pre-1.17 plugins? Will there be any issues?
Pretty sure it won't work
Even if I use it to run the server jar?
I mean you can certainly try it, I've just not really seen Java 16/17 work well with Minecraft versions that aren't 1.17
if (command.getName().equalsIgnoreCase("stats")) {
Inventory inv = Bukkit.createInventory(null, 9, "§aChosse a player");
for (Player players : Bukkit.getOnlinePlayers()) {
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
ItemMeta meta = skull.getItemMeta();
meta.setDisplayName("§e§l" + players.getName());
skull.setItemMeta(meta);
inv.addItem(skull);
}
p.openInventory(inv);
}```
How can i change the texture of the skullitem to the texture of the player
googled it?
you need to parse the item meta as skull meta
and then theres a method to do setSkullOwner()
isnt & 0b1111 the same as >> 4?
How can I create a custom World, for example a plot world?
try something with this
getServer().createWorld() that is
16
14*
hello. i will use this code and i want to detect when a certain armor stand will be at the top after x seconds https://paste.md-5.net/udewebozuq.java
in 14, it was only a preview feature
Preview features are disabled by default. To enable them, we must use the enable-preview argument, which enables all preview features at once.
tho
it rains in snow golems
idk what's wrong
probably sodium has a memory leak
or other optimization mod
Yeah this already works, but i want a world with my own structures, for example plots
you will have to make a custom block populator
i think its called
gets run when the chunks are generated
i cant close my mine craft client
then just set the world type to flat
uh oh
do you have linux equivalent of taskkill
love it
i'll try xkill
oh ye
im on linux
do u have a piece of code for me, i watched a ton of tutorials but they dont show how to create it with like a command. It would be really helpful
wdym by with a command?
you mean when they run a command they create a new world
?
I would like to create the would with a command. The tutorials always use the bukkit.yml the create it or something old like multiworld
not at all lol
nah
hes writing a plugin
its still not fixed
sad
its going to be fixed in sodium 0.3.3 it seems
well, resourcepack features
means ya fucked sommin up
What exactly are you doing with chunkgen?
idk guys but vanilla minecraft runs better than running sodium or optifine
i'm getting 300 fps
on vanilla
while on sodium i get 200-250
🆒
I get lower FPS on Optifine but that's because I opt for higher quality
I do get more consistent FPS with Optifine vs Vanilla, though. So regardless the fps drop is weighed up for by better graphics and smoother framerate
But this is more #general isn't it?
Mojang really polished their graphical engine for caves and cliffs update
to get more fps
no
Server Resource Pack
is Crafting even string
?
No, it's literally in the textures
iirc its a textrue
Get a resource pack with what you want it to say, then force that as a server pack
where can download default resurcepack
WHERE IS PACK.MCMETA? The pack.mcmeta isn't in the 1.17.jar file. Here's what to do instead! Create a file called "pack.mcmeta" and open it in notepad (or any text editor.) Copy/paste the following text, and save it!
{
"pack": {
"pack_format": 7,
"description": "Default 1.17 Resource Pack"
}
}
Learn how to make a resource pack in Mi...
thanks 🙂
i cant believe my minecraft in vanilla runs better than with optimization mods
well i do use starlight
and krypton with phosphor
#general
It should be translatable tho. On russian its different
pls
What's the best way to make an area system where you can create areas and customize their permissions and add/modify owner and co-owner?
By replacing Group with a new name and UUID with the name of the area, would it work?
what are the various command permissions you can use in your plugin.yml?
commands:
setDiscordIDs:
description: Sets your desired Guild and Channel for interaction
usage: /<command>
permission: BroadcastReader.
the example from spigot
# Replace "kit" with the name of your command.
commands:
kit:
description: Your description
usage: /<command>
permission: yourplugin.yourcommandpermission ```
is there like op only?
console only?
?paste
ok default is fine
is it possible to check from the client if entity is actually server side or packets?
check if entity with given entity id exists on server
wait i thought saveDefaultConfig() generated a config for you
why am i getting this error
The embedded resource 'config.yml' cannot be found in plugins/LogReader-1.0.0-all.jar
@Override
public void onEnable() {
this.saveDefaultConfig();
this.getCommand("setDiscordIDs").setExecutor(this);
getConfig().addDefault("guild-id", 0);
getConfig().addDefault("channel-id", 0);
saveConfig();
}```
oh okay lol
which save, saveDefaultconfig() or saveConfig()
?paste
default
also why is my plugin considered legacy?
if your plugin does not define an up-to-date api-version it will be considered legacy
where do i do that?
is there a way to make a player transparent?
like you can still kind of see them
but they are see through?
Hey guys, someone already made a rich presence in the minecraft plugin and could you help me? and because I need a server, but mine keeps giving an error
if you are using someone elses plugin, go to #help-server
as its not about plugin development then
I'm developing, and I wanted help
What are you developing?
hello everyone, I want to make a plugin, that broadcasts over 2 (or more) servers. Here's the example out of the Thread on SpigotMC:
I want to for example send a broadcast message from one server to another.
So something like:
server1 executes /winner foobarbaz, sends a message to server2, says "hey, please broadcast, that foobarbaz has won!"
If you have an answer, that works for me, I would like to copy it in the Thread or you write it directly in there^^
(I'm not impatient, just wanna spread my issue lol)
https://www.spigotmc.org/threads/bungeecord-how-to-send-a-command-from-one-spigot-server-to-another.531023
anyone know a good tutorial or so on the basics of creating a generation plugin
Would PlayerChangedWorldEvent be a good event to check coordinates of a player to see if he enters a custom region?
Is it me or the PlayerChangedWorldEvent makes the the previously stored player object stale
i get two different world names
hm?
I've checked the world name in the event.getPlayer().getWorld() and previously stored player object in hashmap and it turns out after PlayerChangedWorldEvent, player object gets stale, since world names do no match. Hashmap stored value retrieves the old world name while the event.getPlayer() player object retrieves new world name
nice
I wasted 7 hours
debugging this
thinking it was my fault in my algorithm
i thought Player object are stale only when player disconnects
or rejoins
turns out even world change can make it stale
since player object changes, whenever world changes in NMS
Thats why you really shoudnt use player references
Players are entites, and they are bound to the world
i thought i was going to save some cpu power by not using getters to get the uuid everytime
since im utilising intensive events
like playermoveevent
and entitymoveevent
no that's wrong
player objects do only go stale after a disconnect
what version of spigot are you running, post /version
then why world objects stored in player are different wtf
ah
PlayerChangedEvent Player reference:
[23:08:03 INFO]: [DEBUG]: Player's current world name: world
Stored Player reference in hashmap:
[23:08:03 INFO]: [DEBUG]: Player's world: flat
all i did
is changed dimensions
via multiverse-core
Why arent my config functions working
this.getCommand("setDiscordIDs").setExecutor(this);
this.getConfig().addDefault("guild-id", 0);
this.getConfig().addDefault("channel-id", 0);
this.saveDefaultConfig();```
.
saveDefaultConfig copies the config from your jar
im running airplane
if you are using addDefault you want regular saveConfig
@mortal hare so not spigot and almost probably a bug they've introduced
This server is running Airplane version git-Airplane-99 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) (Git: e68f5c2 on HEAD)
lemme try changing server software
not helpful to moan here about it
im not moaning im just thinking what's wrong
in the spigot server
(try on paper)
....
👀
Try bukkit
How to trigger md_5 101
Probably getKey
Dont use numeric ids at all
Numbers are evil
why is my config.yml still blank 😦
@Override
public void onEnable() {
getCommand("setDiscordIDs").setExecutor(this);
getConfig().addDefault("guild-id", 0);
getConfig().addDefault("channel-id", 0);
saveConfig();
}```
getConfig().options().copyDefaults(true) before saving
I'm doing a custom area system... could u tell me if I'm doing god-like work or shit-like work plz?
Area.java : https://paste.md-5.net/adezovosec.java
AreaManager.java : https://paste.md-5.net/ziliwivimu.java
DataManager.java : https://paste.md-5.net/owivehoqij.java
P.S. Method AreaManager#loadHashMap() needs to be called on MaxiCity#onEnable() and method AreaManager#saveHashMap() needs to be called on MaxiCity#onDisable()
P.S.2. MaxiCity.java is my main plugin class
alright this one works. thanks!
how do you check if the server has a world by name
Bukkit.getWorld("name");
and then check if it's null or not
if not null then the world exists
🤓
obviously implies that that world is loaded
the server may still have a world with that name as a folder
Yeah
gonna go to bed, hope someone will respond some day... :aw:
its fine, you'll still refactor it someday when the API will grow up. Its not shitty
Add ItemFlag.HIDE_ENCHANTS to the meta
what API are u talking about?
your Area API
it's... not an API? and what about "refactoring" it? what do u mean?
and what I did is not done yet don't worry, I just wanted to make sure I'm not doing shitty work before doing more
I mean when the Area framework will grow, you will refactor the classes sooner or later
don't do what? making my HashMap public?
static
The point of managers is to hold this stuff inside the actual instance not like to be static
there is only supposed to be 1 manager
so put your map in there
instead of using static
I name my managers registry's but im not sure if that's the proper name for them
all of my managers do is register deregister things
but I separate my managers to avoid having a 2k lines file
and stuff
that doesnt have anything to do with static
you said there is only 1 Manager
i dont think it matters too much
Yeah
if there is only 1 manager
no need to make it static
just put the map inside your actual manager class
uh I'm not sure to understand what you're saying
if there is only 1 manager
I don't have 1 manager but 2
1 manager instance
What you are currently doing is trying to store your map like a singleton. Singletons are something which is only defined once. However, your AreaManager class is a Manager class already, meaning there should only be 1 instance of AreaManager in your plugin. Therefore, you don't have to turn your Map into a singleton and you should remove the static.
but my map is already inside AreaManager so it's inside the class
I know there is only 1 instance of AreaManager, it is defined in MaxiCity.java
just put the map inside your actual manager class
do I remove the static or do I put the map inside my manager class???
java oop experts be like
remove the static
without static
no need to make it static
should remove the static.
remove the static
🥲
public maps?
And encapsulate it
he said just put the map inside your actual manager class
he lost me because my map is already in my manager's class that's why
anyways, everything's good now
how do i use one of the custom things, like Environment.CUSTOM and stuff
like a custom environment for a dimension
there isnt like anything on it
just says represents a custom dimensino
also why am i the only one to have talked in 30 mins this is usually active lol
hey everyone, i have a question regarding yaml files: what is it the best way to set comments, sections, keys and values in a yaml file? and also i want it so if like a section or key or value is not how it is supposed to be, as in someone messed with it, it will send an error to console. i also want to make it so you can do a command in game to reload it to see if there are any problems with it but instead send the errors to the player
sigh
I know how to copy a resource file from my jar file and put it onto the server. How would I copy a resource folder though?
lol can anyone help me with this i cant find any answers
(srry)
Making Custom World Environment
i dont fucking get it
in one world
packet entity
always spawns
but in another
it just doesnt
no matter what i do
its not as if its not sending packets
it does
the client just doesnt render
for some fucking reason
but in another world
it does
i've debugged all the if statements
that could cause packets not to be sent
nothing
i tried adding tick delay
via scheduler
it adds after one second
in the flat world
while in another dimension it doesnt
im so pissed
You know editing messages is a thing 😄
Are you sending the packet to each world?
wdym by each world. im using player's connection to send the packet
via spawn entity living packet
Yes are you spawning said entity in each world?
im sending destroy packet at the worldchangeevent and then resend the spawn entity living packet
spawn entity living doesn't have a field for dimension UUID
Ok and it's spawning it in the wrong world?
im not sure
What world are you trying to spawn it in?
but it doesnt spawn in the right world
at the right time
survival
none of the dimensions do not work
apart from one
And your trying to spawn it if somone joins the survival world?
as i said im spawning an entity whenever PlayerWorldChangeEvent hits
that event has 2 locations it has a from and a to which one are you trying to spawn it at?
it doesnt matter
i dont use these getters
since protocol of packet doesnt require it
Where are you getting the location from then?
Sorry I gtg I'll be back in about 30m dm me if you still need help
omg
thank you
it was the location issue
finally my lovely cod fish spawns
how did i not thought about this before.. I'm so tired that my brain is feeling like the phone on powersaver mode
oh hi dovidas
thats exactly my question
i saw a yt video that explains how to find out what the params were for the nms code (this.a, this.b, this.c, etc.) but the letters arent on the wiki for spawn entity
There was a server where you could design level and publish it for other to play (super mario maker) and I was trying to find if there is a plugin for that?
Isn't it just for runing servers but ok.
anyone know why this is freezing the server during loading/making it take forever to load the world?
if(Bukkit.getWorld("doomdimension").getBiome(x, currentheight, z) == Biome.SOUL_SAND_VALLEY)
Where are you running this
in generateChunkData function
Yeah you can't get get the world during generation like that
ChunkData has a getBiome
no it doesnt
https://wiki.vg/Protocol#Spawn_Entity
do i have to include all of these params for it to work?
the thing isnt showing up in intellij
lol np, always debug all of your parameters.
What version are you on
Man this guy says 30 minutes and he means it
spigot?
Minecraft version
you seem good at packets could u help me pls
Well these are the latest docs, so ¯_(ツ)_/¯
lol
Make sure spigot is up to date
ye maybe my api is outdated
I mean I'm ok at them but i might be able to help, what's up?
i wanna spawn an entity, similar to what hes doing
im not sure how many of the params in the wiki page i need to include when calling the method though
What do you want to spawn?
nope its the latest version
a chicken
just something basic rn to get used to packets
yep it was outdated
lol
downloads updated one
reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
check out this tutorial
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
Thank you
Use BuildTools
also now literally nothing generates in the world
oh
nvm
now createChunkData() is deprecated
it says its directly provided what do they mean by that
like how do i get the chunk data then
oh\
nvm
its split up now
thats annoying
seems to be using nms for regular entities
im doing packet entities
@EventHandler
public void onSomething(PlayerInteractEntityEvent event) {
EntityPlayer player = (EntityPlayer) event.getPlayer();
PlayerConnection playerConnection = player.b;
PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity();
}```
In that case you should be able to create an EntityChicken and pass it into PacketPlayOutSpawnEntityLiving
do i specify location and such when creating the entity chicken or in the method?
//'EntityChicken(net.minecraft.world.entity.EntityTypes<? extends net.minecraft.world.entity.animal.EntityChicken>, net.minecraft.world.level.World)' in 'net.minecraft.world.entity.animal.EntityChicken' cannot be applied to '(net.minecraft.server.level.WorldServer)'
public class PacketsAHH extends EntityChicken {
public PacketsAHH(Location loc) {
super(((CraftWorld) loc.getWorld()).getHandle());
this.setPosition(loc.getX(), loc.getY(), loc.getZ());
}
}
whats up with this
can someone help me with this please?
how do you change the value of a default in the config.yml
so i've added it already, now i want to change it
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(sender instanceof ConsoleCommandSender) {
config.addDefault("guild-id", args[0]);
config.addDefault("channel-id", args[1]);
getConfig().options().copyDefaults(true);
saveConfig();
return true;
}```
so im' trying to figure out why it doesn't change everytime i run the command
i set some values the first time and it worked... now everytime i run the command it defaults to those values
i guess that's why it's called default eh
AH i figured it out
theres an inherited method in FileConfiguration from ConfigurationSection called set 🙂
that does the trick
Probably just set it to that value if it's null maybe? When you use saveDefaultConfig? 
🤷♂️
Man
People really be out here writing commands like this
@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args
Like jeez
And all that for just a few lines of logic
If only there was a lib what makes this 10x easier
Well at the very least you don't need the @NotNull annotations because it's not an API method or anything
IDEA screams at you if you don't use them lol
I haven't had a null pointer exception in my own codebases in like
months
but I still use constructs to avoid null errors
e.g. Optional, NotNull, Nullable, you get it
🧢
can someone help me, im using this code:
@EventHandler
public void onBottleBreak(ExpBottleEvent e) {
Projectile projectile = e.getEntity();
if (projectile.getShooter() instanceof Player) {
Player p = (Player) projectile.getShooter();
ItemStack item = p.getInventory().getItemInMainHand();
net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
NBTTagCompound nbtTag = nmsItem.getTag();
if (nbtTag.hasKey("bottleType")) {
if (nbtTag.toString().equalsIgnoreCase("grand")) {
System.out.println("bottleType:grand");
}
}
}
}
with this command:
/give @p experience_bottle{display:{Name:'{"text":"Grand Experience Bottle","color":"blue","bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false}'}, bottleType:grand} 1
to give me an experience bottle with nbt tag bottleType:grand
but for some reason it says that the nbt is null, please help
error:
Could not pass event ExpBottleEvent to XpBottleUpgrade v1.0
org.bukkit.event.EventException: null
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[minecraft_server.jar:3276-
Spigot-3892929-b58f429]
at org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory.callExpBottleEvent(CraftEventFactory.java:1253) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.world.entity.projectile.EntityThrownExpBottle.a(EntityThrownExpBottle.java:47) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.world.entity.projectile.IProjectile.preOnHit(IProjectile.java:160) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.world.entity.projectile.EntityProjectile.tick(EntityProjectile.java:70) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.server.level.WorldServer.entityJoinedWorld(WorldServer.java:777) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.world.level.World.a(World.java:699) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.server.level.WorldServer.lambda$11(WorldServer.java:489) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.world.level.entity.EntityTickList.a(SourceFile:54) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.server.level.WorldServer.doTick(WorldServer.java:470) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1314) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:438) ~[minecraft_server.jar:3276-
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:438) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1217) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1050) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.nbt.NBTTagCompound.hasKey(String)" because "nbtTag" is null
at net.fordium.xpbottleupgrade.Events.onBottleBreak(Events.java:26) ~[?:?]
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[minecraft_server.jar:3276-Spigot-3892929-b58f429]
... 18 more
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.nbt.NBTTagCompound.hasKey(String)" because "nbtTag" is null
at net.fordium.xpbottleupgrade.Events.onBottleBreak(Events.java:26) ~[?:?]
Sure would be nice if the exception told you exactly what was happening and where
mhm
Well the exception seems to disagree
I feel like a simple null check would fix this
Just early return if the nbt tag is null
i clearly put bottleType:grand here
If the nbt tag is null then it won't have the data you want to begin with
It's entirely possible that minecraft just ignores nbt data you put in the item that it doesn't think exists
Try throwing the item on the ground and using /data get entity @e[type=item,distance=0..5] or whatever
okay
It might not have had the tag applied at all
In which case you would have to apply it programmatically
any reasons for that?
wdym
Might just be how the game is written
Not sure why you're using nbt api to begin with
i want to use this item in datapack loot tables
You could easily use PDC for this
ik that would be so much easier
I don't think plugins and data packs mingle very well
So I wouldn't know how to help further with that
PDC must be represented in some structure in NBT
Where else would it be stored
I'm guessing it just puts a special map in the NBT data for an item or something
yuh
It depends on what you want to do with them
i want to modify almost all vanilla structure loot tables
PSA: If the exception says a value is null, then it's null. It cannot lie as the exception is raised by Java (the JVM) itself.
I don't think you could easily do that
throw new NullPointerException();
🥲
you know what I mean
also it's hard for fake NPEs to exist lol
maybe the way im checking for em is wrong
plus one thing i noticed, the exception only throws when i use the item in survival
I believe it's throwing bc the item isn't guaranteed to have a tag?
ye about that, at first i was using projectilehit event and i used a for loop to print all strings in nbtTag.getKeys() metod
and it displayed bottleType as an nbt
@lavish hemlock help pls
use packetdataserializers
in newer versions of minecraft
it allows packet construction without reflection overhead
although packetdataserializer methods are obfuscated you can find out what those do by just looking at the PacketPlayOut class and comparing it to wiki.vg documentation
for example in 1.17.1
#PacketDataSerializer.d() would write minecraft implementation of VarInt to the buffer
by using these you can create packets without reflection
Karambwans? @mortal hare
what
karambwans are the answer
wdym
(special source and paperweight exists)
Should i cache SQL data or is getting the data from the database every time fine?
never heard of caching data from an sql database and not just fetching it
i would imagine just using the database as intended would be plenty fast enough for pretty much any possible minecraft related use-case
he is talking about a runescape content creator that is also lithuanian
Yes lol
You most certainly want to cache it
Why
First and foremost querying sql is quite the operation, so it should be done async to avoid lag spikes as it’s not just any "function invocation" you’re doing there. Because of this you probably want to store the data retrieved from the database, such that if you’ve queried the database once, there’s no need to do it again. However, if you implement a cache you need to be damn disciplined such that you keep your cache in sync with the database regarding all data, and invalidate unneeded objects in the cache which might be after a certain duration.
well, getting data from db everytime may be a reasonable design, especially with cross-server software, but that requires complex asynchornous design. Even with this you need to cache stuff which is being checked oftenly
You probably want to use a sophisticated cache if it’s across servers like redis
But that’d require even more discipline
🥲
I used to think that i should keep everything in memory, but dam this plugin design is soo awesome
I have idea that I think its possible - since X-rays are very popular and its hard to stop x-rayers that want ORES why not we to stop ores - the server is hiding ores by changing the whole block to stone and if you mine block next to the ORE or close to the ORE its transofrming into ore so the player really must "find" it...
Would it be possible to implement in BIG servers?
Apart from not using gradle it’s quite nice
to stop x-rayers on my server i just tell the world generator not to generate gold, iron, diamond and emerald
cant xray ores if they dont exist, big brain move
xD
that is what the dev of paper thought, and you know what? they even made a system built-in to paper. if you interested in that then i can link you to a post about it lol