#help-development
1 messages · Page 1559 of 1
if your dependencies are other plugins, chances are you dun have to shade anything too, because they should also be present in runtime
I have jsoup
you just have to include it in the plugins sections in pom.xml
ah
ah ok
?paste
he is pasting in it for you to refer
ah
something like https://paste.md-5.net/yuxadamizi.js
well almost, remove the comment junk on line 15
yep
that's fine?
just add the shade section into your existing plugins section
How do I check if a bed was clicked? This code doesn't work
you can fix all indents with CTRL+A then CTRL+I
oh thx
or a formatter to format on save 😎
and now I just run the build configuration?
first: why EventPriority low? second: i am pretty sure its just Material#BED
true but that'd be complicated 🙂 im a beginner
eh now I have two exported jars
ima just re-run it
yeah there's an original- file and then the normal one
one will be a minimized jar, so no dependencies
oh ok
teh larger one will have your depends
kk
I don't think event priority is that important.
Material#BED or Material_BED don't work
Class#Method is JavaDocs. Its Material.BED
default is to shade everything you didn;t set to provided
add a configuration section...
there are beds with different colors, but there is no bed type for all colors
yeah the jsoup is there
a new one or add to the original one?
event.getBlock().getBlockData() instanceof Bed
?
probably something like https://paste.md-5.net/oqowakedux.xml
oh ok
add that in the shade plugin section
open it and make sure it included jsoup
I got
java.lang.NoSuchMethodError: org.bukkit.block.Block.getBlockData()Lorg/bukkit/block/data/BlockData;
nice
theres another problem with the rendering tho
hold on
I'm a mac user
how do I screenshot on windows?
Usage: !verify <forums username>
is there a way to change my forums username
donating
Could not find your SpigotMC.org account!
!verify Simooooooon_
This account is already verified!
right it's on my deleted account
I forgot
discord deleted my old acc for no reason
it was also Simo
what do I do
Probably contact a mod
sure
I know
Because discord 100% deletes accounts because they are bored
I have no way to prove it
no the minimum age here where I am is 14
and when I was 13 I entered that I'm 13
and it banned it
Contact a mod and you'll need to prove to them you are teh account holder
https://paste.md-5.net/avejaziwof.cpp I get this error, I followed a guide to send an sign, not sure why it happens
It still fully works just sends the error once in a while
just spam ping md a bunch of times, im sure he will fix it
I'd probably ping steel.
ok
as I've no clue how to go about fixing it
I actually started making a plugin for someone
he might be able to vouch idk
he's a server booster rn
you'll probably only need to log in to yoru forum account to prove it
yeah the website is glitched rn
Can I cast from EntityPlayer to OfflinePlayer?
oh no it's not
EntityPlayer is nms?
yes
in which case, no
lol 65 alerts on my account
ehm
To verify your discord account, please click this link.
Note that this cannot be undone
oopsie
tab list can be order by teams
q:
where should I put a Random generator?
putting it in onCommand doesn't seem right but intellij doesn't like it being in onEnable
If its a fake player you will add them by name
what if i have multiple fake players with the same name?
I want to add serveral fake players with no name to the scoreboard
good luck? Entities are added by UUID, Players are added by name
well UUID.toString
there's a deprecated function to add a Player
how do I check if my args[1] of my plugin command is a player's username?
try adding by name and see what happens
can I not just get the UUID of my fake player?
a player is an entity right so can I not add it by UUID?
do you really mean args[1] or [0]?
actually args 0
ok, is the player going ot be online?
it's a fake player I've made, which I've not spawned in for the sole purpose of displaying on tab
yes but I think I have it
for(Player p : Bukkit.getOnlinePlayers()) {
if(args[0] == p.getDisplayName()) {
oh
I just had args[1]
sorry thought u were talking to me with the player stuff
use .equalsIgnoreCase not ==
oh ok
You can try both, one may work
k I'll try this
If its a fake player you may be limited to adding by name
they still have UUIDs
It seems to only match on name for Player entities
all non Plyer entities is uses teh uuid
how do I get the star symbol? if I want to do something to everyone, like /smite *
not sure what you mean
like in essentials you can do /smite * and it smites everyone
how do I get the input of *
ah, * is a special character in essentials
it literally looks for it then loops all players and kills them
ah ok
but for some reason it causes a tonne of lag
so if (args[0].equals("*"))
oh ok
and hasn't changed the order :/
As I said, Teams may not accept them by UUID
well it looks like it has worked if you look at what got printed
I'm trying to order them using teams
which should overwrite the order of player names
Yes, that only shows you added those UUIDs to the Team
team.unregister();
}
final OrderCounter counter = new OrderCounter(2);
for (MCUTeam mcuTeam : teamManager.getTeamsList()) {
final ChatColor teamColour = mcuTeam.getTeam().getColor();
final Pair<String, String> skin = ColourMapper.getSkinfromColour(teamColour);
final EntityPlayer entityPlayer = createFakePlayer(mcuTeam.getDisplayName(), skin.getFirst(), skin.getSecond());
final Team team = scoreboard.registerNewTeam(counter.nextInt());
team.addEntry(entityPlayer.getUniqueIDString());
Bukkit.getLogger().info("" + team.getName());
Bukkit.getLogger().info("" + team.getEntries());
Bukkit.getLogger().info("" + team.getPlayers());
final PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(
PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER,
entityPlayer);
for (Player player : Bukkit.getOnlinePlayers()) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}```
it doesn;t actually mean it recognises those fake players as those UUIDs
right
how would i test if it's recognised?
add a team prefix
now add them by name not UUID
I guess you are fubar then
fubar?
I'm going to try to add myself to the team
perhaps the team is not displaying on the scoreboard or something?
I don't know if I need to set the scoreboard to display on the tab menu
are you setting these teams on teh Main scoreboard?
oh
ah, no
I made my own scoreboard
just remember Teams are persistent java if ((team = scoreboard.getTeam(TEAM_NAME)) == null) team = scoreboard.registerNewTeam(TEAM_NAME);
oooh and it's ordered them 😄
yeah which is why I clear them everytime
I unregister it every time
k
god why is making a good looking scoreboard so complicated
the other issue is that I still want to use teams to stop team killing
so if I want to have a player listed on the scoreboard
I guess I'll have to create a fake player to look like an actual player?
You are going to have to completely disconnect players from teh scoreboard
there's another issue still
and that's how do I actually clear the fake players from the tab menu
I don't know if there's an easy way to reset the tab menu?
and yeah the UUIDs don't work, only the name
meaning I'm gonna have to give them unique names somehow
and then change the display name
Im looking here, someone is using packets to display particles to all players but is it better than doing World#SpawnParticle
yeah I could set the name as a random UUID
ooooh
I could set the name and the UUID to the same random UUID
so then I can add them by UUID
ah
perhaps not
yes, but would it be unique then?
is there not a chance it could be the same?
Well
It increases the chance a bit yes
Can you not use the most and least sig bits
I may not be remembering correctly
wdym?
I forget where the methods are but there is a way of taking the uuid to a string, think it is uuid.most/least significantbits
That may make it send?
Idk
Hello, i'm making skin changer and it doesn't works (Only works in tab-list and no console errors)
Here's my code
what I tried: runTaskLater
you need to refresh the others players vision
I need help because when I start my minecraft server I have this error : java.io.IOException: Le processus ne peut pas accÚder au fichier car un autre processus en a verrouillÚ une partie at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[?:?] at sun.nio.ch.FileDispatcherImpl.write(FileDispatcherImpl.java:68) ~[?:?] at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:113) ~[?:?] at sun.nio.ch.IOUtil.write(IOUtil.java:58) ~[?:?] at sun.nio.ch.FileChannelImpl.write(FileChannelImpl.java:280) ~[?:?] at net.minecraft.server.v1_16_R3.SessionLock.a(SourceFile:40) ~[server.jar:3096-Spigot-9fb885e-296df56] at net.minecraft.server.v1_16_R3.Convertable$ConversionSession.<init>(Convertable.java:257) ~[server.jar:3096-Spigot-9fb885e-296df56] at net.minecraft.server.v1_16_R3.Convertable.c(Convertable.java:227) ~[server.jar:3096-Spigot-9fb885e-296df56] at net.minecraft.server.v1_16_R3.Main.main(Main.java:136) [server.jar:3096-Spigot-9fb885e-296df56] at org.bukkit.craftbukkit.Main.main(Main.java:202) [server.jar:3096-Spigot-9fb885e-296df56]
google AdoptOpenJDK
the last time your server crashed it left a file lock
find the lock file and delete it (with the server stopped)
it's the session.lock?
but I can't see myself
I want to fix that
I don't really know how to fix that so I think you can use google to search a packet in this style
I already searched a lot so I'm asking for help ._.
people says : hide and visible player(already do), use runTaskLater(already tried)
etc
so your only issue is, that you are invisible for yourself? @quaint mantle
how may I create my own fork of spigot? I want to be able to edit NMS as well
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
hey guys, I have a project with multiple maven modules that I am upgrading from java 8 to 16, should I implement java modules together with the maven modules?
nop, I'm visible and my skin doesn't applied.
my skin only applied in tab-list
what if you "load yourself" by teleporting or else?
how do servers deal with client communication do they make a new thread for each client or something else
client communication á custom client?
oh should I teleport?
as in how does the server send data to the clients, Block placing ect
Does it make a new thread for each connection
most likely. idk if its enough if you just teleport him into the same world. you can try it. otherwise create a new world, teleport yourself in and out so the skin will load
dope but how do I set the server thing up on my pc?
are you going to host the license server on your pc?
Yeah on my second one
god no
Why not?
bad idea
idk how your license system is made but if I had to guess, any power outage or network outage would mean broken plugins
never really dealt with it, but i would say it depends. at least if we are talking about minecraft since the connection is already given. you just sent data to the client and back.
and any user would just end up annoyed that the plugin they payed for isn't working
also if you are not careful you could end up getting ddos'd by your own plugin trying to authenticate
1.17.1?
yes
Wouldn't Cloudflare not be strong enough?
guys i am trying to get an even when player recieves an achievement
does anyone know the even for it?
doesn't work
player.teleport(new Location(Bukkit.getWorld("Dungeon"), 0, 0, 0)); << but it works
but I want not to teleport another world
declaration: package: org.bukkit.event.player, class: PlayerAdvancementDoneEvent
this one isn't the one im looking for this one fires everytime the player does any sort of advancement, if the player unlocked a new crafting recipe, etc.
i want an event for when player gets an achievement like "We need to go deeper" etc
shh someone
anyone know off the top of their heads if getHighestBlockAt() gets the highest block out of the chunk or the first available passable block?
Just add + 1
smh
i.e. if I did it in the nether would it always give me the height of the nether ceil?
oh
if you use it in the nether it will alwasy return the very top
wdym its literally the most intelligent thing ever
mhm
hmm
nah they should've done away with the y plane and just have you play on a flat surface
Anyone gonna help me?
@silk mirage can you reproduce the issue on the latest version?
have not tried yet
bruteforcing valid spawn locations feels wrong
I am using a chunk pregeneration plugin to generate chunks and I was wondering if there is a way to make my server use more resources. I am using this java -Xmx4G -jar spigot-1.17.1.jar nogui when launching the server.
-Xms 4G ?
-Xmx4G
I already have that
yes
ok
-Xmx is maxium ram
ok
which one of these is better (i know, it doesn't really matter, just wondering)?
T[] values = x;
for (int i = 0; i < values.length; i++) {
T value = values[i];
if (value == null) continue;
if (value.something()) return i;
}
T[] values = x;
for (int i = 0; i < values.length; i++) {
if (values[i] == null) continue;
if (values[i].something()) return i;
}
not really a difference, personally id use the first one but its basically preference at this point
I mean the second one is 2 array lookups so it's probably a little slower
doubt thats a speed decrease you would notice
aah gentlemen, can someone please specify my problem
TextComponent.fromLegacyText maybe?
this has done what I needed it to
quick question... does this code check if the button is right clicked? ```java
public void onInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
ItemStack block = new ItemStack(Material.ACACIA_BUTTON);
player.getInventory().addItem(block);
if(player.getMainHand().equals(block)) {
}```
no
it gives them a button on an interact event
You aren't even checking the type of the block clicked
how to do that?
ok
then check if that block is a button
ok so like this? ```java
public void onInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
ItemStack block = new ItemStack(Material.ACACIA_BUTTON);
player.getInventory().addItem(block);
if(e.getClickedBlock() == block) {
} else {
return;
}
}```
"C:\Users\<>\IdeaProjects\TvheeAPIRepositoryInstaller\test\apache-maven-3.6.0\bin\mvn.cmd", install:install-file, -Dfile="TvheeAPI-1.6.0-01.jar", -DgroupId=me.tvhee, -DartifactId=TvheeAPI, -Dversion=1.6.0-01, -Dpackaging=jar gives me
[ERROR] No plugin found for prefix 'C' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\<>\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
uhhhhhhhhhhhhhhhh what is your question?
Why does this not work?
not even close
Oh my foult, I specified the directory 2 times...
getClickedBlock will return Block iirc.
???? so how can I fix this?
You forgot to remove your user name in the second path
Compare the material
how? With what method? pls be specific
blocks are positions in the world
so you need to do e.getClickedBlock().getMaterial() == Material.ACACIA_BUTTON
the button will be in my hand
it is in my hand
are you trying to test if they right click a button in their hand?
do you want the button to be in your hand
ok
yes
so you're not trying to test if they right click a button in the physical world
yes
right in which case you ahve the wrong event
dang
I think
it
actually maybe you don't
lemme check
no I think you have the right one
in which case you want to compare player.getItem().getMaterial() to Material.ACACIA_BUTTON
or whatever it is
declaration: package: org.bukkit.event.player, class: PlayerInteractEvent
the docs for the event might help you
event.getItem() to get the item in hand
I have been trying to get what is in the players Main hand but all it gives me is the deprecated method
oh yeah, event.getItem()
ok
that's because there are hands now
so you get inventory first
then you can get the item in either hand
but the event already has a method for the same thing so you may as well use that
oh thats what I was doing wrong
woah, nice theme - like that a lot
yeah lol
ty, I spent a while customising it
I based it off of the darkest dark theme in eclipse
ok well thx
np
can i have that lol
sure, lets go dms
would this work? ```java
if(e.getItem() == block || player.getInventory().getItemInMainHand() == block) {
}```
or should I just keep the e.getItem
why are you comparing it to the block?
e.getItem().getMaterial() == Material.ACACIA_BUTTON
lol
3IQ
just do it within a millisecond. teleport to and back. thats the way to go
ah thanks u!
hey so im trying to do a basic plugin that multiplies diamond drops, but nothing ive found works
does anyone know the code for the drop multiplier?
Do you know Java?
a little, im still a beginner but i have experience
Alright so what you can do is just use a Datapack instead of a plugin. If you do want to use a plugin listen to the BlockBreakEvent and set the drops in #getDrops
?eventapi
Here's the guide on how to work with events
thanks, ill try it 🙂
is there a way I can get a list off all players being displayed to somebody?
currently I'm doing this to add fake players to the tab menu
are those all errors or is it your theme?
theme
ugh
you don't like my theme :?
no
angee
Red is for errors :kekw:
is good theme D-:<<<
underlining is for errors
anyway back to the question
I can add players like this
themes with red colors for anything else than errors are a bad habit
store them
they don't show up in Bukkit.getOnlinePlayers()
yeah obv.
so just store them as I add them?
ya
then send a packet to remove each one?
yup
ok that's not gonna fly across reloads but if that's the only option then so be it
I find it weird how there isn't like a packet to just reset the tab menu
you can store their data in the spawn chunk PDC so you know what fake players exist
too complicated for it's worth
doesn't really matter as server shouldn't be reloaded in normal use
using a PDC would be the way to go if you wanna have it persist a reload
^
just remove them when disabling
and add them again on enable
oh that's a good idea
then you have it "persistent"
big brained man
out of interest @supple elk what are they for?
the fake players?
yeah
making a tab menu
ok
will keep that in mind
I wish customising it was easier imo
mmmh
Is there no other way to do a custom tab?
You you really have to create fake players? 🤔
yup
or if there is another way, I haven't found any mention of it
Hypixel is doing it, so I doubt there's a better way
How can I refresh someone's skin without NMS? I'm changing their skin in their gameprofile which is fine, except it's not updated on the player's own screen
public final void reloadSkinForSelf(Player player) {
final EntityPlayer ep = ((CraftPlayer) player).getHandle();
final PacketPlayOutPlayerInfo removeInfo = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, ep);
final PacketPlayOutEntityDestroy removeEntity = new PacketPlayOutEntityDestroy(new int[] { player.getEntityId() });
final PacketPlayOutNamedEntitySpawn addNamed = new PacketPlayOutNamedEntitySpawn(ep);
final PacketPlayOutPlayerInfo addInfo = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, ep);
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(ep.dimension, ep.getWorld().getDifficulty(), ep.getWorld().getWorldData().getType(), ep.playerInteractManager.getGameMode());
ep.playerConnection.sendPacket(removeInfo);
ep.playerConnection.sendPacket(removeEntity);
ep.playerConnection.sendPacket(addNamed);
ep.playerConnection.sendPacket(addInfo);
ep.playerConnection.sendPacket(respawn);
player.updateInventory();
}
thats what I use
could you try it out? Whenever I use this everything around me loses it's texture and becomes transparent for quite a long time
I wanna know if it's my computer's fault or the code's
@quaint mantle
that uses NMS
For up to 1.16 you could try using this api: "https://www.spigotmc.org/resources/tablist-1-12-1-16.78073/"
For 1.17 I have not found anything but you could try looking into this plugin (source available on github): "https://www.spigotmc.org/resources/animated-tab-tablist.46229/"
Bro you leaked an IP address lmao
so ?
Against the rules
oh lol
sorry
Its my dbs Ip
Ill remove it and resend it
found unexpected end of stream
in 'string', line 11, column 1:
^```
is basically what it says, but why would it error..
how do I copy across my mask?
It's actually a fake player in the second screenshot
I copy both skin texture and signature
It might also work to teleport him far away and back, though im not sure
java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null```
Getting this error compiling a pretty basic project with maven
Anyone any idea why?
"String.length()" because "<parameter1>" is null
Yeah I got that part
But it's not really something I know how to solve
so where are you using .length()?
Yeah that's not the issue
yes it is
Then you have no idea what you're talking about
as I don't use it in that project at all 🙂
Probably to do with JDK setup
if you're talking about the 2nd layer of the skin, you need to edit the npc's datawatcher and set index 17 to 127 to enable it
there's more info in that table
Building against Java 8 fixed this
public void drawLine(final Location start, final Location end, final double space, final boolean third) {
final double distance = start.distance(end);
World world = start.getWorld();
Vector point1 = start.toVector();
Vector point2 = end.toVector();
Vector vector = point2.clone().subtract(point1).normalize().multiply(space);
List<Player> list = new ArrayList<>();
if (third) world.getPlayers().stream().filter(all -> !all.equals(player)).forEach(all -> list.add(all));
else list.add(player);
for (double length = 0; length < distance; point1.add(vector)) {
list.forEach(all -> {
all.spawnParticle(Particle.CRIT, point1.getX(), point1.getY(), point1.getZ(), 0);
});
length += space;
}
}```
so, I am wanting to make a line of particles from point a to b, but I would need to make these particles visible only to all players except a specific player, the problem is that the lines of particles are appearing in a line, it only starts at the beginning and ends at the end, does anyone know why ?
no there is other ways to make a custom playerlist
https://bukkit.org/threads/custom-player-lists-create-your-own-tab-list-display.429333/ i saw this rn but idk if it works or not
Description:
This util was created to make it simpler to change player lists (tab lists) that players see. Using this util, you can make player vanish...
its probs for a older version of minecraft tho
I'm trying to compile a class...
ToolProvider.getSystemJavaCompiler().getTask(null, manager, null, Arrays.asList("-classpath", "spigot.yml:plugins/PlaceholderAPI.jar"), null, cl)```
I can only use the objects from spigot.jar in that class, but I can't find a way to acces PlaceholderAPI.jar too
Does anyone know how can I do that?
just randomly found it tho
?
if your trying to do things with PlaceholderAPI use its api
I want to acces the classes from that jar file from the compiled class
why
because I need to?
.-.
ToolProvider.getSystemJavaCompiler().getTask(null, manager, null, Arrays.asList("-classpath", "spigot.yml:plugins/ArandomSpigotPlugin.jar"), null, cl)
that tells you how to use the api
for placeholderapi
that's not what I need
Hello, I'm having an issue when I try to find a UUID converted to a string in a List.
https://pastebin.com/HLWXnMhr
- So I have
UUID uuid = p.getUniqueId();which gets the player UUID - I then convert it to a string using
String uuidStr = uuid.toString(); - Then check it was converted properly with
System.out.println(uuidStr);(yes it was) - And finally checks if the uuidStr is in the List players with
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && !players.contains(uuidStr)) {} - But when II click a block I get the error in the link above
Need the code.
And what's the error
the pastebin link
line 67 is null
code?
String uuidStr = uuid.toString();
System.out.println(uuidStr);
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && !players.contains(uuidStr)) {```
Is players null
give all the code ?
no
ChestListener.java:67
line 67 is the if
ok
players is null as others have said
players is defiantly null then
I can try printing players
do you initialize the array list?
oh it is null in fact
Mhm
List<String> players = new ArrayList<>();
but then how can I check if the uuid is or is not in players, if it gives me an error
what is players supposed to contain?
UUIDS
uuids of what?
Well you can't check if something is in a list that doesn't exist
of player sthat click a chest
So start by creating that list
List<String> players = new ArrayList<>();
and where are you putting those players IN the players list?
dont set it to null
do this
ok, I'm backing out of this one
it supposed to serialize it a json and then deserialize it
ok
players is null, reader is null
but wait I should set UUID instead of String
Just replace String with UUID
Yes
are you storing the uuid as string?
I hope nope
I'm storing it in a list as UUID
wouldnt it be a string tho in the json file
pretty sure also theres UUID.fromString(String str)
ok, your path is wrong for reading yoru json
/home/yot/Documents/Java/MasterSword/src/com/yot/mastersword/players.json
why?
thats not going to resolve from the Spigot plugins folder
Yes, but depending what you're doing it having it as UUID can boost the performance a dat bit
its still nto going to resolve when teh base directory is the server
pretty sure its this yourPlugin.getDataFolder().toString() + "/players.json"
if you have it in your data folder for your plugin
so what
your gonna have to store it as a string anyway in the json
atleast i dont think you can store objects in json
Does a JsonElement count as an object ?
hey is it possible to make it possible to somehow hit through a player?
tho if you stored a object in there it wouldnt look that nice in the file
and also it would be uneditable
Yes with maths or if you have access to collision shapes
As for how with maths, I can't help you xD sorry
Everything works if I check if the UUID is in the players List, but if I check if it isn't in the players List, it does not work
¯_(ツ)_/¯
when creating the first eclipse project does the name and description matter
could someone tell me a way to make this code cleaner? https://paste.md-5.net/avusemihat.cs i reallly dont like this part of my code, class: https://paste.md-5.net/ifukusuhuf.java
This looks like a utility, so you shouldent be creating a new instance of it and thus should be static https://cdn.rackdevelopment.tech/img/PaMDKVIPya.png
public boolean senderIsPlayer(CommandSender sender){
if(!(sender instanceof Player)){
sender.sendMessage("You cant run this command on console");
return true;
}
return false;
}
}```
its just that, but i plan on adding a few more things when the sender is not player
so they cun run a few commands from console
- private final whenever possible
- implicit else
- try to pull out logic into functions for composition and possibly re-usability.
- also your kitmanager, why create new instances of it all the time?
doesnt the final thing delete the variable after the code runs?
thats not true
it does for local variables
not for instance variables/fields, nor methods, nor classes
PotionMeta potion = (PotionMeta) player.getEquipment().getItemInMainHand().getItemMeta();
System.out.println(potion.getColor());``` Is this how you do PotionMeta, because getColor() returns null for me.
https://paste.md-5.net/gumimevuro.java is this better?
getBlockX()
Still looking for some more info on this any help is appreciated
I seem to be getting a null pointer at this line eco.bankDeposit(killer.getName(), 5); even though eco isn't null and killer isn't null
name is null perhaps
the stacktrace would tell you everything
How can i get a baked in config file? It isn't supposed to be changed, so I don't need to write it to disk, but getConfig() only seems to work for the default config.yml that way?
is the negative y level here to stay or is it a placeholder while we don't have pt 2 of 1.17 aka 1.18?
considering it will come in 1.18 i doubt it'll vanish
?paste
I had doubts they would make negative y values to start with yet here we are
it's just I'm currently working on starting a multi-month long build project for which I need to make specific world painting plugins and it would suck to start only to have 1.18 show up in 6 months and wipe it clean
PotionMeta potion = (PotionMeta) player.getEquipment().getItemInMainHand().getItemMeta();
System.out.println(potion.getColor());```
Is this how you do potionmeta, because the getColor() is returning null.
Afaik colour only returns something when a custom colour is applied
Default potion colours through potion effect types may not Return their colour there
that's probably whats going on
So is it completely impossible to get the default potion color?
Or is there another way I could do this
I don't know of a place where the server tracks them sadly
But that's just my knowledge
Ah, alright. Thank you.
Nope it's not
Would greatly benefit from those java 15 npe messages
at me.jm.core.utils.statistics.StatisticsData.KillStats(StatisticsData.java:58) ~[?:?]
whats on that line
exactly
.
I've already provided it
How are you telling if they are not null
I wonder that too
printing them
Can you send the entire class rather then just the line
You can also use a newer version of Java and it will tell you what's null
I mean it's possible the underlying shit might be badly coded
Hey so I'm currently working on a plugin api for my friend and I wanna leave him javadoc or any form of documentation.
All I know atm is that you can package the plugin and use it as a dependency but of course that removes all of my documentation.
Can anyone point me in the right direction?
Do you use gradle?
maven
ah sry idk maven that well
f
@EventHandler
public void KillStats(PlayerDeathEvent e){
Player killed = e.getEntity().getPlayer();
Player killer = e.getEntity().getKiller();
addDeath(killed);
int randomAmount[] = new int[1];
if (killer instanceof Player){
for (int i = 0; i < randomAmount.length; i++) {
randomAmount[i] = (int) (Math.random() * 30 + 1);
}
addKill(killer);
eco.bankDeposit(killer.getName(), randomAmount[0]);
}
}
?paste
How would you do it in gradle? Maybe its similar with Maven
I think maven has the Javadoc plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<configuration>
...
</configuration>
</plugin>
ah
i see
ill try this
Printing out killer.getName() and setupEconomy(). Testing it by killing another player
Show us setupEconomy
public boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
return econ != null;
}
returns true
How are you setting 'eco'
You have two economy type variables, econ and eco.
Economy eco = Core.getInstance().getEconomy();
Stop sending us single lines
And now show us the getEconomy method
send us methods or the entire class
public Economy getEconomy() {
return econ;
}
show us your onEnable
public void onEnable() {
instance = this;
scoreboardManager = new ScoreboardManager(this);
playerManager = new PlayerManager();
textActionBar = new TextActionBar();
kitGui = new KitGui(this);
registerCommands();
registerEvents();
saveDefaultConfig();
config();
reloadConfig();
setupEconomy();
getLogger().info("Setting up economy: " + setupEconomy());
if (!Bukkit.getOnlinePlayers().isEmpty()) {
Bukkit.getOnlinePlayers().forEach(player -> {
playerManager.addPlayer(player.getUniqueId(), new IPlayer(player.getUniqueId()));
});
}
scoreboardManager.runTaskTimer(this, 20, 20);
}
You are right
Tip for next time debug the variable you're using and not something else
Hi, I've upgraded my servers to 1.17 recently and I can't seem to find net.minecraft.server.v1_17_R1 (or anything similar to that) in the jar file. I used this in 1.16 to send custom packets. Is there any workaround to this?
they removed that
1.17 uses vanilla package names now
wont include v1_17_R1 or anything like that anymore
ah
InputStream customClassStream = instance.getClass().getResourceAsStream(path);
InputStreamReader strR = new InputStreamReader(customClassStream);
return YamlConfiguration.loadConfiguration(strR);```
I'm trying to load the baked in configuration, but I always get a NPE. What does 'path' have to look like if I place a structure_config.yml in src/main/resources, whereas the plugin entry file is in src/main/java/<github path>/<plugin_name> ?
Oh and note that methods are unmapped by default now
Why are you using a stream to load the config?
Ah
It has to be changed only on my end
I'm making it so that the code is easier to understand but that config file isnt supposed to actually change
sorry what does this mean?
Methods are named a() and such in NMS
Read the 1.17 release post for setting up mappings
this.getResource("resourcename") returns an InputStream
Name of file
I want to detect when the player drops an item in an inventory. I use InventoryAction, except that there are too many possible cases to put an item in the inventory (click, shortcut, 1 item, half, or all etc). So I wanted to know if there is something that detects the action of putting an item in an inventory, no matter how.
thx
@eternal oxide same issue.
java.lang.NullPointerException: null
at java.io.Reader.<init>(Reader.java:167) ~[?:?]```
open your jar and see if the file is in there
Also what did you set the string to
io
META-INF
config.yml
plugin.yml
structure.yml
structures = getDefaultConfig("structure.yml");
//...
public FileConfiguration getDefaultConfig(String configFile){
InputStream customClassStream = getClass().getResourceAsStream(configFile);
InputStreamReader strR = new InputStreamReader(customClassStream);
return YamlConfiguration.loadConfiguration(strR);
}
All that in main plugin class
and the file is there
Just use getResource like ElgarL said
I did
it got worse
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:178)```
```yaml
name: OfMagic
main: io.github.moterius.ofmagic.Echo
version: 1.0
api-version: 1.17
commands:
setspell:```
@chrome beacon
does the stacktrace send anything else
make sure your main package is correct and the class name is correct
that it is because the rest of it works
also
at java.util.zip.ZipFile$Source.zerror(ZipFile.java:1587) ~[?:?]
at java.util.zip.ZipFile$Source.findEND(ZipFile.java:1441) ~[?:?]```
the hell?
?jd
wait wth
the plugin works
the server is messing up
I'mma excuse myself to #help-server
The reason I was using NMS was because I was trying to make invisibility also hide your armor, but I couldn't find any solution that didn't have NMS, so I had to resort to NMS. Player.hidePlayer seems to also hide the player from tablist, so is there any other way I could hide armor?
Is Player#setPlayerListName meant to only display the list name to oneself? that's the behavior I'm getting and I need everyone's list name to display to everybody else, yet I can't find any docs for it and all setPlayerListName docs says is that it sets the players list name ..
I've done it before with Protocollib. It's not that hard
Which version of the Spigot server jar would be best for developing a plugin?
as in, the default, or the remapped-obf, or the remapped-mojang
etc
Ah the reason my 1.16 code wasn't working was because the code wasn't mapped, I got it now, thanks for your help!
assume that the plugin requires the server jar
i am making a fork of another plugin which makes use of the server jar
but updating to 1.17.1 changed some obfuscations so i want to know which jar would be best to use to make things easier
Hello again, so I have an if statement that checks if a block is touched and then do some things, but it only work once, then I need to reload the plugin for it work again .
the if statement : if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {...}
remapped-mojang should be the best for you in terms of binding into it, but outside of that it might be cancer to work with
see, this is why i want a guide to convert from nms to spigot-api code
The issue is that people use NMS for 20000 reasons
if i recall correctly, using the remapped-mojang requires obfuscating the jar, because legal reasons, right
Unlikely - why exactly this is done is beyond me
oh okay
well that makes things easier so i am fine with that
i did not feel like setting up obfuscation
As long as you do not distribute that jar you should be fine
In almost all occasions that I have seen usage of NMS I was unable to find a 100% ideal solution that did not use bukkit api or protocollib
You have to make compromises when converting code, which I would only do on a case by case basis
but if you have any questions on how to convert something, feel free to ask; someone should be able to find a solution
you could just do it manually
how
typing in the java file
Fill the mandatory name field
....
ok
thanks
sorry i haent done much with java i just used online compilers for the basics
should the name be like the io.github thing
ohwait
No
Read on Java naming specifications
Remove the curly brackets around RandomPotionPlugin
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i would recommend intellij idea, but you do not know how to use java, and i doubt that you know how to use maven, so you can stick with eclipse
IDE is totally irrelevant
good point
?basics
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
its jsut the bukkit fandom tutorial says to use eclipse so i went with thta
im just tryna make a basic plugin
datapacks are easier but way more limiting
Correct
and also inefficient when multiple are used, according to my plugin-developing friend
though they can easily implement things like advancements and worldgen
unfortunately, i do not think that any plugin exists for eclipse or intellij which allows for easier creation of data/resource packs
so that sucks
Anyone know what PacketPlayOutNamedEntitySpawn's remapped name is? I am thinking either ClientboundAddEntityPack, ClientboundEntityEventPacket, or DebugEntityNameGenerator.
guys, how do I make that when a player who is in an ArrayList disconnects, its inventory is cleared?
A Spigot event exists for logging off, I believe.
You could make an EventHandler for that event, and make it clear the inventory.
I used PlayerQuitEvent, wouldn't it do?
So... from the tests I've done, when the player disconnects, he automatically leaves the list, so there's no way to clear his inventory.
Oh.
One second, can I add him to another list when he disconnects?
@EventHandler
public void onQuit(PlayerQuitEvent event) {
// some code for clearing inventory
}
why can't you clear the inventory
probably because the player is off
I just don't know, as I said, apparently the same goes off the list when you disconnect.
the player is not yet disconnected in the event
I tried to clear the inventory when it re-enters, but it is no longer on the list.
you have a list?
either one should work...
Yes. For ease, imagine that when the player runs / arena, he will enter an arena. I made a list so that the player who enters does not fulfill certain events when present on it.
so check your list before you remove the player from it!!!!
What would be a correct way to use an ArrayList in another class? I may be using a wrong method that may be causing this.
how are you doing it now?
I made this example class just to test this out and this clears the player inventory on disconnect for me...public class playerQuit implements Listener{ @EventHandler public void playerLeave(PlayerQuitEvent e) { e.getPlayer().getInventory().clear(); } }
`` @EventHandler
public void onQuit(PlayerQuitEvent e) {
Player p = e.getPlayer();
String nick = p.getDisplayName();
if(PNaArena.contains(nick)) {
e.getPlayer().getInventory().clear();
}
}``
I'm doing it this way
what is PNAArena
PNaArena*
that is your list?
it's in the same class or different class, how is it being referenced?
is an arraylist with the players that are in the arena. I was testing
the list isn't empty?
is in the same class
p.sendMessage("PNaArena.toString()"); prints out what?
I don't think so, since when the player is already in the arena, he can't get back in, due to the verification I made
i gonna try
or something more like list.toArray().toString() xd
Okay, now it's no longer removing the player when it disconnects.
However, it's not cleaning up his inventory either.
Hmmmmm, wait
I have a plugin depending on a plugin with obfuscated nms, but I only have the remapped version as a dependency. When compiling, I get this error.
Error:(50,17) java: cannot access net.minecraft.nbt.NBTTagCompound
Anyone got any idea how to fix that?
It's trying to access the obfuscated version but apparently it's cant?
@pseudo raptor do you wanna show me your list? eg public static List<Schematic> Schematic = new ArrayList<Schematic>();
Since when did Essentials Eco not support bank accounts?
when will people stop throwing their money away
public ArrayList<String> PNaArena = new ArrayList<String>();
if(args[0].equalsIgnoreCase("entrar")) {
if(!(PNaArena.contains(p.getDisplayName()))) {
PNaArena.add(p.getDisplayName());
basically this
wouldn't it be easier?
uuid's are the norm
use UUID
it was the way they taught me
old
i gonna try
are you using maven?
but I think if you make the list static it would fix everything
who taught you?
That doesn't really help solve his issue tho
Yes
taking advantage of the moment, if I want to "call" an arraylist in a class from another package... how would I do that?
Is it static or not?
I already told him to make it static
now I put it as static, but before it was just public
so does it work?
I will test now
and yes to your calling of methods from other classes and packages
`` @EventHandler
public void onQuit(PlayerQuitEvent e) {
Player p = e.getPlayer();
String nick = p.getName();
if(PNaArena.contains(nick)) {
p.getInventory().clear();
}
}``
its correct?
It looked fine to me
uh no
shouldn't I use OffinePlayers or something?
that exists
wait... Is your list in a different class from the onQuit event?
no
So then why is he making it static?
Hey, does anyone know how I can fix this issue? Basically what happening is when I load the server, it's supposed to start the plugin when launching the server, but for whatever reason, the only way to get it working is to do the reload command. Im aware that its a problematic command, but the plugin doesnt work at all otherwise. Here's my on Enable
@Override
public void onEnable() {
instance = this;
// THIS MUST BE FIRST ^
this.getServer().getPluginManager().registerEvents(this, this);
CTeam redTeam = TeamManager.getInstance().registerNewTeam("redTeam", "[RED] ", ChatColor.RED);
CTeam blueTeam = TeamManager.getInstance().registerNewTeam("blueTeam", "[BLUE] ", ChatColor.BLUE);
redTeam.getBukkitTeam().setAllowFriendlyFire(false);
blueTeam.getBukkitTeam().setAllowFriendlyFire(false);
}
I don't see anything wrong but maybe I'm missing something
if it's in the same class
oh, so, I removed the static and left it so public
I'm trying to literally do everything I've learned in this short time
Show me your entire class
Some strings are in Portuguese-br, is there a problem for you?
not for me...
nope
why is private KitManager kits; null if i do it like this
but private final KitManager kits = new KitManager(); works just fine? im trying to call a class without creating a new instance of it
private KitManager kits; = private KitManager kits = null;
unlesss... kits = new KitManager();
no
that makes sense..
this applies to every Object, primitives are an exception here
i now see it haha
this is also why you cannot do private final KitManager kits; without assigning it (the kits variable) at the constructor
kits = new KitManager();```
is no? geol?
so should i make it static?
but thats creating a new instance of the class
it's still the same to
private KitManager kits = null;
kits = new KitManager();
just not explicit
why static?
yes I know it's null first
Did you get it to work?
if you do not need an instance then make your constructor private, the class (KitManager) final and make the constructor throw the UnsupportedOperationException
This should prevent you from doing anything wrong
if a player is flying and i use player.setAllowFlight(false); does he falls out of the air?
yes
ah sadly yes
wher is a good tutorial on how to establish commands and stuff
?wiki
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
TheSourceCode has really good tutorials
It woulden't be a player, itd be an OfflinePlayer, and then you can use .getUUID or a similar method
Is there any way I can adapt the specialsource remapping to also install the mojang mapped version to my m2 for use as a dependency?
I know
there isnt a great way to do it
yes
Just it's not recommended as names arent unique
@ivory sleet Know anything about this specialsource stuff?
hmm
I suck at math so maybe someone else can help lol, but if you convert that it seems right to me
Am I designing this Config properly? I feel like I am doing it wrong because other classes can create an instance of the Config class so I feel like that will lead to future issues.
Hello, is there a way to increase how many slime blocks can piston push?
looks fine for me, not sure why you needed a class for a config but it works I guess
I didn't wanna clutter the main class
I don't see an easy way. I've not looked into it, but maybe, maybe creating a custom server jar patch?
I don't think my proposition is a good idea though ^^'
?
The Server#getOfflinePlayer(name) one?
What would be the better way to listen when a class gets loaded?
I'd like to inject code in them ;p
He's talking about the code written by md-5 that is used in buildtools which is all rights reserved.
😌
Rack, you think I should put the Config in the main class anyway. Does putting it in a separate class seem redundant/more complicated?
I was thinking to override the classloader with my own implementation and the previous classloader as parent but I'm not totally sure how spigot and the other plugins will take that since they use a classloader for each
Why don't you just use the class constructor? Or do you mean in a case where it is reloaded?
I'd like to cover EVERY class available
From NMS-like classes to plugin library ones
why isint kitsInv the same as event.getInventory if i create both inventories using the same method
don't do that 🤦♂️
do what
Pretty sure because they're separate instances
wdym
Your private final Inventory kitsInv = new InventoryGuiManager().buildKitsInv(); is a different instance than event.getInventory()
the event.getInventory() is fired when the event occurs whereas the kitsInv = new InventoryGuiManager().buildKitsInv(); is just creating a new instance
You'd need to grab the event.getInventory() instance, not create a new one
what
i always do it like this
What are some features of NMS? I know you can modify a player’s gameprofile and make custom entities, but is there anything more?
i dont get why its not working now
this for example
i made it a while ago
and works just fine
To sum it up the features are "don't"