#help-development
1 messages ยท Page 930 of 1
you mean my main plugin file right? or the server console?
The code you use to initialize vault economy. It's common to have it in your main fine, so ig that
what do you mean by that?
you can make your own event and call your own damage causes
Looks good to me, weird. Are you sure you have both essentialsx and vault enabling before your plugin?
the plugins will have to listen to your event @faint lynx
Bukkit.callEvent(yourevent)
i can send you my console rq if you want? but im quite sure yea
Sure ig
is there an example on how to do that?
Its pretty clear that you dont have an economy provider like EssentialsX installed.
Also make sure your plugin depends on Vault.
He did say that he depends on vault, though I never saw the plugin.yml, but I trust him lol
go to 3rd part
i know how to make the event but i don't know how to set the damage cause of it to something custom
anyone familiar with this world error? I don't think I've seen it before
make a new enum too
how can a chunk file be at the wrong location
and call the event with your custom cause
It does seem like everything is starting in order.
Can you add a println call to every return false to see which one exactly gets called, and work from there?
Also send your plugin.yml just in case
Looks fine
will do
just to be sure here is my pom.xml as well
https://paste.md-5.net/oxuxivupam.xml
and yes it is due to vault still:
[16:56:51 INFO]: [Nexussmp] NexusSMP has been enabled!
[16:56:51 INFO]: [Nexussmp] Disabling plugin due to no Vault dependency found.
[16:56:51 ERROR]: [Nexussmp] [Nexussmp] - Disabled due to no Vault dependency found!
[16:56:51 INFO]: [Nexussmp] Disabling Nexussmp v1.0
[16:56:51 INFO]: [Nexussmp] NexusSMP has been disabled!
corruption
Strange. Did you make sure to not shade Vault into your plugin?
i have provided every single file i currently have basically that has anything to do with it so im quite sure i didn't but i could have made a mistake of course
Did you send your pom.xml?
since im quite new to it coding and plugin development im using chatGPT-4 a lot to help me out
yes here it is again ๐
Ah there it is
Yeah you're shading vault
add a <scope>provided</scope> on your vault dependency block
Inexperienced*
Add scope provided here
Not knowing how to do something you don't have much experience with doesn't qualify as stupidity
Please don't discourage yourself
hahahaha im just joking but it's so stupid if it's something small like that x)
Someone try uploading an image real quick. My discord is unaliving itself currently because it cant upload images.
im gonna check if it works now but thank you all for the help!!!
yea i can't upload one to the discord here
same
same here
I was about to send an old ass meme with md5
what md5 meme?
omg it finally works again thank you all so much i have been stuck all day on that x)
Nice
md5 ocp enjoyer?
public class SomeClazz<T extends OtherClazz> extends T { ... }
Damn, you can do this?!
I mean, it's cursed. But...
๐
What the hell
Tell me you're kidding
This is weird
idk what would be a sensible use case for that
Just that it looks like it should be a federal violation
Thats literally useless because every generic you have, could just be replaced by itself.
But yeah, technically makes sense.
Practically its useless
yeah
This on the other hand:
public class SomeClazz<SELF extends SomeClazz<SELF>> {
}
Is sometimes used
When? Why?
Ah, I think I see why
how do i register a custom enchant and make it add the lore
for example
sharpness I, customench II
You cant because the clients need a translation component for that.
Every client displays it differently based on their language settings.
You need to edit the Lore and use a fixed language.
dang
is there a way to always make it show up properly if i'll add the lore manually?
so if it already has lore it doesnt get mest up
Yes, ive done this by intercepting outgoing packets of itemstacks and adding the HideEnchants tag to them.
After that i get the Lore of the current ItemStack and replace it with:
- Vanilla enchants (own translation)
- Custom enchants
- Space
- Original lore
This can cause problems with the creative mode.
So modifying the actual lore on the ItemStack instead of intercepting packets is equally viable.
Replacing the original enchants is optional
But it lets the user come up with some custom names for enchantments and allows you to add roman symbols greater than X to even vanilla enchantments.
alr
It helps you enforce transitive or self-referential type constraints for your child classes.
I could come up with some examples. But its quite an abstract concept.
public class SomeBuilder<SELF extends SomeBuilder<SELF>> {
private final List<String> components;
public SomeBuilder() {
this.components = new ArrayList<>();
}
public SELF addComponent(String component) {
this.components.add(component);
return self();
}
protected SELF self() {
return (SELF) this;
}
public String build() {
return "[" + String.join(", ", this.components) + "]";
}
}
public class DecoratedBuilder extends SomeBuilder<DecoratedBuilder> {
public DecoratedBuilder withDecoration(String original) {
String decorated = "%" + original + "%";
return super.addComponent(decorated);
}
}
String result = new DecoratedBuilder()
.addComponent("Normal") // If you dont use SELF then the Builder would be of type SomeBuilder<?> missing withDecoration(String)
.withDecoration("Decorated")
.build();
Was already on it
Ok I think I see what you mean
Its probably best if your copy this into a normal Java project and play around with it.
This is enforcing constraints and to prevent stuff like DecoratedBuilder extends SomeBuilder<OtherClass>
I gotcha
I think I've seen something like that in ACF code actually. Might be wrong
Thanks ๐
My actual usage in a project is a bit less straight forward
that can be an interface
You can be an interface

RPGClass is stateful
rpgclass can be an interface
Illusion coming with an "um actually" any time someone does not write code as if it's a PhD at a multi-billion valuation company:
๐
knowing damn well I'm writing some atrocious stuff rn
Whatever we do, we can't follow OCP. What's the point
I can probably make it an interface to be fair. But that sounds like over engineering.
sounds like dependency inversion
What?
what's OCP?
OCD
It's just something that we cannot ever follow due to the rules of our universe e.g. entropy of everything
Open closed principle
how do i check if a PlayerEvent can be cancelled
Open for extension, closed for modification
instanceof Cancellable iirc
instanceof Cancellable cancellable
Does somebody know if it flackers when i close a inv and open another pne right after?
a bit
Yup
just open a new inventory over @inner mulch
will player.getLocation().setWorld(Bukkit.getWorld(args[0])) teleport the player?
no flicker
To use cancellable instead of event afterwards
?tas
I'm lazy to remember everything at once
Does it?
ok ๐
In non-ancient versions it does
I swear I used to have a thing where I would not clone it and increase its Y position and then the player would be going up
even on 1.8 it does
Maybe just bad code back in the dayl ol
how do i register an enchant in 1.20.4
Ideally you don't. Use pdc to detect your enchantments
๐
Ah, very helpful Discord...
What versions of Log4J or SLF4J are available on runtime nowadays?
Hello
Who can help me?
I have a problem with my bungeecord I opened my bungeeCord and it open but when I look into the server list it doesnt appear
and the same happen when I put the ipadress + the port of the lobby
I'm using ubuntu
how do i turn a ConfigurationSection into a Map
Iterate through its keys and add every value mapped to its key to your map
There might be a built in function for it though
I mean getValues() is basically what you need
Hello, if you have a plugins for stack healsoup. I take
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Google your question before asking it:
https://www.google.com/
Nice
not a single error
sick
i got like 14 triggers rn, is there a list of possible triggers? i cant squeeze my brain harder
Just add them as you go and come up with them
should i just read player.class for possible triggers
It's not legally forbidden so why the hell not
ok
hey, so when i create a variable like
int i = getConfig().getInt("somepathhere")
then change the value of somepathhere in config and reload it
and Then i call i use int i will it be updated?
no
I need opinions: nosql or mysql for storing files, and why? The file size should be under 1MB
Im a fan of nosql because i wrote a really nice ODM and the MongoDB java wrapper is cleaner than writing SQL.
But it depends on your data. If its naturally relational, then sql is also a good option. Also SQL gives you more granular controls
because its an actual turin completel language.
I really think that it comes down to preference.
Well in my case I need to store a file along with some metadata (download count, upload time, etc). This feels like it would be good fit for a table and also very fine for a mongodb document for example
That's why I'm in 2 minds
What's the version of the Plib package do you use ? I'm on 4.8.0 and i don't have the WrappedDataValue Class, do i need to implements PacketWrapper?
5.1.0
thx!
For some reason it's 4.8.0 on the spigot page. I started with protocollib today and was also confused when some things weren't working, turns out it wasn't latest lol
I would simply write a wrapper for tracking objects:
@Getter
public class TrackedObject<T> {
private final T object;
private final long timestamp;
private int uses;
public TrackedObject(T object, long timestamp) {
this.object = object;
this.timestamp = timestamp;
}
public TrackedObject(T object) {
this(object, System.currentTimeMillis());
}
public void incrementUses() {
this.uses++;
}
}
And then use a
MongoCollection<TrackedObject<SomeThing>>
And throw my stuff in there. My codec will handle the rest
You have a library you have written and use for mongo, right?
If I understood you correctly
Is it open source?
Hm, its not. But ive been asked for that a few times. I might create a resource for this.
Do you know a good one then? I've heard Morphia is analogous to Hibernate but for Mongo?
Yeah Morphia is the only decent one i know. You could also use Gson as a backbone.
Most certainly will, I already use it for other things in the project
It supports caching, right? If it does I'll start looking into it tmr
Morphia kinda thicc tho
I split it up so i can load only small chunks of data into memory and dont load everything at once, especially if i wsnt to load some1 data when He is offline
It's fine for a server ig
Aren't these the same thing just written differently? I'm confused
I think he wants either one data obkect for everything or small chunks
idk. Question seems ambiguous
It will get you the output of /version, basically
?
Bukkit is the API bridge class. Without it, you can't separate API from implemenation
the fuck is that now
There's a Bukkit#setServer()
It's really the only place in the API where you can set an implementation of a Bukkit type
That's where CraftBukkit says "Okay, everything from here on out is implemented by CraftBukkit"
Hmm
Why? They're just convenience mirror methods
Calling Bukkit#getServer() is totally redundant 100% of the time
Every method in Server exists in Bukkit as a static method that just delegates to that same server instance
Sout > logger
Yeah... that's fine... do that. But plugin.getServer().blah() makes no sense
Wait what
Server#getPlayer(UUID) == Bukkit#getPlayer(UUID)
For every method in Server, one exists in Bukkit and vice versa
In forge we rely on the event bus and a few static methods lol
public interface Server {
public Player getPlayer(UUID uuid);
}
public final class Bukkit {
private static Server server;
public static Player getPlayer(UUID uuid) {
return server.getPlayer(uuid);
}
}
Every single method in Bukkit just delegates to the Server interface
Calls to Bukkit.getServer() are redundant
Lol
looks like a standard ubuntu terminal
doesnt the console sender support hex colors
smh
Blah, I forgot moving packet entities was a pain
Anyone happen to have a wrapper for that sitting around? :p
What kind of functionality do you need
Just to properly send the relative move vs teleport packet
did you try looking into how mojang does it?
pretty sure mojang treats both moving and teleport packets the same
Yes and it's painful to look at :p
ouch
I have it somewhere
It's 8 but yeah
Whatever
last thing, is there a way to make something like this work
%1 + 1%
or
%player-max-health + 1%
as custom placeholders
I don't think so because placeholders resolve to strings
There is a papi addon that can do math
Yeah but those are in-line. Does that resolve expressions from other placeholders?
Not sure
i don't want papi, it's for a custom plugin
Oh turns out you can
I don't think so
?jd-s
Sort in what way?
Filter, probably
https://docs.oracle.com/en/java/javase/17/docs/specs/javadoc/javadoc-search-spec.html search spec doesn't seem to allow you to filter by return type
idk if im missing something but i can only think of 12 conditions
some players conditions and string conditions like contains, equals, etc and integer as well, chance of like 30% and thats all
is that enough?
Hey, Im looking for advice on a plugin project of mine. I worked on an idea with Google Gemini. I'm wondering what your guys' thoughts are on it and if it would be a good idea, so here it goes:
I have a Game class and I need to use the Bukkit scheduler to handle multiple countdown timers for the game, like respawn timers and what not. I asked Google Gemini for advice on this and it made a suggestion, which with a bit of improvement from me came out to be a separate CountdownTimer class that keeps a list of timers represented by another Timer class (the redundancy in the names is an accidental byproduct of how my conversation with Gemini went) that contain their remaining times. One CountdownTimer would be instantiated per Game object and would schedule a task that would run every second and decrement each of its Timer object's remaining times and upon their times hitting zero, a callback created by the corresponding Game object would be called.
ah yeah nothing quite like opening an old prototype project to be reminded of how great one is at naming variables
can't wait to get a BuildSubSubSubMenuContainerContainer
is this c#?
yeah
i see
godot
the naming's not that bad
honestly I kinda like the ui I was prototyping, will probably actually use it, but the code backend is... interesting
did you see the card game slay the spire
I am familiar with it
you mean slay the spire right
yeah
it's a card game
you could make that thing in renpy
you could make that thing as a browser game using nothing but vanilla js
not sure why they chose java
probably because that's what the dev knew
they shaded the jdk in there
I mean it worked out, they sold over 1mil copies
I find that programmers obsess with completely irrelevant things at times
instead they probably made their own engine
it doesn't matter if you make the game in java or c# or assembly, it matters if the game is good or not
the programming language has nothing to do with it
true
if you're making something like slay the spire I'd def either make my own engine or use godot, there is not point in paying a license fee to unity or god forbid unreal engine to make something that simple
unity made sure to make devs reconsider
it's easy to forget that neither unity nor unreal were made for 2d games and that 2d games are often times simple enough that no engine is really required
if you want to make something in 2d honestly if you want to use an engine just use godot, it's actually the only engine that was built for 2d primarily anyway
ori had layering to make the background go at a different speed
you can get a paralax effect going in minutes if you're making your own engine
it is not hard at all
it's a bit harder to pull the effect on a 2d engine
hell I did it for my website and that took something like 3 minutes of copy pasting
i guess you just have to render the background at a different speed
it's dead easy
you need to define layers anyway because some sprites need to be in front of other sprites
and then you can just create groups and define them as ui, background, foreground or whatever, I am pretty sure that an experienced dev could get that working in under 15 minutes from scratch
i see
I know I've seen absolute cavemen devs getting it done in just a few hours while working on their first engine
yeah, if i think about it there's no need for a 3d engine
it's interesting devs still use one for games
oh
i remember
i think it helped them debug easily
having the layers all in a single space might get tedious to debug
historically people have used unity for 2d projects because unity is the most well-documented engine by the community due to the fact it was the first to get pro-indie dev licensing deals, is easier to learn than unreal and has an asset store built into the interface
before godot 4 godot wasn't really on the map
but nowadays the landscape has changed
not like godot is perfect either, I actually find it to have some serious issues if you're doing something that is actually resource-intensive like running a simulation-heavy game but it seems like the average beginner is either working on a visual novel, a platformer game or something about equally complex in 2d
i'd love to make a 2d game myself
but it's such a long journey to get something good out
Anyone tryna dev an smp for free ;D
I had a cool idea for a 2d game that I think is small scope enough that I might try to actually see through
no
an automation game that mixes dome keeper and motherload elements
I think it would be really sick
basically a mix of manually digging down with setting up and automated infrastructure for mining as the resources you dig up go directly towards defending an above ground base that keeps getting assailed by waves of enemies
you'd have to balance setting up defenses, setting up automation and risking going down
since the farther down you'd go the greater the rewards but also the greater the risks
thats actually a really cool idea.
yeah
dome keeper is kinda like that but no automation and it doesn't really go as far as I'd like it to go
still a really fun game
How can I set the yaw of a slime?
You have to teleport() it to a Location that has a specified yaw
SetBodyYaw doesnt affect slimes and SetRotation only affects the slime every 3 seconds idk why
Unless you want it to look up or down, which would be pitch and is not supported for slimes. They can only look left/right
Is there other way?
I am using a class to set its rotation but I use other to move the slime vรญa teleports and that would conflict it
You responding to me?
yes
Hello everyone, could someone please help me with Spigot's BuildTools? pretty please? c:
Well, what are you struggling with in regards to build tools?
today I realized that I have never written down the word "debris" before
Cooldowns and warmups should always be done by setting a target timestamp and periodically checking the delta between the current time and your target time.
Polling for displaying should be separate from polling for action.
Your actions should be executed by using the following setup:
- Your action should contain the timestamp
- The action needs to implement Comparable for itself
- All actions are inserted into a binary searchable, ordered collection (I usually use PriorityQueue)
This results in all elements in the queue to be ordered based on how far they lay in the future.
Each tick, you simply poll as many actions from the top of your queue as you can, until the first one does not
qualify as being in the past anymore. This transitively invalidates every queued action afterwards, which means
you can save a LOT of CPU time.
I was just trying to edit 1 .java file in Spigot-Server (just to test something), and when I try to run mvn clean install it goes thru, but errors out at:
Spigot 1.8.8-R0.1-SNAPSHOT ......................... FAILURE
?1.8
Too old! (Click the link to get the exact time)
the error was with pom.xml being HTTP instead of HTTPS, fixed that
but still tries to download something from md_5-releases which doesn't exists?
Hmmm. It fixed itself? whaaaat?!!?
hmm in java can we assume that bitwise operations always happen on the big endian respresentation of a primitive?
like in the jvm the types are stored in the hosts endianness, but that says nothing about the bitwise operations in the lang
like can we assume that char >> 8 will always read the high byte?
left to right means nothing in memory terms
ah i thought that was only for the .class files
would be pretty dumb if the language that "runs everywhere" does not run everywhere at such a common operation
wdym modify
unsafe 
have fun with a segfault
bedrock is c/c++ right?
#define true rand() hehe
dunno i started thinking shifts were endianness dependant for some reason
well in c they are, or arent they?
#define if while
i always used endianness abstractions so ig so
bot for what
on?
minecraft has bots?
or you implemented the client join
not too difficult, just implement the protocol
wouldnt surprise me, with their own math classes
When should I use compileOnly, and when implementation in build.gradle?
Im doing it from files btw
Depends on the limit of said mechanics as well as "compensation" provided by bukkit to ensure backwards compatability.
In this case duration iirc had a max limit of int max back in the day
and amplier is 255 kek
yeah I mean i suppose if u wna have it as long just auto promote it to one
compileOnlyApi: used at compile time, not used at runtime, exposed to consumers
compileOnly: used at compile time, not used at runtime, not exposed to consumers
api: used at CT, at RT, exposed to consumers
implementation: used at CT & RT, not exposed
yea basically there are 3 things u consider, compiletime classpath, runtime classpath and transitivity on the 2 first
it kinda scares me how much access modifiers i needed to weaken to make it possible to test internal code :|
so been a good dev and added @VisibleForTesting everywhere
You make it public
it doesnt
The annotation is just for informing people
its for static analysis tools
and no i didnt make anything public, end users break everything
Mojang has some @VisibleForTesting in the server
is there a way to make a normal stacked potions movement in inventories? like if i have 64 potions and click on an inventory slot, it puts only 1 potion instead of 64 ones, also InventoryClickEvent#getCursor() returns ItemStack with amount 1
A bit late, but how can I translate the color codes?
ChatColor#translateAlternativeColorCodes
It don't work lol
show code and input string
Works when I broadcast the string
you speaking like yoda
that is going to be way too much work to refactor all my code to do that
yeah that's how it is usually done
that is not encrypted buster
Hey I am looking into creating custom nametags for players on my server. However even after some googling i'm completely lost. Anyone maybe got some information where to look? ๐
Also not looking for any third party API to use, just wanna use my own plugin, maybe some reference is also good
What version
Arent companions used for utils in kotlin? I remember using that.
singletons
you can have free functions
besides, kotlin's philosophy is that a class should have the BARE MINIMUM to support using it wholly, everything else should be extension methods
very pepega and horrible for discoverability
I only use the most expensive functions
which is why you'll find a lot of extension functions in kotlin's own standard library types

and then you ask yourself "why didn't they just add the function as an instance method?"
that's why
Hello, I took the code from the link below from my project wich was in version 1.12.2 and updated it to 1.16.5. Now that the getID() method is now deprecated, I wanted to ask what the alternative would be, thanks
public static int sum(int x, int y) {
int result;
do {
result = ThreadLocalRandom.current().nextInt();
} while (result != x + y);
return result;
}
how do i avoid naming my command? i just want to use its executor in main command
Dont extend Command, implement CommandExecutor
this is bungee api
And you want to create a command but not register it?
Bungee commands dont have an executor...
what
How about you just implement your own interface for this:
public interface SubCommand {
void execute(CommandSender sender, String[] args);
}
Bungeecord commands dont have an executor. They simply implement an abstract execute method.
and use it like that?
Sure
and to run it just reloadCommand.execute(somethingshere)?
Allocate a field
private ReloadCommand reloadCommand = new ReloadCommand();
and use it in your main command:
public void execute(CommandSender sender, String[] args) {
...
this.reloadCommand.execut(sender, someOtherArgs);
}
yea yea i know i know
im just gonna store every subcommand in map in onenable
and use it from there
I would probably use a Map<String, SubCommand>.
and add a getName() method to SubCommand.class.
Which looks like a normal Command to be honest
the purpose was to remove command name
Ok but if your subcommands have names, then you might as well use them.
/antipvp reload
Name of main command: "antipvp"
Name of subcommand: "reload"
In your AntiPvPCommand class you can have a Map<String, Command>
simply add your commands in there by using their name as a key.
yea i already know how to do it
i already had this thing set up on spigot
just wanted to rewrite it on bungee api
Ok, so there is no point in creating your own interface and your subcommands will simply extend Command.
Are we on the same page here?
lets make sure i understand everything correctly
when i do super("name")
i create command /name right?
No, you just create an instance of your class which extends Command.
It does nothing unless you explicitly register it. Without registering the instance, nothing will happen.
aaaa
There we go ๐
oh so it actually has no point creating own subcommand
Yeah, you can just use bungees Command class and put your subcommands in a map if you want.
Hello i am having trouble connecting plugin to mysql database it shows an error in my server console
Paste the error
.
hi, there's a way to get the player ping n the 1.8?
or maybe get CraftPlayer today?
Ah okay, thank you. Your and 7smile7's responses are the first times Ive been told to use such a method. Granted, I haven't encountered this type of problem before. Thank you for helping me learn more. :D.
i pasted the error
No u didnt
do i have to save it
what do i have to paste
The error
from the console?
Preferably the entire stacktrace
what is stacktracce
?stacktrace
We cannot help without the full stacktrace; Please paste it here: https://paste.md-5.net
Well that doesnโt help
what is it
A stack trace shows a list of method calls that lead to the exception being thrown, together with the filenames and line numbers where the calls happened.
fixit
a fancy word for error log
can you add custom NBT to a player?
1.12
im using NBTeditor but it sets my player positon to the void????
NBTEditor.set(player, getPlayerThirstLevel(player), "thirstLevel");
the number im attempting to save ins't even 0
or int as bytes could be a negitive float
Would be nice to see the NBT data
Sadly I donโt think 1.12 had good /data commands soโฆ
I guess youโd have to extract it from the files
1.12.2 has uh /entitydata
for entities obviously
and /blockdata
but it's really poor (no path querying)
Sometimes I take the tools we have for granted now
You can even debug packet entities with the power of shift F3 i
does someone know how can i get the block where a sign is placed?
Block states have a getBlock() / getLocation()
ok, but that will return the location of the sign itself
i want the location of the block where the sign is placed
yes
I think I found out
private Block blockAttached(Sign sign) {
var block = sign.getBlock();
if(sign.getBlockData() instanceof WallSign wallSign) {
return block.getRelative(wallSign.getFacing().getOppositeFace());
}
return block.getRelative(BlockFace.DOWN);
}
Yeah
How can I convert a hex code to this format?
can i add custom nbt tags to the player?
not with commands
anyone can help me with this
no idea why its not working
its latest version thoe
?whereami
did you sync maven
I am developing something that can be kinda compared to kits, is it possible to have a premade player inventory filled with items in certain slots, and then with one function call update a player's inventory with the premade one?
or do i just manually go about setting the items
A simple way you could do this would have a map of slot number to ItemStack, and then a function that iterates over the map and sets each slot for a player.
yeah thats what i was thinking too
was just wondering if spigot has some method to do this already before i started working on implementing that
the implementation details are up to you
declaration: package: org.bukkit.inventory, interface: Inventory
You can use this
this explicitly removes all items first
instead of replacing only the items you defined
hmm but i dont get control over inventory slot numbers and such with this
It's a bit more verbose.
i can just implement some helper class from scratch then
Sure.
Wdym,the slots are in order
You would have to specify Air for all of the others, right?
i mean like
i need to specify what items should go in off hand
what items should be armor
and like some items should be at the right side of the hotbar and some on the left, with a gap in the middle
also
how do i check if a material is a piece of armor
without me typing a giant list of all possible armor types
declaration: package: org.bukkit.inventory.meta, interface: ArmorMeta
// If the item is a piece of armor, put it in the appropriate slot
else if (item.getType().name().endsWith("_HELMET")) {
inventory.setHelmet(item);
}
else if (item.getType().name().endsWith("_CHESTPLATE")) {
inventory.setChestplate(item);
}
else if (item.getType().name().endsWith("_LEGGINGS")) {
inventory.setLeggings(item);
}
else if (item.getType().name().endsWith("_BOOTS")) {
inventory.setBoots(item);
}
this is what i have right now but it feels wrong
Im not clear on specifics
how would i use this to check though
oh i check if the itemstack meta is an instance of this?
but that still wont let me differentiate the different types of armor
technically any item can be a helmet
but I think your approach is OK
all the helmets do end with _HELMET
or you could refer to the enum members themself
yeah but i feel like theres just a lot of overhead with getting the enum name as a string and then comparing the end of the string name
could create a giant enum list but thatd just be annoying
it's prob barely a performance difference anyways im just a bit of a perfectionist lmao
up to you.
the usual way is to create a Set on load like this (or similar), unless you could use tags or sth (idk if there exists tags for helmets etc)
Set<Material> helmets = Arrays.stream(Material.values()).filter(mat -> mat.name().endsWith("_HELMET")).collect(Collectors.toSet());
is there a way to (de)serialize a PlayerInventory to JSON without manually implementing each field?
idk if kotlinx.serialization provides a way to do that with already implemented objects
or I fork it
Youโll be better off just writing a small serde module for it
2 methods
read and write
Realistically all youre doing is encoding item stacks no?
yeah
then just encode as a stream of b64
well i need to save it to a string for my db
Yes so use b64 strings
This uses serialization capabilities
Instead of manual
companion objects are for "static" methods
Youโll have to inherit its methods in a subclass
oh dear
class Something {
companion object {
fun something() = Unit
}
}
Something.something()
very poor example
i think id be better off creating a data class which can be serialised which just contains the armour, items and offhand stuff
like this
@Serializable
data class SerializedInventory(val hat: String, ...) {
fun deserialize(): DeserializedInventory {...}
}
data class DeserializedInventory(val hat: ItemStack, ...) {
fun serialize(): SerializedInventory {
...
}
}
sry im on my phone lmao
lmao
i would probably manually set the players inv contents
because i cant be bothered to impl PlayerInventory
ConfigurationProvider.getProvider(YamlConfiguration.class).save(whitelistConfig, data);
this two do exact same thing right?
whitelistConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(data);
no? save and load usually do NOT do the same thing lol
hm where's bungeecord-config
yea but why isnt it in intellij
https://javadoc.io/static/net.md-5/bungeecord-config/1.20-R0.2/net/md_5/bungee/config/ConfigurationProvider.html because there simply are no javadocs for this
anyway, save saves the given config to the given file, and load obv loads a file
still no docs in
as I said, there are no javadocs for bungeecord-config
best way to make placeholder system with mathmatical operations?
use a library like expr, apache commons jexl or sth like that
alr, also is it possible to cast PlayerEvent to BlockBreakEvent
oof
any suggestion to improve performance of this code? https://paste.md-5.net/uhapowolam.java
you can save the proxy ip into a set so if the player tries to reconnect it doesnt send another request, it just checks if that ip is in the set
Hello guys! I'm trying make a "custom item" in spigot-plugin using resource-pack, so I add localize file (en_us.json) in my resource-pack, but can't set localized name in my item. Anybody know how to do that?
under localized name I imitate '{"translate": "item.minecraft.stick"}' (minecraft-json-string format for display.Name)
Iโve been trying to find a solution for half an hour... ๐ซ
Maybe already hour
extract the code into helper methods
move fields into classes that encapsulates them and provide methods needed for that
which ones for example?
boolean whitelisted = false; for (String whitelistedIp : AntiVPN.whitelistedIPs) { if (!ip.contains(whitelistedIp)) { continue; } whitelisted = true; break; }
can become
public boolean isWhiteListed(String ip) { for (String whitelistedIp : AntiVPN.whitelistedIPs) { if (id.contains(whitelistedIp)) { return true; } } return false; }
a
:main: Could not find net.md-5:bungeecord-chat:1.8-SNAPSHOT.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/net/md-5/bungeecord-chat/1.8-SNAPSHOT/maven-metadata.xml
- https://repo.maven.apache.org/maven2/net/md-5/bungeecord-chat/1.8-SNAPSHOT/bungeecord-chat-1.8-SNAPSHOT.pom
- https://plugins.gradle.org/m2/net/md-5/bungeecord-chat/1.8-SNAPSHOT/maven-metadata.xml
- https://plugins.gradle.org/m2/net/md-5/bungeecord-chat/1.8-SNAPSHOT/bungeecord-chat-1.8-SNAPSHOT.pom
- https://repo.panda-lang.org/releases/net/md-5/bungeecord-chat/1.8-SNAPSHOT/maven-metadata.xml
- https://repo.panda-lang.org/releases/net/md-5/bungeecord-chat/1.8-SNAPSHOT/bungeecord-chat-1.8-SNAPSHOT.pom
- https://repo.extendedclip.com/content/repositories/placeholderapi/net/md-5/bungeecord-chat/1.8-SNAPSHOT/maven-metadata.xml
- https://repo.extendedclip.com/content/repositories/placeholderapi/net/md-5/bungeecord-chat/1.8-SNAPSHOT/bungeecord-chat-1.8-SNAPSHOT.pom
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/net/md-5/bungeecord-chat/1.8-SNAPSHOT/maven-metadata.xml
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/net/md-5/bungeecord-chat/1.8-SNAPSHOT/bungeecord-chat-1.8-SNAPSHOT.pom
Required by:
project : > org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT:20160221.082514-43
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
HI, does anybody know whats is going here?
my imports:
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
compileOnly("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT")
just plastering him with chatgpr won't help him actually learning what he needs to do
plus it still has the problem of plastering everything in the listener
that was basically spoonfeeding
plastering?
fixed - added sonatype repo
sorry, is that not a english word?
i mean making listener have too many functions than its intended purpose
why
oh
english is my second lang
wait a sec ill google what that means xd
mine too
Ignore it
wdym
It fits
nah
ok ill get back with added methods
i need help ee
already added
but thanks ๐
whats wrong with that ๐ฅน
.Blacklisted
can you be more clear
lowercase
here too
And use an api for proxycheck
And exclude all that stuff from your listener as those guys told you
i already cache it?
my bad didnt saw it
dw
oh out of listener? ok
๐ซ
You need to set the items custom name to a translation component
if (line.contains("proxy") && line.contains("yes")) {
Use gson for this
Problem is we donโt have an api for that yet
why this works just fine
is it more optimized or something?
and performance
giant problem ๐ฐ, but thanks for answer
is gson more optimized?
If I had to guess, it wouldn't bite
in your case it might actually be better to just poke with contains
yea
parsing of json does require more resources
well this plugin may get high load on bot attacks
you'd also want to cache the https calls
yea but then it would be on same url?
ah wait, you do' cachedVPNIps.put(ip, true);'
this way if an attack takes place from the same vpn after restart your server won't be impacted
hmm thats actually a good idea
Youโd probably want to have it expire eventually though
and probably wont cause any issues
why
Bro wtf XD
proxycheck io ever updates their data?
yea
Every 24 hours
yea but if ip is detected as vpn
many of those ips got rechecked
do they remove it as vpn anytime?
well then storing it in file has no sense
if (cachedVPNIps.containsKey(ip)) {
player.disconnect(ChatUtils.color(plugin.blockMessage));
return;
}could happen above the async and you can use the deny function from the event
who restarts proxy server in less than 24 hours
File saving has always no sense
XD
sorry what? "could happen above the async"
What
yea?
You donโt need to run it in the lambda
you can write that method above the runasync
you can run it outside
i don't think the disconnect function is async safe
Should be
It doesnt disconnect immediately i dont think
plugin.getProxy().getScheduler().runAsync(plugin, () -> {
It polls at the network manager rate
In its own thread
At least on clientside
Should be same server side
why does it matter?
yea i know
but what can it damage?
I was talking to mr freestyler
well he was talking to me
i see, but still not a good idea
rather use the event way of disconnection
or rather denying
?workdistro for me
what's the difference between getEffectPermissions and getPermissions
oh getPermissions doesnt exist
whoops
i mistakened it for hasPermission, anyways how do i pull the permissions from getEffectPermissions
PermissionAttachmentInfo has alot of values
'permissible, permission, attachment, value'
read spigot api about this
i'm sure it guides you a little on what each is for
if not you can look into how hasPermission works
player is an interface and im not sure what implements player
so i cant see how it works
btw it's not in craftplayer
Itโs also on stash
must be somewhere else implemented
Probably CraftEntity
hasPermission is in Permissible.class and player extends Permissible
what implements Permissible
how can i place barrier blocks to prevent someone from entering some area?
look in craft entity, it must extend it
huh? ofc it does
oh then i didnt check properly
yeah i saw, i didnt really understand much tbh
just find PermissibleBase
well well well
I didn't know void was considered a Block
if you fall in the void and it damages you, EntityDamageByBlockEvent is fired XDD
apparently void is a Block
oh yeah, newer versions have void blocks and air blocks
can u get the item's disable name even if it's not named? so Oak Log wouldn't return empty string, it would return Oak Log and if it's named lets say test it'd return test
not without a library
oof
How'd you make that
how can i get on place of a spawner the mob within it?
wait so how do you check if it was the void block damage?
i know if it's void damage event.getDamager() is null but
i guess entity isnt a type
i never played with it, i assume they have something in place
but like what??
look in the blockevent, i'm sure it returns something
or damagecause
no
believe that is for void space
like if you fall into the void
yes
well that isn't void block damage o.O
I placed a few void blocks on the ground too but they don't damage you
if you fall in the void EntityDamageByBlockEvent fires
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
but if i place void blocks on the ground, nothing happens
it's a combination of y and block @umbral ridge
i don't know what they're a thing, sounds like extra resources
Hello do you know how I can remove a drop from a BreakBlockEvent ?
I have try this but didn't work
for(ItemStack itemStack : event.getBlock().getDrops()){
if(itemStack.getType() == Material.BARREL){
event.getBlock().getDrops().remove(itemStack);
}
}
//event.getBlock().getDrops().remove(new ItemStack(Material.BARREL));
i'm sure there's a reason in the code
item spawn event
I can't do this in a breakblocksevent ?
no, i tried too
fck, thx !
no problem
declaration: package: org.bukkit.event.block, class: BlockBreakEvent
i see these two will also share the same ๐ฌ
there is only 1 ๐ฌ
sharing is caring. should have learned this by now
hi
HI
a random seems to have responded favorably to that
bro can look #help-server
maybe you can get them to make you that romantic breakfast
xDD
no nooo
frostalf maybe someone could make that romantic breakfast for you
maybe kalex is too shy to ask you
but instead they just said hi to me
They indeed could and sometimes do, but we are not discussing me at the moment, we need to find someone to make that for you
but I didn't think it mattered too greatly from who
I mean, a romantic breakfast is romantic regardless
I could make a plugin that in the morning when i join the server it says good morning here's your romantic breakfast and it gives 1 egg 1 bread and some milk ๐
This is the most common way relationships start, they have to introduce themselves first
be a bit rude if you didn't know who they were before starting some kind of relationship
it would be almost like one sided but with a physical being still there
intellij ide is my only wife now
im very happy with her
she has tab completions.. updates from time to time
All this speaks volumes of your loneliness, we have to get the other spigoteers to help in this matter
we can't allow you to be like this
its terrible, so we shall first start with secretly signing you up to dating services
GOD NO
but this is the only way to realize that person in your neighborhood is for you though
this is what movies and shows dictate that must be true
at the end, its always a romantic ending
so the steps are clear
it's always a very happy end
"i have to choose my username"
"littlekidlover"
"that way, people will know exactly where my priorities are at"
ride of to the sunrise
I think you already chose that one.... wouldn't be available anymore
I always thought it was sunset
because a sunrise is quite blinding in comparison to a sunset
I was wondering if there is a better way I could check if a message is not "empty"?
My current way is if (!e.getMessage().getFormattedMessage().trim().equals(" "))
package me.blueyescat.skriptlogs.util;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import me.blueyescat.skriptlogs.SkriptLogs;
/**
* @author Blueyescat, Equipable
*/
public class LogAppender extends AbstractAppender {
public LogAppender() {
super("skript-logs", null, null, false);
Logger rootLogger = (Logger) LogManager.getRootLogger();
rootLogger.addAppender(this);
}
@Override
public void append(LogEvent e) {
if (!SkriptLogs.getInstance().isEnabled())
return;
LogEvt logEvent = new LogEvt(e.toImmutable(), e.getMessage());
var immutableEvent = e.toImmutable();
new BukkitRunnable() {
public void run() {
if (!e.getMessage().getFormattedMessage().trim().equals(" ")) {
SkriptLogs.getInstance().lastMessage = immutableEvent.getMessage().getFormattedMessage().replaceAll("\\u001B\\[[;\\d]*m", "");
Bukkit.getServer().getPluginManager().callEvent(logEvent);
}
}
}.runTask(SkriptLogs.getInstance());
}
}
Chat has been cleared
e.getMessage().isEmpty()
how does a message be "empty"
whitespace
Any advice how can i easly remove ocean biomes?
Strings are typically not null unless you didn't initialize the string object. Other then that, if there is no printable characters in the string, it is considered empty
^ thatโs why Iโm trying to figure out how to check if it isnโt โemptyโ
note I said no printable characters, which is key here because you can have spaces, tabs, new lines, carriage return characters in the string, however these are classed as non-printable characters, and thus if this is all the string has, it is still empty
That doesnโt work
it should
Still makes another plugin throw an error (which Iโm trying to fix)
Well you did not specify that as part of the conditions
if there is additional conditions you need to be upfront with that otherwise we can not provide the help you need
Ahh sorry
So basically when I test it with the other plugin, it throws the error about empty message despite my LogAppender checking if it isnโt empty
do you have the source for this other plugin?
as a developer, you can code your plugin to throw errors, even if the conditions for the error were not met in the typical fashion. In other words you can impose additional rules in when an error is thrown
hereโs mine:
https://github.com/EquipableMC/SkLogs
Oh alright
so, according to your code the log event comes fromlog4j
not sure how this relates to the other plugin
I think what you want is to instead register a log handler? Because if you append a logger, it would come after not before hence the whole append and all. If I am not mistaken in how it works
but, I am not about to look through that other plugins source with all them files to find what exactly its doing, I asked about the source because then that means you can check to see what it is doing
because of what I said above to verify that there isn't like some check its doing to determine that it is really empty or if its just considering it empty
How can i delete the enchantments section if there is no enchantment? setting them to null how i am doing doesn't seems to work (saving file after)
the first line should work
isn't working
then maybe the path is wrong?
I mean, it's the same path as above and that path work when the item has an enchantment
It sends this error
I mean, there's the error
the config is like this
oh wait
should this work?
getConfig createConfigurationSection
but why would i do that?
is that good idea to use get namespaces as enum?
But I want to remove enchantments: too
oh
wait
you mean