|
|
|
|
@@ -4,17 +4,17 @@
|
|
|
|
|
<div class="flex flex-col gap-6">
|
|
|
|
|
<div class="text-2xl font-semibold text-contrast">Server details</div>
|
|
|
|
|
|
|
|
|
|
<!-- Country -->
|
|
|
|
|
<!-- Region -->
|
|
|
|
|
<div class="max-w-[600px]">
|
|
|
|
|
<label for="server-country">
|
|
|
|
|
<span class="label__title">Country</span>
|
|
|
|
|
<label for="server-region">
|
|
|
|
|
<span class="label__title">Region</span>
|
|
|
|
|
</label>
|
|
|
|
|
<Combobox
|
|
|
|
|
id="server-country"
|
|
|
|
|
v-model="country"
|
|
|
|
|
:options="countryOptions"
|
|
|
|
|
id="server-region"
|
|
|
|
|
v-model="region"
|
|
|
|
|
:options="regionOptions"
|
|
|
|
|
searchable
|
|
|
|
|
placeholder="Select country"
|
|
|
|
|
placeholder="Select region"
|
|
|
|
|
:disabled="!hasPermission"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
@@ -48,7 +48,7 @@
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
class="mt-2 flex items-center gap-2"
|
|
|
|
|
class="mt-2 flex items-center gap-2 text-sm"
|
|
|
|
|
@focusout="
|
|
|
|
|
() => {
|
|
|
|
|
if (!lastPingAddressChanged && javaPingResult) return
|
|
|
|
|
@@ -64,16 +64,6 @@
|
|
|
|
|
wrapper-class="flex-grow"
|
|
|
|
|
autocomplete="off"
|
|
|
|
|
/>
|
|
|
|
|
<StyledInput
|
|
|
|
|
v-model="javaPort"
|
|
|
|
|
type="number"
|
|
|
|
|
:min="1"
|
|
|
|
|
:max="65535"
|
|
|
|
|
:disabled="!hasPermission"
|
|
|
|
|
wrapper-class="w-24"
|
|
|
|
|
input-class="text-center"
|
|
|
|
|
autocomplete="off"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
v-if="javaAddress"
|
|
|
|
|
@@ -121,6 +111,17 @@
|
|
|
|
|
>.
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else class="mt-2 text-sm">
|
|
|
|
|
If you have [SRV records]
|
|
|
|
|
<InfoIcon
|
|
|
|
|
v-tooltip="{
|
|
|
|
|
content:
|
|
|
|
|
'The address you enter here may have DNS SRV records _minecraft._tcp.{your domain} which point to your Minecraft server address and port.',
|
|
|
|
|
popperClass: 'max-w-xs',
|
|
|
|
|
}"
|
|
|
|
|
/>, you do not need to add a port. Otherwise if you have a port which isn't 25565, you
|
|
|
|
|
can include it as :12345
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Bedrock Address -->
|
|
|
|
|
@@ -140,16 +141,6 @@
|
|
|
|
|
wrapper-class="flex-grow"
|
|
|
|
|
autocomplete="off"
|
|
|
|
|
/>
|
|
|
|
|
<StyledInput
|
|
|
|
|
v-model="bedrockPort"
|
|
|
|
|
type="number"
|
|
|
|
|
:min="1"
|
|
|
|
|
:max="65535"
|
|
|
|
|
:disabled="!hasPermission"
|
|
|
|
|
wrapper-class="w-24"
|
|
|
|
|
input-class="text-center"
|
|
|
|
|
autocomplete="off"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@@ -168,7 +159,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { RefreshCwIcon, SpinnerIcon } from '@modrinth/assets'
|
|
|
|
|
import { InfoIcon, RefreshCwIcon, SpinnerIcon } from '@modrinth/assets'
|
|
|
|
|
import {
|
|
|
|
|
ButtonStyled,
|
|
|
|
|
Combobox,
|
|
|
|
|
@@ -189,27 +180,23 @@ const { addNotification } = injectNotificationManager()
|
|
|
|
|
const { projectV3, currentMember, patchProjectV3 } = injectProjectPageContext()
|
|
|
|
|
|
|
|
|
|
const javaAddress = ref('')
|
|
|
|
|
const javaPort = ref(25565)
|
|
|
|
|
const bedrockAddress = ref('')
|
|
|
|
|
const bedrockPort = ref(19132)
|
|
|
|
|
const country = ref('')
|
|
|
|
|
const region = ref('')
|
|
|
|
|
const languages = ref([])
|
|
|
|
|
|
|
|
|
|
const javaPingLoading = ref(false)
|
|
|
|
|
const javaPingResult = ref(null)
|
|
|
|
|
|
|
|
|
|
const lastPingedAddress = ref({ address: '', port: null })
|
|
|
|
|
const lastPingedAddress = ref('')
|
|
|
|
|
|
|
|
|
|
const lastPingAddressChanged = computed(() => {
|
|
|
|
|
return (
|
|
|
|
|
javaAddress.value.trim() !== lastPingedAddress.value.address ||
|
|
|
|
|
javaPort.value !== lastPingedAddress.value.port
|
|
|
|
|
)
|
|
|
|
|
return javaAddress.value.trim() !== lastPingedAddress.value
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
let pingDebounceTimer = null
|
|
|
|
|
|
|
|
|
|
watch([javaAddress, javaPort], () => {
|
|
|
|
|
watch(javaAddress, () => {
|
|
|
|
|
clearTimeout(pingDebounceTimer)
|
|
|
|
|
pingDebounceTimer = setTimeout(() => {
|
|
|
|
|
pingJavaServer()
|
|
|
|
|
@@ -231,13 +218,11 @@ async function pingJavaServer() {
|
|
|
|
|
javaPingLoading.value = true
|
|
|
|
|
javaPingResult.value = null
|
|
|
|
|
|
|
|
|
|
const port = javaPort.value || 25565
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await Promise.race([
|
|
|
|
|
client.labrinth.server_ping_internal.pingMinecraftJava({
|
|
|
|
|
address,
|
|
|
|
|
port,
|
|
|
|
|
timeout_ms: PING_TIMEOUT_MS,
|
|
|
|
|
}),
|
|
|
|
|
new Promise((_, reject) =>
|
|
|
|
|
setTimeout(() => reject(new Error('Ping timed out')), PING_TIMEOUT_MS),
|
|
|
|
|
@@ -248,17 +233,16 @@ async function pingJavaServer() {
|
|
|
|
|
javaPingResult.value = { online: false, latency: null }
|
|
|
|
|
} finally {
|
|
|
|
|
javaPingLoading.value = false
|
|
|
|
|
lastPingedAddress.value = { address, port }
|
|
|
|
|
lastPingedAddress.value = address
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initFromProjectV3(v3) {
|
|
|
|
|
if (!v3) return
|
|
|
|
|
javaAddress.value = v3.minecraft_java_server?.address ?? ''
|
|
|
|
|
javaPort.value = v3.minecraft_java_server?.port ?? 25565
|
|
|
|
|
bedrockAddress.value = v3.minecraft_bedrock_server?.address ?? ''
|
|
|
|
|
bedrockPort.value = v3.minecraft_bedrock_server?.port ?? 19132
|
|
|
|
|
country.value = v3.minecraft_server?.country ?? ''
|
|
|
|
|
region.value = v3.minecraft_server?.region ?? ''
|
|
|
|
|
languages.value = v3.minecraft_server?.languages ?? []
|
|
|
|
|
|
|
|
|
|
pingJavaServer()
|
|
|
|
|
@@ -278,78 +262,15 @@ if (projectV3.value) {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const countryOptions = [
|
|
|
|
|
{ value: 'US', label: 'United States' },
|
|
|
|
|
{ value: 'CA', label: 'Canada' },
|
|
|
|
|
{
|
|
|
|
|
value: 'EU',
|
|
|
|
|
label: 'Europe',
|
|
|
|
|
searchTerms: [
|
|
|
|
|
'Germany',
|
|
|
|
|
'France',
|
|
|
|
|
'Netherlands',
|
|
|
|
|
'Finland',
|
|
|
|
|
'Sweden',
|
|
|
|
|
'Denmark',
|
|
|
|
|
'Poland',
|
|
|
|
|
'Czech Republic',
|
|
|
|
|
'Romania',
|
|
|
|
|
'Austria',
|
|
|
|
|
'Belgium',
|
|
|
|
|
'Ireland',
|
|
|
|
|
'Spain',
|
|
|
|
|
'Italy',
|
|
|
|
|
'Portugal',
|
|
|
|
|
'Lithuania',
|
|
|
|
|
'Latvia',
|
|
|
|
|
'Estonia',
|
|
|
|
|
'Bulgaria',
|
|
|
|
|
'Croatia',
|
|
|
|
|
'Hungary',
|
|
|
|
|
'Slovakia',
|
|
|
|
|
'Greece',
|
|
|
|
|
'Luxembourg',
|
|
|
|
|
'Malta',
|
|
|
|
|
'Cyprus',
|
|
|
|
|
'Slovenia',
|
|
|
|
|
'Great Britain',
|
|
|
|
|
'United Kingdom',
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{ value: 'NO', label: 'Norway' },
|
|
|
|
|
{ value: 'CH', label: 'Switzerland' },
|
|
|
|
|
{ value: 'RU', label: 'Russia' },
|
|
|
|
|
{ value: 'UA', label: 'Ukraine' },
|
|
|
|
|
{ value: 'RS', label: 'Serbia' },
|
|
|
|
|
{ value: 'TR', label: 'Turkey' },
|
|
|
|
|
{ value: 'IL', label: 'Israel' },
|
|
|
|
|
{ value: 'AE', label: 'United Arab Emirates' },
|
|
|
|
|
{ value: 'SA', label: 'Saudi Arabia' },
|
|
|
|
|
{ value: 'IN', label: 'India' },
|
|
|
|
|
{ value: 'SG', label: 'Singapore' },
|
|
|
|
|
{ value: 'JP', label: 'Japan' },
|
|
|
|
|
{ value: 'KR', label: 'South Korea' },
|
|
|
|
|
{ value: 'CN', label: 'China' },
|
|
|
|
|
{ value: 'HK', label: 'Hong Kong' },
|
|
|
|
|
{ value: 'TW', label: 'Taiwan' },
|
|
|
|
|
{ value: 'AU', label: 'Australia' },
|
|
|
|
|
{ value: 'NZ', label: 'New Zealand' },
|
|
|
|
|
{ value: 'BR', label: 'Brazil' },
|
|
|
|
|
{ value: 'AR', label: 'Argentina' },
|
|
|
|
|
{ value: 'CL', label: 'Chile' },
|
|
|
|
|
{ value: 'CO', label: 'Colombia' },
|
|
|
|
|
{ value: 'MX', label: 'Mexico' },
|
|
|
|
|
{ value: 'ZA', label: 'South Africa' },
|
|
|
|
|
{ value: 'NG', label: 'Nigeria' },
|
|
|
|
|
{ value: 'KE', label: 'Kenya' },
|
|
|
|
|
{ value: 'EG', label: 'Egypt' },
|
|
|
|
|
{ value: 'MY', label: 'Malaysia' },
|
|
|
|
|
{ value: 'TH', label: 'Thailand' },
|
|
|
|
|
{ value: 'VN', label: 'Vietnam' },
|
|
|
|
|
{ value: 'PH', label: 'Philippines' },
|
|
|
|
|
{ value: 'ID', label: 'Indonesia' },
|
|
|
|
|
{ value: 'PK', label: 'Pakistan' },
|
|
|
|
|
{ value: 'BD', label: 'Bangladesh' },
|
|
|
|
|
const regionOptions = [
|
|
|
|
|
{ value: 'us_east', label: 'US East' },
|
|
|
|
|
{ value: 'us_west', label: 'US West' },
|
|
|
|
|
{ value: 'europe', label: 'Europe' },
|
|
|
|
|
{ value: 'asia', label: 'Asia' },
|
|
|
|
|
{ value: 'australia', label: 'Australia' },
|
|
|
|
|
{ value: 'south_america', label: 'South America' },
|
|
|
|
|
{ value: 'middle_east', label: 'Middle East' },
|
|
|
|
|
{ value: 'russia', label: 'Russia' },
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const languageOptions = [
|
|
|
|
|
@@ -396,12 +317,10 @@ const languageOptions = [
|
|
|
|
|
|
|
|
|
|
const javaServerPatchData = computed(() => {
|
|
|
|
|
const addressChanged =
|
|
|
|
|
javaAddress.value.trim() !== (projectV3.value?.minecraft_java_server?.address ?? '') ||
|
|
|
|
|
javaPort.value !== (projectV3.value?.minecraft_java_server?.port ?? 25565)
|
|
|
|
|
javaAddress.value.trim() !== (projectV3.value?.minecraft_java_server?.address ?? '')
|
|
|
|
|
if (addressChanged) {
|
|
|
|
|
return {
|
|
|
|
|
address: javaAddress.value.trim(),
|
|
|
|
|
port: javaPort.value,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -410,13 +329,9 @@ const javaServerPatchData = computed(() => {
|
|
|
|
|
|
|
|
|
|
const bedrockServerPatchData = computed(() => {
|
|
|
|
|
const origBedrock = projectV3.value?.minecraft_bedrock_server
|
|
|
|
|
if (
|
|
|
|
|
bedrockAddress.value !== (origBedrock?.address ?? '') ||
|
|
|
|
|
bedrockPort.value !== (origBedrock?.port ?? 19132)
|
|
|
|
|
) {
|
|
|
|
|
if (bedrockAddress.value !== (origBedrock?.address ?? '')) {
|
|
|
|
|
return {
|
|
|
|
|
address: bedrockAddress.value.trim(),
|
|
|
|
|
port: bedrockPort.value,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -425,15 +340,15 @@ const bedrockServerPatchData = computed(() => {
|
|
|
|
|
|
|
|
|
|
const serverPatchData = computed(() => {
|
|
|
|
|
const origServer = projectV3.value?.minecraft_server
|
|
|
|
|
const countryChanged = country.value && country.value !== origServer?.country
|
|
|
|
|
const regionChanged = region.value && region.value !== origServer?.region
|
|
|
|
|
const languagesChanged =
|
|
|
|
|
JSON.stringify([...languages.value].sort()) !==
|
|
|
|
|
JSON.stringify([...(origServer?.languages ?? [])].sort())
|
|
|
|
|
|
|
|
|
|
if (countryChanged || languagesChanged) {
|
|
|
|
|
if (regionChanged || languagesChanged) {
|
|
|
|
|
return {
|
|
|
|
|
...origServer,
|
|
|
|
|
...(countryChanged ? { country: country.value } : {}),
|
|
|
|
|
...(regionChanged ? { region: region.value } : {}),
|
|
|
|
|
...(languagesChanged ? { languages: languages.value } : {}),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -459,28 +374,25 @@ const saving = ref(false)
|
|
|
|
|
|
|
|
|
|
const original = computed(() => ({
|
|
|
|
|
javaAddress: projectV3.value?.minecraft_java_server?.address ?? '',
|
|
|
|
|
javaPort: projectV3.value?.minecraft_java_server?.port ?? 25565,
|
|
|
|
|
bedrockAddress: projectV3.value?.minecraft_bedrock_server?.address ?? '',
|
|
|
|
|
bedrockPort: projectV3.value?.minecraft_bedrock_server?.port ?? 19132,
|
|
|
|
|
country: projectV3.value?.minecraft_server?.country ?? '',
|
|
|
|
|
region: projectV3.value?.minecraft_server?.region ?? '',
|
|
|
|
|
languages: projectV3.value?.minecraft_server?.languages ?? [],
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
const modified = computed(() => ({
|
|
|
|
|
javaAddress: javaAddress.value,
|
|
|
|
|
javaPort: javaPort.value,
|
|
|
|
|
bedrockAddress: bedrockAddress.value,
|
|
|
|
|
bedrockPort: bedrockPort.value,
|
|
|
|
|
country: country.value,
|
|
|
|
|
region: region.value,
|
|
|
|
|
languages: languages.value,
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
function resetChanges() {
|
|
|
|
|
javaAddress.value = projectV3.value?.minecraft_java_server?.address ?? ''
|
|
|
|
|
javaPort.value = projectV3.value?.minecraft_java_server?.port ?? 25565
|
|
|
|
|
bedrockAddress.value = projectV3.value?.minecraft_bedrock_server?.address ?? ''
|
|
|
|
|
bedrockPort.value = projectV3.value?.minecraft_bedrock_server?.port ?? 19132
|
|
|
|
|
country.value = projectV3.value?.minecraft_server?.country ?? ''
|
|
|
|
|
region.value = projectV3.value?.minecraft_server?.region ?? ''
|
|
|
|
|
languages.value = projectV3.value?.minecraft_server?.languages ?? []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|