#help-development
1 messages ยท Page 2293 of 1
๐๐๐ฆ๐ฑ ๐ฆ๐ฐ ๐ฑ๐ฅ๐๐ฑ ๐๐ค๐๐ฆ๐ซ๐ฐ๐ฑ ๐ฑ๐ฅ๐ข ๐ฑ๐ฌ๐ฐ?

\๐
check if clicked inventory == inventory
also the inventory type is PLAYER
?
== not equals ig
if(event.getClickedInventory() == event.getInventory())
or .equals doesnt matter really
Fireball.class
is there a way to increase the explosion radius of this?
yes
listen for it hitting
cancel the explosion of it
create one your self
and create one
yes
okay
I'm using negative sized slimes and armor stand markers to create nametags, but whenever the entities are unloaded, either the entities despawn and the nametags don't, or somehow they seperate from the nametags. I'm tracking a
I'm tracking a EntityDeathEvent, but is there an event to track for despawns?
(yes, i looked)
Alright I got it thanks.. time to just fix the cooldown now
Explosion power/yield affects the range of the explosion
good luck with that
that is overcomplicating things lol
just set the explosionpower
what version that thing is added
not sure, it's been around for a while now
i've used it since 1.16
Hey how do I make a infinite firework and it only expload on someones first join ?
You don;t. Fireworks, like all Particle effects are timed
they have an animation sequence
Can I make a particle effect for it ?
You can define colours etc as the Firework API permits, but you are limited to what is in the API
can I make a new API ?
No, you are talking about Modding the client and server
how about a message like a boss bar for a couple seconds ?
is it possible to send commands to another server? all of the spigot servers are bungee instances
Look up Title and subtitle
how to get killer of player if killer == mob?
i need the name of the mob that killed the player
getLastDamageCause
then I get the name of the player who died, not which killer
of course, getEntity is the player
check if the event returned is an instancof EntityDamageByEntity
cast it
why dont you just use the default config?
many plugins provide default settings when just installed
whats even the point of that plugin, im not fully understanding the question
it tries to get an uuid that doesnt exist?
imagine your ip changing :(
does for (;;) and while (true) compile to the same bytecode or is there a significant difference?
i guess just put the uuid in when the player joines
and save it
im not understanding then
use while true
same bytecode
jvm optimizes it the same
i would when writing my own code
i just keep finding for (;;) loops in nms
Probably an ofustication thing
use zeros
how can current be null?
^
Why are you implementing a linkedlist
owh ye i see
smh nothing better to do
and my brain is dying
yes but current.next can be null
braindead atm
im wondering why first isnt cleared too?
Hey guys, i am making a better tp command and im getting this error https://paste.md-5.net/torulesihu.cs not sure where it is from, heres my github https://github.com/horizonstudiosmc/horizonessentials
Whenever you are done with brush
hmm i guess i need to set first explicitly to null but why is last set to null automatically?
DEBUG: first: Node{value=null, prev=null, next=null},last: null
never ever do ```java
new MyMainClass()
who we got there ๐
oh yeah duh
now im getting java.lang.IllegalStateException: Initial initialization
im not sure what part of the process the error is happening though
Then send the stack trace. It tells you exactly where its happening.
HE.java:11
The first 20 lines of your class pls
You used the reload command didnโt you?
i used a main class constructer there
Nah thats forbidden and everyone knows that. Especially devs.
You are getting an initialization error, meaning that you probably used a reload command.
Or an exception was thrown in the constructor or a static part.
Normally itโs not a big deal for most plugins, but it definitely causes weird behavior. There are a number of things you would need to account for on a reload.
Well not in a static part
prob that
Show your code then we can tell
< here > public class HE extends JavaPlugin {
public static HE instance;
@Override
public void onEnable() {
// Plugin startup logic
instance = this;
saveDefaultConfig();
getCommand("tp").setExecutor(new NewTeleportCommand());
getServer().getPluginManager().registerEvents(new NewTeleportCommand(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
public String getPrefix() {
return ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix"));
}
}``` heres the main class, also its now on line 7 where the error is
Oh look. Static

i can add a constructer if that would help
Well, you donโt need a constructor for your main class since, if it extends JavaPlugin, it will be a singleton instance.
Thats such a weird error... Do you use PlugMan?
I guess a normal reload could cause it as well.
Anyways dont reload anything.
for the other classes
no
In your other classes you get the instance through the static field
mhm
I think those would be fine though? I have a static instance of my plugin and I use /reload all the time without issue. Granted I am getting the instance using JavaPlugin#getClass() instead of his approach.
He is probably instantiating his JavaPlugin class there or doing some other shenanigans in his command.
here ill give u the github
hello im tryna change a 1.8.9v mod to a 1.12.2v but i cant find mcpbot's version, the website is down "export.mcpbot.bspk.rs"
can anyone help me please ?
player.playEffect(EntityEffect.TOTEM_RESURRECT);
Also some particles.
Im new to making plugins and i want to make one where the longer you crouch, a bigger explosion happens when you uncrouch. Right now all I know how to do is make an explosion happen immediately after crouching. Can anyone help?
What made you think that this channel is the right one to ask this question in?
Do you know what a HashMap is?
No
why the main class name
looks like something you use in generics
it stands for horizonessentials
i just saw it
Then go learn the java basics before jumping into spigot pls. You wont come far without knowing at least the very basics.
why public static
also the listener isnt working anymore @lost matrix
private static then getter
let me figure out why its not working now...
@lost matrixso it opens the gui, but the listener doesnt cancel the event
or do anything
debug it
@fleet comet what is the problem
where should i post my question ?
Anyways here is the general approach:
Use a Map<UUID, Long>
When a player starts crouching -> put his UUID and the current unix timestamp in the map.
When the player stops crouching again -> get the timestamp from the map and calculate the delta to the current time.
Then you will know exactly how many milliseconds the player crouched.
Is it a forge or a fabric mod
Oh my days
forge
i registed the wrong event class
@fleet comet the event is not registered
Then in the forge community
ah ok mb
WHY YOU GOT TWO LISTENERS IN ONE CLASS
?
WHY YOU HAVE NEW IN THE FIRST OF YOUR CLASS NAME
do they have a discord server ?
what are you talking about
i think so
the code is not clean
I WANT IT TO WORK FIRST DUMMY
and i hate an unclean code
no one names a class NewBlaBla
oh i guess someone did
YOU
im just triggered of this code
better for me to head out
Show yours then. Im sure i will have to say a lot about it too.
Let this guy write his code. He is just starting out.
oH nO hE AdDED โnEWโ bEfOrE cLaSs nAmE
newteleport... cause its a new teleport system dumbie
MAKES SENSE
YEAH
dude please don't open my github
and don't go to banswebhook
and don't go to the velocity thing
and ignore me registering commands in the constructor
โค๏ธ
mhm
Better fix ur own code before trying to criticise others. And if you do, do constructive criticism
okay i pushed the new code, its debugging test but it wont cancel the event
you registered the listener ?
thats just basic naming conventions
and registering listeners in different classes is much cleaner
When using NMS, what jar should be the best for NMS after compiling / decompiling from BuildTools?
COOL. Use constructive criticism to correct them. Not bashing their head
what is that
Constructive criticism?
yes
Why do you have a constructor that takes a player?
You should never create more than one instance of a listener.
Also: You are not registering all the listeners you are creating with your players.
Normal criticism: Hey yo your class name is trash
Constructive criticism: standarts of naming a listener class is blah blah blah. Its better to use standarts
Use the maven special sources plugin
too lazy for that
well the class that has the listener is the gui class that extends the horizon gui
just take it as constructive thanks
Then thats a you problem
Oh okay, what IDE is that for?
https://www.spigotmc.org/threads/spigot-bungeecord-1-19.559742/
Scroll down to the "NMS" section
Thank you!
my code is trash ;-;
i think i fixed it
This makes no sense whatsoever. You should have one listener that handles all your guis.
im not sure how to implement that
Ew. What you doing? Tree? LinkedList?
E e
i was bored so i decided to write my own kind of linkedlist ๐ค
Doubly or singly linked?
doubly
public class explosion implements Listener {
@EventHandler
public void onBoomBoom(EntityExplodeEvent event) {
FallingBlock fb;
Location loc;
for(Block b : event.blockList()) {
fb = b.getWorld().spawnFallingBlock(b.getLocation(), b.getType(), b.getData());
loc = event.getEntity().getLocation().subtract(b.getLocation());
fb.setVelocity(loc.getDirection().subtract(b.getLocation().getDirection()));
Bukkit.broadcastMessage(color("&A&lLOCATION VECTOR: " + loc.getDirection() + "\n &b&lLOCATION: " + loc));
}
}
}``` Why are the vectors always the same if the location is different?
poor brush
how?
and then cipher started talking about triple linked ones ๐ฅบ
Was he messing with your?
๐ฅบ
That is not conform with the definition of a list. Thats a tree.
ye
anyone please ๐
ah yes we write class names starting with a lowercase letter now
@lost matrixdo you know how i could do that?
java has come so far...
- idc about pascal case
- how does that help with literally anything
- why would u ping me for that stupid shit
your "loc" is always going to be really small.
dunno what pascal case is, just follow conventions
im trying to make the blocks fly in the opposite direction of the explosion
So pulled towards the Entity that invoked the explosion?
pushed away from
Alright one moment
@EventHandler
public void onExplode(EntityExplodeEvent event) {
Location baseLocation = event.getEntity().getLocation();
World world = event.getEntity().getWorld();
for(Block block : event.blockList()) {
Location blockLocation = block.getLocation();
Vector pointingAway = blockLocation.toVector().subtract(baseLocation.toVector());
pointingAway = pointingAway.add(new Vector(0, 0.2, 0));
FallingBlock fallingBlock = world.spawnFallingBlock(blockLocation, block.getBlockData());
fallingBlock.setVelocity(pointingAway);
}
}
@lost matrixcan you help me now
how to Component to string?
Create a manager class that contains a Map<Inventory, YourGUI>
And every gui handles its own events. Then in your listener you get a gui from your map and pass the event to it if the gui is mapped to this inventory.
huh? sry thats super confusing? ho wwould i do the second part?
skill issue
๐ค
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
This is a very basic setup and its still missing some parts but it paints the general idea:
public interface IGui {
void handleEvent(InventoryClickEvent event);
}
public class GuiManger {
private final Map<Inventory, IGui> guiMap = new HashMap<>();
public void setGui(Inventory inventory, IGui gui) {
guiMap.put(inventory, gui);
}
public IGui getGui(Inventory inventory) {
return guiMap.get(inventory);
}
public void removeGui(Inventory inventory) {
guiMap.remove(inventory);
}
}
@AllArgsConstructor
public class GuiListener implements Listener {
private final GuiManger guiManger;
@EventHandler
public void onClose(InventoryCloseEvent event) {
guiManger.removeGui(event.getInventory());
}
@EventHandler
public void onClick(InventoryClickEvent event) {
IGui gui = guiManger.getGui(event.getInventory());
if(gui != null) {
gui.handleEvent(event);
}
}
}
my gui class isnt an interface though
So?
i'm always having a gui class that stores an inventory object and listens for the click event, then checking that inv instead of checking the map
should i use horizongui or the extended gui class instead of igui?
You can do whatever you want. Ive shown you the general idea.
horizongui is the abstract class though, i dont think that would work
7smile7, is it bad to register a listener for each custom inv object? ๐๐
Why though
i would think so
You should avoid it. Registering listeners on runtime is not cheap.
mmh ye what i was thinking, better off using a map then
And it can lead to cpu and memory leaks
Make a custom impl to map these things
how to item.displayName() to TextComponentImpl? (now it is TranslatableComponentImpl)
i already made enough memoryleaks, no more for today
Not using Rust moment
๐ฅบ
please help
When a player switches worlds, I need to get their last location in the world they switched from. But when I get the event PlayerChangedWorldEvent, the from is a world, and the players location is the current location in the new world, which could be different because of spawn plugins. How could I track where the players last location was in this world?
What if you use PlayerMoveEvent, compare if getFrom world doesnโt equal getTo world
I think the PlayerTeleportEvent is fired. You just have to check if the "from" world is different to the "to" world.
I will try that, thanks
can blocks hold meta data when they are placed? I want to create a crafting table that is needed for some recipes, and was going to identify it by meta data. can placed blocks hold meta data?
how do i send a subtitle to a player
player.sendTitle("", ColorFormat.colorize("&aUse &7/family setname &ato set the name."), 10, 70, 20); this doesn't send anything to the player
@lost matrixnow how do i add guis ```java
NewTeleportGUI teleportGUI = new NewTeleportGUI(player);
GUIManager ???
i do not know how though
pretty sure you can go to the next line with a line break
@lost matrix whenever ur ready
Hey everyone, my gui is null for some reason, heres the github, the code is on guilistener class
https://github.com/horizonstudiosmc/horizonessentials
im not sure why
simple. ur creating a new GuiManager to add it
thats not how it works
how does it work then
yea
right now ur just adding it to a new GuiManager
and that GuiManager is just gonna be garbage collected
I know using PlayerMoveEvent is heavily advised against, but I do require it in one of my plugins. Would the following code cause any issues performance wise?
@EventHandler(priority = EventPriority.HIGH)
fun onPlayerMove(event: PlayerMoveEvent) {
if (!config!!.getBoolean("environment.fall.use-actual-fall-distance")) return
val player = event.player
val yLocations = getYLocations()
if (!yLocations.contains(player)) yLocations[player] = player.location.y
if (player.fallDistance == 0F && yLocations[player] != player.location.y) yLocations[player] = player.location.y
}
๐
yLocations is a HashMap<Player, Double>
what does getYLocations do
get that hashmap
ye show how
it's inside of a companion object
companion object {
private val yLocations = HashMap<Player, Double>()
fun getYLocations() : HashMap<Player, Double> = yLocations
}
and it looks like this event should only be working if a config value is set to true
its better to not register the event at all if not needed
I thought of that too, but my events are registered on enable. Meaning that if a server owner were to change the config value, they would have to restart the server again.
Could add a command to reload the spawner feature and register it
well then just register it on reload
I guess that could work. But back to my first question, would that code cause any noticeable performance issues?
well how do you get the companion object
it's defined in the listener class
same class as the event function
Amazing. I can read
How does one make a config.yml file? Since it doesnโt really work the same as spigot
alright now i would make sure to check the player has actually moved
or do you need to track mouse movement
I only need to track vertical movement to be fair
well you should check if he has moved vertically
else just return
else this event will also be spammed when players just move their mouse
By comparing the event location.y by the stored y location in the hashmap?
i would do it by comparing the from location to the to location
if (event.from.y == event.to.y) return
alright
do you need it to be accurate
else you could check if the actual Y block location has changed
would cut down greatly on checks
I do need it to be accurate
hm alright. well i think it should be alright now.
I am setting the fall distance of a player to the value of the y level in the hashmap subtracted by the y level of the player when they hit the ground
Because falldistance is actually just how long a player is falling for
given a location and a vector, how could i get the first entity the ray made from said location and vector passes through?
this is my current code which only works if im inside the starting location
private fun raycast(starting: Location, vector: Vector, accuracy: Int = 5): LivingEntity? {
var loc = starting.clone()
val addVec = vector.clone().multiply(1 / accuracy)
val length = vector.length()
val nearbyEntities = loc.world.getNearbyEntities(loc, length, length, length)
nearbyEntities.re move(player)
for (entity in nearbyEntities)
println(entity.name)
for (i in 0 until accuracy) {
loc = loc.add(addVec)
nearbyEntities.forEach {
if (it is LivingEntity && (it as CraftEntity).handle.boundingBox.contains(loc)) {
return it
}
}
}
return null
}
private fun AxisAlignedBB.contains(loc: Location): Boolean {
return loc.x >= this.a && loc.x <= this.d && loc.y >= this.b && loc.y <= this.e && loc.z >= this.c && loc.z <= this.f
}```
any reason ur not using the built in raycasting ?
theres built in raycasting?

World and Entity both have methods
ya
thats neat ty
๐
@tall dragon Is there a way for me to unregister an event listener?
yes
PlayerMoveEvent.getHandlerList().unregister(Listener) i believe
is it possible to make a custom chatcolor? (from rgb)
1.16 plus yes
ok im using 1.16
Does that unregister all eventhandlers in that listener class, or just the one for playermoveevent?
the entire listener?
you just provide an instance to the listener class?
if (config!!.getBoolean("modules.damage") && bowsConfig!!.getBoolean("environment.fall.use-actual-fall-distance")) Bukkit.getPluginManager().registerEvents(PlayerMove(), plugin)
else PlayerMoveEvent.getHandlerList().unregister(PlayerMove())
in my reload command ^
and what is PlayerMove()
package me.bloedarend.pvpmechanics.listeners
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.entity.EntityDamageEvent
import org.bukkit.event.player.PlayerMoveEvent
class PlayerMove : Listener {
@EventHandler
fun onPlayerMove(event: PlayerMoveEvent) {
}
@EventHandler
fun onEntityDamage(event: EntityDamageEvent) {
}
}
Why is fun in there
eh im not that familiar with kotlin
you have to provide that same instance you use to register it
package me.bloedarend.pvpmechanics.listeners
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.entity.EntityDamageEvent
import org.bukkit.event.player.PlayerMoveEvent
class PlayerMove implements Listener {
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
}
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
}
}
What i'd like to know is, if I use PlayerMoveEvent.getHandlerList().unregister(PlayerMove()). Does it remove the entire listener, or will it still listen to EntityDamageEvent, but ignore PlayerMove?
well as you are removing it from the PlayerMoveEvent it only affects the PlayerMoveEvent
i think
best to just test it
sure
Sorry to interrupt...
Is there a way to run a synchronous-forced event asynchronously?
I want to run LeavesDecayEvent async, but that seems not possible.
You schedule it sync
If something needs to be run sync you can't run it async
hmm, that's a shame ๐ฆ
How do you go about making a hologram a passenger of a player? I've tried casting it into an entity since it requires the entity type, but it gives me an error
player.addPassenger(hologram);```
Sorry again but, I'm trying to register the event to a listener now, but it tells me this:
https://prnt.sc/-PhOXzc0hJJ2
Several users of my plugin reported increased resources usage on their servers.
For example; when 20 players cut down trees simultaneously.
Well running it asynchronously is not going to fix that
just got me curious, what was wrong with this code? i cant seem to find the issue
So I guess the question should be why don't you just register/unregister it in it's own class as to not worry about registering/unregistering other listeners?
You should get these users to create a Spark profiler for like 10 minutes and figure out why it's bogging down server resources and fix the method that's taking up so much time
Async isn't a performance solver
It's a performance hider lol

You can put makeup on a pig, but it's still a pig
But ExecutorService lets me have 1000 threads
but my celeron doesnt
I'd like to register/unregister it in a reload command class, depending on a boolean.
https://cdn.discordapp.com/attachments/931212161114587176/998986948490301622/unknown.png
That's a picture, that a users sent me
Yes, then why not put it in it's own class and just unregister that?
.88 seems kinda low to me?
why dont you just unregister all your events and register them based on booleans
You're doing a lot of weird collection operations in your onBlockRemove() method
Send all relevant code
(or if you have it on GitHub, even better)
fwiw a lot of the weight of that is the Block's #equals() method, but that's likely caused by how frequently you're doing #contains() operations (on an ArrayList no less)
which should be easily solved by having your own location object with a fast #equals check
Ideally, yeah. And use of a HashSet. Though it depends on what all the code is doing
Well, the best solution is to use the minimalist form of comparison possible
If you're checking a lot of .contains() use a hashmap instead
Hash*Set. But again. Code being used here is relevant
Ye
Here's the relevant class
https://pastebin.com/Db9N1DEk
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I am happy to hear ideas on improving
๐
Quick question: Is there anyway to flip an armorstand upside down in 1.19?
why do you annotate normal methods with @EventHandler ?
uh yea
OR a way to make armorstand move through blocks
Did remove the irrelevant annotations
Some notes on improvements:
Block#getType()should be called once and kept in a variable. It maps the NMS -> Bukkit type every invocation, so best to do it once, especially in hot code- Use of a
Set(HashSetspecifically) for thescheduledBlocks, and anEnumSetfor theNEIGHBORSfield would be ideal - I don't think the Collections#shuffle() is necessary because all sides are being iterated over anyways. No need for it to be randomly shuffled
- No reason to do anything asynchronously at all in this. Can remove any attempt at asynchronousy
Those changes alone will probably improve performance
I think the scheduling calls might actually decrease performance rather than increase it
That's what I mean. The asynchronousy is hurting you more than anything
Plus, if you delete it instantly you don't have to make sure it's still there/already queued.
Ah, I see!
Well that's a step forward. Thank you! ๐
you could set the noClip field to true via NMS
You could also make use of a Set<UUID> for your world collections instead. Though you then run into some issues of worrying about loading before world management plugins because you need a World instance to get their UUID, blah blah blah. It's fine. lol
I'll scrap that and try focus on the ideas
It should be possible but i just cant find anything
nametag it with DinnerBone? ๐
Yeah. This is one of those cases where even things as small as calling #getType() only once does make a meaningful difference
I think you cant nametag an armorstand
but your biggest pain point is just the #contains() operations. I think you can scrap those entirely if you remove the scheduling
a nametag is just a displayname as far as im aware
or atleast with dinnerebone working
Okay ๐
what is your code even supposed to do? cant rlly be bothered to figure it out myself
custom decay?
Faster leaf decay
how do i show custom text under a player's username
Yes, very much indeed ;D
well maybe load distribution could also be applied. what do u think @worldly ingot
if your changes are not enough
have u tried setting Marker to true?
Don't think the load distribution is necessary. Going async for this is really not at all necessary ;p
I just think personally that scheduling is going to cause more harm than good here.
I do VeinMiner entirely synchronously with zero performance hit
Are you .... using netbeans?
well i think simply being more carefull about what methods you call should indeed do the trick
Yessir
i think just using noclip is better tbh
its a lil annoying if u wanna go cross version tho
yeah dosnt matter
imma use noclip
ya know how? or are u gud
I might need to begin learning ant for one of my projects. Eclipse doesn't like me using JDT and gradle has absolutely shit documentation. Writing maven plugins is a can of worms I'd not want to open after I looked at their maven resolver
I dont know hot to work with NMs
well spawning an armorstand with noclip is rather easy luckily
but i got the command ig uess
i would just create a class, make it extend EntityArmorStand
public class MiniBlock extends EntityArmorStand {
public MiniBlock(Location location) {
super(((CraftWorld) location.getWorld()).getHandle(), location.getX(), location.getY(), location.getZ());
this.noclip = true;
this.setInvisible(true);
this.setInvulnerable(true);
this.setMarker(true);
}
}
for example
yo im making a data pack my issue is that my achievement trigger isnt working
maven is incredibly easy to understand normally given that it is XML. For gradle I have to agree
ah you need to run BuildTools
wym run buildtools?
?bt
https://www.spigotmc.org/wiki/buildtools/ it builds spigot for you and adds a repo for it into your local maven folder
understandable
already dit buildtools
did
Gradle is difficult but once you learn it you can do anything
well show ur dependency on spigot then
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
remove -api
There is a lot to learn especially when you delve into gradle plugins
Yeah, it's turing complete so 
refresh maven
Gradle in gradle?!?
yeah doing ir tn
yo im making a data pack my issue is that my achievement trigger isnt working
Something like that. I'm thinking of making a plugin to run a server environment in intellij
Ant was the go to about 5-6 years ago
very sparsley do I see people on here using eclipse
<-
How do you just get resource files from within a jar
NoClassDefError on YamlConfiguration
for example those servers which display hp underneath a player's username
@tall dragon why is it obfuscated
because mojang operates in mysterious ways
you can get it deobfuscated if you use a mapping
huh
yeah im using
.getHandle.
and people on internet say you should have like an option with
.getHandle().noclip
u need net.minecraft.server.v1_16_R3.Entity not net.minecraft.world.entity.Entity
thats just a modified jar not a hack lol
Hi guys. How to emulate player's chunk loading?
What I mean: There is a block in the chunk that starts working only when the chunk is loaded by the player. And when I loaded the chunk by world#loadChunk and created an NPC there - the block still does not work...
Details: https://www.spigotmc.org/threads/emulate-a-player-loading-a-chunk.565371/
forking stuff is definitly illegal
all you ended up doing was forking the jar an adding stuff to it lol
for forking bungeecord?
then why does it matter
still confused how you would think editing open sourced software is illegal
oh nvm i see
no lmfao thats not illegal to make plugins
bruh probably just used reflection
access classes from another jar file that may be private
etc
its a great feature of java
again make a class Extend EntityArmorStand
to create a custom ArmorStand
bump
why aren't you using mojang mappings ๐
use mojang mappings and you can see proper names
i rlly dont understand what ur doing. i did this in 1.16 and this is my whole class
public class MiniBlock extends EntityArmorStand {
public MiniBlock(Location location) {
super(((CraftWorld) location.getWorld()).getHandle(), location.getX(), location.getY(), location.getZ());
this.noclip = true;
this.setInvisible(true);
this.setInvulnerable(true);
this.setMarker(true);
}
}
worked fine
but ur not using 1.16 are u ๐
my bad abt that i got confused with someone else i was helping
well then you might indeed benefit from mappings
like said above
bump
Will teleporting snowball entities on every projectile launch cause any lag?
well that depends on how many entities are being teleported probably
and where they are teleported
Well, considering players can spam snowballs, it can lead up to a lot.
As to where they are teleported, about 0.2 blocks to the left
is there a way i can generate fake minecraft accounts
i need to test a feature with 5 players
Can I cancel a redstone event and then call it later?
https://paste.md-5.net/zanahuqobe.java Anyone know how to get everyone online onto the scoreboard?
I tried something in code but im not sure its right
List<String> playersatstart = new ArrayList<String>();
?learnjava
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.
List#add returns a boolean
dont patronise me i just forgot
Something you learn you should not forget it. Always if you learn it correct it
๐ค
ok
I've tried something similar to that, it doesn't work obviously, I'm just wondering how I get the delay?
I know how to do that, I don't know how to get the delay
?paste
okay, maybe this might help you get what im doing
its halting server activity and restoring it
this currently doesn't work all the time due to timings I imagine
I would something stupid, but what could cause me not able to use a specific maven dependency added to a specific module. I have to tell that im adding as dependency the module so i should be able to use it/call it....
Run asynchronously?
And I assume this will fix my timings issue?
I can't test it right now so its all theory
and you are accounting that to it messing up the timings?
Okay, well I will test this out later, thanks for the help
oh?
Maven dependency issue
Timings can also be wildly inaccurate if that is all you are going off of as well
default overall tick speed is 20, random tick speed has nothing to do with the game loop
it has to do with how often it chooses something randomly to tick
but really though, should stop going based purely off timings o.O
what problem is trying to be solved?
I mean the reason for needing to halt all redstone activity
which btw breaks stuff regardless
Frost can you take a small look on my thread please. Im a bit annoyed :D
it breaks bud switches for example
My main concern is loops
Its an optional feature anyways, so as long as it partly works I'm happy
loops are easy
just have to identify a condition to make it stop or make up a condition that would make it stop
or you can make use of schedulers or you can just make your own thread for it
I just did it I think
async tasks you mean, they are not quite threads ๐
Don't they use existing bukkit threads?
tasks != threads
same dif
its not
an async task just means it is broken up over a period of time, instead of trying to be completed right then and there
so if the server has time it will work on it
and then it might work on something else
and then the loop ends for the server, and then in the next cycle it comes back to it
until its finished
DONT JOKE with people that are learning...
yeah, you bully
I think I'm just forgetting something, but how can I have something always run? basically I'm trying to run something whenever a player is in direct sunlight, and I know how to do that part, but how can I always check for that? thanks!
no
As my father always told me if you wont help dont disturb
smart, thanks!
np
Also keep in care to do it async
God async is so juicy
anyways thanks for the help, im on the same time tomorrow I'll let you know how it went
Because someone times executing somethings can cause lag issue
I mean, joke with people, but make it clear it's a joke
wait how do I do this?
yeah async everything
you dont
running the async async, does that mean its sync again?
Can I check if a player can break a block with the rightClick interact event? Check for spawn protection, worldguard, towny, claims, etc..
hf checking for all these "etc"
Hm.. so maybe instead of right click I have them actually break the block and let these plugins cancel it before I do anything
You can send a fake block break event and then check if it gets cancelled
Hm? How to send a fake one
But keep in mind what consequences that may have
Construct a BlockBreakEvent and call it
don't 100% know if this is related to spigot, but I think it is to coding.
I have custom textures that I am trying to add, When added ones for an enchanted book because those are what my skills are, it adds it to all of the skill books, even tho they all have different ModelID numbers.. \
Such as?
Other plugins may do stuff with that event that you donโt want
A simple example would be logging plugins
Hmm okay I'll debug a bit and see if I have any issues, how does one go about constructing an event? Sorry a bit new to plugin development
new BlockBreakEvent
Is this fake by default? I guess I'm just not understanding that side of things lol
Well if youโre calling it when a block isnโt actually being broken, then yes
val cancelled: Boolean = BlockBreakEvent(b, p).isCancelled
if (cancelled) {
return logger.info("Cancelled")
}
Did I do something incorrectly?
I can still harvest even tho towny says no when I punch the crop
that is not java....
You use what you use, I'll continue to use what I use. The beauty of preferences and options
Is it possible to get isCancelled from the callEvent?
hey, how can I check if a player has nothing on their helmet slot?
i tried checking for null and air, but neither worked
it worked when I checked for a specific helmet, so it's not a different part of the code
how are you checking it
player.getInventory().getHelmet().getType().equals(null)
Does anybody know how to add a make a combat tag system, i tried to use this but it just doesnt work ```java
public List<Player> damaged = new ArrayList<>();
private int taskid;
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
damaged.add(player);
if (event.getDamager() instanceof Player) damaged.add((Player) event.getDamager());
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
taskid = scheduler.scheduleSyncDelayedTask(HE.instance, () -> {
int count = 30;
if(count <= 0) {
damaged.remove(player);
scheduler.cancelTask(taskid);
return;
}
count =- 1;
TextComponent message = new TextComponent("You're in combat for " + count + " more seconds");
message.setColor(ChatColor.of(Color.MAGENTA));
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, message);
}, 30);
}
}```
https://kanin.cannot.date/2022/07/19/KRlA this seems to be perfect thus far, I'll have to keep an eye on things and make sure nothing is funky, thank you!
don't use equals() for that
what do I use?
also, don't check the type, check if the itemstack is null
if (player.getInventory().getHelmet().getType() == null) {
stuff
}```
doesnt work
how can I do this?
remove the gettype
is there a way to add lore to a custom enchant? I know that it can be done manually with events, however is it possible to detect whenever a specific enchantment is added to a command. For example in a command (Essentials: /enchant)
Not easily
i would make a custom enchant command
Thatโs why I use packets for custom enchantment text
that executes the normal enchant command if the arg isnt one of ur enchants
wouldn't that make it only support one specific command? There isn't a way to make it dynamic huh?
bump
is there a way to check if a command is a default minecraft command?
wdym?
well minecraft:command
is from minecraft
is there a way to tell if it was a plugin command or one from minecraft in the preprocesscommand event?
does you want that runnable to run every second?
prob
well scheduleSyncDelayedTask() runs only once
and you also never remove the damager from your list
and the 30 at the end of the runnable is in ticks, not seconds
so it would run after 30 ticks
yeah i was testing
you would want to use scheduleSyncRepeatingTask
taskid = scheduler.scheduleSyncDelayedTask(HE.instance, () -> {
}, delay, period);
delay is how many seconds before it runs, period is how many ticks between runs
so if you want it to run every second, set 0 delay, period to 20 ticks (20 ticks = 1 second)
if you're using TextComponent, you could make ones for each color of the sentence
TextComponent has addExtra(TextComponent) which let's you add them together into 1
so you could make different ones with different colors and just add them together
I would check if it's == 0 instead
we need to see some code
so it doesn't display it
i used that
just incase
oh
?paste code
the code is above
public List<Player> damaged = new ArrayList<>();
private int taskid;
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
damaged.add(player);
if (event.getDamager() instanceof Player) damaged.add((Player) event.getDamager());
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
taskid = scheduler.scheduleSyncRepeatingTask(HE.instance, () -> {
int count = 30;
if(count <= 0) {
damaged.remove(player);
scheduler.cancelTask(taskid);
return;
}
count =- 1;
TextComponent message = new TextComponent("You're in combat for " + count + " more seconds");
message.setColor(ChatColor.of(Color.MAGENTA));
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, message);
}, 0, 20);
}
}
ill paste it again though
use this
okay next time
?
I the same for shorts codes
wdym @delicate lynx
I was wrong, use <= 0
hahaha loving lambda one-liners
public List<String> complete(CommandSender sender, Set<Argument> args) {
return args.stream().filter(arg -> !arg.getPermission().isEmpty() && sender.hasPermission(arg.getPermission())).map(Argument::getName).collect(Collectors.toList());
}
@delicate lynxhttps://paste.md-5.net/ihuzudenev.cs
You are setting it to -1?
any better for idea for making an invisble block? Atm im just getting the block and setting to air and them setting it back to the its type
oh
?
Your code literally says count = -1
var = var - 1
i prefer -=
....
I use countโ
@last temple im getting a conponent loop error now https://paste.md-5.net/munivataza.cs
Discord formatting count - - ;
Yeah i was thinking that right now
ill turn it into a hashmap
Always use uuid as key!
mmm.... hello am someone tell me why this appears?
this is the code
package info.miplugin;
`import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import info.miplugin.comandos.ComandoYoutube;
public class MiPlugin extends JavaPlugin{
PluginDescriptionFile pdffile = getDescription();
public String version = pdffile.getVersion();
public String nombre = ChatColor.AQUA+"["+ChatColor.GREEN+pdffile.getName()+ChatColor.AQUA+"]";
public void onEnable(){
Bukkit.getConsoleSender().sendMessage(nombre+ChatColor.WHITE+" Esta listo (version: "+ChatColor.LIGHT_PURPLE+version+ChatColor.WHITE+")");
registrarComandos();
}
public void onDisable(){
Bukkit.getConsoleSender().sendMessage(nombre+ChatColor.GOLD+" Esta terminado (version: "+ChatColor.DARK_PURPLE+version+ChatColor.GOLD+")");
}
public void registrarComandos(){
this.getCommand("youtube").setExecutor(new ComandoYoutube(this));
}
}`
?paste
๐ฎ
Open that url and paste the code there, press CTRL + s and copy the url
mmm.... no
so you dont need help...
๐
Atleast learn the correct formatting in discord
well here it shows that I put it
`main: info.miplugin.MiPlugin
version: 0.1pre-alpha
name: MiPlugin
conmmands:
youtube:
description: El comando youtube de MiPlugin`
is there a limit on the GENERIC.ARMOR && GENERIC.ARMOR_TOUGHNESS Attributes?
Im only getting 30 value when should be getting 80
what?
I EXPLAINED YOU
Whatโs wrong with using โโโplayer.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));โโโ
Pretty sure this also supports color codes instead of using multiple components
where?
Are u trolling or you dont understand english?
I talk spanish that why i ask to you (Hablo espaรฑol por eso te pregunto)
but i need it to look like this "&7(&ftime&7) &cCombat Tagged"
how would i do that?
with 2 compononts?
Why 2 components?
enerio? ยฌ_ยฌ
Yes but if want to talk in spanish dm me (i quieres hablar en espaรฑol escribeme al privado aqui no permiten hablar en ingles)
there can only be 1 color per componont
No you are wrong
You can use ChatColor#translateAlternateColors or something like that
YES
this translate the text using the "&b" format into the color
im not dumb
also that is aqua
i never knew that-
Whatโs wrong with my action bar method?
?
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
And just use color codes vs multiple text components?
bump
any way to get around it?
Make a custom armor system
mhm... yeah, the only hard part ( for me at least ) is getting to work instead of minecraft armor system
Quick question to check if I'm crazy or not. Hosting a server on localhost is supposed to give other computers on the same network access to it right?
Mk, mine's not working and I'm driving me up the wall a bit
For other ips on the network you gotta port forward iirc
connect via your internal IP
Port forward is only for not-on-the-same-network I thought?
thats for outside your wifi
so if you want your friends to connect you got to port forward..
Right right. I'm currently trying to get my old computer to connect to my new one
Lemme try internal ip
@shy forge https://www.youtube.com/watch?v=SPy6qzz6cgs
Want to know how to make a Minecraft server in 1.18? Well, this is the video for you! We show you exactly how to create a Minecraft 1.18 server in order to start playing Minecraft 1.18 with your friends. This truly is a complete guide on how to start a Minecraft server in 1.18, so letโs go ahead and jump right on into it!
Get a 24 hour DDOS Pro...
he will tell you pretty much everything
U sure that's not just port forwarding?
Same Wi-Fi just type your ip not localhost, external use VPN
it shows you how to create the server. you only need to go to the part where he joins it without port forwarding.
if your servers ip is 192.168.1.99
in minecraft for server ip put 192.168.1.99
He's joining it from the same device tho?
I'm trying different device, same network
Hey anyone a math wizard in here?
How can i convert a ChunkSnapshot location to a Block location
I thought the formula was:
(snapshotX * 16) * chunkWorldLocationX (Same for Z)
But it acts rather odd with negative values and obviously wouldnt work if a x or z was 0 in this code snippet here
Got it working
Yh, it was internal ip
Sorry, kept trying to find my internal one and it kept giving me my public one
Thanks guys :)
@EventHandler
public static void PlayerLeave(PlayerQuitEvent event){
if(Bukkit.getServer().getOnlinePlayers().size() == 0) DFVar.globalVars = new HashMap<>();
}
is the player count from before or after the quit event?
I can't test right now
I want to say it's before
(you can omit getServer() by the way. All Server methods are statically mirrored in Bukkit)
I would say before since the player object is still valid
fixed it pog
the problem is that i get the base price not the updated or the inflated price
@last templeand ittsss done for now https://github.com/horizonstudiosmc/horizonessentials
the code looks like shit but it works lol
Hey so I have been working in the PlayerCommandPreprocessEvent and I'm trying to determine if the command is one from Minecraft or if it is one from a plugin.
I setup a reference to the server's CommandMap and checked if the command was in there by doing CommandMap#getCommand(command) that outputted that it is a Minecraft registered command by sending this org.bukkit.craftbukkit.v1_18_R1.command.VanillaCommandWrapper(command), however, I'm not sure what I can do with this information now that I got it. Any ideas?
ha lol
i posted update cause i forget to fix something
the ! in the if statement wasnt there-
andd fixed
yep
he find wood :)) (One day he might notice he passed by 3 trees on the way there)
is it possible to create command hints like the red underline here
pretty sure you can use bit shifts to fix that
tried but it was weird
would love to use bit shifts cause theyre way faster than the ladder option im doing
~ int realX = chunkPosition.getChunkX() << 4 | x;
Whats | x?
ill try this in a min
within the chunkposition
I honestly don't know why you were multiplying X by 16
the formula is chunkX << 4 + x
or chunkX * 16 + x
does the ender dragon death work differently then all other entities? im trying to get the killer and give it items
@last templei should of just released it with bstats- yet another release
Hello, this code is good or i need to use another method?
Probably by importing the correct dispenser I imagine
What's the convention for listing an argument that could either be any string, or a certain string to do something else
for example
/setownname <name|unnamed> This is what I have right now but it doesn't look right to me
name could be any name the user wants to name themselves
or they could type the literal string "unnamed" if they want to set their name to null
there is no convention to command usage
I guess the only convention is [] <> which is stilll swapped by many plugins
Why
Why not just make the argument optional
I don't think that's as clear
No, that not including it will clear it
instead of give you more info like the usage of the cmd
What does this even mean
could probably change those public static methods to private methods
You could probably just use a singleton class here
Research proper singleton objects
Take a closer look at my description
heโs saying (I agree) that doing /setownname without a parameter to clear the name is confusing
when usually you would just type the command to get the usage message
so how would i get based off the player?
I want to add multiversion support to my plugin, I don't plan to use any NMS but am not sure at this point, would Maven modularity be the best option to look into?>
It means that it's not clear that it'll remove the nickname
how do you typically find out the arguments of a command? by typing it without arguments
otherwise, how do you get the usage
by having a single optional argument, it's difficult to immediately understand how to set the nickname, or how to clear it
Then make it a separate command to remove your nickname
Not something that could be an argument
Can somebody inspect my github / plugin? i need criticism https://github.com/horizonstudiosmc/horizonessentials / https://www.spigotmc.org/resources/horizon-essentials.103518/
also really buggy
I clicked a random file
NewTeleportCommand.java line 29 you don't return after your null check
player.sendMessage(he.getPrefix() + ChatColor.translateAlternateColorCodes('&', "&cThat player is not online"));
}```
Oh, also can you just DM me the issues so i can wake up tmr and say MORE WORK
i can REALLY nitpick it if you want
why did you copy/paste the bstats class manually? and you didnt even change the package name so it will throw an IllegalStateException once you try to use bStats
im fixing that tmr, not sure how to use gradle with it
why are all your fields public in the main class?
yeah ik its bad code lol
and why are they static too? you should rather create instance methods as getters for your CombatManager, GUIManager, etc
like ```java
public CombatManager getCombatManager() { return this.combatManager; }
then make it a private instance field
its super glitchy, but yeah
im not gonna read the code again
mk
Does anyone know the NMS methods to make a Player place blocks/use items in theyre main hands?
cant seem to find em, im just replicated it by swinging the nms arm, facing npc at location and settting the block there
not sure
๐ discord plugin ?! ๐ฎ 