#help-development
1 messages · Page 217 of 1
exactly paidyy
Go to Unity and tell them
but fast 😛
I like to learn languages that have actual use is V going anywhere
So is Go most of the time
see that is why I code assembly
Maximum performance
My golang is fast as fuck :)
i'm curious how many people use haxe
Wtf is haxe
language that compiles to c, c++, java, php, js etc
it has syntax like in java and typescript
Does it produce good transpiled code or is it slow
What's the point of compiling a code to java? What does that even mean?
what does "transpiled"mean
So you can compile to the jvm who knows seems dumb though lol
Compile my bad just go with compile I don't feel like explaining
But I will anyways transpile just goes into another language like ts is transpiled into js
V is sweet, didn't know it until now
I'm back
haxe converts it's code to for example html5
How do I actually download the SpigotMC Maven Repository?
maven will do it for you
Google the maven repo and dependency and paste em into your xml
How do I have maven do it for me
Paste the link?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
That's where I'm at
I have maven installed
How do I like
Put the thing in the thing
^?
Then just copy and paste not that complex
The site tells you
in pom.xml
even i didnt had problems with setuping maven for the first time
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>``` copy and paste these to pom.xml
Neither did I
People of all intellects exist remember that
So just go to a new line and paste that whole thing?
before the forward slash?
yeah
"XML document structures must start and end within the same entity"
can you upload your xml file here
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>CreeperSpawn</groupId>
<artifactId>CreeperSpawn</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>/project>
i mean upload not paste lmao
🤷♂️
So I've got a world generator I've been developing for a while and I'm wanting to add structures via Jigsaws. I know how Jigsaw blocks work so none of that will be a problem but I can't seem to figure out how to actually enter data into the jigsaw block on my populate method. I'm just wondering if anyone else has any more experience here. I have already looked at these and they seem to provide nothing:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/data/type/Jigsaw.html
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Jigsaw.html
declaration: package: org.bukkit.block.data.type, interface: Jigsaw
declaration: package: org.bukkit.block, interface: Jigsaw
I may be missing something simple, but I'm not so sure
i still have hell flashbacks from working on world generator
It wont let me just cntrl+c cnrtl+v?
what
Mac user located???
?paste
drag and drop your file
The paste ui is very self explanatory if you can't figure it out I can't help you
you can right click file and select Open In/Explorer
if you dont know where it is located
you're telling me it's not a file
Okay could you like explain this to me like I'm 10
you're using intellj?
No, eclipse
yes
Yeah
so can you upload pom.xml here
Would I have to first download it?
I can't just drag it from eclipse to discord
Just copy and paste it
because you need to drag it from explorer
I did that tho
?paste
Use this website pastr your pom
And the. Paste the link in the discord
?paste
you deleted <?xml> ?
You don't have a closing project tag yoh deleted your xml tag you have no build tags
try adding
<?xml version="1.0" encoding="UTF-8"?> at the top of pom.xml
"The processing instruction target matching "[xX][mM][lL]" is not allowed."
also before / add <
Add ">/project>" where?
add < to /project>
before /
The one on the last line?
yes
"Project build error: Non-readable POM C:\Users\jason\Desktop\MyPlugins\CreeperSpawn\pom.xml: no more data available - expected end tag </project> to close start tag <project> from line 1, parser stopped on END_TAG seen ...</dependencies>/project>... @22:25"
I have "</project>" at the end now tho
ope that fixed it
good looks
Thank you very much hopefully it is smooth sailing from here
Yes
plugin.yml sets the requirement version
As long as you don't use nms
If you use nms you'll need to do a bit more setup to get 1.16 jars working on 1.19
i changed it
Note if you want to use 1.19 exclusive methods you'll need to use reflection and some version detection system
anyways is it possible to define 2 or more versions in plugin.yml?
No just define the api version you use spigot is forwards compatible
As long as you don't use nms
but how ppl make multible version compatible jars?
They put a 1.17 jar in a 1.19 server
That's how as long as you don't use nms don't worry about it
If you do use nms I reccomend either reflection or maven modules with reflection to create interfaces with certain methods
lol
so, i'm trying to make a gui that shows player heads of offline players, but the head item's just don't show up in the gui.
public void RefreshHeads() {
System.out.println(Lifesteal.plugin.banned);
for (int i = 0; i == Lifesteal.plugin.banned.size(); i++) {
OfflinePlayer p = Bukkit.getOfflinePlayer(Lifesteal.plugin.banned.get(i));
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
SkullMeta headmeta = (SkullMeta) head.getItemMeta();
headmeta.setDisplayName(p.getName());
headmeta.setOwningPlayer(p);
head.setItemMeta(headmeta);
inv.addItem(head);
}
}```
should i save rank information in objects to use after or read an information about the rank from config file each time
any errors in console?
nope
maybe, when i don't set the meta, the item shows up
what
ima just save ranks as objects with attributes and just use them
is that bad
and read attributes from files every time server gets on
Multi-Scope Maven Dependency
this for loop is bad
it will not iterate at all
because of i == ...size() condition
it will iterate once only if size is 0
oh lol
sorry i'm pretty new to java
thank you!
I'm trying to stop a player from moving a certain item in their inventory and I have done InventoryClickEvent, InventoryMoveItemEvent, PlayerInteractEvent, and PlayerSwapHandItemsEvent. This blocks most all movement of the item besides one thing, when you hit the number index the item is in, if it is in your hotbar, it moves the item to the inventory slot that your mouse is hovering over. I cannot seem to stop this... does anyone know how I can?
Its ok ! In for loop, your condition must be continuously true until your loop stops
Can I not do this to make my own class for players with extra methods
and then use this
it gives me error
Pplayer 😭
was just trying
to make my own player class
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer cannot be cast to class
You can't upcast to something it's not
you cant do that, try doing Pplayer p = new Pplayer(e.getPlayer())
and make sure that Pplayer has a constructor with the player object
Yeah, but that defeats the purpose and you'd just want to make a utility class
ah wait i see
ok but then how can i use the implemented methods
with Pplayer
Yeah i didnt notice what you were trying to do, i don't work with these kinds of things.
You can do it a different way by just inside Pplayer adding functions that can run
hey, can anyone help me on how to make mobs spawn in the air and at any time (for skyblock)
random number between 2 values, world.spawnentity
what
i mean how to i make it so spawners can spawn the mob in the air
Pplayer player = new Pplayer(e.getPlayer());
player.coolFunction();
// Pplayer.java
public void coolFunction() {
//code
}```
cant do that afaik
easily atleast
ive seen servers with it tho?
i dont wanna add every single function in Player to Pplayer
dont think its a plugin
lol
you wouldnt do that
🤣
oh rip i really need it
ye so how can i use the functions in Player with Pplayer object
pplayer.getPlayer().playerFunction()
so its not possible to make a class that just adds on to another class
just more functions
there is a way, i just dont know how as i dont do that often.
I keep getting this error when I start my plugin on my server... anyone know why?
so, i need to check if the inventory a player has open is the custom one i'm making, but the inventory is never equal.
this always returns false.
what I do is I check the name of the inventory with e.getView().getTitle().equals("title") but this will only work if you are going to name each custom inventory differently
yea, i won't
ok then that should work
I need a way to basically reset a map like in skywars or bedwars and I'm not sure how to go about doing it, does anyone have any experience with doing things like this or have any ideas how I could?
I would prefer to have it loaded from a schematic if possible but I think I need WorldEdit for that, not sure if you can read schematics otherwise without an entire loading system
Write your own method to store the data and restore it or use WE
Store it with MySQL or something?
Yeah, or file based.
not sure how schematic files actually work, yml would probably end up being huge unless schematics are basically just text files
Well you can always make your own serialization system. It's going to be a big file obviously
Has anyone used SuperBoostersAPI to create custom boosters?
Schematics are binary storage. They use nbt system. Can store a lot of block info and not take up much space.
You also don't need worldedit. You can do the loading and saving yourself
Thanks
are you using InventoryDragEvent to check for clicks?
How to do it? is it even possible to check for clicks?
InventoryClickEvent
Save item data where and for what purpose
Like saving rpg weapon stats
It is contain in nbt tag i think
Yes
That is not your problem
Yeh ik
Use PDC don't make it hard for yourself
Alright
I have only recently started using maven. How do I properly shade a dependency?
I have added the dependency to my dependency list in my pom.xml, but do i still need to add the jar manually?
Never manually add jars
That is what I thought. But after adding the dependency I cannot access its classes. Is there other things I need to do?
Look at the pom for this project under servertutorial. https://github.com/frostalf/servertutorial
You need to use the maven shade plugin. Not at an IDE, but here's a mockup
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</groupId>
<version>3.4.1</version> <!-- May depend on your Java version -->
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I believe it shades all compile and runtime dependencies by default (default scope of a dependency is compile if none is set)
Just making sure, I do not need to link to a jar or a repo, I only need to add it to the dependency list?
well, it shades all dependencies that are added to the runtime classpath, which usually excludes the provided scope as thats for compile time classpath dependencies only
Of course include the repo if you need it, but yes, you'd only need to depend on it via Maven.
I have added it, I cannot access anything though. 💀
Is there a way to verify its added? It compiles just fine
You have to compile it using the maven package task
Can I share my warning here?
sure
commandapi-shade-8.5.1.jar, distancemeasure-1.0.jar define 1 overlapping resource:
- META-INF/MANIFEST.MF
maven-shade-plugin has detected that some class files are
present in two or more JARs. When this happens, only one
single version of the class is copied to the uber jar.
Usually this is not harmful and you can skip these warnings,
otherwise try to manually exclude artifacts based on
mvn dependency:tree -Ddetail=true and the above output.
See https://maven.apache.org/plugins/maven-shade-plugin/
You can safely ignore that.
It's just a warning for overlapping manifest files. Only really required for standalone apps afaik, so not so much for libs and plugins
You're not doing anything wrong, but if the warning is bothersome, you can add a filter to exclude all manifest files
Doing something wrong in the context of: not being able to access the api
The warning even says itself it's usually not harmful and can be skipped
oh, mb
I'm not sure, you should just share your pom file as it is so we can see what's wrong
Whats the site for posting files
?paste
It looks like it should be fine.
In principle no need to care about manifest files for plugin jars
💀
As plugin.yml is used instead
Maybe you're not using the right output jar?
But in most jar oriented infrastructures you’d work with manifest files more integrated
nvm
rip
so close lol. I refreshed my ide and it gave me more options lol
but still not compile 😭
What’re those options?
It gave me 'import class'. It didnt before, but I added it 'manually', so no change.
What ide do you use?
intelij
Can you remove the dependency manually?
yes?
(And let maven handle it entirely)
wdym?
Your pom setup works fine for me. It includes the command api
Well, what do you mean by added the dependency manually
Added the import manually
Il fiddle around with things for a bit
Thanks for the help though.
Im still a bit confused, import as in a java import?
import package.package
Ah okay
But what’s the issue that remains? The shading right? If it still didnt work after added what Mauwh gave you, maybe you’re constructing the jar wrongly?
cause basically, you wanna run mvn clean install and then take the jar from the target folder that is not labelled with -original iirc
what's the difference between package and install? I've pretty much always used mvn clean package
No clue🥲
I dont use maven, but gradle :,)
lol
Ah okay
I only use gradle for multi-module projects
Fair
Can I ask, where is this located in your project?
That's the decompiled output JAR.
install basically does the same as package but installs the dependencies on your local repo
Ahh
@static ingot If you still have your dependency test, can you add you verify that adding CommandAPI.onEnable(this); or calling anything works or not?
I just noticed this after going to double-check the decompile output, lol
bad dependency?
@loud frost https://commandapi.jorel.dev/8.5.1/quickstart.html the docs say you're depending on the wrong module, and that you should be using commandapi-core
I believe it says because im shading i dont need to use that
also, progress report: my pom defaulted to java 1.8, changing the version to 19, it showed in the decompile!
but still no worky
I'm not sure what the dependency is supposed to include. The module is completely empty on Github.
These are the docs im reading: https://commandapi.jorel.dev/8.5.1/shading.html#shading-with-maven
@loud frost I managed to get it working. I'm not really sure what's different, but this is what I have https://paste.md-5.net/payodudomi.xml
Hey i have this code that generates a random location for some reason it lags.
Why?
// Generate Random Location for door code
Random random = new Random();
int x = 0;
int z = 0;
int y = 0;
x = random.nextInt(1000);
z = random.nextInt(1000);
y = 150;
Location randomLocation = new Location(player.getWorld(), x, y, z);
y = randomLocation.getWorld().getHighestBlockYAt(randomLocation);
randomLocation.setY(y);
return randomLocation;
}```
its supposed to be for a plugin that like when u enter a door it teleports u
first of all, either dont create a new random instance every time or just dont use random
You should keep a single Random instance instead of making a new one every time. Are you sure your code is making the server lag and not the player?
second, i see nothing that could lag out. how many times do you execute the method?
Might be loading chunks
i printed 2 stuff "1" and "2" i put the 1 print before this and the 2 after.
it printed the 1 and then lagged and then printed 2
looks like it, but the lag shouldnt be noticeable
and it would be loaded anyways on teleport
i havethis second function:
public static boolean isLocationSafe(Location location){
int x = location.getBlockX();
int y = location.getBlockY();
int z = location.getBlockZ();
Block block = location.getWorld().getBlockAt(x, y, z);
Block below = location.getWorld().getBlockAt(x, y - 1, z);
Block above = location.getWorld().getBlockAt(x, y + 1, z);
return !(bad_blocks.contains(below.getType())) || (block.getType().isSolid()) || (above.getType().isSolid());
}
``` that checks if the loc is safe
it might be this?
Ye I know, I just can't think of anything else either, lol
The other function doesnt call this
oh yea i got it confused
if your bad_blocks hasnt 100k+ entries, probably not
that kinda stuff can maybe do it, because you could be checking and loading who knows how many chunks and lcoations
e.e
lol
idk
where and how many times do you call your method
once
Do you have a loop calling this on random locations?
Nah
What kind of lag was it?
i can chat but cannot type commands for a few seconds and then it tps\
Can it be from teleporting?
I dont think tho.
like i said
i put a println code
that prints 1 and 2
i put the 1 before the function and the 2 before the tp
it printed the 1
and waited
and then 2
so then its the chunkloading and your server is just garbage
because this y = randomLocation.getWorld().getHighestBlockYAt(randomLocation); statement loads the chunk you are getting the highest y from
iirc arnt sys prints slow with plugins?
nah
the only thing which are making them slow in general is the internal synchronized
then i guess i cannot make it not lag?
how do rtp plugins stop this lag and instantly teleport?
loading/generating chunks will always be poopy
have a better server
or use a server software which is more performant
or both
You could try to look at chunks already generated by existing players? and have them rtp, if you really need it to work
But that wouldnt really be too random
but that could grief other stuff
waste of ram, less entities in naturally loaded chunks, ...
more on what kind of server it is
yeah but if you keep xx chunks loaded less entities will spawn which could be a problem for survival server
but you could also just redirect the spawnings to natural loaded chunks
fuck them
be unique
dont go mainstream
or just dont have entities
fake them with packets
but handdrawn
is there a way to keep the chunks loaded?
plugin tickets
Seems like other rtps plugins (the one I checked) does the checking asynchronously as well as chunk loading, then teleports the player. However this means the teleport isn't instantaneous.
Try clearing caches or do a maven dependency clean
How do i clear my caches?
My current pom is the working one @static ingot sent
for the people before that toild me to get a better server cause of the lag of the chunk loading just so u know i fixed the problem with the lag
What was the fix and issue?
the issue was the getHighestBlockYAt loads chunk at the random cords i generated
yes
thats exactly what i said from the beginning on
the fix was to teleport the player to y 5 and then use getHighestBlockYAt to tp him back up
it legit fixed the lag
and will kill players with 0.5 hearts if they get tpt at the wrong tick
so i can make it so the player wont get damaged in that time
rather teleport them to a really high y
if iteleport them high they will die on tp
I have done both multiple times. But I did it another time and It works now
I have no clue
🥳
👯♂️
@static ingot @hybrid spoke @ivory sleet we did it
🎉
"This plugin is simple quick to make, might as well use this as an opportunity to learn a useful api"
3 hours later
ye, the dev for the command api has a bit of an odd setup - it seems like it literally just indirectly includes the core module anyway x.x
(nvm, it includes some other parts of the project)
Don't store your world directly. Use its name or UUID or something.
haha memory leak go brr
okay
@Description("{@@command.description.clan}")
Does anybody know what's the name of this mechanism (passing a property value directly to an annotation) or how it's done?
Annotations are basically just fancy interfaces. You're setting a value in that interface when you do that, and it can be accessed via reflection, as is normally done in annotation-based frameworks.
can you make it in a minecraft world so that the whole coordinates change like a certain x y z becomes 0 0 0 and every coord also changes
not without huge effort on the server level
tho look for a plugin, this feels like someone may have already done the work for you
Dont think theres a name for it
Maybe just annotation variable?
Wait no
Annotation attribute value
Glad you got it working
And sorry for not replying earlier. Am at work lol. Well am for another 15 minutes then I go home
Does someone know how to make a GUI update automatically every second and on click?
public void onInventoryClick(InventoryClickEvent event) {
if (event.getInventory() == null) {
return;
}
if (!(event.getInventory().getHolder() instanceof InventoryMaker.InventoryMakerHolder)) {
return;
}
if (event.getCurrentItem() == null) {
return;
}
InventoryMaker.InventoryMakerHolder inventoryUIHolder = (InventoryMaker.InventoryMakerHolder) event.getInventory().getHolder();
event.setCancelled(true);
if (event.getClickedInventory() == null || !event.getInventory().equals(event.getClickedInventory())) {
return;
}
InventoryMaker ui = inventoryUIHolder.getInventoryMaker();
InventoryMaker.ClickableItem item = ui.getCurrentUI().getItem(event.getSlot());
if (item != null) {
item.onClick(event);
}
event.getWhoClicked().openInventory((Inventory) ui);
}```
My current code
Use a runnable and re open it each second
Although you should only update it when needed, a runnable could be pretty inefficient
Yeah, I want it to be lightweight
How do plugins like deluxemenus do it tho?
They repeat it every second
So on click event I should just do
event.getWhoClicked().openInventory((Inventory) ui);
because #updateInventory doesn't work in my case at least
Doesn’t it reset the player’s cursor everytime you reopen the inventory?
with this code?
I haven't tested yet, will do now
When a new inventory opens it resets the player’s cursor to the center of the screen
Yk, idk how to do it exactly without cursor being centered
Idk what you’re doing but why not just use the same inventory instead of trying to open a new one every second
And just update the inventory with whatever changes need to be made
How would you update the content here exactly?
https://i.imgur.com/3ZU28H9.png
Because u can't just add extra diamond sword for example
unless u are talking about itemmeta?
only if you close it before
Wont the old one always close when you attempt to open the new one
yes but not explicit
it just overwrites the "currently open" instance
but doesnt really close it
I hate to spam, but I asked yesterday and nobody seemingly knew any answers so I will ask again in hopes anyone new sees this:
So I've got a world generator I've been developing for a while and I'm wanting to add structures via Jigsaws. I know how Jigsaw blocks work so none of that will be a problem but I can't seem to figure out how to actually enter data into the jigsaw block on my populate method. I'm just wondering if anyone else has any more experience here. I have already looked at these and they seem to provide nothing:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/data/type/Jigsaw.html
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Jigsaw.html
declaration: package: org.bukkit.block.data.type, interface: Jigsaw
declaration: package: org.bukkit.block, interface: Jigsaw
tf is a jigsaw block
what exactly do you mean by enter data into the jigsaw block
what kind of data?
for block related stuff you have the blockstate
otherwise PDC
Jigsaw blocks are similar to schematic files, but have many more drawbacks. They are actually used in vanilla world generation for structures like villages.
are they new or something?
Cipher living in the future
always, has been
I think the top three things that have been added post 1.12 are
- Namespaced IDs (1.13)
- The PDC (1.14)
- Yaml comments no longer being lost when saved. (1.18.2)
for the last one, that is just up to the yaml library
according to the spec, it is appropriate to ignore comments not belonging to the header block
but it is left to the whoever is implementing the spec to handle them how they see fit
so I should just open the same inventory for the player whenever he clicks it or make a bukkit runnable that checks if player has opened inventory and then refresh it?
you can just hold a reference to your inventory object if you have to constantly keep opening it
without ever getting rid of it
this saves time and resources
How can I check if the y coordinate is a block or air?
in essence it is basically caching
get the block at xyz and check for its type?
Location.getBlock().getType() == Material.Air
depends on what exactly you want to do
#getMaterial on Material?
I want to refresh inventory contents. Like so players can see a countdown in inventory
I am tired lmao
most of what I put here is from memory XD
there fixed 😛
if its a countdown you probably want to have a scheduler
if its something that only updates on click, then update it on click
there is something called sleep
but how to update it on click? I've tried player#updateInventory
but it doesn't work anymore
im currently at work 
that only updates the players personal inventory
you will have to reopen it
Like this?
event.getWhoClicked().openInventory(event.getClickedInventory());
if you modified it between then yes
They need these fields provided in order to generate. I don't think I should need to hit "generate", since loading the chunk for the first time does that, but the rest of the fields seem to have nothing I can see spigot-side
I spent like 9 hours on this yesterday and I am totally at a loss for it
i think for those you will have to dig through NMS
They seem so poorly implemented I am debating just making my own system for it
PersistantDataContainer
implement them and PR it instead
or at least grant an api for them since they have to be implemented already
otherwise they wouldnt work
christ okay. time to learn nms i suppose
I was hoping there would be something implemented I was being silly and missed
Minecraft net package come inside the spigot
yeah i got the spigot buildtools in my libraries
Check because maybe you are impottung the spigot api
ye i am
Maven right?
Oh thst why
thats just the api youre importing
Spigot api doesnt co tains thst package
remove the -api
oh-
i hope thats the rigth dependency 😳
also, how would i make multiple versions of NMS? I seen a tutorial but they used the library
well, the default version of my plugin is 1.17 and i wanna support 1.17 - 1.19.2
import multiple versions
thanks guys, sorry about the interruption, i've never really worked with buildtools before
Josh
I will explain you
When u run build tools its install the Artifacts into local maven repo
So you import them thru libraries
You just import them vía pom.xnl
👍
I mean he was not adding dependencies correct ly
How do I do this without it being deprecated?
check the deprecation notice
declaration: package: org.bukkit.inventory.meta, interface: PotionMeta
Pretty sure you need to use PotionMeta
if i have all worlds in a folder how can i use Bukkit.getServer().getWorld()
Why does this make an uncraftable potion instead of a normal potion?
PotionMeta meta = (PotionMeta) item.getItemMeta();
meta.addCustomEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 3*60*20, 0), true);
item.setItemMeta(meta);
e.getLocation().getWorld().dropItem(e.getLocation(), item);
break;```
Might be due to the amplifier being 0.
but it starts with 0
0 means 1
1 means 2
Depends on the method, but if that's how it is then alright.
it is still an uncraftable potion
Hello ! 😄 Do someone know how to get the first two digits after the "," in a coord loc ? Cause it's doing that in my DB : -146.63253833031763
I do that btw:
preparedStatement.setString(2, loc.getWorld().getName());
preparedStatement.setDouble(3, loc.getX());
preparedStatement.setDouble(4, loc.getY());
preparedStatement.setDouble(5, loc.getZ());
You probably need to set the base potion then.
ItemStack item = new ItemStack(Material.POTION);
PotionMeta meta = (PotionMeta) item.getItemMeta();
PotionData data = new PotionData(PotionType.WATER);
meta.setBasePotionData(data);
item.setItemMeta(meta);
Depends on how you store your data. If it's a string put under one column, you'll have to parse your result. If it's in separate columns, then you can just grab based off the name.
ouep ! That's the only solution i have : transform to a String and cast to a double when i Select it
Is this realy the only solution ?
@kind hatch thank you
if it is, it's pretty ok tho
You can store doubles in mysql.
how can I use worlds folder, I did world-container: worlds in settings but still
it creates new world folders
in server folder
and not worlds folder
yeah but the coord is too long to get into the double of SQL
and then SQL round it
a bit
or cut the last 4 digits
Is that level of precision necessary for you? Personally, I doubt it is, so it shouldn't be that big of an issue. However, if you have a reason, please correct me.
no it's that i don't want this level of précision xd
i only want 2 digits
but i found ! round(200.3456, 2);
You can define how many digits are stored using the data type.
Keep in mind that those parameters are based on digits. A typical minecraft world will have a range of 30 million blocks, so 8 digits should suffice.
DOUBLE(8, 2)
cant you cast in mysql?
Actually, the MySQL docs say that the first parameter is the total digit length, (including past the decimal place) so DOUBLE(16, 2) is what you would want.
How can i make entites glow in a player's screen. i am not really good with packets
i know postgres has '100'::numeric(3, 0)
Looks like you can, but why do that when you can just store the proper data type?
Entity result = player.getWorld().rayTraceEntities(player.getEyeLocation(), player.getEyeLocation().getDirection(), 10).getHitEntity(); returns myself, how do i make it so that it doesnt
Remove yourself from the list?
Oh, my bad. I thought that method returned a list of entities.
You should be able to supply a predicate
To filter out entities
One of the overloads
hi im new to coding and wanna code a plugin that removes player collision can anyone help
?
it's not that hard
well... it depends actually
there are 2 ways to make an entity glow
Anyone know a good tutorial on importing entire builds or schematics? (I'm guessing this would be done with the worledit API, which I already have)
I mean technically it cant glow properly cus of lighting engine :/
you want to read blocks or do you want to paste them?
paste
FAWE or just worldedit?
FAWE -> Clipboard#paste(BlockVector3)
WorldEdit -> you gotta use editsessions
I forget i installed it a while ago
in the plugins i have worldedit-bukkit-7.2.12.jar
and in maven i have
should I install fawe or just worledit
aka which ones easier to paste builds into world
FAWE is far more performant, but I'm not sure about it's API. I haven't used it before, but I'm willing to bet it's easier than WorldEdit's API.
Yep, that's the one.
So would I import the jar into the project and plugins folder or just my project
You're using maven. Import the dependency and put the jar on the server.
worldedit nearly let my raspberry pi burn
all threads were trowing an outofmem
fawe just gave a bunch of console errors
what do you guys think?
i wish enums were generic
might just make it an enum instead of holding an enum internally tho
So I think I installed FAWE, now how do I spawn in a building?
I added it here and put a copy in the server's plugins folder
🙃 Use Maven
Well I couldnt find the things you copy paste into the xml file so I just used intellij
That won't work
I don't know much about maven would you mind explaining how to properly import it?
should I get FAWE core or FAWE bukkit & core
have anyone a free eggwars plugin?
Your other worlds are not loaded
just make a copy of these worlds
what
to make sure they do not reset for some reason
wait how do I Bukkit.createWorld(WORLDTHATALREADYEXISTS)
doesnt createWorld make new
Well I imported it into maven, but IntelliJ doesn't recognise it :/
by it I mean FAWE
so I can't really code without it
anyways I can temporarily import into IntelliJ while I am developing it
if the world already exists, it gets loaded
otherwise created
so how do I spawn a schematic into a world using worldedit
read the docs
effort
yeah ours to copy n paste from the docs
it creates a world if it doesn't exist
how to be more lazy than this guy?
Never heard of that
is this correct?
not causing errors
idk what that method does
honestly if someone could share a link to a tutorial on spawning schematics into the world using WorldEdit, I would love u
A as generic type is atleast better than mongos <TItem>
Can someone explain me in noob way for what is Pattern.quote() used I was looking some code and not sure what is that for
xd
command = command.replaceFirst(Pattern.quote(type.getIdentifier()), "");
i'm wondering if i would have to handle mongodb async or if its quick enough to be executed sync?
Async
hi im new to coding and wanna code a plugin that removes player collision can anyone help pls
what do you need help with?
Paper has a setting for that
Hi, since 1.9, player#getInventory returns the inventory content, with items in mainHand and offHand? I'm doing 1.8 plugin and I'm want to be secure that's work
^
like actually pasting it throughcommands or api
Hello, I code on Intellij and I imported an external library but when I build the program, I have an error and it's written : package "mypackage" does not exist
Someone can help me please ?
through the api
also I'm getting package com.sk89q.worldedit does not exist
I copied this stuf
<dependency>
<groupId>com.fastasyncworldedit</groupId>
<artifactId>FastAsyncWorldEdit-Core</artifactId>
<scope>provided</scope>
</dependency>
think thats missing
now dependencies and onwards looks like this, as per the website. but it still gives the error
i have this code in a bukkitrunnable but the armor stand is moving very fast and i dont know how to make him slower
Location dest = armorstand.getLocation().add(armorstand.getLocation().getDirection().multiply(1));
Vector vector = dest.subtract(armorstand.getLocation()).toVector();
missile.teleport(armorstand.getLocation().add(vector.normalize()));
Well the Bukkit Runnable you should be running once every x ticks, which is shown by the number. 20 ticks per second, play around with that number appearing at the end of the runnable declaration
How do I properly import FAWE into my project
yes but the animation wont be smooth
You are modifying the location twice
add teh directional vector to the location once
normalize teh direction and multiply by a fraction to make the jumps smaller
I tried creating a class:
public static void spawnSchematic(String fileName, Location loc, World w) {
try{
File sFile = new File(Housing.inst.getDataFolder().getAbsolutePath() + "/" + fileName + ".schematic");
ClipboardFormat format = ClipboardFormats.findByFile(sFile);
ClipboardReader reader;
reader = format.getReader(new FileInputStream(sFile));
Clipboard clipboard = reader.read();
try {
com.sk89q.worldedit.world.World adaptedWorld = BukkitAdapter.adapt(w);
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(adaptedWorld, -1);
Operation operation = new ClipboardHolder(clipboard).createPaste(editSession)
.to(BlockVector3.at(loc.getX(), loc.getY(), loc.getZ())).ignoreAirBlocks(false).build();
Operations.complete(operation);
editSession.flushSession();
} catch(WorldEditException e) {
Bukkit.getLogger().info(ChatColor.DARK_RED + "There was an error spawning in a schematic, please contact an administrator.");
e.printStackTrace();
}
} catch(IOException e) {
//
}
}
``` This class should spawn in a schematic at the specified location, but it doesn't. No error message, no output, nothing. So I was hoping if someone could help me out. First time using the world edit API. This is the resource I was using: https://www.spigotmc.org/threads/1-13-load-paste-schematics-with-the-worldedit-api-simplified.357335/
Did you manage to fix the error ?
Okay good because I just managed to fix it so I asked you to help you if you want, but you managed to fix it too, so it's good 😄
if someone could pls help with spawning in builds pls do 🙂
I don’t really know how the fuck I’m supposed to do that
Wait
I can show you what I’ve tried
You should take a plugin from the Web, it will be optimised and good.
Hm but I wanna do it myself
https://www.spigotmc.org/threads/stop-player-collision.352972/ I hope that will help you 😉
hmm is there a reason to use the schedulers threadpool instead of the cf common pool to do cf::runAsync?
to not clog it up ig but im not querying it often
but every other plugin could be
Hey is there a way to check if a player was standing for 5 seconds on a Pressure Plate if yes how?
if they move on it -> start timer
if they move away from it -> stop timer
Is there a event to see if a player triggered the plate?
Okay thanks
wouldve done it over the good old playermoveevent
Could not find method maven() for arguments why does this error happen when refreshing gradle
maven("https://repo.codemc.io/repository/maven-public/")
}```
found out that ` maven { url 'https://repo.codemc.io/repository/maven-public/' }` works
i wanna make a gui where you can upgrade items like a pickaxe, sword, axe and each tool tier would have better and better enchants
how could i do that
i dont have any good ideas
I would first write the logic of the upgrading, this should be a seperate piece of code from the GUI. I recommend using for example commands to test this. The gui should only be a means to access this functionality. Once you are happy (enough) with the upgrading I would look into how to make a gui
eggsplain?
server == egg
Hey guys, Is there a way to save pdc data (Item PersistenceDataContainer) on config as a string? Something like this
I success to save & load default item data but I don't know is it possible to save the other data
The point of a PDC is you don;t need to save it anywhere else
why wont this actually save the location
do i need to set section to yml or something
Why are you using getX on every line?
oh shit forgot to change
but still
doesnt save
oh fr
how do i read and write
oh ok
ok
wait so it saves world too
damnn
ty
@last temple
can i not do this
it doesnt even create the file anymore
are you creating it onEnable
no
onjoin
huh
the others always worked
cus im just doing default when they join it just worked so i kept doing it
now it doesnt work idek
oh lmao
i wasnt listenint go onjoin
so it never triggered
do u know why this defaults i have could not work tho
wait it does work
wth
ive tried this: Player player = (Player) Bukkit.getServer().getOnlinePlayers();
player.setCollidable(false);
but that didnt work
What
xD
At least explain the code and what they did wrong
Ello. So I’m tryin to dispatch a command from a discord bot, but only issue is you kinda need to have the bot on a different thread or else it would just freeze the server, but dispatch command has errors if it isn’t on the main thread soo.
I used Bukkit.runTask which made it work, but still has the errors.
Running my plugin on a localhost and it throws this error org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
as well as Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml I've checked my jar in winrar and the plugin.yml is in there. My plugin.yml is as follows
main: me.nightterror.hungergames.Main
version: 0.1.0
load: STARTUP
commands:
kit:
description: Select your kit to play with.
usage: "Correct usage: /kit <kitname> or /kit list"
target:
description: Assassins can use this to select which player their compass targets.
usage: "Correct usage: /target <playername>"```
Does anyone know why I'm getting this error?
its in my src folder, is that correct?
same issue but now the plugin.yml actually isn't in the jar
maven/gradle?
Maven is literally just ignoring the other directories?
is there any way to change the config of the .yml file to allow tnt duping on servers?
What config.yml has that as an option?
Well, that is the question at hand, the server I have is a spigot not paper server I know paper.yml file has an allow-piston-duplication but after going through spigots.yml file that is not an option I am wondering if there is a way to allow for piston duplication through spigot.
If it's not an option you'd need a plugin to allow it.
Hello,
I'm using Spigot's multiworld feature to host a Minecraft server and I ran into a bit of an issue with the nether
For example, I have 6 worlds:
world1
world1_nether
world2
world2_nether
world3
world3_nether
In my plugin i have a command to switch between them and they all work fine, the issue is when I try to use a netherportal in world2 or world3, it defaults to going to world1_nether and then when I go back it brings me to world1. Is there a way to have it so each world goes to it's corrasponding nether (so world2->world2_nether etc.)
Any help would be greatly appreciated!
Anyone know how I would go about checking if a chunk is loaded?
looks like PlayerPortalEvent contains a setTo method
simply setTo to another demention?
idk if that will work very easily, but its some semblance of a solution
that'd be where I'd look to start atleast
Chunck#isLoaded
Hi guys, is there a way to make so drinking milk doesn't delete potion effects?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerItemConsumeEvent.html
Could try cancelling the event if its milk than deleting the item from the inventory and replacing it with a bucket
declaration: package: org.bukkit.event.player, class: PlayerItemConsumeEvent
Copy the effects when the milk is drank and reapply them afterwards, or cancel and delete the itemstack
^
thank you so much, ill give that a shot
I've been looking around and unfortunately there isn't a way to just assign a nether to an overworld in the configs so this looks like my best bet
This is actually really clever
I'm making a plugin where drinking milk gives you different powers
and there are a lot of types of milk
the problem is that drinking milk type X is cancelling drinking milk type Y
so maybe I can cancel the event and replace with a empty bucket, and at the same time apply the code that will run with PlayerItemConsumeEvent
to give the power
I'd save the bucket item stack to a var cancel and remove than use the item stack var to check things like pdc etc
np
How can I print out all of the args except for the first one?
If there's a yaml file in the servers root directory, how can I read it?
IT WORKED PERFECTLY OwO
thank you
now I won't have to do some ugly fix 😅
You can get the absolute path from the world directory
if(!Objects.equals(iteminhand, new ItemStack(Material.AIR))) {
iteminhand is player.getItemInHand-- How would I make this work?
Item maybe?
omg ty
Ugh object.equals
Yes intellisense is not intelligence
How might I use ASWM to unload a world, delete the world, copy a world from a save and repeat
when games end
yet another reason to use vscode 💪🏽
?paste
Honestly it'd help prevent script kiddies
Every few weeks someone complains that an Object.RequiresNonNull throws a NPE
lmao
its not that hard to use vscode though its harder than intellij lol
it requires setup and configuration
Yeah but it hopefully doesn't give the terrible recommendations like Objects.equals
no it doesn't
sonar lint doesn't like Object#equals iirc
i'd have to recheck but yea I'm pretty sure
nvm sonar lint won't yell at you, but it won't yell at you for not using it
So in my config.yml how would I access the permission under "More"
Permissions:
more:
permission: betterserver.permissions.more
this.plugin.getConfig().getStringList("Permissions") or this.plugin.getConfig().getStringList("more") I dont know if the 2nd one will work
"Permissions.more" as the path
thanks
work with me to shove all the script kiddies on to vscode and refuse to help them with me
It's easier to just laugh at the people doing Objects#whatever
what's wrong with Objects?
most people use it wrong
is there a way to raytrace with a specific decimal hit vector rather than blockpos
that already exists and not me having to steal MC source code
How can I tell where a splash water bottle lands? In the PotionSplashEvent when its a water bottle none of these work:
PotionSplashEvent#getEntity() returns the slash potion
PotionSplashEvent#getAffectedEntities() returns an empty collection
PotionSplashEvent#getHitBlock() returns null
Couldn't you just get the entity then get that entitys location
any solution to get rid of this deprecation
?jd-s Attributes
to read*
both are correct
it may sound a little odd, but it's correct
ok
"learn to read docs"?
lol
english is not my native language let me know
and bro like what the code be
what
Probably something like player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() but idk. You can look through the docs if you need more info.
🤓
yes
Learn to eat docs 🤓
i ated the docs
learn to feed the ducs
Why can't we just say "read docs before you ask questions"
read le docs innit bruv
are your keyboard broken?
tek
im sending a block change to 4 locations but one of them are not being changed
i ensured the position being correct by sending some glowstone change around it
sometimes its not showing
Share code?
public void highlight(Player player, Material material) {
Scheduler.runTask(() -> player.sendBlockChange(toLocation(), material.createBlockData()));
}
now its two of them
this only happens with gold blocks
anyone have any good tutorials on worldgen? does spigot allow the use of datapack biomes when generating chunks?
sorry to cut into the current discussion
I have never seen any good tutorial for worldgen :D ping me aswell if u find any good one. the wiki one is sht
lol will do, i found a pretty decent forum post that helped me generate this
ah, right, i can't post images
but i am trying to populate the world with one or two custom biomes that i made in a datapack
googling around seems to indicate that it isn't possible
thought i would also check here
whats the best way to setup plots in a world, shold i check everytime a player places a block if the block is in their plot
and when claiming a plot should i check with every plot in a file, if the plot intersects with any other ones
oh nvm ill replace outer blocks with certain block and if a block is that block i wont let it do
but still for this
Hey, I want to check if the player is looking at the moon.
Does anyone know how I can calculate a Vector for the moon position using the ingame time?
AFAIK, the moon is stuck on an axis. The only time it's not is with texture packs and or shaders. (Offsets and what not)
Are you sure you need to use vectors? Or is the player's pitch not enough?
time = ingaemtime % 24000;
double angle = Math.toRadians(time / 24000.0 * 360.0 - 90.0);
This would be the formula to convert the time to an angle on this circle
I guess its enough
um
So youre suggesting to take this angle and compare it to the player's pitch?
Correct me if im like completely offroad
More or less.
The sky is apparently offset by about 10 degrees causing the sun to appear at exactly 22925 and the moon to appear at 12575
but only sometimes
idk
how do i spawn in a schematic with world edit? anything I've seen is very outdated, using deprecated functions, and non-existent functions 😦
I have FAWE
I tried copying a new one from here: https://www.spigotmc.org/threads/world-gen-in-fawe-schematic.388096/
but
so what am i missing?
Check your Vector import.
from java.util, guessing that's wrong 😛
I think you're looking for the Bukkit one
yes i imported that now
except paste requires a BlockVector3
so why was that thread using Vector
was from 2019 so maybe the method changed since then
@desert loom do you have a link to an updated version? ive spent like 2 hours searching
I haven't used that plugin/api before so I don't sorry
maybe this might help https://www.spigotmc.org/threads/pasting-schematics-using-fawe.550219/ it's newer
not sure if this is what you're doing though
i have that importing now
that looks useful thanksn
no problem
ok I have 2 versions of spawnSchematic I'll test them both soon
yes i added that to the 1st method after seeing in a random thread
Okay so this is what I have so far:
long time = player.getWorld().getTime();
//Check if night time
if(time < 12000 || time > 24000) break;
//Check if players yaw is on moons "orbit"
if(Math.abs(player.getLocation().getYaw()) < 85 || Math.abs(player.getLocation().getYaw()) > 95) break;
double moonAngle = getMoonAngle(time);
player.sendMessage("Moon angle: " + moonAngle);
if(moonAngle > 90) {
if(player.getLocation().getYaw() < 0) break;
moonAngle = 180 - moonAngle; // Moon Angle should always be between 0 and 90
}
else if(player.getLocation().getYaw() > 0) break;
if(Math.abs(Math.abs(player.getLocation().getPitch()) - moonAngle) < 5) {
player.sendMessage("You are looking at the moon!");
}
public static double getMoonAngle(long time) {
time = time % 24000; // 24000 ticks in a day
return time / 24000.0 * 360.0 - 180;
}
Problem being that the night is shorter in minecraft causing the actual moon angle to be off by about 10 degrees sometimes. Do you know how to factor that in? (or anyone else)
Sun can be seen for 11 minutes, the moon only for 9 minutes
I guess you should reduce the range to these 9 minutes then
That's the thing, their time range is just fine.
if(time < 12000 || time > 24000) break; is more than 9 minutes right