#development

1 messages · Page 9 of 1

lyric gyro
#

🌩️
🧠

#

so return is pretty much

dusky harness
#

more like Alice asks Bob for a random number
Bob is randomNumber

lyric gyro
#

dkim

#

it's an example

dusky harness
#

Alice is foo

dusky harness
#

but im just matching it with this example

lyric gyro
#

it's called an analogy

dusky harness
#

:))

lyric gyro
#

why you calling alice a fool

#

what did she do to you

#

she's a thief and stole from me

dusky harness
#

we cannot trust her for random numbers anymore

lyric gyro
#

my niece is named alice

#

she's a spoiled brat

#

so

#

return is pretty much like

#

i understand it ig

#

i just dont know how to put it

#

lol

dusky harness
#

each method can return 1 value
so, once you return, java won't let you run any more code

#

even if the return type is void, it still won't let you run any more code

#

if it's not void however, that return value can be used for Alice

#

(if it's void Alice gets nothing :p)

thorny pollen
#

am I stupid or do they just make it hard for you to download a .jar

lyric gyro
#

I've got no idea

#

They have a support server

thorny pollen
#

I just opened it in intellij and built it that way

lyric gyro
#

return is returning the value of 36 to variable number

dusky harness
#

they have dev builds

lyric gyro
#

since they are equal the same

thorny pollen
#

OHHH

lyric gyro
#

Oxygen Hydrogen Hydrogen Hydrogen

thorny pollen
# dusky harness

I didnt do it just incase bc of the "Your Connection is not private" classic no certification

lyric gyro
#

OH³

thorny pollen
#

oh well

#

there it is!

#

should I go exotic with pufferfish instead of paper for my server jar 😈

lyric gyro
#

another api

#

that i never heard of

thorny pollen
#

ive just seen it used it the past, fork of paper

lyric gyro
#

is there a spoon of paper

#

Alice asks Bob to do something and get back with a number to her when he is done, sometimes he will finish sooner and get back to her when he is done sooner and has nothing else to do (returns earlier), some other times he will take a bit longer while he does some additional things, but in the end gets back to Alice as well (doesn't return earlier and continues execution of some task)

int getNumberFromBob() {
  if (bobIsLazy) {
    return 0;
  }

  // do something useful
  return 2;
}
#

usually the returned value depends on what is being done inside the useful part

#

but uh i'm lazy

#

i'll try to understand this tomorrow

#

get some sleep

#

and see if my brain is normal

thorny pollen
#

or a knife

lyric gyro
dark garnet
#

how can i make a countdown display using xp bar? ik about player#setExp and player#setLevel, but player#setExp only allows values 0-1 and i have countdowns that range from 3 seconds to 10 seconds (so i cant just divide by 10 and call it a day). so how do i go about doing this so that it could work with any number?

grim oasis
#

divide by whatever your countdown is

dark garnet
#

oh true Facepalm

keen panther
#

hey can anyone help me with command deployment?

stuck canopy
#

I wanna add Enchantments names and their level in the ItemStack's lore. 3 enchantments in a line like in hypixel skyblock

#

any suggestions on how should I do it?

proud pebble
#

for loop over the enchantments that are on the weapon, append them to the stringbuilder, check if (i+1 % 3)
then add the stringbuilder as a string to the list<String> and clear the string builder and itll repeat till its done

#

ofcourse append the commas as well

lyric gyro
#

@lyric gyro I finally understood this

#

sorry for the ping

#

told you it was my brain

#

not that I don't know the code

#

and I finally understood how return works

#

I just needed a break

stuck canopy
stuck canopy
#

so I just searched it up and Its not quite understandable. Is there any way you can provide an example on how can I do that

merry knoll
#

you can use string for it as well

#

appending to a string is not performant

#

therefore stringbuilder is a thing

icy shadow
#

appending fundamentally is fine, it's when you do it in a loop that becomes problematic

merry knoll
#

which is extremely common

icy shadow
#

true

merry knoll
#

actually is the compiler smart enough to differentiate between

#

a = a + b
a = a +c

#

and the loop variant?

hoary scarab
#
ItemStack i;
StringBuilder s = new StringBuilder();
# String s = "";
int c = 0;

List<String> l = new ArrayList<>();

i.getEchantments().forEach(e -> {
    c++;
    s.append(e.getName()+": "+e.getLevel()+(c < 3 ? "," : ""));
    # s += e.getName()+": "+e.getLevel()+(c < 3 ? "," : "");
    if(c == 3) {
        c = 0;
        l.add(s.toString());
        # l.add(s);
        s.clear();
        # s = "";
    }        
});
high edge
#

Imagine if you could use more than 1 letter to name a variable

hoary scarab
robust flower
#

@dusky harness

Believe it or not, I have just finished a plugin that does exactly that lol, I had to deal with Clipboard copying, fetching location, storing block offsets, rotating the clipboard content, everything you just described lmao, literally ask me anything and I'll provide you a solution for that if I already have it done in my plugin

The plugin I've made basically loads structures that the user provide (from a schematic file), finds them in the world (using signs as anchors for performance reasons), and do stuff with them

icy shadow
# merry knoll a = a + b a = a +c

it depends, i know that the compiler has used some clever stuff for string concatenation since java 9 but im not sure if it's smart enough to transform things in loops

frigid pollen
proud pebble
wintry grove
#

Hello again, time for regex questions

#

so I have this regex:
([[ꑡ][ꐇ][ꐆ][ꐅ][ꐄ]]) ([a-zA-Z0-9]+): ([a-zA-Z 0-9\W]+)

#

the first part and the others are just testing

#

what I have problems with is the first part

#

this regex was made to separate in three parts this string type:
ꑡ StarL0stGaming: I'm an idiot

#

my problem here

#

is that I need to parse different ranks

#

which is the first part

#

and those ranks have 3 unicode characters each

icy shadow
#

what is your actual question

wintry grove
#

getting to it

icy shadow
#

ok

wintry grove
#

forgot to do it in a single message lmao

icy shadow
#

ill get the popcorn

#

im super hyped

wintry grove
#

my problem here is that I'm not able to make the regex parse those 3 characters

#

bc of how they are encapsulated

icy shadow
#

have you considered |

wintry grove
#

it tries to only parse one of then

wintry grove
#

this is my test btw

#

it only parses the last character

icy shadow
#

ahh right right

#

well

#

thats because your syntax is extremely wrong

wintry grove
#

fair

#

I'm still new to regexes

icy shadow
#

[...] is a character set, i.e. it matches any of the characters in the set once

#

what you probably want is ((abc)|(d)|(e))

broken elbow
icy shadow
#

yeah

wintry grove
#

yeah just checked

#

let me try

icy shadow
broken elbow
broken elbow
icy shadow
#

dunno what you're talking about

wintry grove
#

lmao

#

I did see it

icy shadow
#

see what?

wintry grove
#

nothing

icy shadow
#

thats right

wintry grove
#

it does work

#

thanks

#

btw

#

if I use that on a String#split() will it work

#

or do I need to do some fancy shit?

icy shadow
#

uhhhh

broken elbow
icy shadow
#

it won't split it into all of the components if that's what you're expecting

wintry grove
#

what I need for it to do is to split into three strings

#

based on the groups

#

I suppose it wont work right

icy shadow
#

#split certainly wont

#

what you want is to create a Matcher and then use Matcher#groups

#

i think

#

d;jdk Matcher#groups

uneven lanternBOT
#
public Matcher reset()```
Description:

Resets this matcher.

Resetting a matcher discards all of its explicit state information and sets its append position to zero. The matcher's region is set to the default region, which is its entire character sequence. The anchoring and transparency of this matcher's region boundaries are unaffected.

Returns:

This matcher

broken elbow
#

yes. you are right bm

wintry grove
#

huh

icy shadow
#

docdex smells

wintry grove
#

makes sense

icy shadow
#

group(0..groupCount())

#

close enough

#

yes blitz you're right i'm right

#

i made that syntax up btw

wintry grove
#

and how do you exactly make a matcher lmao

#

no constructor I see

icy shadow
#

Pattern is your friend

broken elbow
#

YOUR-REGEX-PATTERN.match(input)

icy shadow
#

you should be using this class almost whenever you're using regexes

wintry grove
#

wot

icy shadow
#

it's free performance

#

d;jdk Pattern

uneven lanternBOT
#
public final class Pattern
extends Object
implements Serializable```
Pattern has 1 extensions, 1 implementations, 1 all implementations, 11 methods, and  9 fields.
Description:

A compiled representation of a regular expression.

A regular expression, specified as a string, must first be compiled into an instance of this class. The resulting pattern can then be used to create a Matcher object that can match arbitrary character sequences against the regular expression. All of the state involved in performing a match resides in the matcher, so many matchers can share the same pattern.

A typical invocation sequence is thus

compile

A matches method is defined by this class as a convenience for when a regular expression is used just once. This method compiles an expression and matches an input sequence against it in a single invocation. The statement
is equivalent to the three statements above, though for repeated matches it is less efficient since it does...

This description has been shortened as it was too long.

Since:

1.4

broken elbow
#

d;jdk Pattern#match

uneven lanternBOT
#
public Matcher matcher(CharSequence input)```
Description:

Creates a matcher that will match the given input against this pattern.

Returns:

A new matcher for this pattern

Parameters:

input - The character sequence to be matched

broken elbow
#

you create your Pattern

#

then you use the matcher method with the string as input

#

that gives you the matcher

icy shadow
#

^

broken elbow
#

then you can get the groups from there

icy shadow
#

keep the pattern constant btw, it's thread-safe

#

and creating it is slow

wintry grove
#

and how do you make a pattern instance lol

#

I'm quite stupid

#

and IJ doesnt help

icy shadow
#

Pattern.compile

#

static

wintry grove
#

ah good

#

thanks

icy shadow
#

ooh jpa in spigot

wintry grove
#

this is big

icy shadow
#

dont see that very often

#

@frigid pollen

@Id
@OneToOne(mappedBy = "player_id")
private UUID player_id;
``` I believe this is causing your issue, Hibernate has no idea what table this column is supposed to reference
#

try setting targetEntity = Account.class

frigid pollen
#

That fixed it thanks!

frigid pollen
icy shadow
#

not necessarily, just uncommon

#

a lot of people dont like having big jar files so you rarely see big libraries like hibernate being used

frigid pollen
#

Oh

lyric gyro
#

guys

#

can I ask you to give me ideas of what to code?

#

I want to do something

#

I just cant figure out what

#

because I've got to practice

icy shadow
#

what, a plugin?

lyric gyro
#

anything java related

#

just want to see how far my skills go

icy shadow
#

a small console game is always a decent thing to do

#

card game, rpg, puzzle, whatever

#

allow players to save their progress to a file

lyric gyro
#

yeah im not making a game though

#

im not that good

icy shadow
#

im sure you could do a simple one

#

it doesnt have to be AAA

lyric gyro
#

i do not know what I need, i do not know how it works

icy shadow
#

well there's nothing you "need", it's up to you to decide what you make

lyric gyro
#

how do I begin developing a software

icy shadow
#

how much experience do you actually have?

lyric gyro
#

a whole one or two weeks of coding

icy shadow
#

ah

lyric gyro
#

thats why i need to practice

icy shadow
#

what about a text-based bank account simulator?

#

let people deposit and withdraw money (basically just changing a number), saving their balance to a file

#

potentially add multiple accounts

#

seems simple enough

lyric gyro
icy shadow
#

how did you do it then lol

lyric gyro
#

I just defined the variables myself

icy shadow
#

🤨

lyric gyro
#

in the code itsealf

#

itself

icy shadow
#

so the user couldnt actually do anything?

lyric gyro
icy shadow
#

well lol

lyric gyro
#

I just runned the code and it showed up a bunch of stuff

#

I'll do that

icy shadow
#

thats just printing stuff lol

#

yeah

#

make it so the user can actually change stuff

#

user input handling is pretty common

#

and if you feel confident add the file loading / saving like i said

lyric gyro
#

I am fascinated with making plugins with inputs

#

specially because I want to dominate them

#

ok

#

let's start

icy shadow
#

lol

#

gl

#

hf

lyric gyro
#

thanks man

#

one last question @icy shadow

#

do you like coding while listening to music?

icy shadow
#

uh yeah lol

#

but then i just listen to music all the time

#

so

lyric gyro
#

what do you usually listen to

#

my go to for stuff like this is just my youtube music playlist

icy shadow
#

uh nothing specific lol

#

soundtracks are good sometimes for focusing

lyric gyro
#

music with too much lyrics can be distracting while doing stuff

#

atleast for me

icy shadow
#

yeah that can happen

#

i dont notice it too much though

lyric gyro
#

yeah

#

@icy shadow how do I make it so that the program doesn't stop after the first input?

#

so you can input multiple things running the program only once

icy shadow
#

show code please

lyric gyro
#

public class sandbox {

    public static void main(String[] args){

        class contaDoBanco {
            String nome = "João da Silva";
            String endereço = "Casa dos Cacetes";
            int idade = 69;
            int dinheiroBase = 1000;

        }

        int input;
        try {
            input = (int) System.in.read();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }```
#

this is what i've done so far

#

its not finished yet

icy shadow
#

well currently it's ending because theres nothing left to do

lyric gyro
#

i know

icy shadow
#

the code's reached the end, so it stops running

#

if you add more code then it will also run that code

#

similarly if you ask for another input it will wait for that second input

lyric gyro
#

but what I want to do is

#

when you insert a number

#

it will either subtract from int dinheiroBase

#

or add

#

and then it will print out the result

icy shadow
#

okay so do that

lyric gyro
#

but the program wont stop

#

because

#

it will wait for another input

#

and it will keep going for as long as you want

#

can I use like return statements for this?

#

i dont really know how they work

icy shadow
#

look, if you want to ask for another input, do that

#

it's really not that complicated

#

the program will only do what you tell it to

#

if you want the user to input something else, read something else from the scanner

lyric gyro
#

okay but

#

what I am asking if there is a way so the program doesn't stop after the input

#

and keeps going on forever

#

for as long as you like

icy shadow
#

forever?

#

until the user turns off their pc?

lyric gyro
#

until you stop the program manually

#

lets say i run the program

#

then I input +1000

#

the program takes this input

#

adds to the int dinheiroBase

#

and prints out the result

#

then it asks for input again

icy shadow
#

ah right right

#

put your input handling in an infinite loop

#

something like while(true)

lyric gyro
#

tbh I did think about that

#

don't know why I ignored this thought

#

also

#

I don't need that try and catch statement right?

#

I just added it because the ide asked and i was lazy to fix it

icy shadow
#

you do with that code

#

however

#

that is a very bad way of getting input

#

because it only allows you to read 1 character at a time

#

look into the Scanner class instead

lyric gyro
#

okay

#

I've used scanner before

#

let me see how to implement it because i forgot

#

nah wait

#

if its a class then its the same as creating a new instance of a class

#

im stupid 💀

#

aight back to work

lyric gyro
#

I know what I mean

#

you'll see

lyric gyro
#
import java.io.IOException;

public class sandbox {

    public static void main(String[] args) throws IOException {


        int input;
        String operatorDetector;
        while (true) {
            input = (int) System.in.read();
        }

        class idkAAA {
            
            void adicionarDinheiro(){
                
            }
            
        }

    }

}``` @icy shadow
#

why does it say class idkAAA is unreachable

#

what am I doing wrong

#

(also I dropped the scanner thing because I couldn't figure out how it works)

merry knoll
#

because its inside a func

#

why are you using an inner class

#

anyway

proud pebble
#

i dont think your supposed to declare a class inside of a method

lyric gyro
#

you are talking about the main method?

#

there is no issue on declaring a method inside the main class

#

but for some reason the ide is just being a jerk and not allowing me to do it

lyric gyro
#

where

merry knoll
#

class idkAAA {

        void adicionarDinheiro(){
            
        }
        
    }
#

this is a class

#

why is it inside a method

lyric gyro
#

what method

#

it's not inside a method

#

i'm creating a new class with a method

#

i'm not creating a class inside a method

#

unless you are talking about the main method

#

which doesn't make sense afaik

merry knoll
#

you are

#

thats inside your main method

merry knoll
#

not creating it

lyric gyro
#

well whats the difference

merry knoll
#

by using new keyword

#

you create an instance of a class

#

by plugging it like you do

#

you create errors lmao

#

it can be inside another class

#

but not in a method

lyric gyro
#

yeah i just added new before class

#

and the error disappeared

#

but there are two errors now

#

let me check what these are

merry knoll
#

you dont ad

#

add new like that

#

you need to declare the class somewhere

#

THEN

#

you instantiate it

#

inside your methods

lyric gyro
#

can I just create a method without a class?

#

i cant right?

#

cause the class needs to be there

#

for what i am trying to do

merry knoll
#

your method needs to be INSIDE a class

#

but in your case

lyric gyro
#

yeah

merry knoll
#

that class needs to be another file

lyric gyro
#

well

merry knoll
#

so you would have file 1 with your main class

#

ideally named the same

#

so

lyric gyro
#

I think the issue is because the main method is throwing ioexception

merry knoll
#

and file 2 with the new class

#

no its not

#

thats another issue

#

you should catch all the exceptions that are being thrown

#

where you do it is up to you though

lyric gyro
#

well i just removed the throws thingy and now I don't have that error anymore

#

that class needs to be there

#

for what i am trying to do

#

thats the problem

merry knoll
#

move it to another file

#

then instantiate it

#

inside your method.

lyric gyro
#

ok i'll do that

#

christ programming is too confusing

#

but rome wasn't built in one day i guess

#

@merry knoll

#

may sound like a stupid question but

merry knoll
#

it probably is

lyric gyro
#

how do I use an integer create in one class in another class?

lyric gyro
merry knoll
#

you pass it

lyric gyro
merry knoll
#

either from the constructor

#

or a method

lyric gyro
#

I see

lyric gyro
#

also

#

you don't get annoyed by my stupid questions right?

#

you know that i am learning

#

i mean if you tried to learn my language you would also make a lot of stupid questions

#

but i'd answer them

#

so I ask a lot of stupid questions about your language

#

which is java

stuck hearth
#

I once asked a question

lyric gyro
#

how do I pass the variable from a class to another

#

I want to use the same variable in a different class

merry knoll
#

if you dont need to keep the variable

#

pass it in the method

#

if you need to reuse it later

#

then pass it in constructor

#

then put on field

lyric gyro
#

import java.util.Scanner;
import java.io.IOException;

public class sandbox {

    public static void main(String[] args) throws IOException {

        int input;
        while (true) {
            input = (int) System.in.read();
        }

    }

}

#

the variable that i need to pass is input

#

to another class

#

in the same package

merry knoll
#

okay lets fix some small

#

but quite important mistakes first

#

class name

#

ALWAYS starts uppercase

#

so rename that to Sandbox

#

your package name, go with something like

#

me.yourname

#

for how to pass

#

you can define it in a function like this

#

public void function(Int input) {
// do stuff with input
}

#

you call that function like

#

function(15)

lyric gyro
#

i wanna bang my head against the wall

#

i know i am doing something wrong, i know where the error is

#

i just dont know what

#

is the error

#

or how to solve it

merry knoll
#

you need to study java basics then

#

functions - classes especially

lyric gyro
#

to practice

#

public class MoneyClass {

    int baseMoney = 1000;

    public void moneyAdder(int input){
        String operatorDetector = null;
        if(operatorDetector == "+"){
            System.out.println(baseMoney + input);
        }
    }

}
#

import java.util.Scanner;
import java.io.IOException;

public class sandbox {

    public static void main(String[] args) throws IOException {

        int input;
        input = (int) System.in.read();


    }

}

#

here is the whole code

#

for context

#

i was trying to do a bank account simulator

#

where you input +(number) or -(number) to subtract or add money from your account

merry knoll
#

you dont put Class in the name

#

making the first letter capital means that its a clas

#

then call the method

#

first you need an instance of your MoneyClass

#

so MoneyClass money = new MoneyClass()

#

now "money" holds an instance of your MoneyClass

#

then you call your method

#

money.moneyAdder(input);

#

this might help

#

and this for oop basics

lyric gyro
#

what is 'money'? you mean basemoney?

merry knoll
#

its what i named my variable

merry knoll
dusky harness
lyric gyro
#

will this make so that when i input +1000 it will add 1000 to basemoney?

merry knoll
#

nope

#

for that you need to parse that string

#

first you need to take the first character

#

to see what action is being taken

#

then take the rest to see whats the amount

#

parse them to the data types you need

#

and do the calculation after

#

you do not need new classes for that though

#

what you do need new classes for

#

is storing balance of each person

lyric gyro
#

method

#

i need a new class for the add money method

merry knoll
#

well, you dont need a class

#

it is cleaner though

lyric gyro
merry knoll
#

you have a text in hand

#

and you need to extract

  1. a calculation (+ - * /)
  2. an amount
#

from that text

#

thats called parsing

#

you are parsing the text (aka translating) into these 2 things

lyric gyro
#

😭

#

i think ill just

#

try to find something easier

#

i have no clue what to do

merry knoll
#

do a basic calculator

lyric gyro
merry knoll
#

nope

#

dont use any of the Math library methods

#

just basic operators

#
  • / + -
lyric gyro
#

i dont think im able to do that

cinder forum
#

You are, we'll help you 😏

lyric gyro
#

smirk

#

seriously

#

my grandmother just passed away 😏

lyric gyro
robust flower
# dusky harness 😮 Perfecttt Can you give a method to get the block locations?

Wait, I'm not sure what do you need exactly, what do you mean with locations? If you just want to know all locations present in the Clipboard, Clipboard's Region (Clipboard#getRegion) is an Iterable<BlockVector3>, so you can just use Kotlin's toList on it to get a List<BlockVector3>, get all blocks by using clipboard.region.map(clipboard::getFullBlock), or get a Map<BlockVector3, BaseBlock> by associating the block with its location (aka clipboard.region.associateWith(clipboard::getFullBlock)).

In my plugin I used only offsets so I subtracted the minimum point (Clipboard#getMinimumPoint) of all the locations (so your lowest "location" offset is always 0, 0, 0, and it goes up from there). Ping me if your question was not about that.

lyric gyro
#

cause im sure aki is losing patience

cinder forum
lyric gyro
#

i wanted to make a bank account simulator

#

that when you input like

#

+1000

#

it would add to the base ammount of cash

merry knoll
#

the issue is you are lacking extreme basic knowledge

#

do something simpler first

#

like a calculator

cinder forum
lyric gyro
#

im not doing a plugin

merry knoll
#

console, he is not doing spigot stuff

lyric gyro
#

im just trying to practice java

cinder forum
#

ooh okay

lyric gyro
#

since im a beginner

#

but the issue is

#

when I type in +1000

#

nothing happens

#

aki said i need to parse something or whatever its called

#

and idk how to do that

#

im getting so confused

merry knoll
#

yes

#

go back to more basics

#

get used to them first

lyric gyro
#

like what

merry knoll
#

fuck classes, just learn the basics first

#

a basic calculator

cinder forum
lyric gyro
cinder forum
#

i understand now but dont type every 3 words in new message

lyric gyro
#

i wntd t d a bnk acnt sm tht wn y inpt +1000 it wd + t th bse vl bt idk hw

#

is that clear

dusky harness
robust flower
#

hmm what do you want to do exactly, are you reading a schematic file or something? cause that sounds like problem x y

dusky harness
#

but I need the signs in the new pasted location, not the location in the schematic file

merry knoll
#

its just an offset

#

get paste location + add location in schem

#

you get the final location

dusky harness
#

and I'll need to rotate the blocks
I can do this yes, but if SecretX has a working & tested method already, it would be better to use his, I think (unless it's too much work "extracting" the needed code from his plugin, then it's fine)

merry knoll
#

i mean block coord in a schem

#

is just an offset

#

from the paste location effectively

dusky harness
#

and you can rotate blocks in ClipboardHolder

#

(using worldedit api)

merry knoll
#

i am not familiar with the api

#

but does it not let you check coords afterwards?

#

(and you can calculate rotated location too easily)

dusky harness
merry knoll
#

just apply this to the schem coords

cinder forum
# lyric gyro i wntd t d a bnk acnt sm tht wn y inpt +1000 it wd + t th bse vl bt idk hw

Okay so you need to:

- Get the input
- Trim it (if you don't know what trimming is Google it)
- Check if input contain forbidden characters (not operator/number), if yes, print error message
- Parse it
- Do the bank operation

How to parse? There are few options, let's say your trimmed input is +1000
ig easiest option is to split it at 1st character so you will get the opreation (+ in this case) and the amount (1000)

So it will look like this:

- Get the input -> + 1000
- Trim it -> +1000
- Check if input contain forbidden characters (not operator/number)  - ✔
- Parse it - [+, 1000]
- Do the bank operation - can look like this: https://paste.helpch.at/ulenutihes.cs

Also you want to check if operation & amount are valid (like if somebody input +++1000 it will be broken) but I would ignore it rn

lyric gyro
#

christ the effort to help the dumbest idiot in this server

#

thank you

dusky harness
dusky harness
#

don't worry about figuring out the entire thing before coding any of it

lyric gyro
#

so i guess

#

i need a getter?

dusky harness
#

do you know how to read console input?

lyric gyro
#

uhh

#

what

#

do you mean by reading the console input

dusky harness
#

how are you letting the users give their input

lyric gyro
#

ah

#

system.in.read

cinder forum
dusky harness
#

isn't that just reading one character at a time 😬

#

here's a little tool that java has:

#
Scanner scanner = new Scanner(System.in); // tool to read console input
String lineOfInput = scanner.nextLine();
lyric gyro
#

i know about scanners

dusky harness
#

might want to just use scanners instead

lyric gyro
#

i just dont know how to use them properly

dusky harness
lyric gyro
#

different

#

im dumber than a door

lyric gyro
#

numbers

#

words

dusky harness
#

lines

#

so for example

dusky harness
robust flower
cinder forum
#

btw are you trying to code generally or you want to code in java (just curious)

lyric gyro
#

for now just java

lyric gyro
#

if i somehow succeed

#

then ig ill learn like

#

c or whatever

#

ok c++

dusky harness
#

lol

lyric gyro
#

c# is the best i can do

icy shadow
#

dkim

#

thats not nice

#

hmm

lyric gyro
#

and do the whole thing again

#

ok

cinder forum
#

xd

lyric gyro
#

?

cinder forum
#

ok

cinder forum
# lyric gyro ?

for now just try to get the input and print it (multiple times)

lyric gyro
#

i'll try to use the bloody scanner

merry knoll
# icy shadow dkim

why u give him a basic oop task when he cant even do basic methods yet

merry knoll
lyric gyro
#

i can do basic methods

merry knoll
#

ma man

#

you cant do it yet

icy shadow
dusky harness
#

I haven't read the entire convo

#

so

#

idk where he was at

lyric gyro
merry knoll
#

ma man you just tried to put a whole class declaration into your main

#

please

icy shadow
#

technically that'll compile

lyric gyro
#

yeah dude

merry knoll
icy shadow
#

it's just not a great idea

robust flower
# dusky harness oh 💀 💀 💀 💀

Without further ado, here's the method:

fun Clipboard.rotateY(rotateDegrees: Double): Clipboard {
    val rotator = AffineTransform().rotateY(-rotateDegrees)

    val newMinimumPoint = rotator.apply(minimumPoint.toVector3()).toBlockPoint()
    val newMaximumPoint = rotator.apply(maximumPoint.toVector3()).toBlockPoint()
    val newOrigin = rotator.apply(origin.toVector3()).toBlockPoint()
    val newRegion = CuboidRegion(newMinimumPoint, newMaximumPoint)

    val newClipboard = BlockArrayClipboard(newRegion).apply { origin = newOrigin }
    region.forEach { location ->
        val oldBlock = getFullBlock(location)
        val newLocation = rotator.apply(location.toVector3()).toBlockPoint()
        newClipboard.setBlock(newLocation, oldBlock)
    }
    return newClipboard
}```

it rotates the structure by the Y axis (probably what is are also doing), and the use example is here (copy pasted from my plugin):

```kotlin
/**
 * Rotate this schematic by 90 degrees four times, returning all possible 90 degrees rotations.
 */
private fun Clipboard.getAllPossibleRotations(): Set<Clipboard> =
    (0..3).mapTo(mutableSetOf()) { rotateY(it.toDouble() * 90.0) }
icy shadow
lyric gyro
#

k*tlin

dusky harness
cinder forum
lyric gyro
#

isn't rotating a clipboard like 2 lines?

dusky harness
#

is rotating y left/right? if that makes sense

#

just making sure

#

lol

dusky harness
#

no more class confusion

#

ez

#

/s (but it really doesn't require classes)

lyric gyro
#

you will forget how classes work then

robust flower
lyric gyro
lyric gyro
icy shadow
#

(no matter how hard you try)

dusky harness
#

if that makes sense

robust flower
dusky harness
#

ah

#

🤦

#

thanks secretx

#

is that a worldedit class btw?

cinder forum
robust flower
merry knoll
lyric gyro
#

how the fuck do you use scanners

merry knoll
#

DUD

#

someone posted it like 10 times

#

call .nextLine on it

#

to get the whole line

robust flower
# dusky harness imports!1!!1!
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard
import com.sk89q.worldedit.extent.clipboard.Clipboard
import com.sk89q.worldedit.math.BlockVector3
import com.sk89q.worldedit.math.transform.AffineTransform
import com.sk89q.worldedit.regions.CuboidRegion
import com.sk89q.worldedit.world.block.BlockState```
dusky harness
#

lol

lyric gyro
#

i literally made a new scanner loop and it just started fucking printing nonsense

#

what am I doing wrong for god's sake

lyric gyro
# cinder forum can you send the code?

import java.util.Scanner;

public class Sandbox {

    public static void main(String[] args) {

        Scanner bigBuxScanner = new Scanner(System.in);
        while(true){
            System.out.println(bigBuxScanner);
        }




    }

}

dusky harness
#

well

robust flower
#

@dusky harness note that Clipboard stores not only blocks, but also biomes (?) and entities, I just couldn't be arsed to copy them all, so this method only copies the blocks

dusky harness
lyric gyro
#

bruh just apply the damned transform on the holder lmao

robust flower
cinder forum
#

guys i found infinite github commits glitch

#

its called prettier

lyric gyro
#

surprisingly, worldedit is all about vectors

robust flower
#

in my defense, my plugin do not paste any structures, it only deals with them in memory, and WorldEdit ClipboardHolder did not provide me a modified (in my case, rotated) Clipboard copy that I could use to query stuff, at least not one that I could find, so I just wrote one myself, and also I wrote a method to trim Clipboard region removing all sides of the cube where there is just air (and this functionality do not exist on the WE api)

lyric gyro
#

it doesn't modify the clipboard itself

lyric gyro
#

it "stacks" transformations that are applied when an operation is applied

#

reading the holder returns the blocks with the transformations applied

lyric gyro
robust flower
lyric gyro
#

what are you trying to do?

#

just input

#

and printing that input again and again and again

#

Ok well you have to take the input first

#

how

#

you’ve been told how to do above by a couple other people

cinder forum
#

while (true) {} = infinite loop

lyric gyro
#

i just needed to add .nextline

#

what now

cinder forum
#

Look:

public static void main(String[] args) {
  Scanner scanner = new Scanner(System.in);
  while (scanner.hasNext()) {
    String input = scanner.nextLine();
    System.out.println(input);
}
#

this code will took input, print it and wait for next input

dusky harness
#

:)

lyric gyro
#

has

dusky harness
#

well you can use hasNextLine & nextLine

#

although I usually just see hasNext

#

¯_(ツ)_/¯

#

or a while true loop also works fine

cinder forum
dusky harness
#

and in some cases a while true loop is the better method

cinder forum
#

You can easily make exit input by adding

if (input.equals("exit")) {
  break;
}

to the while loop

dusky harness
#

but yes notice how he's doing nextLine on the scanner

#

instead of printing the scanner

lyric gyro
#

what i got to do next again

cinder forum
#

aight

cinder forum
#

Now you want to trim the input

#

Which will remove whitespaces (space, new line etc)

lyric gyro
#

yes

#

where do i put the method

cinder forum
#

You want to trim the input string

#

So you can do String input = scanner.nextLine().trim();

lyric gyro
#

wait wait wait wait

#

do I have to make an integer named input?

#

i told you im restarting

cinder forum
lyric gyro
#

because you put input after string

#

also does this even count as practice?

#

since im basically asking for help

cinder forum
lyric gyro
#

oh

#

i see

cinder forum
#

can you send yuor code?

lyric gyro
#

import java.util.Scanner;

public class Sandbox {

    public static void main(String[] args) {

        Scanner bigBuxScanner = new Scanner(System.in);
        String input = Scanner.nextLine().trim();
        while(true){
            System.out.println(bigBuxScanner.nextInt());
        }




    }

}

cinder forum
#

okay

dusky harness
#

int/integer = whole number (basically)

lyric gyro
#

i know

cinder forum
lyric gyro
#

it doesn't

cinder forum
#

okay nice so

lyric gyro
#

it says that next line cant be referenced from a static context

#

ill try to understand this whole thing later

#

just keep saying what i've got to do

cinder forum
#
Scanner bigBuxScanner = new Scanner(System.in);
  String input = Scanner.nextLine().trim(); // <--- you need to use bigBuxScanner here instead of Scanner, that's why are you getting the error
   while(true){
    System.out.println(bigBuxScanner.nextInt()); // <--- print the input variable here
}
cinder forum
#

& put the input variable in the while loop

#

it should look like this

public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(true) {
            String input = scanner.nextLine().trim().replace(" ", "");
            System.out.println(input);

            if (input.equals("exit")) {
                break;
            }
        }
#

(you need to add the String#replace method to remove space so if the input is +1000 or + 1000 it doesnt matter, trim doesn't remove spaces between characters, my bad)

cinder forum
#
- Get the input - done
- Trim it (if you don't know what trimming is Google it) - done
THIS:
- Check if input contain forbidden characters (not operator/number), if yes, print error message
- Parse it
- Do the bank operation
#

do you have any idea how could you do that?

lyric gyro
#

if statement

#

something like

#

if(input.contains)

#

and then a list of forbidden characters

#

is this right?

cinder forum
#

and then a list of forbidden characters
Nope, there are thousands of characters, you need to list the good ones (which is only numbers and operators)
But I think there's better way

lyric gyro
#

hmm

#

how would i do that

spiral prairie
#

Regex kekwhyper

#

/j

cinder forum
#

I think this is better, because it also fix this issue: "Also you want to check if operation & amount are valid (like if somebody input +++1000 it will be broken) but I would ignore it rn"

First you parse the input (basically 1st char is operator then remaining characters is number)
So you just parse the int = Integer.parseInt(num), if its number, you will get int, if its not number you will get error (which you can catch and print error message)

cinder forum
#

Firstly you get the operator like this: char operator = input.charAt(0);

#

(indexes starts at zero)

cinder forum
#

Then you get the amount: input.substring(1, input.length() -1); (-1 because indexes starts at zero)
first value in String#substring is start index, second end index
If the end index is last index, you can omit it: input.substring(1)

lyric gyro
cinder forum
#

yeah

#

this will get you the operator - it's first character of the input

lyric gyro
#

import java.util.Scanner;

public class Sandbox {

    public static void main(String[] args) {

        Scanner bigBuxScanner = new Scanner(System.in);
        while(true){
            String input = bigBuxScanner.nextLine().trim().replace(" ", "");
            System.out.println(bigBuxScanner.nextInt());

            char operator = input.charAt(0);

            if (input.equals("exit")) {
                break;
            }

        }




    }

}

#

this correct?

cinder forum
#

yeah should be just delete System.out.println(bigBuxScanner.nextInt()); line or it will give you error when the input is not a number

#

now save the amount in variable by using
String amount = input.substring(1);

cinder forum
#

nice

lyric gyro
#

ok

#

import java.util.Scanner;

public class Sandbox {

    public static void main(String[] args) {

        Scanner bigBuxScanner = new Scanner(System.in);
        while(true){
            String input = bigBuxScanner.nextLine().trim().replace(" ", "");

            char operator = input.charAt(0);
            String amount = input.substring(1);

            if (input.equals("exit")) {
                break;
            }

        }




    }

}

cinder forum
#

right

#

now you parse the amount

try {
   Integer.parseInt(amount);
   System.out.println("Amount: " + amount);
  } catch (NumberFormatException ignored) {
    System.out.println("ERROR! Wrong input");
}
lyric gyro
#

i input 51

#

it gave me

#

1

cinder forum
#

yeah because

#

String amount = input.substring(1);

#

Then you get the amount: input.substring(1, input.length() -1); (-1 because indexes starts at zero)
first value in String#substring is start index, second end index
If the end index is last index, you can omit it: input.substring(1)

#

and indexes starts at zero

#

wait are you trying to do that when you do +100 it will add 100 to bank account then when you do -100 it will remove 100 from back account right

lyric gyro
#

yes

cinder forum
#

okay nice so

#

you need to do +100

#

and the amount will be 100

#

and the operator will be +

lyric gyro
#

mhm

#

it gave me 100

#

now we got to add a class correct?

#

so we can have our base value

#

which our input will add or remove to

cinder forum
#

you don't need to just keep it all in 1 class to keep it simple for now

#

do you know what switch statement does in Java?

lyric gyro
#

yes

#

it has multiple cases

#

its pretty much like an if statement

cinder forum
#

okay so now you want to switch the operator

#

like this

switch (operator) {
                case '+':
                    //will be added later
                    break;
                case '-':
                    //will be added later
                    break;
                default:
                    System.out.println("ERROR! Operator is not specified");
                    break;
            }

do you understand why?

lyric gyro
#

yeah yeah

#

i understand

#

if

#

we will take the input

#

and add to the base value

#

if -

#

we will subtract

cinder forum
#

yeah 👍

#

okay so

#

lets declare base value

#

at the start

#

outside the loop

lyric gyro
#

80085

#

this will be base value

#

dont ask why

lyric gyro
cinder forum
#

after the try catch block

#

well you can put it before it it doesn't matter

#

but not before operator is declared

lyric gyro
#

so what now

#

what is the operator again

#

i have short lived attention

#

maybe thats why coding is stupidly hard for me

cinder forum
#
  • or -
#

first character of the input

lyric gyro
#

oh right right right

cinder forum
#

If you don't understand something just ask

lyric gyro
#

then

#

you will help me understand it fully ok

#

because if i dont understand fully

cinder forum
#

okay

lyric gyro
#

im not practicing

lyric gyro
#

import java.util.Scanner;

public class Sandbox {

    public static void main(String[] args) {
        int baseAmount = 80085;
        System.out.println("STARTING WITH BALANCE: " + baseAmount);

        Scanner bigBuxScanner = new Scanner(System.in);
        while(true){
            String input = bigBuxScanner.nextLine().trim().replace(" ", "");

            char operator = input.charAt(0);
            String amount = input.substring(1);

            try {
                Integer.parseInt(amount);
                System.out.println("Amount: " + amount);
            } catch (NumberFormatException ignored) {
                System.out.println("ERROR! Wrong input");
            }

            switch (operator) {
                case '+':
                    baseAmount = baseAmount + newAmount;
                    break;
                case '-':
                    baseAmount = baseAmount - newAmount;
                    break;
                default:
                    System.out.println("ERROR! Operator is not specified");
                    break;
            }


            if (input.equals("exit")) {
                break;
            }

            System.out.println("New balance: " +baseAmount);

        }




    }

}

cinder forum
#

If you still don't understand something just ask but I ll go to bed soon

#

you can try to add check if you are not in negative numbers 👍

lyric gyro
#

because newamount doesnt exist

cinder forum
#

then declare it

lyric gyro
#

newamount = input??

lyric gyro
#

new amount wasnt declared anywhere

cinder forum
#

line 11

lyric gyro
#

oh right

#

its not updating the baseamount

cinder forum
#

code?

#

on helpchat paste please the readinbility is bad on phone

lyric gyro
#

ok

cinder forum
#

compare my try block and yours

lyric gyro
#

because you didnt define a base amount

#

but anyways

#

can you help me understand all this code now?

cinder forum
cinder forum
#

newAmount = Integer.parseInt(amount);

#

you dont assign amount to newAmount

#

so it doesnt change

lyric gyro
#

brb

#

dont leave

#

i still need your help

#

@cinder forum

#

im back

#

please tell me you are still there

cinder forum
#

ye

lyric gyro
#

good

#

now lets understand the code

#

so first

#

we are creating an integer named based value

#

and it is equal to 0

#

then we are printing out

#

the base ammount

#

and a message

#

after that

#

we are creating a scanner

#

which will read in the input

#

then we are creating an inifinite while loop

#

then we are trimming the input

#

what does scanner.nextline mean

#

that it will continue on the next line?

cinder forum
#

google "java <> docs"

#

and you will get official docs

#

so just google "java scanner docs"

lyric gyro
#

ok

#

but what is it doing

cinder forum
#

basically

#

it just return the input

lyric gyro
#

so

#

after that we are creating a char named operator

#

i dont remember what this does

cinder forum
#

okay so

#

you know what the input variable is

lyric gyro
cinder forum
#

charAt is for this:

String woof = "dog";
woof.charAt(0) = d
woof.charAt(1) = o
woof.charAt(2) = g

#

so when you do input.charAt(0)

#

and the input is +100

#

you well get the operator - plus sign

lyric gyro
#

hmmm

#

so moving on

#

then we have int newamount = 0

#

and a try and catch statement

dusky harness
#

or why not just one variable - amount?

lyric gyro
#

from this point forward i can understand the rest of the code

cinder forum
lyric gyro
cinder forum
#

no problemo

dark garnet
#
Object blah = getBlah1();
if (check) blah.doBlah2();```if `check` is false, is `blah` still parsed? *basically, are variables parsed before being used?*
#

also, how can i keep a chunk loaded with a specific item in it? im spawning an item, so if there's a way to keep a chunk loaded by location or something thats fine

dark garnet
#

for some reason my plugin's version isnt updating
it's previous version was 1.9.2 (which its stuck at for some reason), and its updated version is 1.10.0
plugin.yml:yml version: ${version}````build.gradle.kts`:kts
version = "1.10.0"

tasks {
processResources {
filesMatching("**/plugin.yml") {
expand(rootProject.project.properties)
}
}
}```the plugin's file is renamed (PLUGIN-1.10.0.jar), its just the part in plugin.yml

i think it has something to do with updating it from 1.9.x to 1.10.x

lyric gyro
#

May believe for Gracie it’s @version@

#

Or something like that

#

personally i use

    outputs.upToDateWhen { false }
    filesMatching('**/plugin.yml') {
        filter {
            it.replace('@version@', project.version.toString())
        }
    }
}```
lyric gyro
olive dirge
#
Caused by: java.lang.ClassNotFoundException: com.mongodb.client.MongoClients
    at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:151) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
    ... 13 more
#

what does this error mean...

edgy lintel
#

or make use of spigot dependency shading

olive dirge
#

I never shaded before, was it because I swapped over to paper?

edgy lintel
edgy lintel
#

so the server will not load the library and your plugin doesnt know where to refer from

#

plugin.yml would help if you dont know how to use maven
you just have to include the libraries config into your plugin.yml and the spigot server will download it for you

#
name: myplugin
.......

libraries:
   - com.squareup.okhttp3:okhttp:4.9.0
olive dirge
#

oh im doing this through artifacts building

#

and I see the maven is included in the output layer

edgy lintel
#

what IDE are you using

olive dirge
#

intellij

edgy lintel
#

    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <includes>
                                    <include>package:libraryname</include>
                                    <include>commons-io:commons-io</include>
                                </includes>
                            </artifactSet>

                
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

you can try to add this to your pom.xml and it should shade it for you

dense drift
edgy lintel
#

just change the include tags inside the artifact set
it works with intellij too

olive dirge
#

I did the libraries: in yml

#

And it seems to have worked

edgy lintel
#

nice

#

that saves much effort of the maven mess

#

but if your plugin is a public plugin then your user's server may have to download the libraries first run too

misty dragon
#

I wanna check if players are dragging items in custom inventory or in their own inventory, how can i do that with InventoryDragEvent?

#

i wanna cancel the drag event if they're dragging in custom inventory

olive dirge
#

check inventory title maybe? @misty dragon

#

Cannot invoke "dev.failures.core.Config.ConfigHandler.get()" because the return value of "dev.failures.core.Commands.SellCommand.access$000(dev.failures.core.Commands.SellCommand)" is null

#

access error?

dense drift
#

Dont use inventory name

edgy lintel
#

just make like a menulistener with their session stored or sth

misty dragon
edgy lintel
olive dirge
#

wandering any tips for that error above?

#

the command was fine until mongo worked

edgy lintel
olive dirge
#

sellcommand file?

edgy lintel
#

SellCommand.access method

olive dirge
#

I dont have that

edgy lintel
#

dev.failures.core.Commands.SellCommand.access$000 this?

#

cant help you without the code
its coding problem from what i see

#

a snippet is ok

olive dirge
#

wait I think I see it

#

is it cause map is above it

edgy lintel
#

cuz by the time when your hashmap is initialized its before the constructor

#

and its before confighandler is ever initialized

#

so at that time when you try to do anonymous class and call methods, the confighandler is null

#

so you will have to make it a regular hashmap and call the put methods after confighandler = confighandler

olive dirge
#
    private ConfigHandler cropValues;

    public SellCommand(ConfigHandler cropValues) {
        this.cropValues = cropValues;
    }

    Map<Material, Double> CROP_VALUES = new HashMap<Material, Double>() {{
        put(Material.CACTUS, cropValues.get().getDouble("cactus-price"));
        put(Material.SUGAR_CANE, cropValues.get().getDouble("sugarcane-price"));
        put(Material.COCOA, cropValues.get().getDouble("cocoa-price"));
        put(Material.WHEAT, cropValues.get().getDouble("wheat-price"));
    }};

#

like this

#

I think im still getting the error, I'll try again

edgy lintel
#

no lik

#

no like

#
 private ConfigHandler cropValues;
  Map<Material, Double> CROP_VALUES = new HashMap<Material, Double>() {};
    public SellCommand(ConfigHandler cropValues) {
        this.cropValues = cropValues;
        CROP_VALUES.put(Material.CACTUS, cropValues.get().getDouble("cactus-price"));
        CROP_VALUES.put(Material.SUGAR_CANE, cropValues.get().getDouble("sugarcane-price"));
        CROP_VALUES.put(Material.COCOA, cropValues.get().getDouble("cocoa-price"));
        CROP_VALUES.put(Material.WHEAT, cropValues.get().getDouble("wheat-price"));
    }

  
olive dirge
#

oh alright

misty dragon
#

ok fixed it using rawslot

olive dirge
#

I'm getting an issue where I have something in the map but when I access it after its empty

sterile hinge
#

those are likely different maps then

#

show your code though