Skip to content

Commit

Permalink
Merge branch 'Hoshinonyaruko:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
MapleEve authored Mar 4, 2024
2 parents c25a49f + ff69bd3 commit 1bc5296
Show file tree
Hide file tree
Showing 51 changed files with 3,401 additions and 397 deletions.
32 changes: 2 additions & 30 deletions Broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package main
import (
"log"
"math/rand"
"net/http"
"net/url"
"strconv"
"time"

Expand Down Expand Up @@ -34,7 +32,7 @@ func (task *palworldBroadcast) RunpalworldBroadcast() {
log.Println("准备进行全服推送...现已支持所有语言broadcast!")
// 初始化RCON客户端
address := task.Config.Address + ":" + strconv.Itoa(task.Config.WorldSettings.RconPort)
rconClient := NewRconClient(address, task.Config.WorldSettings.AdminPassword, task.BackupTask)
rconClient := NewRconClient(address, task.Config.WorldSettings.AdminPassword, task.BackupTask, &task.Config)
if rconClient == nil {
log.Println("RCON客户端初始化失败,无法进行定期推送,请按教程正确开启rcon和设置服务端admin密码")
return
Expand All @@ -46,32 +44,6 @@ func (task *palworldBroadcast) RunpalworldBroadcast() {

// 获取随机选择的消息
randomMessage := task.Config.RegularMessages[randomIndex]

// 根据task.Config.UseDLL来决定发送方式
if task.Config.UseDll {
// 使用HTTP请求发送消息
dllPort, err := strconv.Atoi(task.Config.DllPort)
if err != nil {
log.Printf("Error converting DllPort from string to int: %v", err)
// 處理錯誤,例如返回或設置一個默認值
return
}
base := "http://127.0.0.1:" + strconv.Itoa(dllPort) + "/rcon?text="

messageText := url.QueryEscape("broadcast " + randomMessage)
fullURL := base + messageText

resp, err := http.Get(fullURL)
if err != nil {
log.Printf("Error sending HTTP request: %v", err)
} else {
defer resp.Body.Close()
// 这里可以添加对resp的处理逻辑
log.Println("Broadcast message sent successfully via HTTP")
}
} else {
// 使用Broadcast函数发送消息
Broadcast(randomMessage, rconClient)
}
Broadcast(randomMessage, rconClient, task.Config.UseDll)
}
}
9 changes: 7 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type Config struct {
EnableEngineSetting bool `json:"enableEngineSetting"` // 是否开启引擎设置
EnableBotNotification bool `json:"enableBotNotification"` // 是否开启机器人广播
EnableRebootLater bool `json:"enableRebootLater"` // 是否开启延时关闭&重启
OverrideDLL bool `json:"overrideDLL"` // 是否由palgo中内置的dll覆盖游戏目录的dll
UsePalServerExe bool `json:"usePalserverexe"` // 是否维持传统启动行为
}

// 默认配置
Expand All @@ -89,6 +91,8 @@ var defaultConfig = Config{
AutolaunchWebui: true,
EnableUe4Debug: false,
EnableEngineSetting: true,
OverrideDLL: true,
UsePalServerExe: false,
BackupInterval: 1800, // 30 分钟
MemoryCheckInterval: 30, // 30 秒
MemoryUsageThreshold: 80, // 80%
Expand Down Expand Up @@ -175,6 +179,7 @@ type GameWorldSettings struct {
IsStartLocationSelectByMap bool `json:"isStartLocationSelectByMap"`
ExistPlayerAfterLogout bool `json:"existPlayerAfterLogout"`
EnableDefenseOtherGuildPlayer bool `json:"enableDefenseOtherGuildPlayer"`
ShowPlayerList bool `json:"showPlayerList"`
CoopPlayerMaxNum int `json:"coopPlayerMaxNum"`
ServerPlayerMaxNum int `json:"serverPlayerMaxNum"`
ServerName string `json:"serverName"`
Expand Down Expand Up @@ -505,7 +510,7 @@ func ReadGameWorldSettings(config *Config) (*GameWorldSettings, error) {
section, err := cfg.GetSection(sectionName)
if err != nil {
fmt.Printf("初次使用,正在为您自动设置游戏默认参数\n")
settingsString = "(Difficulty=None,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=1.000000,ExpRate=1.000000,PalCaptureRate=1.000000,PalSpawnNumRate=1.000000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=1.000000,PlayerAutoHPRegeneRate=1.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=1.000000,PalAutoHPRegeneRate=1.000000,PalAutoHpRegeneRateInSleep=1.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=1.000000,CollectionDropRate=1.000000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.000000,EnemyDropItemRate=1.000000,DeathPenalty=All,bEnablePlayerToPlayerDamage=False,bEnableFriendlyFire=False,bEnableInvaderEnemy=True,bActiveUNKO=False,bEnableAimAssistPad=True,bEnableAimAssistKeyboard=False,DropItemMaxNum=3000,DropItemMaxNum_UNKO=100,BaseCampMaxNum=128,BaseCampWorkerMaxNum=15,DropItemAliveMaxHours=1.000000,bAutoResetGuildNoOnlinePlayers=False,AutoResetGuildTimeNoOnlinePlayers=72.000000,GuildPlayerMaxNum=20,PalEggDefaultHatchingTime=72.000000,WorkSpeedRate=1.000000,bIsMultiplay=False,bIsPvP=False,bCanPickupOtherGuildDeathPenaltyDrop=False,bEnableNonLoginPenalty=True,bEnableFastTravel=True,bIsStartLocationSelectByMap=True,bExistPlayerAfterLogout=False,bEnableDefenseOtherGuildPlayer=False,CoopPlayerMaxNum=4,ServerPlayerMaxNum=32,ServerName=\"palgo\",ServerDescription=\"https://github.com/Hoshinonyaruko/palworld-go\",AdminPassword=\"useradmin\",ServerPassword=\"\",PublicPort=8211,PublicIP=\"\",RCONEnabled=True,RCONPort=25575,Region=\"\",bUseAuth=True,BanListURL=\"https://api.palworldgame.com/api/banlist.txt\")"
settingsString = "(Difficulty=None,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=1.000000,ExpRate=1.000000,PalCaptureRate=1.000000,PalSpawnNumRate=1.000000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=1.000000,PlayerAutoHPRegeneRate=1.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=1.000000,PalAutoHPRegeneRate=1.000000,PalAutoHpRegeneRateInSleep=1.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=1.000000,CollectionDropRate=1.000000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.000000,EnemyDropItemRate=1.000000,DeathPenalty=All,bEnablePlayerToPlayerDamage=False,bEnableFriendlyFire=False,bEnableInvaderEnemy=True,bActiveUNKO=False,bEnableAimAssistPad=True,bEnableAimAssistKeyboard=False,DropItemMaxNum=3000,DropItemMaxNum_UNKO=100,BaseCampMaxNum=128,BaseCampWorkerMaxNum=15,DropItemAliveMaxHours=1.000000,bAutoResetGuildNoOnlinePlayers=False,AutoResetGuildTimeNoOnlinePlayers=72.000000,GuildPlayerMaxNum=20,PalEggDefaultHatchingTime=72.000000,WorkSpeedRate=1.000000,bIsMultiplay=False,bIsPvP=False,bCanPickupOtherGuildDeathPenaltyDrop=False,bEnableNonLoginPenalty=True,bEnableFastTravel=True,bIsStartLocationSelectByMap=True,bExistPlayerAfterLogout=False,bEnableDefenseOtherGuildPlayer=False,bShowPlayerList=False,CoopPlayerMaxNum=4,ServerPlayerMaxNum=32,ServerName=\"palgo\",ServerDescription=\"https://github.com/Hoshinonyaruko/palworld-go\",AdminPassword=\"useradmin\",ServerPassword=\"\",PublicPort=8211,PublicIP=\"\",RCONEnabled=True,RCONPort=25575,Region=\"\",bUseAuth=True,BanListURL=\"https://api.palworldgame.com/api/banlist.txt\")"
fmt.Printf("已为您生成默认游戏配置,默认控制台地址:http://127.0.0.1:52000\n")
fmt.Printf("控制台默认用户名(在ServerName配置):palgo\n")
fmt.Printf("控制台默认密码(在AdminPassword配置):useradmin\n")
Expand All @@ -518,7 +523,7 @@ func ReadGameWorldSettings(config *Config) (*GameWorldSettings, error) {
optionSettingsKey, err := section.GetKey("OptionSettings")
if err != nil {
fmt.Printf("未找到配置设置,使用游戏默认配置\n")
settingsString = "(Difficulty=None,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=1.000000,ExpRate=1.000000,PalCaptureRate=1.000000,PalSpawnNumRate=1.000000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=1.000000,PlayerAutoHPRegeneRate=1.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=1.000000,PalAutoHPRegeneRate=1.000000,PalAutoHpRegeneRateInSleep=1.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=1.000000,CollectionDropRate=1.000000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.000000,EnemyDropItemRate=1.000000,DeathPenalty=All,bEnablePlayerToPlayerDamage=False,bEnableFriendlyFire=False,bEnableInvaderEnemy=True,bActiveUNKO=False,bEnableAimAssistPad=True,bEnableAimAssistKeyboard=False,DropItemMaxNum=3000,DropItemMaxNum_UNKO=100,BaseCampMaxNum=128,BaseCampWorkerMaxNum=15,DropItemAliveMaxHours=1.000000,bAutoResetGuildNoOnlinePlayers=False,AutoResetGuildTimeNoOnlinePlayers=72.000000,GuildPlayerMaxNum=20,PalEggDefaultHatchingTime=72.000000,WorkSpeedRate=1.000000,bIsMultiplay=False,bIsPvP=False,bCanPickupOtherGuildDeathPenaltyDrop=False,bEnableNonLoginPenalty=True,bEnableFastTravel=True,bIsStartLocationSelectByMap=True,bExistPlayerAfterLogout=False,bEnableDefenseOtherGuildPlayer=False,CoopPlayerMaxNum=4,ServerPlayerMaxNum=32,ServerName=\"palgo\",ServerDescription=\"https://github.com/Hoshinonyaruko/palworld-go\",AdminPassword=\"useradmin\",ServerPassword=\"\",PublicPort=8211,PublicIP=\"\",RCONEnabled=True,RCONPort=25575,Region=\"\",bUseAuth=True,BanListURL=\"https://api.palworldgame.com/api/banlist.txt\")"
settingsString = "(Difficulty=None,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=1.000000,ExpRate=1.000000,PalCaptureRate=1.000000,PalSpawnNumRate=1.000000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=1.000000,PlayerAutoHPRegeneRate=1.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=1.000000,PalAutoHPRegeneRate=1.000000,PalAutoHpRegeneRateInSleep=1.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=1.000000,CollectionDropRate=1.000000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.000000,EnemyDropItemRate=1.000000,DeathPenalty=All,bEnablePlayerToPlayerDamage=False,bEnableFriendlyFire=False,bEnableInvaderEnemy=True,bActiveUNKO=False,bEnableAimAssistPad=True,bEnableAimAssistKeyboard=False,DropItemMaxNum=3000,DropItemMaxNum_UNKO=100,BaseCampMaxNum=128,BaseCampWorkerMaxNum=15,DropItemAliveMaxHours=1.000000,bAutoResetGuildNoOnlinePlayers=False,AutoResetGuildTimeNoOnlinePlayers=72.000000,GuildPlayerMaxNum=20,PalEggDefaultHatchingTime=72.000000,WorkSpeedRate=1.000000,bIsMultiplay=False,bIsPvP=False,bCanPickupOtherGuildDeathPenaltyDrop=False,bEnableNonLoginPenalty=True,bEnableFastTravel=True,bIsStartLocationSelectByMap=True,bExistPlayerAfterLogout=False,bEnableDefenseOtherGuildPlayer=False,bShowPlayerList=False,CoopPlayerMaxNum=4,ServerPlayerMaxNum=32,ServerName=\"palgo\",ServerDescription=\"https://github.com/Hoshinonyaruko/palworld-go\",AdminPassword=\"useradmin\",ServerPassword=\"\",PublicPort=8211,PublicIP=\"\",RCONEnabled=True,RCONPort=25575,Region=\"\",bUseAuth=True,BanListURL=\"https://api.palworldgame.com/api/banlist.txt\")"
fmt.Printf("已为您生成默认游戏配置,默认控制台地址:http://127.0.0.1:52000\n")
fmt.Printf("控制台默认用户名(在ServerName配置):palgo\n")
fmt.Printf("控制台默认密码(在AdminPassword配置):useradmin\n")
Expand Down
189 changes: 189 additions & 0 deletions front/palworld-front/src/components/PalguardManage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<template>
<q-page class="q-pa-md">
<div class="q-mb-md">
<q-btn label="保存配置" color="primary" @click="saveConfig" />
<q-btn
label="重启服务器"
color="negative"
@click="restartServer"
class="q-ml-md"
/>
</div>
<q-form class="q-gutter-md">
<q-toggle v-model="config.RCONbase64" label="RCON 基于 Base64" />
<q-field label="管理员 IP">
<q-chip
v-for="(ip, index) in config.adminIPs"
:key="index"
removable
@remove="config.adminIPs.splice(index, 1)"
>
{{ ip }}
</q-chip>
<q-input
v-model="newAdminIP"
dense
placeholder="添加新 IP"
@keyup.enter="addAdminIP"
/>
</q-field>
<q-toggle v-model="config.allowAdminCheats" label="允许管理员作弊" />
<q-toggle
v-model="config.allowNoSpoilModWhichCanCrashYourServer"
label="允许NoSpoil模组(可能会崩溃服务器)"
/>
<q-toggle
v-model="config.allowSpawningNPCItems"
label="允许生成 NPC 物品"
/>
<q-toggle v-model="config.announceConnections" label="公告连接" />
<q-toggle v-model="config.announcePunishments" label="公告惩罚" />
<q-field label="禁止的聊天词">
<q-chip
v-for="(word, index) in config.bannedChatWords"
:key="index"
removable
@remove="config.bannedChatWords.splice(index, 1)"
>
{{ word }}
</q-chip>
<q-input
v-model="newBannedChatWord"
dense
placeholder="添加新聊天禁词"
@keyup.enter="addBannedChatWord"
/>
</q-field>
<q-field label="禁止的玩家昵称">
<q-chip
v-for="(name, index) in config.bannedNames"
:key="index"
removable
@remove="config.bannedNames.splice(index, 1)"
>
{{ name }}
</q-chip>
<q-input
v-model="newBannedName"
dense
placeholder="添加新禁止玩家昵称"
@keyup.enter="addBannedName"
/>
</q-field>
<q-toggle
v-model="config.blockNPCVendorCapture"
label="阻止 NPC 商人捕获"
/>
<q-toggle
v-model="config.blockTowerBossCapture"
label="阻止塔楼 Boss 捕获"
/>
<q-toggle v-model="config.chatBypassWait" label="聊天绕过等待" />
<q-toggle v-model="config.isChineseCmd" label="中文命令" />
<q-toggle v-model="config.isStealingAllowed" label="允许偷窃" />
<q-toggle v-model="config.logChat" label="输出聊天信息日志" />
<q-toggle v-model="config.logNetworking" label="输出网络日志" />
<q-toggle v-model="config.logRCON" label="输出RCON日志" />
<q-input
v-model="config.pveMaxToPalBanThreshold"
label="PvE 最大宠物封禁阈值"
type="number"
/>
<q-input
v-model="config.pvpMaxToBuildingDamage"
label="PvP 对建筑伤害最大值"
type="number"
/>
<q-input
v-model="config.pvpMaxToPalDamage"
label="PvP 对宠物伤害最大值"
type="number"
/>
<q-input
v-model="config.pvpMaxToPlayerDamage"
label="PvP 对玩家伤害最大值"
type="number"
/>
<q-toggle v-model="config.shouldBanCheaters" label="应封禁作弊者" />
<q-toggle v-model="config.shouldIPBanCheaters" label="应 IP 封禁作弊者" />
<q-toggle v-model="config.shouldKickCheaters" label="应踢出作弊者" />
<q-toggle v-model="config.shouldWarnCheaters" label="应警告作弊者" />
<q-toggle
v-model="config.shouldWarnCheatersReason"
label="警告作弊者原因"
/>
<q-toggle v-model="config.steamidProtection" label="Steam ID 保护" />
<q-toggle v-model="config.useAdminWhitelist" label="使用管理员白名单" />
<q-toggle v-model="config.useWhitelist" label="使用白名单" />
<q-input
v-model="config.whitelistMessage"
label="白名单消息"
type="textarea"
/>
</q-form>
</q-page>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { useQuasar } from 'quasar';
import axios from 'axios';
const $q = useQuasar();
const config = ref({});
onMounted(async () => {
try {
const response = await axios.get('/api/getpalguardjson', {
withCredentials: true,
});
config.value = response.data;
$q.notify({
type: 'positive',
message: '配置加载成功',
});
} catch (error) {
console.error('Error fetching configuration:', error);
$q.notify({
type: 'negative',
message: '获取配置失败',
});
}
});
const saveConfig = async () => {
try {
await axios.post('/api/savepalguardjson', config.value, {
withCredentials: true,
});
$q.notify({
type: 'positive',
message: '配置已保存!',
});
} catch (error) {
console.error('Error saving configuration:', error);
$q.notify({
type: 'negative',
message: '保存配置失败',
});
}
};
const restartServer = async () => {
try {
const response = await axios.post(
'/api/restart',
{},
{
withCredentials: true,
}
);
if (response.status === 200) {
alert('服务器重启命令已发送!');
} else {
console.error('服务器重启失败:', response.status);
}
} catch (error) {
console.error('Error sending restart command:', error);
}
};
</script>
Loading

0 comments on commit 1bc5296

Please sign in to comment.