#help-development

1 messages Β· Page 1603 of 1

smoky oak
#

can't i rather split in region files

dense goblet
#

also will work

#

but its harder

#

what if a chunk gets wiped but not the whole region

#

then you need to delete only the data in that region file which is in that chunk

smoky oak
#

'wiped' as in regenerated you mean?

dense goblet
#

also they will be more ram heavy as you will have to load 512 chunks at once instead of just 1

#

yea

smoky oak
#

urgh

#

not storing IN the files

#

in a config for that region i mean

#

im not storing data for every block

dense goblet
#

but if you have 1 config per region then you load the whole config when you want to access any part of it

smoky oak
#

it is unlikely it would be more than a few hundred per region anyways

dense goblet
#

still the chunk wiping problem remains

smoky oak
#

Well the same issue would be by storing it in chunk separated files

#

how do i know a chunk got wiped

#

unless i store the data in the chunk files i cant tell if that happens

#

but as i said earlier i dont want to leave data garbage behind if the plugin gets removed

dense goblet
#

you know it got wiped if it is loaded and the event says its a newly generated chunk

#

also unless you're on paper you can't store your own data in the chunk data

#

I just have my plugin world data folder in the world folder

#

and write my data files there

#

so if you wanna clear the data after removing the plugin you just remove that folder from the world folder

smoky oak
#

I see

#

whats the event call?

dense goblet
#

ChunkLoadEvent iirc

smoky oak
#

ok also since there will be only little data, probably only a few dozen to hundred of coordinates saved per player, is it reasonable to keep it all in one big config file?

#

i would rather not introduce a whole new bunch of possible errors if i can prevent it

dense goblet
#

yeah thats fine but you need to keep in mind to clear the relevant data if a chunk is regenerated

smoky oak
#

that i can do

#

thanks

dense goblet
#

also I think you shouldn't be using a config file, just a normal file which you write/read using file input/output streams

#

cause you need to serialise/deserialise the hashmap

smoky oak
#

ah ok

dense goblet
#
FileOutputStream fileOut = new FileOutputStream(chunkSaveFile);
BukkitObjectOutputStream out = new BukkitObjectOutputStream(fileOut);

then just use out.writeWhatever()

#

remember the try-catch and closing the stream

twilit nexus
#

i am trying to create custom mobs and i don't know how

#

i see in videos that people are using net.minecraft.server stuff but whenever i try and look for that stuff, it's not there

#

is there something that i am missing

smoky oak
#

are you importing the packages?

twilit nexus
#

yea but the net.minecraft.server packages aren't there

chrome beacon
twilit nexus
#

so how will i set it up then?

chrome beacon
#

You use the new package names and update the code

twilit nexus
#

sorry if this seems like a dumb question, but what are the new package names?

chrome beacon
#

Depends on what you're trying to access

twilit nexus
#

let's say i wanna make a custom mob based off the cow

chrome beacon
#

net.minecraft.<something>

twilit nexus
#

the net.minecraft stuff isn't there at all

chrome beacon
#

Sounds like you didn't import them

#

Are you using maven?

twilit nexus
#

yea

chrome beacon
#

Rum BuildTools and change spigot-api to spigot in your dependency

twilit nexus
#

will i just run buildtools in the same file as the project?

chrome beacon
#

You can run it anywhere

twilit nexus
#

oh ok

foggy bough
hardy swan
#

Im not very certain how a configuration would save your map

#

Or rather how you would query for them

smoky oak
#
dataFolder = this.getDataFolder();

    public void saveConfig(String where, FileConfiguration config){
        try{
            File file = new File(dataFolder, where);
            config.save(file);
        }
        catch (IOException e){
            e.printStackTrace();
        }
    }```
That produces a directory. Why? 'where' ends on .yml
near crypt
foggy bough
near crypt
quaint mantle
#

little tip, when I switched from eclipse to intellij idea, I realised how bad eclipse actually was and I couldn't switch back, try intellij ;3

hardy swan
foggy bough
hardy swan
#

You will realise how bad are ides

near crypt
#

xD

hardy swan
#

buttons and everything

#

No thanks

quaint mantle
#

holy shit 3 pings in the span of 5 seconds

#

LMFAO

smoky oak
foggy bough
#

here

near crypt
#

Use the windows editor it's the best and it's free and you don't have to install anything

foggy bough
#

think it will work?

smoky oak
#

?paste

undone axleBOT
foggy bough
#

well i gtg

#

bye

terse oyster
#

Anyone know the commands to delete a warp?

hardy swan
near crypt
smoky oak
hardy swan
terse oyster
#

Ahh sorry, thought this was for the advancedTeleport-mod! Sorry!

hardy swan
#

The method looks correct to me

smoky oak
#

so the question is why does this crap create a directory

File dataFolder = this.getDataFolder();
String file = "Savethis.yml";

File read = new File(dataFolder, file);
    if(!read.exists()){
        read.mkdirs();
        try {
            read.createNewFile();
        } catch (IOException e) {
            log(Level.WARNING,"Could not create "+file+"! The plugin will use a empty config!");
            return new YamlConfiguration();
        }
    }
hardy swan
#

Ahh

#

.mkdirs()

smoky oak
#

explain?

quaint mantle
#

Don't you have to do getParent then mkdirs?

smoky oak
#

ah

quaint mantle
#

Would that work

hardy swan
#

Then you will make directory up to parent i think

quaint mantle
#

yeah

smoky oak
#

Cannot resolve method 'mkdirs' in 'String'

#

um

#

i tried

quaint mantle
#

Hm 1 sec

#

getParentFile

#

thats the one

hardy swan
#

Ah yea you need to getParentFile

quaint mantle
#

I really wonder why they made getParent not return the file

#

kinda annoying

hardy swan
#

Watchu mean

quaint mantle
#

like getParent() returns the name/path I think and then there's getParentFile, why couldn't they have just made getParent return the file instead..

hardy swan
#

Erm thats true

next crater
#

can someone give me a basic plugin idea? (not a complex one, but an easy one, for begginers?)

hardy swan
#

Should have been getParentString() or sth

quaint mantle
#

@next crater /discord /twitter

#

basically a Social plugin

next crater
#

hmmmmm

quaint mantle
#

depends on your experience

next crater
#

ok thx :D

quaint mantle
#

: )

#

Yea exactly Solar

hardy swan
#

Lol

#

I think thats pretty basic

quaint mantle
#

He could make it a complicated way πŸ˜‰

smoky oak
#

thats like 6 linkes tho

#

*lines

#

i want to see that made complicated lol

hardy swan
#

But it can teach beginners a lot of things

quaint mantle
#

Configurable, Command handler

hardy swan
#

If you think about it

quaint mantle
#

guis

#

yea

next crater
#

xd lol

hardy swan
#

Firstly it teaches beginners about inheritance

#

How Plugin is a subtype of CommandExecutor

#

Hence the onCommand method for overriding

quaint mantle
#

Or a different class for the CommandExecutor

next crater
#

just to know, there are many ways of doing a command right?

#

I never used CommandExecutor to do a command

#

🧐

#

fuck

quaint mantle
#

Basically yeah - main class, seperate class, reflection

#

and more

next crater
#

right

quaint mantle
#

Annotations

hardy swan
#

Because Plugin already inherit CommandExecutor

quaint mantle
#

the last 2 are advanced ways

next crater
#

HELP

hardy swan
#

Hence you can do in main class

smoky oak
#

dont forget plugin.yml has to declare the command too

quaint mantle
#

Yeahhh but it would be more oraganized

next crater
#

I searched for "commandexecutor pigot" and it appears A POR* SITE

quaint mantle
#

LMFAO okay

smoky oak
#

add a s

quaint mantle
#

yea

#

I think we know what you're searching for a lot now.

#

cookies

next crater
#

nooooo

quaint mantle
#

Because it sure doesn't for me πŸ˜‰

hardy swan
#

Lol

next crater
#

I wrote wrong

#

it was "commandexecutor psigo"

#

xd

hardy swan
#

Are you completely new to programming?

next crater
#

+/-

hardy swan
#

And java is the first language you are learning

next crater
#

no

#

my first language was python for like a month

#

and then java, for like 2 weeks xd

summer scroll
#

So I have like a mysql database to store player's balance and I save them on player quit and load them back on the player join, the thing is when player switching server too fast, the data hasn't saved yet and it load the old data, how can I fix it?

hardy swan
next crater
#

I learned/Im learning the basics, inheritance, polymorphism, objetcs, etc...

hardy swan
#

?learnjava

undone axleBOT
hardy swan
#

Ah ok

next crater
#

yeah, I already saw that, thx :D

#

is that for free?

#

all of them

hardy swan
#

Erm idk lol but the last one definitely is

#

And the official one clears up most misconceptions

hardy swan
next crater
#

@hardy swan how long do you code?

#

Minecraft plugins

summer scroll
hardy swan
#

Yes, but if you afraid player will spam transactions, then save on plugin disable

grim ice
#

can someone help me

#

what are handlers in spigot

hardy swan
summer scroll
grim ice
#

I'm not using them but I want to get better

#

ik theyre related to events and stuff

#

but idk why and how should u use them

hardy swan
hardy swan
summer scroll
#

So at every server I cached the data on hash map.

next crater
hardy swan
#

Ohh

summer scroll
#

When player make transaction I just modified the cache data.

hardy swan
#

I get it

#

Idk lol

quaint mantle
#

Hello I am back πŸ™‚

grim ice
#

that wasnt helpful lol

hardy swan
#

What if transaction took place in multiple servers

hardy swan
quaint mantle
#

redis!

next crater
quaint mantle
#

hi

summer scroll
hardy swan
#

Why not xd

summer scroll
#

To prevent that of course xd

hardy swan
#

Or is it just your plugin rule

#

Oh

quaint mantle
#

What I do with data is load all the users in when the server starts and just cache inside of a map - UUID and the User object

#

So then you can actually interact with players data when they are offline ^

summer scroll
#

I do that too.

summer scroll
#

I want it to sync across servers.

hardy swan
#

his problem is this map isn't accessible in all servers

quaint mantle
#

Ah yea

#

I see now

#

Redis is always the solution

summer scroll
#

I save the data in async, and when player switch server, the data hasn't saved yet so the plugin load the old data instead.

quaint mantle
#

I've actually never used redis myself but something like this could be achieved using it and very easily too

hardy swan
#

ok i do have a solution

#

create an event

#

for transaction processing or sth

#

lmao

summer scroll
#

and save data to the database for every transaction?

hardy swan
#

then have an eventhandler waiting for the event to fire after transaction is done

hardy swan
#

or quit or watever

smoky oak
#
ConfigurationSection spell_section = Echo.world_spell_list.getConfigurationSection(x+"_"+y+"_"+z);
if(spell_section.equals(null)){
  player.sendMessage("No section");
}
else{
  player.sendMessage("Yes section");
}```
this returns either 'Yes section' or nothing at all. Why does the first branch never trigger?
quaint mantle
#

He could create an artificial delay before it loads the players data in - @hardy swan

#

thats probably another solution

hardy swan
#

but you nvr know how long it will take

quaint mantle
#

Yep

#

there are so many things wrong with that...

smoky oak
#

i'm starting to think java is a bit broken

quaint mantle
#

first - static abuse
second - null.equals(null)
third - no } on the else

smoky oak
#

ah its there but i forgot to ccopy it

hardy swan
summer scroll
#

im confused now on how to fixed this

#

since saving in main thread is a no no

hardy swan
#

ok so

#

on player quit or leave or change server watever

#

fire an event after his balance is saved

summer scroll
#

it's on different servers wdym

hardy swan
#

yes but the same plugin

#

oh wait

#

fk i just realised

#

lmao

summer scroll
#

if you fired an event on server1

hardy swan
#

rip

summer scroll
#

server2 can't listen to it, yopu know what i mean

hardy swan
#

yea

smoky oak
#
ConfigurationSection spell_section = Echo.world_spell_list.getConfigurationSection(x+"_"+y+"_"+z);
if(spell_section.equals(null)){
  player.sendMessage("No section");
}
else{
  player.sendMessage("Yes section");
}```
Since i trust myself about as far as i can throw myself i reduced it to this. The result? The same.
#

the upper branch DOES NOT TRIGGER even if the lower branch ALSO DOES NOT TRIGGER

#

what the heck is wrong here

#

the documentation says it is 'null' when its not set

hardy swan
summer scroll
#

FileConfiguration#isConfigurationSection

summer scroll
hardy swan
#

yea..

quaint mantle
#

@quaint mantle

#

oops

#

@hardy swan

hardy swan
#

hello

quaint mantle
#

I've said it 2 times...

#

redis!!!

hardy swan
#

yea

quaint mantle
#

Hahaha

hardy swan
#

credits to ignPurple

quaint mantle
#

poggers

summer scroll
#

but i want mysql πŸ˜₯

vivid temple
#

i am getting a null error in my main class, but i cant figure out how

quaint mantle
#

@summer scroll You use both, redis and mysql, redis can just send a message to a channel and then other servers register on that channel then receive the message

#

then after that you set the currency in the player data

#

most basic explanation ever

summer scroll
#

do you need like a login credentials for redis, like mysql?

#

i never used redis, but i kinda know how redis works

smoky oak
#

FOR FUCKS SAKE

ConfigurationSection spell_section = null;
if(spell_section.equals(null)){
  player.sendMessage("No section");}```
THAT SENDS NO MESSAGE EITHER
summer scroll
smoky oak
#

guys

hardy swan
#

why would sth be .equals(null)

smoky oak
#

i set it to nul

#

why isnt it nul

hardy swan
#

firstly

#

null dont have equals

summer scroll
#

or he needs to use ==?

hardy swan
#

yea

#

lmao misping solaroi

quaint mantle
#

lmao

summer scroll
#

o he's here

quaint mantle
#

hi

hardy swan
# grim ice wdym

ok back to this, if-this-then-that is if something happens, my plugin will do something. That's how most plugins work - you break this block I do this and this, or if this chunk loads I do this and this. That's the answer to why you should use/know eventhandlers

next crater
#
public class Main {
  int x;
  
  public Main(int x) {
    this.x = x;
  }

  public static void main(String[] args) {
    Main myObj = new Main(5);
    System.out.println("Value of x = " + myObj.x);
  }
}
#

I have a question here

#

could I instead of using "this.x = x" use "myObj.x = x" ?

hardy swan
#

I wanted to shout static abuse then realise it is public static void main lmao

hardy swan
#

in this line right

this.x = x
next crater
#

but this = this object, no?

hardy swan
#

where did your myObj come from

#

this is more of a scoping issue

#

your constructor is separate/outside of main method

#

and doesn't have access to this myObj

next crater
#

im seeing it from here

hardy swan
#

the example is correct, it is showing you what this means

quaint mantle
#

@next crater Also, I would suggest declaring a variable as either being public, private or protected, if you want to access it from other places please do "public int x"

ivory sleet
#

this is a reserved keyword in Java which points to the class instance itself.

next crater
quaint mantle
#

interesting

next crater
#

I think I understeand now, thx guys

#

❀️

hardy swan
#

yea it is just an illustration of this from w3schools

#

I think it is confusing to explain this with this.x = x ngl

ivory sleet
#

myes

next crater
ivory sleet
#

as said this is a reserved keyword in Java and is a variable that points to the class instance.

vivid temple
#

this

tpcsurvival.getConfig().set("NPC.banker", npc.getUniqueId());

gets registered as (in my config file)

NPC:
  banker: !!java.util.UUID '9995e3b1-a8ee-4313-9093-e9d2ba709502'

but i never asked for the !!java.util.UUID

hardy swan
#

npc.getUniqueId() is of type UUID

#

you have to get it string before storing

vivid temple
lunar schooner
#

To explain this easily. Consider the following class:

public class Example {
  public void doSomething() {
  
  }

  public static void doSomethingStatic() {

  }
}

In doSomething you have access to this, i.e the current instance of the class, or easier, an instance of Example. However in doSomethingStatic, you dont have access to this, because the function belongs to the class Example, rather than the instance of Example.

vivid temple
grim ice
#

Is there a way to store an ItemStack in a class and use it whenever I want to

hardy swan
grim ice
#

How

hardy swan
#

store it... in a field

lunar schooner
ivory sleet
#
class Example {
  var x; // instance variable
  void set(var x /* parameter variable */) {
    this.x /*<- the instance variable we declared on line 2*/ = x /*<- parameter variable declared on line 3*/;
  }
}```
In the instance method set(x) we declared a parameter by the name `x` also. If we only type x inside the method, it will simply result in the outer x variable not being accessible due to scoping precedence. To access the outer variable x we simple use the keyword `this` separated with a dot and then the variable name.  It is a way to access instance variables as well as instance methods.
lunar schooner
#

Do note, var is to be substituted with the actual type :"D

ivory sleet
#

^

lunar schooner
#

var is (currently) only allowed in lambda functions

ivory sleet
#

its allowed in local scopes

lunar schooner
ivory sleet
#

yeah, havent used it yet btw lol

lunar schooner
#

thats neat

ivory sleet
#

😌

lunar schooner
#

Though I think Ill stick with explicit types

ivory sleet
#

myeah type inference is dangerous tbh lol

lunar schooner
#

yeah in java i'd say definitely

#

it was never designed for it imo

#

in a language like Rust inference is perfectly fine though

ivory sleet
#

yeah

hardy swan
#

meanwhile Kotlin

grim ice
#

How to make a class to store ItemStacks in

next crater
#

what does "instance" means in java?

ivory sleet
#

well only benefit with this is:

Object method() {
  var result = new Object() {
    int i = 0;
  }
  return result.i;
}```
lunar schooner
next crater
#

oh, ok thx

grim ice
hardy swan
lunar schooner
#

so if you have the class Example,

public class Example {}

public class AnotherClass {
  Example e = new Example();
  // e is an instance of Example
}
lunar schooner
heavy void
#

I found the problem ;-

lunar schooner
#

I do recommend though, if you don't know about fields, learn java's basics first

#

iirc there's a bot command for different guides, but I dont remember it

grim ice
#

I read most them

#

most of them

next crater
#

OOOOOOOOOOOOOOOOO

#

Now it makes sense lol

ivory sleet
heavy void
# ivory sleet ah nice

It was importing fromjava import tk.slicecollections.maxteer.cmd.Commands; and not from ```java
import
tk.arthycollections.nitidezjoga.mysterybox.cmd.Commands;

#

To execute the Commands.setupCommands() ;-;

ivory sleet
#

oh lol

#

could have been me honestly

lunar schooner
#

I want Java 17 already T_T

next crater
#

@lunar schooner @ivory sleet @hardy swan Thx ❀️ have a great day

lunar schooner
#

IIRC, we're getting JEP 412 then :poggers:

ivory sleet
#

ah yes sealed

grim ice
#

anyone

ivory sleet
#

😌

grim ice
#

?learnjava

undone axleBOT
lunar schooner
grim ice
#

1s

ivory sleet
#

I mean thats the one I care about lol but yeah

lunar schooner
#

So much better than all the JNI glue πŸ˜‚

#

once that API stabilises, I might just write a Bukkit API library for Rust πŸ€”

ivory sleet
#

oh that thing

#

is it suppose to replace unsafe in the long run?

lunar schooner
#

I work with native code, and so JNI glue a lot, so definitely excited for it :"D

#

I dont think so

#

it adds to JNI and sun.misc.Unsafe iirc

ivory sleet
#

ah okay

lunar schooner
#

though they do want sun.misc.Unsafe gone

ivory sleet
#

hmm yeah heard that somewhere else

lunar schooner
#

or rather, JDK internal only

ivory sleet
#

after all the name hints why lol

grim ice
#

@lunar schooner

lunar schooner
#

its still required for some things

#

like all Atomic types

grim ice
#

none of the websites i checked

#

have java fields

ivory sleet
#

oh yeah true

#

2Hex what's the issue?

lunar schooner
#

I did read in the JEP that they want to eventually phase out JNI though, as it's a disaster for safety

grim ice
lunar schooner
#

since things like final fields aren't at all final anymore

grim ice
#

so i can access the itemstack whenever i want

#

He told me to learn java

#

I can't find

lunar schooner
grim ice
#

its legit first link in google lol

lunar schooner
#

Exactly :"D Should have all resources needed

ivory sleet
#
class Wow {
  private ItemStack stack;

  public ItemStack getStack() {
    return stack;
  }
}
hardy swan
#

bruh i can imagine everyone abusing sealed in the future

lunar schooner
ivory sleet
#

yeah its basically gold in terms of writing code defensively

hardy swan
#

so you restrict what classes can extend or implement you

lunar schooner
#

does reflection remain unaffected?

ivory sleet
#

yeah in principle

#

its a compile time feature allowing a superclass to explicitly whitelist a set of classes, only each class contained in the set is then allowed to derive from that supuerclass.

grim ice
hardy swan
#

i have only heard of null pointer exception

#

exception != error

#

but yea sure just send pastebin here

ivory sleet
grim ice
#

I want to store an itemstack in a close to use it wherever I want

hardy swan
#

exception is exception, something special that occurred. error is something that wasn't even expected to occur

ivory sleet
#

no like what are you doing as a whole

grim ice
#

i just wanna do it

#

is it possible

ivory sleet
#

necessarily just having a field wont solve it

grim ice
#

then

#

is it even possible

lunar schooner
#

Everything is possible, if you abuse the system enough πŸ˜‡

next crater
#

o

hardy swan
#

press x to doubt

#

?paste

undone axleBOT
hardy swan
#

wont need an account^

grim ice
#

anyone'

hardy swan
#

and the error? paste to a separate bin

lost matrix
grim ice
#

I wanna store an itemstack in a class to access it whenever i want

#

@lost matrix

lost matrix
#

Your yml might not be in the exported jar. Open it with winrar and check

lunar schooner
# grim ice then

We need some more context first πŸ˜„

Essentially to stash a ItemStack, or any object for that matter, in a class is easy:

public class Example {
  public ItemStack is;
}

public class PluginClass extends JavaPlugin {
  public void onEnable() {
    Itemstack i = new ItemStack(Material.STONE);
    Example e = new Example();
    e.is = i;

    // You can now use the ItemStack by doing e.is
  }
}
lunar schooner
#

Of course, there are definitely more idiomatic ways of doing it, like setting the field is using a constructor

grim ice
#

o ty

hardy swan
#

yes, it is an issue with new Main()

#

you re-instantiated your plugin

#

uhh, more like

public WordCommand(JavaPlugin plugin) {
  this.plugin = plugin;
}
#

then you will have

Bukkit.getScheduler().runTaskLater(this.plugin, new Runnable() ...
lost matrix
#

You should try to distribute your one instance of JavaPlugin you have to other sources that need it.
One example is the often used Singleton patter where you store the instance in a static field with a getter.

#

Open the exported jar and check if the plugin.yml is on the root path

quaint mantle
#

How would i cancel the event of drawing back a bow?

grim ice
#

pretty sure it wouldnt work

lunar schooner
#

haven't ever tried it, but you could probably even make the field final

public class PluginMainClass extends JavaPlugin {
  public static final PLUGIN_INSTANCE;

  @Override
  public PluginMainClass() {
    PLUGIN_INSTANCE = this
  }

  @Override
  public void onEnable() {
    ...
  }
}
hardy swan
grim ice
#

the one u sent before doesn't work lol

lost matrix
#

In your main class:

private static MyPlugin instance;

public static MyPlugin getInstance() {
  return instance;
}

public void onEnable() {
  instance = this;
}

The just call MyPlugin.getInstance() where you need it

quaint mantle
lunar schooner
lunar schooner
#

Actually, let me check that

grim ice
#

it would prob say smth like cant resolve symbol 'Example'

grim ice
hardy swan
#

jar -tf <filename>

lost matrix
#

Dont make it public pls.
Some other dev could see this and just do MyPlugin.plugin = null; and ppl will run to you telling your plugin doesnt work

lunar schooner
quaint mantle
#

java -jar

lunar schooner
#

They can set it from another plugin

#

(Though they can too if you make it private, but then they're just assholes)

#

so do we have any folk here also familiar with Rust (rustlang, not the game)

#

I had a little Java idea, not necessarily related to Spigot, but could be used for Spigot nontheless

grim ice
#

lol

hardy swan
lunar schooner
#

you can use java xf <jar file> too

#

to unpack the jar

hardy swan
#

jar should be a operable program directory

lunar schooner
#

It isnt on my system

#

Using Ubuntu 20.04, with openjdk-16-jdk-headless installed

hardy swan
#

hmm

grim ice
#

anyone how to store an itemstack in a class to access it whenever i want

lunar schooner
hardy swan
grim ice
#

didnt understand it

#

u made it more complicated

#

lol

hardy swan
#

isn't runnable a cancellable

#

fk it isn't

ivory sleet
#

BukkitRunnable or pass a Consumer<BukkitTask> inside the scheduler

#

?scheduling ftr

undone axleBOT
lunar schooner
#

are we talking Java's Runnable or BukkitRunnable?

grim ice
#

e none of this was helpful

#

ill just give up

lunar schooner
hardy swan
#

but maybe you can kill the entire thread or sth

ivory sleet
#

BukkitTask

#

?scheduling

undone axleBOT
ivory sleet
#

read that ^

lunar schooner
ivory sleet
#

it goes over canceling

hardy swan
#

I know, im not talking about BukkitRunnable, just pure java

#

and I know BukkitRunnable has a cancel()

#

or maybe "canceling" is just killing the thread i guess

sand rune
#

Guys how to make the owner in the top of the tab list ???

hardy swan
#

yes;no

hardy swan
# sand rune .

which step are you stuck at, finding "owner" or making him on top

next crater
#

what is the difference of using for-each loops and for loops?

#

oh nevermind

#

for-each = every value/object

#

for loop = repeat X times

hardy swan
#

more like, repeat until a condition is false

next crater
#

thx anyways :D

hardy swan
#

is there an existing way that the class instance is passed to that class of interest>

#

if they are static in A, then the other class, B, just need to call using A.var1

#

provided they are public

#

if not, write a getter

undone axleBOT
bronze notch
#

Do I need to still check if I am able to cast this HumanEntity to a Player, as it says in the description that we're talking about a player.

hardy swan
#

ah, then you could just put this bukkittask in a field too

bronze notch
#

I won't receive an error, as only players will be opening the inventory. But why does this method return a Player would be the bigger question πŸ™‚

hardy swan
#

or you can use a callback from class B

unique eagle
#

Hello i search to use hex color in scoreboard can you help me ? πŸ™‚

hardy swan
#
this.runningTask = Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {...);
#

or you can add to a list

next crater
#

When do I use ArrayLists and LinkedLists? (they look the same for me 🧐)

hardy swan
#

I realise you may not want it, but an example would be

Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {
  @Override
  public void run() {
    B.addRunning(this);
  }
);
#

not even sure if it will work

#

cancel in B, yes

#

yea you should use first one, cuz second one passes in a Runnable, not BukkitRunnable

#

Or you can even do this to pass in the bukkitrunnable

B.addRunning(Bukkit.getScheduler().runTaskLater(Main.plugin, new Runnable() {});
next crater
#

are LinkedLists useful in spigot development?

#

or should I only use Arrays?

hardy swan
#

data structures are subjective to its use, you nvr know

#

if you ever want an implementation of a queue

#

then of course you would pick LinkedList

rancid ivy
#

Hey, my server port forward wont work although I have followed all steps in common guides, anyone know what may be the problem?

hardy swan
rancid ivy
#

oh

#

ok

unique eagle
#

Hello how to use hex color in scoreboard can you help me ? πŸ™‚

unkempt otter
#

Does factions have placeholders?

hardy swan
unique eagle
#

thank you πŸ™‚

hardy swan
unkempt otter
#

Were do I find them?

hardy swan
unkempt otter
#

thank you

fast fjord
#

alright quick question with GUI's. Basically I am trying to create a GUI that when clicked it opens up another GUI. That part works and I am trying to add a back button to go back to the initial page. Initially I tried to just have the player dispatch the command to open the original GUI on click, but that does not seem to work. Any suggestions?

quaint mantle
quaint mantle
cinder plume
#

Guys , I need help

I want to use a command to start a scheduler task but I have no idea how to use schedulers and commands together in such a way that commands trigger the schedulers

Please help

quaint mantle
#

?scheduling

undone axleBOT
quaint mantle
hybrid spoke
quaint mantle
quaint mantle
fast fjord
#

bukkit.dispatchCommand

quaint mantle
hybrid spoke
narrow vessel
#

would anyone mind telling me why Bukkit.getEntity(UUID) does not work while using spigot API but does work while using paper API

#
UUID scrn_l = bmv.main_world.spawnEntity(loc_l, EntityType.ARMOR_STAND).getUniqueId(); 
((ArmorStand)Bukkit.getEntity(scrn_l)).setRightArmPose(new EulerAngle(0,0,0));
onyx basin
#

Hello, how to prevent "moved too quickly!" message while using Entity#teleport method?

narrow vessel
#

i get a nullpointerexception

#

java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.ArmorStand.setRightArmPose(org.bukkit.util.EulerAngle)" because the return value of "org.bukkit.Bukkit.getEntity(java.util.UUID)" is null

fast fjord
cinder plume
# quaint mantle ?scheduling

Like I want the player to enable the scheduler with a command, and i didnt understand what it is from the link given

so like can BukkitSchedulers be used inside classes that have implemented CommandExecutors ? because BukkitRunnable cant be used inside that

quaint mantle
#

can i see ur code?

fast fjord
#

oops

#

but ye

unkempt otter
fast fjord
#

if (event.getSlot() == 0) {
event.getWhoClicked().closeInventory();
Bukkit.dispatchCommand(event.getWhoClicked(), "powermenu");
}

quaint mantle
#

what does /powermenu do?

hardy swan
unkempt otter
#

ok thx

fast fjord
quaint mantle
#

ye show me that code

fast fjord
#

ok

quaint mantle
#

of /powermeny

fast fjord
#

ye

quaint mantle
#

/powermenu

fast fjord
#

fyi its in a seperate class

quaint mantle
#

ye

fast fjord
#

all that stuff

quaint mantle
#

use the ` 3* then text then the thing 3x again

fast fjord
#

ok

hybrid spoke
#

?paste

undone axleBOT
quaint mantle
#

onPlayerCOmmandPreprocess????

#

wat language are u coding in

hybrid spoke
fast fjord
#

java

narrow vessel
#

java

hybrid spoke
#

not brainfuck? lame.

quaint mantle
#

thats not how u make commands

hybrid spoke
#

depends

fast fjord
#

essentially does the same

#

anyway

next crater
#

onPlayerCommandPreprocess 😱

quaint mantle
#
public class ExampleCommand implements CommandExecutor {
    @Override
    public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
        return false;
    }
}
``` use this xD
fast fjord
#

i know how it works lmao

fast fjord
#

its a package from intellij

quaint mantle
fast fjord
#

ye

hybrid spoke
#

NotNull is unnecressary, args = strings???

next crater
quaint mantle
hybrid spoke
#

your settings are weird

hardy swan
#

it is just an annotation, leave it if you like

hybrid spoke
#

no @hardy swan

#

its more than a opinion

quaint mantle
#
<dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.destroystokyo.paper</groupId>
            <artifactId>paper-api</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
hybrid spoke
#

its the unwritten spigot coding convention

cinder plume
#

guys can someone guide me through how i can start a scheduling through commands , bcuz idk

hybrid spoke
#

?scheduling

undone axleBOT
fast fjord
#

so can we get back to my initial question aboutmygui

#

lmao

cinder plume
hardy swan
hybrid spoke
cinder plume
#

i need someone to help me out a bit i got a few doubts , but lot of people are msging here

fast fjord
#

what i do xD

hybrid spoke
hardy swan
#

oh, it doesn't have that originally?

#

ok then haha

hybrid spoke
# fast fjord what i do xD

first: the event you are using for your command is just for monitoring. second: opening a gui with executing a command is okay but wrong. third: ew

cinder plume
#

can someone help me out with scheduling doubts?

fast fjord
#

😦

#

fine then ill go make the thing a command

#

be back in 10

hybrid spoke
#

so no need to bring it up

cinder plume
#

@hybrid spoke can you help me out?

#

i want to start a scheduling with commands , how do i do it.

hybrid spoke
#

just start a scheduler at your oncommand

cinder plume
#

then i cant do getserver()

#

how can i put it in the oncommand when getServer method is not possible inside it?

unkempt otter
hardy swan
#

they linked to a wrong faction spigot page

unkempt otter
#

lol

hardy swan
#

it is for Factions UUID

cinder plume
#

@hardy swan can you help me out with my doubt?

hardy swan
hardy swan
#

hmm, is this method in your main class?

cinder plume
#

no its in another class

hardy swan
#

that's why, getServer is a JavaPlugin method

cinder plume
#

im initiating the scheduler in another class

fast fjord
#

so basically i changed it to onCommand

#

and now it works

heavy void
#

Someone knows how can i change my block face in spigot 1.8 ..

#

1.8_R3

cinder plume
#

@hardy swan
so basically my objective is to initiate the scheduler with a command , thats why i put it in that command class

hardy swan
#

You will have to either pass your plugin instance to that class, or Bukkit.getServer()

cinder plume
#

oh so i do bukkit.getserver() in the other class?

hardy swan
# cinder plume

from here im assuming that you are trying to get the server singleton right?

cinder plume
#

okay wait i think i figured it out , let me try this ill tag u if it doesnt work

#

thanks

hardy swan
unkempt otter
#

yes

hardy swan
#

and you did run /papi ecloud download Factions

unkempt otter
#

i did not

hardy swan
#

maybe that's it?

unkempt otter
#

ok

heavy void
#

Someone help me, pls.
I want to know how to change a block face in Spigot 1.8_R3.

quaint mantle
#

this doesnt work

#

it doesnt shoot

#

but it still pulls it back

quaint mantle
cinder plume
#

?paste

undone axleBOT
quaint mantle
cinder plume
#

no wait im talking to someone bout the error right now

quaint mantle
#

send it too

#

i wanna see

cinder plume
#

ok

#

wait

ivory sleet
#

The more the better

dense goblet
#

so seems like an EntityDamageEvent with the damage cause set to PROJECTILE does not modify the final damage if the target has projectile protection

#

does that mean I just have to modify it myself by checking the armour?

cinder plume
#

Its a classcasterror

quaint mantle
#

so i used skript for a while, right? but i knew basic java, kinda learned more in the last month or so for java.. still confused about BukkitRunnables

cinder plume
#

classcast exception

quaint mantle
#

i.e; how do i "wait 1 tick" or etc.

quaint mantle
#

where did these messages come from

dense goblet
#

you can have the execution delayed or repeated

quaint mantle
#

so new BukkitRunnable() (etc.)

@ovverride
public void run()
//stuff

}.runTaskLater(stuff here)?

#

obviously im better at code than that

#

plex forgev

undone axleBOT
ivory sleet
#

It tells you about that

quaint mantle
heavy void
#

Someone help me pls bruh.

dense goblet
#

not sure if this is how it works in reality but imagine you have a queue of runnables, each assigned a time when it should execute. So you have runnable A to execute on tick 100, B to execute on tick 110, and C to execute also on tick 110. Every tick you execute all the runnables scheduled for that tick one after the other.

#

so it would get to tick 100, execute A, then get to tick 110 and execute B and C

quaint mantle
#

i see

rotund pond
#

?help

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

selfrole Add or remove a selfrole from yourself.

**__Cleanup:__**

cleanup Base command for deleting messages.

**__Core:__**

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

**__CustomCommands:__**

customcom Base command for Custom Commands management.

**__Downloader:__**

findcog Find which cog a command comes from.

**__Mod:__**

names Show previous names and nicknames of a member.

**__ModLog:__**

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

**__Permissions:__**

permissions Command permission management tools.

dense goblet
#

all the logic inside the runnables happen in one tick, the waiting is done before the first line of the runnable is executed

rotund pond
#

insane

quaint mantle
dense goblet
heavy void
#

yes

eternal oxide
heavy void
#

in 1.8_R3

dense goblet
#

what do you mean change a block face

grim ice
#

huhuhuhuh

heavy void
#

Like BLOCKFACE.NORTH etc...

#

Idk how to change the block facing direction in 1.8_R3

grim ice
#

do they

eternal oxide
#

Thats an Enum, keep going, when you get to an actual question we can answer we'll let you know

cinder plume
#

@quaint mantle thanks a lot , ill take a look at it , i need to understand too

grim ice
#

by the way

#

anyone knows how to remove an item from existence after a certain amount of time

eternal oxide
#

Blocks can have a facing

heavy void
eternal oxide
#

We still don;t understand your question

#

What do you mean change BlockFace

heavy void
#

I want to know how to change the block direction

quaint mantle
eternal oxide
#

setFacing()

dense goblet
#

you mean to change which way it is facing right

#

yea that ^

heavy void
#

I said, in 1.8

dense goblet
#

why 1.8 ;-;

eternal oxide
#

good luck in 1.8 its a data bit

dense goblet
#

just get a 1.8 pvp plugin

heavy void
#

bruh

grim ice
#

Get the block state
check if state is instance of Directional
cast to Directional
get direction
change the block type
set direction

#

copied from forums

eternal oxide
#

Not in 1.8

cinder plume
grim ice
#

anyone knows how to remove an item from existence after a certain amount of time

grim ice
dense goblet
#

2019 so it is post-1.8

heavy void
#

The most of the big developers still using 1.8 version ' -'

dense goblet
#

who?

eternal oxide
#

1.8 is 10 years old and an unsupported API

grim ice
#

anyone knows how to remove an item from existence after a certain amount of time of its creating?

eternal oxide
#

however, facing in 1.8 is a data Byte on teh block when you set Type(Material, Byte)

dense goblet
#

1.8 was released closer to minecraft's original 2009 debut than to today lol

#

it is like developing for pre-beta, pre-alpha, pre-infdev, etc. when everyone was playing 1.7.10

quaint mantle
#

alright i still need help w/ the runnables

gentle meteor
#

Its me again with being cursed with CraftBlock, why does World.getBlockAt() sometimes return CraftBlock

quaint mantle
#

everythings valid, right?

#

it all sets

#

i just want it to set one block at a time delayed by one tick

#

so one block sets, then the next, etc.

eternal oxide
# quaint mantle

getBlockAt will always return a Block, which has an Implementation of CraftBlock

eternal oxide
#

yep

quaint mantle
#

GG

eternal oxide
#

screen scrolled πŸ™‚

quaint mantle
eternal oxide
#

Your need to increase teh delay on yoru runnable by 1 tick for every additional block

grim ice
#

@eternal oxide do u have an idea

#

how to remove an item from existence after a certain amount of time of its creating

gentle meteor
chrome beacon
eternal oxide
#

^

grim ice
#

the player can just

chrome beacon
#

?scheduling

undone axleBOT
grim ice
#

put it in the crafting grid

#

or

#

hold it

#

or put it in a chest

chrome beacon
#

Yeah then you remove it from there

#

You will have to track the item yourself

grim ice
#

how

gentle meteor
grim ice
#

pcd

quaint mantle
grim ice
#

?

chrome beacon
#

Events

grim ice
#

oh god

#

im not making an event for every way a player can move an item nty

chrome beacon
#

What did you expect

quaint mantle
#

i thought thats what i did lol, ElgarL

#

i'll move it after the if(

#
        ((Directional) block.getState()).setFacingDirection(BlockFace.EAST);
        block.getState().update();```
#

Try using this ^

eternal oxide
eternal oxide
gentle meteor
quaint mantle
#

i'll put it after the if

eternal oxide
#

your delay is always 1

quaint mantle
#

infact i already did put it after the if

#

i hope that helps?

#

honestly runnables confuse me idk why

quaint mantle
quaint mantle
eternal oxide
#

You have to use teh state you set the direction on

gentle meteor
chrome beacon
#

Did that interface even exist in 1.8?

quaint mantle
eternal oxide
#

Directional does not exist in 1.8

quaint mantle
quaint mantle
eternal oxide
#

a State is a snapshot of the current block. any time you call getState you get a new copy

#

discarding yrou old one

quaint mantle
#

idk whta i expected from movong it tbh

eternal oxide
quaint mantle
eternal oxide
#

yes, you need to increment that delay for every block you process

quaint mantle
#

it is int += other int to add to an int?

#

because + is for construcotrs

#

specifically strings

eternal oxide
quaint mantle
#

So it would work then..

#

Also im lookin into it more tbh, And you can do a BlockState which would require a MaterialData

eternal oxide
#

Only if you use the same BlockState

rose aspen
#

Well okay πŸ˜„

How to spawn Fake Items(Clientside Items) with ProtocolLib in 1.17 ?

quaint mantle
#

Fake Items?

rose aspen
#

Yes an Item, that is only clientside

quaint mantle
#

like one on the floor?

rose aspen
#

Just like spawning an Item but clientside

rose aspen
chrome beacon
#

I recommend taking a look at PacketWrapper

rose aspen
#

Is PacketWrapper not outdated ?

chrome beacon
#

Protocollib hasn't changed much

quaint mantle
#

Take a look here ^

#

By the look of it you'd need to do the following

PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(item.getTypeId());```

((CraftPlayer)pl).getHandle().playerConnection.sendPacket(packet);


location.getWorld().dropItemNaturally(location.add(2D, 0D, 0D), item);

#

Something like this ^

quaint mantle
#

ow lmfao

#

nvm then

rose aspen
heavy void
#
BlockState blockstate = this.block.getState();
    Directional blockdir = ((Directional) blockstate);
    blockdir.setFacingDirection(BlockUtils.yawToFace(this.location.getYaw(), false));
    blockstate.update();
``` Maybe this will work?
quaint mantle
#

Try it out

chrome beacon
rose aspen
heavy void
#

BlockUtils has only the public yawToFace snip

chrome beacon
#

Worst case take a look at wiki.vg and see what the packet contains and set the contents

gentle meteor
#

i am a genious of breaking stuff, somehow a blockbreak event returns CraftBlock instead of block

@EventHandler(priority = EventPriority.LOWEST)
    public void onBlockBreak(BlockBreakEvent event) {
        Bukkit.getLogger().info(event.getBlock().toString());
    }
CraftBlock{pos=BlockPosition{x=71, y=77, z=-53},type=BIRCH_LOG,data=Block{minecraft:birch_log}[axis=y],fluid=net.minecraft.world.level.material.FluidTypeEmpty@670b3ca}```
#

any ideas on why

chrome beacon
#

CraftBlock is the implementation

heavy void
gentle meteor
iron condor
#

how does the VillagerReplenishTradeEvent work? did not quite understand it

#

and this getBonus() Get the bonus uses added.

rose aspen
gentle meteor
gentle meteor
chrome beacon
heavy void
#

My outdated spigot 1.8 is working fine, lol.

#

Idk why your latest version is wrong

#

I think that is your code

quaint mantle
#

alr

#

idk if im stupid

rose aspen
#

Then thank you πŸ™‚

quaint mantle
#

PS: i tried d + 1 and d += 1

#

because i see that around

#

idk what im doing wrong anymore

#

d is set to 0

#

private int d = 0;

heavy void
#

Youre using runTaskLater

chrome beacon
quaint mantle
quaint mantle
heavy void
#

Idk, i never used runTaskLater, but the name...

chrome beacon
quaint mantle
#

ahhh,

gentle meteor
# chrome beacon Show me what you're doing

Basicly i get the block (or should get the block) and then cast it into leafs so that i can get the range from a log without writing 3d range code by myself

so the thing that crashes is

@EventHandler(priority = EventPriority.MONITOR)
    public void onBlockBreak(BlockBreakEvent event) {
      final Block block = event.getBlock();
      Leaves leaves = (Leaves) block.getBlockData();
    }

but perplexingly on the leaf decay event it totaly normaly returns a instance of Block

#

But if CraftBlock shows its ugly head ere it returns (for some reason) CraftBlockData wich ofc cant be cast to leaves

chrome beacon
kind coral
#

hi guys, im finally getting into sql, how could i connect to the database offered by spigot?

#

like i mean how to use the connector

chrome beacon
gentle meteor
heavy void
#
import org.bukkit.event.block.BlockBreakEvent;
``` lol...
#

wait

#

My control + v dont worked

worldly ingot
kind coral
heavy void
#
 org.bukkit.craftbukkit.v1_8_R3.block.CraftBlockState cannot be cast to org.bukkit.material.Directional
``` lol...
#

' -'

fathom nova
#

Hey, anyone here know how to get the server folder name?

kind coral
fathom nova
#

or the server name

kind coral
worldly ingot
#

Was just checking you weren't using the Ebean database because it doesn't exist post-1.13 ;p

#

Or 1.14, whenever it was removed

fathom nova
quaint mantle
#

rl pleadingsheesh

kind coral
#

i am using 1.8.8 still sadly

quaint mantle
heavy void
kind coral
quaint mantle
#

i gotta add 1.8 support because so many server owners still use it
proxy interface intensifies

kind coral
#

or just loading that properties file with an inputstream

heavy void
#

You cant get the folders before the server folder

gentle meteor
kind coral
gentle meteor
#

not the same but simalar

quaint mantle
#

when i open a player's inventory, does it call inventorycloseevent?

heavy void
fathom nova
quaint mantle
#

?stash

undone axleBOT
fathom nova
#

I only want the bungeecord server name or the directory name

kind coral
fathom nova
#

In 1.17 by default I don't have the server-name property

heavy void
fathom nova
gentle meteor
# heavy void You solved?

no been banging my head on it for 1day and a couple of h, since nobody on this earth seems to know why is this happening

kind coral
#

get the path of the world container and go backwards one time, that should return the path of the server

chrome beacon
fathom nova
#

hoping it works 🀞

gentle meteor
#

Just did some sanity checks with the logger

#

it seems that the on break event returns CraftBlock

heavy void
#

Why blocks are so...

#

I think minecraft dont needs blocks ..

chrome beacon
#

You can cast CraftBlock to Block if you want

worldly ingot
#

Any instance you fetch from Bukkit, if it's an interface, it will return and print its implementation because that's just the default toString()

worldly ingot
#

Blocks are CraftBlocks, Entity is a CraftEntity, Server is a CraftServer, etc.

quaint mantle
#
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
    Player player = (Player) event.getPlayer();
    String key = getKey(event.getInventory());

    if (key == null || key.equals("shop")) return;

    new BukkitRunnable() {
        @Override
        public void run() {
            final String newKey = getKey(player.getOpenInventory().getTopInventory());

            if (newKey == null) {
                player.openInventory(manager.getInventoryMap().get("shop"));
            }
        }
    }.runTaskLater(shop, 1);
}

this just says if its already on the shop page, let it close
else, if the new inventory is a key then let it

fathom nova
#

Bukkit.getWorldContainer().getParent() returning null

#

so is getParentFile()

paper geyser
paper geyser
#

hmm?

chrome beacon
#

What isn't working

paper geyser
#

im not quite sure but I atleast know that this

        Plugin plugin = Bukkit.getPluginManager().getPlugin("MCBTRPG");
        Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
            @Override
            public void run() {
                for (Player player : Bukkit.getOnlinePlayers()) {
                    if (getPlayerMana(player) >= getPlayerMaxMana(player))
                        player.sendMessage(getPlayerMana(player) + "/" + getPlayerMaxMana(player));
                    addMana(player, 2);
                }
            }
        }, 0L, 20L);```
isn't running
#

WAIT

#

shhhhh