#help-development
1 messages Β· Page 2058 of 1
different purpose
I told you how to do it with Eclipse, but you are now in IJ
eclipse didnt work for me
it just said
no project found
lol
yes, because you didn;t inteligent import
i don't think that you understood what i'm trying to do, i want to specify a piece of code when creating a Queue() instance that will run whenever an entry from the Queue is picked
no, i understand. I'd utilize a stack and an async timer
i would use a Dequeue
never used a queue π³
that would work as well since deque is bi-directional. Stack is single direction
you can just an ArrayDeque
well i'm assuming i'm dumb
so?
Ah yes it is in Java
Queue is FIFO
will get in
so u wanna use an ArrayDeque not a stack
an arraydeque will make it so
first player joining ur queue
will get transferred first
Queue is FIFO First in First Out
actually thats a decent article
guys but i know how to have a list of objects, i want to know how to specify a piece of code while instantiating a class, then this class will have a method called Run() that will start a bukkit runnable and execute the code you specified when creating the instance of the class.
Something like Queue queue = new Queue(
likeThis();
);
idk if its possible
... normally you only have one Queue and add or remove from it
But this is what i'm trying to change! The system is just that, having multiple queues for an Hub system.
like the Shop Queue that will process everything bought recently for example
or a Ban Queue that will ban every player added to the queue
how many 'queues' are there in my messages? π
yes those are valid to have separate queues
those? the stacks? the ArrayDeque? wdym?
wonders how many bad player you have if you have a queue for bans now
well π that was an example
they are all related to linked lists - just special types of them
Either way, I recommend against using java's stack implementation unless you are aware of it's synchronisation details
Again, thats not what i'm asking. The problem is specifying code to be executed in a variable
is it a bad idea to spawn and shoot arrows async or does that not matter whatsoever?
yeah i know
im pretty sure they're just linked list but single responsibility
yes very bad
as arrows are entities I broke a server that way
thank you, but its not what i'm wandering
Then?
ok thanks, didnt know wether your first message was sarcasm XD
please read
you wanna accept a function so you can use it in ur class
if so use Runnable
if you want it to accept a param
use Consumer
if u want it to accept a param and return something
use a function
no, the server has problems ticking a few thousand arrows so they can decay and you cant remove them with the kill entity command
if u want it to accept no param and return something use a supplier
oh I was thinking of spawning one per half second for a few mobs (sentry duty)
Well i'll just assume i can't do this. I don't understand the system behind functions
What do you wanna do
holy shit
talk
i have a question for somebody in DMs since I need to send a picture, who knows how to compile plugins
thats fine as long as you dont get too many
so many names i don't understand
such as?
I will do it sync then XD
what changes between a Function and a Consumer
or verify yourself 
Function accepts param and returns something
Consumer accepts param and returns nothing
a function takes an object and returns an object
do you guys understand that i don't know how Function and Consumers work? You are talking about air for me : (
and yeah function takes an object but returns void
do you know how
void epic(Object o) {
}
work?
Function<Integer, Short> is
public Short method(){
return Integer;
}
yes
u meant consumer
thats the first time I was able to understand the difference XD thanks
thats a Consumer<Object> equivalent
Lol
and then we have
String apply(Object o) {
}
who knows how to compile plugins
this would be a Function<Object,String>
Consumer lets the consumer consume the object
So, the Consumer is what i want if i understand correctly
Function performs a functionality on an object, and returns another one
Yes
you dont want it to return anything
you want your class to accept a Consumer
and then do consumer.apply(...);
Consumer is generic so
Consumer<Integer> for example
would .accept(Integer)
what is the Type <T> it requires?
any thing
will0mane if you really wanna understand classes such as Consumer, Runnable, Supplier and Function then you need to know a little bit about how Java abstract works as well as interfaces
for example Consumer<UUID> will accept only uuids
i'm learning that rn π
if I want to remove an arrow a fixed time after it is fired, do I have any other choice but to create a task for each arrow?
new Clazz(uuid -> System.out::println);
the uuid here is what you pass with consumer.accept(UUID uuid);
Yeah
dangit
why is it a problem
just create one task that runs every second or so?
No that wont work cuz if arrows are fired in different times it wont work
I just wanted a method in arrow which is like "removeAfterTime(int ticks)"XD
that would remove arrows which were just fired too
that would work totally fine?
no of course you must keep track of the time whe nit was fired lol
what do i have to put here?
how is that complicated?
oh you mean a hashMap of arrows with the System millis as values?
thats not a bad idea
the name of the varaible
variable
that consumer.accept() passes to you
u name it whatever u want
follow naming conventions and keep it descriptive
?
if you actually figure out a way to remove arrows that hit a target, let me know - so far I've figured out is that you have to remove what was hit
well those I dont have to remove
I just want to prevent lag by removing arrows which didnt hit π
"hit" is any block or entity they come in contact with
private static final Map<Projectile, Long> projectiles = new HashMap<>();
private static final int delay = 10; // remove arrows after 10 seconds
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
getServer().getScheduler().runTaskTimer(this, () -> {
long currentTime = System.currentTimeMillis();
Iterator<Map.Entry<Projectile,Long>> iterator = projectiles.entrySet().iterator();
while(iterator.hasNext()) {
Map.Entry<Projectile,Long> entry = iterator.next();
if(currentTime > entry.getValue() + delay * 1000) {
iterator.remove();
entry.getKey().remove();
}
}
}, 20, 20);
}
@EventHandler
public void onShoot(ProjectileLaunchEvent event) {
projectiles.put(event.getEntity(), System.currentTimeMillis());
}
This isn't really very complicated
@crimson terrace
way more complicated then it can be tbf
yeah thats exactly what I was thinking of
Hey I want to work with NMS so I imported spigot-1.18.1-R0.1-SNAPSHOT-remapped-mojang.jar in my build.gradle but i have this error:
- What went wrong:
Execution failed for task ':compileJava'.
Could not resolve all files for configuration ':compileClasspath'.
Could not find spigot-1.18.1-R0.1-SNAPSHOT-remapped-mojang.jar (org.spigotmc
1.18.1-R0.1-SNAPSHOT:20211220.014539-2).
Searched in the following locations:
https://repo.dmulloy2.net/nexus/repository/public/org/spigotmc/spigot/1.18.1-R0.1-SNAPSHOT/spigot-1.18.1-R0.1-20211220.014539-2-remapped-mojang.jar
And I don't know how to solve this issue even with researches on Internet, can someone help me?
You can simplify that even more in newer versions
wonders what happens in @tender shard 's code when the delay is less than natural despawn decy
Replace some of the types with var
this shouldnt cause any problems with the amount of arrows I am planning for.
primitives in generics when
how is that complicated? it simpl,y only loops over a map every second and that's it
its not
why async?
idk java 19 or java 20 perhaps
Could you show your build.gradle
does it have to be sync?
plugins {
id 'java'
id 'kr.entree.spigradle' version '2.2.4'
id "com.github.johnrengelman.shadow" version "7.1.2"
id 'de.undercouch.download' version '5.0.2'
}
apply from: rootProject.file('buildtools.gradle')
group 'org.example'
version '1.0-SNAPSHOT'
tasks.prepareSpigotPlugins.dependsOn shadowJar
tasks.runSpigot.dependsOn prepareSpigotPlugins
repositories {
mavenCentral()
mavenLocal()
protocolLib()
maven {
name = "SunderiaRepo"
url = "https://maven.galaxyfight.fr/snapshots"
}
maven {
name = "Jeff"
url = 'https://hub.jeff-media.com/nexus/repository/jeff-media-public/'
}
}
dependencies {
compileOnly spigot('1.18.1')
compileOnly ('org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:remapped-mojang')
compileOnly protocolLib('4.7.0')
implementation 'fr.sunderia:SunderiaUtils:1.1.1-SNAPSHOT'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
test {
useJUnitPlatform()
}
spigot {
name = 'SunderiaSkyblock'
version = '1.18.1'
depends('ProtocolLib')
permissions {
'sunderiaskyblock.visibleholo' {
description = 'Allows to use the visibleholo command.'
defaults = 'op'
}
'sunderiaskyblock.test' {
description = 'Allows to use the test command.'
defaults = 'op'
}
}
debug {
args '--nojline', '--max-players', '4'
jvmArgs '-Xmx4G'
serverPort 25565
eula = true
}
authors 'noalegeek68', 'minemobs'
apiVersion '1.18'
}
does it have to be async?
yes
well i guess the arrow is a bukkit entity
and doing api stuff async will break some stuff
ok, never use async, got it XD

you can just runTaskLater
no
if you want to end up with 10k different scheduled tasks, sure
his is planning for a larger amount of arrows I think
it's a pretty shitty idea to spawn 10 thousands of scheduled tasks if you could just instead use one
and honestly, that could be used every minute or so, reducing the constant performance hit more (even tho running it more often would reduce the spike)
what
if you get 100 arrows per minute, iterating over those isnt bad. doing it after 20 minutes you would have to iterate over 2000 entries
basically
yes, that's no problem
yeah
why is there no scheduler method which takes a timeunit as parameter lol
follow the future
bungee has one
Make one
i barely know what bungee is
because its configureable and fluctuates
that doesnt really matter lol
since the scheduler internally relies on the game ticking
even for its async variants
they couldve made the calculations internal
internal calculation π€©
e.g TimeUnit.SECONDS will just *20
maths lol
ye you can do that 2hex
not all servers run at 20 ticks per second
^
what would even happen if you could screw the tps up?
but what if all tasks also arrive faster?
would that mean you could get a higher fps?
no
nope
iirc the game tick engine uses Thread::sleep to ensure the tps doesnt go higher or sth
sounds to make sense
FPS is bottlenecked by the network and is ultimately a clientside phenomenon
isn't there a private field somewhere that you can just change from 50 to 10 to go from 20 to 100 tps?
Can someone help me? please this would be nice
you didn't compile the remapped .jar
run buildtools with the --remapped option
like that? java -jar BuildTools.jar --rev 1.18.1 --remapped
yep
Ok thanks!
why do you have my repo in your gradle file lol
π₯²
oh btw you also must use the special source plugin to reobfuscate your NMS code
otherwise it won't work
but no idea how it works in gradle
paperweight userdev is pretty much the alternative
And then kind of hope you don't use paper only methods π
any one can tell me what do I need to put in start.bat to generate remaped spigot jar
I don't think you get to run spigot with Mojang mappings
If that is what you are after
Or do you just want build tools to install It in your maven repo
I was lookin for flag
--remapped
needed it for maven repo
so i have blocks like this , server side locations are saved and items are moving from one block to another, client side its impossible to tell without clicking it, how could i represent this?
im looking for ideas
mine was particles, that follow the path of the items but you wont be able to see most blocks
just the ones in the outside
maybe a scoreboard updating whenever you see one of this blocks, showing the state of it?
im not understanding the question
well it gets as simple as "do you see anything happening in the image"?
(a video would be the exact same)
i see blocks being added
each image is individual from each other, those are 3 different setups
now server side you have items in each block, with are moving to the next block
based on the type of each block, different actions happen
based on the speed of the blocks the items more faster or slower
How do you have items in blocks?
but the player has no idea
virtual items
So the item entity?
You mean that?
yes something like that, you also have a generator ( either bedrock or the white concrete, depending on the situation)
each color has a function
so if you start running, the items run away from you?
no, its like factorio or a few modpacks
Today we turn our attention over to a fairly large automation project, one that will span multiple mods and be the catalyst for early rf power, lava generation, bee resources, mob farming, and a lot more. The first step in getting this system up and running will be getting ourselves blaze cakes coming in, making some small additions to our ore ...
for example
now in that video, theres a single player world
so the mod edits the blocks and allows you to see whats going on
i want something similar, a way for the player to see whats going on
ive been messing around with packets and stuff, and got the demo screen to work, are there any other things that still exist that i could have fun with
i was thinking the steve co crate but that seems too long ago cant find anything on it either
Yeah I don't think that one still exists
damn
the giant still exists
i just think it would be funny
yeah
yeah ik that
im more looking for on-screen guis/screens that havent been used but still exist
and i could possibly send to the player using a packet
there are a few libraries to create forms, but i dont recall any other random screens
forms?
and also, is it possible to modify the text on the 'loading world' screen or is that client side
System.exit(0) is a fun one too
or alt f4
Can you share code?
I mean I donβt need it but idk I want to see cuz idk
eyo how tf
He just has a better programmer chair
nvm got it
hi, I have an issue with SQLLite and HikariCP usage. When I do
public ResultSet getQueryResult(final String query)
{
getSQLConnection();
PreparedStatement ps;
try
{
ps = getConnection().prepareStatement(query);
return ps.executeQuery();
}
catch (SQLException e)
{
e.printStackTrace();
}
return null;
}
I get a connection is closed if I make multiple requests.
I do close the connection every time I finish the query
Sorry for not making the precision, but getConnection = the connection instance
getSQLConnection set the actual connection instance to a valid one
public Connection getSQLConnection()
{
try
{
if ((getDs() != null && getDs().isClosed()) || getConnection() == null || getConnection().isClosed())
{
setConnection(getDs().getConnection());
}
return getConnection();
}
catch (SQLException ex)
{
plugin.getLogger().log(Level.SEVERE, "SQLite exception on initialize", ex);
}
return null;
}
the best thing to do is just
try (Connection conn = ...;
PreparedStatement ps = conn.prepareStatement(query)) {
// execute stuff
}```
can't do that with a result set like that
since it will close on return and I'll not be able to use the ResultSet later
btw I have that error only when I stresstest the system
If it goes slowly, it doesn't occur
Who can help me? I want to send and receive the message for bungeecord. There are no plugin messaging guides, the official one only says how to send messages to bungee, but not how to send from it. It was supposed to work, but I debugged and did not see a single message received by the bukkit. Bungeecord gets it, bukkit doesn't
wait can a plugin crash a server cleanly?
without having to overload it
got a gaming carpet
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Server.html reload and shutdown exist
would be rather curious to know what happens when you unload a world with a player in it
lets try it out
hey so i found the reason why player wouldnt get tpd to the given location earlier but now am left with this not actually working
if (event.getEntity() instanceof Player){
player = ((Player) event.getEntity()).getPlayer();
player.teleport(Utils.getSpawnLocation());
}
}```
the damage is cancelled but player doesnt get tpd
player.getPlayer() why?
a player is getting void damage ... where are they getting void damage from?
falling in the void ?
i jumped in the void and didnt get tpd
after falling for very long
so they continue falling or do they get respawned?
they continue falling
for a while
is your connection lagging?
i waited for like 5 seconds down there its too dark
nah everything els works
i typed in chat
and ran commands
working fine
drop in a console message to make sure its actually running the TP section
okay
muses if the void is an entity
i thought about that but idk man
if it is running the tp or not , might answer that
#VLM
void is entity ...
and it worked
hmm void is a material structure
it was this ig
Guys! Who can help me? I want to send and receive the message for bungeecord. There are no plugin messaging guides, the official one only says how to send messages to bungee, but not how to send from it. It was supposed to work, but I debugged and did not see a single message received by the bukkit. Bungeecord gets it, bukkit doesn't
in the API that is where it lives
Api > common sense
so it teleports you with the comment?
does World#getChunkAt(x,z) load a chunk?
Yeah afaik
wow that sucks
how can I check if a chunk is loaded if I only have the coordinates?
ah yes
lo
somehow I still think this won't work lol
public List<ChunkSnapshot> getChunkSnapshots(final World world, final BoundingBox box, final boolean onlyLoadedChunks) {
final int minX = (int) box.getMinX() >> 4;
final int maxX = (int) box.getMaxX() >> 4;
int minZ = (int) box.getMinZ() >> 4;
int maxZ = (int) box.getMaxZ() >> 4;
List<ChunkSnapshot> chunks = new ArrayList<>();
for(int x = minX; x <= maxX; x++) {
for(int z = minZ; z <= maxZ; z++) {
if(!onlyLoadedChunks || world.isChunkLoaded(x,z)) {
Chunk chunk = world.getChunkAt(x,z);
chunks.add(chunk.getChunkSnapshot(true, false, false));
}
}
}
return chunks;
}
I would use Set
that doesnt look like it needs to be ordered
see, if you wrote the frames library he could use that π
that will work
but it will load the chunks
i still dont understand that tbf
it seemed like a pain so i didnt search about it
can u explain it
"A frame is useful to define the position, orientation and magnitude of an arbitrary object which may represent a point-of-view." pretty much sums it up
can i just import a plugin to intellijidea and not have it as a dependency on maven if the plugin is going to be on the server ?
no
why dont u want that
"A structure is a mutable template of captured blocks and entities that can be copied back into the world."
public Nest(Location loc) {
super(EntityType.VILLAGER,((CraftWorld) loc.getWorld()).getHandle());
this.setPos(loc.getX(),loc.getY(),loc.getZ());
this.setCustomName(new TextComponent(ChatColor.GOLD + "" + ChatColor.BOLD + "Unnamed Nest"));
this.setCustomNameVisible(true);
this.setHealth(10000); // **this line does not work**
//List goalB = (List)getPrivateField("b", PathFinder.class, goalSelector); goalB.clear();
//List goalC = (List)getPrivateField("c", PathFinder.class, goalSelector); goalC.clear();
//List targetB = (List)getPrivateField("b", PathFinder.class, targetSelector); targetB.clear();
//List targetC = (List)getPrivateField("c", PathFinder.class, targetSelector); targetC.clear();
// above commented code throws many errors, likely to do with PathFinder.class
}```
Trying to make a custom entity
Setting its health does not work
Also i'm trying to make it stationary, no AI
not sure how to
i think it would be rather confusing to code the location, movement, or size of one structure in reference to another structure
It's an attribute
mm
well
i dont get that
Would also avoid use of legacy colour codes in a text component
It should have some colour methods
wdym to reference another structure
this.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(1000);
gets red underlined
required type different than provided
The classic, simple, example to that would be a Car in the world. The Car frame is in relation to the World frame, however they are independent to each other as they exist/move on their own
Airplane would be Plane, Airspace, Ground, World etc
why will it load the chunks?
in both those cases there are two locations and at least two movements
private BlockVector chunkToWorldCoordinates(BlockVector chunkVector, int chunkX, int y, int chunkZ) {
return new BlockVector(chunkVector.getBlockX() + (chunkX << 4), y, chunkVector.getBlockZ() + (chunkZ << 4));
}
hm will this work lol?
chunkVector is a block vector with inside-chunk coordinates
found solution
https://www.spigotmc.org/threads/new-way-to-register-nms-entity-attributes-1-16.449441/
ok nvm solution is scuffed
im pretty sure this should work fine
what type is different
what is your "this" class?
an entity extending off of Villager
ok
is there like a separate javadocs for that π
ide literally told u it
cause im running into all these issues with nms
thats the point of nms
lol
cant u use this? https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/attribute/Attributable.html#getAttribute(org.bukkit.attribute.Attribute)
declaration: package: org.bukkit.attribute, interface: Attributable
nopers
i found something
yes but that line is AFTER i checked whether the chunk is loaded
use net.minecraft.world.entity.ai.attributes.Attribute not the bukkit one
oh right mb
yeah but intellij doesn't know what's in that class
so ig i guess the name of the attribute
lol
imma try to understand this
wasnt there somthng like getBukkitEntity()?
which u can use to then modify attributes with the api?
if only someone would write a wrapper API for all the NMS stuff so we wouldn't have to use NMS classes directly all the time
wait -
ok idk what this guy means by ep() or b()
Those are the method names
they don't show
For that specific version
do u even have nms in ur project?
yea
why aren't you using remapped?
again, cant u do this.getBukkitEntity() in your class?
anyone here able to help me with my custom yml files problem? would be best to talk in dms
actually would be best if u dont talk in dms if u want the best help
but it won't let me add attributes to this
ig u need to cast to livingentity
ok if u say so
ok
so whats the problem.
new BlockVector(1,2,3).toBlockVector().toBlockVector().toBlockVector().toBlockVector();
ah yessss
can't cast it directly
ima send my class and explain it hold on
try somethn like this ((CraftLivingEntity) entity.getBukkitEntity()).getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(30);
oh wow it works
tysm
ugh I'm currently rewriting one of my oldest plugin and I'm using ArrayList EVERYWHERE
every method takes an ArrayList as argument instead of a List
lol
i feel u, u might aswell throw the whole thing and restart. if its anything like my old projects... xd
yeah I guess I'll rewrite it completely anyway lol
https://pastebin.com/Hm9ji3A1 ok so im trying for like 2hrs now and i cant figure it out, i tried a lot of stuff so its kinda mess rn, it looks like main problem is "addIslandData" cuz it works up until it should set something in my yml file, so it just copies the template data file (witch i think is not needed but i did it anyways) and it doesnt write new data
i barely understand what the heck is going on in my old plugins.
yes exacty lol
I mean wtf
wtf is this
this is 10 lines just to get the center of a block
oh wait I get it, it takes double chests into account
okay so it's not as stupid as I thought
il be looking at a piece of code for 10 min and think, what the heck went thruh my mind here? how did i come up with this piece of garbage?
uppercase package names :D
yes and almost everything in one package
that plugin is 4 years old, I was a noob π
yea i did that shit too
@tall dragon π₯Ί π π
then I filtered the arraylist to remove all non-chest blocks
ah yea il take a look
somehow noone ever reported lag lol
oh yea thats ultra efficient
ur lucky looping generally is pretty fast
I do it like this now, that's a TINY bit more efficient lmao
hmm i see
coulnt u just get all tileentities from a chunk for chests?
and then filter those
chests was just an example
but yeah for the plugin I'm rewriting, getting the tile entities is a good idea
im so bored i need a lib idea
How can I wait in a loop without thread.sleep?
why do you want to wait?
I want to run something 75 times but wait 20 ticks between every run
use a scheduled task
Scheduler#runTaskTiemr
Why is spigot converting the location +0.5 blocks more?
?scheduling
btw why
is it for performance
If I'm teleporting to -189 71 -73, it's teleporting to -188.5 61 -72.5
Even in the code
cuz if so that sucks
it's setting the block here instead of the actual location
I can't figure out why
I'm on 1,17
@shut solar well there is alot there could be better looking at ur class, but when u add the data ur using getResource() thats what taking ur file in the jar.
just do /tp -189.0 71 -73.0
No its for a particle effect
Ah thanks
@shut solar i dont rlly understand why ur doing this at all
try (InputStream in = Skyblock.getInstance().getResource("IslandData.yml");
OutputStream out = new FileOutputStream(this.getDataFile(island.getUniqueId()))) {
ByteStreams.copy(in, out);
} catch (IOException e) {
e.printStackTrace();
}
cuz nothing worked so i tried this
just create a yml file, load it as file configuration. set ur data
saveResource("IslandData.yml",true)
and dont do it on main thread
yw, sure but im not sure a template is needed at all.
i said that its prob useless
yea. so remove that
and if i were you i would store a FileConfiguration in ur Island
so u avoid loading it every time it needs changes
switching tools manually is for nooobs
sure, il be here for another hot minute
u doin that with the BlockDamageEvent?
PlayerInteractEvent
oh, yea ig that works too
i think blockdamage is too late since it would then reset the first tick of having mined the block
I think block has a method for that
I have some complicated methods for that
pliz show :)
Is discord dyin?
I am schizophrenic, there is no method
discord back alive
anyway, here, those messages didnt send:
it's also one of my first plugins and also everythings in one package, etc bla bla lmao
discord lag?
https://github.com/JEFF-Media-GbR/Spigot-BestTools/blob/master/src/main/java/de/jeff_media/BestTools/BestToolsUtils.java
https://github.com/JEFF-Media-GbR/Spigot-BestTools/blob/master/src/main/java/de/jeff_media/BestTools/BestToolsHandler.java
I know, the code is horrible, don't judge me
do color codes work in usage messages
if you use Β§, they should work
so dont return false?
since sonarlint is like "don't always return true"
just send ur own msg
like bruhv
who cares what they say
i have never in my life ever returned false in a cmd
you can also just do sth like this to trick it out
public static boolean true() {
return !System.getProperties().isEmpty();
}
then return true();
but i have my cmd lib that automatically handles usage
discord just died
If you don't want a static instance
just use
public static MyPlugin getInstance() {
return JavaPlugin.getPlugin(MyPlugin.class);
}
no static
and no need to do the getPlugin yourself
still uses static method
or dont use it at all
eh
and use dep injection
I inherently dislike dependency injection for spigot plugins
why is that
some people have a badge on their github repo that shows the latest versions, does someone know where to get it?
so much to type all the time without any additional benefits, imho
in my plugins I just do
public final class SomeListener implements Listener {
private static final StackResize main = StackResize.getInstance();
i just repeat getInstance
yea thats a singleton
because I am too dumb to realize that the class loads after the main
anyways gtg
cya
thats pretty acceptable most times
I think the opposite is true, but just let everyone use what they prefer :3
yea ig its preference
what I just hate is when people start crying "uuugh something is static, that's sooo bad, bruh learn java" etc
gn
i mean. in some cases those people are right. but there are indeed alot of cases where static is acceptable and people still whine about it
but generally i stick to only using static for util and my config
static is ALWAYS acceptable and actually it'd be stupid not to use it, when something doesn't need any class fields/methods
stutihc bad
conclure speling bed
bed mhhhh
i handle my config like this for example
public class Settings extends SimpleSettings
{
@Override
protected int getConfigVersion() {
return 1;
}
public static Boolean DEBUG;
public static Action STACKER_ADD_ACTION;
public static Action STACKER_TAKE_ACTION;
public static String STORAGE_TYPE;
public static String HOLOGRAM_PROVIDER_TYPE;
private static void init()
{
DEBUG = getBoolean("DebugMessages");
STACKER_ADD_ACTION = Enum.valueOf(Action.class, getString("Stacker_Add_Action"));
STACKER_TAKE_ACTION = Enum.valueOf(Action.class, getString("Stacker_Take_Action"));
STORAGE_TYPE = getString("StorageType");
HOLOGRAM_PROVIDER_TYPE = getString("HologramType");
}
}
or just pass your plugin instance via constructor
like a sane human being
I guess using object mapping can be fine in combo with static
but like
kinda sus
naaa i think its fine
like the only issue I have with it, and to be fair is insinuated into most plugins, is in fact the tight coupling
ofc thats generally not an issue at first
how do i make something wait but not stop my task, i tried Thread.sleep(); but that paused the task
?scheduling perhaps
public final class MyThing {
private static final MyThing myThing;
static {
myThing = new MyThing();
}
public static MyThing getMyThing() {
return myThing;
}
private MyThing() {
}
}
One of my better work ^
lmfao
looks like a singleton
static block kek
yes but a weird one
how so?
because it creates MyThing even if you only access some static method of it
no, just once
the static { } gets called exactly once, when the class is first loaded
myes but its still effectively a singleton
the normal { } gets called everytime you use a constructor
only thing that makes it a bad singleton is the name of the static method to retrieve the instance
it's a perfect name! You wanna get my thing, you ask for my thing
nah
if its a singleton suffixing with instance is the general rule for the pattern
getBlahInstance or blahInstance (or just getInstance)
@SuppressWarnings("conclureDoesntLikeIt")
public final class Instance extends Object {
private static final Instance instanceInstance;
static {
instanceInstance = new Instance();
}
public static Instance getInstanceInstance() {
return instanceInstance;
}
private Instance() {
}
}
what about this
π
both flattered and enraged concurrently
i liked it better as MyThing idk man
btw does conclure mean sth? is it a word or sth?
getMyThing() was pretty clean
apparently conclude in french
concluder
french always sounds like if a snail was speaking
yes but that'd disregard the naming convention of the design pattern since it turns out to be a singleton 
lol ig
i hate learning french at school
there should be a french coding language
let fromage = baguette()
π₯
bonk
laissez le nom Γͺtre "mfnalex"Β ;
si nom est Γ©gal Γ "mfnalex" {
print "je suis mfnalex"Β ;
}
shit its already 12 pm
yes and I still havent completed the spaghetti quest in sneaky sasquatch
i was planning to do some rust but uhm ye
does anyone have a good, updated tutorial on hand for doing yaml configs?
yall know what happened
spigot has everything built in for that
declaration: package: org.bukkit.configuration.file, class: YamlConfiguration
how fancy
the most relevant things are in MemorySection and FileConfiguration, which this extends
π
nope but I have a quick summary of the necessary parts
and ye alex gave u a good link there
but a YamlConfiguration is a fancy LinkedHashMap adapter
I have the best links
most of the times
and then you have FileConfiguration (superclass of YamlConfiguration) which has a save(File) and load(File) method
save would obviously save the content of the backing map to the file
and load would load it
pretty simple
I still have to look at the whole "save comments" stuff that was added
oo ye
I heard it was added, I was happy, then I never looked at it lmao
comments supported 
sheessh
the bad thing is that it makes my ConfigUpdater library useless lmao
well okay not completely useless
but 90% of it
french
it's french++, my new WIP coding language
π₯
ayo what
lol not really
lmao rip i got exited for a sec
π
i would baguetting on those coders
tf am i talking about
https://www.spigotmc.org/wiki/config-files/
Does this not work anymore?
anyways, i have question,
is there a way to store data similar in config file similar to hashmaps ?
key,value type thing
i know thers this plugin.getConfig().getMapList("something");
Shakiz
but any better ways ?
yo
Could i send you something? it is a awesome plugin
for(Entry<String,Object> entry : myMap.entrySet()) {
config.set(entry.getKey(), entry.getValue());
}
This saves a map to a config
uhh sure
sus
Shakiz just be careful when downloading stuff from arbitrary people (:
I bet it's some furry plugin
are we allow to send some video? here
I want to receive it too
Myes
AYOOO
NO
can i see the plugin
IRTS NOT LIKE THAT
same bro curiosity
I expect y'all to receive the "youareanidiot" video
ay thank you
that would just be perfec
on join:
send "Are you a furry" to player
send "&a&l<command:/furryfound >>>Click here<<<reset> &6if you are!" to player
command furryfound:
trigger:
make console execute command "Ban %player% Reason: furrys are not accepted on this server"
best skript ever
he doesnt have to go trough all that pain tbh
the only skript that will ever be allowed on my server
i actually dont understand this
config.set ?
will i be cancelled if i like this resource
i need some way to store data in yaml file as Key,Value
yes, config can be any kind of MemorySection
might as well turn it into a java plugin
yes
the whole idea of yaml is basically key: value
if you dont, i will
like a list
YamlConfiguration config = new YamlConfiguration();
// Now the code from above
adding on:
config = YamlConfiguration.loadConfiguration(typeOfFile);
if you wanna load a config from file Shakiz
okay discord just says fuck you to me and my color scheming with code blocks, thanks discord
yes
and then how to add data to "something" for example here
somethingcool : verycool
as a value and key
skript is very odd
from there, get the ConfigurationSection "something"
And thatConfigurationSection.set
Using the code alex provided here
ConfigurationSection section = config.getConfigurationSection("something");
for(Entry<String,Object> entry : myMap.entrySet()) {
section.set(entry.getKey(), entry.getValue());
}
Say you have a entry in the Map of
Key: Hey, Value: there
Using the code above, it should do this:
something:
"Hey": "There"
oh yes this is what i was looking for
thank you
how can i fire arrows one after another using player.launchProjectile?
Argument should be Arrow.class but im not entirely sure
is it possible to remove from the config section ? i cant find any functionf for that
never done that
will getPath() return the path to the key/value ?
try setting that value of set(arg1, null) (second argument to null)
Not sure if that would work but worth trying
getString or whatever object is stored there
section.getString("ThatKey");
if you want the path
you need to loop through the section
one second
servers.set("server", position);
}
public void removeServer ( String server){
plugin.getConfig().set(servers.getCurrentPath() + server + servers.get(server),null);
plugin.getConfig().set(servers.getCurrentPath() + server ,null);
}```
i did this
servers = plugin.getConfig().getConfigurationSection("Servers");
for (String key : section.getKeys(false)) {
// key here
}
how can i fire arrows one after another using player.launchProjectile(Arrow.class)
so if you have lets say:
settings:
"THat": "Value"
key in that code snipped would be "THat"
(Considering the configuration section you grabbed was settings)
@vestal barn
Doubt this is how it works though
i know that but what i am tring to find out is how to fire them one after the other
it fire them all at once
BukkitRunnable with runTaskLater
still fires them all at once just a bit later
and the runTaskLaterasync gives me Asynchronous entity add!
i want to remove just 1 specific one
like 1 key,value set where the key is equals to something
if key == key you want
section.set(key, null)
like said, cant remember how you remove config values, iirc you just nullify them
yes but then the key will still be there with a null value ? thats what i was wondering
it should remove it, but i could be wrong
only way to know is to test it
never hurts to test things
@vestal barn pinging so you see meant to reply
dont use async for spigot methods like that
for me it fires them all at once just later
new BukkitRunnable() {
@Override
public void run() {
player.launchProjectile(Arrow.class);
}
}.runTaskLater(getInstance(), 20 * 3);
}```
π
that will only make it fire whatever ticks later x is, so youll need to figure out a value that works for you
Why doesn't speed attribute go back to normal?
Player.getAttribute(Attribute)
i used setBaseValue(getDefaultValue)
Oh wait i just found on a spigot thread another user that had the same problem and looks like the only fix is use setBaseValue(0.1) for speed, probably a spigot bug right?
You can always store the default value before setting it
But IIRC these things reset when a player relogs too
or server restart, one of the 2
if i remember correctly.
^
thx
thanks for the tip
I can also use attribute modifiers
yet i scanned anyway
whats the enum name for cyan
this one
depends on version too iirc
yep, if its 1.13+ its Cyan_Dye
no like the chat color
oh uh
or dark aqua &3
ah ^
thats dark aqua
made a CustomConfig file to operate the user's config but the CustomConfig.get() method returns null, here's the setup
public static void setup() {
file = new File(Bukkit.getServer().getPluginManager().getPlugin("HearthNest").getDataFolder(),"config.yml");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
}
config = YamlConfiguration.loadConfiguration(file);
}
}```
why use ChatColor just translateAlternateColorCodes
why use chatcolor just \u00a7
Dont hide exceptions like that
^
wdym
Also make sure the that you are using the same instance you call setup() on
Because thats the problem most likely
doesn't it being static avoid that issue?
another thing too thats not gonna copy data from a config file in your plugin
its just gonna create a blank yml file
If config is static then it doesnt matter
yeah it is
https://www.youtube.com/watch?v=3en6w7PNL08
following this old ass tutorial btw
In this episode, I show you how to create custom configuration files for your plugins. This means that you can use other files to store data other than the typical config.yml file. These are used by every major plugin, usually. #Spigot #Bukkit #MinecraftPluginDevelopment
Code: https://snippets.cacher.io/snippet/e1f3bdc29b1739dc374c
β Kite is a...
use JavaPlugin#saveResource("string", booleanReplaceValue);
If your saving a file inside your /resources folder
You only create the config if the file doesnt exist. Move the config init further down
u prolly shoulnt
it will handle all of the if exists all that
it teaches u bad coding standards.
what is your .get() method?
ok should i scrap what i have now and just free form it or follow something else
literally just return config
sec i got a wiki for you
Epic fun fact for epicgodmc: i got it to work thx
You only create the config if the file doesnt exist. Move the config init further down
π
i would just wing it with google.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
π
also it looks like that's just using the default config anyways?
shrug
why not just do Main.getConfig() or whatever it is
that wiki wont show you how to make getters and setters, but you should know how to do that already
(Considering you learned java before trying to learn SpigotAPI)
and addong onto this
If you are using just the default config file
JavaPlugin#saveDefaultConfig()
just use that
and JavaPlugin#getConfig()
anything else use JavaPlugin#saveResource
unless your wanting to write to a yaml file via code instead of copying a config file over from /resources
then the way you were doing it is fine, some cases you want to do this for configs but not often
kk
i aint a fan of the default shit
since it only supports one file
i rather have my own system that can create as many as i want.
yeah but for his it was only using one
is this called when a player right clicks ?
uhh
saveResource supports all files in /resources
yes
okay thank you
of course. im talking about getConfig()
in most cases called twice actually
for both hands.
twice ?
you mean like if i left click it could be called twice ?
yea. once for the main hand and once for the offhand
oh thats for 1.9 + ?
modern problems require very old solutions
Unbased opinion
thank you
