#help-development
1 messages · Page 1458 of 1
or just compare Material
yes
someone able to join a server to test something for me?
a Workbench
sure
nope
how do i get create temporary team in scoreboard?
defaultTeam.setPrefix("§7");```
i use this
but it saves it into scoreboard.bat
and i don't want that
@eternal oxide can i steal your code for it if you get it working 😄
yep
awesome
Not sure I will. I'm just playign around
Well, fingers crossed
I can get both players using the same workbench, but one of them can't craft as its treated as a normal inventory
I wonder...
how do I load a yaml that's inside a sub directory
you use google
k
Reverse of saving
can you try one more test
if i define a vector in the direction of a player and define another in another direction, can i create a distance between these two directions with the pitch and yaw axes?
i can craft
I can too, but seperate inventories 😦
oh so File file = new File()
then a.load(file)?
ohhh
I can get both using the same crafting inventory but only one can craft.
It seems only possible using nms
how to get the time in the real life?
I tried using the same location, but it just creates a seperate inven
a combination
When the first player opens you openWorkbench, then store the TopInventory reference, so any subsequent players open that inventory
That allows you to all use teh same grid, but the one who opened it as an Inventory can;t craft
Riiiight, what does the boolean do
forces it to open a Workbench even if teh location has no workbench
ah ok
I have a really bad idea:
you could just manually set the result
oh wait, that might not work anyways, cause it would not consider the ingredients as ingredients
ok
How are you moving stuff in my inv?
lol, It seems it can work as crafting, but the result is not filled in for me
that was so weird
I could access your inventory by storing the View and opening that
lmao
So close, but its not quite right
Now that is an actually good invsee plugin right there
i get player's scoreboard and register new objective inside it
This is the code thats forcing everyone to have seperate Workbenches java getHandle().openTileEntity(new TileEntityContainerWorkbench(getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
In CraftHumanEntity
yes
Hmmm, i mean, If there was an easy event listener for change, you could just get the contents and for every Viewer just set the result
But idk other than that
yuhuh
is there a way to check a string like if title.equals("add" + anything here)
im trying to make a gui that has 2 functions based on the title, but same items
ok so
so if the title is "add location" it will run command "add location"
it does work, but not 100% of the time
but if the title is add item it will run command "add item"
if u try enough, the item will get stuck and wont be canceled
Objective e = board.registerNewObjective("Tablist");
i register new one
on the main
that's the wrong way to do that, don't do that xd
why is that
it works for me
you're comparing inventory using its title
and the item clicked, plus i have an unique id for my plugin in the title name
#help-development message can some1 help me with it ?
can u come in private?
There is not going to be anything ground breaking enough not to share
if you can share it private you can share it here
sec lkoging to pastebin
?paste
holly
Boolean displayHealth = Settings.getValue("DisplayHealth");
Boolean updateName = Settings.getValue("DisplayUpdateAboveName");
for (Player pls : Bukkit.getOnlinePlayers()) {
sendTablist(pls);
if (updateName == true) {
loadTeams(pls.getScoreboard(), pls);
}
if (displayHealth == true) {
removeHealth(pls);
showHealth(pls);
} else {
removeHealth(pls);
}
}
}```
oke
So it won't save it in scoreboard.bat?
oke
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
i did like this
how should i use it instead?
oh new
oke Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
so this
will not override player's scoreboard?
like this
already have it
but will it override player's scoreboard?
because i don't want to override player's current scoreboard
It's in different plugin the scoreboard
Objective?
I used to use objectives
and it worked
but it stored the teams in Scoreboard.dat
which i didnt want
because it makes the player wait longer
Can i do it with objectives?
like get player's scoreboard
and register new objective
I have a problem: when i want get type of 1.16 item my return is "AIR"
code: String itemType =player.getInventory().getItemInMainHand().getType().toString(); player.sendMessage(itemType);
if a player is holding nothing or what?
hey there so i have this part of my code which once a player dies it sends them back to the lobby, and then unloads all the worlds on that bungeecord server for example World1_overworld World1_nether & World1_the_end and then deletes them. but for some reason the world that the player dies in doesn't get deleted. im getting no stacktrace.
Hey @eternal oxide you mind sending me what you got to
I'm still digging through nms
that is to say?
here is the function. do you want my full class?
public void GameEnd() throws IOException {
for (Player player : Bukkit.getOnlinePlayers()) {
plugin.runners.clear();
plugin.hunters.clear();
plugin.playermanager.clear();
plugin.playersInGame.clear();
plugin.playersLeftGame.clear();
player.getInventory().clear();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
plugin.sendToServer(player, plugin.getConfig().getString("Settings.Hub"));
}
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Bukkit.getServer().unloadWorld("ManHunt", false);
Bukkit.getServer().unloadWorld("ManHunt_nether", false);
Bukkit.getServer().unloadWorld("ManHunt_the_end", false);
FileUtils.deleteDirectory(new File("ManHunt"));
FileUtils.deleteDirectory(new File("ManHunt_nether"));
FileUtils.deleteDirectory(new File("ManHunt_the_end"));
Bukkit.createWorld(WorldCreator.name("ManHunt"));
Bukkit.createWorld(WorldCreator.name("ManHunt" + "_nether").environment(Environment.NETHER));
Bukkit.createWorld(WorldCreator.name("ManHunt" + "_the_end").environment(Environment.THE_END));
}
``` and yes i know that i have to fix the Thread.sleep thing. its just there for testing purposes
?paste
lmao just said that its for testing purposes
i was going to fix that
do you mean in between Bukkit.getServer().unloadWorld("ManHunt_the_end", false); and FileUtils.deleteDirectory(new File("ManHunt_the_end"));?
Where would I learn how to do custom world/terrain generation and adding custom ores/blocks?
you have a long way to go
how do I write FileConfiguration to a custom config file
you use google
That seems unlikely
javadocs has it lel
instructions unclear how to goooogloo
Just Fucking Google It helps you help others to use Google and search on their own!
imagine googling how to use google
lmao
Hello! Sorry to interrupt, I am having trouble adding a lore to an item when combining it with another in an anvil. Here is my EventListener.java https://paste.md-5.net/ikefugefin.java
wew
?paste
?paste
Is player#getStatistic available in <1.13?
i always thought it was easier to read code here than clicking on a link
no
oh
any ideas on how to edit preexisting jar files, if i want to adjust just a couple of lines
??
decompile, edit, recompile
ctrl +c + ctrl + v
Very sorry, fixed it.
after i decompile its missing libraries and getting a lot errors tho
decompile
Thank you!
.
Set the meta before you add it to the inventory
make e.getInventory().setItem(2, result); the last line
If you're lucky and whoever compiled that jar used maven, their pom is inside the jar as well in the META-INF folder.
maven mmm
well, look at what ur missing and get them ><
Ok. Is this what is stopping the item from being added at all?
what :/
Errrm, no
I dont understand Exclipse
is Filippo you?
._.
@tidal dust i think there is a better event listener for this:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/PrepareAnvilEvent.html
declaration: package: org.bukkit.event.inventory, class: PrepareAnvilEvent
Yes? Because i've had issued with the getPlayedTick stat
Oh, for some reason when I place a lingering potion (in my test i used a lingering potion of slowness) and a diamond block, nothing appears in the output box, and the arrow has a x over it.
Oh, let me check that out
where on the javadocs can I find stuff on creating custom bloccks and such?
yeah, have a look at that
Wdym 'Custom'
ones that I make myself, in the code
There won't be anything, cause it ain't possible
Cause the client doesn't know how to interpret it
does it matter if i reference a 1.16.5 library :)
so it wont work im guessing
most likely not
does anyone have a quick link to 1.9 spigot?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
oh yeah true
christ overwriting someone's code for single patch is much more difficult than anticipated
which is why you say "no" when someone tells you to do it for a project that's not open-source
do I need to import anything to use Logger?
yes
i feel like ill copy all the classes all the files individually and it will be faster
-_-
like i have no idea what to do
when i put the new version of the plugin back it only took half of the storage of the previous one and it didnt even show up as plugin after i ran the server
any ideas for good player health display plugins
ty,
1.9?
1.16.5
what's the point in using 1.9?
no just 1.9 was the thing that the revious plugin used, and its like impossible to adjust it
when would WorldLoadEvent be triggered
when a world is loaded
like server start?
how did i mange to copy a chest with internal items? whenever i place it it has the items
or player join
lol no
under what circumstances would a world be loaded
declaration: package: org.bukkit.event.world, class: WorldLoadEvent
when the world is loaded 🤷
oh shit with ctrl you can copy a chest and it data
wtf
whenever a world is loaded into the server first WorldInitEvent is fired (precisely after instantiation), then WorldLoadEvent is fired once the world loaded in stuff into memory like chunks etc
lol its fine 🙂
oof
CraftBukkit's repo of course
damn never seen that happen on any gh repo b4
Anyone have an example of PacketPlayOutOpenWindow for 1.16?
?Paste
this is the code for automatically disabling
natural regeneration
but for some reason, non of the logs outputted
Did I overlook something simple?
nvm I figured it out
Does anyone know if you need to use setDescriptionComponent(BaseComponent description) to set the motd on a proxy ping event for a BungeeCord plugin? setDescription(String description) is deprecated or am im totally off track with this....
i have an a question i trying to make multiple items and for each item i made it events like Item1.EntityDamageByEntityEvent Item2.OnFish
but my question is on a event is fired for example EntityDamageByEntityEvent how i can get all items in a folder so i can fire it event instead of making listener for each items
how do I create a taskbar(or whatever it's called)(actionbar?) that updates every tick
so 2 problems 1. how to action bar 2. how to have something happen every tick
but how do I schedule an event tho
@ILikeToCode so should i use the deprecated one or the on with the BaseComponent?
anyone ello
wdym
i creating it through itemStack
classes
I actually made a plugin which does this not too long ago, I’ll check my computer later and see if I’ve still got it and you can see how I did it
Essentially each item extended a CustomItem class and then if I knew an events item was the same one as the customitems item stack I could cast it and run the event
Event method for that item*
ok thx i hope u still have it
yoo
I believe there’s a good api for it, may even be protocolsupport
@ILikeToCode do you know how to create a BaseComponent, im having a hard time even figuring out how to create one it....
so there's no good way to do it by oneselves?
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
another question is there is a way to make a itemStack item have a uuid for database saving for an example an item have random damage value on it lore but on hit i want to import that item data from a database and check it damage instead of reading item lore
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Statistic.html
i cant find Distance By Elytra here?
declaration: package: org.bukkit, enum: Statistic
TextComponent test = new TextComponent();
test.setText("is this working!");ping.setDescriptionComponent(test);
fuck
If I was suppose to replace ACTION_BAR with that it's the same error
@quaint mantle am i far from doing it right?
TextComponent test = new TextComponent();
test.setText("is this working!");
ping.setDescriptionComponent(test);
it just says something about it not existing
.
I think it just doesn't recognize ChatMessageType
for some reason
cause
ChatMessageType A; also gives error
repository?
spigot api you mean?
did you mean the api
What dependency are you using?
Because ChatMessageType should be included in the spigot one
https://paste.md-5.net/ukubabuhib.cs
Why wont this work?
1.16.5-R0.1
import
What isn't working
I dont think the plugin message is being sent
I followed this guide https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-intellij-idea/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
but the player isnt null
Did you import the spigot or craftbukkit jar
Uh import the full spigot jar
@quaint mantle i'm sorry, for asking so much... But TextComponent.fromLegacyText("test", ChatColor.AQUA) returns BaseComponent[] and if try to setDescriptionComponent with test[0], i get a lot of errors so i think i'm still doing something strange... On of the errors are "Index 0 out of bounds for length 0" so i guess the text is not even there......
Yes
Hi! I want to start plugin development and I have found a good tutorial. It calls for the Spigot/Bukkit JAR file and I can't find it. The tutorial tells me to get it from getspigotmc.org but this URL doesn't exist. Please help
google "Spigot build tool"
wait so do i use the BuildTools.jar from Jenkins?
You download the BuildTools.jar and use to to locally compile your spigot.jar
nonononononono
Not THAT site!
lmao. Props to the ass hole that bought getspigot.com and directed it to their hosting company
goddamnit
Funny enough, that hosting company is also advertising Hytale servers

but yeah RE: BuildTools. Download it, stuff it in a folder and run it, will build the latest version of Spigot for you
?bt
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
No, just java -jar BuildTools.jar
That's it. That's all you need
Unless you're building a version other than 1.16.5
java -jar BuildTools.jar --rev 1.12.2
so what jar do i add to my project libraries?
@quaint mantle DUDE!! thank you so much! finally got it to work! Thank you!
Let BuildTools run and it will generate a spigot-1.x.x.jar for you
That's what you'll use
Should take anywhere from 5 - 10 minutes on first run depending on your internet connection and hardware
Subsequent runs will take like 1 - 2 minutes
Ohh ok ty :)
Can I debug my plugin with breakpoints in IDEA?
help meh xD
You have an invisible separator character in your plugin.yml
Some systems will try to use that in place of tabs, though tabs aren't supported either. Anywhere you have a tab, use spaces
thonkkkk
Oh, sorry, it's in a schematic file
xd
It's loaded with YAML For some reason so I was confused lol
neither
Hey guys, looking for a way to get all active boss bar in a world / a server thanks :b
ty I will take a look
hi can someone help me i am trying to make it whan it get to 00:00
it's wiil do something like summon particle
i need to use while?
don't work :/ the getBossBras method doesn't return bar created with creatBossBar method or boss bossbar
package me.moob.hardersurvival;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
ArrayList<Location> listOfblocksplayersplaced = new ArrayList<>();
getServer().getPluginManager().registerEvents(new eventThatChangesListOfBlocksplayersplaced(listOfblocksplayersplaced), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
I want to keep the list the same until the world changes to a different seed, does this work?, or does the list reset when the server restarts(not the world). and if so, is there a better method?
not Location like real time
the list will be cleared when the server restarts
You would have to save it to file if you want it to persist
so save it to a file in the plugin?
some one can help me or i will die jk
Although, i reccomend a Set over an ArrayList @livid tundra
the list will go away after the plugin is disabled
I'm creating a boss bar with createBossBar method but If the server crash when it restart the old boss bar is still active because my plugin didn't has the time to delete it before the crash so I want to delete it. But problem solved, I was using /rl so bars are not removed but if the server crash / reload all bars are removed so it's okay
@quaint mantle
arent files slow
private static BossBar bar = Bukkit.createBossBar("EnderDragon", BarColor.PINK, BarStyle.SOLID, BarFlag.CREATE_FOG, BarFlag.DARKEN_SKY, BarFlag.PLAY_BOSS_MUSIC);
u mean save it to a file
ty
so I should fill the list from a file on onEnable, and then save it to a file on onDisable?
yeah
hum interesting, how I can do ti ?
idk what is YamlConfiguration?
what is YamlConfiguration i never heard of it
oh its a spigot thing is that why i see gson in my dependencies when i didnt put it in my pom.xml
why tf is your bounding box at your feet when you are gliding lol
wait, should the file be outside or inside the src
wdym by src
the src folder
oh, it should just be created by the plugin rlly ig
What's the most effizient way to store data per Player permanent
but if I create the file, there will be a new file every time I run it, which kind of ruins the point
wait, nvm
it will just save over top
?
of the existing data
I was thinking of checking if the file already exists and then creating it
like this: ```java
File myObj = new File("filename.txt");
if (myObj.createNewFile()) {
System.out.println("File created: " + myObj.getName());
} else {
System.out.println("File already exists.");
you need to do it in the plugin Data Folder
also, the createNewFile() will just create a file no matter what
database u could do files but thats slow
It would be like myObj.exists() or something
Heya @eternal oxide you manage to get anywheres? 😄
Nope, I've fallen down the rabbit hole of nms
ohhhhh, thats a one way trip 🙃
wait what is he doing?
Linking two crafting inventories together
Experimenting with shared crafting
thats sounds easy but not at the same time XD
Its really not ><
And also i find that as soon as you involve nms it gets more difficult as things don't get documented
cant you get all the items in one of the crafting inventories and then put it in the other one in the correct slots?
I got it working (without NMS) as far as each player could see their own inventory and had a shared crafting grid, but only one of those players could actually craft.
my intelij needs updating
You could both put items in, but only one player coudl see and pull out results
Did the other player's inventory view function as a crafting table if you manually set the output?
or was it just a pretty chest 🤣
I didn;t try
fair enough
I started diving into nms
nms sucks kinda cuz u need reflection to even use it or it just supports one version i mean if you dont care about it being one version then its fine but still i dont like using nms
w3schools(the source I got it from) says it will return false if there is already a file with that name
ok
idrk
Not really, it would require extending the ContainerWorkbench class to accept multiple EntityHumans
Huuuuuh, im thinking we go the non-nms way and then do some hacky stuff...
what are you even making that needs that
Persistent Crafting Table storage
or modify openWorkbench to accept an extra value to reuse its TileEntity
I tested it with a not minecraft test code and it worked, not sure if it will work for the minecraft plugin
This ^^
but it needs to work for multiple people
Cause atm you can easily just dupe glitch it
If this method were modified to allow reuse of the TileEntityContainerWorkbench.java public InventoryView openWorkbench(Location location, boolean force) { if (!force) { Block block = location.getBlock(); if (block.getType() != Material.WORKBENCH) { return null; } } if (location == null) { location = getLocation(); } getHandle().openTileEntity(new TileEntityContainerWorkbench(getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()))); if (force) { getHandle().activeContainer.checkReachable = false; } return getHandle().activeContainer.getBukkitView(); }
it creates a new one each time its accessed.
hahha, yeah i saw that earlier when u mentioned the src
it only needs to accept a int argument.
what about if we ping md_5 right now to just add the ability to add an extra arg which is an existing one 🙃
what the int id
i mean do u really need this
yeah i kinda do want it
seems useless
yep, if you provide an id it would open the existing TileEntity if it already exists
Stop being so defeatist
If only
actually
it wouldn;t need that, it would just base it on the location
same location = same bench
Map of TileEntities with the location as a key. Remove from the map on closeInventory
is the source code of bukkit and spigot obfuscated?
no
no
Wdym
why tho
I have no use for it, but its a fun thing to attempt
its free software, whats the point
only nms is obf
bruh
It makes sense that Mojang want to protect their code
stupid bot
lmoa
lmao
Mojang have to make a minimal effort or they can't so easily sue anyone who tries to steal their code.
If not, the people can make the argument that 'they didn't bother to protect it anyways'
i made this odd thing for some reason public Player getPlayer(CommandSender sender) { if (sender instanceof Player) { Player player = (Player) sender; return player; } return null; } and i really dont know why since its pretty pointless
I can't remember if its Copyright or Trademark, but you have to do some level of defending your mark or its no longer yours.
Hi! Im creating a fake break effect with protocollib but after its done with its animation it gets stuck at the last stage of the animation. Ive tried sending a packet of 0 or 100 (to remove it) a few tick later but it didnt do anything
PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.BLOCK_BREAK_ANIMATION);
packet.getBlockPositionModifier().write(0, new BlockPosition(location.getBlockX(), location.getBlockY() - 1, location.getBlockZ())); //position
packet.getIntegers().write(0, new Random().nextInt(2000)); //entityid
float divideby = timeAlive / 8;
if(tick[0] % 3 == 0) {
packet.getIntegers().write(1, (int) ((Integer) tick[0] / divideby)); //stage
try {
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
protocolManager.sendServerPacket(onlinePlayer, packet);
Bukkit.getPlayer("InvertedOwl").sendMessage("send packet " + tick[0] / divideby);
}
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}```
hi i just have a question how can i add some string to mysql that looks smth like sdfghj\\y\y:¨'\n bcz i get this error https://paste.md-5.net/ebovotafaf.makefile
i believe : ¨ ' \n are not allowed in mysql
\n might
i know its not allowed how do i fix that
u cant
its probs disabled for a reason
hash it?
well yeah
wait no
dont hash
its one way - im dumb
yeah lmao
ok thank you, also, is there a way to detect when blocks are destroyed by an explosion? or just destroyed in general
i was about to say that
which way
yeah, you can do getBlocks() or something on the event - or block break event
it goes forward but not backwards hashing does
Yes, the explosion event has a blocklist
okay
so after u hash something u cant unhash it
nope
u can compare hashes tho
so like a fireball would be entity explode event right?
yes
tysm!
yeah its kinda weird that its not the explode event
Explode is for tnt
i wonder why they did that
no the explode event is for unknown explosions
ohhh, sorry yeah it is the block one
no
no?
Block is for things like beds. TNT is entity explosion
but why isnt explode event for everything lmao
It is? huh i mean i guess it is an entity b4 it explodes
TNT, fireballs etc are all entities
yeah primed tnt is a entity
makes sense
its basically a falling block with explosion
lmao
actually it probs is a falling block lol
which that is a entity
According to the zzzCats guy from paper earlier, the EntityHuman#openWorkbench() creates an inventory which is basically weirdly linked to the player it was for, hence the crafting didn't work
yes
they reckon'ed the only way was to manually set items
You can get the top inventory from the returned view, but if you have a player open that as an inventory its not recognized as a Crafting inventory
Yeye, just thought i'd let ya know just in case ya didn't know
what
what = what
If Player.openInventory treated teh top inventory correctly as a workbench it would all work as we want
but it opens it (hence the name) as an inventory
yep, its just one of those stupid things
i saw this thing and it says u can create a inventory with InventoryType.CRAFTING and then it works Lmao
thats what i saw on a forum
I think i saw that thread, it used nms right?
its actually InventoryType.WORKBENCH as craftign is the player crafting grid
no
oh lol
oh, thats why lmao
if you want i can figure out how to make a inventory thats shared and then i give it to u (cant promise this XD)
Ummm, idm
if you can't do it this guy can't get it done either
Did u keep ur code ElgarL when you got it to mostly work but with no crafting for one person?
lmao
1.14 plebian
yes, theres very minimal code
who knows
wym 1.14 is the best vershun
can ya make a gist and huck it this way?
have you tried the manually synchronizing inventories by setting items approach yet
thats kinda the only way
no, I wan;ted a simple way
probably nms town
population : not fun
@opal juniper could you join for one last test
oh im kinda busy rn
idk if some1 else can
@wraith rapids Join my test server you noob, I need a guinepig
nm, it doesn;t work 😦
what u cant make a inventory with InventoryType.MERCHANT
cuz i looked in the enum inventorytype in intelij and it sets isCreatable to false for that one
how do i check if a world exists (even if it isnt loaded)
wait no
how do i load a world
without creating a new one if it doesnt exist
how would i fix this, i dont think its a string
its a string
getTimeLeft returns a String
the timer.getTimeLeft() is a string
Integer.getInteger() i think
anyone
wait no
thanks i think its working
Integer.parseInt(string)
nah use parseInt its better
not getInteger
lmao
why compare int to long
oh if u want a long its Long.parseLong i think
this is probably more of a question for java, but could someone explain why this doesn't work?
@EventHandler
public static void onExplosion(EntityExplodeEvent event) {
event.blockList().forEach(block -> {
if (!(block.getType() == Material.OAK_PLANKS)) event.blockList().remove(block);
});
}
uh first and foremost != comparison exists
also I think you might have to use an iterator there if you wanna remove while iterating
oh shoot ya
also wdym
like for (int i = 0; i < blockList.size(); i++){}?
That shoudl blow up only OAK_PLANKS
Iterator<Block> iterator = event.blockList().iterator();
while (iterator.hasNext()) {
if (iterator.next().getType() != Material.OAK_PLANKS) {
iterator.remove();
}
}``` smtng like that
ik
anyone know
its probably throwing a CME
event.blockList().removeIf(block -> (block.getType() != Material.OAK_PLANKS));
yep
tysm
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html#createWorld(org.bukkit.WorldCreator) took me 3 minutes to find
if u want it to be minimal use elgars code altho it has negligible overhead as the compiler doesnt inline removeIf iirc
read the description of the method
it says that it will create or load a world
Creates or loads a world with the given name using the specified options.
or load
yes but in the event the world doesnt exist, i want it to not create it
so check for the folder
Does anyone happen to know when https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Projectile.html#getShooter() returns null?
declaration: package: org.bukkit.entity, interface: Projectile
¯_(ツ)_/¯
how
how bad is it to make a plugin using guis comparing the clicked item and the title name in a scale of 1 to 10?
i am doing Bukkit.getWorldContainer().getAbsoluteFile()
that will give you a file to the server folder
you want to check that the folder (file) to the server folder + /(name) exists
there is setShooter
and i guess if you just summon the projectile without using ProjectileSource#shoot
I think it returns null if the source got destroyed or is otherwise invalid (i. e. logged off), but that would not explain the frequency of the issue
But it does nothing
do you guys know how to add to an array within its definition?
you cant add new elements to an array, like extend its size
*arraylist is what i meant
just #add
uh whats ironSlot equal
i know u can do that but is there a way to do something like this?
ArrayList<Material> weakBlocks = {Material.OAK_PLANKS};
List<?> list = new ArrayList<>();
list.add(new Object());
what does ironslot equal
Where the heck is TileEntityContainerWorkbench I can not for the life of me find it in any CB or nms
Which line are you looking at
That just sees if the slot you clicked is the slot in the GUI for iron
int ironSlot = pl.gui.getInt("Iron.Slot");
whats the value of Iron.Slot in ur config
11
whats the best method to delete and regenerate a world
delete a world then create a new one and load it
yes how
idk
to be able to post a premium resource do I really have to have 80 posts on the forum? I read a thread that said that, but the thread was a bit old
overwise it wont delete
I am trying to check if 2 players are facing the same direction and if one hits the other while facing the same direction they get poisoned
how would I check to see fi 2 players are facing the same direction
World world = new WorldCreator("world_active").createWorld();
if (world != null) {
//world exists
world.setMetadata("regenerating", new FixedMetadataValue(SpeedrunRace.getInstance(), true));
Bukkit.getLogger().info(ChatColor.GREEN + "active world not null");
if (world.hasMetadata("regenerating"))
Bukkit.getLogger().info(ChatColor.GREEN + "Regenerating");
Bukkit.unloadWorld(world, true);
} else {
//world doesn't exist
Bukkit.getLogger().info(ChatColor.GREEN + "active world null");
WorldCreator wc = new WorldCreator("world_active");
wc.environment(World.Environment.NORMAL);
this.world = Objects.requireNonNull(wc.createWorld());
}```
i have this
and then a reload event
unload
?paste
to delete a world u need to unload and then delete the world
it in theory should delete the world
but the unload event
isnt even called
but it says "active world not null"
and then "Regenerating"
so its kinda odd
its like the event isnt being called
do you guys know how to prevent this?
but i know for a 100% fact that i have registered the listeners
the block explodes thru another block
would i just have to make my own custom explosion raytracing?
its probs cuz the wood blast resistance is lower than dirt
or higher i dont get how it works
no i prevented the dirt from exploding using some code, but I was wondering if there was a way to reraytrace after exploding
not easily
oh
does it not explode if there's obsidian instead of dirt?
no i mean like i only want the oak planks exploding
not the dirt, but I want the dirt to act like obsidian
yes, but thats just default mc mechanics
im trying to remake bedwars btw, and in bedwars only certain blocks can explode
and all blocks that can't explode act like obsidian, as in they stop blocks behind them (in relation to the explosion) from exploding
im fine if I have to make my own explosion raytracing, but i was just wondering if there is an easier way
WAIT A MINUTE
I KNOW WHAT I COULD DO!
it might cause lag, but... I could cause the explosion, then i could set all blocks that haven't been exploded to obsidian, then undo the explosion, then set all the obsidian blocks to what they were before
can anyone help i have described my question above
fortnite is a scam
truly is helpful
could anyone help
why is my WorldUnloadEvent not running
thats my issue
it should say "Unloading world: <worldname>"
but it doesnt say anything
@EventHandler
public void onUnload(WorldUnloadEvent e) {
World w = e.getWorld();
String name = w.getName();
File folder = w.getWorldFolder();
Bukkit.getLogger().info(ChatColor.GREEN + "Unloading world: " + name);
}
cancel block break event?
did you register the listener
yes lmao
im not that bad
i even tested it in a class that was already registered
nothing
yes, but blocks behind it still explode
I mean, when are you expecting these events to be called ? Like are you unloading a world ?
did i do something wrong here? ```ItemStack item = new GetItemFromConfig().get(locID, lootID, (itemSlot + 1));
ItemMeta itemMeta = item.getItemMeta();
ArrayList<String> lore = new ArrayList<String>();
lore.add("location:" + locID);
lore.add("loot:" + lootID);
for(String i : lore){
itemMeta.getLore().add(i);
}
item.setItemMeta(itemMeta);
inv.setItem(inv.firstEmpty(), item);```
error ar itemMeta.getlore.add(i)
yes
i call Bukkit.unloadWorld(World, boolean)
Looking at the source code of the unloadWorld method, the event is called rather straight forward xD
Are you trying to like unload main world or something
can you also check the return value of the unloadWorld method
like, if that method returns false the event is probably not fired
the method returns a boolean tho ?
yea
doesn't matter that the internal process takes longer than the method itself
?paste
but that will remove the current lore and add a new on e
i want to add the lines to the current lore
like there
go read the implementation of the unloadWorld method
one of those checks is either failing for you
or you are not unloading the world at all
or your listener is not registered
pick your poison
ItemMeta itemMeta = item.getItemMeta();
ArrayList<String> lore = (ArrayList<String>) itemMeta.getLore();
lore.add("location:" + locID);
lore.add("loot:" + lootID);
item.setItemMeta(itemMeta);
inv.setItem(inv.firstEmpty(), item);```
i get null when i try lore.add.
because spigot convention is to return empty data structured rather than null most of the times
List<String> lore = new ArrayList<String>();
if(itemMeta.hasLore()){
lore = itemMeta.getLore(); // add lines onto current lore if the item has lore
}
lore.add("location:" + locID);
lore.add("loot:" + lootID);
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
inv.setItem(inv.firstEmpty(), item);```
it works, but now the lores get added on top of eachother for some reason
ur adding lore to the current lore with the location:1 and loot:1 already on it so its just gonna add it again
but it gets added everytime i open the gui, and im creating the item on the spot
where is it getting saved?
the config item is the same
¯_(ツ)_/¯
lol
maybe dont add it again if its already there
who knows bot detection?
lmao
are all coders programmers tho
does inv.setItem() sets a slot to a itemstack?
ye
yea
i want them to be able to see the current location and loot of the item
but also want to respect prior lore on the item
exactly
I mean, then you would only have to check that, if the item already has lore, the first two lines do not start with location: and loot: respectively
well just make it so if theres a change in it remove the current ones from the lore and then add it idk
and if they do, remove them
i dont think the problem is how im adding the lines
somehow the current lores gets saved in the config
even tho theres like 5 lines running
sure m8
The concept of "get lore from item -> prepend something to lore -> save to lore -> do again" in itself means it will duplicate
the lore of the item you fetch the second time around obviously already includes the previous two lines you added
who knows bot detection?
i dont think FileConfiguration can be instantiated
what should I do then?
YamlConfiguration
what are you trying to do
cause thats what I was told last night to do
im trying to save an existing file
messages.yml file
YamlConfiguration
YamlConfiguration
declaration: package: org.bukkit.configuration.file, class: YamlConfiguration
i think this is it
idk
maybe wrong thing
YamlConfiguration xD
Okay ?
lol
FileConfiguration#save(File)
is the method
YamlConfiguration extends FileConfiguration tho
any way YamlConfiguration extends FileConfiguration
so feel free to use that
so
heres my issue
i cant just do FileConfiguration.save
your fc variable is not initialised
but when I do this, what should I initialize it as
yeah u need to instantiate yamlconfiguration
a new YamlConfiguration?
lol
i meant yamlconfiguration
well no error
ill try it out
ok its working
just need to fix my event now
thanks
👋
Does anyone have insight into why I cannot get mongodb sync 4.2.3 to stop logging in console?
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.2.3</version>
</dependency>
I have tried:
Logger logger = Logger.getLogger("org.mongodb.driver");
logger.setLevel(Level.OFF);
as well as:
logger.setLevel(WARNING)
I also tried using logback to no avail.
The documentation (https://mongodb.github.io/mongo-java-driver/4.2/driver/reference/logging/) says that if slf4j is not present then it will send out a warning and not continue to log but it still does and I have no idea where it is coming from.
MongoDB Java Driver documentation
because im creating a new file that overrides it
then dont do it if the file exists
yea ik
im fixing it rn
do you know if there is a way of saving it as deafults instead of just saving it?
and then resetting on reload
might be cuz it does extend FileConfiguration but probs not
do we have any piglin trade event?
stackoverflowerror is very overwhelming
I think I saw some work on a piglin barter event on spigot stash
Don't know if that had been pulled yet
wait
i just realized
if u can get stackoverflowerror to run
you can crash any server
holy
What
Xd
No you can't
The JVM will cancel a stack overflow
Hence the thrown exception
It doesn’t exist
can I bungee a "paper version" of my plugin together with the spigot version when releasing a premium plugin?
use the spigot api if u want to have a spigot and paper plugin
u cant use paper methods which is not in spigot in spigot api tho
translate the color
whats ItemMaker
just a lib i use
with that code how would i get the block that blocklist returns?
ok ty, i was wondering if it would get the next next block
everytime next() is called the next element will be returned except if you reach the tail
so a good thing can be to put next() into a variable assuming u want to reuse it
wait so would it get the next next block?
big brain
np
uh cant find anything but like yeah this:
for (int i;i<100;i++) {
System.out.println(i);
System.out.println(++i);
}
//can be this also sort of
Iterator<Integer> it = intList.iterator();
while (it.hasNext()) {
System.out.println(it.next());
System.out.println(it.next());
}
I think
assuming u r not storing the it.next() into a variable
ty
the second one tho will error out
you only check if the next one exists, but you are taking 2
is there a way to do something like:
for (int i : *HashMap variable*) {}
well fori doesnt throw
wdym?
List<Integer> list = new ArrayList<>(Arrays.asList(1,2,3));
for (int i = 0; i < list.size(); i++) {
list.remove(i);
}
wont throw since its index based loop
or like fori
i mean it might help if i explain what i want to do,
I want to store a bunch of blocks and their materials in some sort of map variable (or other variable type i just think some form of map would be easiest), then for each one, edit its type, then set it back to what i stored in the map variable
oh yeah also using map gives u special ability to remove entries in a for loop with the entry set
lmao this looks cursed
i cant craft a crafting table :(
?
?
ill show you the code after
blockList is mutable
it might explain it
its immutable
thats what im doing, sort of
Oh yes ILikeToCode that's true but that wasnt my point
there we go
it works
should i send the code in pastebin?
its not too long, but ill send it in pastebin anyway
there it is
i think it explains it much better than i did
also all the armor stand stuff is unnecessary
i accidentally left it in there
im not
i didn't explain what i was trying to do very well

