Skip to content

Undoundoundo/Pxls

 
 

Repository files navigation

Pxls

Java CI with Maven

Pxls is a collaborative image editor where you can place up to six pixels at a time, inspired by Reddit's r/Place experiment.

Note: A Docker image is available at aneurinprice/docker-pxls.space and on Docker Hub.

Prerequisites

Building

  1. Install the above requirements either via package manager (recommended) or by building from their sources.

  2. Clone the repo:

    $ git clone git@github.com:pxlsspace/Pxls.git

  3. Navigate to the directory:

    $ cd Pxls

  4. Clean the package:

    $ mvn clean package

The output .jar is in target/.

Running

  1. Create a new directory.
  2. Copy resources/ and the output .jar to it.
  3. Copy resources/reference.conf to the directory as pxls.conf.
  4. Copy resources/roles-reference.conf to the directory as roles.conf.
  5. Configure pxls.conf and roles.conf (optional; see roles.md for details).
  6. Execute the jar with java -jar pxls-1.0-SNAPSHOT.jar

The server will start on port 4567 by default, and will expose a rudimentary console with a few commands (listed in Commands below). You will need to configure the database for the server to start, see the Configuring Database section below.

The config file uses HOCON. The config will not be automatically created, you must create/copy it yourself. Any unspecified option will use the default value from resources/reference.conf.

Pxls will automatically save a backup of the map every five minutes to $STORAGE/backups/board.<timestamp>.dat, as well as before executing a blank operation and right before exiting (via Ctrl-C).

Configuring Database

You will need to set the database URI/credentials in pxls.conf.

The relevant config options are database.url, database.user, and database.pass. An example database section in the config could look like this:

database {
  url: "jdbc:postgresql://localhost:3306/pxls"
  user: "AzureDiamond"
  pass: "hunter2"
}

Configuring OAuth

OAuth keys must be set in the config file (see above). Right now, five services are supported - Reddit, Google, Discord, VK, and Tumblr.

The config node oauth.callbackBase must be set to your app's URL (including protocol and port), followed by /auth (for example, http://pxls.space/auth). On the OAuth setup page for the various services, you need to set the redirect URL to oauth.callbackBase followed by the service name. Reddit, for example, would be http://pxls.space/auth/reddit, and likewise for Google.

An example OAuth section could look like this:

oauth {
    callbackBase: "http://example.com/auth"
    reddit {
        key: "AsPxXweEomQjUD"
        secret: "tYJlz_xbH-qjxw8xvKVj0qLXRCw"
    }
    google {
        key: "pxls-"
        secret: "AIzaSzAS9wxgdXw6G3Q2lGMlyxG03F3hmXEMnce"
    }
    discord {
        key: "112233445566778899"
        secret: "yo4DkHFDy0k1euPyxMef6m243qRgX00z"
    }
}

Configuring host

You must update the host option in your pxls.conf otherwise session cookies will not set, making auth impossible. host should be your domain (or IP if testing locally) without port.

Configuring CAPTCHA

By default, CAPTCHAs are disabled, and need to be configured in the config to work. You will need a CAPTCHA key and secret. The type must be Invisible reCAPTCHA.

The host key also needs to be one of the approved domains on the reCAPTCHA admin panel. For local testing, this will likely be localhost (no port).

An example CAPTCHA section could look like this:

host: "example.com"

captcha {
    enabled: true
    key: "6LcedG4UAAAAAKA6l9BbRPvZ2vt3lTrCQwz8rfPe"
    secret: "6LcedG4UAAAAAIXZcNFhnLKvTQwG1E8BzQQt_-MR"
}

Commands

Commands are entered directly into the running instance (stdin):

  • reload - Reloads the main configuration, applying most changes immediately. Also reloads the user and faction cache.
  • save - Saves the map.
  • logins <username> [{service ID}:{service user ID} ...] - Gets or sets the user's login method(s).
  • addlogins <username> <{service ID}:{service user ID} ...> - Adds login method(s) to the user.
  • removelogins <username> <service ID ...> - Removes login method(s) from the user.
  • roles <username> [role ID ...] - Gets or sets the user's role(s).
  • addroles <username> <role ID ...> - Adds role(s) to the user.
  • removeroles <username> <role ID ...> - Removes role(s) from the user.
  • alert <text> - Sends an popup-like alert to all users on the canvas.
  • ban <user> <reason> - Bans the user for 24 hours, with the specified reason (if any).
  • permaban <user> <reason> - Permanently bans the user, with the specified reason (if any).
  • shadowban <user> <reason> - Shadowbans the user (hiding newly-placed pixels to all but themself), with the specified reason (if any).
  • unban <user> - Unbans the user.
  • nuke <x1> <y1> <x2> <y2> <color> - Replaces all pixels from (x1, y1) to (x2, y2) with the color (by index).
  • replace <x1> <y1> <x2> <y2> <from> <to> - Replaces all pixels in the rectangle delimited by (x1, y1) to (x2, y2) from the color from to the color to
  • cons [authed] - Lists the total (or authed) connection count.
  • users - Lists all of the authed users, by username.
  • stack <user> [set <amount>] - Sets the user's stack count. The user must not be on cooldown before setting.
  • placementOverride list|<user> [placeAnyColor|ignoreCooldown|ignorePlacemap] [on|off] - Sets or lists the placement overrides of an user
  • captchaOverride list|<user> [on|off] - Lists all captcha overrides or sets the captcha override of an user
  • broadcast <message> - Sends a message in chat
  • chatban <user> <length> <purge> <reason> - Chat bans the user for length in seconds, optionally purges all of their messages
  • permachatban <user> <purge> <reason> - Perma chat bans the user, optionally purges all of their messages
  • unchatban <user> - Unchatbans the user
  • chatpurge <user> [amount] [reason] - Purges up to amount chat messages from the user
  • cf <query> - Runs a chat filter against query
  • reloadusers - Reloads the user manager (laggy)
  • flagrename <user> [0|1] - Sets the user's Rename Requested flag
  • setname <user> <name> - (alias: updateusername) Changes the user's name
  • idlecheck - Runs an user timeout check
  • senduserdata - Broadcasts the non-idle user count in chat
  • addnotification <title> <expiry> <body> - Adds a notification to the notification panel. A "+x" on the expiry makes the expiry now + x in seconds.
  • bp <json packet> broadcast a raw packet to everyone online.
  • up <username> <json packet> send a raw packet to all active connections from an user.
  • f <faction_id> [delete|tag|name [<new_value>]] updates a faction. if <new_value> is omitted, then the console will print the current values.

Contributors

A full list of contributors is available here.

Licenses

About

Open-source expansion of /r/place

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 44.3%
  • JavaScript 33.1%
  • CSS 10.3%
  • HTML 7.9%
  • Python 4.4%