#help-development
1 messages · Page 1345 of 1
hm, I'll try again
How?
how should I make damage dealt from this fall damage cancell out but no other fall damage?
dont need to
they will launch on right click
so you launch them randomly or what
How to
@lost matrix pinging cos no one else helping
anyone?
@quaint mantle can you help?
bruh
can someone help me
god damn how do i addStorageEnchantment to item 😂
did it lol forgot to
NewItem.setItemMeta(NewItemMeta);
NewItem.setItemMeta(NewEnMeta);
Use camelCasing 
hello?
So you want to cancel fall damage and subtract mana if a player holds this specific item and has enough mana?
hi
Or is it some kind of leap after which the player should not take fall damage. Because this is a bit more complex.
kind of a leap
I am trying to make the itemmeta change when you shiftrightclick but nothing happends
abillity also changes when meta changes
any idea why nothing happends?
@lost matrix
thread for check if player is shifting? 🤔
wait there probably a check for hold shift nvm (ignore me)
meaning?
The very first thing you should do is listen to your IDE.
It tells you that comparing Strings with == is very bad and will not work in 99% of cases.
Then you need to re-structure your code. This whole lore tinkering needs to be in its own method or even its own class.
If you split your code in a lot of small method then it gets way more readable and flexible.
Now to your problem:
Preventing fall damage after a leap is hard because the player wont always take fall damage after he has lept.
So on leap you should tag him. (A Set<UUID> should be enough) and then remove the tag some seconds later.
Then you check the EntityDamageEvent. If its of type fall damage and the user is tagged then remove the tag and cancel the event.
ok
God pls no. Player has the method isSneaking() for a reason ^^
soo why doesnt lore change work though?
did you remeber to do Item.setMeta()?
You are changing the meta of the item thats being held by your ItemManager. Why?
so I have a sword
which i make in my itemmanager
then when shiftrightclick, abilty changes
so i want lore to show that
i think you missed it 🤔
I have small problem
But the player is not holding this item so he wont see the change.
You need to change the ItemMeta of the ItemStack that is being held by the player.
How I can fix this?
For what version do you want to use ProtocolLib?
i dont know how to do that
The repo currently looks like this:
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.6.0-SNAPSHOT</version>
</dependency>
<repository>
<id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
player.getInventory().getItemInMainHand() for 1.13+
This is one of the basics for Spigot development. Did you create some simple plugins before jumping into a bigger project?
Okay I’ve never seen an error produced by SQLite drivers before, anyone know that cause of this is? It’s just one person in my discord said they’ve got this https://haste.olziedev.com/molupumicu.yaml
Btw your code looks a bit like a speedrun for violating every clean code principle.
yes
oh lol
should i just change item holdin
g
@oak mica
player.getInventory().getItemInMainHand() 1.9+
otherwise use
p.getInventory().getItemInHand();
You are passing a capacity thats out of bounds. Are you trying to construct an ArrayList or something with an initial capacity thats smaller than 0?
ok
Nope all I’m doing is executing a SELECT query that has worked for everyone apart from this one person
Is that the full stack trace?
well then they'll need to elaborate on what the hell is so special about their system
No
Hey, anyone here experience with mockito and maven?
Expecting Unit test expertise on the Spigot discord. lul
PreparedStatement ps = con.prepareStatement("SELECT * FROM playerwarps_warps WHERE name = ?"); that’s the code that it’s coming off of. Never really seen this issue ever before
Whats this line:
xyz.olzie.playerwarps.d.k.<init>(PlayerWarp.java:63)
I sent that line just now
Thats the constructor of some class.
That’s the line
have him send the db maybe there's something messed up in there
So is that a yes or no?
He said he can’t due to something?
Thats a "kind of" but im sadly out for today
use MockBukkit
You use that?
I told him to back it up and delete it with a fresh pne and still the same issue. But only he is having the issue and no one else has ever had this so 🤷♂️
I find this interesting
Its fine but the interfaces are not fully implemented. For most cases its fine but dont expect stable integration tests.
yeah
Well, just going to be straight forward. I needed to mock the PluginDescriptionFile class, but because I couldn't because the class is final. So after some research, I found out I could use mockito-inline and version 2+ and use Mockito.mockStatic()
Now the problem is , no matter what I try, no matter what version I use in maven, that Mockito.mockStatic() method simply doesn't exist
I've been trying for hours now to find the solution
cant really give you any pointers, best to just experiment or try mockbukkit 🤷
it works well for me, but that is me, they seem to have docs https://mockbukkit.readthedocs.io/en/latest/index.html
does anyone know why you can't edit the yaw of entities spawned through spigot?
what do you mean?
no matter what location I give it, it will always be facing with yaw = 0
ur doing something wrong then
can you show ur code
spawned using location.getWorld().spawnEntity(location, entityType);
new Location(Bukkit.getWorld("Lobby"), -30.5, 63, 2.5, -90, 0)
I tried editing through nms but that didnt seem to work either
totally lost rn
hmm
what I would recommend you trying
is get your own (player) location
try setting that
as the location
and see if the yaw is correct there
are u disabling the AI?
perhaps
that’s the issue
i’ve had it before, i can’t remember what i did to fix it, unfortunately
try teleporting after spawn
okay so it's either nice yaw or ai LOL
Use the spawn method with a Consumer<T> as third argument
I assume you're referring to the latest version? 😬
there is also the setPositionRotation if I'm not mistaken
I don't seem to have that method
if you’re not using latest version then you’re gonna have to play around with it
ah nvm, nms
teleport, nms, etc
yeah I have no problem dealing with nms, but nothing seemed to work there either
tried sending rotation packets, setting fields, etc
it’s definitely possible, i’ll try to find the project i had the same issue in
I noticed the pitch works fine though
Something like
public Zombie spawnZombie(final Location spawnLocation) {
return spawnLocation.getWorld().spawn(spawnLocation, Zombie.class, preSpawnedZombie -> {
preSpawnedZombie.setRotation(2F, 0);
});
}
Yeah unfortunately I don't have a method matching those parameters
What version are you on? The method exists since 1.12 or so
im on 1.8
Oh. Then you are on your own. That version is half a decade old and has some bugs that will never be fixed + lacks a ton of API methods.
google, google, google! https://www.spigotmc.org/threads/cant-change-spawning-direction-of-noai-villager-1-8.334946/
Support was dropped a long time ago+
I know I'm pretty much on my own, just thought I'd hear if anyone ever faced this problem working with 1.8 before
there's no reason for it to act the way it does even if it's an outdated version
didnt find it obvious to link the no ai to the problem but I'll give it a read
what would be the correct event for when a player is killed by a charged creeper explosion
PlayerDeathEvent has no getCause method?
you can get the last damage cause from the player
huh?
I thought getLastDamageCause was a method of PlayerDeathEvent
the above returns an event, which is the last damage event that the player took and if it was from a creeper then it will be an instance of EntityDamageByEntityEvent
ah
what is typeof in java?
instanceof
ok
is there a command that spawns a mob every few seconds automatically?
i know how to spawn a mob
nope
you sure?
use a scheduler
ok
assuming you're just talking about vanilla, then no
you could set up a simple script with command blocks
i think
idk I don't use em very often
alright thx
you could, but command blocks are iffy
^^
ill just try a scheduler then
if you can, you're better of writing a plugin and spawning one yourself rather than relying on commands and command blocks
There are those blocks called spawner which can be customised. Scheduling is also an option
How do I fix this? Cannot resolve method 'getConfig' in 'AntiSwear'
by making a getConfig method
alr im stuck
BukkitTask Listeners = new Listeners(plugin:this).runTaskTimer(plugin:this, delay:100L);
this is in the main.java
and this is in the listeners
Main plugin;
public Listeners(Main plugin) {
this.plugin = plugin;
}
the plugin in "Main" shows an error
what did i do wrong
i have no idea what plugin:this does
BukkitTask Listeners = new Listeners(this).runTaskTimer(this, 100L);
?
what do yall use to code in java?
like this?
ye
eclipse
intellij
intelli jay since 2 days ago .-.
it says i have to implement runTaskTimer on listeners...
im prettty sure it was inclusded in
scheduler.BukkitTask
@modest oar wut u tryna do?
make like a command that runs automatically every few secs
this is more opinion than anything
dafuq is intellij ultimate LOL no just get "IntelliJ IDEA"
oh u dont need a listener, just make a runnable
leme show u example
alr thanks
LOL
intellij idea ultimate
there is a community and ultimate edition for it
period = 20; // how many ticks in between after that
getServer().getScheduler().runTaskTimerAsynchronously(Plugin, new Runnable() {
@Override
public void run() {
// timer code goes here
}
}, delay, period);``` @modest oar somethin like this
damn lol i didnt even see the ultimate one ._.
this goes into the main
why the hell did you ping me of all people
well
from apps import *
app = App()
app.addwidget(Text('What is your name?'))
entry = EntryBox(var='name')
def onclick():
variables['name'].set('')
app.addwidget(entry)
app.addwidget(Button('Submit', onclick=onclick))
app.run()
i made this
pythan ❤️
its a lib for Tkinter
wuts tintker .-.
hi, is there anyway you can return the location of the block thats hit by a projectile with ProjectileHitEvent?
?jd
package index
declaration: package: org.bukkit.event.entity, class: ProjectileHitEvent
.getLocation()
ahh ty
Working with trying to get user input from a config file. I think Im using ConfigurationSection..
Example config input:
drops:
SomeDrop:
SomeKey: SomeValue
SomeOtherKey: SomeOtherValue
SomeOtherDrop:
SomeKey: SomeValue
SomeOtherKey: SomeOtherValue```
How can I access the names of `SomeDrop`
Oh so like SomeDrop would be a key of drops
yeah so once I obtain the Set of all of the input, I can access the keys/values as a map of each drop
Or are all of those also sections
they're all sections, however internally they are kept as maps
Perfect.
Finding it challenging to migrate from json to yaml but bukkit does make it easier
or spigot is responsible for this class it seems actually
you can see how your yaml translates to json here https://yaml-online-parser.appspot.com/
you can see they are effectively maps, but they get loaded in as ConfigurationSections (or more specifically MemorySections)
So can they be accessed with getConfig.getMap?
the preferred way to get the section would be with getConfigurationSection
I'm not sure if getMap is a method
Oh it sure isnt 😫
Yikes, this seems like a nightmare lol.
Essentially need to pass each user defined section into an object
wait would this work?
@SuppressWarnings("unused")
BukkitTask Listeners = new BukkitRunnable() {
public void run() {
}
}.runTaskTimer(this, 100L, 100L);
i dont know why its suppressing Listners though
I actually prefer how they are loaded as ConfigurationSections, as it's easier to use in case the user has fucked something up
e.g you don't have to worry about what type they get loaded in as
should it be new Linsteners(this) or should it be a runnable?
what are you trying to do?
you've made an empty runnable there, which runs every 5 seconds
run listeners?
erm... how do you do that again?
I'm not sure what you mean
Has anyone ever programmed a discord bot with nodejs? Or has experience?
is there anyway to put a itemStack amount to 100? in a inventory
i've done a little, but i use it mainly for reddit bots
for me it only display 64
yeah I don't think you can override that anymore
the later versions won't show stacks > 64
and spigot might not even let you set it to such a high amount
nice to know discord & reddit use the same bot language :I
i mean you can make bots in any language
because its a range from -127 to 128
provided you can make http requests in it
wait really? its all just http requests? o_o
idk but isnt it that u can do something like: inventory.setMaxStackSize(128); ?
sadly it only shows 64 for me
the libraries you're using are just making requests to the APIs
oh okay. i need help with something and discord.js has no help with that or no guide xD
why is why if you ever read discord's documentation you see it's all requests to endpoints
discord.js is quite well documented
they also have a discord
i tried xd
is packet possible to update the inventory to show the right amount above 64?
So getting the subsection, it looks like you don't have access to the value?
since it only returns a set
or jesus ignore me, now we have to go deeper
well with the configuration section, you can get the values from there (if you know the keys), otherwise you can iterate through what is returned by the getKeys method and then get the values that way
Set<String> keys = config.getConfigurationSection("drop").getKeys(false);
keys.forEach(key -> {
System.out.println("-----" + key + "-----");
Set<String> subKeys = config.getConfigurationSection("drop."+key).getKeys(false);
subKeys.forEach(subKey -> {
String value = config.getString("drop."+key+"."+subKey);
System.out.println(subKey + " - " + value);
});```
There HAS to be a better way lol
That's what I just hacked together lol
nvm i will use lore to display instead of item Amount
someone might, but it's the easiest solution to implement
import time
from threading import Thread
import random
import sys
class WorkerThread(Thread):
def __init__(self, id):
self.id = id
Thread.__init__(self)
def run(self):
time.sleep(random.randint(0, int(sys.argv[1])))
threads = []
for i in range(int(sys.argv[2])):
t = WorkerThread(i)
threads.append(t)
t.start()
while threads:
for t in threads:
if not t.is_alive(): print('Thread', threads.pop().id, 'completed.')
time.sleep(1)
print('Completed')
Thread 14 completed.
Thread 13 completed.
Thread 12 completed.
Thread 11 completed.
Thread 10 completed.
Thread 9 completed.
Thread 8 completed.
Thread 7 completed.
Thread 6 completed.
Thread 5 completed.
Thread 4 completed.
Thread 3 completed.
Thread 2 completed.
Thread 1 completed.
Thread 0 completed.
Completed```
wtf
am i doing something wrong?
it shouldnt keep completing in chronological order
threads.pop().id will always return the last thread in the list
so in this case you're not removing the dead thread, but the last one instead
damn my thought process is failing
thanks
while threads:
for t in threads:
if not t.is_alive():
threads.remove(t)
print('Thread', t.id, 'completed.')
time.sleep(1)
#######################################################
Thread 1 completed.
Thread 10 completed.
Thread 0 completed.
Thread 3 completed.
Thread 6 completed.
Thread 2 completed.
Thread 7 completed.
Thread 13 completed.
Thread 11 completed.
Thread 5 completed.
Thread 14 completed.
Thread 9 completed.
Thread 4 completed.
Thread 12 completed.
Thread 8 completed.
Completed
idk if this works
not sure how to get it to run in the public void run()
what does entity represent?
only living mobs?
or just regular blocks
nvm its mobs
Hey, So I have 3 Classes
ExtensionProvider: https://paste.sentinalcoding.eu/km75qCSvR9
ExtensionRegistry: https://paste.sentinalcoding.eu/VI8L6ph7iE
und Extension: https://paste.sentinalcoding.eu/84Zlwj1wy5
and my goal is to make a custom APIExtensionProvider.
keeping it short, using a method (for example getExtension(LuckPerms.class)) I want to get a specific Interface, that Interface should have a method called getPlugin, using that I want to get an Instance of the needed API (in this case LuckPerms)
I am guessing I need to use Generics for that, and I have never worked with them so I need some help.
I made that ExtensionRegistry which I can basically add to a Arraylist and if the class matches a specific generic, using the Get method it would return a Extension<LuckPerms>.
but I am not sure if this is correct and if that is a good way todo it, I want the system to be very expandable but I want it to be also custom.
alr last question
would this work
public boolean onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
player.getWorld().spawnEntity(player.getLocation(), EntityType.CREEPER);
return true;
why is there a return true?
you dont need it, you can change boolean to void and remove the return true
so when you break a block, it spawns a creeper at the players location right?
yep
thx
EntityDamageByEntityEvent don't work for minecart
So i have a question:
I'm trying to make a plugin where you right click an item, and the block you're looking at becomes let's say stone.
The problem is, I don't want to replace the block, I want something like right clicking with a stone block on another block. So, like "placing" a block. Is there any way to do this? Thanks!
" I want something like right clicking with a stone block on another block. So, like "placing" a block. Is there any way to do this? Thanks!" Could you explain what you mean by this?
so like
when u place a block
i want to get the position of the placed block
without placing it
does that help?
uhhhh
if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
mhm
Block blockR = event.getClickedBlock().getRelative(event.getBlockFace());
ok I will try that
@EventHandler
public void onClick(PlayerInteractEvent event) {
if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
if (event.getItem().getType().equals(Material.AZURE_BLUET)) { // < Change to Material of Choice
Block block = event.getClickedBlock().getRelative(event.getBlockFace());
}
}
}
try that.
is it supposed to be spawnentityevent?
missing ```@EventHanlder
Wheres the @EventHandler
Yes!
you need @EventHandler above all event methods
thank you
yes
Key word. "all event methods"
re:
EntityDamageByEntityEvent don't work for minecart
how to get a minecraft hit event?
Well. What Version, 1.16?
yes
VehicleDestroyEvent?
declaration: package: org.bukkit.event.vehicle
try one of these
Actually VehicleDamageEvent.
they did well hah
i should send doc instead xD
he did link you the right stuff
Yep!
the point is that they made dedicated Events for vehicles, probably because someone might be in the vehicle*
thanks for the help ❤️
That worked, thanks!
-. -
thanks to u too
Glad to help!
Note: i also saw someone claim that Entity#getLastDamageCause() is possible with a Entity Vehicle
It's firing twice though, even when I return if the hand is the offhand
Could I see your code?
I was destroying vehicles and listening to EntityDamageByEntityEvent, HangingBreakByEntityEvent and it detected nothing
the debug is saying HAND twice
PlayerInteractEvent is performed by pressing and unpressing the mouse
(as far as I know)
i didn't test it myself
This is what it says on the Java Docs.
Represents an event that is called when a player interacts with an object or air, potentially fired once for each hand.
what is the inverse of "press" in english? xD
I'm not sure. Should be working fine.
i did more testing and it seems like when i right click the air it only fires once
"pull the mouse" it looks strange in my mother language. ;_;
lol, what are you trying to describe?
yes, lets"push the mouse"
Hello! could you help me how to create inventory pages please?
i already did a check
alrighty
it seems like it only fires twice when i right click a block
Did you try Google first by chance?
https://www.spigotmc.org/resources/inventorypages.32432/ <- plugin (no free)
I don't need plugin I'm making a plugin and I need how to make pages in inventories and I haven't found anything to help me.
or learn to program in spigot
That's low key a cool plugin
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
What is your problem?
||we can't do everything for you*||
Then you can make it so when you click on an Item it opens another inventory by creating another inventory. Scratch that. Use one of the API's/ Libraries at the bottom of the link @sick ravine sent.
@hasty lynx pages work by either re-using the same inventory window and you just remove the old items and put in the updated items in the so called next page or you create a new inventory window
Then it is just a matter of choosing which slot to put your previous and next buttons and listen for clicks on those slots
https://github.com/Phoenix616/InventoryGui
https://wiki.phoenix616.dev/library:inventorygui:usage
Use this API, and this Wiki and it will help you a lot!
How to use it Take a look at the examples below to learn how to create a GUI with this library or use the InventoryGui Javadocs. Defining the GUI setup Every line in the array define the line in the inventory chest interface. The characters are getting assigned to certain elements laters, similar to how recipes are defined. Any empty slot w...
another solution use these ^
and don't bother making your own boilerplate code for this 😛
Exactly unless you know java and the spigot api pretty well. It will be to complicated for you at this very moment.
well its not too complicated
the complicated part is when you try to implement checks to prevent duping XD
Well yes and no. A lot of new devs haven't learned an ounce of java and want to make minecraft plugins straight away.
sure, so I mean its situational in that term
overall making a GUI inventory, isn't all that difficult in itself. Super easy to get that to happen. The hard part is implementing protection checks to prevent certain things from happening which most gui inventory plugins don't do lol.
That's definitely true. I see what you mean.
bruh I couldn't spell definitely for what ever reason lol.
really the cause of most duping that happens on servers too. But, unfortunately when it comes to the free plugins you take a gamble I suppose
Yep unless you make it you self haha
yes
🤭
Hey, I want a plugin that will be an advanced item shop, unfortunately there is no one for free, can someone help me make the entire plugin?
there is chest shop
||I think he was being sarcastic||
lol
||I think so too||
I can do $200 plus 15 an hour.
can i pay in venezuelan bolivars?
||oh and if you think as a plugin dev you should be paid by the hour, you are dumb.||
ok well i figured out that it only fires twice when placing the stone blocks
Lol aternos removed my plugin
bruh that currency is inflated. 100USD = 24821000VEF
I will pay you 20000VEF
really depends for this
I have been paid by the hour before for programming
8 cents lol
usually I will do an hourly rate if its something super easy but will take a couple of hours
But hourly rate isn't based on project rate though
if you do that you are dumb XD
you can have those two things separate
I should of specified, meant like a commission. Commission should be flat rate and time should be included in the price, depending on the size of the project.
I agree
I was just saying if its something super easy, I don't bother with commission rate was all
do people teach? 🤔
yeah yeah. like I made a plugin for some one where you could place water in the nether. Took me like 5-10 mins and made $5 lol and 5 stars.
@round finch sometimes
i would consider paying someone to teach me stuff
like? NMS?
for now it is just a thought
idk what the price is for some people
and their skills
Some of us here, are up there on the ladder in terms of skills. But it really depends what exactly it is you are wanting to be taught
maybe Nms and packets
if you are talking about Java, there is already great courses out there for free and paid
can the course be in Polish?
You can learn about packets with a generic Java course on networking btw
Minecraft packets are not special
java networking hmm 🤔 nice
we only refer to the minecraft packets because there is a protocol or better termed a standard in how the packets for minecraft are structured
i know they change that stuff for each update maybe
They do sometimes. Sometimes it is just a minor change some where and thus a bump in protocol version lol
That will be your best friend with protocol
But I mean learning about packets in general is going to be more beneficial for you in the long run then justt learning minecraft packets
because packets for everything are pretty much the same, only difference is how the data in said packet is laid out
most packets have their own numbering system so you already know from the start what kind of packet it is. Thus, determine do you really need to dig through the packet for data or not. An example would be, maybe a packet with 01 in the header means it is just a ping packet. Only thing it might have in it is something useless like hello or helo
really didn't need to decipher the packet for that at all XD
This will help you a lot in the long run, for example you some how get a job using java in the future and they need you to know packets and protocol. It will help alot.
easiest way to learn about packets
is to setup a simple chat server and simple chat client
running from the command line
and then just practice sending messages back and forth by using packets only 😉
Not hard to find a decent Java course on networking and how to create a simple chat server/client to do this
its like what, at most 50 lines of code for the server and maybe the same with the client. Just depends how you choose to go about it really and which protocol standard you want to try to use
IE, TCP or UDP
or maybe some other protocol standard
minecraft uses TCP just fyi
Many of us have seen mysterious "TCP/IP options" in our network settings, but what is TCP/IP, and how does it enable the Internet to operate as it does?
TunnelBear message: TunnelBear is the easy-to-use VPN app for mobile and desktop. Visit http://tunnelbear.com/linus to try it free and save 10% when you sign up for unlimited TunnelBear data.
...
why do they always include /IP -.-
TCP/UDP* 
IP is the most upper protocol where almost all protocols are derived XD
lol idk
frostalf how have you been? Haven't seen you around for a few months
understandable
@quaint mantle ok I watched it. It is a decent video to recommend someone watching to possibly get a little bit of understanding of how IP works. Didn't really describe TCP though ironically.
Yeah. Noticed that
@dusty herald what is the song in that video?
can't remember what it is XD
need to add it to my playlists so I don't lose these old great songs >>
I feel good - James Brown
LMFAO forgot about that video
i'm trying to set an Item(the entity)'s customName to something like {"translate":"item.minecraft.egg"}, so the client will automatically translate it
but apparently spigot translates that into something like that in the image
is there a way to bypass this without nms/packets?
this problem also somehow happens with sendMessage/sendRawMessage
how are you attempting to do this?
i set the customName to
ComponentSerializer.toString(
TranslatableComponent(
ItemHighlight.localeManager!!.queryMaterial(
item.type
)
)
)
the string it returns is correct
i verified it by literally telling the server to send a tellraw command
and it worked
(note that i did check if localeManager is null)
Not entirely sure then. But there is API methods for setting entity names though without using the text components
without using the text components
ComponentSerializer.toString(component) translates the component into a string
but somehow during setCustomName() the server decides to translate that string into.. this
https://cdn.discordapp.com/attachments/741875863271899136/825597963815616532/unknown.png
do you have no other way other then using toString? o.O
again, i verified that the toString is doing its job
i sent a tellraw with something like this
Bukkit.dispatchCommand(
Bukkit.getConsoleSender(),
"tellraw " + player.getName() + " " + ComponentSerializer.toString(it) //"it" is the component
)
and it actually got translated by the client
i listened to the packets sent by the server to see what exactly the server sent to players
up: tellraw
down: sendMessage
(both taking ComponentSerializer.toString(it))
would appear this is something gson is doing
everywhere and nowhere 🙂
lurker
Not entirely sure why gson might be doing that @minor knot but the '\' is generally an escape character. Maybe there is something wrong with your json format that might cause gson to think characters need escaping?
pretty sure that the escaping problem happened when i told the server to send it to players?
even so gson is what handles all the component stuff behind the scenes mostly though. I can't see anything in the bungee API that would cause this other then it gets ran through gson's api methods
bungee chat api*
but like, i used tellraw to send ComponentSerializer.toString(it), and it worked
that should verify that ComponentSerializer.toString(it) is correct :/
further more, sendMessage(ComponentSerializer.toString(it))
sent that problematic/weirdly-escaped message to players
so the sendMessage() must had done something to the string
Well sendMessage isn't part of the bungee chat api
instead of using toString, could you just send the TextComponent to SendMessage?
think you are able to do that, I don't mess with text component stuff all that much. And first time actually seeing this problem lol
yes(actually with player.spigot().sendMessage(component)
it works, but that doesnt really matter, because what i want to do is set an Item's customName
well not sure if you can do that with Text Components or not. Minecraft doesn't just magically translate whatever you put in there.
I am sure that is something possible to do. But if you are asking if there is such a plugin out there for download. I doubt it but I really have no idea as this isn't really a common thing people seek out lol.
take a look at this, i think
https://developers.google.com/youtube/v3/guides/implementation/comments
you'll need to do it yourself
How can I make a block activate normally? Setting the block data seems to break the piston properly moving the block above it
i mainly say that cause i don't think anyones does this in this discord
there is a section on the api that shows you the java code you will need
how would you modify the text of a BaseComponent or TextComponent but keep the original modifiers? I just want to change the message is all but keep the fancy little colors and what-nots
yes you can
however, there is a limit in where it will just register as block of air
declaration: package: org.bukkit.entity, interface: LivingEntity
any ideas Frosty?
No, because I don't mess with that stuff all that much
thank u good sir
I generally stay away from chat related things. Too much of a hassle
and I just like plain and simple
you're telling me, I'm forced to fuck with the raw json to get what I want
shit aint fun
lol
this should help you out. That is the repo for the chat api stuff that the spigot server uses
are hackers able to make the server think they are sprinting when they are not so that isSprinting is true but they arnt?
Probably, I wouldn't worry about it though
as long as they toggle sprint (double tab w, or press their sprint key) the server will always think they are sprinting
if that helps
so in context if a hack client made the player use sprint by normal minecraft standards and just increased walk speed yes the server will read they're sprinting
Please. PLEASE don't do this, sending console commands is not the way to do anything
Hey guys, I asked this yesterday but didn't really get an answer
eh, it was just to bypass buggit and verify that the string is correct
I'm not exactly sure of a proper way to send GSON in Bukkit, but kyori/adventure (https://docs.adventure.kyori.net/index.html) has a GSON serialiser which you can send to a BukkitAudience/(Player if on paper api)
I'm making a lobby system for a minigame. I have an abstract class called Lobby and then any game I make will have a class which extends from that. So for example if I have ExampleGame I'd also have ExampleLobby. The purpose of this is so that say ExampleGame has a bunch of kits, and I want to allow players to select kits whilst in the lobby. In my extended class I want to override the playerJoin() method and give them items
I'll post the classes now
what i actually need is setting an Item's customName tho
Still doable with adventure iirc
my abstract lobby class: https://paste.md-5.net/notawewofu.java
an incomplete child class: https://paste.md-5.net/towenivesa.java
if not on paper/its forks you need to also use a LegacyComponentSerialiser
My current issue is that in the parent class (Lobby) I call playerJoin() and pass in the creator of the lobby
however the items I want to give the player in the playerJoin() method have yet to be initialised
as I initialise them in the child class constructor, which happens after the super constructor has been called
the problem is, buggit seems to translate json literals(at least of a simple "translate" tag) into this garbage https://cdn.discordapp.com/attachments/741875863271899136/825597963815616532/unknown.png
any suggestions on how I could resolve this would be great
@supple elk you shouldnt be doing actual game logic in the constructor
move it afterwards to a new method
well giving things to a player is game logic
constructors only serve to construct the object
giving items to a player is not what a constructor is meant to do
ok
ok so I still need to add the creator the list of plaers when the lobby is created
so if I were to separate that into something like an init() function which I then call at the end of my constructor
actually yeah that makes sense
I could then overide that in the child class
yeah this is perfect
cause I can now add stuff before the parent init() method
ty @sullen marlin
np
actually
one last thing
doing it like this means that I can't make it a final field?
well that's the thing I can't
this is the problem I was having earlier
in my parent constructor I call the method addPlayer()
as I want to add the creator of the Lobby to a list of players who are in the lobby
the addPlayer() method gives the player items in the child class
but the items haven't been initialised yet
as the super() constructor has to be the first thing which is called
so if I had ```java
Child {
super() //super calls addPlayer()
//initialise items
}
addPlayer() {
//give player items
}```
then I think the problem becomes pretty clear
yes you need to split it
constructors calling this methods is bad practice
call addPlayer manually after new Child
new Child().addPlayer()
netbeans warns about code that looks like your example
Should this do the job?
Use ?paste so it's easier to read for us.
I'm guessing you using PlayerInteractEvent?
wut? if (ItemManager.metatype == "launchplayer"){
Yeah, you don't compare string using ==, but use .equals() or .equalsIgnoreCase() instead.
ok
whats ItemManager
which one?
item manager
i use metatype
so ability changes
i put as much sd fit
so currently metatype can be only launchplayer?
when you shiftrigcht click, lore and metatype is supposed to change
but you know this is global right?
if you create lets say 3 items and change the metatype
yes
only the last one will remain
ok
meaning there will be no more skills
so?
not for skills
i just want the ability to change
but its changing for everyone
when the player sifht right clicks
not 1 person
store the skill name in the item
You need to play with PDC I guess, so the ability will be detected each item.
meaning?
this aint it chief
shiftrightclick = 1 ability
in that case yeah
more or less..you are avoiding learning new things though
PDC is a op feature of the api
allowing you to store everything
well it is too hard
inside a item
and i have no idea abot it
plus original idea was using it as separate abilities
not swapping between
in case you want later to look into it spigot has a guide https://www.spigotmc.org/threads/a-guide-to-1-14-persistentdataholder-api.371200/
Basically you can store a variable inside an item for example.
thing is pdc will allow you for unlimited skills if you want togo the name way
it is pretty easy
after seeing
but i am finding changin lore very hard
like it deosnt update
well you can always post here for help
wich part
well the code is properly doing it
its more of a "can it even get there"
type to console before doing it
Bukkit.getConsoleSender().sendMessage("Reached");
but my one currently makes a new item altogether
it doesnt stay sword
well you also set the meta to the sword rather than only the player one
ItemManager.sword.setItemMeta(meta);
item.setItemMeta(meta);
you change both the global sword
and the one in the player inventory
should change the lore
is there an easy way I can order player into the list based on the integer returns by the getKills() function?
I know there's a list.sort() but I don't know if that's applicable here
how do I use sort?
is getKills() an int?
is so, a TressSet would be somethign like Set<MutantMayhemPlayer> treeSet = new TreeSet<>(Comparator.comparing(Integer::getKills()));
yeah getKills() is an int
Does complex data caches in pdc?
For example, i have uuid complex data type. Every time when i call PersistentDataContainer#get, uuid serializes from primitves?
Or is it cached?
no cache
So, its being serialized/deserialized everytime?
from the object in memory yes
@supple elk removeIf only implements an iterator so you can remove from the collection you are iterating. it doesn't provide serialization with other code.
synchronize on the tickables
I think it's because I was trying to add an item to the list whilst iterating over it
that would do it
you'll want the synchronize the three lines that access toadd
as your code its still possible to add and read/clear the toadd collection
just needs a synchronized(this.toAdd) {} around the two calls in in tickAll and in your add method
I am trying to use this but I am not able to
Please could you help me?
I am using a hasmap now lol
ok screw it
im not doing this
Under the name The sword of air, it says combat, how should I remove that?
why does no one help
Leave creative mode
thanks
does anyone know which packet is being sent to the client when an armor stand spawns?
The living entity spawn packet
oh ok so PacketPlayOutSpawnEntityLiving?
for future reference, you can use a tool such as pakkit https://github.com/Heath123/pakkit to find packets
heh
if (e.getClickedInventory().getTitle())
Why isnt getTitle identified?
Get the title from the view
wot
@EventHandler
public void clickEvent(InventoryClickEvent e){
if (e.getClickedInventory().getTitle())
e.setCancelled(true);
}
okay please use more suitable names for variables like event instead of e
Both 7smile7 and Conclure gave you your answer
Because an Inventory only gets a title when its being viewed
It should work, I am doing it the same way as the guy on youtube
Your Youtube video is out of date
Could be that he is doing 1.12.2 and me 1.16.5?
yes
weird
Not weird at all. its called API changes
You really should read what people tell you.
getView doesnt exist
Intellij tells me someting else : /
Then you are doing something wrong
Thats very probable
my guess is you are trying to get it from the inventory
the question is, where?
If you are on 1.16 then Ij tells you the same story
view is on the event not the inventory
Ohhhh
So i put it before getClickedInventory
yea
works now
thanks guys
ok now getClickedInventory is gone 🙄
no its not
It doesnt get identified anymore
Show the code you got so far pls
package guimenu.guimenu.events;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import sun.jvm.hotspot.ui.ObjectHistogramPanel;
public class ClickEvent implements Listener {
@EventHandler
public void clickEvent(InventoryClickEvent e){
if (e.getView().getClickedInventory())
e.setCancelled(true);
}
}
both are from the event, you can;t get the inventory from the view
Well, I cant get view if I get the inventory
Sorry but take some basic java classes on object inheritance
Thats not the answer bruh
of course it is
Ok the very first thing you are going to do now is rename e to event.
Then you take it slow and get every variable you need line by line.
InventoryView view = event.getView();
String title = view.getTitle();
Inventory clickedInv = event.getClickedInventory();
I used html css, js, linux several java courses and THEN I got into spigot, I dont think thast the answer
Inventory is a child of event.
View is a child of event.
Inventory is NOT a child nor parent of view
Well then.
Look at the code ive provided. Its probably everything you need.
Im working on it
and view is unidentified
he literally gave you the code to access both
I don;t play anything that has micro transactions
I only play micro transaction games
So its your fault games these days are shit 😦
Lmao very well, I’ve come to realize games that does not have micro transactions aren’t as good
To be honest games went to crap when it became all about the money.
Lol feel quite the opposite
Games developed in a bedroom by someone with a real passion for writing games are the best
I dont play it, its too pay2play, however I liked clash a rama
Lol I concur
for me micro transactions is fine as long it doesn't pay2win
or pay2play
event.getClickedInventory()```
Nevermind, im an idiot
it's fine too ig
clash of clans isn't pay2play, you can download it for free right?
Didnt mean it that way
its free, but later almost impossible to progress without paying
Yeah, those games make it almost impossible to advance at any reasonable rate without paying more
Often they run double XP weekends and things of that type.
playable during the double XP, then impossible to advance after
best paywall is the wizard 101 pay wall
Hey thats pretty cool, now we just need to combine it
no I just cant
wtf
OOOOOH
NOOO
NEVERMIND
Alright I did it
does anyone know a good website to go for colored heads of a certain hexa? e.g. need lime head that i can find on namemc
On Minecraft-Heads.com you can find more than 30.000 custom heads, which can be used to decorate your world! The collection is seperated into two databases: the first contains custom heads, which never change their texture, using the Give-Codes from Minecraft 1.8+, the second one includes player heads which can be used in all Minecraft versions.
ty
Hi. I have problem with replacing seeds at place where the weath was. Can someone help?
My code is
public void onBlockBreak(BlockBreakEvent event) {
if(event.getBlock().equals(Material.WHEAT)){
Bukkit.broadcastMessage("test");
event.setCancelled(true);
event.getBlock().breakNaturally();
event.getBlock().setType(Material.WHEAT_SEEDS);
}
}
}
There is no need to call breakNaturally(); as its being broken at this moment anyways. If you want to place a block right after another is broken you need to delay the task by 1 tick
can you show me and example/
@EventHandler
public void onBreak(final BlockBreakEvent event) {
final Block block = event.getBlock();
if (block.getType() != Material.WHEAT) {
return;
}
final Ageable ageable = (Ageable) block.getBlockData();
if (ageable.getAge() != ageable.getMaximumAge()) {
return;
}
Bukkit.getScheduler().runTask(this.pluginInstance, () -> block.setType(Material.WHEAT));
}
Didnt test
Ther is something wrong with pluginInstance
You need an instance of your plugin in your Listener class. Best way is passing it as an argument in the constructor of the Listener class.
works
Can you help?
What am i supposed to write?
You need an instance of your plugin in your Listener class. Best way is passing it as an argument in the constructor of the Listener class.
Thats very basic Java
Defining the constructor in your listener
public MyListener(JavaPlugin plugin)
and then when you instantiate a new listener in the main class extending JavaPlugin
new MyListener(this)
Question, should I either update a mysql table whenever a player gains some virtual currency or cache the data and save it when the player logs off, server shuts down and an interval
caching is always better for mysql
Yeah thats what I thought
Can I convince anyone to look through a quick prototype of a plugin before I continue working on it? Would like to build it somewhat smart from the get-go and avoid as many beginner mistakes as possible.
What type of plugin is it
It's supposed to let players perform a variety of "spells" through items. Currently only have a leap.
https://github.com/simonlk1/SRClasses repo's here incase anybody wants to take a look :)
loc.setYaw((float) Math.toDegrees(loc.getYaw()+90));```
this works in every dir except east
and now its returning 2054
2053
setYaw, convert already converted yaw + 90 is what you're doing
thats because if the yaw if already 360 then errors arise
Is 90 in degrees?
as in?
As in, is it degrees?
Math.toDegrees(loc.getYaw()+90) getYaw is already degrees since you're already converting that, but what about 90?
Are you doing math correctly, what is going on?
You are adding over 5000° there. Doesnt really make sense to me.
wut
the 90 us just a number
90 * (360° / 2pi) is around 5150°
Considering he also has the latest Yaw you can add a few hundred potentially
But you are adding 90 radians currently
Well you are not understanding the delimiters
it returns a float
Adding 90 is what is correct, but you gotta "wraparound"
Gets the yaw of this location, measured in degrees.
A yaw of 0 or 360 represents the positive z direction.
A yaw of 180 represents the negative z direction.
A yaw of 90 represents the negative x direction.
A yaw of 270 represents the positive x direction.
Increasing yaw values are the equivalent of turning to your right-facing, increasing the scale of the next respective axis, and decreasing the scale of the previous axis.
just set it, no need to calculate, the method in Spigot will do that for you
Oh i see nice.
You sure? https://i.imgur.com/T16wfJ8.png
Oh prolly handled when applying onto a player then
was it you doing it before?
as in?
a few weeks back
ye
was that the one wich i said didnt work and just built a 4 high pilar
your doing a super constructor
you can't reference anything
make one of the constructor parameters be disabled lore
a string
and then put that as the super
Intellij is telling what you have to change , you have to make an Super Constructor.
thanks
its cause the variable is initilized after the super call
Also wrong naming convention
lol
He probably uses it as an effective final variable in a lambda function
How would I get the yaml key length of a certain value?
e.g
Value1:
Value2:
Would be 2
yea
just get the keys and the length of the map?
How would I get all of the keys.
YamlConfiguration?
getValues(true) gets you the map from that path
from there you can get the keySet and check its size
Ok thank you
not the code I just gave you doesn't
the wall was in the ground because the arrow hit the ground
shoot a tree
i tried shooting a block and it faces in a strange dir
ive tried this
show the code you are using