#help-development
1 messages · Page 1368 of 1
different files/separate txt files
for each inv
i'm guessing you're gonna save it in yaml?
it's basically a txt file.
idk how to explain it properly.
usually spigot plugin will use yml as their configuration.
ok
so for the answer of your question is no
it will not take a lot of server performance
and also it really depends on how you save and load it.
thx
[14:44:22 INFO]: [BasicCMDs] Enabling BasicCMDs v1.0*
[14:44:22 ERROR]: Error occurred while enabling BasicCMDs v1.0 (Is it up to date?)
java.lang.NullPointerException: null
at me.zeprix.BasicCMDs.cmd.help.<init>(help.java:17) ~[?:?]
at me.zeprix.BasicCMDs.Main.onEnable(Main.java:19) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-574]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.5.jar:git-Paper-574]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.5.jar:git-Paper-574]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) ~[patched_1.16.5.jar:git-Paper-574]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) ~[patched_1.16.5.jar:git-Paper-574]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:580) ~[patched_1.16.5.jar:git-Paper-574]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:280) ~[patched_1.16.5.jar:git-Paper-574]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1055) ~[patched_1.16.5.jar:git-Paper-574]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-574]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_281]
[14:44:22 INFO]: [BasicCMDs] Disabling BasicCMDs v1.0
What is wrong?
This is code that made something bad xD
you try to execute a method on a something that is null
Hello, I have 2 small questions.
-
How to get server folder? but Not plugin folder. (ex: I want to get also, bukkit.yml spigot.yml etc) (I tried file = Bukkit.getServer().getWorldContainer().getName(); it only returns
.) -
how to zip my file? (No result in google)
just check code i tried args but it didn't work
just create zip folder
- use winrar
- look on ytb
@quaint mantle https://youtu.be/lNp4I-600wo
i used this
very good
any help?
What is the best way to do custom enchantments?
@abstract sleet
thanks. but It's development channel. I want to get server folder in code.
It's development channel ;-;
???? so
I just want zip file in code
oh
how to register command with args in plugin.yml?
server folder
I don't want zip myself! lol
getServer().broadcastMessage("Working Directory = " + System.getProperty("user.dir"));
@quaint mantle
You mean this?
thanks
np
how to register command with args in plugin.yml?
You don't
just use
commands:
test test:
You just register the base command
oh ok
It works. but i'm not sure
mb just register command and all args auto register
Team team = score.getTeam(p.getName()) == null ? score.registerNewTeam(p.getName()) : score.getTeam(p.getName());
if (!team.hasEntry(p.getName()))
team.addEntry(p.getName());
team.setPrefix(ChatColor.valueOf("RED").toString());
team.setNameTagVisibility(NameTagVisibility.ALWAYS);
p.setScoreboard(score);
why does this only apply it to the local player, rather than showing for everyone else?
Because you only set it for that player
Yeah
same questions. System.getProperty("G:\\@Server") it doesn't work, also it returns string but i want to get file 🙂
and i want zip a file.
it's called from a Bukkit#getOnlinePlayers with that passed in as a parameter
Are you giving them each a different scoreboard?
am i meant to?
no
uh well in that function i described above, i'm declaring a scoreboard
so yea...? i think?
since the function's being called for each player alone
i'll try fixing that rl quick
now my server doesn't even start ........//
how exactly would i initialize the variable if it's not with player#getScoreboard?
btw RED was just a filler, each player would have different colors
does that still require the same scoreboard per player?
name: BasicCMDs
version: 1.0
main: me.zeprix.BasicCMDs.Main
commands:
discord:
description: Discord invite link!
basic:
description: Basic commands'
:0
[15:04:33 ERROR]: Could not load 'plugins\BasicCMDs.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
yeahhhh
:0
wtf
What's the matter with you?
can you show me full error?
is it placed in your resources folder?
@young knoll
@Override
public void onEnable() {
org.bukkit.scoreboard.Scoreboard score = Bukkit.getScoreboardManager().getNewScoreboard();
for (Player p : Bukkit.getOnlinePlayers()) {
Scoreboard.setTag(score, p);
}
}
public static void setTag(org.bukkit.scoreboard.Scoreboard score, Player p) {
Team team = score.getTeam(p.getName()) == null ? score.registerNewTeam(p.getName()) : score.getTeam(p.getName());
if (!team.hasEntry(p.getName()))
team.addEntry(p.getName());
team.setPrefix(ChatColor.valueOf("RED").toString());
team.setNameTagVisibility(NameTagVisibility.ALWAYS);
p.setScoreboard(score);
}
what's up w this?
I am working on the enum rn to make it more accurate
Here error and plugin.yml
name: BasicCMDs
version: 1.0
main: me.zeprix.BasicCMDs.Main
commands:
discord:
description: Discord invite link!
basic help:
description: Basic commands
in 'reader', line 10, column 3:
description: Basic commands
^
Can you set an item to not be able to be crafted with?
as in not able to be used as an ingredient
Add unique data to the PDC and then use PrepareItemCraftEvent to check for it
Try this @crude charm https://paste.gg/p/anonymous/2ae70595cbfc4ae789aeae053d6fb28b
i need help
thanks
Replace the old class with this one and lmk now it goes :)
yup
😣😣
You do not put arguments in plugin.yml commands
only the base command
oh
e.g. if I had the command /how are we going, I would only add how to plugin.yml.
smbdy lmk about this
cause it don't seem to work
but it still says the same thing -_-
Can you cancel the crafting?
send the new file here
cause there isn't like a event.setCancelled()
North = {North, NorthNorthWest, NorthNorthEast}, East = {East, NorthEastEast, SouthEastEast}
for example
ok
set the result to null
Each main direction has two deviations now so it is far more accurate
hmm?
Wrong replay, dangit discord
ah np :)
set the result to null
: - ) , thanks
does anyone know a good minecraft bot api plugin?
bot api? for Discord or like a fake player?
fake player, a pvp bot
i will code the pvping my self
ah okay, sorry I don't know
switch(DirectionUtil.getDirection(loc.getPitch())) {
case NORTH_WEST:
case NORTH_EAST:
case NORTH_NORTH_EAST:
case NORTH_NORTH_WEST:
case NORTH:
clipboard.rotate2D(0);
System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
break;
case EAST:
case NORTH_EAST_EAST:
case SOUTH_EAST_EAST:
clipboard.rotate2D(90);
printConsole("EAST");
System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
break;
case SOUTH_EAST:
case SOUTH_WEST:
case SOUTH_SOUTH_EAST:
case SOUTH_SOUTH_WEST:
case SOUTH:
clipboard.rotate2D(180);
printConsole("SOUTH");
System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
break;
case WEST:
case NORTH_WEST_WEST:
case SOUTH_WEST_WEST:
clipboard.rotate2D(270);
printConsole("WEST");
System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
break;
}
like this?
I think so. There is still a slight issue where you have north east, north west, south east and south west but we can't really do anything about it
if you want, you can even avoid the entire DirectionUtil class and use multiple if statements like
snip, don't use this
actually yeah, @crude charm this would be far better
scrap the DirectionUtil class
this?
ok
hopefully it works
Pitch is the vertical one
tfw I am trying to help but keep fucking up 😄
if yaw >= 90, west
else if yaw >= 0, south
else if yaw >= -90, east
else, north
@crude charm ignore absolutely everything I have said previously, this is the way
ok
It may be 0-360
I tested in singleplayer, it's -180 to 180, unless bukkit does differently, highly unlikely that they would change it to 0-360.
if (yaw >= 90) {
//west
}else if (yaw >= 0) {
//south
}
else if (yaw >= -90){
//east
}
else {
//north
}
yup, just put clipboard.rotate2D(...); in and should be good to rock and roll
if (yaw >= 90) {
clipboard.rotate2D(90);
System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
}else if (yaw >= 0) {
clipboard.rotate2D(180);
System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
}
else if (yaw >= -90){
clipboard.rotate2D(270);
System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
}
else {
clipboard.rotate2D(0);
System.out.println("DirectionUtil translated yaw of " + loc.getYaw() + " to direction " + getDirection(player.getLocation().getYaw()).toString() + ".");
}
is this it?
or did I mix one up
try that and if it works then get rid of the debug logs 👍
yup
i am tring to build my project into a jar but i just get the error: java: invalid source release: 11 does anyone know how to fix it
i am useing java 8 and intellij if that helps
this aint working amazing
https://gyazo.com/2d9fada8b223235f980c8de5d196c3b5 @abstract sleet
could you send me the console logs?
that's weird.
[22:43:40 INFO]: 177.6405
[22:43:40 INFO]: Successfully pasted 'plugins\WorldEdit\schematics\House1.schematic' at -247 21 -12
[22:43:41 INFO]: Pasting plugins\WorldEdit\schematics\House1.schematic
[22:43:41 INFO]: (FAWE) @CuboidClipboard used by SchematicUtil.pasteSchematic():40 is deprecated.
[22:43:41 INFO]: (FAWE) - Alternatives: { class com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard,class com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat }
[22:43:41 INFO]: 282.59448
[22:43:41 INFO]: Successfully pasted 'plugins\WorldEdit\schematics\House1.schematic' at -247 27 -11
[22:43:42 INFO]: Pasting plugins\WorldEdit\schematics\House1.schematic
[22:43:42 INFO]: (FAWE) @CuboidClipboard used by SchematicUtil.pasteSchematic():40 is deprecated.
[22:43:42 INFO]: (FAWE) - Alternatives: { class com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard,class com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat }
[22:43:42 INFO]: (FAWE) @CuboidClipboard used by SchematicUtil.pasteSchematic():53 is deprecated.
[22:43:42 INFO]: (FAWE) - Alternatives: { class com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard,class com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat }
[22:43:42 INFO]: SOUTH
[22:43:42 INFO]: DirectionUtil translated yaw of 3.4956055 to direction SOUTH.
[22:43:42 INFO]: 3.4956055
[22:43:42 INFO]: Successfully pasted 'plugins\WorldEdit\schematics\House1.schematic' at -247 34 -12
[22:43:43 INFO]: Pasting plugins\WorldEdit\schematics\House1.schematic
[22:43:43 INFO]: (FAWE) @CuboidClipboard used by SchematicUtil.pasteSchematic():40 is deprecated.
[22:43:43 INFO]: (FAWE) - Alternatives: { class com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard,class com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat }
[22:43:43 INFO]: 90.69678
[22:43:43 INFO]: Successfully pasted 'plugins\WorldEdit\schematics\House1.schematic' at -247 40 -12
Interesting.. so it is 360?
@crude charm Try adapt the values from 0 to 360 instead.
I have some problems setting NBT-Tags with ProtocolLib. If I apply NBT-Tags to items and try to query them, the specific keys aren't there:
NbtCompound nbtData = (NbtCompound) NbtFactory.fromItemTag(MinecraftReflection.getBukkitItemStack(selectTeam));
nbtData.put("Team", team.getTeamId());
NbtFactory.setItemTag(MinecraftReflection.getBukkitItemStack(selectTeam), nbtData);
NbtWrapper<?> nbtWrapper = NbtFactory.fromItemTag(event.getCurrentItem());
NbtCompound nbtCompound = (NbtCompound) nbtWrapper;
System.out.println(nbtCompound.getKeys());
teamId = nbtCompound.getInteger("Team");
java.lang.IllegalArgumentException: Cannot find key Team
at com.comphenix.protocol.wrappers.nbt.WrappedCompound.getValueExact(WrappedCompound.java:227) ~[?:?]
at com.comphenix.protocol.wrappers.nbt.WrappedCompound.getInteger(WrappedCompound.java:380) ~[?:?]
at de.daniel.speedrun.game.item.lobby.SelectTeamItem.onInventoryClick(SelectTeamItem.java:73) ~[?:?]
Soooooooo, i need some ideas / pointers. I need a way to have ammo for an item... At the moment i just do it by getting the slot in the hotbar to the right of it however does anyone have a better idea?
0, 90, 180, 270?
yes
you could use a map storing the ammo, or exp level, or a line in the gun's lore
if (yaw >= 0) {
clipboard.rotate2D(0);
}else if (yaw >= 90) {
clipboard.rotate2D(90);
}
else if (yaw >= 180){
clipboard.rotate2D(180);
}
else if (yaw >= 270){
clipboard.rotate2D(270);
}
The first one will always pass
hmmmm, im not sure if i necessarily like storing all the players' ammo in a map. I feel like that could become quite a pain
you need to do it in the reverse order,
if it is more than 270 then execute x, more than 180 then do y, more than 90 then do z, etc.
Pain?
I'm sure a <UUID, Integer> map should be fine
if (yaw >= 270) {
clipboard.rotate2D(0);
}else if (yaw >= 180) {
clipboard.rotate2D(90);
}
else if (yaw >= 90){
clipboard.rotate2D(180);
}
else if (yaw >= 0){
clipboard.rotate2D(270);
}
like this?
are the clipboard rotate2D values correct?
yea, i mean that having to deal with the loading / unloading of ammo on plugin load / unload might be annoying, irdk
idk
you might want to go for a lore-based ammo storage then
if the schem is taken north
e.g.
Shotgun
---
Ammo: 123
---
Yeah, makes sense
i love you guys
You can scan the gun item's lore, look for a line that starts with Ammo: , grab the number next to that, decrease it by 1, set new lore
Your all making me want to put on a bassnectar remix and write some plugins
your reminding me of my youth right now
Paint and all
https://gyazo.com/6a4224706cd70c13f33f6b4df7555662
@abstract sleet
if (yaw >= 270) {
clipboard.rotate2D(0);
}else if (yaw >= 180) {
clipboard.rotate2D(90);
}
else if (yaw >= 90){
clipboard.rotate2D(180);
}
else if (yaw >= 0){
clipboard.rotate2D(270);
}
please show how yaw is set
^
i will hop off in a min by the way :)
double yaw = loc.getYaw();
ok
Plus there has got to be a cleaner way to invert your angle besides a big branch
i have a CommandKit.java
How do i register it in my main file?
getServer().getPluginManager().registerEvents(new EventClass(), this);
I used to use this for my event class
what do i have to use instead of registerEvents?
in your main class: getCommand("kit").setExecutor(new CommandKit())
Ok I just noticed something
Big logic error. Your only making the first branch or second
ok thx
Yaw is probably greater then 0 at the bottom is always triggering.
Cause your yaw is zero
Im assuming your trying to rotate the building depending on where your looking?
Quick question how can I compare itemstack and material
yes
package me.geoffrey.Tutorial.Events;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class CommandKit implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
ItemStack diamond = new ItemStack(Material.DIAMOND);
diamond.setAmount(20);
player.getInventory().addItem(diamond);
}
return true;
}
}
I get an error
In my main file i got in my onEnable
getCommand("inventory").setExecutor(new CommandKit());
why does it not work
Is it in your plugin.yml
You seem to be pasting these blocks to an anchor a couple blocks off of you in a direction. You need to shift those block in the direction your looking. I would recommend seeing where the anchor is.
i got no such file
idc about exact
Ok then you need to calculate what Direction they are looking (I'm sure the API has something baked in [I haven't touched the spigot API in a while]). Then you need to shift whatever that anchor is in that direction. Im not sure exactly how these blocks are being placed.
But rotating them in a "clipboard" is probably just rotating the whole structure.
Thats not actually manipulating their X/Y Coords in relation to you. It seems to just take your POS then minus some X or Z then paste the structure there.
Plus your overall If Else Statement is flawed. Your checking if a number is bigger then or equal to another in sequential order in what im guessing is to reverse it.
Does anyone know about any popular closet clients? (For use in anti cheat testing)
How are these blocks being placed? Are you using a library or are you converting them from some flatfile (i.E schematic) yourself and placing them
schematic
Show me what code exactly is being executed
Instead of just a random if else statement
So I see why this is fucky. Your always triggering the first if statement in your invert.
Your yaw is always gonna be >= 0 and if it isnt then it doesnt trigger at all
This Cuboid Clipboard where is it's API?
we api
Is this a schematic thing? ( I havent been in the Spigot Scene since like 2018~)
world edit api
I see you have a Parameter called loc. Humor me where this Location comes from. I see it is passed into this Method.
Is this the player location?
yes
So im assuming the rotate2D just rotates the whole structure top down. But lets assume it does. Your never rotating the object cause your first branch in that else if statement is looking for a positive angle.
Another assumption, but all angle are positive so your always rotating by 0.
But I see on line 91 you are adding the schematic with a vector off of the players Location.
I would recommend maybe shifting that location. That will actually move the structure around you.
Try adding 10 blocks to the x and z on the vector and see what happens.
@crude charm i saw u on mc market lol
haha
I havent touched java / mcmarket in over a year
so ive forgot alot
compared to when I was taking commissions every day and coding for hours
i saw the post
What order does getArmorContents return the array in
were you wanted a prac core
Boots to helmet or other way?
try!
Thats common. 8 months ago I was building a nodejs Server Wrapper and could quote off the dome how to read processes and write to them.
I was writting a small script to scrape some youtube id's off of filenames the other day and had to look up the fs modules o.o
@crude charm what practice core you ended up buying?
My hcf core free not that it works or anything
i was talking with geegeetom
I got you
?????
player.sendMessage("/msg "+player.getDisplayName()+" "+data);
I did a update but forgot about this feature I started to add but didn’t finish so it spams console rn
why does this not work to send a private message?
Reread it
that send's a message to the player
That’s going to send a message to “player” saying “/msg”
what command
what do you want to do?
Boom
i make an inventory backup command
player.chat
Thank @young knoll
Hey would it be safe to load an inventory async with some items and then display it to the user back in the main thread? (its a gui)
A method returning an array should specify order in docs fr
I can’t be booting up the server for this
why would you want to do that? an inventory shouldn't have any impact on the performance. not sure if it would be thread safe. think you have to test it^^
Basically I have few loops to add the items into the inventory before displaying it to the user which creates some lag to the main thread
I'm trying to make a bedwars shop but I don't know how to buy the items with iron and gold etc. Is there anything that could help?
can you show me one of the loops?
Can i set durability on an item like a blaze rod which doesn't normally have durability
Well its not something really really heavy but I was thinking that if it's thread safe why not do it that way.
We are talking about ~20-15ms
you could try to do it with packets
then you have to throw your idea
hmm, ok
Anybody know what order getArmorContents returns the pieces in
thanks anyways then 🙂
does anyone know what IntStreamEx and StreamEx are, error that came in a resource about protocollib's sign input w packets, dk if it's a library i get or if it's supported in a newer version of java
what are you looping? what loop are you using?
basically I have a switch statement that holds a value and I loop materials to get the value
Some kind of a "shop" basically.
They way I think it modifying the inventory async before sending it to the player should work
Can you not cache it
That's what I do currently
are you looping with a while.. for...?
So you need to think about time complexity my friend.
O(N^6) jesus
me either I just heard about it in a ben awad video where he commited 2 counts of cha cha slide.
But for real though how many loops are you doing, plus whats going on in the loop
what does O mean
Cause you can start squaring instructions like a mad man really easdy
and more important what loop are you using
for
Im guessing the For loop is the loop in Java that isnt using iterators and generators instead of a foreach or whatever it is in Java (Has been a while since I have written Java)
its more or less the same
I guess you can just write both in there. I remember you could do (string [] derp : string herp) or whatever in the loop
I've been writing interpreted javascript and php garbage the past 2 years
;p
im wondering what you are doing inside your loops to get performance peaks, @pine wing.
can you show us your code, or is it a top secret?
Basically my question was if it would be safe to modify an inventory before its shown to a user unrelated to the amount of time needed to fill the inventory
wait is the NSA gonna kick in my door for talking about time complexity with you for your project?
uh no
Encrypts Dank Memes Folder
Yeah I know right but since its Bukkit API and they say "async bad" everywhere
but it should be, if you don't mess with it in another thread
you also could synchronize it
This should work, right? https://paste.md-5.net/huwuyabobe.java
I'm trying to make a command that creates a recipe
this fits here more
um...
bruh
I dont know but I know it's now being imprinted into memory
theres this one https://dontasktoask.com/
Not the same affect though. I like how it shoots out an mp4. Its pairs BEAUTIFULLY with discord
but i need to know.. what shouldn't i forget to click???
whats getI18NDisplayName ?
there's no such thing as n^6 as big o annotation
can it be used to get the display name of an item in a gui?
ah yea
yeah think its just still n^2
sorry didnt see it
cause big o notation is like trash and doesnt describe anything helpful
it does
not true
we need the whole error
it tells you the growth rate
that is the whole error...
but you can't define how much a method will take in time
so that's why you stick to the basic ones like O(1)
and n^2
its not. there have to be a "caused by" part. "Mehr anzeigen" <--
u have an npe
but I shouldn't
52
switch (player.getItemInHand().getItemMeta().getDisplayName()) {
oops
yeah both are that
looking at 2 different errors
either the itemmeta or the displayname is null
#hasItemMeta - #hasDisplayName
if (event.getItem() == null) return;
ok
if(event.getBlock() == null) return;
but the itemmeta can be null
?
thats the class
do it in multiple lines
i thought its a screenshot
the class
?paste
but its an actuall class
how did you do that
bruh
oops
there
it's if its a big file you can still add it I think
idk
big message
anyways, just add a item#hasItemMeta && item#hasDisplayName check before your switch
whats wrong with it
anyways, just add a item#hasItemMeta && item#hasDisplayName check before your switch
the itemmeta and the display name of an item can be null. thats the case here. you have to check, if one or both of these things are null. if so - return.
ok
also, little recommendation -> use a for loop
getItemMeta will only return null if the material returns true for isAir
if (event.getItem().getItemMeta() == null || event.getItem().getDisplayName() == null) return;
like this?
yeah. you can do it like this.
or you just use the methods which are intended for this purpose -> item#hasItemMeta && item#hasDisplayName
event.getItem().getDisplayName() == null)
event.getItem().getItemMeta().getDisplayName()*
@crude charm
its a bit dirty but im on my phone
@hybrid spoke can I make a minecraft plugin in lua?
eeeew
Is it gonna use alot of deditated wam?
I didn't
huh
I only changed the switch
BanRepository repo = databaseHandler.getRepository("ban", Ban.class);
...
public <T> Repository<T> getRepository(String key, Class<T> type) {
return (Repository<T>) this.repositories.get(key);
}
Why is this not working?
I have no idea.
What's that, spring?
where do you see spring?
Nvm read it wrong
Define "not working" 😄 do you have any exceptions?
won't even compile
does your repository class have a generic type?
You will get a Repository<Ban> which does not have to be this exact implementation
public class BanRepository extends Repository<Ban> {
public abstract class Repository<T> {
I'm tired
Exactly. But there could also be other repositories who implement Repository<Ban>
As soon as you throw away the generic type and use concrete implementations you need to define concrete methods for those implementations.
layman's terms
public BanRepository getBanRepository() {
return (BanRepository) this.repositories.get("ban");
}
But this kind of defeats the purpose of the generic.
no
what's confusing to me
is this:
public <T> OxideDAO<T> getDAO(String key, Class<T> type) {
return (OxideDAO<T>) this.daos.get(key);
}
public <T> Repository<T> getRepository(String key, Class<T> type) {
return (Repository<T>) this.repositories.get(key);
}
cba to ?paste
You could also work with the generic class instead.
So Repository<Ban> repo = databaseHandler.getRepository("ban", Ban.class);
the first one works fine
oh yeah that's fine
I'll test that
actually that might be an issue
I implement some methods in BanRepository but I also have some that I've added
guys, using reflections to access a private class' fields versus writing them to a packetdataserializer and reading them from there
BanRepository repo = (BanRepository) databaseHandler.getRepository("ban", Ban.class);
But thats an unsafe cast because there could be other classes returned that implement Repository<Ban>
I mean. Then everything you need should be defined in the interface Repository<T>
there's per-type methods
for example:
public List<Ban> getAllByModerator(UUID moderator) {
return this.dao
.createQuery()
.filter("moderator", moderator)
.asList();
}
I could just get rid of the method and use that query each time but that's less consistent
Generic methods can be defined in the interface too.
And if you have type specific functions you need to separate your concerns and write new classes for that.
I suppose
But working with generics is always a hustle and will lead to weird casts left and right
Depends. Writing directly to a packetdataserializer is faster but not type safe.
I'll probably go with interfaces
This should work, right? https://paste.md-5.net/huwuyabobe.java
I'm trying to make a command that creates a recipe
Try it and see
I would do this:
On command -> the held item is the result
Open a Dropper inventory where the player can insert items
Listen for close event and get the item matrix of the dropper inventory and create your recipe from that.
ik the one i sent is my ripoff site lmao
¯_(ツ)_/¯
Good question
is there some easy way to make this like "case tier NUM - player perform command crafts blaze tier NUM" ?
?paste
im not gonna download that
you dont have to
damn
discord really bumping up there coding features
indeed
whats ur issue
use a loop my guy
for loop
yea ik i need to use some loop i just dont know how to make it
i get errors when i try to do it
dumb ones
for(int i = 0; i < 12; i++) {
if(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("Tier " + i) {
// code
break;
}
}
This should not be done with a loop but with a simple HashMap<String, String>
Good day! I don't want to interupt anyone but is there anyone who can help me with my server console log error
Nvm... not even with a map. This can be a one liner...
paste it G
i have no more than 1 month of coding experience..
in a paste bin
Thats fine
i get that you are a pro and everything
and ik everything i do can be better
but i dont need to do it in 1 line
i need it to work
u right
thats some wise words right here
whats in line 24 in your Main?
@old dock send the code too
getCommand("Kill").setExecutor(new Kill());
the whole main?
onenable
"java.lang.NullPointerException: null
at com.gummychewz.powercore.Main.onEnable(Main.java:24) ~[?:?]"
that second line is gonna tell you where the error is most of the time
ill send a pastebin
did you register your "Kill" command in your plugin.yml? is there any chance, that "new Kill()" could be null? lol, brain not working. object instantiation null
This is how you could handle any arbitrary number in the String.
public void dispatchFromItemName(Player player, ItemStack itemStack) {
if (itemStack == null) {
return;
}
ItemMeta meta = itemStack.getItemMeta();
if (meta == null) {
return;
}
if (!meta.hasDisplayName()) {
return;
}
String displayName = meta.getDisplayName();
if (!displayName.startsWith("Tier")) {
return;
}
String numberString = displayName.replace("Bob ", "");
String commandString = "crafts blaze tier " + numberString;
Bukkit.dispatchCommand(player, commandString);
}
Just a new method that takes the Player and the ItemStack.
Then it dispatches the command based on the ItemStacks name.
Thats not a good practice but it should work as long as the name does not contain any color formatting.
anybody think of a better way to see what set of armor a player is wearing? https://paste.md-5.net/jutumocino.cs
ok so i do have 19 of there menus so could i get the second argument of the title ? something like
type = e.getView().getTitle()
and then only take the second word from
All Blaze Tiers!
String commandString = "crafts" + type + " tier " + numberString;
Bukkit.dispatchCommand(player, commandString);
that functionality is from pumpkin heads right
maybe check if the armorcontents of the player equals with the armorcontets of the kit?
but to show any block on the head
its either pumpkin heads or that is some next level packet stuff
🤔
yea and what im thinking is its able to do that cause the code for the pumpkin head can just get applied to any block
more like the normal equip function. you can set any itemstack as the players hat
and whats your error?
your returning false
you need to return true or it will do that
oohhh
idk im following a tutorial from 2018 so sorry
thats decently recent ni coding terms
some things are from 2005 and they get plenty of attention
how do i do the full command im kinda new to spigot
?jd
package index
how do i fix my localhost saying that my plugin is dissabled
how to import BungeeCord in maven? P.S. import net.md_5.bungee.api.plugin.Plugin; doesn't work for me
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
That shows what you need to add to your pom
i lurk 👀
already
Can you send what your pom is currently if that's not working, if that's what you mean by already
import net.md_5.bungee.BungeeCord; - NOT WORKING
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.ChatEvent;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.event.EventHandler;
rip the pom.xml
Likely the bungeecord api import only imports api classes. What do you need the BungeeCord class for?
what happens more often, inventoryclickevent or 5 seconds passing without one occurring
@cinder thistle how do i enable my plugin
@quaint mantle
full error please
https://www.spigotmc.org/wiki/event-api/ this is how you register events with bungeecord
https://www.spigotmc.org/wiki/creating-basic-command-functions-in-bungeecord/ this is how you register commands with bungeecord
its not
there is more stuff below that
and
the whole server logs
and the start
during the startup of the server
it should say why it didn't launch correctly
how do you get that squiggly symbol that makes the text change colour on an english keybored
yea
lol, the gods seem to agree
y did his messages get removed
Cause mac is for weirdos
sure
macOS and butterfly keyboard are the nice things
and that it's primarily laptops
but other than that? ffs the pricing
ok well i will contact your local insane assilum
^
?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.
is something wrong with this if statement? if(player.getWorld().getName().equals("skyblock")){ Location skyblocklobby = new Location(Bukkit.getWorld("skyblock"), 2.31,90.00 ,4.45); player.teleport(skyblocklobby); return; }
i didnt asked if u could help me
it is the same concept
can someone figure out how to fix my plugin disabling
enable it
that's not the only thing in that message but k
lol, i just said that i need help and then i sent the question lol
To get Bukkit.getName() and use an List array on the inventory click item event would this be te best way to get player name across classes ?
Is there a way to have blocks disappear for you, but to other player's they're still there.
For instance, there is a wall and for you, that wall has a whole you can walk through but to other players that whole isn't there.
It is disabled cuz it didn't start correctly
oh
what happens if you add an identical potion effect to a player, does the duration get summed or is the new duration used
overrides, i believe
the effect with longer duration takes priority
that then
yeah
does anybody know what this means?
[20:03:25 ERROR]: Error occurred while enabling gunWars v1.0 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.roey.gunwars.Main.getCommand(String)" is null
But good on you for java 15+
but lowercase plugin name
Theres nothing wrong with that if statement, depends on what its being called though.
I have a private Object object field in my class that I am trying to serialize/deserialize with Gson, but for some reason it won't deserialize, the value is always null
what event should i use to check if a player picks up an item?
Did you google it?
I mean, if even says what event to use instead
ok thx
declaration: package: org.bukkit.event.entity, class: EntityPickupItemEvent
damn
so fast
public void onPreLookupProfile(PreLookupProfileEvent event) {
UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + event.getName()).getBytes(Charsets.UTF_8));
event.setUUID(offlineUUID);
event.setProfileProperties(new HashSet<ProfileProperty>());
}```
That prevents the server from looking up stuff right?
always use the javadocs. It usually tells you right in the deprecated notice what the replacement is.
That's a Paper event.
oh
https://papermc.io/javadocs/paper/1.12/com/destroystokyo/paper/event/profile/PreLookupProfileEvent.html <- proof its a|| paper ||event.
No paper here, only us Spigoters
It's funny to me how there is a fork of a fork of a fork of a fork of a fork of a fork of a fork of a fork of a fork of a fork of a fork etc
Posting links to forks is generally frowned upon. I've seen people banned for it.
really?
They form a ban- aww
Afraid so. Its akin to posting adverts for Wendys in McDonalds
damn
btw, do you guys know whether there are pull request from paper to spigot sometimes?
need help with plugin
I want to make red leather armor, and then give it meta data
But when i do that
It overwrites the color data
ItemStack item = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta metaLeather = (LeatherArmorMeta) item.getItemMeta();
metaLeather.setColor(Color.RED);
ItemMeta meta = item.getItemMeta();
if i set the meta to metaLeather
then set the meta to meta
It overwrites each other
It doesnt work..
LeatherArmorMeta have the same functions ItemMeta has
Yes it does
Oh you know what
So i am adding attributes to it
And those arent appearing on leather armor
but they appear on the helmet im using
wich is just a player skull
How are you applying the attributes?
meta.addAttributeModifier(Attribute.GENERIC_MAX_HEALTH, helmetHealthModifier);
meta.addAttributeModifier(Attribute.GENERIC_ARMOR, helmetDamageModifier);
holy crap
thank you
It all on head
EquipmentSlot.HEAD
I need to change that
eyyyy
im trying to tp a player to a specific world when he dies
I'm going to guess you are trying to do this in the death event?
yes
You can;t.
you have to do it in teh damage event or the respawn event
Are you wanting to avoid teh death screen totally?
no, i just want to make when the player press the "respawn" button he gets teleported to a specific world
then set a flag (PDC) on the player in the death event, then when the PlayerRespawnEvent fires look for the flag and teleport as you need.
Thats Not spigot
Would it work on spigot?
No
Its not spigot so no
i have used that before
Ok
How would i detect if the player is jumping
without side effects like if they are flying
close to the ground
it can get resource intensive, but something like player.isOnGround() maybe
StatisticIncrementEvent is the best option
then test if player.isGliding()
check teh isFlying() is false and check their Y velocity
alright
though you will run into issues with ladders
That will trigger with a bunch of other stuff
and climables
Yea
climbables*
Even using the StatisticIncrementEvent has some issues with ladders
you can;t trust isOnGround() as thats totally client side adn can be easily faked
How do you do it?
Jumping is simply too client sided to detect reliably
so check if the block at their feet is Material.AIR in addition
or get the blocks height and its adjacents and see if he player is actually standing on a bloc
I still vouch for the StatisticIncrementEvent
whats the difference
something like this
public boolean IsJumping(Player player) {
boolean jumping = false;
if(!player.isOnGround()) {
if(!player.isGliding()) {
if(player.getLocation().getBlock().getType().equals(Material.AIR)) {
jumping = true
}
}
}
return jumping;
}
It handles most of the scenarios for you
But will still trigger when getting on ladders
probably not a very good solution but you could add on to it
ye thats most likely a better idea
isn't isOnGround() deprecated?
Ill check for air
Yes
yeah
just use paper's PlayerJumpEvent /s
Dont you need the server to be running paper?
yes
^
there isn't a great way to detect whether the player is jumping
but any of the ideas above might be a solution
hey
whats damage sound?
like when player hits a player
what is sound name
can smb tell me pls?
thx
...
its hard to take u seriously lol
How do I make a message sent to a client but isn't visible for others
Player#sendMessage(String)
hello guys can somebody make a 3x3 pickaxe plugin for me also the pickaxe mine 3x3blocks bc everytime i try some shit errors comes out
Thats not a difficult project. Just take it one step at a time.
Hello, I've got a question, is it possible to get the server public IP and the port, the ones a player would use to connect? I can't use Bukkit.getServer().getAddress(), as I have read it returns the IP in server.propreties (returns blank string for me anyways), and the InetAddress way doesn't work either because it returns the local IP...
(it also shouldn't use an external website)
Is there a way to do that with "normal" bukkit?
No
Bukkit has no routing nor gateway information revealed
ok thanks
not with bukkit, but with java
URL whatIsMyIP = new URL("http://checkip.amazonaws.com");
BufferedReader in = new BufferedReader(new InputStreamReader(
whatIsMyIP.openStream()));
String publicIP = in.readLine();
He did say he didn;t want to use an external website
too bad!
true
You can listen for the Server list ping
not what hes trying to do
Yes, but it does return the domain name
server public IP
You can resolve the domain name afterwards
"normal" bukkit?
It'S java
read the question
I. e. listen for SLP, obtain the Server Address field in the handshake packet, then connect to that address via Java API, then obtain the ip address to it
or, just use my solution which is 10x easier
It does not use any foreign Websites
Alternatively on windows you can make use of ipconfig and parse that
I think so at least
no reason to do that
Using a website is the naive approach, using SLP is the extremely naive approach and lastly using ipconfig or similar is the hacky approach.
Choose what you want
yup, that's the conclusion I arrived to and was asking to find out if there is a normal approach
thanks everyone 🙂
double radianYaw = player.getEyeLocation().getYaw();
if (radianYaw > 180) {
radianYaw -= 360;
} else if (radianYaw < -180) {
radianYaw += 360;
}
Bukkit.broadcastMessage(String.valueOf(radianYaw));
radianYaw *= Math.PI / 180.0;
Vector dir = new Vector(-Math.sin(radianYaw) * chargeCoef, yCoef, Math.cos(radianYaw) * chargeCoef);
player.setVelocity(dir);```
Hi ! I'm trying to eject a player to the direction where it look. but there everytime a small gap between where the player watch and where he is eject
and i don't know why this gap is present and i don't find solution to correct this
you want to push him in the direction he's looking?
yep
Hello! I recently added a new plugin to my minecraft server, the name of it is "ShopGUI+", and I would like to translate him to french, is it possible ? Thanks for responses!
set the player's velocity to the direction of their location and then u can adjust that velocity how u want
thanks and sorry for send this here x)
for example player.setVelocity(player.getLocation().getDirection().multiply(2.0D));
this is not what i want to do. I need to control the Y velocity as you can see on the line of new Vector
you can adjust the Y to whatever you want after modifying the vector entirely
and fun fact it don't work
however there still the problem
show a gif or video idk what u mean by small gap
in red where the player he looking and in blue ejection direction
and some times his more important and other less
yes, a variable you're using on line 26 is null
ah i see
for (int i = 0; i < MineEvents.mine.size(); i++) {
for (Player spieler : MineEvents.mine.get(i)) {
ActionBarAPI.sendActionBar(spieler, "TEST");
return;
}
}
Why is this not working?? for (Player spieler : MineEvents.mine.get(i)) {
Can only iterate over an array or an instance of java.lang.Iterable
Hm ok, thx i tryit
Bukkit.getScheduler().scheduleSyncRepeatingTask(Lobby.instance, () -> {
armorStand.teleport(p.getLocation().add(0D, 2.35D, 0D));
}, 0, 0);
this armor stand should stay on top of the player's head at all times, however even with 0? (which i can't comprehend the logic behind), let's say 1 tick repeating, it's not perfect. i've seen servers pull this off before so i'm sure it's possible if anybody knows
i'm aware the server is behind the player client-side, so there's a sort of latency in that aspect, but i'm talking about other players.
How can I add an ItemStack to a chest? inventory.setContents, inventory.setStorageContents, and inventory.setItem all aren't working out for me. Surely I'm doing something wrong.
Itemstack instantiation:
itemStack = new ItemStack(Material.RED_STAINED_GLASS_PANE, 1);
itemMeta = itemStack.getItemMeta();
Lore.add("THIS CHEST IS A DISPOSAL CHEST.");
Lore.add("ALL ITEMS PLACED INTO IT ARE FORFEIT.");
itemMeta.setDisplayName("Warning!");
itemMeta.setLore(Lore);
itemStack.setItemMeta(itemMeta);```
Container append:
```java
container = chest.getContainer();
inventory = container.getInventory();
inventory.clear();
item = new ItemStack[container.getInventory().getSize()];
item[0] = itemStack;
//Tried inventory.setContents, inventory.clear + inventory.setItem, inventory.setStorageContents.
inventory.setStorageContents(item);
container.update(true, false);
No errors are being thrown (It's in a try/catch -> log block). I'm thinking I'm probably doing something wrong with the ItemStack, since clearing the inventory works perfectly fine. All variables are declared out of these blocks just to save space on my already large message.
guys how big r object references? .-. i assume 8 bytes on 64bit cpu?
if youre calling .update you need to use getSnapshotInventory
greetings master 
Thanks so much!
Is it possible to see the "decompiled" code from BuiltTools?
work/decompile folder
Alright thanks
Is there a way to have blocks disappear for you, but to other player's they're still there.
For instance, there is a wall and for you, that wall has a whole you can walk through but to other players that whole isn't there.
yes w/ packets
@ornate heart i fucked around wit this a while back, heres the relevant code so u can kinda see how it works:
https://paste.md-5.net/obekozoxav.cs
lol i used sendBlockChange instead
yea this isnt even packets ;-; sry
Gotchu. Would the player be able to go through the space that doesn't have the block change if that makes sense or is there sort of a invisible barrier still there?
if the block is there in reality but hidden for the player, no the server still knows theres a block there so it'll knock player back
idk how to get around that .-.
do the opposite probably
yea lol the sample code i posted was for placing imaginary blocks where there were none
Gotchu. I'll play around with it. Thanks
hav fun sir
is nms the solution
Hey I have a medieval based server and I created this plugin that lets players to pick between General chat, RP chat, and Kingdom chat though kingdom chat is not working it has worked before in the past but is no longer working even though the code seems fine, so I was wondering why it isent working.
Code - https://paste.md-5.net/esipazuzox.cs
This is unreadable...
I would strongly advise you to clean that up a bit. Create more methods with meaningful names and try to limit your nesting as much as possible (2 is almost too much already).
And really respect the character limit.
If your line is more than 130 - 150 chars then there is something seriously wrong with the code style.
And prevent single character variables. Thats a bad habit.
hey @lost matrix r u able to comment on my issue?
I ik I dont really like it either but this plugin was made awhile ago when 1.12 was still relevant, ill do the clean up later but the only code that matters is this
if (!p.hasEnabledLChat().booleanValue())
this.msg.sendMessage((CommandSender)pl, (MessageUtil.Messages)MessageUtil.Message.CHAT_LAND_DISABLED);
e.getRecipients().clear();
for (Player on : Bukkit.getOnlinePlayers()) {
DivineCorePlayer online = Main.get().getPlayerManager().getPlayer(on.getUniqueId());
if (on == pl) {
e.getRecipients().add(on);
continue;
}
for (String land : p.getLanden()) {
if (online.hasLand(land) && online.hasEnabledLChat().booleanValue())
e.getRecipients().add(on);
}```
srry xD
likewise
what ide do you use?
intellij
the .booleanValue() and the redundant casts should be picked up by intellij
yea?
telling you that they're unnecessary
Thats probably from MetaDataValue
And not even a cast
(CommandSender)pl
Ah you mean that line
hello, how can i lock the instrument in a noteblock? I put a noteblock with a given instrument, but when the block under the noteblock is updated, the instrument changes
This kind of looks like it was taken from decompiled code actually
^
yeah I said I made it when 1.12 was still relavent im trying to update it to 1.16
Cancel the BlockState change if the target block is of type NOTEBLOCK
player extends commandsender, hence the cast is unnecessary (CommandSender)pl
do me a favor and send me a screenshot of your ide's pov
hover over all the yellow highlights
and fix them
hover over the dark gray
fix them
last time I did that it broke the whole thing
would you show some sample code please? (I'm a beginner and I don't understand too much)
?
it won't break anything
it'll ask you to remove .booleanValue() as it's unnecessary, then the new Object[] {, yeah definitely decompiled
Boolean.valueOf(false)?
Everything that is yellow should be resolved. That would be step one to "updating" something from decompiled code.
on is very ambiguous
try all or allPlayers
for the Player on : Bukkit.getOnlinePlayers()
this. is also unnecessary in that context but that's your choice 🤷
I actually dont know what event is fired. So i would start with the BlockPhysicsEvent?
Collored is literally spelt wrong in getColloredMSG
consider changing pl to -> p or player
i can't really help u with this, but reduce nesting with the } else { and if () {'s
if (message#startsWith("! ")) {
// blah
}
if (message#startsWith("# ")) {
// blah
}```
is better than collapsing it all with `} else {`
I would just re-write this to be honest.
With proper object oriented models. Create a ChatChannel class and add/remove users from there.
I put it as pl because it smthing else is using p
no its to get the playermanager
is there any difference between
Bukkit.getOfflinePlayerIfCached(String)
and
Bukkit.getOfflinePlayer(String)
Dont use single or binary length variable names. Its a bad habit.
manager && pm > p
for that instance
looks like your main class is dubbed as a final ? you should also learn to use that since i'm guessing it wasn't you who put that
you should definitely switch to maven/gradle since your plugin's size rn is gonna be looking at 40mb or so
Yes. getOfflinePlayer() will first go through the cache and if the player is not in there it will query the mojang server to provide a GameProfile and then create/return a profile in any case.
Then getOfflinePlayerIfCached() will just go through the cache and if the user is not in there than it will just return null.
stick to all lowercase for packages
nah just 30jmb
ik
Thanks, the 2nd one is what I needed.
it's sort of weird you went with cokm.trixy.dcv2 and then there's .Json and .Utils, but then .listner which is spelt wrong
stick to lower
case
your sidebar on intellij does not need to be that big either
resolve these
it also looks like you have several classes inside one another, i'd assume they're not enums so
you should also get that checked
or maybe they're enums ig
all your json stuff should go into utils.json
the ambiguity between events and listeners because unless you're creating your own events i don't see why they're not all just under one or the other
they are there own events
ok this plugin was made 1 or 2 years ago its not gonna be clean I was still only learnin gback then
BRO IT IS I MADE IT TO YEARS AGO ON A 1.12 server
two*
yeah 2 years ago srry
I started 2.5y ago. If i would have to re-write something from more than 6 months ago i would just be like "screw this trash im rewriting everything"
yeah I get that thing is though I dont have the time to rewrite im really busy this was made during the summer when I still had time, I just need the plugin to work for now and when I have time I swear to god ill rewrite this shit
All good
how can i get the velocity of a projectile and set it to the velocity of another, but change the direction it's going while keeping the speed the same?
