#help-development
1 messages · Page 2102 of 1
well to call .close
yea
i use that for my native methods
from my dll
¬í ur ![Lorg.bukkit.inventory.ItemStack;–lr¤Ï xp )sr org.bukkit.util.io.WrapperòPGìño L mapt Ljava/util/Map;xpsr 5com.google.common.collect.ImmutableMap$SerializedForm L keyst Ljava/lang/Object;L valuesq ~ xpur [Ljava.lang.Object;ÎXŸs)l xp t ==t vt typet metauq ~ t org.bukkit.inventory.ItemStacksr java.lang.Integerâ ¤÷‡8 I valuexr java.lang.Number†¬•
”à‹ xp
Ÿt NETHERITE_SWORDsq ~ sq ~ uq ~ q ~
t meta-typet enchantst Damageuq ~ t ItemMetat
UNSPECIFICsr 7com.google.common.collect.ImmutableBiMap$SerializedForm xq ~ uq ~ t
DAMAGE_ALLuq ~ sq ~ q ~ "sq ~ sq ~ uq ~ q ~
q ~
q ~ t amountuq ~ q ~ sq ~
Ÿt
DIAMOND_BLOCKsq ~ @sq ~ sq ~ uq ~ q ~
q ~
q ~ uq ~ q ~ sq ~
Ÿt WOODEN_SWORDsq ~ sq ~ uq ~ q ~
q ~
q ~ q ~ &uq ~ q ~ sq ~
Ÿt CHICKENsq ~ sq ~ sq ~ uq ~ q ~
q ~
q ~ q ~ &uq ~ q ~ sq ~
Ÿt FEATHERsq ~ sq ~ sq ~ uq ~ q ~
q ~
q ~ q ~
uq ~ q ~ sq ~
Ÿq ~ 0sq ~ sq ~ uq ~ q ~
q ~ q ~ uq ~ q ~ q ~ q ~ "sq ~ sq ~ uq ~ q ~
q ~
q ~ uq ~ q ~ sq ~
Ÿt
GRASS_BLOCKppppppppppsq ~ sq ~ uq ~ q ~
q ~
q ~ uq ~ q ~ sq ~
Ÿq ~ ppppppppppppppppppppppp
``` so it serialized just fine
guys when i try test my plugin the Console print an error on this code, can someone help me?
lets see the deserialization process
Show the error
so lets see if it deserializes ```java
ItemStack[] is = (ItemStack[]) NonReflectables.deserializeBukkitObjectFromFile(invDir.getPath() + '/' + p.getUniqueId().toString() + ".bin");
for (ItemStack item : is)
{
Bukkit.broadcastMessage(item.getType().toString());
}
yes it does
only crashed cause i forgot to exclue null entries
but works now @eternal night ty for the info about Bukkit sers btw xD
glad to be able to help 🙂
like i asked 3 times before and no one was apparently able to inform me that bukkit has a serializer wrapper xD
so i started writing my own system
which is where the mess came from
oof
Yea no the serializers works fine
idk how well it does version upgrades
(paper has a nice method for that, but I digress)
public static void onPlayerJoin(Player p)
{
File invDir = new File(Utils.getOwnDir + "inv");
if (invDir.exists())
{
if (new File(invDir.getPath() + '/' + p.getUniqueId().toString() + ".bin").exists())
{
p.getInventory().setContents((ItemStack[]) NonReflectables.deserializeBukkitObjectFromFile(invDir.getPath() + '/' + p.getUniqueId().toString() + ".bin"));
}
}
}
public static void onPlayerQuit(Player p)
{
File invDir = new File(Utils.getOwnDir + "inv");
if (!invDir.exists()) invDir.mkdir();
NonReflectables.serializeBukkitObjectToFile(p.getInventory().getContents(), invDir.getPath() + '/' + p.getUniqueId().toString() + ".bin");
}
``` final implementation @eternal night once ive cleaned up xD
now i can start writing the methods to alterate the contents(used to edit offline players inventories)
maybe save those files instead of re-creating it
urgh file api is so ugly
ngl paths are life
^^
Utils.getOwnDir
does this
for me
public final static String getOwnDir = "./plugins/PluginMeta/" + new File(main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName().substring(0, new File(main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName().length() - 4) + "/";
gets a path to its own directory
where its supposed to write
based on the main classes directory
wdym
theyre supposed to be applied when the player logs in and to be created when the player logs off
oh
as a copy to be edited
you are just passing a string
to the file input and output streams
interesting design choice
yea but the string
the plugin gets its own path by this
i store all plugin data in plugins/PluginMeta
and i use a master plugin to manage most of my directoy drama
which loads first and for example creates such a directory for all other plugins
if it doesnt exist
and deletes directories of non existant plugins
so no junk data remains
Means the data doesn’t exist in ur file
@eternal night ik many call that bad practice but since i write my entire system myself, i see no problem in having a master plugin taking care of the file structure
“Pkers:”
Doesn’t seem to exist in the target yml
well there’s nothing there is there
Cause there’s no data under pkers: then
Since there’s no data given to pkers: it’s considered null
but that's where the PK list will be
by nature it must be clean 🤣
then if a player kills an innocent person he enters this list
yeah but you’re trying to get a value from it that doesn’t exist
so what should i do?
create it first?
i've discovered something: if i break redstone ore with holding with pickaxe (like in survival), it wont drop anything, but if i break it in creative (no time for it to activate), it will drop something according to those 2 codes
ok i will tempt
so basically if i break before ore activates, first part works, if it activates, first and second not working
how do i cancel redstone ore activation
use "...".equals(var) for comparison
youre going to experience a lot of inconsitent bugs if you dont
only reason it might work now is because it is stored in a string pool
you meants up at ==
yeah
now i understand
https://paste.md-5.net/pegiloraye.coffeescript
im trying to generate a custom wold
world*
the worldcreator.generatorSettings doesnt work
so == checks for identity, meaning the objects have to be the same instance, .equals(...) should check the actual content.
so if i have
String a = "hi";
String b = "hello";
System.out.println(a == b); // false
System.out.println(a.equals(b)); // false
// but...
String c = "test";
String d = "test";
System.out.println(c == b); // false (most of the time)
System.out.println(c.equals(b)); // true (always)
@celest scaffold
you defenitely should change it
ok i will try
is it possible to use this to create a player inventory?
Inventory inv = Bukkit.createInventory(null, InventoryType.PLAYER, ChatColor.DARK_RED + "TEST");
((Player)sender).openInventory(inv);
i don’t think you can do that
i mean the player inv UI, ik its bound to the PlayerInventory interface
anyone?
ah yeah i've forgot about my issue
so.. if the block is broken instantly before the redstone ore activates, i get the item, but if i try to break as survival with any pick, it activates and after breaking, i dont get anything, even if i have the code ready
else if(BlockBroken.equals("REDSTONE_ORE")) {
ItemStack item = new ItemStack(Material.REDSTONE, 1);
event.getPlayer().getInventory().addItem(item);
}
else if(BlockBroken.equals("ACTIVATED_REDSTONE_ORE")) {
ItemStack item = new ItemStack(Material.REDSTONE, 1);
event.getPlayer().getInventory().addItem(item);
}
i also have this at the end of the code so it wont double
does anyone know how minecraft furnaces work?
does it re-evaluate the recipe every tick for every block
or does it store the recipe in the nbt tag or something like that
and rematch that every time the input is modified
if not ill use a normal inventory for it
https://paste.md-5.net/pegiloraye.coffeescript
im trying to generate a custom wold
world*
the worldcreator.generatorSettings doesnt work
Im sorry for posting that a lot of times but rn i rly need it
unload the world, delete the world folder
Bukkit.unloadWorld -> WorldUnloadEvent -> File#delete
world unloads aren't instant
also paper does IO async with no way to know when it's done
you can just wait like 2 seconds for it to be done
the folder will still be in use when you try to delete it
is there an event for slimes/magma cubes splitting?
i think SlimeSplitEvent exists, but is that also for magma cubes
just put a condition
if Entity is not equals slime return
Magma cubes should extend slime
no as in 'slimesplitevent' would suggest that it is only for slime
okay
ill see if that is so
I generally just play it safe and have some utils for that
it eyup it extends slime
thanks
is there a method that returns all the newly created entities
lol the cache folder is hella useless
i would think not since its catching the event
because all there is is getCount()
no one knows?
What event might i use to detect if a block breaks?
BlockBreakEvent
why is it lookin' so fancy 🥺 👉👈
i want to modify all the split entities
But that's player only
probably my scheduler util
I want to detect if a portal gets blown up
but the thing is i also want to know if the portal is just destroyed in general since people could punch the obsidian
guys how to i use the generatorsettings
bruh ask somewhere else we clearly dont know
I probably have some code using those generator settings but it's clown stuff I made 3 years ago
blockexplodeevent
how do i modify the baby slimes when a slmie splits into babty slimes?
making sure the world is properly unloaded
But then that won't work if someone breaks the portal via destroying the obsidian though
my WorldUtils#unload method actually waits for the WorldUnloadEvent to get called and such
by doing some async latches
Is there a way to display the mesh-texture of a block?
Green lines along the edges?
only had to suffer for 2 weeks straight to understand why
hm
not sure then
Maybe this but instead of just getblock().getlocation do getSourceBlock()?
5 quintillon fancyness points
yessir
Latch is a fancy CountdownLatch that throws an exception if I try to await on the main thread
narnia
whenNextUnload just puts that Consumer<World> on a collection
that iterates whenever WorldUnloadEvent is called
no
:)
what are you trying to do
deletin a world
ah
any1?
mods
: D
unless there's some packet fuckery with structure blocks
yes, i'm looking for that fuckery
maybe do something like
/* some method */ {
final String worldName = ...;
new Thread(() -> {
while (Bukkit.getWorld(worldName));
Bukkit.getScheduler().runTask(plugin,
() -> actuallyDeleteWorldOrSomething(...)
);
}).start();
}
public void actuallyDeleteWorldOrSomething(/* args */) {
// ...
}
idk if the world is removed when its unloaded
bruh
does it get called when you force unload it then
wait until its unloaded
yeah its not a very good idea
didnt know there was an event
adding data to a collection and iterating it whenever the event gets called
aka using a latch
Does anyone know?
Hi i have a problem! I have a private github repo and i'm using jitpack to use it. I don't quite understand how to do this...
Its gradle and I did refresh it
@quaint mantle or do like
public CompletableFuture<WorldUnloadEvent> waitForWorldUnloadEvent(Plugin plugin, World world) {
CompletableFuture<WorldUnloadEvent> future = new CompletableFuture<>();
Listener listener = new Listener() {
@EventHandler
public void onEvent(WorldUnloadEvent e) {
if (!e.getWorld().equals(world))
return;
HandlerList.unregisterAll(this);
future.complete(e);
}
};
Bukkit.getPluginManager().registerEvents(listener, plugin);
return future;
}
/* some method */ {
waitForWorldUnloadEvent(world)
.whenComplete(event -> {
// ...
});
}
https://jitpack.io/private like where do i need to put this server part?
and the token
please make variables with more than 1 letter
also you gotta register the listener
oh
yeah
shit
also there were some bugs
well really i fucked up the code again because i was writing it in discord
possible
please
Does anyone know?
yeah but there isn't any Jitpack discord server and also i'm using this for spigot
where should i ask?
try restart and invalidate caches
will0mane its fine to ask here
just keep in mind, people may not be at all knowledgeable concerning other topics
especially jitpack since it has a notorious reputation
wdym?
its known for not working very well per say
oh..
I almost vomited last time I tried fiddling it into a working state with my gradle subprojects
so can you suggest something better to do that?
maven central is nice
or if you have the resources, host a custom nexus repo manager
Im not implying you should give up on jitpack
but ye its far from optimal
whats this? $HOME/.m2/settings.xml?
Already tried did not work
Also tried running gradlew clean
(event, error) ->
delete .idea and .gradle (the folders) then invalidate and restart
like that
do i have to create it?
Will try I guess the thing is that it also happens in girhub actions I think
Hm?
build script = build.gradle(.kts)
ye
is there any community, tutorial, documentation, or anything that I can specifically get help for nms code?
there's just so much to take in with all of the thousands of classes and stuff
You can generally ask here
Why do you want to use nms?
tho docs are going to be rough
You should never use nms if there is a spigot api for it and if theres not any u should contribute creating one unless its very specific I guess
I mean I started wanting to change the default nether chunk generator and looking at all the mess that is the nms code my brain is self-imploding
Also what is the minecraft mappings that spigot uses?
I looked at other people's rough implemntation of what I want on github and they all seem to use nms or reflection
so I'm trying it by myself to learn
I don't think there's a spigot api to change the nether chunk gen
or the end
idk about the spigot mappings but i'm using mcp mappings
moj maps is preferred
actually scratch what I said I just cloned MinecraftForge and used their mappings which I think is mojang not sure
so how could I practically override the nether chunk generator, and use my own ChunkGenerator class?
hey i an EntityTargetEvent listener, but whenever the player hits one of the mobs or dies, they start attacking again.
@EventHandler
public void onTarget(EntityTargetEvent e) {
if (e.getTarget() instanceof Player) {
Player target = (Player) e.getTarget();
if (SpawnPackMain.getMobOwner().containsKey(e.getEntity())) {
if (SpawnPackMain.getMobOwner().get(e.getEntity()) == target.getUniqueId()) {
e.setCancelled(true);
}
}
}
}```
oh god
it works when they are spawned, they do not attack the player. But whenver i hit one of them or i die they target me again
wym
I see at least like 4-5 things wrong with your code
oh ok what is
- you should reuse code (not call the same getter 15 times)
- you should name your variables properly, as
esays a lot less compared toevent - you should use return statements to keep your code as "flat" as possible
- static abuse? you're storing a static Map<Entity, UUID> on your main class
- use Object#equals to compare objects, and == for primitives (it compares the memory address rather than the values)
- Store a UUID instead of an entity reference on the map, for safety (also helps with leaks)
- Calling containsKey and get immediately after is a bit wasteful, just check if the get() value is null
eventhandler methods on spigot can be private (bungee will yell at you however)
How to cancel players moving items on their own inventory?
Cancel the InventoryClick and DragEvent
?
I dont why its make issues with chest commands
Because chest commands uses inventory, so when i cancel the event the chest commands get the events called too
They haven't specified to ignore cancelled events
Still not sure what the issue is
I explain
But you can always fork ChestCommands or make your own
They wont pay me extra for fixing they issues
🤔
So that option its discarded
Hahaha
So i will deff do a issue report on gth to the author
Looks intended yeah
@EventHandler
public void onTarget(EntityTargetEvent event) {
if (event.getTarget() instanceof Player) {
Player target = (Player) event.getTarget();
UUID targetUUID = SpawnPackMain.getMobOwner().get(event.getEntity().getUniqueId());
if (targetUUID != null) {
if (Objects.equals(targetUUID, target.getUniqueId())) {
event.setCancelled(true);
}
}
}
}```
any better? also can you help with my problem
targetUUID.equals(...)
If you use Objects#equals you can skip the null check
Comparing them like that will work just fine
mk
so, when a player first spawns in the mobs they don't target the player, (the event works) but when the player dies or relogs they start attacking again.
or if the player hits one of them
Put your project on github and I'll take a look tomorrow. You're probably doing something wrong
the @NotNull ... hurts my brain
why are you still using something that i told you not too
this never, has never, never will, will never, has not, has never will, ever will be
actual valid java, this is not a String like the javadocs say that the input needs to be
the moment u make one typo
just put an extra } :}
lol
intellij like to have panic attacks
its actually all the functions and stuff
everything imported from the api
it just decided to yeet the api
also my resolving dependencies bar if bugging out
i hope thats not a 1k line long class file
its actually 2586

I don't suppose i can cancel the death event can i?
For players no
if event.isCancelled() exists, then yes
what you need to do
else no
it will skip the respawn screen using that method
That sounds a lot simpler then all the other things i keep seeing then
nope but you could listen for the entitydamage event and cancel that
anyways restarting the ide and reloading the maven didnt fix
May have undesired effects if you still want death event to fire
Like for instance not having a death message?
isnt there a way to set it off manually
this is why we dont make 2.5k line files lmao
you couullld but, its a lot easier to forcefully respawn the player
ie other plugins listening to death event
Oh :P
Hey, does anyone have a tutorial regarding dat files and how to use them?
I don't have others
nbt better
I'm looking for a way to backup player's inv
is setBedSpawnLocation() the only way to set a player spawn point btw?
YamlConfiguration suports reading and writing ItemStacks
json/ base64/ yaml?
I was looking towards json but isn't Itemdata gonna be broken?
nah metadata/nbt gets stored when a item stack gets serialized
Like, I'm getting the itemstack and writing it to the json but how do I retreive it?
derserializing
look into MemorySection's way of doing it
Can I do the same creating a database?
i deleted the iml file it fixed smh
mfs
anyways i need more ideas in #961763801869451335because im bored
i already made baby zombies steal stuff, crops randomly die, nothing burn, phantoms spawning all the time, custom bossfights, op mobs, stuff randomly exploding, etc.
raid them ;)
but what do i input !
you encapsulate the object you have in string quotations
This is pretty basic java
@EventHandler
public void onDeath(PlayerDeathEvent event) {
event.getEntity().spigot().respawn();
if (team_manager.getSouth().hasEntry(event.getEntity().getName()) || team_manager.getNorth().hasEntry(event.getEntity().getName())) {
event.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 0, true, false));
}
}```
This kills me with my original death after a few seconds of respawning
well
kind of
It brings up the respawn screen
might need to call it one tick later
Reading a text file without crashing the server
yessir
@EventHandler
public void onDeath(PlayerDeathEvent event) {
death = new BukkitRunnable() {
@Override
public void run() {
event.getEntity().spigot().respawn();
if (team_manager.getSouth().hasEntry(event.getEntity().getName()) || team_manager.getNorth().hasEntry(event.getEntity().getName())) {
event.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 0, true, false));
}
}
};
death.runTaskLater(plugin, 1);
}``` So this should run after 1 tick right?
just use runTask
Right
I realized that after i said it tbh
lol
Okay how do i set a player spawn point?
how can I override the nether chunk generator with a custom one? will I need nms?
Cause the way i'm doing it doesn't work
#961763801869451335 more ideas pls
Idea: Spamming asking for ideas
Don't u love the types of parents that shut off ur wifi
Bruh I'm not a toddlee
And its 6 pm
Wtf
probably don’t want to respawn after a tick
why
i would check entitydamagebyentity event check if it’s a player and if the amount of hp is less or equal to 0
because let’s say i log out the tick i die
it’ll try to respawn a nonexistant player and can break things
plus some other problems with being dead for 1 tick
Entity killer = e.getEntity().getLastDamageCause().getEntity();
will that get the kliler of the entity
EntityDeathEvent
i would use event.getDamager()
hello
How would you get the name of an inventory
Hi
InventoryView
my server is crashing can anyone help
Nah
what
I came here to get help if you won't write at all?
server crashes
this sounds primarily like a server only issue, go to #help-server
don't paste that again either
sorry 1m
i need help
server crashes
I couldn't solve it for 3 days, I wrote to paperspigota, they were not interested
go to #help-server
ok sir thanks
what have you done to your server lmao
i dont know man
when did this start happening
and did it happen when you changed something
server setting, plugin?
yada0, please continue this in #help-server
thanks
Back at this, I have an inv which I created. As it doesnt have .getView() how would I get the custom title I gave it? Or if anyone else knows :/
it isnt
?jd
1 sec
I can't see any method that would give the custom name
why do you need to get the name?
So I can get the correct ItemStack[] for my crates
I have two inventories. One is the crate opener and one is where you view the items you can get.
I swear I've used like a get title in 1.16
probably with getView().getTitle()
just from directly the inventory
anyways
why do you take that item stack list from the inventory?
you should really store it elsewhere e
in a class or a config file
I don't think there is a way to do what you want
Is pattern variable will not work If there are multiple check?
if (!(event.getEntity() instanceof Player player)
&& !(event.getDamager() instanceof Player damager)) {
return;
}
``` I can't use the variable on there
ok, I'll try creating a class to store my ItemStack list and work from there
I recommend making a Crate class
where it stores each item and information about them, chance, etc, and then in like onEnable you create instances of that class with information for each crate and store it somewhere so you can access it
ok. I'll do that now, Thanks for the help
wdym good sir
that code doesn't compile because the syntax is invalid if that's what you're asking
Hey guys,
Sorry for bothering yall, I've got a question.
How do you make an event where it detects variable cahnges / player balance changes?
I know this is a dumb question, but if someone could help, that'd be great!
i can't use the pattern variable if i'm using pattern variable with guard clause or early return
anyways, nevermind about that
if you're gonna just return like that there's no point anyway
Guys I'm messing around with mojang remap NMS stuff, and I can't figure out what ResourceKey<Levels> is and how to obtain it
I'm trying to create a ServerPlayer object
Hello. Is it possible to give a inventory gui to spectator players?
depends on the version
yes
Yeah you right I realized that after
Will adding better potion effect will override the current potion effect?
Hey! Whenever I use AsyncChatEvent.message(Component) to change the chat message, I still get the players name in angle brackets in front of the message.
I’m using paper with adventure api btw
Is there a way to remove the player name
use setFormat
For paper related questions your better asking in the paper discord
Can I bring back the hotbar in spectator?
with packets, maybe but it likely wont be functional
e.setFormat("%1$s %2$s"); will remove angle brackets
deid
what are you trying to achieve?
or can someone help with smthin else
its not rlly development but when i try to remove a spigot resource pack it wont let me (i know how to remove a pack) but it doesnt show that option for this 1
can confirm, it will override, and less stronger effect will not be applied, at least this is the case if i use minecraft effect give command.
pretty sure you just delete the url in server.properties
it wont let me remove my resource pack its not the servers pack its my personal one
like when i go options resource packs
so it's like curse of unbinding but on your texture pack
yes
that's crazy
Working on a part of a minigame where when you die you become a ghost of sorts. You would be able to hinder alive players as a invisible creative player or a spectator player. my problem is them interacting without commands
I'd say close mc, delete it from the folder, then reopen it
other than the resourcepacks folder is there anywhere else it could possibly be
unless it was some virus you downloaded no
oh
thats a server sided resource pack
qualityarmor has a config for it to not send the rp
is a inventoryclickevent called when a player interacts with their inventory in spectator?
most likely, but for a question like that it's better to just take 5 mins to test it yourself and get a faster definitive answer
^
you're asking like every little question
just assume something works, if it doesnt then ask
okay sorry
How can I check If player is looking at a player?
Like I don't want PlayerInteractEvent and PlayerInteractAtEntityEvent can be called at the same time If player is right clicking on a player.
You'll have to raycast if you want to tell they're looking at a player
it wont.
playerinteractevent is purely for blocks
thats why there are two separate events
air also
?
right clicking entity counted as right clicking an air too somehow
Honestly it might. Interactions are weird
sounds like a pr to me
I wouldn't put it past it
They can both fire
It's a hard thing to fix if it does call them both
cause you cant interact with air
with an item in hand
right
oh that would make sense
but thats shitty
because you still cant interact with air
and that would be misleading
He wants to see if you're looking at a player tho, not right clicking on them
what i want is
i want to prevent PlayerInteractEvent from being called if player is right clicking an entity
with item in hand yes
Check the order in which they're called
Why do you want to cancel that event anyway, or prevent it from being called
i have a skill system where it can be activated by right clicking on entity and right clicking not on entity
because of that, both skills got called
yes, the entity is first
And something weird also, the entity skill got called twice.
If so just set a flag for 1 tick which automatically returns on PlayerInteractEvent
How can I set a flag?
or, if they're holding an item in their hand set a flag to return on the next PlayerInteractEvent while also changing the flag when that is fired
by flag I just mean bool
boolean shouldFire = true;
// PlayerInteractAtEntityEvent
shouldFire = false;
// PlayerInteractEvent
if (!shouldFire) {
shouldFire = true;
return;
}
```Something like that?
It's weird that InteractAtEntity is being called twice sometimes too
I'll try to use the flag first let's see If it will fixed it
After add a debug messages, and the flag thing, the PlayerInteractAtEntityEvent got called twice, and it's the same entity.
@summer scroll
The event fires twice for each hand
so check their hand
only fire for mainhand
I thought interact at entity only for right click
Try out what I told ya
Yeah, now the event fires for both hand, thanks!
Yeah tricky 1.9 features
Giving someone weakness potion effect will remove strength potion effect, is it always like that?
@alpine urchin Dependency 'com.github.retrooper.packetevents:api:2.0-SNAPSHOT' not found
That doesn't happen
Yeah, I got this weird issue, whenever I add potion effect, all of potion will be cleared first.
show us how you're adding them
you might be setting instead of adding potions
I'm starting out on plugin messaging in bungeecord, on the bungeecord side, I'm assuming the PluginMessageEvent is where I would listen for when I try to talk to bungeecord through spigot?
yes
Alr thanks
is that the best way to communicate between the two
I'd assume so
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
You implement the listener
not listen to an event
I read people saying that it's not 100% reliable
Talking about on the Bungeecord side
What would be an alternative
That's what I'm askin about rn
im pretty sure plugin messaging is the best option unless you want to set up a complicated socket system which might have its own bugs
Yeah, I really don't want to set up a socket system lmao
I was afraid someone would say that
Fair enough
plugin messaging should work fine enough
just add some utility methods or something to make sending data easier
i do this on the regular
get on my level
too pro
sheeeesh
most developers forget about encryption tho
is that vital for plugin messaging
no
thoughts on cracked servers using google to authenticate
cracked server bad
why are they bad
supports pirating the game
does microsoft really need that money
Nope, but servers owners shouldnt be forced to run theyre server in an unsafe mode just to support people who dont want to support a game
- Its not like microsoft took over completely
Mojang is still mojang and it still has the OG team when microsoft bought out
What dangers come with turning online mode off if you know I'm curious
People could link it to their bungeecord
And join as any name they want
I once made that mistake funny as fuck
They kept on joining as youtubers
yeah but that aint really a problem if you have proper authentication measures
You turn off the entire authentication from your server to mojangs servers entirely
Meaning your running into the issue you talked about, authentication, having to rely on plugins for authentication rather than the built in authentication Mojang provides
Yeah there's no risk if you set it up properly
Banning people becomes a lot harder, since a vpn + name change and theyre in
rather than needing to buy a new account + vpn
Gotta create a godly anti-cheat
imo I think MC anticheats are redundant
better to have staff that actually spectate
but that requires lots of volunteers depending on the server scale
i mean hypixel manages to spectate people
just saw a vid the other day actually of mods macro checking people
where were the mods when I needed them last bw game 😦
to make a team do I instantiate a new team object?
does anyone know if in inventory framework when creating an event on an item and passing a value in the event, the variable gets the value when the event was created on when it was fired?
in that case, will lan or messages, displays, keys etc have the same value when the event is fired?
what
in most events, when you call for a value outside the event, the value is the one at the time the event is fired
does that work in the same way with inventory framework item callbacks?
?
idk either
do you really not understand or just messing with me?
are you asking if everything is a reference?
in java everything is a reference
i
dont understand what you're asking
aigt nvm im just gonna test it
Id argue its not even possible
Its A constant battle between cheater and anticheat developers
yep that too
you could never actually "finish" an anti cheat
its something you need to constantly commit too
Which is... a pain
WOuld anyone know of a way for me to send kinda like a command to a server, lets say the player executes /join arena arena1 in a lobby arena, I want them to join a seperate bungee connected server and then join that arena on the server they were kicked to, any thoughts how to do this with the bungee messaging system?
I know you can do it, but the limitation is that each server needs to have atleast one player online, so it wont work if one doesnt have a player on, I kinda want to have the server wait until the player joins to send that command over to the server, but it wont work cause of the limitation
does anyone know how this plugin is possible? https://www.spigotmc.org/resources/✨itemsadder⭐emotes-mobs-items-armors-hud-gui-emojis-blocks-wings-hats-liquids.73355/
what did they use to add custom textures?
and custom items
i thought that wasnt possible, to add a new material to the game
NoteBlocks my good sir
one moment
i got an example for you
fr?
You need to modify the block state in the texture pack too
Example resource pack
Youll ofc need to prevent block state changes
so this class creates a new ore?
its not really an ore tho right?
Little more complicated as the way i reister it is different but in a sense yes i have a video too
i cant use Material.CobaltOre
that wont be possible
i have a class that handles loading these ores
https://github.com/Burchard36/SpinkersConstruct/blob/main/src/main/java/com/burchard36/tinkers/block/events/PreventStateChange.java preventing block state changes, little messy but it works
https://github.com/Burchard36/SpinkersConstruct/blob/main/src/main/java/com/burchard36/tinkers/block/BlockRegistry.java Registry that handles getting the blocks as item stack/checking if a Block is a TinkersBlock (IE CobaltOre)
wow thats interesting
Why not just make a re-usable water bucket? Stackable things that arent meant to be stacked are rather buggy
you cant properly manage them in your inventory
do /i dpick on your server if you have essentials installed
and try moving it around in your inventory
youll see what i mean by properly manage
The player should execute commands when joined the other server?
Use sockets
Or redis
not that THEY execute a command, but a plugin caches some data and awaits them to join to then queue them up for an arena
What i done sockets is that
When a player wants to join an arena in another bungee server
Sends a message to the other bungee and when arena server got it, creates a cacheddata with required data. Then when a player joins, reads it and do codes, afteer that send the player to the other bungee server
Sorry for the grammar and spelling i just woke up and im with a phone 💀
@marsh burrow
And, the lobby should be the socket servers
And arena servers should connect to (they both should be able to receive messages from each other and send messages to eachother)
actually, this might be the solution, is it dependable though
Or use redis to do this
I used sockets the way i explained to make a bungee mode for my bedwars pl
ima need to read up on sockets then
And dont forget, when you load the data remove it from the map or set or list that it was before to prevent memory leaks
will do, thank you for pointing me in the right direction
Yw
Hi guys, I'm trying to override / replace the nether / end chunk generators and I'm looking through nms and I'm not quite sure how I could do that, idk if I could somehow just replace it in the Registry before the world loading starts, I'm just not exactly sure how to do this (maybe I can even do this through the plugin api?), any help is appreciated 😄
Hello im currently practicing lambdas
Lmbd l = (Player p)-> p.getKills(); is this true?
yes, without the type declaration because a lambda has to define an anonymous functional interface, which means the types are already defined
There's a worldgen api
Guys I'm messing around with mojang remap NMS stuff, and I can't figure out what ResourceKey<Levels> is and how to obtain it
I'm trying to create a ServerLevel object
Hey everyone, I would like to know if it's possible to use an RGB color in a team prefix or on an item name/lore. When I try to convert toString my bungee ChatColor.of(new Color(bla, bla, bla)) for exemple exmple, it will return me the closest Bukkit ChatColor...Am I doing something wrong ?
As you can see I is blue in game but my color should be yellow
Here is how I register a team```java
public void registerTeam(TeamEnum team){
Team t = scoreboard.registerNewTeam(team.getTag());
t.setAllowFriendlyFire(true);
t.setPrefix(team.getPrefix());
t.setSuffix(team.getSuffix());
t.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
t.setOption(Team.Option.DEATH_MESSAGE_VISIBILITY, Team.OptionStatus.NEVER);
t.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.ALWAYS);
}```
team.getPrefix() return the bungee ChatColor toString.
hello!
It is possible to use rgb colors in team prefixes and in item names/lore.
You can do something like \u00A7x\u00A7R\u00A7R\u00A7G\u00A7G\u00A7B\u00A7B Some Text to color "Some Text" using rgb values.
is there a way of getting the width (and maybe height) of an inventory, or will i just have to do
int width = craftingInventory.getSize() == 9 ? 3 : 2; // crafting table/survival inv
Red Green and Blue in hex
what
oh
a bit tired due to my colors problem
ah
You can surely do something with InventoryType#getDefaultSize()
does anyone know how i could use mongoDB's object ids for players? like lets say i have 3 players, and i need a specific one of them - do i have to put their uuid in the doucment of the player so i can filter it or is there a way i can use only objectid?
Use their UUID as objectID
I have something for you @lean gull
oh you can set the object id to something?
Sure
yup
did not know that
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
check this
seems sus 😳
You can also use a property and have an additionally generated objectID but then you would need to hash index that
property to get the same performance. And thats not worth it.
i do not understand a thing so i'll take your word for it 👍
uhh?
oh wait this is in the update section, maybe it means that you can set it at the start but not change it?
// x +1 y 0 (->)
if ((nx = x + 1) < width && (ny = y) < h) if (removeStatus[i1 = flatten(nx, ny)] == 0 || !slots.get(i1).isEmpty()) anc++;
``` lmfao
aids code
@lost matrix so R: 247 G: 194 B: 33 should looks like this ? "\u00A7F7\u00A7C2\u00A721team color" ? 🤔
You should not create or update like that. You have to do double the work if you always search for an object
before inserting. You should also not write String queries like "$set" when you have the MongoDB Java driver.
mmmmm ok noted, I will check
public void write(K key, V value) {
Bson filter = Filters.eq(key);
ReplaceOptions options = new ReplaceOptions().upsert(true);
this.mongoCollection.replaceOne(filter, value, options);
}
Use upsert instead. upsert = Update if present or else insert.
You can also skip the parsing of json if you simply implement a Codec<V> that is based on Gson in the background.
where do i put the uuid in insertOne?
like how do i put a specified _id instead of a auto-generated one
?
no i want to write one when making a new document, not find one with a specific one - atleast not yet
public void persist(PlayerData playerData) {
Bson filter = Filters.eq(playerData.getPlayerID());
ReplaceOptions options = new ReplaceOptions().upsert(true);
this.mongoCollection.replaceOne(filter, playerData, options);
}
can u explain to me what all this does? i don't understand
*This only works if your codec can serialize PlayerData. Otherwise you need to use Documents
public void persist(PlayerData playerData) {
Bson filter = Filters.eq(playerData.getPlayerID());
Document document = Document.parse(gson.toJson(playerData));
ReplaceOptions options = new ReplaceOptions().upsert(true);
this.mongoCollection.replaceOne(filter, document, options);
}
???
?paste
basically a Mongo Document is a json file
I still don't get how do you convert the hex to a viable color. I tried few things like ChatColor.of("#f7c221") which is basically same as ChatColor.of(new Color(247, 193, 33)) so same result...
I tried "\u00A7F7\u00A7C2\u00A721" F7, C2 and 21 are the hex value for R, G and B but I get three colors differents because it takes only the first char of the hex.
he filters for something and then sets replace options and then he replaces a document in the given mongo collection based on the filter with the options
i need to go so i'll come back later and ask again
cause i don't understand anything that's going on in that code lol
https://paste.md-5.net/qoyahiciyi.cs
I'm using Legacy 1.8🥲
My DoubleJump isn't working properly.
What currently happens:
The Player uses the DoubleJump. If the Player spams the Space Bar, he glides through the air.
Expected behavior:
The Player can use DoubleJump only if he touched the ground again
reading docs works perfectly
i did, i didn't see anything about actually changing the _id
you cant change that
or lets say you shouldnt
i was told i could?
§x§R§R§G§G§B§B Where RR GG BB are the hex colors. So 0-255 is mapped to 00-FF
you can but mongodb stores important data like timestamps in that id
you can basically filter everything
(not like i even understand what that means)
Filters.eq ("name", "iDerpyOfficial")
it filters for the document that has the name value iDerpyOfficial
im hungry and can not deal with this right now, cya later
what is §x ? I cannot find it's definition in mc color map
It lets spigot know that a hex color is following
He can also replace the _id field with whatever. Doesnt have to be an ObjectID
never said he couldn't
?
You never check the cooldown map
@lost matrix It still not combine RGB value
public String getColorText() {
String color = "§x";
String R = "§"+Integer.toHexString(getColor().getColor().getRed());
String G = "§"+Integer.toHexString(getColor().getColor().getGreen());
String B = "§"+Integer.toHexString(getColor().getColor().getBlue());
return color+R+R+G+G+B+B;
}```
i'll have a look at this
first getColor return bungee ChatColor, second return the java Color
Can i register a command without adding it to the plugin.yml (1.8)
Can't somehow connect to mysql get this error in minecraft console
public class MySQL {
private String url;
private String username;
private String password;
String table;
private Connection connection;
public MySQL(String String1, String String2, String String3, String String4, String String5, String String6) {
this.url = "jdbc:mysql://" + String2 + ":" + String3 + "/" + String4+"?useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe/Berlin";
this.username = String5;
this.password = String6;
this.table = String1;
}
public void connect() throws SQLException {
this.connection = DriverManager.getConnection(this.url, this.username, this.password);
}
public Connection getConnection() throws SQLException {
if (this.connection == null || !this.connection.isValid(5))
connect();
return this.connection;
}
}```
I saw a resource on this topic on the forum
Accessing the commandmap
Only works during onEnable btw
thanks
i did. look at line 22
It can also be that when you jump, it immediately sets your cooldown
Try checking the block 0.5 below the player
PLAYER_HIT
💀
Thanks
Oh it's actually ENTITY_ARROW_HIT_PLAYER but you helped me find it so all g
yeah I know I wasn't exact but that's it
im trying
it's still the same
Not working
send code
class Main{
public static void main(String args[]){
Player player = new Player("Yay", 14);
Lmbd l = (p)-> p.getKills();
l.getKills(player);
}
}
Ah what
Sorry
what is Lmbd
What fhr fuck happende my main method
Lambda interface
and it has a getKills(Player) method?
is it like
@FunctionalInterface
public interface Lmbd {
int getKills(Player player);
}
Yes
ah k
Player is not by spigot api btw
Made normal object class(name, kills)
Searching Minecraft Staff members . DM me if you want be in my staff team.
wrong server lol
so how do i set the object id of a document in mongodb to a player's uuid?
i'm using playerdeath event, how would i check if the player died from a fireball
or a tnt explosion
You can just set it as you would any other value in a document. Mongo will only autogenerate the _id field if it's not already present.
i don't know where though, and neither do i know how
Have you use mongodb before with java?
yes but so far i've only been able to read from samples, today was my first actual writing with a document
document.append("_id", uuid)
When you create your mongo client make sure to set the UUID representation, e.g:
MongoClientSettings.Builder builder = MongoClientSettings.builder()
.uuidRepresentation(UuidRepresentation.STANDARD);```
?
what's all that do
That creates a builder for MongoDB's settings, which you can use when creating a MongoClient instance. It sets the UUID representation which is required to be set to save UUID parameters via the java client.
sorry but i do not understand a thing
You need a MongoClient right
i have that, yes
These are MongoClientSettings, settings for the client.
In order to save a UUID you must set the uuid representation value, which this does
..what's a client?
When you do MongoClients.create() it can take in a MongoClientSettings value
MongoClient just provides you an API to interact with mongo with
ok
MongoClients.create(MongoClientSettings.builder().uuidRepresentation(UuidRepresentation.STANDARD).build())
?
I'm trying to decrease my jar size, bnut i currently use a lot of libraries for what im doing and its getting to quite a few mb
That's an example of what you would use.
again, i don't understand a thing
Oke well i don't think i can literally explain it better so
What dependencies are you shading?
you just explained what a client is, not the code you sent though
When you do MongoClients.create() it can take in a MongoClientSettings value
yes
so what is all of this
And as you can see, that's MonoClients.create() taking in a MongoSettings value
And as I explained before, MongoSettings.builder() is a builder for settings that affect the MongoClient.
And as I explained, in order to save UUIDs in mongodb, you must first set the uuidRepresentation setting.
which does what?
From their javadocs: The representation to use when converting a UUID to a BSON binary value. This class is necessary because the different drivers used to have different ways of encoding UUID, with the BSON subtype: \x03 UUID old.
what
if you don't set uuidRepresentation, MongoDB doesn't understand what format you want to save a UUID in.
ok so where do i put that?
Can you show the code for where you create your MongoClient
MongoClient mongoClient = MongoClients.create(
Ok so where you do MongoClients.create() that takes in a MongoClientSettings value as I showed above.
You can do pretty much what my example showed.
You'll need to put your address and other information into the MongoClientSettings
...how do i do that
See the available methods after doing MongoClientSettings.builder()
Have you considered the following: Utilize your IDE's code autocompletions to see if you can find a method that does the thing you want?
In other words, this.
Alternatively: Google the fucking javadocs.
if you want to help but you're gonna be mean: don't 🛑
It's common knowledge. If you want help but you're not willing to be proactive, don't ask for help.
so i put applyConnectionString, but now i can't add the .uuidRepresentiation
You should be able to
The builder's methods immediately return the builder instance afterwards
Only way you wouldn't be able to is if you placed a semicolon after the method call :p
Unrelated but who the fuck named StreamFactoryFactory lmao
MongoClient mongoClient = MongoClients.create(MongoClientSettings.builder()
.applyConnectionString(new ConnectionString("LINK"))
.
.build());```
there's no autocomplete suggestion after the individual .
.uuidRepresentation is not a thing?
it lets me import UuidRepresentation but not .uuidRepresentation
I checked the javadocs and it's not actually there
tf lol
looks like dependabot + renovate are broken for mongo or something then i guess
either that or the javadocs are outdated
yep renovate and dependabot haven't been giving me mongodb driver updates
Oke well updated and there's still a uuidRepresentation method for me
declaration: package: com.mongodb, class: MongoClientSettings, class: Builder
i still don't know what i'm supposed to do...
use morphia
?
morphia my beloved
MongoDB object-document mapper in Java based on https://github.com/mongodb/mongo-java-driver - GitHub - MorphiaOrg/morphia: MongoDB object-document mapper in Java based on https://github.com/mongod...
The latest mongo java driver already supports UUID representation out of the box with the default settings.
if ur wondering how to enable uuid representation u can just add it to the connection string link
I think he should def work a while with MongoDB before hopping on an ODM.
true yeah
it would be like adding a query parameter (i think thats what its called)
yes it is
uuidRepresentation=standard
i'm trying to make a players collection with a document for each player and make it so the ObjectID is the player's UUID, except i have no clue what i'm doing
Ok first: How do you plan on serializing your pojos into Bson?
w h a t
i would assume you insert like normal but set _id equal to the uuid
baeldung ❤️
i already watched a youtube tutorial that covers how to read, write and find with a filter
An object is just a bunch of random bytes in memory. MongoDB doesnt know how to handle that. It needs Bson data
so it can store it properly.
have u tried putting _id to the player uuid
can't i just set it to a string and then read that string and parse it as a uuid or something
Please show us what you got so far for upsertion.
MongoClient mongoClient = MongoClients.create(MongoClientSettings.builder()
.applyConnectionString(new ConnectionString("LINK HERE"))
.uuidRepresentation(UuidRepresentation.STANDARD)
.build());
MongoDatabase database = mongoClient.getDatabase("testing_database");
MongoCollection<Document> coll = database.getCollection("cars");
Document data = new Document("vehicleType", "Truck")
.append("numberOfWheels", 4)
.append("color", "red");
coll.insertOne(data);```
3rd line does not work ofc
3rd line is ur uuid representation?
(i mean that .uuidRepresentation is red)
dunno what that means but i don't see that in the link
can u send ur connection string link but ofc censor ou the details
idk how it works so i'd rather not cause i might leak it by stupidity
i have a question, when sending a message to the chat and treated as an async right? If so the server lag your message will not be delayed to be sent to the chat, but the commands are handled of formation of synchronization as well?
I dont see why we would need the connection string...
First make sure that you have the latest version of the MongoDB Java Driver.
You cant import it because you have an outdated version.
how is that possible? i copied the dependency from the github earlier today
Whats your version?
3.11.3
nah its because i wanted to see what it ends in because u can also add the uuid representation to the link
isnt the latest like 4.x
3.12.10 is the latest 3.x version. Use that instead.
ok the thing is no longer red
Alright
lemme make a quick event class for the player part
hey im creating a pvp-based mob-spawner that will spawn mobs that do not attack you. The main concept is working, but i just realised that magma cubes and slimes deal damage to players without actually targetting them?
as in if you bump into a big slime it will damage you, whether its targetting or not.
Is there a way to fix this?
EntityDamageByEntityEvent -> cancel ?
or prevent them dealing damage like that for certain players
I tried that already but it's never called for some reason
ill do some more tests
ok so i made it so every time a player joins, it creates a document - now how do i make it so it checks for a document with the objectid of the uuid of the player, and if it doesn't find one then it makes a new one with the object id of the uuid of the player?
This is called upserting
And its done like this:
Bson filter = Filters.eq(key);
ReplaceOptions options = new ReplaceOptions().upsert(true);
this.mongoCollection.replaceOne(filter, value, options);
Where key is your _id key and value is the data you want to save.
Bson? neber hear d of it
i don't understand how i'm supposed to use this
is registering multiple listeners of the same kind a bad practise?
since i have 3 of EntityDamagebyEntityEvent and it doesnt seem to have affected performance, or cpu or anything
exactly the same result with spark and my own checker
Use this instead of inserting in a collection.
The filter is used to select a document.
The ReplaceOptions is used to define the upsert action (Insert or if present then update).
actually it’s recommended
Kind of. If its for one plugin then probably. Nothing stops you from writing 3 methods and delegating the event from one listener to just 3 methods.
why would that be the case
If the listeners are all of different purpose, by all means separate it
At least that’s by opinion 🤷♂️
yeah i only seperated them because they have literally no correlation they are for completely different things
one is for player death, one is for fireball deflection and one is for slime damage cancelling
mhm Id say it’s fine then, that’s what listeners are for
That violates the single responsibility principle. A listener should not have any logic in itself. It has one purpose: Listen for events and delegate them to where they are needed.
theyre not that related i guess
No it doesn’t violate the single responsibility principle
how tho
having one listener for three different purposes does
why write a method when you are only listening for it once
just write the logic into the listener? or am i not getting something
Well when you develop for multiple platforms that becomes a problem
it all depends on your situation
Unless it’s platform specific *
once again, depends
what do i replace here?
No it doesnt. The listener has one responsibility: Listen for events.
Having logic in them should be avoided:
private final SomeManager someManager;
private final OtherManager otherManager;
private final ThirdManager thirdManager;
@Override
public void onDamage(EntityDamageEvent event) {
someManager.handleEvent(event);
otherManager.handleEvent(event);
thirdManager.handleEvent(event);
}
what no