#help-development
1 messages · Page 695 of 1
i made a batch file and ran java -jar BuildTools.jar --rev 1.8.8
did it finish
it should say something like "copied jar to xxx"
ill run again sec
Also there should be a spigot 1.8.8 jar in the folder where you ran BuildTools
yea its there
reload maven again
maven tab on the right side, first button at the top
looks like a circle
actually i just realized something - woudln't obfuscators think @EventHandler methods are dead?
yes but you can keep them
This account is already verified!
f
catch md5 when he's around
or rejoin
if you're already okay
prolly the bot is dead
are you allowed to dm md5?
is there a way of making sort of "custom projectiles" for example can i extend class like Fireball and then just edit values and somehow change the itemstack of fireball and just pass that class in launcProjectile()
no
but you can make a custom fireball
you just can't use launch projectile to launch it
how can i then launch it (i mean mob should launch it)
is it possible using spigot to see the boundaries of certain areas like you can do with structure blocks
Any help with this new error? (happens randomly and Im sure world & chunk is loaded), I hope if someone helps, I think those errors are directly related to getBlockAt thing or idk
it says type chest
what's Team line 355
The weird thing is, it is saying a chest is not a chest lol
Caused by: java.lang.IllegalStateException: CraftChest is not a chest but is instead CraftBlock{chunk=CraftChunk{x=3z=3},x=51,y=100,z=48,type=CHEST,data=5}
what's team line 355
how am I supposed to know which is line 355 now
hm, first switch case, applySharpnessToSwords
info.getChest().getState() thing
public Inventory getInventory() {
int x = getX();
int y = getY();
int z = getZ();
// The logic here is basically identical to the logic in BlockChest.interact
CraftInventory inventory = new CraftInventory(chest);
if (!isPlaced()) {
return inventory;
}
int id;
if (world.getBlockTypeIdAt(x, y, z) == Material.CHEST.getId()) {
id = Material.CHEST.getId();
} else if (world.getBlockTypeIdAt(x, y, z) == Material.TRAPPED_CHEST.getId()) {
id = Material.TRAPPED_CHEST.getId();
} else {
throw new IllegalStateException("CraftChest is not a chest but is instead " + world.getBlockAt(x, y, z));
}
That's where it throws the exception, getBlockTypeIdAt is probably mismatching with getBlockAt, not sure why
ughm why don't you just Materials directly
Tha fk is getBlockTypeIdAt ??
no clue
That's old spigot code (CraftChest), I've tried to change it using getBlockAt().getType() for now
why do you even need to check the material? can't you just check if the BlockState is instanceof Chest / Container / InventoryHolder?
Well it would thrown cast exception if it was not a chest
Don't blind cast
That's the only reason you'd get an error do your checks properly
I mean, the blockstate is a chest already, it doesn't give me class casting exceptions, calling getInventory() is giving errors.
.
Im getting the block, then getting its state and casting it to Chest, Based on docs
What are you doing on line 355 of team
PermissionAttachment pa = p.addAttachment(this); i get error with "this" im supposed to provide plugin there but i dont know what to put there in my plugins main class onEnable "this" works but this one is in events what should i put there?
You are throwing this exception yourself after your faulty logic check
no no, that's craftbukkit exception
I don't throw that, I just pasted that code from CraftChest.java
Might be one of those 1.8 errors that never got, and never will be fixed
Well anyway, thats 1.8, I shouldn't expect any support then (its one of those ancient versions), Thanks btw 👍
no it wouldn't because you do instanceof
If you are changing a block in the interact event, try delay the interaction by a tick
can som1 tell me how i can add npc players
well your plugin instance ofc https://blog.jeff-media.com/getting-your-main-classes-instance-in-another-class/
You often need a reference to your main instance (the instance of your class that extends JavaPlugin) in some of your other classes. There’s two basic concepts for this. Choose whichever you like more. Method #1: Static Getter First way is to create a static method called getInstance() or similar in your main class. You...
I do this on InventoryClickListener, ok I'll try delaying it. hope that helps.
This is an really advanced topic and will require quite a bit of experience and work.
If you are new then i would recommend an external lib for that.
You can either go with depending on citizens or build your own npc framework by just doing some researches about faking players with packets and scoreboard team stuff, but it'll take time to stablize it for sure (understanding packets surely takes a quite time to practice and work with)
java.lang.ClassNotFoundException: org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity 🤔
private static MyPluginMainClass instance; throws an error when i put it in my main class
What's the error?
Send full stacktrace
what site should i use to upload the stacktrace
?paste
You're trying to run 1.8.8 code on and 1.8 server
ah i see
guys what are some of the best libraries that you almost always use to make your work easier?
like for ex theres acf-bukkit which I use for making commands much easier
lombok
PermissionAttachment pa = p.addAttachment(Fernv2.getInstance());
if(!(p.hasPlayedBefore())) {
pa.setPermission("zaza.helpzaza", true);
i set permisson to a player using this code but when i use the command i still dont have the permission
you cant just name yourself lol
Unless you're making a permission plugin yourself, it's not really worth messing with permissions directly. I'd recommend using a permissions plugin like LuckPerms to handle that.
thats not making your work easier thats doing the work elsewhere
i know but i also want to learn how to use them
But thats what I‘d use lol
i
fair
think this is the proper channel
so I'm using placeholder api for a scoreboard.
it's showing everything which is good, but i need it to show Team Points. cause it can show player's individual points but not team points. i'm wondering if there would be an addon or something? i'm a bit stuck
i need something to like rank the teams like mcc, top 3 highest for example
I make plugins (i prefer smaller ones) is anyone interested?
?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/
thanks :)
wtf
What event should I listen to if I want to check for an item being burned in lava ?
maybe itemonground event and if the ground is lava? idk rlly shouldnt take my advice haha
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityCombustEvent.html might be dis
declaration: package: org.bukkit.event.entity, class: EntityCombustEvent
not sure if melting in lava counts as a entity death
oh actually
itemstacks on the ground might not be entities in the definition of spigot
what
mockbukkit
Items on ground are 100% entities
just make a void world, listen to Event and print em all out
Don't think combust event will work, sounds like "entity begins to burn" not "entity burned to death" but idk
They're entities
maybe but if item is thrown to lava it dies instantly except netherite so shuold be the same
false, it still has health
That is why you can burn the item for some time before it is gone
ye, I guess I looked at a wrong event, one that gave me only living entity so I was confused
time to think about how I'd implement a command tree
oh cool to know thx
they are
ah i see
can you show the init method cuz we cant see it bec of the warning
init {} is kotlin
isnt {} just short for 'public this'
Not quite
it applies for all constructors
Code inside of an init block gets executed for every initialisation regardless of the constructor used
wait really
Ye
like the java public class c { {/this/}}
does that also happen if you write it out?
what is seldom
'rarely'
Rarely
:D
And no, there’s a difference between a no-arg constructor and an init block
choco get off discord
roasted
ayo chill
are you on aeroplane
Nah I’m laying in bed. Just woke up from a nap
public class wtf{
//So this is
{}
//equal to this then?
public wtf(){
}
//And run first if i use this?
public wtf(Object someArg){
//a la this()
}
}
```?
in canada or america
The two are not equivalent
huh
{} will run AND your default constructor will run
both will always run if present? weird
{} runs regardless of the constructor used
US
go take ur gf to lunch
She’s finishing her shift at work
We’ll go out to lunch here shortly. She’s on her way home
:)
are you choco's long lost father???
you will never know
public void onBlockBreak(Player player, Block block) {
if (block.getType() == Material.BIRCH_LOG || block.getType() == Material.BIRCH_LOG) {
int count = 0;
BlockFace[] directions = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP,BlockFace.DOWN};
for (BlockFace direction : directions) {
Block connectedBlock = block.getRelative(direction);
if (connectedBlock.getType() == block.getType()) {
connectedBlock.breakNaturally();
count++;
if (count >= 10) {
break;
}
}
}
}
}```
In that how can i make the it breakByPlayer instead of breakNaturaly so it triggers the BlockBreak event
In that how can i make the it breakByPlayer instead of breakNaturaly so it triggers the BlockBreak event
if anyone wants to get eye cancer, here you go https://github.com/mfnalex/PAPI-Replace/blob/master/core/src/test/java/com/jeff_media/papistringreplace/TestReplacer.java
show the yaml
I'm creating a YAML file in Java. It creates "Home.unofficial" and "Home.costChanged" but it only saves the last setting under Home when its written to a file. Any reason why?
YAMLHandler yaml = new YAMLHandler(file.getName());
yaml.loadConfig(file);
english.set(newKey + "." + key, messages.getString(key));
try {
english.save(English);
} catch (Exception ignore) {}```
public void onBlockBreak(Player player, Block block) {
if (block.getType() == Material.BIRCH_LOG || block.getType() == Material.BIRCH_LOG) {
int count = 0;
BlockFace[] directions = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP,BlockFace.DOWN};
for (BlockFace direction : directions) {
Block connectedBlock = block.getRelative(direction);
if (connectedBlock.getType() == block.getType()) {
connectedBlock.breakNaturally();
count++;
if (count >= 10) {
break;
}
}
}
}
}```
In that how can i make the it breakByPlayer instead of breakNaturaly so it triggers the BlockBreak event
List<String> turfs = new ArrayList<>();
for (String turf : config.getKeys(false)) {
if (!name.equalsIgnoreCase(config.getString(turf + ".gangCaptured"))) continue;
turfs.add(turf);
}
ur issue is calling getString on a config section
player.breakBlock(block)
thx
Player#breakBlock
declaration: package: org.bukkit.entity, interface: Player
well im initializing variable inside of init block, but it still shows warning for whatever reason
yeah this isnt lateiniting, im initing it when object is made
crazy piramid 👀
i tried this in kotlin playground and works fine
weird
how to remove without updating
*** Error, this build is outdated ***
*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***
*** Server will start in 20 seconds ***
wich?
or just update
-DIReallyKnowWhatIAmDoingISwear
ok lets update
what is the val named in the init function?
do you mean sth like this? https://github.com/mfnalex/PAPI-Replace/blob/master/core/src/main/java/com/jeff_media/papistringreplace/NaiveReplacer.java If yes, done 😄
it's much more readable then regex for sure
I just have both versions included now. if someone finds a bug in the NaiveParser I just replace it with the regex one until it's fixed
public void onBlockBreak(Player player, Block block) {
if (block.getType() == Material.BIRCH_LOG || block.getType() == Material.BIRCH_LOG) {
int count = 0;
BlockFace[] directions = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN};
for (BlockFace direction : directions) {
Block connectedBlock = block.getRelative(direction);
if (connectedBlock.getType() == block.getType()) {
player.breakBlock(connectedBlock);
count++;
if (count >= 10) {
break;
}
}
}
}
}```
its creating a stack overflow each time i mine Birch
where is that coming from
in a yml file
you break a block in BlockBreakEvent, hence the event gets called again and again. Use a field to ignore the next event
private static void MigrateToLanguage() {
// Create English file if it doesn't exist
File EnglishFile = new File(instance.getDataFolder() + "/Languages/English.yml");
if (!EnglishFile.isFile()) {
try {
EnglishFile.createNewFile();
} catch (Exception ignore) {
}
}
YAMLHandler englishYAML = new YAMLHandler(EnglishFile.getName());
englishYAML.loadConfig(EnglishFile);
// Loop all folders in plugin.getDataFolder() and then loop all files in each folder
File[] folders = instance.getDataFolder().listFiles();
if (folders != null) {
for (File folder : folders) {
if (!folder.isDirectory()) continue;
File[] files = folder.listFiles();
if (files == null) continue;
for (File file : files) {
if (!file.isFile()) continue;
// Load file as YAML config
YAMLHandler yaml = new YAMLHandler(file.getName());
yaml.loadConfig(file);
ConfigurationSection messages = yaml.getConfigurationSection("messages");
if (messages == null) continue;
// Loop all messages in the file
for (String key : messages.getKeys(true)) {
// Check if the message is in the English file
String englishKey = file.getName().replace(".yml", "") + "." + key;
englishYAML.set(englishKey, messages.getString(key));
Methods.log("Setting " + englishKey + " to " + messages.getString(key));
}
}
}
try {
englishYAML.save(EnglishFile);
} catch (Exception ignore) {
}
}
}
In the debug info I see:
[10:33:52 INFO]: [EpicCore] Setting Home.costInvalid to §7? §7Cost needs to be a whole number
[10:33:52 INFO]: [EpicCore] Setting Home.costChanged to §7? §7Changed §f%home%§7's public warp cost to §f%cost%```
But in the new YAML file under Homes there is only 1 value:
```yaml
Home:
costChanged: '&7▌ &7Changed &f%home%&7''s public warp cost to &f%cost%'```
Its only saving the last item that was set in each section. Can someone help me with this?
boolean ignoreEvent = false;
@EventHandler
public void onBlockBreak(BlockBReakEvent event) {
if(ignoreEvent) return;
// if(...);
ignoreEvent = true; // Ignore the next event
player.breakBlock(someBLock);
ignoreEvent = false;
}
@gilded granite
what r u trying to do
Does anyone know if it's possible for a plugin to host a website? I've only ever found one example that does it but it's Fabric so I was wondering if you could do it with Spigot
im not trying to do anything
how can i block the rain?
helping this ugy
why arent you initializing it?
you can do /gamerule doWeatherCycle
thx
have you heard of variable shadowing?
also cancel weather change event

ye i did
i asked the name of the name of the val in the init method bec of that
im saying to goksi
yeah it compiles and working just fine, but i hate why intellij is showing that warning
weird
and how can i block the spawn of animals?
how is this shadowing
im trying to init variable inside of init block
?
that doesn't matter lol
it matters
i don't have two variables named mapping
well you do
?
you have mapping variable inside the init function and outside it
val mapping: Any
init {
mapping = "A"
}
the mapping inside the init isnt defined as a variable
that is one variable, not two
val mapping: Any
init {
val mapping =...
mapping = "A"
}
``` but from your code i see this
where do you see that name of first variable inside of init block is mapping ?
its not
can i somehow dynamically parse String to Integer or Double or anything else using generics?
without making a method for each type
.
no
or you can use old method of Object
I mean, you can run a local webserver with a plugin, but I don't know about a full blown website.
just did this at the end, but i would really like to understand that warning lol
Like something just to display statistics or something. Nothing major, something like dynmap
maybe init isnt meant to initialize something lol
wdym by that
doubt lol
Object can hold any type so it is dynamically typed, basic java, was used before java generics
he asked if he can determine if string is int, double, float or long
and parse it acordingly
instanceof
?
a string will not be instanceof Integer lol
so try parsing it and check for errors
also what do you want to parse?

I'd do it like this
public class StringToNumber {
private static final Pattern INTEGER_PATTERN = Pattern.compile("^-?[0-9]+$");
public static Number parse(String numberString) {
try {
if (!INTEGER_PATTERN.matcher(numberString).matches()) {
return Double.parseDouble(numberString);
}
Long asLong = Long.parseLong(numberString);
if(asLong >= Integer.MIN_VALUE && asLong <= Integer.MAX_VALUE) {
return asLong.intValue();
} else {
return asLong;
}
} catch (NumberFormatException ex) {
return null;
}
}
}
\d 🤔
you saying +1 is not an integer smh
NumberFormat.getInstance().parse(String)?
public void onJungleAxeBlockBreak(Player player, Block block) {
if (block.getType() == Material.BIRCH_LOG || block.getType() == Material.BIRCH_LOG) {
int count = 0;
BlockFace[] directions = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN};
List<BlockFace> shuffledDirections = Arrays.asList(directions);
Collections.shuffle(shuffledDirections);
for (BlockFace direction : shuffledDirections) {
Block connectedBlock = block.getRelative(direction);
if (connectedBlock.getType() == block.getType()) {
if (count >= 10) {
break;
}
Bukkit.getScheduler().runTaskLater(plugin, () -> {
player.breakBlock(connectedBlock);
}, count * 10);
count++;
}
}
}
}```
i have an issue it breaking all conected blocks instead of just 10 can any1 help?
Player#breakBlock() will call a BlockBreakEvent, did you account for that?
ik
i tried
clazz.isInstance(something) ? clazz.cast(something) : null
but i cannot cast like that
even tho i give it an Object not a String
it always gives me null
What exactly do you want to accomplish?
simply casting an instance of String to Object will not make it assignable to numeric types, it is still a string
You can use one of the mentioned methods to convert a String to a numeric value
not one that you'd normally get if you just turn a number into a string in java
yea but the other way around it is a valid parsable number
didn't really read the context so I don't even know what the issue is
yes, sure. maybe they should specify why they have numbers as strings in the first place / where they come from lol
if(something instanceof SomethingElse somethingElse)
it is already null safe
Lol my own parser is slower than using regex lol
what are you trying to do
public void onJungleAxeBlockBreak(Player player, Block block) {
if (block.getType() == Material.BIRCH_LOG || block.getType() == Material.BIRCH_LOG) {
int blockBreakCount = 0;
BlockFace[] directions = {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN};
List<BlockFace> shuffledDirections = Arrays.asList(directions);
Collections.shuffle(shuffledDirections);
for (BlockFace direction : shuffledDirections) {
Block connectedBlock = block.getRelative(direction);
if (connectedBlock.getType() == block.getType()) {
if (blockBreakCount >= 10) {
break;
}
Bukkit.getScheduler().runTaskLater(plugin, () -> {
player.breakBlock(connectedBlock);
}, blockBreakCount * 10);
blockBreakCount++;
}
}
}
}```
i have an issue it breaking all conected blocks instead of just 10 can any1 help?
also regex does some pretty smort stuff under the hood iirc
https://github.com/mfnalex/PAPI-Replace
A %replace_search_replace_text% placeholder for PAPI. Check out core/src/.../NaiveParser and RegexParser
any1?
you can do instanceof on a class
oh wait
lets see
'String (or object)' cannot be safely cast to 'T'
Player#breakBlock() will call a BlockBreakEvent, did you account for that?
public void onBlockBreak(BlockBreakEvent e) {
Player p = e.getPlayer();
ItemStack item = p.getInventory().getItemInMainHand();
if (ignoreEvent) return;
if(!isApplicable(item)) return;
ignoreEvent = true;
onJungleAxeBlockBreak(p, e.getBlock());
ignoreEvent = false;
}```
You must set ignoreEvent to true right before you call breakBlock in the task
Thx
is displaying particles in NMS even worth it?
Check CraftPlayer#spawnParticle
You‘ll see that it simply creates a particle packet and sends it
any1 have a tutorial for nms
doesnt exist
i want to sspawn npc
nms is internal code so wont be documented
with player skill
use citiens api
coded red
wat codered?
for holograms you can use display entities
there are no "general NMS" tutorials
did you even set up your project to use NMS yet?
If not, you should start with that
yes i setup
I think
I have seen many plugins that list the Jar version but how do I do the same? And to make it convenient to change versions and not change the name of the class
how to know if yes
?link
@gilded granite nice photo
?verify
interfaces
wat?
what:
how to link forum
wym
no
display the plugin version on the plugin name but change the version if desired without changing the class name
You got an example? Cause you're not making sense.
so u wanna change the name of the output jar to contain the version?
iirc maven does that by default lol
👍
Start making sense then.
a....?
Ok, but what do you want to do with it?
PluginName-VERSION.jar?
if I update the plugin then I need to change the version and display it like from 1.0 to 2.0 and so on
Do you want me to change the name of the whole main class?
Display it in-game or in the file?
in file
that makes
no sense
what
what are you trying to do
how can u know what u wanna do but cant give an example of what u wanna do
"if I update the plugin then I need to change the version and display it like from 1.0 to 2.0 and so on"
display it where
bruh
Internal issues with spigot?
org.bukkit.plugin.IllegalPluginAccessException: Unable to find handler list for event org.bukkit.event.player.PlayerEvent. Static getHandlerList method required!
it literally says what you're missing
myPlugin-2.0.jar
he? PlayerEvent is from bukkit
in this displayName
what what
Set a final name in your maven pom.
<build>
<finalName>ProjectName-${project.version}</finalName>
</build>
Dont you know about that? its really weird also its internal server code
What?
this
????
You're missing the getHandlerList() method.
Its also points to line 25, thats is the register
??
Its internal server code
It happen when i register my listener
Doubt. If you're making your own listener, you need to override the proper methods.
You can't just not include them
I don't want to change the class name because I have to change it in other places too
what?? Im doing a spigot listener, nothing else
That's not the class name...
Im not even listening to custom events, im listening to bukkit events
That error doesnt make sense
Look shadow
?paste the HubListener class
file name and class name are not related?
No, maven's rules for building are defined in the <build> section. It's a different process altogether.
So he mainly trying to do relocations from what i understand ?
If you needed to change your class name, you'd do that via a refactor.
Have you seen the issue is realyl weird man, doesnt make sense
It'd also help if you pasted the full stacktrace
i not have this
this need set?
oh waut
okk
i forget sorry man
i not have THIS
Are you not using maven?
Just add the section I sent to the build section. That's all you have to add.
do I need to replace the word in brackets with the version?
Look at how the other sections are formatted.
<key>value</key>
What are you trying to? I cant udnerstand
display plugin version on jar file
oh nice
thenks
You mean when you compile it, it turns from bla.jar into bla-<version>.jar?
yes
If you mean that you add build tag and then the finaNname tag
And then you close the build tag, with </build>
I don't see any real issue with this. Maybe you have an outdated build on the server? Recompile and try again I guess.
yes i was do this
now this work
ok will try, it weird. Doesnt make sense that why haha
okay restarted IDE and worked perfect
very, very weird. on my macbook, my NaiveParser is about 4 times faster than the regex parser. on Windows, the regex parser is faster. ??
Do your macbook and windows machines have the exact same specs?
i can understand why regex parser can be faster for some situations since it can do work on the og array and not a copy
weird that regex is faster
no ofc not
I'm currently running the benchmarks again, I'll post results here later lol
it's a lot more generic
I have this code: https://paste.md-5.net/egudalixab.java
This should calculate the dot product between the player and the zombie and according to the maths, give me a number close to 1 if I'm looking at the zombie and a number closer to 0 or a negative value if I'm looking away from the zombie. For some reason the output sometimes makes sense and sometimes doesn't and I mostly get wrong values. This is my NuxVec class:
https://paste.md-5.net/fafaxutize.cpp
Is your code maybe expecting a yaw between 0 and 360 while its actually between -180 and 180?
Or vice versa
I mean yeah dot product in maths is normally -180 to 180 by default
You can do this directly in bukkit
im switching to gradle but for some reason all references of variables from other classes are errors now
plugins {
id "io.freefair.lombok" version "8.2.2"
}
No additional dependencies required
why/how that? it always worked fine for me
No clue this is what works for me
ok it builds now but why is that all red
because you haven't git added those files
oh that makes sense
you shuold definitely upload those too
🤦♂️
Why do you have a build.gradle.kts and a pom.xml
that's a good question lol
would be funny if the project is neither in java nor kotlin but sth else
It makes it build twice as fast
fr
yeah I also always run both at the same time mvn clean install & && gradle build &
anyone know of the best way to get the Item entity from a BlockDispenseEvent because getItem() returns an ItemStack
delay a tick and look for the closest item to the dispenser?
Yo is a block display considered an entity?
yes
Yes, it's part of the Display Entities that were added.
there won't always be one. E.g. if it's a boat, it turns into a regular boat
oh so it also does that, damn
would make more sense for the event to display an entity then wouldnt it
Nahhh no way?!?!
but yeah it's weird, there should be a getEntity() method
Hey, you asked. ¯_(ツ)_/¯
BlockDisplay, ItemDisplay, TextDisplay all extend Display which extends Entity
welp, hacky shit it is then
oh and there also won't be an entity always
Buckets -> place water/lava blocks
I think best you can do is wait a tick, then get the entities at the block the dispenser was facing
you can also apply a custom PDC tag to the ItemStack being dispensed, then identify the Item one tick later through that
hacky but that's the only solution I can think of
its not a huge deal if not all use cases are covered in this case, i got like cauldron recipes where i want the player to be able to throw shit into it and have it produce some item and now i want it to work for dispensers as well
if players are dumping a bunch of entities in front of their cauldron recipe thingy thats their fault lmao
You could probably do this in combination with ItemSpawnEvent
there really should be a BlockDispenseItemEvent though
time for a PR i guess
There should be
an item spawn event could work, though the spawn event doesn't have spawn reasons which would be useful in this case
BlockDispenseEvent is sobbing in a corner ?
well yeah thats what im using but it doesnt provide sufficient info
Yeah I was about to say SpawnReason should be added to EntitySpawnEvent and not just
CreatureSpawnEvent
it would be better if BlockDispenseEvent#getItem() was getEntity() instead
It can't be that because it won't always dispense an item
the event is way too early for that
ah right
Maybe if it was split into BlockDispenseEntityEvent and BlockDispenseBlockEvent
then what alex suggested would be nice
or that
both methods should still have getItem() so we can know what item was dispensed
if you could modify the blockdispenseevent's block that could be a neat simple way to allow other blocks to be placed with the dispenser
https://hub.spigotmc.org/jira/browse/SPIGOT-7468 I opened an issue
if this were to be added would this only affect future spigot versions or would existing minecraft versions also be updated to support this
im not sure how this works
ofc only for future versions
I mean, simple PDC tag, read in ItemSpawnEvent seems pretty straight forward
Well it could also be a block that's gonna be placed
I mean, BlockDispenseEvent cannot do either
applying a PDC tag, then waiting a tick to loop over all existing Items would ofc work, but it's a pretty weird hack
i dont think i actually wanna fuck with the items being dispensed because that could interfere with other plugins, think simple item detection would be sufficient
ItemSpawnEvent would mean you don't have to loop
yes but having a real method in the event would be better
i could always compare entities in the front facing block before and after and see which one, if any, popped up
you are never going to have full info for the dispenser ¯_(ツ)_/¯
it has so many different piece of behaviour
Like, hey it spawned an armor stand. Should we be exposing the armorstand instance too ?
armorstands are normal entities?
Why not do what was already suggested:
- Listen for dispense event, add PDC with location of dispenser
- Listen to
ItemSpawnEvent, and check for PDC - Now you know
as I said, there could just be getBlockState() and a getEntity() method, both Nullable
Obviously it's a workaround, but it should work
And there doesn't seem to be a better way in the current version
yea but getEntity on that event would be the item dispensed no ?
yea
at least, that is what it does rn
no
an Item, or an ArmorStand, or a Boat, whatever it has spawned
no currently there is no getEntity() method whatsoever
right now it only outputs the item being dispenced, which is an ItemStack
not an Item or Entity
yea
you can set the item
how are you going to provide me the armorstand instance if I can just
change the item
there could be separate BlockDispensedEvent
An even more sane solution would be to remove dispensers from the game
yeah I didnt htink about it, I'll update my jira thingy
non cancellable, non mutable itemstack
just, it dispensed this entity from this itemstack
or this blockstate from this itemstack
question is, do you call this after the respective spawn events
remove crafting tables while we're at it we dont need em
I mean, another alternative for this would be expanding the spawn reason API
and the Dispenser that caused it
idk, dispensers are absolutely fucked
yeah especially the ones that shoot burning arrows at me whenever I'm minding my own business
can dispensers also set stuff on fire?
with lava i guess
right dispensers can shear shit too
like yea, idk
thats alot to take into account 😄
you are just never getting everything shat into that event
i wanna put a knife into one and take it into london
Yea, I mean the per action event approach seems to somewhat most reasonable
yea i agree
its just bleh when there is already existing events
that don't allow for the context of the dispenser/item used
my benchmark is done. seems like my parser is faster than regex after all lol
Is this for spigot plugins help?
no
but you should rather look for the actual plugins' discord if you got questions about a specific plugin
Na its a plugin I'm making but having errrs
oh a plugin you are making? yes then you're correct here
ITs a dependcy err
then ur in the right place
Alr,
tell us more
if you get verified you can send screenshots btw
?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 can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
you almost made me learn regex
I just create plugin with intellij and get this:
java.lang.IllegalArgumentException: Plugin already initialized!```
wtf?
is ur plugin in the folder twice?
i love regexes
nop
or are to trying to create an instance of your main class?
are you doing new MyPlugin() somewhere?
public class Meteors extends JavaPlugin {
private static Meteors inst;
public static ConsoleCommandSender console;
@Override
public void onEnable() {
// Plugin startup logic
inst = this;
console = getServer().getConsoleSender();
this.getCommand("meteor").setExecutor(new Meteors());
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
public static Meteors getPlugin() {
return inst;
}
}```
ye u are
But I have this code in others plugins and it works 😄
just pass this
no, it has never worked like this
that woulnt ever work
it expects a Plugin object - you already have one. this
Its working for me for some reason 😄
no, you can create any object you like, except a new instance of your main class
use this isntead of new Meteors()
your class extending JavaPlugin is a singleton
this.getCommand("meteor").setExecutor(new MeteorCommandManager()); this is what I changed and its working
there was linked bad class 😄 Im blind
yeah well MeteorCommandManager() does not extend JavaPlugin, hence you can create as many of those as you like
reckon you should look more into how objects work because if i have to guess you probably dont want several new instances of your command manager
btw. In some videos, I saw code like this to get instenc of plugin. But Im getting error
private Meteors inst;
public static Meteors getPlugin() {
return inst;
}
well yeah you havent made inst static yet
you cant pass non-static variables into static methods
You often need a reference to your main instance (the instance of your class that extends JavaPlugin) in some of your other classes. There’s two basic concepts for this. Choose whichever you like more. Method #1: Static Getter First way is to create a static method called getInstance() or similar in your main class. You...
Alr, my old account was on my main email but switch to a business email where multiple people use it am I allowed to make a new one if my main email isn't being used by spigot anymore
static methods you can see as behaviors of the class as whole whereas non-static methods are behaviors specific to the class instance, you cant pass on class instance-specific information to general class behaviors. there's no way for the program to know which information you could possibly be referring to
you mean a new spigot account? actually no, that's not allowed
but I'm not staff, so what do I know, I don't care lol
I doubt that a singleton is a good example to explain the differences between instance and class members 🥲
yeah uh
anyone has an idea
of how to reverse this
uint32_t a=genrand_uint32(self)>>5, b=genrand_uint32(self)>>6;
return PyFloat_FromDouble((a*2^26+b)*(1.0/2^53));```
💀
I saw on one video there was Database instance and he was able to useit whitout making it static. Gonna find that
it's how python generates random.random() using random.getrandbits(32)
that's method 2, dependency injection
@tender shard thought it would be worth asking so uh
do u know how to reverse
random.random()
not reverse actually
but to predict future outcomes
based on previous outcomes
Is there a reason as to why the metadata packet is sent twice for the same item when invoking World#dropItem?
Im doing same way but getting error. Like this was in the video https://youtu.be/MbsI0bNxDEc?si=SfUROubzx72aIHLb Trying to find some time where he use it.
In this episode of the Spigot series, I show you how to make your first plugin that connects to and uses a MySQL Database to store player statistics. It uses JDBC to connect and execute SQL statements upon the database. #Spigot #Minecraft #SQL
(Adding video timestamps soon)
Code: https://github.com/Spigot-Plugin-Development-Tutorial/plugin-with...
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
It did, but in video is not static and still can accesit in other class. Probably I miss something
what ever
I just makeit static
probably because they passed around the instance
exactly as described in method 2 of my blog post
it's called "Dependency Injection"
Thats what I missed proably. It depends withc method I use? Its problem if I make it static and use like that?
you should learn java if you dont know this
as I mentioned, your plugin instance is a singleton anyway, so you can use a static getter just fine
difference between static and non static
Yep.. I just jumped in spigotAPI whit soem rly small knowleage of programing.
static = properties or behaviors ALL instances of the class shares, nonstatic is properties or behaviors only that one instance has
usually online tutorials all suck. I'd rather read a book about java
thats why utils methods are all static because they're always the same
public class Person {
public static int MAX_AGE = 150; // No person can be older than 150
public String name; // Every individual person can have a different name
public int age; // same for age
}
Imagine this.
You can now do Person.MAX_AGE because it's static, it belongs to the Person class itself. But you cannot do Person.name because every Person can have a different name, hence you can only call "name" on a SPECIFIC person object
could technically make an instance of your utils classes, but really why would you
gonna need to bump that max age number up after a few with billionaires and their baby blood diet 😔😔😔
dw it's not final lol
you rite
Oke I see. Gonna need learn some java OOP, thanks anyway
Person.MAX_AGE = 250; //watch me
public void setAge(int newAge) {
while(newAge > MAX_AGE) {
MAX_AGE++;
}
// ...
ez fix
public void setAge(int newAge) { while(newAge != new Random().nextInt(MAX_AGE) + 1) { } MAX_AGE = newAge;
this is cooler
gotta implement bogo sometimes too
and also instantiate the random every time
public enum PrettyBoolean {
VERY_MUCH,
MORE_OR_LESS,
NOT_SO_MUCH
}
i once worked for a company that used fuzzy logic all over the place
it was quite annoying
well I didn#t work there, I only did an internship
what for?
they made a time management system and stuff for employees/employer, e.g. people could enter when they wanted to have vacation and which times they wanted to work, and then it generated the plan who has to work when, who got vacation when, who works on which project, and so on
the software's called IntraSail https://indal.de/intrasail-software-rund-um-den-menschen/
i see
yea ittl just randomize true and false hahaha
sometimes should be a java keyword
public sometimes synchronized void waitMaybe();
throws FellAsleepException
lmfao
I would like an amongus keyword
its a company secret
Hm how do you export the jar automatically to a local server directory?
this?
from jar
into '/path/to/server/directory'
}```
Looks good
Then you can make it depend on build
tasks.copyJar.dependsOn
Something like that
Check out my fancy buildSrc https://github.com/mfnalex/PAPI-Replace/tree/master/buildSrc/src/main/groovy
Why not turn that into a named task that you can run separately
i don't know how to code that i just used chat gpt
tasks.register("exportToTestServer", Copy) {
dependsOn build
from shadowJar.archiveFile
into '/c/mctest/plugins/'
}
Eg like this if you use shadow
Otherwise use „from jar“
Every second tuesday excepton full moon
exactly, when can I have my boolean with a 100 possible values
oh im using kotlin not groovy oops
I have bungee project
and api project for that bungee project
the api needs the bungee as dependency
but bungee needs the api also as dependency
how should I organize my project structure so maven can compile it?
https://blog.jeff-media.com/maven-multi-module-setup-for-supporting-different-nms-versions/ this for spigot+nms but the basic idea applies to every multi module project
Hi there! Today I’m going to explain how to setup a multi-module project using maven to support different NMS versions. Important notes about this tutorial: Every step will have detailled screenshots using IntelliJ. I explicitly chose not to include everything as copy/pastable source code, but normal screenshots (you can click on them to show th...
You can also just use normal separate projects
tysm
Then mvn install the API and then use it like any other dependency
tried those
but when i install project 1, it doesn't knows of project 2
and wise versa
riight
what makes more sense?
api depending on the plugin
or plugin on api
i think api on plugin?
Plugin depending on API, 100%
is it bad project structure when the API consists of just ClassName extends ClassName ( but from the plugin )?
if that even makes sense :d
never made API before
soo
That makes little sense. Usually the api would be mainly interfaces that the plugin implements
is it possible to spawn in the explosion rays tnt causes and declare their strength, or do i have to fake it with ray traces?
oohh right
thx again
Np
so apparantly i cant find the stash for the tnt explosion and only get some JIRA entries :/ dafuq
I'm trying to disguise a player as a block. I'm using an un-expiring falling block that TPs to the player upon move. However, it only teleports after about a second. I read on this discord that it may be to do with how often Minecraft renders falling blocks. Is there any way to get around this?
What version
1.20.1
Is there any way to get a list or array of blockstates from a Worldedit clipboard or schematic without getting the maximum and minimum points and iterating through all possible blocks within the cuboid defined by those points?
I was before but I wanted to try using a falling block so it'd have a hitbox
Use an interaction entity to add a hitbox
Ah, cool
Didn't know you could stack a block display on the player. Sounds a lot smoother than TPing every move. Thanks!
My plugin isn't like recognizing the json dependency
Why not just use Gson. Spigot has that already.
Your problem is that you didnt shade org.json in.
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230618</version>
</dependency>
Also I kinda can't cause the plugin generates files in a datapack unless minecraft can read it.
Why wouldn’t it be able to
Doesn't datapack need to be .json for minecraft to read it?
Json from gson is the same flavour
Yes? And
Gson can generate json files
Gson is just the name of the library
Sorry, how do you translate a passengers location?
Can't find it on google
Its part of the entities transformation.
A transformation consists of:
- Translation
- Rotation
- Scale
Thanks! Working now
Am I the only one who thinks that you need to submit your home address to pr to spigot is wierd?
Only thing is now, no idea what the ride height is for players
So IDK by how much I should be translating down
Am i allowed to ask people for a favour
generally ye$, but mo$t wont do $hit if you don't offer compen$ation
why are u typing like that
or give something in return like
it really depends what you mean by favor like
is it really a favor or a massive pain in the ass
i clicked here from a different channel
and only saw the words "gag reflex"
welcome to hell
where would i start with coding plugins with java?
uh theres good series on youtube, and i believe spigot.net has a basic tutorial somewhere
if you're asking in terms of 'what' instead, like... start with things like making blocks/entities appear. The api is massive
Do also take a look at events. 99% of plugin code starts with either commands or events
yeah im trying to recreate a minigame that used to be on mineplex
spigot.net wat
figured that one out
:D
How do I set custom model data of net.minecraft.world.item.ItemStack?
How do I get the meta data? There doesn’t seem to be a built in method for it
That’s org.bukkit.inventory.ItemStack. Not net.minecraft.world.item.ItemStack
For NMS purposes
no like
wheres the difference between NMS and spigot custom model data
cuz if you can do it with the api you really should lol
I need to display an item in an item-display. The item-display does not exist, thus I need to use the net.minecraft.world version of it to show it to the client only, without spawning it in the actual world. The API for net.minecraft.world.entity.Display.ItemDisplay has a method to set the ItemStack, but it takes a net.minecraft.world.item.ItemStack as an argument. This version has no metadata method
wdym ItemDisplay is a thing
declaration: package: org.bukkit.entity, interface: ItemDisplay
why dive into NMS when you could use the spigot version? unless you're planning to spoof
Anyone know if there's a way to rotate a block display?
I need the server not to handle the entity, and the entity to appear only to a specific player
The transformation method is so overcomplicated, surely there's gotta be a way to just set facing west or something?
well with ItemStacks don't edit ItemStacks raw
use the Api then translate it after
CraftItemStack#asNMSCopy
if you do edit them raw I reccomend looking at NBT structure it'll be needed for some things such as lore
blockdisplay = entity
ergo: Setting direction vector to 1,0,0 should do it
actually it doesnt use vectors in the teleport method
Is that safe to do if the block display is mounted?
no clue
Yh, I would assume it would teleport it off
only way i see to do it is to teleport it to the same location with pitch 270 and yaw 0
Hmm
Eyo, just figured it out
Literally, blockDisplay.setRotation(yaw, pitch);
Totally didn't just spend an hour trying without trying the most obvious method in the world
Rotates around the centre and everything ffs
In mcmmo, I am trying to access the database in my code, but the tables are confusing. Does anyone have a guide to the tables created by the db?
Hello, I have a survival server. the lobby is in a world apart from survival, but every time someone enters the nether in the survival world, they are automatically teleported to the nether of the lobby, Does anyone know how to change this so that the nether and end world lobby are no longer used?
help by what criteria to evaluate the cost of the plugin if there is no clear technical specification
how many features, is it unique, quality, etc?
Arent you turkish and hence dont have paypal?
how would you guys get all air blocks in cuboid?
hello , i got a problem in development.
is the way i use multiply correct?
why i get zero after multiplied a number(0<number<1) to a vector?
System.out.println(arrow.getVelocity().clone().multiply(1));
System.out.println(arrow.getVelocity().clone().multiply(1/2));```
[15:10:42] [Server thread/INFO]: 3.035488808816186,0.09096469190424816,-0.5375180709861463
[15:10:42] [Server thread/INFO]: 0.0,0.0,-0.0```
with worldedit or what?
oh , i figure it out by replace 1/2 to 0.5.
1/2 is integer division and results in 0
with nothing, same as yesterday i have 2 locations and need to figure out how many blocks of air is inside
Cuboid cuboid = new Cuboid(one, two);
World world = ...;
for(BlockVector vector : cuboid) {
Location location = vector.toLocation(world);
Block block = location.getBlock();
...
}
This is the dumbest approach
The smart approach if you're working with a huge area is to make chunk snapshots n stuf
so you essentialy just iterate through every block?
any1 has a nms packets tutorial
Just use Protocollib or PacketEvents
depends on why you believe you need packets
to make player npcs
YOu first need to decide if you really want to do all that yourself instead of using Citizens
I wouldnt mess with ProtocolLib.
Either NMS packets or simply use Citizens
Citizens is great
I need custom pathfininding
That has nothing to do with packets
Using Citizens to create/manage all your NPC's means you don;t need any NMS
But does citizens support custom pathfinders?
Or only their builtin stuff eg walk from x to y?
You can make them wander and set a range limit
You can probably do more with the API directly
Nice, but I wonder if they support a totally custom nms pathfinder
Doing NPC's yourself is a little difficult as you have to update for every single release of Spigot.
Like an actual GoalSelector thingy
probably not
Sad
That's why i need that
why?
What does your pathfinder do?
We no longer believe you need pathfinding
i need atleast player npc for now
Citizens
Citizens is starting to lose rep
Does it means i have to install the plugin?
But its pathfinders are good
You can set NavigatorParameters by the looks
I'll bump its rep hereby: +1
It's hacky and constantly respawns entities
getEntityId changed throughout time
Nameplates are weird armorstands that you have no control over how often they spawn
And no idea if they've spawned or not
Sounds like it bloated over the years
tbh npcs have always been pretty jank code wise
i've made npcs but they're client sided
well... if we just had mixins :)
Well there is this
Not saying it's good, but it's possible
4 years ago ;-;
ye think I saw this 2 years ago
But I think it still works like a charm
As it's just a launch wrapper
Using a probably old version of mixin but who cares lol
ik there's another 1 i used
Ignite prob
I think that also bootstraps mixins
Mixins in spigot, would be hilarious

ye well it doesnt make sense to have here with the api but ntl would b nice
They also bundle accesswideners
For the funnies
Or just straight up raw dogging asm
That would be master class
"just pr it mann"
lol ye
im not that masochistic but drastic measures call for drastic changes
just make every field public also 
sponge
I now wanna do this when I get out of brussels
I think there already was something like this for fabric
i acc hate public fields
so much easier to callback inject in fabric when theres a setter/getter
Only one more reason to do it
acc idk, maybe its possible to callback inject fields
That transformation will prob take ages with all the method and fields Minecraft contains💀
fr lol



