Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eb462e5a7 | ||
|
|
e5dda9531f | ||
|
|
b851cbc20b | ||
|
|
de04e58242 | ||
|
|
166bfad1d4 | ||
|
|
1de9e4b155 | ||
|
|
501be8649a | ||
|
|
3c80758b12 | ||
|
|
f7e0dcb23d | ||
|
|
65ea93e22d | ||
|
|
fde1947ae7 | ||
|
|
7556521a0e |
Binary file not shown.
@@ -2,7 +2,7 @@
|
||||
"manifest_version": 3,
|
||||
"name": "Minecraft Bungee Status",
|
||||
"description": "Zeigt den Live-Status mehrerer Bungee/Proxy-Server an. Fallback auf WordPress AJAX möglich.",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"action": {
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": {
|
||||
|
||||
+435
-217
@@ -1,217 +1,435 @@
|
||||
:root {
|
||||
--bg: #111827;
|
||||
--panel: #0b1220;
|
||||
--text: #e6eef8;
|
||||
--muted: #9aa7b3;
|
||||
--accent: #3b82f6;
|
||||
--danger: #ef4444;
|
||||
--radius: 8px;
|
||||
--online: #22c55e;
|
||||
--offline: #ef4444;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: Inter, Arial, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.root {
|
||||
width: 520px;
|
||||
padding: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
header h1 { font-size: 16px; margin: 0; }
|
||||
|
||||
header .actions button {
|
||||
background: transparent;
|
||||
border: 1px solid var(--muted);
|
||||
color: var(--text);
|
||||
padding: 4px 8px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.main {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
position: relative;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.server-list {
|
||||
width: 45%;
|
||||
background: var(--panel);
|
||||
padding: 8px;
|
||||
border-radius: var(--radius);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.detail {
|
||||
flex: 1;
|
||||
background: var(--panel);
|
||||
padding: 8px;
|
||||
border-radius: var(--radius);
|
||||
min-height: 220px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.detail.full-width {
|
||||
width: 100%;
|
||||
flex: 1 1 100%;
|
||||
}
|
||||
|
||||
.add-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
|
||||
.add-form input { padding: 6px 8px; border-radius: 6px; border: 1px solid #21303b; background: #071019; color: var(--text); }
|
||||
.add-form button { padding: 6px 8px; border-radius: 6px; border: none; background: var(--accent); color: white; cursor: pointer; }
|
||||
|
||||
#serversContainer {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.server-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px;
|
||||
margin-bottom: 6px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
background: rgba(255,255,255,0.02);
|
||||
transition: background 0.2s ease;
|
||||
}
|
||||
|
||||
.server-item:hover { background: rgba(255,255,255,0.05); }
|
||||
.server-item .meta { display: flex; flex-direction: column; }
|
||||
.server-item .meta .name { font-weight: 600; }
|
||||
.server-item .meta .url { font-size: 11px; color: var(--muted); }
|
||||
|
||||
.server-item .status-bubble {
|
||||
font-size: 11px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.placeholder { color: var(--muted); padding: 12px; font-size: 13px; }
|
||||
.hidden { display: none; }
|
||||
|
||||
.detail-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.server-identity h2 { margin: 0; font-size: 18px; line-height: 1.2; }
|
||||
.server-url { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
|
||||
|
||||
.status-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.pulsing-dot {
|
||||
width: 10px; height: 10px; border-radius: 50%;
|
||||
background-color: var(--offline);
|
||||
box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
|
||||
animation: pulse-red 2s infinite;
|
||||
}
|
||||
.pulsing-dot.online {
|
||||
background-color: var(--online);
|
||||
animation: pulse-green 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse-green { 0% {box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);} 70% {box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);} 100% {box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);} }
|
||||
@keyframes pulse-red { 0% {box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);} 70% {box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);} 100% {box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);} }
|
||||
|
||||
.detail-stats {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
background: rgba(255,255,255,0.05);
|
||||
padding: 10px;
|
||||
border-radius: var(--radius);
|
||||
margin-bottom: 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.playerList {
|
||||
list-style: none;
|
||||
padding: 10px 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
justify-content: center; /* Das hier setzt die Köpfe wieder in die Mitte */
|
||||
}
|
||||
|
||||
.player-item {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.player-avatar {
|
||||
width: 42px; height: 42px;
|
||||
border-radius: 6px;
|
||||
transition: transform 0.2s ease;
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,0.3);
|
||||
border: 2px solid rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
.player-avatar:hover {
|
||||
transform: scale(1.1);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.player-hover-info {
|
||||
position: absolute;
|
||||
bottom: -28px;
|
||||
background: rgba(0, 0, 0, 0.95);
|
||||
color: white;
|
||||
padding: 3px 10px;
|
||||
border-radius: 4px;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
pointer-events: none;
|
||||
opacity: 0;
|
||||
transform: translateY(5px);
|
||||
transition: all 0.2s ease;
|
||||
z-index: 100;
|
||||
border: 1px solid rgba(255,255,255,0.2);
|
||||
}
|
||||
|
||||
.player-item:hover .player-hover-info {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.detailButtons { display: flex; gap: 8px; margin-top: 15px; border-top: 1px solid rgba(255,255,255,0.05); padding-top: 10px; }
|
||||
.detailButtons button { padding: 6px 12px; border-radius: 6px; border: none; cursor: pointer; font-size: 12px; font-weight: 600; }
|
||||
#btnEdit { background: #f59e0b; color: #000; }
|
||||
#btnDelete { background: var(--danger); color: #fff; }
|
||||
|
||||
::-webkit-scrollbar { width: 6px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
|
||||
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
|
||||
:root {
|
||||
--bg: #0d1117;
|
||||
--panel: #161b27;
|
||||
--panel2: #111620;
|
||||
--text: #e6eef8;
|
||||
--muted: #5a6a7a;
|
||||
--muted2: #8899aa;
|
||||
--accent: #3b82f6;
|
||||
--radius: 9px;
|
||||
--online: #22c55e;
|
||||
--offline: #ef4444;
|
||||
--border: rgba(255,255,255,0.07);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
html, body {
|
||||
margin: 0; padding: 0;
|
||||
font-family: Inter, Arial, sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.root {
|
||||
width: 560px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* ── Header ── */
|
||||
header {
|
||||
background: var(--panel);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 13px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
header h1 {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
letter-spacing: 0.03em;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
header .actions { display: flex; gap: 7px; }
|
||||
|
||||
header .actions button {
|
||||
background: rgba(255,255,255,0.07);
|
||||
border: 1px solid rgba(255,255,255,0.1);
|
||||
color: var(--muted2);
|
||||
border-radius: 7px;
|
||||
width: 32px; height: 32px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
|
||||
header .actions button:hover {
|
||||
background: rgba(255,255,255,0.12);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* ── Main layout ── */
|
||||
.main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* ── Settings / add-form panel ── */
|
||||
.settings-panel {
|
||||
background: var(--panel2);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 14px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.settings-panel input {
|
||||
padding: 8px 12px;
|
||||
border-radius: 7px;
|
||||
border: 1px solid rgba(255,255,255,0.09);
|
||||
background: rgba(0,0,0,0.3);
|
||||
color: var(--text);
|
||||
font-size: 13px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.settings-panel input:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.settings-panel button {
|
||||
padding: 8px 12px;
|
||||
border-radius: 7px;
|
||||
border: none;
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ── Server list ── */
|
||||
.server-list-panel {
|
||||
background: var(--panel2);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
#serversContainer {
|
||||
list-style: none;
|
||||
margin: 0; padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.server-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 9px 12px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
transition: background 0.15s, border-color 0.15s;
|
||||
}
|
||||
|
||||
.server-item:hover { background: rgba(255,255,255,0.04); }
|
||||
.server-item.selected { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.25); }
|
||||
|
||||
.server-item .meta { display: flex; flex-direction: column; gap: 2px; }
|
||||
.server-item .meta .name { font-size: 13px; font-weight: 600; color: #fff; }
|
||||
.server-item .meta .url { font-size: 11px; color: var(--muted); }
|
||||
|
||||
.status-bubble {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 3px 10px;
|
||||
border-radius: 999px;
|
||||
color: #fff;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* ── Detail panel ── */
|
||||
.detail-panel {
|
||||
padding: 18px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
padding: 24px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Server identity + online badge */
|
||||
.srv-identity {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.srv-name { font-size: 20px; font-weight: 700; color: #fff; margin: 0 0 4px; }
|
||||
.srv-url { font-size: 12px; color: var(--muted); }
|
||||
|
||||
.online-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
border-radius: 999px;
|
||||
padding: 5px 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.online-badge.online {
|
||||
background: rgba(34,197,94,0.12);
|
||||
border: 1px solid rgba(34,197,94,0.25);
|
||||
color: #4ade80;
|
||||
}
|
||||
|
||||
.online-badge.offline {
|
||||
background: rgba(239,68,68,0.1);
|
||||
border: 1px solid rgba(239,68,68,0.2);
|
||||
color: #f87171;
|
||||
}
|
||||
|
||||
.pulsing-dot {
|
||||
width: 7px; height: 7px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.pulsing-dot.online {
|
||||
background: var(--online);
|
||||
animation: pulse-green 2s infinite;
|
||||
}
|
||||
|
||||
.pulsing-dot.offline {
|
||||
background: var(--offline);
|
||||
animation: pulse-red 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse-green {
|
||||
0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
|
||||
50% { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
|
||||
}
|
||||
@keyframes pulse-red {
|
||||
0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
|
||||
50% { box-shadow: 0 0 0 5px rgba(239,68,68,0); }
|
||||
}
|
||||
|
||||
/* MOTD */
|
||||
.motd-bar {
|
||||
font-size: 12px;
|
||||
color: var(--muted2);
|
||||
background: rgba(255,255,255,0.03);
|
||||
border-radius: 8px;
|
||||
padding: 8px 14px;
|
||||
border-left: 2px solid rgba(59,130,246,0.35);
|
||||
font-style: italic;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
/* Stats row – 3 gleich breite Karten */
|
||||
.stats-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
gap: 10px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 12px 16px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.stat-val {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.stat-val.small {
|
||||
font-size: 12px;
|
||||
padding-top: 4px;
|
||||
font-weight: 500;
|
||||
color: var(--muted2);
|
||||
}
|
||||
|
||||
/* Section label */
|
||||
.section-label {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: var(--muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
margin-bottom: 9px;
|
||||
padding-top: 6px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* Sub-server chips – immer 3 pro Zeile */
|
||||
.sub-servers {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.sub-chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
border-radius: 8px;
|
||||
padding: 8px 12px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--panel);
|
||||
color: var(--muted2);
|
||||
cursor: default;
|
||||
transition: background 0.15s;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.sub-chip.active {
|
||||
background: rgba(59,130,246,0.1);
|
||||
border-color: rgba(59,130,246,0.3);
|
||||
color: #93c5fd;
|
||||
}
|
||||
|
||||
.sub-chip-dot {
|
||||
width: 7px; height: 7px;
|
||||
border-radius: 50%;
|
||||
background: #2a3040;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sub-chip.active .sub-chip-dot {
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.sub-chip-name {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.sub-chip-count {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
opacity: 0.65;
|
||||
flex-shrink: 0;
|
||||
margin-left: auto;
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
/* Players grid – 2 Spalten */
|
||||
.players-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.player-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 10px 14px;
|
||||
transition: background 0.15s;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.player-card:hover {
|
||||
background: rgba(255,255,255,0.05);
|
||||
}
|
||||
|
||||
.player-avatar {
|
||||
width: 40px; height: 40px;
|
||||
border-radius: 7px;
|
||||
border: 1px solid rgba(255,255,255,0.1);
|
||||
flex-shrink: 0;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
|
||||
.player-info { flex: 1; min-width: 0; }
|
||||
|
||||
.player-name {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.player-prefix {
|
||||
font-size: 11px;
|
||||
color: var(--muted2);
|
||||
margin-bottom: 2px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.player-server-tag {
|
||||
display: inline-block;
|
||||
margin-top: 3px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
background: rgba(59,130,246,0.18);
|
||||
color: #93c5fd;
|
||||
border-radius: 5px;
|
||||
padding: 2px 7px;
|
||||
}
|
||||
|
||||
/* Edit/Delete buttons */
|
||||
.detail-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.detail-buttons button {
|
||||
padding: 7px 16px;
|
||||
border-radius: 7px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#btnEdit { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }
|
||||
#btnDelete { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
|
||||
|
||||
.hidden { display: none !important; }
|
||||
|
||||
::-webkit-scrollbar { width: 5px; }
|
||||
::-webkit-scrollbar-track { background: transparent; }
|
||||
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }
|
||||
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
|
||||
|
||||
@@ -1,66 +1,97 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>Bungee Status</title>
|
||||
<link rel="stylesheet" href="popup.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="root">
|
||||
<header>
|
||||
<h1>Bungee Status</h1>
|
||||
<div class="actions">
|
||||
<button id="btnRefresh" title="Jetzt aktualisieren">↻</button>
|
||||
<button id="btnToggleSettings">⚙</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main">
|
||||
<aside class="server-list">
|
||||
<div class="add-form" id="settingsForm">
|
||||
<input id="inputName" placeholder="Name (z. B. Lobby)" />
|
||||
<input id="inputUrl" placeholder="URL (127.0.0.1:9191)" />
|
||||
<input id="inputWpSite" placeholder="WP Site" />
|
||||
<input id="inputWpServerId" placeholder="WP Server ID" />
|
||||
<button id="btnAddServer">Hinzufügen</button>
|
||||
</div>
|
||||
|
||||
<ul id="serversContainer"></ul>
|
||||
</aside>
|
||||
|
||||
<div class="detail">
|
||||
<div id="noSelection" class="placeholder">Wähle einen Server aus der linken Liste.</div>
|
||||
<div id="detailContent" class="detailContent hidden">
|
||||
|
||||
<div class="detail-header">
|
||||
<div class="server-identity">
|
||||
<h2 id="detailName"></h2>
|
||||
<span id="detailUrlText" class="server-url"></span>
|
||||
</div>
|
||||
<div class="status-wrapper">
|
||||
<div id="detailPulse" class="pulsing-dot"></div>
|
||||
<span id="detailStatus"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="detail-stats">
|
||||
<div><strong>Spieler:</strong> <span id="detailPlayers"></span></div>
|
||||
<div><strong>Version:</strong> <span id="detailVersion"></span></div>
|
||||
<div><strong>Ping:</strong> <span id="detailPing">-</span></div>
|
||||
</div>
|
||||
|
||||
<h3>Online Spieler</h3>
|
||||
<ul id="detailPlayerList" class="playerList"></ul>
|
||||
|
||||
<div class="detailButtons">
|
||||
<button id="btnEdit">Bearbeiten</button>
|
||||
<button id="btnDelete">Löschen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>Bungee Status</title>
|
||||
<link rel="stylesheet" href="popup.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="root">
|
||||
|
||||
<header>
|
||||
<h1>Bungee Status</h1>
|
||||
<div class="actions">
|
||||
<button id="btnRefresh" title="Jetzt aktualisieren">↻</button>
|
||||
<button id="btnToggleSettings" title="Einstellungen">⚙</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="main">
|
||||
|
||||
<div id="settingsForm" class="settings-panel hidden">
|
||||
<h3 id="settingsTitle">Neuen Server hinzufügen</h3>
|
||||
<input id="inputName" placeholder="Name (z. B. Lobby)" />
|
||||
<input id="inputUrl" placeholder="URL (z. B. 192.168.1.1:9191)" />
|
||||
<input id="inputWpSite" placeholder="WP Site (z. B. https://meine-seite.de)" />
|
||||
<input id="inputWpServerId" placeholder="WP Server ID" />
|
||||
<button id="btnAddServer">Hinzufügen</button>
|
||||
</div>
|
||||
|
||||
<div id="serverListPanel" class="server-list-panel hidden">
|
||||
<ul id="serversContainer"></ul>
|
||||
</div>
|
||||
|
||||
<div class="detail-panel">
|
||||
|
||||
<div id="noSelection" class="placeholder">Noch kein Server ausgewählt.</div>
|
||||
|
||||
<div id="detailContent" class="hidden">
|
||||
|
||||
<!-- Server Name + Status Badge -->
|
||||
<div class="srv-identity">
|
||||
<div>
|
||||
<div class="srv-name" id="detailName"></div>
|
||||
<div class="srv-url" id="detailUrlText"></div>
|
||||
</div>
|
||||
<div class="online-badge offline" id="statusBadge">
|
||||
<div class="pulsing-dot offline" id="detailPulse"></div>
|
||||
<span id="detailStatus">Offline</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MOTD -->
|
||||
<div id="motdBar" class="motd-bar hidden"></div>
|
||||
|
||||
<!-- Stats: Spieler / Version / Ping -->
|
||||
<div class="stats-row">
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">Spieler</div>
|
||||
<div class="stat-val" id="detailPlayers">-</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">Version</div>
|
||||
<div class="stat-val small" id="detailVersion">-</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-label">Ping</div>
|
||||
<div class="stat-val" id="detailPing">-</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sub-Server -->
|
||||
<div id="backendSection" class="hidden">
|
||||
<div class="section-label">Sub-Server</div>
|
||||
<div class="sub-servers" id="backendServersList"></div>
|
||||
</div>
|
||||
|
||||
<!-- Online Spieler -->
|
||||
<div>
|
||||
<div class="section-label">Online Spieler</div>
|
||||
<div class="players-grid" id="detailPlayerList"></div>
|
||||
</div>
|
||||
|
||||
<!-- Edit / Delete -->
|
||||
<div class="detail-buttons hidden" id="detailButtons">
|
||||
<button id="btnEdit">Bearbeiten</button>
|
||||
<button id="btnDelete">Löschen</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+429
-334
@@ -1,335 +1,430 @@
|
||||
//popup.js
|
||||
const $ = id => document.getElementById(id);
|
||||
const uid = () => 'srv_' + Math.random().toString(36).slice(2,9);
|
||||
|
||||
const inputName = $('inputName');
|
||||
const inputUrl = $('inputUrl');
|
||||
const inputWpSite = $('inputWpSite');
|
||||
const inputWpServerId = $('inputWpServerId');
|
||||
const btnAdd = $('btnAddServer');
|
||||
const serversContainer = $('serversContainer');
|
||||
const serverListPanel = document.querySelector('.server-list');
|
||||
const btnRefresh = $('btnRefresh');
|
||||
const btnToggleSettings = $('btnToggleSettings');
|
||||
const settingsForm = $('settingsForm');
|
||||
|
||||
const noSelection = $('noSelection');
|
||||
const detailContent = $('detailContent');
|
||||
const detailName = $('detailName');
|
||||
const detailUrlText = $('detailUrlText');
|
||||
const detailStatus = $('detailStatus');
|
||||
const detailPulse = $('detailPulse');
|
||||
const detailVersion = $('detailVersion');
|
||||
const detailPlayers = $('detailPlayers');
|
||||
const detailPing = $('detailPing');
|
||||
const detailPlayerList = $('detailPlayerList');
|
||||
const btnEdit = $('btnEdit');
|
||||
const btnDelete = $('btnDelete');
|
||||
|
||||
let servers = [];
|
||||
let selectedId = null;
|
||||
let statuses = {};
|
||||
let previousStatuses = {};
|
||||
let settingsVisible = false;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
btnAdd.addEventListener('click', handleAdd);
|
||||
btnRefresh.addEventListener('click', manualRefresh);
|
||||
btnToggleSettings.addEventListener('click', toggleSettings);
|
||||
btnEdit.addEventListener('click', handleEdit);
|
||||
btnDelete.addEventListener('click', handleDelete);
|
||||
|
||||
async function init() {
|
||||
await loadServersFromStorage();
|
||||
await loadStatusesFromStorage();
|
||||
await loadSettingsVisibility();
|
||||
renderServerList();
|
||||
|
||||
if (servers.length === 1) selectedId = servers[0].id;
|
||||
renderDetail(selectedId);
|
||||
|
||||
adjustDetailLayout();
|
||||
}
|
||||
|
||||
// --- NEU: Minecraft Color Parser (Eingebaut ohne Löschung) ---
|
||||
function parseMinecraftColors(text) {
|
||||
if (!text) return '';
|
||||
const map = {
|
||||
'&0': '#000000', '&1': '#0000AA', '&2': '#00AA00', '&3': '#00AAAA',
|
||||
'&4': '#AA0000', '&5': '#AA00AA', '&6': '#FFAA00', '&7': '#AAAAAA',
|
||||
'&8': '#555555', '&9': '#5555FF', '&a': '#55FF55', '&b': '#55FFFF',
|
||||
'&c': '#FF5555', '&d': '#FF55FF', '&e': '#FFFF55', '&f': '#FFFFFF'
|
||||
};
|
||||
let html = text.replace(/[<>]/g, '');
|
||||
Object.keys(map).forEach(code => {
|
||||
const color = map[code];
|
||||
const regex = new RegExp(code, 'g');
|
||||
html = html.replace(regex, `</span><span style="color: ${color}">`);
|
||||
});
|
||||
return `<span>${html}</span>`.replace(/&l/g, '<b>').replace(/&r/g, '</b>');
|
||||
}
|
||||
|
||||
// --- 3D Avatar URL Generator ---
|
||||
function get3DAvatarUrl(playerName, uuid = null) {
|
||||
const isBedrock = playerName.includes('.') || (uuid && uuid.startsWith('xuid'));
|
||||
if (isBedrock) {
|
||||
if (uuid && uuid.length > 0) {
|
||||
return `https://mc-heads.net/head/${encodeURIComponent(uuid)}/64`;
|
||||
}
|
||||
return `https://mc-heads.net/head/${encodeURIComponent(playerName)}/64`;
|
||||
} else {
|
||||
return `https://mc-heads.net/head/${encodeURIComponent(playerName)}/64`;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadSettingsVisibility() {
|
||||
const obj = await chrome.storage.local.get(['settingsVisible']);
|
||||
settingsVisible = obj.settingsVisible !== undefined ? obj.settingsVisible : false;
|
||||
if (!settingsVisible) settingsForm.classList.add('hidden');
|
||||
else settingsForm.classList.remove('hidden');
|
||||
}
|
||||
|
||||
async function saveSettingsVisibility() {
|
||||
await chrome.storage.local.set({ settingsVisible });
|
||||
}
|
||||
|
||||
async function toggleSettings() {
|
||||
settingsVisible = !settingsVisible;
|
||||
settingsForm.classList.toggle('hidden');
|
||||
await saveSettingsVisibility();
|
||||
adjustDetailLayout();
|
||||
}
|
||||
|
||||
async function loadServersFromStorage() {
|
||||
const obj = await chrome.storage.local.get(['servers']);
|
||||
servers = obj.servers || [];
|
||||
for (const s of servers) if (!s.id) s.id = uid();
|
||||
await chrome.storage.local.set({ servers });
|
||||
}
|
||||
|
||||
async function saveServersToStorage() {
|
||||
await chrome.storage.local.set({ servers });
|
||||
}
|
||||
|
||||
async function loadStatusesFromStorage() {
|
||||
const obj = await chrome.storage.local.get(['serverStatuses']);
|
||||
statuses = obj.serverStatuses || {};
|
||||
}
|
||||
|
||||
function adjustDetailLayout() {
|
||||
const settingsHidden = settingsForm.classList.contains('hidden');
|
||||
detailContent.classList.toggle('full-width', settingsHidden);
|
||||
serverListPanel.classList.toggle('hidden', settingsHidden);
|
||||
btnEdit.style.display = settingsHidden ? 'none' : 'inline-block';
|
||||
btnDelete.style.display = settingsHidden ? 'none' : 'inline-block';
|
||||
}
|
||||
|
||||
function renderServerList() {
|
||||
serversContainer.innerHTML = '';
|
||||
if (servers.length === 0) {
|
||||
serversContainer.innerHTML = '<div class="placeholder">Noch keine Server hinzugefügt.</div>';
|
||||
return;
|
||||
}
|
||||
for (const s of servers) {
|
||||
const item = document.createElement('li');
|
||||
item.className = 'server-item';
|
||||
item.dataset.id = s.id;
|
||||
const meta = document.createElement('div');
|
||||
meta.className = 'meta';
|
||||
const name = document.createElement('div');
|
||||
name.className = 'name';
|
||||
name.textContent = s.name || '(Kein Name)';
|
||||
let listUrl = s.url || (s.wpSite ? s.wpSite + ' (WP)' : '');
|
||||
listUrl = listUrl.replace(':9191', '');
|
||||
const url = document.createElement('div');
|
||||
url.className = 'url';
|
||||
url.textContent = listUrl;
|
||||
meta.append(name, url);
|
||||
const statusBubble = document.createElement('div');
|
||||
statusBubble.className = 'status-bubble';
|
||||
statusBubble.textContent = '—';
|
||||
statusBubble.style.backgroundColor = 'transparent';
|
||||
item.statusBubble = statusBubble;
|
||||
item.append(meta, statusBubble);
|
||||
item.addEventListener('click', () => {
|
||||
selectedId = s.id;
|
||||
renderDetail(selectedId);
|
||||
});
|
||||
serversContainer.appendChild(item);
|
||||
}
|
||||
updateServerListStatuses();
|
||||
}
|
||||
|
||||
// --- Fortsetzung popup.js ---
|
||||
|
||||
function renderDetail(id) {
|
||||
if (!id) {
|
||||
noSelection.classList.remove('hidden');
|
||||
detailContent.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
const srv = servers.find(x => x.id === id);
|
||||
if (!srv) {
|
||||
noSelection.classList.remove('hidden');
|
||||
detailContent.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
noSelection.classList.add('hidden');
|
||||
detailContent.classList.remove('hidden');
|
||||
detailName.textContent = srv.name || 'Unbenannter Server';
|
||||
let urlToShow = srv.url || (srv.wpSite ? srv.wpSite : 'Lokal');
|
||||
urlToShow = urlToShow.replace(':9191', '');
|
||||
detailUrlText.textContent = urlToShow;
|
||||
updateDetailForServer(srv, true);
|
||||
}
|
||||
|
||||
function updateDetailForServer(srv, force = false) {
|
||||
const st = statuses[srv.id];
|
||||
const prevSt = previousStatuses[srv.id];
|
||||
const statusChanged = force || !prevSt || (prevSt.ok !== st?.ok) || (prevSt.data?.online !== st?.data?.online);
|
||||
|
||||
if (!st || !st.ok || !st.data) {
|
||||
if (statusChanged) {
|
||||
detailStatus.textContent = 'Offline';
|
||||
detailPulse.classList.remove('online');
|
||||
detailVersion.textContent = '-';
|
||||
detailPlayers.textContent = '-';
|
||||
detailPing.textContent = '-';
|
||||
updatePlayerList([]);
|
||||
}
|
||||
} else {
|
||||
const d = st.data;
|
||||
if (statusChanged) {
|
||||
detailStatus.textContent = d.online ? 'Online' : 'Offline';
|
||||
if (d.online) detailPulse.classList.add('online');
|
||||
else detailPulse.classList.remove('online');
|
||||
}
|
||||
const newVersion = d.version || 'unknown';
|
||||
if (force || detailVersion.textContent !== newVersion) detailVersion.textContent = newVersion;
|
||||
const playersCount = Array.isArray(d.players) ? d.players.length : (typeof d.players === 'number' ? d.players : 0);
|
||||
const maxPlayers = d.max_players;
|
||||
let newPlayersText = String(playersCount);
|
||||
if (maxPlayers && maxPlayers !== '-1') newPlayersText += ` / ${maxPlayers}`;
|
||||
if (force || detailPlayers.textContent !== newPlayersText) detailPlayers.textContent = newPlayersText;
|
||||
let pingVal = d.ping || d.latency || '-';
|
||||
if (pingVal !== '-' && typeof pingVal === 'number') pingVal = pingVal + ' ms';
|
||||
if (force || (pingVal !== '-' && detailPing.textContent !== pingVal)) detailPing.textContent = pingVal;
|
||||
|
||||
const currentPlayers = Array.isArray(d.players) ? d.players : [];
|
||||
const prevPlayers = (prevSt && Array.isArray(prevSt.data?.players)) ? prevSt.data.players : [];
|
||||
let playersChanged = force || JSON.stringify(currentPlayers) !== JSON.stringify(prevPlayers);
|
||||
if (playersChanged) updatePlayerList(currentPlayers);
|
||||
}
|
||||
previousStatuses[srv.id] = st ? JSON.parse(JSON.stringify(st)) : null;
|
||||
}
|
||||
|
||||
// --- Spielerliste mit Prefix-Hover und Farbsupport ---
|
||||
function updatePlayerList(players) {
|
||||
detailPlayerList.innerHTML = '';
|
||||
if (!players || players.length === 0) {
|
||||
detailPlayerList.innerHTML = '<li class="placeholder">Keine Spieler online.</li>';
|
||||
return;
|
||||
}
|
||||
|
||||
for (const p of players) {
|
||||
const li = document.createElement('li');
|
||||
li.className = 'player-item'; // CSS Klasse für den Hover-Container
|
||||
|
||||
let name = '';
|
||||
let uuid = null;
|
||||
let prefix = '';
|
||||
|
||||
if (typeof p === 'object') {
|
||||
name = p.name || p.username || p.player || '';
|
||||
uuid = p.uuid || null;
|
||||
prefix = p.prefix || '';
|
||||
} else {
|
||||
name = String(p);
|
||||
}
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.src = (typeof p === 'object' && p.avatar) ? p.avatar : get3DAvatarUrl(name, uuid);
|
||||
img.className = 'player-avatar';
|
||||
img.loading = 'lazy';
|
||||
img.onerror = function() {
|
||||
this.onerror = null;
|
||||
this.src = `https://mc-heads.net/avatar/${encodeURIComponent(name)}/64`;
|
||||
};
|
||||
|
||||
// Das Hover-Element mit farbigem Prefix + Name
|
||||
const info = document.createElement('div');
|
||||
info.className = 'player-hover-info';
|
||||
info.innerHTML = `${parseMinecraftColors(prefix)} ${name}`.trim();
|
||||
|
||||
li.appendChild(img);
|
||||
li.appendChild(info);
|
||||
detailPlayerList.appendChild(li);
|
||||
}
|
||||
}
|
||||
|
||||
function updateServerListStatuses() {
|
||||
const items = serversContainer.querySelectorAll('.server-item');
|
||||
items.forEach(item => {
|
||||
const s = servers.find(x => x.id === item.dataset.id);
|
||||
if (!s) return;
|
||||
const st = statuses[s.id];
|
||||
if (!st || !st.ok || !st.data) {
|
||||
item.statusBubble.textContent = 'Offline';
|
||||
item.statusBubble.style.backgroundColor = 'var(--offline)';
|
||||
} else if (st.data.online) {
|
||||
item.statusBubble.textContent = 'Online';
|
||||
item.statusBubble.style.backgroundColor = 'var(--online)';
|
||||
} else {
|
||||
item.statusBubble.textContent = 'Offline';
|
||||
item.statusBubble.style.backgroundColor = 'var(--offline)';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function handleAdd() {
|
||||
const name = inputName.value.trim();
|
||||
const url = inputUrl.value.trim();
|
||||
const wpSite = inputWpSite.value.trim();
|
||||
const wpServerId = inputWpServerId.value.trim();
|
||||
if (!url && !wpSite) return;
|
||||
const s = { id: uid(), name: name || url || wpSite, url: url || null, wpSite: wpSite || null, wpServerId: wpServerId || null };
|
||||
servers.push(s);
|
||||
await saveServersToStorage();
|
||||
inputName.value = inputUrl.value = inputWpSite.value = inputWpServerId.value = '';
|
||||
renderServerList();
|
||||
}
|
||||
|
||||
async function handleEdit() {
|
||||
if (!selectedId) return;
|
||||
const srv = servers.find(s => s.id === selectedId);
|
||||
if (!srv) return;
|
||||
const newName = prompt('Name:', srv.name) || srv.name;
|
||||
srv.name = newName.trim();
|
||||
await saveServersToStorage();
|
||||
renderServerList();
|
||||
renderDetail(selectedId);
|
||||
}
|
||||
|
||||
async function handleDelete() {
|
||||
if (!selectedId || !confirm('Server wirklich löschen?')) return;
|
||||
servers = servers.filter(s => s.id !== selectedId);
|
||||
selectedId = null;
|
||||
await saveServersToStorage();
|
||||
renderServerList();
|
||||
renderDetail(null);
|
||||
}
|
||||
|
||||
async function manualRefresh() {
|
||||
try { chrome.runtime.sendMessage({ cmd: 'refreshNow' }); } catch(e) {}
|
||||
}
|
||||
|
||||
chrome.storage.onChanged.addListener((changes, area) => {
|
||||
if (area === 'local' && changes.serverStatuses) {
|
||||
statuses = changes.serverStatuses.newValue || {};
|
||||
updateServerListStatuses();
|
||||
if (selectedId) {
|
||||
const srv = servers.find(s => s.id === selectedId);
|
||||
if (srv) updateDetailForServer(srv);
|
||||
}
|
||||
}
|
||||
// popup.js
|
||||
const $ = id => document.getElementById(id);
|
||||
const uid = () => 'srv_' + Math.random().toString(36).slice(2,9);
|
||||
|
||||
let servers = [];
|
||||
let selectedId = null;
|
||||
let statuses = {};
|
||||
let previousStatuses = {};
|
||||
let settingsVisible = false;
|
||||
let editingId = null; // Welcher Server gerade bearbeitet wird
|
||||
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
$('btnAdd')?.addEventListener('click', handleAdd);
|
||||
$('btnAddServer')?.addEventListener('click', handleAdd);
|
||||
$('btnRefresh').addEventListener('click', manualRefresh);
|
||||
$('btnToggleSettings').addEventListener('click', toggleSettings);
|
||||
$('btnEdit').addEventListener('click', handleEdit);
|
||||
$('btnDelete').addEventListener('click', handleDelete);
|
||||
|
||||
async function init() {
|
||||
await loadServersFromStorage();
|
||||
await loadStatusesFromStorage();
|
||||
await loadSettingsVisibility();
|
||||
renderServerList();
|
||||
if (servers.length === 1) selectedId = servers[0].id;
|
||||
renderDetail(selectedId);
|
||||
}
|
||||
|
||||
// ── Minecraft color code parser ──
|
||||
function parseMinecraftColors(text) {
|
||||
if (!text) return '';
|
||||
const map = {
|
||||
'§0':'#000000','§1':'#0000AA','§2':'#00AA00','§3':'#00AAAA',
|
||||
'§4':'#AA0000','§5':'#AA00AA','§6':'#FFAA00','§7':'#AAAAAA',
|
||||
'§8':'#555555','§9':'#5555FF','§a':'#55FF55','§b':'#55FFFF',
|
||||
'§c':'#FF5555','§d':'#FF55FF','§e':'#FFFF55','§f':'#FFFFFF',
|
||||
'&0':'#000000','&1':'#0000AA','&2':'#00AA00','&3':'#00AAAA',
|
||||
'&4':'#AA0000','&5':'#AA00AA','&6':'#FFAA00','&7':'#AAAAAA',
|
||||
'&8':'#555555','&9':'#5555FF','&a':'#55FF55','&b':'#55FFFF',
|
||||
'&c':'#FF5555','&d':'#FF55FF','&e':'#FFFF55','&f':'#FFFFFF'
|
||||
};
|
||||
let html = text.replace(/[<>]/g, '');
|
||||
let result = '';
|
||||
let i = 0;
|
||||
while (i < html.length) {
|
||||
const ch = html[i];
|
||||
if ((ch === '§' || ch === '&') && i + 1 < html.length) {
|
||||
const code = ch + html[i+1].toLowerCase();
|
||||
if (map[code]) {
|
||||
result += `<span style="color:${map[code]}">`;
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result += html[i];
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function get3DAvatarUrl(name, uuid = null) {
|
||||
return `https://mc-heads.net/head/${encodeURIComponent(name)}/64`;
|
||||
}
|
||||
|
||||
// ── Storage ──
|
||||
async function loadSettingsVisibility() {
|
||||
const obj = await chrome.storage.local.get(['settingsVisible']);
|
||||
settingsVisible = !!obj.settingsVisible;
|
||||
applySettingsVisibility();
|
||||
}
|
||||
async function saveSettingsVisibility() {
|
||||
await chrome.storage.local.set({ settingsVisible });
|
||||
}
|
||||
function applySettingsVisibility() {
|
||||
$('settingsForm').classList.toggle('hidden', !settingsVisible);
|
||||
$('serverListPanel').classList.toggle('hidden', !settingsVisible);
|
||||
$('detailButtons').classList.toggle('hidden', !settingsVisible);
|
||||
}
|
||||
async function toggleSettings() {
|
||||
settingsVisible = !settingsVisible;
|
||||
applySettingsVisibility();
|
||||
await saveSettingsVisibility();
|
||||
}
|
||||
|
||||
async function loadServersFromStorage() {
|
||||
const obj = await chrome.storage.local.get(['servers']);
|
||||
servers = obj.servers || [];
|
||||
for (const s of servers) if (!s.id) s.id = uid();
|
||||
await chrome.storage.local.set({ servers });
|
||||
}
|
||||
async function saveServersToStorage() {
|
||||
await chrome.storage.local.set({ servers });
|
||||
}
|
||||
async function loadStatusesFromStorage() {
|
||||
const obj = await chrome.storage.local.get(['serverStatuses']);
|
||||
statuses = obj.serverStatuses || {};
|
||||
}
|
||||
|
||||
// ── Server list ──
|
||||
function renderServerList() {
|
||||
const container = $('serversContainer');
|
||||
container.innerHTML = '';
|
||||
if (servers.length === 0) {
|
||||
container.innerHTML = '<div class="placeholder" style="padding:8px 0;">Noch kein Server hinzugefügt.</div>';
|
||||
return;
|
||||
}
|
||||
for (const s of servers) {
|
||||
const li = document.createElement('li');
|
||||
li.className = 'server-item' + (s.id === selectedId ? ' selected' : '');
|
||||
li.dataset.id = s.id;
|
||||
|
||||
const meta = document.createElement('div');
|
||||
meta.className = 'meta';
|
||||
|
||||
const nameEl = document.createElement('div');
|
||||
nameEl.className = 'name';
|
||||
nameEl.textContent = s.name || '(Kein Name)';
|
||||
|
||||
let urlText = s.url || (s.wpSite || '');
|
||||
urlText = urlText.replace(':9191', '');
|
||||
const urlEl = document.createElement('div');
|
||||
urlEl.className = 'url';
|
||||
urlEl.textContent = urlText;
|
||||
|
||||
meta.append(nameEl, urlEl);
|
||||
|
||||
const bubble = document.createElement('div');
|
||||
bubble.className = 'status-bubble';
|
||||
bubble.textContent = '—';
|
||||
li._bubble = bubble;
|
||||
|
||||
li.append(meta, bubble);
|
||||
li.addEventListener('click', () => {
|
||||
selectedId = s.id;
|
||||
document.querySelectorAll('.server-item').forEach(el => el.classList.remove('selected'));
|
||||
li.classList.add('selected');
|
||||
renderDetail(selectedId);
|
||||
});
|
||||
container.appendChild(li);
|
||||
}
|
||||
updateServerListStatuses();
|
||||
}
|
||||
|
||||
// ── Detail ──
|
||||
function renderDetail(id) {
|
||||
if (!id) {
|
||||
$('noSelection').classList.remove('hidden');
|
||||
$('detailContent').classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
const srv = servers.find(x => x.id === id);
|
||||
if (!srv) {
|
||||
$('noSelection').classList.remove('hidden');
|
||||
$('detailContent').classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
$('noSelection').classList.add('hidden');
|
||||
$('detailContent').classList.remove('hidden');
|
||||
|
||||
$('detailName').textContent = srv.name || 'Unbenannter Server';
|
||||
let urlToShow = srv.url || (srv.wpSite || 'Lokal');
|
||||
urlToShow = urlToShow.replace(':9191', '');
|
||||
$('detailUrlText').textContent = urlToShow;
|
||||
|
||||
updateDetailForServer(srv, true);
|
||||
}
|
||||
|
||||
function updateDetailForServer(srv, force = false) {
|
||||
const st = statuses[srv.id];
|
||||
const prevSt = previousStatuses[srv.id];
|
||||
const changed = force || JSON.stringify(st) !== JSON.stringify(prevSt);
|
||||
if (!changed) return;
|
||||
|
||||
const badge = $('statusBadge');
|
||||
const pulse = $('detailPulse');
|
||||
|
||||
if (!st || !st.ok || !st.data) {
|
||||
badge.className = 'online-badge offline';
|
||||
pulse.className = 'pulsing-dot offline';
|
||||
$('detailStatus').textContent = 'Offline';
|
||||
$('detailVersion').textContent = '-';
|
||||
$('detailPlayers').textContent = '-';
|
||||
$('detailPing').textContent = '-';
|
||||
$('motdBar').classList.add('hidden');
|
||||
updatePlayerList([]);
|
||||
updateBackendServers(null);
|
||||
} else {
|
||||
const d = st.data;
|
||||
const isOnline = !!d.online;
|
||||
|
||||
badge.className = 'online-badge ' + (isOnline ? 'online' : 'offline');
|
||||
pulse.className = 'pulsing-dot ' + (isOnline ? 'online' : 'offline');
|
||||
$('detailStatus').textContent = isOnline ? 'Online' : 'Offline';
|
||||
$('detailVersion').textContent = d.version || 'unknown';
|
||||
|
||||
const count = Array.isArray(d.players) ? d.players.length
|
||||
: (typeof d.players === 'number' ? d.players : 0);
|
||||
const max = d.max_players;
|
||||
$('detailPlayers').textContent = max && max !== '-1' ? `${count} / ${max}` : String(count);
|
||||
|
||||
const ping = d.ping || d.latency;
|
||||
$('detailPing').textContent = typeof ping === 'number' ? ping + ' ms' : '-';
|
||||
|
||||
const motdRaw = d.motd || (d.network && d.network.motd) || '';
|
||||
if (motdRaw) {
|
||||
const motdEl = $('motdBar');
|
||||
motdEl.innerHTML = parseMinecraftColors(motdRaw);
|
||||
motdEl.classList.remove('hidden');
|
||||
} else {
|
||||
$('motdBar').classList.add('hidden');
|
||||
}
|
||||
|
||||
const currentPlayers = Array.isArray(d.players) ? d.players : [];
|
||||
updatePlayerList(currentPlayers);
|
||||
updateBackendServers(d.network?.backend_servers || null);
|
||||
}
|
||||
|
||||
previousStatuses[srv.id] = st ? JSON.parse(JSON.stringify(st)) : null;
|
||||
}
|
||||
|
||||
// ── Sub-Server chips ──
|
||||
function updateBackendServers(list) {
|
||||
const section = $('backendSection');
|
||||
const container = $('backendServersList');
|
||||
if (!list || list.length === 0) {
|
||||
section.classList.add('hidden');
|
||||
container.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
section.classList.remove('hidden');
|
||||
container.innerHTML = '';
|
||||
for (const bs of list) {
|
||||
const count = bs.online_players || 0;
|
||||
const chip = document.createElement('div');
|
||||
chip.className = 'sub-chip' + (count > 0 ? ' active' : '');
|
||||
|
||||
const dot = document.createElement('span');
|
||||
dot.className = 'sub-chip-dot';
|
||||
|
||||
const nameEl = document.createElement('span');
|
||||
nameEl.className = 'sub-chip-name';
|
||||
nameEl.textContent = bs.name;
|
||||
|
||||
const countEl = document.createElement('span');
|
||||
countEl.className = 'sub-chip-count';
|
||||
countEl.textContent = count > 0 ? count : 'leer';
|
||||
|
||||
chip.append(dot, nameEl, countEl);
|
||||
container.appendChild(chip);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Player list ──
|
||||
function updatePlayerList(players) {
|
||||
const grid = $('detailPlayerList');
|
||||
grid.innerHTML = '';
|
||||
|
||||
if (!players || players.length === 0) {
|
||||
grid.innerHTML = '<div class="placeholder">Keine Spieler online.</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
for (const p of players) {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'player-card';
|
||||
|
||||
let name = '', uuid = null, prefix = '', serverName = null;
|
||||
|
||||
if (typeof p === 'object') {
|
||||
name = p.name || p.username || p.player || '';
|
||||
uuid = p.uuid || null;
|
||||
prefix = p.prefix || p.group || '';
|
||||
serverName = p.server || p.current_server || p.connected_server || null;
|
||||
} else {
|
||||
name = String(p);
|
||||
}
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.src = (typeof p === 'object' && p.avatar) ? p.avatar : get3DAvatarUrl(name, uuid);
|
||||
img.className = 'player-avatar';
|
||||
img.loading = 'lazy';
|
||||
img.onerror = function() {
|
||||
this.onerror = null;
|
||||
this.src = `https://mc-heads.net/avatar/${encodeURIComponent(name)}/64`;
|
||||
};
|
||||
|
||||
const info = document.createElement('div');
|
||||
info.className = 'player-info';
|
||||
|
||||
if (prefix) {
|
||||
const prefixEl = document.createElement('div');
|
||||
prefixEl.className = 'player-prefix';
|
||||
prefixEl.innerHTML = parseMinecraftColors(prefix);
|
||||
info.appendChild(prefixEl);
|
||||
}
|
||||
|
||||
const nameEl = document.createElement('div');
|
||||
nameEl.className = 'player-name';
|
||||
nameEl.textContent = name;
|
||||
info.appendChild(nameEl);
|
||||
|
||||
if (serverName) {
|
||||
const tag = document.createElement('span');
|
||||
tag.className = 'player-server-tag';
|
||||
tag.textContent = serverName;
|
||||
info.appendChild(tag);
|
||||
}
|
||||
|
||||
card.append(img, info);
|
||||
grid.appendChild(card);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Server list status bubbles ──
|
||||
function updateServerListStatuses() {
|
||||
const items = $('serversContainer').querySelectorAll('.server-item');
|
||||
items.forEach(item => {
|
||||
const s = servers.find(x => x.id === item.dataset.id);
|
||||
if (!s || !item._bubble) return;
|
||||
const st = statuses[s.id];
|
||||
if (!st || !st.ok || !st.data || !st.data.online) {
|
||||
item._bubble.textContent = 'Offline';
|
||||
item._bubble.style.background = 'rgba(239,68,68,0.15)';
|
||||
item._bubble.style.color = '#f87171';
|
||||
} else {
|
||||
item._bubble.textContent = 'Online';
|
||||
item._bubble.style.background = 'rgba(34,197,94,0.15)';
|
||||
item._bubble.style.color = '#4ade80';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ── Edit / Add Mode ──
|
||||
function enterEditMode(server) {
|
||||
editingId = server.id;
|
||||
$('settingsTitle').textContent = 'Server bearbeiten';
|
||||
$('btnAddServer').textContent = 'Änderungen speichern';
|
||||
|
||||
$('inputName').value = server.name || '';
|
||||
$('inputUrl').value = server.url || '';
|
||||
$('inputWpSite').value = server.wpSite || '';
|
||||
$('inputWpServerId').value = server.wpServerId || '';
|
||||
}
|
||||
|
||||
function exitEditMode() {
|
||||
editingId = null;
|
||||
$('settingsTitle').textContent = 'Neuen Server hinzufügen';
|
||||
$('btnAddServer').textContent = 'Hinzufügen';
|
||||
$('inputName').value = '';
|
||||
$('inputUrl').value = '';
|
||||
$('inputWpSite').value = '';
|
||||
$('inputWpServerId').value = '';
|
||||
}
|
||||
|
||||
// ── Actions ──
|
||||
async function handleAdd() {
|
||||
const name = $('inputName').value.trim();
|
||||
const url = $('inputUrl').value.trim();
|
||||
const wpSite = $('inputWpSite').value.trim();
|
||||
const wpServerId = $('inputWpServerId').value.trim();
|
||||
|
||||
if (!url && !wpSite) {
|
||||
alert('Bitte eine URL oder WordPress-Einstellungen angeben.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (editingId) {
|
||||
// === BEARBEITEN ===
|
||||
const srv = servers.find(s => s.id === editingId);
|
||||
if (srv) {
|
||||
srv.name = name || url || wpSite;
|
||||
if (url) srv.url = url;
|
||||
if (wpSite) srv.wpSite = wpSite;
|
||||
if (wpServerId) srv.wpServerId = wpServerId;
|
||||
}
|
||||
exitEditMode();
|
||||
} else {
|
||||
// === NEU HINZUFÜGEN ===
|
||||
const s = {
|
||||
id: uid(),
|
||||
name: name || url || wpSite,
|
||||
url: url || null,
|
||||
wpSite: wpSite || null,
|
||||
wpServerId: wpServerId || null
|
||||
};
|
||||
servers.push(s);
|
||||
}
|
||||
|
||||
await saveServersToStorage();
|
||||
renderServerList();
|
||||
if (selectedId) renderDetail(selectedId);
|
||||
}
|
||||
|
||||
async function handleEdit() {
|
||||
if (!selectedId) return;
|
||||
const srv = servers.find(s => s.id === selectedId);
|
||||
if (!srv) return;
|
||||
|
||||
settingsVisible = true;
|
||||
applySettingsVisibility();
|
||||
await saveSettingsVisibility();
|
||||
|
||||
enterEditMode(srv);
|
||||
}
|
||||
|
||||
async function handleDelete() {
|
||||
if (!selectedId || !confirm('Server wirklich löschen?')) return;
|
||||
servers = servers.filter(s => s.id !== selectedId);
|
||||
selectedId = null;
|
||||
await saveServersToStorage();
|
||||
renderServerList();
|
||||
renderDetail(null);
|
||||
exitEditMode();
|
||||
}
|
||||
|
||||
async function manualRefresh() {
|
||||
try { chrome.runtime.sendMessage({ cmd: 'refreshNow' }); } catch(e) {}
|
||||
}
|
||||
|
||||
// ── Live updates from background ──
|
||||
chrome.storage.onChanged.addListener((changes, area) => {
|
||||
if (area === 'local' && changes.serverStatuses) {
|
||||
statuses = changes.serverStatuses.newValue || {};
|
||||
updateServerListStatuses();
|
||||
if (selectedId) {
|
||||
const srv = servers.find(s => s.id === selectedId);
|
||||
if (srv) updateDetailForServer(srv);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,12 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* Plugin Name: Minecraft BungeeCord Status – Network Edition
|
||||
* Description: Der ultimative Live-Status für dein BungeeCord Netzwerk (Border None Fix).
|
||||
* Tags: minecraft, bungeecord, server status, player list
|
||||
* Version: 3.6.4
|
||||
* Author: M_Viper
|
||||
* Requires at least: 6.0
|
||||
* Requires PHP: 7.4
|
||||
Plugin Name: Minecraft BungeeCord Status – Network Edition
|
||||
Plugin URI:https://git.viper.ipv64.net/M_Viper/Minecraft-BungeeCord-Status
|
||||
Description: Der ultimative Live-Status für dein BungeeCord Netzwerk.
|
||||
Version: 3.6.6
|
||||
Author: M_Viper
|
||||
Author URI: https://m-viper.de
|
||||
Requires at least: 6.0
|
||||
Requires PHP: 7.4
|
||||
Tested up to: 6.8
|
||||
PHP Version: 7.4
|
||||
License: GPL2
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
Text Domain: minecraft-bungeecord-status
|
||||
Tags: minecraft, bungeecord, server status, player list
|
||||
Support: [Discord Support](https://discord.com/invite/FdRs4BRd8D)
|
||||
Support: [Telegram Support](https://t.me/M_Viper04)
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
@@ -76,144 +85,116 @@ function mcss_get_3d_avatar($name, $uuid = null) {
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------- AUTO UPDATE (MCSS) ---------------- */
|
||||
if ( ! class_exists( 'MCSS_Auto_Update' ) ) {
|
||||
class MCSS_Auto_Update {
|
||||
|
||||
private $plugin_file;
|
||||
private $repo_owner = 'M_Viper';
|
||||
private $repo_name = 'Minecraft-BungeeCord-Status';
|
||||
private $api_url;
|
||||
private $transient_key;
|
||||
// ===============================
|
||||
// MCSS - UPDATE NOTICE SYSTEM
|
||||
// ===============================
|
||||
|
||||
public function __construct( $plugin_file ) {
|
||||
$this->plugin_file = $plugin_file;
|
||||
$this->api_url = 'https://git.viper.ipv64.net/api/v1/repos/' . rawurlencode( $this->repo_owner ) . '/' . rawurlencode( $this->repo_name ) . '/releases';
|
||||
$this->transient_key = 'mcss_update_check_' . md5( $this->repo_owner . '/' . $this->repo_name );
|
||||
// Plugin-Version aus Header lesen
|
||||
function mcss_get_plugin_version() {
|
||||
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_init', array( $this, 'check_for_update' ) );
|
||||
$plugin_data = get_plugin_data( __FILE__ );
|
||||
return $plugin_data['Version'] ?? '0.0.0';
|
||||
}
|
||||
|
||||
// Cache manuell leeren
|
||||
function mcss_clear_update_cache() {
|
||||
if ( isset($_GET['mcss_clear_cache']) && current_user_can('manage_options') ) {
|
||||
check_admin_referer('mcss_clear_cache_action');
|
||||
delete_transient('mcss_latest_release');
|
||||
wp_redirect( admin_url('plugins.php') );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
add_action('admin_init', 'mcss_clear_update_cache');
|
||||
|
||||
// Neueste Release-Infos von Gitea holen
|
||||
function mcss_get_latest_release_info( $force_refresh = false ) {
|
||||
$transient_key = 'mcss_latest_release';
|
||||
|
||||
if ( $force_refresh ) {
|
||||
delete_transient( $transient_key );
|
||||
}
|
||||
|
||||
$release_info = get_transient( $transient_key );
|
||||
|
||||
if ( false === $release_info ) {
|
||||
$response = wp_remote_get(
|
||||
'https://git.viper.ipv64.net/api/v1/repos/M_Viper/Minecraft-BungeeCord-Status/releases/latest',
|
||||
['timeout' => 10]
|
||||
);
|
||||
|
||||
if ( ! is_wp_error($response) && 200 === wp_remote_retrieve_response_code($response) ) {
|
||||
$body = wp_remote_retrieve_body($response);
|
||||
$data = json_decode($body, true);
|
||||
|
||||
if ( $data && isset($data['tag_name']) ) {
|
||||
$tag = ltrim( $data['tag_name'], 'vV' );
|
||||
|
||||
$release_info = [
|
||||
'version' => $tag,
|
||||
'download_url' => $data['zipball_url'] ?? '',
|
||||
'notes' => $data['body'] ?? '',
|
||||
'published_at' => $data['published_at'] ?? '',
|
||||
];
|
||||
|
||||
set_transient( $transient_key, $release_info, 6 * HOUR_IN_SECONDS );
|
||||
} else {
|
||||
set_transient( $transient_key, [], HOUR_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
|
||||
public function check_for_update() {
|
||||
if ( ! function_exists( 'get_file_data' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
$current = get_file_data( $this->plugin_file, array( 'Version' => 'Version' ), 'plugin' );
|
||||
$current_version = isset( $current['Version'] ) ? $current['Version'] : '0.0.0';
|
||||
|
||||
$latest = $this->get_latest_release_info();
|
||||
|
||||
if ( $latest && ! empty( $latest['version'] ) && ! empty( $latest['url'] ) ) {
|
||||
if ( version_compare( $latest['version'], $current_version, '>' ) ) {
|
||||
add_action( 'admin_notices', function() use ( $latest, $current_version ) {
|
||||
?>
|
||||
<div class="notice notice-warning is-dismissible">
|
||||
<p>
|
||||
<strong>Minecraft BungeeCord Status – Update verfügbar</strong><br>
|
||||
Neue Version: <strong><?php echo esc_html( $latest['version'] ); ?></strong><br>
|
||||
Installiert: <strong><?php echo esc_html( $current_version ); ?></strong><br>
|
||||
<a href="<?php echo esc_url( $latest['url'] ); ?>" class="button button-primary" target="_blank" rel="noreferrer noopener">Direkter Download (ZIP)</a>
|
||||
<a href="<?php echo esc_url( 'https://git.viper.ipv64.net/' . rawurlencode( $this->repo_owner ) . '/' . rawurlencode( $this->repo_name ) . '/releases' ); ?>" class="button" target="_blank" style="margin-left:8px;" rel="noreferrer noopener">Releases ansehen</a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function get_latest_release_info() {
|
||||
$cached = get_transient( $this->transient_key );
|
||||
if ( false !== $cached && is_array( $cached ) && ! empty( $cached['version'] ) ) {
|
||||
return $cached;
|
||||
}
|
||||
|
||||
$result = false;
|
||||
|
||||
$response = wp_remote_get( $this->api_url, array(
|
||||
'timeout' => 8,
|
||||
'headers' => array(
|
||||
'Accept' => 'application/json',
|
||||
'User-Agent' => 'MCSS-Update-Checker/1.0',
|
||||
),
|
||||
) );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
set_transient( $this->transient_key, array( 'version' => '', 'url' => '' ), HOUR_IN_SECONDS );
|
||||
return false;
|
||||
}
|
||||
|
||||
$code = wp_remote_retrieve_response_code( $response );
|
||||
if ( 200 !== (int) $code ) {
|
||||
set_transient( $this->transient_key, array( 'version' => '', 'url' => '' ), HOUR_IN_SECONDS );
|
||||
return false;
|
||||
}
|
||||
|
||||
$body = wp_remote_retrieve_body( $response );
|
||||
$json = json_decode( $body, true );
|
||||
|
||||
if ( ! is_array( $json ) || empty( $json ) ) {
|
||||
set_transient( $this->transient_key, array( 'version' => '', 'url' => '' ), HOUR_IN_SECONDS );
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $json as $release ) {
|
||||
$tag = '';
|
||||
if ( ! empty( $release['tag_name'] ) ) {
|
||||
$tag = ltrim( (string) $release['tag_name'], 'vV' );
|
||||
} elseif ( ! empty( $release['name'] ) ) {
|
||||
$tag = ltrim( (string) $release['name'], 'vV' );
|
||||
}
|
||||
|
||||
if ( ! empty( $release['assets'] ) && is_array( $release['assets'] ) ) {
|
||||
foreach ( $release['assets'] as $asset ) {
|
||||
if ( empty( $asset['name'] ) || empty( $asset['browser_download_url'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( strtolower( $asset['name'] ) === 'minecraft-bungeecord-status.zip' ) {
|
||||
$version = $tag ?: $this->extract_version_from_string( $asset['name'] . ' ' . ( $release['name'] ?? '' ) );
|
||||
if ( $version ) {
|
||||
$result = array(
|
||||
'version' => $version,
|
||||
'url' => $asset['browser_download_url'],
|
||||
);
|
||||
break 2;
|
||||
} else {
|
||||
$result = array(
|
||||
'version' => ( $tag ?: (string) ( $release['name'] ?? '' ) ),
|
||||
'url' => $asset['browser_download_url'],
|
||||
);
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $result ) {
|
||||
set_transient( $this->transient_key, $result, 12 * HOUR_IN_SECONDS );
|
||||
return $result;
|
||||
}
|
||||
|
||||
set_transient( $this->transient_key, array( 'version' => '', 'url' => '' ), 6 * HOUR_IN_SECONDS );
|
||||
return false;
|
||||
}
|
||||
|
||||
private function extract_version_from_string( $str ) {
|
||||
if ( preg_match( '/([0-9]+\.[0-9]+(?:\.[0-9]+)?)/', $str, $m ) ) {
|
||||
return $m[1];
|
||||
}
|
||||
return '';
|
||||
} else {
|
||||
set_transient( $transient_key, [], HOUR_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
|
||||
new MCSS_Auto_Update( __FILE__ );
|
||||
return $release_info;
|
||||
}
|
||||
|
||||
// Admin-Update-Hinweis anzeigen
|
||||
function mcss_show_update_notice() {
|
||||
if ( ! current_user_can('manage_options') ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current_version = mcss_get_plugin_version();
|
||||
$latest_release = mcss_get_latest_release_info();
|
||||
|
||||
if ( ! empty($latest_release['version']) && version_compare($current_version, $latest_release['version'], '<') ) {
|
||||
|
||||
$refresh_url = wp_nonce_url(
|
||||
admin_url('plugins.php?mcss_clear_cache=1'),
|
||||
'mcss_clear_cache_action'
|
||||
);
|
||||
?>
|
||||
<div class="notice notice-warning is-dismissible">
|
||||
<h3>Minecraft BungeeCord Status – Update verfügbar</h3>
|
||||
<p>
|
||||
Installiert: <strong><?php echo esc_html($current_version); ?></strong><br>
|
||||
Neueste Version: <strong><?php echo esc_html($latest_release['version']); ?></strong>
|
||||
</p>
|
||||
<p>
|
||||
<a href="<?php echo esc_url($latest_release['download_url']); ?>" class="button button-primary" target="_blank">
|
||||
Update herunterladen
|
||||
</a>
|
||||
<a href="https://git.viper.ipv64.net/M_Viper/Minecraft-BungeeCord-Status/releases" class="button" target="_blank">
|
||||
Release Notes
|
||||
</a>
|
||||
<a href="<?php echo esc_url($refresh_url); ?>" class="button">
|
||||
Jetzt neu prüfen
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_action('admin_notices', 'mcss_show_update_notice');
|
||||
|
||||
|
||||
|
||||
|
||||
/* ---------------- Assets ---------------- */
|
||||
add_action('admin_enqueue_scripts', function($hook){
|
||||
global $pagenow;
|
||||
@@ -516,25 +497,89 @@ function mcss_render_row($srv, $i, $font_sizes, $announcement_types) {
|
||||
}
|
||||
|
||||
/* ---------------- LOGIC: STATUS API FETCHER ---------------- */
|
||||
function mcss_fetch_data_via_api($host, $port, $timeout = 2) {
|
||||
function mcss_socket_http_json($host, $port, $path = '/', $timeout = 2.0) {
|
||||
$socket = @fsockopen($host, $port, $errno, $errstr, $timeout);
|
||||
if (!$socket) return false;
|
||||
if (!$socket) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$out = "GET / HTTP/1.1\r\n";
|
||||
stream_set_timeout($socket, (int)ceil($timeout));
|
||||
|
||||
$out = "GET " . $path . " HTTP/1.1\r\n";
|
||||
$out .= "Host: " . $host . "\r\n";
|
||||
$out .= "Connection: Close\r\n\r\n";
|
||||
fwrite($socket, $out);
|
||||
$out .= "User-Agent: MCSS-WordPress/3.6.6\r\n";
|
||||
$out .= "Accept: application/json\r\n";
|
||||
$out .= "Connection: close\r\n\r\n";
|
||||
|
||||
if (@fwrite($socket, $out) === false) {
|
||||
@fclose($socket);
|
||||
return false;
|
||||
}
|
||||
|
||||
$response = '';
|
||||
while (!feof($socket)) {
|
||||
$response .= fgets($socket, 128);
|
||||
$chunk = @fread($socket, 2048);
|
||||
if ($chunk === false) {
|
||||
break;
|
||||
}
|
||||
if ($chunk === '') {
|
||||
$meta = stream_get_meta_data($socket);
|
||||
if (!empty($meta['timed_out'])) {
|
||||
break;
|
||||
}
|
||||
usleep(10000);
|
||||
continue;
|
||||
}
|
||||
$response .= $chunk;
|
||||
}
|
||||
fclose($socket);
|
||||
|
||||
$parts = explode("\r\n\r\n", $response);
|
||||
$body = end($parts);
|
||||
$data = json_decode($body, true);
|
||||
return $data;
|
||||
$meta = stream_get_meta_data($socket);
|
||||
@fclose($socket);
|
||||
|
||||
if (!empty($meta['timed_out'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$parts = explode("\r\n\r\n", $response, 2);
|
||||
if (count($parts) !== 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$statusLine = strtok($parts[0], "\r\n");
|
||||
if (!is_string($statusLine) || stripos($statusLine, '200') === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = json_decode($parts[1], true);
|
||||
return is_array($data) ? $data : false;
|
||||
}
|
||||
|
||||
function mcss_fetch_data_via_api($host, $port, $timeout = 2) {
|
||||
// Primärer Endpunkt mit Detaildaten
|
||||
$full = mcss_socket_http_json($host, $port, '/', $timeout);
|
||||
if (is_array($full) && isset($full['online'])) {
|
||||
return $full;
|
||||
}
|
||||
|
||||
// Fallback auf Health-Endpunkt (StatusAPI >= hardened build)
|
||||
$health = mcss_socket_http_json($host, $port, '/health', $timeout);
|
||||
if (is_array($health) && !empty($health['online'])) {
|
||||
return [
|
||||
'online' => true,
|
||||
'players' => [],
|
||||
'version' => 'BungeeCord',
|
||||
'ping' => 1,
|
||||
'motd' => 'StatusAPI erreichbar (Health)',
|
||||
];
|
||||
}
|
||||
|
||||
// Ein zweiter kurzer Versuch reduziert False Negatives bei Paketverlust.
|
||||
$retry = mcss_socket_http_json($host, $port, '/', max(1.0, $timeout));
|
||||
if (is_array($retry) && isset($retry['online'])) {
|
||||
return $retry;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function mcss_parse_bungeecord_version($raw_version) {
|
||||
@@ -545,16 +590,26 @@ function mcss_parse_bungeecord_version($raw_version) {
|
||||
}
|
||||
|
||||
function mcss_fetch_server_with_ranks($srv) {
|
||||
$cache_key = 'mcss_data_' . md5($srv['host']);
|
||||
$host = $srv['host'];
|
||||
$port = $srv['player_port'] ?? 9191;
|
||||
|
||||
$cache_key = 'mcss_data_' . md5($host . ':' . $port);
|
||||
$last_good_key = 'mcss_last_good_' . md5($host . ':' . $port);
|
||||
|
||||
$cached = get_transient($cache_key);
|
||||
if ($cached !== false) return $cached;
|
||||
|
||||
$host = $srv['host'];
|
||||
$port = $srv['player_port'] ?? 9191;
|
||||
|
||||
$api_data = mcss_fetch_data_via_api($host, $port, 1);
|
||||
$api_data = mcss_fetch_data_via_api($host, $port, 2);
|
||||
|
||||
if (!$api_data || !isset($api_data['online'])) {
|
||||
$last_good = get_transient($last_good_key);
|
||||
if (is_array($last_good) && !empty($last_good['online'])) {
|
||||
$last_good['stale'] = true;
|
||||
$last_good['stale_reason'] = 'temporary_connection_loss';
|
||||
set_transient($cache_key, $last_good, 5);
|
||||
return $last_good;
|
||||
}
|
||||
|
||||
return ['online'=>false,'players'=>[],'version'=>'Offline','ping'=>9999,'motd'=>'Verbindung fehlgeschlagen'];
|
||||
}
|
||||
|
||||
@@ -602,7 +657,7 @@ function mcss_fetch_server_with_ranks($srv) {
|
||||
$clean_version = mcss_parse_bungeecord_version($api_data['version'] ?? 'BungeeCord');
|
||||
|
||||
$result = [
|
||||
'online' => true,
|
||||
'online' => !empty($api_data['online']),
|
||||
'players' => $players_info,
|
||||
'version' => $clean_version,
|
||||
'ping' => 1,
|
||||
@@ -611,6 +666,9 @@ function mcss_fetch_server_with_ranks($srv) {
|
||||
|
||||
$fast_cache_ttl = max(2, absint($srv['cache_ttl'] ?? 10));
|
||||
set_transient($cache_key, $result, $fast_cache_ttl);
|
||||
if (!empty($result['online'])) {
|
||||
set_transient($last_good_key, $result, 180);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,4 +135,10 @@ Bei Problemen überprüfe bitte:
|
||||
## Weitere Informationen
|
||||
|
||||
Für detaillierte Informationen zur Installation, Konfiguration und Fehlerbehebung der StatusAPI:
|
||||
**[https://git.viper.ipv64.net/M_Viper/StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)**
|
||||
**[https://git.viper.ipv64.net/M_Viper/StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)**
|
||||
|
||||
---
|
||||
|
||||
**Copyright © 2026 - M_Viper - Alle Rechte vorbehalten**
|
||||
|
||||
Die unbefugte Vervielfältigung, Verbreitung oder Weitergabe dieses Plugins ist strafbar und wird rechtlich verfolgt.
|
||||
Reference in New Issue
Block a user