#help-development
1 messages Β· Page 2147 of 1
oml
did you delete the message lmao
you literally made a static listener
i saw it with my own eyes
okay so please explain to me why not to pass the event as function parameter?
I have methods where I pass events as a parameter
5 mins ago since my solution wasnt wanted
solid layer of abstraction
i want him to elaborate since he knows better
works well with some interfaces I have set up
xD
amazing for gui clicks and such
because having a static event handler is absolutely awful practice
oh bruh has a static event handler
main.class
yes obv, i use this a lot but in this case it made no sense as the class name was "User" which definitely sounds like it should be instanced
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event)
{
User.onPlayerRespawn(event);
}
User.class
public static void onPlayerRespawn(PlayerRespawnEvent event)
{
if (!event.isBedSpawn() && !event.isAnchorSpawn())
{
event.setRespawnLocation(spawn);
}
}
But why
because having this
...why not just have the listener in the user class

public void onEnable()
{
Bukkit.getServer().getPluginManager().registerEvents(this, this);
Callbacks.init(this);
Ranks.init(this);
Admin.init(this);
User.init(this);
}
``` otherwise this is getting messy af
so that i vomit
what
wtf is the point of using static initializer pattern if you dont even store it anywhere
??
lmao
second deleted message
lol, they are storing it as singleton
thats not the point
why would user be a singleton π
a user shouldn't be singleton
or just rename the class to be better descriptive of its contents
yeah
something like UserHandler would maybe make more sense
no one knows, this class just came out of nowhere
use sounds to me like it should be instantiated
maybe it makes sense given his codebase
yeah
as like a Player would be
What exactly is so bad about this
Just split it up
Make an initializeUtils method or something like that where all the init happens
But all of that stuff is static and probably shouldn't be
its 3 distinct systems that interact with each other but operate independent
depends what it does ig
wrapping everything in one and the same initialize method and bundling them caused my code to go messy last time
if its just removing the player removePlayer probably makes more sense
How could it be messy
It's just a sequence of init calls
And you can make it more branching if needed
Like one call to initialize all of the systems for one thing, then a call to initialize all of the systems for another thing
if user is supposed to be a singleton why not just put the listener in the user class instead of making another class that gets the singleton and then triggers a method inside of it
youre not even trying to listen to me you've just bashed me for the last 10 minutes alongside a couple others without even knowing what my code is doing
bruh
i dont know what your code is doing because you havent explained lol
but isnt that what im doing?
if i aint getting u wrong here
Do I have to make a new enchanted book to modify the stored enchantments or something? Just remove/adding them doesn't seem to work.
I dunno I just got here
What do you mean?
You have to get the ItemMeta, cast it to EnchantmentStorageMeta, and then add/remove stored enchantments
ffs
implementing a custom permissions system, overriding vanilla commands to make em compatible with the rank system, implementing administration commands, implementing oh wonder, user commands like setting a home, a global spawn
forgot I had to do that with meta
So you're reinventing essentials?
im already done
and fully operational
yea i forget this all the time lol
Have you ever used nucleus
It's like essentials but for sponge
And my god it is so much better
I did that a lot with my first plugin and I still forget
I kinda hate essentials
i have a quick question. Did spigot overrides equals method, like if i would like to compare chests or sth. Did i need to override them on my own?
Why would two different chests ever be equal
chests as in the blocks or inventory?
i mean that was example
ItemStack overrides equals
I can't even really think of much else that would need to
Different entities, blocks, and such will never be equal
BlockData overrides equals
ItemStack#equals?
Yes
to be exact, ive bound the permissions to scoreboard teams which can be dynamically managed ingame.
It only returns true if the items are identical
Yes
Oh my god it is not that complicated nor does it matter that much
Just pick something lol
Both the names sound fine
Leave a comment/javadocs if you really think it's unclear what the method does
lol
currency.get(player.getName()) -= helmetP[helmet];
Currency is a hashmap having the player as a key and an int associated and helmetP is an array containing integers, yet i can't do this operation
well u need to re-set it
but you cant -= cause that is reassigning to something that isnt a var
map.put(key, value)
^
(you could use map.merge or something like that but eh)
but how do I get the previous value associated to the key
I still need to do an operation
just get it?
Also, you should always store data based on the player's UUID, not by name
currency.put(player.getName(), currency.get(player.getName() )- helmetP[helmet]); ?
close
no need for data, the hashmap is deleted when the player opens an inventory and a new one is created so no need to use uuid, i'll nver have two players with the same name online
But you probably meant the right thing, it's just a stray bracket
no wait
it works
i'm just dumb and used player's name instead of the player itself
yeah ^^'
What better for comparing ItemStack, equals() or isSimilar()?
Oh allright good point i didnt think that
iirc equals converts the objects into their sha hash and then compares the two so they must be absoloutly identical to return true
but i bet if im wrong here someone will be happy to enlighten
at some point I believe equals cloned the stack 3 times
So for ItemStack equls() is memory lost right?
hm?
Because when you compare ItemStack you dont care about the amount for example
then isSimilar
Allright thanks
I dont know why the fuck, interface doesnt allow to use their implementation methods of a class
For me its so engorrous
I explain
So you told me if correct
I use interface when need to have the same methods in multiple class
i mean im prob just dumb but iirc an interface just tells the class it must have a method
thats one way to use them
So in my case i have a Menu interface with getName(), getSize(), getInventory(), bla bla.
So i have 2 diff types of menu, Inventory (normal one) and Paginated.
So in paginated i want to use there the methods from interface and the methods from the class
I cannot, because for tracking my inventories i have a Map<UUID, Menu> because as i have diff menu types
that sounds extremely like an impl detail
good thing it isnt exposed in your interface
I would love to do that lmao
setPage() its specific from the PaginatedMenu
My main problem come when i need to get the inventory, into the diff types
Because if i cast it, them i get issue
π€
I mean expose the type then?
I cannot because the Menus will be saved in 1 map only
I dont want to have them separated
I mean
the map can still consume the type Menu
but you should have a separate type which is paginated
as it seems to expose further api functionality
Conclure i dont understand sorry im dumb :(
Ajam, and how you track them?
Allright, so you have a class for normal menus and one for paginated right? And you track uuid and BaseGUI
Yeah i do that for dont killing myself
So what i can do? explan what you mean Conclure by doing further api functionality
Yeah you keep the full player object losting memory
That what i avoid using UUID instead of whole object
But iin fact is the same
make a PaginatedMenu extends Menu
which has a static factory
to make its implementation (PaginatedMenuImpl/SimplePaginatedMenu)
Yeah
thats what i would do
A factory right?
yeah, factory pattern
ok
hows the event called thats fired when the beacon is activated?
when the effect is chosen for an emerald, diamond etc
So its organized good in this way:
Menu interface - For the menus implementations
InventoryMenu - For working with normal inventory
PaginatedMenu - For working with paginated menus
MenuButton - For managing the item and the action it run
MenuAction and ActionEvent - For managing the actions
MenuHandler - Keep tracks of menus
For looks organized, maybe im wrong
i mean that sounds fine
Yeah but i need to take care because its open source api
2Hex factory are usually singleton classes right?
nah
they can be interfaces
It does
Oh ok
majority is the correct
by correct I mean that you cant suppress it
if you cant suppress an opinion, society calls it correct
like it or not lol
It will become correct
Well
the new born babies will be taught that it is correct, if chosen so by the majority
therefore the next generation will think its correct, even though it actually was not
so the fact that it is incorrect will be forgotten
Agree with you, here happens that with the diff opinions about governements if you say something against most people critize you when you are just giving your opinion
and democracy is just the definition of what im saying
the representative that assigns law, is elected by the majority
meaning correct or incorrect heavily depends on the majority
lol
it does
Yes.
can some one help me
i can bet none of you have that high of a social status that your opinion matters in society
its the sad truth lol
@grim ice
what
Dont tag
And if need help follow this ?ask
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
can some one explain this is confuing is it just a sever with mods installed for that version of mc?
For server help #help-server and for programming help #help-development
hello Im totally new to java & spigot, is there any resource I can learn how to implement adding new tool/weapon types? (scythes daggers)
obv with variants such as wooden, stone, iron etc.
I thought of giving them an NBT tag so I can get the item type and execute code for all material types, but I couldnt find much help on that online
isnt there a bukkit implementation for the beacon activate event?
i saw that post but its still too complicated, not that good with plugins yet
I tried looking for github repos that would have something similar but no luck there
there's other ways like checking for specific lore but I would recommend learning pdc
yea no lore checking would be dogshit for what Im trynna do
is there some fully-working example available so I can have something that works and learn from that?
Im real shit at theory I need something practical to learn how stuff works
prolly worded taht wrong tired asf soz, all I'd need to learn this is to have 1 example of someone reading any custom nbt tag off an item
Itβs really not complicated
Not even remotely
yea its prolly not
jsut too much information in the post my ape brain gets overloaded
Maybe a video can help
yes
yes
yeah
?pdc
so in this case
the section
is a "namespacedkey"
namespacedkey is nothing complicated
its just a word
(string)
attached to your plugin
ItemStack itemStack = ...;
NamespacedKey key = new NamespacedKey(pluginInstance, "our-custom-key");
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.getPersistentDataContainer().set(key, PersistentDataType.DOUBLE, Math.PI);
itemStack.setItemMeta(itemMeta);
here
u have the itemstack from somewhere
and a namespacedkey, which is ourcustomkey
u get the container of the item, and write
our-custom-key: Math.PI
in it
which is 3.14 ofc
so this is how it looks like
I'm not sure if it is in the rules of this server, but can we ask questions about the installation of Third party spigot libraries?
because I'm having trouble with the installation of https://github.com/IPVP-MC/canvas
I went through to instructions and the
mvn clean install
is just not working for me
It says that mvn is not a command in the terminal
item:
|__ container:
|__ our-custom-key: 3.14
|__ something-else: hello
@chilly pagoda
its just a hashmap if u know what that is
a PDC its easy to understand its literally a key-value pair
where key can be a name to indentify and the value can be a object, string, integer, etc
Hex im burning my head trying to do the paginated menu - hahaha
I have a biome provider, and when I set a biome to deep ocean, it sets it in f3, but still generates land there. The land has shipwrecks and ocean monuments on it, yet no water.
lol
(thats why i dislike guis)
2Hex its correcta List<PaginatedMenu>?
yea ig
public interface HandleableUIContainer<T extends HandleableUIContainerView<? extends HandleableUIContainer<T, V>, V>, V> extends UIContainer<T, V>, HandleableUI<T, V> {}
my generics best record
What shit are you doing lmao
abstraction shit
im doing an experimental lib, where toasts, container inventory uis, and holograms could be implemented using the same couple interfaces
dovidas can i get your gth profile please
UI<?> hologramUI = HologramFactory.getInstance().createHologram("Hello world!", loc).display(player);
UI<?> inventoryUI = ContainerUIFactory.getInstance().createGUI(Component.text("Title"), ....).display(player);
UI<?> toastUI = ToastsFactory.getInstance().createToast(IconType.STONE, Component.text("Title"), Component.text("Detailed info")).display(player);
it theory it should work similiar to adventure api
there's nothing particularly interesting there. but sure https://github.com/Dovias
There's no git repo there
containing this
its on my pc currently since its very experimental
and not complete yet
have you tried using SpiGUI
My Inventory UI implementation currently doesnt use InventoryHolder
InventoryFramework afaik use that
why?
to detect if the inventory is gui
I dont understand the need of that
you can store instances of objects there
but there are some consequences of doing that
I just check the top inventory
π
dovidas
How can i design the paginated part?
what is the difference between Bukkit.getWorld and Bukkit.getServer().getWorld()
Nothing
one's shorter
I bet Bukkit.getWorld() internally just calls Bukkit.getServer().getWorld()
so Bukkit.getServer().getWorld() should be with a pinch of salt faster to call since you are calling only one method you need, and not two methods instead
but that's premature optimization
JIT would take care of that, I bet.
Uh
How do i make some sort of
communicating from a client and a server (not in spigot or minecraft)
so it cant be replicated
by others
cuz if i wanna make a point system for example
i will want to tell the server to add me a point when i do something
end-to-end authentication or a token system
however you will never write anythign that is 100% secure
that sounds hard
You have to decide how much work you really want to put into making it secure
i guess not that secure
but not extremely easy to bypass
do u know some tutorial
or guide
Nothing up to date. I've not done anything with encryption in 10 years
doesnt need t o be up to date
I like how I despised using generics and now im abusing the shit out of them lol
void transferMoney(
Player sender,
Player recipient,
Connection connection,
Statement statement,
String amount
) throws SQLException {
float senderBalance = 0;
float recipientBalance = 0;
ResultSet result = statement.executeQuery("SELECT * FROM currencies;");
while(result.next()){
if(result.getString("uuid").equalsIgnoreCase(sender.getUniqueId().toString())) senderBalance = result.getFloat("money");
if(result.getString("uuid").equalsIgnoreCase(recipient.getUniqueId().toString())) recipientBalance = result.getFloat("money");
}
statement.execute("UPDATE currencies SET money = " + (recipientBalance + Integer.parseInt(amount)) + " WHERE uuid IS " + recipient.getUniqueId().toString());
statement.execute("UPDATE currencies SET money = " + (recipientBalance + Integer.parseInt(amount)) + " WHERE uuid IS " + recipient.getUniqueId().toString());
recipient.sendMessage(MetricCraft.prefix + ChatColor.WHITE + "You've received " + amount + "$ from " + ChatColor.GREEN + sender.getName() + ChatColor.WHITE + ".");
sender.sendMessage(MetricCraft.prefix + ChatColor.WHITE + "You sent " + ChatColor.GREEN + recipient.getName() + " " + amount + ChatColor.WHITE + "$.");
}```
This should work, right ?
use prepared statements
this seems vulnerable to sql injection exploits
I just started with sql today
This JDBC Java tutorial describes how to use JDBC API to create, insert into, update, and query tables. You will also learn how to use simple and prepared statements, stored procedures and perform transactions
if people managed to inject some sql related query text into those variables (like recipientBalance), they can literally wipe your SQL table or make infinite amounts of cash
Is it possible ?
it could be impossible
but you shouldnt trust your senses
of what's possible
its just not worth it
Its late for me (1AM) and its alr monday so I'm gonna probs sleep soon since i need to get up at 7 AM
so can't really help much
so do i just replace the normal statements with prepared ones ?
it requires more than that, I suggest you reading that doc, so you would understand how that works
Hey quick question, does someone know how to retrieve a list of all ids and those that are usable for BlockData?
instead of using string appending for your queries you create query format string, for example:
statement.execute("UPDATE currencies SET money = " + (recipientBalance + Integer.parseInt(amount)) + " WHERE uuid IS " + recipient.getUniqueId().toString());
would turn into
PreparedStatement statement = con.prepareStatement("UPDATE currencies SET money = ? WHERE uuid IS ?");
statement.setInt(1, Integer.parseInt(amount);
statement.setString(2, recipient.getUniqueId().toString());
by doing that you're letting the SQL implementation classes to clear your variable data if they contain malicious SQL query code, leaving harmless data in place
why commit?
isnt executeUpdate()
i haven't used sql for a while don't blame me
dont worry
executeUpdate() => for update
executeQuery() => for getting data
hich?
Also what means blame?
nvm wrong source
you should call execute(), executeUpdate() or executeQuery(), in this case executeUpdate()
I'm getting an error from the uuid
coz it has -
if(result.getString("uuid").equalsIgnoreCase("\"" + recipient.getUniqueId().toString())) recipientBalance = result.getFloat("money");```
How do I implement it in here?
so whats the best way to store some data on a item? for example when you wanna create a custom item that triggers when you right click you check if its the custom item or not with ItemMeta but they arent always a good solution and now i need another way i think i can use NBT data but i dont think its the best way to do it
?pdc
thanks
I need help with this
That wiki is fine
the actual uuid wont have the " in it when you get it
you just use that to avoid sql injections
When you use it depends on what you need. If you need "metadata" or even just extra data on an item, it's recommend to use the pdc.
but you shouldnt really use \" either
because then they could just inject with a "
Then how do I inject he uuid?
how would you do it ?
always use prepared statements and it will prevent injection attacks
Could you give me a small code snippet ?
how can I make in blockbreakevent the breaker of the block is the owner of the item that drops
it correctly wraps and parses the values
statement.setInt(1, int)
yeah
I was thinking of going the way to cancel the drop and actually spawn the item there with the breaker se to the owner of it
owner as in?
but I dont think u can just create an Item
use pdc most likely
get the drop and assign some data to it. Then compare players with the pickup event.
#setDrops
like Item#setOwner
that isnt a thing
Ik but I need to fix this rn, I'm slowly learning how to use sql
then learn the correct way to do it
String concatenation is not to be used with sql
so if I use the prepared statements it will automatically do it for me, right ?
yes
So I won't have a problem with the - anymore ?
teh - in a UUID is always there
look at silly 1.8 me
Well yes.
unless you are querying mojang or something
But there's a problem with normaly storing it.
well then yeah just make a new itemstack and set its owner to the uuid you want
then setDrops
it gets stored as a string so it should maintain the -
Well time to learn it then, thank you for the recomentation man!
if you use the parameter it shouldnt
but itemstacks cant have owner
Items can
Yep, prepared statement and adding the UUID using statement#setString
is just cancel the event and then set the blocks type to air
then spawn an item naturally at that spot
yes but u cant make ur own Item i think
u can make ItemStack
atleast im trying and cant seem to figure out
.
ye thas what im saying
but then I cant set owner for itemstack
i can set for Item
How you do it all depends on how nice you want it.
World#dropItemNaturally...
eg, you could just insert all the drops into teh block breaking players inventory
ye but eh want it drop
then stop any drops happening
lemme tes tthis
if you want it to drop you have to modify each item in teh drop item event or in teh block break event and mark the item with the players UUID
then in teh pickup event you check each item tht tries to be picked up
Quite complex if you are at the level of being unsure how to create ItemStacks
#setOwner does the job of preventing others from picking up the item unless the uuid is equal to that dropped item
ik but its hard to do it from blockbreakevent
cus u cant get Item of the block but u cant setOwner for ItemStack
After breaking the block, get the dropped entity item, and do setOwner
how to get the dropped entity item
cancel the event -> set the block type to air -> get the location of the block and do World#dropItemNaturally(location, itemstack, (item) -> item.setOwner(owner))
I'm not in my pc rn so can't check
this is good
ty bro
I didn;t know they had added a setOwner on Items
So now I have an issue of not being able to actually apply the higher level enchantments with my plugin
Is there anything in the anvil event to get rid of the limit of 40 levels, or increase it?
I see you can remove the limit
But what about increasing it?
Nevermind, found it
interesting
before I go out of my way to do it is there an easy way to get all the enums from the api for a given page without me having to write a parser or doing it manually?
Does anyone know how to import another project I made with gradle into my current gradle project?
page?
are you just trying to get a json list of all the materials?
and when I say get I mean hardcode, I'm not going to be accessing that page every time that would just be mean of me
I'd be fine with any kind of text really, this is just so I can add them to a dropdown list on the webapp
ive been on this for hours. cant figure it out. any ideas?
i made something a while ago that parsed an entire enum into json
although now that i think about it using gson probably wouldve been simpler
oh actually let me check something
like a jar?
or an actual project
hm
ah damn it decompiled materials also don't give me a clean list
How can I change the ItemMeta of an ItemStack if the amount of the ItemStack changes (ItemStack in inventory)
Too many actions can affect a stack size
when pickup lets say
Tell us what you are trying to do and we can probably tell you a better method
and an itemstack size changes
I have a yml of set materials and prices for them
so I wanna update the itemmeta
to the total price of that stack
but it can be siz 9 or 64 or whateverf
calculate the total when you need to, not every time the size changes
(function() {
'use strict';
const values = document.getElementsByClassName("member-name-link");
let parsedStrings = [];
for (var element in values) {
parsedStrings.push(values[element]['innerHTML'])
}
console.log(parsedStrings);
})();
Because I'm lazy I worked around parsing the api with tampermonkey, feel free to steal this. It outputs all enums on the page to console in a way that can be used elsewhere pretty easily.
oh oops looks like it has a little bit of contamination lol
anyone know why this wont trigger?
the system prints
i press E to open INV but it never actually gets triggered
How do I replace a string with a component in a component?
why does getKiller exist on the player and not the playerdeathevent
good question
?paste
alright if anyone cares to this script on greasemonkey / tampermonkey will add a download button to the top of the spigot api page which you can click to download a yml file containing all of the enum values, excluding things tagged as "LEGACY" because I don't want that
https://paste.md-5.net/jejasomuda.js
a very specific tool for an issue that I've had more than once tbh
How do I use the component's showItem hover?
you cant check when a player opens their own inventory unfortunately
that's client side
also just made this thing like a minute ago to do the same thing but for jar files lol
Code: ```java
package hello.ello;
import hello.commands.GUICommand;
import hello.events.ClickEvent;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class Ello extends JavaPlugin {
@Override
public void onEnable() {
this.getCommand("spacepowers").setExecutor(new GUICommand());
getServer().getPluginManager().registerEvents(new ClickEvent(), this);
}
}```
thank you for the code
not exactly sure what you want us to do with this but sure
o
spacepowers command is not in your plugin.yml
^
then thats not the same plugin.yml that is actually in the jar you are testing
open the jar you are testing with any archive program (7-zip)
check teh actual plugin.yml that is inside the jar
drop your jar in here
yes
@crisp steeple is it normal for the server to be around 4-6gb memory use
uh
idk tbh
what ver, with what plugins
sounds like a bit much but im not really an expert on ram usage
my
so descriptive
what ver
what
minecraft version
1.18.2
hop in #help-server and i'll do more there
looks fine to me. It shoudl work fine with a 2 space indent. change it to the standard 4 to be sure
What line should have a two space indent?
How do I turn off people from using a locked in the off hand?
the indentation on commands and all after
ok
multiples of 4
theres certain items i put on inventories that can't be moved, and i want to fix a bug where they move it via using the off hand
heya im trying to make a plugin that includes a PlayerBedEnterEvent but it doesnt seem to be listening, i have the eventhandler annotation, implemented listener and registered the class
does a task automatically delete once its done executing? like if i had a runnable execute 2 seconds later would it delete itself once it runs everything?
Hey, if I'm using a scheduler inside of a library, do I pass the library's plugin for the parameter or do I pass the main project's?
a library doesn;t have a Plugin instance. You pass yours
If they are runTask they run once. So not repeating
so once its run once they wont run again? and the variable it was stored in is cleared/deleted?
yes, Tasks are cleaned up once done (with GC)
ight ty
add sysout commenting to see if yoru code is running
Here's the code from the library, however idek if I'm getting the plugin instance right
your plugin instance is this as the code is in your main class
it needs to be static
You can;t initialise your static plugin like that.
i tried that already
on your last line, change the plugin to this
yeah, that gives a syntax error
'me.wonk2.DFSpigotLib.this' cannot be referenced from a static context
because yoru method is static it wants a static reference
remove the static before playsounds
is this a library? as you have no onEnable or anything
it is
library methods have to be static iirc
oh
then you shoudl not be extending JavaPlugin as this is not a plugin
oh what the fuck
I was looking at some forum posts online to figure out how to make the plugin instance, and I came across that
so I guess it's not needed then
no, your library shoudl not care who is accessing it. They should provide their plugin instance in any method calls which require one
This playSounds method seems more appropriate for a utility class rather than a library
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
yeah thats the issue
nvm
he's commenting on your TreeMaps
i was commenting on all of it tbh lol
lol
add sysout comments to see IF yoru code is running
should be camelCase rather than PascalCase
i already tried that
and?
I basically just use camel case for variables and pascal case for methods
then we'll need to see some code
naming conventions are just practices for most people
aka how to never get a job in industry
You really think they're gonna care that I capitalize the first letter in a method's name
pfft
yes
If what you are doing is only for you; sure I understand that, but being that is is a library and others will be using it you should follow the standard conventions
Don't get a job in "the Industry". Everyone becomes a dick when theyr ego inflates.
no embed perms
ye
use the paste link or verify
Never mind, my idea doesn't work. Is there any other way to change the maximum enchantment cost? I just get this and can't take the complete sword when I set the maximum to a higher value.
can i use hastebin instead
yeah, up to you
alr
iirc this is clientsided, dont quote me on that as Ive never looked into it but I remember someone saying that
There's a plugin that somehow allows it, but I'm looking for a specific usage and it can't do that
oh also yes ik I was asking how to get a static instance of the plugin
You can't get one at class init but using the Bukkit method is fine
the one I was using before?
yes
what a plugin name lmao
just not how you are doing it
all static items in a class are initialized at class load. Which is before teh plugin loads
Can you add sysouts at all if statements in your listener, including one at the start to see if its actually firing
I cant see a reason that it wouldent work
DoSing or DDoSing is illegal and you'd get banned from pretty much every ISP you try to get
tell that to the tons of people that DoS lmao
That's what proxies are for. :/
You should care more about your IP being leaked. Just because it's illegal doesn't mean that people are going to stop doing it.
It's a pain in the ass to get your IP changed sometimes.
What reason does anyone have to DDoS you, though?
people are weird
is this good?
that's true
But unless you're going around pissing people off, pretty much no one's going to
Me personally, none. At least to my knowledge, but even then. Why ignore best practices? Just because you may not be a target doesn't mean that you might not be in the future.
The method call is fine, but not doing it a a Field
I've been a dev as long as Spigot has existed. They have never ddos'd me.
Any websites you go to gets it too Β―_(γ)_/Β―
Besides, it becomes more than just your IP at a certain point. If you aren't careful, you could become part of a botnet without realizing it.
Or install something unknowingly.
like this then?
Yes, if you have a plugin of that name
that is the library name
then no, its not a plugin
Any reason you can't call JavaPlugin#getPlugin()
well if I'm not supposed to extend JavaPlugin then how do I do this
Oh, it's not a plugin.
It requires a plugin instance. Your library is not a plugin
you could just, being an api, get it through a method var
so instead of using a library I should use an utility class?
as it is a library you could use teh SheduledExecutorService
yes util method
the code you currently have is not really apropriate for its own lib
I'm translating JSON representing a custom programming language to Spigot Code, I wanted to make this a library to make the code more readable for people that use it (Instead of having one big class at the bottom)
then your methods need to ask them for a plugin instance (when required) or use Javas ScheduledExecutorService instead of BukkitRunnables
well since I can't use the library as a plugin, do I pass the main project's (the one that uses the library) plugin instance to the method?
yes
Thanks. that's what I've been meaning to ask all along lol
i did that already, it didnt work
Yes, Rack told you to add sysouts before each if statement
i removed the whole code after the method and only added sysout
Don't say "it didn't work" say what happened vs what you expected to happen
it just doesnt show up
Ok so your event listener is not being called
if you got absolutely no output then chect your startup log for errors. your plugin doesn;t sound like it's even running
no errors nothing
it is the other listener works
its just that specific listener that gives no output
show us the listener with your debug in it
I see no debug messaging
uh wdym?
No souts or getLogger()
yeah but the bedevent is the only listener thats not doing anything
Well that probably means that the criteria for this line of code isn't being met.
e.getBedEnterResult() == PlayerBedEnterEvent.BedEnterResult.OK
use dependency injection instead of trying to import a static reference
new PlayerSleepListener(this)
Staaaatic abooze
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ah
but on what line?
im not really understanding
im using static reference on the task scheduler
read teh basic concept from that wiki link
only your bed enter uses a plugin reference
you mean the getPlugin method?
public void onPlayerSleep(PlayerBedEnterEvent e) {
System.out.println("a");
}
ive tried this
with the static reference
and you see the a?
nope
yep
?
use Dependency Injection to pass a reference of yoru plugin
k
I mean i can just write the methd then?
make a class extends the runnable then store it somewhere else. when you want to run it just call the run method
What do you mean by "save it for later"?
I want to cancel it from outside
like this?
when you start a task you shoudl get an id returned
using that id you can cancel the task using the scheduler
i cant get it to work
ill watch a tutorial instead and see if i can follow that instead lol
wdym?
it didnt work
still nothing
show what you did
looks fine
the other listeners are working as intended
I see nothing wrong in that code
is there a way to check if a creature is undead (like if smite affects them)
should i screenshare to make sure?
No real point. Theres nothing wrong in that code. The sleep listner has no reason not to work
so what do i do?
I assume you get your custom enabled message at startup
and your custom join message
yup
does yoru consume listener do anything?
wanna see config.yml?
yes
its questionable for what it does but yes it works as intended
Then I see absolutely nothing wrong. unless you failed to build the new jar or didn't correctly update the version on your test server
oh right
ill see if somethings wrong with that
does reload confirm make a difference?
it may. Restart
okay see you when the sun explodes
wait what
that was the issue all along
no way lmao
LMAOO i was uploading the file to the host but i wasnt deleting the old one so it doesnt replace it
classic
welp im just glad i got to resolve the issue and learn constructor injection
thanks elgarl see ya next time
that's a vibe
zhe vibe
how to make this?
I can't think of anything
How can a single text chat be partially colored?
https://www.youtube.com/watch?v=-aWx3bGbyf4
I fixed all the prob by using scanner.nextLine(); before inputting
scanner.nextInt(); does not creating a new line
it can be done using resource packs and negative set unicode characters
Then, is it right to make each dot using the font of the resource pack and specify the color for each dot separately?
yeah the actual resource pack only has to be white
chat colour will colour it for you
realistically you only need 1 unicode charcater and 8 negatively spaced characters
i don't have undertstand
you just need 1 unicode character which is 1x1 white pixel
yeap
then 8 negative spaced characters, (-8, -7, -6 etc)
hmm okay i try
Hi, I would like to manage the nms well and I wonder if anyone knows of a mapping viewer site
Or you can use an anonymous inner class and call its cancel() method within the run()
This is actually what you should do
you cant use method sfrom the class in a lambda
so youd have to make it an anonymous inner class
hi guys, i am making a plugin rn for 1.18. Id also like to run it in 1.8 if that possible. Do i need to make the same plugin twice or is there some hacky workaroud
you could use multple modules
have a
plugin-base
``` with the code
using a
VersionProxy
``` interface or whatever
and then implement that in different modules for different versions
can you elaborate
also, how does one make an array of objects in YAML
myRootObj:
- objOne:
objData: "never gonna give you up"
objDataSecond: "rick astley"
- objTwo:
objData: "never gonna give you up"
objDataSecond: "rick astley"
smth like dis?
i mean, i dont think anyone would want to use json for spigot plugins, as YAML is what a lot of server owners are comfortable with
so, lets say youre making a plugin to spawn an entity or something and in 1.8 you want to use armor stands, and in 1.18 you use area effect clouds
you have a structure like
plugin-base
- src/main/java/me/myplugin
- Bootstrap.java
- VersionProxy.java
plugin-v1_8_8
- src/main/java/*
plugin-v_1_18_2
- src/main/java
``` in this case, the `Bootstrap.java` file contains a class extending `JavaPlugin`, and has a method to get the version proxy, like so:
```java
public abstract class Boostrap extends JavaPlugin {
public abstract VersionProxy getVersionProxy();
// all of your other logic
// you can implement the rest here
}
since we want entity spawning,, we create a class
public interface VersionProxy {
Entity spawnMarker(Location loc);
}
then, in each version module, you shade/shadow the base into the jar and implement the plugin using the Boostrap class. this is also where you would define your plugin.yml, this is so you can implement the VersionProxy class and pass it, like so:
public class Boostrap_1_8_8 extends Bootstrap {
public static class Version_1_8_8 implements VersionProxy {
@Override
public Entity spawnEntity(Location loc) {
// do logic
}
}
@Override
public Version_1_8_8 getVersionProxy() {
return new Version_1_8_8();
}
}
lol long af
i was like, what is this guy doing
The lambda is an instance of Runnable and not BukkitRunnable, which you need an instance of in order to cancel itself during running
That's why I'm proposing an anonymous class
hey guys
i have a question, how to add gravity to EntityPlayer? (npc) with nms
can anyone help ?
guys how can I make it so that when I press Install in maven
I can save these
ymls to a specified folder
Why do you want them to be placed in a specified folder? They get packed into your jar at the end.
They should already have gravity.
*Unless they are packet based.
yes they are packet based
and i dont wanna use any npc library
Then you need to calculate the gravity yourself and send a bunch of update packets to every observer.
portals:
- startCords:
x: 69
'y': 69
z: 69
- startCords:
x: 79
'y': 79
z: 79
how can I get all the portals?
Oh wait then how should I access to them
make a new Location(x,y,z)
Cus rn I do new File(path)
No no, I know that, I mean how can I read them from the config
Access to do what?
How should I read those files
This is a List of X
How do you save them?
use Config#getInt("portals.startCords.x")
for y and z as well
FileConfiguration#getInt
Cus rn I do new File((A_PATH_ON_MY_COMPUTER)
They are in the config
Ohh
How can I get each startCord section then?
like an array of all of them
Yeah. No. Thats not how yml works.
Again: How do you create them?
Because this is a List of X
get the config section of "portals" and then loop through
using ConfigurationSection#getKeys
use saveResource in JavaPlugin to save them to disk when ther server starts
that will help us
portals:
- startCords:
x: 69
'y': 69
z: 69
endCords:
x: 169
'y': 69
z: 169
replace: true
block: STONE
rewards:
commands:
- /give %p% dumbItem
- /kill %p%
items:
- GOLDEN_SWORD
- DIAMOND_SWORD
potionEffects:
- name: FIRE_RESISTANCE
duration: 69
level: 4
particles: true
- name: FIRE_RESISTANCE
duration: 69
level: 4
particles: true
- startCords:
x: 69
'y': 69
z: 69
endCords:
x: 169
'y': 69
z: 169
replace: true
block: STONE
rewards:
commands:
- /give %p% dumbItem
- /kill %p%
items:
- GOLDEN_SWORD
- DIAMOND_SWORD
potionEffects:
- name: FIRE_RESISTANCE
duration: 69
level: 4
- name: FIRE_RESISTANCE
duration: 69
level: 4
thats my whole config
what are the dashes for?
My guy, ive said it 3 times now: You cant look through keys here. It is a yml List
this part is incorrect
thats how you make an list right?
If they are packed in the jar
f u c k
What is the path to them
fock
i didnt realise
mb
how should I make an array of objects then?
Alright do what you want... sigh
that returns an ArrayList<ConfigurationSection?
Mb, what should I do then?
Bro just do like
Portals
portal1:
whatever info for portal 1
portal2:
whatever info for portal 2
No?
No u dont
dont quote me on that tho
yea if u use config sections like that
And then create the objects
and THEN you can use getKeys
And place them in list after
portals:
- portalOne:
startCords:
x: 69
'y': 69
z: 69
endCords:
x: 169
'y': 69
z: 169
replace: true
block: STONE
rewards:
commands:
- "/give %p% dumbItem"
- "/kill %p%"
items:
- GOLDEN_SWORD
- DIAMOND_SWORD
potionEffects:
- name: FIRE_RESISTANCE
duration: 69
level: 4
particles: true
- name: FIRE_RESISTANCE
duration: 69
level: 4
particles: true
- portalTwo:
startCords:
x: 69
'y': 69
z: 69
endCords:
x: 169
'y': 69
z: 169
replace: true
block: STONE
rewards:
commands:
- /give %p% dumbItem
- /kill %p%
items:
- GOLDEN_SWORD
- DIAMOND_SWORD
potionEffects:
- name: FIRE_RESISTANCE
duration: 69
level: 4
- name: FIRE_RESISTANCE
duration: 69
level: 4
Idk myself I started using them yesterday
But I have like 13 ranks with name, bounding box, cost and whatnot
All saved and works perfeclty
portals:
portal1:
coords:
x: 111
portal2:
coords:
x: 112
for (ConfigurationSection section : config.getConfigurationSection("portals").getKeys(false)){
player.sendMessage(section.getInt("coords.x");
}
returns:
111
112
Also of u dont mind me asking why is it βyβ
getKeys returns all the keys inside of the config section
so that returns a list of "portal1" and "portal2"
Ye so then u can do for each portal
Get keys
Which u get the info for each portal
yea
I think y is a synnonym for true, so I need to wrap it in string
but i am not sure, i saw it in an online formatter
Isnt it just y location
This is your general structure.
Now before we can give you any meaningful advise you should answer my question:
How do you generate your yml data?
I just wrote it myself
and then the server owner can change it for their needs
i reckon its easier than lists
Then the memory representation of "portals" is a List<ConfigurationSection>
ty
@lost matrix i am still very confused on how to open the ymls insid the jar
look at a tutorial
Cus rn I have them all in a folder in my computer and
for custom yaml files
Thats where I take data from
You dont. Save them to your plugin folder and open them there.
ArrayList<ConfigurationSection> portals = (ArrayList<ConfigurationSection>) vClasses.getConfig()
.getConfigurationSection("portals")
.getValues(false);