#help-development
1 messages · Page 712 of 1
cant you just convert the color string into an int?
and then use Color.fromRGB with the single int
like Integer.decode("0xffffff")
but you have to convert your hex string from #color to 0xcolor
you could always use bitshifting too for this
yea
is it possible to create an empty PlayerInventory without a player object?
how about with an Inventory object?
what if i do java Bukkit.createInventory(null, InventoryType.PLAYER)
would that work
yes
it was actually the update method i had that was manipulating the loc variable
so i just cloned it inside the method
lol
no it doesnt if i do PlayerInventory inventory = (PlayerInventory) Bukkit.createInventory(null, InventoryType.PLAYER); it still throws the same ClassCastException
shouldn't need to cast like this
it just gives me an error if i remove the cast
Inventory inventory = Bukkit.createInventory(null, InventoryType.PLAYER)
i need a PlayerInventory tho
wait
can i do
inventory.getClass().getDeclaredMethod("getArmorContents") to get the armor contents?
since its technically a player inventory
if you need an actual real player inventory
then you need to get the inventory from the player object
not create one
?xy
Asking about your attempted solution rather than your actual problem
i need an empty one without a player object
because when you create one there is no inventory holder
unless you specify who the holder is, but the armor contents is something that only entities and players have and thus you would need a holder to at minimum be some kind of entity
cant i like just create an empty one without an inventory holder?
not if you are wanting armor contents
what if i dont want armor contents
but a PlayerInventory object not Inventory object
?xy
Asking about your attempted solution rather than your actual problem
i want to create an empty player inventory with no holder
^
to do what
cuz it creates it in the onEnable method
what will this help you achieve
i want it to save it before the server restarts and then get it after the server starts from a yml file (im serializing it btw)
basically a persistent PlayerInventory variable
so far you haven't explained why you need these inventories or what it is you are trying to accomplish overall. Why do you need player inventories to save from and to a yaml file. Inventories of players and entities are already saved by the server
why does it need to be this type? I dont think you can have a PlayerInventory without a player
but an inventory is just an array of items
i need it so i can invsee offline players incase they scam an item and just leave or anything
im just setting their inventory contents to the invetory contents in a hashmaap
public void processOfflinePlayer(OfflinePlayer offline) {
// Ensure player has data
if (!offline.hasPlayedBefore()) {
return;
}
// Create a profile and entity to load the player data
// See net.minecraft.server.PlayerList#attemptLogin
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
GameProfile profile = new GameProfile(offline.getUniqueId(), offline.getName() != null ?
offline.getName() : offline.getUniqueId().toString());
server.getAllLevels().forEach(level -> {
Player onlinePlayer = Bukkit.getPlayer(profile.getId());
if (onlinePlayer != null && onlinePlayer.isOnline()) {
ServerPlayer handle = ((CraftPlayer) onlinePlayer).getHandle();
processRemoval(handle.getInventory());
processRemoval(handle.getEnderChestInventory());
} else {
ServerPlayer offlinePlayer = new ServerPlayer(server, level, profile);
PlayerDataStorage storage = offlinePlayer.server.playerDataStorage;
// Load data
storage.load(offlinePlayer);
processRemoval(offlinePlayer.getInventory());
processRemoval(offlinePlayer.getEnderChestInventory());
// Save data
storage.save(offlinePlayer);
}
});
}
use NMS
Yeah ur over complicating this
All you need is an item stack array
Items at the start, offhand then armor
although
you can use NBT reader plugins for IDEA
its much easier
just goto levelworld/playerdata/uuid.dat
copy the file
and open it in IDEA
it also supports gzip
minecraft already saves these stuff for you
does that change their inventory while being offline?
yes, and it works
and for sure, don't over-complicate stuff
Im aware this might sound stupid, but how do I tell the server that a player chatted something?
i.e. if I want Notch to say "I won!" in chat, but have any chat formatting plugins still do their thing, how would I do this?
ik i couldve used an itemstack array but i got lazy and when i was trying to get an empty playerinventory i completely forgot that i couldve used it
you could call AsyncPlayerChatEvent yourself
Call the async and normal chat event prob
This is how OpenInv gets offline player inventories
https://github.com/Jikoo/OpenInv/blob/master/internal/v1_20_R1/src/main/java/com/lishid/openinv/internal/v1_20_R1/OpenPlayer.java
its not overly complex. Also you can do as the previous and just read the data file yourself
speaking of that does Bukkit.dispatchCommand call the PlayerCommandPreproccessEvent and PlayerCommandSendEvent or do i call it manually
Ah, didnt know I could just make those. Thanks <3
That's pretty much the same story here
what do you mean?
.
playerdatastorage has its own method for that (saving and reading)
uh
Ah yes, pretty much
what method name is Server#getAllLevels in craftbukkit 1_19_R2
or maybe jikoo is manually doing that on purpose, not sure why
You need to get all players for all worlds? or just one target player's inventory?
one target player
thats literally the code u sent me
get the level world, and get the player data
k
that's an example for all players
because they handle player loading differently
ServerPlayer is just EntityPlayer right?
World bukkitMainWorld = Bukkit.getWorlds().get(0);
You can get it like that so
yes, in mojang mappings
k
or for NMS (based on what frostalf sent of OpenInv's code):
ServerLevel mainWorld = server.getLevel(Level.OVERWORLD);
I couldn't understand minecraft
why they just not saving the data in server directory?
or maybe its because each client world has its own data? so they move the world to the server and launch it easier?
?nms
It isn't easy to always know the directory for the server directory, but what is guaranteed is the directory for the world exists since you already have it. So easier to save the relevant data of the world in the same directory the world data is in.
ok last question does proccessRemoval just remove the items / modify the items from the inventory only or does it have to do something else?
Yeah, ppl just copy/paste the world
remove it, That's my function to remove a special duplicated item in game
k
can anyone help me with a bug?
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
int maxHealth = (int) player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
ItemStack heldItem = player.getInventory().getItemInMainHand();
Player player = event.getPlayer();
if (!(heldItem.isSimilar(ItemManagerHeart.Heart)) || !(event.getAction().name().contains("RIGHT_CLICK")))
return;
if (maxHealth >= 40) {
player.sendMessage("§8[§4✕§8] You have reached the maximum amount of hearts!");
return;
}
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(maxHealth + 2);
player.sendMessage("§8[§a✓§8] You have gained 1 heart!");
heldItem.setAmount(heldItem.getAmount() - 1);
}
The item equips twice when clicked once
event.getHand
that will fix the event firing twice?
Yes
This event is fired twice.
Once for each hand. You need the get the hand involved in this event and
simply return (aka do nothing) if the event with an unwanted hand appears.
I had tried doing java ItemStack heldItem = player.getInventory().getItemInMainHand(); but it still did the same thing
Ofc. The event is fired for the main hand and the offhand.
And in both cases you get the item in the main hand.
ohhhhhh
You need to check for which hand the event was fired
And then you can simply get the used item from the event
event.getHand()
So I have an if statement with event.getHand?
sorry, still pretty new to Java
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.
how to off combat with mobs please tell
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
cant understand can you tell @lost matrix
Are you developing a plugin?
so it would be something like if (event.getHand().equals(HAND)) ?
Nope
no i used your combat log plugging but in that when i hit with any mob and taken fall damage i come in combatlog i nedd only combat in with hitting with a player @lost matrix pls help bro
I dont have a combat log plugin and this is not the right channel to ask. This channel is reserved for development questions.
okay, back to the drawing board
But close
I tried isHand(HAND) but it gave me a red line underneath HAND
where should i ask
#help-server or ask the developer of your plugin directly
Well variables dont fall out of the sky. HAND doesnt simply exists everywhere. Its an enum constant for the EquipmentSlot class.
Yeah, thats why I did it
It seems to be working
The solution is
public void onInteract(PlayerInteractEvent event) {
if(event.getHand() == EquipmentSlot.OFF_HAND) {
return;
}
// Continue with your code otherwise
}
For enums you can use ==. Otherwise you should prefer .equals()
Can I replace OFF_HAND with HAND? Because I only want to equip the item when its in the players main hand
well
since its returning, it doesnt matter right?
Do you know what return does?
Yeah, I was being stupid
This is called an early escape and makes your code cleaner. Use it often for events.
okay
thanks for the tip
Yep, still works! thanks for the help!
Wait, one more question that a diffrent bug
So I have it to where when a player dies, they get banned off the server, then when a player uses a certaint item, it pardons them
the only problem is that when the player rejoins the server, they get both the items that they had, and the items that were on the ground from their death
any ideas on how to make it to where it clears the banned player so it doesnt dupe the items?
Players dont keep their items on death. That must be a gameruel you added
Thats the thing, its banning them before the death registers
Then ban them afterwards
I am
but it doesnt work
here, 1 sec
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getPlayer();
Player victim = event.getPlayer();
Player killer = victim.getKiller();
int valp = (int) player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
if (killer != null) {
int valk = (int) killer.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
int valv = (int) victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue((double) (valv - 2));
if (victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() <= 1.0) {
victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue((double) (6));
victim.kickPlayer("§cYou have run out of hearts!");
victim.banPlayer("§cYou have run out of hearts!");
}
if (valk >= 40 && killer != victim) {
killer.getInventory().addItem(new ItemStack[]{ItemManagerHeart.Heart});
} else if (killer != victim){
killer.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue((double)(valk + 2));
}
} else {
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue((double)(valp - 2));
if (player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() <= 1.0) {
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue((double) (6));
player.kickPlayer("§cYou have run out of hearts!");
player.banPlayer("§cYou have run out of hearts!");
}
}
}
kick them one tick later
how do I do that?
?scheduling
both the items that they had, and the items that were on the ground from their death
What does this even mean? Did they duplicate their items?
yes, the items they had were on the ground, and the items were also in their invetory
Do you use essentials?
the mod or the plugin?
-.-
EssentialsX?
Yes
What error?
Nothing, it was a bug in my code that failed
how many network_compression_threshold use for network with many players like 300+? 256/512/1024?
Can someone help me on registering commands on runtime?
If i register the command in onEnable it works as normal but after that the command seems to get registered only for the console sender
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
?paste
first class contains only the method to register the command and to update the commands list for every player online
second class is what the "main command" class contains and seems to work just fine if used in the onEnable method
third class is what the the command that the main command registers if ran at anytime and is pretty much the exact same thing
last thing is the plugin's onEnable method
fixed it
Hi! I need some help making a system where every 30 seconds a boss switches between a "minigame" and a normal phase, my current method seems to crash the server 😂
boolean minigamePhase = true;
new BukkitRunnable(){
@Override
public void run(){
if(boss.isDead()){
hellBossManager.handleDeath(boss);
return;
}
if(minigamePhase = false){
normalPhase();
} else if (minigamePhase = true) {
Minigamephase();
}
}
}.runTaskTimer(HalalBoxCustomBosses.getInstance(),0l,20l);
new BukkitRunnable(){
@Override
public void run(){
if(minigamePhase == true){
Bukkit.broadcastMessage("Minigamephase: true");
minigamePhase = false;
boss.setAI(true);
boss.setInvulnerable(false);
boss.getWorld().spawnParticle(Particle.PORTAL,boss.getLocation(),1);
boss.getWorld().playSound(boss.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT,1,1);
boss.teleport(HalalBoxCustomBosses.getInstance().HellBossSpawnLocation);
} else if (!minigamePhase == false){
Bukkit.broadcastMessage("Minigamephase: false");
minigamePhase = true;
boss.setAI(false);
boss.setInvulnerable(true);
}
if(boss.isDead()){
return;
}
}
}.runTaskTimer(HalalBoxCustomBosses.getInstance(),0l,5*20l);
public void normalPhase(){
while(minigamePhase = false){
if (boss.getTarget() == null) {
for (Entity entity : boss.getNearbyEntities(100, 100, 100)) {
if (entity instanceof Player) {
boss.setTarget((Player) entity);
}
}
}
}
}
public void Minigamephase(){
BlockData blockData = Bukkit.createBlockData(Material.BLACK_CONCRETE);
Location location = boss.getLocation();
location.setY(1.75);
while(minigamePhase == true){
for(Entity entity : boss.getNearbyEntities(3,3,3)){
if(entity instanceof Player){
Vector launchDirection = entity.getLocation().toVector().add(entity.getLocation().toVector().multiply(-1));
launchDirection.setY(1);
entity.setVelocity(launchDirection);
}
}
HalalBoxCustomBosses.getInstance().drawCircleWithData(location,Particle.BLOCK_MARKER,3,blockData);
}
}
net.minecraft.world.entity.EntityEvent is seemingly entirely missing from NMS - I can find it as usual using Paper's system, mapping websites, etc., but when using BuildTools and importing Mojang-mapped NMS into a project it seems to be entirely missing
Am I missing something? or should I open a bug report?
how can I set the power of a fireball or tnt in 1.8? Was that not a thing or will I have to do it on some kind of explosion event?
you can cancel the tnt explosion event and do Bukkit.getWorld().createexplosion
thanks
why do you use
instead of if?
while in your case will trigger a thread freeze
I tried if
and it wouldnt switch
but thats I think because of the menthod I used to switch
yeah I removed that now cuz I already called if in a runnable
it can be solved with if
don't use while in this case
it's for looping, not for condition checking
yeah thats a good point
what about the switching part of the code?
I'll send it again hold on
new BukkitRunnable(){
@Override
public void run(){
if(minigamePhase == true){
Bukkit.broadcastMessage("Minigamephase: true");
minigamePhase = false;
boss.setAI(true);
boss.setInvulnerable(false);
boss.getWorld().spawnParticle(Particle.PORTAL,boss.getLocation(),1);
boss.getWorld().playSound(boss.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT,1,1);
boss.teleport(HalalBoxCustomBosses.getInstance().HellBossSpawnLocation);
} else if (!minigamePhase == false){
Bukkit.broadcastMessage("Minigamephase: false");
minigamePhase = true;
boss.setAI(false);
boss.setInvulnerable(true);
}
if(boss.isDead()){
return;
}
}
}.runTaskTimer(HalalBoxCustomBosses.getInstance(),0l,5*20l);
you're using ! and == false
so in theory this should work now
yes
also
don't use == false
or == true
use if (minigamePhase) or if (!minigamePhase)
this is how you see code basically everywhere
so it's best to keep it like this
I want java to see a unique message and the bedrock to see another unique message which is different from the other
I asked geyser project lead, they told me that it's something related to spigot api
Ex.
If I type meow, the bedrock players see it I'm a cat
While java players see it I'm not a cat
It refers to the edited message by
e.setMessage.
Use geyser api to get the session and check it the player is bedrock
Then send accordingly
Might be related to the class being only constants?
@lilac dagger everything is working now, thank you. Except theres one little problem: boss.setInvulnerable(true); doesnt work.
Is there a way to fix it?
Guys?
Mention me on answering please
he already answered it
Where
I can't see the message
Use geyser api to get the session and check it the player is bedrock
Then send accordingly
thats what he said
Can you give me a code for example
I have reloaded discord
because I want to edit the message to show to the bedrock as a message in chat , and to show another unique message for java in chat also
Or is that not possible?
It should be possible, but I don't think anybody here can give a code sample
Amm, is there a way to do it or what
Ig something like what you need could either be done with geyser api if it has the correct tools or packetry
I have talked with geyser project lead
They told me that it's related to spigot api
¯_(ツ)_/¯
I dont see how making a plugin that shows different stuff to geyser players is a spigot api issue?
spigot api doesn't know about bedrock
Yes
So, you can just track outgoing packets, and if a message packet is going to a bedrock user (check through geyser api ig) modify it?
ranker = (Player) Bukkit.getOfflinePlayer(args[1]);
can i use this to get offline player as player
Why would you want to have a player objebt of an offline player?
cuzzzz my sql stuff is based on player
and i want to manipulate offline player data
I would guess, since the player doesn't exist in the server currently, that wouldn't do it
Yep, uuid is always the way
Although don't think something like that would cause the entire class to be removed? it is in Paper's NMS & mapping websites and all so it's definitely not just outright gone
Mainly unsure if it's an issue on my end or a bug I should report
okay thanks!, i added some UUID constructors to the sql stuff now it works
use entity damage event
i'm not sure if setinvulnerable works for every entity
check by entity uuid
I did, I even tried with persistant data container, or without any check
I was still able to hit him
Sounds like you didn't register your event
the whole class is registered
otherwise the damage leaderboard wouldn't show up
its weird
@tender shard Tagging you here so its not in general
I heard that some people use an extension "Minecraft Development"? Is that recommonded?
debug the event
at where you cancel it
btw this does nothing
at least cancel the task
yeah I use cancel() now
and move it on top
its on top everywhere
its the if(minigamephase){
check if the players name starts with the bedrock prefix, then just send the message via sendMessage
you're talking about the IntelliJ plugin? It adds very little features that are useful when devloping for spigot
- A project wizard that gives you a kinda broken pom.xml file
- Previewing chat colors in the sidebar
That's it. It also comes with a number of downsides, usually memory leaks or crashes.
I would not using that plugin at all, you should disable it unless you develop for fabric/forge
I would suggest to just create your project using a proper maven archetype, e.g. mine
https://github.com/mfnalex/spigot-plugin-archetype
it also has a fancy gui:
https://github.com/JEFF-Media-GbR/Spigot-Plugin-Generator
ofc you can also use gradle instead, but gradle has a much harder learning curve imho while adding 0 advantage when just doing simple projects
Not sending messages, I want in chat
Hey, idk if this is the right channel but:
I'm trying to generate a world with more ores, and I was looking for simple solutions as this is not the main focus of my project.
I have been looking for solutions, but nothing really fit me: either it's not working, or it have to be overly configured and I dont really want to spend a lot of time doing this.
All I want is to "override" minecraft's default ore generation, but with -way- more ores.
I tried using ChunkGenerator which kinda worked, but all it did was to generate more ores in the walls, which is not exactly what I want.
I also couldn't make OrePopulator work properly, even though it seems like its the way to go.
Can you help me with this ?
no problem. Listen to ChunkLoadEvent
it has a method isNewChunk() which well, gets called if this is a new chunk
then you can add you ores there
the proper solution however would indeed be to use a custom OrePopulator - you say it "didnt work properly" - what do you mean with that?
is there a way to mimic like swinging on a rope from point a to point b with velocity
hey guys, i know im probably gonna get shot on site for this, but I am running a server that uses bungeecord for minecraft 1.5.2, and I need to address a super slow memory leak present in it
i backported the spark plugin to it to check, but since its such a slow memory leak, itll still be tough to narrow down
oh hi
im very much willing to patch it myself
oh hi
it runs out of memory after a couple months
where it just straight up hangs, after erroring for a few incoming connections
which is annoying and i COULD just have it auto restart every 24hrs but thats LAME
so tl;dr need to narrow down and patch (myself) the memory leak source
but would appreciate some help especially if anyone has any insight about any memory leaks since 1.5.2 bungeecord
Try creating a memory dump when the ram is getting full
And see what objects are in memory
If your Bungeecord crashed with an out of memory error there should already be one in the folder
it never crashes, just hangs
i just checked, there's nothing in the folder related to dumps
but itll be tough since the memory leaks take so long to actually happen
i have a friend who made a fork of bungeecord 1.5.2 for a different purpose (eaglercraft); I mght be able to ask them if they encountered/patched any memory leaks when making their fork
@young knoll @remote swallow https://github.com/Jishuna/PrisonCore/pull/1
The only thing that appeals gradle to me is that it takes a lot less time to compile than maven
thanks, looks good ood enough for me but ill let coll merge it incase theres anything he says
yea 👍
yeah, that's what you are supposed to do anyway
☹️
i mean, one of my bukkit servers auto restarts every 4 hours anyways...
the other one runs 24/7 tho
(its creative anarchy with a limited world size and so I have everything reset upon restart)
but the bungee i dont really want to auto restart
specifically since i'd have to 1) sync up server crashes/restarts with the bungee
and 2) the 2nd server that runs 24/7 would be affected whenever bungee restarts
If you don't want to automatically restart it, just create a memory dump after one month or when the memory it's full
ig ill have to, thanks
I meant that the populate method wasnt called but now it is (i forgot to register the event 💀)
But now the issue is that I dont really understand how does ore generating work
does IJ have an indicator that changes have been made since the last time you have built? I've just realized i couldnt remember if i ended yesterday with building or fixing some code
uh alright more pressing question, why does it take more than a second to register a max health attribute change on localhost?
goddammit its a visual bug
ah i see
you have no idea how useful this feature is
probably pushing your project to git would do the same but...
well that's not even true
git clone a normal gradle project and you can sit down and wait for at least 10 minutes
it's because gradle thinks that "maven local isn't good enough"
"i only use maven local if it was declared using mavenLocal() in the repositories { } closure"
Can someone please explain why this is happening. Ignore the fact that I am using the package path in a method. Just trying to figure out why I can't import it
It seems like all biome related classes are gone in 1.20 nms
?paste your pom
or build.gradle if using gradle
All of it or just the spigot nms dependency
?
Could the mojang mappings be the issue?
That was it apparently
I've no idea why the classes are not present with them though
?switchmappings
i thought capcreeper already got the mappings?
yep, BiomeBase is the spigot name. the Mojang mapped name for that class is just "net.minecraft.world.level.biome.Biome"
https://blog.jeff-media.com/switching-from-spigot-mappings-to-mojang-mappings/
If you are switching from Spigot’s mappings (with class names like EntityZombie, WorldServer, PacketPlayOutSpawnEntity…) to Mojang mappings, you will notice that many of the classes you were using can’t be found anymore, since they now have different names. You will have to change all your references to those classes to their new names. Setup Mo...
that makes sense
See the above linked buide on how to switch from obf/spigot mappings to moj maps:
I feel kinda stupid now
?switchmappings
smh
screaming sandles is deprecated
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
If i add a custom logger handler and do not remove the default handler:
- does it just call the handler's publish method every time something is written to the logs?
- does it have to handle the log level manually?
goddammit it doesnt
alright
how do loggers work
maybe im printing to the wrong location
i cant tell if its not calling it or if it's not outputting anything. I'm assuming system.out.println is the wrong output stream, but idk where to go from here
log4j is a bitch with logging level
I'd need to get the logger working in the first place lol
sysout is purely for debugging, don;t use it in a production plugin
ah
its not calling it in the first place
i just put a bukkit broadcast into it
no output
are you hooking the bukkit logger or your plugin logger?
uh
OnEnable getLogger().addHandler(new GGPLogHandler());
Handler: ```
@Override
public void publish(LogRecord record) {
System.out.println("GGP Handler");
Bukkit.broadcastMessage("GGP Logger \n"+record.getMessage());
}
Bukkit.getLogger or Plugin#getLogger ?
that'd be plugin
yea
thats probably the issue
oh that's curious
exception log records dont contain the stack trace
its been a while since I played with the logger but I know when it switched to log4j it was a pain in the ass
hm
I'm trying to extract the cause message from throwable, but i only get the text 'test' which is the command I'm throwing a runtimeException
e
getStackTrace just spits out the actual stack trace
You may find these useful```java
public static String getStackTraceAsString(Exception exception) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
exception.printStackTrace(pw);
return sw.toString();
}
public static String printStackTrace() {
return StringUtils.join(new Throwable().getStackTrace(), "\n");
}```
i dont think i have access to the exception
im getting the Throwable cause
also does the logger not clean out previous handlers on restart?
👀
EntityEvent is an abstract class.
what kind of breakpoint is this lol
stop I'd assume
huh
'no executable code found'
so if true {} doesnt work as a java breakpoint
noted
welp im out of ideas
the stacktrace in test is just everything EXCEPT the caused by
Considering what google just spat out im about 95% certain using this is exactly what i need, is there a way to obtain the exception from logRecord?
At any point you can obtain the current stack by creating a new Throwable
rly?
imma try that
wait a throwable aint a exception
i have the throwable
its just not containing the stuff i need
What do you need from it? it has many components
getMessage(), getStackTrace() and getCause()
oh you edited ur message
I often do, for typos
the 'CAUSED BY: line...' part
both new Throwable and new Exception crash the server
you can;t get a cAUSEDbY IF THE tHROWNABLE HAS NOT BEEN tHROWN
err caps, I'm not editing that
ie, you can create a Throwable which has a null cause as it's not been thrown
ah thats not exactly what im trying to do here
ie `throw YourThrowable
I'm trying to catch exceptions and print the cause to the chat
caught in a try catch would have a cause
ah
yea im trying to get around try/catch
by using the message when it's printed to the logger
new Throwable().getCause() would not
if you toString on teh Throwable you can see all it has
but why is that only the exception?
is it printed to the console in two separate messages?
not sure
im pretty sure i need the stacktrace
but the stacktrace isnt the caused by
or at least not the right one
nope, it's just a list of all calls
Er, are you talking about the API EntityEvent event class?
yes
If so, please read my message - I'm talking about an NMS class
net.minecraft.world.entity.EntityEvent
Compare different mappings with this website: https://mappings.cephx.dev
I know, please read my message ;-; - the issue there was that it seems to be entirely missing when importing NMS into a project
read what message?
^
'no such instance field'
.......
are java classes handled differently?
its a non-static field and a non-static method
That NMS class seems to be entirely missing when running BuildTools and importing NMS into a project, (but definitely exists, as it's both on mapping websites & works fine in Paper's NMS tooling), so not sure why is it missing when using BuildTools & if it's an issue on my end or a bug
Yep (I know the API has an enum for that, but it doesn't include everything & all I really need is to use the constant from there instead of hard-coding in the id)
no clue, it shoudl be there but it seems its not
@worldly ingot https://mappings.cephx.dev/1.20.1/net/minecraft/world/entity/EntityEvent.html Doesn't seem to be available via Buildtools or MojMaps
Looks like a class filled with constants and no methods. All constants are probably inlined by the compiler and the decompiler was just like "lol whatever" and discarded the class because it was empty
ah
So, decompiler "bug" I guess
You could use EntityEffect.CONSTANT.getData() if you don't want to hardcode something
The names might not be precise but the ids should all be there
Or Effect.CONSTANT. Depends on which ones you need
Reason it exists in Paper btw is because they use ForgeFlower iirc which is a Fernflower fork that probably forces that class to exist
I think they might use Vineflower now? or are going to at least
Something like that. Some fork of Fernflower
But ye makes sense, EntityEffect is missing some sadly so can't really use that - I guess hard-coding one number isn't too bad for now if this isn't something that can be easily fixed
As an aside though, if we are missing some constants in EntityEffect or Effect, please do either make a bug report or create a pull request
We'll happily get them added. Super easy to do
is it possible to replicate a swinging rope animation with a player, if so how 😭
It's hard to keep up with them
Ye I think Paper had some PR for that - can't make Spigot PRs sadly, but I'll open an issue soon
An issue would be fine. I or someone else on the frequent contributors list can tackle it
Like I said, easy to add so it's not that big of a deal
I'd do it myself but I'm still away on vacation. No access to BT lol
Nah I don't wanna run BT and install a bunch of dependencies
Does anyone know what getCustomRegistry() is? I can't find it anywhere. Not even in https://nms.screamingsandals.org/
Probably registryAccess()
Probably #registryAccess (in Mojmap)?
oop
Then b() is likely getRegistry() or getRegistryOrThrow()
It doesn't seem like it's either
someone know how to create an action bar?
It does work when I replace WritableRegistry with a normal Registry
but idk if it'll work for the rest of the code
Nvm Writable registries changed it 1.19.3
Hello!
I hope you're doing well. I'm currently working on implementing ATMs in my project, and I've typically stored "blocks" within the configuration file by saving and loading raw location data (x, y, z, world). Then, I've checked for block interactions by verifying if the list contained those clicked block coordinates. However, I'm interested in improving my code and wanted to get your opinion on a more efficient approach. Do you have any suggestions or ideas to enhance this aspect of my code?
To be quite honest, using something simple like a List is probably totally fine. The time it would take to iterate that list and compare positions with the amount of ATMs that would be in the world at any given time is probably negligible.
The better way, however, would be to use a Map of some sort to map positions to some ATM object instance which should be an O(1) operation as opposed to the List which would be an O(n) operation (worst case)
Thank you so much!
what would i use to check when a zombie walks on carpet
I'm going to consolidate the issue I've been trying to solve into one message:
I've created a new Handler (java.util.logging) to print out the type of exception and causedBy messages to chat so i can quickly go back into the code and find the spot that's causing issues.
The problem is that while the Throwable in the LogRecord contains the stackTrace, it doesn't seem to contain the causedBy, but as far as i can tell, it is all printed to the chat (Stack trace and exception origin) to the console in one message
Tag.isTagged(Tag.CARPET, zombie.getLocation().getBlock().getMaterial()) or very similar
which event though
depends when you need to check
Preferably an asynchronous scheduler that checks the current location of all Zombies periodically
how much data can PDC carry on an item?
(or a specific chunk of them every n ticks)
so theres no event to check when an entity/zombie moves?
good luck doing block checks async without creating a whole snapshot
Technically infinite but after a while it'll nuke the client
or lag the server by just encoding
(iirc)
There sure is, but I am not sure whether it is a good idea to use it
thank you
updating an item's PDC for every block break would be bad for performance?
illusion'S kind of right, kind of wrong. theoretically infinite, but if it's ever sent to the player and above ~3MB / ~20MB (version dependent) it kicks the player
Depends on how many block breaks and how many items ig
It's fine
cool
maybe i'm dumb a bit, but is there a way to disable this two messages?
oh
can't attach a photo
SpigotLibraryLoader to be exact
my pc about to explode
ah i made that mistake once
Hello
I have a question: why doesn't buildtools install any files to the local repository?
Well, the problem is that I don't want to install Bukkit and I don't know if it's supposed to be like that or if there's an error
Is there any way to get a custom biome from a namespace and key and use it in a BiomeProvider?
but Spigot needs Bukkit
confused on your issue
seems like a non issue to me buildtools is working as expected
The problem is that I can download spigot but not bukkit
get the vineflower plugin, it doesnt crash anymore with it
might be quiltflower
why would you ever download bukkit
seems rather useless
I mean granted spigot builds craftbukkit jar if for some reason you'd ever want that
Hello guys, i have a wildtp plugin and i wanna let the normal players do the command /wild bcz its only works for the op players.
does anyone know how can i enable it for the normal players ?
ok
Okay, but I can't add bukkit to the local repository using buildtools
yes you can, im pretty sure it mvn install its when running anyway
i dont think bukkit can even run as a server on its own
you have to use craftbukkit
No these are always logged to console at the INFO level. No way to disable these. Though it shouldn't matter too much given they're only sent once at the beginning of the server log. It's a server log after all. It's meant to log important information, and runtime library loading does seem pretty important 🙂
Unsure why it's prefixed with SpigotLibraryLoader though. Definitely not something we added. Probably a Paper addition
paper
its probably to have them not get screamed at for "breaking maven central tos"
if you really really dont want those lines use libby
When is getAddress from Player supposed to return null?
Maybe, but it happens when using h2 dependency
it will happen with all libraries
so during PlayerJoinEvent and PlayerQuitEvent, I can ignore this?
So understandable
It will most definitely be available in join and quit, yeah
okay thanks
https://github.com/The-Epic/libby this is a fork of libby which does the same thing but with 1 line message only on download, all the fork does is modify some of the messages and make it download it to the server libraries folder instead of the plugins data folder
(https://repo.epicebic.xyz/#/ repo link if wanted)
Oh, I was wondering how there were 25 forks but zero stars
I guess GitHub displays the forks of the parent for some reason
its a fork of a fork
.
any better way for getHUDHealth to return 50 full and empty strings max?
how can i add hex color support in a plugin? (for command output and player messages)
hmmm I'd use components personally
its easiest that way. Though if you're doing the proper thing and parsing from configs I'd suggest just using something like MineDown or MiniMessage
If you're wanting your health bar to be only 50 characters long, then the way you've written it is the best way to do so
If you want things to be more clear, just a few more variables would be fine
public static String getHUDHealth(Player player, String full, String empty) {
double healthPercentage = player.getHealth() / player.getMaxHealth(); // (should technically be using attributes here)
int fullCharacters = (int) (50 * healthPercentage);
int emptyCharacters = 50 - fullCharacters;
return full.repeat(fullCharacters) + empty.repeat(emptyCharacters) + " " + player.getHealth();
}```
I mean just mathematically it's impossible to be more than 50 characters. So what you're seeing on screen is probably 50 characters
If you want less, reduce the amount of characters I suppose
how's that hud thing handled? I'm curious how it's beind displayed
boss bar and negative and positive space
Yep
that doesnt look like a bossbar lol
the bossbar has no texture
you can do it with action bar too
I'm also looking for help with loggers but apparantly nobody knows about those
wouldnt that interfere with health boost stuff?
except you have to also account for other peoples action bars and adding dynamically doing the space math
resourcepack and shaders
thanks
aslong as its made correctly it shouldnt
lemme test
you can use negative and positive space in action bars too, to get water on a hud
it just takes a lot of work to try and dynamically add the negative/positive spacing according to char length
well this is using an actionbar too
damn
but i use shaders to move it into top-left
i thought it was bossbar
nope
bossbar is a nice idea too but for updating its very heavy
it has a lot of cpu usage on the server
you can display a single lined text without icons
but for more lines and icons, you need resourcepacks
with bossbar specifically you mean?
yea
pretty sure you can have multiple bossbars visible at once
for mine its an actionbar
you can use bossbar too but its limited to 1 line
also you can't allign it in top-left always
half of the text goes behind the game screen
thats why i use resourcepacks for icons and multi lined text
Can someone provide some guidance on gaining traction on your plugin?
If you provide a unique quality plugin it will come naturally. No real way of promoting it without being annoying
can i get bukkit color directly from hex?
md_5 import ChatColor.of(...
how do i secure my bungee network
same answer you got in the other 2 channels
sometimes the spigot developement help forums confuse me
https://www.spigotmc.org/threads/error-playerquitevent-could-not-pass-event.619085/
made their own eventbus that listens to bukkit events
like if ur gonna make a listener and have to register it why not just make a listener???
im trying to make my players velocity be set like a pendulum
but its like
not working 😭
like its shooting me in a direction really high
if (!player.isOnGround() && !player.isSneaking() && anchored) {
double angle = Math.PI / 4;
double angleV = 0;
double angleA = 0;
double len = 15; // Length of the "rope"
double gravity = 0.01;
double force = gravity * Math.sin(angle);
angleA = (-1 * force) / len;
angleV -= angleA;
angle += angleV;
double velocityX = len * Math.sin(angle);
double velocityY = len * Math.cos(angle);
player.setVelocity(new Vector(velocityX, velocityY, player.getVelocity().getZ()));
}```
It's not creating the advancement from the config, I'm honestly not sure why.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
You don't seem to be doing anything with the json
divide by 20. Velocity in blocks per tick iirc
also y is up
not z
divide what by 20
speed?
your calculations look like they're done under the assumption of distance per second
youre setting distance per 50ms however
i translated thecodingtrains sing pendulum from js to spigot
it aint loading for me
what isnt
the code example
oh i think i know what it is
the code is calculating the pendulum's position, not velocity
so since you're using speed instead of position, the players move much too far
either figure out some calculation for the pendulum speed or use the distance from the previous to the current position of the 'pendulum' each tick as speed
@thin iris
so I am building reward system when player is fishing
I figurate out how to get item which is caught thru event
but problem is player can throw that fish on floor and spam it again
abusing the system
thats how normal fishing works too aint it
I only want for reward to be executed when fresh fish is caught
if u understand me
wait
well yea
capture it again
PlayerFishingEvent
or that
yea I solved it, only thing now is, is it possible to make the description display a minecraft scoreboard
hevaily based lol. it doesn't even show gradle taking 3 minutes to download the dependencies because unlike maven, it cannot just grab them from maven local but instead wants to copy them
also it needs to download itself, usually 100-150mb lol
gradle is great and stuff but it's not perfect and some things are definitely upper bullshit
Is there a way to make a advancement description use minecraft scoreboards?
if you specify mavenLocal it will, might also check external poms tho
often user error
anyone experienced in python or more specifically sqlite3?
I have a python script that loop through thousand of json files and saves them to multiple tables inside sqlite3 database by using 5-6 insert into queries but its so slow (only 4-5 file is read and saved in database each second) how to make this queries faster by executing them all at once or some other approach? I can show you the code with anydesk help is appreciated
I'd use a different programming language like Dart
If you're worried about speed Python isn't the way to go
Ye but that's just a one time thing. I thing it's a fair trade, especially if you need to compile a larger project frequently
wat the fuck
sir this is spigot
Java != Python-nal
Spigot == Java-val
.-.
sounds about right but this is still Spigot
"Serious Spigot and Bungeecord programming/development help"
thats the channel description
yw babe
well, its not spaced
so it is bungeecord programming and bungeecord developement
not bungeecord progranning or developement help
true
i need help if anyone knows python and sqlite3
if i make online-mode false they plugin author can't they plugin check for updates?
Try it and see
Maybe learn a bit about what that method does
where does gradle save downloaded dependencies?
Turning off online mode won't kill plugin updaters what
.gradle iirc
bc its per project
just checked it, can't find anything
some stuff might be user home .gradle
what?
is there any other way ?
yes if the plugin provides the method to disable it
otherwise no
simply dont have op permissions, and dont add update notification permissions
and there you go
is that even a development question? are you coding your own plugin?
no i just dont want the plugin author have access on my server in case he would disable his plugin
what
is it a pirated plugin by chance
no
i feel like it is
so there is not a way to disable access his plugin on my server?
correct
sad
well you can uninstall the plugin
or check the source code, line by line
no trusted plugin dev would add any backdoor whatsoever
or i can make my server online-mode false and disconnect my internet ?
online-mode has nothing to do with that
if you disconnect internet people cant join it
its local host so
online-mode specifies if it should verify accounts with mojang auth servers
i dont care
and disabling online mode means EVERYONE join pretending to be notch or whatsoever
i have it for my personal use
then you can disconnect internet, sure
whats the point?
i have no clue
they don't trust a plugin but still wanna use it
it will activate
rule 1: do not download / run .jar files if you don't trust them
absolutely
rule 2 is the same
i'll have to replace every downloaded jar on my private server
then run no other
XD
I somehow read it as "pirated server" lol
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
plugin.playerManager.put(player.getUniqueId(), new PlayerManager(player.getUniqueId()));
System.out.println("Added player to hashmap");
ItemStack kitSelectorBow = new ItemStack(Material.BOW);
ItemMeta meta = kitSelectorBow.getItemMeta();
meta.setDisplayName(ChatColor.GREEN + "Kit Selector" + ChatColor.GRAY + " (Right Click)");
kitSelectorBow.setItemMeta(meta);
player.getInventory().clear();
player.getInventory().setItem(0, kitSelectorBow);
player.updateInventory();
}```
stupid question but
this doesnt give me the bow and i have literally no idea why
the only roadblock ive hit so far in this entire pluginb
Forgot to register the event or forgot the EventHandler annotation?
that could only be it
yes it does
and the print happens aswell
imnot braindead im just like
the code is sentient or something not following lines
Whats up with the updateInventory call?
and why is updateInventory needed?
i read that if you dont have updateinventory then it wont replicate clientside
That is only the case for out of sync inventory events
Like disabling hot swapping, right?
I usually use an update inventory there
tru
that way your issue won't be found anymore
or make a little delay then give the kit selector on join if you wanna clear inv on join
Could be a problem on server crashes. On login is probably safer.
Legit
I actually never tought ot it
cheers
aswell for minigames
i should just make the server be the minigame "game" and then throw it in like .. bungeecord?
and that handles lobbies and stuff?
brutal
What hypixel does is have "mini" servers with their small minigames
(and their game system is so modular they just toss all games in their "mini" core)
And run 1 game / server based on demand
And then lobby servers are separate
this is my first time touching java
but ive done c++ for a few years now so it's not too bad
I struggled with the countdown for like 3 months
yeah lmfao
I can write a minigame in like 30 minutes now
i'm recreating an old hypixel gamemode that was removed
But that takes a core that took me like 10+ hours to write
im gud
I'm adding debug printouts to my code thats linked to my uuid instead of perms, would u say that's going too far or fine?
i got this problem with args, how can i fix it? (i just started learning java)
thats cuz its named strings
and if you plugin is public, no public debug will be available
autocomplete can be weird
bruh rsw is not old actually
the game mode does not exist
wha
totally fine, I usually have a method ```java
private static boolean debug = false;
public static void debug(String... text) {
if(debug) {
for(String s : text) {
Bukkit.getLogger().info("[DEBUG]" + s);
ah i meant like a non-perm bound command
so i can log in, check on stuff, and leave without having to rely on logs
thats also why im so pissed off about loggers atm
oh you mean, you send the debug messages to yourself if that UUID is online?
basically yes
I wouldn't do that, I'd rather make it configurable for the admin to enable or disable the logging
many anti malware thingies check for hardcoded player names / UUIDs
-me hardcoding minigames-
ono
I've been ripping my hair out all day
and people on the java server im on dont answer to this question
*the other java server
@tender shard ?
sure, I wrote a blog post about how to hook into spigot's log4j
you have a long ass name
my name is Alexander Christian Majka, if that helps?
yeaht he last name is polish
That's.. A Hungarian musician
my grandpa was from poland and my grandma was from russia
the other side was german
cant find it https://blog.jeff-media.com/?s=logger
Spigot uses Log4j to log console output, hence making it easy to listen to incoming console messages, or to block certain console messages from appearing. Prequisities You need to have Log4J on your classpath. We simply add the dependency to our pom.xml using the provided scope, as Spigot already contains those classes on runtime: Create...
oh that one
not sure if this helps you or anything, I don't really know what you're trying to do
get the 'caused by' message
oh yeah I read that
for some reason i only get the stacktrace
I dont have IJ open right now, but take a look at Throwable#printStackTrace() (the decompiled code of that)
how does it look like?
1sec
it seems to also loop over the "enclosed" stacktrace
are you catching the exception and then throwing it into the logger?
if so, you can use printStackTrace(InputStream) and throw the loggers stream into that method
no, im just doing 'throw new runtimeException'
i want to generally catch all exceptions, then figure out if my plugin caused em
for that i need the caused by
huh
cuz i doubt my name is in any other plugin lol
yeah tbf you could actually follow my blog post for that
then check for incoming log messages that contain your plugin's package name
the stack trace should show the the the the the i cant remember what the fuck forrás is in english
but it should show the classes
so
it already shows if its urs or not
can i put a stringbuilder as a output stream?
i want to check on something
printwriter/printstream
ah i got it
I don't know if that's possible. you could write your own PrintWriter that shoves all the input into a strinbguilder ofc
now i need 3 minutes and a server
@tender shard GUESS WHAT I FUCKIN FOUND
Object test = thrown.getStackTrace();
THIS is the StackTrace
StringWriter out = new StringWriter();
PrintWriter out2 = new PrintWriter(out);
thrown.printStackTrace(out2);
String wtf = out.getBuffer().toString();
And THIS is the SAME DAMN THING BUT includes the CAUSED BY
WTF BUKKIT
im so mad
any idea why this nonsense happens, anyone?
oh well that's not a bukkit issue
it does surprise me that getStackTrace includes the "caused by" though
i mean its gotta be somewhere
I would have assumed that StackTrace has a separate method for the caused by thingy
because getStackTrace only returns an array of StackTraceElement, doesn't it?
wont return the whole shit for sure
i already tried it
didnt work
but i was ok with it lmao
well yes but... those elements are the string parts of the stacktrace encapsulated
thats it
see the image i posted
here
what is thrown
org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin GreekGodsPlugin v1.0.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:875) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchServerCommand(CraftServer.java:860) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
at net.minecraft.server.dedicated.DedicatedServer.bf(DedicatedServer.java:413) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:389) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1198) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1015) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.RuntimeException: Test
at io.github.moterius.GreekGodsPlugin.Command.CommandTest.onCommand(CommandTest.java:30) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]```
what exactly are you trying to do
oh i figured it out
see here
at this point its already initialized cuz it's printing the full error to the console
i was just pulling out my hair over the fact the fuckin log didnt seem to have the full error
perhaps you were doing the forbidden RuntimeException(underlying)
which hides the trace
thats got nothing to do with that
the proble is the formatting of the stacktrace in the log
тебе повезло бро что они смогли добраться до сша
no clue what you mean. all my grandparents were living in germany
I think I was the only one from my family to have visited the US
but that's a long time ago, I think 2010 was the last time I visited US
а так ты в германии живешь тогда извиняюсь, ну мы получантся соседи я в Польше, я подумал ты в такое время не спишь значит у тебя часовой пояс как в северной америке
haha nah I'm from germany and I'm usually awake at weird times. But please keep in mind that the server rules are "english only"
Does anyone know of a reliable way to listen for when an Openable block is opened or closed, or at least a door or trapdoor? Listening for PlayerInteractEvent sort of works but I have to manually check for a lot of conditions that could change between Minecraft versions myself and I have to listen for it being changed by redstone separately
There appears to be no other standard event to do so
I was on this server and they have this massive hologram, does anyone know how they could've done it?
?paste