#help-development
1 messages · Page 2068 of 1
Which is where
I want to avoid building all of this junk and get to the actual problem
I assume this?
thats the code for building all json files
so the mcmeta and models
in this case
Which is what's causing the issue right?
i think so
i dont know for sure
because i dont even know what the issue is really
Well that was difficult
how can i instantiate a new command instance from the PlayerCommandPreprocessEvent callback using only the string it provides(and yes im not tarded enough to ask for how to split a string, thats already done)
It's in the MC logs
so i can use the getAliases
how did you get it to load the model
xD
By moving them where they're supposed to be
?
Your dir looks like this
but everyone seems to have everything in the MC folder
That might not be the issue. However, I can't get this setup to work so 
this guide uses it though
on 1.18.2
so it is possible
and it would make my life a lot easier
k
how can i cast the command into a org.bukkit.command.Command instance from the ```java
public void onPlayerCommand(PlayerCommandPreprocessEvent event)
{
}
with obviously ```java
String[] args = event.getMessage().split(" ");
@glossy venture Hey
Dude you're gonna kill yourself over this one
Get a glass of water and take a seat
Please use the logger more often. Your folder is misnamed. You named it items it's supposed to be item
sigh.
what folder?
Your items folder in example->textures
try it
rename it from items to item
It is the problem?
Just do it
Unless you're saying that there is another problem in which case we're going in circles here
The one you sent me wasnt
pull new version
send it
just git pull -f
I'm not pulling the project I don't even know how to set it up
oh
Just generate another one that's broken or w/e
k
I checked this one
one sec
Cause it doesn't help if you're sending me stuff that is out of date
I'm gonna take a breather brb. IRL stuff is bleeding into my messages
I'm using MiniMessage, by parsing the strings from the config into (Minimessage) Components. However, I also want to replace placeholders, etc. So I saw the followingpossible ways to do this:
- Only turn the String into a Comonent AFTER I have replaced placeholders. That however means I have to parse the message everytime I send it
- Using some kind of custom Tag Resolver for MiniMessage, but not sure if thats even possible or if that also only gets called at the beginning. Also placeholders would have to be inside <tags>
- Using a TextReplacementConfig, but that means I'll have to provide a Regex Pattern to placeholders which gets nasty when I have nested placeholders :/
Does anybody have any idea on how to efficiently use Placeholders with MiniMessage? 😦
k thanks for the help so far
Just send me an updated pack that doesn't work when you can
bruh filebin storage is full
like the whole websit
e
but here is new generated pack
Alright and the issue is?
can i check if a PDC has a key of ANY type
yeah
for(PersistentDataType type : PersistentDataType.values()) {
if(container.has(key, type) return true;
}
It works for me?
what about custom values
custom values?
custom PDC types
it is
bruh what
nope
then it has to be an issue with my minecraft
Clear your packs and try again?
yeah, but why
eh its fine
yeah ima move it in manually now
Sets.of(PersistentDataType.BYTE, PersistentDataType.BYTE_ARRAY, PersistentDataType.DOUBLE, PersistentDataType.FLOAT, PersistentDataType.INTEGER, PersistentDataType.INTEGER_ARRAY, PersistentDataType.LONG, PersistentDataType.LONG_ARRAY, PersistentDataType.SHORT, PersistentDataType.STRING)```
@rough drift
wtf it still doesnt work
you can add your custom ones with them if u need to
nah its fine
I'll just check integer
all of the items will be created trough my method
so i can just add it as integer
I really just use PDC to store flags
You were using Fabric, have you tried Vanilla
Now it's not. 
Did it work?
why does this only return icanhasbukkit
Map<String, String[]> Commands = Bukkit.getCommandAliases();
for (String key : Commands.keySet())
{
Bukkit.getPlayer("TheTimeee").sendMessage(key);
}
still setting up multimc profi;e
Because it's the only alias defined in the file. You probably want to loop all commands and get their aliases
didnt find a reliable method to get a map of all commands yet
except for this Helper method
i guess
i mean i basically want this method but for all commands not just plugin registered ones Bukkit.getPluginCommand(null);
search the command map
if youre using paper i believe you can just do like Bukkit.getCommandMap()
otherwise you have to use reflection to get the field from craftserver
How are you zipping the files?
bruh filebin stupid
hm
Are you using a library or native stuff to zip
java zip output stream
winrar reads it fine
wait lemme put the unzipped folder
Java is zipping it poorly
and see
Something it's doing makes it unreadable
Yup
kek
<dependency>
<groupId>org.zeroturnaround</groupId>
<artifactId>zt-zip</artifactId>
<version>1.15</version>
<type>jar</type>
</dependency>
ZipUtil.pack(new File("pack"), new File("pack.zip"));
current zipping code
I tried this on the files and it zipped and it worked
you just zip the overall directory and it seems to work. Maybe it's because they've been unzipped idk
try it and see moment
ok the library is kinda huge so ill see how they do it and base it off that
i dont need 99% of the features
tysm
i didnt have time then
but i did it now
and it works
thanks
That's good
Using SQL, when executing a select statement and there is no record found, does it return null?
Hello i search to use multiple version of spigot in gradle 😢
i have some class with the name NMSHandler_1_18_R2 and the version
but is all version in this class like 1.13 to 1.18 not only 1.18
i see this https://www.spigotmc.org/threads/gradle-using-gradle-with-multiple-spigot-versions.443479/
but how to add in my project ?
ik prob dumb question but ive seen alot of ppl parse commands using if else if
isnt this much more efficient
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
switch (cmd.getName().toLowerCase())
{
case "sudo":
return Ranks.cmdSudo(sender, args);
case "desudo":
return Ranks.cmdDesudo(sender, args);
case "rank-create":
if (args.length == 1)
{
return Callbacks.getUUIDByName(sender, args[0]);
}
break;
case "admin-uuid":
if (args.length == 1)
{
return Callbacks.getUUIDByName(sender, args[0]);
}
break;
case "admin-inv":
if (args.length == 2)
{
return Callbacks.getInvByName(sender, args[0], args[1]);
}
break;
}
return false;
}
since the strings get parsed into their sha-1 code by the JRE anyway
premature optimization
makes decompiling it a pain in the ass
Also if you really want to optimize things
a huge switch statement is far worst than looking by hashcode on a map
i use switch 👉👈🥲
please don't judge me with this lol, I am a complete beginner, I know nothing about spigot development, I barely know any java. I tried to make a very simple plugin that just gives players effects on join (night vision and speed) after a slight delay, this is what I copied from a guy on youtube and a random article lol:
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
try {
Thread.sleep(700);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Player player = (Player) event.getPlayer();
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 999999999, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999999, 1));
}
}```
I probably have done something horribly wrong, please have mercy on me 😭
oh my, please do not sleep the main thread when a player joins
You can use a scheduler which is in Spigot to delay your task: https://www.spigotmc.org/threads/how-can-i-delay-this-task.177508/
I'll take a look at that, thanks
?scheduling
this sucks
reason: uses allman
I have a velocity plugin, i need to use JDBC driver, do i have to shade it in or can i use smt like spigot's libraries in plugin.yml?
huh
you’re stopping the server for 0.7 seconds every time someone joins
and the class “main” isn’t even a listener so that eventhandler won’t ever trigger
👀 if you wanna stop the main thread just use world builder atleast you get a new cool world out of it
yeah I'll come back here when I learn more stuff cuz I only understand english sorry
Oof, okay
Thank you for you help 👍
Wonder why it works with commandblocks
NMS Manipulation wouldn't work either right?
I don't think it does work with command blocks. Or at least it kicks off the passengers
Last I recall, at least. However this is like 7 year old 1.8 knowledge
I was making an elevator system with command blocks and the way to go is to have a falling sand block and a shulker ride an armor stand and then move that armor stand 0.05 every tick
Meaning it'll give you smooth movement
So it does work with Command blocks but I guess not with Spigot
Welp, back to the drawing board
how can i simply make kit system
think its just both 0
I am not able to compile because of me using a jar dependency instead of maven dependency (Maven doesn't exist)
oh
There is no “forward”
Each yaw angle corresponds to a cardinal direction
What are you meaning by “forward” in this case @quaint mantle
no? i tought there was a repo online
no, it's illegal to distribute mojang code or craftbukkit, you have to run buildtools if you want NMS
is it mapped with mojang mappings tho?
you can tell it to, yes
figure out what cardinal direction the head points in
the head is pointing in North, East, South, West, or some combination of two of those
then use the yaw corresponding to that direction
how
why is it actually illegal? because of the mojang code or craftbukkit code?
both
bukkit didn't get DMCA'd
lol
no
craftbukkit got DMCA'd
but bukkit doesn't rely on any mojang code, so there was nothing to DMCA
i mean spigot is still distributing bukkit
Is there a compiled version of https://github.com/WesJD/AnvilGUI ?
When importing that code, maven doesnt recognize it and the owner of a 200+ star repo CANT EVEN PROVIDE A COMILED VERSION.
WHY
No way, id didnt see that BECAUSE IM TOO STUPID TO READ THE README
YOU NEED MAVEN AND INTELLIJ DOESNT ALLOW IT IN AN FROM OTHER SOURCES IMPORTED CODESTUFF
it is
?paste your pom.xml
What POM? Just throw that stuff into IntelliJ
User error
For real, Spigot/paper/Bukkit couldnt implement such a feature in 4+ years...
maven?
Yes
uhm
intellij is not your build system, maven or gradle is
The plugin requres it
you realize they use maven, right?
Yes
You still need it as a plugin in the plugins folder afaik
no
naw
shade it
^
but reLOcaTE
Thanks
doesnt that only work for maven centrall
anvilgui is on codemc
libraries only works for central yeah
and you're supposed to use it for large non-minecraft APIs, not minecraft-specific stuff
local :peepogrin:
So something like JDA
I think JDA is on maven central anyways
it is
Is there a playerworldchange event, which is called before the player has changed its world?
PlayerTeleportEvent
How can an instance of a class that extends JavaPlugin be null if it is instantiated?
java.lang.NullPointerException: Cannot invoke "me.cosmic.farming.Farming.getConfig()" because "this.plugin" is null
Set your variables in the constructor
done, lemme test
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD, 1);
ItemMeta meta = playerHead.getItemMeta();
meta.setDisplayName(list.get(i).getName());
why does this set the meta to the players display name
how do i set an entities max and current hp
so, adding a listener for a PlayerTeleportEvent seems to fire the event 9 times for a basic /tp command...is there a reason for that? All 9 events seem to be identical, and I know from sending a message to the Logger about the event, and the message shows up 9 times
@EventHandler public void onPlayerTeleport(PlayerTeleportEvent event) { Bukkit.getLogger().info("Player " + event.getPlayer().getName() + " is in world " + event.getPlayer().getWorld() + " and is going to " + event.getTo()); }
I appreciate that, I'll likely use that instead...but is there still a reason I got 9 console messages?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
just to be clear, you're saying I need to be proficient at Java to understand why the message shows up 9 times?
oh, I was worried I was in over my head there
oh interesting...
well, as I'm going to use the other event anyway, I guess it's more an academic point now lol
but thank you for the assistance 🙂
Is there a way to get the Persistentdatacontainers of offline players?
Code:
package me.rudiemc.maintenance.Commands;
import me.rudiemc.maintenance.Maintenance;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class ToggleMaintenance implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Plugin plugin = Maintenance.getPlugin(Maintenance.class);
String prefix = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Prefix"));
Player p = (Player) sender;
}
}
guys sorry if you thought that was about any of you, i needed the links for a friend
how would i do that
((Zombie)entity).getAttribute() I think
well obviously you would check before
yeah sorry, that was for me XD
spawnEntity
public void spawn(Location spawnLocation) {
Entity entity = spawnLocation.getWorld().spawnEntity(spawnLocation, mainMob);
}
EntityType mainMob = null;
just wanted to be clear XD
set when instanciated
public CustomEntity(String name, float maxHp, float damage) {
this.name = name;
this.maxHp = maxHp;
this.damage = damage;
}
not random
but different
yes but how
k
...
thats a terrible way
what you mean
id have to hardcode each and every individual one
singleton meh
not really
copy and pasting over and over
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
no iirc
EntityType.valueOf() exists
When working with teams, it has the method addEntry(string Entry). What...is an entry? And how do you turn a Player into a string to add it to the Team? Is the String supposed to be the UUID or something? I'm not sure what an "entry" is
iirc its a player name
Ah, the player's name, that works. Thank you
so anyway is there a better way than manually hardcoding?
as hardcoding fans are clowns
What for example if I needed to open an offline player's inv?
you would need to save every players inventory to a file
how to get a player from a UUID?
ty
okay ty
you should always check wether it actually is a living entity tho
otherwise youll get tons of errors if it doesnt tell you its an unchecked cast before
item
dropped items arent
question
ask
not sure what you mean
that works
do i need to do it
but why would you want ot
not sure why u would cast a living entity to an entity
any living entity is an entity and thus has the same methods I think.
correct
you could just cast it using entity = (LivingEntity) entity after checking wether it actually is a living entity. its still the same entity you have saved in that object, you just specified it
minecarts arent iirc
if(entity instanceof LivingEntity livingEntity)
huh
never seen that syntax before
ah thats why. I have to use java 11 for projects, its a pain XD
instanceof I know, just not the LivingEntity livingingEntity part
oh I see
why???
ik
java does not add features and release
they do bug tests
they are really really cautious
well, cant really argue with someone who grades your projects, can ya
nah not really
they are pretty dum
they should use j17 rather than 11
or even j18 or j19
there are releases for them alr
i dont really care, since I still do pretty good with coding projects, no matter the java version
alr
What's this field for in 'Share Project On GitHub'?
Hi, anyone know how I'd need to go about making a player use the currently held item, I have gathered that I'll need to use packets but am not fully sure how to go about doing it
Hi! i have a question
Why are the "pods" non-water blocks still considered not-air blocks?
like why is this block considered a not-air block?
how can i make simple a simple kit class
It could be CAVE_AIR instead of normal AIR. I think those pockets of water can be generated in caves. It might be close to one and had some air overridden.
yo, how do you cast a block into an itemstack?
like i want to turn a block into an itemstack, but if i cast it gives me an error
get the block material then create an itemstack with that material
ty!
Get the block type and use it for the material for the ItemStack.
oh yeah, thanks!
But why did they use CAVE_AIR instead of plain regular good old AIR?
why must they differentiate it?
i'd assume world generation
idk. Cave air is really just a relic of the past. It may have some internal use that no one is aware of, but it’s probably just one of those features that were going to be expanded upon but ultimately never were.
🤷🏻♂️
how to get a location of a player and then write it in chat
My best guess would be that it revolves around the temperature values that exist for biomes. Second best guess is it’s an easy way to check if players are in caves so the game can play the spooky sounds.
get the Location object using player.getLocation(); and then print in chat the x, y and z coordinates (and also the world name if you want)
Player#sendMessage(Player#getLocation))
im trying to make it say the coords they died at but all i have right now is telling the player they are ded instead of "You died at X Y Z"
Bukkit.broadcastMessage(player.getLocation().toString())
and the VOID one?
is that for damaging?
pretty sure mc uses cave_air to generate underwater caves
Honestly no clue about that one. Probably for damaging, but a simple integer comparison would be far more efficient.
. use this! to get the x coordinate use location.getX() and so on
Well, you could get the specifics from the other methods that exist.
you can even print the pitch and yaw angles if you want
I just didn’t want to write out Location#getX getY etc.
You wouldn’t need to cast if you used getBlockX
use string.format please
Yea. 😛
why did you photoshop in a semicolon
getBlockX Y and Z return an integer.
i really don't like this casts i see everywhere. If i really want to get the integer value from a decimal number i would use Math.round();
i forgot that while coding so i added it to the screenshot instead of rewriting the whole thing down just for that
concatenation is the devil if used more than like twice
My plugin doesnt show up when I type /pl
Main class:
package me.rudiemc.maintenance;
import me.rudiemc.maintenance.Commands.AddPlayer;
import me.rudiemc.maintenance.Commands.RemovePlayer;
import me.rudiemc.maintenance.Commands.ToggleMaintenance;
import me.rudiemc.maintenance.Listeners.PlayerConnectEvent;
import org.bukkit.ChatColor;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class Maintenance extends JavaPlugin {
static Maintenance plugin;
public String prefix = ChatColor.translateAlternateColorCodes('&', getConfig().getString("Prefix"));
@Override
public void onEnable() {
// Register Commands
getCommand("togglemaintenance").setExecutor(new ToggleMaintenance());
getCommand("addplayer").setExecutor(new AddPlayer());
getCommand("removeplayer").setExecutor(new RemovePlayer());
// Save Config
getConfig().options().copyDefaults(true);
this.saveDefaultConfig();
// Register Listeners
this.getServer().getPluginManager().registerEvents(new PlayerConnectEvent(), this);
plugin = this;
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
and yes
i did build it
and add it into the plugins folder
but when i executed /plugins in the console
my plugin didnt show up
Do you have a plugin.yml
It probably spit out an error in the console when trying to load your plugin
So send that
the error
sure ok
@hasty prawn
if i have two extra lines
after the last line
of my plugin.yml
does it generate an error..?
Probably not unless there's white space there like tabs
package me.rudiemc.maintenance;
import me.rudiemc.maintenance.Commands.AddPlayer;
import me.rudiemc.maintenance.Commands.RemovePlayer;
import me.rudiemc.maintenance.Commands.ToggleMaintenance;
import me.rudiemc.maintenance.Listeners.PlayerConnectEvent;
import org.bukkit.ChatColor;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class Maintenance extends JavaPlugin {
static Maintenance plugin;
public String prefix = ChatColor.translateAlternateColorCodes('&', getConfig().getString("Prefix"));
@Override
public void onEnable() {
// Register Commands
getCommand("togglemaintenance").setExecutor(new ToggleMaintenance());
getCommand("addplayer").setExecutor(new AddPlayer());
getCommand("removeplayer").setExecutor(new RemovePlayer());
// Save Config
getConfig().options().copyDefaults(true);
this.saveDefaultConfig();
// Register Listeners
this.getServer().getPluginManager().registerEvents(new PlayerConnectEvent(), this);
plugin = this;
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
Need the error
oh
wait
can I do it later
like
can i send the error later
I've to go somewhere
Yes
sure ok
bro
I changed a boolean to a string
And
changed everything in my code
and the solution was so simple
😩
Is there a way, that I say a zombie /... it should walk to a location?
Thanks I'll try it when I can and tell you if it works
but
the error was in config.yml
not the main class
That will only work if the other classes are trying to access plugin.
Which, perhaps they are, so you should still do that. But I doubt that's the main cause.
can you use spongepowered mixins standalone?
Yes I'll move plugin = this; to the top of onEnable
without any minecraft environment
does anybody know why this isn't working? it isn't giving me any errors too. java public static void addEnchant(ItemStack item, Enchantment enchantment, int lvl){ item.addUnsafeEnchantment(enchantment, lvl); List<String> lore = new ArrayList<String>(); ItemMeta meta = item.getItemMeta(); if(meta.hasLore()){ meta.getLore().add(enchantment.getName() + " " + lvl); }else{ meta.setLore(lore); lore.add(enchantment.getName() + " " + lvl); } item.setItemMeta(meta); }
you could try using nms pathfinding
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Is this included in SpigotAPI or is this an extra API?
it isn't adding a lore to the item and it isnt giving me errors so i dont know how to solve it
You're setting it before adding to the list
idk but i think you have to call setLore(...) after modifying it
It's supposed to be meta.setLore(...) I think
Would anyone be able to help me out with this?
so you want the player to only be able to use the item in one slot?
Bro i found the error
after you add stuff to meta's lore
you set it back to default
like
yeah
string list lore does not have any changes made to it after it's defined
No, I want to make the player interact/use the item they are currently holding
fuck
Not there
still need to modify
After that
this won’t work
yes
i know
you forgot to modify lore
xD
that seems difficult
you could try to instance a playerinteractevent and then call it, but i don’t know if that would work
I am fairly certain it is possible with the use of packets
anyone know
it’s not
I've seen it mentioned before
like this right? java if(meta.hasLore()){ meta.getLore().add(enchantment.getName() + " " + lvl); }else{ lore.add(enchantment.getName() + " " + lvl); meta.setLore(lore);} item.setItemMeta(meta);
You can.
still won’t work
exactly
You'd just have to figure out how to apply it to a Minecraft-less environment.
so how?
Good luck, their API is fucking complicated as hell.
instead of doing all of that, just set your lore list to meta.getLore()
then add your stuff to “lore” and set the lore on the item meta
then add the item meta on the item
but the lore can be null
wait let me try
you’re doing meta.getLore().add(), which won’t do anything since getlore just returns a copy
or
yes lore can be null
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.List.add(Object)" because the return value of "org.bukkit.inventory.meta.ItemMeta.getLore()" is null
in that case, keep the if statement just don’t do getlore.add
this doesn’t have to do with packets though
if i do it like this, the lore would be replaced with the new one
not really
since
at first, you set List's value to the old lore
then you add something to the List
and then you set the List as the item's lore
so it should have the old lore as well as the stuff you added
probably?
but the old lore can be null
that's why i made the if statement
yes
but it isn't still working
List<String> lore = meta.getLore() == null ? new ArrayList<>() : meta.getLore();
Sorry if I used the wrong terminology, but there has to be a way of going about doing this. I am specifically trying to make the player retract their fishing rod line.
tf is that
It's called the conditional operator
damn
condition ? if true : if false
oh
(fun fact, Kotlin allows you to simplify this to val lore = meta.lore ?: listOf())
yeah kotlin is great
more languages should have elvis operator
And yet people talk shit about it constantly for no good reason
It'S tOo DiFFeRent FroM jAvA
Maybe that's a good thing, you pricks
Uhh yeah it's like
i cant seem to get it
org.spongepowered:mixin:<version>
i have org.spongepowered:mixin:0.8.5-SNAPSHOT right now
You need to use their repo
this is the same thing that I did before
public static void addEnchant(ItemStack item, Enchantment enchantment, int lvl){
item.addUnsafeEnchantment(enchantment, lvl);
ItemMeta meta = item.getItemMeta();
List<String> lore = meta.getLore() == null ? new ArrayList<>() : meta.getLore();
lore.add(enchantment.getName() + " " + lvl);
item.setItemMeta(meta);
}``` like this right? This isn't working
do meta.setLore(lore) after adding it
opsies haha
it probably is possible, just probably difficult since a lot of that interaction is handled by the client, which you would have to simulate perfectly. in your specific situation, there’s probably an easier solution, maybe just simulating a fishing rod being retracted
now it's working correctly! tysmmm
uh guys i need help
if (p.getPlayer().isDead()) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aYou have died. &bLast location: ") + p.getLocation());
}
``` it's not exactly how i expected it to be
if (p.getPlayer().isDead()) {
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aYou have died. &bLast location: " + p.getLocation());
}```
this should be correct i think
uh
what did you even change?
oh the )
well i mean the location
I thought it was going to like "X Y Z" but no its a lot more
it says yaw and stuff
well yeah, a location includes that
you could just get the x y and z individually if that’s all you want
or a better option would be making a function that takes a location, and returns your formatted string
I actually am trying to do that and i hope what i wrote is correct lol imma try it
brb
you could, but i would recommend using the other way
yup I did it
what i wrote is correct and exactly what i wanted
is the /reload even worth using?
most of the times it says it wont work
YO DID DISCORD CHANGE FONT
Resetting?
am I not doing that at meta.setDisplayName()
so how do I do that
oh
ok I know
I just checked my code and it does have the setItemMeta()
so i made a custom item but i was wondering how i can craft it with the custom lore
if (config.getBoolean("Bad_Omen_Potion")) {
new RecipeManager("Bad_Omen_Potion", new ItemStack(Material.POTION))
.shape(
"L L",
" S ",
"L L")
.set('L', Material.EMERALD_BLOCK)
.set('S', Material.GOLD_INGOT)
.register();
}```
do i change item stack orrr
just modify the itemstack before you add that recipe probably
i have this
public static ItemStack bad_omen;
public static void init() {
create_potion();
}
private static void create_potion() {
ItemStack item = new ItemStack(Material.POTION, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("Bad Omen potion");
List<String> lore = new ArrayList<>();
lore.add("Right click to get bad omen");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK, 1, false);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
bad_omen = item;
}
is this a class?
why not just return the item from one of those methods instead of setting it to the field
also having a method that links to another one seems pretty pointless in this case
uhh wdym
oh i think new RecipeManager("Bad_Omen_Potion", new ItemStack(ItemManager.bad_omen))
would work
ill try it
if you ever try using that itemstack again though it’ll break things
what will break?
it doesn’t make sense to do that entire process where you make an item, set it to a field, and then clone it instead of just calling the method directly and returning the item
since you’re only ever creating one itemstack object, if that ever changes then everything else that uses that field will as well
will this repeat the same thing over and over again?
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> p.setScoreboard(board));
no
.getScheduler().runTaskTimerAsynchronously(plugin, <task>, <interval>);
syntax might be wrong since i’m on mobile
Damageable damaged = (Damageable) item; damaged.setDamage(56); respawnItems.add((ItemStack)damaged);
This method does not work for setting the durability of a new item, it doesn't keep its damage when casted to an itemstack apparently
how do i do this properly?
you don’t need to cast it
wdym
“item” is an itemstack right
you removed the (ItemStack) cast and it doesn’t work?
hm I tried but it doesnt seem to be working
let me try fixing
correct
that doesn’t make much sense
is damageable an interface?
i don’t use later versions that much
Bukkit.getScheduler().runTaskTimerAsynchronously(this, (p.setScoreboard(board)), 10, 10);
``` yeah I have no idea on how to use this thing.
I am new to coding plugins. What would be the best way to implement 'gravity', so to say, for a NoGravity armor stand?
The first thing that comes to mind is simply just checking the block below the armor stand and moving it down, but perhaps there might be a better way I do not know of? I tried looking online, but my search results did not end up with anything useful
that will work, you just didn’t do the lambda right
() -> p.setScoreboard(board) should be it
?scheduling
good wiki on it
^
yes it did it
I was just dumb
XD
also how much is the delay and period
idk what are these
the delay is 20 = 1 tick right?
what is the period?
#runTaskTimerAsynchronously(<plugin>, <task>, <delay>, <period> );
the docs explain it
public class LecternScreenMixin extends Screen {
protected LecternScreenMixin(Text title) {
super(title);
}
@Inject(at = @At("TAIL"), method = "init")
public void init(CallbackInfo ci) {
this.addDrawableChild(new ButtonWidget(10, 10, 160, 20, Text.of("Crash Server"), (button) -> {
ScreenHandler screenHandler = client.player.currentScreenHandler;
DefaultedList<Slot> defaultedList = screenHandler.slots;
int i = defaultedList.size();
List<ItemStack> list = Lists.newArrayListWithCapacity(i);
for (Slot slot : defaultedList) {
list.add(slot.getStack().copy());
}
Int2ObjectMap<ItemStack> int2ObjectMap = new Int2ObjectOpenHashMap<>();
for(int slot = 0; slot < i; ++slot) {
ItemStack itemStack = list.get(slot);
ItemStack itemStack2 = (defaultedList.get(slot)).getStack();
if (!ItemStack.areEqual(itemStack, itemStack2)) {
int2ObjectMap.put(slot, itemStack2.copy());
}
}
((ClientConnectionAccessor) client.getNetworkHandler().getConnection()).getChannel().writeAndFlush(new ClickSlotC2SPacket(client.player.currentScreenHandler.syncId, client.player.currentScreenHandler.getRevision(), 0, 0, SlotActionType.QUICK_MOVE, client.player.currentScreenHandler.getCursorStack().copy(), int2ObjectMap));
client.player.sendMessage(Text.of("Crashing Server..."), false);
button.active = false;
}));
}
}
any one cane tell what is this exploit doing ?
it crashes server
what packet is sent
ClickSlotC2SPacket, what arguments is that taking?
what d o you mean
it is book glitch
The server just doesn#t handle it correctly
both paper and spigot already patched this
lectern glitch
see their commit history and figure it out
Update to latest CraftBukkit, fixed last night
most the server crashes people find now are lame
just stressing a server until it times out
ArrayList<Player> list = new ArrayList<>(p.getServer().getOnlinePlayers());
Inventory bangui = Bukkit.createInventory(p, 45, ChatColor.BLUE + "Player List");
for (int i = 0; i < list.size(); i++) {
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD, 1);
ItemMeta meta = playerHead.getItemMeta();
meta.setDisplayName(list.get(i).getName());
ArrayList<String> lore = new ArrayList<>();
lore.add(ChatColor.GOLD + "Player Health: " + ChatColor.RED + list.get(i).getHealth());
lore.add(ChatColor.GOLD + "XP: " + ChatColor.AQUA + list.get(i).getExp());
meta.setLore(lore);
playerHead.setItemMeta(meta);
bangui.addItem(playerHead);
}
p.openInventory(bangui);```
why does this code always show the player display name as the item meta?
meta.setDisplayName(list.get(i).getName());
? that sets the item meta to the player name
displayname is apart of meta, you have to set it in the meta to change the display name
no i want to show the players real name not the display name on the meta
that makes not a lot of sense
getName should get the real name
no it gets the display name
it shows the display name
show screenshot
which is?
ok
maybe Player#getPlayerListName()?
without making or installing a bungee plugin, how could I make proxy restart automatically every day?
I do have the code on my spigot plugin (which I use on every of my servers by the way) to restart the server, so all servers can get auto restarted, but not proxy
no
i still want the proxy to close cleanly
plus i don't like pterodactyl
is there a way to execute /end from a spigot plugin (with plugin messaging for example) (without needing to put any additional code/plugin on proxy)
doesn’t /end just stop it indefinitely
yeah but my file while true runs it
so whenever its stopped it restarts
(its a pretty standard design)
you infinitely attempt to run the proxy?
that sounds like a bad idea
no i swear this is used often
like you aren’t even checking if it’s down?
because it cannot attempt to run it while its running
its in a syncchrnous logic
bro its just a standard restart file really
but i don't want that
to autorestart
😛
not to close down
i mean closing down restarts
so whatever either auto close or auto restart
both are equivalent in my case
so you want to close your proxy from a spigot plugin
should be accomplishable with plugin messages
im curious yes
because bungee sucks because i don't like bungee and it kinda breaks all my design;
I've been opting for a 1plugin per server instead of a centralized plugin for all servers
It has many advantages, more customizability over each server,
but disadvantage i guess,
But yeah making a central bungee plugin would kinda go against the philosophy i've been ^putting to my impl
first time hearing of a philosophy against making bungeecord plugins
sure :p
it doesn’t really make sense
bungee plugins exist to be on a bungee proxy
not on every server in a plug-in message
im not sure what u want is possible without a bungee plugin
ok then thank you!
Pterodactyl is an open-source game server management panel built with PHP 7, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
Myeah well if you use sth like ptero then it’s pretty much already done for ya
well he doesnt like ptero
but doesn't it abruptly close the process?
Understandable, but having your own custom duct taped solution is error prone
Wouldn’t say abruptly
Like you can setup certain routines
btw conclure i managed to find a way for my player data sync issue. ended up making a standalone application that manages all the data & servers can request pieces of that data with redis pub/sub
its working pretty nicely
That’s nice
i see, i'll think about it thank you:)
How would I use an entity in a different class?
could you be more specific
Sure
I have an armorstand defined in a method in a command that implements CommandExecutor and I want to use it in a Listener class. Both classes here: https://paste.md-5.net/opomewacuh.java
haha yea
you would set it as a field in that class
in the class where the armorstand is defined?
no
in the listener class
also why are you defining what your plugin is in every class?
That's another perfectly valid way to do it if not it being a better practice
I can't do that without the actual entity?
what?
Dependency Injection is a better practice than static access
Thanks, never used it or seen it
He's a static only guy
You used it on your code already tho
oh
lol
If you would ask me what it is, I would not be able to say lmao
Like whenever you pass an object through a function/construction then that’s pretty much dependency injection
ah
it doesn’t really change anything in his case though since it’s only applicable to his plugin
The name is just a bit fancy for what it implies
Mk, yea I just need the exact entity I spawned
Dependency injection is more portable
Alright, I'll try that
good pun
Mye, for spigot Idm whether you use a singleton or dependency injection I suppose at least as long as you’re not planning to scale your project

whats the good mining plugin
when you mine, you instant get money for mining that.
probably getting the air block that it got hit at
That doesn't even work with what he's asking
what i mean is that line of code is probably getting the air block
get Entity refers to the projectile correct?
not the actual block it hit
@Override
public void onEnable() {
// Plugin startup logic
SomeClass sc = new SomeClass(this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
-----------------------------
public class SomeClass {
Plugin plugin;
public SomeClass(Plugin plugin)
{
this.plugin = plugin;
}
}
^ dependency injection
Hey! I have multiple of these layouts and I want to prevent anyone from going in the red area how would I do it?
Myes altho if possible tho pretty much avoid passing your plugin type
wouldn’t that only work if the plugin is specifically “Plugin”
well you would use your own classes yeah
that up there is just a concept, not a copy paste thing
:/ you can also use JavaPlugin
For api
ik but in that example it was just Plugin
Also the name instance is probably something you wanna avoid as that is softly reserved for the singleton pattern
^
Anyways I’d much rather see people pass their instances than rigorously enforcing static state over their design so noice
Static pattern is awful for scalability
I think people do that because if you go to youtube and look up spigot tutorial the youtubers create a static method to get the instance of the plugin

Yea I learned java alongside spigot so I knew that was a NoNo lol
I yelled at my friend for abusing static
Hehe
yes DI is very clean
I remember the first time someone told me to do dependency injection it seemed like such a fancy term and I didnt know that I had already done it before, just didnt know what it was called
Ye
never knew what the downsides of accessing something statically were though, what are the downsides?
I should make my own Spigot tutorial
Oh yea
https://paste.md-5.net/acozutijaf.java It says the entity is null: Cannot invoke "org.bukkit.entity.ArmorStand.getPersistentDataContainer()" because "a" is null
just make it a field
Atrociously maliciously impossible to maintain in any concurrent environment (static state) (why for example SimpleDateFormat is a sin), static generally provides no abstraction at all, static makes it extremely hard to unit test which most enterprise companies use heavily, static also couples code like crazy and decreases a component’s general reusability, nevertheless does static take away type usage as for instance the ability to use generics which depends on types.
But I mean for constants, for stateless data, for general helper functions that abstract away manual management of side effects as well as utility functions
Conclure how much math you got in you?
Learning group theory and category theory rn lol
i only really ever use static for plugin getting
its a basic trig question
lmao same
Oh my expertise is definitely not trigonometry or well normal calculus in general, but sure ask away
👀
There are 2 fields in both classes, is this what you mean?
if you want to use that specific armor stand in your other class, you would add a field for it along with getters and setters so you could use it
Have you looked at the code, because I think I've already done what you mean here.
looked at your old haste by accident
No problem haha
you’re getting it, but you aren’t setting it anywhere
What do you mean anywhere? Where would you suggest setting it?
it depends, are you planning on there being multiple cows? do you have a reference somewhere to this object you can use?
- Yes
- I don't have a reference yet
with what you have right now, you’ll only be able to access one cow
since you registered that listener at the start of your plugin presumably
Yes
Is there a way I can access all the entities that belong to the player?
Like for each entity that needs to be moved run that method
you could use a map of the players uuid and the entities
also, don’t put a SpawnCommonCow field, use the actual entity
Mk, I'm assuming I should store the map in the javaplugin instance?
put it in your listener if that’s where you’re intending on using it
Well no, I'm planning to use it in other listeners too.
well then you could either make it static, or add a reference to the listener object it when you first initialize it that other classes will be able to access
Ok, I can give that a try
what's the correct way to apply a patch from another spigot branch into the main if the file to patch has been changed over time (I'm speaking about NMS patches from CraftBukkit)?
I have an item that I retrieve from an inventoryClickEvent and I would like to retrieve its shorts
example: the orange wool shorts is 1 (the full id is 35:1)
Currently I'm doing an event.getCurrentItem(); to retrieve the item
i don't know
Does anyone know how I could have players regain health regardless of their food level?
I want to use the hunger bar for showing when an ability is charged
maybe EntityRegainHealthEvent gets set to canceled when hunger is below certain amount?
i already am for a different ability
perhaps i could send packets for it so it wouldnt actually change it
any way to get right eye location?
There is only one eye location. Player#getEyeLocation()
yeah i know that
im spawning a entity in that location but it keeps covers the screen so i want to spawn it right side of the screen
Then just offset it a little bit. It won't be perfect for everyone as people have different FOV settings, but usually half a block would do.
You may need to do some calculations for which direction to add or subtract the x and z value from, but you can use the player direction to help with that.
.... that is what i want to find
i think i have to use vector
but that is literally one thing i am weak at
You don't have to use vectors if you don't want to. There is a method that takes doubles in as the x,y, and z parameters and you can use that instead.
Something like Location#add(0.5D, 0, 0.5D) would suffice. If you wanted to move in a negative direction, you'd use Location#add(-0.5D, 0, -0.5D)
Yes, but you still need to register both of them with the proper methods.
As a class that contains both a command and a listener.
umm bro no think about it.
offset will be different on player's direction you can't just add or subtract any value
Yea... that's why I said this earlier:
You may need to do some calculations for which direction to add or subtract the x and z value from, but you can use the player direction to help with that.
@kind hatch
how would i get properties from my config file outside of the main class? i tried doing something like this private final Main pl = new Main(); but unsurprisingly it gave me an error
i cant make a static method that returns the config because the config is non-static
also rather than using hunger you should use either a bossbar or the exp bar
using hunger will probably cause some unnecessary complications
yeah im already using the exp bar and boss bar. I think ill just use a random item cooldown and set it fixed in their hotbar
you can make more than one boss bar btw
if u want to use abilities then an item probably will be the best way
yeah im the boss bar for objectives not cooldown. unless i can reposition the boss bar
Well vector math isn't my specialty, but there is a method you can use to get the player's direction as a vector. Player#getLocation()#getDirection() which will return a vector based on their pitch and yaw values. You could then add a new vector on to this using Vector#add().
well i know that because although im not best at it i just know some thing
The main class is a singleton instance. You're really not supposed to try and create new instances of it. You could create a static getter in your main class, but most people just use dependency injection for accessing things in their main class.
but how the frick can i change vector vertically
i already tried a static getter, but since the config is non-static it wont work, but ill try dependency injection
Well there is a tutorial on the wiki if you wanted to look over it. https://www.spigotmc.org/wiki/vector-programming-for-beginners/
ik that too... ;-;
I'm trying to change a player's skin to a random skin when they join, but it isn't changing their skin. D: There are no errors. https://paste.md-5.net/nisudahulo.java
You get their profile. Do you have to set it again?
Because only the last repetition is captured
Which bit are you trying to get
?
Idk how to make it more clear 
I mean, isn't that what the connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.a, craftPlayer.getHandle())); is for?
I'm new to plugin development and I was wondering why this isn't working, I'm getting no errors but it just doesn't work lol
public class BlockReset extends JavaPlugin implements Listener {
@EventHandler
public void OnBreakEvent (BlockBreakEvent e) {
Player p = (Player) e.getPlayer();
Block b = (Block) e.getBlock();
if (b.getType() == Material.COAL_BLOCK) {
e.setCancelled(true);
b.setType(Material.BEDROCK);
p.getInventory().addItem(new ItemStack(Material.COAL, 9));
this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { b.setType(Material.COAL_BLOCK); } }, 20 * 15);
}
}
}```
You registered the event, right?
I realized I forgot to register the event so I did that and now my plugin is red, woo!
Poggers.
Hi
Anyone know any good resources for making custom classes for custom entities? I’m trying to make a custom projectile
fixed it lol
So anyone?
so im having issues all of a sudden with creating new projects in intellij
keep getting this
Cannot resolve org.spigotmc:spigot-api:pom:1.18.1-R0.1-SNAPSHOT failed to transfer from https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigotmc-repo has elapsed or updates are forced. Original error: Could not transfer artifact org.spigotmc:spigot-api:pom:1.18.1-R0.1-SNAPSHOT from/to spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/): transfer failed for https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/spigot-api-1.18.1-R0.1-SNAPSHOT.pom ```
Try doing File -> Invalidate Caches
nope it wont register anything its acting dumb, even after a reset and import project back is t he same t hing
Change Skin
