#help-development
1 messages · Page 1640 of 1
Why are you using nms entities?
i am remaking the gravity gun in minecraft :p
What is teh gravity gun?
A gravity gun is a type of device in video games, particularly first-person shooters using physics engines, whereby players can directly manipulate objects in the world, often allowing them to be used as projectiles against hostile characters. The concept was popularized by the gravity gun found in Valve's Half-Life 2, as well as the Temporal Up...
ok, so still why use nms?
so the fallingblock doesnt lag while teleporting
im using packets
throwing blocks is simple. you don;t need nms nor packets
No
when you pick the blocks
i need to teleport them
i can also throw them
but the old nms falling block
stays
and i need a way to kill it
do you mean you want to be able to pick up a block using one click and throw it using another?
hey any one know simple way to generate player file from uuid
i can do that
of player which never played on server
when you throw it
another block is spawned
and the old one doesnt get killed
for some reason
throwing is simple. I did this the other day to throw blocks```java
@EventHandler
public void onLeftClickAir(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND
|| event.getAction() != Action.LEFT_CLICK_AIR
|| event.getItem() == null
|| !event.getItem().getType().isBlock()) return;
Player player = event.getPlayer();
Location loc = player.getLocation();
Vector direction = loc.getDirection();
Material item = event.getItem().getType();
FallingBlock entity = player.getWorld().spawnFallingBlock(loc.add(direction), Bukkit.createBlockData(item));
entity.setVelocity(direction.multiply(2));
}```
that allows you to throw a block you have in your hand
no nms
dude
i can throw the fucking block
but i need to kill the nms falling block
can i just share my screen, it seems i cant explain it good enough
never dive to nms if it can be done using the API
Can you cancel the PlayerChangeArmorEvent somehow? Like if they click with a specific item on their helmet slot, then that click doesnt even properly register and the armor reverts + they still have the old item on their cursor
sure
send me a friend request
ok, let me see if I can do the pick up part not using nms or lag
Can you cancel the PlayerChangeArmorEvent somehow? Like if they click with a specific item on their helmet slot, then that click doesnt even properly register and the armor reverts + they still have the old item on their cursor
That is not an event...
not yet at least
but yes
it has not been released yet
RedLib has one iirc but unless you wanna pester
about it it’s gonna be a while
Pretty sure paper has the event
yep
Nice it doesn't seem like you can cancel it, which makes sense
ChangeReason is enough
In ProjectileLaunchEvent, how do I get player who triggered the event?
getShooter on the projectile
Incorrect, some NMS methods provide huge performance benefits (setting blocks fast etc)
So i was using VisualBukkit for the first time and i dont understand code so i will ask, how do i make it so when players stay on diamondbloc kthey will get levitation?
ehh this isn't really the place for visualbukkit
But there are 2 ways you can approach such feat
How?
Alright
So whenever the player moves
Check the block below
Is it a diamond block?
Yes
If so, apply the levitation effect
yea
yeah but at the same time you kinda argued against yourself - setting blocks fast cannot be done with the api so nms is often required
Setting blocks is possible with the API, however it is very slow to do so
uhh can i save an inventory in a InventoryClose event? or are the contents cleared then?
They're not
well for some reason i cant save an inventory
Save the itemstack array inside
i did
else if (event.getView().getTitle().endsWith("safechest")) {
CommandSafechest.getMenus().put(player.getUniqueId(), event.getInventory().getContents());
Utils.message(player, CommandSafechest.getMenus().toString()); // debug
}
no
don't compare inventory names, use instances
yea i did like this
inventoryholder instances
just the inventory is fine
you dont need inventoryholder. a set will do
A set of what
Basically the same idea as using the holder instance
yep
I wonder which one has faster equals
shouldnt make a difference
using the inventoryholder "breaches" the api, said choco
as the communtiy frowned upon his response
no he said invholde
And I said view
.
I’m saying you can compare using the view
Or the inventory instance, not sure it really matters
i think inventory checks for titlr
I do wonder what .equals on an inventory compares
?stash
find it im on phone
Just this == other iirc
wouldnt be logical
It would
i also get this error from my uuid in my yml file
https://paste.md-5.net/igayecilof.sql
it says data.yml but there's only this inside
I have a problem that my buildtools doesn't generate source(--generate-source) and javadoc(--generate-docs)
How do I display action bar in 1.8?
Nvm it delegates to nms inventories
wrong file then
btw u cannot serialise uuids,. you must convert them to strings
?
because that is a string
Find an API or use NMS
somewhere you've done set(UUID) and its trying to read that back and failing
👀👀
hellouw everybody
heywo
do people prefer saving data to json/xml because it's better then java io or just because they don't understand java io well enough to use it?
json/xml/yaml is just a format
with libraries and serialization it makes life easy
just depends on the library
speeds wont matter
I used json for some other application and it seemed slow for what I needed it to do.
shouldnt matter. yaml runs more checks
if you wanted it to be fast you shoudl not have chosen json
at that time I was new to java
yaml has the minimum of syntax bloat.
Will it work just as good if I serialize my own custom objects?
xml is next
.ini is fastest
true
i do this
yes, just use the Bukkit serialization
removes the :==
right
I found it quite good saving data to a database and serialize the data objects
how do I get a block? cause I need to get the noteblock so I can give it custom nbt for when it's placed down
getBlockAt
If when placed use this event https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/block/BlockPlaceEvent.html
declaration: package: org.bukkit.event.block, class: BlockPlaceEvent
Can anyone tell me why this code
//calculating animation borders
for(int i = 0; i<borders.length; i++){
//resolving corners (ymin isn't necessary since it's always equal to xmin)
int xmin = borders.length - i - 1;
int xmax = xmin + 4 + i * 2;
int ymax = xmin + 2 + i * 2;
int[] border = new int[((xmax - xmin) + (ymax - xmin)) * 2];
//filling perimeter x and y edges
int[] xRange = MiscUtils.range(xmin, xmax);
int[] yRange = MiscUtils.range(xmin, ymax);
int borderIndex = 0;
for(int j = 0; j<xRange.length; j++, borderIndex += 2){
border[borderIndex] = getSlot(xRange[j], xmin);
Bukkit.broadcastMessage("Adding top x edge slot " + border[borderIndex] + " (" + xRange[j] + ", " + xmin + ") in border " + i);
border[borderIndex + 1] = getSlot(xRange[j], ymax);
Bukkit.broadcastMessage("Adding bottom edge x slot " + border[borderIndex + 1] + " (" + xRange[j] + ", " + ymax + ") in border " + i);
}
for(int j = 0; j<yRange.length; j++, borderIndex += 2){
Bukkit.broadcastMessage("Adding top y edge slot " + border[borderIndex] + " (" + xmin + ", " + yRange[j] + ") in border " + i);
border[borderIndex] = getSlot(xmin, yRange[j]);
Bukkit.broadcastMessage("Adding bottom edge x slot " + border[borderIndex + 1] + " (" + xmax + ", " + yRange[j] + ") in border " + i);
border[borderIndex] = getSlot(xmax, yRange[j]);
}
borders[i] = border;
}
doesn't generate borders like this
Sorry for the huge message
is there a better way to do this?
I'm trying to convert a JSON string into an array, I added some json parsing libraries, but every time I attempt to use them I get errors. I'm just trying to get data like this into a clean array:json {"data": [{ "name": "Test", "desc": "This is just a test.", "extra_info": [{"id": 10000}] }]}(I added white space for readability)
Could anyone help?
dont hardcode shops
well i only have one shop
@EventHandler
public void railGun(ProjectileHitEvent event) {
Player player = (Player) event.getEntity().getShooter();
World world = player.getWorld();
Entity fireball = world.spawnEntity(player.getLocation(), EntityType.FIREBALL);
Location arrowLocation = fireball.getLocation();
fireball.setVelocity(player.getEyeLocation().getDirection());
if (player.getInventory().getItemInMainHand().equals(rail())) {
fireball.setVelocity(player.getLocation().getDirection().multiply(3));
world.createExplosion(arrowLocation, 2, false, true);
Firework f = (Firework) event.getEntity().getWorld().spawn(arrowLocation, Firework.class);
FireworkMeta fmeta = f.getFireworkMeta();
fmeta.addEffect(FireworkEffect.builder()
.flicker(true)
.trail(true)
.with(FireworkEffect.Type.BURST)
.withColor(Color.RED)
.withFade(Color.ORANGE).build());
f.setFireworkMeta(fmeta);
f.detonate();
new BukkitRunnable() {
@Override
public void run() {
f.detonate();
}
}.runTaskLater(new SlimeFun(), 2);
}
}``` how do I test for right clicking an item in a projectilehitevent
anyone?
Why doesn't 1.8.8 show up? I downloaded the build
set it to whatever and then manually change it
add meta to the projectile
Metadata
?jd
^
How may I use REDSTONE_LAMP_ON for 1.8.8? It spawns as the off one
i hate spigot
or bukkit
who made it an enum for block states
and that material update should come for 1.18, MaterialBlock MaterialItem
I have no idea how to do this as I have never used metadata or looked into it
MetaData gets applied to the entity so you can check if the player is owner or something, I don't know how you can check for right clicking though
whats the difference between PlayerInteractAtEntityEvent and PlayerInteractEntityEvent
read the docs
?jd
what ver
1.8.8
instead of metadata, I could add the entity to a hashmap in the interact event and check if the entity had the location of an assigned var in the projectilehitevent
how can I make a command that gives a noteblock with custom nbt?
the fact that they didnt fixed that, makes me kinda mad
Nah this sucks because you need to handle a ton of unloading and dying events
Use the PersistentDataContainer
I'm not sure how to use MetaData to the entity and check for rightclick
Dont use MetaData. Use the PersistentDataContainer.
i'll look at the docs to see how to use this
How can I set the facing of a block?
how can i make a reload config command?
Make a command and just call the reloadConfig method that's in java plugin
Because I want to get the Face of a block and later I want to load that Face again
plugin.reloadConfig() atleast
Load that face?
So I have to get the face and set the face of a block. Does somebody know how to do that
set the face
When I cast BlockData to Directional it gives me an internal error. It says: class org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData cannot be cast to class org.bukkit.block.data.Directional
Show your code
oh and uh make sure you get the blockdata from the right block
what do you mean?
This is my code:
BlockData blockData = b.getBlockData();
BlockFace blockFace = ((Directional)blockData).getFacing();
my problem is 'ReloadCommand(java.lang.String)' in 'org.bukkit.command.defaults.ReloadCommand' cannot be applied to '(bangui.me.duke.Me.Duke)'
Because that constructor does not take the type of your main plugin class
what does this mean lmao and how can i check
this is an issue
u see how ReloadCommand is graw
gray
and not blue
so i think thats where that error comes from
unused
do I have to check which blocks can have different block faces?
im not
Bro
oh
org.bukkit.command.defaults.ReloadCommand
adding this in imports legit just deletes my command class
In your Duke class 
You import the wrong one still
what?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
?learnjava
Import YOUR ReloadCommand not Bukkits
You need to check if the block can have a direction or not
ok i will try
is there a chance that player.setInvulnerable(true) causes a state like between survival and creative where i can break blocks sometimes?
i hear the sound of damage but dont get it
it may be better to cancel the damage event, what are you trying to do?
i'm in survival and dont get damage and somethimes i can break blocks instantly :/
Ok so I'm working on a custom enchant plugin, which saves the items enchantments as nbt data. Now idk what would be the best way about going to display the enchants in lore, as I can't seem to get an idea how to only redraw the enchantment portion when an enchantment is added? Since I want items to have the regular old lore, and then the enchantments part?
lmao found something
is there one DamageCause that comes from a player or are there multiple?
i think those two
EntityDamageEvent.DamageCause.ENTITY_ATTACK EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK
why not check if the damager is a player?
is see no event.getDamager method
afaik there isnt a damage cause that is limited only to players
there's the EntityDamageByEntityEvent
check if the event is instanceof EntityDamageByEntityEvent
that has a #getDamager
good move
aha like this
if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
}
basically
i was thinking why i got no damage from lava :/
how do i disable armor stand collision, because when i teleport the armor stand somewhere like inside a block it gets pushed out
Ok so I'm working on a custom enchant plugin, which saves the items enchantments as nbt data. Now idk what would be the best way about going to display the enchants in lore, as I can't seem to get an idea how to only redraw the enchantment portion when an enchantment is added? Since I want items to have the regular old lore, and then the enchantments part?
You can set the armorstand entity to not tick .setCanTick(false)
That should disable collisions
when I change the facing of a block the block drops itselfs. So when I change the facing of a piston the piston drops. Can I disable that?
r u saying you want the shiny effect?
since theres aw ayto make items shiny without adding an enchantment
like this
does anyone knows the event when a player regains health?
PlayerRegainHealthEvent? lol
nope
No I mean i don't know how to keep the original lore, while changing the enchantment lore? For example you have an item with the role
"This is an epic item"
Now when I add an enchantment to it it adds to the lore like this
"This is an epic item
Imaginary enchantment II"
But lets say the player changes that enchantment by leveling it up to level 3. Now I want to remove the imaginary enchantment, while keeping the original lore
but idk how xp
oh found
what was it
EntityRegainHealthEvent
hah
stupid entity
i knew it 🦆
You could save it on a custom nbt property and then read from it
You arent understanding
I have the enchantment data as an nbt
Which im writing as lore
you didn't
But idk how to ONLY remove the enchantment lore while keeping the original lore
so are you saying you want it tochange fom
"This is an epic item
Imaginary enchantment II"
to
"This is an epic item
Imaginary enchantment III"
when they level it up
Yes
and now stop making me sad :(
😳 🥰
Regex.replace on the lore then?
or 127.0.0.1:25565, doesn't matter
what client version do you use?
and what server version
both? looks like one of the both is lower
anyways i want to send continously an actionbar to all players with their health, so in the playerregain event and player damage etc should i send a new actionbar or change the text of the existing one? (they get one on playerjoin)
just send it in a runnable
why is there a need for the RegainHealthEvent and damageEvent then?
wait a sec
just send the health continously no?
gimme one seeeeccc
doing it right now
@Override
public void run() {
Utils.sendActionBar(player, "§c" + player.getHealth() * 5 + " / 100");
}
do something liek this:
@Override
public void onEnable() {
Bukkit.getScheduler().runTaskTimer(this, () ->
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(ChatMessageType.ACTION_BAR,
new TextComponent("Your text"))), 0L, 20L);
}```
at least thats what i'd do
oh you are on 1.8?
no?
in playerjoin
new ActionBar(p).runTaskTimer(plugin, 1, 5);
yea thats my Utils.sendActionbar
public static void sendActionBar(Player player, String message) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(message));
}
why not do this? it's probably easier and works perfectly
like in onEnable? there's no need for events
Iirc a loop on getOnlinePlayers may throw an exemption if a player goes offline while is running
nope it doesnt
on my variable
ArmorStand a = (ArmorStand) p.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
there is no a.setCanTick function
spigot 1.8.8 btw
it doesnt run the task FOR the players
What exception? 😮
the task just executes stuff for all online players... so if no one is online, it just does... nothing
and i guess sending it every second should be enough
I'm not on my computer right now but I recall having an exemption like that because the collection was modified while the loop was running.
Maybe It was by another reason though, Im talking just from my memories.
it looks like it was something different lol. i don't think that it throws any exceptions lol
me when i just create a project to test that one method out rq
Afsasdf seems like a cool plugin idea
The new essential plugin
Awesome, Fricken Super Amazing, Software Development Features
The new must-have library
Can you send me the maven repo. I need this as a dependency for my core plugin.
lol
i finally reached something in my life lol
any one has solutin to change this ugly prefix
[me.mraxetv.beasttokens.sqllib.hikari.HikariDataSource]
to my plugin prefix
I really don't undarstand
why is that not changable
Use another logger
u can't
works
that is written in class of api
which is compiled thru maven in my plugin
Use another logger for HikariCP
slf4j
how would I do that
so that is hikari
class
which is grabed by maven and compiled to my plugin
thing is final
and private
so u can't change it
I have it in my maven repository
can I edit classes there
I was modifying it this way
but after java 11 this is not working any more
so I am stuck
and I have no clue is it possible to edit maven repository code
HikariCP uses slf4j under the hood. There must be an easy way to define another logger for it.
Why are you decompiling when it's open source
that is when u press intellj shift+ left click
Just customize HikariCP and use that
so what download it and manually install it in repository then
Download the source change it then install that in to your repo
Is there an Event for when water ticks? Trying to make an erosion plugin.
Only when it flows
so I don't need to do it for every new version of hikari
when I change the facing of a block the block drops itselfs. So when I change the facing of a piston the piston drops. Can I disable that?
How can i change death messages expire time?
When a player interacts with another player/mob and after certain amount of time if he dies, mob/player will not get kill, and players death will be counted as natural. What is that death expire time and how can i change it with plugin(can i even)?
Nothing drops there...
in my case the piston is powered with redstone
mybe thats the problem
Its a bit weird but it drops nothing
I will send you an video soon
here is my piston
What version?
can this output something like 95.4?
DecimalFormat df = new DecimalFormat("#.#");
?
Welp, that was about the easiest plugin I've wrote.
Sure. Or
double value = ...;
double cutValue = (int) (value * 10) / 10D;
i just want to limit to 1 digit after the dot
Thats what the code snippet ive just sent does.
You can also use string.format
how can i check if two entites collided with each other
Only by using custom nms entities i think. You need to overwrite the collide method.
And then checking every entities BoundingBox every tick? That sounds expensive.
bytecode manipulation time
well um
i dont think
i can make overwrite
a real players
code
so
a falling block and a player collides
can't you just check if the fallingblock is within the distance of 1
basically
i need the falling block damage the entity it hits
jesus. i cant explain anything
i need the falling block damage the entity it hits
but yeah, this.
EntityDamageByEntityEvent or EntityDamageEvent
i think EntityDamageByEntityEvent
I imagine that is fired
Which allows you to store data on the entity to use for determining the damage
@EventHandler
public void onDamage(EntityDamageByEntityEvent e){
if (e.getDamager().getType() == EntityType.FALLING_BLOCK){
e.setDamage(5);
}
}
like this then?
oh yeah
so i should check
if i its not an anvil
or a chipped anvil
or a damaged anvil
I tried following a tutorial how to do worldgen but the plugin for it won't generate, anyone how how to fix that?
@EventHandler
public void onDamage(EntityDamageByEntityEvent e){
if (e.getDamager().getType() == EntityType.FALLING_BLOCK){
FallingBlock fallingBlock = (FallingBlock) e.getDamager();
if (fallingBlock.getBlockData().getMaterial() != Material.ANVIL || fallingBlock.getBlockData().getMaterial() != Material.CHIPPED_ANVIL || fallingBlock.getBlockData().getMaterial() != Material.DAMAGED_ANVIL){
e.setDamage(8);
}
}
}
so this is good?
aight imma try
1.16.5
use return;
etc
You want to download the API?
?stash
I guess?
you could check if string of the block type ends with ANVIL
🤨
how can I add a delay in my code so the server doesn't crash with a large loop?
What do you mean?
Let's say you have a loop that does 100k iterations
you make it do 1k iterations every tick
Anyone know how I can make this shape into a circle as right now its like a weird shape that doesn't resemble a circle.
Location loc = player.getLocation();
int points = 5;
for (int iteration = 0; iteration < points; iteration++) {
double angle = 360.0D / points * iteration;
double nextAngle = 360.0D / points * (iteration + 1);
angle = Math.toRadians(angle);
nextAngle = Math.toRadians(nextAngle);
double x = Math.cos(angle);
double z = Math.sin(angle);
double x2 = Math.cos(nextAngle);
double z2 = Math.sin(nextAngle);
double deltaX = x2 - x;
double deltaZ = z2 - z;
double distance = Math.sqrt((deltaX - x) * (deltaX - x) + (deltaZ - z) * (deltaZ - z));
for (double d = 0.0D; d < distance - 0.1D; d += 0.1D) {
loc.add(x + deltaX * d, 0.0D, z + deltaZ * d);
player.getWorld().spawnParticle(Particle.DRIP_WATER, loc, 50);
loc.subtract(x + deltaX * d, 0.0D, z + deltaZ * d);
}
}
?eventapi
Could anyone help me figure out a crash from a report? https://cdn.discordapp.com/attachments/876144468041007104/876530454898032740/crash-2021-08-15_20.16.58-server.txt
Something modified the world async
redirected him to support disc
how can i get where a falling block landed?
EntityChangeBlockEvent
when I change the facing of a block the block drops itselfs. So when I change the facing of a powered piston the piston drops. Can I disable that?
You sure that's not one of your plugins
Maybe you get the center of the player, use a radius of choice calculate the points based on location of the player by the radius with x angle and repeat
how do I make a command give me a noteblock with custom blockstate?
Is there a way to have ChunkGenerators from different versions of minecraft ? I wanna have a world with 1.17 generation and one with 1.16, is it possible ?
You would have to port the ChunkGenerator yourself
Like create it manually with all the generateNoise and all ?
Is one of mixins usages to pretty much add new stuff to methods?
player.getInventory().addItem
for noteblock its not possible since its for blocks
You will have to use NMS for custom blockstate (by which I assume what note it is on)
So, I'm trying to make a command with a start and end function to it(ex. /tag start, /tag end). When I use this:
plugin.tag.tagged(plugin.tag.pickFirstIt());
}
else if (args[0].equalsIgnoreCase("end")) {
plugin.tag.end();
} else {
player.sendMessage(ChatColor.ITALIC + "" + ChatColor.RED + "Incorrect!" + ChatColor.WHITE + " Try /tag <start/end>");
}
}
sender.sendMessage(ChatColor.WHITE + "You can" + ChatColor.ITALIC + "" + ChatColor.RED + " NOT" + ChatColor.WHITE + " use that command!");```
It tells me that the command doesn't exist, but when I type in `/t` it gives me the option to autocorrect to the command...
Also, when I do `/plugins` it tells me there aren't any plugins...
Can anyone help?
NMS is what? and how would I use it?
NMS stands for net.minecraft.server
there are quite a lot of tutorials to work with it
check error in console
I don't think there are any
I might be looking in the wrong place, where would I find that?
latest.log is found in the logs folder
I'm trying to send some inventory information on the client side only, what event should I be looking at?
client.getInventory(player).show().continue()
How to turn a redstone lamp on if REDSTONE_LAMP_ON doesnt work?
redstone block
I mean.. it should be possible to do without?
Pretty sure it won’t compile
ChatColor.stripColor just removes color codes? :))
and does it remove & also if it's the case?
Yeah
Does player switched world event get called if a player joins the server?
This is the first time I've done something like this, I really just want to edit NBT data that the client sees
if I print a entitys name will it print out it's custom name or default name
you guess
wow thanks
ya i just made that up on the spot
Hello i have a question how can i chance the blockbreak speed in 1.16.5
any ideas?
and how
thx i will test that
what are some cases when you would have to use net minecraft server
bump
I'm trying to modify NBT data of some items of players ONLY on the client side
Do you know if that's included in the API?
I'll look into NMS then
Because I've been killing myself over the docs
?
nah ur gonna have to fuck with outgoing packets
that's what I've been thinking
Give me an example
Is there an outbound packet event?
e.g. strip all shulker box data
or make it so that all players render having an enchantment effect on armor/items
I can do it via packets ez
PacketPlayOutEntityQuipment u send it only for player
equipment is just inventory no?
Yeah I can do the packet stuff no problem
Do you have a link for modifying NMS?
wonderful
thank y ou
how would i add a tab complete to a command thats being done via commandpreprocess?
?paste
This was a really interesting question so this is the answer https://paste.md-5.net/umerucahuz.java 🙂
How do I implement a custom format from a config string into CustomDateFormat?
with system currentmillis?
Date date = new Date(Premium.getLong(your config millis));
String mm_dd_yyyy = (new SimpleDateFormat("dd.MM.yyyy")).format(date);
String hour_min = (new SimpleDateFormat("HH:mm")).format(date);
did you mean this?
How can I make particles despawn faster?
I mean I want to read the format from a config
can I move them?
well you can spawn it again somewhere else
So the user can set the format for themselves
just replace the string with whatever the user wrote in the config then
Config:
date-format: "yyyy MM dd HH:mm:ss z"
Code:
public static SimpleDateFormat dateformatter;
dateformatter = new SimpleDateFormat(config.getString("date-format"));
dateformatter.setTimeZone(timeZone);
String date = dateformatter.format(unix * 1000L);
With this code, the format of the displayed date should change, but it doesn't, displaying yyyy-MM-dd HH:mm:ss z
What do I need to change?
How do I do that? Change the location of it?
yeah but the previous particle won't clear
the server can't tell the client to forget about a particle
you'll have to pick a short particle
ok
Thanks :)
Anything to that? 😦
don't see anything wrong with ur code
maybe load the config before?
it doesnt do anything tho
that'snot very descriptive
it is loaded, all other messages work fine
the date format is always the default one
maybe put the dots between yyyy.MM.dd
shouldnt be doing anything as the function only replaces yyyy etc
anyone know how to extend the world generator to add some custom generation/prevent some generation. such as prevent certain blocks from spawning and spawn other?
i suppose try logging the format returned by the config call then
there is definitely some guide you can follow on spigot if you google it
i've been trying, but all i've found was just grabbing each chunk before it is loaded and editing it from there, and that is lagging my server horribly
if i can edit the generation directly it wouldnt be laggy, cause rn its building each block and then grabbing each block again
its basically generating a chunk twice before loading it rn
Anyone reviewing my code? Would appreciate it 🙏
https://github.com/deroq/ClanSystem/
your module structure is very confusing
is ClanSystem-API supposed to provide an abstract version of the plugin or something
because you have server-specific bindings in that moudle
A function should only do one thing, a class should only change for one reason
API’s are made to provide interfacing not implementation
Encapsulate your fields
Don’t have static unless you very much need, just because you have one instance of something doesn’t inherently mean a static singleton is the right design and it doesn’t go well with object orientation
Use more explanatory variables
Don’t mix command and query methods, as mentioned before functions should only do one thing
(We can also talk about that every line in a function should be the same level of abstraction but probably going overkill here)
Enterprise™️ClanSystem
😌
Having no return in those if statements is making me nervous for the ClanCommand class.
I know it is fine but hmm
Myes that function is like the horizon of Madagascar or something
And no it’s not fine
I will find you if you write long functions that do more than one thing
It’s fine when we write the code
But we shouldn’t leave it in such state
So once we get that code to work, simply put some effort to clean it (:
I would do dependency injection for the PluginManager
Myes that’s a good choice probably
Myes :3
:3
So many private function calls, also a big nein
Yeah but it isn't utilised more than once?
what's the opposite of Myes
That might not be the point of it
Why create a function that you only use once
Mno doesn't have that ring to it
Readability
It’s polite to the reader
killConclure() reads better than KillManager.getInstance().getKillable("Conclure").execute()
And no you won’t drown in a pool of private functions
Because you will name those functions and put them in appropriate classes and packages and so on
I guess it is just personal preference.
You’ll end up with this nice semantic hierarchy of functions
The functionality inside the scope is the same for all of them.
That’s not the point
It provides the reader what’s happening in a function at high level detail
And subsequently the reader can exit early
Its just better programming
I have a quick question that I can't seem to find the answer to in the docs or on the forums
how can I determine if a player was killed by an entity that is NOT a player in the PlayerDeathEvent event
I can see if they were killed by a player using getKiller() but how can I determine if a mob killed them
trying to only run my code if they died to mobs
I see that there's getLastDamageCause() but how can I be sure I get every mob with that?
Player Death event
then get killer
instance of EntittDamgeByEntityEvemt
and instance of Monstor
doesn't getKiller only work if it's a player?
killer returns only player
oh
see this
how would I determine inside of this event if the damage was fatal though
sorry if that's a stupid question, first plugin
well it’s the last damage cause
Guys is there anyway a player sees a different time than another. Like in my screen it is sunny but in another players screen it is night.
yes
nms
Good luck 🙂
thank you >)
declaration: package: org.bukkit.entity, interface: Player
that method has existed for years
😮
@unreal quartz
What ver is 2011
literally a decade
it was one of the first methods added to bukkit
LMFAO
I should delete all the ugly nms
haha
Mb just too many player methods, I skipped over it
if you use a world#spawn method and store a reference to the living entity you're spawning, but then that spawn gets cancelled, does the #isDead() method return true for the living entity?
i don’t think so
Probably not
ok how can you tell if a living entity went through the spawn event successfully ?
because isValid is doing some weird shit as of 1.17
does world have a getentity(uuid) method? because you can try that after
it would just be a loop
ping!
why would it be a loop
thats literally what getentity would do
you’re testing if the world contains an entity from a uuid
if a plugin cancels the spawn event, the test will be false

is there no field in the living entity that would indicate that it is... valid... but also isn't the currently somewhat broken isValid method
Thought it worked absolutely fine
?stash
me too until I realized that on world load every single entity that spawns in a chunk load is convinced it's not valid
Oof
well not every single entity, actually it was much worse because it wasn't quite that linear
there's something weird about 1.17 chunk vs entity loading I swear
Haven’t tried so can’t tell but yeah what lmbi said might not be a bad approeaxh
I sort of wanted to avoid querying the world for performance reasons if I could avoid it
hm
I'll do some further tests for now, thanks for the help
Cheers
anyone know how to remove biomes from spawning in a world?
nvm
"java.lang.reflect.InaccessibleObjectException: Unable to make boolean java.beans.FeatureDescriptor.isTransient() accessible: module java.desktop does not "opens java.beans" to unnamed module "
what is this error
just raise in this save expression
Well, it looks like someone's trying to reflect a class from java.beans but the module system is prohibiting it as java.desktop doesn't open it for reflective access.
"unnamed module" probably means that the module performing the reflective operation either doesn't have a module descriptor or is from a pre-Java 9 version.
Looks like the issue is with snakeyaml.
yes it is spigot 1.12.2. how to fix it?
Give me a second, just found a Bitbucket issue related to this.
snakeyaml might be outdated with (your version of) Spigot 1.12.2 actually.
/gamerule spectatorsGenerateChunks false
Yeah spigot 1.12 doesn’t support modern java
A'ight then, so, xogh, you're probably going to need to downgrade your server's Java version.
okay
i think you can do that only with NMS
As stated previously.
how do we do player ranks? like having icons in-front of player names in chat and in tab
What do you mean by 'icons'? You can only use the unicode chars that are supported by minecrafts font.
does canceling EntityToggleSwimEvent make the player swim more slowly? Visually it looks the same
(please reply or @)
like what Origin Realms does for example
The use resourcepacks for that
To alter the font and add icons
can anyone help me increase the chanches of happening?
it should be 5% now
i need like 50%
what about to add the character in-front of the name?
Not too hard to implement but a bit tricky if you want to properly link it with your plugin
The client only has a limited amount of characters in his font. If you want to let him see more then you need to
provide him with the textures. This is done with a resourcepack.
ik about that, I already have the font thing ready
it's just the part of adding it to the name I have no idea about
One example:
@EventHandler
public void onJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
final String playerName = player.getName();
final char customChar = TextureModel.KILL_QUEST_ICON.getChar();
final String listName = "§f" + customChar + " §e" + playerName + " §f" + customChar;
player.setPlayerListName(listName);
}
Which results in:
But you need to use your own custom char for that.
and that works in both chat and tab? does it include tab-complete also?
This is only for the tab list.
You usually dont want to autocomplete or select custom names but the players actual name.
You should toy around with methods like Player#setCustomName(String) and Player#setName(String)
hm
there is and i imagine that you should probably just google it as there are likely a million examples
need help
any easy/non-regex ways to get list/array from a yaml config like this:
arr: [1, 2, 3]
You will need to use PacketPlayOutEntityMetadata to make a player glow using packets
i am not trying to make a player glow, i am trying to make an EntityFallingBlock glow
Split on "," on the substring indexof('['), lastIndexOf(']')
If you can use snakeyaml use it - it Supports getList iirc
So I have like a weird issue, this issue is sometimes happens and sometimes not, basically the issue is when player go in the water, armor stand that rides them will dismount automatically, and I won't that to happen (client side armor stand)
I'm still stuck trying to do this :P
<#help-development message>
EntityDismountEvent?
nvm you cant cancel that event I think
or just on dismount mount them?
You can cancel that event, it's fixed in 1.16.5, and I can't do that because the entity is client side.
how is the entity client side? 🤔
It's created with packets
how can I make this thingy?
https://www.youtube.com/watch?v=zXuF3L0pHC8
hello , am trying to get the group of a player
with this :
public static boolean isPlayerInGroup(Player player, String group) {
return player.hasPermission("group." + group);
}
but since op players have all perms it will always return true if the player is op
how Can I get the group of an op player?
Op doesn’t possess a group
OK then let's say in a server there is admin group and owner group and both of their members are op'ed
how can I check if that player is an admin or an owner ?
ops will always have the permission group.<string here>
^
that's what am saying
i'm pretty sure there is a way to do it by hooking into the luckperms api, assuming you're using luckperms
I am
any1?
probs a question for the luckperms discord then
LP heavily discourages OP anyways
Something is going terribly wrong with my intellji when i import the spigot project my IDE refuses to import the dependencies or plugins causing massive errors inside the IDE however maven is able to compile
Pog my IDE wont even recognize files within the same project
Time to conceed and invalidate and reboot 😦
soo I am getting this Error
and Idk why
can any1 tell how can I fix it?
:evo_shin:
Why no files are allowed :V
👌
instead of saving all slots of an inventory to a file shouldnt i just save the ones thats arent empty?
myeah
probably save it as a map
ie <Integer, ItemStack>
where is it slot number to the item
obviously you would need to deserialise
yea
Use an array for stuff like this, @tardy delta
well
it depends
if they want to keep the slot of the items
then a map would be needed
Still an array
You’re saying an array won’t let you know the slot?
Why do the null ones matter?
If (stack != null$
map is more expensive
Quicker especially for something that is index based like inventories. Cleaner and more proper imo
but i thought - for their usecase - it would be necessary
I still say array def for something like this
Same shit man
Just forked spigot
Still spigot
I assume people would use paper in 2021
no friendhsips allowed
congratulations on winning the award for worlds worst colour scheme
How do I make a mob not pushable and not moveable?
I mean yea that’s fine you don’t have to create the inventory everytime but that’s fine too
wtf
thats onedark
and it looks awful 🙂
What do you use?
the default
in vscode i also use the default
Imagine having a pointless argument about themes in a help chat
i don't see any arguing happening here
imagine shutting the fuck up
Imagine not being verified and talking shit
i changed it to Map<Integer, ItemStack[]> but i also need an uuid from the player and that isnt static 😦
:what:
UUID of players are always static if they would be not id be concerned
but i mean
UUID = Unique User ID
its in a command
:what:!
static != final
^
?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Stupid bot 😦
???
What are you trying to achieve?
:derp:
What’s the keys purpose here?
oh wew just ItemSTack is better btw the key is the slot
Lol what
static != final
i could store a map in a map but that goes brrr
And you need like a player to identify who's inventory is that?
Table
final means it cant change
Just make an itemstack array man.
yea thats why i said a map in a map goes brr
figuring out other way
It's not?
static means you dont have to call it on instance of that class
Just use Table, instead having a map inside a map.
hmm never used it lemme see
I'm guessing he want to store player's inventory contents.
not if it is private
static = belonging to a class rather than the instance
how do people not know this
but then i cant get to which slot that item refers and cant check if the item is air
but they are helping people with it
Could work, but he want to put the slot too ig, and that's better.
thats the point
I phrased it wrong i meant that the UUID is cannot be changed
I thought he wanted to modify the UUID
no
The array handles the slot?
im not really sure on that
What bro?
i'm making a private vault for players to store there stuff
i save the items in a file
Arrays are index based?
an inventory's contents is literally represented by an array
but dont want the empty ones
i mean i know but i haven't do anything with that
huh?
so i thought lets make a map with integer and the itemstack and check if that item is null or air
could you not use an inventory?
do you understand?
Then why talk against what I say lol?
arrays are programming 101 in any language
yes i think i do
i didnt know that the array is the slot, i thought it's skipping the null/air items
i mean index
If you don’t set it then it’ll be bull
well now you know
annd i dont want null in my files
why not
how else will you represent a missing item
what kind of file is it
If (stacks[i] != null)
i want to save like 1: leather
That simply
and how will you save the amount or any of the item meta with that
so just plain text?
something like that
itemstack is serializable, you can just write the array and it wilk be handled for you
i had it like this and the nulls go brr
will a user be looking at this file?
no
you seem to be trying to solve a non-issue
He’s just trying to fix his design I understand
i don't really understand why you want to go write your own method to save the contents when you can just use the one which is literally built in and done for you
You can yea base 64 for saving it to databases
if you really want to you can set each key and value manually, but why go through the hassle to save a few nulls?
i have something like this
for (Map.Entry<Integer, ItemStack> entry : inventories.entrySet()) {
if (inv.getItem(entry.getKey()) != null && inv.getItem(entry.getKey()).getType() != Material.AIR) {
ConfigManager.getDataConfig().set("safe_chests" + p.getUniqueId(), entry.getValue());
}
}
is there any way to do something that can throw an exception, without the ide telling me to use try/catch? i mean, the editor doesnt tell me to use try/catch whenever i use an object that can be null and that can produce null pointer exception, or something like that
runtime exceptions are unchecked
wrap whatever it is inside a runtime exception and it won't throw a compile time error
of course you sohuld probably document what it will throw and when
if its your own then you can subclass RuntimeException, or just throw a new RuntimeException instead
yea, its my own exception
what about assert? does that kill the server or something
should i use it besides for just testing
Guys I'm made a custom rank sys and i want to show the Owner rank on the top of tab list
( I don't use luckperms)
and debugging
assert is useless if a specific flag is not set, which in production environments it is not
your program will be stopped if the assertion is false
can you show some code?
so its not just one more exception, it will kill the server
You need to make something for custom tabs using playoutinfo packets I believe
Or teams
wdym?
an AssertionError is thrown which in most cases will not be caught, spigot will probably catch it but whatever your plugin was doing likely wont
Can any one answer me ?
essentially why go through the hassle
Guys ?
pretty sure its sorted by team score
maybe i could save in some sort of database
your question has been asked 100 times on spigot before and i can guarantee some googling will get you the answer
have you listened to anything hes said
Okay @unreal quartz
does that work?
I googled it and didn't find it @unreal quartz