#help-development
1 messages · Page 973 of 1
We cannot help without the full stacktrace; Please paste it here: https://paste.md-5.net
^
looks like a connection issue
Hello @Prasanna_Bale, welcome to the MongoDB community forums. Based on the error message you provided, it appears that you might be encountering a similar issue to the one described in JAVA-2609: mongo throws IllegalStateException: state should be: open. The error could be caused by another process or thread closing the connection with your Mo...
?google first 🙏
Google your question before asking it:
https://www.google.com/
did that
even if i create a new connection
it dosent make a difference
now im getting this
you shouldn't make a new connection on each access
I will put my plugin.yml like this
name: {$PluginName}
main: {$PackageName}.{$MainClass}
version: {$VersionNumber}
mongoDB = MongoClients.create(uri);
yeah
that how i create my connection
that's the issue
wrong or correct?
you should just have one private static connection that gets initialised at your onEnable and return that
well you just told me differently
i said for testing i created a new instance
and it didnt make a difference
so i came here
Iyi, but it comes already written if u use IntelliJ
private static MongoClient client;
public static MongoClient getMongoDb() {
return client;
}
@Override
public void onEnable() {
client = MongoClients.create(uri);
}
I use eclipse
only if you use the mc dev plugin
i just use a @getter
I suggest u to use IntelliJ
my laptop very bad
It doesn’t need a powerful laptop
well the exact same thing works fine for me
that's how I do it in all my apps
brb
lol
runs fine on a thinkpad T400 for me
I was used jetbraing pycharm its very lagging
IJ with the MC dev plugin kills full powered PC's
he also only has 6gb of ram
Well I’m using a laptop from 2015 MacBook and it works fine
IJ is memory hungry
i have 8, uses 4-5
It sounds like a storage skill issue
storage skill issue?
oh i thought that was just a helper class
main.getMongoDB().getDatabase("testDb").getCollection("_testcollection").insertOne(document);
this an okay way of doing it?
main 😓
and should i have 1 document per player or all players in 1 document
@drowsy helm whats wrong with main
where I can find the plugin
target folder in your project
thanks dude
but I am not sure if my laptop will open tlauncher xd
How would I make this entity follow a player
Add a follower goal
what I need to put in the plugin yml
could i make the entity save a player that it will follow but not attack
If you want
@eternal oxide
how do I convert a server wise plugin to a bungeecord plugin
First of ask yourself if it's a good idea
What plugin is it
/stafflist plugin, need it to be in bungee so it shows every staff member online
Then just rewrite it using the Bungeecord api
thats the problem, I dont do bungeecord
theres no goal with a player or even entity in it
that contains follow
There is
idk how
How do you think pets work
bro I will leave coding plugin because my laptop cant open minecraft and eclipse same time my laptop is very bad so I will next with html css javascript and python
FollowOwnerGoal
There you go use that
and you cant use a zombie with it because a zombie isnt a tamableentity
You can use the logic from it
so making a custom goal?
yes
is there no other way to do it
There probably is
Heyo, how do I get a block with the full data, for example chest with its content or sign with text.
I want to store a block in memory and then later place it somewhere.
Full context: creating undo for my own "world edit" thing.
I was told to store the BlockState, but I don't see a way of placing it.
this will not modify the state of a block if it is no longer the same type as it was when this state was taken. It will return false in this eventuality.
So I first have to place the block data, then do update ?
Is there an event to check when a player attempts to use a spawn egg on a monster spawner?
PlayerInteractEvent
Interact wvent
ahhh is ee
is even eee
How would you get a net.minecraft.world.entity.player.Player target block
theres no function in ti
What do you need this for?
org.bukkit.entity.Player provides a method for raytracing and getting a targeted block.
hello, I read the documentation and I found to change the durability in 1.20 I need to write
ItemMeta meta = event.getItem().getItemMeta()
((Damageable) meta).damage = damage
event.getItem().setItemMeta(meta)
but if I set damage to 0 to remove all damage i keep the durability - 1 on my item, I do somethings wrong ? (i do this piece of code in a PlayerItemDamageEvent event handler)
Was making a custom goal
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/LivingEntity.html#rayTraceBlocks(double)
nmsEntity.getBukkitEntity()...
declaration: package: org.bukkit.entity, interface: LivingEntity
maybe because NMS is fancy
'
In which event are you doing this? Events are generally fired before something happens, meaning the durability might be removed
right after you are repairing the item.
I listen PlayerItemDamageEvent
@EventHandler
fun onItemDurabilityDown(event: PlayerItemDamageEvent)
(it's in kotlin)
That event has a method setDamage set that to 0
is there a better way than adding every mob manually
PS: You should structure your code a bit more to reduce all those getter calls
ItemStack item = event.getItem();
ItemMeta meta = item.getItemMeta();
Damageable damageable = (Damageable) meta;
damageable.setDamage(0);
item.setItemMeta(meta);
// Now you need to prevent the item from being damaged after you repaired it:
event.setDamage(0);
// or
event.setCancelled(true);
or use editMeta instead.
yeah it's setDamage I just wrote shit x)
Sure, if you use Paper then you could use editMeta
Oh, expected to be in Spigot. my bad.
ok it work now thx
Write your own target goal i guess
couldn't you use like... Monster.class?
I'm not sure though
Should be possible under the condition that all monster should be added.
this.target = this.mob.level().getNearestEntity(StreamSupport.stream(this.mob.level().getEntities().getAll().spliterator(), false).filter(entity -> entity instanceof LivingEntity && entity != this.mob && entity != this.p && entity.isAlive() && !entity.isSpectator()).map(entity -> (LivingEntity) entity).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
how scuffed is this
cringe
what in the god is that
reason youre using a spliterator?
turning it into a stream
turning a collection into a stream?
There must be at least a new line, it's too long and hard to see.
iterable into a stream
who even returns an Iterable \💀
How do i turn org.bukkit.entity.Player into net.minecraft.world.entity.player.Player
mob#level#getEntities#getAll
mojang moment
((CraftPlayer)player).getHandle()
cast it?
was just askign cuz i usually try not to cast
should be an Entity implicitly, atleast if Zombie is
havent used nms for years but isnt there a getBukkitEntity() or is that craftbukkit
yeah
there is
ty
Caused by: java.lang.ClassNotFoundException: net.minecraft.world.entity.player.Player
oh lord
remapping moment
of course it doesnt work
You forgot to remap
yeah no i fixed that
the pathfinding doesnt owrk
it should follow me and target mobs
instead it just stands there
why is that?
you can use addUnsafeEnchantment or something
now it crashes the server :goog:
this doesnt wanna work
hell nothing wants to work
im so confused
public class FollowPlayerGoal extends Goal {
public Player target;
public Mob mob;
private int timeToRecalcPath;
private float oldWaterCost;
private final PathNavigation navigation;
public FollowPlayerGoal(Player target, Mob mob) {
this.target = target;
this.mob = mob;
this.navigation = mob.getNavigation();
}
public void start() {
this.timeToRecalcPath = 0;
this.oldWaterCost = this.mob.getPathfindingMalus(BlockPathTypes.WATER);
this.mob.setPathfindingMalus(BlockPathTypes.WATER, 0.0F);
}
public void stop() {
this.navigation.stop();
this.mob.setPathfindingMalus(BlockPathTypes.WATER, this.oldWaterCost);
}
public void tick() {
if (--this.timeToRecalcPath <= 0) {
this.timeToRecalcPath = this.adjustedTickDelay(10);
double var0 = this.mob.getX() - this.target.getX();
double var2 = this.mob.getY() - this.target.getY();
double var4 = this.mob.getZ() - this.target.getZ();
double var6 = var0 * var0 + var2 * var2 + var4 * var4;
if (!(var6 <= (double)2)) {
this.navigation.moveTo(this.target, 1f);
} else {
this.navigation.stop();
}
}
}
@Override
public boolean canUse() {
return true;
}
}
The target is null
by the time it gets to tick()
i have no clue why
I added a null check to tick() now it jsut doesnt move
Then you're passing null to the constructor because it's assigned nowhere else
How do i add a NBT tag to a entity using spigot NMS 1.15.2
i checked and i don't pass null to the constructor but the entity constructor registers the goals before i set the value of p, do yk how i would fix that
so it registers before p is set, but i cant set p before either
I thought goals were initialized in a separate method now
if you go like 10 methods into the super() it registers goals
Are you on the latest version?
Suppose your only option is to instead pass it lazily. Store it in the entity itself, then in your goal, pull it from the entity
alright
You can pass the entity itself into your pathfinder's constructor
yeah i already do that
Then yeah, just be sure you're still doing a null check somewhere
Likely in the canUse() method
How do i add a NBT tag to a entity using spigot NMS 1.15.2
You should have access to the PersistentDataContainer of an entity
Entity#getPersistentDataContainer()
i have access
alright that works ty
to it
like i have access to the entity.getBukkitEntity.getPersistentDataContainer
then you can just use PersistentDataContainer#set
Wait, you're using NMS? 
Then you can override the read/write methods for NBT instead
Don't remember what they're called. It's like "save()" and "read()" or something
yea intellij shows save and read
but could those be used to set the texture of the entity?
yea using a texture pack
Don't think you can render a specific texture based on NBT though (exception to ones the client actually understands, like cat or villager variants for example)
neither of them actually make it target a player
wait
it doesnt actualyl attack
it looks at them but doesnt target
What are you trying to do? I just tuned in
So i was making a custom zombie that follows a player but should only attack everyone but that player
public class MiniWarde extends Zombie {
public final Player p;
public MiniWarde(Location loc, Player p) {
super(EntityType.ZOMBIE, ((CraftWorld) loc.getWorld()).getHandle());
this.setPos(loc.getX(), loc.getY(), loc.getZ());
this.setCanPickUpLoot(false);
this.setAggressive(true);
this.setCustomNameVisible(true);
this.p = p;
}
@Override
public void registerGoals() {
this.goalSelector.addGoal(1, new FollowPlayerGoal(this));
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 2.0F, true));
this.targetSelector.addGoal(0, new TargetMob<>(this, true, false));
this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
}
@Override
public void addBehaviourGoals() {
this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false));
this.goalSelector.addGoal(6, new MoveThroughVillageGoal(this, 1.0, true, 4, this::canBreakDoors));
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0));
this.targetSelector.addGoal(1, (new HurtByTargetGoal(this)).setAlertOthers(ZombifiedPiglin.class));
}
@Override
public boolean isSunSensitive() {
return false;
}
}```
i got the moving thing to work
Ah
but it doesnt target
public class TargetMob<T extends LivingEntity> extends TargetGoal {
protected final int randomInterval;
@Nullable
protected LivingEntity target;
protected TargetingConditions targetConditions;
public TargetMob(Mob entity, boolean flag, boolean flag1) {
super(entity, flag, flag1);
this.randomInterval = reducedTickDelay(10);
this.setFlags(EnumSet.of(Flag.TARGET));
this.targetConditions = TargetingConditions.forCombat().range(this.getFollowDistance());
}
public boolean canUse() {
if (this.randomInterval > 0 && this.mob.getRandom().nextInt(this.randomInterval) != 0) {
return false;
} else {
this.findTarget();
return this.target != null;
}
}
protected void findTarget() {
this.target = this.mob.level().getNearestEntity(StreamSupport.stream(this.mob.level().getEntities().getAll().spliterator(), false).filter(entity -> entity instanceof LivingEntity && entity != this.mob && entity != ((MiniWarde)this.mob).p && entity.isAlive() && !entity.isSpectator()).map(entity -> (LivingEntity) entity).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
}
public void start() {
findTarget();
this.mob.setTarget(this.target, this.target instanceof ServerPlayer ? TargetReason.CLOSEST_PLAYER : TargetReason.CLOSEST_ENTITY, true);
super.start();
}
}
That's outside the scope of my knowledge 🤐
Thought you were doing something a bit different haha
I remember when I was making a chicken attack a player and my server crashed because of some attribute shit and I had to figure it out
Thought you were doing smth similar
That's NMS for you
Make a PR. :p
i cant make an api ftho
Hi guys I'm trying to set a body to this post request but I get a 400 status code (Bad Request). I don't know what I'm doing wrong.
public class PlayersService {
public static void createPlayerEntry(UUID uuid) {
try {
Map<String, String> body = new HashMap<>();
body.put("uuid", uuid.toString());
body.put("first_joined", new Date().toString());
URL request = new URL(ApiEndpoints.PLAYERS.getUrl());
HttpURLConnection client = (HttpURLConnection) request.openConnection();
client.setRequestMethod("POST");
client.setDoOutput(true);
client.setRequestProperty("Content-Type", "application/json");
client.getOutputStream().write(body.toString().getBytes());
client.getOutputStream().flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
if its telling ou a 400 then that means its your body code wrong probably
go check what the api requirement is
of the body format
Easier said than done
I made the api and it should be nice as the body params are going
idk
let me sout the info
You'll need to send that body as json
how can I do that then?
gson or jackson are two good json libraries
but yeah how could you make a custom entity target all mobs
Like this?
that might work but you shouldnt do that
Idk, I was asking copilot
I had that deam
then the body is just gson.toString()
with .getBytes() yeah?
no?
JsonObject object = new JsonObject();
object.put("uuid", uuid.toString());
object.put("first_joined", new Date().toString());
String body = object.toString();
but to .write() need a bytes type
huh
let me try 1 sec
ok then jsut try that
Is there something like SignedVelocity for BungeeCord?
how do i loop thru all people with a certant permission?
loop through players check if they have permission x and then do what you need
fak
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: http://localhost:3000/players
xdd
yeah i know but nvm i already got
?paste
to what end?
Reading Null Values Failing?
Basically my GUI is also storing alot of information in the items themselves. And for some reason when Hashing it into a hashmap some null values get turning into the name of one of the sections (null to "upgrade_1") which is confusing.
Getting the section of the item works fine.
itemToDisplay function (Where the logs come from) https://paste.md-5.net/iguravivux.cs
Item Hashing function https://paste.md-5.net/domusizoce.js
[00:44:21 INFO]: {locked_upgrade=null, costs=[minecraft:gold_ingot;12, minecraft:diamond;13, itemsadder:aurorium_pack:aurorium_shard;10, -1;5], item=minecraft:diamond, lore=[Costs 12 Gold Ingot, 13 Diamond, 10 Aurorium Shard, 5 Dollars, Yep], upgrade=Heart2, locked_item=locked_item_example, permission=phytor.advancedboats.upgrade.upgrade_1, slot=4, title=Avoid, error=MemorySection[path='boat_gui.upgrades.upgrade_1.error', root='YamlConfiguration'], bought_item=empty_item, success=MemorySection[path='boat_gui.upgrades.upgrade_1.success', root='YamlConfiguration'], next_upgrade=upgrade_3, modeldata=1, previous_upgrade=null}
[00:44:21 INFO]: Success of item MemorySection[path='boat_gui.upgrades.upgrade_1', root='YamlConfiguration']
[00:44:21 INFO]: {locked_upgrade=[upgrade_1], costs=[minecraft:gold_ingot;12], item=minecraft:gold_ingot, lore=[Costs 12 Gold Ingot, 13 Diamond, 10 Aurorium Shard, 5 Dollars, Yep], upgrade=Heart1, locked_item=null, permission=null, slot=5, title=Cool, error=MemorySection[path='boat_gui.upgrades.upgrade_2.error', root='YamlConfiguration'], bought_item=empty_item, success=MemorySection[path='boat_gui.upgrades.upgrade_2.success', root='YamlConfiguration'], next_upgrade=null, modeldata=1, previous_upgrade=upgrade_1
broski wrote half of the bible
i mean i want help so 🤷♂️
Okay i found the issue, I need to pass the date as a valid ISO 8601 date string
You are tinkering too much with default data structures and already existing classes.
For your next project you should try to write more concrete classes with proper fields instead of throwing your stuff into loose maps.
This currently looks like something from a scripting language instead of Java.
You are going to jail with this one 🗣️
Yea i realised but midway through the plugin the scope changed completely so i just want to get a working version then ill go back through and fix it all
(by remaking the entire project)
Eg.
HashMap<String, Object> itemHash = itemSecConstructor(section);
Should be something like
SlotItem slotItem = new SlotItem(section);
And SlotItem has fields like item,modeldata etc
?
why do you need to do that
oh i wanted to send a message to everyone with a certant perm but i already got it
Yeah i can see a few fallpits where this conversion could come from. Throwing type safety over board generally leads to confusing and hard to debug problems.
broadcastMessage my beloved
Sry im trying to read this code but i really dont feel like checking for mundane errors like typos
*Which isnt a problem if your code would be type safe on compile time
?
there is a mthod in spigot to send a message to everyone with a specific permission
broadcast my beloved
This for example. If you have a typo in here, or simply used the wrong String to access a value, then you are getting random null values for no reason.
But if your Map was a proper class like SlotItem then
LockUpgrade upgrade = slotItem.getLockUpgrade();
Will never have those problems, because you cant have typos as your code would simply not compile then.
Could u quickly just show me a short example of a SlotItem class and what it would look like?
its 1am and my brain is fried
Alright, ill base this on your itemConstructor method
:) thank you
nvm, this method is for serialization it seems like.
Send me your itemSecConstructor(section) method
lmfao my code is so bad
its the exact same but instead of using
getSection(item)
it just parses the section
Wait... wtf is the purpose of this method?
You give it an ItemStack, and then it randomly grabbs a ConfigurationSection and merges
some values into a HashMap
upgrade_1:
item: minecraft:diamond
modeldata: 1
slot: 4
title: "Avoid"
lore:
- "Costs 12 Gold Ingot, 13 Diamond, 10 Aurorium Shard, 5 Dollars"
- "Yep"
costs:
- minecraft:gold_ingot;12
- minecraft:diamond;13
- itemsadder:aurorium_pack:aurorium_shard;10
- -1;5
error:
title: "Not Enough!"
subtitle: "Not Enough Subtitle"
chatmessage: "You don't have enough"
sound:
- sound{s=entity.allay.item_taken;v=0.5;p=0.5}
- sound{s=block.enchantment_table.use;v=0.5;p=0.3}
success:
title: "Upgrade 2"
subtitle: "Upgrade 2 subtitle"
chatmessage: "test"
sound:
- sound{s=entity.allay.item_taken;v=0.5;p=0.5}
- sound{s=block.enchantment_table.use;v=0.5;p=0.3}
- sound{s=block.beacon.deactivate;v=0.5;p=0.5}
permission: advancedboats.testperm
locked_item: locked_item_example
bought_item: empty_item
upgrade: Heart2
then its used to pass all the information through to my upgrading methods
Hm
its messy majority of it was done from 1-4 am
public class ConfigurableAnnouncement {
private final Title title;
private final String chatMessage;
private final List<Sound> sounds;
...
public void playTo(Player player) {
}
}
The itemConstuctor method is literally doing nothing. ConfigurationSection is a Map<String, Object> under the hood.
All you are doing is getting one map, and simply copying the values into another map.
Time for this sleepy boi to hit the hay?
nope because tmr i have to do school assessments
so i gotta get this done before like 9am tmr
(or else i will not do school)
So this method here:
private HashMap<String, Object> itemConstructor(ItemStack item) {
HashMap<String, Object> itemHash = new HashMap<>();
if (getSection(item) == null) {
return null;
}
ConfigurationSection conSec = getSection(item);
itemHash.put("item", conSec.getString("item"));
itemHash.put("modeldata", conSec.getString("modeldata"));
itemHash.put("next_upgrade", conSec.getString("next_upgrade"));
itemHash.put("slot", conSec.getInt("slot"));
itemHash.put("title", conSec.getString("title"));
itemHash.put("lore", conSec.getList("lore"));
itemHash.put("costs", conSec.getList("costs"));
itemHash.put("permission", conSec.getString("permission"));
itemHash.put("locked_item", conSec.getString("locked_item"));
itemHash.put("upgrade", conSec.getString("upgrade"));
itemHash.put("error", conSec.getConfigurationSection("error"));
itemHash.put("success", conSec.getConfigurationSection("success"));
itemHash.put("locked_upgrade", conSec.getList("locked_upgrade"));
itemHash.put("bought_item", conSec.getString("bought_item"));
itemHash.put("previous_upgrade", conSec.getString("previous_upgrade"));
return itemHash;
}
Could be shortened to just
private ConfigurationSection itemConstructor(ItemStack item) {
ConfigurationSection conSec = getSection(item);
return conSec;
}
Which would be a method of questionable usefulness
yea i realised
wow who coulda guessed replacing itemConstructor with my cleaner getSection method would've been better
Anyways im gonna go play some games with friends, bb
thanks lols
How do i actually register the custom entity
You don't want to register it to the registry
That will cause problems with the client
Just spawn it directly
You will have to handle the loading and unloading of the entity yourself
what do i have to do for that
also the reason i was talking about that was since this doenst work
i was tryna make it target all mbos as long they arent the same type with the same owner
but it never gets to that point
would htis have to use a database?
I want to check whatever a block is placed naturally or not, i am interest in only 2 types of block tho, what is the best solution? Using an hashmap or using meta data? I have seen a lot of conflict over this topic by googling it
A database wouldn't be ideal for this usecase
Does it need to persist restarts?
wouldnt it need ot handle restarts though
so what else would i be able to use
ohh cafebabe is back
This is an over engineered solution for my use case
Bu ty anyway
what would i a ctually do with that though
Then simply put them in a Map and store them in the Chunks PDC when it unloads and load them back into the Map from the PDC when the chunk loads again.
But be aware that some blocks can be moved by pistons or destroyed by mobs
Store where your entity is and spawn your entity when entities are loaded (and the opposite when unloaded...)
Chunks have a pdc?
yes
how do you keep it when the server is restarted
im presuming rn your saying like a hashmap?
a chunks pdc or osmething?
yes
yes
how do you filter which entities to save in the pdc and which to not save
Here are all classes with a PDC. I marked the most important ones (excluding ItemMeta bc everyone seems to know just this one)
Even some Blocks have PDCs
Basically if it can store NBT, it probably has a PDC
If it doesn't, then we missed it
how do you actually check if say a zombie is one of your custom zombies
is there something in their nbt?
If you put something in its NBT, then yes
so i presume you should put something in their nbt to filter them?
Hmm, I wonder if I could "simulate" ticking blocks? Like, have an actual entity with some pdc at the same coordinate as a block and make it act as a block entity or something
Just use packets
Holy that is a lot
this.target = this.mob.level().getNearestEntity(this.mob.level().getEntitiesOfClass(this.targetType, this.getTargetSearchArea(this.getFollowDistance()), (entityliving) -> true).stream().filter(entity -> !entity.getBukkitEntity().getPersistentDataContainer().getOrDefault(Overcharged.WARDEN, PersistentDataType.STRING, "").equals(this.mob.getBukkitEntity().getPersistentDataContainer().get(Overcharged.WARDEN, PersistentDataType.STRING))).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
i need to stop doing this
is there a method that eliminates all extra lines in the lore?
so this wouldnt do anything
line1
empty line
line2```
but this would
Line1
empty line
empty line <-- removes this
line2```
Well we decided to go with a seasons plugin
Bad choice
Nah it’s gonna be cool
But you wont make good money with it
That’s not my goal
back to htis iwas doing it
and i dont understand
what do i actually ssave
in the pdc
that i can use to respawn the same entity
Please at least tell me you go to the next line each operation like functional programming, but i can assure you 90% of java devs are just gonna refactor that
Also that is hell because there are no null safety checks
The data that you want to persist
is someone electrifying your chair every time you write a new line? This is somehow worse than the code I wrote to make fun of imillusion
How can I do a PATCH request, in Java 8 sais there is no PATCH method?
java.net.ProtocolException: Invalid HTTP method: PATCH
Move to newer java versions
But the plugins are with 1.8.8 and Java 8
That is highly unfortunate frankly
Try this:
httpconnection.setRequestProperty("X-HTTP-Method-Override", "PATCH");
httpconnection.setRequestMethod("POST");
I'm trying but still not working I think
no error but gives a 404 (not found)
Even the ancient version mc 1.8 can run using Java 11
What's the max on that btw?
Some servers claim that they pushed the limits up to java 17 by disabling a netty native io setting.
Or you could, idk, update :p
That's weird, just do what choco said haha
That's way easier. I didn't test the java 17 mc 1.8 thing bc I'm on 1.20.2 and 1.20.4
Hey fellas, got a question for you
@HandleInterface(action = ActionType.GET, handles = InventoryHolder.class)
public static <T extends InventoryHolder> SInventoryHolder getInventory(T entity) {
// Stop all viewers from accessing (prevent potential race conditions
entity.getInventory().getViewers().stream().forEach((HumanEntity::closeInventory));
System.out.println("Inventory: " + Arrays.toString(entity.getInventory().getContents()));
return new SInventoryHolder(entity.getInventory().getContents());
}
I have this code here for serializing the inventory. It fails specifically with a donkey (or other chested horse I'd assume). I can print out the inventory and I get this
[ItemStack{WHEAT x 37}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null] Which is what I'd expect.
I'm just curious as to why the printing of the actual itemstack array works (I assume its using the default configSerializable interface which is what I want) and Gson has an issue with it.
I have other record type classes similar to this that holds info and it doesn't have an issue with those. Only with this InventoryHolder interface does it fail.
Full log here
I also have a similar record for armor contents for mobs and it works fine.
Gson doesn't understand how to serialize an Optional
What it's failing on is SEntity, not SInventoryHolder
So whatever you're serializing in SEntity holds an Optional field somewhere (which, yikes - Optionals aren't meant to be fields)
I got that, but I have other records that process itemstack objects as well which is where I am concerned why there is a difference between these two
SEntity does not have any optional fields. Its a reflection invoker method for these records. I've narrowed it down to that specific method causing the issue with GSON, but if you really want the invoking code here it is as well
Gson gson = new Gson();
JsonObject serializedEntity = new JsonObject();
serializedEntity.add("EntityType", gson.toJsonTree(new SEntityType(entity.getType())));
JsonObject attributes = new JsonObject();
for (Map.Entry<Method, Class<?>> entry : interfaceMethodMap.entrySet()) {
try {
if (entry.getKey().getName().startsWith("get")) {
Record record = (Record) entry.getKey().invoke(null, this.entity);
JsonObject recordJson = gson.toJsonTree(record).getAsJsonObject();
attributes.add(entry.getValue().getSimpleName(), recordJson);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}
serializedEntity.add("Attributes", attributes);
return serializedEntity;
}```
This is not how you should serialize objects with Gson.
Ideally you would have one Gson instance for your application which is aware of all serializable classes and how
to serialize them properly.
i was just too lazy to bother with adding new lines and declaring new variables
that was the question ¯_(ツ)_/¯
I've written code like that, halway through writing it it becomes more work than doing it the right way
what do I save in the chunk that will allow me to respawn an entity from it
specifically when it starts running off the monitor for the third time
Are you talking about using GsonBuilder? Or is there a better more dynamic way?
almost half this file runs of the monitor
a ultrawide curved monitor
absolutely degenerate behavior
I like it
you should ping imillusion with your worst examples
I mean bare minimum, put some newlines :(
Also, if that's running in any area of code that's particularly hot (which I think it was - this is in a pathfinder?), you're going to lose a lot of performance for really no benefit
ez way to get blocked
yah its in a pathfinder
One of the reasons Mojang's AI code has as bad performance as it does is because they use streams in some of it :p
Another reason is their use of "brains" which I think has made things significantly worse, but that's another issue lol
huh
Streams have lots of overhead
Thr villager ai looks more complicated than it had to tbh
So in the design of a seasons plugin, for each season I want to include particles for visual effects. Would the best way to do so be in usage of packets + rendered particles? In that you send particle updates to the player within a certain distance
I'm not versed in protocol lib in any way, how difficult is a process like this?
You could broadcast the particles to the world which would use the entity tracker anyways
annnnyways how do you reload a custom entity when the chunks loaded
I'm trying to keep it as optimized as possible, that being said won't packets be the best way to do so?
Why use an internal dependency though? The whole purpose of Bukkit is to abstract things away so you're not depending on specific versions
Bukkit's Particle API sends a packet to players
World#spawnParticle() will automatically optimize it so it only sends to players capable of seeing it (within 32 blocks)
Rather to keep it localized to a player, but I if I can do this then yeah, you're right.
I mean if you want to do it for only one player, then sure, Player#spawnParticle() works fine too
The thing about using packets is that you can make one and send it just to those close enough
Well it was more for the consideration of ranks but now that I'm talking about it, that doesn't make much sense - to limit visual effects based on a players rank... especially for a seasons plugin haha
^
And beyond that, if you opt to use Player#spawnParticle() anyways, you can make the server-sided distance check yourself
what event is called when a entity loads
I don't think I want to do all that if the spawnParticle method already exists in world
So is that distance just constant at 32? Or can I make that configurable? (Configurable within the same world method rather than having to switch to the player.spawnparticle)
Or would this require extra impl
Pretty sure distance is configurable
Would htis work
this.target = this.mob.level().getNearestEntity(this.mob.level().getEntitiesOfClass(this.targetType, this.getTargetSearchArea(this.getFollowDistance()), (entityliving) -> true).stream().filter(entity -> !entity.getBukkitEntity().getPersistentDataContainer().getOrDefault(Overcharged.WARDEN, PersistentDataType.STRING, "").equals(this.mob.getBukkitEntity().getPersistentDataContainer().get(Overcharged.WARDEN, PersistentDataType.STRING))).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
alsooo how would i limit the distance
don't kill the entity like this, remove it.
Also don't forget to add your entity-specific data
(If I'm understanding what you're trying to do)
What entity specific data would there be
If you gave your entity some data, don't forget to copy it over
like your own custom data
alr yeh that happens in the constructor
Its something weird to do with accessing items of the inventory with a holder, as it has no issues serializing items in general. When I insert my own array of items rather than pull from the entity
{"EntityType":{"type":"DONKEY"},"Attributes":{"InventoryHolder":{"inventoryContents":[{"type":"DIRT","amount":3},{"type":"DIAMOND_SWORD","amount":5}]},"Damageable":{"health":24.0,"absorptionAmount":0.0},"Ageable":{"age":0,"adult":true},"Attributable":{"attributeMap":{"HORSE_JUMP_STRENGTH":0.5,"GENERIC_MAX_ABSORPTION":0.0,"GENERIC_ARMOR_TOUGHNESS":0.0,"GENERIC_ARMOR":0.0,"GENERIC_MAX_HEALTH":24.0,"GENERIC_KNOCKBACK_RESISTANCE":0.0,"GENERIC_MOVEMENT_SPEED":0.17499999701976776,"GENERIC_ATTACK_KNOCKBACK":0.0,"GENERIC_FOLLOW_RANGE":16.0}},"Nameable":{},"LivingEntity":{"armourContents":[{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1}],"mainHand":{"type":"AIR","amount":1},"offHand":{"type":"AIR","amount":1}}}}
is there any way to build a jar into a file from gradle
Location location = null;
while(true) {
int x = random.nextInt(-1000,1000);
int y = 320;
int z = random.nextInt(-1000,1000);
World world = Bukkit.getServer().getWorlds().get(0);
location = new Location(world, x, y, z);
if(location.getBlock().getType()==Material.AIR) {
System.out.println("Location " + x + ", " + y + ", " + z + " is safe");
break;}
else { System.out.println("Location " + x + ", " + y + ", " + z + " is safe not");}
}
return location;
}```
Is there anything wrong?
?
whats the problem
let me show you
it's always at the top
at randomX, 320, randomZ
is it normal?
use imgr
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
entity.getInventory().getContents() does not serialize by default with Gson - says something a java.optional field needing a type adapter
But ``` ItemStack[] itemStacks = new ItemStack[]{new ItemStack(Material.DIRT,3), new ItemStack(Material.DIAMOND_SWORD, 5)};
Is there something I'm missing? It should just be the same itemstack array I'm serializing?
in the main class
how good is this method to make circle animation?
ZFirstHalf is Z coordinate for first half of the circle.
dont think Math.pow(2) is a fantastic choice
why
ur using a while*(ture)
yeah but there's a break
why dont u use a lamda for the Runnable
it still will be called until it meets the conditions
and ur using a random number generator so it could be a infinate amount of times
why
why dont u use two random numbers and then start at the bottom of the world and use a loop until you find a air block
that's smart
or start at the top of the world and go down until you find a block thats not air
to find caves
to avoid*
im gonna do that way but i dont really understand why it is not working as i did
you can also still put it into a while(true) loop to check if there are not any blocks and it will work almost the same but you wont see nearly as many messages
because there is no guarentee that it will be an air block
and you keep checking over and over again
it calls into Math, it calls into StrictMath, and it calls into FdLibm.Pow just to get the fast path of a pow function, why not multiply it yourself?
therefor you will get a lot of output messages
hm ok
ill also get Radius to power of 2 out of the for loop
also make your variables lowercase, this isnt c#
dont variable name shame
i dont know C# xd
well it should be at least once since it checked 802347539857 times for y = 320 xd
holy shit
yea this would be 802347539857 times faster
also it prob did that because block 320 cant be anything bc thats build height
yea
use Material#isAir
about this method, somewhy it has tiny cut that never spawns particle in that spot
anyone knows why?
pollution
wdym
jk
@torn shuttle i made it better
this.target = this.mob.level().getNearestEntity(this.mob.level().getEntitiesOfClass(this.targetType, this.getTargetSearchArea(this.getFollowDistance()), (entityliving) -> true).stream().filter(entity -> !(entity.getBukkitEntity().getPersistentDataContainer().getOrDefault(Overcharged.WARDEN, PersistentDataType.STRING, "").equals(this.mob.getBukkitEntity().getPersistentDataContainer().get(Overcharged.WARDEN, PersistentDataType.STRING)) || Shard.getSummoningMobs(Overcharged.getPlayerShard(Bukkit.getPlayer(UUID.fromString(this.mob.getBukkitEntity().getPersistentDataContainer().get(Overcharged.WARDEN, PersistentDataType.STRING)))).getItemMeta()).contains(entity.getBukkitEntity()))).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
wh... what?
i don think i understand it anymore either
wtf is that
there is a keyboard touch named enter
just because you can do it in one line doesn't mean you should
I think you should use it
It’s constant. Hard-coded in source
Client probably also has a similar hard coded constant
Only time it’s higher is if the force flag is set to true, in which case it will render up to 512 blocks
Hello, if I want to get the total available surface using LimitedRegion#getBuffer, do I need to multiply it by 3?
So started to use Triumph Gui API
and I was reading using InventoryHolder
is bad practic
and now I found out this api is using inventoryholder to
so
Can I expect bad preformance
Nah
I already talked about this a bunch
The problem is when the check fails, not when it passes
Thing is they call it twice which is twice as bad
You could do compare ids but inventory click doesn't make much lag
In short, expect at most 0.2ms per call
damn another attempt to write useless docs
You'd need 250 players spam clicking on chests in order to have any kind of tps loss
You aint getting even 50 in a single server
for safte I will add who click more then 10 times in a min auto ban 🤣
@EventHandler
public static void damage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player p) {
ItemStack shard = Overcharged.getPlayerShard(p);
if(Shard.getSummoningMobs(shard.getItemMeta()).contains(e.getDamageSource().getCausingEntity())) {
e.setCancelled(true);
((CraftMonster)e.getDamageSource().getCausingEntity()).setTarget(null);
}
}
}
how come the warden is still targetting the player even though the player isnt taking damage
EntityTargetLivingEntityEvent
isn't getting called when the warden targets the player, anyone know why?
Do you think 32 would be enough?
Some of the winter effects were going to reduce their visibility someway
Make sure to pass false to getHolder
is there any way to modify the Spigot server code itself
like is there a download for the code somewhere
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
So, I've made a custom enchantment via extending the Enchantment class and registering it. I am able to apply the enchantment to an item, but the lore isn't updated with the enchantment + level.
Is this something that I have to handle (the lore)?
Never versions don’t allow you to extent enchantment either
So you should just switch to handling it via the pdc
I see
Thank you
Any common API's that handle enchantments via PDC?
Not against developing such a thing myself, but I would want to use one if it's out there.
There should be a lib or smth for custom encahnts
Doesn't use PDC but thanks.
Hello, i cant understand why is my code not working. I want to create a Shop plugin, i created a gui named "Sell Or Buy"
I want to open that menu when i click on an item. I get the event of which click is (Right or Left). I can't even log that shit it dont works, could you help me ?
Don't detect inventories by their name
?gui
public Location randomLocation() {
Location location = null;
boolean generateNew = true;
World world = Bukkit.getServer().getWorlds().get(0);
while(generateNew) {
boolean k = true;int x = random.nextInt(-1000,1000); int z = random.nextInt(-1000,1000); int y = 320; while(k==true) { location = new Location(world, x, y, z); if(location.getBlock().getType().isAir()) { y--; } else if(location.getBlock().isLiquid()) { k=false; printCoordinates(location); System.out.println("Is Water"); } else {location.setY(y+1); generateNew=false; return location;} } } return null; }
Seems like this code that checks for air and water and return the location if there is no water makes all the server lag/makes some stuff such as events not work
Because it loads chunks
oof
what can i do for it?
i used to randomly spawn it somewhere randomly without checking for water and it worked perfectly, coult it be because of the while loop?
in my small experience i have never had a good time with loops in spigot plugins
You could probably save yourself a bit of processing by re-using the same chunk for multiple checks. e.g. load one chunk, check maybe 16 positions or so in that chunk for a safe position. At least that way you're only loading one chunk and trying to find a good spot there instead of loading 16 different chunks
mh
do you know of a good tutorial and a good boilerplate for starting to develop a plugin that follows good practice?
well wouldn the method only return a location in the same chunk over and over? I need that random location to spawn a mob there
Why do you want to spawn a mob in unloaded chunks?
it's a mini-boss players need to reach and kill
it worked until i put that watercheck
but still, happend that on killing that boss some stuff happened and now it doesnt
Yeah the water check is the harsh part as you otherwise could spawn the mob once a player loads the chunk
If you make sure the relevant chunks have been generated before you could work with chunk snapshots
well, before doing the water check i could spawn it anywhere
Even spawning it anywhere would load the chunk which does not make sense before anyone comes close
But obviously 1 chunk isn't that bad
That's fine, just check 16 positions in the same chunk then move onto the next one
let me check by reducing the spawn to one point
I'm just saying that it would probably load a hell of a lot less chunks if there's a good position in the chunk you're already in, so it's best to give a few different chances in a few different positions within the chunk's coordinates
because it's likely that in the 256 columns of blocks in that chunk, you picked a shitty one :p
Unless he lands directly in an ocean which isn't that unlikely
it cannot
You use a random chunk, how would it not be able to pick one that is ocean?
Or do you not have oceans?
well because it doesnt land
it spawns in a block right above the ground if the ground !isLiquid()
Actually it would be a great addition to spigot to be able to check which biome a chunk has without fully generating/loading it.
Since blocks depend on the biome it should be possible to find that out prior to generating all the blocks, spawn the mobs etc.
I'm still inside your function to determine a save location. If that function selects a random chunk and it is ocean, it isn't unlikely you won't find a suitable location
Sure, but then who cares? You move onto the next chunk, which is what they're doing already
but what i mean is:
Chunks should be loaded once it teleport to the boss spawn location
What I'm saying is to not test x 100 z 100, find out "oops, there's a tiny 2x2 pit of lava there", then go to like x -950 z 739 when you could have just checked another spot in that same first chunk and avoid the 2x2 pit of lava
Check the same chunk you're at like 8 times or something so that way you're probably going to load literally 1/8th the amount of chunks
Yes I got that and I'd agree on that optimization
If your first chunk happens to be an ocean, whatever. The next chunk might not be
There's no performance impact there, the alternative would have been to give up after one check and move onto the next chunk anyways
So at least you're still checking the same chunk for all the other 100+ biomes that aren't totally water lol
I'm sure there's a possibility to do that with NMS and then skip directly if it's some kind of ocean
iirc theres a get highest block method too
i now understood
but i have no idea how to do that
Just an extra loop inside of your chunk one
i dont have any chunk loop
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#getBiome(int,int)
Why is this deprecated but there is no replacement for 3 coords?
declaration: package: org.bukkit, interface: World
There is, it's in RegionAccessor
Oh
tyty
there you go
Does the RegionAccessor getChunk function load the chunk?
getBiome*
If not you could check and skip ocean chunks before even loading them and checking any locations
public static Location findRandomLocation(World world) {
ThreadLocalRandom random = ThreadLocalRandom.current();
int x = 0, y = 0, z = 0;
int attempts = 0;
while (attempts++ < 10) {
x = random.nextInt(-1000, 1000), z = random.nextInt(-1000, 1000);
y = world.getHighestBlockYAt(x, z);
if (world.getBiome(x, y, z) == Biome.OCEAN) {
continue; // Would want to check for more than just OCEAN, obviously
}
Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
for (int i = 0; i < 16; i++) {
int minX = chunk.getX() << 4, minZ = chunk.getZ() << 4;
int maxX = minX + 16, maxZ = minZ + 16;
x = random.nextInt(minX, maxX), z = random.nextInt(minZ, maxZ);
y = world.getHighestBlockYAt(x, z);
Block block = world.getBlockAt(x, y, z); // Could also use World#getType(x, y, z) to avoid a Block allocation
if (isValidPosition) { // Do your checks here
return new Location(world, x, y, z);
}
}
}
return null; // Just a safety in case it couldn't find a position in 10 (* 16) attempts
}```
This is probably how I would do it
holy
while loop with safety condition? Thats no fun 
And yes, RegionAccessor#getBiome() does not load the chunk
It pulls the biome from the noise map
Find me a suitable Location or die trying
That's perfect
Now absolute worst case you'll load 10 chunks, plus you're checking 16 times within each chunk you find
160 checks total
(I didn't verify this logic btw - I just wrote this in Discord lol)
How do I obtain the HeightMap for functions like this?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/RegionAccessor.html#getHighestBlockYAt(int,int,org.bukkit.HeightMap)
And does that exist prior to a chunk being loaded? I'd assume not
declaration: package: org.bukkit, interface: RegionAccessor
🥣
(legends say that he programs in binary)
They're just constants
HeightMap.OCEAN_FLOOR_WG might be what you want
Checks for non-air and non-fluid
So I'm able to find a suitable location without loading the chunk when I use that?
Well you could at least check the biome first (as I did in my snippet)
Of course
You're going to have to load the chunk one way or another and the World#getChunk() method will do that
I have to say though, if you're depending on the Paper API, they do have some async chunk loading. We don't have that in Spigot, but if you're writing a private plugin for a Paper server, take advantage of that
Yeah that's what I expected. I thought the height map might be a way around it
Nah, the height map would just help you get the highest block under different conditions
I see
I'm sure that comes with some problems but generally speaking it sounds cool to load chunks async
PaperLib allows you to interface with that
Yeah they have an optional softlib
Just checked, I might make use of that in the future. Thanks!
me when i go to use entity snapshots and paper don't have em :pepehands:
They don't? 
It's not super new to where they wouldn't have pulled upstream changes
i just thought
they don't have it ye
choco you might have to break ur cla by looking at paper code for hypixel
kek
client-sided minigames?
dont break cla choco
hypoxlr
EntitySnapshots are in Paper. idk why anyone would use them, its pretty scuffed atm
it seems to arbitrarily not save some data about the entity. I can't see a pattern to it
Unless something went wrong I programmed them to only discard instance specific data
Mostly position and uuid
what is instance specific? there are tons of positional information stored in entities that are still saved. ALL of the brain stuff
iirc, its also not saving some useful data about item frames and paintings
Ah yeah the brain stuff probably needs more work
Pretty sure it also discards some additional positional data on hanging entities, I don’t think it should discard anything else
thats funny
public static Location findRandomLocation(World world) {
ThreadLocalRandom random = ThreadLocalRandom.current();
Location location = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
int x = 0, y = 0, z = 0;
int attempts = 0;
while (attempts++ < 10) {
x = random.nextInt(-1000, 1000);
z = random.nextInt(-1000, 1000);
y = world.getHighestBlockYAt(x, z);
if (world.getBiome(x, y, z) == Biome.OCEAN) {
continue; // Would want to check for more than just OCEAN, obviously
}
Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
for (int i = 0; i < 16; i++) {
int minX = chunk.getX() << 4, minZ = chunk.getZ() << 4;
int maxX = minX + 16, maxZ = minZ + 16;
x = random.nextInt(minX, maxX); z = random.nextInt(minZ, maxZ);
y = world.getHighestBlockYAt(x, z);
Block block = world.getBlockAt(x, y, z); // Could also use World#getType(x, y, z) to avoid a Block allocation
if(block.getType().isAir()) {
y--;
}
else if(block.isLiquid()) {
printCoordinates(location);
System.out.println("Is Water");
}
else {
location.setX(x);
location.setY(y+1);
location.setZ(z);
printCoordinates(location);
System.out.println("is fine");
return location;
}
}
}
return null; // Just a safety in case it couldn't find a position in 10 (* 16) attempts
}
Shouldn't need your first isAir() check. The getHighestBlockYAt() does that for you
^^
how do i find the ground lvl then?
Also, yeah, you aren't using the Block itself so you can optimize that last bit with a getType() instead
// ...
Material type = world.getType(x, y, z);
if (type == Material.WATER || type == Material.LAVA) {
continue; // is water
}
return new Location(world, x, y + 1, z);
Oh there is an isLiquid() :p
Not 100%
Why? You're avoid a CraftBlock allocation
this is not working tho 😭
Oh, sure
i can stand on waterlogged blocks
But it is always on water
Yeah I think waterlogged blocks is less of an issue
Kelp is just always waterlogged
But it doesn't have the waterlogged BlockData
Like I said, my logic might be slightly wrong. I didn't verify anything
Because you can’t un-Waterlog it
Still, bit annoying
It’s basically just water2
It fails isLiquid too
Wack
I still want Mojang do come back to waterlogging
Java got done dirty in that regard
I recently had a commission project that basically teleported you back if you touched on water
and kelp was giving issues
:)
So I just hardcoded it
The game just needs a fully layer system tbh
pr it
To who
minecraft is probably on github
Yeah lemme just hack the private repo
they wont question why rando canada is pring stuff
just blind merge
my one vein is so chunky
its weird
Yo ik this is almost 102% not a thing but can u take pictures of the POV of a player?
This is possible, expensive and very complicated
p sure cmarco did it
yes 😭
Basically you want to do a bunch of raycasts and get a projection going
Well im trying to use it with a discord bot lol
If i really wanted to
I could just raycast
and just use emojis
as a very very low resolution version
but at that point there isnt a point in it lol
ud prob want a cooldown on that bc its heavy
also prob not 100% accurate bc players can move before its finished
fr
josh why is one of me veins so big
no im pretty sure its blood
😭
stop tryna flex bro
Feet leak 🗣️🔥🔥🗣️🗣️🔥
i have a sock on
im built like a paperclip its not flexing
wtf he said paper
calm ur nose
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Objects;
public final class SkillTrees extends JavaPlugin implements Listener {
private SkillTrees skilltrees;
@Override
public void onEnable() {
skilltrees = this;
getCommands();
getListeners();
// Plugin startup logic
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
public void getCommands() {
Objects.requireNonNull(getCommand("skills")).setExecutor(skilltrees);
}
public void getListeners() {
Bukkit.getPluginManager().registerEvents(skilltrees, this);
}
}
[23:03:54 ERROR]: Error occurred while enabling SkillTrees v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
at java.util.Objects.requireNonNull(Objects.java:233) ~[?:?]
at me.jesse.skilltrees.SkillTrees.getCommands(SkillTrees.java:33) ~[SkillTrees-1.0-SNAPSHOT.jar:?]
at me.jesse.skilltrees.SkillTrees.onEnable(SkillTrees.java:19) ~[SkillTrees-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:188) ~[purpur-1.20.4.jar:git-Purpur-2169]
at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[purpur-1.20.4.jar:git-Purpur-2169] ```
Could someone tell me why this is registering as null?
hey guys, is there a way to use an API to get a random minecraft account UUID or username?
?whereami
I'm not using paper
👏 Tell 'em, Em
Though spigot plugins still work on ( my other plugins were working on it )
The problem is just that you didn't register your "skills" command in your plugin.yml
i need this quick btw so any help is appreciated
Dang it. I did I just type command: instead of commands: 😦
Hellooo~ I'm an amateur as far Java/Spigot goes, so, please. Go easy on me.
I'm using NEZNAMY's TAB plugin for a certain thing. Now, I have two questions:
- Is it possible to embed that dependency, or somehow NOT require the user to install the plugin too?
- If 1 is not possible, how would I go about abstracting the features that use the dependency, so that they are not REQUIRED.
Check if the plugin is installed via PluginManager#isPluginLoaded(iirc) and then run code based on that
Oook, as in? My question is how I'd go about abstracting it? Do I have to make another class that handles everything that has to do with the dependency, and then not instatiate/use that class in case the plugin is not present?
You just have to avoid method calls involving the other plugins classes
I belive data version?
so it only changes between updates?
Yes
wait major or minor
Any version
it just tells the server what version of the item, so it can perform upgrades if needed
https://pastebin.com/LPYUtKbq - Could someone tell me why I can't get it to open the inventory when I run the command. There are no errors.
https://paste.md-5.net/salukocawu.java
Could I get some notes on this implementation? I'm not very creative so the visual effects / particles will need some work + I still have to write out the custom effects given to players during these seasons
Would anyone here be able to make me a somewhat simple plugin? (I believe it's simple at least 😭) I'm willing to pay for it to be made in nitro/usd (cashapp, paypal) 🥺
?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/
anyone work with text displays using packets?
the second i set a scale on 1, it makes the text display non-existant
There’s api for it
sending them client side
using protocollib
new WrappedDataValue(12, WrappedDataWatcher.Registry.getVectorSerializer(), new Vector3f(3.0F,3.0F,3.0F))
if i dont set a scale, i get the text display
thhe second i add it, its gone
without scale https://i.imgur.com/U1Qhk3J.png
declaration: package: org.bukkit.entity, interface: Player
ik that exists, but why would i spawn say 50 of them if im just creating one catered to the client
just seeing if anyone has worked with them before and has set the scale correctly on them
You have to pass in the player in the
player.openInventory();
Player player = (Player) sender;
player.openInventory(player);
Oh you have the player already, just do player.openInventory(player);
No you don't
Did you just use chatgpt?
xDDD
?gui that aside this method of inventory management is primitive and prone to bugs highly reccomend you check out this thread. While what you're doing should work my guess is their may be other variables involved that cause the issue
Oh forgot to say, I fixed it it was an issue with my things getting declared weird in the main class but thanks!
World edit is seemingly the only way to go here
Though I'd be aware of the computational strain saving an entire chunk will have
Yeah 66 * (1616) * 324
Not sure how much threading can be done with world edit be cautious all I'm tryna say
3m blocks isnt actually that much, prob only take 1-2sec if not less
(well, depending on server ressources but still, should be pretty fast)
Can a chunk get unloaded by itself if i use load()?
Should I use setForceLoaded()?
Yo so my plugin got basic permissions,
But not all of them are shown in the commands section of the plugin.yml
How do I register them through vault or otherwise so that permissions plugins like luckperms will see it.
add them to your plugin.yml permissions section
what's better? Store a link to a location in its usual form or store only the components of an object separately in its own created object
as I understand it, option 2 is better, because the location is changeable, just like the Player object
what exactly is the usecase
bit of an xy problem that you're asking
how to make those crossversion plugins without NMS or external libraries like those chat management plugins
I mean that you can’t transfer or store a location object, right? After all, it is changeable just like the Player object, so the link to the object is stored as a uuid
and that's why you need to use worldUUID or worldName
depends
Is the situation the same with the location?
yes you can store/transfer a Location object, but it depends on a few things
which is why your question is an x/y one
so you just want immutability?
well, in my case, I save the location block for further chunk regeneration
Hey guys
i want to know if it is possible to store the Location object as usual or is it better to use worldUUId, int,int,int
Sure
just store it as normal, you are over thinking it
You should nto really be using locations if you are refering to Blocks
but again, without any context it's hard to give a concrete answer
this is for chunk regeneration
i save this in map
for restoring a chunk you should def not use Locations
a Block has a position, an x,y,z
that block is in a Chunk, which is also a x,z
that Chunk is in a World, which is the only difficult part
as you can;t get a World reference if it's not loaded is all
i not should use location?
the thing is that I need to save only part of the chunk, leaving the bedrock
why are you storing ItemStacks?
to store inventories im guessing
yes
seems to have nothing to do with a Bl;ock regen
check out minecraft's chunk format, you'll save heaps of memory
location is 3 ints, mat is a byte, then inventory content is many many btes
times that by however many blocks are in a chunk, and you are using tens of MB per chunk
then what is the best way to save chunks ?
many ways, depending on what you want to do with it
delete, regenerate.
Just use an Array of materials
a chunk at a time?
So I have this problem, I can’t see my prefixes of LuckPerms on my test mc server. I translated the “&” codes into chat colours but I still can’t see the prefixes. And if a prefixes is null, null should also be translated.
Here’s the code: https://paste.md-5.net/gikififezo.java
ask in #help-server
you're most likely missing a chat manager plugin
Why so? It’s plugin development
ah nvm
all pieces vertically leaving the thigh
You are translating prefix AFTER you set the display name
you shouldn't be using displayName for prefixes aswell
We told him that yesterday
So it should be translated before?
Then what should I use?
I told you yesterda
AsyncPlayerChatEvent
set format
declaration: package: org.bukkit.event.player, class: AsyncPlayerChatEvent
create a method to getFormattedName
How? I wasn’t online yesterday
really?
It must be the day before
I meant, I wasn’t coding
So I should create a new method sure
so uh how i can save chunk?
read that
you can just use an array of materials
super simple
if you want to get more complex, an array of bytes which point to the index of a material on another array
then for tyour inventory data, another array
how many chunks are you wanting to save/restore
the index of which is just a 3d vector flattened to a 1d index
more than 10
There are ways to do what you want but you are being so vague I'm giving up asking 20 questions.
Hi there, is there any way to make lore on an ItemMeta translatable? it seems to be purely String based snd I'm not sure how I'd pass in a translation key with arguments to be parsed on client
I will answer specifically. I want to use a command to delete a chunk (with filtering of some blocks) and restore them to their original state
save only in memory not in files
Then Structures are out
what exactly do you want to hear
if you are not saving then chunk Snapshots are your simplest method
everything should be the same as it was before restoration (except entity)
you can hold them in memory and read their data to perform yoru block replacement
spigot doesn't support it. I know paper supports Component lores but i think under the hood they are still just strings anyway
might be a minecraft limited thing
On chunk load (first time) take a snapshot and hold it in memory
theres definitely trickery you could do to translate it, but nothing natively supported (afaik)
ah, probably just isnt worth it for me then, its fairly simple one word lines mostly so cant imagine its going to be too much of an issue to use server default locale
appreciate it
Nearly all text in minecraft is Text Components, so spigot is limited in this case
You can use some NMS fuckery to access the item NBT directly and set it to the translate json thing
As I understand it, ChunkSnapshot stores data about the chunk, but how can I change it for my needs? Can I do something like Chunk.setSnapshot?
no you read BlockData from it as you need
x,y,z
The Snapshot is literally a copy of the chunk as it is when you take the snapshot
a moment in time
Are there special methods for deleting chunks? or through overkill?
To restore it to the live chunk, you loop over its data (x,y,z) and set teh BlockData to the live chunk
Well, that means deletion and restoration remains the same. Only the storage method changes
its a much smaller memory footprint than the idea you had
and simpler
getting the data is also a single method call
instead of doing it for each and every block
you said you were not saving, you were keeping in memory
I'm guessing English is not your native language as what you said makes no sense
i mean after all, the snapshot itself somehow stores data about the chunk
The Snapshot is a copy of the chunk (in memory)
but doesn't use much memory
you were storing block data and a location for each
oh now i see
Ok so I did it, I did what u said, here’s the code https://paste.md-5.net/xoziboqine.java
https://paste.md-5.net/bitapexeqe.java
https://gyazo.com/22257697c83afc77dff7a40d38a3e185
https://gyazo.com/9221c48d114d571c1bdfb20e16d6459c
Could I get some notes on this implementation? I'm not very creative so the visual effects / particles will need some work + I still have to write out the custom effects given to players during these seasons
But I get missing return statement in line 46
And I get the error that prefix might not initialise
In line 53
so then add a return statement and initialize the prefix
If I add one I get another error
such as?
Cannot resolve for getFormattedName
And I still have the missing return statement error
you are setting Display Name and not returning it as a String
Ill return it into prefix
I forgor
But for the problems I mentioned
Any solutions?
String result = "";
String prefix = "";
User user = plugin.getLuckPerms().getUserManager().getUser(player.getUniqueId());
if (user != null)
prefix = user.getCachedData().getMetaData().getPrefix();
prefix = ChatColor.translateAlternateColorCodes('&', prefix);
... /add your StringBuilder here to make the result using prefix and name etc.
Return result;```
Elgarl got the time?
public String getFormattedName(Player player) {
User user = plugin.getLuckPerms().getUserManager().getUser(player.getUniqueId());
if(user == null) return null;
String prefix = user.getCachedData().getMetaData().getPrefix();
if(player.hasPermission("hoverinfo.admin")) {
return prefix + ChatColor.RED + player.getName();
}
// etc
return null; // Default
}