/* * MHSF, Minehut Server List * All external content is rather licensed under the ECA Agreement * located here: https://list.mlnehut.com/docs/legal/external-content-agreement * * All code under MHSF is licensed under the MIT License * by open source contributors * * Copyright (c) 2024 dvelo * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ "use client"; import { getCustomization, ownServer, reportServer, serverOwned as sOFunc, setCustomization, unownServer, userOwnedServer, } from "@/lib/api"; import { OnlineServer } from "@/lib/types/mh-server"; import { SignedIn, SignedOut, useUser } from "@clerk/nextjs"; import { zodResolver } from "@hookform/resolvers/zod"; import { CheckIcon, X } from "lucide-react"; import Link from "next/link"; import { Dispatch, SetStateAction, useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; import { z } from "zod"; import { Button } from "./ui/button"; import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "./ui/form"; import Setting from "./ui/setting"; import { Textarea } from "./ui/textarea"; import "@/themes.css"; import { themes } from "@/lib/themes"; import Editor from "@monaco-editor/react"; import { useTheme } from "next-themes"; import { BannerPopover } from "./misc/BannerPopover"; import { DiscordPopover } from "./misc/DiscordPopover"; import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "./ui/card"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "./ui/dialog"; import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover"; import { LoadingSpinner } from "./ui/loading-spinner"; const formSchema = z.object({ description: z .string() .min(2, { message: "Description must be at least 2 characters.", }) .max(1250, { message: "Description cannot be longer than 1250 characters.", }), }); export default function ServerCustomize({ server, cs, setCS, }: { server: string; cs: string; setCS: Dispatch>; }) { const [serverOwned, setServerOwned] = useState(false); const [userOwned, setUserOwned] = useState(false); const [loading, setLoading] = useState(true); const [reason, setReason] = useState(""); const [description, setDescription] = useState(""); const [get, setGet] = useState({}); const [author, setAuthor] = useState(""); const [minehutOwned, setMinehutOwned] = useState(false); const { resolvedTheme: mode } = useTheme(); const { user, isSignedIn } = useUser(); useEffect(() => { sOFunc(server).then((c) => { setServerOwned(c); getCustomization(server).then((b) => { setGet(b); setDescription(b != null ? b.description : ""); form.reset({ description: b != null ? b.description : "" }); setCS(b != null ? b.colorScheme : "zinc"); userOwnedServer(server).then((c) => { setUserOwned(c); fetch("https://api.minehut.com/servers").then((c) => { c.json().then((c: { servers: Array }) => { c.servers.forEach((v) => { setAuthor(v.author); if (v.name == server && isSignedIn) { if (user?.publicMetadata.player === v.author) { setMinehutOwned(true); } } setLoading(false); }); }); }); }); }); }); }, [isSignedIn]); const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { description, }, }); if (loading) { return ( <>
); } return ( <> {!serverOwned && (
Do you own this server?
Create an account and link it to the owner of the server to customize it.
)}
{!serverOwned && user?.publicMetadata.player == null && (
Do you own this server?
Create an account and link it to the owner of the server to customize it.
)} {serverOwned && !userOwned && (
Is this server in violation of the ECA?
Is this server in violation of the{" "} External Content Agreement (aka ECA) ? You can report the server to remove the customizations from the server. Report Server This will send a notification to MHSF maintainers. This server must be in violation of the{" "} ECA {" "} to be a valid report. Typical response times include 1 hour to 1 day, and you will not be notified if your report is successful or not.{" "} Please do not spam this form with mindless reports. If you do, your account will be banned. We are not Minehut support, we cannot help you with a problem within the Minehut platform or within the server, we can only moderate the customization of the server. {" "} (if the problem is within the server,{" "} report it on Minehut )

Reason: