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

Beta33 #78

Merged
merged 40 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1479feb
beta9
Hoshinonyaruko Jan 26, 2024
4a6f523
beta11
Hoshinonyaruko Jan 26, 2024
8739198
beta11
Hoshinonyaruko Jan 26, 2024
d9e0844
beta13
Hoshinonyaruko Jan 26, 2024
ab96bf7
beta14
Hoshinonyaruko Jan 26, 2024
9b7bf0e
beta12
Hoshinonyaruko Jan 26, 2024
7c66e7d
beta13
Hoshinonyaruko Jan 26, 2024
eb0b186
beta15
Hoshinonyaruko Jan 26, 2024
122de8b
beta16
Hoshinonyaruko Jan 26, 2024
5e4903f
beta17
Hoshinonyaruko Jan 26, 2024
7a82cfb
beta18
Hoshinonyaruko Jan 27, 2024
ecc8263
mergefix
Hoshinonyaruko Jan 27, 2024
d0a0a85
beta19
Hoshinonyaruko Jan 27, 2024
afcb856
beta20
Hoshinonyaruko Jan 27, 2024
fafe0f9
beta20
Hoshinonyaruko Jan 27, 2024
397d4c7
beta21
Hoshinonyaruko Jan 27, 2024
c00e1a8
fixmerge
Hoshinonyaruko Jan 27, 2024
42ed202
add_playermanager_api
Hoshinonyaruko Jan 27, 2024
31a6771
beta22
Hoshinonyaruko Jan 27, 2024
050d359
beta22
Hoshinonyaruko Jan 27, 2024
939e818
beta23
Hoshinonyaruko Jan 28, 2024
19cf927
merge
Hoshinonyaruko Jan 28, 2024
8073f3a
beta24
Hoshinonyaruko Jan 29, 2024
fdd6016
mergechanges
Hoshinonyaruko Jan 29, 2024
b167455
beta25
Hoshinonyaruko Jan 30, 2024
844698b
merge
Hoshinonyaruko Jan 30, 2024
f5c8d82
beta26
Hoshinonyaruko Jan 30, 2024
2d5e94d
merge
Hoshinonyaruko Jan 30, 2024
3076085
beta27
Hoshinonyaruko Jan 30, 2024
a8a67ed
beta28
Hoshinonyaruko Jan 31, 2024
4c954fa
beta28
Hoshinonyaruko Jan 31, 2024
2f9063e
beta28
Hoshinonyaruko Jan 31, 2024
cd6fad7
beta29
Hoshinonyaruko Jan 31, 2024
2651176
beta29
Hoshinonyaruko Jan 31, 2024
265b5e3
beta30
Hoshinonyaruko Jan 31, 2024
8aac47a
beta31
Hoshinonyaruko Feb 2, 2024
a559fa2
beta31
Hoshinonyaruko Feb 2, 2024
f5bb66a
beta32
Hoshinonyaruko Feb 2, 2024
44fac8f
beta33
Hoshinonyaruko Feb 6, 2024
a44ef68
merge
Hoshinonyaruko Feb 6, 2024
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
30 changes: 28 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Config struct {
SteamPath string `json:"steamPath"` // steam路径
CommunityServer bool `json:"communityServer"` // 社区服务器开关
UseDll bool `json:"useDll"` // dll注入
DllPort string `json:"dllPort"` // dll通信port
Cert string `json:"cert"` // 证书
Key string `json:"key"` // 密钥
Address string `json:"address"` // 服务器 IP 地址
Expand Down Expand Up @@ -70,6 +71,7 @@ var defaultConfig = Config{
ProcessName: "PalServer",
Onebotv11HttpApiPath: "",
UseDll: false,
DllPort: "53000",
Cert: "",
Key: "",
SteamCmdPath: "C:\\Program Files\\PalServer\\steam",
Expand Down Expand Up @@ -250,6 +252,18 @@ func ReadConfig() Config {
writeConfigToFile(config)
}

// 刷新dll通信端口 构造rconsettings.ini的完整路径
filePath := filepath.Join(config.GamePath, "Pal", "Binaries", "Win64", "rconsettings.ini")

// 准备写入文件的内容
content := fmt.Sprintf("[rcon]\nport=%s\n", config.DllPort)

// 写入文件
err = os.WriteFile(filePath, []byte(content), 0644) // 使用0644权限创建或覆盖文件
if err != nil {
fmt.Printf("Failed to write to %s: %v", filePath, err)
}

return config
}

Expand Down Expand Up @@ -492,7 +506,8 @@ func ReadGameWorldSettings(config *Config) (*GameWorldSettings, error) {
fmt.Printf("控制台默认密码(在AdminPassword配置):useradmin\n")
fmt.Printf("登录cookie 24小时有效,若在控制台修改后需立即刷新,删除cookie.db并使用新的用户名密码登录\n")
} else {
settingsString = optionSettingsKey.String()
// 去除settingsString中的所有反引号
settingsString = strings.Replace(optionSettingsKey.String(), "`", "", -1)
}

// 解析设置字符串
Expand Down Expand Up @@ -597,7 +612,16 @@ func settingsToString(settings *GameWorldSettings) string {
var valueString string
switch fieldValue.Kind() {
case reflect.String:
valueString = "\"" + fieldValue.String() + "\"" // 添加双引号
// 特殊处理:如果字段名为"Difficulty"且值为"0",则输出"None";否则,不添加引号
if field.Name == "Difficulty" {
if fieldValue.String() == "0" {
valueString = "None" // 特殊值处理
} else {
valueString = fieldValue.String() // 不添加双引号
}
} else {
valueString = "\"" + fieldValue.String() + "\"" // 为其他字符串值添加双引号
}
case reflect.Float64:
valueString = strconv.FormatFloat(fieldValue.Float(), 'f', 6, 64) // 格式化浮点数,保留6位小数
case reflect.Int:
Expand Down Expand Up @@ -643,6 +667,8 @@ func WriteGameWorldSettings(config *Config, settings *GameWorldSettings) error {

// 使用settingsToString函数生成OptionSettings值
optionSettingsValue := settingsToString(settings)
// 去除optionSettingsValue中的所有反引号
optionSettingsValue = strings.Replace(optionSettingsValue, "`", "", -1)

// 获取或创建OptionSettings项,并设置其值
optionSettingsKey, err := section.GetKey("OptionSettings")
Expand Down
99 changes: 99 additions & 0 deletions front/palworld-front/src/components/BanManage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<template>
<q-page padding>
<q-btn icon="refresh" color="primary" @click="loadPlayers" class="q-mb-md"
>刷新</q-btn
>

<div v-if="loading">加载中...</div>
<div v-else>
<q-list bordered separator>
<q-item
v-for="player in players"
:key="player.playeruid"
clickable
@click="selectPlayer(player)"
>
<q-item-section>
<div class="text-h6">{{ player.name }}</div>
<div>playeruid: {{ player.playeruid }}</div>
<div>steamid: {{ player.steamid }}</div>
<div>上次上线时间: {{ player.last_online }}</div>
<!-- 添加显示上次上线时间 -->
</q-item-section>
<q-item-section side>
<q-btn flat color="red" icon="block" @click.stop="setUnBan(player)"
>解除封禁</q-btn
>
</q-item-section>
</q-item>
</q-list>
</div>
</q-page>
</template>

<script setup lang="ts">
import { ref, onMounted, computed } from 'vue';
import { useQuasar } from 'quasar';
import axios from 'axios';

interface Player {
name: string;
playeruid: string;
steamid: string;
last_online: string;
}

const players = ref<Player[]>([]);
const loading = ref(true);
const $q = useQuasar();

const loadPlayers = async () => {
loading.value = true;
try {
const response = await axios.get('/api/getban');
// 取出bannedPlayers数组并赋值
players.value = response.data.bannedPlayers;
} catch (error) {
console.error('API 请求失败', error);
$q.notify({ type: 'negative', message: '加载失败' });
} finally {
loading.value = false;
}
};

// 解除玩家封禁的函数
const setUnBan = async (player: Player) => {
try {
const response = await axios.post('/api/setunban', {
steamid: player.steamid,
});

if (response.status === 200) {
$q.notify({
type: 'positive',
message: '解除封禁成功',
});

// 重新加载封禁列表以反映更新
await loadPlayers();
}
} catch (error) {
console.error('API 请求失败', error);
$q.notify({
type: 'negative',
message: '解除封禁失败',
});
}
};

onMounted(loadPlayers);

const selectPlayer = (player: Player) => {
// 记录选中的playeruid和steamid
console.log('选中的玩家:', player);
};
</script>

<style scoped lang="scss">
/* 可以添加自定义样式 */
</style>
76 changes: 51 additions & 25 deletions front/palworld-front/src/pages/IndexView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<q-tab name="command" label="服务器指令" />
<q-tab name="player-manage" label="玩家管理" />
<q-tab name="player-white" label="玩家白名单" />
<q-tab name="ban-manage" label="封禁玩家管理" />
<q-tab name="advanced" label="SAV修改" @click="redirectToSav" />
<q-tab name="server-check" label="主机管理" />
<q-tab name="save-manage" label="存档管理" />
Expand Down Expand Up @@ -55,7 +56,19 @@
<q-input
filled
v-model="config.maintenanceWarningMessage"
label="维护公告消息(英文)"
label="维护公告消息"
class="q-my-md"
/>
<q-input
filled
v-model="config.webuiPort"
label="webui端口(多服务端请自行错开)"
class="q-my-md"
/>
<q-input
filled
v-model="config.dllPort"
label="dll通信端口(多服务端请自行错开)"
class="q-my-md"
/>
<q-input
Expand Down Expand Up @@ -275,11 +288,11 @@
<!-- 难度和死亡掉落 -->
<!-- 难度选择框 -->
<div class="q-my-md">
<q-select
<q-input
filled
v-model="config.worldSettings.difficulty"
:options="difficultyOptions"
label="难度"
label="难度 0默认 1简单 2中等 3复杂"
class="q-my-md"
/>
<q-btn
icon="help"
Expand All @@ -289,7 +302,7 @@
@click="toggleTooltip2('difficulty')"
/>
<q-tooltip v-if="showDifficultyTooltip">
难度说明:简单(Eazy),困难(Difficult)
难度说明:数字越大,越难
</q-tooltip>
</div>

Expand Down Expand Up @@ -412,7 +425,7 @@
filled
v-model.number="config.worldSettings.palDamageRateDefense"
type="number"
label="Pal 防御伤害率"
label="Pal 承受伤害倍率"
class="q-my-md"
/>
<q-input
Expand All @@ -426,7 +439,7 @@
filled
v-model.number="config.worldSettings.playerDamageRateDefense"
type="number"
label="玩家防御伤害率"
label="玩家承受伤害倍率"
class="q-my-md"
/>
<q-input
Expand Down Expand Up @@ -954,6 +967,10 @@
</div>
</div>
</q-page>
<!-- 封禁玩家管理组件 -->
<q-page padding v-if="tab === 'ban-manage'">
<ban-manage />
</q-page>
<q-page padding v-if="tab === 'server-check'">
<div class="text-h6">服务器检测页面</div>
<running-process-status
Expand All @@ -977,23 +994,24 @@
import { ref, onMounted, onUnmounted, onBeforeUnmount, watch } from 'vue';
import axios from 'axios';
import { QPage, QCard, QCardSection } from 'quasar';
import { useQuasar } from 'quasar';
import RunningProcessStatus from 'components/RunningProcessStatus.vue';
import PlayerManage from 'components/PlayerManage.vue';
import SaveManage from 'components/SaveManage.vue';
import BotManage from 'components/BotManage.vue';
import BanManage from 'components/BanManage.vue';

//给components传递数据
const props = defineProps({
uin: Number,
});

const players = ref([]);

Check warning on line 1009 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for arm64

'players' is assigned a value but never used

Check warning on line 1009 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for arm64

'players' is assigned a value but never used

Check warning on line 1009 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for amd64

'players' is assigned a value but never used

Check warning on line 1009 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on windows for amd64

'players' is assigned a value but never used

Check warning on line 1009 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for amd64

'players' is assigned a value but never used

const status = ref(null); // 假设 ProcessInfo 是一个对象,这里使用 null 作为初始值

const tab = ref('guard'); // 默认选中守护配置修改
// 难度选项
const difficultyOptions = ['Eazy', 'None', 'Difficult'];

// 死亡掉落选项
const deathPenaltyOptions = ['None', 'Item', 'ItemAndEquipment', 'All'];

Expand All @@ -1002,11 +1020,11 @@
const showDifficultyTooltip = ref(false);
const showDeathPenaltyTooltip = ref(false);

const toggleTooltip = (type) => {

Check warning on line 1023 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for arm64

'type' is defined but never used

Check warning on line 1023 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for arm64

'type' is defined but never used

Check warning on line 1023 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for amd64

'type' is defined but never used

Check warning on line 1023 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on windows for amd64

'type' is defined but never used

Check warning on line 1023 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for amd64

'type' is defined but never used
showDeathPenaltyTooltip.value = !showDeathPenaltyTooltip.value;
};

const toggleTooltip2 = (type) => {

Check warning on line 1027 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for arm64

'type' is defined but never used

Check warning on line 1027 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for arm64

'type' is defined but never used

Check warning on line 1027 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on linux for amd64

'type' is defined but never used

Check warning on line 1027 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on windows for amd64

'type' is defined but never used

Check warning on line 1027 in front/palworld-front/src/pages/IndexView.vue

View workflow job for this annotation

GitHub Actions / Build on darwin for amd64

'type' is defined but never used
showDifficultyTooltip.value = !showDifficultyTooltip.value;
};

Expand All @@ -1014,19 +1032,6 @@
window.location.href = '/sav/index.html'; // 重定向到 /sav 路径
};

// // 难度选项
// const difficultyOptions = [
// { label: '简单', value: 'Eazy' },
// { label: '困难', value: 'Difficult' },
// ];

// // 死亡掉落选项
// const deathPenaltyOptions = [
// { label: '不掉落', value: 'None' },
// { label: '只掉落物品', value: 'Item' },
// { label: '掉落物品和装备', value: 'ItemAndEquipment' },
// { label: '掉落物品、装备和帕鲁', value: 'All' },
// ];
const config = ref({});

// 增加一个消息到数组
Expand Down Expand Up @@ -1058,20 +1063,41 @@
}

onMounted(async () => {
const $q = useQuasar();
try {
const response = await axios.get('/api/getjson');
const response = await axios.get('/api/getjson', {
withCredentials: true, // 确保携带 cookie
});
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 () => {
const $q = useQuasar();
try {
await axios.post('/api/savejson', config.value);
alert('配置已保存!');
await axios.post('/api/savejson', config.value, {
withCredentials: true, // 确保携带 cookie
});
$q.notify({
type: 'positive',
message: '配置已保存!',
});
} catch (error) {
console.error('Error saving configuration:', error);
$q.notify({
type: 'negative',
message: '保存配置失败',
});
}
};

Expand Down
Binary file modified mod/embeds/PalServerInject.exe
Binary file not shown.
Binary file modified mod/embeds/pal-plugin-loader.dll
Binary file not shown.
20 changes: 20 additions & 0 deletions status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package status

var memoryIssueDetected bool = false
var successReadGameWorldSettings bool = false
var manualServerShutdown bool = false // 存储是否手动关闭服务器的状态
var globalpid int = 0

// SetMemoryIssueDetected 设置内存问题检测标志
func SetMemoryIssueDetected(flag bool) {
Expand All @@ -23,3 +25,21 @@ func SetsuccessReadGameWorldSettings(flag bool) {
func GetsuccessReadGameWorldSettings() bool {
return successReadGameWorldSettings
}

// SetManualServerShutdown 设置手动关闭服务器的状态
func SetManualServerShutdown(flag bool) {
manualServerShutdown = flag
}

// GetManualServerShutdown 获取手动关闭服务器的状态
func GetManualServerShutdown() bool {
return manualServerShutdown
}

func SetGlobalPid(pid int) {
globalpid = pid
}

func GetGlobalPid() int {
return globalpid
}
Loading
Loading