improved communication system
@@ -11,6 +11,16 @@ export default defineNuxtConfig({
|
||||
'@vueuse/nuxt',
|
||||
'@nuxt/image-edge'
|
||||
],
|
||||
app: {
|
||||
head: {
|
||||
link: [
|
||||
{ rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" },
|
||||
{ rel: "icon", sizes: "32x32", type: "image/png", href: "/favicon-32x32.png" },
|
||||
{ rel: "icon", sizes: "16x16", type: "image/png", href: "/favicon-16x16.png" },
|
||||
{ rel: "manifest", href: "/site.webmanifest" },
|
||||
]
|
||||
}
|
||||
},
|
||||
runtimeConfig: {
|
||||
discordId: '',
|
||||
discordSecret: '',
|
||||
|
@@ -52,9 +52,11 @@
|
||||
|
||||
<script setup>
|
||||
definePageMeta({
|
||||
middleware: ["auth"]
|
||||
middleware: ["auth"],
|
||||
})
|
||||
|
||||
useHead({ title: 'Polarcraft' })
|
||||
|
||||
const user = useState('user')
|
||||
|
||||
const refreshMinecraftUsername = async () => {
|
||||
|
@@ -20,5 +20,7 @@ definePageMeta({
|
||||
layout: 'blank'
|
||||
})
|
||||
|
||||
useHead({ title: 'Login | Polarcraft' })
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
</script>
|
||||
|
@@ -8,4 +8,6 @@
|
||||
definePageMeta({
|
||||
middleware: ["auth"]
|
||||
})
|
||||
|
||||
useHead({ title: 'Map | Polarcraft' })
|
||||
</script>
|
||||
|
@@ -8,4 +8,6 @@
|
||||
definePageMeta({
|
||||
middleware: ["auth"]
|
||||
})
|
||||
|
||||
useHead({ title: 'Player Stores | Polarcraft' })
|
||||
</script>
|
||||
|
@@ -14,4 +14,6 @@ const user = useState('user')
|
||||
definePageMeta({
|
||||
middleware: ["auth"]
|
||||
})
|
||||
|
||||
useHead({ title: 'Team | Polarcraft' })
|
||||
</script>
|
||||
|
BIN
web/public/android-chrome-192x192.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
web/public/android-chrome-512x512.png
Normal file
After Width: | Height: | Size: 174 KiB |
BIN
web/public/apple-touch-icon.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
web/public/favicon-16x16.png
Normal file
After Width: | Height: | Size: 825 B |
BIN
web/public/favicon-32x32.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 15 KiB |
1
web/public/site.webmanifest
Normal file
@@ -0,0 +1 @@
|
||||
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
|
@@ -3,15 +3,17 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
const config = useRuntimeConfig();
|
||||
|
||||
const coll = db.collection('users')
|
||||
const doc = await coll.findOne({ 'minecraft.uuid': uuid })
|
||||
|
||||
const usersColl = db.collection('users')
|
||||
const user = await usersColl.findOne({ 'minecraft.uuid': uuid })
|
||||
|
||||
const response = await getUsernameWithTeam(user);
|
||||
|
||||
await $fetch(config.discordHost + '/minecraft/sendchatmessage', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
username: doc.discord.username + ' | ' + doc.minecraft.username,
|
||||
username: response.usernameWithoutStyle,
|
||||
// avatarURL: 'https://cdn.discordapp.com/avatars/' + doc.discord.id + '/' + doc.discord.avatarHash + '.png',
|
||||
avatarURL: 'https://api.mineatar.io/face/' + doc.minecraft.uuid + '?scale=16',
|
||||
avatarURL: 'https://api.mineatar.io/face/' + user.minecraft.uuid + '?scale=16',
|
||||
content: content,
|
||||
}
|
||||
})
|
||||
|
@@ -1,10 +1,21 @@
|
||||
import { getUsernameWithTeam } from "~/server/utils/auth";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { discordId, content } = await readBody(event);
|
||||
|
||||
const coll = db.collection('users');
|
||||
const doc = await coll.findOne({ 'discord.id': discordId });
|
||||
const user = await coll.findOne({ 'discord.id': discordId });
|
||||
|
||||
await sendRconCommand(`tellraw @a {"text":"(DC) ${doc.discord.username} > ${content}"}`)
|
||||
const response = await getUsernameWithTeam(user)
|
||||
|
||||
let tellraw;
|
||||
if (user.team) {
|
||||
tellraw = `["",{"text":"DC","color":"gray"},{"text":" ${user.username} ["},{"text":"${response.team.name}","color":"${response.team.color}"},{"text":"] > ${content}"}]`
|
||||
} else {
|
||||
tellraw = `["",{"text":"DC","color":"gray"},{"text":" ${user.username} > ${content}"}]`
|
||||
}
|
||||
|
||||
await sendRconCommand(`tellraw @a ${tellraw}`)
|
||||
|
||||
return { status: 'success' }
|
||||
});
|
||||
|
@@ -1,12 +1,22 @@
|
||||
import { getUsernameWithTeam } from "~/server/utils/auth";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { uuid } = await readBody(event)
|
||||
|
||||
const coll = db.collection('whitelist')
|
||||
const usersColl = db.collection('users')
|
||||
|
||||
const doc = await coll.findOne({ uuid: uuid })
|
||||
|
||||
if (doc && !doc.verified) return { code: doc.code, verified: false }
|
||||
if (doc && doc.verified) return { verified: true }
|
||||
|
||||
if (doc && doc.verified) {
|
||||
const user = await usersColl.findOne({ 'minecraft.uuid': uuid });
|
||||
|
||||
const response = await getUsernameWithTeam(user);
|
||||
|
||||
return { verified: true, username: response.username, usernameWithoutStyle: response.usernameWithoutStyle }
|
||||
}
|
||||
|
||||
await coll.createIndex({ code: 1 }, { unique: true })
|
||||
|
||||
|
@@ -61,3 +61,13 @@ export const applyUsername = async (user) => {
|
||||
body: { nickname: discordUsername, discordId: user.discord.id }
|
||||
})
|
||||
}
|
||||
|
||||
export const getUsernameWithTeam = async (user) => {
|
||||
const teamsColl = db.collection('teams')
|
||||
const team = user.team ? await teamsColl.findOne({ _id: new ObjectId(user.team.id) }): undefined;
|
||||
|
||||
const username = user.team ? user.username + ` [<color:${team.color}>${team.name}</color>]` : user.username;
|
||||
const usernameWithoutStyle = user.team ? user.username + ` [${team.name}]` : user.username;
|
||||
|
||||
return { username: username, usernameWithoutStyle: usernameWithoutStyle, team: team }
|
||||
}
|
||||
|