#help-development
1 messages · Page 2157 of 1
dk what you mean with that but I need to save a loc basically so a player can teleport himself there then
in which case you are likely going to need pitch and yaw too
yes
and teh double precision
This is how you handle a TypeAdapter for Location. Just replace Student with Location https://www.tutorialspoint.com/gson/gson_custom_adapters.htm
okay thank you alot but I think I almost got it
I fixed it, appearently this is what it takes to call a custom event
how do i get players in X radius of a Location
how do I know what I can save to json? Can I save floats for example
it will handle all primitives fine
and blocks aswell? because I get the same error I got with the location before
it should handle blocks. I don;t belive there is anything in a Block that it would struggle with
How do I get TPS from BungeeCord?
scheduler.scheduleSyncRepeatingTask(this, () -> {
for (Location loc : getLightLocations()) {
for (Player player: getServer().getOnlinePlayers()) {
// if(player.getLocation().getBlock().equals(loc.getBlock())) {
World world = loc.getWorld();
int lightLevel = LightAPI.get().getLightLevel(
world.getName(),
loc.getBlockX(),
loc.getBlockY(),
loc.getBlockZ()
);
if(!world.getNearbyEntities(loc, 1, 1, 1).contains(player)) {
if (lightLevel > 0) {
LightAPI.get().setLightLevel(
world.getName(),
loc.getBlockX(),
loc.getBlockY(),
loc.getBlockZ(),
0
);
getLightLocations().removeIf(location -> location.equals(loc));
}
LightAPI.get().setLightLevel(
world.getName(),
loc.getBlockX(),
loc.getBlockY(),
loc.getBlockZ(),
lightPlayers.get(player).getIntensity()
);
}
// }
}
}
}, 0L, 0L);
This still leaves some lights
Bungeecord has no TPS
I mean from BC plugin
I want to get all servers tps
Send a custom plugin message through plugin messages
right.. thx
Got it to work with replacing the Block with x y z somehow the Block was a problem idk thank you a lot
does anyone know hwo to create custom entities with ai? i just need to use player models
but i need them to do stuff
how would I make it? how would I add ai to it?
Thats really not an easy task. There are several approaches but almost all of them include quite a bit of nms.
You need to extends an nms entity that is of type insentient and change its AI goal selector.
But making an entity look like a player is a bit tricky.
Which part. How to create a custom entity or how to disguise entities as players?
is there like a guide anywhere
disguise entities as players
i think i can figure out the other stuff
The easiest way would be to simply not change the entity type server side but let other players
see the entity as something else (like a player). This can be done with
https://www.spigotmc.org/resources/libs-disguises-free.81/
for example.
how did they put a text under the pointer?
with a resourcepack
isn't that just a title?
pretty sure rhats just /title
subtitle 👀
yea just Player.sendTitle(null, ".......") or sth
okkk thank you all i didn't think of that option
are these good to use?
hi can someone help how to set custom damage for itemstack?
It's not like i need to push it to its limit so i assume the default works well enough
what MC version?
just cast the ItemStack's ItemMeta to Damageable, set the damage, then set back the Meta using ItemStack.setItemMeta(...)
1.12.2
let me try
I think in 1.12 you can just do setDamage(...) or sth on the itemstack itself
Just add some attribute modifier on the ItemStack
I think they want to damage the item itself, and not change how much damage this itemstack does to mobs
but not sure
The method addAttributeModifier(Attribute, AttributeModifier) is undefined for the type ItemMeta
i get this errrors
do you want to "damage" the itemstack, or change how much damage this item does to mobs/players?
i want to change damage to mob/player when hit
you could always use the EntityDamageByEntityEvent, then check if the damager had your custom item equipped
i will doing event EntityDamagebyEntity event to change damaage
but attributes are better, as 7smile said
but my attributes get suck some where
yeah as said, I don't know anything about 1.12 API
but I am pretty sure that attributes existed there too
@lost matrix do you have anyway to set Attribute for item in bukkit 1.12.2?
I dont work with old versions
Can anyone familiar with JSON help me- I am trying to get a long value from a JSON Object but it gives me this error, but it also literally says it's a long..
It's a string
It's wrapped in quotes, so it's a string
Get it as a string and then use Long#parseLong
Why would it be?
Long.parseLong() i think should help
Hm
I dunno, you tell me
its serialized, which means that it is stored as a String basically
when deserializing you have to take that into acount
Why would it be serialized though, I thought converting a document to json handles that.
Oh god what why
It might be due to boxed types
So should I iterate and unbox each thing when converting the document to json?
you meant this when saying that it was stored as a long?
On MongoDB it is stored as a long, and all I did was Document.toJson() which converts the document to json, which leads to me to believe that it'd be a long lol
Then again it's just printing the Json Element as a string, that could be it's info when it's a string- but when I do getAsLong() (what it should be) it errors.
because it's stored as "12345"
json is a bit weird
one reason to avoid it lol
the key to the value is "$numberLong", that doesnt mean it is stored as a long
The key is supposed to be "price" lol
When getting the "price" element it is that
Alright I may have found the issue, when looking into MongoDB- using toJson has different modes which changes what the output will be for things.
It seems if I set it to relaxed it'll fix the issue.
Yup
Oh you are talking about Mongo i seen, as far im getting this shity error but i think its caused by the logger of mongo:
may 22, 2022 11:15:22 A.M.
com.mongodb.diagnostics.logging.JULLogger log
INFORMACIÓN: Cluster created with settings {hosts=[127.0.0.1:27017], srvHost=mongodb.aa6vu.mongodb.net, mode=MULTIPLE, requiredClusterType=REPLICA_SET, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500, requiredReplicaSetName='atlas-j0k5hq-shard-0'}
If someone can confirm i will be thanks
How do I get if the block is tilled dirt ?
LEGACY_SOIL is deprecated
do you mean Material.FARMLAND?
`
import net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget;
import net.minecraft.world.entity.animal.EntityPig;
import net.minecraft.world.entity.monster.EntityZombie;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
import org.bukkit.entity.Zombie;
public class CustomZombie extends EntityZombie {
public CustomZombie(World world) {
super(((CraftWorld)world).getHandle());
Zombie craftZombie = (Zombie) this.getBukkitEntity();
this.targetSelector.a(new PathfinderGoalNearestAttackableTarget<EntityPig>(this, EntityPig.class, true));
this.getWorld().addEntity(this);
}
}
`
Why are my methods targetSelector and getWorld red - cannot ressolve method xy in Custom Zombie?
How would I go about creating guilds that I can be saved and others can join?
What do you mean by guilds?
because with this.getWorld() you are calling an undefined method (you haven't created one)
A group/list that players can join
But it also has to save over server restarts
Then you should use a database/yaml or json for saving them
Yeah but in every tutorial those methods are predefined?!
i assume they're outdated
try this.bQ instead of this.targetSelector
bbq
https://paste.md-5.net/xayakojupi.coffeescript how can i fix this?
It's compiled on a newer Java version than the one you are running
yes i know that, but how can i fix this? that is a dependency i added in my pom
use Java 17
^
Basically update your Java
or use an older version of the dependency which i might not recommend
i can't because minecraft 1.17 only works with 16
already did
nothing changed
can i put items on head of armorStand?
man this would break everything i've done i guess
or probably not
Doubt that
Not many things changed on the api side iirc
Only thing is really the world
this is 1.18 right?
Yes but use 1.18.2
is there a way to make tnt smaller
or like have it ride a player
without ruining their hitreg
?
you forgot the R0.1
?
so R0.2?
No
1.18.2-R0.1-SNAPSHOT @midnight shore
not that hard
how do I retrieve the clicked entity from a PlayerInteractEntityEvent?
Thank you
Get the entity
how
e.getRightClicked() i guess
no
check the docs
or check what methods the object has
np
Lol
idk why my maven reload is getting slower and slower, even if i don't quite think there are lot of heavy things in there
get a location and spawn the armorstand there, it will spawn at any location even if it is inside of a block
no
?
That's how I'd do it lol
or if it doesn't work just teleport inside
Probably need to deal with collisions and what not
do you know how?
is there a method in the ProjectileHitEvent event that gets the damaged/hit entity? (That works in the 1.8.8, event.getHitEntity(); throws a NoSuchMethodError here)
Check the javadocs
If it's throwing a nosuchmethod i would assume that your api version does not match the server version
listen for the EntityDamageByEntityEvent and verify that the damager is an arrow and get the entity (defender)
same thing
THANKS!!!
iirc tho
no, i need to get center of teh block. Do you know how?
https://paste.md-5.net/pecacoyuce.cs can anyone help me to understand whats wrong here?
bad password?
add 0.5 to x and z
but its correct
then I dont know
i fixed, ty anyways
plugins {
id 'java'
}
group 'fr.program.testplugin'
version '1.0.0'
repositories {
maven {
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
content {
includeGroup 'org.bukkit'
includeGroup 'org.spigotmc'
}
}
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url = 'https://oss.sonatype.org/content/repositories/central' }
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
compileOnly 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
}
test {
useJUnitPlatform()
}
``` When I execute : gradle on the right -> build -> jar, I got this: ```
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find commons-lang:commons-lang:2.6.
Searched in the following locations:
- https://oss.sonatype.org/content/repositories/snapshots/commons-lang/commons-lang/2.6/commons-lang-2.6.pom
- https://oss.sonatype.org/content/repositories/central/commons-lang/commons-lang/2.6/commons-lang-2.6.pom
Required by:
project : > org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220517.093124-43
> Could not find com.google.guava:guava:31.0.1-jre.
Searched in the following locations:
- https://oss.sonatype.org/content/repositories/snapshots/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.pom
- https://oss.sonatype.org/content/repositories/central/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.pom
Required by:
project : > org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220517.093124-43
> Could not find com.google.code.gson:gson:2.8.9.
Searched in the following locations:
- https://oss.sonatype.org/content/repositories/snapshots/com/google/code/gson/gson/2.8.9/gson-2.8.9.pom
- https://oss.sonatype.org/content/repositories/central/com/google/code/gson/gson/2.8.9/gson-2.8.9.pom
Required by:
project : > org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220517.093124-43
> Could not find net.md-5:bungeecord-chat:1.16-R0.4.
Searched in the following locations:
- https://oss.sonatype.org/content/repositories/snapshots/net/md-5/bungeecord-chat/1.16-R0.4/bungeecord-chat-1.16-R0.4.pom
- https://oss.sonatype.org/content/repositories/central/net/md-5/bungeecord-chat/1.16-R0.4/bungeecord-chat-1.16-R0.4.pom
Required by:
project : > org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220517.093124-43
> Could not find org.yaml:snakeyaml:1.30.
Searched in the following locations:
- https://oss.sonatype.org/content/repositories/snapshots/org/yaml/snakeyaml/1.30/snakeyaml-1.30.pom
- https://oss.sonatype.org/content/repositories/central/org/yaml/snakeyaml/1.30/snakeyaml-1.30.pom
Required by:
project : > org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220517.093124-43
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
I would like to do my plugins test in 1.18.1
Does anyone know how I make the schematic paste to the direction the player is looking?
https://media.discordapp.net/attachments/704811371996381245/977941881470193674/unknown.png
ArmorStand hologram = (ArmorStand) chest.getBlock().getWorld().spawnEntity(chest.getLocation().add(0.5,0,0.5), EntityType.ARMOR_STAND);
hologram.setMarker(true);
hologram.setGravity(false);
hologram.setInvulnerable(true);
hologram.setCustomName("test");
hologram.setCustomNameVisible(true);
}``` why name of hologram is invisible?
You're setting all of those things after you already spawned the armor stand
does it matter?
yes iirc
but other things works, like setMarker etc.
someone help me for maven ?
Does anyone know why my result set is null? I'm working with SQLite and I've also tried changing what I'm selecting. * to self_hugs. The data is in the database, so why am I getting null?
not using a try with resources aaaaa
The sqlite.executeQuery() is.
But I pass it through.
yep
he connection and the ps are closed after the try block
yea
ah got ninjad
🥷
So I would have to make the same query again wouldn't I?
Or just move the check to that try block?
i guess you want to handle the try with resources in the method that handles the resultset
so put it in one place
or use some fancy database library brrr
or that
additionally, prepared statements exist for a reason
passing in the entire query as a string screams for SQL injection
Well, I'm just testing things out right now. I'm sure once I get things in a working state, I'll try and improve things. I'm also using PreparedStatements btw, it's just that I'm currently passing in a concatenated string. Which will probably change to that mysql syntax with the question marks here shortly.
a good idea to do that asap 👍
Yea, that's what I'm probably going to do for as a starting point.
Yea usually the easier approach
and now i remade my whole storage design for different databases :/
Oh right, this is SQLite. So I'm used to mysql using a while loop to iterate over the resultset. This seems to be an issue with SQLite. Will there be any issues if I change it to an if statement? Wouldn't that cause issues if there are multiple results?
the result set works the same
you should still be able to use a while look just fine
It would, yes. You use a while
Well apparently I'm having issues with that. 😛
java.sql.SQLException: ResultSet already requested
Amazing shity, i have checked on goole and its okay
UUID.fromString
If im telling to cast as uuid, why its treating it as string?
are you still busy with that claims plugin?
Yeah 1 month
could be caused because the datbase contains a document?
I will try deleting the test document i created, maybe that the issue
dude can u help me for maven ?
im working for authme maven 2 hours
What are you trying to do?
i want to add aliases for authme commands
and i try to add authme with maven
Looks like Nullpointerexeption
yeah but i cant see any other informations
You have something hiding the rest
Have you add the repo for authme?
did you reload it?
wdym
I really dont know just check the authme repo on their github
I think this causing the issue. Im actually really dumb
yes this is true
😂
So its the same repo?
How can I enable UTF-8 for my plugin?
yes
In project settings
do people even use google
Try this things:
-
Go to .m2/fr/xephi/authme and check if its inside the pom.xml or if its empty the directory
-
Delete the .m2/fr/xephi directory
-
Close your project, open it again and reload the maven
-
If issue still there, try to invalidating cache if you are on Intellij
Maybe something of this work
That what i usually do when something its not working
is there any way to get front face of chest?
Got it working. Looks like I didn't copy the updated version of the project correctly. :/
is there an way to delete an chunk or prevent generating new chunks entirely?
omggg thanks
😢
how could i get fornt face of chest?
Uh why? I got this error: error: illegal character: '\u00bb' package fr.program.testplugin.commands;
package fr.program.testplugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AnnonceCMD implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("annonce") || command.getName().equalsIgnoreCase("announce")) {
if (sender instanceof Player) {
Player plr = (Player) sender;
if (args.length > 0) {
Bukkit.broadcastMessage("§f[§4ANNONCE§f] §7" + args);
} else {
plr.sendMessage("§f[§ERREUR§f] §7 Vous devez donner des arguments !");
}
}
}
return false;
}
}
i want to change some plugin's commands with maven someone know ?
actually i wanna execute command with
Somewhere you have this symbol: » Probably an issue with your encoding. Check your project settings.
What I have to change about the encoding? https://gyazo.com/295e11ba9009b4f5194bdc78be33cab7
Ensure that the section down in the bottom right says this when you are in a file. Your project settings look fine. Are you using maven for this project?
Welp. Check your build files then. In maven we have to declare the following properties.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
Something similar should exist for gradle.
No nvm.
Build files?
Whatever file is equivalent to the pom for maven. I think it's gradlew.
Looks like this might be it.
compileJava {
options.encoding = 'UTF-8'
}
Thank you!
how much hp does armorstand has?
I'm writing a large-ish killeffects plugin, and all the effect classes are inside of my package net.vlands.effects. Is there a way to go through every class and add it to my effectmanager map instead of writing like 120 lines for all the effects
using reflection maybe im not sure
public static List<Class<?>> getClassesInPackage(String packageName) {
String path = packageName.replaceAll("\\.", File.separator);
List<Class<?>> classes = new ArrayList<>();
String[] classPathEntries = System.getProperty("java.class.path").split(System.getProperty("path.separator"));
String name;
for (String classpathEntry : classPathEntries) {
if (classpathEntry.endsWith(".jar")) {
File jar = new File(classpathEntry);
try {
JarInputStream is = new JarInputStream(new FileInputStream(jar));
JarEntry entry;
while((entry = is.getNextJarEntry()) != null) {
name = entry.getName();
if (name.endsWith(".class")) {
if (name.contains(path) && name.endsWith(".class")) {
String classPath = name.substring(0, entry.getName().length() - 6);
classPath = classPath.replaceAll("[\\|/]", ".");
classes.add(Class.forName(classPath));
}
}
}
} catch (Exception ex) {
// Silence is gold
}
} else {
try {
File base = new File(classpathEntry + File.separatorChar + path);
for (File file : Objects.requireNonNull(base.listFiles())) {
name = file.getName();
if (name.endsWith(".class")) {
name = name.substring(0, name.length() - 6);
classes.add(Class.forName(packageName + "." + name));
}
}
} catch (Exception ex) {
// Silence is gold
}
}
}
return classes;
}```
from stack overflow lol
Hi I was wondering if someone knows why this doesnt work. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "team add Ruubbie.Robbers"); I have it in the onEnable method and when I type it in the console myself it does work. I have already tried and the . isnt the problem.
scoreboard teams https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/scoreboard/package-summary.html
declaration: package: org.bukkit.scoreboard
declaration: package: org.bukkit.block.data, interface: Directional
thanks man]
public void registerAllEffects() {
List<Class<?>> discoveredClasses = ClassEnumerator.getPackageClasses(Angry.class.getPackage());
discoveredClasses.forEach(clazz -> {
try {
clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
});
}```
lmao idk
error: illegal character: '\ufeff'
Does anyone know how I make the schematic paste to the direction the player is looking?
maybe something with the player's direction ? idk if they have methods for that
Anyone know how to check what item the playyer dropped?
I want something to happen when a player drops tnt
why is that in a bukkit runnable
you want the front to face away
besides that your IDE is already screaming at you
or at the player?
you are comparing an item stack with a material
ok i want it to explode like 10 seconds after they drop the tnt
those will never add up
yes
if you want the schematic to face away, you need to rotate in memory 180 degrees
you can grab an item stacks type using .getType()
I tried that but the IDE is saying it always evals to false

how do i cast an unknown subclass to it's superclass?
I have a List<Class<?>> and i can iterate through them with
forEach(clazz -> {}
nvm i see what i did wrong
accidently deleted something
public void registerAllEffects() {
List<Class<?>> discoveredClasses = ClassEnumerator.getPackageClasses(Angry.class.getPackage());
discoveredClasses.forEach(clazz -> {
try {
clazz.newInstance();
if (clazz.getSuperclass().equals(Effect.class)) {
plugin.getEffectsManager().addEffect(((Effect) clazz));
}
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
});
}```
I dont even know
im tryna init every class in a package and add those classes to my effectmanager map
i could just do 120 lines of new Class() but if this is possible i wanna see if i can get it to work
oh right ok 😬
you can cast the instance of the subclass as a super class
but the class themselves are not related on the type system level (well they are the same type, java.lang.Class)
isnt that the same thing? wdym
I don't think I understand your point
i should cast thei nstance and not the class you mean
yes
the class is just an instance of java.lang.Class
there is nothing to cast there
your code is just not good
you are creating a new instance
and do nothing with it
you want to cast that instance
tho that is also wrong, you should check the type of the class before hand
Entity.class.isAssignableFrom(Player.class)
``` would return true
I am still a beginner and cant really figure the team api out. Does someone have a example?
package fr.program.testplugin.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AnnonceCMD implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("annonce") || command.getName().equalsIgnoreCase("announce")) {
if (sender instanceof Player) {
Player plr = (Player) sender;
if (args.length > 0) {
Bukkit.broadcastMessage("§f[§4ANNONCE§f] §7" + args);
} else {
plr.sendMessage("§f[§ERREUR§f] §7 Vous devez donner des arguments !");
}
}
}
return false;
}
}
guys someone help me ? i download authme's source code from github and open with intellij but i can't build this project no one console messages and no one file for target someone help ?
hi can someone help me please ? I want to spawn an entity in a random location around another location
I can help you with that
do you wanna randomize the y aswell? or just x and z
x and z for now i guess
you have your location to spawn around?
at that point you just have to get 2 random numbers, I believe that ThreadLocalRandom.current().nextInt(int lowerBound, int upperBound) should be good enough
what radius should it be in?
maybe like +5 to -5
so you have your bounds for the random number. now do it for both x and z and you got yourself a pseudorandom location around the original location
alternatively you could randomize a vector and its length, but thats a bit more complicated than just randomizing the location
you know how to actually make that location be around the original one, right?
I try some .add() with fixed value but it didn't work
i'm a beginner and i'm kinda lost x)
you mean location.add()?
yes
hold on
thats the one you want. randomize the first and third one, put the second at 0
beginner in java or just spigot?
java
ah ok, could you show me what you tried for the add() method?
can i take you in mp ?
mp?
private message
mb
Anyways you should use a string builder , args is an array so you won’t see your text
guys pls help i download a project from github and open with intellij i build project but no one file in target why ?
I have this now, but it does not do anything. 😦 ```public final class Teams extends JavaPlugin implements Listener {
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
Team Red = board.registerNewTeam("Red");
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
Red.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
}
@EventHandler
public void onPlayerJoin (PlayerJoinEvent e){
Red.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.NEVER);
Red.addEntry(e.getPlayer().getName());
}
}```
how could I attach special data when a player switches over to another server?
my use case is that i need to send resource pack status from one server to the other so that I know not to redownload it on switch
how can I accomplish this in bungeecord’s message system or some other bungeecord feature?
public void registerAllEffects() {
List<Class<?>> discoveredClasses = ClassEnumerator.getPackageClasses(Angry.class.getPackage());
discoveredClasses.forEach(clazz -> {
if (Effect.class.isAssignableFrom(clazz)) {
try {
plugin.getEffectsManager().addEffect(((Effect) clazz.newInstance()));
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
});
}```
Mine reset lite dose not work for me can someone help
hello guys how could we decrease the amounts of ores
Can I get the entity that the projectile hit with EntityProjectileHitEvent?
is there an way to add or remove an permission to/from an player? I know there are permission plugins. but i want to do it with an own plugin.
is there an bukkit method for it?
if so, you can use the getEntity() and getShooter() methods in order to get the source of the projectile
I figured it out
What is better an armor-stand or player entity for doing npcs?
Hi I am using a for loop and want it to sleep for 500ms after every repeat: How do you do that in spigot?
sleep what?
?scheduling
you never sleep in the main thread
to wait before doing the next loop
How can I manage to do that??
Its urgent
read the link I gave you
....
If need it fast pay someone to do it
If not be patient...
You can not sleep in a for loop on the main thread. Use the scheduler to move off the main Thread (Async), or use a Sync repeating task (BukkitRunnable) to increment a value instead of a for loop.
Usually people want delays between sending messages and think sleep is the way
Ok I have this code:
// With BukkitRunnable new BukkitRunnable() { @Override public void run() { Bukkit.broadcastMessage("Mooooo!"); } }.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
Have you read what he linked?
The "plugin" is the instance of your Main class
Oh lmao for sending broadcast i use schedule running every x time + a delay given by a timestamp
if you are IN your main class you use "this"
Maybe iits worst but idk i always learn new things
If you are not in your main class you use dependency injection to pass a reference to your main class.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Mine reset lite dose not work for me can someone help
If im not wrong you tell me use DI on main class right?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
how does that work with maven?
#help-server If this a config issue and not coding
maven has nothing to do with it
I dont want to sound rude but have learnt java before doing plugins?
If you didnt most of the time its not recommend to start first doing plugins without learning java atleast the basics things
Sorry if i sound rude but that the truth
weell i have, but i havent heard about dependency injection
And i still dont get how to use that to fill the plugin section
everything in Java is Objects. There is only ever one copy (instance) of your main class. You need to pass that reference around to any other objects which need to access it
read teh wiki about it. its very easy once you read it
oops
Almost every time i come looking here i see very basic java questions being answered. Classics like "How can i access variable x from class foo"
Is there any efficent (i.e. preferably without sorting based on random values) way of iterating over a list in a random fashion?
can someone tell me if this will work? my aim is to find all the classes in a package and initialise them.
the method: https://pastes.dev/VtDoR3lKAK
the ClassEnumerator (taken from github and not mine): https://github.com/ddopson/java-class-enumerator/blob/master/src/main/java/pro/ddopson/ClassEnumerator.java
Simple code to dynamically discover Java classes. See http://stackoverflow.com/questions/176527/how-can-i-enumerate-all-classes-in-a-package-and-add-them-to-a-list/3527428#3527428 - java-class-en...
syntaxed in javascript woops
How efficient does it have to be? You could generate a List<Integer> with the indices and shuffle it if you dont want to shuffle the original list.
Also: Why does it have to be random? What are you doing=
This is a good library for simple classpath scanning:
https://github.com/ronmamo/reflections
Reflections reflections = new Reflections("com.my.project");
Set<Class<?>> subTypes = reflections.get(SubTypes.of(SomeType.class).asClass());
Set<Class<?>> annotated = reflections.get(SubTypes.of(TypesAnnotated.with(SomeAnnotation.class)).asClass());
Is this the code (example from wiki)
`
public class PlayerStatsPlugin extends JavaPlugin {
@Override
public void onEnable() {
this.getServer().getPluginManager().registerEvents(new PlayerListener(this),this);
}
}
public class PlayerListener implements Listener {
private final PlayerStatsPlugin plugin;
public PlayerListener(PlayerStatsPlugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
event.getPlayer().sendMessage("This server uses %s :)".formatted(plugin.getName()));
}
}
`
ill check it out !
Basically I want to do something like
while (true) {
Predicate predicate = predicates.get(random.nextInt(predicates.size()));
if (predicate.test(testObject)) {
// Do something with the predicate
}
}
but have a stop-condition at some point so just in case that none of the predicates match I will be able to return a default value or something
But I guess I'll use Collections#shuffle on second thought given that I do not actually need to preserve the order of the list thankfully
The PlayerListener then uses that Plugin reference to access the Plugins name
For sending short code use this
Do you just intend to run through a random predicate and return a value if it's true
Collection<Predicate<?>> predicates = ...;
Collections.shuffle(preficates);
for(Predicate<?> predicate : predicates)
if(predicate.test(someObject)) {
...
return ...;
}
return defaultValue;
I might be tripping with the generic type part
That is what I will do
Though it does not make much sense to shuffle the entire collection if the first random value matches, aah.
I think I'll just look at Collections#shuffle and see if I can cheat a bit there
you can call Collections#removeIf
before shuffling
unless that predicate does more than just checking
predicates.removeIf(predicate -> !predicate.test(someObject));
https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/master/src/java.base/share/classes/java/util/Collections.java#L459-L460 myeah, I think I need to shuffle the entire list. Doesn't look too bad anyways as long as my random impl is fast enough
what saerver
We are currently stuck in our project and have a private server
removeIf is basically an iterator
who is we
Oh I see
5 students
Eh, I'm over-complicating things anyways
oh
Hey, how can I send a message with translateAlternateColorcodes that is also bold?
Random rand = new Random();
List<String> colorCodes = Arrays.asList("&1", "&2", "&6", "&9", "&a", "&c", "&d", "&e");
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
if(e.getMessage().equalsIgnoreCase("GG")) {
if(BLGGWave.getPlugin().isActiveWave()) {
// cancel the event
e.setCancelled(true);
// send message with random colors
e.getPlayer().sendMessage((ChatColor.translateAlternateColorCodes('&', randomColorCode() + "G" + randomColorCode() + "G")));
}
}
}
private String randomColorCode() {
return colorCodes.get(rand.nextInt(colorCodes.size()));
}
i would be soo pleased
what is that code
what's the problem?
oh random color code ok
misread lol
i thought u were using an arraylist for color coding idk
@quiet ice
Just thought about something. Try this:
public static <T> void iterateRandomly(List<T> list, Consumer<T> consumer) {
ThreadLocalRandom.current().ints(list.size(), 0, list.size()).mapToObj(list::get).forEach(consumer);
}
Hm... does this produce duplicates? I think it does :/
Probably does
fixed it by adding ChatColor.BOLD to each letter instead of the entire message.
how can i save an itemstack in a mongodb collection?
You need to order the color and boldness in a specific way otherwise it breaks, but no idea if this issue applied to you
- Serialize it
- Save it
yes, what primitive should i use?
For serialisation you'd need to use BukkitObjectOutputStream or if you use paper use it's serialisation methods which are a bit saner given that they come from DFU
Dont worry.
Just do something like:
private static final Gson GSON = ...;
public Document toDocument(ItemStack item) {
Map<String, Object> data = item.serialize();
String json = GSON.toJson(data);
return Document.parse(json);
}
This is really rudimentary but you get the general idea.
I personally like implementing a Gson backed Codec for MongoDB so i can literally
throw anything in it and treat MongoDB as a Map<K, V>
oh yeah that might be a bit better
thank you!
*PS
private static final Gson GSON = ...;
public ItemStack fromDocument(Document document) {
String json = document.toJson();
Map<String, Object> data = GSON.fromJson(json, new TypeToken<Map<String, Object>>{}.getType());
return ItemStack.deserialize(data);
}
doesn't toJson take some arguments?
probably should take in the map
Nope.
Bson can easily be translated to a json String
huh, then how can GSON know what to serialise?
Oh you mean GSON.toJson(). Yes that needs an argument. I thought you were talking about document.toJson().
😅
the 'data' has to be given
You can pass the ItemStack if you registered a JsonSerializer<ItemStack> in your Gson instance. Then the method would look like this:
public <T> Document toDocument(T element) {
return Document.parse(GSON.toJson(element));
}
Which is quite handy because Gson can (de)serialize a ton of things on default.
Just not ItemStacks, Locations and other game bound objects.
?
wdym jsonserializer?
You can register custom TypeAdapters in Gson.
Im thinking about writing a resource thread about the Gson, MongoDB stack...
might be useful
BungeeCord
How can I check if Server's contain My plugin?
?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/
send a plugin message and check if the server responds
Custom message via the plugin messaging channel or opening a socket on both proxy and server
im currently sending msg but it takes some time till it reaches back
How can I call Player#chat() from AsyncPlayerChatEvent? I'm getting an AsyncPlayerChatEvent may only be triggered synchronously. error.
Still the wrong place to ask: #help-server is the correct one then
Why serialization? If mongo contains:
Document doc = new Document();
doc.put("item", ItemStack);
ItemStack item = doc.get("item", ItemStack.clas);```
huh
funny
really?
and that would work?
Just ignore him
So why do you think that people here in #help-development would answer your question
Im not trolling lmao, in my case is working
😐
hm?
?stash this error message makes 0 sense, let's see why that may be
@lost matrix explain why please.... You are always doing people feel small
Thats a gamble. If your Codec can handle that then i would be very surprised because ItemStacks contain some game linked objects.
Im just still annoyed from the hour long discussion we hade some months ago where you wanted to lecture me on a bunch of stuff that made no sense...
What Codec are you using for your mongodb driver?
I want to check out if it can actually handle ItemStacks
also imagine if that ItemStack instance is a direct CraftItemStack instance
I can see a ton of problems with skulls. As soon as you hit like 10 recursion levels into the PlayerProfile and the codec starts choking on some internals like a WeakReference<World> or something XD
why doesn't spigot adopt adventure api by default
they're way better than bungeecord's basecomponents
Spigot is a bit too old at this point
"unnecessary change" afaik
Someone has to maintain that.
You are free to write a PR
But be prepared for a bazillion upstream problems
but yeah also, all things considered, adventure adds a ton of complexity also, somehow a oneliner devolved into a 25 liner
Myeh, a collision with paper's adventure integration would be fun
You wouldnt believe what i had to do for a little chat replacement...
lol
But adventure uses proper chat formatting which mojang has introduced back in 1.8 days
not saying that the complexity is bad necessarily, but it definitely has cons
yup dovidas
I personally use things such as MineDown if I just want formatting
Of course you guys probably want to use MiniMessage instead
They all support spigot in one way or another
Hi, i've added a new file to my github repository, made a release and got it on jitpack but i can't seem to find this new class when i use the dependency
Did you update the version?
Also make sure jitpack properly compiled. Sometimes it takes a while.
that is why you selfhost repositories, much easier to understand where the issue is. I believe however that you might need to add a bit more info there to be able to narrow down your issue
first: release | second: the class i've added | third: the pom i use | fourth: the class doesn't show up
Did you refresh your IDE?
yeah
You may need to invalidate caches and all the fun
Oh yeah. Self hosting is much less painful because setting up reverse proxies and making sure your ssl certificates are updated and constantly updating nexus, jenkins etc is really
relaxed devops work that doesnt shorten your lifetime by raw anger.
Meanwhile, me: FTP all the way
screenshot from JitPack
Then -> invalidate caches and restart in Intellij
still nothing
I.e. for me installing stuff to a maven repo is just as simple as adding
<distributionManagement>
<repository>
<id>geolykt-maven-ftp</id>
<!-- This is the developer connection. The actual repository
is located under https://geolykt.de/maven/ -->
<url>ftp://geolykt.de/geolykt.de/public_html/maven/</url>
</repository>
</distributionManagement>
<build>
<extensions>
<!-- Enabling the use of FTP for deployment -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>3.5.1</version>
</extension>
</extensions>
to the pom as well as doing the one-time initialisation for the ftp connection (where you set up the usernames and passwords to use) and then you just can do mvn deploy. Gradle on the other hand is a bit trickier
Sure, you won't find any fancy index files, but noone will use your repo seriously anyways
Does EssentialsX come with configurable permissions or do i have to get another plugin for it?
I need to make groups to give people certain perms
LuckPerms is probably what you want then
and how will that interact with essentials? is there something i have to do to get it to recognize the essentials commands i want to give people permission to use?
well every essentials command has a permission
so just add that permission to the luckperms group
okay thanks
the deserializer?
this looks much easier than the way i had to do it 8 years ago
I would create my gson instance by using the builder:
Gson GSON = new GsonBuilder().disableHtmlEscaping().create();
But other than that the serializer looks fine
yes but i will do that later
ah
Should I rather commit and push my code to github alot like after every few things I made or like once per week?
what does this part do?
I personally do once per added feature
And I usually push with every commit
Every so often. I usually do 2-3 pushes with ~10 commits each day.
You forgot the {}
(){}.getType()?
true
Map<String, Object> data = gson.fromJson(json, new TypeToken<Map<String, Object>>(){}.getType());
why the {} tho?
Ah right, that was anonymous
it WORKS! TY!!!
Im burning my brains trying to think what code goes first on the event BlockPlaceEvent, because i need to:
- Check if a claim already exists on that location and run custom event
- Create a new claim, if a claim doesnt exists and he is placing a specific block
So im really dumb
I dont know why its so diff for me
its the gson typetoken class no? lol now it shows up
so with this method i can actually serialize everything that implements serializable right?
Think about priorities.
So number one should be protection.
If a claim exists -> prevent placement and return
Yes everything that implements ConfigurationSerializable
or anything that is a map<String, Object>
Allright and then do the rest right?
Gson can also serialize your data classes like
public class PlayerData {
private final Set<UUID> friends = new HashSet<>();
private double currency = 250.0;
private long playTimeMillis = Duration.ofHours(30).toMillis();
// and so on
}
With ease. No need to implement ConfigurationSerializable.
this is fantastic
is that supposed to be friends? >-<
Yeah just typed it really quick XD
it was cool firends! leave it like that
Can only think of reflections.
?jd-s
it is an enum isnt it? just loop over the values() then
Yeah, reflections will probably be the only way
lmao ninjad again
uh
Color is a normal class
oh i see, lets do it manually then
Technically there are near-infinite colors
because you can get it from rgb
Just to show how easy it would be:
public static Document toDocument(PlayerData data) {
return Document.parse(GSON.toJson(data));
}
public static PlayerData fromDocument(Document document) {
return GSON.fromJson(document.toJson(), PlayerData.class);
}
And the data class has to contain only objects that are serializable by Gson.
You can expand that list by registering TypeAdapters. This way your data can also
hold ItemStacks, Inventories and Locations...
nice
google says 16777216
i've done in the calculator 255^3
Why ^3
but google says more
because there is red green and blue
0 included so 256^3
true, now its correct
0xFFFFFF
Or Red Green Blue:
[FF, FF, FF]
(0 -> 0xFF) = (0 -> 255)
So 3 slots with 256 possible entries resulting in 256^3 total possibilities
i prefer working with low exponents
I prefer working with powers of a level exceeding at least 9000
I just set up Luckperms but the prefixes aren't showing up, the only other plugin that I have is essentialsx. How do I fix this
Programmatically?
are you in harvard?
If not then ask the plugin dev
I am doing a bit too much bit manipulation apparently
you might need to use vault
That was an "its over 9000" joke...
but idk
🙄
so just install vault and it should work?
At least that is the idea
ok i'll try that
Hey Guys. I set string for Player msg and When event finished I wanna reset this string. How Can I Do That
When I try to do a second operation it gets the previous string
I Have String for "Boss Name". Players can create a boss whatever name he want. But When Players Try to create boss for second time. It setting boss name to previous boss name
How Can I reset previous Boss Name String
here
how could i check if player clikc at blokc?
PlayerInteractEvent
wasn't getByCombinedId the legacy shit for block data bytes
Is there an API or something for making skulls I've never touched making player skulls before so I'm clueless
What can I use instead?
SkullMeta
Yeah is there a way to get the default nms BlockState from a material?
Why do you want to do that?
yea I'm doing research on how to make it not dependent on a player I found some resources on the website so i'm chillin
I'm making a plugin that, whenever someone says "GG" in chat, replaces it with randomly color coded "GG"
There you go
Edit their message
this is my code
How?
&l
The event works, but Player#chat doesn't
sorry, the caption for that code was for another question I had
My problem atm is that I can't use Player#chat() in the async event
and I'm unsure how to fix it
Oh, I did not know that method was a thing. Going to try it
That won't fix your issue though
That'll just replace the chat message that is sent with the event?
yes, the issue with sending bold messages was resolved already; sorry for the confusion
Nah they want it to work with the Player#chat() method
You use teh Scheduler to use teh Player#chat from teh Async event
not necessarily, I just want to make peoples' chat fancy colors
Huh
then you should not be using Player#chat
yeah, I'm using setMessage() now
That doesn't send a chat message though
setMessage and setFormat
you already have all teh chat in the event, you just format it
what's the difference between message and format?
I'm running into another weird issue. For some reason, the size of my result set is 0. The data is there, the string I'm checking for is the same as the column name, so wtf?
Sets the format to use to display this chat message.
Sets the message that the player will send
What's the difference?
bump
i'm summoning an invisible armorstand, is there a way i can make the armorstand not be visible for a really short period before turning invisible
use the spawn method with the Consumer. set it to be invisible and schedule a BukkitRunnable to make it visible later
wait what do you mean in your original reply
make it visible later?
i just want to spawn armorstand invisible so it's never visible ever
In the consumer you get to run code on the Entity before it's actually created. so you can set it invisible etc
coolio
else it will spawn visible for a fraction of a second
While still in teh consumer you create a BukkitRunnable to set it visible at a later time
i don't want it visible ever
then no need for teh runnable
poog
just set it invisible in the consumer and it will forever be invisible
just a naming convention.
with z
yes, you can;t use teh name class
so we use clazz
i thoughti it was a typo
clazz would be ArmorStand.class
this is like a dumb question but how do i use that syntax
i've used generics before in uni stuff
that bit
the consumer part?
what
spawn( location, ArmorStand.class, false, stand -> { stand.setVisible(false); } )
i tried that too
spawn() is just red underlined
like there's no method spawn
do i have to make my class implement regionaccesor
yes, its just a different method
hooray
can someone tell me how i can import import org.bukkit.craftbukkit.inventory.CraftItemStack;
what is the valid import for craftitemstack
I need it for NMS
I have a problem. I wrote a code so that i can send and receive plugin messages. The sending process works great but he cannot receive data somehow. Can someone tell me why? Pastebin: https://pastebin.com/k7PNq9jG
NMS imports all changed for 1.17+
Servers listening to PMC need to have a player oin them to receive messages
I am online
where are you sending the message?
in a spigot server
where i am online in
Can one Plugin send and receive the same time?
where is the message coming from?
From the same plugin
but i know my problem maybe
You cannot send a message from your own plugin on the same server to your own plugin back, right?
._.
U can't use custom channels from spigot to spigot
U have to use the Forward
On bungeecord channel
What do you mean?
I also don't understand what they tried to say lol
That why i prefer redis PubSub over PMC
hello Verano, I'm mfnalex
this basically explains everything needed
Redis is a memory database, which contains a feature called PubSub its a system which allow to send and receive mesages between many devices
One of the most amazing of redis pubsub, is that you dont depend on a player for sending or receiving data
thats a point
and one of the most annoying is, that you have to install it
well
like something else?
apt install redis and that's it
I have redis anyways because of pterodactyl
hello mfnalex, i am god, godcipher.
If you cannot afford a vps or host, you can use their free redis db
henlo :3
hello mfnalex, i am god, Alexito
Alexito?!
yeah but not really user-friendly
tf is a alexito? you are verano
hm tbh you just install it and then it works
it isn't even password protected by default IIRC
Amazing as owner it doesnt allow me to place blocs fucking amazing
Atleast it work
more than 3 months with this
hahahaha
public void onDeath(PlayerDeathEvent event) {
final var deceased = event.getEntity();
Optional.ofNullable(deceased.getKiller()).ifPresent(killer -> {
if(deceased.equals(killer)) {
return;
}
killer.sendMessage("§b> §fYou killed §b%s §f and he dropped a §bdisaster shard§f.".formatted(killer.getDisplayName()));
killer.playSound(deceased.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.2F, 1F);
deceased.getWorld().dropItemNaturally(deceased.getLocation(), CustomItemManager.createDisasterShard());
});
}```
Anyone help me with this
https://github.com/booksaw/BetterTeams/wiki/API
I want to make it so that the custom item won't drop if you were killed by your party but not your allys
can i make a small region of the world indestructible
like a 1x2x1 part
i have an entity with some blocks inside it to give the entity collision
but you can break the blocks then walk through it
i'd like to make the blocks indestructible
is that possible ·_ .
if there's another way of achieving collision i would do that : ) as long as it's easy
How would I check what inventory a player is in?
for what? gui?
Yes
Inventory#getType()
Well I have insalled redis and its working properly in my IDE. But in my minecraft server it says this
you have to shade the redis dependency
shade it
?paste your pom.xml pls
where i find the shade
i dont have one i use the artefacts from IntelliJ
oh well then that's the problem
but whats with shaded?
you know, the spigot server itself has no idea about how to use redis. that's why you need to "shade" the redis dependency
shading basically means that your .jar includes the classes needed to talk to redis
okay...
but I have no idea whether intelliJ artifacts support it. in 99% of cases you should simply use maven to handle all this stuff
i have an iml file. Maybe i can use that?
you should switch to maven
check out the link I sent above, then create a new intelliJ project
ok
you can then copy/paste your current code into your new maven project
how can i give an armorstand collision like it's a block
barrier 😂
Probably? What do they tell you?
click on the maven reload button
is it in another repo
xd
I need a meme for everytime someone comments on alex's use of light mode everything
lel
Is there any way I can send data when a player goes to anothe rserver in bungeecord?
message channels
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Depends on what's being sent
yeah I'm tired of this too lmao
I mean, I get it, people don't like light mode
damn I love maven
but there's really no need to send a gif everytime I sent a screenshot when I'm just trying to help someone lol
it's funny for the first 20 times but after that it just gets boring
although I understand that it became a running gag here lol
you didn't shade it
well
do you have the shade plugin
you have to add the maven-shade-plugin to your <build> section
one minute pls
check out the second part
the one that says "how to shade dependencies"
but i need to make sure the player is on the other server
what data are you sending?
use something like redis to hold the data
resource pack status
essentially i need to tell the other servers that player received the resource pack and does not need to be redownloaded when they switch servers
you could just use plugin messaging for this
i might be wrong but if the resourcepack has the same checksum it wont prompt them
that's correct
it doesnt prompt them, it takes it off then puts it back on again
ill check if its checksum or something
I shaded it right?
does ItemStack play nicely with GSON, and if not is there a way to make it friendly?
that looks good to me
but yeah unless you want to do annoying player checking just broadcast it and hope they are on the srver
error is stil there
show full pom
wait
how did you compile your plugin?
i use pastebin
you HAVE to use maven to compile it!
yea
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
easiest solution would be to upload the whole plugin to github or something, then tell us the link
just upload it and send link lol
it's 10 pixels wide
Am I unable to serialize Inventory inside of classes? https://paste.md-5.net/ivotivawim.md
are you sure you are using the shaded jar
did you create a class that extends "Inventory"?
No, should I?
what are you serializing an inv for anyway
by saving the inventory gui and loading it each time.
what InventoryType do you use for your custom inv?
Not sure, you can try ig
thats the biggest nonanswer ive ever seen
lmao
private Inventory poorINV = Bukkit.createInventory(null, 9, "small"); A regular one
I have code for that on my github
Look
ItemStack implements ConfigurationSerializable
that means that there's an serialize() method that returns a Map<String,Object>
idk how you can turn that into a json object though
yea
spigot includes methods for YAML so you can easily save an ItemStack inside a YAML file
for json, idk how to do it though
json can serailize maps right?
i need it to be json, i think ill just use a typeadapter