Is there any way to make a plugin runs commands in an txt file?

Trying ur plugin steps is wasting too much time
stoping the test server
then building ur plugin again
then starting the server again
then joining the server
and finally trying the command…

is there a way to take Strings from a txt file
then using them like they have been wrote in ur plugin?
this way all u have to do is to change the command strings in file and use run command…

This seems like something you should be doing with a config. Although if you want to use a text file, you can make a BufferedReader like so
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(new File("path/goes/here"))));. Then you can use BufferedReader#readLine() to read each line of the file in turn

im not asking how to write to a file or config…
What im trying to say is;
I want to try some codes without restarting server
i want this plugin to read the file,
then convert that string into usual commands…
Actually i dont think this is possible but im just trying…

game.getCommandManager().process(game.getServer().getConsole(), cmd) // cmd is the command string
2 Likes

Totally possible.
CommandSource console = Sponge.getServer().getConsole();
Sponge.getCommandManager().process(console, “op @a”);

Edit: Ninja’d by seconds. Gah.

3 Likes

Op all eh?

Never knew Ryan was this evil

2 Likes

When you say reading a command from a file, you mean reading a script that will be executed when you will call a certain command ?

actually it’s probably “op @a” without the /.

As long it’s the OP all command it does not matter

its not CommandSender its CommandSource but thx :slight_smile:
was it Sender in old API?

It was CommandSender in Bukkit.

Oh sure… :smiley: its easy to understand that im very newbie in this :smile:

1 Like

Hey, everyone’s a newbie at some point. :smile:

Yeah sorry, the actual code I copied straight out of my plugin, but then I split it over multiple lines without checking to make sure I didn’t make any errors, as well as changing the variable to a hard coded string.

1 Like

No problem intellij directly show an autocorrect :smiley: