Add new Particle with onlineTime restriction
Dieser Commit ist enthalten in:
Ursprung
39ec6d2212
Commit
71e1a07e11
@ -22,6 +22,7 @@ package de.steamwar.lobby.inventories;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import de.steamwar.sql.OnlineTime;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.bukkit.Material;
|
||||
@ -29,19 +30,20 @@ import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.MatchResult;
|
||||
|
||||
public class ParticleInventory {
|
||||
|
||||
private ParticleInventory() {}
|
||||
|
||||
private static SWItem mysteryParticle = new SWItem(Material.STRUCTURE_VOID, "§5§l???", Arrays.asList("§5Ein mysteriöses Partikel"), false, clickType -> {});
|
||||
private static List<String> lore = Arrays.asList("§aKlicken zum Auswählen");
|
||||
|
||||
private static SWInventory createInventory(Player player) {
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup();
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("§aKlicken zum Auswählen");
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
SWInventory swInventory;
|
||||
if (userGroup == UserGroup.Member) {
|
||||
@ -67,7 +69,8 @@ public class ParticleInventory {
|
||||
add(swInventory, Material.ZOMBIE_HEAD, "§7Mob", lore, Particle.SPELL_MOB, 25, player, lobbyPlayer);
|
||||
|
||||
if (userGroup == UserGroup.Member) {
|
||||
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 31, player, lobbyPlayer);
|
||||
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 34, player, lobbyPlayer);
|
||||
add(swInventory, 28, steamwarUser, player, lobbyPlayer);
|
||||
} else {
|
||||
add(swInventory, Material.SPIDER_EYE, "§5Damage", lore, Particle.DAMAGE_INDICATOR, 28, player, lobbyPlayer, true, 0.2F, 0F, 0.2F, 0.01);
|
||||
add(swInventory, Material.EXPERIENCE_BOTTLE, "§5Hexe", lore, Particle.SPELL_WITCH, 29, player, lobbyPlayer);
|
||||
@ -77,12 +80,44 @@ public class ParticleInventory {
|
||||
add(swInventory, Material.TOTEM_OF_UNDYING, "§aTotem", lore, Particle.TOTEM, 33, player, lobbyPlayer, true, 0F, 0.2F, 0F, 0.2);
|
||||
add(swInventory, Material.END_ROD, "§fEnd Rod", lore, Particle.END_ROD, 34, player, lobbyPlayer, true, 0.2F, 0.2F, 0.2F, 0.01);
|
||||
|
||||
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 40, player, lobbyPlayer);
|
||||
add(swInventory, Material.BARRIER, "§8Keine Partikel", lore, null, 43, player, lobbyPlayer);
|
||||
add(swInventory, 37, steamwarUser, player, lobbyPlayer);
|
||||
}
|
||||
|
||||
return swInventory;
|
||||
}
|
||||
|
||||
private static void add(SWInventory swInventory, int slot, SteamwarUser steamwarUser, Player player, LobbyPlayer lobbyPlayer) {
|
||||
swInventory.setItem(slot, mysteryParticle);
|
||||
swInventory.setItem(slot + 1, mysteryParticle);
|
||||
swInventory.setItem(slot + 2, mysteryParticle);
|
||||
swInventory.setItem(slot + 3, mysteryParticle);
|
||||
swInventory.setItem(slot + 4, mysteryParticle);
|
||||
|
||||
double onlineTime = OnlineTime.getOnlinetime(steamwarUser) / 60 / 60;
|
||||
|
||||
if (onlineTime < 200) {
|
||||
return;
|
||||
}
|
||||
add(swInventory, Material.DRAGON_BREATH, "§5Dragon Breath", lore, Particle.DRAGON_BREATH, slot, player, lobbyPlayer);
|
||||
if (onlineTime < 400) {
|
||||
return;
|
||||
}
|
||||
add(swInventory, Material.DOLPHIN_SPAWN_EGG, "§bDelphin", lore, Particle.DOLPHIN, slot + 1, player, lobbyPlayer);
|
||||
if (onlineTime < 800) {
|
||||
return;
|
||||
}
|
||||
add(swInventory, Material.RED_CONCRETE, "§cInstant Spell", lore, Particle.SPELL_INSTANT, slot + 2, player, lobbyPlayer);
|
||||
if (onlineTime < 1600) {
|
||||
return;
|
||||
}
|
||||
add(swInventory, Material.PURPLE_WOOL, "§5Portal", lore, Particle.PORTAL, slot + 3, player, lobbyPlayer);
|
||||
if (onlineTime < 3200) {
|
||||
return;
|
||||
}
|
||||
add(swInventory, Material.WHITE_DYE, "§fFlash", lore, Particle.FLASH, slot + 4, player, lobbyPlayer);
|
||||
}
|
||||
|
||||
private static void add(SWInventory swInventory, Material material, String name, List<String> lore, Particle particle, int slot, Player player, LobbyPlayer lobbyPlayer, boolean customVelocity, float vx, float vy, float vz, double time) {
|
||||
SWItem swItem = new SWItem(material, name, lore, false, clickType -> {
|
||||
lobbyPlayer.setParticle(particle, customVelocity);
|
||||
|
@ -24,7 +24,8 @@ import de.steamwar.lobby.inventories.LobbyInventory;
|
||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
@ -19,8 +19,11 @@
|
||||
|
||||
package de.steamwar.lobby.utils;
|
||||
|
||||
import de.steamwar.sql.SQL;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
public class LobbyPlayer {
|
||||
|
38
src/de/steamwar/sql/OnlineTime.java
Normale Datei
38
src/de/steamwar/sql/OnlineTime.java
Normale Datei
@ -0,0 +1,38 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.sql;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class OnlineTime {
|
||||
|
||||
public static double getOnlinetime(SteamwarUser steamwarUser) {
|
||||
ResultSet set = SQL.select("SELECT SUM(UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime)) as Playtime FROM Session WHERE UserID = ?", steamwarUser.getId());
|
||||
try {
|
||||
set.next();
|
||||
return set.getBigDecimal("Playtime").doubleValue();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren