#help-development

1 messages · Page 1830 of 1

mortal hare
#

it could be that Citizens interface is splitted from the JavaPlugin instance object

#

and instead implemented in separate class

#

but not sure

smoky finch
#

If I have a block and a block facing, how do I get 3x3 adjacent blocks based on that facing? (That means west and east - north and south give the same set of blocks)

olive lance
#

Is the command in the plugin.yml?

olive lance
#

Ah it’s not

proven river
#

oh

olive lance
#

There is a description but no command

proven river
#

I just realised too

#

lmao

trail lintel
#

I feel like I should share this as it has been a road of learning and it may help some people in the future. So item durability is handled by the base Material. If you didn't use a base material that can take damage like armor, or a tool when creating your custom item, you won't be able to damage it. This is a problem for me as I know some users are not going to want to use the resource pack, and seeing a pair of shears named "Ender Chest" just isn't right. So what I ended up doing was implementing a custom durability stat on the item with an integer value in the persistence data container. Then in the events I am interested in, I just update the lore of the item with its durability. This way the player can see durability of non-tool items when they hover over it. A little annoying it isn't displayed at a glance, but a good enough solution for me =]

#

I suppose if I wanted to be REALLY hardcore I could have like 20 different custom textures each with the health bar a little lower, and essentially use custom model data for each individual health tick....

#

that seems silly tho....

ocean marsh
#

Hey I have a question for premium plugins.
How do you put an external link to download the .jar

vale ember
#

can anyone help?? i can't figure out how to use citizens api

thick gust
#

Is there a way to spawn a barrier particle using 1.18.1 api?

golden turret
#

api?

#

maybe

#

maybe not

#

let me check

#

no

mighty sparrow
trail lintel
#

perhaps I shall once I get the kinks worked out a bit more =]

worldly ingot
#

player.spawnParticle(Particle.BLOCK_MARKER, location, 1, Material.BARRIER.createBlockData())

cold field
#

Hi guys quick question. How do I stop the spigot server from crashing when I'm debugging (Reason: Server not responding)

visual tide
#

theres mods for changing the client's timeout

#

iirc you cant do that in vanilla

visual tide
cold field
#

Ty

quaint mantle
#
public void chat(AsyncPlayerChatEvent e) {
        String UUID = e.getPlayer().getUniqueId().toString();
        if(UUID.equals(spaceID)) {
            Bukkit.getServer().getConsoleSender().sendMessage("§a[prefixes] [DEBUGGING] space talked lol");
            e.setCancelled(true);
            e.getPlayer().getServer().broadcastMessage("§o"+space+"§f: "+e.getMessage());
            
        }
        else if(UUID.equals(eliID)) {
            e.setCancelled(true);
            e.getPlayer().getServer().broadcastMessage("§o"+eli+"§f: "+e.getMessage());
        }
        else if(UUID.equals(cassID)) {
            e.setCancelled(true);
            e.getPlayer().getServer().broadcastMessage("§o"+cass+"§f: "+e.getMessage());
        }
        else if(UUID.equals(bsID)) {
            e.setCancelled(true);
            e.getPlayer().getServer().broadcastMessage("§o"+bs+"§f: "+e.getMessage());
        }
        else if(UUID.equals(flagID)) {
            e.setCancelled(true);
            e.getPlayer().getServer().broadcastMessage("§o"+flag+"§f: "+e.getMessage());
        }
        else {
            e.setCancelled(true);
            e.getPlayer().getServer().broadcastMessage("§o§7"+e.getPlayer().getName()+": "+e.getMessage());
        }
    }```
#

this doesnt work, no errors in console, chat is still default

late sonnet
vagrant edge
#

helo, i wanna respawn a player istantly, but i'm using the mojang-remapped NMS, so i don't have the .spigot.respawn();

How can i solve?

#

ping me if someone can solve, thx

quaint mantle
late sonnet
quaint mantle
#

im a dumbass

#

thanks bye

thick gust
#

Is it able to cancel the dismount for players so they keep being the passenger of an entity?

vagrant edge
late sonnet
vagrant edge
#

thx

#

rn i'm not using NMS, i wanna only respawn the player

late sonnet
#

but your are using the mojang maps not?
then not sure how not have the respawn method (i dont use the mapping for know)

vagrant edge
#

yessir

late sonnet
#

but another thing... you can try make this check in respawn event

worldly ingot
#

What do you mean you're using remapped NMS so you don't have spigot().respawn()?

#

NMS has nothing to do with whether or not you have access to API. If you're depending on Spigot, you will have those methods lol

late sonnet
#

this.. when i read i was thinking you try use CB directly >.<

worldly ingot
#

Yeah... you're in API. You have those methods.

#

Unless you were doing spigot.respawn(), which won't work. spigot() is a method, not a field

vagrant edge
late sonnet
#

and directly p.respawn() ?

hasty prawn
#

player.spigot().respawn() exists for me with 1.18.1 Mojang Maps

vagrant edge
vagrant edge
worldly ingot
#

It's existed since like 1.8

vagrant edge
#

.... i'm using mojang-remapped

hasty prawn
#

Pretty sure it existed for me when I was still using 1.17.1 too

fickle yacht
#

i need citizens but the github wont work

late sonnet
vagrant edge
hasty prawn
#

How are you getting that Player object

fickle yacht
#

do i need the api heybro?

vagrant edge
#

through the event

vagrant edge
fickle yacht
#

yes the github one

thick gust
#

What's the event for firework blowing up?

vagrant edge
thick gust
#

Thanks ^^

trail lintel
#

Hey guys, so this ones probably a no but I gotta ask. Is there a way to make my custom item repairable at the anvil, and to determine what kind of material is required? Or is it completely based on the Material of the base item

fickle yacht
#

do i need the api

hasty prawn
thick gust
hasty prawn
trail lintel
#

I was just looking into that =] I still can't seem to find an event that fires when a player actually clicks to accept the repair. PlayerMendEvent I thought I was close, but that was for the mending enchant

hasty prawn
vagrant edge
hasty prawn
#

Usually it makes the text red if it doesn't exist unless your theme changed that

vagrant edge
#

nop, its not the ide / theme:

hasty prawn
#

Or InventoryInteractEvent, one of the two

trail lintel
#

Ohhhhh wait I think I might get it. So I need to listen for PrepareAnvilEvent. Then detect when my custom item is put in there along with the item that I want to repair with, then I need to use the Inventory attached to that event to explicitly set the output slot to the repaired item? But PrepareAnvilEvent says it fires when items are put into slots, will it fire when the output is taken back?

#

Oh snap another separate just inventory interact to check for them grabbing it, that may work

late sonnet
urban lantern
#

Hello, i am trying to make my first plugin, but i cant get it to work. Spigot log says, i have to extend java plugin. But in code i have public class Main extends JavaPlugin

urban lantern
#

[16:59:59] [Server thread/ERROR]: Could not load 'plugins\logit.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: main class `jejt.survival.LOG_test.Main' does not extend JavaPlugin
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:415) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:231) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassCastException: class jejt.survival.LOG_test.Main
at java.lang.Class.asSubclass(Class.java:3924) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:74) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 8 more

tall dragon
#

well apperantly your class does not extend javaplugin then

#

show ur code too

urban lantern
#

wait, does every class have to extend java plugin?

tall dragon
#

no

#

only your main class

#

declared as such in your plugin.yml

urban lantern
#

my main class looks like this:

#

package jejt.survival.LOG_test;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
this.getCommand("logit").setExecutor(new CommandKit());
}

@Override
public void onDisable() {
    
}

}

tall dragon
#

you shoulnt use the name LOG_test

#

dont use uppercase

#

and dont use _

urban lantern
#

ok, i try, thank you

fleet imp
#

whats the yml reader class for spigot

tall dragon
#

i believe you are looking for YamlConfiguration

urban lantern
#

[19:25:30] [Server thread/WARN]: Legacy plugin logit v1.0 does not specify an api-version.
[19:25:30] [Server thread/ERROR]: Could not load 'plugins\logit.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: main class `jejt.survival.logit.Main' does not extend JavaPlugin
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:394) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:301) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:415) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:231) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3368-Spigot-8965a50-2a2caa7]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassCastException: class jejt.survival.logit.Main
at java.lang.Class.asSubclass(Class.java:3924) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:74) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 8 more

tall dragon
#

aifht show plugin.yml

urban lantern
#

main: jejt.survival.logit.Main
name: logit
version: 1.0
author: me
description:
commands:
logit:
description: something
usage: /logit
permission: logit.logit

tall dragon
#

check if it is a player

#

then cast it

sudden reef
#

Hello

#

I need help with scoreboards

#

Scoreboard objectives

white thicket
#

Hey, how can I play right click animation? Like when you right click grass block with shovel then it plays an animation, how can I play that animation again by sending packets?

tender shard
#

convert? you don't

tall dragon
#

@urban lantern could you send me your jar in dm, it might not be compiled right

tender shard
#

do you mean casting it?

sudden reef
#

/execute store success score output saveall run save-all

How can i get the value of player "saveall" in objective "output" with the api?

white thicket
#

event.getPlayer()?

fleet imp
#

ive made some plugins, but they were completely autonomous. I need config for this one

tall dragon
white thicket
#

Cast it to player

eternal oxide
white thicket
#

Player player = (Player) event.getEntity() if that is what you mean

sudden reef
#

nvm i think i got it

thick gust
#

What's the best way to identify an Inventory?

mighty sparrow
thick gust
#

Well I got multiple inventories which got similar content but different titles. I gotta code an item click for each of that inventory which got the same function. I need an id or something like that.

white thicket
# mighty sparrow wdym ?

I assume they are doing something where they need to check for a specific inventory but in an efficient way, not the usual name checking way

young knoll
#

Use the view returned from openInventory

mighty sparrow
#

mb my english bad this morning, maybe I misunderstood

trail lintel
#

hey guys, im trying to use Inventory.remove(ItemStack item), but it doesn't seem to be affecting the inventory. Do I need to do an inventory = *previous*? I'm having trouble finding the implementation of remove. Both Inventory and PlayerInventory are interfaces which extend Iterable.

thick gust
young knoll
#

It’s a unique identifier

thick gust
#

Got it.

vale ember
#

it's mutator method

thick gust
#

Aight I will keep use that, thanks Col!

sudden reef
#
  Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
  Objective obj = board.getObjective("output");
  assert obj != null;
  int num;
  Score save_all = obj.getScore("save-all");
  int num = save_all.getScore();
#

?

#

Like that right

trail lintel
#

Hmmm, it doesn't seem to be working. Let me check my logic

vale ember
#

maybe amounts don't match?

trail lintel
#

Ohhh I think you may be right

vale ember
#

you may use remove (Material)

fleet imp
tall dragon
trail lintel
#

@vale ember it was a logic issue 😉 I was comparing player inv to ender chest inv from a previous method

fleet imp
#

oh yea. yt has everything

thick gust
#

@young knoll Why does an inventory have many Viewers? On the inventoryclickevent I got the option to use event.getView() but on the Inventory i can only use .getViewers() 🤔

young knoll
#

Yes because multiple players can view an inventory

mighty sparrow
#

your friends can take the content of the chest while you have it open

#

same concept of the inventory here

thick gust
#

Yeah but how do I get the inventoryholder of the viewers?

royal vale
#

How to get craftbukkit and bukkit as maven dependencies for 1.18?

thick gust
#

Do I have to iterate through the viewers and check the uuid @mighty sparrow

lost matrix
#

Wait

#

For 1.18

royal vale
eternal oxide
royal vale
#

I need them for NMS

#

Like import net.minecraft.server.level.ChunkProviderServer;

eternal oxide
#

Spigot-api includes Bukkit, Spigot includes CraftBukkit

#

nms is neither Bukkit nor CraftBukkit

lost matrix
gleaming grove
lost matrix
gleaming grove
#

i guess any use of NMS is hacky

lost matrix
#

Meh sure

gleaming grove
#

hmm but why is that hacky, using NMS is like modding vanilia server, so we could assume that all minecraft mods for client are hacks

lost matrix
#

Just using NMS is not modding the server. It doesnt change any of the source code.
Its basically the same as using Spigot only that you dont have a fixed API layer between you and
the server.

thick gust
#

Does some1 know a way to get an itemstack displayname without the chatcolors?

quaint mantle
#

ChatColor.stripColors or smrh

lost matrix
young knoll
#

stripColors

fleet imp
#

i have a yml that i created and set to compile with the jar. How do I generate that file if the yml isn't already there

lost matrix
fleet imp
#

oh, thx

lost matrix
#

Its an instance method of JavaPlugin.
Where do you have access to an instance of your JavaPlugin class? -> in your onEnable() method
This means that you could call saveResource() in this context:

  @Override
  public void onEnable() {
    boolean replaceExisting = false;
    this.saveResource("cool-config.yml", replaceExisting);
  }

The 'this' keyword is optional here. It just emphasises that you are referring to a method of the instance you are currently in.

#

@fleet imp ^

royal vale
#

net.minecraft.world.entity.EntityInsentient doesn't exist, is there a replacement for this?

tardy delta
#

if i use an Player object for a player who is currently not on the server
does calling methods like .setHealth affects the player or not? because i donno where player data is saved

lost matrix
tardy delta
#

maybe some operations affect files while others need an active player

#

sound stupid but i'm just wondering

#

its also stupid tbh

lost matrix
tardy delta
#

right

#

still i see plugins doing it, i know its bad practice but yea

royal vale
fleet imp
tardy delta
#

yes

lost matrix
#

Best practice:
Only use Player objects in volatile scopes. Never have Player fields unless the encapsulating Object also only exists in volatile scopes.

young knoll
#

WeakReference

tardy delta
#

what's volatile again?

eternal oxide
#

a weak reference

lost matrix
mighty sparrow
#

no

#

?

hexed hatch
#

is running a Set#contains operation to check if a block is a certain material on every player interact event a good idea?

fleet imp
tardy delta
#

ah thats on class level

hexed hatch
lost matrix
quaint mantle
#

EnumSet is your friend

young knoll
#

Ehh

#

I may advise against that

tardy delta
#

no idea what your saying lets translate it

quaint mantle
#

Although material shouldnt be enum at all

young knoll
#

It won't be soon™️

tardy delta
#

ah i understand

vale ember
young knoll
#

Because it is big and ugly

hexed hatch
royal vale
vale ember
lost matrix
young knoll
hexed hatch
lost matrix
young knoll
#

Yes

quaint mantle
#

Plus minecraft becomes data driven, there's a possibility of custom materials in future

young knoll
#

MD said it will probably be fine, but

#

He has also said "To reduce the risk of breakage, please consider avoiding the use of switch statements and EnumSet over enums which implement 'Keyed'."

lost matrix
#

Pretty sure spigot will be forced to handle Material as an enum for at least another decade as players hold on old versions because of
selectOneOf("performance", "combat-system")

quaint mantle
#

fuck legacy support smh

young knoll
#

Nah MD plans to change it but also make it binary compatible

#

How? Idk

lost matrix
lost matrix
# fleet imp how do i set the resource path

If you dont use maven then just throw your yml file into your java project (src folder)
Thats what i meant by "resources path". Its just a file that was thrown into your jar.

tender shard
#

quick question: is 16 chars still the max length name for player names?

#

I mean the "official" limit to get an account, not whether I can avoid it serverside or sth

quaint mantle
#

yes

lost matrix
tender shard
#

thx

#

that's very handy in my case lol

lost matrix
#
  public boolean isValidMinecraftName(String name) {
    return name.matches("^\\w{3,16}$");
  }
fleet imp
lost matrix
quaint mantle
fleet imp
mellow gulch
#

if you setMetadata on a shulkerbox and then break the shulker box, is the metadata accessible through the shulker box itemstack's BlockStateMeta, or is the meta from the shulkerbox block lost?

lost matrix
lost matrix
mellow gulch
#

im just in general curious about how metadata and persistent data containers both behave and im having trouble finding information about how they are implemented.

tender shard
#

I have an ItemStack PLAYER_HEAD. How can I get the BlockData for that head?

lost matrix
mellow gulch
#

ok thanks

lost matrix
#

PDC is saved in the NBT String

manic furnace
#

When i create a thread in my plugin, how can i change the name? When i try it with .setName(), it doesn't change anything,

mellow gulch
tender shard
#

I am pretty sure that when placing or breaking a shulkerbox block, it will NOT keep the PDC data that was on the item and vice cersa

lost matrix
#

You would have to manually transfer them on BlockBreakEvent and BlockPlaceEvent

summer scroll
#

How can I create a bossbar with auto-refresh value? I want to put placeholder on that

tender shard
tender shard
summer scroll
#

I'm guessing by setting the title every x second?

tender shard
#

yes of course

summer scroll
#

ah okay

lost matrix
mellow gulch
lost matrix
quaint mantle
tender shard
quaint mantle
#

It has efficient compression and such

manic furnace
manic furnace
summer scroll
manic furnace
#

My code

Save saveFiles = new Save();
saveFiles.setName("TheName");
saveFiles.start();
lost matrix
tender shard
summer scroll
#

okay thanks

quaint mantle
lost matrix
tender shard
#

I wasn't the one who asked the question 🙂

lost matrix
#

Wait...

#

I have an ItemStack PLAYER_HEAD. How can I get the BlockData for that head?

tender shard
#

ooh

#

sorry

#

I totaly misread your answer

lost matrix
#

XD

tender shard
#

I do NOT want to place the head, I just need the blockdata that would be created when it would be placed

#

currently checking whether this works

            return Material.PLAYER_HEAD.createBlockData(blockData -> {
                ((Skull)blockData).setOwningPlayer(getOfflinePlayer(string));
            });

however that won't work for base64 textures :/

mortal hare
#

quick question

quaint mantle
#

Ha! You dont have player profile api on spigot!

mortal hare
#

if use default:

lost matrix
#
    BlockData groundData = Bukkit.createBlockData(Material.PLAYER_HEAD);
    BlockData wallData = Bukkit.createBlockData(Material.PLAYER_WALL_HEAD);
mortal hare
#

do i need break before default: case to stop the execution

tender shard
quaint mantle
#

You still cant set it for skulls

lost matrix
quaint mantle
tender shard
mortal hare
#

i need breaks

#

since i dont want pyramid of hell

#

im refactoring big chunk of code

#

thus why i need break

#

that way i can execute the same block of code for two different clauses without copy pasting

#

for each one of them

quaint mantle
#

case case1, case2 -> {}?

mortal hare
#

both cases have different code in them too

lost matrix
#

Or if-else blocks

young knoll
#

This is why the material enum is cursed

mortal hare
#

im just askin one simple question

#

does default: flow in

#

without break

#

from other cases

#
case BLABLA:
default: {
  System.out.println("Others and blabla executed it");
}
#

can i do something like this

#

will it flow in

lost matrix
mortal hare
#

so default: is not an exception

#

i can expect the same results as using simple case x:

#

for this particular situation

wide coyote
#

does the itemspawnevent triggers when a player drops an item

#

i dont think it will trigger but just to be sure

golden turret
#

heloo whats the probvlem here

mortal hare
lost matrix
mortal hare
#

eh fuck it

#

i found out the answer for myself

wide coyote
mortal hare
#

i dont need

lost matrix
#

XDDD

mortal hare
#

anything

wide coyote
#

ah

mortal hare
#

thats a simple example

terse raven
#

how do i create a world without making a folder for it

wide coyote
#

ye ye sorry

#

didnt read the code

#

lol

tender shard
wide coyote
tender shard
terse raven
#

to interact with

#

the world shouldnt be saved at all

tender shard
#
Bukkit.getWorld("world").setAutoSave(false);
#

can't you just use this?

fleet imp
#

I made this funny line of code and it doesn't like the saveResource:

if(!(Bukkit.getServer().getPluginManager().getPlugin("MineCord").getDataFolder().exists())) {
      plugin.getResource("config.yml").saveResource(Bukkit.getServer().getPluginManager().getPlugin("MineCord").getDataFolder());
}
terse raven
tender shard
terse raven
#

just not safe the changes

tender shard
modern sluice
#

what is an api and how does it work the definition in java termonology is confusing

fleet imp
terse raven
quaint mantle
#

a way to interact with a program via code

lost matrix
# mortal hare thats a simple example
  private static final Map<Character, Consumer<String>> someStuff = new HashMap<>() {{
    put('x', SandboxCore::doX);
    put('y', SandboxCore::doY);
  }};

  private static void doX(String value) {
    System.out.println("Im doing X: " + value);
  }

  private static void doY(String value) {
    System.out.println("Im doing Y: " + value);
  }

  private static void doSomethingElse(String value) {
    System.out.println("Something else happened: " + value);
  }

  private static void apply(char c) {
    someStuff.getOrDefault(c, SandboxCore::doSomethingElse).accept(String.valueOf(c));
  }

  public static void main(String[] args) {
    char x = 'x';
    char y = 'y';
    char z = 'z';
    apply(x);
    apply(y);
    apply(z);
  }

Outputs

Im doing X: x
Im doing Y: y
Something else happened: z

HashMaps scale O(1) while switch case scales O(n)
I always prevent switch statements and chained if statements wherever possible.

quaint mantle
#

switches are O(n)?

#

i thought that their advantage over if-else is O(1)

lost matrix
#

I never checked to be honest... i just assumed it as primitves dont have hash values...

#

huh

quaint mantle
#

umm FastUtil primitive maps exist for a reason

lost matrix
#

Yes looks like runtime complexity of switch-case is O(n)

young knoll
#

You might say

#

The switch is On

lost matrix
#

Its a bit weird because they have a fixed size

#

but still

#

Maybe the objects have abysmal equals implementations XD

tender shard
mighty sparrow
#

yo

#

made a custom block

#

but

#

the model is weird

lost matrix
tender shard
#

weird = best

mighty sparrow
#

x-ray mode poggers

lost matrix
#

Texture is not accessible

#

Also the model looks scuffed

tender shard
#

looks a bit like my bf

mighty sparrow
#

aaahahaha

#

how do I make it accessible then lol @lost matrix

#

for the texture on the model I know

#

but

#

on the grass block

#

avoid that

lost matrix
#

something something have a texture in your texture folder and refer to that texture in your model.json

calm star
#

to get an actionbar, should i use the api or sender.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(""));

lost matrix
calm star
#

Cannot be accessed from outside package do i have to implement it then

calm star
#

cant get it to work

lost matrix
calm star
#

1.17.1-R0.1-SNAPSHO

lost matrix
#

Show some code pls

calm star
#

sender.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent.fromLegacyText("hrll"));

noble lantern
#

what the...

#

Player#sendActionBar

calm star
#

wdym

#

im not using api

lost matrix
young knoll
#

It is

lost matrix
noble lantern
#

99% sure that spigot also has those methods to send action and titles to players?

young knoll
#

No

quaint mantle
#

no

lost matrix
#

Player.Spigot has

calm star
#

it fdoesnt work tho

#

Cannot resolve symbol 'fromLegacyText'

eternal oxide
#

wrong TextComponent import

calm star
#

no

#

import net.md_5.bungee.api.chat.TextComponent;

lost matrix
#

This is not valid java:
new TextComponent.fromLegacyText("hrll")

young knoll
#

Remove the new

calm star
#

Cannot resolve method 'sendMessage(net.md_5.bungee.api.ChatMessageType, net.md_5.bungee.api.chat.BaseComponent[])

mighty sparrow
#

pretty basic:

#

How to get coordinates of a player

young knoll
mighty sparrow
#

Thanks Coll

hexed hatch
# mighty sparrow

the textures are missing because they aren't pathed in the resource pack correctly

#

and the xray effect is due to cullfacing since you're using a solid block and not occupying space otherwise occupied with a full block

mighty sparrow
stable ice
#

bump

mighty sparrow
#

?

manic furnace
#

How can i use ansi-colercodes in my program? When i simply hang it behind the string and executeit in Powershell, it doesn't change but basically prints the color-code out too!

hexed hatch
#

my advice to you is to use the bottom slab variant

#

do something like this

mighty sparrow
#

trueeeeee

#

makes total sense

#

because the half we see it

hexed hatch
#

but even then, understand that the model cannot be rotated

#

so it would always be facing the same way

#

but you could make it face random directions

quaint mantle
#

you are doing your model in blockbench, right?

hexed hatch
#

He is

#

there might be a way to fix the cullfacing, but it's not something I'm really familiar with

#

but I still would advise making it the half slab instead since the hitbox will be less bizarre for such a small object

native gale
#

Please someone help, I wanna change something about ore distribution, but I don't understand how to make my own worldgen which changes only that and keeps the rest of 1.18 generation as it is

#

Are there any tutorials or something else I can read about that?

olive lance
#

Im sure there is some API methods now

tender shard
#

erm what's the name for consumers without any arguments again?

#

like I wanna pass a void function with no parameters as parameter into another function

#

I need something like this:

public class MyClass {
  private Consumer consumer;

  public MyClass(Consumer consumer) {
    this.consumer = consumer;
  }
}

and then do something like this

MyClass thing = new MyClass(() -> {
  // do stuff
});
#

am I stupid or is that just a runnable?

quaint mantle
tender shard
#

thx

#

I had a stupid moment

quaint mantle
tender shard
#

Looks perfect. That will DEFINITELY compile and run fine without problems

young knoll
#

The red means it's working

opal juniper
#

red = running

tender shard
#

imagine being red/green colorblind

sterile token
#

A question if you have a running a jar on the JVM and its obfudcated you can get it source code vía ASM (assamble) library right?

tender shard
quaint mantle
#

umm

tender shard
#

there's some deobfuscated for some obfuscators

#

although they never truly restore the original code

sterile token
#

Yes I know

#

But i dont know why no one recommend obfuscation when some jar have never been de obfudcated up to know

tender shard
#

I use allatori on all my paid plugins^^

#

even on my library in free plugins to make it a bit smaller and faster, though with different settings of course

sterile token
#

Thanks for recomendación

tender shard
#

but allatori is 290$

sterile token
#

At its paíd?

tender shard
#

yes

#

there's a demo version of it though

sterile token
#

I thought I seen it public on github

quaint mantle
#

Smh just dont obfuscate your plugins

tender shard
#

you must not use it for commercal stuff though

quaint mantle
#

Thst doesnt really help

tender shard
sterile token
#

I know it doesnt help but what about for selling thinks

#

👀

tender shard
#

of course people could deobfuscate it, but they simply don't take the time and leak another plugin instead lol

gleaming grove
#

hi i'm currently working on my GUI, so i displayed all Materials with it. However some Material are not displayed because of lack of ItemMeta or something. How what condition use to get only Material that can be display in Inventory?

quaint mantle
#

Same. If people want to crack your plugin, they will

tender shard
#

yes, but until now people just didn't after I started using allatori

young knoll
#

Anything with isItem == false should not be in an inventory

golden turret
#

i forgot an english word. the pronunciation is something like "cooldown". help!

quaint mantle
#

What

sterile token
#

Im really stress btw. I have been looking for a java socket framework. And people only recommend Netty and Apache Mina. When they are too big for building simply things

gleaming grove
#

meh does not work :,

tender shard
#

what's the item that's not showing?

young knoll
#

Looks like air

gleaming grove
#

i guess air

tender shard
#

yeah true

young knoll
#

You can exclude that too with isAir

gleaming grove
#

but there are still 44 pages

#

so it does not affect any Material

golden turret
#

maybe

gleaming grove
#

pagination is done corretly

tender shard
#

anyone got a quick regex for me to check whether a string is 32 numbers? ^^

golden turret
#

your page calc is not correct?

sterile token
#

Simply dont let put air item on your inv

tender shard
#

\d is digits

#

but what is "exactly 32"? 😄

gleaming grove
#

i have idea

#

maybe i firstly filter the list and then do the button mapping

young knoll
#

\d{32}

golden turret
#

(.+){32}

tender shard
golden turret
#

define pushing

granite burrow
#

How can I disable players colliding with each other, I tried to do this when they joined:
e.getPlayer().setCollidable(false);
But it didnt work

tender shard
#

player.spigot().setCollidesWithEntities(false)

sterile token
#

What that

tender shard
#

I think

sterile token
#

Collides?

mighty sparrow
#

What is inventory extraContents ?

tender shard
#

left hand

golden turret
#

deprecated

mighty sparrow
#

Alright thx

tender shard
golden turret
#

the method you sent

tender shard
#

lemme check

sterile token
#

If you are using eclipse and tells you deprecsted its because its a yeat

tender shard
sterile token
#

I have never liked using eclipse

tender shard
#

yeah it's moved to LivingEntity

golden turret
sterile token
#

Mfnalex

#

So if I want to modify a spigot let say I should use Spigot Build Tools?

olive lance
#

i just tested that allatori demo and idek what my own plugin does now

tender shard
tender shard
#

I can help you with allatori if you like

granite burrow
#

im on 1.18 btw

olive lance
#

idk havent tested it i dont have a server setup rn

tender shard
#

important: you must not rename your main class

olive lance
#

but its some weird stuff it did

tender shard
#

also not all methods you are overriding

olive lance
#

Like it has to be called Main?

sterile token
#

Yes because i will tríed to implemente a server-client and viceversa, messaging system without players

opal juniper
tender shard
opal juniper
#

u can rename it?

tender shard
olive lance
#

When would i have renamed it i guess is what im saying

tender shard
#

when using allatori of course lol

quasi patrol
#

event.getHook().setHookedEntity(null); isn't working for me, and there is no errors. .-.

sterile token
#

mfnalex can I then dm u?

olive lance
tender shard
sterile token
#

I wanna talk to you about obfuscator if you have no problems

olive lance
#

It just put a random 'this;' in

tender shard
#

sure, feel free to dm

olive lance
#

what does that even do lmao

tender shard
olive lance
#

and it used to just be getCommand now its "\027\030\022\r\030\026\037".getCommand

#

whatever that is

olive lance
#

No idea how that works

#

cause there was no string there before?

tender shard
#

don't worry about what it does

#

it's very complicated

#

^^

#

it can even rename your variables to use keywords

olive lance
#

actually hold up

tender shard
#

e.g.

#
private static final int if = 3;
olive lance
#

woah

tender shard
#

also for methods

#
public static void void(String else) {
  ...
}```
olive lance
#

tell me how this getCommand("faction").setExecutor(new FCommand(this)); becomes this "\027\030\022\r\030\026\037".getCommand(NotInFaction.ALLATORIxDEMO((String)this)).setExecutor(new FCommand(this)); saveDefaultConfig();

NotInFaction is an expection i made that appears no where in that class lol

tender shard
#

it moves certain stuff to other classes

olive lance
#

oh ok

tender shard
#

the ALLATORIxDEMO method is probably the string decryptoin method

mighty sparrow
#

How to set armor contents ?

#

when my inventory instance is of inventorytype player

olive lance
mighty sparrow
#

Thanks @tender shard

proud basin
#

To make a core would you need to make a separate plugin for bungee so it can work with another plugin from another server?

gleaming grove
tender shard
#

sorry wrong reply

#

@olive lance

#

^

mighty sparrow
#

np

olive lance
#

ohh ok

tender shard
#

I suggest ReCaf, it's one of the best decompiler GUIs imho

olive lance
#

bet

tender shard
#

I don't think you're allowed to share CMI's byte code 😛

olive lance
#

Lmao

#

it actually ended up making my jar file bigger. still a chance it runs better?

tough field
#

is it?

#

i dont think so

tender shard
#

here's settings to just make it smaller and faster:

young knoll
#

Leaking bytecode is still leaking

olive lance
#

Those would be helpful

tender shard
olive lance
#

Cause im open source just wanna make it fast as possible

tender shard
#

well it won't change much tbh

#

but it can't hurt either

olive lance
#

yea

young knoll
#

Anyone here good with streams?

olive lance
#

LFG

#

saved a kb

young knoll
#

I'm looking to check if a list of an abstract class contains at least 1 of a certain subclass, using a stream

olive lance
#

It still did that string encryption thing tho with the exception class

tender shard
olive lance
#

yea my plugin is only 55kb right now so i wasnt expecting much

tender shard
olive lance
#

hm

#

Let me see

#

it did make it a different size

gleaming grove
#

Somebody know if we have class A with 300 line of code, and class B 150 code lines that inherits class C with 150 code lines.
After compilation to .class files both classes A and B will have 300 lines of code inside?

olive lance
#

Yeah it definitely used it and had the string encryption set to disable. maybe thats not considered that? idk why it wouldnt tho

#

hold up lemme try 1 thing

#

restart my decompiler

mighty sparrow
olive lance
#

Ok it did work

tender shard
mighty sparrow
#

alright

proud basin
#

How do yall name your projects if its two words do you do TestWater or Test Water

tender shard
#

ugh

#

never spaces

#

btw how would you name this method:

    public static UUID getUuidFromString(final @NonNull String string) {
        if(string.length()==36) return UUID.fromString(string);
        if(string.length()==32) return fromStringWithoutDashes(string);
        throw new IllegalArgumentException("Not a valid UUID.");
    }

getUuidFromString
or
getUUIDFromString
?

proud basin
#

UUID

sullen marlin
#

UUID is more correct, even if ugly sometimes

#

but name it whatever you want tbh

tender shard
#

yeah I know it's just for my OCD

#

aight I'll go for UUID

#

sometimes intellij is a bit stupid

#

it doesnt even suggest to create that method lol

proud basin
#

the only reason why you would do UUID is because its a acronym

tender shard
#

String#replace and String#replaceAll really have misleading names

#

they should be called "replace" and "replaceRegex" or sth

eternal oxide
#

kinda. replaceAll will accept a non regex

mystic sky
tender shard
#

yes

#

visual studio is the worst

mystic sky
#

vsc isn't even a ide

tender shard
#

and eclipse's maven integration sucks

mystic sky
#

but it's fine for py + js

tender shard
#

I know a few people using VSC for java and

#

I really wonder

#

why do they make their own life so hard

mystic sky
#

i use it sometimes when my Intellij idea bugs

tender shard
#

getting IntelliJ Ultimate was the best decision I ever made

mystic sky
tender shard
#

I got a for free

mystic sky
#

bruh

tender shard
#

somehow even law students get coding software for free at my university

mystic sky
#

My school doesn't have the E-Mail registered.

#

: (

tender shard
#

lmao meanwhile I can make as many email aliases as I want and get free stuff again and again XD

proud basin
#

what's the command line again to shade with maven?

tender shard
eternal oxide
#

You only need an OS project and you can get it for free

tender shard
#

if you have declared it in your pom

tender shard
#

oh open source

#

really?

eternal oxide
#

open source

tender shard
#

how?

sullen marlin
#

whats wrong with the community edition

tender shard
#

well I got it anyway, just curious

sullen marlin
#

or netbeans :>

tender shard
#

but why not use Ultimate if you get it for free 🙂

#

it has some MySQL features added, I dont know what else

tender shard
#

md_5 what do you use?

mystic sky
young knoll
#

Md uses netbeans

eternal oxide
#

a profiler I belive

mystic sky
tender shard
#

yeah

#

probably

#

or emacs

#

that would be legendary

#

sometimes I force myself to use vim but emacs? that's a whole nother level

mystic sky
#

well he's a god

#

mamadisimo I got a lot of money by him

tender shard
#

yeah I can finally pay my rent too lmao

mystic sky
#

Yeah*

#

Like im working on a lot of big networks by that ;: )

tender shard
#

three AngelChest's per day and I got enough money for that day lol

mystic sky
tender shard
#

which one?

mystic sky
tender shard
#

I'm still using waterfall but seems like I gotta switch to Velocity soon

mystic sky
#

I thing that there's some type of rule of that

tender shard
#

I read the rules 20 times, I don't think there's a rule about that 😛

oblique wigeon
#

When creating multiple config/data files, should i create a class for every one of them? or should I create instances of a class and reload/edit them by name

#

(im followed a codedred tutorial and was wondering how to continue further)

tender shard
#

never heard of that, I'll look it up 😄

tender shard
mystic sky
#

I won't spam here

tender shard
#

I think it's because paper said they'll drop bungee / waterfall

mystic sky
tender shard
#

slowly remembers Heartbleed...

oblique wigeon
tender shard
#

fun fact: the Heartbleed bug was introduced into OpenSSL by a student from my town's university lmao

mystic sky
#

XD

tender shard
#

I'd already be happy if bungee API would include YamlCOnfiguration lol

young knoll
#

The API is improved constantly

#

Removing old things, less so

mystic sky
#

my bad* Modern proxy dependencies

sullen marlin
#

example?

#

you want more API but you also want less API

#

🤔

mystic sky
#

Well, velocity guys doesn't need to use Firewall or even antibots to avoid this.

tender shard
mystic sky
#

Well, u improved in some way the proxy applying the limit of bytes on the protocol, but are some other type of layer attacks that doesn't follow it.

sullen marlin
#

have you opened a bug report

mystic sky
#

Well i allways thinked that u just didn't want to fix it or something like that

sullen marlin
#

yes I purposely make my software as bad as possible and hate improving it

young knoll
#

Me too

mystic sky
#

XD i don't know i thing that u saw that are 400 bungee forks not because bungeecord fixes them.

proud basin
mystic sky
tender shard
proud basin
#

that's because it is

tender shard
#

what exactly is your question?

#

where you can find the finished .jar, outside of your local repo? o0

mystic sky
sullen marlin
#

because you see people that fork bungee, add absolute garbage that does nothing, and then claim its an improvement

tender shard
#

what "bug" are you even talking about? 😄

sullen marlin
#

without understanding what their code does or why it sucks

#

snake oil central

mystic sky
tender shard
#

packet api when?

young knoll
#

ProtocolLib

tender shard
#

nah ProtocolLib sucks

mystic sky
tender shard
sullen marlin
#

answer the question instead?

#

what 'bug' ?

mystic sky
#

Well is not really a bug as i said?

tender shard
sullen marlin
#

you havent said what it is at all

tender shard
#

I only recently made up my first proxy server and just instantly used waterfall without any proper reason

proud basin
#

well im trying to update it so I can use the new buildtool

tender shard
#

?buildtools

#

?bt

undone axleBOT
proud basin
#

I do have it

#

smh

mystic sky
thick gust
#

ProtocolLib is bad

mystic sky
#

and hard

tender shard
tender shard
thick gust
#

😂

tender shard
#

lol

tacit drift
young knoll
#

Tbf I mostly only use it for listeners

tender shard
#

I don't think so.
packet.setDoubles(...)
with NMS I just use the proper constructor^^

#

so I can see in my IDE directly what it needs instead of looking up everything on some website

#

also I can use the proper packet names instead of Packet.PLAY.OUT.WHATEVER

tender shard
mystic sky
thick gust
#
if(ProtocolLib.isBad()) {
  System.out.println("Change your library, otherwise your server will be detonated in 3... 2... 1...");
}
merry sky
tender shard
tender shard
thick gust
#

Aight thx for your help

tender shard
#
assert ProtocolLib.isBad(); // will always be true
quaint mantle
#

K

#

im gonna post my issue now

#

because most issues rn seem solved

#

having some config weird things happening, i have the default config as a resource

it loaded right, and i set the config once and restarted.. and the config reloaded, and the values were displayed correctly

now, i'm trying to reload the config in-game, or on console (via-command) and it does not reload the new values... not exactly sure why either, because i dont have a reload config on my onEnable()

#

and like heres the config

quaint mantle
thick gust
#

that's eclipse

tender shard
quaint mantle
thick gust
#

Error 404: No IntelliJ IDE found.

quaint mantle
#

that plugin works on reload

tender shard
#
  1. why don't you use the inbuilt reloadConfig() method?
quaint mantle
quaint mantle
tender shard
quaint mantle
#

¯_(ツ)_/¯

#

im bad with configs

tender shard
#

also your file is called config.yml, you can use bukkit's javaplugin's builtin getConfig()

quaint mantle
#

this one?

tender shard
#

you only need to create your own FileConfiguration / YamlConfiguration objects if you need additional config files NOT called config.yml

quaint mantle
tender shard
#

must be leftover from 2012 code then 😄

quaint mantle
#

😭

tender shard
#

I'd suggest to get rid of all your custom config code and use the builtin methods

#

they are made to make your life easier 🙂

quaint mantle
#

thats my only custom config method

#

everything else (making the config) is built in

tender shard
#

how do you access your config?

quaint mantle
#

file?

tender shard
#

by doing yourPlugin.getConfig()

quaint mantle
#

oh yeah

tender shard
#

or by using yourPlugin.fc ?

#

yeah but you only load the config into the fc field

quaint mantle
#

built in

#

BRUH

tender shard
#

yeah but the code you sent does not reload JavaPlugin's getConfig() but only your custom fc config

quaint mantle
#

reloadConfig() worked now

#

technology moment

#

tysm

#

will return bye <3

tender shard
#

np 😄

mystic sky
#

@sullen marlin Why you use slf4j instead log4j?

#

Its just a question

sullen marlin
#

I dont use either

#

I use java.util.log

mystic sky
#

Then it's useless?

#

oh

tender shard
mellow gulch
#

is there any good way to get the shulker box item that spawned as a result of a block getting broken by a piston?
i already have a bad way of doing it, but im searching for a better option.

mighty sparrow
#

log4j is my dude

young knoll
#

BlockDropItemsEvent?

mellow gulch
# tender shard what's your bad way?

store the location of where the block was (method of storing doesn't matter) then in ItemSpawnEvent get the spawn location and check if the locations match

mystic sky
mellow gulch
thick gust
#

what's the updated method for sendBlockChange?

young knoll
#

Ah by a piston

#

Hm

young knoll
tender shard
thick gust
#

Yeah but it's deprecated sadly

young knoll
#

No

#

One of them is deprecated

tender shard
#

No it's not

young knoll
#

The other one is not

thick gust
#

Duhh

tender shard
#

Player#sendBlockChange(Location,BlockData)

#
player.sendBlockChange(someLocation, Bukkit.createBlockData(Material.STONE));
thick gust
#

Oh wow

young knoll
#

Isn't there also Material.X.getDefaultData or something

tender shard
thick gust
#

it is

#

But i had to hard code it

#

It's a cage with a 3x3 room with invisible barriers

#

I am dumb at math

#

So ...

tender shard
#

I understand 😄

thick gust
#

I decided to not calculate it lol

#

xD

tender shard
#

yeah I was an A student in school in math and a year later, I forgot everything

#

anyway, just use Bukkit.createBlockData(Material) 🙂

thick gust
#

Already done, sir.

#

isOnGround() is also deprecated ffs

young knoll
#

Only for players, because it can be spoofed

tender shard
#

LivingEntity#isOnGround

#

oh no

thick gust
#

So should I cast my player to a living entity?

#

Uh

tender shard
#

just Entity.isOnGround

#

((Entity)player).isOnGround()

thick gust
#

thx

tender shard
#

reason for deprecation:

#

This value is controlled only by the client and is therefore unreliable and vulnerable to spoofing and/or desync depending on the context/time which it is accessed

#

as @young knoll already said

#

so yeah, better use Entity#isOnGround

#

although it's a bit strange that the subclass declares a non-deprecated method that it overrides as deprecated lol

#

Quick Question

#

even when casting to Entity, doesn't it still call the isOnGround method from Player?

sullen marlin
#

yes

thick gust
#

Lol

#

Weird methods spigot weird methods 😄

young knoll
#

I just made my own method that involves subtracting a small amount from the players Y value

#

And checking the block there

sullen marlin
#

the method sucks, but anticheat developers are the worst

#

thats the only reason it exists

tender shard
#

maybe another method could be added to get the actual Entity's isOnGround?

sullen marlin
#

that is the entity's isOnGround

#

vanilla lets the client set it for who knows why

#

thats why things like nofall exist

young knoll
#

Oh mojang

tender shard
#

oh okay

#

strange lol

young knoll
#

Movement really should be server side

tender shard
#

I still remember when I started MC, multiplayer and singleplayer had different code

#

then some update came and single player was just local multiplayer from then on

#

WOW intellij really is stupid sometimes

#

I removed the "player" parameter from new CustomBlock

#

and now intellij says "can't find block.getState()" instead of telling me to remove "player" from "new CustomBlock"

thick gust
#

is there a shortcut in intellij to comment code?

tender shard
#

Ctrl+/

#

and Ctrl+Shift+/

thick gust
#

uh does not work for me?

tender shard
#

what keyboard?

#

german? US? ... ?

#

try the / from your numpad

thick gust
#

normal qwertz (german)

#

CTRL, SHIFT, 7

tender shard
#

yeah me too

#

use / from your numpad

#

it will work

#

Ctrl+ Numpad /

#

the one above the 8 ^^

thick gust
#

got it lol

#

I am just not used to numpad. I prefer the other numbers.

tender shard
#

yeah you could probably change it to Ctrl+Shift+7

thick gust
#

Ctrl+7 is more comfy i think

tender shard
#

but then toggle block comment would not work so youd need to set that to Ctrl+Shift+Alt+7 or sth

#

yeah makes sense

#

lol

thick gust
#

still having problems with comparing inventories.

#

I'm just not good in comparing stuff i guess XD

tender shard
#

inventories will be == if they are the same

#

if only their content is the same - you'll have to loop over them I think

#

yeah, Inventories are just Iterable<ItemStack>, it doesnt have their own equals method

#

so equals() is the same as == for inventories

quaint mantle
#

still, use == for reference and .equals for comparison for convention 😼

tender shard
#

yeah but equals in inventories is the same

quaint mantle
#

👍🏿

tender shard
#

so you need write your own method if you just wanna compare the contents 🙂

thick gust
#

I think i will develop my entire plugin once again sometime

#

Refactoring takes too long lol

#

However refactoring this was not useless because I can write my new version of it even easier now.

waxen plinth
#

Yea sometimes you just gotta scrap everything and rewrite

thick gust
#

It's annoying but a must-have if your plugin doesn't take care of name conventions, etc.

#

I am shocked how much my coding style has changed over years...

waxen plinth
#

Yeah

tender shard
waxen plinth
#

I mean

#

I don't rewrite entire projects that are too large

#

I will often rip out and replace functions or classes though

thick gust
#

Think I will open twice IntelliJ and just recreate it by copy pasting and like comparing what I could do better.

#

I won't copy paste everything dw lol

#

Just some pieces

#

Step by step and then I improve each little part

tender shard
#

I normally refactor everything with git

young knoll
#

I have rewritten custom enchantments so many times

tender shard
#

so I can always go back

waxen plinth
young knoll
#

I think this should be the final one

#

It's data driven

thick gust
#

fk how do I create a random again between 2 numbers?

#

wasn't it random.nextInt(high + low) + high;

#

Or something like that

young knoll
#

If you are using the standard random

#

Random.nextInt(high - low) + low

tender shard
#
package de.jeff_media.jefflib;

import lombok.experimental.UtilityClass;

/**
 * Random number related methods
 */
@UtilityClass
public class RandomUtils {

    /**
     * Returns true with a specific chance, otherwise false, with a range between 0 (always false) and 1 (always true)
     *
     * @param chance chance to return true (0-1)
     * @return true when the chance succeeds, otherwise false
     */
    public static boolean chance(final double chance) {
        return getDouble(0, 1) <= chance;
    }

    /**
     * Returns true with a specific chance, otherwise false, with a range between 0 (always false) and 100 (always true)
     *
     * @param chance chance to return true (0-100)
     * @return true when the chance succeeds, otherwise false
     */
    public static boolean chance100(final double chance) {
        return getDouble(0, 100) <= chance;
    }

    /**
     * Returns a double between {@param min} (inclusive) and {@param max} (exclusive)
     *
     * @param min min
     * @param max max (exclusive)
     * @return double between {@param min} (inclusive) and {@param max} (exclusive)
     */
    public static double getDouble(final double min, final double max) {
        return JeffLib.getThreadLocalRandom().nextDouble(min, max);
    }

    /**
     * Returns an int between {@param min} (inclusive) and {@param max} (exclusive)
     *
     * @param min min
     * @param max max (exclusive)
     * @return int between {@param min} (inclusive) and {@param max} (exclusive)
     */
    public static int getInt(final int min, final int max) {
        return JeffLib.getRandom().nextInt(max - min) + min;
    }
}

#

that's my RandomUtils class

thick gust
#

youh

#

I don't need an entire class

tender shard
#

just copy paste what you need lol

thick gust
waxen plinth
young knoll
#

Currently making some fairly big changes, but it's on my github

waxen plinth
#

Ah

#

So it's all done in config

young knoll
#

Yes