#help-development
1 messages · Page 2162 of 1
Hey
so uh
anyone has an idea of what to start with if I wanna learn AI
ik thats too generalized but im not sure with what to start
Does anyone know why it crashes my server?
public void DeadlyLava(PlayerMoveEvent event){
Player player = event.getPlayer();
if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.LAVA){
while (player.getHealth() > 0){
player.damage(1);
}
}
}```
if you know how to use js, then i think brain js would be easy to start with https://brain.js.org/#/
GPU accelerated Neural Networks in JavaScript, for Browsers and Node.js
just set his health to 0 wtf
just found this library to be really easy
I wat the player to get damage very fast and not instantly die
why is it crashing
how do I delay it?
?
?scheduling
ok i dont get it
then use an easier library, will probably not be able to make ai that advanced, but you should start small
i literally
just wanna make
a rock paper scissors
ai
lmfao
nothing can get simpler than this
literally a brain js example
why doing ai in java btw?
probably wants it in his plugin or something
this seems like a good resource
it lists a bunch of good and free machine learning frameworks for java
although I hate python I have to admit that it has one of the best libraries providing exactly what you're looking for
For example numpy which is written in C making it faster than it would've been if it was written in python
How do I get the plugin?
scheduler.runTaskLater(plugin, () -> {
player.damage(1);
}, 20L * 30L);```
I have a question, i use on my server tree twerk and its just enabled with op on the server, please say me how to fix
Hi guys, I created a plug-in with the use of placeholderapi. I used JAVA 8 in 1.16.5 but unfortunately placeholders are not registered in 1.18 with java 17, what could I do in your opinion to create a multicompatibility?
@quaint mantle The problem was that I need a delay in the while loop. can you help me here please?
?di to get the plugin
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Help me pls
get the plugin instance via the constructor
class MyPlugin extends JavaPlugin {
void onEnable() {
new ClassThatNeedsPlugin(this);
}
}
class ClassThatNeedsPlugin {
private final MyPlugin plugin;
ClassThatNeedsPlugin(MyPlugin plugin) {
this.plugin = plugin;
}
}```
Cannot assign a value to final variable 'plugin'
shouldn't it not be final?
are you doing it in the constructor?
yes
show code
hi so i would like to tp the command sender to the target but player.teleport is not working for me, this is my code:
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("spectate")) {
Player target = sender.getServer().getPlayer(args[0]);
if (target == null) {
sender.sendMessage(ChatColor.GOLD + args[0] + ChatColor.AQUA + " is not currently online.");
return true;
}
player.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
}
return false;
}```
uhm sir youre not checking the length of the args
I keep getting this error, trying to add citizensnpc dependency
Could not find artifact net.citizensnpcs:citizens-main:pom:2.0.29 in everything (https://repo.citizensnpcs.co/net/citizensnpcs/citizens-main/2.0.29-SNAPSHOT/)
the pom.xml code has been pasted below
?paste
do player.teleport(target.getLocation())
i get this error: Cannot resolve symbol 'player'
here is the pom file
anyone can help me?
or do I need to ask the citizen server thing
I mean you never define a variable called player ?
im new to this, how do i do that
?
Follow whatever tutorial you are following
You need to instanceOf check the sender
And then cast
But your tutorial should show you that
🥄
I have this code but it only works in the first time it is executed since the plugin is reloaded
public void DeadlyLava(PlayerMoveEvent event){
Player player = event.getPlayer();
if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.LAVA){
while (player.getHealth() > 0){
BukkitScheduler scheduler = Bukkit.getScheduler();
Main plugin = new Main();
scheduler.runTaskLater(plugin, () -> {
player.damage(1);
}, 10L /*<-- the delay */);
}
}
}```
Player player = (Player) sender;
You are blocking the main thread
?
THANK YOU
doing things like while(true) {} will block the whole server so thats why you need to use the scheduler
No
but first check if the sender is an instance of a player because the command could be executed from the console
** I use it**
.
someone has to hug me now
It isn’t rocket science here
im not
I’d give you a hug fourteen but this is too depressing
Also generally speaking a while loop is never the answer
You want to run a task timer
I just want it to execute every 0.5s
Run a task timer that ja a Delay of 10 ticks
read the docs about scheduling
while loops are for iterating. Scheduling is for repeating tasks
Roughly 500 ms
still depends on the tps but ye
I says I can do .runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
but my IDE says Cannot resolve method 'runTaskLater(Main, <lambda expression>, long, long)'
?ask
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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
is there any way to use something like "PlayerChangeBlockEvent" instead of player move event
No
can I do it somehow with PlayerMoveEvent
I get Plugin already initialized!
in the console
hey how can i hide player from target's tab?
Don’t create a new instance of your plugin
You can not create a new instance of your main class. There is only one and it is created by Spigot
I haven't created an instance tho
public DeadlyLava(Main plugin) {
this.plugin = plugin;
}```
it's what he sent
Somewhere else you have
Most likely where you create the class
oh
DeadlyLava
i got it
remove any new Main()
public class StrengthZombie extends EntityZombie {
public StrengthZombie(Location location){
super(EntityTypes.be,((CraftWorld)location.getWorld()).getHandle());
}
I unable to use this code and it give me error"x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type"
yes. You can check whether .getBlockX() changed (same for y and z obviously)
yup
You should be using the mojang mappings if you're using NMS on 1.17+
i am
for some reason the scheduler repeats every seconds instead of 1/10 of a second
?bootstrap read the 1.18 nms section AND the 1.17 post it links to
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
EntityTypes.be is NOT a mojang mapping
Your exact error https://www.spigotmc.org/threads/nms-entity-problem.542187/
Does the Inventory#remove method remove all items? Or is it just Inventory#removeItem under a different name
I checked the docs and it looks like the latter but I'm just making sure
declaration: package: org.bukkit.inventory, interface: Inventory
you will find every answer you need in those docs
.
scheduler.runTaskTimer(plugin, task -> {
player.damage(1);
if (player.getHealth() <= 0 || player.getLocation().getBlock().getType() != Material.LAVA){
task.cancel();
}
}, 0, 2);```
the code
I'm asking if the amount matters 🤦♂️
ok
.
it says that in the docs
and like I said
I checked the docs
Nice
just test it then
if the docs says the amount matters, then it matters?
Hey if I have a string in my messages configuration file and someone uses a formatting or color code like &7, how do I get it so that it will actually show the format or color with the sendMessage method?
Translate color codes method from CharColor class should do you well
a repeat of 2 = 2 ticks. Its running 10 times a secoond
20 = once per second
that's what I want but it repeats every 1s instead of 1/10s
Wdym by this?
save the nameColor as one value in the config and the actual name string as another
then you can do ChatColor.Of(config.getString())
pretty sure .damage() has a cooldown on it
or at least it doesn’t update properly client side, i remember having issues trying to damage very quickly
how do i bypass this
^ I tried to ask the question in citizens server, and I keep getting muted for exsisiting
exsisting
here is the error
can anyone help?
You are probably being muted as you are not using the repo correctly
I'm guessing they already linked you to some wiki
hello im trying to add a player to onlineplayerlist that has been removed from the list
i guess thats the tab
this is my code:
target.getServer().getOnlinePlayers().add(player);```
yes
but i get this error: 'add(capture<? extends org.bukkit.entity.Player>)' in 'java.util.Collection' cannot be applied to '(org.bukkit.entity.Player)'
What are you doing
uh thats the online player list that bukkit is keeping
which i just wanted to say
Um, adding to teh OnlinePlayers. You can not do
what are you tryin to do?
i have already removed a player tho and i want to add him back is there any way i can do so?
You can;t manually remove an online player
^
i did tho target.getServer().getOnlinePlayers().remove(player);
that did nothing
and did it give an error?
nope
if i cant remove the player or add the player is there a way i can hide and show it?
wHaT aRe YoU dOiNg?
you are talking about tab lists?
yes
packets probs
no I got muted for pining a staff
and then got banned
I tried
everything in the repo
how?
I mean the wiki
I just linked you the wiki. look at the very first section about accessing the API. Compare it to your pom entries
When you right-click on a fake block, it disappears. I'd like to disable that.
The only packet I found that blocked this is PacketPlayOutChangeBlock. The problem is that this packet not only blocks what I want, but also blocks the sendblockchange etc. Someone would know how to just block the right click (cancel interact event etc doesn't work)
I TRIED BOTH OF IT
how do it do my tab list show and hide?
Look at your repository entry in your pom, and then look at what the wiki says to use
dont press at the tab putton
Could not find artifact net.citizensnpcs:citizens-main:pom:2.0.29-SNAPSHOT in ess-repo (https://ci.ender.zone/plugin/repository/everything/)
bro
the thing
is just doing
what ever shit it wants
No, you are not reading nor listening to anyone
ok tell me
?paste your current pom
Now paste your full maven log
Could not transfer artifact net.citizensnpcs:citizens-main:pom:2.0.29-SNAPSHOT from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [everything (http://repo.citizensnpcs.co/, default, releases+snapshots)]
thats all
it said
how to change?
opening my ide
OMG
IT WORKED
LETS GO
THANK YOU GUYS SOO MUCH
@eternal night @eternal oxide
U GUYS ARE THE BEST

lol
dont close ur ide pls
What errors?
It crashes my client
public void DeadlyLava(PlayerMoveEvent event){
Player player = event.getPlayer();
if (player.getLocation().getBlock().getType() == Material.LAVA || player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == Material.LAVA){
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskTimer(plugin, task -> {
player.setNoDamageTicks(0);
player.damage(1);
if (player.getHealth() <= 0 || player.getLocation().getBlock().getType() != Material.LAVA || player.getLocation().getBlock().getRelative(BlockFace.UP).getType() != Material.LAVA){
player.setNoDamageTicks(20);
task.cancel();
}
}, 0, 2);
}
}```
oh my that is going to kill your server
you are creating a NEW task every move packet you are in or on Lava
there are Thousands of move packets
how do I not create a new task?
You create a single task, outside the event, then either activate it or deactivate it in the move event
ok
hi i get this error in the console when typing a command from my plugin:
[19:57:50 INFO]: Gizmo0o issued server command: /unspec Gizmo0o
[19:57:50 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'unspec' in plugin PlutoCraft v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.dispatchCommand(CraftServer.java:906) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2306) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2117) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2098) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]
at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:51) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1399) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:188) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1376) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1369) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1347) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1229) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-337]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.IllegalArgumentException: location
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.0.1-jre.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer.teleport(CraftPlayer.java:1131) ~[paper-1.18.2.jar:git-Paper-337]
at org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity.teleport(CraftEntity.java:558) ~[paper-1.18.2.jar:git-Paper-337]
at net.plutocraft.plutocraft.PlutoCraft.onCommand(PlutoCraft.java:74) ~[PlutoCraft-1.0.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more
IllegalArgumentException: location
how can i fix this?:
else if (command.getName().equalsIgnoreCase("unspectate")) {
if (sender instanceof Player) {
Player player = (Player) sender;
} else {
sender.sendMessage(ChatColor.DARK_RED + "You must be a player.");
return false;
}
Player target = sender.getServer().getPlayer(args[0]);
Player player = (Player) sender;
if (target == null) {
sender.sendMessage(ChatColor.GOLD + args[0] + ChatColor.AQUA + " is not currently online.");
return true;
}
player.teleport(getServer().getPlayer(player.getName()).getBedSpawnLocation());
((Player) sender).setGameMode(GameMode.SURVIVAL);
target.showPlayer(player);
player.setPlayerListName(player.getDisplayName());
target.sendMessage(ChatColor.BOLD + "" + ChatColor.GOLD + "+" + ChatColor.YELLOW + player.getDisplayName() + ChatColor.GREEN + "joined the game");
player.sendMessage(ChatColor.AQUA + "No longer spectating" + ChatColor.GOLD + target.getDisplayName() + ChatColor.AQUA + ".");
}```
./unspectate Gizmo0o
idk
i would assume they don’t have a spawn location
its a prob with this i think:
player.teleport(getServer().getPlayer(player.getName()).getBedSpawnLocation());
how do i make it so if they dont have a spawn location it would tp them to the worldspawn?
check if player.getbedspawn returns null
if it's null it not a location
why are you casting to sender three times?
How do I make it execute also when im standing still in lava?
public void DeadlyLavaKill(PlayerMoveEvent event){
Player player = event.getPlayer();
if (player.getLocation().getBlock().getType() == Material.LAVA || player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == Material.LAVA){
scheduler.runTaskTimer(plugin, task -> {
player.setNoDamageTicks(0);
player.damage(1);
if (player.getHealth() <= 0 || player.getLocation().getBlock().getType() != Material.LAVA || player.getLocation().getBlock().getRelative(BlockFace.UP).getType() != Material.LAVA){
player.setNoDamageTicks(20);
task.cancel();
}
}, 0, 2);
}
}```
what would the code be?
if (player.getBedSpawnLocation() != null){
}
I guess i'll switch to a different event
@tardy delta does player.getLocation() return the xyz of the head block or the leg block?
feet
this seems like its gonna crash the server
why would it
creating a repeating runnable every playermoveevent that runs every 2 ticks
💀
will it work if I set the damageTicks of the player to 2 when he's in lava?
ok
would this work or did i do it wrong?
player.teleport(getServer().getPlayer(player.getName()).getBedSpawnLocation()); {
if (player.getBedSpawnLocation() != null){
player.teleport(getServer().getWorld(player.getName()).getSpawnLocation());
}
}```
its just youre effectively creating 20 repeating runnables every second a player is in lava
and each one of those is running 10 times a second
nullcheck the player you got from the server
and theyre performing fairly expensive operations as well
overtime that is gonna break the server
Why the heck should one use getServer().getPlayer(player.getName())
what does this mean?
Null points error
Ah yes I love the world that is named after my player name
having a personal world
It’s a good flex
how can i change my code to fix the error?
player.teleport(getServer().getWorld(player.getName()).getSpawnLocation());
Well what world do you want
player.getWorld().getSpawnLocation()
only for premium users
What world?
the default one
Is it a world named the same as the player?
yes
I don't understand noyes
Is the player alreadyin that world?
i want it to tp the player to the spawn of the world wich the player is in
if i do heavy stuff in the async prelogin, that wont block the user from logging in right?
They will not join until the async event finishes. but you are safe to delay a few seconds in it
it would suck if i changed my name and lost my entire world
ah so it will block the user
then i probably confused it with smth else
owh ye i forgot
The player.damage(1) just kills the player instantly (it doesn't do it every 1/4 of a second, it just instantly kills me). I tried to remove it but then the lava didn't do the damage fast like I wanted.
public void DeadlyLavaKill(EntityDamageEvent event){
if (event.getEntity() instanceof Player){
Player player = (Player) event.getEntity();
if (player.getLocation().getBlock().getType() == Material.LAVA || player.getLocation().getBlock().getRelative(BlockFace.UP).getType() == Material.LAVA){
scheduler.runTaskTimer(plugin, task -> {
player.setNoDamageTicks(0);
player.damage(1);
if (player.getHealth() <= 0 || player.getLocation().getBlock().getType() != Material.LAVA || player.getLocation().getBlock().getRelative(BlockFace.UP).getType() != Material.LAVA){
player.setNoDamageTicks(20);
task.cancel();
}
}, 0, 5);
}
}
}```
It will kill you instantly because you are spawning (possibly) hundreds of tasks, each doing 1 damage 4 times a second
oh you are in teh damage event, even worse
how do I make it execute only 1 task?
hundreds
id use a hashmap for each <player,boolean> and check if i already did the task
one sec
so I need a hashmap of all the players in the server? how do i do that
Just make one in your main class
Next time a player kills entity,
check if they are in the hashmap. If they are, check if they already damage (by getting their key which is true or false).
If they are not in the hashmap, just add them into the hashmap
?paste
https://paste.md-5.net/tirizewugo.cs If this throws a ConcurrentModificationException let me know
I couldn;t remember if the forEach was iterated
ah yep, forgot about that
it does like 3-5 hearts of damage every time
actually 4 per second. Thats the speed you have the task set to run
yes but it does it a once instead of every 1/4 of a second
it does it every second
no, it does it every 1/4 a second. your client just isn;t updating that fast
if you want to slow the damage down, increase teh timer delay from 5 ticks to 10
so twice a second
no there's no way. it does damage every second and it's not 1 hp
i just checked
It does 4 damage per second, as I just told you
it runs 4 times every second (5 ticks) doing 1 damage every time
1 damage = half a heart
so it will be taking 2 hearts per second
that's what it should do but it activates every seconds and not 1/4
it takes more
im not
then that code I gave you will do 2 hearts per second, assumign you have not got any health scaling on
ok
and assuming your server is not lagging to be able to run at 20 ticks per second
oh, fix this line, as currently your code will allow you to pop your head above the lava and stop taking damage java if (player.getHealth() <= 0 || (player.getLocation().getBlock().getType() != Material.LAVA && player.getLocation().getBlock().getRelative(BlockFace.UP).getType() != Material.LAVA)){
can i just add another <relocation></relocation> to shade something else?
ah noclassdef found
entire pom looks like this now
https://paste.md-5.net/iranezaquj.xml
too much indents or smth?
someone got ideas what to code?
ok its name is pyramid of doom
We'd be writing it if we did
yep
still noclassdef found brr
Make a plugin where Herobrine spawns in front of you and you die of a heart attack when you're too long in the dark
I'm sure it's fun to play with
Or make a Gravity Gun plugin, that one is definitely fun
im trying the herobrine one thats sounds good thanks for your idea
You're welcome 🙂

how could i make it possible for the player to cross the worldborder?
when we place jigsaw block through code, can we change its direction?
isnt that some old block
make your line shorter 😠
it came in 1.14 it allows u to generate structures randomly
kekw
you mean just walk through it?
yes
Anyone know how to clear crafting slots? (The ones in the player inventory)
alright so which packet is the one who sents the world border?
any android developers?
?ask
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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Ye
I do not have a specific question, I need to talk to one in PMs.
I'm basically stuck with the entire topic of making responsive layout
what I was taught in school is to use DP for everything, and now in the real world where I want to release my app, it looks more than horrible on other devices
ConstraintLayout is a big headache
I'm lost
I mean using dp is wise
Is there a way to set the priority of world initialization event to low, so it doesn't hit the performance as much?
Myeah there are probably better ones in practice now
But it can be favored in certain scenarios to some other size types
whats the event that happens when someone uses this
im trying to make it so when an item is removed either mannualy or with that button it adds it back
InventoryCreativeEvent or whatever it’s called might be of help
ah yea
Everyone says to use ConstraintLayout now
but nobody shows a real example
I'm so lost
Let me take a look at what that is
I don't even understand how people made responsive layout prior to constraintlayout(which was released at 2016)
Yeah well, I kinda “hard coded” it
^
When I use my library in the multiple project (only for personal use) should I implement it manually adding library to the project structure or create maven artifact dependency using jitpack or smth like this?
If you can put it on jitpack or sth
Since then it’s basically accessible from everywhere
Yeah, but when I use it in about 3 - 4 projects, personal use etc, putting it on the jitpack is better way than doing it manually?
Maybe just put it in your local maven repository
So got problem with softdpendcy
my plugin wont load after MythicMobs
my plugin soft depend
how can i get the location based on the world border like this
last I looked only Depend affects the actual load order
really
softdepend only makes sure they exist
What issue are you having?
because I got class which loads types of mythic mobs
so my plugin loads before Mmobs
and fires constructor which should store types of Mmobs to map
but they are not there yet because thing is null
You are doing your loading in your onEnable?
yes
then detect MM in your onEnable, but schedule your init of your MM code 1 tick later
it is token plugin which allows token drops
for mobs farmin etc
and mmobs are one of things
well I thouht of that
with softdepend you can never guarantee load order so you should never expect other plugins to be loaded before yours
but was confused didn't knew that soft depend only check if plugin is there
thanks for that info
I am lazy reader so probably slipped thru my eyes 🍻
I don;t believe its actually written anywhere. I remember it from having this issue myself long ago in Towny.
you guys
how can i draw lines based on the player location and world border
i will give an example
@EventHandler(priority = EventPriority.LOW)
void disableWorldLag(WorldInitEvent e){
e.getWorld().setKeepSpawnInMemory(false);
}```
Would this reduce lag when loading a world ?
The big lag spike that you get, when loading it.
i would like to get the shortest line
1 tick was not good or even 1 sec
so I made repeat task
which checks if plugin is loaded once a sec
and then loads thing and cancel task
maybe?
board.getTeam("RedTeam").setColor(ChatColor.RED);```
Is there an alternative for .isItem() on the 1.8.8 API?
oh, mmmh
That seems like overkill. MM should be enabled by the time their onEnable finishes. 1 tick past that and all plugins are assumed enabled.
is there something like setGlowColor? @kind patrol
thing which I said up still not working xd
looks like there is some other problem with Mythic api
are you defining yoru reference to a static reference too early?
or is all access via Bukkit getPlugin?
u were right
I was defining instance in class where I register event MythicMobDeathEvent
this helps
@Override
public void run() {
if (pl.getServer().getPluginManager().isPluginEnabled("MythicMobs")){
mythicOn = true;
mythicMobs = MythicBukkit.inst();
}
}
}.runTaskLater(pl,1);```
forgot I got it there
So i currently havd a problem where when someone moves it doesnt cancel the command and there is no errors for this
Command Class: https://paste.helpch.at/ikacuhixob.java
Event Class: https://paste.helpch.at/aparunaqul.java
Arrays :https://paste.helpch.at/oranokaget.java
HashMaps: https://paste.helpch.at/megayoxogi.java
looks like you still got a double space before "mimic"
Happy
I is happy
now eat
I didn't say that
BANANA
Is it possible to instanciate generic array or generic fixed sized list?
new Foo<Baz>[50]; doesnt work, but Arrays.asList(new Foo<Baz>[50]; doesnt work either as you can see
there's a workaround to wrap interfaces inside subinterfaces with types already defined
but that would be a hassle to maintain in the long term, especially if there's no new functionality inside those interfaces
class Sub derives Foo<Bar>{}
Sub[] could work altho it’s probably not what you’re looking for
that's what I currently do
but imagine many classes
and for each you have to create a new class or extend interface
smelly
But else since types passed to type parameters aren’t necessarily retained during runtime it then becomes an issue for arrays hence why it isn’t possible
Yeah it’s smelly
Yes because then it accepts Foo<T> where T can be anything
So it effectively doesn’t impact anything in other words
Anyone know a tnt tag plugin
Generic<String>[] arr = (Generic<String>[]) new Generic[5]; ?
Do you?
Yo. I'm trying to create a command where it saves a message from the player, for example: /savemessage Hello my name is Steve. Any idea how to do this?
i tried this but it doesn't seem to work
are you trying to store one message per player?
then use a Map<UUID, String>
Got it
no need to loop over an array then
ah so the for loop would be uneeded
correct
Ok
just wanted to clarify, the enderse array is for player and the msg array was used to store the players message
Hashmaps are also far more efficient
I will try the map
never used one before so I was trying to do a different approach lol
So has anyone gotten mojang mappings to work in gradle?
Map<UUID, String> messages = new HashMap<>();
onCommand...
messages.put(event.getPlayer().getUniqueId(), event.getMessage());```
However, you would be better creating an actual command and not using the preprocess event
let me send you a picture of my whole class
?paste
yep, don;t use the preprocess event at all
what would you suggest then?
so the code would be something like```java
Map<UUID, String> messages = new HashMap<>();
onCommand...
if (sender instanceof Player player) {
if (args.length > 0) {
messages.put(player.getUniqueId(), String.join(" ", args));
return true;
}
sysout(player.getName() + " : " + messages.getOrDefault(player.getUniqueId(), "No message stored!")
return true;
}```
what does .put do?
that would allow you to use the same command to store or retrieve a message
put adds am entry in the Map
so thats essentially what stores the messages into the hash map
So it stores teh message under teh players UUID
kind of like .add for an arraylist
Ok
So I would'nt even need to use an event handler!
interesting
no
just the command
if you enter teh command with no text after it will show you the stored message
sorry not directed towards this message
If there is a message stored for that player it will fetch it, or if none it will add the no message message
saying that if nothing was stored and nothing was put in then default is called
yeah
getOrDefault is nice to prevent null errors
what does String.join do?
Have a guess
lol fair
builds a single string of all the args with a space between each
yah
would any know how to fix when you teleport two players a world the one player can't see one and the other one can see the other one? (i don't know how to explain it one, but it's like as one of the players have invisiblity in one of the mc window but the other mc window sees the other play perfectly fine.)
Is the world loaded before you teleport?
Player.setVisible()?
I'm getting an error for the String.join part
its asking for character sequences.
google it, I may have got it slightly wrong
yep I got it in reverse
String.join(" ", args)
Is there a way I could have done this with arraylists
yes, but not as easily
Ok
It would have been a nightmare to replace a message
and lots of looping to find the right entries
I see
Hypothetically how would I go about storing the message tho?
would I need to use an event?
this Map you can put straight into a FileConfiguration (config)
Cool
yeah the whole reason I want to store this message is because i’m creating another command where when you call it it will display the saved message
and imma just extend the saved message class to it
That code currently allows you to use just the command to see the message
What do you mean by see
the sysout line System.out.println
if you just type the command with no message after it, it will show you whatever message is already stored
oh awesome
well i slightly changed it so that it is player.sendMessafe instead of sysout
yep, thats fine
I guess it isn’t technically the world sending the message but whatever
I have a question regarding IntelliJ and an artifact not being built and I'm loss as to why it won't build. Is anyone here familiar with IntelliJ on this one
Show me your project structure
?ask
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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
In my build.gradle I have org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT and in my plugin.yml I have 1.18.2-R0.1-SNAPSHOT however my server says that's an unsupported API version, what exactly do I put here?
1.18 api version
So just 1.18
yes
very much so
then I have quite the nooby question to ask you
I don't know the whole me.x.x I keep seeing on forums. What is the pattern for that because I only know the directory of the main file
it will be the package name + your main class name
whatever package you have at teh top of your main class
no
Oh?
you use packages to structure your classes, like directories with normal files
look in your actual class file, at teh top, the very first line will say package me.
There’s one main class in spigot, the one that extends JavaPlugin as you are aware of
Oh then I've done something wrong because I don't have a package
I thought package was synonomous with folder
I may have had a contextual misunderstanding then
it is, kind of
They’re to some extent
Packages do have a deeper meaning than just being directories in Java, but for your sake that deeper meaning isn’t substantially important
Oh I mean I'll probably end up learning about them soon
I have more of a C-background and some python, not a huge Java background besides some small projects
Right
Would it be acceptable structure to create a package underneath that java folder then?
Java introduces several principles that advocate splitting the code up into different packages with different classes
yes
Usually (assuming you still use gradle) you got the src/main/java
Your packages should be under that directory
Correct
there are of course classes with no package (in other words they are located directly under src/main/java) but for most part you wanna avoid doing that
yeah, how can i make sure though? it says the world is loaded in the console
you could just load it yourself
it says it's being loaded
im loading it through a db and the world is actually here when im teleported
loading through a db?
I believe my plugin.yml is correct - but my server is still spitting out "Unsupported API version 1.18.2-R0.1" and I just updated it with BuildTools to latest. Again for reference my project directory looks like SpigotGradleProject > src > main > java > me.goodvibes > Main.java and the plugin.yml main reads as me.goodvibes.Main. For version, in my build.gradle I have org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT and my plugin.yml is api-version: 1.18
you can;t have updated teh jar or you did not update teh plugin.yml
I rebuilt the artifact & rebooted server to make sure but I will do that again
open your plugin jar with any (7zip) and view its plugin.yml
um, yes gradle + artifacts spells boom

I take it that's improper. After reviewing the spigot page real quick yeah it looks like those are separate methods of doing things, I must have bled one page to another
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I wrote this a while back
That shows you how to properly use gradle
respect 💯
I'm just built different, thank you for pointing that out. This just shows how unfamiliar I am with java & IntelliJ
defaults?
gradle? icky
the defaultValue?
like it always print the No message stores
yea
I think it has to do with my main method
Oh that’s iirc called inlay hints or sth
It comes up whenever you pass a magic value to a function
A magic value is either this, or a number/boolean/string
it's a null check iirc
^
this is my save message class which im extending
This doesn;t have any of the code to store the message
ah you seperated it to two commands
yeah
what i meant by this
You are using different maps for storing and retrieving
Am I?
don't extend it just make the store static
then make store static
a static object only has one instance
does the jvm pass this into methods even if they dont require it?
or are they just accessed through a load istore or something
Not sure what you are asking
Where does gradle make the .jar
target folder
I can't say I know where that is but after searching the entire directory there is no jar file being created
But I definitely followed that article to a T
the target folder will be at teh same level as the src folder
yeah there's nothing there
It should be created in build/libs
there is no libs folder, I'm definitely lost here I might revert back to the artifact method on a non-gradle project tbh
Yeah all the way
If it makes you feel better I'd rather stay on gradle but I definitely am drawing a blank here haha
If your DM's are open I could send screenshots of my stuff since I can't send them here, but like I'm lost lost
Sure
using a YamlConfiguration option to read a config file... is it not possible to .get("list.0.subkey") where 0 is the index of the list you want to pull?
anybody know how to rewrite velocity of enderpearls whenever they are thrown - event?
basically what I mean is
when they touch a open fence gate, make it so people can pearl through open fence gates
basically tali pearls plugin
and like make it so people cant pearl glitch
refund pearl
Hey everyone, im trying to extend EntityZombie but i can't since im getting an error
'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type```
Im using spigot mapping
https://paste.md-5.net/padobumofo.java
I'm trying to add a metadata "role" to the player (runner, hunter, etc.) and im getting a null error which seems to be caused by this line from some debugging
metadata = (MetadataValue) player.getMetadata("role");
```and i set it here ```java
player.setMetadata("role", new FixedMetadataValue(plugin, role));
```and i have been unable to find any good resources regarding how to use and retrieve metadata
"role" is an enum btw
When I create a nbttagcompound, do have to set the uuid range? Or is there a chance that it is overwritten by another item?
I don't know much about metadata but you can take a look at pdc, it might be helpful.
I think you need to use NMS for that.
what is NMS
i got it without nms
May I know how? I'm curious also.
I thought you need to actually modify the PathFinderGoals.
public void MobAngry(EntitySpawnEvent event){
if (event.getEntityType() == EntityType.ENDERMAN){
Enderman enderman = (Enderman) event.getEntity();
for (Player player: Bukkit.getOnlinePlayers()){
enderman.setTarget(player);
}
}else if(event.getEntityType() == EntityType.ZOMBIFIED_PIGLIN){
PigZombie pigman = (PigZombie) event.getEntity();
for (Player player: Bukkit.getOnlinePlayers()){
pigman.setTarget(player);
}
}
}```
Ah, that's very useful, I wonder when it was added.
idk im kinda new
@summer scroll do you know how to make the enderman and piglin be angry even when the player dies?
because it works until the player dies and then they stop hunting him
Maybe you need to keep track of the Enderman and Piglin reference and set the target whenever player respawn.
so another event when player respawns?
Yeah, listen to that event and since you keep the reference of the Mob, you can just loop through the mobs and then set the target to the player.
ok
UPDATE scores s1 INNER JOIN (SELECT *, FIND_IN_SET(score, (SELECT GROUP_CONCAT(DISTINCT score ORDER BY score DESC) FROM scores WHERE ranked = 1)) AS rank FROM scores WHERE ranked = 1) s2 SET s1.previous_place = s2.rank"
This does nothing to my table? No error, just no value is changed
is ther a post player join event?
PlayerLoginEvent
Is there a event that is called after the join msg?
You want to change the joinmessage?
No i want to send something after the join msg
Then send it 1 tick after PlayerJoinEvent
ok thanks
how can i run buildtools with mojang mappings?
--remapped
SELECT *, FIND_IN_SET(score, (SELECT GROUP_CONCAT(DISTINCT score ORDER BY score DESC) FROM scores WHERE ranked = 1)) AS rank FROM scores WHERE ranked = 1
This works, but I can't manage to save the rank result in a column named previous_place
doesnt works...
java -jar BuildTools.jar --rev 1.18.2 --remapped
pause```
oh worked
thanks
it there a way in InventoryClickEvent to get the inventory after the click?
because event.getClickedInventory() returns the inventory before the click
All cancellable event will occur before the actual event happen.
ok so is there a way to get the inventory after the click?
I feel like this is an xy problem, can you tell us what you are trying to achieve?
check if a player equips armor
This is what I have @EventHandler public void ArmorChange(InventoryClickEvent event){ if (event.getClickedInventory() instanceof PlayerInventory){ Player player = (Player) event.getWhoClicked(); if (IsArmor(player)){ for (Entity entity: player.getWorld().getEntities()){ if (entity.getType() == EntityType.ZOMBIFIED_PIGLIN){ PigZombie pigman = (PigZombie) entity; pigman.setTarget(player); } else if (entity.getType() == EntityType.ENDERMAN) { Enderman enderman = (Enderman) entity; enderman.setTarget(player); } } } } }
IsArmor(player) returns if the player wears armor
just check if the player clicked on an armour slot?
You can either delay it by 2-3 ticks, or you can check If player is about to wear the armor by getting the item on the cursor.
and if he unequipped the armor?
check if the slot isnt null after
so I need to schedule a delay of 2 ticks?
How can I get the "targeted" block of a player
How could I get the location of that spruce log?
declaration: package: org.bukkit.entity, interface: LivingEntity
what should i add after that in pom.xml?
Currently i have xml <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> </dependency>
should i add something else too that applies the mojang mappings?
How can I send a message as a target
aight thanks
Nevermind I think I found it
hi how can i add cooldowns to my playermoveevent? i want it so when a player walks on COAL_ORE it gives the player RABBIT_FOOT but i want there to be a cooldown or 30 seconds so before the 30 seconds end, if the player wanks on the block again they wont get the RABBIT_FOOT
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(event.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.COAL_ORE) {
Player player = (Player) event;
player.getInventory().addItem(new ItemStack(Material.RABBIT_FOOT));
}
}
}```
use UUID if you want it to work while the player's offline
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
how would i use that with my playermoveevent?
just read the wiki entry first and ask if you have anymore questions after that
alright thanks
@terse raven i have imported and created all i needed but now how can i implement this:
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//Player only command
if(sender instanceof Player){
Player p = (Player) sender;
int timeLeft = cooldownManager.getCooldown(p.getUniqueId());
//If the cooldown has expired
if(timeLeft == 0){
//Use the feature
p.sendMessage(ChatColor.GREEN + "Feature used!");
//Start the countdown task
cooldownManager.setCooldown(p.getUniqueId(), CooldownManager.DEFAULT_COOLDOWN);
new BukkitRunnable() {
@Override
public void run() {
int timeLeft = cooldownManager.getCooldown(p.getUniqueId());
cooldownManager.setCooldown(p.getUniqueId(), --timeLeft);
if(timeLeft == 0){
this.cancel();
}
}
}.runTaskTimer(this.plugin, 20, 20);
}else{
//Hasn't expired yet, shows how many seconds left until it does
p.sendMessage(ChatColor.RED.toString() + timeLeft + " seconds before you can use this feature again.");
}
}else{
sender.sendMessage("Player-only command");
}
return true;
}
}```
into my code:
```java
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if(event.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.COAL_ORE) {
Player player = (Player) event;
player.getInventory().addItem(new ItemStack(Material.RABBIT_FOOT));
}
}
}```
Why I am duping the sponge?
When I place a sponge I get 1 extra
Before placing it, after placing it
Infinite sponge
Check if slot is not null
Why that?
Are you getting another copy of sponge after placing it again?
yeah
Because if slot has one than it wont be added again
but the player can have more than 1 sponge
Umm i did not get the problem here
wdym by physically
I mean what do you expect after placing a block
I just want to make an infinite sponge, that when you place it you re-obtain it for using it again
So the problem is it is giving a copy of it right?
yeah
If you check that if the slot is null, cant you control adding a new one?
Or check if its "Air"
let me try smt
hello, would this code work?
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = (Player) event;
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
if(timeLeft == 0) {
if(event.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.COAL_ORE) {
player.getInventory().addItem(new ItemStack(Material.RABBIT_FOOT));
player.sendMessage(ChatColor.GOLD + "10 Coins Earned!");
cooldownManager.setCooldown(player.getUniqueId(), CooldownManager.DEFAULT_COOLDOWN);
new BukkitRunnable() {
@Override
public void run() {
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
cooldownManager.setCooldown(player.getUniqueId(), --timeLeft);
if(timeLeft == 0){
this.cancel();
}
}
}.runTaskTimer(this.plugin, 20, 20);
}
} else {
player.sendMessage(ChatColor.GREEN + "You can get coins again in " + ChatColor.GOLD + ChatColor.GREEN + " seconds!");
}
}
}```
try?
💀
Fixed it @kindred valley
It probably fires twice once for main hand and once for offhand or something
@EventHandler
public void blockPlaceEvent(BlockPlaceEvent event) {
ItemStack item = event.getItemInHand();
if (item.getType() == Material.SPONGE) {
if (item.getItemMeta().getCustomModelData() == 302) {
Player player = event.getPlayer();
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskLater(Neo.getInstance(), () -> {
event.getBlock().getLocation().getBlock().setType(Material.AIR);
ItemStack sponge = new ItemStack(Material.SPONGE, 1);
ItemMeta itemMeta = sponge.getItemMeta();
itemMeta.setDisplayName(Data.color("&eEsponja Infinita"));
itemMeta.setCustomModelData(302);
sponge.setItemMeta(itemMeta);
player.getInventory().addItem(sponge);
}, 1L);
}
}
}
hi i get this problem on console with my plugin not loading:
[11:44:57 ERROR]: Could not load 'plugins\PlutoCraftParkourRun-1.0.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Abnormal plugin type
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:87) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:415) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:323) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.loadPlugins(CraftServer.java:418) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:288) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-337]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.InstantiationException: net.plutocraft.plutocraftparkourrun.PlutoCraftParkourRun
at java.lang.Class.newInstance(Class.java:671) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:83) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 8 more
Caused by: java.lang.NoSuchMethodException: net.plutocraft.plutocraftparkourrun.PlutoCraftParkourRun.<init>()
at java.lang.Class.getConstructor0(Class.java:3617) ~[?:?]
at java.lang.Class.newInstance(Class.java:658) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:83) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 8 more
Hoe? ._.
he meant how i think
what does this mean?
Caused by: java.lang.InstantiationException: net.plutocraft.plutocraftparkourrun.PlutoCraftParkourRun
Caused by: java.lang.NoSuchMethodException: net.plutocraft.plutocraftparkourrun.PlutoCraftParkourRun.<init>()
you are calling a method that does not exist
could you send us the corresponding lines?
this my my code:
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = (Player) event;
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
if(timeLeft == 0) {
if(event.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.COAL_ORE) {
player.getInventory().addItem(new ItemStack(Material.RABBIT_FOOT));
player.sendMessage(ChatColor.GOLD + "10 Coins Earned!");
cooldownManager.setCooldown(player.getUniqueId(), CooldownManager.DEFAULT_COOLDOWN);
new BukkitRunnable() {
@Override
public void run() {
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
cooldownManager.setCooldown(player.getUniqueId(), --timeLeft);
if(timeLeft == 0){
this.cancel();
}
}
}.runTaskTimer(this.plugin, 20, 20);
}
} else {
player.sendMessage(ChatColor.GREEN + "You can get coins again in " + ChatColor.GOLD + ChatColor.GREEN + " seconds!");
}
}
}```
How could I make a player double jump?
the line that gets referenced in the error log
this is my log:
org.bukkit.plugin.InvalidPluginException: Abnormal plugin type
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:87) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:415) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:323) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.loadPlugins(CraftServer.java:418) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:288) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-337]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-337]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.InstantiationException: net.plutocraft.plutocraftparkourrun.PlutoCraftParkourRun
at java.lang.Class.newInstance(Class.java:671) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:83) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 8 more
Caused by: java.lang.NoSuchMethodException: net.plutocraft.plutocraftparkourrun.PlutoCraftParkourRun.<init>()
at java.lang.Class.getConstructor0(Class.java:3617) ~[?:?]
at java.lang.Class.newInstance(Class.java:658) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:83) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 8 more```
Is there any way to listen for packets with NMS?
could you send us the PlutoCraftParkourRun class?
here:
package net.plutocraft.plutocraftparkourrun;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
public final class PlutoCraftParkourRun extends JavaPlugin {
private final CooldownManager cooldownManager = new CooldownManager();
private final Plugin plugin;
public PlutoCraftParkourRun(Plugin plugin) {
this.plugin = plugin;
}
@Override
public void onEnable() {
getLogger().info("PlutoCraftParkourRun Enabled");
}
@Override
public void onDisable() {
getLogger().info("PlutoCraftParkourRun Disabled");
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = (Player) event;
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
if(timeLeft == 0) {
if(event.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.COAL_ORE) {
player.getInventory().addItem(new ItemStack(Material.RABBIT_FOOT));
player.sendMessage(ChatColor.GOLD + "10 Coins Earned!");
cooldownManager.setCooldown(player.getUniqueId(), CooldownManager.DEFAULT_COOLDOWN);
new BukkitRunnable() {
@Override
public void run() {
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
cooldownManager.setCooldown(player.getUniqueId(), --timeLeft);
if(timeLeft == 0){
this.cancel();
}
}
}.runTaskTimer(this.plugin, 20, 20);
}
} else {
player.sendMessage(ChatColor.GREEN + "You can get coins again in " + ChatColor.GOLD + ChatColor.GREEN + " seconds!");
}
}
}```
thats everything in my class
You must have a no-args constructor
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
super.channelRead(ctx, msg);
}
@Override
public void write(ChannelHandlerContext ctx, Object object, ChannelPromise promise) throws Exception {
if (object instanceof ClientboundBlockDestructionPacket) {
ClientboundBlockDestructionPacket packet = (ClientboundBlockDestructionPacket) object;
//if (packet.getId() != player.getEntityId()) return;
player.sendMessage("§a§l[BananaPrison] §f§lProgress: §e§l" + packet.getProgress()*10 + "%");
//if (packet.getProgress() == 0) return;
}
super.write(ctx, object, promise);
}
});
((CraftPlayer) player).getHandle().connection.connection.channel.pipeline().remove(player.getName());```
@terse raven
You must have a no-args constructor
^
how do i do that?
Thanks
Remove your constructor?
remove the public PlutoCraftParkourRun () function
The plugin instance is going to be this anyways
🥴 sorry
and add a this.plugin = this in onEnable
There is much ways i guess
but I'ma go now
wait so like this?
@Override
public void onEnable() {
getLogger().info("PlutoCraftParkourRun Enabled");
this.plugin = this;
}```
remove your plugin variable, it is completely nonsense
Instance named plugin?
You PlutoCraftParkourRun instance is going to be your plugin instance, what you have here is a useless GETFIELD operation
Yeah
And any references to this field are replaced with this and any assignments need to be dropped
How do I check if a player is not holding any item?
@quiet ice i cant remove it tho because it caused a ton of errors
You can
but it causes a lot of errors
As I say, you need to replace any this.plugin or plugin references with this
Whats wrong with this code for spawning a npc?
MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer();
Level level = ((CraftWorld) Objects.requireNonNull(e.getPlayer().getWorld())).getHandle();
ServerPlayer player = new ServerPlayer(minecraftServer,level.getMinecraftWorld(),new GameProfile(UUID.randomUUID(),"Martin"));
ServerPlayerConnection connection = ((CraftPlayer)e.getPlayer()).getHandle().connection;
connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER,player));
connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME,player));
so like this?:
@quiet ice
public PlutoCraftParkourRun(Plugin plugin) {
this = plugin;
}
its a problem in bukkit trying to initialize your plugin i think
DROP THE FUCKING ASSIGNMENTS
do you have a constructor defined with no arguments?
i dont know what that is im new
this cannot be assigned anyways
bro
JavaPlugin implements Plugin
the instance this is your plugin
bukkit cant create your plugin if you dont have a 0 args constructor\
as such any plugin is going to be this anyways
you need to have either no constructor or a 0 arg constructor
What idiotic tutorial did you read to come to the conclusion that you need such a constructor
ok done
the wiki that mja send me lol
tf
@quiet ice so my code should be ok now?
package net.plutocraft.plutocraftparkourrun;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
public final class PlutoCraftParkourRun extends JavaPlugin {
private final CooldownManager cooldownManager = new CooldownManager();
public PlutoCraftParkourRun(Plugin plugin) {
}
@Override
public void onEnable() {
getLogger().info("PlutoCraftParkourRun Enabled");
}
@Override
public void onDisable() {
getLogger().info("PlutoCraftParkourRun Disabled");
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = (Player) event;
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
if(timeLeft == 0) {
if(event.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.COAL_ORE) {
player.getInventory().addItem(new ItemStack(Material.RABBIT_FOOT));
player.sendMessage(ChatColor.GOLD + "10 Coins Earned!");
cooldownManager.setCooldown(player.getUniqueId(), CooldownManager.DEFAULT_COOLDOWN);
new BukkitRunnable() {
@Override
public void run() {
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
cooldownManager.setCooldown(player.getUniqueId(), --timeLeft);
if(timeLeft == 0){
this.cancel();
}
}
}.runTaskTimer(this, 20, 20);
}
} else {
player.sendMessage(ChatColor.GREEN + "You can get coins again in " + ChatColor.GOLD + ChatColor.GREEN + " seconds!");
}
}
}```
NO
drop the constructor
you dont need the constructor
what are you trying to create?
what is the constructer?
only use a constructor if you need custom behaviour on instianiaton
public PlutoCraftParkourRun() {
}
?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.
does anyone know how to make a give command and amount choice
alright done
i am quite new to coding
i just said its class constructor
is it ok now?
package net.plutocraft.plutocraftparkourrun;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
public final class PlutoCraftParkourRun extends JavaPlugin {
private final CooldownManager cooldownManager = new CooldownManager();
@Override
public void onEnable() {
getLogger().info("PlutoCraftParkourRun Enabled");
}
@Override
public void onDisable() {
getLogger().info("PlutoCraftParkourRun Disabled");
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = (Player) event;
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
if(timeLeft == 0) {
if(event.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.COAL_ORE) {
player.getInventory().addItem(new ItemStack(Material.RABBIT_FOOT));
player.sendMessage(ChatColor.GOLD + "10 Coins Earned!");
cooldownManager.setCooldown(player.getUniqueId(), CooldownManager.DEFAULT_COOLDOWN);
new BukkitRunnable() {
@Override
public void run() {
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
cooldownManager.setCooldown(player.getUniqueId(), --timeLeft);
if(timeLeft == 0){
this.cancel();
}
}
}.runTaskTimer(this, 20, 20);
}
} else {
player.sendMessage(ChatColor.GREEN + "You can get coins again in " + ChatColor.GOLD + ChatColor.GREEN + " seconds!");
}
}
}```
yes at least the loading will work now
i recommend reading some java help articles or the oracle spec to get more familiar with java
or any of the links in ?learnjava
i started coding last week lol
?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.
I recommend w3schools for learning java basics its good enough
Anyone able to help me. cause i wanna know how to make a command that gives items and you can choose the amount of it
i want this code to give me rabbit foot when i go on coal ore but it doesent work, how can i fix this?
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = (Player) event;
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
if(timeLeft == 0) {
if(event.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.COAL_ORE) {
player.getInventory().addItem(new ItemStack(Material.RABBIT_FOOT));
player.sendMessage(ChatColor.GOLD + "10 Coins Earned!");
cooldownManager.setCooldown(player.getUniqueId(), CooldownManager.DEFAULT_COOLDOWN);
new BukkitRunnable() {
@Override
public void run() {
int timeLeft = cooldownManager.getCooldown(player.getUniqueId());
cooldownManager.setCooldown(player.getUniqueId(), --timeLeft);
if(timeLeft == 0){
this.cancel();
}
}
}.runTaskTimer(this, 20, 20);
}
} else {
player.sendMessage(ChatColor.GREEN + "You can get coins again in " + ChatColor.GOLD + ChatColor.GREEN + " seconds!");
}
}
}```
could you send us the cooldown manager class?
package net.plutocraft.plutocraftparkourrun;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class CooldownManager {
private final Map<UUID, Integer> cooldowns = new HashMap<>();
public static final int DEFAULT_COOLDOWN = 15;
public void setCooldown(UUID player, int time){
if(time < 1) {
cooldowns.remove(player);
} else {
cooldowns.put(player, time);
}
}
public int getCooldown(UUID player){
return cooldowns.getOrDefault(player, 0);
}
}```
there
anyone knows this?
@terse raven
has the error changed?
their are no errors
bruh thats literally the code from the cooldownmanager on the forum
yea and?
i use it
can somebody help pls
it loads properally now