#help-archived

1 messages ยท Page 81 of 1

brisk mango
#

Wdym singleton

marsh nova
#

you stated

runic wadi
#

all enums are singletons

marsh nova
#

nah it can return false even if its equal

#

which is patently untrue

runic wadi
#

they possess a single instance

#

enums cannot be instantiated

marsh nova
#

#equals cannot return false if reference equality is true

runic wadi
#

unless equals is overridden

marsh nova
#

it can't be overridden in enums

frigid ember
#

how many of you here have studied software engineering at uni here

runic wadi
#

i am a software engineer of 40 years

frigid ember
#

wow nice

marsh nova
#

Not me. I started learning Java last summer, so not even a year.

frigid ember
#

what languages

brisk mango
#

Singletons are in classes not in enums, an enum is an constant not a singleton @runic wadi

runic wadi
#

an enum is a singleton

frigid ember
#

wtf is a singleton

brisk mango
#

yeah I assume when you're so shit at java that ur arguing over nothing with more experienced people, and say .equals is a common practice to use on enums

runic wadi
#

in fact an enum is the best way to enforce a singleton

marsh nova
#

What I find ironic is the amount of users who claim they have so much experience but don't know these basic terms.

brisk mango
#

its not @runic wadi

marsh nova
#

I do not mean offense.

runic wadi
#

yes, actually enums are singletons

#

that is true

velvet halo
#

I am studying software engineering atm

frigid ember
#

cool

#

do you study java?

velvet halo
#

No c++ and C

frigid ember
#

damn

brisk mango
#

@runic wadi retarded

velvet halo
#

Java is similar anyways...

marsh nova
#

This is so incredibly hilarious because I'm the only one who noticed that temedy asserted that the same condition can produce different results.

frigid ember
#

it has its differences

#

c++ object orianted

#

c is not

velvet halo
#

Yeah but if you learn c++ it is easy peasy to learn java

#

Same goes for C#

#

a language easy to learn

frigid ember
#

c#?

marsh nova
#

Further, I find it ironic that users who claim so much experience are arguing over Java basics.

frigid ember
#

is that some windows applications crap

runic wadi
#

why is he saying enums aren't singletons ๐Ÿ˜‚

marsh nova
#

For instance, enums are technically not singletons because there are multiple instances of the enum.

brisk mango
#

Its not the same condition, but no point arguing with someone that has basically no experience and probably coding some shit plugins in spigot and some real shit code, no shit when youve started java in summer and ur tryna act like ur smarter than everyone and arguing with more experienced people @marsh nova

runic wadi
#

okay that is wrong

brisk mango
#

There is no multiple instance of an enum, its a static final

runic wadi
#

an enum is one instance

brisk mango
#

and singleton is used whenever u wanna get 1 instance of a class instead of creating an new instance

frigid ember
#

decompiling java programs is ez

marsh nova
#

temedy, it is so ironic that you think because I have only started Java last summer that you are somehow entitled to a superior position. Nothing could be more wrong.

brisk mango
#

its basically a static method like getInstance()

#

well it seems like it, you are really shit at java if you think its common practice to do stuff that isnt common practice

#

im not arguing with you anymore

#

basically, theres no point when u cant understand a thing

velvet halo
#

I think it is good to accept criticism from people who have more experience. (Something I was bad at accepting but it helps me alot )

#

It isn't a competition

frigid ember
#

facts solve problems

#

so send proof

#

lol

velvet halo
#

People with more experience generally try to help so you can take it or leave it

#

up to you

marsh nova
#

temedy, I also find a few more things odd. First, you would think that one's tendency to use #equals indicates poor programming in that user's entirety. Second, you think that the person you are speaking do "cant understand a thing" merely because you realise you've said something wrong.

brisk mango
#

I havent said nothing wrong?

runic wadi
#

actually no, you should use equals

#

temedy everything you have said is wrong

velvet halo
#

Guys relax

brisk mango
#

@runic wadi you should stfu because you dont even know what a fucking singleton is

marsh nova
#

So, temedy, in fact, it would rather appear that your great years of experience have failed you.

runic wadi
#

you're wrong

frigid ember
#

what is it that ur arguing about anyway

brisk mango
#

well I was right in everything, u guys just have none java experience so u cant understand at all

velvet halo
#

Can we stop calling people out and just say what is right or wrong?

#

...

#

There doesnt need to be arguments here

runic wadi
#

i'm actually implementing a singleton pattern right now using enums

marsh nova
#

I think neither of you know what a singleton is, at least according to the common definition of the term. A singleton is a design pattern where there is only 1 instance of the class. There are multiple instances of an enum class, one instance for each constant.

brisk mango
#

and singleton is used whenever u wanna get 1 instance of a class instead of creating an new instance

#

"neither of you know what a singleton is"

#

w/e

frigid ember
#

im not very familier with enums i have never used them in practice yet

#

unless i have and i did not know i had

marsh nova
#

That is completely fine.

runic wadi
#

it's good to get started at a young age

velvet halo
#

enums are great with switch statements.

frigid ember
#

lol

brisk mango
#

i think you should learn the difference between singletons and constants

runic wadi
#

click it, it can help you correct your knowledge

frigid ember
#

i know what a constant is

#

its a thing that does not change after initialized

brisk mango
#

noobie plugin dev is telling me to start my education while he doesnt know himself what a singleton/constant is

marsh nova
#

An enum can be used to implement a singleton but enums are not necessarily singletons. Consider the following enum:

frigid ember
#

like pi

#

or e

marsh nova
#
public enum SomeEnum {
  VALUE1,
  VALUE2,
  VALUE3
}
#

that is not a singleton

#

there are 3 instances of SomeEnum

runic wadi
#

each instance is a singleton yes

#

very good

marsh nova
#

The enum itself is therefore not a singleton.

runic wadi
#

enums are one instance, optionally with instance fields and created using a constructor

#

but you cannot instantiate them yourself

#

because there is one inherent instance

#

and that is a singleton

marsh nova
#

There is one instance of each constant in the enum, but there are multiple instances of the enum.

#

Thus, strictly speaking, the enum itself is not a singleton.

runic wadi
#

okay hopefully that attitude gets you places

#

you know what i mean

marsh nova
#

Yes, I know what you mean.

velvet halo
#

I guess I learned something today

runic wadi
#
public enum SingletonEnum {
    INSTANCE;

    int value;

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }
}
velvet halo
#

Never really looked at enums this specifically

marsh nova
#

That SingletonEnum is a singleton but not only because it is an enum, but because it is an enum and there is only 1 constant in the enum.

runic wadi
#

if there are 3 enums instead of 1, each one is a singleton and they are always equal to themselves but not one another

velvet halo
#

I know that an instance is thread-safe but you just have to make sure that methods and data that the instance carries is also thread-safe

marsh nova
#

In the context of Java, a singleton usually refers to a type, such that there may only be 1 instance of a certain class, but I guess you could say, in a sense, that each enum constant is its own singleton.

runic wadi
#

yes that is what they are

#

each singleton has an instance field called "value"

gusty comet
#

Is there method to set/modify the name displayed above player's heads within Spigot/Bukkit?

marsh nova
#

Instances themselves are always thread safe โ€“ assignation is thread safe, reference equality is thread safe. Just ensure that concurrent reads happen to volatile fields where applicable.

#

There is no simple method zen.

#

As far as I know.

gusty comet
#

Is there any complicated methods (if not simple lol) then?

marsh nova
#

Not off the top of my head

frigid ember
#

@gusty comet im pretty u have to use a plugin for that

marsh nova
#

But there are plugins which do that

gusty comet
#

I'm trying to make a plugin to do that lol

#

im making a simple rank and nick system for my personal use

velvet halo
#

You can do it with scoreboard teams if you want to avoid nms

frigid ember
#

im pretty sure the spigot api does not have a direct method to do it

gusty comet
#

damn

#

whats nms?

marsh nova
#

NMS stands for 'net.minecraft.server'

frigid ember
#

i think the scoreboardt teams only adds text to the player's name below

marsh nova
#

meaning accessing implementation details directly

velvet halo
#

but it has to be done with reflection if you wanna do that

marsh nova
#

not necessarily

#

if your project is only for 1 version, you can simply use nms directly

#

if you need compatibility with multiple versions, you can use a multi-module setup and abstraction

velvet halo
#

That is true but I recommend to have to compatibility for multiple versions.

#

So it is future proof.

#

then again... code changes sometimes anyways

marsh nova
#

I prefer abstraction over reflection, because it is easier to manage differences in NMS details.

frigid ember
#

but does scoreboard teams change the actual name above the players head

#

or does it just add a new line of text

marsh nova
#

With reflection your code silently breaks unless you test it. It defeats the purpose of static typing.

velvet halo
#

Yeah that is true.

#

I saw a thread on stackoverflow comparing reflection versus abstraction

#

and it seems the abstraction is faster too

runic wadi
#

pretty sure people use reflection in order to avoid importing version-specific classes

frigid ember
#

@frigid ember scoreboards only add new text. To change the playername you will need to edit the gameprofile or PlayerInfoData packets


    protocolManager.addPacketListener(new PacketAdapter(this, PacketType.Play.Server.PLAYER_INFO) {

        @Override
        public void onPacketSending(PacketEvent event) {
        if (event.getPacket().getPlayerInfoAction().read(0) != EnumWrappers.PlayerInfoAction.ADD_PLAYER) {
            return;
        }

        PlayerInfoData pid = event.getPacket().getPlayerInfoDataLists().read(0).get(0); //get the original packet to set the skin later

        PlayerInfoData newPid = new PlayerInfoData(pid.getProfile().withName(finalName), pid.getLatency(),
            pid.getGameMode(), WrappedChatComponent.fromText(name));

        newPid.getProfile().getProperties().putAll(pid.getProfile().getProperties()); //Set the skin of the new PlayerInfoData to the original skin from the original PlayerInfoData

        event.getPacket().getPlayerInfoDataLists().write(0, Collections.singletonList(newPid)); //Overwrite the packet
String finalName //Name to change player's name to

example using protocollib to not change the name in chat, but only above player head

runic wadi
#

just make lambda metafactories for every nms method you need

frigid ember
#

yeah thats what i thought

runic wadi
#
inline fun <reified F> metafactory(
    process: MethodType.() -> MethodType,
    methodhandlefunc: (MethodHandles.Lookup) -> MethodHandle
): F {
    val lookup = MethodHandles.lookup()
    val methodhandle = methodhandlefunc(lookup)
    val func = methodhandle.type()
    val invoked = MethodType.methodType(F::class.java)
    val callsite = LambdaMetafactory.metafactory(
        lookup, "invoke", invoked,
        func.process(), methodhandle, func
    )
    val factory = callsite.target
    return factory.invoke() as F
}
```metafactory maker ๐Ÿค”
#

makes the factories that make lambdas

#

faster than reflection

#

basically produces a functional interface for every method

velvet halo
#

Have you tested it?

runic wadi
#

yes of course

velvet halo
#

What were the results

runic wadi
#

it's like using nms directly

#

do not recommend using in java though; kotlin extension methods help a lot

velvet halo
#

Yeah I haven't had the need to switch over to kotlin so I am on java atm

#

Could you show me an implementation of the metafactory?

runic wadi
#
val isTileEntity: Any.() -> Boolean = metafactory(MethodType::generic) { l -> l.findVirtual(blockClass, "isTileEntity", MethodType.methodType(Boolean::class.java)) }
#

there now you have a lambda for isTileEntity

#

obviously you need to invoke this on a block

velvet halo
#

Oh yeah I see

runic wadi
#

there is no type safety with Any, but we're not looking for safety if we're doing this shit

frigid ember
worldly heathBOT
frigid ember
#

I know this is probably freaking stupid but How do I purchase plugins? I click buy plugin and it just brings me up say your are purchasing *plugin name and doesnt have a purchase or buy button?

keen moth
#

If there is no paypal set, I don't believe it actually gives you the option to buy it. Otherwise, it should let you click on a button that re-directs you to the paypal payment site.

#

And... he left. lol

quartz quiver
#

Been a few years since I ran a self-hosted bukkit minecraft server and am running into some problems. It is my understanding that I want to run craftbukkit.jar on my server but am having some issues:

  • I got the latest craftbukkit jar from <website link removed upon request> - 1.15.2
  • When run it throws an error claiming it's outdated:
*** Error, this build is outdated ***
*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***
*** Server will start in 20 seconds ***
  • This seems odd since no newer version was listed was the latest and matches the current Minecraft server version number, but I'll bite.
  • I follow the link which redirects to https://www.spigotmc.org/wiki/buildtools/ and unlike the error message only has instructions to build spigot/craftbukkit from source. Sure, let's do that.
  • As detailed there, I download the latest BuildTools.jar and run java -jar BuildTools.jar --rev latest
  • The instructions claim "You can find CraftBukkit and Spigot in the same directory you ran the the BuildTools.jar" but no craftbukkit jar file was created, only spigot-1.15.2.jar

So I'm trying to be a good boy and update so I don't have an error thrown in stderr which is messing up my supervisor and don't have to wait 20 seconds, but as far as I know I already had the latest version, and when I follow the instructions to build from source I also don't seem to get the jar I need.

Any tips on where I went wrong?

velvet halo
#

While it is recommended to use the latest build it isn't really an error. More of a warning

quartz quiver
#

it's output to stderr

velvet halo
#

nvm I didnt' read the question properly

quartz quiver
#

am I misunderstanding that I need 'craftbukkit.jar'? or is the 'spiggot.jar' file output by buildtools sufficient?

red zenith
#

Incidentally, why not just run the spigot jar?

quartz quiver
#

honestly, I wasn't sure what was the API and what was the server to run, heh. if spiggot works then I'll use that

keen moth
#

@quartz quiver Would you please remove the first link in your message?

quartz quiver
#

can do

#

curious, howcome? not affiliated?

red zenith
#

spigot is basically an extension to bukkit, and a drop in replacement

stark salmon
#

Does anyone know how I can make an inventory that you can input a number into

keen moth
#

Legality reasons ๐Ÿ˜›

quartz quiver
#

understandable

#

also, was that 'IReallyKnowWhatImDoing' flag that was posted temporarily real? XD

torn robin
#

it's real yes

red zenith
#

exactly that

torn robin
#

@stark salmon what have you tried?

velvet halo
#
@ECHO OFF
java -Xms1024M -Xmx2048M -DIReallyKnowWhatIAmDoingISwear=true -jar spigot.jar nogui
#

Yes it is real

#

it is to remove the warning message

stark salmon
#

I tried making a normal inventory GUI and using a stack of an item already in it to count with

quartz quiver
#

yep, understandable. I was half expecting one to exist, but hadn't poked at the source yet

red zenith
#

weird, where is it documented?

quartz quiver
#

the whole point is that you are meant to look at source code to see it I'm guessing, thereby proving its claim

stark salmon
#

but it's bad and idk how to detect how many of an item is in a slot

#

can i make a custom sized inventory gui?

velvet halo
#

I don't think so. There has to be 9 columns in each row and up to 6 rows to not break things.

stark salmon
#

oh ok

red zenith
#

So it removes the warning about your server jar being out of date?

velvet halo
#

Yes that is the only functionality for the flag

red zenith
#

should have an alias ImTooLazyToRunBuildTools

velvet halo
#

:3

#

ImTooLazyToUpdateMyBuildTools

red zenith
#

Although there are times you can be too aggressive, I just happened to get lucky enough to update right when a bug was released, woke up the next day and there were way too many mobs everywhere.

stark salmon
#

lol

#

well sorry about the questions but i give up on a GUI how do I get the options passed to the command?

red zenith
#

Do you care how many rows are in your inventory?

#

You just want to be able to figure out the number of items in the stack of a particular slot?

latent rock
#

WTF is wrong with Shockbyte

pastel condor
latent rock
#

They're bragging about ancient Xeons and bragging about how they have the best hardware vs their competitors

#

They literally rent from OVH like everybody else

pastel condor
#

lol

latent rock
#

"We are the biggest provider in Asia Pacific" like i give a fuck on the NA website

pastel condor
#

xD

#

why OVH though

latent rock
#

idk ovh does make a fortune off of resellers

#

funny cuz they told me in an older ticket that they own all their 'revolutionary hardware'

red zenith
#

Well, by revolutionary, they mean it marches around with pitchforks

pastel condor
#

revolting on shockbyte

#

I mean shockbyte is a good name

latent rock
#

revolting abt their sht customer service i bet

pastel condor
#

lol

latent rock
#

yeah im certainly shocked by my experience

pastel condor
#

are they pricey?

latent rock
#

no thyre cheap

pastel condor
#

oh

latent rock
#

but downtime is rampant and their support knows fuck all

#

all they do is copypaste

pastel condor
#

lol

red zenith
#

Well, there's your answer, you get what you don't pay for.

pastel condor
#

I self host lol

#

100% uptime unless theres a power outage

#

my backup battery only lasts for 1 hour

latent rock
#

I switched to Skynode then ovh

red zenith
#

Must be nice, having a serviceable connection

pastel condor
#

VPS?

red zenith
#

Have you tried vms from OVH?

latent rock
#

skynode vps then ovh dedis

red zenith
#

or are you using dedicated?

latent rock
#

yeah

pastel condor
#

omg $66 a month

#

wtf

#

thats insane

latent rock
#

$125 rip

pastel condor
#

for all you know they are just glorified raspberry pies with a price tag

#

"dedicated"

red zenith
#

Hey, that gives me an idea..

red zenith
#

I've got two pi's sitting around doing nothing. Time to start a hosting service

pastel condor
#

xD

#

All my pies are slaved into websites

#

oh wait

#

I have one free one

#

lol

buoyant path
#
    public boolean playerFileExists(String UUID) {
        File playerFile = new File(pluginPath + File.separator + "Players", UUID + ".json");
        return  playerFile.exists();
    }``` how does this throw NPE?
#

I dont get it

red zenith
#

plugin.getDataFolder()?

#

I had some weird issues with using File.separator

#

What's the value of pluginPath?

#
String path = playerFilePath + File.separator + defaultPlayerFile;
File file = new File(plugin.getDataFolder(), path);
buoyant path
#

Im changing the definition of that to the constructor

red zenith
#

That's an example of how I'm using it in one place

pastel condor
#

this is an example of what I do uuidFile = new File(getDataFolder(), "uuid.yml"); if (!uuidFile.exists()) { uuidFile.getParentFile().mkdirs(); saveResource("uuid.yml", false); }

#

idk about the file separator though

#

never used it

red zenith
#

so for example, if your file is in your plugin's data folder: plugins/myplugin/Players/playerUUID.json

// String playersFolderPath = "Players";
// String playerFile = UUID + ".json";
String path = playersFolderPath + File.separator + playerFile;
File file = new File(plugin.getDataFolder(), path);
buoyant path
#

Im working on it lol

red zenith
#

If you're calling this from within your plugin class, then obviously you wouldn't have plugin.getDataFolder(), it would just be getDataFolder()

buoyant path
#

Oh

#

its not even related to that

#

Im stupid

#

I gave an instance of something that hadnt been instanced yet

#

lol

red zenith
#

Yeah that'll do it

buoyant path
#

ffs i hate myself

#

xd

red zenith
#

I think that type of thing comes with the territory, overlooking a small typo or detail, and you debug for hours.
It happens

#

Incidentally, for those of you self hosting or running a dedicated server, what flavor of linux do you use?

buoyant path
#

I mean I've got 5 years of experience

#

and I cant believe I didnt see thruogh it

#

through*

red zenith
#

Lol, I've been programming for probably 35+ years, and it still happens every so often, though more likely because of age at this point.

stark salmon
#

OK so I made a custom command, packaged it and all but the command won't show up

#

I use arch for my server

#

nvm it was an error

#

i found the error

red zenith
#

was it one of those user id 10t errors? I make a those every once in a while.

stark salmon
#

it was something about command description

#
[00:27:09 ERROR]: Could not load 'plugins/VaultToEmeralds.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: commands are of wrong type
        at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:1008) ~[patched_1.15.2.jar:git-Paper-240]
        at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:246) ~[patched_1.15.2.jar:git-Paper-240]
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:166) ~[patched_1.15.2.jar:git-Paper-240]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:148) ~[patched_1.15.2.jar:git-Paper-240]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.loadPlugins(CraftServer.java:359) ~[patched_1.15.2.jar:git-Paper-240]
        at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:234) ~[patched_1.15.2.jar:git-Paper-240]
        at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:895) ~[patched_1.15.2.jar:git-Paper-240]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222-ea]
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
        at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:990) ~[patched_1.15.2.jar:git-Paper-240]
        ... 7 more
red zenith
#

That seems to indicate that a description is supposed to be a Map, and not a String.

stark salmon
#

oh

#

what the fuck is a map

red zenith
#

Where's Dora, when you need her, amirite?

stark salmon
#

like an array kind of thing?

#

lol

red zenith
#

It's a data structure

stark salmon
#

i've used java for years but w h a t

red zenith
#

Uses Keys and Values

stark salmon
#

oh

#

ok

#

do you want to see my plugin.yml

#
main: com.masonmeirs.vaulttoemeralds.VaultToEmeralds
name: VaultToEmeralds
version: 1.0
author: Mason Meirs
description: Converts money to emeralds. 250$ = 1 emerald.
commands:
    convertmoney:
    description: Converts money to emeralds.
    usage: /convertmoney
    permission: vaulttoemeralds.convertmoney
    permission-message: You don't have the convertmoney command permission.
frigid ember
#

Can someone help me load the corners of the map

    @Override
    public void render(MapView map, MapCanvas canvas, Player player) {

    // int mY = maxValue(map.getScale());

    if (switc) {
        map.getRenderers().clear();
        map.getRenderers().add(this);
    }

    worldMap.decorations.clear();
    map.setCenterX(player.getLocation().getBlockX());
    map.setCenterZ(player.getLocation().getBlockZ());
    map.setWorld(player.getWorld());

    for (int x = 1; x < 128; ++x) {
        for (int y = 1; y < 128; ++y) {
        canvas.setPixel(x, y, worldMap.colors[y * 128 + x]);
        }
    }
    }
red zenith
#

What's your end goal? to just reveal the whole area?

frigid ember
#

@stark salmon I would suggest removing the ambiguous symbols

$, =, .
stark salmon
#

ok

frigid ember
#

@red zenith I'm trying to load the corners of the map without the player walking there. What my total goal is, is that I'm trying to zoom in and out of maps, but when I zoom out it sets it to a circle

stark salmon
#

thank you

red zenith
#

So instead of having to use multiple copies of a map, one for each scale, you're creating a system that lets you scale in and out the map, using one item?

stark salmon
#

@frigid ember still same error

#
main: com.masonmeirs.vaulttoemeralds.VaultToEmeralds
name: VaultToEmeralds
version: 1.0
author: Mason Meirs
description: Converts money to emeralds 250 dollars is 1 emerald
commands:
    convertmoney:
    description: Converts money to emeralds
    usage: /convertmoney
    permission: vaulttoemeralds.convertmoney
    permission-message: You don't have the convertmoney command permission.
frigid ember
#

Your spacing is wrong

stark salmon
#

oh

frigid ember
#

indent description and everything after

stark salmon
#

ohh ok

#

im dense as hell how did i not realize

torn robin
#

reduce the indent of convertmoney

#
commands:
  convertmoney:
    description: Converts money to emeralds
    usage: /convertmoney
    permission: vaulttoemeralds.convertmoney
    permission-message: You don't have the convertmoney command permission.
frigid ember
#

Yeah, my bad I did the opposite

red zenith
#
main: com.masonmeirs.vaulttoemeralds.VaultToEmeralds
name: VaultToEmeralds
version: 1.0
author: Mason Meirs
description: Converts money to emeralds 250 dollars is 1 emerald
commands:
  convertmoney:
    description: Converts money to emeralds
    usage: /convertmoney
    permission: vaulttoemeralds.convertmoney
    permission-message: You don't have the convertmoney command permission.
stark salmon
#

wait 2 or 4 spaces

torn robin
#

either or

#

i recommend 2

stark salmon
#

Oh it worked

red zenith
#

but not both

stark salmon
#

thank you

torn robin
#

๐Ÿ‘

stark salmon
#

first plugin lol

torn robin
#

gl lol

stark salmon
#

the code is... mess

#
public  boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            ItemStack emeralds = new ItemStack(Material.EMERALD);
            try {
                emeralds.setAmount((int) clamp(Integer.parseInt(args[0]),0,255));
            } 
            catch(Exception e) {
                sender.sendMessage(e.toString());
                sender.sendMessage("You probably put a negative number or put a very high number. Don't do that.");
            }
            int moneyNeeded = (int) (clamp(Integer.parseInt(args[0]),0,255) * 250);
            if(economy.has(((Player) sender).getPlayer(), "world", (double)moneyNeeded)) {
                economy.withdrawPlayer(((Player) sender).getPlayer(), moneyNeeded);
                player.getInventory().addItem(emeralds);
            } else {
                sender.sendMessage("Not enough funds! $250 = 1 emerald.");
            }
            
        }
        
        return true;
    }
#

just an example

#

of mess

torn robin
#

nice

#

great try without catch for no legitimate reason :D

stark salmon
#

oh for the parseint

#

when the parseint throws an exception

#

like if you put a letter instead of a number or something

torn robin
#

you should use NumberUtils.isInt

stark salmon
#

oh

#

ok

velvet halo
#

Yeah NumberUtils is a good replacement

torn robin
#

if(!(sender instanceof Player))
return false;

#

i wouldn't use the arrow pattern

stark salmon
#

immediately i get an internal error occured while running this command :/

torn robin
#

nice, what's the error?

stark salmon
#

NullPointerException

red zenith
#

The command is registered?

stark salmon
#

yeah

#

i register on the enable

red zenith
#

What's the full error

torn robin
#

it's probably args[0]

#

you aren't checking if the length of args > 0

#

so trying to get args[0] is null

stark salmon
#

it was thrown from my economy variable ...?

#

im confused

frigid ember
#

Where do you set the economy variable

torn robin
#

yeah you probably aren't setting it anywhere

stark salmon
#
package com.masonmeirs.vaulttoemeralds;

import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import net.milkbowl.vault.economy.Economy;
public class CommandEmeralds implements CommandExecutor {
     
    public static Economy economy = null;
    @Override
    public  boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player) {
            Player player = (Player) sender;
            ItemStack emeralds = new ItemStack(Material.EMERALD);
            try {
                emeralds.setAmount((int) clamp(Integer.parseInt(args[0]),0,255));
            } 
            catch(Exception e) {
                sender.sendMessage(e.toString());
                sender.sendMessage("You probably put a negative number or put a very high number. Don't do that.");
            }
            int moneyNeeded = (int) (clamp(Integer.parseInt(args[0]),0,255) * 250);
            if(economy.has(((Player) sender).getPlayer(), "world", (double)moneyNeeded)) {
                economy.withdrawPlayer(((Player) sender).getPlayer(), moneyNeeded);
                player.getInventory().addItem(emeralds);
            } else {
                sender.sendMessage("Not enough funds! $250 = 1 emerald.");
            }
            
        }
        
        return true;
    }
    public static float clamp(float val, float min, float max) {
        return Math.max(min, Math.min(max, val));
    }
}
#

theres the entire class

torn robin
#

public static Economy economy = null;

frigid ember
#

public static Economy economy = null; well thats why

red zenith
#

from vault

torn robin
#

you're setting it to null

stark salmon
#

oh

#

shit

torn robin
#

it probably shouldn't be static either

#

for now you can keep it

#

you're learning basics

stark salmon
#

i stopped my server trying to copy the logs

#

welp

torn robin
#

just keep that in mind once you figure this out

stark salmon
#

ok

#

idk what to do tho because if i dont do that i cant reference it because its not static

red zenith
#

also, you could probably make a helper utility class and put your clamp method in that

stark salmon
#

oh

torn robin
#

@stark salmon Dependency Injection

red zenith
#

In case you end up wanting to use it later

stark salmon
#

what's that

torn robin
#

basically setup the economy variable in the main class and then have a public Economy getEconomy()

stark salmon
#

ok

torn robin
#

then when you create the new CommandClass() you pass your main class as an argument

pastel condor
#

can someone helpme? I posted my password on github (private repo) what can I do to remove it?

red zenith
#

In very simple terms it means passing a dependency, vault economy in this case, as a parameter to your Commands constructor

stark salmon
#

how do i do that tho, im a little dense

pastel condor
#

ty

red zenith
#

Well, in your onEnable method you have to construct and register your command class

stark salmon
#

ok

#

this.getCommand("convertmoney").setExecutor(new CommandEmeralds());

torn robin
#

cark you can define the command constructor to require the main class argument with

private Main main;
public CommandEmeralds(Main main) {
    this.main = main;
}
red zenith
#

So you would add a constructor to your CommandEmeralds class.
Like that

torn robin
#

so main which is in your CommandEmeralds class is set to the instance of your main class if that makes sense

stark salmon
#

ok

red zenith
#

What's the name of your plugin class?

stark salmon
#

the name is VaultToEmeralds

frigid ember
#
The method a(ItemStack, ItemStack) in the type Item is not applicable for the arguments (ItemStack, World)

Why is this not working?

torn robin
#

what line @frigid ember

red zenith
#

alright so then

private VaultToEmeralds plugin;

public CommandEmeralds(VaultToEmeralds plugin) {
    this.plugin = plugin;
}
stark salmon
#

put that in my CommandEmeralds()?

torn robin
#

yes

stark salmon
#

ok

frigid ember
#

@torn robin

        WorldMap worldMap = ItemWorldMap.a(player.getItemInHand(), player.getWorld());
red zenith
#

You have to get the economy instance though

torn robin
#

for some reason .a is looking for an additional ItemStack instead of the world

stark salmon
#

ok

torn robin
#

do you have the source code for a?

red zenith
#

look at that, cark

stark salmon
#

i have been

#

the java docs

torn robin
#

@frigid ember is that code itself not working? Have you written any code yourself trying to implement ItemWorldMap? What are you trying to do?

red zenith
#

So you have something like the setupEconomy method in your VaultToEmeralds class?

stark salmon
#

im making it rn

red zenith
#

That checks to make sure that vault is loaded, and then uses a service provider to get an instance of the economy class from vault.

stark salmon
#

im trying to figure out how to get the world's economy

#

because there isnt a method to get the current economy

frigid ember
#

@torn robin I'm trying to get a WorldMap from a map

#

I solved it, nvm

red zenith
#

If you notice in that code example, cark, there's also a static method

    public static Economy getEconomy() {
        return econ;
    }

If you add that then you don't need a constructor in your CommandEmeralds class.
You should be able to just call Economy econ = VaultToEmeralds.getEconomy(); in your onCommand method, inside your first if statement.
Then you can remove public static Economy economy = null; from your CommandEmeralds class

stark salmon
#

Ohh

#

I dont have a variable defined as econ tho

red zenith
#

Well, it's based upon the example I linked

#

From the github repo for VaultAPI

stark salmon
#

oh

red zenith
#

So you would need to add that in your plugin's class

stark salmon
#

i thought it was a link to the java docs lol

#

sorry im dense

red zenith
#

you can name it whatever you want

#

there's the direct link

stark salmon
#

do I put the snippet in CommandEmeralds or VaultToEmeralds

red zenith
#

Which snippet?

#

the one at the link?

stark salmon
#

the one you posted here

red zenith
#

I've posted several.

stark salmon
#

Ohhh

#

Wati

#

I got it

red zenith
#

The first thing you need to do is make sure your VaultToEmeralds class that extends JavaPlugin
has the methods required to connect to the VaultAPI

stark salmon
#

the setupeconomy and the geteconomy

#

i put those in my main class

red zenith
#

plus private static Economy econ = null; at the top

#

setupEconomy is what's supposed to assign an instance to that variable

stark salmon
#

do I call setupEconomy from onEnable?

red zenith
#

Do you see the onEnable code in that link?

stark salmon
#

oh yeah

red zenith
#

If you're not going to use the permissions or chat api from vault then you can just leave out the code for that

stark salmon
#

yeah im not using those

#

how do I send messages to the console from onEnable?

red zenith
#

that's what the logger does

stark salmon
#

oh

red zenith
#

you can use the method shown there

#

or you can just getLogger()

pastel condor
#

or System.out.println()

#

I use that

stark salmon
#
public static Economy economy = VaultToEmeralds.getEconomy();```
frigid ember
#

Bukkit.getConsoleSender().sendMessage("hello"); another alternative

stark salmon
#

does that make sense at the top of my commandEmeralds

red zenith
#

getLogger().severe("Danger Will Robinson!")

#

By using getLogger() it appends the name of your plugin in front of the console message

stark salmon
#

ok

pastel condor
#

System.out.println(ChatColor.RED+"Danger Will Robinson!");

red zenith
#

I don't think System.out.println does that

pastel condor
#

it does ๐Ÿ™‚

#

at least with spigot

stark salmon
#
public static Economy economy = VaultToEmeralds.getEconomy();

Can I put this on top of CommandEmeralds

#

or will this cause something bad

red zenith
#

don't really need to do that

stark salmon
#

oh ok

red zenith
#

getEconomy is a static method of your plugin class

#

so doing that is just redundant

stark salmon
#

oh

red zenith
#

and you don't know when that's going to be called. remember, that Economy instance isn't set until your plugin retrieves it using the API

stark salmon
#

so do I just call the geteconomy method whenever I need to use it

red zenith
#

If you don't want to keep calling it multiple times in the same method, then you can just assign it to a variable in your method

stark salmon
#

ok

red zenith
#
Economy economy = VaultToEmeralds.getEconomy();
stark salmon
#
package com.masonmeirs.vaulttoemeralds;

import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import net.milkbowl.vault.economy.Economy;
public class CommandEmeralds implements CommandExecutor {
    

    @Override
    public  boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Economy economy = VaultToEmeralds.getEconomy();
        if (sender instanceof Player) {
            Player player = (Player) sender;
            ItemStack emeralds = new ItemStack(Material.EMERALD);
            try {
                emeralds.setAmount((int) clamp(Integer.parseInt(args[0]),0,255));
            } 
            catch(Exception e) {
                sender.sendMessage(e.toString());
                sender.sendMessage("You probably put a negative number or put a very high number. Don't do that.");
            }
            int moneyNeeded = (int) (clamp(Integer.parseInt(args[0]),0,255) * 250);
            if(economy.has(((Player) sender).getPlayer(), "world", (double)moneyNeeded)) {
                economy.withdrawPlayer(((Player) sender).getPlayer(), moneyNeeded);
                player.getInventory().addItem(emeralds);
            } else {
                sender.sendMessage("Not enough funds! $250 = 1 emerald.");
            }
            
        }
        
        return true;
    }
    public static float clamp(float val, float min, float max) {
        return Math.max(min, Math.min(max, val));
    }
}
#

here's my finished code

#

the build time skyrockted lol

#

96 ms -> 306 ms

red zenith
#

One other thing I'll mention, you call this code twice.
(int) clamp(Integer.parseInt(args[0]),0,255)
you could just call it once and assign it to a variable:
int numEmeralds = (int) clamp(Integer.parseInt(args[0]),0,255);
int moneyNeeded = numEmeralds * 250;

stark salmon
#

oh ok

#

ok i just added that and rebuilt, time to scp it to my server

#

moment of truth

#

No errors

#

time to run it

frigid ember
#

You registered it in your main class as well?

red zenith
#

Another thing, if your clamp method is only going to be used to create an int you can change it to:

public static int clamp(float val, float min, float max) {
  return (int)Math.max(min, Math.min(max, val));
}
#

that way you don't have to cast the result

stark salmon
#
org.bukkit.command.CommandException: Unhandled exception executing command 'convertmoney' in plugin VaultToEmeralds v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[patched_1.15.2.jar:git-Paper-240]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.15.2.jar:git-Paper-240]
        at org.bukkit.craftbukkit.v1_15_R1.CraftServer.dispatchCommand(CraftServer.java:760) ~[patched_1.15.2.jar:git-Paper-240]
        at net.minecraft.server.v1_15_R1.PlayerConnection.handleCommand(PlayerConnection.java:1854) ~[patched_1.15.2.jar:git-Paper-240]
        at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:1662) ~[patched_1.15.2.jar:git-Paper-240]
        at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:47) ~[patched_1.15.2.jar:git-Paper-240]
        at net.minecraft.server.v1_15_R1.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[patched_1.15.2.jar:git-Paper-240]
        at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:23) ~[patched_1.15.2.jar:git-Paper-240]
        at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) ~[patched_1.15.2.jar:git-Paper-240]
        at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.15.2.jar:git-Paper-240]
        at ...
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222-ea]
Caused by: java.lang.NullPointerException
#

shit

frigid ember
#

Are there more lines to the error

red zenith
#

yeah

#

after the NPE

stark salmon
#

yeah but it was over 2000 chars

red zenith
#

just copy starting with the Caused by: and the next couple of lines

stark salmon
#

ok

red zenith
#

anything that references your class/package

stark salmon
#

Caused by: java.lang.NullPointerException
at com.masonmeirs.vaulttoemeralds.CommandEmeralds.onCommand(CommandEmeralds.java:26) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.15.2.jar:git-Paper-240]
... 17 more

red zenith
#

so what's line 26 of your CommandEmeralds class?

stark salmon
#

int moneyNeeded = (int) (clamp(Integer.parseInt(args[0]),0,255) * 250);

#

wait

#

i changed it

red zenith
#

must be args

stark salmon
#

oh

red zenith
#

Are you only testing this on your remote server?

stark salmon
#

no..

#

on my server with plaeysr

#

players*

#

well yeah remote

red zenith
#

I mean you're not testing a local server

stark salmon
#

im not

red zenith
#

I set up a local one for development

stark salmon
#

oh

red zenith
#

because I have to restart it frequently

stark salmon
#

im testing on my server that currently has players..

#

ive caused so many memory leaks by reloading its unreal

red zenith
#

Well, I would normally restart the server entirely

#

which is why I use a local development copy of my server

stark salmon
#

oh

red zenith
#

In your case you just need your plugin and vault

#

and a player with some money

stark salmon
#

The method parseInt(String) in the type Integer is not applicable for the arguments (String[])

#

uhm

frigid ember
#

you typed args instead of args[0] or whatever argument

stark salmon
#

oh

red zenith
#

right

#

args is an array of String (String[])

stark salmon
#

but it was args[0] when i got the error

frigid ember
#

Can you paste the code

red zenith
#

Did you restart your server after you uploaded your plugin?

stark salmon
#
public  boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Economy economy = VaultToEmeralds.getEconomy();
        if (sender instanceof Player) {
            Player player = (Player) sender;
            ItemStack emeralds = new ItemStack(Material.EMERALD);
            try {
                emeralds.setAmount((int) clamp(Integer.parseInt(args[0]),0,255));
            } 
            catch(Exception e) {
                sender.sendMessage(e.toString());
                sender.sendMessage("You probably put a negative number or put a very high number. Don't do that.");
            }
            int moneyNeeded = (int) (clamp(Integer.parseInt(args[0]),0,255) * 250);
            if(economy.has(((Player) sender).getPlayer(), "world", (double)moneyNeeded)) {
                economy.withdrawPlayer(((Player) sender).getPlayer(), moneyNeeded);
                player.getInventory().addItem(emeralds);
            } else {
                sender.sendMessage("Not enough funds! $250 = 1 emerald.");
            }
            
        } 
#

i did

red zenith
#
    if (args != null && args.length > 0) {
      // Do stuff
    }
    else {
      // Send an error message
    }
#

you were providing a value to your command when you used it right?

#

/convertmoney 5

stark salmon
#

yeah

#

oh

frigid ember
#

Nvm I think I was wrong

stark salmon
#

oh ok

red zenith
#

and you're calling your command from in game and not the console, correct?

stark salmon
#

yeah

bright forge
#

Someone is creating fake accounts to give negative reviews to my plugin

#

Is this a reason of reporting?

stark salmon
#

I'd say but im not on the forums much

#

whats the plugin ill review it good

stark salmon
#

YOo I actually have this on my server

bright forge
#

hahaha

#

i hope you test the latest update

#

its awesome!

stark salmon
#

ok lol thanks

#

ill review it good

bright forge
#

thank you a lot :)

stark salmon
#

no problem ๐Ÿ™‚

#

i still get a nullpointerexception at line 26 even though it's a {
what the fuck

#

god i should not be writing a plugina t 1:40

#

am

#

especially my first one

pastel condor
stark salmon
#

are you cancelling gui drags

pastel condor
#

I'm canceling click event

stark salmon
#

oh

#
@EventHandler
    public void onInventoryClick(final InventoryDragEvent e) {
        if (e.getInventory() == inv) {
          e.setCancelled(true);
        }
    }
pastel condor
#

it worked when I was implementing InventoryHolder (but I was told not to do that)

stark salmon
#

try that

pastel condor
#

I'm doing that

#

just in a longer way

stark salmon
#

oh

pastel condor
#
        SlimeLoader loader = SPlugin.getLoader("file");
        final Player player = (Player) event.getWhoClicked();
         if (event.getInventory() != CreateGUI(player)) return;
        
        event.setCancelled(true);```
stark salmon
#

idk then, im new to plugins

pastel condor
#

oh okay

#

thanks though

#

idk what to do

stark salmon
#

no problem

#

sorry i couldnt help

pastel condor
#

it's okay

stark salmon
#

i cant even get my own plugin working

pastel condor
#

need help?

stark salmon
#

ok

pastel condor
#

you're using vault right?

stark salmon
#

i get a null pointer exception at a line that only contains a {

#

yeah

pastel condor
#

oh

#

lol

#

um

stark salmon
#
public  boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        int emsreq = (int) clamp(Integer.parseInt(args[0]),0,255);
        Economy economy = VaultToEmeralds.getEconomy();
        if (sender instanceof Player) {
            Player player = (Player) sender;
            ItemStack emeralds = new ItemStack(Material.EMERALD);
            try {
                emeralds.setAmount(emsreq);
            } 
            catch(Exception e) {
                sender.sendMessage(e.toString());
                sender.sendMessage("You probably put a negative number or put a very high number. Don't do that.");
            }
            int moneyNeeded = emsreq * 250;
            if(economy.has(((Player) sender).getPlayer(), "world", (double)moneyNeeded)) {
                economy.withdrawPlayer(((Player) sender).getPlayer(), moneyNeeded);
                player.getInventory().addItem(emeralds);
            } else {
                sender.sendMessage("Not enough funds! $250 = 1 emerald.");
            }
            
        }
        
        return true;
    }
#

thats my code

#

Caused by: java.lang.NullPointerException
at com.masonmeirs.vaulttoemeralds.CommandEmeralds.onCommand(CommandEmeralds.java:26) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.15.2.jar:git-Paper-240]
... 17 more

#

this happens

pastel condor
stark salmon
#

ok

#

thanks

pastel condor
#

look at the last method

#

and the 2nd to last

stark salmon
#

ok

pastel condor
#

what does this do? ((Player) sender).getPlayer()

#

why not just cast it?

#

why add the .getPlayer

stark salmon
#

idk

#

eclipse generated it

pastel condor
#

ooof

#

not really needed

#

also you already have a player varable

torn robin
#

that's unnecessary ye

pastel condor
#

just call that, you don't need to keep casting it

stark salmon
#

ok

#

eclipse wont let me do it like that

pastel condor
#

what?

torn robin
#

code?

stark salmon
#

it keeps changing it to the old one

pastel condor
#

I'm using eclipse

stark salmon
#

when I do sender.getPlayer() it changes it back to the casted one

#

and i cant stop it

pastel condor
#

oh okay

#

could you just use your varable instead?

stark salmon
#

oh

pastel condor
#

I see you have Player player = (Player) sender;

#

no need to keep casting

#

just use player

stark salmon
#

ok

pastel condor
#

but I can't really seem to find the issue

#

maybe you compiled the wrong code?

stark salmon
#

well whenever I save eclipse auto-builds

torn robin
#

sender.getPlayer is being auto casted because eclipse has to cast it as it's a CommandSender not a Player

pastel condor
#

just to be safe I would click export then jar file

stark salmon
#

ohh

#

ok

torn robin
#

so you have to use the player variable otherwise it will keep casting it

stark salmon
#

wont that export the entire workspace

#

ohh

#

ok

pastel condor
#

you can select

stark salmon
#

i just got a warning for spamming from the bot?

#

wtf

pastel condor
#

right click the project

stark salmon
#

ok

#

do I export classpath and project with it

pastel condor
#

export everything in the project

stark salmon
#

ok

pastel condor
#

thats what I do lol

stark salmon
#

Im dumb

#

I was copying the wrong jar to my server

#

Im braindead

pastel condor
#

lol

#

I did that last week

stark salmon
#

I'm retarded

pastel condor
#

such a time waster lol

stark salmon
#

lol

#

no wonder it was giving me the error for a goddamn bracket ๐Ÿ˜†

amber swallow
#

xd

pastel condor
#

๐Ÿ™‚

trim fjord
#

Is there a way to detect if someone is holding right click on a block for let's say 30 seconds?

stark salmon
#

IT WORKS

pastel condor
#

good

stark salmon
#

yeahhhhhhhh

vital delta
#

Is there a way to detect if someone is holding right click on a block for let's say 30 seconds?
@trim fjord maybe add a listener to playerinteractevent on block and just print some debug to the console, im honestly not sure if the event repeats per tick or its just once

#

you'll have to do some investigative work yourself

trim fjord
#

I have, this is what I am doing so far

stark salmon
#

thank you guys

pastel condor
#

maybe you could use the cooldown thing in reverse?

trim fjord
#

I am currently using a Map storing their UUID and a Long, then later on using that map to check

if (System.currentTimeMillis() - lastClicked.get(p.getUniqueId()) > 30000)
// If the current millis - the lastClicked time is greater than > 30 seconds

Literally in my head simple but not so simple after all.

#

The fact of the matter is I just want to basically detect if they stop right clicking. If they do, then it doesn't run at all, however, if they continue to hold right click till it's >= 30 seconds it'll do something

timber barn
#

I guess you have to write a method for this

amber swallow
#

There is no a easy way is you looking for

#

You need to write a tricky function xd

trim fjord
#

No sir, def. not haha.

#

I was close, then it just caused other havoc.

timber barn
#

Search for things like onkeypress down for jaca

#

Java*

#

And cancel ur timer with another method for onkeypressup

#

Something like a key listener

#

There is definetly something out there

amber swallow
#

what, for minecraft server?

timber barn
#

For his plugin yes

#

He wants to know how long right klick is pressed

#

I guess basic java is the correct way for this. Nothing with the spigot api

trim fjord
#

Not quite. But kinda.

amber swallow
#

right click on a block

#

And as far i know, you cant handle listener key press

trim fjord
#

I need to check if a player is clicking a block for about 30 seconds. If they are do blah blah shoot of a firework for example.
If not then don't do anything, they must be holding right click on the block for 30 seconds.

timber barn
#

SwingUtilities.isRightMouseButton(MouseEvent anEvent)

#

Returns true if the right mouse button was active

naive goblet
#

Vinex schedule a repeating task?

amber swallow
#

Maybe I can try it(plugin example), but you need to wait, because I gonna sleep xd

trim fjord
#

That's a bummer. Thanks though.

#

I can easily detect if they stop holding right click my part is, I need to detect if they held right click for 30 seconds.

naive goblet
#

If youโ€™re in the Bukkit API use a BukkitTask repeating 30 times?

#

1run/second

#

If it gets up in 30 it checks ...

#

Or just make 2 tasks and compare

pastel condor
#

anyone know how I can get this to work? if (!(event.getInventory().getContents().equals(inv.getContents()))) return; event.setCancelled(true);

heady jolt
#

!Arrays.equals

pastel condor
#

thanks lol

frigid ember
#

I was curious what do you guys use to listen to packets? (Specifically server & client side) I couldn't get ProtocolLib to work.

#

I use ProtocolLib

#

I've tried but I failed to listen to the packets for some reason.

#

Can you post what you've tried so far?

hoary parcel
#

I use my own packet handler that hooks directly into the server without reflection or that BS

#

But not everyone can do that so protocoollib is the way to go

frigid ember
#

Ok flex on us like that...

#

Before I proceed, can all packets be listened to, and canclled?

#

I tried listening to BlockBreakAnimationPacket and tried cancelling

#

and debugging still d idn't display an error or do anything 1 second.

hoary parcel
#

Yes

frigid ember
#

Okay.

torn robin
#

do you have any code Nerm?

frigid ember
#

It was a few a days ago but I'll do a mockup 1s.

#

    private final PrisonPlugin plugin = PrisonPlugin.getInstance();
    private final ProtocolManager protocolManager = this.plugin.getProtocolManager();
    
    public ArmAnimationPacketListener() {
        this.protocolManager.addPacketListener(new PacketAdapter(this.plugin, PacketType.Play.Client.ARM_ANIMATION) {
            @Override
            public void onPacketReceiving(PacketEvent event) {
                event.setCancelled(true);
            }

            @Override
            public void onPacketSending(PacketEvent event) {
                event.setCancelled(true);
            }
        });
    }

hoary parcel
#

Well, obviously packet will only every trigger the event in one direction

frigid ember
#

so if I swing will it still be called?

torn robin
#

That should work assuming you are creating new ArmAnimationPacketListener()

frigid ember
#

^

#

calling that after initializing the protocolmanager

torn robin
#

I'm assuming getProtocolManager is just returning ProtocolLibrary#getProtocolManager

frigid ember
#

^

#

I'll try it once more.

#

Hey guys, how do I delete a map from the game?

    
    final WorldMap worldMap = (WorldMap) MinecraftServer.getServer().worlds.get(0).worldMaps.get(WorldMap.class,
        "map_" + p.getInventory().getItemInHand().getDurability());

I have this, but how would I remove it so my world file doesn't get to large?

fleet crane
#

um

#

you mean a map item?

frigid ember
#

Yeah

fleet crane
#

(world container)/(world name)/data/map_(number).dat or something

#

just delete it

frigid ember
#

Alright

idle zodiac
#

How can I check if a click event was a Middle Mouse Button? sorry for the engrish I'm tired

frigid ember
#

There should a ClickType enum.

idle zodiac
#

ah

#

ok

#

i see it now

#

e.getClick()

frigid ember
#

๐Ÿ‘๐Ÿป

#

The packet seems to be displaying now, but I'm guessing other players can't see it? (since I did cancel it)

torn robin
#

that would make sense

timber barn
#

Is there a way to redirect a player to another server which is not part of the own network/bungeecord?

fleet crane
#

no, because the target server needs to be offline mode

frigid ember
#

Would sockets not even work at that point?

#

or possibly MemCached / Redis?

timber barn
#

Don't need to be a bungee, lets say jusg from spigot to spigot. Make the launcher connect to another server

idle zodiac
#

OMG

#

ITS MD_5

#

HI

timber barn
#

"Just" lol

hoary parcel
#

There is no save way to make that happen

idle zodiac
#

the optifine developer is here

#

let us all bow down to him

#

and praise his name

hoary parcel
#

You want firewalls and all kind stuff in between to prohibit such connections

timber barn
#

Yes

hoary parcel
#

Oh yes, optifine, violating mojangs rules est 2012

timber barn
#

Lets praise the message digest algorithm 5

idle zodiac
#

XDDD

frigid ember
#

Well, they allow it to happen ๐Ÿ˜›

hoary parcel
#

Because that's how it works

#

Nobody is stopping me so it's ok

frigid ember
#

Well they're aware of it I'd assume? They're not dumb?

#

OptiFine's obtained such notority over the years I'd assume a staff member running the rules @ Mojang are aware.

#

If not ๐Ÿคท๐Ÿปโ€โ™‚๏ธ

hoary parcel
#

Yes, they are aware, but it's not easy to handle something like this

frigid ember
#

What rule are they violating if you don't mind me asking?

hoary parcel
#

What do you think?

frigid ember
#

I'm not too familiar with there ToS and Privacy Policy; my guess would be selling?

hoary parcel
#

Selling itself is fine

#

It's just that there is one thing mojang never allowed to be sold and never will

frigid ember
#

Capes?

hoary parcel
#

Yes.

frigid ember
#

Even if it's client-based?

hoary parcel
#

It's not client sided?

#

And yes

#

Not asterisk

frigid ember
#

Makes sense.

#

Why out of everything did they decide capes to be a prohibition lol?

hoary parcel
#

Because it's their thing

#

It's meant to be special

frigid ember
#

Fair enough.

timber barn
frigid ember
#

Possibly, but I'm not sure there's a way to hook and verify they have that mod in there to connect

#

via. Channels etc

hoary parcel
#

There is no good way to send players around without a proxy currently

#

Requiring a mod for something a properly setup proxy could do without a mod is dum

timber barn
#

The idea is not using a proxy at all

frigid ember
#

so offline-mode based servers without a bungee?

timber barn
#

Online-mode

hoary parcel
#

Well, you can't without a client mod

timber barn
#

I know

hoary parcel
#

And requiring a mod is dum

frigid ember
#

Yea.

timber barn
#

Sad there is no different way

hoary parcel
#

So proxy is all you have

timber barn
#

Or a way at all without client modification

frigid ember
#

Not familiar with Networking, but Sockets wouldn't event work would it?

hoary parcel
#

It's way better than exposing your backend servers anyways

#

Dafuq are sockets supposed to help here? All this obviously uses sockets

#

You need a way to tell the client "connect to this ip now" which isn't available without modding that feature in yourself

timber barn
#

Can I redirect from bungee to another extern bungee network?

hoary parcel
#

No

#

Can you pls explain your usecase?...

timber barn
#

I thought about how is there no serverlist on a server with actual portals to the servers. Now i know why

#

Thats why I ask these specific questions

frigid ember
#

Caused by: java.lang.IllegalArgumentException: Packet of sender CLIENT cannot be sent to a client.

#

Anyone care to explain this to me ๐Ÿ˜› ?

hoary parcel
#

You need to respect the packet direction

#

A client packet can't be send to a client

frigid ember
#

Rather sent to whom exactly?

hoary parcel
#

The server ^^

frigid ember
#

so stream through all online players and send it to them? or am I just dumb..

hoary parcel
#

No that would be sending to the client

#

You don't need to send that packet, you only need to intercept packets the client send

#

For that type

#

What are you trying to do?

frigid ember
#

Basically when they punch a block remove progress.

#

Basically going step behind cancelling block-breaking.

#

As if they were in adventure mode in a way? But like when they punch it cancels it.

hoary parcel
#

Mmh, not actually sure how that works, I think the client predicts all kind of stuff here

frigid ember
#

Would the server be capable of declining such things?

hoary parcel
#

Iirc there an ack packet for digging

#

Where you can cancel the digging

frigid ember
#

Rather than cancelling I was trying to set the DigProgress

#

to 0 each time they dig if you feel me.

hoary parcel
#

Client will still attempt to start digging but cancel when it processed the ack

#

Iirc the block break animation is only send to other clients, not sure

frigid ember
#

I've got a gif of what I mean.

hoary parcel
#

But yeah, I guess you could try sending that one too

frigid ember
#

Am I allowed posting GIF's?

hoary parcel
#

But you really want set the ack to cancel

#

I know what you trying to do

#

You just lack experience with the protocol

frigid ember
#

^

#

Sadly

#

But I never give up.

#

So how would you necessarily modify Client-based wrappers then if you can't send them to the client?

torn robin
#

are you trying to not show the player breaking a block?

frigid ember
#

They mine, 0 progress.

hoary parcel
#

You don't need to touch client packets

#

You want to intercept the digging packet from the client, cancel it and send back an ack with cancel and maybe a block break animation with 0 progress

frigid ember
#

Just curious, what's ack mean?

hoary parcel
#

Acknowledge

frigid ember
#

I could just

hoary parcel
#

Packet id is 0x08

frigid ember
#

Damn

torn robin
#

real quick I never fully learned maven, what's the diff between a repository and a dependency?

#

more specifically, what does a repository do?

hoary parcel
#

Repo is where dependencies are fetched from

frigid ember
#

Repo is the storage container no?

torn robin
#

how does maven know which storage container to use to grab the dependency?

hoary parcel
#

It doesn't

torn robin
#

so how does it get it then?

hoary parcel
#

It just tries everything

torn robin
#

ah

hoary parcel
#

And stores where it found it

torn robin
#

that seems like a poor system

hoary parcel
#

It works ๐Ÿคท

#

Better than one central repo

#

Like npm

#

And well, maven does have a central repo you can use

#

I have my own repo, I only specify that in my poms, and proxy all other repos there

torn robin
#

nice

#

another small question

#

I've found that I don't need to override onEnable, it works either way

naive goblet
#

Wym by not overriding?

#

Ignore the annotation?

torn robin
#

like the annotation

naive goblet
#

It still overrides

torn robin
#
    @Override
    public void onEnable() {
    }

is the same as

        public void onEnable() {
    }
#

yeah I never understood how that works

naive goblet
#

And the annotation is only for increasing readability

torn robin
#

is that how it always works?

naive goblet
#

In that way we donโ€™t need to look into the superclass to see what methods got overridden

#

Certainly annotations can be used for just more than readability but it was primarily made for that though.

torn robin
#

interesting

#

good to know, thanks!

sturdy oar
#

I think Override annotation was also mainly introduced because people were writing their methods mispelled from the parent classes

#

with it it tells you without compiling if the method respects the one in the parent class

naive goblet
#

@torn robin if you want to use the code from the super method you can simply call super.method() in the subclass

torn robin
#

as in you're trying to override a method that doesn't exist

#

what is the super method of onEnable? nothing?

naive goblet
#

itโ€™s empty

#

So no need to

#

Letโ€™s say youโ€™re working with abstraction that might come handy then

sturdy oar
#

There are many other annotations that help readability

naive goblet
#

Indeed

sturdy oar
#

Actually I think some also help the performance

#

but I can't confirm this

#

like @FunctionalInterface

naive goblet
#

Yeah idk if it helps performance or just classifying the @interface as that

torn robin
#

I was able to block the BlockBreakAnimation packet from being sent to other players but I can't figure out how to prevent it from showing up on the player breaking the block itself

vernal spruce
#

i think thats just another client side feature..

#

as the server seem to only register the left-click being pressed once,not if its still pressed

timber barn
#

I think breaking the actual block is client side

vast fog
#

im wondering how i could change Compatible FML modded server to Vanilla server in bungee?

stuck goblet
#

Can anyone help to me?

#

I will a Minecraft Spigot Server on my Pc and i cant this dowload from craftbukkit

pine goblet
#

anyone know why this is happening?

stuck goblet
#

What is that

pine goblet
#

i even put this.cancel();

#

but it still goes back up

stuck goblet
#

is this a site?

pine goblet
#

i'll send it as a pic

stuck goblet
#

I cant help you i am player of mc

pine goblet
#

well idk

stuck goblet
#

I dont know what that is

torn robin
#

@ember solar source code?

stuck goblet
#

can anyone help me?

charred silo
#

paste it in hastebin or pastebin

torn robin
#

@stuck goblet what are you trying to download?

stuck goblet
#

Spigot

torn robin
#

You cannot download spigot directly

stuck goblet
#

For a pc server

charred silo
#

are you using BuildTools?

stuck goblet
#

No

#

i will a spigot server

torn robin
stuck goblet
#

on 1.12.2

torn robin
#

Read through that please Simi

stuck goblet
#

yes

#

what can i do whith tis

charred silo
#

its recommended to use BuildTools instead of downloading it directly!

stuck goblet
#

What can i do whith build tools

charred silo
#

just run java -jar BuildTools.jar --rev 1.12.2

torn robin
#

it is expected not recommended

pine goblet
#

dw i fixed my error

torn robin
#

๐Ÿ‘

charred silo
#

oh right heh. sorry lol

vast fog
#

any answers?

torn robin
#

what was the question?

vast fog
#

im wondering how i could change Compatible FML modded server to Vanilla server in bungee?

#

copy and paste

stuck goblet
#

How can i create an minecraft server on my pc???

torn robin
#

what's not compatible Sketch? Worlds?

vast fog
#

it shows that in forge

#

i cant send a picture because im not ranked

charred silo
#

^

#

oh wait

torn robin
stuck goblet
#

Thanks

torn robin
#

or do that ^

charred silo
#

yeah

torn robin
#

I don't have that much experience with Bungee/FML but I doubt you'd be able to convert that easily

fleet crane
#

?kick @forest cobalt

worldly heathBOT
#

๐Ÿ‘ข Kicked peppis#5783

charred silo
#

oh alright. that was off topic :p

stuck goblet
#

?kick @stuck goblet

#

?help

#

?

worldly heathBOT
#

Edit this to change the output of the command!

charred silo
#

only admins can do that.

stuck goblet
#

Ok

bronze marten
#

is there a way to make a block not being removed after a time? E.g. when I manually set a flower on top of a sand block, it will be removed after ~10s (just pops off, because its an invalid block) - is there a way to make this persistent? I looked online and someone suggested to set tickspeed to 0, but this is not an option for me, is there something else im missing?

clever hornet
#

where can I download essentialschat for essentialsx

#

nmv

#

nvm

bronze marten
#

@frigid ember I meant with thats not an option for me as in: I cannot go that direction as it disables a whole lot of other game elements.

charred silo
#

its probably one of your plugins.

clever hornet
#

how do i make it so it doesnt show the world im in when I type in chat

#

nvm i fixed it

summer rock
#

Luckperms: how do i give players permission to do /gamemode survival and /gamemode spectator?

#

@everyone

bronze marten
#

lmao

#

have u searched xd

hidden glade
#

converting the argument to int but it gives out the error how shall i be doing it so it goes the right way?

bronze marten
#

Integer.parseInt

hidden glade
#

ok lemme try that out

#

oh dont relate sharpness and durability xD just didnt find sharpness much fast in the suggestions

#

that worked very well thanks!

bronze marten
#

if you just implement tabcomplete its fine I think for your users

#

then they can try stuff really quickly

#

you dont have to rename every enchantment haha

hidden glade
#

ty for suggestion will do that!

bronze marten
#

what you maybe can in addition, is indeed do tabcomplete, but add your "custom" elements to it which are aliases :)

#

so if user types SHARPNESS it will be replaced to DURABILITY :)

hidden glade
#

i wont lie but im just learning tab completion

#

but i think ive found out how to do tat too^^^^

chrome edge
#

I'm making block queue system for placing massive amount of block. Should I use stable X blocks per X ticks or make it depends on TPS?

#

Basically the queue place X blocks each X ticks and if queue is still in processing it's not continue until process finish.

#

So what do you think about it? Should I use like it or make in another way?

#

Example code;```
new BukkitRunnable() {
public void run() {

            if (inQueue)
                return;

            inQueue = true;

            int limit = 0;
            while (true) {

                Block block = queue.poll();

                if (block == null) {
                    inQueue = false;
                    cancel();
                }
                
                //PLACE BLOCK

                limit++;

                if (limit >= 100) {
                    inQueue = false;
                    cancel();
                }
            }

        }
    }.runTaskTimer(X, 0, 1);```
idle zodiac
#

How can you set worldborder?

heady jolt
#

./worldborder

idle zodiac
#

no but i mean

#

in spigot commands