Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Basic File implementation #44

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

NexelOfficial
Copy link
Contributor

Added some basic File classes to support file reading and writing. Added the following classes:

  • java.io.File
  • java.io.FileReader
  • java.io.FileWriter
  • java.util.Scanner

This should provide the basic File reader and writing needs that are crucial for plugin development.

Example file reading implementation:

import { ServerCommands } from "@customrealms/core";

ServerCommands.register("/log-properties", () => {
  const serverPropsFile = new java.io.File("server.properties");
  const propsScanner = new java.util.Scanner(serverPropsFile);

  while (propsScanner.hasNextLine()) {
    const nextLine = propsScanner.nextLine();
    console.log(nextLine);
  }
});

Example file writing implementation:

import { ServerCommands } from "@customrealms/core";

ServerCommands.register("/write-file", () => {
  const file = new java.io.File("test-document.txt");
  const writer = new java.io.FileWriter(file);
  writer.write("This is some example text!");
  writer.close();
});

src/java.ts Outdated Show resolved Hide resolved
Copy link
Member

@connerdouglass connerdouglass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested your two examples, and they worked perfectly. This is an awesome addition!

@connerdouglass
Copy link
Member

You're free to merge this whenever you're ready 🚀

@NexelOfficial
Copy link
Contributor Author

You're free to merge this whenever you're ready 🚀

I don't have write access to the repository :o

@connerdouglass
Copy link
Member

Oh, I thought you would be able to merge an approved PR. I'll look into that later, but merge this one myself 👍

@connerdouglass connerdouglass merged commit 0b9378d into customrealms:master Jun 25, 2024
2 checks passed
@NexelOfficial NexelOfficial deleted the file-system branch June 25, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants