#help-development
1 messages · Page 1750 of 1
Also another thing to look into is try-with-resource
You can do try (PreparedStatement statement = connection.prepareStatement()) {
…
}
It will automatically close your statement
closing the statement didn't really solve my issue
Well it was needed anyways :p as for your issue. Not really sure why it’s lagging the main thread when it’s being called asynchronously thTs weird
Accessing a database or any other IO on the main thread naturally produces lag
Yea that’s the thing tho he’s doing it asynchronously by the looks of it, unless I missed something. I’m reading his code on my phone so maybe I read it wrong but looks good to me
maybe it's happening in other places?
how can I pinpoint it
I just read the question at the beginning XD
If you want to load player specific data then your should use the AsyncPlayerPreLoginEvent. There you can just access your DB as long as you want.
does it not let the player join until the task has finished?
Do you make other DB calls or mess around with any files anywhere?
Events don’t complete until what you’re doing inside of the listener is finished
I do, hence why I needed help pinpointing the location
is there a way to do so?
Yea you can’t really pinpoint it you just gotta look at all your db calls and file usage
And see if you’re doing anything on the main thread
I think I'm (theoretically) doing it in async in every call
If I am inside a callback, am I working in the main thread?
i.e here
Database.someStuff(result -> {
Database.doSomeStuff();
});
``` where someStuff is wrapped in a .runAsync task
Yea if you’re inside the callback as long as you run the call as a sync task it will be on the main thread
so in other words doSomeStuff is on the main thread?
maybe that's why it was lagging
Yes that’s correct
in what way can I edit Map asynchronously?
via a mutex?
How about a ConcurrentHashMap?
Anyone know how to prevent an arrow from being sent to clients when fired? (to make it completely invisible)
Tried sending an entity destroy packet immediately after firing the arrow, but it still sometimes appears for a frame or so
Maybe listen to spawn entity packets and cancel it if it’s the right one
can't use player#launchProjectile to launch a bat in the player's front facing direction, what's a solution?
or more particularly, i want to launch a bat from the player's face always following the direction of their crosshair
Try this. Adjust the value in .multiply() to whatever you want their velocity to be.
Location loc = player.getEyeLocation();
Entity bat = loc.getWorld().spawnEntity(loc, EntityType.BAT);
bat.setVelocity(loc.getDirection().multiply(10));
in this case, does it creates a new instances on every loop?
Yeah, just create the itemstack before the loop
Also you could just set every slot to glass pane and then set your other items overwriting the glass
true but then i would have to fill air blocks back in
dude just please store that in a variable regardless if its in a loop or not
thats not readable lmao
uhh i only need it once
variables that i dont need..
Trying to update my old plugin to 1.17 coming up with those 2 issues. 1. RandomPositionGenerator isnt a thing anymore? 2. The operator < is undefined for the argument type(s) boolean, double any ideas? 1.16 worked fine
Its for readability, and you really should do it
hmwoa ok
if people were to look at your code, they would be disgusted from how tight it is
store it outside
Surely creating 1 array over idk 50 times is better
but whats better now when i have only one class instance? making a field static or not when it doesnt really belong to an instance?
you mean to the chat?
(only he's able to see it)
a title on the screen?
liek this?
player.sendTitle()
if you added the spigot api as an dependency
sorted :D
is that lang given a value every time an enum value gets loaded?
Is there some way to execute my /version command before the paper one?
(I know about the loadbefore, but I can't load before paper lol)
plugin commands should override the vanilla ones by default
you could use something i call shape system
String shape = "#########" +
"#xxxxxxx#"
"#########";
char[] chars = shape.toCharArray();
int currentItem = 0;
for (char c : chars) {
if (c == '#')
//put glass
if (c == 'x') {
//put the item based on the currentIndex
currentIndex++;
}
}```
if i wanted to manipulate the speed of a bat, would that be with nms or possible thru the API?
zomifiedpiglin set agrow(no idea how to spell this word)
could anyone help in thread above? ^^^^^^^^^
Be patient
okay.
FileConfiguration
Hi, Does anyone know how to get the event trigger from Player#damage ? feels like entitydamage doesn't trigger from what I tested
it should
Well it actually does trigger when I use the damage(double,entity) but not when I use damage(double)
And I am using a plugin which seems to be using the damage(double)
Which doesn't trigger properly my events
is there a built in method for getting players nbt? (preferably as a raw string or dictionary)
what does that return?
PersistentDataHolder has the method getPersistentDataContainer which returns a PersistentDataContainer instance
?jd-s
?pdc
and will this give me raw nbt?
I'm not trying to edit a players nbt
I'm trying to save it as a string
explain your goal
variables
in mcfunction
${variable name}
the idea being that I could say something along the lines of
/var <variable name> = <selector>.getNBT(<path>)
ok, the PDC is persistent. You save your data to the PDC and its on the player object until you remove it or the player data gets wiped.
We still assume you’re coding this in Java
then yes teh PDC is what you want to use
and I assume there's something in the docs about this?
we just linked you to teh docs and a tutorial
this link is different tho right?
try reading it?
also: the game stops while spigot is running something right?
like while I'm running the code of my parser, the server will freeze
if you run it on the main thread, yes
protocolib's tab completer events... i see no javadocs... how can i modify that list sent to client?
Im having issues with opening a custom inventory. I printed out the player's current open inventory and it appears to be changing, but no GUI appears..
Before openInventory(): org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView@3a2ab454
After : org.bukkit.craftbukkit.v1_17_R1.inventory.CraftContainer$1@686a2933
Heres my methods. The message "Opening Win Inventory!" does appear.
public void WinBattleGUI() {
WinInv = Bukkit.createInventory(null, 54, ChatColor.GOLD + "" + "Exp");
initWinInvItems();
}
public void initWinInvItems() {
WinInv.setItem(0, createGuiItem(Material.PURPLE_CONCRETE, ChatColor.DARK_PURPLE + "" + "Test"));
}
public void openWinInventory(final HumanEntity e) {
WinBattleGUI();
e.sendMessage("Opening Win Inventory!");
Bukkit.getServer().broadcastMessage("1: " + e.getOpenInventory().toString());
e.openInventory(WinInv);
Bukkit.getServer().broadcastMessage("2: " + e.getOpenInventory().toString());
}
At what point are you trying to open this inventory? in an event?
After a battle finishes. I have a method "finishBattle" that invokes openWinInventory(player)
are these triggered through an event?
Yes, the battle starts on an NPCInteract event
Your debug says you already had a view open when you opened your Inventory
I run player.closeInventory and print it out. The same
org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryView@3a2ab454
``` is printed
Is there another way to force close and possible guis?
are you doing any of this from an InventoryClickEvent?
Yes
Hmm okay. I'll take a look. Am I missing something specific?
https://paste.md-5.net/kifimimufe.rb i just did ```java
@Override
public void onPacketSending(PacketEvent event) {
if (event.getPacketType() == PacketType.Play.Server.TAB_COMPLETE) {
PacketContainer container = event.getPacket();
String[] completions = container.getStringArrays().read(0);
}
}```
PigZombie.setAngry() has 2 inputs a boolean and arg0. what would go in the arg0 space if the boolean is true?
?jd-s check the docs
I've glanced through, specifically at InventoryClickEvent and am not seeing something obvious...
I was looking here, is this the wrong spot? https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/PigZombie.html#setAngry(boolean)
declaration: package: org.bukkit.entity, interface: PigZombie
Because InventoryClickEvent occurs within a modification of the Inventory, not all Inventory related methods are safe to use.
The following should never be invoked by an EventHandler for InventoryClickEvent using the HumanEntity or InventoryView associated with this event:
HumanEntity.closeInventory()
HumanEntity.openInventory(Inventory)
HumanEntity.openWorkbench(Location, boolean)
HumanEntity.openEnchanting(Location, boolean)
InventoryView.close()
To invoke one of these methods, schedule a task using BukkitScheduler.runTask(Plugin, Runnable), which will run the task on the next tick. Also be aware that this is not an exhaustive list, and other methods could potentially create issues as well. ```
Do you use paper or spigot?
paper, i think
But im using the interface Player not HumanEntity, is this still an issue?
Check their docs then
yes
do you mean for server software?
What other object could I use? If I can't use Player or HumanEntity
Player is a sub interface of HumanEntity
why r u ignoring me
You do as teh javadoc says and use a runnable
read teh javadoc, it tells you to use teh scheduler to run a task 1 tick later
i think im using the spigot api, but paper server software
?scheduling
Hmm okay. So I should make a runnable that is invoked to close the player's inventory after 1 tick?
no, to open your new one
Hmm. I have a battle GUI that opens fine first, but then opening the WinInventory doesn't work. Why would it work on its first interion?
because you are not opening yoru battle inventory through the InventoryClickEvent
I'm not directly using the InventoryClickEvent to open the inventory. Will the runnable still fix my issue?
You are calling the open method from the InventoryClickEvent
Not directly, but eventually
it all branches FROM the event. Its an event based system
you are still IN the code path of the event when you call open
?paste
Ahh gotcha, thank you for sticking with me!
Look right?
public void openWinInventoryLater(HumanEntity e) {
new BukkitRunnable() {
@Override
public void run() {
e.openInventory(WinInv);
}
}.runTaskLater(main, 1);
}
try it and see, it won't break anything
Could anyone help me in my thread? About setting zombified piglin agro.
hello. im trying to do a simple registry system for an ArgsReader, but when i try to add a new reader to it intellij warns me about deadlock (see print). i dont like to see warnings so i would like to remove that
ArgsReader: https://paste.md-5.net/xexacoqiru.java
ArgsReaderRegistry: https://paste.md-5.net/retodakehi.java
StringReader: https://paste.md-5.net/qehayoruci.java
Yeah thats probably not going to work
You are trying to create an instance of StringReader, which is a sub class of the class you are in., which has not yet finished being intitialized
your abstract class does not actually exist yet when you try to sub class it in StringReader
separate it from your registry
Also y static 😐
Your registry should be autonomous and not depend upon anything
Zombiefied Piglin automatically attack players off spawn
Hey !
I actually create an inventory like a backpack of 27 slots and i put 9 differents item in the first line, 9 red stained glass in the second, and the third is empty.
What event i have to use to see when a player put one item in one slot of this backpack ?
thanks in advance
inventoru click
this works if one player just shift+click on item ? 🤔
yes but it will be called on the player inventory
Arf :/
so you need to check the top inventpry
declaration: package: org.bukkit.event.inventory, class: InventoryDragEvent
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
the first is the normal click
you click and then click in the target inventory with the item in the cursor
so you just need to check the clicked inventory
the 2nd you need to see if it is a shift click
if so you need to verify if the top inventory is your backpack and if it is empty
You should not check every time a player adds something to his backpack. Just listen for the InventoryCloseEvent, then serialize the content.
Make your ArgsReaderRegistry a singleton which holds its own instance
this does not seem to me very suitable for my functionality, since I will have to compare the item (put in 3rd line by the player) with the one on the first line to see if it is the right one and to grant the point
if so you need to verify if the top inventory is your backpack and if it is empt
it seems to be a good id i'll search this way, thanks
nope, unfortunately not working
You can replace it using the PlayerCommandPreProcessEvent
Do you want to actually overwrite a fully namespaced command like
/minecraft:help
Otherwise just registering /help would override the default help command unless you used the full namespace
Doesn't work with spigot commands, which may be the issue
Since spigot replaces /help afaik
I did this in the past
@EventHandler
public void onCommand(PlayerCommandPreprocessEvent event) {
if (event.getMessage().equalsIgnoreCase("/plugins") || event.getMessage().equalsIgnoreCase("/pl")) {
event.setMessage("/plugingui:plugins");
}
}
I'm using this code. so it should work, if paper cmds are replacable
public class VersionCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
FileConfiguration config = CustomVersionSeedCommand.plugin.getConfig();
if (sender.hasPermission("CustomVersionSeedCommand.original.versioncommand")) {
Bukkit.dispatchCommand(sender, "bukkit:version");
} else {
Set<String> lines = config.getConfigurationSection(ConfigVariables.VERSION_SECTION).getKeys(false);
for(String one_line : lines) {
sender.sendMessage(one_line);
}
}
return true;
}
}
(I do not have OP Permissions)
Sysout which branch gets called
okeydokey
just /version
Also this can just be bypassed by a user if he just types /bukkit:version instead of /version
you can block that with permissions. What my "client" wanted, was a plugin that can output a funny message, when you type /version
There's no event for when tile entities are initialized, right?
Then just use the PlayerCommandPreprocessEvent
no branch's being called
okey, this isnt gamebreaking hopefully xd
Meh. Best you can do is this:
private void initTileEntity(final BlockState entity) {
// Init/Check your tiles here
}
private void initChunk(final Chunk chunk) {
Arrays.stream(chunk.getTileEntities()).forEach(this::initTileEntity);
}
@EventHandler
public void onWorldLoad(final WorldLoadEvent event) {
Arrays.stream(event.getWorld().getLoadedChunks()).forEach(this::initChunk);
}
@EventHandler
public void onChunkLoad(final ChunkLoadEvent event) {
this.initChunk(event.getChunk());
}
And dont forget to enable your plugin before the worlds load so that the default chunks in the default world are also affected.
okey thank you
Yeah that was what I had, quite messy
One thing though I just remembered
Actually nevermind
Still not working :/
public class VersionCommand implements Listener {
public static final String BUKKIT_VERSION = "bukkit:version";
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerExecutingVersionCommand(PlayerCommandPreprocessEvent e) {
FileConfiguration cfg = CustomVersionSeedCommand.plugin.getConfig();
String command = e.getMessage();
Player player = e.getPlayer();
player.sendMessage("I am being called!");
player.sendMessage(command);
if(command.equalsIgnoreCase("/version")) {
if(player.hasPermission("CustomVersionSeedCommand.original.versioncommand")) {
e.setMessage(BUKKIT_VERSION);
} else {
Set<String> all_lines = cfg.getConfigurationSection(ConfigVariables.VERSION_SECTION).getKeys(false);
for(String one_line : all_lines) {
player.sendMessage(one_line);
}
}
}
}
}
Output in chat:
/version
Normal paper /version output
.
.
.
could anyone help me in my thread?
First of all:
Dont read out of configurations all the time.
Secondly:
This works for me just fine
public class VersionCommandHandler implements Listener {
private final Set<String> commandSet = Set.of("/version", "/bukkit:version");
private final List<String> lines;
public VersionCommandHandler(final FileConfiguration configuration) {
this.lines = configuration.getStringList("section");
}
private void sendLines(final Player player) {
this.lines.forEach(player::sendMessage);
}
private boolean hasBypassPermission(final Player player) {
return player.hasPermission("CustomVersionSeedCommand.original.versioncommand");
}
private boolean isWatchedCommand(final String command) {
return this.commandSet.contains(command);
}
@EventHandler
public void onVersionCommand(final PlayerCommandPreprocessEvent event) {
final String command = event.getMessage();
final Player sender = event.getPlayer();
if (!this.isWatchedCommand(command)) {
return;
}
if (this.hasBypassPermission(sender)) {
return;
}
event.setCancelled(true);
this.sendLines(sender);
}
}
ahh i forgot the setcancelled
I'll take a look at it Tomorrow (I don't want to copy the code if I don't understand it completely)
But a huge thank you! ^^
?scheduling
So I have the standard plugin channel setup, where
player.sendPluginMessage(Plugin.getInstance(), Constants.API_CHANNEL_ID, out.toByteArray());
However, my forge client doesn't receive this. I'm sure that the forge client works for vanilla plugin channels (minecraft:register).
if I send chunks to a client outside of render distance using protocollib, will the client just throw it out or nah?
the client wont care if its outside their own render distance right?
is there a way to change mob fire rate or does that require forge
im just trying to teleport someone millions of blocks away without having the couple seconds of unloaded chunks
like make things shoot really fast
theres probably a load chunks thing, just get the chunks at the tp coords and load them and then tp
yeahs that’s what I’m tryna ask, if pre-loading chunks would even work
i have no idea how, and I’ll have to learn protocollib to try it
just askin before I spend the time to learn it
How do you get the offline UUID of a player?
what is an offline uuid of a player o.O
the UUID thats returned when you try to get that of a player in offlinemode
WAIT I worked it out
UUID.nameUUIDFromBytes(("OfflinePlayer:username").getBytes()) interestingly simple
for the attributemodifier, on the operation you can add numbers, but there is no method to set the attribute equal to a certain number
all you can do is add and subtract
does anyone have any ideas?
how would i use '' inside a yml configuration and get it as a string, for example
thing:
- 'd''
and get it as d'
"d'"
thank u
Attribute base value? No modifiers needed
thanks bro
what if its something like d" ' d ' " to get the string
is it the same?
Idk !!str or a text block maybe
Go check a yaml guide
Or just call .set in your code and see what spigot does
alright
Hey ! Someone know how to know if the cursor have no Item (in inventory) with getCursor ?
I assume the value of get cursor would be null
Me too but getCursor().toString() return : ItemStack{AIR x 0}
Then check if it's equal to air
it not match with ItemStack(Material.AIR,0) or ItemStack(Material.AIR)
Itemstack.getmaterial == Material.AIR
getType
Yea that
Intellij remembers for me
Np
And in 1.8.9 can we differentiate 2 wools ? (different colors)
Easiest way would probably be XMaterial
Or the legacy MaterialData
it's not Deprecated ?
I mean it's 1.8 so
Just use XMaterial
I don't know what it is, I'll get some information! Thanks
I mean there is nothing stopping you using it
Don't think MD is going to go back to 1.8 to remove it
I'm trying to order and group player attacks based on a saved integer within objects attached via their UUID. For example, multiple players might have the attack number 4 and i'm trying to add their UUIDs to something so, once their sorted by the saved integer, I can group their attacks together. Does anyone have a clever way of doing this?
Hey, I read you can't track when a player opens their own inventory (since it's client-sided.) what's the next best thing/event?
Wait for them to click something I guess
just InventoryClickEvent? do I need to do something to determine it's the players inventory and not another?
Check if it’s an instance of PlayerInventory
alright, thank you
Just update to 1.17
Anyone here experienced with OP prison style servers ?
Looking to make my own server but have absolutely no clue how to code or anything
would you like me to send you some java tutorials?
or are you looking for a dev
if so
?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/
I’m sure there are plenty of public plugins to configure
I’m told There are, but I don’t have any experience or knowledge on how to do this
Probably looking for a dev, and then I can pickup some skills along the way
Any roughy idea of a cost ?
depends on the dev, some do per project, some per hour
starting from 15/hr for a decent dev
thats a rough estimate, idk some devs charge different
Ah ok I see
Sorry to sound like an idiot, but how do I write a post in the forum? ( I have an account)
on the top right theres a blue "Post New Thread" button
I need atleast 20 posts and a week old account
oh yeah for resources you need some posts
bump
Have you ever programmed before?
Have you ever programmed before?
what lang does FIVEM support
The heck is fivem
I think it's lua
Oh no
gta roleplay thingo
Luarraysstartat1
pog
"FiveM supports the general purpose programming language Lua as one of its scripting languages. Lua is a very easy language to learn, simple to use and fast to write. To use Lua, just use . lua in your scripts file extensions."
Skript but LUA
Lua is a very easy language to learn if u hate urself
Actually that could be kind of neat
or play roblox
i mean theres a lot of lua interpreters out there
I'd suggest before you start trying to setup a server (if you want to learn), first learn the basics of java and write some hello world apps.
a lua version of skript wouldn't be out of the picture
Would be less cursed
?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.
would take a long time to make an op prison server core because of the optimizations needed but I believe you could do it 😄
@humble garnet
Theres a few people about who would teach, but not the real basics. You must at least know how to use an IDE and write a java program
Is optimization that important for op prison
Ok thank you, I’ll have a look around, it would probably be a lot quicker and better done if I find a dev though, but I will make sure to have some skills prior! Thank you all for the help
Ok cool! If anyone knows of any developers looking for work, please let me know! I’m trying to get this sorted as soon as possible!
What kind of work
Prison work. Depends on what you need lol. It can cost a few bucks to hundreds depending on many factors
?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/
hey if I want to learn how to make custom plugins is visual studios a good software to do so? Im asking this as im already familiar with visual studios as I use it for python projects
I’d suggest an actual ide
It is one
But you can make visual studio code to work like an ide with extensions
He said visual studio not vs code
Oh nvm
Too be fair he might be talking about vs code
Ye lol
its da same thing
It's really not
well im an idiot xD
VS code is a fancy text editor. VS is a full IDE
oh
My plan is to make a custom crates plugin
but im gonna start with something more simple as im not that dumb
I recommend using Intellij for plugins. And then you can use Pycharm for Python
ill check them out
Are you quite the new one to Java or just the spigot api?
im a beginer so I know how to do website (html css) and ik the basics aswell hex and binary good enough to know what im doing but im relatively knew to Java and spigot api
Ah okay yeah then initiate with something simpler
im gonna just start with a simple ping pong command
Sounds good
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.
in terms of difficulty is do you guys know if java is harder or easier than python?
Harder
k
Python is a quite easy language to learn
yea
Which is why many recommend it for beginners
Igloo did you work with object orientation regarding python?
nah i recommend scratch lmao
more or less
well anyway ima get started thanks for the help
True but when you want to start with a real language
right one?
yes
How can I achieve items rotation like this?
https://i.gyazo.com/2ca109065346384a25ea85dc435b37c7.gif
a rotating armorstand
Yeah but I don't know the math for the rotation
Probably want to set the right arm to reach right out such that you get a right angle between the arm and the body, then manipulate the body pose
Done the arm
You’ll have to use an EulerAngle for setting the body pose
quick question so ive just downloaded intellij and minecarft developer but for the project SDK what do i select?
What should I use to rotate the body?
to rotate it in a task
i think intellij can install a jdk by it self too idk
@summer scroll i had a fucking weird dream...
it tells me i can install version from 1.8 to 17 is there any in particular or does it not matter?
wut
hahahah
you like it huh?
Too much minecraft in your life
😳
im pretty sure that called insanity
um the ArmorStand#setRightArmPose doesn't seem to be working for me for some reason.
Still downwards like this
If I could afford it hahahah
Hello, do you guys use library or something else for easy database managment ? I would like to provide for my future plugin every type of database like h2, json, mysql, sqlite
Look at what LuckPerms does
@hazy rose https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html#EXPERIENCE_ORB
declaration: package: org.bukkit.entity, enum: EntityType
Use World.spawnEntity() and pass this value as the entitytype
if(!(player.getInventory().getItemInMainHand().equals(BaowgsPick.baowg_pick))){
player.getInventory().addItem(player.getInventory().getItemInMainHand());
return;
}
why is this if statement triggering but when it adds an item to my inventory, it is EQUALS to the item im holding
i dont understand the phrasing? You are adding the item in their hand if it matches
int expAmount = 100; ExperienceOrb orb = null; Location loc = /*someLocation*/; ((ExperienceOrb) loc.getWorld().spawn(loc, ExperienceOrb.class)).setExperience(expAmount);
its for debugging purposes...
depends on your needs, sql or mongo should do the trick
How i can make it repeat
mysql is easy to setup and use
alr ty
make what repeat?
does postgres exist for java too?
i am adding the item in their hand IF their item is NOT equal to a certain itemstack, but the item given to me when i tried it is equal to that certain itemstack
yeah it does
for/while loop
postgres is just a database, its the library you are looking for
Exp bottle drown
just use a for loop
would this be good? https://github.com/alaisi/postgres-async-driver
is baowgs pick just a static itemstack?
yea it is
just use jdbc
if its a custom item you should make a handler class, you cant give the same itemstack to all players
Do u have plugin who make exp bottle drown from no where just by using command?
Believe you could just use something like hikari
the "giving the itemstack to players" is a debugging line
my question is, why is the if statement getting satisfied?
when infact, it should not
thats what im saying
a uh ping reply wouldve been cool so i wouldve seen it easier
you are testing with the Baowgs pick in your hand right
but it is still being satisfied
yup
so how would i make it not satisfy
theoretically, it should not be satisfied
dont use a static itemstack and make a proper handler
wdym by proper handler?
like a wrapper class for custom items instead of a static variable
ill send through an example, give me a sec
mhm sure
Uh I have it to toggled off by default and cba to turn it on😅
something like that where you have a method to check whether an itemstack is actually a custom item
far better than using one static itemstack
think about it, if you give 10 players the same itemstack, it will share all the same data
why would i need to check whether an itemstack is actually a custom item
stack size, enchant etc etc
so you can handle it properly
just checking whether item in hand = static itemstack is crude and won't work in many circumstances
so ill just create a getter that creates a new copy of the item stack and returns that item stack?
then in my listener ill run the getter method
thats what im understanding
yeah, then to check whether it actually is a custom item have a method in the custom item class
alright ill try that out, thanks
unless you want to check material, name and lore but that is a big workaround
and can be cheated easily
yea ill stick with itemstack
will if(!(player.getInventory().getItemInMainHand().equals(BaowgsPick.baowg_pick))){ get satisfied if the itemstack from getiteminmainhand has a different durability than the itemstack?
well in an ideal setup you would just use
ItemStack hand = player.getInventory().getItemInMainHand();
if(itemManager.getHandler(hand) != CustomItem.BaowgsPick){
//do stuff
} ```
that getHandler method would return an enum
and the enum being a list of all your custom items
the struggle with comparing an itemstack to a static one is data will vary. durability, stack size, name etc
Will ignore the stack size.
Honestly you can just use PDC I guess, make things easier.
yeah but theres many cases where custom items will vary with lore etc
^ my example uses nbt
Yeah true, nbt it is then.
so if im using postgres, do i just create the db with the postgres user with CREATE DATABASE then login to that db with the same postgres user?
i guess ill do that then
actually it wont even work for stuff like minehut as well i dont have access outside of the mc server and my folder so ig sqlite
wdym stuff like minehut
How do you register commands without reloading a plugin AND without adding the command to the plugin.yml?
for example, how do commandalias plugins do it
checkout plugin.yml annotations
a command alias plugin should not be registering any commands
its just providing aliases for existing ones
okay but a plugin like ezcommands
makes own commands and registers them
how does one do that
reflect into the command map
aaah okayy
thats cool
but you still need to register it in plugin.yml
no you don't
really?
not when reflecting
would be useless if you did have to
is it even possible to change the plugin.yml by the plugin itself?
no
no right? since its compiled etc
its not that its compiled, its that its in use
ah ok
why are methods like sendTitle deprecated and replaced over time?
I use it too in one of my Plugins, i don't know why they aren't deprecated in the SpigotMC API Website but in IntelliJ
teh javadocs and Intelij are identical deprecations
sendTitle (if I remember) the two arg method was deprecated. You have to use the full 5 arg method
actually not. Like I looked twice or more, it had the same arguments, etc etc. but it was deprecated in IntelliJ but not on the docs
just use -1 for all thre ints and it works identical to the deprecated method
sendTitle can use 5 arguments
ye, in IntelliJ it is / was deprecated
showTitle uses 1 argument
this is deprecated in intellij.
Ye, there you go
whats this?
java.lang.ExceptionInInitializerError: null
that one is deprecated
That is Paper not spigot
oh kk
lol.
well, theres a null in th error
ah i found it
wait how do you open this window?
hover over it long enough, okey okey
very useful ^^
does anyone know how to remove the dependency of citizens for goldencrates I dont want to pay the 10$ and I generally dont need it as its described as an optional dependency here is the source codehttps://github.com/nulli0n/GoldenCrates
What happens when you run it without Citizens? It says that the Citizens is optional dependency, not required/mandatory.
if its in the depend of the plugin.yml just remove it
I get a few error messages
its soft so you should be fine
Show us the error
29.10 10:56:48 [Server] Server thread/ERROR [Citizens] v2.0.24-SNAPSHOT (build 1605) is not compatible with Minecraft v1_17_R1 - try upgrading or downgrading Citizens. Disabling.
51 29.10 10:56:48 [Server] Server thread/INFO [Citizens] Disabling Citizens v2.0.24-SNAPSHOT (build 1605)
52 29.10 10:56:48 [Server] Server thread/ERROR [NexEngine] Plugin NexEngine v**...** has failed to register events for class su.nexmedia.engine.hooks.external.citizens.CitizensHK because net/citizensnpcs/api/trait/TraitInfo does not exist.
53 29.10 10:56:48 [Server] Server thread/INFO [NexEngine] [Hook] Citizens: Success!
(was too long to take screenshot)
idk, i think they are using their own libs and i cannot see that code
ok
I think the method this.getCitizens() on the GoldenCrates source code causes the error that you got. https://github.com/nulli0n/GoldenCrates/blob/master/GoldenCrates/src/su/nightexpress/goldencrates/GoldenCrates.java#L133
citizens is free
they have a jenkins
yeah xd, i dont see why you dont want to add citizens
on the jenkins page
does anyone know how i can do thread.join but asynchronously
Hello, i have an error
and it says that "customFile" is null
but, don't know how to solve it
could anyone help me? 😄
lol anyone have an easy way yo do the
Location loc = Player.Location();
it doesnt work for me lol
the location method doesnt exist
by the looks of the capitalisation, youre doing that on a class
tab complete is ur friend
nope i have no hope
ook then
it would usually be getSomething anyway
public class TestNMS extends EntityZombie {
public TestNMS(Location loc) {
super(((CraftWorld)loc.getWorld()).getHandle());
this.setPosition(loc.getX(), loc.getY(), loc.getZ());
}
Location loc = Player.getLocation();
TestNMS NMS1 = new MySuperZombie(((CraftWorld)world).getHandle());
NMS1.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
((CraftWorld)loc.getWorld()).getHandle().addEntity(NMS1, CreatureSpawnEvent.SpawnReason.CUSTOM);
}
Im trying to do the nms thing
oh god i forgot i need to put it inside commandexecutor
you know java // codeblocks exist so stop() { using = snippets; }.likeThat();
goldencrates hates me
This command can be executed only from the game!
Can I remove the error without changing the plugin?
There are some commands that don't need console and I want to run these commands through console.
which command?
Hello, i have an error
and it says that "customFile" is null
https://paste.md-5.net/cowalupura.java
but, don't know how to solve it
could anyone help me? 😄
in the sysout?
public static Direction getNeighborDirection(BlockPos origin, BlockPos neighbor) {
int ox = origin.getX() - neighbor.getX();
int oy = origin.getY() - neighbor.getY();
int oz = origin.getZ() - neighbor.getZ();
switch (ox) {
case 1: return Direction.EAST;
case -1: return Direction.WEST;
default:
switch (oy) {
case 1: return Direction.UP;
case -1: return Direction.DOWN;
default:
switch (oz) {
case 1: return Direction.NORTH;
case -1: return Direction.SOUTH;
}
}
}
return Direction.SOUTH;
}
``` u think this will work
idk how to do this
its only ever next to it
never further
so no need to do > and <
Does the file exist?
ur attempting to save your file before its loaded
or it doesnt exist at all
check if YamlConfiguration.loadConfiguration(file); returns null if it doesnt exist
when a player joins it creates a file
Rather than file.getParentFile().mkdirs();
nah that will create the file itself as a directory
wait
when i start the server, it returns this error
not when i join...
you mean something like this?
if (!file.exists()) {
customFile = YamlConfiguration.loadConfiguration(file);
}
the file needs to be exist before you use it with loadConfiguration
so like that it should work ig?
i'm checking if the file exist
and if it does it creates
right?
@summer scroll?
other way around
you need to create the file first before using loadConfiguration
if (!file.exists()) {
file.createNewFile();
}
customFile = YamlConfiguration.loadConfiguration(customFile);
or use
if (!file.exists()) {
throw new IllegalArgumentException("file doesnt exist");
}
customFile = YamlConfiguration.loadConfiguration(customFile);
ur checking if the file doesnt exist
in the 2nd one
and also
u need to create the file itself
ye ye, that was now...
file.createNewFile();
how do you enchant an item past its cap?
with spigot api or?
i have it already
ItemMeta#addUnsafeEnchantment();
``` i think
lemme try that
It’s just addEnchantment in the meta
then you are trying to save the file before u have loaded it
as customFile is null
you are creating an empty file
yes
uh
but im not sure
public class VersionCommand implements Listener {
private static final String BUKKIT_VERSION = "/bukkit:version";
private static final String HEX_CODE_REGEX = "&#[a-fA-F0-9]{6}";
private final Pattern pattern = Pattern.compile(HEX_CODE_REGEX);
private final FileConfiguration cfg = CustomVersionSeedCommand.plugin.getConfig();
private final List<String> all_lines = cfg.getConfigurationSection(ConfigVariables.VERSION_SECTION).getStringList(ConfigVariables.STRING_LIST_MESSAGE);
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerExecutingVersionCommand(PlayerCommandPreprocessEvent e) {
String command = e.getMessage();
if (command.equalsIgnoreCase("/version")) {
customVersionCommand(e.getPlayer(), e);
} else if (command.equalsIgnoreCase("/ver")) {
customVersionCommand(e.getPlayer(), e);
} else {
return;
}
}
private void customVersionCommand(Player player, PlayerCommandPreprocessEvent e) {
if(player.hasPermission("CustomVersionSeedCommand.original.versioncommand")) {
e.setMessage(BUKKIT_VERSION);
} else {
for (String one_line : all_lines) {
one_line = hexCodeFormatter(one_line);
player.sendMessage(one_line);
}
e.setCancelled(true);
}
}
private String hexCodeFormatter(String msg) {
Matcher match = pattern.matcher(msg);
while(match.find()) {
String color = msg.substring(match.start(), match.end());
color = color.replace("&","");
msg = msg.replace("&"+color, ChatColor.of(color) + "");
match = pattern.matcher(msg);
}
return msg;
}
}
It's working for me now!
(can anyone please help me, if this is optimized?)
hmm
wait what else return
isn't it so, when you make this, the event handler "aborts" so just ends his changes and things?
i tried with dataStoreOnJoin.get().addDefault("hello", "yes");
java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.file.FileConfiguration.addDefault(String, Object)" because the return value of "me.fragment.minespaceskills.store.dataStoreOnJoin.get()" is null
this error
so i can just delete the else and return and it's fine?
yes
player.playSound(player.getLocation(), Sound.LAVA, 0.4f, 1.0f);
How do I get the sound to be heard everywhere, not just in one spot?
You'll presumably want to sent the sound to every player ?
no just one player
What do you mean with everywhere then ?
I changed the lava sound, it is a long sound but it is not heard from a certain block away.
Concerning you are using the players location, it would always be heard
just my bad english
There is a sound of lava at the player's location, but when she moves away, the sound becomes muted and inaudible until she goes to the place where the sound started.
I just want to extend the reach of the sound.
i solved
just player.playSound(player.getLocation(), Sound.LAVA, 1000.0f, 1.0f);
how does inventory instanceof SomeClass works?
does the class needs to have an Inventory field?
like it worked before
The inventory has to be an instance of SomeClass for that to work
cant i just check if inventory instanceof ParentClassOfCustomGui?
liek i have custom gui classes like TradeGui, ShopGui and in the inventory click event i'm checking if the inventories are instanceof GuiCreator (which is the parent class of all those mentioned before)
anyone know which plugin is used to make a pickaxe have custom enchants? play.wildprison.net ( the one use on there)
hello?
What is the best way to use InventoryClickEvent ? I have created custom GUI menu and I have some codes on items in this custom menu but i would like to be sure I don't send my action to another gui menu ?
how do you guys do that ? I see many tutorial using itemname (if itemname = "blababla) do this, but I think it's a bad pratice because if two gui menu use same item name, my code will be run
If all your classes extend/implement your parent and your parent is a sub of Inventory
but if that would be a subclass of inventory, i would have to define all those methods
idk why but instanceof worked everytime and now it doesnt
it has to actually be an instanceof Inventory for it to be true
but how can i check then if the inventory is from one of my custom gui classes?
as instanceof doesnt work
you compare the inventory instance,
InventoryHolder
to what?
but the problem is that there are multiple instances
and?
i cant check that for every instance
why not?
because i'm not storing them somewhere and the amount of them could be big
You have to be storing them at some point
anyone know where i can change the server listing name ?
its not in properties.yml
InventoryHolder Cough
hmm if i just let my super class implement inventoryholder, can i check then if the event.getInventory().getHolder() instanceof Superclass?
Not like I said it twice
there is no other easy way
^ yes
cringe
I'd have to guess you forgot to register the listener?
no
Is there anyway to store Itemstack into mysql except serializing itemstack to base64?
not simply, no
oh...
Hey, little fast question, when we spam click on an Inventory, InventoryClickEvent can't catch all click right ? 🤔
im using crateKey, and the createtier command isnt working ? any ideas ?
you need #help-server
o thanks
I am trying to load maps onto item frames on server start, but for some reason the item frame entities cannot be found. On server start there are 0 entities in the chunk where the item frame is supposed to be, but 30 seconds after server start there are, even though the chunk is loaded in both cases. Is there something I can do about this?
you may be checking before the entities are loaded
Is there any way to load the entities?
any explanation why it doesnt work?
I tried using chunk#load() but that didn't seem to do anything
ChunkLoadEvent
Chunks aren't loaded instantly
Is there any way to load the entities
Use I believe it's EntitiesLoadEvent
It's called whenever the entities of a recently loaded chunk were finished loading
I know, but my plugin uses POSTWORLD on load, and logging chunk#isLoaded was true
Yeah, again a chunk being loaded does not guarantee its entities being loaded
Yes I understand, I'll see if I can listen to the event
It's weird, my InventoryClickEvent don't catch all click.. it's a problem of allowed RAM ? 🤔
which clicks doesnt it catch?
about one left click out of 10
It isn't type click problem, just sometimes he ctach the click, and sometimes (more rarely) not
It's a problem cause at each click on a backpack inventory i have to compare the item with an other and if all click isn't catch i can't compare 😦
@tardy delta i think this could be usefull https://www.spigotmc.org/threads/how-to-check-if-a-player-clicked-a-custom-inventory.486230/ (by comparing holder)
hey, considering this returns a map ProxyServer.getInstance().getServers() am i suppose to grab the value of each element in the map or is there another way to get all the servers?
trying to loop through all the servers connected to bungee.
ProxyServer.getInstance().getServers().getKeys()
can you show me your code, it's intersting
it's .keySet() right?
probably
yea, plus it's .values i'm looking for anyway but you pointed me towards the right path ty
uhh what do you want to see, its a big chunk of code
i just let all my classes extend a base class (GuiCreator) which implements InventoryHolder
how you check if event is called by your gui
i had the same question when you was talking here
ah when making the inventory in the GuiCreator class, i pass this as InventoryHolder
and in the listener
Nice thanks 😉
Anyone have any idea how to solve this error?
public static class Dude extends EntityZombie {
public Dude(World world, Player p)
{
super(((CraftWorld)world).getHandle());
Location loc = p.getLocation();
Dude dude = new Dude(((CraftWorld)world).getHandle());
dude.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
((CraftWorld)loc.getWorld()).getHandle().addEntity(dude, CreatureSpawnEvent.SpawnReason.CUSTOM);
}
}
new Dude() :kekw:
im talking about this lol
ah i see stackoverflow
what is the error?
its first time of me messing with nms and im confused
yoru method wants a Bukkit world
Dude dude = new Dude()
-> Dude dude = new Dude()
-> Dude dude = new Dude()
...
you understand?
so only new Dude(world)
thats a stackoverflow no?
I..
creating instances of itself in the constructor
yes
thats alot of dudes
that's a whole army
Jeez, never thought i need to write 10 lines of code to spawn a dude i can do from just 1 line
because its nms
So, i don't find solution to left click who are not caught by the InventoryClickEvent
Do i have to search an other way to do what i need ?
Like verifying item when inventory is closed ?
whats even the point of making a new dude when making a new dude?
the dude needs another dude to have fun with
OOOOOHHH
yep, i dont get it at all
yeah i know i gave the wrong world but
Can't you just
public Dude(World world, Player player) {
super(((CraftWorld)world).getHandle());
setLocation(player.getLocation());
((CraftWorld)loc.getWorld()).getHandle().addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
}```
🥄
?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.
Dude
smh that emoji sucks
but eh
bruh
i guess when it comes to nms? we can close an eye
he probably doesnt know you can pass this as argument
i legit dont
this is just the current instance with all methods and stuff
current instance wich is extending the entity hence why it accepts it btw...
just in case you think you can do this for everything😂
oh i think i get it
yeah i get this part
bug hunting for a week now...
@tardy delta
I'm looking for add holders too,
e.getClickedInventory().getHolder()
return com.example.testmaven.gui.holders.MenuHolder
e.getClickedInventory().getHolder() instanceof MenuHolder
return false
here my holder
package com.example.testmaven.gui.holders;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
public class MenuHolder implements InventoryHolder {
@Override
public Inventory getInventory() {
return null;
}
}
Stange no ?
How do I make a armorstand not lag behind when teleporting it every tick?
How will that make any difference
whats the problem?
when nothing is in /out 😔 🙏
The problem is e.getClickedInventory().getHolder() instanceof MenuHolder return false even of true
When e.getClickedInventory().getHolder() = com.example.testmaven.gui.holders.MenuHolder
you mean teleporting a entity 20 times a second where the server has to keep track of replaced to non existing only for client?
cringe
are you passing a menuholder instance when creating hte inventory?
what so if I just send it to the client your saying it won't lag behind
and you are clicking the right inventory not the players one right?
oh french
and if you try event.getInventory() instead of clickedinv
hmm whats with the specific package name?
same
import com.example.testmaven.gui.holders.MenuHolder;
hmm should work
try putting a debug above the check
and see if it reaches the check
Ok nevermind, i had to reload all entier server. I'm using biletool plugin for hot reload plugin when they are edited and seems to cause that bug
👍
it works so
trying to understand concurrency with java and java CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> { // some database connection return "Result of the asynchronous computation"; }).thenApply(result -> { System.out.println(result); return "Result of the then apply"; });
how would i get the result from this?
preferably not a blocking way to get it
ah right
Or if you want to chain it could use
thenApply where the function returns its argument
so do i not need thenapply?
As said
thenAccept is viable
However it returns a CompletableFuture<Void>
Which does no longer contained the computed object
This if you want to chain more higher ordered functions after the future you might just use thenApply where the lambda passed return its argument
Since that’ll keep the computed object
oh so i cant get the object back out of it without blocking?
Yes you can but you can’t await the result
Since that’ll block
So the only option would be a callback
should i cache inventory instances?
Depends
i kinda want to extract the database connection, if its on the main thread and only occurs on startup i guess its fine?
Extract the database connection?
Pretty sure you can instantiate the connection pool and everything synchronous assuming it’s during bootstrap time. But then again queries, updates and retrievals from the database should be done async
it chains a Function<T,R> on to the future
Where the method returns CompletableFuture<R>
i honestly have no idea what R is
R is the type parameter standing for resulting type
are you able to grab the ProxyServer on a spigot plugin? ProxyServer.getInstance()
If it’s from BungeeCord no
whats the difference between the async and non-async methods, do they do nothing in this context or are they just not different
They’re very different
because they dont have an await, does that mean its a different thread?
You often establish a CompletableFuture with CompletableFuture::runAsync or supplyAsync which will use a thread from the executor you pass along with the supplier or runnable (the executor is by default the common fork join pool). Assume you do call thenBlahAsync, basically it’ll just use another thread from the executor, so it’ll be async in relation to the already async task.
Wym?
Await means you just wait for something to be done, in java we have Future::get or CompletableFuture::join for instance
Yeah
Which in 99% of the times is unnecessary
Yeah it’s a bit weird at first
I just don't understand why : https://youtu.be/8IIf9w0NWv0
why i can't put this lapis block in the backpack
Red message is in english : "Sorry, it's not the good item =("
normally, when i try to put an item in the backpack, the plugin will check if it's the same item that the item in first line and if not, the event is cancel
Inventory inv = event.getClickedInventory();
Player player = (Player) event.getView().getPlayer();
ClickType type = event.getClick();
player.sendMessage(type.toString() + debug);
player.sendMessage(inv.getType().toString());
debug++;
if (type == ClickType.DOUBLE_CLICK) {event.setCancelled(true); return;}
if (type == ClickType.LEFT && inv.getType() == InventoryType.CHEST && inv.getName().equals("§8Backpack")) {
if (event.getSlot() < 18 || event.getCursor().getType() == Material.AIR) {
event.setCancelled(true);
return;
}else {
Team team = Team.getUserTeam(player.getDisplayName());
Backpack backpack = team.getBackpack();
int itemSlot = event.getSlot();
System.out.println(inv.getItem(itemSlot-18));
System.out.println(event.getCursor());
System.out.println(event.getCursor().isSimilar(inv.getItem(itemSlot-18)));
if (!event.getCursor().equals(inv.getItem(itemSlot-18))) {
player.sendMessage("§cCe n'est pas le bon item... =(");
event.setCancelled(true);
player.updateInventory();
return;
}else {
player.sendMessage("§a c'est le bon item, votre équipe marque un point !");
backpack.goalAchieved(itemSlot);
backpack.updateBackpack();
player.updateInventory();
team.addOnePoint();
}
}
}
Can you put anything in it?
I would imagine no
Only (normally) the good item
Whats the normally good item
if you try to put an item in the first slot of the third line, the good item is the first item of the first line
I didn't think it's the problem 'cause in the video, the click when i could put the labis block below the quartz block didn't catch by InventoryClickEvent 🤔
Otherwise, a message would have been send in the Minecraft chat
And i don't understand why this click is catch by the eventHandler
RAM problem maybe ? i put 2048 to max ram
if (newlocation.getBlock().getState().getType() == Material.WALL_SIGN || newlocation.getBlock().getState().getType() == Material.SIGN_POST) {
BlockState blockState = newlocation.getBlock().getState();
Sign S = (Sign) blockState;
}``` how can i set a line of the shield. It´s the version 1.12.2. S.setLine() doesn`t work with this code
Nah, it was doing the right thing. It declined it because Lapis isn't Quartz. It only let you do it because the click type was probably wasn't Double Click or Left so it wasn't canceled.
but in first instruction of the event there is :
ClickType type = event.getClick();
player.sendMessage(type.toString() + debug);
player.sendMessage(inv.getType().toString());
if this was an other click type, he should have displayed
if cancel becomes true, it should get cancelled no?
Hm true that is a little weird
the best solution, i think, is to change the way that the plugins works no ?
An idea is to let player put all he wants in the third line of backpack and when he close the inventory, i compare items
tell me if i'm wrong
Hey everyone ! I dont find the way to get the value of each pixel of a map. Is it possible to get them ?
I saw MapCanvas but idk how to get it
Hey, is there an event or way to detect vehicle collisions when ridden? e.g: Boat hits wall => action
Cause i've tried it (VehicleBlockCollisionEvent )and it only works if they do it by themselves
how to send images here
verify
its not working
what should i type
when i tried it before it didnt send me any message in my soigot accoun
pog
unsure but this might require nms
anyway can someone help me, I can't select version in intellij spigot plugin settings
i saw other people do it
without error
why is it not working for me
report thjat
but yeah
ensure u got the latest intellij version
and then reinstall that plugin
isnt 2021.2.3 the latest intellij
That's the latest version yeah
bruh i reinstalled the plugin and it still erro
hmm you might wanna delete that spigot.json file
such that it can generate a new valid one
i could only find the github. I posted an issue there a week ago
no response?
the only way I could make a plugin was by asking another guy to give me a template
yea no response
oof
hey i have an error java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_12_R1.block.CraftBlockState cannot be cast to class org.bukkit.block.Skull (org.bukkit.craftbukkit.v1_12_R1.block.CraftBlockState and org.bukkit.block.Skull are in unnamed module of loader 'app') at tyko.de.haikobra.knockffa.De.HaiKobra.ranking.Ranking.set(Ranking.java:51) ~[?:?]
LOC.get(i).getBlock().setType(Material.SKULL);
Skull skull = (Skull) LOC.get(i).getBlock().getState();
skull.setSkullType(SkullType.PLAYER);
String name = Bukkit.getOfflinePlayer(UUID.fromString(rang.get(id))).getName();
skull.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(rang.get(id))).getPlayer());
skull.update();```
But when i import the material and the block i get the error: ```'org.bukkit.block.Skull' is already defined in a single-type import```
Who can help me with this error or has a suggestion?
You setType on a BlockState, then you get a new BlockState and try to cast to Skull. It will not be a Skull as you never committed the change from the last state.
nm, ignore me, I was reading it wrong
However your LOC.get(i).getBlock().getState() seems to be returning a CraftBlockState, why?
yes, but that method shoudl return a BlockState not the implementation
I wouldn;t expect to see his cast error on a BlockState
Show us your imports
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import tyko.de.haikobra.knockffa.De.HaiKobra.KnockFFA;
import tyko.de.haikobra.knockffa.De.HaiKobra.MySQL.SQLStats;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;```
Yeah no clue, I'm tired and my heads not working.
who does this
tyko.de.haikobra.knockffa.De.HaiKobra.KnockFFA
its the main class
ye but don't you have to nest that in like two other fuckin' classes?
class De {
static class HaiKobra {
static class KnockFFA {
}
}
}
a new file is generated for every class ^
so that becomes De, De$HaiKobra, and De$HaiKobra$KnockFFA when compiled
which, I'm not entirely sure if this correct, but I believe De must be loaded if De$HaiKobra is
which means this approach causes two unnecessary problems:
- code size increase for redundant classes
- class load overhead for redundant classes
just like
what