#help-development

1 messages · Page 384 of 1

eternal oxide
#

?basics

undone axleBOT
grand magnet
#

Show me an example code

glad prawn
#

And your getIP return nothing. Nice.

tardy delta
#

3 commands for the learnjava thing now, nice

lost matrix
#

Is basics a less passive aggressive version of learnjava?

eternal oxide
#

yes

lost matrix
#

lul

glad prawn
#

Lmao

remote swallow
tardy delta
#

learnjava! is pretty aggressive

lost matrix
#

AllArgsConstructor takes all fields as parameters

#

*Which are not pre-initialized ofc

#

In which way?

tardy delta
#

= null?

lost matrix
#

@RequiredArgsConstructor only uses those fields which need to be initialized in order to construct the class.

tardy delta
#

i might aswell start to use lombok

lost matrix
#

Probably not

tardy delta
#

interesting If a sheep is within a certain distance of another sheep, it will move towards it and try to stay close to it. This distance is controlled by the "follow range" attribute, which is set to 8 blocks by default.

calm crow
#

Hey guys. Is there an easy fix for when two plugins use the same command? How do you choose which takes priority- or even change the commands? The two plugins are EpicCore and Lands-land claim plugin with the same command /chat.

quaint mantle
#

Possible to create object that implement interface on the runtime?

#

Any interface extend parent interface

#

I decided to make a server where gamemode adventure will be by default, but all the plugins that I found do not help...( and there is also an auth me plugin on the server and it resets it to 0. what should I do in this case and which plugin /datapack is needed for the automatic issuance of gm 2 when entering the server? (pls ping me)

tardy delta
#

new Interface() {
void someMethod() { return true }
};

#

damn chatgpt is lying so badly

lost matrix
quaint mantle
lost matrix
quaint mantle
#

Bruh I think it was impossible.

lost matrix
tardy delta
#

you want to inject method behaviour?

lost matrix
tardy delta
#

just already create an object that implements your interface and have functions (like Runnable) for each method impl

#

thats the most simple way, but idk what you want to achieve

calm crow
quaint mantle
#

and how will I build?

quaint mantle
lost matrix
tardy delta
#

arent you just trying to get the value of the query annotation?

quaint mantle
#

Yea it hard to explain 😩

tardy delta
#

just give an example

quaint mantle
#

Ok

lost matrix
# tardy delta arent you just trying to get the value of the query annotation?

Nope i think hew wants to write a text query and let the interface execute the query.
But there is no actual implementation for that interface. He basically wants to "inject"
an implementation so that the query is actually run by usefull code. Im still trying to find
out when and from where he actually tries to "inject" the implementation so that i can recommend
either using RegisteredServiceProvider or a Factory pattern.

tardy delta
#

oh i kinda understand

hazy parrot
#

You can't

tardy delta
#

in c# you can :)

hazy parrot
#

Sql have order of keywords

tardy delta
#

sounds like abusing someone elses code

lost matrix
#

But someone has to write the implementation

quaint mantle
# tardy delta just give an example
public interface SQLController<object> {

    @Query(query = "SELECT * FROM %name% LIMIT 1;", response = RepoResponse.EQUAL_ONE)
    object findFirst();

    @Query(query = "SELECT * FROM %name% LIMIT 20;", response = RepoResponse.MORE_THAN_ONE)
    List<object> findTwenty();

    @Query(query = "INSERT INTO %name% VALUES(hello = %hello%, wassup = %wassup%;", response = RepoResponse.VOID)
    void insert();

}

Something like this.

tardy delta
#

just have common code for all those methods that executes those queries ig

#

then figure out whatever type of query it is aaa

pseudo hazel
#

just make a method that sends a query

#

it doesnt need to be complicated

tardy delta
#

im just wondering why

pseudo hazel
#

I mean it doesnt make much sense for this to be in an interface in any case

#

writing a query is an implementation

tardy delta
#

there are probably some restrictions

lost matrix
quaint mantle
#

I see frameworks that makes database controls like this

#

idk

tardy delta
#

looks like spring

quaint mantle
lost matrix
quaint mantle
#

Or I can just use JPA?

lost matrix
tardy delta
#

bytecode injection 🙉

quaint mantle
#

another idk

lost matrix
#

It implements the JPA standard

quaint mantle
#

ok

#

thanks

lost matrix
# quaint mantle ok

Looks a bit like this:

@Entity
@Table(name="STUDENT")
public class Student {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    
    @Column(name="STUDENT_NAME", length=50, nullable=false, unique=false)
    private String name;
    
    // other fields, getters and setters
}

And then you can just throw your objects in a database as they are.

quaint mantle
#

Cool so I not need to implement my self 🙂

lost matrix
#

And then you can also use your @Query annotation for some custom DAOs

tardy delta
#

i tried to make something like that but reflections but it went brr

#

too much annotations, reflections and stringbuilders

pseudo hazel
#

how can I find out if an object isnt getting deleted

#

because I am making a game but everytime I start it the old instance doesnt get removed

#

like im used to c++ and stuff where I have to free thngs myself so idk how it works here

tardy delta
#

finalize kinda goes brr

lost matrix
#

This happens if you dont write robust code. Strongly encapsulate your objects and you will never have
problems with random references floating around.

quaint mantle
pseudo hazel
#

well

tardy delta
#

for a reason

pseudo hazel
#

so what are common pitfalls then

#

because idk where to look

sterile token
#

How can people code using Velocity, they api is relly unfriendly

tardy delta
#

to invoke code when an objects is getting gced now, look at the cleaner api

tardy delta
sterile token
tardy delta
#

and you sure arent on weed?

pseudo hazel
#

like how does a reference get lost anyways

lost matrix
tardy delta
#

free() :(

pseudo hazel
#

there is too much to just show but I can try to give a summary

lost matrix
#

Like manually setting a reference to null is almost always a code smell.

quaint mantle
pseudo hazel
#

so for reference I am creating a minigame plugin for bingo, and I have a "gamemanager" called GameWorldManager, in it I have a list of active games and I can add games to that list and remove them when they are done

#

but when I remove them they dont seem to get deleted

#

but just talking about this made me get an idea on something I should still check xD

tardy delta
ivory sleet
tardy delta
#

oh no we summoned conclure

tardy delta
#

runn

quaint mantle
#

Runtime

ivory sleet
#

Yes

#

PhantomReference and WeakReference with a ReferenceQueue is provided by Java std

lost matrix
#

Use a LinkedHashMap and sort it before joining.

ivory sleet
#

(Also SoftReference)

quaint mantle
lost matrix
ivory sleet
#

🥲

quaint mantle
#

I think we not need low level for java

#

It will be like c++

tardy delta
#

what

lost matrix
#

PS you can also wrap the entry set in a List<Entry<K, V>> and call Collections.sort on it with a custom comparator which sorts by value or key

pseudo hazel
ivory sleet
#

I believe that Java should provide low level api, but similar to rust, the user should be well aware of in case they enter that type of shit

lost matrix
tardy delta
#

Unsafe my beloved

pseudo hazel
#

those objects are listeners so when an event happens it fires for all of them, so they must still exist

lost matrix
#

Is it still in incubation btw?

ivory sleet
#

mye or preview

#

One jep of it might have been released idr tbf

eternal oxide
pseudo hazel
#

hmm

#

so I just unregister them then?

eternal oxide
#

yes

tardy delta
#

this is kinda fun

pseudo hazel
#

is the best place to do that when I remove them from the list? cuz afaik there are no destructors in java

lost matrix
#

Sounds like a side effect to me

eternal oxide
#

All you do is drop all references and GC will delete them

pseudo hazel
#

what about circular references

#

like dependency injection stuff

tardy delta
#

gc should be able to handle that

lost matrix
#

So glad i learned how to do bézier curves. They looks so smooth.

pseudo hazel
#

like I add my plugin as a variable to another class

eternal oxide
#

you drop all reference the object you want to delete

tardy delta
#

:o

eternal oxide
#

if they are listeners unregister them

#

then drop your references

tardy delta
#

looks like santa spawning presents mid-air

pseudo hazel
#

yeah so dropping a reference is really just removing them from whatever container they might be in

#

or leaving the scope

quaint mantle
pseudo hazel
#

no

#

it does not

quaint mantle
#

So you can show your code?

pseudo hazel
#

why?

#

xD

#

I already know what I need to do to fix it

#

and its too much to just show here

quaint mantle
#

Ok do it yourself :))

mortal hare
tardy delta
#

i just want to know how to let chunk generation work on minestom

#

but this looks pretty good

half bane
#

Is there a function to get when a player has joined/for how long has been online?

#

(i cant find it)

lost matrix
half bane
tardy delta
#

thats not possible right

half bane
#

oh

pseudo hazel
#

eehm actually, how do I unregister a listener?

tardy delta
#

you could always keep track of it

tardy delta
lost matrix
#

There is no info on that. You need to track that yourself.
PlayerJoinEvent -> get current time and put it in a Map<UUID, Instant>

pseudo hazel
#

oh

half bane
#

ok thanks

pseudo hazel
#

I like the consistency

lost matrix
pseudo hazel
#

well they are listeners

lost matrix
#

o.O

pseudo hazel
#

what do you suggest

#

making another manager?

tardy delta
#

we love managers

lost matrix
#

Registering one listener which propagates the events to every game

lost matrix
pseudo hazel
#

I already have like 5 of those

lost matrix
#

I sure hope that you have a GameManager

pseudo hazel
#

yes thats what I was saying earlier

#

thats how I add and remove games

#

but that one isnt a listener

lost matrix
#

Alright let me give you a minimal example. One moment.

worldly ingot
#

Ideally you want to avoid registering and unregistering listeners anywhere other than onEnable()

#

Every time you do that, the listeners have to be re-baked

#

Which isn't exactly cheap

pseudo hazel
#

okay

spare mason
#

how i can get the player that killed an speficic mob?

worldly ingot
#

LivingEntity#getKiller()

#

Returns a Player if killed by one, otherwise null

pseudo hazel
#

is this explained anywhere?

ivory sleet
#

(Which bukkit does once after all plugins have been loaded and enabled)

worldly ingot
#

It is. It's baked for performance reasons. But the whole thing has to get rebaked if a new listener gets added

pseudo hazel
#

like how tf am I supposed to know when to or when to not register events xD

tardy delta
#

what does re baked mean in this context?

ivory sleet
#

Tho, wouldn’t it still work fine w/o rebake after initial server load up?

#

Cause I know some libraries that lazily register listeners taking JavaPlugin::getProvidingPlugin and just passes it along with the listeners

lost matrix
# pseudo hazel but that one isnt a listener
public interface ActiveGame {

  void handleDamageEvent(EntityDamageEvent event);
  void handleDeathEvent(EntityDeathEvent event);

}
public class GameManager {

  private final List<ActiveGame> activeGameList = new ArrayList<>();

  public void handleDamageEvent(EntityDamageEvent event) {
    activeGameList.forEach(game -> game.handleDamageEvent(event));
  }

  public void handleDeathEvent(EntityDeathEvent event) {
    activeGameList.forEach(game -> game.handleDeathEvent(event));
  }

}
public class GameListener implements Listener {

  private final GameManager gameManager;

  public GameListener(GameManager gameManager) {
    this.gameManager = gameManager;
  }

  @EventHandler
  public void onDamage(EntityDamageEvent event) {
    gameManager.handleDamageEvent(event);
  }

  @EventHandler
  public void onDeath(EntityDeathEvent event) {
    gameManager.handleDeathEvent(event);
  }

}

Then you will never have to unregister any listeners. All you do is remove a game from the list and it doesnt receive any events anymore.

#

Ugh the spam

ivory sleet
pseudo hazel
#

well yeah I guess that makes sense

#

I just hoped there was a more straight forward way

#

but this is fine

#

thanks

lost matrix
#

HandlerLists after someone constantly un/registers events

pseudo hazel
#

lmao

tardy delta
#

id make the gamemanager implement Listener 🙏

#

do private methods work for a listener?

lost matrix
#

Separation of concerns fourteen

lost matrix
tardy delta
#

how so

#

havent really looked at the impl

worldly ingot
#

I'd personally argue it's more recommended to make them private lol. I don't want my listeners being manually called

lost matrix
#

something something reflection fkery taking longer. I looked into that back in spigot 1.12
Was something about the JIT taking longer for method invocations to get JIT compiled on private methods
because of the accessible flag

ivory sleet
#

Reflection invocation beinng reimplemented with method handles soon 😌

lost matrix
#

But i guess spigot now uses MethodHandles (?)

tardy delta
#

:o

worldly ingot
#

I don't think we do

#

At least I'm unaware of it if that's the case

rare rover
#

okay so im learning gradle and i dont understand how to add a module to another module?

lost matrix
#

Never bothered benchmarking it in java 17 so my assumption stems from java 1.8 and spigot 1.12 data

tardy delta
#

gradle kek

rare rover
worldly ingot
#

Instead of depending on its groupId and artifactId, you depend on project(":YourModuleName")

#

So compileOnly project(':foo-bar') for example

tardy delta
#

love it how my pom.xml has errors and it still compiles

rare rover
pseudo hazel
#

I feel like those can just be one class

lost matrix
ivory sleet
#

They can, but they lay at different levels of abstraction also. GameManager being at a higher level than your listener.

tardy delta
#

me where my VanishManager is a Listener, Reloadable and Iterable<UUID> :)

pseudo hazel
#

what do you mean by that? how is the gamemanager higher?

tardy delta
#

separated the listener tho

worldly ingot
ivory sleet
pseudo hazel
#

like to me it looks just as concrete as the listener

ivory sleet
#

It may not seem very apparent, but in the long term, having high and low level components/classes figured out helps quite well with the structure (:

pseudo hazel
#

and with the filecount

#

but ig thats just an oop thing

ivory sleet
#

Yeah well if that’s an issue then it’s time to start considering the amount of files you have

#

Though with all due respect, that is likely not going to be a concern of yours

pseudo hazel
#

it isnt

#

its not too bad yet

ivory sleet
#

Sounds good :>

lost matrix
pseudo hazel
#

lol

#

I was like thats not too bad

#

but then started scrolling

tardy delta
#

imagine crying about filecount

#

not my code tho

lost matrix
#

"crypto" XD

pseudo hazel
#

imaging writing a book

tardy delta
#

uh ye its a minecraft server, so ig the player encryption stuff is there

lost matrix
#

Ah makes sense

pseudo hazel
#

I mean atleast there is no utils package with like 50 random classes

tardy delta
#

HEEHEEHEE

pseudo hazel
#

nvm

#

wait are these separate folders from the other ones?

#

there is double crypto

#

would be a nightmare to find anything I imagine lol

tardy delta
#

wdym separate folders

pseudo hazel
#

or was that the same screenshot but cropped differently

#

cant be bothered t read everything

tardy delta
#

last screen is a subfolder of the first

#

always fun looking at internals and seeing that half of the stuff isnt used

pseudo hazel
#

I see

#

on a different topic, how can I see if an Inventory is currently open?

tardy delta
#

id say getOpenInventory().getTopInv() == custom but from what i understood from Elgarl you cant

pseudo hazel
#

what objects

eternal night
#

how would objects be joined lol

tardy delta
#

Stream#reduce 💀

pseudo hazel
#

wait yes there is

#

its called an array

lost matrix
#

I guess StringBuilder has append(Object) which just calls toString() on the appended Object

eternal oxide
tardy delta
#

ah im bad at listening then

#

👍

pseudo hazel
#

so how do I check if my custom inventory instance is open?

eternal night
tardy delta
#

player.getOpenInventory().getTopInventory().equals(custom)

#

ig

eternal night
#

or yea

eternal oxide
#

yep

pseudo hazel
#

oh

eternal night
#

keep track of the instances ^

lost matrix
pseudo hazel
#

well nvm then, thats just as bad as looping through the inventories itself xD

lost matrix
#

Isnt there a modern resource on how to create GUIs which use the chain of responsibility pattern? 🤨

#

Speaking about the general idea of Map<Integer, Consumer<InventoryClickEvent>> and variations

ivory depot
#
            public void run() {
                if(Bukkit.getOnlinePlayers().contains(e.getPlayer())){
                    if(e.getPlayer().getInventory().firstEmpty()!=-1){
                        e.getPlayer().getInventory().addItem(coin.coin());

                    }else{
                        e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&cNie masz miejsca w ekwipunku!"));
                    }
                }
            }
        }, 0L, 1200L * 1);``` I got this task, and it runs everytime when i join to server. I want to start this after specifed time and repeating this
tardy delta
#

time to write a resource then

#

modify the numbers

ivory depot
#

i must change delay?

tardy delta
#

the first one is delay in ticks yes

ivory depot
#

okay, thanks

lost matrix
tardy delta
#

and use a lambda instead of a runnable

lost matrix
#

And use a concrete class implementation instead of an anonymous one or a lambda.

tardy delta
#

and if you dont want to get bonked by me, never instantiate bukkitrunnables unless its needed

lost matrix
# ivory depot ``` this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Ru...

Would look like this:

public class CoinRunnable implements Runnable {

  private final CoinSomething coin;
  
  public CoinRunnable(CoinSomething coin) {
    this.coin = coin;
  } 
  
  @Override
  public void run() {
    for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
      giveCoinTo(onlinePlayer);
    }
  }

  private void giveCoinTo(Player player) {
    PlayerInventory inventory = player.getInventory();
    if (inventory.firstEmpty() != -1) {
      inventory.addItem(coin.coin());
    } else {
      player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cNie masz miejsca w ekwipunku!"));
    }
  }

}

spoonfeed

tardy delta
#

i know you, you added the giveCoinTo to use this::giveCoinTo ;-;

lost matrix
#

XDD yes

tardy delta
#

but yet youre not doing it

lost matrix
#

But i didnt want to confuse him

lost matrix
ivory depot
lost matrix
tardy delta
#

Weak map

ivory depot
#

Okay, thanks for advices, I'll try to do it

hard socket
#

How to check if a player has an inv opened?

lost matrix
hard socket
tardy delta
#

scroll a few minutes back ^^ oh

lost matrix
#

*Remove them on inventory close

#

Something that was mentioned above as well: Custom InventoryHolders

magic wharf
#

the PlayerInteractEvent wont be triggered if i right click the air with a item (even a bow or anything), its always being cancelled before it runs. Anyone know what could causing it? If i right click a block its working without any problems

hard socket
#

I am confused but I will try

lost matrix
magic wharf
lost matrix
magic wharf
#

nothing changed

lost matrix
#

Then show some code

restive mango
#

How do you get a method from a class you’ve extended from to return the object representing your current class?

magic wharf
#

Rn thats the code, cuz i just wanna check if its even triggered @EventHandler(ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {

    Bukkit.broadcastMessage("PlayerInteractEvent triggered!");
}
hard socket
#

how do I make an Item Unstackable?
I got this code but how do i cast it to ItemStack

#

public void setMaxStackSize(Item item, int i){ try { Field field = Item.class.getDeclaredField("maxStackSize"); field.setAccessible(true); field.setInt(item, i); } catch (Exception e) { e.printStackTrace(); } }

lost matrix
restive mango
#

Like if you have the class dirt which extends the earth, and earth has a method ‘returnSelf’ which just returns itself, how do I get that method to instead return the dirt object instead of the earth object?

lost matrix
magic wharf
lost matrix
restive mango
#

@lost matrix I think so

lost matrix
magic wharf
lost matrix
restive mango
#

Not really, the issue is when it returns, it returns as the ‘Earth’ class and NOT the ‘Dirt’ class, so I can no longer call methods unique to the dirt class.

lost matrix
magic wharf
restive mango
#

If I go Dirt.returnSelf()

hard socket
restive mango
#

That returns an earth object

lost matrix
lost matrix
# restive mango That returns an earth object
Earth earth = someMethod();
if(earth instanceof Dirt) {
  Dirt dirt = (Dirt) earth;
  dirt.dirtOnlyMethod();
}

Or in newer java versions:

Earth earth = someMethod();
if(earth instanceof Dirt dirt) {
  dirt.dirtOnlyMethod();
}

And returnSelf is a useless method. Remove it.

lost matrix
restive mango
#

@lost matrix is there some way to make this generalizable so I don’t need to check with instanceof all the subclasses of Earth, though?

pseudo hazel
#

well if they all have different methods, you need to call them one way or another

lost matrix
restive mango
#

So

#

In reality all these subclasses just have a method called ‘run’ which they derive from a class they implement called ‘LocationGenerator’, which just does a bunch of geometry to give me a bunch of locations in particular geometric distributions. It’s not actually dirt or earth etc

#

The bigger problem is I’d really like to be able to set the parameters for these subclasses independently of each other, and for that to happen I need methods which return the object which I can then call those same methods with again

#

But those methods are in the class which I am extending for these subclasses

#

Really

#

is there some way to make this generalizable so I don’t need to check with instanceof all the subclasses?

#

I mean I can

#

It’s not a huge amount

lost matrix
# restive mango In reality all these subclasses just have a method called ‘run’ which they deriv...
  public static void main(String[] args) {
    List<Animal> animals = new ArrayList<>();
    animals.add(new Cat());
    animals.add(new Dog());
    animals.add(new Cow());

    for (Animal animal : animals) {
      animal.makeSound();
    }
  }

  public static abstract class Animal {
    public abstract void makeSound();
  }

  public static class Cat extends Animal {
    @Override
    public void makeSound() {
      System.out.println("Miau!");
    }
  }

  public static class Dog extends Animal {
    @Override
    public void makeSound() {
      System.out.println("Wuff!");
    }
  }

  public static class Cow extends Animal {
    @Override
    public void makeSound() {
      System.out.println("Mooo");
    }
  }

Console output:

Miau!
Wuff!
Mooo

Take a close look at this pls.

drowsy helm
#

miau????

#

nah

#

never seen anyone spell it like that

lost matrix
#

Thats how germans write it out

drowsy helm
#

germans wilding

restive mango
#

Does not help

lost matrix
#

Ok let me take a closer look at your question then

restive mango
#

Give me a bit I’ll paste code

drowsy helm
#

do you mean

#

casting?

pseudo hazel
#

what is lifesteal?

eternal oxide
#

plugin/game style

restive mango
#
public class LocationGeneratorMeta {
    public Location origin = null;
    public Integer locationNumber = 1;
    public boolean seekGround = true;
    public boolean noSolids = true;

    public List<Location> endLocationList = new ArrayList<>();


    public List<Location> getLocationlist() {
        return endLocationList;
    }

    public LocationGeneratorMeta setLocation(Location loc) {
        origin = loc;
        return this;
    }

    public LocationGeneratorMeta setPoints(Integer pnts) {
        locationNumber = pnts;
        return this;
    }

    public LocationGeneratorMeta setSeekGround(Boolean seek) {
        seekGround = seek;
        return this;
    }

    public LocationGeneratorMeta setNoSolids(Boolean slds) {
        noSolids = slds;
        return this;
    }

}
#
public class LocationGeneratorCircular extends LocationGeneratorMeta {

    public double outerRadius = 10;
    public double innerRadius = 0;

    public LocationGeneratorCircular setInnerRadius(double oInnerRadius) {
        innerRadius = oInnerRadius;
        return this;
    }

    public LocationGeneratorCircular setOuterRadius(double oOuterRadius) {
        outerRadius = oOuterRadius;
        return this;
    }

}
#
public interface LocationGenerator {

    public List<Location> run ();

    public List<Location> getLocationlist();

}
echo basalt
restive mango
#
public class GenDisc extends LocationGeneratorCircular implements LocationGenerator {
    @Override
    public List<Location> run() {
        //buttload of code to return a disc of random points based on the parameters in LocationGeneratorCircular and LocationGeneratorMeta
    }

}
lost matrix
#

Alright makes sense so far

restive mango
#

I want to be able to go:

GenDisc sampleDisc = new GenDisc();
sampleDisc.setNoSolids(true).setInnerRadius(5);

#

the issue with that is

#

setNoSolids returns a LocationGeneratorMeta, which does NOT have the setInnerRadius method

drowsy helm
#

ah so you're trying to do a builder

restive mango
#

in contrast, I could go:
sampleDisc.setInnerRadius(5).setNoSolids(true);

#

i guess so

#

i dunno what that is though lol

drowsy helm
#

you need some sort of overarching class

lost matrix
#

Ok i understand you. This is a common problem for the Builder pattern. One moment ill fix it for you.

restive mango
#

danke

drowsy helm
#

Also not relevant but why are you doing some primitive and some not?

restive mango
#

because i'm a complete idiot, primarily

drowsy helm
#

if you don't need to use the method's of Integer just use int

#

Integer uses more mem

restive mango
#

yeah i should do that

drowsy helm
#

not really a big issue but if you're using this hundreds of times over it can help a little

restive mango
#

i do only use it once, but still, best practices

#

Just note, GenDisc is just one of MANY classes which all extend LocationGeneratorCircular and implement LocationGenerator

#

well

#

by many I mean like 4 lol

#

i guess in theory it might increase as I add more shapes

#

which is why im even doing this

lost matrix
restive mango
#

you mean why does GenDisc extend it? Or why does LocationGeneratorCircular extend it?

lost matrix
#

Both make little sense

drowsy helm
#

i feel like all of it could be consolidated into a singular class

lost matrix
#

Well for the Circular i can understand it.

drowsy helm
#

rather than having 2 separate classes

lost matrix
#

Alright let me scrap the GenDisc part and write something type safe for your meta.

restive mango
#

There is also a LocationGeneratorSegment which extends LocationGeneratorCircular and is only used for cones and pieces of discs; it requires, in addition to the variables listed above, a vector for direction in space to point the segment and an angle which the segment takes up.

#

GenDisc extends it because there is also a GenSphere

lost matrix
#

Here is the solution:

public class LocationGeneratorMeta<SELF extends LocationGeneratorMeta<?>> {

  private final Class<SELF> runTimeType;
  public Location origin = null;
  public Integer locationNumber = 1;
  public boolean seekGround = true;
  public boolean noSolids = true;
  public List<Location> endLocationList = new ArrayList<>();

  public LocationGeneratorMeta(Class<SELF> runTimeType) {
    this.runTimeType = runTimeType;
  }

  public List<Location> getLocationlist() {
    return endLocationList;
  }

  public SELF setLocation(Location loc) {
    origin = loc;
    return runTimeType.cast(this);
  }

  public SELF setPoints(Integer pnts) {
    locationNumber = pnts;
    return runTimeType.cast(this);
  }

  public SELF setSeekGround(Boolean seek) {
    seekGround = seek;
    return runTimeType.cast(this);
  }

  public SELF setNoSolids(Boolean slds) {
    noSolids = slds;
    return runTimeType.cast(this);
  }

}
public class LocationGeneratorCircular extends LocationGeneratorMeta<LocationGeneratorCircular> {

  public double outerRadius = 10;
  public double innerRadius = 0;

  public LocationGeneratorCircular() {
    super(LocationGeneratorCircular.class);
  }

  public LocationGeneratorCircular setInnerRadius(double oInnerRadius) {
    innerRadius = oInnerRadius;
    return this;
  }

  public LocationGeneratorCircular setOuterRadius(double oOuterRadius) {
    outerRadius = oOuterRadius;
    return this;
  }

}
restive mango
#

public LocationGeneratorCircular() {
super(LocationGeneratorCircular.class);
}

lost matrix
#

Hm?

lost matrix
undone axleBOT
#
CafeBabe Help Menu
*Red V3*
**__Admin:__**

selfrole Add or remove a selfrole from yourself.

**__Cleanup:__**

cleanup Base command for deleting messages.

**__Core:__**

embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.

**__Downloader:__**

findcog Find which cog a command comes from.

**__Mod:__**

names Show previous names and nicknames of a member.
userinfo Show information about a member.

**__ModLog:__**

listcases List cases for the specified member.
reason Specify a reason for a modlog case.

**__Permissions:__**

permissions Command permission management tools.

hazy parrot
#

?blockpdc

undone axleBOT
bold vessel
#

Thx

solar mauve
#

i spawned an arrow

#

and i couldn't pick it up

#

and there is no functions in Arrow interface in order to that

#

what should i do?

#

ok, i know, but bedwars must be developed in 1.8, and there is no other way to this, because its lightweight and anticheats are stablizied with that + pvp, im using paper 1.8

bold vessel
#

Som1 know why this isnt working ?

restive mango
#

@lost matrix why cant they extend their meta?

drowsy helm
#
public abstract class LocationGenerator<E extends LocationGeneratorMeta> {

    public abstract List<Location> run(E meta);
    public abstract List<Location> getLocationlist();
}
public class LocationGeneratorMeta {
    public boolean noSolids = true;

    public LocationGeneratorMeta setNoSolids(boolean slds) {
        this.noSolids = slds;
        return this;
    }

}
public class CircularMeta extends LocationGeneratorMeta{
    public double outerRadius = 10;
    public double innerRadius = 0;

    public CircularMeta setInnerRadius(double oInnerRadius) {
        innerRadius = oInnerRadius;
        return this;
    }

    public CircularMeta setOuterRadius(double oOuterRadius) {
        outerRadius = oOuterRadius;
        return this;
    }
}
public class CircularGenerator extends LocationGenerator<CircularMeta>{
    @Override
    public List<Location> run(CircularMeta meta) {
        return null;
    }

    @Override
    public List<Location> getLocationlist() {
        return null;
    }
}

@restive mango how about something like this where generator takes an instance of meta which has to be of specific type

#

rather than having it extend a meta

bold vessel
lost matrix
drowsy helm
bold vessel
#

what should i use ?

drowsy helm
#

have to get TileState iirc

tender shard
lost matrix
tender shard
#

if you want to have a PDC per block:

#

?blockpdc

undone axleBOT
dense falcon
#
package fr.program;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import java.util.Arrays;

public class ConstructorCommands extends Command {

    private final CommandExecutor executor;

    public ConstructorCommands(String name, String description, CommandExecutor executor, String... aliases) {
        super(name, description, "", Arrays.asList(aliases));
        this.executor = executor;
    }
    @Override
    public boolean execute(CommandSender sender, String commandLabel, String[] args) {
        return executor.onCommand(sender, this, commandLabel, args);
    }
}

``` How can I set up a permission in my constructor for cmds?
lost matrix
tender shard
lost matrix
#

Oh hes extending the bukkit Command...

dense falcon
tender shard
#

there is

tender shard
#

but setPermission takes a string

dense falcon
#

Ah ok, so the name of the permission?

tender shard
#

yes

dense falcon
#

Like a normal permission in plugin.yml.

#

Alright thanks.

tender shard
#

np

solar mauve
# solar mauve ok, i know, but bedwars must be developed in 1.8, and there is no other way to t...
public void d(EntityHuman entityhuman) {
        if (!this.world.isClientSide && this.inGround && this.shake <= 0) {
            ItemStack itemstack = new ItemStack(Items.ARROW);
            if (this.fromPlayer == 1 && entityhuman.inventory.canHold(itemstack) > 0) {
                EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
                PlayerPickupItemEvent event = new PlayerPickupItemEvent((Player)entityhuman.getBukkitEntity(), new CraftItem(this.world.getServer(), this, item), 0);
                this.world.getServer().getPluginManager().callEvent(event);
                if (event.isCancelled()) {
                    return;
                }
            }

[... more]

nvm, found it, "this.fromPlayer"

lost matrix
#

?1.8

undone axleBOT
solar mauve
#

i already know about hat, but thanks

solar mauve
lost matrix
#

?whereami

solar mauve
#

tnx

small hawk
#

Hey @lost matrix can i send u part of my code in DM, i have one question and you are like a boss? If u have a second ofc.

lost matrix
# solar mauve tnx

Use ancient software -> Live with the consequences
You probably need to find out what NBT tags the Arrow has in 1.8
and then change them using NMS or Reflections.

lost matrix
solar mauve
#

thank you, it did the trick

restive mango
#

@lost matrix not sure this'll work tbh

#

because locationgeneratorcircular wouldn't return locationgeneratorsegment when its methods are called IF it is a segment

#

thanks for trying though

rare rover
#

anyone got a good color method?

#

for mc colors and hex?

small hawk
rare rover
#

yes but that requires <gray> or <gradient:red:green>

#

which most people dont know

#

im using it for a config

#

so

bold vessel
#

What can i use if storeditem key isnt in persistence ?

#

And i imported it

small hawk
lost matrix
rare rover
#

true

restive mango
#

Anyone else know how to make it so a class can return itself or a class extended from itself?

lost matrix
#

Your design is flawed. What ive sent you is the maximum you can do.

tender shard
tender shard
#

or php

#

lol

#

$myvar = whatever()

restive mango
#

hm

#

oh

#

figured it out

#

i'll just pass the class back in every method and then cast it based on what you pass back

lost matrix
#

Anyways. php bad

tender shard
lost matrix
#

lol

drowsy helm
#

php is great you guys are haters

lost matrix
#

You go explode your variables

tender shard
#

everyone_knows_that_PhpSucks()

#

average naming scheme for php default methods

drowsy helm
#
$stmt->bind_param("ssssisssi", $order_firstname, $order_lastname, $order_notes, $order_phoneno, $order_amount, $addr_address, $addr_suburb, $addr_postcode, $order_vegan);

check out this badboy of a method

#

array index out of bounds

lost matrix
#

Check your array lenght before accessing it

dense falcon
#

Yeah I am stupid 🤣.

restive mango
#
    public <T extends LocationGeneratorCircular> T setInnerRadius(Class<T> cls, Object obj, double oInnerRadius) {
        innerRadius = oInnerRadius;
        return cls.cast(obj);
    }
#

Solution for those interested

drowsy helm
#

extra param 😦

lost matrix
#
    public <T extends LocationGeneratorCircular> T setInnerRadius(T obj, double oInnerRadius) {
        innerRadius = oInnerRadius;
        return obj;
    }
#

Which makes the parameter utterly useless because the caller has it already.

#

Which results in

    public void setInnerRadius(double oInnerRadius) {
        innerRadius = oInnerRadius;
    }
drowsy helm
#

sort of ruins the point of a builder

#

why use it if you're just gonna pass the builder obj through a param anyway

restive mango
#

decreases the amount of variables

lost matrix
#

No it doesnt

#

Literally the same

restive mango
#

well originally i had 1 big class which stored variables for every possible shape

lost matrix
#

That alone sounds like a nightmare

restive mango
#

yeah

#

so this is a huge improvement

#

by the way 7

tardy delta
#

wheres 6

restive mango
#

nvm

bold vessel
#

And explide me how to fix it

restive mango
#

poor lad

lost matrix
restive mango
#

well

#

now that i have the easy solution to rely on when i give up

#

i should think more about how to satisfy smile and buoobuoo

drowsy helm
#

Aesopian it's possible if you only want one layer of inheritance for meta

restive mango
#

yeah, so, i know

#

i did think about that

bold vessel
#

what should i do

restive mango
#

the issue is that this would add the 'angle' and 'orientation' parameters to the LocationGeneratorCircular class

#
public class LocationGeneratorSegment extends LocationGeneratorCircular {

    public double arcAngle = 360;
    public Vector orientation = new Vector(0.1, 0, 0);

    public LocationGeneratorSegment setPointer(Vector orientation) {
        this.orientation = orientation;
        return this;
    }

    public LocationGeneratorSegment setAngle(double arcAngle) {
        this.arcAngle = arcAngle;
        return this;
    }



}
#

I have this too, you see

drowsy helm
#

right

restive mango
#

For segments of circles or spheres.

drowsy helm
#

yeah it's just a java limitation really

#

sort of sucks

icy sage
#

I'm setting lore on an item and it doesn't show up

        ItemMeta meta = item.getItemMeta();
        assert meta != null;
        meta.setDisplayName(name);
        meta.setLore(desc); 
        item.setItemMeta(meta);
restive mango
#

I could do the obj return strategy, though

#

It's just fucking ugly

lost matrix
dense falcon
#

How can write in configs? 🤔

small hawk
icy sage
icy sage
bold vessel
#

pls

restive mango
#

wait

icy sage
#

ok nvm

lost matrix
# icy sage nope

Add a debug message after item.setItemMeta and see if it even gets called.

lost matrix
icy sage
#

my list was empty, wrong config key

lost matrix
drowsy helm
#

it's hacky but it will work

small hawk
#

Configs 💀

lost matrix
restive mango
#

damn

drowsy helm
#
@SuperBuilder
@Getter
@Setter
public class LocationGeneratorMeta{
    private boolean noSolids = true;

}```
```java

@SuperBuilder
@Getter
@Setter
public class CircularGenerator extends LocationGeneratorMeta{
    private double outerRadius = 10;
    private double innerRadius = 0;
}
restive mango
#

@drowsy helm havent used Lombok before

drowsy helm
#

        CircularGenerator circularGenerator = CircularGenerator.builder().innerRadius(1).noSolids(true).build();```
#

results in that

dense falcon
drowsy helm
#

lombok is great but can cause some issues at compile

restive mango
#

Is Lombok good?

#

oh

drowsy helm
#

i use it all the time

#

but some people dont like it

#

but it will solve your issue

restive mango
#

does it cause any lag

drowsy helm
#

no lol

#

it's an annotation framework

#

that generates code on compile time

restive mango
#

does the code it generates cause lag

drowsy helm
#

no

restive mango
#

okay

drowsy helm
#

how would it cause lag?

restive mango
#

idk

drowsy helm
#
@Getter
@Setter
public class MyClass{
  private int myInt;
}

on compile becomes

public class MyClass{
  private int myInt;

  public int getMyInt(){
    return myInt;
  }

  public void setMyInt(int myInt){
    this.myInt = myInt;
  }
#

it saves heaps of space coding

#

but like i said alot of other devs don't like it

#

but their SuperBuilder annotation would solve your issue

lost matrix
#

lombok adds a Thread.sleep(10) in every getter to delay them by 10ms
This makes the server lag big time kappapeek

drowsy helm
#

lmao

restive mango
#

oof

#

i cant use it then

winged anvil
#

@lost matrix were you able to figure out how that one product was able to create those UI's with the buttons?

icy sage
#
        fileConfiguration.addDefaults(CONFIG_DEFAULTS);
        if (!configFile.exists()) {
            fileConfiguration.options().copyDefaults(true);
            saveConfig();
        }

Is this a bad practice
I feel like this is better than using saveDefaultConfig

winged anvil
#

these

lost matrix
#

They use inventories for the clicks. You can decrease the bar size between the upper and lower inventory so
that you have a 9x9 area

drowsy helm
#

i had a resource on the forums for that specifically

#

all the github links are fucked tho

restive mango
#

hm

#

this seems to work

#

possibly

#

let us continue to test...

winged anvil
#

werent the buttons something special? like they had their own click region that wasnt a collection of slots

vivid hill
#

Which method is better?
- update the scoreboard every x seconds
- update it only when it should get updated

lost matrix
drowsy helm
#

that isnt possible lol

#

its all snapped to a grid

restive mango
#

ah

#

nope

#

buoo

#

you lied

drowsy helm
#

how?

restive mango
#

doesnt let me access build methods from the class it is extended from

vivid hill
restive mango
#

nvm

#

i lied

#

LOL

#

this

#

does seem to work though

#

...why does this work

#

what does superbuilder do, @drowsy helm ?

#

what... form of magic is this?

#

hmm... . . . . . . .

drowsy helm
#

same as the @Builder annotation but works with inheritance

restive mango
#

sussy....

#

does it

#

cause

#

lag?

drowsy helm
#

make sure you don't have your own ubilder methods tho

#

yours will overwrite lombok's

restive mango
#

why didn't @lost matrix suggest this?

#

i feel like i'm purchasing crack.

#

there is too much upside.

drowsy helm
#

because it's sort of hacky

#

depending on who you ask

#

i love lombok

#

others dont

restive mango
#

what does that MEAN!

#

why is it hacky...

drowsy helm
#

because the code is generated on compile

restive mango
#

honestly

#

it seems great

drowsy helm
#

it is

restive mango
#

and i'll probably use it

#

but

#

i just really want to know what 'superbuilder' /does/

#

like what is its mechanism of action

drowsy helm
#

like how it works behind the scenes?

#

or

restive mango
#

yeah

#

i just really want to rule out it causing more lag

#

the entire reason im doing this is because my math causes lag

drowsy helm
#

lombok doesn't cause lag

restive mango
#

if you say so!

drowsy helm
#

it maybe makes your compile 10 milliseconds longer

#

thats the only lag you will experience

restive mango
#

yeah im fine with compile lag

#

id compile for a day if it saved the server milliseconds

kind hatch
#

Lombok only affects the compile stage. It just adds the methods that you are not adding by using Lombok. Like the getters and setter methods

drowsy helm
#

compile into the same thing

#

they are both exactly the same at runtime

#

lombok just simplifies it on the developer's end to make it more readable

restive mango
#

actually

#

buoo

#

one thing i did notice

#

wait

#

i cant post pictures

#

sigh...

glad prawn
#

Verify dude

restive mango
#

can i build something WITHOUT assigning every variable?

kind hatch
#

?img

undone axleBOT
restive mango
#

like

drowsy helm
#

egsblain

kind hatch
#

Put them in the global scope and never access them?

restive mango
#

On IntelliJ, it now says 'Variable initializer is redundant'.

kind hatch
#

About the only way unless you bypass the compiler checks.

#

But then you’ll get nothing done.

restive mango
#
@SuperBuilder
@Getter
@Setter
public class LocationGeneratorMeta {
    public Location origin = null;
    public Integer locationNumber = 1;
    public boolean seekGround = true;
    public boolean noSolids = true;

    public List<Location> endLocationList = new ArrayList<>();


//    public List<Location> getLocationlist() {
//        return endLocationList;
//    }
//
//    public LocationGeneratorMeta setLocation(Location loc) {
//        origin = loc;
//        return this;
//    }
//
//    public LocationGeneratorMeta setPoints(Integer pnts) {
//        locationNumber = pnts;
//        return this;
//    }
//
//    public LocationGeneratorMeta setSeekGround(Boolean seek) {
//        seekGround = seek;
//        return this;
//    }
//
//    public LocationGeneratorMeta setNoSolids(Boolean slds) {
//        noSolids = slds;
//        return this;
//    }

}
#

when I hover over one of those variables

#

it goes

drowsy helm
#

make them private

restive mango
#

Variable 'origin' initializer 'null' is redundant

kind hatch
#

That’s just a warning.

restive mango
#

oh

#

I see

kind hatch
#

You can ignore it.

restive mango
#

ah great

#

because I'd like to not have to assign EVERY variable every time I build something

#

I want to have a few defaults

#

like number of locations to 1 etc.

kind hatch
#

Unless it says it’s an error and underlined in red, then you can most likely just ignore them.

#

The only ones that you’d want to pay attention to is dead code warnings or similar stuff.

nimble hill
#

So am i off my rocker or is this a bug in spigot?
Here is the situation:
Im trying to check when a player right clicks an Ender_Eye (and check if it has my custom data and all that)
And let me preface that im not a new developer or anything, i just want to ensure nothing has changed from 1.19.2-1.19.3 that im not heretical about.

  • I can trigger my event to see whats in my hands (interact event, left click) and i get the following:
    PlayerInteractEventItemStack{AIR x 0} ItemStack{ENDER_EYE x 1} (offhand, main hand) which is correct, the main hand contains an endereye

  • i can trigger the same with a different consumable like an enderpearl and get the following:
    PlayerInteractEventItemStack{AIR x 0} ItemStack{ENDER_PEARL x 1} (also correct)

Here is where the issue is:
i spend the enderpearl (right click / trigger its throw)
Enderpearl: PlayerInteractEventItemStack{AIR x 0} ItemStack{ENDER_PEARL x 1} (this reflects the pearl)
Endereye: PlayerInteractEventItemStack{AIR x 0} ItemStack{AIR x 0} (this SHOULD) reflect the ender eye, but it does not.

This is my check as a snippet: so you can see what im replicating:

@EventHandler
    public void on(PlayerInteractEvent e) {
        Plugin.info("PlayerInteractEvent" + e.getPlayer().getInventory().getItemInOffHand() + " " + e.getPlayer().getInventory().getItemInMainHand());
...

and here is a gif of the situation:
as you can see the interaction reflects the pearls correctly, but does not reflect the eyes correctly.
https://gfycat.com/UnluckyPositiveCobra (you can see it in hd if you click the little hd button)

Now, i already looked around but i could have totally missed the change if they changed where this event trigger for eyes is, but i dont think thats the prpblem, nor do i think they would change that.

#

Sorry for the page of text, i hate sending small bits of messages when i can just dump explain all in one

drowsy helm
#

sounds like a bug to me

nimble hill
#

(╯°□°)╯︵ ┻━┻

#

Ok ill make an issue report

drowsy helm
#

im guessing the two items are consumed differently

#

if you try and cancel the ender eye one does it work?

kind hatch
#

It might be a projectile being thrown.

#

Might want to check that.

nimble hill
#

And i can have a stack of 2 of them and it will throw one eye, and do nothing with the second , but if i do the same with enderpearls it cancels both

#

It just seems like its misordered

drowsy helm
#

yeah doesn't sound right

dense falcon
#
                    plr.sendMessage(ChatColor.WHITE + "[" + ChatColor.DARK_RED + "Loup Garou" + ChatColor.WHITE + "]" +
                            " Les données sont entrain d'être supprimées...");
                    for (int i = 1; i < 3; i++) {
                        plugin.getConfig().set("roles.loup-" + i, "None");
                    }

                    plugin.getConfig().set("roles.loup-pere", "None");
                    plugin.getConfig().set("roles.mechant-loup", "None");
                    plugin.getConfig().set("roles.loup-blanc", "None");
                    plugin.getConfig().set("roles.voyante", "None");
                    plugin.getConfig().set("roles.sorciere", "None");
                    plugin.getConfig().set("roles.ange", "None");

                    for (int i = 1; i < 7; i++) {
                        plugin.getConfig().set("roles.villageois-" + i, "None");
                    }

                    plugin.saveConfig();
                    plr.sendMessage(ChatColor.WHITE + "[" + ChatColor.DARK_RED + "Loup Garou" + ChatColor.WHITE + "]" +
                            " Les données sont supprimées.");
                    return true;
``` Why once I do this, my value are not Strings?
#
roles:
  loup-1: None
  loup-2: None
  loup-3: None
  loup-pere: None
  mechant-loup: None
  loup-blanc: None
  voyante: None
  sorciere: None
  ange: None
  villageois-1: None
  villageois-2: None
  villageois-3: None
  villageois-4: None
  villageois-5: None
  villageois-6: None
  villageois-7: None

``` After.
#
roles:
  loup-1: "None"
  loup-2: "None"
  loup-3: "None"
  loup-pere: "None"
  mechant-loup: "None"
  loup-blanc: "None"
  voyante: "None"
  sorciere: "None"
  ange: "None"
  villageois-1: "None"
  villageois-2: "None"
  villageois-3: "None"
  villageois-4: "None"
  villageois-5: "None"
  villageois-6: "None"
  villageois-7: "None"
``` Before.
drowsy helm
#

setString

dense falcon
#

It does not exist? 🤔

drowsy helm
#

ah nvm im bugging

dense falcon
#

So how I do :(?

#

It does not matter or 🤔 ?

#

I think it's not :>.

fathom summit
#

im trying so that my scoreboard shows the rank of a player but everytime i put %vault_rank% on the config my scoreboard js disappears how can i fix this

drowsy helm
#

nononono

#

bad practice

#

dont do

vocal cloud
#

You'll create unreadable code

wet breach
#

you shouldn't add the path separator manually

#

instead use PATH.separator for them slashes

#

not that it matters anymore I suppose

fathom summit
#

im trying so that my scoreboard shows the rank of a player but everytime i put %vault_rank% on the config my scoreboard js disappears how can i fix this

remote swallow
#

you dont really need to check if it exists

#

saveDefaultConfig doesnt overwrite anything

analog thicket
#

Why do i keep getting the "NullPointerException" didnt get it in my other plugin on the same stuff, im so confused

#

i get it on this line

getCommand("animation").setExecutor(new crateAnimation(this));

at

.setExecutor
echo basalt
#

did you register the command on the plugin.yml

analog thicket
#

Yep

#

I reloaded maven, that seems to work

fresh timber
#

in an EntityDamageByEntityEvent, how do you get the person that attacked the player?

#

if the person that attacked used an arrow

worldly ingot
#

A few extra steps but you can check if the damager is a Projectile. If it is, call getShooter(). Check if the shooter is a Player. If it is, you've got your killer

#
if (event.getDamager() instanceof Projectile projectile && !(projectile.getShooter() instanceof Player killer)) {
    return;
}

killer.sendMessage("hi you killed them");```
#

(checking for a Projectile instead of an arrow will support other projectiles as well btw)

sterile token
#

Lmao for being real, idk how Velocity Is going to be the proxies future. Startim from it's horrible api where you dont even implements a base class for plugins. Instead you use some really ugly injections vía @Inject.
Lmfao, not even going to code any plugin for that.

#

Also you use events for plugin activation and deactivation

#

Well it's done by paper whats More i can expect Hahahaha

green tapir
#

how can i code a lifesteal plugin but it only applies when the player uses a specific weapon?

#

and that weapon dissapears after a kill?

#

oh

sterile token
#

If you are on newer versions (1.16 and up, if im not wrong) you can use PDC, to add custom meta to the item

vocal cloud
#

Thought it was 1.14

icy beacon
#

1.14.4 and up afaik

ivory sleet
#

Sure its a bit of an opinionated way, but I don’t see the big starving point here

worldly ingot
#

Not much. Just opts to make use of Guice

rare rover
#

is there a way to add a dependency to all modules?

#

without putting the dependency in each one

wet breach
#

add it to the parent pom

rare rover
#

what about the relocation for the dependency?

#

just put it in the core?

#

or what

wet breach
#

you can still do relocation in the module pom

#

anything in the parent pom applies to all the modules unless overriden by the module

#

if you don't specify the shade stuff in the parent pom, then obviously each module has to handle the shading itself

rare rover
#

dont i need the shade plugin?

wet breach
#

so, nothing to worry about for you except just moving where the dependency is specified

wet breach
# rare rover

I never said you don't need it, just said you can leave the shade stuff as it is

worldly ingot
#

You would put the shade plugin wherever you need to use it

rare rover
#

ah

worldly ingot
#

Maven works in a hierarchy. Think of it like all the repositories, dependencies, and build settings are copied from the parent and pasted into all its children

rare rover
#

right

#

so uh?

#

i put it into the parent pom

worldly ingot
#

May need to refresh or rebuild

wet breach
#

^

rare rover
#

i just did, let me try again

worldly ingot
#

Especially in IJ, Maven needs to be rebuilt every time you change something in the pom

rare rover
#

oh that time it worked

#

so just add the relocation to the Core module

#

and we good?

worldly ingot
#

Yeah whichever one it is that needs it

rare rover
#

awesome, thanks so much!

#

does this look good?

    @Override
    public List<HoeEnchant> getEnchants() {
        List<HoeEnchant> enchants = new ArrayList<>();
        for (HoeEnchant enchant : HoeEnchant.values()) {
            if (nbtItem.getInteger(enchant.name()) > 0) {
                enchants.add(enchant);
            }
        }
        return enchants;
    }```
#

just wanting some clarification

wet breach
#

isn't there like only one hoeEnchant o.O

rare rover
wet breach
#

ah

rare rover
#

would that be the best way of doing that?

lost matrix
rare rover
#

1.19+

lost matrix
#

Yes

#

Then use PDC

rare rover
#

wtf is that

lost matrix
#

?pdc

rare rover
#

ahh

lost matrix
#

You can store persistent data in a lot of things. Makes NBTApi mostly useless.
Also NBTApi uses reflections iirc which is for sure slower than Spigots API.

#

Btw you can actually register custom enchantments.

worldly ingot
#

but you really shouldn't

quaint mantle
#

when given an itemstack would the best way to find like the custom enchants (from lore) and getting like the amount of kills like if the line contains "Kills: then split it then or is there a better way?

left plover
#

Does BungeeCord send signed chats by default or no?

#

Or is it just the unverified chats banner?

lost matrix
quaint mantle
#

when did that get added?

lost matrix
#

1.14

quaint mantle
#

mmm i support 1.16 through 1.8

lost matrix
#

Then at least use NBTItem

quaint mantle
#

then how would i go about adding a new enchant in a specific place?

#

or adding a new line or editing a specific line on the itemstack

lost matrix
charred blaze
#

How can I automatically include the project version set in the POM.xml file in the compiled output of my IntelliJ IDEA project? I have already searched for solutions on Google.

eternal oxide
#

<filtered>true</filtered> in your resources section of your pom

charred blaze
#

<filtering>true</filtering>

#

i see this

#

okay

#

so set it to false?

eternal oxide
#

no

#

true means filter any resources you include

#

like plugin.yml

charred blaze
#

how is that helping me?

eternal oxide
#

any values available to mvn will be available to your plugin.yml

#

you just have to insert the correct field

charred blaze
#

can i just insert this "${project.version}" in artifact?

eternal oxide
#

you add that to your plugin.yml and it will be replaced when your jar is built

charred blaze
#

its already added

#

i dont mean version in plugin.yml

#

i want version on jar output

#

like

#

plugin-version.jar

eternal oxide
#

oh you want it in the actual compiled source?

charred blaze
#

yeah

eternal oxide
#

yes you can set a final name in your pom

charred blaze
#

where do i add it

eternal oxide
#

<jar.finalName>${project.name}</jar.finalName> in your properties section

charred blaze
#

thx

eternal oxide
#

put whatever you want in there

charred blaze
#

not working

kind hatch
#

Whoa, you don't need that tag. You can just set a final name under the build section.

<build>
  <finalName>WhateverYouWantToNameIt<finalName>
</build>
charred blaze
#

maybe because i have artifact with custom name?

eternal oxide
#

yes

charred blaze
#

so just remove it?

eternal oxide
#

I have it under properties as I have everythgin that can be edited there

charred blaze
#

but if i delete artifact it change's compile directory

eternal oxide
#

?

#

you should not be specifying a path in the name

charred blaze
#

i know

#

why does it create articafts folder now ;-;

#

what am i doing wrong

eternal oxide
#

?paste pom

undone axleBOT
charred blaze
#

its no longer creating artifacts folder but still version is not included in the compile output

#

its just duels.jar

eternal oxide
#

add teh version placeholder in teh jar.finalName entry

kind hatch
#

That's cause you never specify a final build name under the build section.

charred blaze
#

it is there

eternal oxide
#

thats JUST the name

#

you don;t have a version in it

kind hatch
charred blaze
#

oh right

eternal oxide
#

properties tag is just fine

#

it keeps it all in teh same place for editable entries

kind hatch
#

True, but you still have to include that variable in the build section using the <finalName> tag.

eternal oxide
#

no you don't

charred blaze
#

<jar.finalName>${project.name}-${project.version}</jar.finalName>

#

its

#

still

#

duels.jar

eternal oxide
#

sec let me pull up a jar that actually uses a custom name

charred blaze
#

ok

eternal oxide
#

?paste

undone axleBOT
eternal oxide
charred blaze
#

ill try to insert just numbers instead of version placeholder

#

still

#

duels.jar

#

what im doing is clicking on build>build artifacts>build

#

if not with artifact

eternal oxide
#

this <jar.finalName>${project.name}-${project.version}</jar.finalName> builds GroupManager-3.0-SNAPSHOT.jar

charred blaze
#

how do i compile it?

eternal oxide
#

no

#

]artifacts is not maven

kind hatch
charred blaze
#

uhh

#

so how do i compile with maven?

#

is maven compile faster?

eternal oxide
#

right side of screen -> maven tab -> lifecycles -> package

charred blaze
#

you mean this?

kind hatch
# charred blaze so how do i compile with maven?

Use this button to run maven commands. clean package is what you'll need to run.
You can also setup a <defaultGoal> in your <build> section to use the automatic maven build tool built into maven so that it does that for you.

charred blaze
#

i cant see that button

#

im using new ui

kind hatch
#

Maven's on the right side.

charred blaze
#

where

kind hatch
eternal oxide
#

the M in teh right column

kind hatch
#

Click that button

charred blaze
#

got it

#

it started compiling

#

maybe

#

but where to

kind hatch
#

Yea, it's working

eternal oxide
#

now look in the target folder

kind hatch
#

^

lost matrix
#

I need some brainstorming support. I am currently writing a plugin which involves machines.

  • Machines need energy
  • Energy needs to be distributed via energy connections
  • Connections can be established between machines and poles (poles are technically also machines)
  • A machine can either consume or produce energy
  • Every machine has an internal energy storage for buffering

Now i have a few design problems i need to tackle:
Distributing energy:
Should every machine simply "send" or "draw" energy to/from every other machine
when they get ticked? Every machine would have to traverse the network like a graph then.
Or should the network be its own object which has decentralized, collective energy storage
and every machine simply interacts with only the network storage.
I can argue for both cases and there are more questions for each case.
Example concerns for the network object case:

  • When do networks get loaded and who keeps track of networks?
  • How do i handle two networks being connected together?

Any thoughts are appreciated

charred blaze
#

where is that target

kind hatch
#

Should be in the root of your project folder.

charred blaze
#

how do i change output

#

directory

eternal oxide
kind hatch
charred blaze
#

whats difference between this two

eternal oxide
#

If you only draw when there is buffer space machines which are full would nto tick

#

no work, no draw = no tick

charred blaze
#

<directory>C:\Users\PC\IdeaProjects\Duels\target</directory>

kind hatch
#

IIRC, that's the default directory anyways, but it should show up in the file browser on the left there.

lost matrix
# eternal oxide I'd just draw, IF there is a provider in range/connected and there is buffer spa...

So you would check the network like a graph every time a machine ticks and simply draw from
producers if they are in range. This makes sense but what about fairness? If i have 3 consumers
which use 100/s and 1 producer who produces 150/s then i want the energy to be evenly distributed
between them. If i now go ahead and let the first consumer draw then the second only gets 50 and the
last one never gets anything. I would prefer behavior where everyone gets 50/s

eternal oxide
#

only allow a machine to draw from another node until it's less than or equal to the providers energy store

#

so one machien can;t empty anothers cache

#

the network will balance it's energy

charred blaze
eternal oxide
#

and you only need to tick each machine and draw from connected nodes

kind hatch
eternal oxide
#

Directly connected, no need to seach the network for more power

charred blaze
#

oh

#

i remember i copied my directory's path

#

sorry for being dumb

lost matrix
#

Hm you brought an idea to me. I could never let anyone draw from others. I simply only let producers
push out their energy to connected consumers. So if a producer gets ticked and has 100 energy to give
he goes through the network and finds all consumers. Then he simply gives every consumer (which can take it)
100 / N energy.

charred blaze
#

wait does this sets project directory??

eternal oxide
#

You could do it that way, less work too

kind hatch
charred blaze
eternal oxide
#

so producers would be generators and poles

kind hatch
charred blaze
#

why does it compile two jars. original- and default?

lost matrix
#

Hm poles either need to be neutral, so just a node for iteration.
Or they need to be producers and consumers at the same time.

eternal oxide
#

yep

kind hatch
eternal oxide
#

if you are pushign then poles have to be both

lost matrix
#

But the latter would dilute the energy distribution because of the energy / N fairness.
So i would rather make them neutral.

kind hatch
charred blaze
#

why is it compiling two jars?

eternal oxide
#

neutral would only work if you also have machines pull

charred blaze
#

original-Duels-1.0-SNAPSHOT.jar

#

and

#

Duels-1.0-SNAPSHOT.jar

eternal oxide
#

second one is the one to use

charred blaze
#

whats the point

eternal oxide
#

original is before shading etc

charred blaze
#

how can i set it to atomatically delete?

eternal oxide
#

stop being finicky

lost matrix
#

Why would neutral only work if i have machines pulling energy?
If a producer pushes energy then he traverses the network like a graph,
puts all found consumers in a list and gives them energy. A pole would simply
be a Node in the network without consuming or producing energy.

eternal oxide
#

if you are tryign to auto deploy there are plugins for that

kind hatch
eternal oxide
#

ah ok I assumed poles would have an energy cache

lost matrix
#

Yeah would make sense...

charred blaze
#

meh okay

lost matrix
#

But only if they are consuming and producing. I think ill make them energy less tho.

eternal oxide
#

makes sense, less to tick

kind hatch
# charred blaze meh okay

Relax, it's a small directory and that's from one of my projects. Yours will likely be smaller in size.

lost matrix
#

I think i will actually create an energy policy for machines where they can either push, pull or do nothing.
This way the user can cycle through that. Producers will have push on default and Consumers will have no strategy on default.
This brings up a bunch of implementation problems but i think i can figure those out.

eternal oxide
#

So long as your pull policy only attempts to balance energy it should be fine

kind hatch
eternal oxide
#

else you have one machine pull from another, then the other machine ticks and it pulls back

lost matrix
#

If i would create an electrical system i would be here for weeks. Im studying electrical engineering and i would probably
try too hard to make this accurate. And it would be less fun to play.

kind hatch