Upload via Git Manager GUI

This commit is contained in:
Git Manager GUI
2026-04-29 16:41:51 +02:00
parent f5b14ffd6f
commit d11fef0032

View File

@@ -1135,6 +1135,12 @@ class WIS_Admin {
$resolved_item_id = 'rank_' . $rank_id . '_' . $lp_group . '_' . $default_group . '_' . $rank_days;
} elseif ($item_type === 'fly_abo') {
$resolved_item_id = 'fly_abo';
} elseif ($item_type === 'plot_slots') {
$plot_extra_slots = max(1, intval($_POST['plot_extra_slots'] ?? 1));
$resolved_item_id = 'plot_slots_' . $plot_extra_slots;
} elseif ($item_type === 'plot_abo') {
$plot_abo_slots = max(1, intval($_POST['plot_abo_slots'] ?? 1));
$resolved_item_id = 'plot_abo_' . $plot_abo_slots;
} else {
$resolved_item_id = sanitize_text_field($_POST['item_id'] ?? '');
}
@@ -1159,7 +1165,7 @@ class WIS_Admin {
'sell_enabled' => isset($_POST['sell_enabled']) ? 1 : 0,
'sell_price_mode' => in_array($_POST['sell_price_mode'] ?? '', ['percent','fixed','minus']) ? $_POST['sell_price_mode'] : 'percent',
'sell_price_value' => max(0, intval($_POST['sell_price_value'] ?? 80)),
'status' => (intval($_POST['price'] ?? 0) > 0 || $item_type === 'fly' || $item_type === 'rank' || $item_type === 'fly_abo') ? 'publish' : 'draft',
'status' => (intval($_POST['price'] ?? 0) > 0 || $item_type === 'fly' || $item_type === 'rank' || $item_type === 'fly_abo' || $item_type === 'plot_slots' || $item_type === 'plot_abo') ? 'publish' : 'draft',
];
if (isset($_GET['edit'])) {
@@ -1857,23 +1863,29 @@ class WIS_Admin {
// Fallback für altes Format rank_{rank_id}_{days}
$is_rank_old = !$is_rank && $item && preg_match('/^rank_(.+)_(\d+)$/', $item->item_id, $rm_old);
$is_fly_abo = $item && ($item->item_id === 'fly_abo' || preg_match('/^fly_abo_\d+$/', $item->item_id));
$cur_abo_days = 0; // nicht mehr relevant
$cur_abo_days = 0;
$is_plot_slots = $item && preg_match('/^plot_slots_(\d+)$/', $item->item_id, $ps_m);
$cur_plot_extra_slots = $is_plot_slots ? intval($ps_m[1]) : 1;
$is_plot_abo = $item && preg_match('/^plot_abo_(\d+)$/', $item->item_id, $pa_m);
$cur_plot_abo_slots = $is_plot_abo ? intval($pa_m[1]) : 1;
$cur_rank_id = $is_rank ? $rm[1] : ($is_rank_old ? $rm_old[1] : 'vip');
$cur_lp_group = $is_rank ? $rm[2] : $cur_rank_id;
$cur_default_group = $is_rank ? $rm[3] : 'default';
$cur_rank_days = $is_rank ? intval($rm[4]) : ($is_rank_old ? intval($rm_old[2]) : 30);
$cur_label = $item ? esc_attr($item->name) : '';
$detected_type = $is_fly ? 'fly' : (($is_rank || $is_rank_old) ? 'rank' : ($is_fly_abo ? 'fly_abo' : 'minecraft'));
$detected_type = $is_fly ? 'fly' : (($is_rank || $is_rank_old) ? 'rank' : ($is_fly_abo ? 'fly_abo' : ($is_plot_slots ? 'plot_slots' : ($is_plot_abo ? 'plot_abo' : 'minecraft'))));
?>
<select id="item_type" name="item_type" onchange="wisToggleItemType(this.value)" style="margin-bottom:8px;">
<option value="minecraft" <?php echo $detected_type === 'minecraft' ? 'selected' : ''; ?>>Minecraft Item</option>
<option value="fly" <?php echo $detected_type === 'fly' ? 'selected' : ''; ?>>✈ Fly-Gutschein</option>
<option value="rank" <?php echo $detected_type === 'rank' ? 'selected' : ''; ?>>👑 Rang (LuckPerms)</option>
<option value="fly_abo" <?php echo $detected_type === 'fly_abo' ? 'selected' : ''; ?>>✈ Fly-Abo (tägl. Limit)</option>
<option value="plot_slots" <?php echo $detected_type === 'plot_slots' ? 'selected' : ''; ?>>📦 Plot-Slots (einmalig)</option>
<option value="plot_abo" <?php echo $detected_type === 'plot_abo' ? 'selected' : ''; ?>>📦 Plot-Abo (monatlich)</option>
</select>
<div id="wis_item_minecraft">
<input type="text" id="item_id" name="item_id" value="<?php echo ($item && !$is_fly && !$is_rank && !$is_fly_abo) ? esc_attr($item->item_id) : ''; ?>" class="regular-text" placeholder="minecraft:diamond">
<input type="text" id="item_id" name="item_id" value="<?php echo ($item && !$is_fly && !$is_rank && !$is_fly_abo && !$is_plot_slots && !$is_plot_abo) ? esc_attr($item->item_id) : ''; ?>" class="regular-text" placeholder="minecraft:diamond">
<p class="description">Z.B.: minecraft:diamond (Kategorien werden automatisch zugewiesen)</p>
</div>
@@ -1933,16 +1945,59 @@ class WIS_Admin {
</p>
</div>
<div id="wis_item_plot_slots" style="display:none;">
<table style="border-collapse:collapse;">
<tr>
<td style="padding:4px 10px 4px 0;"><label for="plot_extra_slots"><strong>Zusätzliche Plot-Slots:</strong></label></td>
<td>
<input type="number" id="plot_extra_slots" name="plot_extra_slots"
value="<?php echo esc_attr($cur_plot_extra_slots); ?>"
min="1" style="width:80px;">
<span style="margin-left:6px; color:#666;">Slots</span>
</td>
</tr>
</table>
<p class="description" style="margin-top:6px; padding:8px; background:#f6f7f7; border-left:3px solid #50b56a; border-radius:2px;">
<strong>📦 Plot-Slots einmaliger Kauf (permanent)</strong><br><br>
Der Spieler erhält dauerhaft zusätzliche Plot-Slots on top seines Rang-Limits.<br>
LuckPerms Meta <code>plotlimit</code> wird automatisch gesetzt.<br>
Gespeicherte Item-ID: <code>plot_slots_{anzahl}</code>
</p>
</div>
<div id="wis_item_plot_abo" style="display:none;">
<table style="border-collapse:collapse;">
<tr>
<td style="padding:4px 10px 4px 0;"><label for="plot_abo_slots"><strong>Zusätzliche Plot-Slots (Abo):</strong></label></td>
<td>
<input type="number" id="plot_abo_slots" name="plot_abo_slots"
value="<?php echo esc_attr($cur_plot_abo_slots); ?>"
min="1" style="width:80px;">
<span style="margin-left:6px; color:#666;">Slots</span>
</td>
</tr>
</table>
<p class="description" style="margin-top:6px; padding:8px; background:#f0f6fc; border-left:3px solid #2271b1; border-radius:2px;">
<strong>📦 Plot-Abo monatliches Abonnement</strong><br><br>
Spieler zahlen den <strong>Artikelpreis einmalig beim Kauf</strong>.<br>
Am <strong>1. jedes Monats</strong> wird der gleiche Betrag per Vault abgebucht.<br>
Bei Zahlungsausfall: Abo-Slots verfallen, überzählige Plots werden eingefroren.<br>
Kündigung ingame mit <code>/plotabocancel confirm</code> läuft bis Monatsende.<br><br>
<strong>Artikelpreis</strong> = monatlicher Beitrag<br>
Gespeicherte Item-ID: <code>plot_abo_{anzahl}</code>
</p>
</div>
<script>
function wisToggleItemType(val) {
document.getElementById('wis_item_minecraft').style.display = (val === 'minecraft') ? '' : 'none';
document.getElementById('wis_item_fly').style.display = (val === 'fly') ? '' : 'none';
document.getElementById('wis_item_rank').style.display = (val === 'rank') ? '' : 'none';
document.getElementById('wis_item_fly_abo').style.display = (val === 'fly_abo') ? '' : 'none';
// item_id Pflichtfeld nur bei Minecraft-Items
document.getElementById('wis_item_minecraft').style.display = (val === 'minecraft') ? '' : 'none';
document.getElementById('wis_item_fly').style.display = (val === 'fly') ? '' : 'none';
document.getElementById('wis_item_rank').style.display = (val === 'rank') ? '' : 'none';
document.getElementById('wis_item_fly_abo').style.display = (val === 'fly_abo') ? '' : 'none';
document.getElementById('wis_item_plot_slots').style.display = (val === 'plot_slots') ? '' : 'none';
document.getElementById('wis_item_plot_abo').style.display = (val === 'plot_abo') ? '' : 'none';
document.getElementById('item_id').required = (val === 'minecraft');
}
// Initial state
wisToggleItemType(document.getElementById('item_type').value);
</script>
</td>
@@ -2262,6 +2317,10 @@ class WIS_Admin {
echo '<span title="' . esc_attr($item->item_id) . '">👑 <code>' . esc_html($rm2[1]) . '</code> &mdash; ' . ($rd === 0 ? '<em>dauerhaft</em>' : esc_html($rd) . ' Tage') . '</span>';
} elseif ($item->item_id === 'fly_abo' || preg_match('/^fly_abo_/', $item->item_id)) {
echo '<span title="' . esc_attr($item->item_id) . '">✈ Fly-Abo &mdash; monatlich</span>';
} elseif (preg_match('/^plot_slots_(\d+)$/', $item->item_id, $plt_m)) {
echo '<span title="' . esc_attr($item->item_id) . '">📦 Plot-Slots &mdash; +' . esc_html($plt_m[1]) . ' permanent</span>';
} elseif (preg_match('/^plot_abo_(\d+)$/', $item->item_id, $plt_m)) {
echo '<span title="' . esc_attr($item->item_id) . '">📦 Plot-Abo &mdash; +' . esc_html($plt_m[1]) . ' monatlich</span>';
} else {
echo '<code>' . esc_html($item->item_id) . '</code>';
}
@@ -3568,12 +3627,29 @@ class WIS_API {
$title_parts[] = $item['qty'] . 'x ' . $item['title'];
} elseif (preg_match('/^fly_abo$/', $item_id) || preg_match('/^fly_abo_\d*$/', $item_id)) {
// Fly-Abo: monatlich abonniert, Preis = Monatsbeitrag
// qty > 1 wird ignoriert (nur 1 Abo pro Spieler möglich, Mehrfachkauf = keine Wirkung)
$commands_payload[] = [
'type' => 'fly_abo',
'label' => $item['title'],
];
$title_parts[] = $item['title'];
} elseif (preg_match('/^plot_slots_(\d+)$/', $item_id, $ps_m)) {
// Plot-Slots: einmaliger permanenter Kauf
$extra_slots = intval($ps_m[1]) * intval($item['qty']);
$commands_payload[] = [
'type' => 'plot_slots',
'slots' => $extra_slots,
'label' => $item['title'],
];
$title_parts[] = $item['qty'] . 'x ' . $item['title'];
} elseif (preg_match('/^plot_abo_(\d+)$/', $item_id, $pa_m)) {
// Plot-Abo: monatliche Abbuchung, Preis = Monatsbeitrag
$abo_slots = intval($pa_m[1]);
$commands_payload[] = [
'type' => 'plot_abo',
'slots' => $abo_slots,
'label' => $item['title'],
];
$title_parts[] = $item['title'];
} else {
// Normales Item
$items_payload[] = [