#help-development
1 messages · Page 1360 of 1
You can not return a value from your getDiuscordUser.
Yes, now I use future
You still can;t get a return in your same code, the future has to run then you can get the result later
you simply can not getDiscordUser adn get a result when multithreading
Ok but how can I then null check the user?
you have not delt with yrou return
your getDiscordUser method needs to change to a void return type
guyS i'm back with my errors! I've this same problem https://www.spigotmc.org/threads/java-lang-noclassdeffounderror-com-warrenstrange-googleauth-googleauthenticator.294462/ but with a most recent version, ideas? (I tried all of this post)
And how to null check then?
I don't understand your question. It has no application in the discussion.
I just want to get all values from the database (async), and then return the DiscordUser with the UUID if there is one
@maiden briar it seems you need some help. If you need help you can look at my GitHub for a reference.
That was the main question 1.5 hours ago
Ok I will have a look
How easy is this API to use?
I'm pretty sure your question 1.5 hours ago was how to get a discord user without crashing the server
Yes, and then the question changed to async, because I know that is the solution
yes
There is no API at the moment but I plan to create one in the future
But it seems you are not understanding how to use callbacks
See you later in 2030
LOL
When windows live messanger will become like discord. Oh no, the opposite
I will ask on coded red's server
Simply put, you can not fire of anything Async and wait for the answer. You have to fire it and forget about it. The Async has to do its work, then call a method sync with the server thread and deal with the result.
🙂 🐬
That result could be 10ms later or 30 minutes. You have no control over it.
I'll try
Are you using maven?
Your answers are already in that thread you linked
^
Yes my love https://pastebin.com/TGJyKanp
need to shade the api into your plugin since you know that api isn't going to be available magically for your plugin
That's the Answer.
Did yoru plugin compile with no errors/warnings?
most likely if the problem is only noclassdef exception
Can you read my question before?
i already tried this..
Open your resulting jar file and see if it includes a com/warrenstrange folder
hey i wanna ask how do i set a premium (online mode) to player on bungeecord proxy when online mode is off? (something like fastlogin)
No errors in compiling
should be using online mode anyways
well yea but
This community does not support people who disable online mode for illegitimate reasons
i do not disabling it im just making a plugin
simple answer is don't even bother with offline mode? Not sure why you would need to even bother supporting that lol
im sorry, but i didnt ask about why to not use offline mode or something im just making a plugin for premium
No, open yoru JAR and see if its in there. Not your project
that supports offline mode, all i can say you are for the most part going to be on your own for that endeavor.
it's maven, i can't see nothing..
No, the jar that is created after you compile, open it with any compression util like 7zip
maven is just a build tool, still produces a jar
If its not there I'm betting you are building using Artifacts in InteliJ, which is wrong. Right hand window marked as Maven... Expand lifecycles and run packge. The jar it makes with be in the target folder of your project.
Don;t use artifacts
This event is deprecated, what should I use instead? PlayerPickupItemEvent
lol
And what, my dog can't build the jar..
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityPickupItemEvent.html
@dry beacon
declaration: package: org.bukkit.event.entity, class: EntityPickupItemEvent
Thanks!
you do know the JavaDocs states such
close that window. In your main project view, look right
?jd
package index
You need to build using maven, not artifacts
Anyone who uses InteliJ please talk @green prism thorugh a maven build. ( I use Eclipse so couldn;t tell you where to find the correct window)
and no, thats not the right place
Yea, please
@here
Lmfao
I find it interesting you use eclipse @eternal oxide
from now on I will just send people who use that IDE to you 😉
So i want smth to auto spawn mobs (Custom nametag ect) in a certain AREA of a certain wORLD WITH CuSTOm name, HeA L Th and wepon/dmg eCT Any plUgins YOu Knmow?
heyo im tryna use enjins api, but i dont understand their docs at all
there's no maven repository or anything
to the right
Should i ask that qiustiion somejybehwere else
it's probably a REST api, not a java library
i think it is, but how am i supposed to use it?
with http requests
someone recommended i use the okhttp library but i really do not understand anything about it
yes, you'll need to understand how http requests work
any good tutorials explaining how to use http requests with java?
even better if its video, but i dont mind a good read
don't have any suggestions but I'm sure this is something you can google and get plenty of results for
enjin has a plugin just fyi
@quaint mantle I wouldn't bother with enjin since its pretty much now defunct. Hence their documentation not being very good.
the server owner im developing for insists that i use enjin only because of its points system for donationcraft
lol good luck with that then
i already told him that he should be using tebex
personally I drop people as clients if they insist I use something that is severely broken
wut is that
link?
or does it even exists
what
very right side of that screen, blu bar
ngl sounds like a rly good ideea
considering the lack of tags i assume this is old af
@onyx shale it is a good idea, but the source code is just atrocious though
oh yeah 2015
like updating the existing code will take many hours XD
original source code was compiled for 1.7.10
and now? What i need to do for the build
and yes, it uses NMS
package
🤷
good ideea still gonna add it for reproduction
https://github.com/betterphp/BloodMoon/pull/134 the commit messages are good too
I think he wants to rename it to 1.8
@eternal oxide Hey! The error is another now, after build with maven, https://i.imgur.com/zABXxy7.png
arent u spending more time fixing maven than actually coding?
seems non productive for me
what are you actually doing
it looks like you're interfacing with google... which isn't exactly spigot related
I'm using spigot for my server, so..
Your error is now that you are using teh library incorrectly.
except the error has nothing to do with spigot now
i doubt you're using it correctly if you're blindly copying code snippets from spigot
Does somebody has an idea ?
I don't do it for money, I do it for experience and passion (I have nothing to do)
the problem is no longer maven related, you have the classes you need, the problem now is that you're incorrectly using whatever library you have just shaded
Is shade the problem?
no
I just said it was no longer maven related
Ah thanks! Good spaghetti to everyone
Hey is it possible to hook into the PAPI API and use that to parse Placeholder within your own Plugin?
More specific example String name = %player_name%
I don't actually want to parse that placeholder, but wanted to be as clear as possible on the question
yes
So I can do this, for a Placeholder which is NOT in my Plugin, but from another?
yes
Might you know where it's documented at? I looked on the Wiki and I only see how to setup my own Placeholder https://github.com/PlaceholderAPI/PlaceholderAPI/wiki
Aw frick ya! Thanks 😄
hey how do i check if player is logging with premium minecraft or is cracked on bungeecord?
if the server is online-mode then everybody is, if not then you cannot check
then how does fastlogin check it?
well.. it's open source
and how do i do that?
well I'm not gonna write the plugin for you but the steps are described right in front of you
okay
Is there a decent plugin for maybe handling database connections in a centralized area (think: instead of multiple mysql pools throughout various plugins, use 1 central plugin api to manage a single pool for other plugins)?
I found something but it wasn't clear to me, without testing with it, whether or not it was secure (prepared statements, etc) or straight up open for injection. :/
@unreal quartz ok so i watched a whole 1 hour series on gson, so now i understand how gson works.
but now i still do not get how im supposed to use enjins' api
you perform a get request, or a post request, or whatever to whatever endpoint it is
this should be documented somewhere
they documented what we ened to put in the post request, but im still a little confused
one sec ill send you what i mean
what do they exactly mean by method?
i wouldn't know myself without knowing how enjin works
but that is something you supply in the body of your post request
Guys guys guys, very fast question, is possible to make a player directly open a book by clicking on an icon in a GUI?
mike mike mike, yes it is
thanks thanks thanks thanks
never done it myself lol or id show u example but i kno u can open books at will serverside
So your answer is useless
no xD u asked if its possible not how, mi answer still valid
So this is illegal
wat
Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.
@sage swift gets the title of mvp for this period
ahaha
Read the private chat
I havent worked with gui's in a couple years
public void onInventoryClick(InventoryClickEvent event) {
if (!(event.getClickedInventory().getHolder() instanceof AbilitySelector)) return;
event.setCancelled(true);
ItemStack item = event.getClickedInventory().getItem(event.getRawSlot());
}
Is this the way to see what item in an inventory is clicked? And does it differ from the upper or lower inventory?
Java float to int casts round down, right?
no
Event#getCurrentItem()
it is truncated
depends which way you consider "down"
if you interpret that as closer to 0 then it's wrong
The f2i instruction performs a narrowing primitive conversion (JLS §5.1.3).
a negative number will be truncated and produce unexpected results
Here, I got the proper terminology
when sending a message in chat, trailing whitespaces are removed. Is there a way to get the message with those whitespaces, or is it done on the client side?
why do you need them? @idle grotto
on 1.8 when spawning horses i want the nametags near the ground while the horse is around 50 blocks above that y position of the nametag, how would i go about this?
armour stands?
Ohhh... we don't really support ~1.8 here
how do I go about stopping the lag from sending packets of blockchange to the client? I can't figure it out
Hahahaha
it'd take a while to explain, indentation basically
Errm... I don't know. I imagine that it is the client that does it
Wdym by lag?
it lags the client
i mean, i think that is kinda what happens? A combination of calculating light updates + other calculations
would you know how to go about it without lagging the client?
What are you sending in the packet? Just like blocks?
Hang on... Every second! Im not suprised that it kinda lags the client
new to packets and stuff of that sort
protocollib
Can you send a recording or something of the lag?
yeah give me a sec
Out of curiosity why are you doing it in 1.8
?
Like why are you writing plugins in 1.8, is it not a bit obselete
no lol
Yikes, can I see the code?
uhh
u wanna hop in a private call?
the code is probably bad I haven't coded in a few years
It doesn’t matter. I don’t wanna call but if you really want to you can dm it
kk i'll sned u it
Any Ideas why I get this? ```
** BEGIN NESTED EXCEPTION **
javax.net.ssl.SSLException
MESSAGE: closing inbound before receiving peer's close_notify
STACKTRACE:
javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
at sun.security.ssl.Alert.createSSLException(Alert.java:133)
at sun.security.ssl.Alert.createSSLException(Alert.java:117)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:311)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:267)
at sun.security.ssl.TransportContext.fatal(TransportContext.java:258)
at sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:637)
at sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:616)
at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:2249)
at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4221)
at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1464)
at com.irgendwer.myworlds.MyWorlds.onDisable(MyWorlds.kt:31)
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:179)
at org.bukkit.plugin.java.JavaPluginLoader.disablePlugin(JavaPluginLoader.java:341)
at org.bukkit.plugin.SimplePluginManager.disablePlugin(SimplePluginManager.java:417)
at org.bukkit.plugin.SimplePluginManager.disablePlugins(SimplePluginManager.java:411)
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.disablePlugins(CraftServer.java:443)
at net.minecraft.server.MinecraftServer.func_71260_j(MinecraftServer.java:512)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:680)
at java.lang.Thread.run(Thread.java:748)the Code:
override fun onDisable() {
try {
if(connection!=null && !connection!!.isClosed) {
connection!!.close()
}
} catch(e: Exception) {
e.printStackTrace()
}
}```
?jd
package index
which line is the 31st one?
is it the close one?
Probably connection!!.close()
yes
It says that SSL Connection to the database is failing
However don't ask me what !!.close() does
Ah
Meanwhile I thought it was double negation
LOL, It says that it closes the connection before it recieves from the SQL server that the connection is closed
lmfao
javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
question is whether the issue is at your side of the libraries side
Does the event get fired even when there is no item inhand to be swapped?
I would look at the docs of close again, maybe it has more info on that matter
Ok
Would be new to me if spigot being able to detect what button presses the client
there's no info regarding it
Not specifically f but whatever hotkey the player has set
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
wait wrong method sry
declaration: package: org.bukkit.event.inventory, enum: ClickType
Nice I think that's it
@obtuse basin Which event has that info
PlayerInteractEvent?
is there a way to see where the events actually gets called?
Dive into the source code of Spigot
declaration: package: org.bukkit.event.player, class: PlayerInteractEvent
I'm developing a Boss Bar Api for my use and I'm having a problem!
And every time I use it it doesn't work perfectly!
That's what happens!
Whats the method in that to get the click type
Does anyone have a better experience?
If you got a boss bar in the map then simply dont create a new one...
Yes! But I put a check on her not to do that.
Oh is it InventoryClickEvent?
This event doesnt have click types. Only actions.
to get the Item he's interacting with or get if the Item is in the offhand?
More continues to create a new one.
Nope. You create a new boss bar regardles.
No I just wanna detect whenever F is clicked
Then cancel any default action (if there's any), then do something
You can not detect a specific key press, only if its bound to somethign that has a server reaction
There is some event that triggers when the hands are swapped. Listen for that.
Yes there is but not for any few
Key*
Which?
Lemme search
if(player.hasPermission("astreans.world.") + target.getWorld().getName());
There is an error on this line, where did I go wrong?
Does this trigger even when the slot is empty?
I can't find anywhere where EntityBlockFormEvent gets called
btw
Player target = Bukkit.getPlayerExact(args[0]);
Because in ClickType there's an enum for that click
if(player.hasPermission("astreans.world.") + target.getWorld().getName()); -> if(player.hasPermission("astreans.world." + target.getWorld().getName()));
Wouldnt happen if you created more variables instead of stacking method calls like that.
oh, i might just found it
True, however that would just make my code longer
it is in the nms
longer = better
anyone know?
slower
lmfao
If the event gets fired even when the hand is empty
its compiled all the same my dude
longer = more readable. else you may as well strip all whitespace.
good job, now its 2 lines shorter and doesnt even work
Add a sysout right over the line where you create the BossBar and inside your if body. You will see that you create a BossBar regardless of the condition.
Can you explain to me in the written part?
No idea what that sentence means. Sry...
How do I see what version a feature in the API was added?
use search featurette
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Can you explain to me in writing?
in writing? as in pen n paper? xD
Add a stdout or log in line 40 and one in line 30.
Then you will see that the createBossBar method is called regardless of the condition above it.
Can you give me an exampleCan you give me an example?
System.out.println("Bossbar exists already.") in line 30
System.out.println("Bossbar is created.") in line 40
Or get your logger from you JavaPlugin and call info()
I'm so sad. it seems impossible to get any Hangable to stick on a floating point location, it needs a BlockPosition.
Tried using packets, but I wasn't successful.
Do you guys think there is a way to get an itemframe to take any position ?
My gut feeling says no.
Ok so the condition is never met even when using the same name?
That!
i'm making animated image2maps;
in a MapRenderer, i'm currently doing mapcanvas.drawImage(imageFrame) for every frame of a gif; ain't there a more optimised way? so existing pixels don't get redrawn?
That doesnt add up with your code. Are you using only one single instance of your BossBarAPI class?
How can I go about dismounting a rider from a saddled pig?
I am!
i've attempted using #eject() but does nothing
Alexis I don't think so. The most you can do is using a packet to only update a rectangle in the map.
Then the toCheck method should be true the second time. Do the id Strings match up? What happens if you add the same bar 3 times.
Who do you call eject on?
how do you mean
ah
but like, wouldn't it be interesting to store in memory all the changes that need to be applied from a frame to another? so like a hashlist containing the (x,y) coordinatess of the pixel and its associated color index?
so i only change through setPixel what needs to be changed
and not the whole picture
I would actually just cache the packets from 1 to N and then just send them repeatedly instead of rendering the map again each time.
i don't have protocollib
You don't need protocolib
so u mean caching the canvas?
if that was true, wouldn't spigot be slow then?
like significantly
oh I can imagine spring also
I mean caching the actual packet. Spigot actually never re-renders the map. You just send a packet to the client telling him that the map is supposedly rendered with the sent data.
So its a really light task on Spigot because its just sending a packet each tick.
This brings me to an idea...
how do i handle packets tho?
i never did that before
i thought this was protocollib
((CraftPlayer) player).getHandle().playerConnection.networkManager.sendPacket(new PacketPlayOutMap(yourMapId, 4, false, true, new ArrayList<>(), yourByteArray,0,0,128,128));```
This line can send a map update packet to a given player
oh
"yourByteArray" being a byte[], with every byte représenting a color from MapPalette
You could actually make a working internet browser using maps and a selenium docker that creates several screenshots each second which are then send via the map.
All i need to figure out is how to input data to the browser...
and like, how do i convert BufferedImage to a byte[]
i saw a static method of MapPalette.imageToBytes but its deprecated
It's marked as deprecated cause it uses 'Magic Values'. All the colors in MapPalette are magic values too
so i shall not care of this depreciation?
I take note of it, but that's all. It's like NMS, you will have to do a quick check at every minecraft update.
deprecated means fuck all in spigot
aha
at this point im pretty sure they deprecate things because the warning looks pretty...
Yup. Minecraft use a weird indexed color map, and all its uses are marked as 'deprecated, magic values'. But we have no other ways x)
does that suffice to update a map for a player? or does the map need to be rendered at least once with a MapRenderer or something?
Also, is it okay if the player does't have it in hand, but somewhere else in inventory, or in somehwere in a chest, or in item frame? Important is that we provide the correct map id, right?
i see
After a long time I noticed that it was just that!
No need. You can even create a fake itemframe with a map using a 'SpawnEntity' packet, then give it a render using 'EntityMetadata'. You just have to have matching map id.
I'm very used to this theme
That theme burns my eyes 😦
use intellij lol
not you
wrong pers
np np x)
use intellij lol @floral kindle
I'm using Eclipse with white theme too x)
do yall wanna see something really hazardous
I use Eclipse with InteliJ theme 🙂
@sturdy patrol thanks a lot for your help!!!
i think that updating packets like this will make it infinitly faster 😛
Np alexis ^^ I've been working on something similar for a few weeks, so I got to read some documentation ahah
haha i see 🙂 bonne nuit buddy; i spotted ur "é" 😉
ahah bonne nuit à toi aussi good night to you ^^
languages
wtf
you successfully exploded my eyes
yw
Now I'm taking onto myself not to send gifs about the discord white theme flashbang x)
when I use blockchange packet, and the player right clicks the fake block and it updates again it heavily lags the client
any idea why?
are you doing anything in the interact event?
no interact event, just when the client realizes it doesn't exist
i dont know if this has to do with spigot but im making a custom crafting recipe and i dont understand how to make it enchanted
oh i forgot to say im really bad at coding ;-;
No real idea. As a quickfix, I would try intercepting the interact packet, and send back a block break to the player so that it doesn't have to do a weird resync with the server. No idea if it would work though. And no idea why you get this weird lag to begin with xD
like you create custom recipes like this, you can enchant it (say I was making the greatsword)
ItemStack greatsword = new ItemStack(Material.DIAMOND_SWORD);
ItemMeta greatswordMeta = greatsword.getItemMeta();
greatswordMeta.setDisplayName(ChatColor.RESET + "Greatsword");
greatswordMeta.spigot().setUnbreakable(true);
greatswordMeta.addEnchantment(Enchantment.ALL_DAMAGE, 1);
greatsword.setItemMeta(greatswordMeta);
ShapedRecipe diamondSword1 = new ShapedRecipe(greatsword);
diamondSword1.shape("**B","**B","**S");
diamondSword1.setIngredient('B', Material.DIAMOND_BLOCK);
diamondSword1.setIngredient('S', Material.STICK);
Bukkit.getServer().addRecipe(diamondSword1);
idk if thats right for your version though, adding enchantments is weird between 1.8-1.16
wait i dont think ym thing is related to spigot
i found a tutorial with json files
sorry
Is it a data pack
which is diff
yes
soryr
That also works for doing stuff
I dont think you can enchant them unless you had your own mod
Anyone know a good way to add a prefix to a players name in the tab list and in their name tag but not in chat, honestly I couldn’t find a clear way to do it in general so any help is nice
They do but I would prefer to do this without using teams
uhh
you could do it with gameprofiles + nms but thats a really bad idea
whats wrong with teams?
I still want to have players able to join other teams
oh
anyone know what packet goes through when a player left/right clicks a block?
This is a list of packets so it’s probably in here somewhere https://wiki.vg/Protocol
Why do you need them? Arent the spigot events enough?
sPeEd
Hey , I'm currently trying to deactivate collisions between my players. Using player.setCollideable(false) or p.spigot().setCollidesWithEntities(false) do not work.
Any idea?
try using scoreboards
I tried with ingame scoreboards and collideRule do not work :/
Ferskfisk nice name
ty
🇩🇰?
Do someone have code to share with scoreboards disabling collisions maybe?
🇳🇴 😉
you wish
It’s true tho
would be easier to help if you share the code you have so far
Mhh no code for now using scoreboards in a plugin
I used teams ingame and setCollideable in plugin
Both don't work
cap
Any way to make a new config?
any give me an example that an Attribute would be used for when adding to Items?
@cursive glen https://www.spigotmc.org/wiki/creating-a-config-file/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
like there's a method to add attributes, but what are they exactly good for
Damage, attack speed, knockback resistance, max health, etc
yes
yeah but does it give damage, attack spped, knockback resistance, max health to the player when they hold the item or something?
You can specify which
cause i was going through the package overview but wasn't sure what i was looking at xD
Yes
The two test folders that comes with Maven, do I need them or can I delete them?
test folders?
src/test/main and src/test/resources i belive
quick question guys... if i /stop my server, do players get kicked before or after my plugin's onDisable()? :I eg. do i need to call player cleanup code from onDisable() or can i just rely on player quit event?
Plugins are disabled then players are kicked. I would add cleanup code on disable
edit: with a quick google search you’ll find your answer as I just did
ah 😄 i did find lol ty, guess i used wrong keywords 1st time
in any case you'd want to save onDisable because of /reload or unloading the plugin
Reload isn’t really supported or recommended
But it was meant to be at first, and you should design around it properly if possible
How do i make a config for a plugin in bungeecord
is ConfigurationSection#getKeys mutable?
yes maam
I don't understand. What do I need to do?
you should really change the package.
Can someone send link for tab plugin please
Ok
Hello discord! 1. what is name of farm sweet barry? (Right click on sweetbarry) 2. How do I know if it's the bottom or not when I dig up bamboo or churros?
chrous
Oooh Chorus fruit
oh thanks!
hey so I was trying to make like a bossbar that is constantly going down then like refilling and I tried this but it just goes down instantly even when I set the delay to a whole second
BossBar bar = Bukkit.createBossBar(ChatColor.BLUE + "" + ChatColor.BOLD + "play.electricraft.net", BarColor.BLUE, BarStyle.SOLID);
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
bar.addPlayer(e.getPlayer());
Bukkit.getScheduler().scheduleAsyncRepeatingTask(main, new Runnable() {
public void run() {
for(int i = 0; i < 10; i++) {
bar.setProgress(i / 10);
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
bar.setProgress(1.0);
}
}, 10L, 10L);
}
it's don't exists on 1.15.2
y u no use 1.16
yes but you can use the PlayerInteractEvent to recreate that I think
happy to help
Hey spigot discord! How do I know if it's the bottom or not when I dig up bamboo or churrus?
your first move is 0/10
?
nvm, my brain isn't working on maths
oh wait it doesn't go down now
wait wait wait, i think my brain is generally not working right now
starting at 0 was totally fine.
bar.setProgress(1.0); you won't need that, cause your 10/10 is already doing this for you
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
``` don't do that. you will sleep the main thread for a whole second which will cause a lag.
ok do you have a better solution?
if you want to have it delayed you could use an index-integer
now it goes down (ignoring the delay) and stops there
maybe because your scheduler isn't coming far
In intellij if I go to Editor -> Code Style -> Java, and I change the code in the example it will be automatically set back
So I can't use a custom code style
wdym?
I set it to repeat
@quaint mantle You can look for an alternative in the javadocs btw ;P
https://hub.spigotmc.org/javadocs/bukkit/
package index
double index = 0.0;
on..(yeah.. argument goes brrr) {
scheduler {
if(index != 1.0) {
index+=0.1;
} else {
index = 0.0;
}
bar.setProgress(index);
}, 20L, 20L);
}
let me try that
oh, answered on your wrong message.
anyways: your scheduler now is sleeping the main thread ever half a second for a second 10 times
You can just cancel the event when it hits 1.0
he want to have a repeating task. and cancelling the joinevent 🤔
Local variable index defined in an enclosing scope must be final or effectively final
ohh wait, join event. yeah, you shouldn't start a new scheduler everytime a player joins btw
scheduler lol
it doesn't have to be on join I just want to have a bossbar that is like constantly going down
So right now you have a The join event and when a player joins the server they get a boss bar that is constantly going down correct?
with this code it goes up. but he can just invert it
^ that should work
PlayerDropItemEvent
How can I immediately remove the dropped item? Just despawn, I don't want to cancel because then they get the item in the inventory back
get the drop item with the get drop item method and then do what ever you want with it
Ok, but I can't find a method .despawn()
#remove()
how do i download spigot 1.8.8?
you could use BuildTools (https://www.spigotmc.org/wiki/buildtools/) or just google some url like (get bukkit)
yeah xd happened to me twice septicuss
it is dumb xd
tbh it is
yw
I am making a plugin but i get this error in console how do i fix it?
Could not load 'plugins\helloworld.jar' in folder 'plugins'
If I run this task async nothings happens, if I run this task with "runTask", also nothings happens and the server will crash. What I want is displaying the border of a region
anyone who knows anything about dns/domain stuff please friend me i need help diagnosing and solving an issue with my server and domain, it's urgent!!! please friend me!
I know things about domains
you should use ?paste btw
Yes
and the error below?
?paste
@maiden briar
runTask crashes your server because your while loops and the Thread#sleep sleeps the main thread.
runTaskAsync will not work in combination with the bukkit/spigot api.
you could execute code sync in your async scheduler with #runTask. for example:
//async
while(myBooleanIsTrue) {
Bukkit.getScheduler().runTask(() -> {
//sync
});
//async
}
but in your case you don't need a sleep, neither a while loop nor an async task
Guys, I need help but I would prefer not to send that code here out of respect for my friend who asked me to do it, who can help me write to me privately.
pls
whats the issue?
Well, I did a parse time to make a bossbar with the date but .. the time every now and then is 11-12-13-15-16 ..
Write to me privately for code-snippets
🤔 i would need the code to look over, just sent it to me in private
this worked thanks
a bit of a delay but thanks
So i'm rlly confused, I have an uuid and just use Bukkit#getPlayer to make it a player, but somehow the player is null?
List<String> list = plugin.points.getConfig().getStringList("PlayerDataBase");
Bukkit.broadcastMessage(String.valueOf(list.size()));
for (int i = 0; i < list.size(); i++) {
Bukkit.broadcastMessage(list.get(i));
Player player = Bukkit.getPlayer(list.get(i));
if (player != null) {
// other code
}
What am I missing?
how on earth is this causing an error?
List<String> barText = new ArrayList<>();
barText.add("play.electricraft.net");
``` this is basic Java
Bukkit#getPlayer() returns null if the player is not online if im not wrong
The player is online :/
But I guess i'm not completely crazy I guess
will look into it again later
anyone?
what is the error?
Syntax error on token ".", @ expected after this token
Could you give the full method? You should also trace back all your backets to your corresponding closing brackets
I am not inside any method
So you are within a class?
Then put the barText.add line in either the constructor, or static init block
how would i make something that equips zombies with random armour pieces eg, diamond boots with a diamond chestplate, leather pants, etc?
Cast the entity to zombie, it should have an inventory method that you can make use
okay
also how would i get something like hypixel so players can only break player placed blocks because i dont want my map to be broken
or alternatively keep a log of all non-player placed blocks
thanks lmb
how can I spawn something but 1 block in front of the player?
I could use setX or setZ but it will spawn in front o in left or right
idk if I should use Vectors (and how)
you could just check wheres he s facing and then do if to x or z
When exactly do event listeners catch subclasses of the specified event? E.g. a PlayerMoveEvent seems to catch a subclass of PlayerMoveEvent I defined myself, but not PlayerTeleportEvent which is also a subclass of PlayerMoveEvent.
when its that type, it'll be an instance of PlayerTeleportEvent when the player teleports
then why does my PlayerMoveEvent listener also listen to my subclass of PlayerMoveEvent?
wdym
I have a subclass of PlayerMoveEvent, but when I send it, my PlayerMoveEvent listener receives it too, presumably because it's a subclass
but that doesn't happen for PlayerTeleportEvent, even though it's a subclass too
so I don't get the difference
you didnt add an independent HandlerList
ohhh, that makes sense, thank you!
I want to program a GUI with Custom Heads in 1.16.4 only the problem is how can I use the textures from texture.minecraft.com?
I would like to include the following texture: http://textures.minecraft.net/texture/4ef356ad2aa7b1678aecb88290e5fa5a3427e5e456ff42fb515690c67517b8
When do you use "==" and when ".equals()"?
== when you want to match the exact instance and .equals when you want to check if the value is the same
Iirc
== is mostly for primitives and enums
Hey guys, did someone already worked with animated frames ?
Cause there is a kinda strange problem
Even if the chunk is kept load
The animations when teleporting on an other world just stop working
@EventHandler (priority = EventPriority.HIGHEST)
public void on(PlayerChatTabCompleteEvent e) {
if(!e.getChatMessage().startsWith("/")) {
e.getTabCompletions().clear();
return;
}
if (e.getChatMessage().startsWith("/")) {
e.getTabCompletions().clear();
e.getTabCompletions().addAll(Arrays.asList("command1", "command2", "command3"));
}
System.out.println("USED COMMAND....");
}
I dont know why is this not working?, if i remove the if e.getchatmessagesstartswith /, then i type in the chat 7 <- in the chat an then press the tab then the "Commands" will display...
anybody can help ?
not working
im on 1.8
@unreal quartz
String msg = e.getChatMessage();
List<String> items = Bukkit.getServer().getCommandAliases().tabComplete(e.getPlayer(), msg.substring(1));
(this is only a test)
well that event isn't called for tab completing commands
the only event I see is the one I sent, but you're not on the latest version so I don't know what to tell you
sure, but i still can use if i tye in the chat a int 1-9, then press tab then i get the "Commands"...
withaout the e.getchatmessagestartwith/
My plugin has a problem and it can't be enabled error:
[14:42:00 ERROR]: Could not load 'plugins\houseflipper.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
@EventHandler (priority = EventPriority.HIGHEST)
public void on(PlayerChatTabCompleteEvent e) {
if(!e.getChatMessage().startsWith("/")) {
e.getTabCompletions().clear();
return;
}
if (e.getChatMessage().startsWith("/")) {
e.getTabCompletions().clear();
e.getTabCompletions().addAll(Arrays.asList("spawn", "kit", "test123123"));
}
System.out.println("USED COMMAND....");
}
Invalid plugin.yml
send that
Invalid plugin.yml
name: discord
version: 1.0
main: me.zeprix.house.Main
commands:
discord:
description: Discord invite link!
try this
name: discord
version: 1.0
main: me.zeprix.house.Main
commands:
discord:
description: Discord invite link!
and your main class is me.zeprix.house.Main?
yeah\
and the plugin.yml is packaged with the jar
yess
name: discord
version: 1.0
main: me.zeprix.house.Main
commands:
discord:
description: Discord invite link!
. :c
author is not required as i know
you sure?
its in me.zeprix.house package
in src?
yes as long as when the jar is packaged the plugin.yml ends up in the base directory
@lost matrix did you have an idea what i can do?,
@EventHandler (priority = EventPriority.HIGHEST)
public void on(PlayerChatTabCompleteEvent e) {
if(!e.getChatMessage().startsWith("/")) {
e.getTabCompletions().clear();
return;
}
if (e.getChatMessage().startsWith("/")) {
e.getTabCompletions().clear();
e.getTabCompletions().addAll(Arrays.asList("spawn", "kit", "test123123"));
}
System.out.println("USED COMMAND....");
}
I've created a new project.
The following code also did not work.
DebugProject.java
package dp.debugproject;
import org.bukkit.plugin.java.JavaPlugin;
import sun.security.util.Debug;
public final class DebugProject extends JavaPlugin {
@Override
public void onEnable() {
getCommand("").setExecutor(new DebugCommand());
}
@Override
public void onDisable() {
}
}
DebugCommand.java
package dp.debugproject;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class DebugCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String Prefix = args[0];
if (Prefix.equalsIgnoreCase("debugcommand"))
{
sender.sendMessage("Command Detected");
}
return true;
}
}
plugin.yml
main: dp.debugproject.DebugProject
name: DebugProject
version: 1.0
commands:
debugcommand:
description: DebugCommand
GroupID DP
ArtifactID debugproject
Error ↓
getCommand("").setExecutor(new DebugCommand());
that will always return null
you want to do getCommand("debugcommand") instead, how it is defined in your plugin.yml
@lethal field try this, getCommand("debugcommand").setExecutor(new DebugCommand());
Fix: getCommand("debugcommand").setExecutor(new DebugCommand());
🙂
Nobody is perfect
@unreal quartz Here is screenshot but still doesnt work https://ibb.co/mF6Rkpq
[20:56:45 ERROR]: Error occurred while enabling DebugProject v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "dp.debugproject.DebugProject.getCommand(String)" is null
at dp.debugproject.DebugProject.onEnable(DebugProject.java:10) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at java.lang.Thread.run(Thread.java:832) [?:?]
🤔
you sure that is in the base dir?
fix
@Override
public void onEnable() {
getCommand("debugcommand").setExecutor(new DebugCommand());
}
dont work
then where is base if not in src
Make sure debugcommand is in your plugin.yml
the plugin.yml should be in the base dir when you unzip the jar
main: dp.debugproject.DebugProject
name: DebugProject
version: 1.0
commands:
debugcommand:
description: DebugCommand
this?
wait
you mean the House Flipper folder?
no I mean your jar
public final class DebugProject extends JavaPlugin {
remove the final
how to unzip?
and try again
like any other zip
😢 I don't know. What the hell is going on?
i dont have winrar
you don't need winwar
@lethal field remove the final in your debugproject, to this : public class DebugProject extends JavaPlugin {
then try out
is there any way to create an event for when someone reels in a fishing rod on 1.8.8?
PlayerFishEvent
package dp.debugproject;
import org.bukkit.plugin.java.JavaPlugin;
import sun.security.util.Debug;
public class DebugProject extends JavaPlugin {
@Override
public void onEnable() {
getCommand("debugcommand").setExecutor(new DebugCommand());
}
@Override
public void onDisable() {
}
}
Is that okay?
sure try out
i dont know how to extract bruh
dont work
[21:03:42 ERROR]: Error occurred while enabling DebugProject v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "dp.debugproject.DebugProject.getCommand(String)" is null
at dp.debugproject.DebugProject.onEnable(DebugProject.java:10) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at java.lang.Thread.run(Thread.java:832) [?:?]
I'm not getting reel in on 1.8.8
there is no button extract all like in zip files
getCommand("debugcommand").setExecutor((CommandExecutor) new DebugCommand());
then try this
I don't know what to tell you if you can't unzip a file...
package dp.debugproject;
import org.bukkit.command.CommandExecutor;
import org.bukkit.plugin.java.JavaPlugin;
public class DebugProject extends JavaPlugin {
@Override
public void onEnable() {
getCommand("debugcommand").setExecutor((CommandExecutor) new DebugCommand());
}
@Override
public void onDisable() {
}
}
I got the same error.
Bruh look https://ibb.co/7ktQSMN
open with file explorer or download 7zip or something
@lethal field
name: DebugProject
version: 1.0
main: dp.debugproject.DebugProject
commands:
debugcommand:
idk try this?
I got the same error😢😢😢
@latent vale download this: https://www.winrar.de/downld.php
Mad sus
so what is wrong? https://ibb.co/sRtBF0f
there is no plugin.yml, and your sources aren't even there
zeprix you ever tried gradle?
export what?
yeah thats how you make a JAR File from ur code
as jar or runnable or javadoc?
jar
i think the place to select your sources is on the next page
then?
I always spam enter after clicking jar file
untick project and classpath
you don't need .classpath, .project, you should find the src folder on the left
oof ive been doing it wrong
the left is correct
like that?
good that I switched over to IJ like half a year ago
well as long as your sources are there then it's not really wrong
yeah but selected too much
ugly
nah right top @latent vale
@unreal quartz
untick project and classpath on the right
i don't use eclipse
ugly?
still do i need to export src only?
once you have unticked .project and .classpath on the right, click finish
idc if u use intelj
idea ultimate is pretty good ide
Should I have mentioned that I am using "inteleji"?
. if you listen to this guy, he is telling you how @latent vale
oh thx
@empty oyster Please support😭
Your command in your plugin.yml needs at least one child entry to be a valid command. Add a description or usage node.
not rly
Yes really. Just the command is a null ConfigurationSection
Is that okay?
commands:
debugcommand:
description: DebugCMD
usage: debugcommand
perfect
Actually it does work without a child node
with no child node it shoudl return null as not valid
it will check as valid Yaml but Spigot will return a null when read as a command
That’s the thing, it doesn’t use the normal file config system probably allowing it to parse that without any child nodes
I@m going to guess you are using a Fork of Spigot
ij 100x better
nah
ok I'm going to test this. Its always returned null for me with no childs and it was md_5's response to it too
your point being?
What do you want me to do?
you need to pass "this" as a second argument
in the executor
Give me the code, please.
In Listener yes. But not in Executor lol
how can I add comments to my config files?
getCommand("debugcommand").setExecutor(new DebugCommand(), this);
``` 🥄
error
'setExecutor(org.bukkit.command.CommandExecutor)' in 'org.bukkit.command.PluginCommand' cannot be applied to '(dp.debugproject.DebugCommand, dp.debugproject.DebugProject)'
comment
is this your main class?
but it only supports headers
yes
cuz it needs the main class
although wait
thats how you register an event
setExecutor should take a Plugin argument
¯_(ツ)_/¯
I think at least
Hello, I have a quick question.
I'm currently working on plugin that changes your leather armor color every x seconds / ticks. Currently everything works perfectly fine until I set the time to be below 1 second.
When I do that the following happens (we have two players, p1 and p2 and colorChangeTime = 0.5s):
p1 can see that the armor of p2 changes every 0.5 seconds, however p1 can see that his own armor change every second
p1 can see that the armor of p1 changes every 0.5 seconds, however p2 can see that his own armor change every second
Also it's worth noting that when for example p1 can see his own color change every second (instead of every 0.5s), certain colors may get skipped, as if the server wants to change them, but the client doesn't update the colors as fast.
Here is the part of the code that handles changing of the color. It executes on all players at once, so there should be no reason that player's character would be changing slower.
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
int newIndex = colorOrder.indexOf(playerArmor.get(player)) + 1;
if (newIndex == colorOrder.size()) newIndex = 0;
GiveArmor(player, colorOrder.get(newIndex));
}
}, 0L, (long) (20L * colorChangeTime));
Currently the only thing that would make sense to me is that the refresh rate for your own character is set somewhere in the client, that's why other players update normally and your own character doesn't. However I wanted to confirm my theory here.
Thank you for any help in advance 😄
well how do you cahnge the armour color
@quaint mantle @ivory sleet I'm wrong it seems. A single command works correctly without child nodes.
ye : )
It's in the GiveArmor function. It essentially just creates the itemstack and assigns it the given color.
But as I said, it works completely fine until you set time below one second. And even when it's below one second you can see that everyone else changes color when they should, except for your own player, which always changes at lowest rate of one second.
However here is the code for changing armor color:
private void GiveArmor(Player player, String color) {
playerArmor.put(player, color);
for (int i=36; i<39; i++) {
ItemStack item = new ItemStack(Material.valueOf(armor[i-36]));
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
meta.setColor(Color.fromRGB(LPVP_Colors.getValue(color)));
item.setItemMeta(meta);
item.addEnchantment(Enchantment.DURABILITY, 3);
item.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, armorProtectionLevel);
player.getInventory().setItem(i, item);
}
}
I don't know anything. 😭
Give me the code.
package dp.debugproject;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
public class DebugProject extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getCommand("debugcommand").setExecutor(new DebugCommand());
Bukkit.getServer().getPluginManager().registerEvents(this, this);
}
@Override
public void onDisable() {
}
}
Hi, can someone explain me why the color of the team prefix is not set to the player name?
you might want to look into gaining some Java experience before starting with spigot, I would suggest this:
https://www.amazon.com/Java-Beginners-Hands-Project-Project-ebook/dp/B01LZOCVN9/ref=sr_1_3?dchild=1&keywords=Java&qid=1617627071&s=digital-text&sr=1-3
oh
because the color is applied to the prefix, not the name
also great
in the old versions the color of the name has also been adapted. how can i now set the color for the name
you can create a nickname system then loop through all players and setting their nickname to the color + the name
Any Ideas why this still outputs uncolored text? sender.sendMessage("World created sucessfully!" + ChatColor.GREEN)
ChatColor is before the text
if i set the Name with setDisplayName the prefix will disappear
You could always do a really weird thing and cancel the message event, and resend a custom message woth the prefix and display name, then you could do textcomponent bs with it too
i dont get it
messages are not my problem, its only the name above the player and in the playerlist
ok i'm just stupid, could have simply set a color for the team with setColor. thx anyway
hey how do i disable collide in spigot 1.12.2? my code:
if (p.getScoreboard() != null) {
Scoreboard sb = p.getScoreboard();
if (sb.getEntryTeam(p.getName()) != null)
sb.getEntryTeam(p.getName()).setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
}
https://sourceb.in/ytYSBI3BTt - so I have this huge piece of code, and if I click either one of the slots it sends "test" twice
same with the no perm msg
Fun fact, you technically don't
Only way is to use teams flags
yeah but it doesnt work
Yeah because mc is shit
It never worked properly
oh
Implement a proper tab completer. Dont use this event for completions for your own commands.
okay ty
worldedit has a discord and an api help channel
but they're also hella pretentious
for example, wizjany's answer to your question there is next to useless:
WG doesn't track that, you'll either need to track it yourself or check when you need it
you were most likely asking about getting the edges to then be able to calculate if the location is between them, and just need to figure out through their overcomplicated api how to get the corners of a region
Hello,
i search an good command framework for easier create command.
I have see ACF and i want know if it is advanced and stable enough for production usage. If is NOT want i can use ?
hi, i once say a while ago String... i think i was, so you could move multiple strings using "test,"test1" for lore, for example but i cant remember what it is
how its called
the ...
or ...String something like that
nvm i found it it was String... lore
This is null anyone know why? this.getCommand("alerts").setExecutor(new Alerts());
you havent put the command in your plugin yml @timber crescent
Hello Everyone, I just started my own server and I need help with building a plugin. I have 0 experiences with building plugins, could anybody help me developing 1? I would really appreciate it!! DM me
I'd suggest learning the basics of Java first
From there just look for tutorials on yt and resources on spigot
But It's a pretty big plugin
?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/
Show some code pls
that are probably floats or doubles and you are displaying ints
public static TownReturn isClaimed(ClaimData data){
TownReturn townReturn = new TownReturn();
if (claims.containsKey(data)){
townReturn.name = claims.get(data).town;
townReturn.intown = true;
}else{
for (Map.Entry<ClaimData, Claim> I :claims.entrySet()){
Bukkit.getLogger().info(String.valueOf(I.getKey().X)+","+String.valueOf(I.getKey().Z));
Bukkit.getLogger().info(String.valueOf(data.X)+","+String.valueOf(data.Z));
}
townReturn.intown = false;
}
return townReturn;
}
Pls use code blocks
ok
Some code
public static TownReturn isClaimed(ClaimData data){
TownReturn townReturn = new TownReturn();
if (claims.containsKey(data)){
townReturn.name = claims.get(data).town;
townReturn.intown = true;
}else{
for (Map.Entry<ClaimData, Claim> I :claims.entrySet()){
Bukkit.getLogger().info(String.valueOf(I.getKey().X)+","+String.valueOf(I.getKey().Z));
Bukkit.getLogger().info(String.valueOf(data.X)+","+String.valueOf(data.Z));
}
townReturn.intown = false;
}
return townReturn;
}
Did you properly implement the equals and hashCode methods in your ClaimData class?
wdym
package thyclaims.thyclaims.obj;
public class ClaimData {
public int X;
public int Z;
}
that is the class
i am still new to java
hello i just come to ask you how i could make a plugin with special texture mobs please ^^
optifine texture pack or armourstands and heads
as far as ik
Or use player models with custom skins
If you use hash based collections like HashMaps and HashSets then the key will be stored using their hash code which is just an integer.
Not really possible without some tricks. Only by using a resourcepack and optifine.
how can i fix this
Do you plan on adding more fields to your "ClaimData" class?
do you have a tutorial to do it?
I am trying to make a page system for a leveling GUI. The system is set up so that whatever level a player is set to is the level they are currently working on. There are 29 levels per page. I want to make it so, let's say the player's level value is 10. Their page is set to 1. If they are level 29, their page is still 1 because they are working on level 29. How do I code this? I am trying Math.floorDiv(lv, 29);, but as you can probably expect, if a player's level value is 29 it will send them to page 2 which shouldn't happen. How do I fix this?
lv-1
Ok so its more of a ClaimCoordinate than actual ClaimData. @torn jewel
This would be a proper implementation of that data class:
public class ClaimCoordinate {
private final int x;
private final int z;
public ClaimCoordinate(final int x, final int z) {
this.x = x;
this.z = z;
}
public int getX() {
return this.x;
}
public int getZ() {
return this.z;
}
@Override
public int hashCode() {
return Objects.hash(this.x, this.z);
}
@Override
public boolean equals(final Object other) {
if (!(other instanceof ClaimCoordinate)) {
return false;
}
final ClaimCoordinate otherCoord = (ClaimCoordinate) other;
return this.x == otherCoord.x && this.z == otherCoord.z;
}
}
Can anyone help me with this?
Quick fix: add 1 to the upper bound
so... 30 instead of 29?
Yes
You want the page index to start at 0 or at 1?
1, but that's easy because I can just add 1 to it
0 is the default value passed through the message if you don't want a custom page number
So then just
public int getPageFor(int level) {
return Math.floorDiv(level - 1, 29) + 1;
}
ok
oh rip
My mistake was where i thought the level might somehow be zero
that's why I was avoiding that
ty!
What about it doesn’t work
Does anyone know if I can make a server with a world without any interactions(your stuck in one place, cant move, no chunks)? Because i'm planning on making a queue server for if my main server is full(where people will wait till some-one leaves the main server). So I want the queue server to use the least resources possible(otherwise it defeat the purpose of a queue server and I would be better off making the player cap higher)
How can I lock the note blocks so that no matter what block they stand on, they keep their instrument
i dont get the craft
if i change the ingredient to recipe.setIngredient('%', Material.EMERALD_BLOCK);
then it works
but idk why the custom emeral block doesnt work
Use RecipeChoice.ExactChoice
i would write it in nodejs (using the minecraft networking library)
theres also pistonqueue for spigot n waterfall etc if you wanna do it that way
Okay I have a quick question.
How does BungeeCord use BungeeCord for custom payload packets?? From my understanding it's not a valid channel name. Someone with knowledge about this please explain, thanks! (ping me)
why when i try to run this code it will not remove the dropped item, but instead duplicate it and give the player the STAINED_GLASS_PANE afterwards?
@EventHandler
public void onUseOfSyringe(PlayerDropItemEvent e) {
Player player = e.getPlayer();
if (player.isSneaking()) {
e.setCancelled(true);
player.setItemInHand(null);
player.setItemInHand(new ItemStack(Material.STAINED_GLASS_PANE));
}
}
wdym
that will make the item desapear
player.setItemInHand(new ItemStack(Material.STAINED_GLASS_PANE));
and this will set the item back to stained glass pane
if you are trying to cancel the drop event
then just use e.setCancel(true)
that will prevent the drop
e.setCancel(true) is not a valid expression
but no i don't want to just cancel the drop
setCancelled
e.setCancelled(true);
but when i try to do it, the item that should be removed just gets duplicated
i do cancel the event my stupid ass just forgot to copy it from the code when i send the snippet
remember Bloodmoon?