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

Rework navigating configuration pages. #236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ slug: /reference/configuration

# Paper Configuration

import ConfigurationStructureDiagram from '@site/src/components/ConfigurationStructureDiagram';

---

## Paper Configuration Files

:::info

Many of our files have been comprehensively documented. If this is the case, they will offer a link to their page.
If this is not the case, they offer a brief explanation to what they are.

:::

<ConfigurationStructureDiagram/>

## Per World Configuration

One of the most powerful yet least understood features of the Paper configuration is setting
Expand Down
134 changes: 134 additions & 0 deletions src/components/ConfigurationStructureDiagram.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import React, {useState} from "react";
import "@site/src/css/configuration-explorer-layout.css";
import { Icon } from '@iconify/react';

const folderIcon = "mdi:folder";
const fileIcon = "mdi:file";
const infoIcon = "mdi:information-outline";

interface ExplorerNode {
name: string;
type: "folder" | "file";
children?: ExplorerNode[];
description?: string;
url?: string;
}

const folderData: ExplorerNode[] = [
{
name: "logs",
type: "folder",
description: "This folder contains all the logs for the server. It compresses old logs into .gz files, but holds the most recent log as a .txt file.",
},
{
name: "config",
type: "folder",
children: [
{ name: "paper-global.yml", type: "file", url: "/paper/reference/global-configuration" },
{ name: "paper-world-defaults.yml", type: "file", url: "/paper/reference/world-configuration" },
],
},
{
name: "plugins",
type: "folder",
description: "You can place your plugin jars here.",
},
{
name: "<world>",
type: "folder",
children: [
{ name: "paper-world.yml", type: "file", url: "/paper/reference/configuration#per-world-values", description: "Every world folder will have this file. The values here only apply to this world." },
],
},
{ name: "banned-ips.json", type: "file", description: "This file stores all the banned IP addresses on the server." },
{ name: "banned-players.json", type: "file", description: "This file stores all the banned player information for the server." },
{ name: "bukkit.yml", type: "file", url: "/paper/reference/bukkit-configuration" },
{ name: "commands.yml", type: "file", url: "/paper/reference/bukkit-commands-configuration" },
{ name: "eula.txt", type: "file", description: "This file is in place to allow you to accept the Minecraft EULA.\nThis is required to start the server." },
{ name: "help.yml", type: "file", description: "This file provides you with a wide variety of ways to configure the /help system in your Paper Server." },
{ name: "ops.json", type: "file", description: "This file stores a list of all players with operator status." },
{ name: "permissions.yml", type: "file", description: "The permissions.yml file allows creating of permission nodes so that server admins can easily distribute permissions." },
olijeffers0n marked this conversation as resolved.
Show resolved Hide resolved
{ name: "server.properties", type: "file", url: "/paper/reference/server-properties" },
{ name: "spigot.yml", type: "file", url: "/paper/reference/spigot-configuration" },
{ name: "usercache.json", type: "file", description: "This file acts as a cache of user information that has been requested from Mojang's servers when they join the server or their texture is used as a Head." },
{ name: "whitelist.json", type: "file", description: "This is is a server configuration file that stores the usernames of players who have been whitelisted on a server." },
];

interface IndentationArrowProps {
level: number;
}

const IndentationArrow = ({ level } : IndentationArrowProps): null | JSX.Element => {
if (level === 0) {
return null;
}

return (
<span className={"indentation-arrow"}>
{level > 0 && "└─".repeat(level)}
</span>
);
};

export default function ConfigurationStructureDiagram() : JSX.Element {
const [popupNode, setPopupNode] = useState<ExplorerNode | null>(null);

const renderNode = (node: ExplorerNode, level: number = 0) => {
const isFolder = node.type === "folder";
const hasDescription = "description" in node;
const hasUrl = "url" in node;

const handleNodeOpening = (event: React.MouseEvent) => {
event.stopPropagation();
setPopupNode(node);
};

return (
<div key={node.name} className={level > 0 ? "config-explorer-node" : "config-explorer-node-noflex"}
onMouseLeave={() => {setPopupNode(null)}}
>

{level > 0 &&
<IndentationArrow level={level} />
}

<a className={`${("config-explorer-file-" + (isFolder ? "folder-" : "") + "node")}
${(!hasUrl ? "config-explorer-file-node" : "config-explorer-file-node-with-link")}`} href={node.url}
style={{cursor: hasUrl ? "pointer" : "default"}}>

<span className={"config-node-contents-wrapper"}>
<Icon icon={isFolder ? folderIcon : fileIcon} className={"config-explorer-icon config-explorer-node-icon"}/>
{node.name}
</span>
{hasDescription && (
<span className={"config-explorer-popup-window-open-tag"} onMouseEnter={handleNodeOpening}>ⓘ</span>
)}
</a>

{hasDescription && (
<div className={"config-explorer-popup-window-container"}>
<div className={"config-explorer-popup-window"}
style={{ display: popupNode === node ? "block" : "none" }}>
<strong>Description:</strong><br/>{node.description}
</div>
</div>
)}

{isFolder && node.children &&
node.children.map((child) => (
<div key={child.name}>
{renderNode(child, level + 1)}
</div>
))}
</div>
);
};

return (
<div>
<pre className={"config-explorer-code-outer-container"}>
{folderData.map((item) => renderNode(item))}
</pre>
</div>
);
}
114 changes: 114 additions & 0 deletions src/css/configuration-explorer-layout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/* Outer Container */
.config-explorer-code-outer-container {
overflow: visible;
white-space: nowrap;
}

/* File Node */
.config-explorer-file-node {
display: flex;
align-items: center;
border-radius: 10px;
width: fit-content;
flex-shrink: 0;
white-space: nowrap;
}

.config-explorer-file-node-with-link {
font-weight: bold;
}

.config-explorer-file-node-with-link:hover {
background-color: rgba(0, 0, 0, 0.1);
cursor: pointer;
text-decoration: none;
}

/* File Folder Node */
.config-explorer-file-folder-node {
display: flex;
align-items: center;
width: fit-content;
color: var(--config-node-highlight-text-color);
}

.config-explorer-file-folder-node:hover {
cursor: default;
text-decoration: none;
color: var(--config-node-highlight-text-color);
}

/* Popup Window Container */
.config-explorer-popup-window-container {
position: absolute;
margin-left: 30px;
transform: translateZ(0);
top: 100%;
left: 0;
width: fit-content;
z-index: 10;
white-space: normal;
}

/* Popup Window */
.config-explorer-popup-window {
background-color: #1c1e21;
padding: 10px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
border-radius: 5px;
margin-right: 100px;
width: fit-content;
z-index: 20;
white-space: pre-wrap;
}

.config-explorer-popup-window-open-tag {
z-index: 5;
}

.config-explorer-popup-window-open-tag:hover {
font-weight: bold;
cursor: pointer;
}

/* Indentation Arrow */
.indentation-arrow {
font-size: 14px;
color: #bbbbbb;
margin: 0 8px 0 2px;
}

/* Node Icon */
.config-explorer-node-icon {
font-size: 23px;
}

/* Node */
.config-explorer-node {
align-items: center;
position: relative;
display: flex;
flex-shrink: 0;
white-space: nowrap;
margin: 5px;
}

/* Node without Flex */
.config-explorer-node-noflex {
align-items: center;
position: relative;
margin: 5px 0 5px 0;
}

.config-node-contents-wrapper {
margin: 0 5px 0 0;
display: flex;
align-items: center;
font-size: 15px;
}

.config-explorer-icon {
/* Make it go back to the original color */
color: var(--config-node-highlight-text-color);
margin-right: 5px;
}
2 changes: 2 additions & 0 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/* Config Node */
--default-config-node-text-color: rgb(148, 148, 148);
--config-node-highlight-text-color: black;
--config-explorer-file-node-text-color: rgba(0, 0, 0, 0.03);
}

html[data-theme="dark"] {
Expand All @@ -29,6 +30,7 @@ html[data-theme="dark"] {
/* Config Node */
--default-config-node-text-color: rgb(128, 128, 128);
--config-node-highlight-text-color: white;
--config-explorer-file-node-text-color: rgba(0, 0, 0, 0.1);
}

.button.button--secondary {
Expand Down