-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
114 lines (95 loc) · 3.74 KB
/
server.js
File metadata and controls
114 lines (95 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;
app.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "*");
next();
});
app.get('/StoreOffer/:itemId', (req, res) => {
const itemId = req.params.itemId;
const minecraftUrl = `minecraft://openStore?showStoreOffer=${itemId}`;
res.redirect(minecraftUrl);
});
app.get('/DressingRoomOffer/:itemId', (req, res) => {
const itemId = req.params.itemId;
const minecraftUrl = `minecraft://openStore/?showDressingRoomOffer=${itemId}`;
res.redirect(minecraftUrl);
});
app.get('/StoreHome', (req, res) => {
const minecraftUrl = 'minecraft://openStore';
res.redirect(minecraftUrl);
});
app.get('/MineCoinOffers', (req, res) => {
const minecraftUrl = 'minecraft://?showMineCoinOffers=1';
res.redirect(minecraftUrl);
});
app.get('/MarketplaceInventory/:type', (req, res) => {
const type = req.params.type;
const minecraftUrl = `minecraft://?openMarketplaceInventory=${type}`;
res.redirect(minecraftUrl);
});
app.get('/ProfileScreen', (req, res) => {
const minecraftUrl = 'minecraft://showProfileScreen';
res.redirect(minecraftUrl);
});
app.get('/HowToPlay', (req, res) => {
const minecraftUrl = 'minecraft://?showHowToPlayScreen=1';
res.redirect(minecraftUrl);
});
app.get('/AddExternalServer', (req, res) => {
const name = req.query.name || '';
const address = req.query.address || '';
const port = req.query.port || '19132';
const value = `${encodeURIComponent(name)}|${address}:${port}`;
const minecraftUrl = `minecraft://?addExternalServer=${value}`;
res.redirect(minecraftUrl);
});
app.get('/ConnectServer', (req, res) => {
const serverUrl = req.query.serverUrl || '';
const serverPort = req.query.serverPort || '19132';
const minecraftUrl = `minecraft://connect/?serverUrl=${encodeURIComponent(serverUrl)}&serverPort=${serverPort}`;
res.redirect(minecraftUrl);
});
app.get('/ConnectLocalWorldByName/:worldName', (req, res) => {
const worldName = req.params.worldName;
const minecraftUrl = `minecraft://connect/?localWorld=${encodeURIComponent(worldName)}`;
res.redirect(minecraftUrl);
});
app.get('/ConnectLocalWorldById/:levelId', (req, res) => {
const levelId = req.params.levelId;
const minecraftUrl = `minecraft://?load=${encodeURIComponent(levelId)}`;
res.redirect(minecraftUrl);
});
app.get('/AcceptRealmInvite/:inviteId', (req, res) => {
const inviteId = req.params.inviteId;
const minecraftUrl = `minecraft://acceptRealmInvite?inviteID=${inviteId}`;
res.redirect(minecraftUrl);
});
app.get('/ConnectRealmById/:realmId', (req, res) => {
const realmId = req.params.realmId;
const minecraftUrl = `minecraft://connectToRealm?realmId=${realmId}`;
res.redirect(minecraftUrl);
});
app.get('/ConnectRealmByInvite/:inviteId', (req, res) => {
const inviteId = req.params.inviteId;
const minecraftUrl = `minecraft://connectToRealm?inviteID=${inviteId}`;
res.redirect(minecraftUrl);
});
app.get('/JoinGathering/:gatheringId', (req, res) => {
const gatheringId = req.params.gatheringId;
const minecraftUrl = `minecraft://joinGathering?gatheringId=${gatheringId}`;
res.redirect(minecraftUrl);
});
app.get('/JoinExperience/:experienceId', (req, res) => {
const experienceId = req.params.experienceId;
const minecraftUrl = `minecraft://joinExperience?experienceId=${experienceId}`;
res.redirect(minecraftUrl);
});
app.get('/SlashCommand', (req, res) => {
const command = req.query.command || '';
const minecraftUrl = `minecraft://?slashcommand=${encodeURIComponent(command)}`;
res.redirect(minecraftUrl);
});
app.listen(PORT, () => {
console.log(`Server läuft auf http://localhost:${PORT}`);
});