#help-development
1 messages · Page 1437 of 1
but what do people mean by register?
As I said, Ill do what you recommended to me.. 😄 but it wont solve the problem 😄
The fact it says that it is never used by IntelliJ doesn’t matter
It’s because the event handler calls it not ur code
also, the error likely caused from error on server startup caused your plugin to shutdown... so show us your main class
and the error
or else we can't help you
is there a way to fill an inv with a material if the slot is free? i could do a for i = 0 i < size and if the slot is free, but i wonder if theres something like fillWith
{
@Override
public void onEnable()
{
//check if files and databases exists etc
new SetupDefaults(this);
//register EventManager
getServer().getPluginManager().registerEvents(new EventManager(), this);
getCommand("stats").setExecutor(new stats());
System.out.println("[FoxStats] Plugin enabled.");
Plugin plugin = this;
new BukkitRunnable() {
@Override
public void run() {
DatabaseCleanup cleanup = new DatabaseCleanup();
cleanup.runTaskTimer(plugin, 0, 72000L); //every hour check for available database cleanup
}
}.runTaskLater(this, 1);
}
@Override
public void onDisable()
{
System.out.println("[FoxStats] Plugin disabled.");
}
}```
and error here: ```[16:08:58 ERROR]: [FoxStats] FoxStats v0.0.1 BETA attempted to register an invalid EventHandler method signature "public void eu.skyfox.foxstats.events.EventManager.onPlayerHarvest(org.bukkit.event.player.PlayerHarvestBlockEvent,eu.skyfox.foxstats.storage.MySQL)" in class eu.skyfox.foxstats.events.EventManager ```
Than why the onBlockDropItem works fine? 😄
you're only passing that method the event
well I think it's easier for me to use an eventlistener class
Like, if I only leave @EventHandler public void onPlayerHarvest(PlayerHarvestBlockEvent e) { System.out.println("Harvest!"); }, it still does not execute, thats the weird thing.. 😅
oh wait
oh, yes, thank you! that solved the startup error, Im so dumb...
There is normally no reason not to send an actionbar to a player. Any idea?
athough it still does not do anything 😅
Is there a limited number of characters in the message? so it didn't work 🤔
did you register the listener?
me?
yes
well you didnt register the event
do getServer().getPluginManager().registerListener(this, this)
I gave up using NMS and turned to this. I forgot
i think you should use TextComponent.fromLegacyText
yeah, sorry my dumby xD
its alright
yeah god thanks, working now. I just can't believe I spent 30 minutes doing this -_-
I have the same issue and trying this gives me an error
oh sorry maybe its registerEvent
registerEvents*
oh yea
yeah sorry i didnt have my ide opened and didnt remember it
i hope that works 🥲
well uh its still not working
public class MagmaBuildNetwork extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getLogger().info("onEnable is called!");
// This will throw a NullPointerException if you don't have the command defined in your plugin.yml file!
this.getCommand("ignite").setExecutor(new PluginCommandExecutor(this));
getServer().getPluginManager().registerEvents(this, this);
saveDefaultConfig();
}
@Override
public void onDisable() {
getLogger().info("onDisable is called!");
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
event.getPlayer().sendMessage("Welcome to the server!");
}
}
It gives me no welcome message..
someone who has ideas?
does the plugin load?
yes
do you export it into right directory?
which configuration do i need to use for that?
wdym by configuration
no you dont do this
uh
press ctrl alt shift s and do artifacts
well there's nothing there
well you need to create it
am i allowed to ask a question about intellj idea here
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
Is it possible to add spigot.jar directly to pom without sending it to libs?
and how, can anybody help me ^^
wdym by sending it to libs
what means "wdym" my main language is not eng sorry
which is better to use mysql connection (regular) or mysql pool? For Minecraft Network
"what do you mean"
uhh for some reason the playerjoin still isnt working
public class MagmaBuildNetwork extends JavaPlugin implements Listener {
@Override
public void onDisable() {
getLogger().info("onDisable is called!");
}
@Override
public void onEnable() {
getLogger().info("onEnable is called!");
// This will throw a NullPointerException if you don't have the command defined in your plugin.yml file!
this.getCommand("ignite").setExecutor(new PluginCommandExecutor(this));
this.getServer().getPluginManager().registerEvents(this, this);
saveDefaultConfig();
}
@EventHandler //THIS ONE
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
event.setJoinMessage("&7[&a&l+&7] &b" + p.getName() + " &7joined the server.");
}
}
try stopping the server removing the plugins folder, start the server let it make the plugins folder then stop server, put in your plugin then start and see
I know this might sound nooby but how can I have a hashmap be synchronized between classes? I currently have special items which have per-item cooldowns in their classes, so how can I set a value in the hashmap in those class so the cooldown goes away when I run a method from my commandhandler class?
make the hashmap static
Ok, just making sure. Thanks
then access it with ClassName.hashmap
oh no no no
does anyone have an example of a multipage inventory to display as many items as i want to?
static hashmap, oh no no no
with like an arrow that sends you to the next / previous page
Usually you don't want to expose the HashMap to other classes.
So create a manager class.
Ok, so a class which will manage all of the cooldowns?
Yes.
Alright, so then how should I change the values of those cooldowns from my commandhandler class? Just use a getter-setter method?
Using dependency injection.
Alright thank you, Ill look into that.
can i use color codes inside the "onEnable is called":
@Override
public void onEnable() {
getLogger().info("onEnable is called!");
}```
How can I remove the anchor block explosion?
and cmd?
@EventHandler
public void anchorExplode(BlockExplodeEvent event) {
event.blockList().clear();
log.info(event.getBlock().getType().toString());
/*
* This does blocks ALL block explode events
* including beds.
* This has to be fixed at some point, but
* currently event.getBlock()
* doesn't give the right block.
*/
}
I can't use BlockExplodeEvent, because it happens before the explosison.
Look: Color codes in the console are hard to do
Your terminal has to support ANSi color codes and V100
Which doesn't happen a lot
and ingame? bcs i now get this
(cmd doesn't allow it to hapen easily too)
Color.GRAY
well i want to use different colors so that would be a very long sentence
lets try then
Wait a second
hu
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "your string"));
Here you go
It's ChatColor.RED for red
BTW
Did you see this
this
Bukkit runnable or EntityMoveEvent
maybe this works
this.getLogger().info(ChatColor.RED + "Color test.");
at least I think entitymoveevent exists
That event does not exist
nope its only in paper
For obvious reasons
in that case I would use a bukkitrunnable if you only need to run something every tick
how do you do that?
It’s not in paper either
or it could be every second.
oh i dont mean that, no, you misunderstood
wait
You can also see this for bukkitrunnables: https://bukkit.fandom.com/wiki/Scheduler_Programming
I wanted to say is there a way to use it by adding something directly to pom.xml without adding it here
Hey pls someone know how to restart the ender dragon fight as if a player placed the 4 ender crystal on the portal, I have tried to use dragonBattle.initiateRespawn() where dragonBattle is the battle linked to my World but it doesn’t work
@gaunt eagle https://www.spigotmc.org/wiki/spigot-maven/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I Know this but if I do it I will have to replace all crystal and to recreate a bossbar :/ but if it’s the only way . .
ig then just kick everyone out of the world and recreate it
That will destroy any end farms
Yeah
But what really annoy me is that there is a method for what I want to do but it doesn't work x)
im getting this error when i start my server up:
java.lang.NullPointerException: null
at com.defiantburger.tutorial.tutorial.onEnable(tutorial.java:27) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-651]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.5.jar:git-Paper-651]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.5.jar:git-Paper-651]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) ~[patched_1.16.5.jar:git-Paper-651]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:591) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:281) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1065) ~[patched_1.16.5.jar:git-Paper-651]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-651]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
hello, does anyone know how to make text that can appear over the toolbar?
for some reason it has an issue with this line:
getCommand("top").setExecutor(new top());
do you have top in plugin.yml?
ofc, i cant believe i forgot that
thats what i forgot
ty
you wanna send an actionbar from what i think. what version u use
my server uses 1.16.5
/ latest build
yw but u found it yourself
soon gonna switch to 1.8.8
when do you wanna send the actionbar
Basically, i have an vanish command, and I want it to send whenever an player goes in vanish
or, send it and remove when player goes out of vanish
okay you may wanna try player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("Message"));
Okay, let me try
ok
Anybdoy know the event for Enderdragon spawn
or just Entity spawn?
check for entityspawn and then if the entity is enderdragon
it worked! tysm :D
Is there any way to make the text like a little transparent?
i dont think so
alright, thank you!
yw
i mean you forgot naming conventions as well
wdym
EntitySpawnEvent?
top -> CommandTop or TopCommand
top is lowercase, doesn tmeet convention
and command classes should start/end with Command
ok i didnt know that
also, is there a way to detect the location that a raycast ends at?
Get the location of what it returns
ig
ray.getHitPosition?
I get a nullpointer exception w/ this code:
player.teleport(ray8.getHitBlock().getLocation());
because ray8 is null
but how would i get it to not be null
as far as I can tell i would have to check if its null, and if it is then get the location of ^ ^8 ^
which i think is 8 block directly ahead
hello. i'm here about my vanish command again, how do i make it so the player that's vanishing is still visible to other staff members who have op for example or have a specific permission?
and for vanished players, add something like a [V] before their name to indicate that they're vanished
package index
If you iterate through all the players you want to hide the vanished player from, you can use the method:
Player.hidePlayer(this, player);
Also you can use Player.setDisplayName(name); https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html
declaration: package: org.bukkit.entity, interface: Player
I saw you can register commands without plugin.yml into Bukkit, but is this also possible in Bungee?
This only shows which commands you can use
Then I'll need to look into their source
I have this line of code, ((CraftWorld)event.getEntity().getWorld()).spawnEntity(event.getEntity().getLocation(), EntityType.type); But I would like to have a dynamic type is that possible? I have an onDeath event as my variable.
whyyyyy are you casting it to craftworld
Will this also work without plugin.yml then?
read the command tutorial
Ok...
I need to get the craft world to get the mothod spawnEntity
no... you dont
ok then how whould I do it? I'm sorry I kinda new to this
It didn't got mentioned "without plugin.yml", so it always work without plugin.yml?
World has the method
Alright I'll try
And now without caps pls
what do you mean by dynamic type
EntityType.values().get(random.nextInt(EntityType.values().size()))
will choose a random entity type
but obviously that includes players and ender dragons
so you would be better off making a list of the ones you want to spawn
Sorry, I have a Listener that listens for a animal deathEvent. I from the event, I need to spawn that Entity again. And yes I will remove players from the code
I kinda want all mobs to "respawn"
well the event should be able to get the entity type
hello, some people have told me to use hash over arraylist
How do i make a hashlist??
no such thing as a hashlist
thats... not..
how do you make explosions not destroy blocks?
List<T> list = new ArrayList();
yes, sorry i've been creating plugins for 1 month only now. never heard of hash before
Set<T> listAsSet = new HashSet();
if you spawn it in yourself you can set whether it blows up blocks
not much different between a list and a hashset,the list has a nice index you can use,the set doesnt allow duplicates
What i'm trying to do is a list to store player's information, aka a vanish command. f.e if they went offline vanished i want their vanish to still be there when they come on
and apparently arraylist can't do that
yes
I've tried event.getType I mean there might be a better way though
event.getEntity.getType
"
No, like I said
An ArrayList is not good
Use a HashSet<UUID>
"
you probably should use arraylist @quaint mantle
yes thats a set
and you should use the set
because you won't be storing values twice
nor will you need them in any specific order
its much more efficient for your use case
the hashset?
the set yes
hashset is like 3900ns faster lol
why wouldnt you use it in this case
Okay, let me try it tho
because he didnt know about it
how do you make explosions bounce you upwards?
put them below the player
do they not already
doesnt work for some reason
event.getPlayer().getVelocity().add(0, 10, 0);
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
the thing that makes sure when a new player joins, staff stay hidden broke..
player.hidePlayer(plugin, plugin.invisible_list.get(i));
the .get
as i said above
dis
you gotta use a list for that i think
ty
okay, 2 people have told me to use array and 2 have told me to use hash
you dont need to iterate through them like that
what?
here's what you do hold on i type
it depends on which type of "list"
DON'T use Array
that's what im trying to do hahaha
great 👍
for (Player vanished : plugin.invisibleSet) {
evt.getPlayer().hidePlayer(vanished);
}```
that will get the objects themselves without having to use the indices
which you had been using as i
public void PlayerJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
for (int i = 0; i < plugin.invisible_list.size(); i++ ){
player.hidePlayer(plugin, plugin.invisible_list.get(i));
}
}
this is my check event
and i just told you what to do
alright
dont need the i in the for loop
is there a way to launch a player the direction they are looking?
yes
addVelocity to them
calculate velocity by getting the direction they're looking at (I assume it's a unit vector) and multiply by how fass you want them to go
there is no easy way to do it i don't think
you'll have to construct a vector with the player's pitch and yaw
although you could look how this does it https://github.com/Geolykt/EnchantmentsPlus/blob/3xx/src/main/java/de/geolykt/enchantments_plus/enchantments/Gust.java
no, you can just get it from Player class
then pitch and yaw would not help anyway
^
Hey pls someone know how to restart the ender dragon fight as if a player placed the 4 ender crystal on the portal, I have tried to use dragonBattle.initiateRespawn() where dragonBattle is the battle linked to my World but it doesn’t work
public HashSet<Player> invisible_list = new HashSet<>();
am i doing it right?
nvm
i realised
hashet<uuid
no, use UUID
will the getuniqueid output a string?
World#spawnEntity
Yes but if I do that I will have to replace all crystal and to re create a boss bar :/
no you dont
no it will give UUID
use UUID as a class
doesnt the dragon rely on the crystals you made?
Player player = (Player) sender;
this get's my player
idk how to make it get an uuid
^ make sure to check that player is a sender there
got the launch thing
geez y'all are so helpful towards new people to programming hahah
not like this another server that barked at me to go to the right section just because i asked for some help
[deleted message]
wrong channel
What do you mean ?
:c
When I just spawn a dragon there is no boss bar and crystals doesn’t appears
nah, I sent message in wrong channel earlier
deleted though
it's now in general if you're curious 😆
i feel so retarded...
nah
I know its an easy fix but idk how do do it
meh its wrong channel if someone needs help or smthn
the uniqueid part
lol
Yeah this server is so helpful
yes, im just stupid
yes, its not helpful for you because nobody can help you. youre too smart. and your issues are out-of everyones leagues
honestly yeah no one helps me with my problems anymore
it's confirmed that people who have numbers after their names are usually the smartest
there are 10000 of me
dam
😮
10k bigbrains
if you were to make java courses i'd definetly buy them
i tutor 👀
i'll probably need to buy a course soon since i cant even get this uuid
do you?
whats happening with the uuid
i'm learning minecraft plugin development mainly because i have a powerful server at home that I want to put-to use and make a mc server on it.
most course probably won't mention UUID
but you should know data structure stuff though
UUID is just a class after you're familiar with Java
idk how to get it basically..
so all entities have a UUID
yes
powerful server isn't enough
you can get the entity through Entity#getUniqueId
since Player is an Entity it has getUniqueId as well
you'll also need an UPS and a high end internet connection
it has 32gb's of ddr4 ram and a 8 core processor. and my network is a 900mbps one
number of cores doesn't matter
to get the player from the uuid, you can do Bukkit.getPlayer(UUID)
amount of physical memory hardly matters
what's the single thread rating
network bandwidth also doesn't matter, latency is more important
it kinda does actually
well, for smaller servers anyway
but yeah, single core performance is more important than amount of cores
How do i see that?
many people run bigger servers on single core or dual core systems
it's an i7-9700K
for smaller servers dedicated core solutions are preferred over having multiple shared cores
especially on spigot
since splögget doesn't leverage threading as much as the alternatives do
yeah, but im extremely confused on how to do it on code
oh wait
So sorry to interupt but for the spawn entity method how would I add PDC?
Bukkit is static
Entity#getPersistentDataContainer
add what again?
ah
then you can set the value of a NamespacedKey which basically makes it so you dont interfere with other plugins' data
since it's persistent you'll also have to specify a data type which handles serialization to a primitive type
Player player = Bukkit.getPlayer(UUID);
yes
:O
ah yes, a new error
'add(java.util.UUID)' in 'java.util.HashSet' cannot be applied to '(org.bukkit.entity.Player)'
Alright you guys are the best 😄
your set contains UUIDs, you're trying to add a Player
set.add(player) -> set.add(player.getUniqueId())
do you guys know why this isnt working?
@EventHandler
public static void onDamage(EntityDamageEvent event) {
LivingEntity entity = (LivingEntity) event.getEntity();
if (entity.getHealth() - event.getDamage() < 1) {
event.setCancelled(true);
entity.sendMessage("You almost died!!!");
}
}
no
0 is dead
less then 1 will show as half a heart
Also event.getFinalDamage
Heath is a double
The game just rounds it to half hearts
ty
@young knoll
if two halves of an egg equal a whole egg, what does a pound of butter weigh?
13
What
What
if two halves of an egg equal a whole egg, what does a pound of butter weigh
About 0.45 kilograms
0.453592
Good job
0.45359237
Just to double check, spigot does not have a creeper ignite event, does it
it might
declaration: package: org.bukkit.entity, interface: Creeper
I have been doing backend for too long
That isn't an event
that's a method :3
And sadly ExplosionPrimeEvent runs at the end of the fuse, not the start
yeah, I think I had that problem before
just check for tnt spawned event
What does that have to do with creepers
oh my bad
Guess I either need to listen for outgoing packets (maybe) or use paperlib
Or not be lazy and try to pr it to upstream
aw man
at that point go with NMS
just add an extra check on the tick
you think it would be accepted tho?
UUId =/= Player
waht?
look at the method and see what it returns
¯_(ツ)_/¯
i want it to return a UUID
it does return a UUID
Then don;t store it as a Player. Store it as a UUID
Why is it a red underline then D:
yet ur trying to store it in a Player
learn java
object
that's what im tryna do
or that
this might be the best answer
didnt want to go straight to it
Look at your line of code again.
i didn't know going from discord bot creating to minecraft plugin developing would be so confusing
it isn't
java
you just have no clue what you're doing with the language you're writing in
oh lmao
this is java 101
that solved alot
you are calling a method with a return type of UUID and trying to assign the returned value into a variable of type Player
You can write discord bots in a lot of languages
Player is not a supertype of UUID
Sometimes you can be blind to the simplest of mistakes
hey noob question, when you do this. what does that mean?
what would this. be in that case?
it means this object
thank you! @eternal oxide
thats overriding nms,each entity calls a tick method so it does something
for example a entity will call tick to move,to find a target or smthng
this can be overridden to add extra logic
this.fieldname is synonymous with just fieldname
unless there is a variable by the same name in the same scope
i have no clue what he's talking about, I can't see replies
he tagged my nms photo
but i assume he's talking about the this keyword in the screenshots you sent
seems like it
the answer to "what is this" involves understanding oop
like if i have something like
public void onclick(InventoryClickEvent evet)
this.getWhoClicked
would return the player that clicked the inv
there is no simple explanation
other than that it just refers to the current object
i guess simplest would be this points to current instance
but without understanding oop it means nothing
wich as he said,instance is oop
because you'll think in terms of classes
and not objects
this returns the object the method is called on
in onEnable, this refers to the instance of your main class that bukkit constructs
basically look up some oop explanation or tutorial somewhere
look at your error
are you sure that method still exists?
a method with that footprint does not exist
It is saying the method watcher(int, byte) does not exist
the last argument looks like a magic variable to me, perhaps that got replaced
wtf, the guy in my guide video was using it quite normally, our codes are the same
The versions are not though#
I'll check again to see if there is a place I missed
Times change
you see, 1.13 did a lot of improvements on a lot of issues
This means magic values are more or less gone and I bet this is an instance of it
Try to look into the class and find a more appropriate method that looks similar in what it does
oh, wish luck for me -_-
I am trying to register a command without plugin.yml, but now I just get "command not found"
public void registerCommand(Command command)
{
System.out.println("Registering " + command.getName());
org.bukkit.command.Command bukkitCommand = new org.bukkit.command.Command(command.getName())
{
@Override
public boolean execute(CommandSender sender, String label, String[] args)
{
command.handle(new BukkitCommandSender(sender, chatFormat, pluginLoader), label, args);
return true;
}
@Override
public List<String> tabComplete(CommandSender sender, String label, String[] args) throws IllegalArgumentException
{
return command.tabComplete(new BukkitCommandSender(sender, chatFormat, pluginLoader), label, args);
}
};
bukkitCommand.setAliases(command.getAliases());
bukkitCommand.setPermission(command.getPermission());
bukkitCommand.setPermissionMessage(command.getNoPermissionMessage());
ReflectedObject commandMap = new ReflectedObject(bukkitPluginLoader.getServer()).get("commandMap");
commandMap.getMethod("register").invoke(commandMap, command.getName(), bukkitCommand);
registeredCommands.add(command);
}
Command is my own class, org.bukkit.command.Command is bukkit's class
Idk, I need to get better names for some classes indeed
name them letters of the alphabet in order of when you create them
Haha ok
But my issue?
Oh I see, I made a mistake: I only need the name and the command itself in the method, no commandMap
But weird that I didn't get any stacktrace
Not yet working....
Haha I forgot to print the stacktrace....
why are you reflectively invoking the register method when you can just use reflection to get an instance of SimpleCommandMap (which afaik isnt version dependant)
public static SimpleCommandMap getCommandMap() {
Field cmdMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
boolean cmdMapAccessible = cmdMap.isAccessible();
cmdMap.setAccessible(true);
SimpleCommandMap commandMap = (SimpleCommandMap) cmdMap.get(Bukkit.getServer());
cmdMap.setAccessible(cmdMapAccessible);
return commandMap;
}```
something like that
Oh yes the SimpleCommandMap is not with version
(I didnt catch the relevant exceptions, make sure to do that)
Yes I will do
👍
i think my plugin is somehow causing IO exceptions, can someone please take a look?
Let us just read your mind for your code
let us just know the errors somehow
Hey, you get anywhere with that physics code? 😁
show errors and code
isnt there a way to make an item only able to interact with certain blocks? or is that adventure mode
just say "no, we can't take a look"
if someone points a gun at your head and demands all the money from the register, just say "no, you can only get money from the register for change"
do you mean the {CanDestroy} thing
{CanDestroy:["minecraft:stone"]}
is there something in spigot api for that
im not actually sure lmao
for EntityDamageEvent how would u check if the damager is an instance of player?
instanceof Player
use the EntityDamageByEntityEvent
ok
or something like that, idk
EntityDamageByEntityEvent and event.getDamager() instanceof Player
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
so im trying to implement a reload cmmand, this is what i have so far
if (checkPerm(player, "chest.reload")) {
new Reload().reload();
}
}```
wich works perfectly, unless i do saveConfig in the time that i edit and save, how could i force it somehow, should i remove all the saveConfig in my code so it doesnt update?
and only save config on disable
or reload
whats the point in saving config.yml on reload, it'd just overwrite any changes somebody makes, wouldnt it?
yea ig
i could remove all saveConfig
so when i reload
oh wait i sent the wrong code
lmao
Main.get().saveDefaultConfig();
Main.get().reloadConfig();
}```
store teh file modification time in memory when you load the config. When you reload if the file modification time is different to that in memory it was altered so you can load instead of save
anyone got a way to move multiple armorstand based on a base armorstand rotation?
wut
how do i get the file modification time
when you load the config you read its file modification attribute and store that in memory.
You can then compare teh files attribute any time you want to see if the file has been modified since you last read it
oh haha i'll open source it in a bit
nothing too crazy
remind me if i forget in an hour
why do you say teh instead of the
No problem, i just wondered how it had gone 🤣
Greetings dear developers, any knows what sound plays when a item get bone mealed?
i think Material.canDestroy
not sure
same
thanks will give it a go
nope
declaration: package: org.bukkit, enum: Sound
i a null pointer exception when this event is called for some reason:
hmm no there's isInteractable but thats for block materials n general
What is the stack trace?
wdym
i had a look there as well but there no specific one that indicate a bone meal sound
this is the error msg
its probably re-used. try and think of a similar sound ig
it looks better to me
yeah
this is on line 40:
if (wands.contains(event.getItem().getItemMeta())) {
ill play around till i find it
oh, so there is a few things
or the item is air which doesnt have a meta
this is wands:
ArrayList<ItemMeta> wands = new ArrayList<ItemMeta>();
wands.add(itemManager.explosion_wand.getItemMeta());
wands.add(itemManager.growth_wand.getItemMeta());
wands.add(itemManager.bounce_wand.getItemMeta());
thanks for the help everyone
check it has meta with hasItemMeta()
it may either:
item is null
Item has no meta
You need to implement null checks for these
there is a #hasItemMeta() iirc
ie check if getItem is null
if (evt.getItem() == null || evt.getItem().getType() == Material.AIR) return;
there you go
k
but you really should not be using item meta to find your item
how should i?
Which is Persistant Data Container if you didn't know
so like how would i add that
ty
gl!
what is
pluginInstance
in NamespacedKey key = new NamespacedKey(pluginInstance, "our-custom-key");
an instance of your class that extends JavaPlugin
yea
so what would it look like in that line?
you need an instance of it, so like, ```java
private static MyPlugin instance;
public void onEnable() {
instance = this;
// the rest of your onEnable
}
public static MyPlugin getInstance() {
return instance;
}
wdym
using the example i specified, NamespacedKey(pluginInstance, "our-custom-key"); would become NamespacedKey(MyPlugin.getInstance(), "our-custom-key");
ok
ohhh, i see
thanks
also, i'd recommend making all your classes start with an Uppercase letter
hmmmmm
now it doesnt work at all
but there arent any errors
nvm
it was a typo in a string
Guys I tried to make a dash thing and I wrote this
`public void dash(PlayerInteractEvent e) {
Player player = e.getPlayer();
if(player.getInventory().getItemInMainHand().getType() == Material.SHIELD){
if(e.getAction() == Action.RIGHT_CLICK_AIR) {
Vector vector = player.getLocation().getDirection();
vector = vector.multiply(1);
player.setVelocity(vector);
}
}`
there is no error in eclipse but it is not working
I'm trying to replace a block at a certain location and I'm not sure why but it's not working. The block stays the same even though sysout outprints OBSIDIAN Could someone please help me out? ```java
Block b = player.getTargetBlock(null, 5); // targeted player block
Location loc = b.getLocation();
if (b.getType().equals(Material.CHIPPED_ANVIL) || b.getType().equals(Material.DAMAGED_ANVIL)) {
loc.getBlock().setType(Material.OBSIDIAN); // I try setting to obsidian
System.out.println("Block set to:" + b.getType().toString());
}```
Here's the full class if anyone wants to check it out https://pastebin.com/NWhpzqbg
you get the blockdata before setting the block to obsidian, and then set it back to whetever it was, which im guessing changes the material back
Hmm, I need the block data to save the block direction though
loc.getBlock() why cast it again to block
if you alrdy have a block reference just above?
when do you call it?
well you need to consider its on interact event
so if you stand still and click smthng you basically have no velocity 0,0,0
did you register the event
still same when I fly or move
how can you give example
player.getvelocity
In a list of arguments how can I get the first and last arg
pretty sure @severe folio told you how to solve it lmao
@EventHandler
public void myEvent(SomeEvent event){
// ...
}
and did you register it with Bukkit.getPluginManager().registerEvents(listener, plugin) in your onEnable or wherever you register them.
args[0] and args[args.length-1]
check the length of the array first
`public void onEnable() {
getLogger().info("Ekstra Silahlar Aktif");
Bukkit.getPluginManager().registerEvents(this, this);
}`
I am using register thing like this
some snippet from a scroll
this will leap the player
in the direction his facing
works both moving or standing still
multiply the power,setY how high
Firstly, move the event to a separate listener class. Listening for events in the main class is bad practice (afaik)
Secondly, ensure you have the @EventHandler annotation above the event method.
Thirdly, use player.getVelocity() instead of the direction.
I dunno if im going crazy but I ran a plugin I just made and in console it said I did not specify the main class "aight ez fix" I went in a checked and I have specified the main class again but when I ran it the second time it still says the same thing I tried renaming classes and making the main class path shorter but it still syas the same thing is there a reason why?
is the package also right?
yes it is
post a pic of the structure
and the plugin.yml
thanks @severe folio @onyx shale my problem solved
how?
hierarchy should start from src
how are you compiling?
ye
not for main class name, stellrow
no it shouldnt
Im using maven so it klinda dose that for u automatically so ..
how are you building it
wdym?
how are you compiling the plugin
hello everyone, how do I get the location of a respawn anchor if a player has set one?
that's a good question
I go to project structure make a new artifact and defined the output location or is there smthing else im suppose to do??
thank you gecko
seems player doesnt directly access it
only respawnevent
so i geuss you need to go into nms
what I dont get is I did it for this pic works completely fine and I followed the same steps I did and all so wtf?
Using ProtocolLib, how can I get the whole message being typed in a TAB_COMPLETE packet?
what's happening with it? 🤔
@dusty herald
show me the error
hmm how does the anchor work? you have to click it or smthng?
will this code work: ```java
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
public class Main extends JavaPlugin {
private Main plugin;
@Override
public void onEnable() {
}
public void onDisable() {
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(label.equalsIgnoreCase("TNTSpawn")) {
if(sender instanceof Player) {
Player player = (Player) sender;
Location loc = player.getLocation();
World world = player.getWorld();
BukkitScheduler timer = player.getServer().getScheduler();
timer.scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
world.spawnEntity(loc, EntityType.PRIMED_TNT);
}}, 0L, 100L);
return true;
}
else {
sender.sendMessage("Nope!");
return true;
}
}
return false;
}
}```?
No 🥳 it won't
You also need to specify the api-version
not necessarily
now i must leave
i mean it bitches at me if i dont gecko 
and i use an up-to-date api
yeah but it'll work
holy the nms code for anchor is so convoluted
?
How do i send messages to webhooks
or would a bot be easier?
class java.lang.byte cannot be cast to class java.lang.byte
abi ben de yeniyim vallaha
xD
I do not want the error msg from you, I want a solution idea. I can see the error too. Thanks anyway ^^
😄
you r trying to set a boolean to a byte
which line did you tried to set a byte
31
I dont know this type of listeners so I cant tell something correct
why did you use 127 for it
whats the purpose of (byte) 127
I made a thing like this if a weapon or anything contains Lore "Tırpan" it will deal damage the neabry entities.But When I try to add knockback to the entities A error occurs in the console called "x is finite"
why
cause it is easier than pdc
are you using spigot or spigot-api
How do i check if my event entity is 10 blocks away from the player?
location.distance(location)
Location#distance
Location#distanceSquared < 100
entities.setVelocity(entities.getVelocity().add(entities.getLocation().toVector().subtract(whoHit.getLocation().toVector()).normalize().multiply(knockback)));
this is my knockback code
sorry what does #mean>
and thats a stroke
on an instance of the object
meaning you'll need to get the entity's location and perform the "distanceSquared" method on that location object
ok Thanks!
FileConfiguration?
any idea guys?When I searched it in spigot a guy said When level is 0, you get division by 0. Which leads to infinity.
That's why you get the error. The value is not finite. It's infinite.
split the line up into multiple and see which part causes the error
You have no division in yoru code and infinite does not mean divide by zero
add(entities.getLocation().toVector().subtract(whoHit.getLocation().toVector()).normalize().multiply(knockback)));
ohh
subtract is NOT dividing
no clue, whats your error?
did you saw my code
yes
okey
you have shown no error
send the stacktrace
when I use the weapon
you have no x
thats the confusion 😦
show me an actual error, not some guess at it
well it probably means x as in a number in a method used with Location
okey
I will send the command line in the console with paste.md
when I hit a mob
x not finite
yeah he knows
line 54, youre somehow getting infinity
within setVelocity is a function that gets you infinity
yep (Main.java:54)
entities.setVelocity(entities.getVelocity().add(entities.getLocation().toVector().subtract(whoHit.getLocation().toVector()).normalize().multiply(knockback)))
this is the code
yeah probably because you're adding and subtracting the locations as vectors
wait no nvm
you are trying to implement some kind of knockback?
yeah
without knockback
it looks bad
I tried to make aoe damage weapon
like scythe
I want to knock neabry entities
try java entities.setVelocity(entities.getLocation().toVector().subtract(whoHit.getLocation().toVector()).normalize().multiply(knockback));
How
but set your knockback to 1
still same
can;t be the same
still bro I am so confused
what is knockback
float knockback = 1;
That code I gave you above is simple vector math between two locations
using the knockback like this
sometimes it can work @eternal oxide
Well, there is nothing at all wrong with that vector/velocity math
Mine, not yours 😉
What do you mean by sometimes?
hey is there anybody that could help me with running methods over servers using the bungeecord messaging system?. for example if a player joins server 1 it runs a method on server 2
what do you mean by not correctly? As they they knockback but the wrong direction?
goooooood luck
Sometimes knockbacks and damages others
lmao im remastering my manhunt project to run smoother so yea ill see how it goes
But still occur that x not finite error
You are getting all entities 3 blocks around the one that was hit
does that include the player entity maybe
yes
@sage swift do you think you could help me?
should I descrease range @eternal oxide
you should exclude the player from your entity list
But my server will be pve and pvp
oh
I tried that
But I didnt make it
if (!(entities instanceof Damageable))
continue;
I am using this for exclue item frame dropped item etc.
It will be a spoonfeed but can you guys send example?
if (entity.getUniqueId().equals(source.getUniqueId())) continue;
dont call the single entity entities please it's really confusing
its a list
no, "whoHitted2" is a list
List<Entity> whoWasHitted2 = whoWasHitted.getNearbyEntities(3,3,3);
entities is an entity
like im saying, entities is a singular entity
it
it's pseudocode
you can convert it into your variables
it's not even really pseudocode
im saying you want to compare the uuid of the entity to the uuid of the entity that hit and see if they are the same
if they are, skip over and continue in the for loop
if (entity.getUniqueId(whoHit).equals(source.getUniqueId(Player)))
I see
why are you putting something in getUniqueId
it doesnt need anything passed in
you call it on the entity itself
whoHit.getUniqueId
😬
that was really dumb
last question
if (whoHit.getUniqueId().equals(entities.getUniqueId()))
is this right..
sorry for overasking
mhm
hey @eternal oxide you think you could help me with my issue?
this ^^
@EventHandler
public void on(EntityDamageByEntityEvent evt) {
if (evt.getDamager().getType() != EntityType.PLAYER) return;
if (!(evt.getEntity() instanceof LivingEntity)) return;
Player player = (Player) evt.getDamager();
if (!player.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(identifyingKey, PersistentDataType.BYTE)) return;
for (Entity entity : evt.getEntity().getNearbyEntities(3, 3, 3)) {
if (!(entity instanceof LivingEntity)) continue;
if (player.getUniqueId().equals(entity.getUniqueId())) continue;
((LivingEntity) entity).damage(1, player);
// knockback code
}
}``` is a little cleaner and easier to follow in my opinion
how do you get the item meta of an item?
then I want to say if (event.getItemMeta().equals(ItemMetaoffishingrod)) {
how would i do that
its not custom
i just want to see if the item is a fishing rod
if you want to see if it's a fishing rod get its type
use Material not item meta
ok thx
Anyone know how to fix this?
I did not understand exactly what and how to add
yeah i know
probably use Bukkit.getWorld("world") and then get the WorldServer from that
@sage swift ...getPersistentDataContainer().has(identifyingKey, PersistentDataType.BYTE)) return; what is the meaning of this?
a better way of identifying your custom item
#help-development message here's an explanation of how to use it
where I should write my lore?
you don't need to
it's an nbt tag that doesnt show up for the player
and it doesnt require the meta to be exactly the same
but I want to run the skill if a item has Scythe lore
I didnt understand very well
give the item a tag that identifies that it's a custom item
we rly need a more simplified guide to pdc
so everyone.. everyone can get how it works
eg. ItemMeta#getPersistentDataContainer().set(new NamespacedKey(plugin, "scythe"), PersistentDataType.BYTE, (byte) 1);
this will set an nbt tag on the item
dang gecko getting his spoon out
mmh, nope probably want something else. I do not understand how WorldServer works
-_-
and when you later need to figure out whether it's the correct item you can use ItemMeta#getPersistentDataContainer().has(new NamespacedKey(plugin, "scythe"))
WorldServer is just the nms world
Ahh I see now
WorldServer world = ((CraftWorld)Bukkit.getWorld("world")).getHandle();