#help-development
1 messages · Page 1967 of 1
sorry my english is 💩
but it requires doubles. What do I need to do if I want to use Integer variables for the equation?
I really don't get it
It seems like you're saying two different things here
Which is it
Are they reassigned each time?
Or do they never change?
You cast to int
(int) Math.pow(2, 1)
what's really the benefit of NMS?
cant you already do everything in the spigot api itself?
oh :(
Reassigned when you call the class
Okay so they're not constant values
Oh sorry my bad
And {name} would evaluate to the name of the player, correct?
thanks man!
So if my username is Redempt and the input text is hello {name}
Then the output would be hello Redempt?
You would decire (via code) which placeholders you want to add and then replace it with the value on a message
For example on my coins command i would need 2 placeholders to be able to use {target} and {coins}. So you would add it as follow
Placeholders placeholder = new Placeholders();
placeholder.set("{target}", target.getName());
placeholder.set("{coins}", String.valueOf(10));
Player#sendMessage(placeholder.replace(Config#getString("Coins-Message")));
Man that is so overcomplicated
Hmn why?
And you also didn't answer my question
Yes or no
depend on what you assign on Placeholder#set()
So they're all global values detached from players
And {coins} would be what exactly?
Some global coin counter rather than the number of coins I have?
are there like some sort of "docs" to see what function names i should override for nms?
I explain
How do I change the angle of the fireball projectile im shooting. so when I left click instead of it going straight it would shoot left of the plus sign in the middle of the screen?
Listen for the player punching it, it probably fires EntityDamageByEntityEvent
Then schedule a task to run the next tick which modifies its velocity
Easiest way is to rotate it 90 degrees around the y axis, there's a method you can use for it I think it's Vector#rotateAroundYAxis or something
It's rotateAroundY
Let say my config looks like this and command:
Messages:
Coins: "Player {target} have {coins} coins"
// Command should be /coins <target>
public boolean onCommand(sender, args[]) { // just an example
if (args.lenght == 0) return true;
OfflinePlayer target = Bukkit.getPlayer(args[0]);
Profile profile = Main.getInstance().getProfiles().getProfile(target.getUniquedId());
if (profile == null) return;
Placeholders placeholder = new Placeholder();
placeholder.set("{target}", profile.getName());
paceholder.set("{coins}", String.valueOf(profile.getCoins()));
sender.sendMessage(placeholder.toString(Config.getString("Messages.Coins")));
}
There redempt you have an example
...
So it is dependent on players
It does set their name
And it is their coin count
It's really hard to help you because I keep asking you questions and you keep telling me it's supposed to be doing something entirely different from what it is
It doesnt dependent from player, its just to avoid being doing String.replace("{placeholder}", "value") on every message sent to player. I though doing a key-value which store it temporary, and then a method for replacing all placeholders in that message
But i dont udnerstand you most of time
paceholder.set()
hey look i found a bug!
What?
Hmn i dont understand
It does depend on the player though
The value that is set for the placeholders depends on the player it's being generated for
yes
i use build tools to decompile the jar and find stuff methods yes?
in general you should use the API whenever possible. There are some things not possible via the api, however most people generally don't need NMS either.
buildtools gives you the source
well the source for spigot
I just do Ctrl + click class on Intellij Idea and it decompile the class
ah
oh
custom mobs :kek:
Can I pay someone to make me a plugin that adds a upgradable pickaxe with many cool enchants
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
What do you think about the idea of placeholder class would be player dependent?
Just search on goggle "Java reflections"
oh okay
And it should be info there
Reflection. It allows an executing Java program to examine or "introspect" upon itself, and manipulate internal properties of the program
oh
back to the docs i go then
ty!
For using NMS you use Reflections
oh..
For example, to get the server version
Any good tutorial about regex i wanna check via regex if a string contains text between {}?
How do I set an armor slot to nothing?
this doesnt seem to be working
ItemStack item = new ItemStack(Material.AIR);
p.getInventory().setHelmet(item);
#setHelmet is nullable
so just set it to null
{\w+}
oh yea redempt should be furious now
I'm just having a bad day
Why might this be running logging twice?
@EventHandler
public void onPlayerInteractEntity(final PlayerInteractAtEntityEvent e) {
final Player p = e.getPlayer();
if (e.getRightClicked() instanceof Player) {
final Player clicked = (Player) e.getRightClicked();
String data = clicked.getPersistentDataContainer().get(new NamespacedKey(this, "costume"), PersistentDataType.STRING);
System.out.println(data);
}
}
simple
your main hand, and your off hand
How might I avoid it logging twice?
if (e.getHand() != EquipmentSlot.HAND) return;```
^
^
Is there a way to force the player to rejoin?
No
if that were possible i would have a server with thousands of players :D
I just need the server to believe a player has logged off and logged back on without the player actually having to relog
to update the player's uuid
If posible i woudl already been using plugin message channel with fake entities
yes
I've done that before
How much do you ask for coding?
$20/hour
Oh
I tried that but it seems to cause some plugins to break
Here's the code for that project if anyone wants to mess with it
coulnt this cause some performance problems to other plugins on some occasions ?
I haven't updated it for a long time so it doesn't work on the latest versions
The Player just returns null
like saving/loading data it has about players
The one for firing PlayerQuitEvent?
Probably not much
No it's the entire project
Oh lmao i have never downloaded so fastest
haha
Redempt
I done something similar but with Sockets doing Handshake and Login
Thanks I'll take a look
I just started making my first plugin using Maven, and I just setup NMS. When I try to create a custom entity class (as seen below), "public class EntityNPC extends EntityZombie" has a error over it saying "'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type" java public class EntityNPC extends EntityZombie { public EntityNPC(World world) { super(world); } }
What do you guys use for website dev?
I've tried just about everything I can, and the error still won't go away. I'm using IntelliJ, if that means anything
this is your entire class?
Yes
I wrote the first 4 lines of code and it won't go away regardless of how much more information I add
Like communciation client? Backend? explain please
when i replicate this it works fine for me
Do you think there's a problem with my spigot build?
what version u working on?
In my pom.xml I have 1.18.1-R0.1-SNAPSHOT in my dependencies
WebStorm
and IntelliJ for the backend stuff
oh yea, i got the same on 1.18 now
Or RubyMine
I'd rather not downgrade to an older version
with PlayerInteractAtEntityEvent how would I get the item in the users hand?
if that's possible
you shoulnt have to. but i dont really know why this is at this point
I've googled it just about a thousand times, and can't find anybody else with the problem
so I did some more digging, and apparently I'm supposed to use the Mojang mappings on 1.17+
that could work but to my knowledge thats only to make coding using nms easier for you. it was never a requirement
?bootstrap
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
i c
So... What exactly does that mean?
I'm already using Maven, so I shouldn't really have to do anything, at least by my understanding
what ru depending on, in ur pom
1.18.1-R0.1-SNAPSHOT
yw show the whole dependency block
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
yh
don't you need spigot-api?
i think this means u actually need to use spigot-api
but then I can't use NMS
did you try?
yeah, when I first started I used spigot-api but I couldn't make the entity
I guess I could try again, though
Yeah, I swapped it out and then it just says it can't resolve symbol on EntityZombie
did you read this https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163 ?
Yes
what error do you have?
IDE errors are not exactly the same as compile errors just fyi
so what is the IDE complaining about?
this
This:
'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
I'm sorry if I seem clueless, but what exactly about it are you referring to?
oh i was just replying to that message so he could read your error
how can I add NMS dependecy to a gradle project? (no maven)
Oh, ok
o where can I find it?
you need to use mojang mappings
So just re-run buildtools with --remapped, right?
To use it on Gradle?
I know how to add the dependency on a maven project, but I never use it o gradle
if you had read the post from up earlier
you would have gotten to this link here
Your fake player its detected as an online player? Becuase if yes i would continues using plugin message channel
read the NMS portion it is applicable to 1.18
I unfortunately don't use gradle so I don't know how you would do it in gradle.
like program to develop.
Does anyone know which EnumPlayerInfoAction is ADD_PLAYER and REMOVE_PLAYER for 1.17.1?
How do I use NBT data?
Entity covers entity NBT, ItemMeta covers ItemStack NBT, and BlockState covers tile entity NBT
PersistentDataContainer for all of those types covers custom NBT
How I would I go about assigning a string to a book using NBT?
where to learn java for spigot
Thank you
?
Um I cant help you sorry, Just look up a tutorial or something.
okay
?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.
What type of error would I need to catch when attempting to set a player variable to a player who is not online?
Hmm?
Bukkit.getPlayer returns null if they aren't found ^
Oh.
pretty non-optimal honestly
it should just stop the server if the player isn't found
Agreed
Oh nice
Im having an issue
That it doesnt throw any exception btww
Never happen, please Jesus...
?
What?
Its amazing having an issue without any Exception thrown
Oh its throwing NPE. Lmao plugin.yml has command registered
I dont find any cause why getting NPE, cuz command its registered on plugin.yml and via getCommand() method
What do you think?
I dont find any reason
commands is misspelled
OH
How can I get the actual damage an item will inflict on a player (listening to EntityDamageByEntityEvent)?
Thanks i never notice that its was misspelled
getFinalDamage
Does anyone know why changing the uuid of a player by changing the UUID field in Entity causes some plugins to always return Player as null?
Because you are doing something very hacky
For some reason only a select few plugins return Player as null, the rest work as intended
Watchdog npc its something like this right?
Haven't heard watchdog but whats that
Watchdog its called the Hipixel Anticheat
It’s possible they store the uuid and then use Bukkit.getPlayer
That’s fairly common rather than holding a player instance
It based on NPC that get moved around you if detect extrange activity or always i dont know
I just know that sometimes it get bug and you can see the entity moving around you
oh I see
But i think every anticheat its bypassable
but thats for armorstands, can work with npc's ig
Imagine i bought a +60 dollars anticheat im still figthing again DMCA to get my money back. Because the anticheat its so good that doing a simple ping-spoof you can disable checks
I barely use nms if I really need it I have to learn it again lol
yeah not all anticheats are 100% protection
Yeah but imagine paying 60 dollars for a shit
Yes but since my plugin changes the player's uuid first the plugin should store the new uuid rather than the old one. It also seems that for one plugin the PlayerJoinEvent getPlayer method returns null.
most of them are aggressive and mostly false positives
That get me mad, because with that money and a bit more. I could bought a custom one and better
or make your own
I mean like I said you are doing something very very hacky
Good luck
Alright, thanks
I'm trying to create a character save system where each character is essentially a new player
this way all plugins will store data to the seperate uuid instead of the player itself
Why?
feels like singleplayer game saves
I would do a custom Object for each player and save there the custom data there
But the issue with that is that isn't compatible with all plugins since I would have to modify all of my plugins to save data there
And of course using DB for persisting it
Explain again
i didnt understand
Its like a save file that allows all plugins to save data under a specific save file
this way players can go back and forth between different save files or restart if they wish
Hum looks that its not working, the player its not being registered on PlayerList
But on tab i can see it Hahaha
if you're using this in a live server, its neat but there are lot of things can go wrong
prob for using plugin message channel without player, i will inject it via Socket, doing Handshake protocol
Yeah, that's why I'm testing everything on a test server just in case I screw something up and lose all of my player data
Everything works fine currently except for the select few plugins that have broken getPlayer methods
u using db for it?
Yes
what db
MySQL
Pick one of the broken plugins and look at the source I guess
You are using a custom Object and DB but with different uuid, its the same as doing it using their uuid
oh mySql, still learning that currently this semester
See if said plugin doesn’t anything specific
I took a look at one of the source code of one of the plugins and found that the player join event getPlayer method returns null
What? i didnt try-catch it
Unit testings so
Cannot invoke "org.bukkit.OfflinePlayer.getUniqueId()" because "player" is null
the player parameter is passed through a join event where it gets event.getPlayer
I would recommend doing a custom Offline Player object and Player object
Wouldnt be better than using OfflinePlayer from bukkit?
It might but the issue is I can't modify this since its not my plugin
u using the api of the plugin?
I'm just looking at the source code
what plugin is it
I'm not actually using the API or any methods of the plugin
BetonQuest
and VoxelSniper
What are you doing?
but I'm currently trying to figure out BetonQuest
A custom Data system
Yep
And then?*
A custom data system that saves data to multiple player save files rather than the player itself
so a player could have 5 save files and swap between them
return player.getUniqueId().toString();
}``` most of the errors seem to have to do with this method
does it save inventories too?
Yes
it saves inventories balances custom currencies etc
basically anything that plugins can save
This is one of the big problem when trying to use custom system. You have to adapt other plugins or code custom ones
🥵
Yeah thats why im changing the uuid of the player as most plugins save data based on uuid
I mean
If you're interested, I have a config framework that could help with this
I think you’ve all missed the point
I would like to see that
They are changing the actual UUID of the EntityPlayer
Does it support json?
No but it would be pretty trivial to make it support json
why change the actual uuid
I dunno why you would use json for config though
Same question
Idk why
I dont find any reason
you can store a primary key for them instead since u use a databse for it
Oh i love networking, bungeecords telling me enable ip forward, ip forward its enable. HAHAH. TThis is the real life
On mysql you can have 2 primary keys?
Well an issue is not all of the plugins i currently have support a database
I thought thats the purpose of your save system, to fetch data and store it
you use their api for it, might be for listeners or handlers
I ask because i see that people for saving for example player log, they save each log on a log_table and the primary key is log_id and uuid
And then idk how they link the profile save on other table with log
A complete mess for me
That why im #Mongo, just saving and parsing objects
Mongo is the python of databases
Explain reference, i dont understand OOP explanations
no
Is it possible to extend an event? I want to create a new method that slightly changes the logic of EntityDamageEvent#getFinalDamage()
You can but if you want it to be heard by listeners of EntityDamageEvent then you will need to use its handler list
how do I do that
Every event class needs to implement public HandlerList getHandlers() and public static HandlerList getHandlerList()
Just make these both return the HandlerList for EntityDamageEvent, which you can get with EntityDamageEvent.getHandlerList()
What about if i done?
@AllArgsRequired
@Getter
public abstract UserEvent extends Event {
private final HandlerList handlers = new HandlerList();
private final UUID uuid;
private final User user;
}
@AllArgsRequired
@Getter
public class UserEventJoin extends UserEvent implements Cancellable {
private boolean cancelled;
}
Could custom plugin make proxy server telling?
is there a eventListner for when a command is issued?
?jd
Go to package: org.bukkit.events
yeah
And you have all the events there
Its called PlayerCommandProcessEvent or something like that
Search it on the docs
nice i dint know there was a doc for events
I made the class, added the method, and implemented getHandlers and getHandlerList, but it doesn't trigger the event.
code:
https://pastebin.com/4DPk8gV7
https://pastebin.com/B4RwUG3n
the listener is registered, It works with the actual EntityDamageByEntityEvent
java.lang.NullPointerException: Cannot invoke "java.util.List.equals(Object)" because "lore" is null
@EventHandler
public void onClick(PlayerInteractEvent e){
if(e.getPlayer().getInventory().getItemInMainHand().getType()==Material.AIR){
return;
}
List<String> lore = e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore() ;
if(lore.equals(WurskiesAxe.wurskiesAxe.getItemMeta().getLore()) && lore!=null){```
anybody know what i'm doing wrong here?
Do you have experience with Java
yea i do xD
i just need help with determining my mistake
If you are just starting i would straight recommend first learning the basics about Java. I tell it cuz from personal experience
I'm not that new in java. I just need help with what i'm doing wrong
(lore.equals(WurskiesAxe.wurskiesAxe.getItemMeta().getLore() == null) return;
Try that
Wait i will refactor so you understand
im making a small plugin that sends the command that got issued by ops to avoid cheating in my smp, what would be better for that use case
yea ik what you mean
It doesn't have its own handler list if you do it this way
PlayerCommandPreprocessEvent is called before the command is registered the normal way, you can do PlayerCommandPreprocessEvent#getMessage() to get the full string they typed and it can also be cancelled
I thought you wanted to fire it and have it be listened to by all the same event listeners that get EntityDamageByEntityEvent
If that's not the case then make a new HandlerList and keep it in a static field, and just return that from the two methods
ohk nice
@EventHandler
public void onClick(PlayerInteractEvent e){
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.AIR) return;
List<String> lore = e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore() ;
if (lore == null) return;
if (!lore.equals(WurskiesAxe.wurskiesAxe.getItemMeta().getLore())) return;
// rest code
Try that
alright
I want it to be called under the same conditions as EntityDamageByEntityEvent, I just want to change the final damage calculation
It not working sending data without any online player
Do you know what happening? I already defined the fake entity
I just want to use the new class as the event in the listener so I can use the method I created
Did it work?
1 sec i'm fixing it up and trying to make it neat
neat?
Your welcome
I think the problem was that you where doing .equals before checking if lore was null or not
oh i see
yup
Omg i would love to have the experience of developers
That they read 2 hours something new and they are done to do whatever they want
i want to check if the sender is console any idea?
if(sender instanceof ConsoleCommandSender)
wait that wont work because sender is event.getPlayer()
maybe sender.equals(Bukkit.getServer().getConsoleSender())
PlayerCommandPreproceesEvent
there is a seperate event for console
PlayerCommandPreprocessEvent
yeah
You want ServerCommandEvent
I still haven't figured out extending EntityDamageByEntityEvent, I want my custom event to fire whenever EntityDamageByEntityEvent fires, but setting the handlers to the same thing as the parent class didn't work
Please stop pinging me
If you're trying to get your event to fire instead of the regular EntityDamageByEntityEvent whenever EntityDamageByEntityEvent is fired, that's not gonna work
If you want to fire your event independently on its own handler list then you need to call Bukkit.getPluginManager().callEvent(your event here) whenever you want to fire it
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
will this check case?
Get the args and say equalsIgnoreCase
that wont workfor that case
I'm trying to use discord4J in my spigot minecraft plugin, but the server the plugin is in stops loading discord4j loads.
Then this should only fire if you have exactly “ban”
If you use equalsignorecase Will /BAN work?
this should be better
Because the command itself is registreredr lowercase
its a event
Why not just making a command instead of listening for the command event lol
huh no this will check if a command is issued it to avoid cheating in my smp
?
Is there any way to get Spigot permissions/prefixes into a BungeeCord plugin?
Using LuckPerms that is
why not use luckperms
im not referring to your chat
oh sorry
You'd likely need to communicate via Plugin packets
For my problem?
Yes
Perhaps some already Made Plugins, otherwise no
Thank you! Btw, do you know which packet it is?
that I need to get
Bukkit and spigot have integrated Support for that
What is discord4j?
Just Look Up Plugin channels
java wrapper for the discord api
I've never done Plugin Messaging before so I'm kinda stuck... How do I get a message from Spigot to BungeeCord easily? I've seen docs for the other way round but
I just need like a doc link or something
Ye.
https://www.spigotmc.org/wiki/sending-a-custom-plugin-message-from-bungeecord/
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I thought that was the jda
There are multiple
Oh
Thats also one. Discord uses http requests in their API. Usually you dont want to manually tinker with requests so people write wrappers so you can just call methods.
when i load my plugin, the .yml files have generated, but not enabled, i need to save the files manual and reload the plugin, and after the files have enabled, why?
🤷♂️ Show your code
what do you mean by enabled?
when i use a command with a message from file, i get an error
Use uuid instead of player in ur map
hello guys, how to give the player a spawner which spawns an entity (I want to give the spawner of a random entity)
IIRC there's no thing as SpawnerMeta. You'll have to add some PDC tags yourself to store the entitytype, then listen to BlockPlaceEvent and change the placed spawner's BlockState to spawn the correct entitytype (CreatureSpawner#setSpawnedType())
frick
^ use nbt then change the entity type on place
You have two options;
1... What mfnalex said
2. Use NMS and modify the item
Why NBT if PDC exists
what is PDC
NMS isn't needed too
same deal
PersistentDataCOntainer
persistent data container
?pdc
you can use that on the spawner's ItemMeta to save e.g. the EntityTypea s String
inb4 1.8
so about the minecart thing^^
can you show all your code stefan?
@faint aspen are you trying to move it whilst a player is inside it
i have a feeling you are constantly applying a -1 velocity
yeah
exactly^^
But what other way can you make an minecart drive the opposite direction?
yeah its repeating
so you are constantly putting it back and forth
you only want to apply the velocity once
but then it'll brake again when the player keeps pressing W
yeah thats true
yeah
I don't think you can easily do that
unless you also keep track of the direction the player is looking and the direction they were looking when the cart started to move
and you would have a problem when there is a turn
there's only vehiclemoveevent and that can't be cancelled
and it also doesn't have any method to get the "input"
I don't think there's a proper way to do this imho
yeah it seems complex
okay thanks anyways guys^^
Em it should be a railroad where the player can be transported and there should be two direction the arriving and the leaving railroad so. Thats why I need the minecart to take the opposite direction sometimes
hm I guess you'll have to forget that idea 😦
also just checked paper's docs and there's nothing helpful in there either
i mean you can keep track of the "front" of the minecart and ensure its velocity is in the right direction
but it would be pretty hard
how would you differentiate between a minecart slowing down by itself or it slowing down because a player pressed W though?
well probably the slowing down delta-v for pressing W is always a fixed rate
but then again the cart could be going upstairs, downstairs, or have a changed maxspeed, etc etc
btw why do I keep hearing stuff about 1.18.2
are they actually going to release 1.18.2 before 1.19?
I think I found a simpler solution, we can just execute a command to give the player a spawner? 😂
is there a command for that?
hm maybe you can use a BlockStateMeta
according to this you can do it
yeah I think I am stupid
you can probably just get create an itemstack of CreatureSpawner
cast it's meta to BlockStateMeta
cast the BlockState to CreatureSpawner
then change it easily
I'll see if it works
please let me know if it does
that was my idea too
somehow it still only uses pig spawners
seems like you always manually have to set the type when placing a spawner
yeah I got it working but as said it requires a listener on blockpalceevent
@EventHandler
public void onSomething(PlayerInteractAtEntityEvent event) {
ItemStack spawnerStack = new ItemStack(SPAWNER);
BlockStateMeta meta = (BlockStateMeta) spawnerStack.getItemMeta();
CreatureSpawner spawner = (CreatureSpawner) meta.getBlockState();
spawner.setSpawnedType(event.getRightClicked().getType());
meta.setBlockState(spawner);
spawnerStack.setItemMeta(meta);
event.getPlayer().getInventory().addItem(spawnerStack);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlace(BlockPlaceEvent event) {
if(event.getItemInHand().getType() != SPAWNER) return;
EntityType type = ((CreatureSpawner) ((BlockStateMeta)event.getItemInHand().getItemMeta()).getBlockState()).getSpawnedType();
Bukkit.getScheduler().runTaskLater(this, () -> {
((CreatureSpawner) event.getBlockPlaced().getState()).setSpawnedType(type);
},1);
}
@golden kelp
best village ever
Sorry What? Village? Did you mean Population to 10 billion?
did you see the code I've sent?
the second listener "onPlace" makes your custom spawners actually work
by default you CAN give yourself spawners with a custom entitytype, but when placing those, it'll still be a pig spawner
that's what the onPlace listener is for
into the world?
- set some block to Material.CHEST
- get the BlockState of that blocK
- cast it to Container, or Chest
- use getInventory() on that one
you can just cast the blockstate to container
Aight
@EventHandler
public void onChest(PlayerInteractEvent event) {
if(event.getAction() != Action.LEFT_CLICK_BLOCK) return;
if(event.getHand() != EquipmentSlot.HAND) return;
Block block = event.getClickedBlock();
block.setType(TRAPPED_CHEST);
Container container = (Container) block.getState();
container.getInventory().addItem(new ItemStack(DIAMOND));
}
Thanks for spoon feeding twice in a row 😂
i'm bored lol
feel free to post it lol
So 8 players can join a game and its a 9x9 square in the ground with stairs on each side & all of the players are teleported into a stair each (giving a chair like look) & theres a item frame in the middle which rotates and selects a random player, which has to do something (that something is decided by the player infront of the player who got selected)
I suck at explaining 😅
sounds a bit like truth or dare or "spin the bottle" lol
Hello guys how Can you change the error message that appears when a server is not working in minecraft?
When its offline?
Yes
when it's offline, it's offline
there must be some server running to send a motd / other message
you could just put your server behind a proxy like bungee, waterfall or velocity
then use that to send a message
but ofc that requires the proxy to be running
Does Player#damage() bypass the resistance potion effect and armor resistance? or do they factor in those...?
it's a proxy listening to ServerPingEvent
Okay
it should deal exactly the amount of damage you've specified
you can use LivingEntity.damage(entity) to make one entity damage anotherone while also calculating potions effects etc
so does it take away from the heart directly? or does it factor in the resistance of potion effects + your armor
if you do player.damage(10) they will always lose 5 hearts
oh i see what you mean
you'll want to use sth like this
LivingEntity#attack()?
yeah
tysm
but yeah that only works if you have another entity that should deal the damage
what do you mean
e.g. you can't use it for fall damage
because then you only have the victim entity but no attacker entity
another entity should deal the damage
okay then use entity1.attack(entity2)
oh
wait does it force entity1 to attack entity2?
like they'll swing their sword
no
i'm confused
it only calculates the dmage that would have been dealt if it would actually use their sword
and then deal that damage
ahhhhhhhhhh
but you can also just call entity1.swingMainHand
np
gonna try that out
another question, is there a way to make the damage be customized?
since Player#damage, you can modify how much damage it does
i'm not sure about .attack()
I don't think so. You could listen to EntityDamageByEntityEvent and customize it there, maybe
oh. alright. Thanks
You need either 3 or 5 values (excluding world). See https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Location.html
declaration: package: org.bukkit, class: Location
World is not an object
You did that right the first time
Then you need to add pitch and yaw
How to give the player a random lingering arrow
Use your F3 screen to find them
Second constructor
As an item? If so create an ItemStack from Material.TIPPED_ARROW. Then cast it's item meta and add your potion effect. Don't forget to save the ItemMeta back again
ok ty
what don't you understand?
I dont see a method to specify the potion effect in ItemMeta
PotionMeta
PotionMeta potionMeta = (PotionMeta) yourPotionItemStack.getItemMeta()
Guys I have a problem, I added a team with a prefix and it works but it doesn’t show up in the tab list
Any idea?
Oh I forgot to specify that it should be cast to potion meta
You add two commas and in the first you specify the yaw and in the second the pitch
To find out north you could to to mc, open F3 and look to north, then copy the two values that change when you move your head and you are good to go
Are u on a world record for spoon feeding 😂, Noobie me wouldve asked u everytime
When i have to cache some data in my plugin when the server starts, should i do that onEnable or onLoad?
Not sure if that even is spoonfeeding
its a few seconds of research, he just helped him
How would I implement a cron-style scheduler into a plugin that runs a task asynchronously?
Would something like cron4j work fine?
oh actually he helped you, anyways
OnEnable
In your main class
Ok
Should work fine. If you want to do something with game objects then you can just start a bukkit task when the cron job runs.
Oh my god it just clicked that 4j is for java
What do you think is the benefit of using onEnable over onLoad?
lul. log4j, discord4j... XD
Im not quite sure what that means. When does the effect occur? Honestly never heard of a shake effect...
Doesn’t they do the same thing?
Do you mean the knockback?
@lost matrix nah ur screen shakes when u get damaged
Ah i see. That is client side. There might be a workaround with just reducing the health instead of damaging the player.
yes which is what i said
or maybe there is a packet sent to the client when damaging, cant u just stop it from sending
They do nothing on their own. They are called at very different times in the loading process
Do you mean programmatically?
Have you tried just cancelling the damage event if the cause is FALL_DAMAGE?
You could cancel the event and subtract the desired amount of damage from the player’s health
How to give the player a random enchanted book
Generate a random enchanted book -> add it to the players inventory
How to generate a random enchanted book then
ENCHANTMENT enum
with a Random
ThreadLocalRandom, get an int between 0 and ENCHANTEMENT Enum size
By writing code that choses N random enchantments with H levels each
Where do u specify the ENCHANTMENT enum to the item stack?
then u cant do what u want
its client side not smth u control
make a mod
if u want that
This does cancel every single type of damage a player could get
thats if its not possible with packets
Add an if statement checking if the damage type is fall
Ok so that’s right sorry
public static ItemStack addEnchantment(ItemStack item, Enchantment enchant, int level, boolean ignoreRestriction){
ItemMeta itemMeta = item.getItemMeta();
itemMeta.addEnchant(enchant, level, ignoreRestriction);
item.setItemMeta(itemMeta);
return item;
}``` @golden kelp if ur lazy
Hell yea I am
oop i edited it, check again
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
i didnt ask for it, neither am I a noobie
No idea of context, all I saw was you giving someone code in what it seemed like that would solve their issue, which is generally defined as spoonfeeding
he did it for every damage cause, by not checking for it and it still didnt do what he wanted (removing the shake effect)
he couldve gotten it in a few minutes if he had absolutely garbage internet costing 0.5$ a month, it would've not mattered, and he is not a newbie as he said
and imo it isnt spoonfeeding, he just used the time he could spend in google in discord
alright, I really dont care to argue about something this stupid ¯_(ツ)_/¯
Look at his code
he will ask you how to get "Entity" when he asks that it doesnt work then u tell him that its just a class name and u have to invoke the method from the event to get the entity after saying that instaceof doesnt work too (thats if he doesnt get autocomplete suggestions by intellIj tho)
prob gotta fix it before that happens
what did I say
literally predicted it :o
What to use instead of ItemStack#setDurability as its deprecated
Damageable
^
cast the item meta to that
though I kinda hate how it works, cause there's also entity damageable interface, and it's just meh..
ItemStack crossBow = new ItemStack(Material.CROSSBOW, 1);
Damageable damageable = (Damageable) crossBow.getItemMeta();
damageable.setDamage(1);
Btw will this set the damage to zero (meaning TOTAL DURABILITY - 1) or Set the durability to 1
Material.isInteractable()
Oops, accidentally deleted the message.
Posting original message for posterity.
Does anybody know of a way to detect if an interactable block was right-clicked?
Or if there's an easier way to detect if an item was equipped when right-clicking, i.e. not consumed by e.g. right-clicking a door/chest or similar.
Thank you, will try 👍
Np
was wondering why so many messages were being deleted lol
Fish!!!
Byodiful, works great.
That’s me!!

How are you doing?
Short question: does somebody know a good tutorial for making a texture pack in 1.16.5 with models and textures for items which depend on the items or blocks name? For example you rename a gold ingot to "coin" and it has a coin texture.
I am good, not coding much rn tho, hbu?
I’m doing pretty good, I’ve actually had more time to code lately
How come you want to use the name instead of custom model data?
Nice still doing Java?
That's the only way I know of so far
Yeah
I’m trying to start some web development, can’t design for my life though
What version of Minecraft?
1.16.5
You can use custom model data then, I’ll see if I can try to find a tutorial
Spring
Oh backend, still pog
Yeah no front end framework lol
thank you
Just plain css/js for now
Ah fair
Np
If you like Java, then angular might suit you in frontend
I want to be able to be good at plain css first
I’ll take a look
Thank you

My websites always look terrible though lol
Did you do a Udemy course or something?
no the courses I "took" was just reading some conventions on insta
Lol
yeah
so how then does that work with spigot plugins? How can you create this items then to put them in an inventory or give it to a player?
Create an itemstack. Set the custom model data. give the itemstack to a player. pretty basic stuff.
yeah but im not sure how to set the custom model data
with the method setCustomModelData(int)
How can I check if a player is in a block? (for example to check whether a block can be placed there)
You can get the BoundingBox of that Block and then call World#getNearbyEntities with the created BoundingBox to get all Entities currently intersecting this box in any way
honestly, I was more interested in checking a specific entity but I will try thanks
public boolean hasEntitiesInside(Block block) {
BoundingBox box = BoundingBox.of(block);
World world = block.getWorld();
return !world.getNearbyEntities(box).isEmpty();
}
A bit like this
thanks I wouldn't expect something like this to exist 😅
I believe Block#getBoundingBox() exists too
In lieu of BoundingBox#of()
They accomplish the same thing, but yeah
isn't Block.getBoundingBox() for the "exact" hitbox (e.g. for a fence it's 0.5x0.5x1.5) while BoundingBox.of(Block) is always 1x1x1?
No
This isn't exact as some blocks Stairs contain many bounding boxes to establish their complete form. Also, the box may not be exactly the same as the collision shape (such as cactus, which is 16/16 of a block with 15/16 collisional bounds).
well okay but it's still different from BoundingBox.of, which always rerturns 1x1x1
Pretty sure Alex is right though isn't he? That would return a different bounding box for a fence to approximately get it's actual shape.
I am right that block.getBoundingBox returns "roughly" the block's hitbox and that BoundingBox.of is always 1x1x1
but it's not the "exact" hitbox
yes
Hi! I added https://wiki.citizensnpcs.co/API repository and dependency to my pom.xml but when i try to access CitizensAPI it returns null
Citizens has an extensive API that can be used for making your plugins work with NPCs or even for adding a brand new character that can be attached to an NPC. Make sure you always are using an up-to-date build of the CitizensAPI to ensure that your plugin works with the latest release of Citizens.
did you add citizens as depend to plugin.yml ?
Dont shade it
i don't know if i done everything right
i'm using maven
yes
did you add <scope>provided</scope> to the dependency section?
Good. Dont shade it.
wdym
<scope>provided</scope>
All good your scope is fine
which you already have
are you sure that CitizensAPI is null? Because since it's a class, I doubt it can be null at all
what exactly returns null?
what's the error?
did you click the maven reload button?
sorry i never used maven and this stuff, where can i find it?
wait!
i found it
now it works
ty
np
not everyone remembers all those fancy shortcuts 😛
(especially if they didn't know a reload button even exists)
hm ctrl+shit+o doesn't do anything for me anyway
weird
is it in the default keymap? because all I did was assign "run maven build" to alt+shift+p
in idea, ctrl+alt+o is optimize imports
so we finally found out why idea is better than eclipse - it makes your shift key live longer
public String format(CommandSender sender, MessageValueMap values) {
String returnType = format(CommandSenderType.valueOf(sender), values);
System.out.println("returnType " + returnType);
return returnType;
}
public String format(CommandSenderType senderType, MessageValueMap values) {
System.out.println(rawMessage);
if (nullMessage)
return null;
StrSubstitutor strSubstitutor = new StrSubstitutor(values.getMessageValues(senderType), "%(", ")");
System.out.println(strSubstitutor);
String format = strSubstitutor.replace(rawMessage);
System.out.println(format);
if (senderType != CommandSenderType.PLAYER)
format = ChatColor.stripColor(format);
return format;
}
In the first method I print the return value of the second method. The print statements in the second method are not called?
System.out.println(rawMessage); isn't being printed?
No
CommandSenderType is an enum right? Because that valueOf() call is odd if it is.
Yes
I'd imagine that's where your problem is.
Looking to freeze a player without canceling move event for efficiency. Is there a way to attach a player to an invisible armorstand?
pretty sure you could just set his movespeed to 0
cancelling the event doesn't affect the performance at all
people associate "playermoveevent" with laggy because some plugins do weird shit in it
doing simple stuff like cancelling it is like nothing for the server
and they are right to do so. you must be carefull when working with this event
what if I want to calculate the sqrt of a random number 10000 times when the player moves 
yeah but doing stuff like ```java
if(fronzenPlayers.contains(event.getPlayer()) event.setCancelled(true);
isn't anything one should worry about
no indeed that should be fine
I assumed it would considering if the player can be trying to move and it would be canceling 20 times a second, now add another frozen player, and so on
yeah but just imagine what happens every tick anyway for every player
every player that moves causes collision checks, entity AI to do some things, etc etc etc
The event is being fired regardless if you're listening to it or not.
on every single tick
Ok
I doubt that stuff like that will even appear in the timings
Probably not
then you're too drunk to notice any lag anyway :3
Eh I will still refrain from doing checks on player move event if I can help it
alternatively set the movement speed to 0 and teleport them back to their original location every other second
Most of the time there is another way such as that
but tbh I guess that cancelling the move event will be better for TPS than allowing players to move
Honestly yeah
if the server doesn't calculate anything further regarding the player's movement ^
True
performance boost: stop everyone from moving every so often.
What does it look like to the client when you cancel the movement event
With 100 players being frozen, all spam moving, you would have 100 hash table checks per tick.
Lets assume the hashCode impl of player is really bad and it takes 5us for one check.
Then this would result in 500us or .5ms which is about 1% of your tick. Thats your worst case scenario.
something like this would be funny
@EventHandler
public void onCancellable(Cancellable cancelleble) {
if(randomInt <= 10) cancellable.setCancelled(true);
getLogger().info("Reduced lag by 10%!");
}
Alright get this though
100 players being frozen seems like a lot too, if you needed everyone frozen you wouldn't even need the hash table at all.
I did this to fk with a friend in the move event. Quite rarely. He was complaining that he had lags but only when he was connected on my dev server.
aren't their also collections that just do == ?
lol now make him pay to "get it fixed"
I have 100 factions with 4 claims each making 400 claims and the claims are in a list inside the faction. How much would performance get hit if I checked for being inside the bounding box of every single claim and continuing when one is found, notifying the player they have entered a claim
On movement event
just imagine you have 100 worldguard regions and 100 players
that must somehow result in up to 10k checks per tick
and not even that causes lag
Thats what worldguard did in the beginning.
what does it do now?
Yeah I feel like worldguard is more efficiently coded than my plugin
State of the art now is using chunks as buckets
I really wonder if that's better
checking for locations is basically just if x > x2, && x < x3, ...
It is far better. Because now you only need to check all regions that are intersecting a chunk.
And when will you have more than 5 regions in a single chunk?
I‘ve seen servers doing strange things
Treefarm = 1 large region
Every spot where a sapling is supposed to be planted = another region
Thanks for the debate, helps me understand haha
so i have the need to make an item have a texture unless it already has one, is there a way i can merge a resource pack into an existing one (if it exists, otherwise just send it) when the client joins
Still a big diff if you check all 1000 boxes or only the 10 boxes in your chunk
yeah sure
I just wanted to say some people are weird enough to have more than 10 regions per chunk
that's why you use quad trees
what I still don't understand is...
the city's admin would have to manually add persons to all the regions
I wonder if they had some kind of client mod to run /rg addmember 1 thousand times
I would just create a folder and let the client put his resourcepack(s) in there. Then you merge your stuff in there and create a new one that you then have to provide.
merging that can get complicated though
e.g. if you have two minecraft/sounds.json files
isn't there some library to merge resource packs?
like:
I have a texture for X item with X model data, i am only going to merge if there isn't one that matches the previous requirements
such as stick with model data of 1 will be merged in the resource pack of the server unless:
the server does not have a resourcepack, in which it will just send it
the resourcepack already has a stick with model data of 1
Resourcepacks are a hustle to work with. I have a 1k lines class that builds a resourcepack when the server starts. Cant imagine how tricky merging would be.
got two screens to code on lol
merging would require extracting the files from within the resourcepack, and comparing the json values for the model data and item
more like i got a pc and a tv
Is there a way to display an actionbar instead of title? I can't find anything in the docs.
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, "hello world")
yep
What do you mean by "instead"?
You can use the Player.Spigot class to send any type of message including the action bar
you need a runnable tho to keep it sending
?
if you just call that method, it will maybe stay there for one tick
wish you could specify time with actionbars :(
thats why
mojang pls
just runnable
well the /title actionbar does have time
lol
sounds like a fast way to break your world
people really makin skripts like that
7smile if i would have to send an actionbar for a specific amount of time, would i need to have to runnables, an inner repeating one to keep the runnable sending and a timer to cancel both of them after the specific amount of time?
hmmmm
net.md_5 import i guess
One runnable should be enough.
knowing the fact that if you call the method to display an actionbar, the actionbar only stays for ~ a second
so you'd need to repeat it
I would even use one runnable and never stop it.
and if you want to stop it after some time?
set a bool to false and display nothing as actionbar
idk
but what version do I need for this because the import is not there
or do I need to decompile
like i would do it liek this
int task = Bukkit.getScheduler.runTaskTimer(plugin, () -> {
player.spigot().sendMessage( // ... actionbar stuff
}, 1L, 5L); // repeat it to prevent the actionbar stops sending
Bukkit.getScheduler().runTaskLater(plugin, () -> {
Bukkit.getScheduler().cancelTask(taskId);
}, 20 * 5); // after 5 secs cancel the sending```
public class ActionBarRunnable implements Runnable {
private final Map<Player, BaseComponent[]> activeBars = new HashMap<>();
public void setActiveBar(final Player player, final String message) {
this.activeBars.put(player, TextComponent.fromLegacyText(message));
}
public void removeMessage(final Player player) {
this.activeBars.remove(player);
}
@Override
public void run() {
this.activeBars.forEach(this::sendBar);
}
private void sendBar(final Player player, final BaseComponent[] message) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, message);
}
}
Then start this runnable in your onEnable.
If you want to send someone an actionbar -> add him
is there any side effect of using runTaskAsynchronously?
no :/
What do you mean by side effect? Do you mean if its a pure function?
I have a problem where I am using Discord4J in my Minecraft Spigot Plugin, but when the D4J bot loads, the rest of the server stops loading.
like is it safe to use?
is it use more resource or something?
Start D4J in its own thread. You dont want to block the server thread with your stuff.
Its safe to use if you know what to do and what not to do.
It does not consume more resources than starting a sync task.
But from your questions i can read that you should not use that method because
async does not mean something is better or faster.
What do you want to do async?
I am using a api which search head from a database. but it freeze the server on task. so I use async then. so I just asked about it😶
Thats a good example of when to use an async task. Was expecting the usual "wanna place blocks fast weeeee"
Yeah, operations which to some extent are dependent on external services such as IO as it has to talk to the disk, and namely database requests.
are you ever talking to a disk?
by accident
just edit the bytes in the region files kekw /s
okay thank you both
my game almost crahgses lol
hey so i am trying to deserialize a json file with jackson, and the json file has three arraylists in it, i want to deserialize them each seperatley, how would i do this?
hey anyone willing to help me?
yea
error?
Why Jackson?
Why separately?
Yes let me show you
gson can't deserialize itemstacks
Yes it can
ive given up on type adaptors since none of them work with arraylists the way i need them too
anyway
because if i don't i get the exception cannot deserialize instance of
show me the exception
ok?
now figure out why that is
that is the items in the menu, which works fine, only focus on the top line, sorry for not saying this before
the top line is the menu itself
i am not really good at jackson
but ill throw a wild guess: Menu does not have a constructor that takes an array