#help-development
1 messages ยท Page 2114 of 1
after all it only has 500 downloads, it will probably never get updated again
well that's not exactly java, but the result of a decompiled shitty plugin lol
how exactly is it broken?
I used to use that one though
it's at least open source
yeah
so everything can be fixed easily
yeah but anyway, fixing this weird MultiWorldMoney plugin will probably take more time than rewriting it from scratch lmao
but as said, I'm sure someone would change all the messages for you for a tiny bit of $$$ lol
intellij refactoring takes 2seconds
select string -> right click -> refactor -> Change string -> its changed everywhere in the project
ofc but first of all you'd have to turn this into an intellij project
all they have is a weird .jar file
hmm
oh thought you were talking about the plugin you just sent :p
MWMoney is workign somehow
Alex I tihnk u may have solved my life issues
lemmie test it a min
how? ๐
I need some ideas for my string encryption
all strings encrypt into different youtube urls
All youtube urls link to "Never Gonna Give You Up"
no idea ๐
so yeah I need ideas for my string encryption
currently there's 4 things:
- strings having a rick roll link
- strings having the ``%%USER%%` placeholders etc
- strings having a copyright message
- strings without any additional stuff
but I need more funny things like rick roll stuff
oh and a fifth thing: a message telling people to buy the legal version at https://spigotmc.org / plugin link
What is the best way to set a certain range of blocks to air?
The way I am currently doing it keeps causing issues with the server and crashes
how many blocks? in loaded or unloaded chunks?
maybe take a look at this: https://www.spigotmc.org/threads/methods-for-changing-massive-amount-of-blocks-up-to-14m-blocks-s.395868/
Hmm, well currently its like 3x a 9x4x9 and I would say unloaded
unloaded chunks is always a problem
9x4x9 is NOTHING
that's only like 4000 blocks
it would be hard to load them because the blocks are currently in a world made fully of bedrock XD
you can use PaperLib to async load chunks
oh?
HOWEVER
if you run the plugin on spigot (instead of paper) it falls back to normal chunk loading
so async loading will only work on paper
Well I am currently developing a plugin for paper but figured since most things in paper are still spigot it would be best to ask here XD
So I guess that I already have access to paper lib
you can just shade PaperLib
it will also work on spigot
buuut on spigot it will not be async. so you can use the same code for both spigot and paper, on paper it'll load chunks async, and on spigot it'll still cause lags
I will give it a test and see
Would this be right?:
PaperLib.getChunkAtAsync(origin)
.thenAccept(c -> rooms.forEach((name,room) -> room.construct(origin)));
that looks correct
Alright, wanted to be sure lol
but
what does room#construct do?
if it intercepts with nearby chunks, obviously you wanna load them too
otherwise you only load the original chunk async, then you're fucked if your construct method interacts with unloaded chunks directly
Hmm, alright. Well the room#construct just makes the 9x9 rooms currently. I am curious though, what would be the best way to load the nearby chunks if they are needed?
I plan to use the nbt files to generate the structures in the future, the for loops way I am doing it now is just for testing
are sign packets broken in 1.18.2?
Swear I updated and sendSignChange no longer works
ill do some more testing but im so confused
Hello, I am having issues with my code. The goal is to give the player a potion effect when they equip a specific Player Skull. The code below works fine in creative but when switching to survival mode, it is unreliable.
Can anyone help fix this code?
public static void onInventoryClickEvent(InventoryClickEvent event) {
HumanEntity player = event.getWhoClicked();
ItemStack item = event.getCursor();
Bukkit.getServer().getConsoleSender().sendMessage(String.valueOf(event.getSlotType()));
Bukkit.getServer().getConsoleSender().sendMessage(String.valueOf(event.getRawSlot()));
if (item.getItemMeta() != null) {
if (item.getType().equals(Material.PLAYER_HEAD) && ((event.getRawSlot() == 5 && event.isShiftClick() == false) || (event.isShiftClick() == true && event.getRawSlot() != 5))) { //(player.getGameMode() == GameMode.CREATIVE && event.getRawSlot() == 5 || player.getGameMode() == GameMode.SURVIVAL && event.getRawSlot() == 11))
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 999999, 2));
} else {
player.removePotionEffect(PotionEffectType.FAST_DIGGING);
}
}
}
that code looks horribly complicated. can you ?paste it pls
?paste
also erm, why are you listening to a click event if it's about equipping? there's a ton of ways to equip armor
the clickevent isn't enough to listen to
I have a library that adds an ArmorEquipEvent, you might wanna look into using that instead
Welp, I found out what the cause of my crazy lag was.
I was using Location#add instead of Location#clone#add so it just kept increasing the values.
oh yeah, locations are mutable
Yeah, it was luckily just something simple.
However my numbers are slightly off, they are generating the rooms at least so thats what matters
that's horrible. first of all:
- You're checking the raw slot. The raw slot however is a different slot, depending on what inventory the player has open
- Why are you checking shift click at all?
- Why are you removing the effect if the first if isn't true? that basically removes the effect everytime the player clicks into their inventory
You should definitely use the ArmorEquipEvent instead @fierce hawk
^
right now, player's lose the potion effect e.g. when they craft something, because in the else block, you remove the potion effect
I doubt that's what you wanna achieve
A1 naming
who what where why and when
this
๐ static events what the hell
why
what
that is the most horrific thing I've seen in a while
i need a bigger screen
I have a pretty decent sized screen 1366x768 or something like that
mines just a 32 inch
why do you need bigger than that
why the fuck do I always get ghost pings from this server
cause im a little blind so if i wanna see methods on my screen i have to zoom in
but when i zoom in i cant see the full line of code and end up scrolling for days
Is there a more efficient way to add a value to a Location without using #clone
if you worry about performance when doing simple vector math, you should rething your whole concept
is there a specific reason why you're worrying about this?
Well, its not about the performance.
its just about me having quite a few clones hanging around
its just about me having quite a few clones hanging around
?
for(int y = 0; y < 4; y++) {
if(y > 0 && y < 3)
loc.clone().add(0,y,0).getBlock().setType(Material.GOLD_BLOCK);
else
loc.clone().add(0,y,0).getBlock().setType(Material.IRON_BLOCK);
if (facing == BlockFace.WEST || facing == BlockFace.EAST) {
loc.clone().add(0,y,-1).getBlock().setType(Material.IRON_BLOCK);
loc.clone().add(0,y,1).getBlock().setType(Material.IRON_BLOCK);
} else {
loc.clone().add(-1,y,0).getBlock().setType(Material.IRON_BLOCK);
loc.clone().add(1,y,0).getBlock().setType(Material.IRON_BLOCK);
}
}
Just feels a bit clustered
yeah tbh that does look disgusting
I mean, its only for testing but still
you could press enter at the end of some of those lines and add some more curly braces
but performance-wise, there is no problem at all
welp, guess I will live with it for now.
After I get a bit of the other code working I will be working on loading the schematics
I wonder what this is supposed to do in the first place
ah u can also addcomments to make it more pretty
maek them constructive though like this thing does sthing
Why are you doing this
You can do Block#getRelative(int, int, int) if you want to make it more compact
But you shouldn't be needing this kind of repetitive code anyways
Well, I am going to swap over to using that.
I am used to having the ability to add two values together without needing to clone it, so that will work perfectly
Well this bit of code is just to clear out some space while I do some testing
That specific line creates the 'door' i am working on
Is it an animation via blocks or something
No, just static blocks
So you're creating a static structure
And you want to build it at a relative location
And you're doing this with manual calls to setType using relative coordinates
For now yes.
Until I get this bit of code working and add the schematics
Do you want my solution
Sure ๐
I've got a library that does this sort of thing, among many others
You can scan in a structure and then it's pretty trivial to build it programmatically
Rotated, relative to a certain location, mirrored, whatever you need
But isnt there already a way to use minecraft structure nbts to spawn in structures?
Think so, haven't dabbled with that part of the api
Since I just use my own
If you're aware of a better way to do it why are you doing it by hand to begin with?
Well, I haven't done it either.
I saw it was a thing when poking around a bit, but I was already working on one thing and wanted to finish it before starting another
Any idea how to serialize entity nbt and then load it back from it's nbt?
I'm good by knowing how bukkit does it so I can figure out how to do it on my own
Hello everyone, I come to ask for your help because I am stuck. I need to use NMS for my server under 1.17.1. I work with intellij idea. I have run Buildtools to get the 1.17.1 version as well as the remapped version. When I ask intellij idea to run the compilation of my plugin, it tells me this : Unresolved dependency: 'org.spigotmc
jar:1.17.1-R0.1-SNAPSHOT' (I modified the name of the files before to see if it came from that but no) I used the remapped mojang classifier but nothing to do. Help me please ๐ฆ
Can someone pls explain simply what is TileState and what is the difference between BlockState, i read the docs for 60 times but as for english is my not native language, im getting stucked. Someone pls explain shortly like explaining it to a dumb.
Intellij often gets messy with some dependencies, try going to file > invalidate caches... and see if that solves the problem
TileStates are tickable, some things needs to tick in order to work, furnaces, beehives, etc.
What is the difference between blockstate
BlockState holds some of the Block data, a TileState represents when the Block is loaded and ticking
I will check that, thank you so much for your answer
So if i need to make PersistentDataContainer of a normal block i need to use BlockState?
No, because those PersistentDataContainer methods are not in the BlockState. The only objects that support this are TileEntities as far as I'm aware, hence why the PDC API is only implemented on the TileEntity.
I think i got it well
Ty
I still need help with this :P
Hmm, do the data still storing at block when im placing it
ItemStack item = new ItemStack(Material.QUARTZ_BLOCK);
ItemMeta meta = item.getItemMeta();
PersistentDataContainer container = meta.getPersistentDataContainer();
NameapacedKey key = new NamespacedKey(Main.getPlugin(), "itemdata");
container.set(key, PersistentDataType.DOUBLE, 12.1);
I mean if i place this (Block) item, the data still stays on placed block?
No
It wont
if you mean give the item to a player and then be placed by him, then don't
Hmm how can i store something to the custom item i placed
Hmm so event.getIteminHand can handle my custom item
I know, but I would like some help if somebody has knowledge about code this deep or whatever
I think I found it tho
NMS's Entity.load method apparently, I'm not sure
oh, I thought you were talking to him
so, may I know what strategy did you use?
I don't know, I don't plan to use Bukkit's API
No, they are individually filled in one of the Entity methods
Anyone know what version within the world edit api contains the CuboidClipboard class?
Nevermind i just figured it out lets goooo
Bukkit.getWorld(string name) doesn't work for me when I upload a new world to the server, so I plan on getting the world through the file directory of the server, my question is if I have an instance of a file can I convert/cast it to a world?
Hello, i performed on spigot 1.17.1 and I have a question.. I have this code ;
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer world = ((CraftWorld) Bukkit.getWorld(p.getWorld().getName())).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "");
EntityPlayer npc = new EntityPlayer(server, world, gameProfile, new PlayerInteractManager(world));
npc.setLocation(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), p.getLocation().getYaw(), p.getLocation().getPitch());
}```
At the entityPlayer, they return the (world) as underlined, can anyone help me ?
that methods only gets already loaded worlds
use the WorldCreator.create to load an unloaded world
and they say, required : entityPlayer and Provided : WorldServer
they changed nms a lot in 1.17
previous methods don't work
besides, Bukkit.getWorld(world.getName())?
just use the world given by the p.getWorld()
Wouldn't that create the world if it doesn't exist?
I want to teleport the player to that world, he isn't in that world already
Do you know where can i found New methods ?
you need the nms world for this
you could search them up or look at the source code
I remember getting stuck here and there wasnt lots of tutorials
Hi!I can change that anywhere? (PowerRanks) The Language
--------------------PowerRanks---------------------
Your Balance: "---"
Click 'confirm' to purchase
"Rank"
Cost: 100000
[Confirom]
Given a world folder (of type File) can I convert it to a world?
hi, my spigot isn't remapping properly, ran buildtools with --remapped, and copied the maven thing from one of the posts md_5 made
I'm trying to build a plugin so I can fork it, but I'm getting an error when trying to run the server with it. NoClassDefFoundError specifically. I couldn't figure out why that issue appears. It originates at Line 13 of this file https://github.com/oraxen/oraxen/blob/master/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/efficiency/EfficiencyMechanicFactory.java
When it hits this, the plugin fails to enable and goes to disable. It also runs into an issue here, but this time a NullPointerException.
Line 102 in the main class https://github.com/oraxen/oraxen/blob/master/src/main/java/io/th0rgal/oraxen/OraxenPlugin.java
I've tried building a few different ways, maybe I am dumb but what I've been doing is running a gradlew build. I'm going to be contacting the main dev later today, but thought I'd ask here first.
lmao nvm I'm getting a different error now and idk why
When setting the players health using player.setHealth() , is there a way to simulate the flashing hearts effect that shows on the client normally without packets?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDamageEvent.html could be of help
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent
bump
Show your pom
and make sure you're actually using maven to build your jar
?paste
how to create a itemstack for a custom player head from a nbt tag, i searched that, but i didn't find nothing
If you're using nbt tags you need to use NMS
NMS is generally undocumented and you will have to take a look around yourself to see how things work
I do happen to know that you can use the MojangsonParser or TagParser in Mojmaps
Also is there a reason why you want to use nbt tags instead of the api?
nvm, i need to create a itemstack as a head from https://minecraft-heads.com/custom-heads
You can still use the api for this
I explained it a few days ago, let me see if I can find it
I have a database somewhere. I am writing a multi-server plugin and the plugin will store data on the database. How can I synchronize the data between the database and the local plugin cache?
what api do i need?
Spigot api ๐
The conversation starts here. You can read through it, ping me if you have any questions
ok thanks you
What was the method removing item from inventory
removeItem
is it removing all or 1
Put in the item you want to remove so 1
Hmm how can i directly remove all
clear
I believe you can clear per slot. I believe you can get the slot the players hand is on
int hand = player.getInventory().getHeldItemSlot();
player.getInventory().setItem(hand, null);
@kindred valley Does this solve your problem?
I dont know, im coding it to a notebook ๐
Ok haha just write it down
null is valid for slot?
But this code is at least accepted in my IDE
Ah alright then that works tysm
Np
so that is base64?
Yes
ty
...
It needs 2 arguments
Pls can you show me an example?
player.sendTitle("This is a awesome title", "This is a awesome subtitle")
If you only want one of them, leave the other empty ("")
No i use spigot 1.8.8 sendTitle doesn't exist
Lol
I am coding on 1.8.8... It does
Wait it does? Interessting ๐
I can't use packets
Legacy versions are a pain to work with
Pls dm the spigot
You will have to sooner or later if you're on 1.8
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Wtf
can you send me your jar where do you get the libraries from?
^ this is the only official way to get the spigot jar
But you don't really need it you can just depend on the spigot api
Like tvhee has done above, but with spigot-api instead of spigot inside of the artifact id
there is no need to change the jar ?? just change the libraries?
You shouldn't be depending directly on the jar
Use a build system like maven or gradle
BuildTools is the way
Yes
how can I do?
Thanks
Also if using IntelliJ, right click and choose "Add framework support". Lot easier
Yes i use intellij
Hey guys, I'm looking to implement a dynamic arena creation system for a minigame, which creates a new arena automatically when there are enough players in the queue. My question is, is there a more performant way than creating and loading a world and deleting it after the game is over?
is the map edited or something like that during the minigame?
if not you could theoretically just keep a single map active at all times. just not sure whether that is less performant that creating it when you need it
@maiden briar titleAPI is good?
Never used it, just try it
Okay
So all players would be on the same location?
I meant a single map inside its own world which you can just tp people to whenever its not occupied and the playercount is reached.
so instead of deleting the map when the players are done you could just keep it there and teleport the next batch of players there
But there are going to be multiple arenas with the same map at the same time
you can change the amount of maps permanently active. possibly make it depend on the overall playercount?
so if theres 50 players on the entire server just keep 2 of the maps open, if theres 100 keep 4 or something like that
Hmm that would be an idea
So whenever a player joins or leaves, check how many arenas it would need to fit all online players, and then delete or load one if necessary
basically
as I said, I don't actually know whether its more or less performant to keep the maps open compared to just making them on demand
I think defining the arena region with WorldEdit and then only loading the chunks which are actually used would also drastically increase performance
And disable spawn chunks
Why do we need a File object for custom config file
how else did you wanna make a file?
Path go brrr
Path#toFile(), right? or is there another method?
How can you create an object with a new model that does not exist in Minecraft?
I mean you could just use a Path by itself
well you still need that file so that the path works
I mean, how do you wanna access a file that does not exist
What is the difference between File and FileConfiguration
What is FileConfiguration pls explain shortly
Couldnt understand from docs
not actually sure, but its a (i think) hashmap representation of the config file? please correct me if im wrong
what physically it is
data
FileConfiguration does not inherit from File, if thats what you mean
(At least, for the duration it's allocated)
Burchard got this
File - the literal file, eg config.yml, it allows the creation/deletion of the file and opening of the file as a type of InputStream, it holds no data in itself other than that stuff, its basically just a pointer to a file on your system
FileConfiguration - Data from your File, what maow said, it is typically loaded into ram when you load the File -> File Configuration, its basically just the data content of the File
How can you create an object with a new model that does not exist in Minecraft?
Items yes
anyone knows how to stop a this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
?scheduling
oh thx !
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
if(getIntVallue(block) = 0){
Runnable.cancel();
}
}
},20,20);
so like this for instance?
Read lt.
what?
Items can have custom models
I looked at it, but with that you can include new items? I don't want to replace the ones that are already there
With that method? It is that I have only seen that it replaces the textures of the items, it does not create new ones
hi, I have this error: java.lang.NoSuchMethodError: 'buw org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack.asNMSCopy(org.bukkit.inventory.ItemStack)' No idea how it's happening, any ideas?
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskTimer(this, task -> {
if (block.getType() != POLISHED_ANDESITE_SLAB) {
setintVallue(block, 0);
task.cancel();
}else{
setintVallue(block, getintVallue(block) + 100);
}
}, 20L, 20L);
so would this work
send the code
I should probably clarify it a bit more, this is from remapping
what got remapped to that: net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item);
hello?
Is there a way to heal a player while showing the flashing heart effect without packets?
Apply potion effect?
@fringe wyvern
I am coding a plugin which stores the versions of all plugins installed on the server. How can I get the version from their plugin.yml
im pretty sure rheres like a get descriptor method or get version
on the plugin instance
it gives a NPe sometimes
yes Plugin#getDescription()
Some plugins dont specify the version ig
maybe check whether the plugin instance is null
Is it because my plugin is loaded before the plugin i am checking for?
version is standard in my pom
possibly
its best to set your plugin to load after all other plugins
How
maybe do it in onEnable and set your plugin to load on STARTUP
then all plugins will have been loaded
but not enabled yet
when you make the project I think you can set when to load it. not sure how to do it once the project has been created already
maybe do it in onEnable
i do it when the player executes a cmd
set your plugin to load on STARTUP
how
if you do it when the player executes a command there is no way rhe plugins will be null
show code
or do it inside a Bukkit.getScheduler.scheduleSyncDelayedTask
and do it like a minute after onEnable in your plugin
check if the plugin is null when getting it
if so then send the player like "unknown plugin name"
oh sorry I forgot about that, it's on https://www.spigotmc.org/threads/specialsource-not-working.555449/ , i made a thread on the spigot forums
How do I rename a file in the plugin's data folder? I know that I can user file.renameTo(File file) But this method receives a file, how do I rename an existing one?
https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/io/File.html#renameTo(java.io.File) is the method you want to use o.O ?
what is the issue what that method
What am I supposed to pass to that method?
Lets say I have a file variable named f and I want to rename it to "newName"?
Well if you have a file, lets say ```java
final File dataFolder = ....;
final File existingFile = new File(dataFolder, "f");
existingFile.renameTo(new File(dataFolder, "b"));
renames your f to b
A file object doesnโt actually represent a file on the file system (like it doesnโt need to exist)
and yeah make sure you specify the parent my bad
Oh I see, thanks for the help!
How do I save these changes? because I see that they are being done but for some reason after I rename a file the plugin still sees the old name
When I execute this : getServer().createWorld(new WorldCreator(file.getName()))
Does this create a new world with the file's name or does it load the world that is in the file?
Both
If the file exists it loads the world from the file
If it doesnโt it creates the world instead
is there a cleaner way to write this?
Why don't end portals fall under the event PortalCreateEvent?
declaration: package: org.bukkit.event.entity, class: EntityCreatePortalEvent
they are under DragonBattle
ah right
thanks but ill also try out PlayerPortalEvent
if it doesn't work ill also try ur method
'org.bukkit.event.entity.EntityCreatePortalEvent' is deprecated
oh, mb then
it's ok
but ur method actually has portal type
why the fuck would they separate the different portals lol
Constructors are how you instantiate an object. It lets you control what exactly happens when you first create an object, before doing anything else to it.
old depreciated method lets gooooo!
the server creates the instance of your plugin's main class
It's called when Spigot loads the plugin.
Hi! Can anyone please tell me an idea for a boss? Whatever theme is accepted
@surreal prawn doesn't work :(
@EventHandler
public void portalCreatEvent(PlayerPortalEvent event) {
Player player = event.getPlayer();
if (player.getWorld().getName().equals("worldName")){
player.sendMessage("Error!");
player.setVelocity(player.getLocation().getDirection().multiply(-1));
player.setNoDamageTicks(40);
event.setCancelled(true);
}
}```
How can i make it so that it waits before i send another message? instead of spamming the player
Well, the server will try to teleport the player each tick they are inside the portal
you will have to implement a cooldown yourself
what would be a good approach to a cooldown?
I mean, a plain Map<UUID, Long>
You could use System millis
?paste
i know its an exception wtf
ah right ok
messing with ya ๐
Any good github example for doing multiplatform plugins. Like a example which demostrate how to use let say a Core module and use it for Bungee and Spigot?
youre using reflections, right?
if(p.getInventory().getItemInMainHand().isSimilar(cash.getCash())) this is 115
Always send full code: if not its relly diff to help
@EventHandler
public void onClicking(PlayerInteractEvent e) {
Player p = e.getPlayer();
Cash cash = new Cash();
Block block = e.getClickedBlock();
Action action = e.getAction();
if(action == Action.LEFT_CLICK_BLOCK) {
if(p.getInventory().getItemInMainHand().isSimilar(cash.getCash())) {
if(block.getState() instanceof TileState) {
BlockState blockState = block.getState();
TileState tileState = (TileState) blockState;
PersistentDataContainer container = tileState.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(Main.getInstance(), "blocks");
int i = 1;
if(container.get(key, PersistentDataType.INTEGER).equals(i)) {
int amount =p.getInventory().getItemInMainHand().getAmount();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "money give " + p.getName() + " " + amount);
int hand = p.getInventory().getHeldItemSlot();
p.getInventory().setItem(hand, null);
}
}
}
}
}
Allright
you should check for null values for the p.getItemInMainHand and others there
not sure what this means, anyone?
As it says it can find or load that class
if it wasn't able to find that class, wouldn't it throw that error in the 4th line already?
how can i access the GameProfile?
i fixed it but now its throwing another https://paste.md-5.net/jukacogebe.cs
it cant find a class from the api?
why
youre using the spigot api, right?
yeah
you using maven? maybe reload the dependencies?
gotta guess at this point
no im not using
gradle?
no
just a plain java project?
yeah?
who hurt you
jkjk, i don't know how you could fix that, maybe check your dependencies
Using spigot-jar as maven or gradle dependency
bro how can put bow enchantment infinite arrows in spigot?
You have to create/get a item stack
actually thats from 2013 damn
It should works
just surprised at how nobody has asked that on spigot in like 9 years
maven
It's missing their class Item/Cash
thats the new error
Have you installed spigot on your local maven repo using Spigot build tools?
yes
let start from there
Allright so check your .m2/org/spigotmc
And check if you have spigot-api and spigot-jar folder
nvm
You should have it
i solved without gameprofile
thx
Your welcome
Zacken NMS which maven dependency is?
Its called as spigot-nms?
Oh ok
Because you have org.bukkit:bukkit-nms too
Block block = e.getBlockPlaced();
BlockState blockState = block.getState();
TileState tileState = (TileState) blockState;
is this a true situation?
my console sends Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState cannot be cast to class org.bukkit.block.TileState
yes i have
Doubt this
ah no
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
Player p = e.getPlayer();
Bank bank = new Bank();
if(p.getInventory().getItemInMainHand().isSimilar(bank.getBank()) && e.getBlock() instanceof TileState) {
Block block = e.getBlock();
BlockState blockState = block.getState();
TileState tileState = (TileState) blockState;
PersistentDataContainer container = tileState.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(Main.getInstance(), "blocks");
container.set(key, PersistentDataType.INTEGER, 1);
}
}
is this true rn
:/
Your casting tile state to block state and your checking if it's instance of a block Two different things
As such you get an error
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
Player p = e.getPlayer();
Bank bank = new Bank();
if(!(e.getBlock() instanceof TileState))
return;
if(p.getInventory().getItemInMainHand().isSimilar(bank.getBank())) {
Block block = e.getBlock();
BlockState blockState = block.getState();
TileState tileState = (TileState) blockState;
PersistentDataContainer container = tileState.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(Main.getInstance(), "blocks");
container.set(key, PersistentDataType.INTEGER, 1);
}
}
wow e.getBlock().
ahahha
nah somehow not working
p.getItemInHand()*
I'm pretty sure the event one is like get tool or something
neverm ijnd
i wouldnt create variables before checking whether or not to return
blocks don't hold data
tile entities do
if your block does not hold onto a tile entity
you cannot store custom data in it
i would cache namespacedkeys but is that really worth it?
a regular block like stone or grass cannot hold data, but anything that has further functionality like a furnace, beacon, etc, has custom data availability
why i have that error: Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @7ff2a664
my code is:java public static void saveBlocks() throws IOException { Gson gson = new Gson(); File file = new File(plugin.getDataFolder().getAbsolutePath() + "/blockStorage.json"); file.getParentFile().mkdir(); file.createNewFile(); Writer writer = new FileWriter(file, false); gson.toJson(blocksList, writer); writer.flush(); writer.close(); System.out.println("All blocks have saved"); }
use new File(plugin.getDataFolder(), "blockstorage.json") instead
wont solve it but ye
Also, the error is in line: gson.toJson(blocksList, writer)
And blocksList is an ArrayList
Hello i am using intellij and when i build my project as an artifact there is only the resources folder
configuration in imgs
intellij idea 2021.2.2
Where does dependency: ninja.leaping.configurate came from?
I recommend to built maven or gradle proejcts. They will do your works really better
i am using maven
Allright
So can you send a picture
Of his please but a fully picture
I want to see your project structure
Is there a way to suppress chest open and close sound also the animation?
how do i change the ObjectId in the _id of a document in MongoDB to a player's UUID
Document document = new Document().appen("_id", player.getUniqueId());
Could you solve it?
append?
You can either do:
Document#appen("field-name", value)
Document#set("field-name", value)
if i do getConfig().options().copyDefaults and then something liek config.getString("smth here") when that string isnt set, will it return the default value from within the yml file in the jar?
You should set via:
getConfig().set(key, value)
Or that what i think
You can always use my simple class for files
So you can either load files with content from yaml inside jar or empty file
well basically my problem is that rn im having an enum to save lang defaults in, and i would rather save them in the file directly because i need to initialize those values and stuff
is there an event for when a chest is opened/closed?
Wait you can do:
Enum.values().forEach()
InventoryOpenEvent and InventoryCloseEvent
Ah okay
look at the Lang#initialize method, thats what im trying to avoid
there must be a more elegant way
where that?
scroll down or do ctrl + f lol
Replace the for to:
Lang.values().foreach(entry -> yaml.set(entry, entry.getText()));
getText() replace it according to your method
- Early return
- dont call your variables one letters
- you dont need to make a seperate namespacedkey for each block placed, just one for everything
i handled all this
I can't find any methods for animations or sounds in there
im f*cking dealing with fileconfigs
i mean i get all logic of it but when phsycially the thing i want to see in config, i cant code it
you need to go into spectator mode for a short time to disable the animation
and handle the item clicks
atleast thats what i think is the easiest way
You can see the docs
Do you want to see my file handler?
I want to create a thing like this when player puts a block
Locations:
location:
x: {}
y: {}
z: {}
String text = "Locations"
Configs.fileConfig.createSection(text + ".location");
Configs.fileConfig.createSection(text + ".location.x");
Configs.fileConfig.createSection(text + ".location.y");
Configs.fileConfig.createSection(text + ".location.z");
Configs.fileConfig.save(Configs.file);
i have this
start by learning java
hey how should i calculate a 'Top Overall Player' using Kill rank, death rank, highest bow accuracy, highest mob kills, damage dealt, damage taken etc
just save the location by itself, you are making yourself do more work this way
(kdr * bow accuracy) / mob kills * (damage dealt / damage taken)
maybe
idk
bow accuracy is (hitShots / Math.max(1, totalShots)) * 100
so its a percentage atm
i just dont know how i would put them all together nicely to have a fair top player
execute console command: "/kickall"
wait 1 tick
execute console command: "/tempban * 1d maintenance, you are not banned, this is a whitelist"```
Would this work?
I'm brand new to skript, haven't done it before, ever.
and idk why you would divide by mob kills, surely that would decrease their total?
I'm thinking something like
int playerTotalStat = (kills - deaths) + hitShots + mobKills + (damageDealt - damageTaken);
@grim ice
.
Would that work?
thats skript
this is for java im fairly sure
the skript discord if they have one
doesn't skript have a discord?
Can you send me it please?
lightfury okay first of all how easy is it to get damage dealt contrary to a kill
and how easy is a mob kill contrary to a normal kill
you need to figure that out
i mean to kill a player on max health, you would gain at least 20 damage per kill
and then translate each one of them into a unanimous currency
and a mob kill is easier because they arent critting you out constatntly
but you still get damage so
like "skill points" or sth where every other unit in your system can be translated to this unit
pretty much how its done everywhere
ill try
im updating the leaderboard a lot so i may not calculate it every time, maybe just get the values and add the skill points when people kill each other. I'm thinking i could just have a leaderboard for each stat and then have a 'skill point' leaderboard.
(kills + hitShots + (mobKills / 2) + (damageDealt / damagetaken))-(deaths/10)
maybe try urs tho
or well
still the same error
(hitShots/100) + ((kills+deaths)/damageDealt)) + (damageTaken / (kills/1000))
SortPlayerlist?
Hello, I made a gun with a fireball as projectile, everything is ok with that except when the fireball hit a player, it made it in fire, how can i remove this ?
It made it in fire?
?
Any good library for managing Json and Yaml files?
I have seen Gson or Jackson what do you recommend?
YAML is pretty easy with the API. I think Gson is what most people use here.
Gson over Jackson
Yes
I know the 2 of them support json and yaml parsing
I want a library for parsing yaml and json, so them i can built my own file api
What do you think? iI accept opinions
How to calculate the Speed of a player?
I thought player.getVelocity().length(); would do, but its just the acceleration :/
So sneaking, sprinting, walking all gives the same result
I know i could make a map for every player and in moveevent use pythagoream theorem to calculate the distance since last moveevent and divide by time since last moveevent
but thats kinda suuuper complicated. Does anyone know an easier way?
How can I add a new section to the config every time?
Wdym new section? Like another node or something like a value in a list?
You could use #createSection() or just #set() the new section.
What the diff between node and section?
I always asked that question
Idk, I.refer to them as nodes but sections also work. I categorize sections as a group of nodes like in his example.
Itโs just language semantics
So nodes can either be? string, integer, byte, etc, maps?
The path to it yes.
Again, really just semantics, but I refer to them as nodes because they are similar to permission nodes.
Permission Node: myplugin.command.permission
YAML Node/Path: path.to.your.value
I guess.
can i put letters like: ลก, ฤ, ฤฃ in .yml file comments?
Allright:
- Do you think a file api would be useful?
- What data format will you add for support?
I think yes
its not creating the new one, its overwriting
did i make mistakes on load/save?
Depends on what it would do. I already know how to use the File class, so itโs not hard to get data.
If you are talking about different formats, then possibly.
Is it the same location? Because if it is, then it will be overwritten.
no
Like the path name?
Yes an all in one simple library for working with differents storage formats, like yaml, json, xml, etc
oh yes it is
That would be why
That would be useful for file based storage yea. If it was as easy as the API makes it for yaml, then it could be really useful.
Another one for relational databases would be just as nice. However Iโm not sure how easy itโd be to make.
I already am working a similar setup for my plugins, but it is a bit messy atm. Different storage solutions require certain things.
Caching is another problem Iโm trying to work around.
Allright so you agree that doing my storage api wouldnt be a lost of time
Allright so will start working on the lib
Also shadow i want some help about coding the section thing
Code: https://pastebin.com/7Gh8VdBk
With placeholder api I made a placeholder where the value is obtained from the config. The problem is that when I modify and save the programmatically config, the placeholder does not update until a total reload with /reload confirm. Version 1.16.5
Can you help me?
Hmn
Looks strange that
but, how can i provide it always to create another one with diff name
Another section?
Thatโs up to you. Idk what itโs for so I can only give general suggestions.
Similar to warp plugins, put the location in a subsection thatโs the name of the warp.
https://i.imgur.com/rbnDMXA.png
I changed my name via programming but it doesnโt update and it always stays the same until I reload. Same for all values
Wait explain carefully hat doing
ok, im trying to do if a player puts block, writing the blocks location to the data for all block i putted.
but its always overwriting
after placing
Oh ok
You should keep the blocks in memory
And then right back to file
I dont know what you are doing exactly that why
I simply made a plug-in that allows you to create a custom name, gender and age and puts them in the config (and then giving value to the placeholder). I added a command that allows you to reset the values of this player and re-entering them requires the "setup" resetting the data in the config. The problem is that the data remains old and the placeholder does not update except with a /reload confirm
Can you send your code in please ?paste
?paste
Allright paste the code there please
.
oke
and this is the part of the command which reset the name
if(args[0].equalsIgnoreCase("removePlayer") && sender.hasPermission("identity.removePlayer")) {
if(main.getConfig().isConfigurationSection("data") && main.getConfig().getConfigurationSection("data").contains(args[1])) {
main.getConfig().set("data." + args[1], null);
main.saveConfig();```
are you sure that you have that permossion?
also is it the file that isnโt updating or is it just in game
the file is surely updated
it works I tested
Doing /papi reload doesnโt change anything then idk
Hi in my kitpvp plugin i want the snowball refill when kill, im a new developer can any one help me pls?
ItemMeta SBMeta = Arrow.getItemMeta();
SBMeta.setDisplayName("ยง7Snow Ball");
SB.setItemMeta(SBMeta);
k.getInventory().setItem(0, SB); ```
i know the snowball will take the slot 1
but idk how to make it refill the snowball
i want the snowball refill when kill
whut?
I'll just do it like this lol
what is overwriting what?
everytime i put a block its not creating a new section, its just changing the x, y, z of the location
are you storing blocks in a config file?
locations
okay, show some code pls
i mean the location of block
let me explaing it bit because i made it a bit long
int y1 = (int) e.getBlock().getLocation().getY();
int y2 = (int) e.getBlock().getLocation().getY() -1;
int y3 = (int) e.getBlock().getLocation().getY() +1;
int x = (int) e.getBlock().getLocation().getX();
int x1 = x - 1;
int x2 = x - 1;
int x3 = x - 1;
int x4 = x;
int x5 = x + 1;
int x6 = x + 1;
int x7 = x + 1;
int x8 = x;
int z = (int) e.getBlock().getLocation().getZ();
int z1 = z;
int z2 = z + 1;
int z3 = z - 1;
int z4 = z - 1;
int z5 = z - 1;
int z6 = z;
int z7 = z + 1;
int z8 = z + 1;
String text = "Locations";
Configs.fileConfig.createSection(p.getUniqueId() + ".");
Configs.fileConfig.set(p.getUniqueId() + ".locations.x", x);
Configs.fileConfig.set(p.getUniqueId() + ".locations.y", y1);
Configs.fileConfig.set(p.getUniqueId() + ".locations.z", z);
Configs.fileConfig.save(Configs.file);
well your section is called "uuid."
so obviously you overwrite it every time
instead of saving a configurationsection, you should save a List<ConfigurationSection>
or just directly store a List<Location>
but i made all things integer
for casting location as Integer
Why don't you just save a List<Location>?
List<Location> locations = new ArrayList<>();
list.add(someLocation);
configFile.set("locations",locations);
agree
I need a help in bukkit schedular.. can somebody tell me how to send a msg per minute.. whats the delay time
try with ะฟัะธะฒะตัะฟัะธะฒะตั
verano, do u have any idea for this prob?
because its returning double
How would you read this yanl file and load it into cache using Jackson?
Yaml file looks
Section-1:
key-1: "value 1"
key-2: "value 2"
?paste
Quick java question, how can I pass a throwable to a different function when the catch block defines the exception as multiple types?
To me?
not
Oh ok sorry
i want link
basically instanceof
and then cast
since thats a union type
that works fine
you dont need to loop anything
if you implement ConfigurationSerializable or smth for the value type then you dont have to worry about doing it manually
declaration: package: org.bukkit.configuration.serialization, interface: ConfigurationSerializable
how can i control if player is close a specified location
wym
Is a player close to a location I have specified
okay i have a kitpvp plugin, the default kit have Axe - 16x Snowball - Bow
i want when the player kill other player refill the snowball to 16
- apply a special PDC tag to the snowball itemstack
- when a player dies, get their killer
- if the killer has the snowball itemstack, set it's amount to 16
private final double maxDistance;
boolean isInRange(Location loc, Location area) {
return loc.distance(area) <= maxDistance;
}
can anyone help me?
can you change how fast a particle changes it texture? my assumption is no
i want to store the specified locations on a yml config and try to control if is player close to the locations on yml.
what version of Gson are you using?
try to use a more recent version of gson and it should work
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
I use the version shown in github
ConfigurationSection also has "getLocation()"
hm then I have no idea
Im having trouble with my GUI. I have used InventoryClickEvent to disable dragging items in and out from the GUI and it doesn't fully work. When i try to put an item in to GUI with right click - the gui closes, but when i put an item with left click - it stays and when i close the gui manually - the item just disappears. Any ideas how to fix it? My code:
@EventHandler
public void onInventoryClick(final InventoryClickEvent event) {
final Player whoClicked = (Player) event.getWhoClicked();
final String title = event.getView().getTitle();
if (!(title.equalsIgnoreCase(whoClicked.getName() + "ลฝmogลพudลพiลณ gaudytojas"))) return;
event.setCancelled(true);
try it in survival mode
creative is weird because the inventories are mostly client sided
Tried in survival and now it allows me to use the gui as a trash can with both mouse buttons
even worse :D
But atleast it doesn't allow me to drag items out of the gui
how are you opening the inventory? I assume that you create a new one everytime?
๐ฅบ
if so, obviously it will be empty when you reopen it
unnecessary finals โน๏ธ
yea, creating new one
yeah so everything works, where's the problem?
if you create a new inventory, of course it will be empty
I mean i dont need to save the items
I need to disallow players to put something in the gui
@quaint mantle do you have anything i can read about this sh*t cause just because of this yml stuff i will leave java
have you checked if your "if" statement actually evaluates to true?
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
like - are you sure that you cancel the event?
also you must also listen to InventoryDragEvent
@EventHandler
public void onInventoryClick(final InventoryClickEvent event) {
final Player whoClicked = (Player) event.getWhoClicked();
final String title = event.getView().getTitle();
if (!(title.equalsIgnoreCase(whoClicked.getName() + "ลฝmogลพudลพiลณ gaudytojas"))) return;
event.setCancelled(true);
this is the code
really shouldnt compare titles
I know that this is your code, and as I said, the title is probably incorrect
ah
aah I don't think I understand what you mean
?pdc
your inventory is called ลฝmogลพudลพiลณ gaudytojas
right
however you check if the inventory is called "<playername> ลฝmogลพudลพiลณ gaudytojas"
declaration: package: org.bukkit.event.entity, class: PlayerDeathEvent
#getKiller()
Ooooh
Right
Im so stupid
loop through the inventory until you find the snowball pdc, (optimizable)
so it should be like this?
no, you shouldn't use titles to identify your inventory in the first place ๐
you should store your inventories in a set or map or similar
then you can check in the clickevent if yourSet.contains(inventory)
or use reference == for more safety, i think that works
some people say i should check inventories using titles ._. idk who to trust
Alright, i'll try that
== and equals() are the same for inventories
oh wait
no, CraftInventory implements equals like this:
public boolean equals(Object obj) {
return obj instanceof CraftInventory && ((CraftInventory)obj).inventory.equals(this.inventory);
}
still, it's basically the same
messy
so yeah using equals() on an inventory will never compare the contents
so it's fine to use for this stuff I guess :3
But what will happen if i will identify invetories using titles
Like, what are the security issues?
you go to hell
can confirm
well it will work if done properly, BUT
can be manipulated
for instance if another plugin allows custom GUIs
or renaming chests
is that a plugin? im finna do that
lets assume you want to give your father 100โฌ but not to anyone else. now someone comes to you who has the same name as your father, and you give him 100โฌ.
obviously that's not what you wanted. you wanted to give 100โฌ to your father and not to some person who randomly had the same name
ah, i get it
but if the server is using only like 2 plugins and they dont allow renaming chests or making custom guis
yeah as said, it will probably work fine
it's bad practice nonetheless
simply do this:
final Set<Inventory> myGuiInventories = new HashSet<>();
everytime you open a custom GUI inv, add it to that set
everytime a player closes any inv, remove that inv from the set
now you can simply check if myGuiInventories.contains(event.getInventory())
or check the holder and let your custom inventory implement InventoryHolder
no
that's not supposed to be done
idc
should probably use Map<UUID, Inventory>
although I have to admit, I also use custom inventory holders
well they don't really need the "owner" of the inv
they only want to see "is this my custom inv"
its in the api so useable by us
sure it's usable, but the api docs also say you shouldnt implement it
as said, I also abuse inventoryholders myself, but actually one should not do that
what about different owners, same inventory, resulting in the same functionality
where?
they only want to prevent people putting stuff into the GUI
oh aight
what could happen worst
?jd
api implementation change
a new method gets added to the InventoryHolder interface and your plugin breaks
The Bukkit API is designed to only be implemented by server software.
Okay i did that and it works :D Thank you :P
np ๐
so on own risk
you have to remember to remove the inventories from the set in InventoryCloseEvent
like everything in bukkit
otherwise you'll have a memory leak
ah okay
you can simply do this:
@EventHandler
public void onInvClose(InventoryCloseEvent event) {
mySet.remove(event.getInventory());
}
np
by the way, is there any way to check if player is holding the specific item and when he's not holding it - it will run command?
broken english but i hope you understand :D
if (customItem.isSimilar(player.getInventory().getItemInMainHand()) {
// run code
}
if the custom item can change, sometimes by config, you should use PDC
this bug in the Scoreboard idk why at all
int Deaths12 = StatsAPI.getDeaths(p.getName());
int Points12 = StatsAPI.getPoints(p.getName()); ```
```[22:23:55 WARN]: [FFA] Task #42 for FFA v1.5 generated an exception
java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getName()" because "this.val$p" is null
at Offender.Events.ScoreBoardListener$1.run(ScoreBoardListener.java:49) ~[?:?]```
p is null
does anyone use Aikar's Annotation Command Framework (ACF)?
I like ACF, the only problem is it's inflating my jar file by 325 kb. trying to figure out if that's expected or I'm doing something wrong
I am
oh jesus
it's a small plugin, 10kb without ACF, so it seems rediculous to add so much size just to ease the command programming
sooooo dont use it
unless you manually modify ACF its not gonna get smaller
Can you please help me?
when i import org.bukkit.plugin.java.Javaplugin it says it cannot be resolved
even i did everything in the tutorial
heres the tutorial
it's "JavaPlugin" and not Javaplugin"
i had writen it corectly
then you dont have it as a dependency
btw the tutorial is quite shitty. I would suggest that you get started with maven right now
codedred :/
https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/ this is for intellij, but it will be very similar in eclipse
you should definitely read this and use maven to handle your dependencies, instead of manually adding them
@quaint mantle
either maven or gradle, but definitely NOT like they do it in the video
ok
can i ask mongodb things here? ๐ maybe someone knows
yes
yeah
anything development related
how can i make the rayTrace ignore some blocks
like, i would like to ignore the barrier
what does Player#getItemInMainHand return if there is no item?
maybe air for sure, i will search 1sec
its annoted with @NotNull so does that mean it will never return null?
air would indeed make sense
air seems to be what's used whenever there is "nothing"
based
Would you like to try mine?
It gives multiple options
You can shade RedCommands, which is quite small - 72kb unminimized
You can shade RedLib, 400kb, which includes RedCommands
Or you can put RedLib as a plugin dependency and not shade anything at all
confirmed through testing is it indeed AIR
And it's easier than acf to use
how can i make a block not persistent, make he disappear when the server restarts
it is for a minigame
so i would like not to see the blocks after the server crashes
?
save to map
that map would need to be persistent then ๐ก
save to config
like are you following me here
i dont want a config
bro
nor a database
so stubborn for what
Yeah why do you not want to do that
If you really hate it that much you could use chunk pdc
no
:<
working on a lite plugin
gonna make it extremely feature rich
for like the simplest thing ever
chunk pdc โค๏ธ
for real, PDC is the best thing that was ever added to bukkit
can pdc modify nbt
e.g. imagine you save "asd" inside the PDC usin g namespacedkey "chestsort:keyname", the whole NBT thing will look like this:
BukkitValues: {
"chestsort:keyname": "asd"
}