#help-development
1 messages · Page 1203 of 1
i wonder if there's any fast way to construct static proxy classes in intellij
like have one private field of proxied object
and then it implements every method whic forwards the method by calling this.proxied.foo() to proxied object
something like:
public class FooProxy implements Foo {
private final Foo foo;
public FooProxy(Foo foo) {
this.foo = foo;
}
@Override
public void bar() {
this.foo.bar();
}
@Override
...
}
alt insert, delegate
Certainly. Mods already proof the significant potential if Mojang would care about optimization
I wouldnt trade chunk loads speeds for bugginess of bedrock edition
it should be called: Minecraft: Bugrock
Also marketplace
Hi guys, I wrote a Economy Plugin for Minecraft 1.21 with the dependency of vaultapi but did a huge mistake… yes, there is no VaultAPI on 1.21….. Im curious if there is another api like vault or do I need to write another plugin for it?
vault doesn't really depend on any specific Minecraft version
it will work everywhere
I get this problem on Pelican, that my server cant start my plugin, also the vault
vault doesn't do anything
so it will work
the issue is somewhere else
look at the logs for errors during startup or something
And I‘ve got 1 more problem with luckperms/ my db
Do you have Knowledge abt it? I cant paste pics here
you can use imgur
Vault is so mainstream that i believe it should be included in main software package of spigot or paper
80% of plugins requires or softdepends on it
vault problem fixed ! thanks, just got a bad version of it I guess
vault is working
but my plugin not
why is getItemInHand deprecated?
for the vault api dependency in pom.xlm, I have vault 1.7.3, but I cant change it to 1.7.3 from 1.7
is the groupID right? its com.github.MilkBowl
and should the artifact id be Vaultapi or just Vault
i guess because since 1.9 there's offhand?
that's just a guess
ok
IntelliJ says dependency com.github.MilkBowl:VaultAPI:1.7.3 not found
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>${api.version}.3</version>
source code of vault 1.7.3 says this, should I just copy it?
Why you don't use just an vault api?
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
and yes, 1.7 is the latest version of vault api, which is compatible with vault 1.7.3 (latest vault plugin) which is compatible with all mc versions
I did it, but found 1 thing, I will test it now
okay, my plugin loaded but there are new issues
Is it possible to control server-side which villager trades get autofilled when clicked in the GUI?
hm? why would you want a different one than the player clicked
Don't want a different one, I want to potentially cancel it
Let's say there's a trade that takes 4 diamonds, if those diamonds have different NBT they still fill into the trade
Cancel the https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/TradeSelectEvent.html
declaration: package: org.bukkit.event.inventory, class: TradeSelectEvent
does anybody ever have problems with plugins using config.yml tht is in project file structure under resources instead of the dynamically generated one upon plugin startup on the server?
No
my plugins doing this but still reads and uses the dynamically generated config file and works but im left with a consistent error in terminal window where i can see its still attempting to use the values in non dynamically gen config.yml
Wait why are you mixing the two?
it doesnt generate the config file on startup if im not including it in /resources as well for some reason
im wondering if the logic in main plugin code is using that file as a template to generate it because ive not got the template for what i want it to generate as in my main plugin code
do uj think thats the issue?
Could be? If I'm understanding you correctly
but don't mix the two
Have a dynamic or a static one
sorry english second language so makes it more difficult. this is in my static config.yml for example
supabase:
url: "https://your-supabase-url.supabase.co/rest/v1/" # Replace with your actual Supabase API URL
key: "your-supabase-api-key" # Replace with your Supabase API key
table: "tablename" # Replace with your Supabase table name
i think it is using this static config.yml file as a template for how it should generate the dynamic config file, as i dont have the template within my main plugin code
and without this it doesnt know what format to generate the config file as
i do but its only generating when ive included config.yml and that template within my project file structure
then when the plugin runs
You appear to be speculating about the issue instead of just describing what the issue actually is 🤷♂️
its only generating the dynamic config.yml file when its template is present as a static config.yml included in the file structure under /resources before compiling the plugin.
the plugin runs fine, but i see errors in the terminal where it is trying to use the default values specified in the static config.yml file, not the dynamically generated one with actual values in (api endpoint, key + tablename). but it also does use this dynamically generated config file as it is writing data to the db table just fine
What is your "dynamic" config
supabase:
url: "https://your-supabase-url.supabase.co/rest/v1/" # Replace with your actual Supabase API URL
key: "your-supabase-api-key" # Replace with your Supabase API key
table: "tablename" # Replace with your Supabase table name
but with the actual values (obv not gonna put them in here)
that is the contents of my static config.yml as i pasted it just now
the error i get in terminal shows its trying to reference the placeholder values from the static config file
[17:37:55 ERROR]: [VerifyWalletPlugin] Failed to monitor Supabase: No such host is known (your-supabase-url.supabase.co)
[17:37:57 ERROR]: [VerifyWalletPlugin] Failed to monitor Supabase: your-supabase-url.supabase.co
but its also referencing the true values i have added in the dynamically generated config.yml file as it is successfully writing the relevant data to the correct table
So what is it
not the content of it
Might be easier if you just put the plugin on GitHub or smth
plan on doing that soon but yhh no worries thanks for help regardless ill try figure it out on my own
The config resource in the jar is not accessed if you programatically create a config, OR save/load a config from file.
that what i thought but for some reason have programatically created the config to my knowledge yet its still accessing it so probbaly havent created the config properly im assuming
No, the first time you call getConfig() is tries to read from file, then tries to read from resource if the file does not exist
So to programatically create your memory config if you first call getConfig() you are telling it to load the defaults
Ahh i see i think that helps me undertsand it a bit more ty, sorry im just very novice programmer using this as a project to help me learn more
If you want a completely empty config you must create a new FileConfiguration (or subset) and fill it. you can't use teh getConfig() call in the API
?paste
looks overcomplicated
no need for the else
just keep a set of values you already got and call next until you are done or until you find an element that isnt there
that is slower, though
checking and maintaining a set is slower than what they wrote
oh wait I didn't see the map
my bad chief
you need a way to keep track of items you already iterated and a fast way to access that
there would be no way around it
hm yeah
so then this solution is overcomplicated imo
what about remove() method
i need to somehow inform that duplicate values should removed
if iterator already reached the first element
if i used the Set<> i would remove the values by default without calling remove() before next()
the main point of Boolean inside map is so that remove() can set its candidate map value to true so that any other duplicate values would get removed when iterating over
I keep getting this damn error:
Unable to resolve table 'kingdoms'
can someone help me figure it out
how about you share some code
well you need that table to exist
i am using IntelIJ to setup my sql database
i dont see the table creation
well you don't have it
I made it with the console it opened
code:
-- Create the database if it doesn't already exist
CREATE DATABASE IF NOT EXISTS kingdom_invites;
-- Use the database
USE kingdom_invites;
-- Create the kingdoms table if it doesn't already exist
CREATE TABLE IF NOT EXISTS kingdoms (
id INT AUTO_INCREMENT PRIMARY KEY, -- Auto-increment ID
name VARCHAR(255) NOT NULL, -- Name of the kingdom (required)
leader_uuid CHAR(36) NOT NULL, -- UUID of the leader (required)
description TEXT NULL, -- Optional kingdom description
banner_link VARCHAR(512) NULL, -- Optional banner URL
UNIQUE (leader_uuid) -- Ensure unique leader_uuid
);
-- Optional: Clear existing data before inserting sample data (only for testing/development)
TRUNCATE TABLE kingdoms;
-- Insert sample test data, avoiding duplicates
INSERT IGNORE INTO kingdoms (name, leader_uuid, description, banner_link)
VALUES
('Kingdom Alpha', '123e4567-e89b-12d3-a456-426614174000', 'A peaceful kingdom.', NULL),
('Kingdom Beta', '223e4567-e89b-12d3-a456-426614174001', 'A kingdom of warriors.', 'https://example.com/banner_beta.png');
-- Verify inserted data to ensure everything works properly
SELECT * FROM kingdoms;
let me introduce you to the stream api
well does it actually exist
SHOW tables;
i need this for my view class
i cant use streams there
It showed 1 table 'kingdoms'
idk what you mean by that but sure you can?
make sure you're using the correct database
I think I am:
config.yml
database:
jdbcUrl: "jdbc:mysql://localhost:3306/kingdom_invites?allowPublicKeyRetrieval=true&useSSL=false"
username: "root"
password: "removed"
also I'd recommend using https://github.com/jetbrains/exposed
i need this because i implement Iterable<> interface for my view class
no idea why you'd be getting that error tho
im using kotlin but I didn't convert it yet
i don't see the problem
Yeah i also have no idea really weird
Can I install a Multiverse Portals Plugin on Spigot 1.21.3? If yes, which one? I can't find it..
why do you need to remove antthing in your iterator
stream.filter() will work only for processed elements before. If i add something via add() method on veiw, iterator will have it on next(), meanwhile if i do filter() before adding something, Filtered stream will not include that element
you are just moving over items
yes but the same thing applies
it will only work with the snapshot of the data
not the current data
I guess there is a decision to make for duplicate values
not that you should be mutating a collection while iterating it anyway, regardless of how you do it
say you have a filter on an iterator of your type, then you have to decide to remove all instances of the value or only the first one since after that the value is not unique
you can if you're underlying iterator is backed by concurrent hashmap implementation
like I assume you wanna filter out all the values if there are duplicates, not just the one that happens to be first
never said you can't
it's just bad practice
not that you should
iterators are just as ephemeral as streams too
well streams are lazy in java. They only do operations when the values are being collected. So in any way you will capture the snapshot of the filtered data.
it will skip anything that would be filtered out
so are iterators?
and the collection is probably the only thing that does any work
each element is individually evaluated at a time at every step in the iterator chain
yes but they do not copy the data
neither do streams
streams do not copy any data
by moving through the chain for each element
i have no clue what you are talking about
and how would you collect values from an iterator without a new collection 🤨
you can also just iterate values in a stream
meanwhile in streams i have to collect it first
you don't have to collect them
no
my dude
streams are literally implemented as a chain of iterators
like, actually
you don't have to put them into a collection to operate on the elements or anything
if you decide to iterate them using forEach without collecting them you're essentially just evaluating them still, but internally
yeah?
and?
same thing with iterators?
if you do forEach you will evaluate them
streams are actually just iterators under the hood
i guess. Streams can also be used for this, but what I wanted is just a way to implement iterable for my view for nicer enhanced for syntax
Streams wouldn't allow me to do this, unless i dont know something
that's not a nicer syntax
you can just make your iterator method return the stream's iterator
Iterator<T> iterator() { return source.stream.distinct.iterator }
ok, you got me. I didn't knew earlier before that Stream api provides iterator() publicly
well that's lot of time wasted
implementing this
🥲
welp at least i learned something new
congrats emily you got them
Stream#distinct also makes for some fun optimisation, if you're using a sorted source like a treemap it does not use a set/map to know for distinctness
converted
so i guess streams api in java can be thought of as a custom iterator builder in a sense
kind of
my iteration impl is something what you had to do pre java 8 like without any libs. I'm switching my custom iterators inside view classes for stream api ones. Thanks @slender elbow
sick
this will get rid of 5 custom iterators
😄
return this.data.values().stream().flatMap(map -> map.values().stream()).distinct().iterator(); returns distinct nested map values
i should probably cache the stream object somewhere as a private field so that i wouldnt have to construct stream object all over
i guess if i dont return stream object
i should be fine
since iterators cannot close streams, right
streams are single use, but so are iterators
If you're doing something terminal, you can't reuse a stream
doesnt stream produce new iterator on each call
oh
A terminal operation is basically anything that doesn't return the same stream
At that point it just cuts it off and says "No more operating on me >:("
So yeah, Stream#iterator() returns the contents of the stream as a new Iterator
but why don't we have reusable streams. At this point it would quite handy to store the state of the stream inside some kind of field
That's just not what streams were designed for
You could use a collection for that
the source of the stream might be stateful
and backed by resources like files or something
any solution to "reuse streams" would involve rebuilding the entire pipeline anyway, but like, it's a handful of objects we're talking about here
chm iterator is weakly consistent by any means anyway so bad example
v: 3700
type: DIAMOND
meta: !!org.bukkit.craftbukkit.v1_20_R3.inventory.CraftMetaItem
...```
I wonder if this global tag is serialized with an item or it was created by dumper
Looks strange, there shouldn't be any CraftMetaItem if done from the API
@Override
public Object represent(AnnotatedType type, Object obj) throws Throwable {
Method method = obj.getClass().getDeclaredMethod("serialize");
return method.invoke(obj);
}
}```
I use the serialize method so I'm not sure what's causing it
It's not that simple to serialise
You need to recursively serialise setializable types and also expand aliases
That looks like yaml so why not just use the yaml config API?
I'm using config annotation based so it looks quite weird
That's the representer spigot uses (see RepresentConfigurationSerializable)
But you'll also need to implement recursive representation if your yaml API doesn't automatically
Ok thank you 
Can someone tell me what I'm doing wrong?
I'm starting to create my first plugin, and when I try to import some classes like (import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.NamespacedKey;
import org.bukkit.Java.util.UUID
)I get an error, I try to change the libraries (in file pom.xml) from spigot-api to spigot server, but I get an error, I don't know what I should do
run buildtools?? right
when i deop myself i dont have access to warp command why is that wtf do i do idk man
I'm very new and have little knowledge. Can you explain a little more? Should I download it from the link and install it?
BuildTools is a necessity for developing spigot plugins.
Download it.
Run it for the version you are developing against.
Refresh/reload your project.
Don't forget the remapped flag
how is it?
I'm installing it, thanks man, i get it
for developing... not always
for testing... yes
Love yu men!!
Loveee yuu!1
nop, it´s same, i can´t import the classes
what happend
What are the dependencies and repositories that I need to import classes as (import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.NamespacedKey;
import org.bukkit.Java.util.UUID;)
Update Intellij and switch back to -api
You don't need the full server dependency unless you're working with internals
Which you should avoid especially since you're a beginner
i need to creat a new project, or change some think in pom.xml, how i can update intellij? idk
What
to make a new project in intellij u do it either from the project select menu by hiting new project
or if u have a project loaded, do File -> New Project
and as far as modifying ur POM.xml, intellij has a handy little button to refresh the project when it detects changes made
yeah, but still it doesn´t work
Hey I’m looking for someone as I have no developer for my new Minecraft server and I’m in desperate need of one.
?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/
You ran buildtools?
yeah, download from link, execute, after click on compile, (version 1.21.3)
In which directory or folder should I save it?
save what
buidtools before compile
doesnt matter
its just the exe or terminal version of buildtools, compile it in some folder
and then the resulting spigot.jar is the server
could someone help me with my plugin? I've got an issue with the connection with my mariadb
if possible pm
Just ask here
its a bit longer thing
You can make a thread if you want
Or if you plan on sending a massive message use paste
?paste
still, I would like to ask sb private, but thanks
but another question for here, how to fix this issue
?paste
no maria driver, and paper
you didn;t package a driver
if you are not usign any mariadb specific funtionality just use teh standard packaged MySQL driver
I got the mariadb on my server, what do you mean by packaging a driver? where do I do it and how do I do it?
you include it in your plugin when you build it
if you are compiling with maven you include it as a dependency in your pom
or add it to your plugins libaries section of the plugin.yml
are you running mvn package, or are you building with Artifacts in your IDE?
If InteliJ the maven tab is on teh right of yoru screen
under lifecycles double click package
do I use the original-plugin or just plugin name
just plugin name
let me try
shortest jar name
same error. Check your jar does include the driver
rename jar to zip and browse through it
look in the org folder
apache, checkerframework, mariadb and slf4j
you may need to init it then in your code before using it
Class.forName("org.mariadb.jdbc.Driver");
in which file do I init it and where exactly
so I think in databaseManager
private void initializeDatabase() {
try {
// Laden Sie hier Ihre Datenbankeinstellungen aus der Konfiguration
String url = "jdbc:mariadb://localhost:3307/kieremeconomy";
String user = "server";
before this one?
yes, I guess. Too little code to tell
before the connection = DriverManager. code
after string password?
add to the enclosing try/catch
look at teh advice box Intelij is showing you
simplest fix is to change SQLException to Exception
no
just change teh catch clause
oh man im so dumb sorry but I dont understand how 
brooo tf now
its working
im so dumb sorry man
Let me try
there is a shaded version added now
but still use the shortest jar right?
always shortest named jar
well there is a new problem
[01:48:14 ERROR]: [KieremEconomy] Fehler beim Verbinden zur Datenbank: Socket fail to connect to host:address=(host=localhost)(port=3307)(type=primary). Connection refused
you need the whole text?
or is it okay
refused = wrong port/db/password
socket fail, so port is wrong
3306 is teh default port for maria. Unless you changed it
but hooow I've changed it on pelican
the error seems to say its not on 3307
maybe it can help
2025-01-01 1:38:57 106 [Warning] Aborted connection 106 to db: 'minecraft' user: 'server' host: '172.18.0.1' (Got timeout reading communication packets)
thats what my db says
on pelican console
ah
I'd fix the credentials then
is it hard for an idiot like me?
in yoru connection string you are passing minecraft
the plugin or db?
um your eco code says its using kieremeconomy
yes
but your pelican log says it tried to connect to a db of minecraft?
ive got the database minecraft for backups I guess and kieremeconomy for this plugin
and I looked in my db
and there is my plugin
then its workign. the pelican error is a backup error
however it was refused the connection
you have an idea what Can I do ?
which is usually a user/password error
check that user has right to access the correct db
err user:server
no clue
i just copied the password from luckperms
the password is on the user. but you also have to grant the user access to the db
SELECT User, Host FROM mysql.user;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'mysql -u root -p
mysql -u root -p
mysql -u root -p
mysql -u root -p
mysql -u ...' at line 1
cant help with the SQL bit. Its been so long since I did any SQL syntax
your driver is workign now though. You just have to get your db setup properly
I thank you a lot man, you helped me a lot
if someone has db knowledge, please let me know
you could try asking chatgpt, it always helped me with sql
wait am i stupid or have chunks always had pdc?
1.16.3 it looks like
hey does anyone know what servers like Hypixel might be modifying for their fireball explosions?
(also, I'm still quite new to Spigot so aplogies if I have any misunderstanding or ask about something silly by accident)
in a 1.8.8 server I'm trying to make throwable fireballs, that can be used for knocking off players or using them on your own player to perform a "fireball jump". similarly to what you'd see on Hypixel Bedwars and Minemen Fireball Fight
I've got the basic feature working, right clicking shoots a fireball, and it explodes on impact, but the physics seem off. with the vanilla fireball explosions I seem to not be able to perform the jumps and get the KB height I am looking for when shooting the ground.
does anyone know what changes most of these servers make to these fireball explosions? I'm unsure as to whether it's the explosion being changed itself, or the knockback, or if velocity is being set manually to the player during explosion damage events
not sure how they do it, would just set the velocity manually, then you have control over the how strong the boost is
hypixel and minemen are both based off 1.7.10 iirc, perhaps it is just as simple as there (maybe) being a change in fireball explosions between 1.7 and 1.8
I see, good point. I had not considered that so thank you for bringing up that possibility
at this point they essentially have their own forks that are not remotely the same as spigot etc. Yes there custom implementation started from 1.7 but it isn't correct to say they are running 1.7 servers though
just that is where they started as a basis
as long as you implement the protocol, you can essentially do whatever you want
how can i change the recipe of crafts from a crafter?
im trying to make only 1 mace craftable and the crafting table works but the crafter keeps the mac recipe
like in the whole world?
or do you mean 1 mace per player
thats gonna be hard
as crafters can be automated
1 mace only
yea fr ive been trying for so long
couldn't you just remove the recipe entirely
i just want to make it so the mace cant be crafted by the crafter
ive tried
unless i did it wrong
Can anyone tell me what external jar I need to import to be able to use CraftEntity? I have Spigot 1.21.4 API right now and it's not working. I also tried the shaded API as well as the server jar and the remapped one.
?xy
k
nope, doesn't work
ok I'm just trying to make a custom entity
specifically want to ride and control it
using the spigot jar breaks everything
I don't know what those are
How the fuck are you developing this plugin?
Are you just like using Eclipse or whatever and specifying the jar file or something???
well I have eclipse and I clicked on add external jars and I put the API from build tools in...
I dont know if this is your issue, but it would be better for the long run if you used a Build Tool
they mean to say a build system
nvm, I have no idea what I'm doing >_<
you will need to either use maven or gradle
and add dependencies in through that build system
it used to be easier XD
Don't want to offend you or anyone else here, but maybe try using intelliJ, it makes using a build system easier 😭
I have that
okay sooo use it
and install the plugin called "Minecraft Development" it will auto-do whatever Spigot u need
trust
its gud
its the bomb
its the shit
couldn't figure out intellij
you don't need the mcdev plugin
you really don't
intellij is not difficult to figure out
IM FUCKING LAZY
i really recommend you use maven
because the configuration format (pom.xml) will likely be a lot easier for you to work with than the DSL that gradle uses
and it's also just XML
a format that has existed for 30 years
dang it I spent like an hour trying gradle
couldn't even get past "extends JavaPlugin"
ah gotchu
when you have the main class and it needs to say extends JavaPlugin so your plugin can have onenable and stuff but I can't get "JavaPlugin" to resolve
did you import it
yes I did
show gradle
oh that was when I was trying to use paper...
what do you have now
hang on let me change to spigot...
ok that's a lot of fireworks in a city that banned them -.-
always happens
it's up to you.
I'd say gradle is much easier
I'll fight you on that
but you are free to use any build system
if you already have gradle, use that
Yeah if it doesn't work then show us, we'll figure it out
Maven is typically easier and there is plenty of documentation and guids/tutorials for just about anything in regards to it
can I stick with eclipse? XD
you can
change is hard
yeah eclipse has its own maven stuff
oh look it's 2025 😄 Happy new year guys
no idea
I have the spigot jar in referenced libraries
I'm just trying to figure out what else I need to do
you havent shown any code or configs
I don't have any yet because JavaPlugin won't resolve
someone probably already told me what to do. I suffer from memory loss
your gradle file?
isn't that not maven?
I don't have one, still not sure what it is
okay what build system are you using
are you using eclipse or intellij
eclipse
HEY GUYSSS! xd
hello
google doesn't forget
sounds a bit sinister lol
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
how do i check if the itemstack they are holding is my custom itemstack?
do i just check if the item name is the same as my itemstack like this?
item.getItemMeta().getItemName().equals(HAMMER_ITEM.getItemMeta().getItemName())
and how can i slow down the mining speed of a itemstack pickaxe with attributes in 1.21?
?pdc
Give your itemstack a custom persistent data holder and check if the item meta of that item has it
what would a usual data value be for this sort of thing? a string? or?
I use a string that is then used as a map lookup
If it’s just something that you need to check for one specific behavior (an egg that hatches 2 chickens for example) I just use a Boolean, if it’s something that’s has a variable such as an egg that spawns x number of chickens I store that as an integer, depends on your use case
its just a custom item "hammer" that i want to check if the hammer is being used when a block is broken
Then I’d just store a Boolean on it and check if that pdc exists on the item
what happens if i have another item with a boolean set then how would it tell the difference?
You go by the identifier of the pdc, you’re not checking if the item has any Boolean you’re checking if the item has a pdc entry with your identifier
This is where the string and map lookup comes in when you have a bunch of custom items
Rather than a bunch of if statements
so this is what i had made
public ItemBuilder setPersistentData(String persistentData){
NamespacedKey key = new NamespacedKey(getServer().getPluginManager().getPlugin("Hammer"), "plugin");
meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, persistentData);
return this;
}
let them use their key instead of 'plugin'
my items can get an optional compare_key string tag that I use for comparison of custom item types
if (item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(getServer().getPluginManager().getPlugin("Hammer"), "custom_item"), PersistentDataType.STRING)) {
// Code for hammer
}
``` so checking the item would look like this?
yeah pretty much
so really the name space key is telling me if its the correct item or not and not the persistent data itself
The data should be telling you ideally
so i should be checking if the item has a persistent data with the namespacedkey then after that getting the persistent data and checking if its correct?
Ideally you use the same key for every custom item
And then use the data to determine which item it is
right but i still need to check if it has data first tho right? then check if the data is correct?
Yes
if (item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(getServer().getPluginManager().getPlugin("Hammer"), "custom_item"))) {
if (!Objects.equals(item.getItemMeta().getPersistentDataContainer().get(new NamespacedKey(getServer().getPluginManager().getPlugin("Hammer"), "custom_item"), PersistentDataType.STRING), "Hammer")) {
return;
}
// Code for hammer
}
would this seem right?
You can compact that, but yes that should work
compact it by turning the namespace into a variable so its not used two times there?
NamespacedKey key = new NamespacedKey(getServer().getPluginManager().getPlugin("Hammer"), "custom_item");
if (item.getItemMeta().getPersistentDataContainer().get(key, PersistentDataType.STRING) != null) {}
so like that for the first if statement?
NamespacedKey key = new NamespacedKey(getServer().getPluginManager().getPlugin("Hammer"), "custom_item");
String data = item.getItemMeta().getPersistentDataContainer().get(key, PersistentDataType.STRING);
if (data != null) {}
you mean like this?
Yeah so you won't have to get it twice.
If it's just to verify it's a custom item then you don't need to do that just check it like before
NamespacedKey key = new NamespacedKey(getServer().getPluginManager().getPlugin("Hammer"), "custom_item");
String data = item.getItemMeta().getPersistentDataContainer().get(key, PersistentDataType.STRING);
if (data != null) {
if (!data.equals("Hammer")) {
return;
}
// Hammer code
}
NamespacedKey key = new NamespacedKey(getServer().getPluginManager().getPlugin("Hammer"), "custom_item");
String data = item.getItemMeta().getPersistentDataContainer().get(key, PersistentDataType.STRING);
if (data != null) {
// Hammer code
}
so your saying just do the second option instead?
I mean it depends on your goal
i mean for at least this moment im just having a singular custom item
but do you wanna know if its that item or do you wanna know if its an item from your plugin
logic wise
well would need to know if its that item because it does stuff that only that item should be able to do but there is also only that item in the plugin so either way would work fine from the sounds of it, but may as well make sure its that specific item and not just one from my plugin
so am i correct in saying the namespace key would be useful for if i had tools and armor in my plugin then i could have a namespace for tools then one for armor? or am i just misinterpreting namespacekey?
well thats another way to use it
namespacekey is used to tell something apart, minecraft uses it for a bunch of things, like item types or advancements, so you can do it similarly, but for pdc the namespacekey is just the key of the item data you want to have
i.e. you can have a second key called item_type or whatever that could be tool, armor, or whatever
kind of a bad example but yeah
You can also do "Hammer".equals(data) and skip checking if data is not null
Because equals will return false anyway if data is null
NamespacedKey key = new NamespacedKey(getServer().getPluginManager().getPlugin("Hammer"), "custom_item");
String data = item.getItemMeta().getPersistentDataContainer().get(key, PersistentDataType.STRING);
if ("Hammer".equals(data)) {
// Hammer code
}
so just this? makes sense
yes except that data.equals("Hammer") will throw nullpointer exception if data is null
if ("Hammer".equals(data))
and "Hammer".equals(data) will not because "Hammer" is not null
id just null check and return
Dependency error I cant seem to resolve :?
Hello, is anyone here good with models, using the mythicmobs, modelengine and oraxen plugins?
?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!
i'm looking for someone because i can't send picture or smth here
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
Use imgur 😛
Guys, how can ItemStack's ItemMeta be null??
air yields null
did you assign the itemStack itemMeta?
so about this text description in spigot when submitting premium resources, can I put the text description in a spoiler that says text description and put image description about it?
but isnt air itself null
no
Hi
how can i get the width of a textdisplay?
You can't really
oh
Text size is font dependend
ok so the issue im having is the following:
and the font can be changed via resourcepacks and such
https://i.badlion.net/dwJd5ytEtbzvT7ZUsnVTgX.png this is what it looks like with a single digit amount of items inside
https://i.badlion.net/qrbwfKqTMc4FnrLXCbtYwh.png and this is with double digit items
looks bad
one solution i had in mind is to offset the text on the left by -width of a single digit
One fun solution is to force a resourcepack, have that RP supply a specific font, use that font (requires papre or nms tho) for your numbers.
That means you know what font the player sees and you can be sure you know the width.
meh
are you talking about the coal? why don't you just change the text alignment to right aligned and not center
theres a text alignment option????
damn
ye
why didnt i think of that 😭
i will still have issues with the item on the right though
yeah that's the only problem i see with it
you could just add extra padding on the one on the right and keep it center aligned so the text doesn't overlap
would anyone know of anyway I could make a custom smithing table recipe like I could with a normal crafting recipe without using prepare events?
its fine i think i almost got the width down
its 0.04 with my transformation
but ill use text alignment on the ones on the left
thanks!
np!
thank you! this will be very helpful
doesnt work ): https://i.badlion.net/Txr9JQYX9Hr8ebk3GrzeaC.png
code?
public static TextDisplay showText(String text, Vector translation, Direction direction, Location baseLoc, TextDisplay.TextAlignment alignment) {
Location loc = baseLoc.clone().add(swapSign(swapXZ(translation, direction), direction));
return loc.getWorld().spawn(loc, TextDisplay.class, display -> {
display.setText(text);
display.setSeeThrough(false);
display.setBillboard(Display.Billboard.FIXED);
display.setShadowed(false);
display.setRotation((float) directionToAngle(direction), 0);
display.setDefaultBackground(false);
display.setAlignment(alignment);
display.setTransformation(new Transformation(new Vector3f(), new AxisAngle4f(), new Vector3f(0.5f, 0.5f, 0.5f), new AxisAngle4f()));
});
}
``````java
textLeftA = SpigotHover.showText(leftText, new Vector(-0.3625, 0.545, 0), direction, baseLoc, TextDisplay.TextAlignment.RIGHT);
might be a thing with the transformation?
as in the transformation might be causing the alignment to look centered
hm
@worldly ice https://www.reddit.com/r/MinecraftCommands/comments/12j2jvy/comment/jfxc37r/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button seems like its only supposed to align multiline text
and not the kind of alignment we want
hmm that's annoying
i dont believe there is a way to do that then without being hacky
okay
ill just go with 0.04 then lol
seems to look okish
(for you, as stated before, if someone has RP that changes font, it may be broken for them)
Could just hardcode the widths of the default font then
It will become a you issue the second someone reports a bug
im not sure how to translate pixels into ingame coordinates
every digit is 6 pixels
I got this working, although the plugins custom recipe gets overridden with the original one (its a netherite templet, diamond sword with some data, and netherite) though if i change it the base item to a gold helmet for example it work just fine, are there any work arounds for this?
could anyone help me with this if they dont mind?
can you share your code?
if it's just addRecipe then its probably a bug
in which case
?jira
ItemStack result = dagger.returnDagger(5);
RecipeChoice template = new RecipeChoice.MaterialChoice(Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE);
RecipeChoice addition = new RecipeChoice.MaterialChoice(Material.NETHERITE_INGOT);
RecipeChoice base = new RecipeChoice.ExactChoice(dagger.returnDagger(4));
NamespacedKey key = new NamespacedKey(DynastSMP.getPlugin(), "netheriteDagger");
SmithingTransformRecipe daggerRecipe = new SmithingTransformRecipe(key, result, template, base, addition);
Bukkit.addRecipe(daggerRecipe);
}```
the 'dagger's are just custom swords
5 is netherite and 4 is diamond
it works just fine as long as the base item isnt diamond
if it is it'll just output what it normally would
Your key is invalid
"Namespaces may only contain lowercase alphanumeric characters, periods, underscores, and hyphens."
changing it to "netherite_dagger" didnt fix my issue
did you allow the player to discover the recipe? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/HumanEntity.html#discoverRecipe(org.bukkit.NamespacedKey)
i believe so, the recipe works just fine as long as the base item isnt diamond
Is diamond the only one that has a vanilla recipe too
what do you mean?
Is the issue w conflict with a vanilla recipe?
Isn't that what you were saying earlier
Or is nothing happening
yeah im pretty sure its just conflicting with the vanilla recipe, it just outputs the same sword as before just now netherite
not the new item it is suppose to be
how would I do either of those?
sus link
lol
the real link is to sus
i trust lmgtfy/search more than gprivate/magic
lmgtfy is too revealing tho...
i did that, not a whole lot came up to help just plugins
i was looking for docs
I mean the method you're looking for is called removeRecipe
so it shouldn't be too hard to find in the javadoc
ill take another look
google doesnt give much info but the docs directly are really helpful 😭
?
this i mean https://jd.papermc.io/paper/1.21.4/
just googling what im looking for doesnt show much but this does
i gotta start using it more :/
?jd-s
ohh i see, well thank you i almost missed that
uhm
I'm trying to push an update for a plugin on a github repo via IntelliJ but whenever I commit and push the update it does not update the github repo
Any error messages
I always forget if world#getBiome takes world coordinates or biome coordinates….
Ive been having issues with it aswell, i logged out and now it wont let me log back in xD i just gave up
hi, i want the spigot 1.20.6 maven, how i get?
Could not find artifact org.spigotmc
pom:1.20.6 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
Hi guys! Speaking of maven, I'm trying to set mine up for a project that needs spigot and craftbukkit together. I finally got spigot working but I don't know what to do for craftbukkit. I think I need the craftbukkit-1.21.4-R0.1-SNAPSHOT jar? I added that but I don't know how to add it in the pom.xml
You just need to depend on the spigot artifact instead of spigot-api
?nms
I already read that but ty
that broke everything. none of the imports work now
could I show my pom.xml?
I'm pretty sure the problem is in there
?paste it
When I create an armor stand and then set it to invisible, there is a split second where the armor stand is still visible. How can I make it so the armor stand instantly becomes invisible as it is created?
you can use I think it was called a consumer to modify it in the spawn method instead of modifying it post-spawn
LivingEntity livingEntity = (LivingEntity) spawnLocation.getWorld().spawn(spawnLocation,
customBossesConfigFields.getEntityType().getEntityClass(),
entity -> applyBossFeatures((LivingEntity) entity));
that's what i use, the generic would be
LivingEntity livingEntity = (LivingEntity) spawnLocation.getWorld().spawn(spawnLocation,
entityClass,
entity -> myCoolMethodThatRunsBefore((LivingEntity) entity));
private void myCoolMethodThatRunsBefore(LivingEntity livingEntity){
...
}
or whatever
okay thanks
how do I do another consumer for doing setMarker(true);
for the same object
you just do everything you need to do in the one method
or have that method call other methods if you need to
ohhhh ok
Hi, does anyone know how to use Spigot 1.8x?
this is what I did. I get an error that the armor stand is null
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.
that's not what you did, because the code I showed uses the spawn method from spigot
Did anyone have time to look at my pom.xml? I've been experimenting with it and narrowed down the issue. The dependencies can't find their software in the repository. No idea what that means but maybe someone here does ^-^
While waiting I made sure I was using remapped jars
so like this?:
stand = originLocation.getWorld().spawn(originLocation, ArmorStand.class,
armorStand -> armorStandMethod(armorStand));
No
have you ran bt?
Yep brand new buildtools
my pom.xml is a mess and getting worse while I try to fix it XD
does the Player class use different logic objects like registry factory etc. inside it? Or is it a data class?
I'm making a plugin for statistics and I'm thinking about whether to stick to the Player example from the bukkit api or create a manager class?
Remove the type tag and remove the craftbukkit dependency.
Reload your Pom afterwards
Ok but then I can't make Craft Entities, can I?
If you make it a marker I assume you are doing some display thingy. I'd recommend display entities for that as they are lightweight and don't eat as much performance as armorstands
I don’t see why you shouldn’t.
I am trying to add craftbukkit because it wasn't letting me with just spigot
if you read this your pom shouldn't look like that lol
it's not as simple as just changing spigot-api to spigot, it takes more steps than that
?nms
I can't use that, it gives me an error at the "[...]" about... being well formed?
That's meant to show "other stuff you put here"
You're not meant to copy that part...
removing it doesn't help either though
well it ought to show a different error now then
yes it has a different error for each way
Have you run BuildTools guy
Yeah I got my spigot jar out of it
- send your pom again
- did you run bt with the same command as in the article (obv. change version)
- send what errors it shows
https://paste.md-5.net/apugaxutix.xml
I ran it from the gui so I need to change the arguments...
And it looks like the pom.xml is missing things but idk
Is that your full pom ?
You're not meant to just copy and paste it from the article, you're meant to add those things to your existing pom.
yes but people keep linking me to that without telling me how to start 😛
buildtools is running
Ig ppl usually assume you know what maven is and some basics
And that you would know to not mindlessly copy paste stuff without knowing what it is/does
the thing is I need to depend on spigot AND craftbukkit. is that even possible?
with just spigot(remapped, not api) I can't make a CraftEntity
Sure you can (well I think at least)
nope I've tried everything but I can't get it to import
So far your pom was not correct and you probably never built the correct dependencies either
probably not
If you fixed all that, you should have access to all nms and craftbukkit
well buildtools finished. going from there let me set up a maven project
@potent atlas still???
dude for the love of God use intelliJ
I'll even call you and show you, if u find it confusing
-# what, what are they using
eclipse ;-;
oh, that's not that bad
intellij doesn't show me the errors
If someone is offering as much as to call with you to show you IntelliJ, I would accept.
It really is an upgrade.
imo you should attempt the switch anyways. there is a plugin for intellij that makes setting up any MC modding/plugin project very simple, just few clicks.
oh I don't have money for intellij
well I have that but I figured it doesn't do the highlighting errors and stuff because it's not paid for
anyways eclipse says my plugin doesn't have an explicit coding set so as promised, over to intellij
You have something incorrectly setup.
Well then, I guess feel free to message/call that other guy if you have problems, he'll surely be more help in this case.
mmk got set up finally... and got the same error eclipse gave me
Project 'Taxi' has no explicit encoding set
StackOverflow is saying that
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Is missing from your pom
intellij community has all the features the premium version does except features that are really only necessary for commerical products anyways.
Eclipse Project encoding setting is an IDE warning not a Maven thing. There is a default setting, which if nto set, all projects will give this warning
Setting it in Maven can stop the error when you update the project. It just applies to the workspace
show your pom again...
I was told I could use CraftEntities with just spigot
just to clarify
it is included in spigot but not spigot-api ?
correct
refer to this message please
change the spigot-api to spigot
then go to the article again and copy the part starting with <plugin> and ending in </plugin>
paste it into the corret place, change versions
it should work then
Right
<classifier>remapped-mojang</classifier> <!-- Important! -->
If he needs remapped, yes
if he ONLY wants craft he can just change the artifactId and run buildtools normally
anythign below that be needs remapped
right, thank you for that info
I think I got it o:
Congratz!
I do apologize for my incorrect help, I tried to get you to do more than you really had to.
Hello! I'm trying to make a plugin which behaves somewhat like DiscordSRV. However, I'm stuck on the console integration part. Could someone please guide me in setting up the console logging in Discord?
?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!
ask specific questions so people have a better idea on whether they can help
would it be possible to find / replicate the logic behind scaffoldings falling? i.e. "will i fall at this location because im too far away from the base or im not connecting to any scaffold thats close enough to a base"
Yes
yes im looking at that
but both get max distance and distance are returning 7
just quick testing
for the max distance i assume its hardcoded, but the distance one i dont fully get
Basically, I have a Handler class which essentially just sends any log message provided by JavaPlugin.getServer().getLogger() in the publish() method. I initialise all information needed by Discord in a separate Manager class and call functions from it in the plugin's Main class. However, inspite of correct initialisation, the console integration doesn't seem to work. Also, when I try to use /reload confirm on the server, the console integration briefly logs 2 messages and stops.
ah nvm its stupid mc, i had to delay the getDistance..
💀
just wanted to confirm this, servers dont have like a unique ID right or like some way to tell its unique besides obv IP
I also have a public GitHub repository if someone is willing to look at the code... it's at https://github.com/Buoyy/DTMBridge
You should not be using /reload, it is not supported
I just used it randomly, and for some reason it worked briefly
do you have any logs on the receiver end of the mc -> discord message?
I can send them, sure..
ignore the first two messages... I had accidentally linked the chat channel to the console channel
so if you fully stop the server and start it, the message manager will still not work, until you restart the server, the plugin works briefly and then stops working again?
No... when I use the command reload confirm in my server, it works for a brief period. Not an actual restart.
With no code its hard to tell where your issue lays
right but what happens if you fully stop the server
he linked the git
If it works from a normal startup but not in your reload its likely an object initialization issue
The Bot instance is shut down correctly... nothing erroneous there
I did get the chat linkage to work correctly, though. It's (hopefully) correct.
I meant the server reload command.
um, it seems you never call initJDA
where do you call the constructor for ConsoleDiscordHandler
There is no call reference for initJDA in that Git repo
im just blind ik you do
On line 92, Manager.java
My main class is pretty short, so it shouldnt be a problem to look up
ty
The Manager class did get clogged up a bit, I guess
initGuildChannels() is borderline unreadable for me, look up guard clauses (also called early return)
Should i call initGuildChannels() inside of initJDA() instead?
why do you queue ie channel.sendMessage(msg).queue(); and are you not supposed to dequeue it
Because I did do it, but to no avail
afaik, we arent supposed to dequeue it. The JDA documentation said it was mandatory or something during sending messages
That is not what I am saying, guard clause will remove the many nested if-elses
it could be timing out
if only works on restart it could be flushing it out
Possibly, yes... because the chat messages show up relatively slowly than any logs
alright lemme review it
add a error method for the queue and see if theres an error thats being thrown too
^ this too
I'm relatively new to using logging... could I get a bit more help here? I'm extremely sorry
it has a consumer, use it to see the response of the request
declaration: package: net.dv8tion.jda.api.requests, interface: RestAction
Alright, hold on
,queue(
success -> {sout("Sent to discord")},
error -> {sout("error sending to discord");error.printStackTrace();}
)
smth like that
use https://ci.dv8tion.net/job/JDA5/javadoc/net/dv8tion/jda/api/JDA.html#shutdownNow() instead of shutdownJDA, its probably better
declaration: package: net.dv8tion.jda.api, interface: JDA
I did use shutdownNow() earlier, but it only caused errors when stopping the server.
Did that, but there's nothing being printed.
It looked like that the shutdown wasn't able to complete
yea, we got to that part, but why isint it able to complete
lemme do it again and show you the error (if it still occurs)
not even the "sent to discord?"
Nope.
add an sout("Got console msg") at the top of the public method
lowk just doin debug stuff 💀
Alright so it seems that when I use shutdownNow(), the WebSocket for the Bot doesn't even get closed. Should I use awaitShutdown() too?
idk
Did that. Console is still empty.
based on this, yes https://ci.dv8tion.net/job/JDA5/javadoc/net/dv8tion/jda/api/JDA.html#awaitShutdown()
declaration: package: net.dv8tion.jda.api, interface: JDA
Alright.
send the error you get
oh boy this will clog the chat
?paste
ok so then it wouldnt be a discord sending the message issue and its rather a the loggers not being registered issue
Yeah.
should be fixed with sync shut down i think
await shut down
add a logger line so sout("constructor loaded") or smth in the constructor for ConsoleDiscordHandler, if that works then its just due to the loggers level i think if it doesnt log then its due to the guildinit function
Sure.
That works..
So the handler does load up correctly.
so then its a level issue most likely
alright... lemme setup some kind of level check
here