#help-development
1 messages · Page 993 of 1
to avoid exceptions
He's clearly trying to program for minecraft without understanding java. I was one of those 😂
i indeed am
Don’t bully him he’s very new to Java
Unlike me, a pro
change .equals to .contains
and check if item, meta and lore is null
what's the issue? getContents() might return null items iirc so you can't just call getType()
Actually, do NOT loop the inventory contents. You shoudl get the consumed item from the event
you are literally tryign to check the item they just consumed
I have a question, can you still run all that code and have a .json file and a custom texture?
not a random one from their inventory
what even is the issue besides "just don't work"?
i just couldnt figure out how to grab an items lore without getting an error about it being null
Anyone know?
do not use inventoyr
as said, check if the item is null before calling any methods on it
and this ^ still important information to not blindly call getType() on everything that Inventory#getContents() returns because some of them might be null
😭 Does anyoneee know??
no need to ask every 1.5 minutes
you can bump your question again in 10 minutes or something but don't ask every 30 seconds pls
I have no idea what he is asking
I dont understand the question
i also dont get the question
Things dont even seem related
i think he means like a custom model for it or something
ah they're probably talking about custom model data + resource pack
We still have no idea what you are actually asking though
Okay, so basically can you import a 3d model texture onto a plug-in?
Or does it have to be a completely seperate texture pack
like
using the client
idk
A plugin is a thing and a texture pack is another
you'll need a resource pack. you can merge different resource packs ofc so you don't need a "completely seperate" one
wait that’s the perfect answer wtf
I believe you can now specify multiple (I think)
but what about my 1.3.2 server
really? that is awesome.
if it's not possible however, or you're using older versions: Here's how you can easily merge resource packs: https://www.spigotmc.org/resources/resourcepackmerger.103875/
play chess!?
when someone gets a chance I am struggling with custom config files, keeps rejecting the path I give it. I can show the file. I know the code, I just can't seem to find an example of how to write the path. thanks!
Yeah you can have multiple server resource packs as of 1.20.3
File chestsYml = new File(myPluginInstance.getDataFolder(), "chests.yml");
fanceeeh
that means I can stop updating my resource pack merger haha
oh my bad I said my question wrong
I'm writing paths -inside- the file to get the values
persons:
mfnalex:
age: 29
address: Münster
myConfig.getInt("persons.mfnalex.age") -> 29
or what's your question?
or do you rather mean something like this:
persons:
mfnalex:
something: asd
someoneElse:
something: asd
and now you want a list of "mfnalex, someoneElse"?
If so you do it like this:
ConfigurationSection persons = myConfig.getConfigurationSection("persons");
Collection<String> personNames = persons.getKeys(false);
the first example is the closest
maybe you could show us your config and then tell us which data you need, that'd be helpful
yep
one sec
ok here https://pastebin.com/j4XvXCpd
I need the x, y, z etc. for each point
I see, gimme a minute. Let's assume you got a class like this:
public class TeleportPoint {
public int x, y, z;
public TeleportPoint(int x, int y, int z) {
this.x = x;
// etc
}
And now you can basically do this, and loop over the result of getKeys
example:
List<TeleportPoint> tpList = new ArrayList<>();
// This is the whole "teleport-points" section
ConfigurationSection tpPoints = myConfig.getConfigurationSection("steps.step1.teleport-points");
// This loops over "point1", "point2", etc
for(String tpName : tpPoints.getKeys(false)) {
// This gets you the section for each point
ConfigurationSection teleportPoint = tpPoints.getConfigurationSection(tpName);
// Now you can get each point's values
tpList.add(new TeleportPoint(tpPoint.getInt(x), tpPoint.getInt(y), ...);
sth like this, sorry I'm on the phone. But I hope you get the idea
ohhh I'm stupid, I see where I went wrong. I can work with that! thank you!
alternatively, if do not need the names (point1, point2) etv you can use a map list
points:
- x: 1
y: 2
z: 3
- x: 100
y: 200
z: 300
oh smart
then you can use getMapList("points")
just a suggestion
hope that helps, I'm going to bed now, good night everyone!
goodnight ❤️
Edible blocks?
nope
Also question
it's the material you're .
how do i check the type like
Psueodo code
if block.type is diamond_ore
it is not assumed that the material that is returned from the block is a food item
type == Material.DIAMOND_ORE
alr thanks i tried using instanceof lol
yep np, for further reference all enums have that property, can compare using ==
Trying to set the max stack size, but doesn't seem to be setting
public static void setStackSize(ItemStack item){
if(item == null) return;
ItemMeta meta = item.getItemMeta();
if(meta == null) return;
meta.setMaxStackSize(1);
}```
Running this of different events that cause new items, like ItemSpawn, PickUp, InventoryClick
Sniped
dam, sorry for the stupid mistake 🤦♂️ thank you
NVM forgot about air
why is there nothing to break a block not natural, im trying to make it when a block gets mined it turns into a different block and then waits ... seconds to turn back
setType
Ahhh
I want to remake text from 1 page of book to the lore, and after that an opposite -> lore to the text of books page, but I always have problems with enters (\n) if I'm trying to save them like new line, and after that add them for each line, then they're duplicating
couple years ago i thought that 16gb of ram would be enough for my usage
but now i peak at 15 gb of ram with no problems
fuck me
intellij eats ram like its disk space
4gb of ram
just for one project
i give it the minimum that i can and it works fine lol
not entirely sure if this is a spigot question but is there any library to translate 3d models (e.g. from blockbench) into display entities?
oh hey illusion long time no see lol
ill look into this
Some days I wish illusion would be in a call so I can voulenteer myself to get yelled at
20 bucks and I yell at you for an hour how about that
wsup man
Keep in mind I was like 15 when we met so a lot has changed
20 bucks is like my weekly gas amount and to be fair, off 12 hours of work a week I need it D:
it's like half my net worth
It's like double mine
You spend $20 on gas?
Are you driving a small motorcycle?
are you?
No. My gas bill is like $100 per tank :(
does anyone know what math would apply to this, i have a vector (0, 0, -1) that would represent north (0 degrees or 360), but if i rotated this vector 45 degrees to the right, it would represent a vector x, how i get that degrees number i have that code,
float yaw = (float) Math.toDegrees(Math.atan2(FRONT_DIRECTION.getX(), FRONT_DIRECTION.getZ()));
yaw = (yaw + 360) % 360;```
which is returning wrong numbers
can someone tell me how to fix the error that says "Required Type : Collection | Provided : PotionEffect"
Z and X should be inverted in the atan2
p sure that's it
hello i enabled all config files for sand duplication (unsafe teleportation) but my sand is not duping, can someone help?
i'm playing on paperMC 1.20.6
Arrays.asList
List.of
your choice
can you tell me what this means
if you didnt know, then pls learn about the Collection.
yeah im trying to learn this stuff and none of it makes sense
This collections Java tutorial describes interfaces, implementations, and algorithms in the Java Collections framework
can you just tell me how to add it into the code correctly so i can go to sleep
player.addPotionEffects(List.of(new PotionEffect(...), new PotionEffect(...), new PotionEffect(...)));
Is there a way to fade out sound(music) volume?
It’s only 16$ to fill it up with premium 100% also yes, I’m on a ninja 400
3 gal tank, 1 gal reserve
Yeah that tracks
But that’s when it’s not raining, gas bill goes up to 35$ a week if it’s rainy
That’s when I bring the focus out and let me tell you 45 mpg city - 60 mpg highways is quite nice in that thing
also why does it not allow me to add strength in here
wrong import? Do you use nms too?
There is no FAST_DIGGING in the PotionEffectType Enum
in Spigot thats HASTE
ah I see, old version
what version of Spigot?
In pre 1.13 Spigot STRENGTH was called INCREASE_DAMAGE
hello this is a weird question but can i ask a help about my problem because i try to create command on my plugin and when i try it , it was not register on my server
check your latest.log for errors
is it set in your plugin.yml ?
check your latest.log for errors during startup
I'm putting money on a missing plugin.yml from the jar due to wrong build method
command is not in the plugin.yml you are using. show code where you register the command
Ghostbreeding.java:20
I keep on trying to build ImageFrames, but it isn't finding the dependenices in intellej. I have already build craftbukkit, and Spigot up to 1.17. https://github.com/LOOHP/ImageFrame I was wondering if anyone had any advice for me?
I'm also in vc lol
👀
What error do you get building?
plugin.yml https://paste.md-5.net/iwuqomoyut.http
Ghostbreeding.java https://paste.md-5.net/uvuyofedil.java
Here, one sec.
The jar on your server is not the same as the code you are posting here
sorry wrong link
this one is the ghostbreeding.java
https://paste.md-5.net/bakadogifi.java
your plugin.yml is not the one in yoru jar. run clean before Package in maven
Oh ok i'll try that. thx ( :
Okay, so I should clean first, then package right? If so, it failed. : / https://mclo.gs/5jsQheA
Is there a reason you are trying to build ImageFrame over using it as a dependency?
Yes, I'd like to make changes to it, but first well, I want to be able to build it .
did you build spigot using Buildtools?
Yes!
its wierd as this design is rubbish in ImageFrame
it shoudl be using Spigot not spigot-api and there shoudl be no craftbukkit dependency at all
yea tbh idek whats going on there
Buildtools doesn;t even build CB by default now
Yea, but it was easy enough to select the option to build it
are you 100% certain you build 1.16.1?
the build?
its failing building the abstraction
those are CB, what about spigot?
they are also downloads not maven repos
it must be installed in yoru local maven repo to be seen by maven
I had to download java 14 to build all the dependencies for this lol
browse to C:\users\yourname\.m2\repository\org\spigotmc
you should have a spigot-api folder if you built with BT
What does BT stand for?
you can double click it to run as it now has a UI
Oddly I dont see it
then you did not build using BuildTools
But I used this?
Interesting lol
Thx, that was a good guide
Im basically there now lol
I didn't go into the .m2 folder
at first
ah
lol
Windows 7 hehe
This is my spigot-api
Oh god
the best 🙂
Linux is the best apart from windows
I have never liked Linux. I've tried it a few times but it's just not as comfortable as Win7
Takes a while to get used to the missing pieces
So your saying it must be installed in my local maven repo to be seen by maven. Will I be able to just drag my jars into the folder and have it work lol?
no
Damn
there is a command you can install with though
I'm sure alex has a post about it, one sec
?nms for me
I’ll have to read about that, thanks (:
the one I posted is about installing jars to maven repo
mvn install:install-file \
-Dfile=somejar-1.0.jar \
-DgroupId=com.github.someuser \
-DartifactId=somejar \
-Dversion=1.0 \
-Dpackaging=jar```
just change args to match what you are installing
or, just run buildtools for each version you need
it auto installs to maven repo
Yea, what I originally did is build it on one pc, then transfer the jars to the other.
I am just doing it on the pc I built it on orignally
instead.
If anyone could help (:
Wrong task?
Uh try
public void stopTimer() {
if (taskId != null){
taskId.cancel;
taskId = null;
}
}```
maybe?
Also that is a funky way of doing tasks
you constantly reset the timeInterval to teh config setting so it never really decreases
Can you tell me a better way to do it?
public static void applySweatEffect(Player player) {
applySweatEffect = new BukkitRunnable() {
@Override
public void run() {
player.spawnParticle(Particle.WATER_DROP, player.getLocation().add(0, 1.6, 0), 3, 0.1, 0.2, 0.1);
}
}.runTaskTimerAsynchronously(seasons, 5, 100);
}```
I do mine like this
Idk if its better
oh Runnable
It's the same thing I'm pretty sure
oh I see, you reset after it counts down
You never call the stopTimer in that code.
I call it in a command
I assumed since it was a public method, that call comes from somewhere else
then there is no reason for it to not cancel
unless you are calling startTimer when its already running
I call stopTimer & then call startTimer
How can I track when someone gets item out of Brewing Stand?
Then there is no reason your task would not stop unless its throwing an error from the scheduler
There is no error, I can send you how I call it.
yep
What makes you think teh task is not stopping?
While testing, when i run the /reset-timer command the timer should restart at that time correct? well it does not it just goes on how it was
the timer will not reset on cancel as its external to the task
it will remain at whatever it was last at
It was working fine before though
you need to reset the timeInterval before you start your task
top of startTimer method
okay! I'll do that and let you know the result.
It's a curious ask, but why do you need an exception for console command?
Is the system supposed to be ran through console commands?
So that it could do the keyall events
Automatically
Gotcha
Thanks, it works perfectly now!
Hi there, anyone know how to send a chat with Item hover event with BungeeChat on Spigot 1.20.5+?
I tried 3 ways to send chat:
@Override
public void sendNBTDebug(ItemStack stack, @NotNull CommandSender sender) {
// test with NBTAPI
String nbtapi = NBT.itemStackToNBT(stack).toString();
System.out.println("NBTAPI: "+ nbtapi);
sendNBTDebugActually(stack.getType().getKey().toString(), nbtapi, sender);
// test with NMS
DataComponentPatch patch = CraftItemStack.asNMSCopy(stack).getComponentsPatch();
String nmsPatch = DataComponentPatch.CODEC.encodeStart(NbtOps.INSTANCE, patch).getOrThrow().getAsString();
System.out.println("NMS-DataComponentPatch: "+nmsPatch);
sendNBTDebugActually(stack.getType().getKey().toString(), nbtapi, sender);
// test with NMS stack
String nmsStack = net.minecraft.world.item.ItemStack.CODEC.encodeStart(NbtOps.INSTANCE, CraftItemStack.asNMSCopy(stack)).getOrThrow().getAsString();
System.out.println("NMS-ItemStack: "+nmsStack);
sendNBTDebugActually(stack.getType().getKey().toString(), nbtapi, sender);
}
private void sendNBTDebugActually(String key, String nbt, CommandSender sender) {
net.md_5.bungee.api.chat.HoverEvent hoverEvent = new net.md_5.bungee.api.chat.HoverEvent(net.md_5.bungee.api.chat.HoverEvent
.Action.SHOW_ITEM,
new Item(key, 1,
ItemTag.ofNbt(nbt)));
BaseComponent component = TextComponent.fromLegacy("Hover on this");
component.setHoverEvent(hoverEvent);
sender.spigot().sendMessage(component);
}
However, I didn't get any luck on them (all ways just show regular item infomations without special name and lores)
Console Outputs:
[15:56:14] [Server thread/INFO]: NBTAPI: {components:{"minecraft:custom_name":'{"extra":[{"bold":false,"color":"red","italic":false,"obfuscated":false,"strikethrough":false,"text":"Piston!","underlined":false}],"text":""}'},count:1,id:"minecraft:piston"}
[15:56:14] [Server thread/INFO]: NMS-DataComponentPatch: {"minecraft:custom_name":'{"extra":[{"bold":false,"color":"red","italic":false,"obfuscated":false,"strikethrough":false,"text":"Piston!","underlined":false}],"text":""}'}
[15:56:14] [Server thread/INFO]: NMS-ItemStack: {components:{"minecraft:custom_name":'{"extra":[{"bold":false,"color":"red","italic":false,"obfuscated":false,"strikethrough":false,"text":"Piston!","underlined":false}],"text":""}'},count:1,id:"minecraft:piston"}
no idea
ah, alright
this should work, so maybe some 1.20.5 changes
yea it break since 1.20.5
Start by figuring out the correct tellraw I guess
Sure you aren't after .getAsComponentString ?
You don't need nms for this
ah! I didn't notice this API, has it been around for a long time? I'm definitely will switch over to the Bukkit API if it exists 👍
Hey there
Spigot version 1.20.4
Problem:
So, I am currently having an issue trying to remove all commands from the tab completions list and only showing the commands from my own plugin as well as making it where people cannot do luckperms or other commands in the chat. Its still showing the commands in the tablist completions (some of them) and as well as allowing players to do /luckperms and other commands even though in my plugin is explicitly denying that permission??
My code:
https://paste.md-5.net/moyazifore.cs
Bully all you want :( but I tried EVERYTHING lmao
I will be going to sleep so ping me if you have some sort of potential solution please 🙏
?fork
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
?whereami
Paper has a lot of internal changes under the API, and Spigot's solution may not be applicable to Paper.
UnknownCommandEvent is not in Spigot
😢
Literally any ounce of help would be appreciated even it doesnt even correlate to what i have.
you can disable all tab completions in the config
There is an event to modify the commands sent for tab complete
just modify the Collection
Yeah that goes against what Im doing.
Because I dont want to hide all commands. I just want to hide all commands that arent in my own plugin. There is no need for any other plugins commands.
if people dont have the permission they shouldnt be able to tab complete the commands anyways
^ also true
oh so i should just wait for LP to add a permission to their commands?
I will take a look at that. Thank you :)
how to disable fall damage tag on combat log X
does this mean custom enchants and custom paintings?
but using maps not fun >:(
maps are such a cringe solution
texture packs
Well
with datapacks yea
will there be no api :(?
if its possible with datapacks its possible with plugins too, right?
in the future yea. thats pretty likely
Well its tricky
Editing the registries like that has to happen at a very very early point in time.
soo
in what way early?
Well registries are frozen by minecraft once created. All that fun stuff happens before plugins are even loaded.
the reloadable stuff like enchantments you can technically edit down the line tho
its just a bit annoying to do so outside the normal lifecycle for the registries
ok
idk, I mean, problem with an API for this kind of jazz is that, as you might be able to tell by "data version 42", the format also changes rapidly
an api around that might not really be able to live as long as you'd like it to
in terms of cross version compatibility
they are the source for pretty much any data in the game
ah
can u custom color (hex) concrete or wool
cuz that'd be hella cool
what's the new Wool class?
I've been (painfully) toying with packet events using the wrappers to try and make leaves colorful for autumn effects (my seasons plugin)
I'm pretty sure it's possible... it's what I am trying to do lol
i dont think leaves can be colorful unless u make ur own leaves with block displays
We'll see
if concrete can be colored then display blocks can make all cartoony stuff (no textures)
yeah wool cant be colored
wait chatcolor is depricated?
If I want save coordinates, how can i save them without putting them in a yml or json or whatever format file?
database
just variables if u want them to be lost on restart
cache or save?
save
database
They don't have a yml file or a database
uh sure but why
yes
formatting
- you can later upgrade to a nosql database
I don't need a database to just save 1 spawn loc
no other api/plugin needs to know another servers spawn
yeah thats what i said xd
xd
How does NamespacedKey work?
player.StoreCookie takes one but the constructor (even though its public) there is a comment saying it's for internal use only
wrong constructor
declaration: package: org.bukkit, class: NamespacedKey
be aware, that cookies are essentially useless unless you properly sign the content as they are 100% controlled by the client
They indeed are very yummy
I guess no one knows
How to send adventure lib supporting messages to a non player?
Basically what do i call to send a component message
on spigot
ah, sorry idk
I think you have to create an audience from something
see the bukkit bridge/platform
oh that shouldnt be too hard
Maven Gradle
real

who needs adventure when u have bungee chat 😎
Is there any way to have the player store a certain value, like on his pc, so that when he connects again I can ask him about that value?
?
or: Why you should NEVER use NBT tags again! Spigot 1.14.1 added the biggest improvement that (in my opinion) ever made it into the Bukkit API: The Persistent Data Container (PDC). It can be used to store custom data on Entities, TileEntities, and ItemStacks. Using a bit of math, it can also be used to...
makes sense
nah, I wanna differentiate between different computers
cuz on offline mode anybody can use any nickname
please do not the cat
not without client mods
will not the cat
offline mode moment
also what's the purpose, if players can choose any nickname they want in offline mode, they also can just copy over every file that you want to store on their PC
ye
anyway, if not, then too bad
how to raytrace entities?
the usual way to half-way secure offline servers is AuthMe or however it's called
uh
it's unideal
that's why I wrote AlixSystem
much better
ofc it is unideal, the proper solution is online mode
the proper solution is supporting piracy 🙏
RayTraceResult#getHitEntity iirc
pretty much nothing can be done to the server in terms of security breaches
and with auth me
oh nice
well, it doesn't even try
possibly set the power to zero
location, 0, false, false
why are you trying explosions?
do boats not have the normal entity atriutes?
what time is it
14:12
thx
(germany)
13:12
thx
which one 🖍️
the
how do i cancel blocks from expldoing
clear the block list in the Entity/BlockExplodeEvent
do you mean exploding or breaking due to explosion?
Hey guys, I need a bit of advice. I'm building a mini-game, but the games will have different types, like solos, doubles, fours, etc., each of which will have different numbers of teams and max team sizes. I am wondering how I should define this behavior. Should I use Game class properties like numberOfTeams and maxTeamSize, or should I use an enum? I know I could also define an enum with these properties, but that might defeat the point of the enum since Id have to grab those in order to determine what type of game it is.
breaking due to explosion
then as Emily said
the block list is mutable for removal.
boats have a maximum speed and explosions will not "push" them
nope lols
the way i've seen plugins do it is by just increasing the velocity
problem is you need to know when to and when not to increase the velocity
one plugin did this by only increasing the velocity while players were holding a special item.
could see it working but problem is it would get rid of blocks and cause issues for other players
plus during lag that breaks completelty
velocity is the way i'd do it.
Maybe give the player an item while in boats?
or (i know this defeats the point of a spigot server) have the players download a mod that will send specific keystrokes as a packet to the server
then get those packets and increase the boat speed when said keystrokes are being pressed
Only error msg im getting is "Unsupported class file major version 65" when building my maven package
(my maven plugin into a .jar)
how do i set attribute for entity?
entity.getAtribute.setWhatEver iirc
nah getAttibute does not exist
Not from the overaching entity class
you gotta go to the specifc class
Example for a ghast instead of doing
Entity ghast = (whatever here)
ghast.getAttribute();
it'd be
Ghast ghast = (whatever here)
...
yea
uh
I can't decide correctly when to use interace or abstract class. I would like to make a plugin that will manage the location as a trigger. So the player sets with a command the location as a trigger. Another player clicks on that trigger and sends it to the chat, opens the inventory... or whatever. There will the Trigger class for each type of trigger. Should I make an interface for the main Trigger class or should this abstract? I was thinking about an abstract class because each trigger will have a List of requirements. I'm trying to understand when to use an abstract class and when to use an interface.
I read some articles about that but Im still confused lol
you probably shouldnt learn it spigot related
learn it with vanilla java first
ad then apply that logic to spigot
different trigger types will have many comonalities so abstract
public String getData(OfflinePlayer player, String query) throws SQLException {
if (!playerExists(player)) addPlayer(player);
if (sqlContains(query) != 1) return null;
try (PreparedStatement preparedStatement = connection.prepareStatement("SELECT ? FROM Players WHERE uuid = ?")) {
preparedStatement.setString(1, query);
preparedStatement.setString(2, player.getUniqueId().toString());
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) return resultSet.getString(query);
else return null;
}
}
When using this code and parsing through the player and lang
it returns "No such column 'lang'
But:
the column literally exists
I mean I know difference between that and thats why Im asked here to get learn with spigot logic to learn it more easily.
That was what I tought as well, tbh. I kinda dont need lot of variables or anything it will be mostly methods and they probably wont be scenerio when I will use same method in multiple triggers, that's why Im thinking about interface as well. I was working on one project with someone before when we were creating custom drinks and food and there we used interface for some reason... That what confused me
I kinda know how to do it and stuff but Im strugling on correct logic on thinks need some mentor/couch or smtn like that lol.
Abstract Class -> inheritance
Interface -> composition
that is the simplest explanation and at the same time the best lol
Yeah, I would say Interfaces are used when u have broad ranges of implementations with many different fields and stuff, while inheritance should only be used if you really use ALL that this class offers
Pizza interface
they are all like a pizza
You can compose your Pizza with different ingeredients but it remains food so it can have the food interface with the eat method
it follows the builder pattern to make diff pizzas
I mean.. at the custom items state. I would do that with abstract class. I would create an abstract class CustomItem where it would be protected field ItemStack item and int uses with 2 methods getRemaining() (witch I would probably define in abstract class, becaouse every item will have same) and abstract void consume(Player player) method. But guy told me this is blueshit. The way how it was done was interface with getuses method and use method. Than every class had ItemStack and uses field but that why I would use abstract class to avoid that making same field for every class.
Im not sure about all the impl details, but all mentioned seems like it should be an abstract class
I mean for me it make seasn make it interface bcs not only item is think what u can eat, but still... For me it seams to be pointless to have that as interface when its only for items. I cant rly find ussage for interface for what ever Im doing lol. I started feeling wrong bcs of that.
It was done like this:
public interface Consumable {
int getRemaining();
void consume(Player var1);
}
public class Juice implements Consumable {
private ItemStack item;
int getRemaining() {
blabla
}
void consume(Player var1) {
blabla
}
}
Yeah thats good
I would still use abstract class as I mentioned, lol.But I think I get it. It can be something other then ItemStack like block (Cake) or something probably thats why and thats why it was done this way.
Yes
Interfaces are more used to control what is exposed.
and to seperate API from implementation
ocp
This is my fight basicly:
public interface JobTrigger {
void handle();
boolean meetsRequirements(Player player);
}
public class TestTrigger implements JobTrigger {
@Override
public void handle() {
}
@Override
public boolean meetsRequirements(Player player) {
return false;
}
}
vs
public abstract class JobTriggerAbs {
private List<Requirement> requirementsList = new ArrayList<>();
abstract void handle(Player player);
boolean meetsRequirements(Player player) {
boolean results = true;
for (Requirement reg : requirementsList ) {
if (!requirementsList.meat()) {
results = false
break;
}
}
return results;
}
}
public class TestTrigger extends JobTriggerAbs {
@Override
public void handle(Player player) {
if (!meetsRequirements(player)) return;
}
}
Sure I can load requirements from config in meetsRequirements method thats why I cant decide, lol 😄 But since the requirements is same Im closely to use abstract class rather then interface. Thats probably correct?
Can I somehow change max stack size of Material.POTION (in player's inventory)?
yeah u can set the max stack size of an itemstack i think
Nope, there's only way to getMaxStackSize
let me check the method
itemmeta#setmaxstacksize
@proper cosmos
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
Im trying to get it. So there will be Food interface. Than the Pizzaabstract class with will implements food interface that will be extended with HawaiPizza class (yes ananas belong on pizza lol)? I would make pizza abstract because it will have some eat method as every other pizza. I guess I get it if yes.
anyway thanks guys thats helped me.
Don't over abstract
yeah.. that what I want to prevent as well
he just wants to comply with ocp
Thats ocp
yeah I was just advising against things like food -> pizza -> Hawaiian.
the pizza abstraction would be pointless in that instance
"the pizza abstraction" sounds like a research paper a uni student started as a joke but actually published
look at this function signature 😍
private suspend inline fun <reified T> downloadAndParse(
crossinline downloadCallback: suspend BackendAPI.() -> Response<ResponseBody>,
crossinline inputCallback: suspend (InputStream, String) -> File
): Pair<T, File>? = coroutineScope {
i definently understand what this does
lol
Yeah, I think about it as well. Just make List of Topping and Name lol.
Kotlin >:(
look at the usage 😍
suspend fun downloadPack(id: Long): Pair<EnchantmentPack, File>? = downloadAndParse({ api.downloadPack(id) }) { input, name ->
saveToFile(input, name).await()
}
If this will work first try, I'll be extremely happy
is there any showcase of citizens plugin? is it possible to make hostile mobs with it?
or would I have to go into NMS to make one?
like the ones Hypixel has made
I cant read it
Hello, how can I remove the color of a player in tab when he is in a team with color?
Team#setColor iirc
well, to remove the color applied by his team in scoreboard*
but not remove the color from the team for other usages
hmmm
how?
I found this, maybe....
https://www.spigotmc.org/threads/edit-tab.571816/
How can I intigrade a MySQL Databank in my plugin?
spigot already ships with mysql drivers
so like, follow any mysql java tutorial and you are good to go
no a 3 provider
package me.dean.aokigens.Listeners.Mines;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
public class Mines implements Listener {
@EventHandler
public void OnMine(BlockBreakEvent b, Player p){
if (b.getBlock().getType() == Material.DIAMOND_ORE){
b.setDropItems(false);
b.getBlock().setType(Material.BEDROCK);
//wait 5 seconds
b.getBlock().setType(Material.DIAMOND_ORE);
}
}
}
how do i wait ... seconds
Bukkit's scheduler i think
yeah i know but it wouldnt work here right?
since i need to wait in the middle of the code
Thats not how events work
wym?
from the event
nvm
yeah
public class Mines implements Listener {
@EventHandler
public void OnMine(BlockBreakEvent b) throws InterruptedException {
Player player = b.getPlayer();
if (b.getBlock().getType() == Material.DIAMOND_ORE){
b.setDropItems(false);
b.getBlock().setType(Material.BEDROCK);
TimeUnit.SECONDS.sleep(5);
b.getBlock().setType(Material.DIAMOND_ORE);
}
}
}
help?
i did
sleep will break the server
then how else am i suppost to wait?
you don't
but i need to
no
you schedule a task for 5 seconds time
still dont get it
then read the linked wiki
I know but i dont know how to schedual
read it and learn. All you need is in that wiki post
Has there been any announcement or changelog about Spigot 1.20.4 (or Bukkit or Minecraft, I don't know) dropping JDK 8 support?
I know that 1.20.4 is now compiled in JDK 17 ( vs. JDK 8 before) but I can't find any information on this
use 17
past that you need 21+
I think jdk 8 was dropped singe mc 1.16 or smth
Spigot 1.20.3 is compiled in JDK 8
no its not
Yes it is
I use 21, but what does that have to do with my question?
17 has been a requirement since 1.17
well my point was that if such an announcement were to be made
JDK 8 compiles Spigot 1.20.3 perfectly
it would be for 1.16/1.17 instead
its impossible to build spigot 1.20.3 (using Buildtools) with java 8
since thats when mojang decided to drop support for it
As a Maven dependency, it works. But not with 1.20.4
as a dependency is Not building it
Yes but what has changed between 1.20.3 and 1.20.4 that makes it impossible to compile with JDK 8?
I don't use JDK 8, I'm just trying to understand what has changed
Ah, that makes sense!
Is there any announcement or changelog that mentions this?
Not that I know of?
is this a good article/ piece of advice? I am trying to use my own set of classes across multiple plugins, similar to a library https://www.spigotmc.org/wiki/creating-external-libraries/#maven
how do you know, then?
Because I saw the commit that changed it
oh okay
to clarify: you're talking about the spigot api?
yes
okay hash maps are BROKEN
facts
the ability to just add an entry to your data access object without need of flipping upside down half of your project is really awesome
I use it to list statistics of my weapons
how to add lore to item to add second line
setLore(List.of("first line", "second line"))
idk x
this seems active, last commit a week ago
I don’t see the point of it.
Hey
I was wondering how can I save the inventory of a player inside an entity without saving the inventory in a file
There’s no single mob that can store player’s inventory iirc
You can do with chests
PDC
?pdc
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
can also be of use
thanks !!
Hello! I need to remove player's money from Vault when he writes /auctionbet amount. When I write /auctionbet and any amount it just sends "usage" don't understand why.
https://paste.md-5.net/yebanewaza.java Can someone help please
Is the command /auctionbet auctionbet
because that's what you've set it to in the code
does persistentdatacontainer on items use NBT or what?
like if a client tries to combine two itemstacks which are same everything except a different persistentdatacontainer tag what happens? will it be sent to the client as nbt so not merge?
It is sent to the client yea
pdc is nbt
which is why saving secret things in there is not a vibe
Yee, you can view PDC with a nbt viewer, I have a screenshot a friend sent me somewhere
is it just a wrapper over nbt?
Eh, its implemented in NBT.
I cant create config on player join because of statistics for loop, how can I make it so that it creates "statistics:" that is empty and not throw null pointer exception?
Don't use it to edit NBT
This is a thing my friend sent me once, most of it is not pdc, but "PublicBukkitValues" is pdc iirc
it is
wait explain me this, are you doing a cache lookup, and if its found, youre doing the lookup again?
I created a java project with maven and a single class with a public static method and I wanna use that in my plugin
but I cant seem to get it right

Press install
Are you shading?
Oh, like in IDE?
Invalidate caches
where is teh button for that again? xD
Im not sure top left the 3 bars and somewhere there
thats where everything is..
How can I do get player's balance in Vault? Cause when Player has balance 10 and try to bet 20 dollars they remove and player has -10 balance.
EconomyResponse balance = Plugin.getInstance().economy.getBalance(Player p);
if (balance.balance <= 0 && balance.balance <= amount) {
EconomyResponse response = Plugin.getInstance().economy.withdrawPlayer(player, amount);
if (response.transactionSuccess()) {
player.sendMessage("Success: " + amount);
} else {
player.sendMessage("Failed to place bet. Insufficient funds.");
}
}
return true;
}
}
Click the maven button and find the double arrow (circular lookin) button
Try that first
then do the caches
Are you using Essentials as the economy plugin
how can I add an empty object in yaml
Coinsengine now
so that I'd have statistics:
please dont use a singleton for your plugin instance
im thinking all people follow the same stupid tutorial
I feel like this is something you might want to introduce a db to
?
I literally
spent
like
5 hours
switching to yaml
why
Yeah why
because db is apparently "unnecessary"
yaml is trash
both things didnt work
... What are you trying to do with the statistics
sqlite sounds like a better place to store statistics
Flat file could work for this but a db would just offer you so much more
Idk who told you to just use flat files for this but they were kinda wrong or just not thinking in expandability / maintainability
why not
none of your business at this point
this is trash, that is trash
everything is trash at this rate
so why even bother doing this
try the 'Repair IDE' button and basically do everything it suggests including the IDE restarts etc, normally fixes most of the issues if 'Invalidate Caches' doesn't work
I mean yeah ide's be buggin sometimes, usually the buttons work but sometimes you just gotta hard reset the application
Oops sorry to ping ya
haha np
yep, IntelliJ once completely deleted every of my imported maven libs and completely screwed up my VCS, took around an hour setting it up again, love it
How did it fuck the vcs?? lmao
idfk, it just all broke somehow, my code suddenly had over 1k+ errors inside each class like tf 😂
Ahaha so it literally just poofed all the lib depends?
Aw thats messed up man
I think that's the issue with intelliJ is that it's too good, meaning there are just too many modules / features for it to run 100% all of the time
I want a <String, Integer> hashmap statistics that is stored in yaml in that sequence:
statistics:
one: 1
two: 2
three: 3
, but I can't seem to initialize it when the player is joining for the first time, because fetching newly made object from yaml file returns nullpointerexception, it can't create statistics: object, because it gets every element from it, and since it's not created, it has null
I temporarily fixed it by adding check variable into it that is set to 1 for the sake of filling it and creating the statistics object
but hey, works most of the time haha
have you tried saving that flat file before access?
You can set the value to 0
Ie: player joins -> add elements -> save file -> access file
You could do that too, I'm not sure if that's an issue or not I just thought you meant you wanted an empty value
uh
Your doing it wrong somehow
^
I mean, yea statistics isn't a configuration section
0 isn't null
And I know you don't want to hear it buttttttt you could go back to db
... why?
fuck off with that, seriously
mojang uses flat files
there is 0 gain with moving to yaml here for them
it isn't that big of a deal
I am not going to postpone project for 2932934923th time because someone tells me to change data saving way
"because X is trash"
Yea
just use get instead of getconfigurationsection
and then instanceOf the object you get
Why would you do this when all of the #getX() methods exist?
literally because of the above
still didnt work
getConfigurationSection will yield null if you call it for a non section
Wtf
for all I care you can also just null check it
I just think maybe there is something wrong with the setup
what do I do with it then
well you just check if that is null
if it is null, the player does not have any statistics
Try #createSection()
oh, just set it to an empty hashmap I think?
okay, this works
Hello, I am having trouble extending an entity to make a custom mob, at the moment I am trying to do
public class DesertZombie extends Husk {
however it wants me to implement like 300 methods, and doesn't have a super Cannot resolve method 'super' in 'DesertZombie'
all the tutorials I've seen use things such as EntityZombieHusk but I don't have that class somehow? can I get some support on this I can't find any good docs
Isnt Husk an interface
Okay so, spigot is not for making mods
You need to use fabric or forge or whatever the tutorial guy is using
createsection
they're all using plugins
or add values to the section
No they arent
EntityZombieHusk doesnt exist, they are using something else than spigot
Advanced Spigot Coding | Custom Pathfinder Goals [Pet Plugin] | (Ep. 6) Spigot 1.15
Yes and this tutorial is not showing how to make an entity
Good thing we're only at 1.20.6 now
Say I wanna transmit data from a plugin to the world using redstone pulses. What's a reasonably efficient way to power and unpower redstone? Would switching a block's material between wire and redstone blocks quickly using Block.setType be horribly slow?
I have no clue how they've changed the API since then
There are plenty of changes most of which you don't have to really worry about until 1.20.5
The changes dont matter, the guy is using nms classes in the tutorial
Yeah uh friendly advice: learn spiogt api before delving into nms 💀
you ask nicely of course
What if you did a map<String, PDC> for each item or wtv then all your containers are cached in that map?
Yeah that's called a list
A list allows you to store multiple things
Does it matter whether its a list or a map
Maps don't allow for identical keys to different values
Lists don't have keys
Boom
Hi, I was wondering if you can silence a dispatchCommand (for example Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "give %player% minecraft:dirt 1");) to not send a message to console of CONSOLE issued server command: /give %player% minecraft:dirt 1 on 1.20.4
Why are you making console run commands
allowing configurable rewards in config and I don't want their console to spam constantly
and to allow the rewards to be whatever (even items from other plugins) having commands to execute it to give the user the items would be the best method for it all from what I can think of.
Hmmm, new project or fix the performance issues with seasons?
could it be because the library project is not a plugin on its own?
like its literally a project with a pom file and a class with a single static method in its thats just public static String test() { return "hey";}
but yet my intellij doesnt find it, even though it has found the repo and if I open the jar with 7zip I can see the method in the jar file
omg
im stupid
I forgot to add a package with teh group id into the project
so I guess it didnt count
well its fixed now xD
another question, how do I put it on github, because this is now in a completely different place, but I want people potentially working on the plugin to not run into build issues, how do I make sure that the dependency can be used even when downloading from github
is there a better way to check if Namedspacedkey is null?
I dont feel like its legit, although it works
?paste
try {
weaponDamage = Integer.parseInt(ItemPDC.getPDC(physicalElement + " Damage", weapon).toLowerCase().replace(" ", "_"));
} catch (IllegalArgumentException e) {
weaponDamage = 0;
}```
you shouldnt use try catch in this case probably
depends, where is that IllegalArgumentException coming from
my guess is that you use PersistentDataContainer, it has either the get method which can return nullable/throw IllegalArgumentException
so instead maybe use PersistentDataContainer#getOrDefault
cant provide more help without more context
Wrong in this situation.
Try catch likely comes from the int parse
is there a better way to check if Namedspacedkey is null?
Not sure why we're not just storing an int tho
also parseInt doesnt throw IllegalArgumentException
Ph facts
instead it throws NumberFormatException
Kek
It is real to copy text to clipboard when player clicks a gui?
Not possible 99% sure you can only do this through chat
Unless you use a book
Then you can have the player click the text inside of if
okay thanks
why not store it as an int
there is osmething wrong
when I call ItemPDC method it returns null when in one class
but returns normal value when in another class
I like quadruple checked and PDCs are applied correctly
show stacktrace, show code
it just returns null all the time
check the item in game with /data get entity @s SelectedItem while holding it
for a quick sanity check if the PDC applied
where is it
If you don't see PublicBukkitValues in that output, the pdc did not apply
what do you mean different namespaced keys
Well you set a value with a namespaced key for a key
well, you use "myplugin:firstkey" -> first value
and "myplugin:secondkey" -> second value
but I mean, depends on what you need/want
PDC is basically a map
that are different keys but why do you use the minecraft namespace
I mean, depends on what you pass for "keyName"
presumably because they only pass "weapon"
it defaults to the minecraft namespace
thats the keyname
I think from the screenshot it's visible that there's more PDC, isn't it?
they only sent the first line but it looks like the next line continues PDC data
oh yeah that's only one key
why
because as lynx said, entry.getKey() probably is always "minecraft:weapon"
you sure your code really works though
they were referring to the minecraft: bit, which can be changed if you used a string format like the namespace i.e. myplugin:weapon
or if you create a key using your plugin instance
People should really just be doing this.
yeah, its fool proof pretty much
I hate this
im sure you can figure it out
i mean, can you recap what youre stuck on
how to do several pdcs
do you want others to create your plugin? you arent appreciating any help lmao, asking low quality questions just to be mad at answers
as if your questions were the awesome quality
show your whole code of creating the item and how you're giving it to the player
well one message isnt proof of anything, maybe look at the other 10
you got the relevant part
not really
rest is just item meta flavor
okay from the part I am seeing it should work
well then it should work, good luck
if that would be the relevant part, then why does it not work lol
answer: because the relevant part must be somewhere in the code you haven't sent
you literally said what doesnt work
something about namespaced key
but you decide to gatekeep it
you know the issue
just use different keys
look
look
for a second
what do you see under keyName
since when they are equal
to eachother
tell me
you never shared the ItemPDC implementation
ok thats mb, I didnt see it
I only get the last pdc tag that I put
@storm crystal As I have already said, all the code you sent looks fine to me, except that you're using the minecraft namespace (which should still work).
But as you refuse to send more code, nobody can help you.
And if you repeat "I sent all the relevant code", then I now ask you: well then why doesn't it work?
private final WeaponManager weaponManager;
public WeaponCommandTest(WeaponManager weaponManager) {
this.weaponManager = weaponManager;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if (!(commandSender instanceof Player player)) {
return true;
}
if (args.length != 1) {
player.sendMessage(ChatColor.GRAY + "Usage: " + ChatColor.RED + "/weaponspawn <weaponID>");
return true;
}
WeaponDAO weaponData = weaponManager.retrieveFromDatabase(args[0]);
if (weaponData == null) {
player.sendMessage(ChatColor.GRAY + "Weapon with an id " + ChatColor.RED + args[0] + ChatColor.GRAY + " does not exist.");
return true;
}
List<String> lore = new ArrayList<>();
ItemStack weapon = new ItemStack(Material.matchMaterial(weaponData.getType()));
ItemMeta meta = weapon.getItemMeta();
meta.setDisplayName(weaponData.getName());
ChatColor color;
String value = "";
for (Map.Entry<String, Integer> entry : weaponData.getStatistics().entrySet()) {
if (entry.getValue() == 0) {
continue;
}
color = switch (entry.getKey().split(" ")[0]) {
case "Necrosis" -> ChatColor.DARK_GRAY;
case "Sanity" -> ChatColor.WHITE;
case "Otherworldly" -> ChatColor.DARK_PURPLE;
case "Fire" -> ChatColor.GOLD;
case "Crit" -> ChatColor.YELLOW;
default -> ChatColor.RED;
};
List<String> keywords = Arrays.asList("Crit", "Multiplier", "Penetration");
for (String keyword : keywords) {
if (entry.getKey().contains(keyword)) {
value = entry.getValue().toString() + "%";
break;
} else {
value = entry.getValue().toString();
}
}
lore.add(color + entry.getKey() + ChatColor.GRAY + ": +" + value);
ItemPDC.setPDC((entry.getKey().toLowerCase().replace(" ", "_")), entry.getValue().toString(), weapon);
}
lore.add("");
for (String descriptionElement : weaponData.getDescription()) {
lore.add(ChatColor.DARK_AQUA + ChatColor.ITALIC.toString() + descriptionElement);
lore.add("");
color = switch (weaponData.getRarity()) {
case "rare" -> ChatColor.BLUE;
case "epic" -> ChatColor.DARK_PURPLE;
case "legendary" -> ChatColor.GOLD;
default -> ChatColor.WHITE;
};
lore.add(color.toString() + ChatColor.BOLD + weaponData.getRarity().toUpperCase() + " SWORD");
meta.setLore(lore);
weapon.setItemMeta(meta);
ItemPDC.setPDC("weapon", args[0], weapon);
player.getInventory().addItem(weapon);
player.sendMessage(ChatColor.GRAY + "Weapon " + weaponData.getName() + ChatColor.GRAY + " has been added to your inventory.");
return true;
}
}```
you store the Meta object, then set it back later
in human words?
bro ngl, learn java first
getItemMeta yields you a snapshot.
it includes the ENTIRE state of the item's data
Hi lynx
quick fix: make your setPDC method take in an ItemMeta instead of ItemStack
^
Still helping this guy?
I believe
Interesting
so fucking stupid
What is stupid
no
I actually think ItemMeta is pretty nice API
lmao
Worlds most productive help development
You keep around different copies of ItemMeta. Then you add the PDC to another Meta copy, then set the item's meta back to the original copy.
That's why you only get one key.
As I said, the easiest fix, if you don't understand what this means, is to make setPDC take in an itemMeta. This will
- fix your problem
- be more performant as no copies of the meta have to be created all the time
bro asking for help, getting help, ignoring help
alright, then good luck to you. Have a good night
Help my plugin doesn't work!
Here is solution!
No!
I already fixed it
yeah whatever lmao
so whats your point
🗣️
you probably fixed it by moving around your setPDC calls, which is basically what I told you the problem is - keeping around different copies of the itemmeta
now tell me why this doesnt work
no
I fixed it. Why doesn't it work lmfao
read I guess