13
0

EasterEggHunt #27

Zusammengeführt
YoyoNow hat 19 Commits von EasterEggHunt nach master 2023-04-06 22:51:18 +02:00 zusammengeführt
12 geänderte Dateien mit 537 neuen und 19 gelöschten Zeilen
Nur Änderungen aus Commit 67ed66777f werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -27,6 +27,8 @@ import de.steamwar.lobby.command.PortalCommand;
import de.steamwar.lobby.jumpandrun.JumpAndRun; import de.steamwar.lobby.jumpandrun.JumpAndRun;
import de.steamwar.lobby.listener.*; import de.steamwar.lobby.listener.*;
import de.steamwar.lobby.map.CustomMapCommand; import de.steamwar.lobby.map.CustomMapCommand;
import de.steamwar.lobby.particle.ParticleListener;
import de.steamwar.lobby.special.easter.EggHunt;
import de.steamwar.lobby.team.TeamPlayer; import de.steamwar.lobby.team.TeamPlayer;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -71,6 +73,8 @@ public class LobbySystem extends JavaPlugin {
new TeleporterListener(); new TeleporterListener();
new TeamPlayer(); new TeamPlayer();
EggHunt.init();
new AlphaWall(l -> l.getX() > 1199, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() > 1199, AlphaWall.REFLECT_X);
new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X);
new AlphaWall(l -> l.getZ() > 892, AlphaWall.REFLECT_Z); new AlphaWall(l -> l.getZ() > 892, AlphaWall.REFLECT_Z);

Datei anzeigen

@ -20,9 +20,15 @@ PARTICLE_INVENTORY = §6Particle
PARTICLE_DESELECT = §8No particle PARTICLE_DESELECT = §8No particle
PARTICLE_LOCKED = {0} §8- §c§lLocked PARTICLE_LOCKED = {0} §8- §c§lLocked
PARTICLE_UNLOCKED_BY_TEAM = §fJoin the team PARTICLE_UNLOCKED_BY = §eUnlocked by
PARTICLE_UNLOCKED_BY_TEAM = §fJoin a team
PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM = §fTeam {0}
PARTICLE_UNLOCKED_BY_EVENT = §fEvent participation PARTICLE_UNLOCKED_BY_EVENT = §fEvent participation
PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServer Team PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServer Team
PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. or 3. Place
PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0}
PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_HALF = §fFind 45 Easter Eggs
PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_DIFFICULTY = §fFind all Easter Eggs with difficulty {0}
PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring
PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Double ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Double ring
@ -32,8 +38,6 @@ PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in air
PARTICLE_ATTRIBUTE_WING = §8-§f Wings PARTICLE_ATTRIBUTE_WING = §8-§f Wings
PARTICLE_ATTRIBUTE = §eAttributes§7: PARTICLE_ATTRIBUTE = §eAttributes§7:
PARTICLE_UNLOCKED_BY = §eUnlocked by
PARTICLE_SELECT = §eClick to select PARTICLE_SELECT = §eClick to select
PARTICLE_SNEEZE = §aSneeze PARTICLE_SNEEZE = §aSneeze
@ -71,9 +75,6 @@ PARTICLE_WATER_FIRE = §bWater§7/§cFire
PARTICLE_MAGIC_ENCHANTING = §5Magic/Enchantment PARTICLE_MAGIC_ENCHANTING = §5Magic/Enchantment
PARTICLE_WINGS_EVIL = §5Purple wings PARTICLE_WINGS_EVIL = §5Purple wings
PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. or 3. Place
PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0}
PARTICLE_EVENT_ENCHANTING = §cEnchantment PARTICLE_EVENT_ENCHANTING = §cEnchantment
PARTICLE_EVENT_CLOUD = §fClouds PARTICLE_EVENT_CLOUD = §fClouds
PARTICLE_EVENT_SMOKE = §7Smoke PARTICLE_EVENT_SMOKE = §7Smoke
@ -87,3 +88,10 @@ JUMP_AND_RUN_PROGRESS = §e{0}§8/§f{1} §c{2} §7{3}
JUMP_AND_RUN_CANCEL = {0} JUMP_AND_RUN_CANCEL = {0}
JUMP_AND_RUN_TIME = mm:ss SSS JUMP_AND_RUN_TIME = mm:ss SSS
JUMP_AND_RUN_FINISHED = §aFinished in {0} with {1} fails JUMP_AND_RUN_FINISHED = §aFinished in {0} with {1} fails
# Easter Egg Hunt
DIFFICULTY_EASY = §aEasy
DIFFICULTY_MEDIUM = §eMedium
DIFFICULTY_HARD = §cHard
DIFFICULTY_EXTREME = §5Extreme
DIFFICULTY_ADVANCED = §5Advanced

Datei anzeigen

@ -20,9 +20,15 @@ PARTICLE_INVENTORY = §6Partikel
PARTICLE_DESELECT = §8Keine Partikel PARTICLE_DESELECT = §8Keine Partikel
PARTICLE_LOCKED = {0} §8- §c§lGesperrt PARTICLE_LOCKED = {0} §8- §c§lGesperrt
PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch
PARTICLE_UNLOCKED_BY_TEAM = §fTeambeitritt PARTICLE_UNLOCKED_BY_TEAM = §fTeambeitritt
PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM = §fTeam {0}
PARTICLE_UNLOCKED_BY_EVENT = §fEventteilnahme PARTICLE_UNLOCKED_BY_EVENT = §fEventteilnahme
PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServerteam PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServerteam
PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. oder 3. Platz
PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0}
PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_HALF = §fFinde 45 Oster-Eierer
PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_DIFFICULTY = §fAlle Eierer mit Schwierigkeit {0} finden
PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring
PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppelring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppelring
@ -32,8 +38,6 @@ PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in Luft
PARTICLE_ATTRIBUTE_WING = §8-§f Flügel PARTICLE_ATTRIBUTE_WING = §8-§f Flügel
PARTICLE_ATTRIBUTE = §eAttribute§7: PARTICLE_ATTRIBUTE = §eAttribute§7:
PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch
PARTICLE_SELECT = §eZum Auswählen klicken PARTICLE_SELECT = §eZum Auswählen klicken
PARTICLE_SNEEZE = §aSneeze PARTICLE_SNEEZE = §aSneeze
@ -71,11 +75,6 @@ PARTICLE_WATER_FIRE = §bWasser§7/§cFeuer
PARTICLE_MAGIC_ENCHANTING = §5Magie§7/§eZauber PARTICLE_MAGIC_ENCHANTING = §5Magie§7/§eZauber
PARTICLE_WINGS_EVIL = §5Lila Flügel PARTICLE_WINGS_EVIL = §5Lila Flügel
PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. oder 3. Platz
PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0}
JUMP_AND_RUN_FINISHED = §aBeendet in {0} mit {1} Fails
PARTICLE_EVENT_ENCHANTING = §cVerzaubert PARTICLE_EVENT_ENCHANTING = §cVerzaubert
PARTICLE_EVENT_CLOUD = §fWolken PARTICLE_EVENT_CLOUD = §fWolken
PARTICLE_EVENT_SMOKE = §7Rauch PARTICLE_EVENT_SMOKE = §7Rauch
@ -84,3 +83,12 @@ PARTICLE_EVENT_WINGS = §fFlügel
PARTICLE_EVENT_RAIN_CLOUD = §fRegenwolke PARTICLE_EVENT_RAIN_CLOUD = §fRegenwolke
PARTICLE_EVENT_WGS = §fWGS PARTICLE_EVENT_WGS = §fWGS
PARTICLE_EVENT_WARGEARCLASH = §fClash PARTICLE_EVENT_WARGEARCLASH = §fClash
JUMP_AND_RUN_FINISHED = §aBeendet in {0} mit {1} Fails
# Easter Egg Hunt
DIFFICULTY_EASY = §aLeicht
DIFFICULTY_MEDIUM = §eMedium
DIFFICULTY_HARD = §cHart
DIFFICULTY_EXTREME = §5Extrem
DIFFICULTY_ADVANCED = §5Advanced

Datei anzeigen

@ -0,0 +1,47 @@
package de.steamwar.lobby.otherparticle;
import de.steamwar.inventory.SWItem;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
public class Particle {
private ParticleItem item;
private static class ParticleItem {
private Material material;
private String name;
private Set<String> attributes = new LinkedHashSet<>();
private String unlockedBy;
public SWItem toSWItem(Player player) {
String translatedName = LobbySystem.getMessage().parse(name, player);
List<String> lore = new ArrayList<>();
lore.add("");
if (!attributes.isEmpty()) {
lore.add(LobbySystem.getMessage().parse("PARTICLE_ATTRIBUTE", player));
attributes.forEach(attribute -> lore.add(LobbySystem.getMessage().parse(attribute, player)));
lore.add("");
}
if (unlockedBy != null) {
lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player));
lore.add(LobbySystem.getMessage().parse(unlockedBy, player));
lore.add("");
}
lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player));
return new SWItem(material, translatedName, lore, false, clickType -> {});
}
}
private Predicate<SteamwarUser> unlocked = player -> true;
}

Datei anzeigen

@ -0,0 +1,179 @@
package de.steamwar.lobby.otherparticle;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.special.easter.EggDifficulty;
import de.steamwar.lobby.special.easter.EggHunt;
import de.steamwar.sql.Event;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import de.steamwar.sql.UserGroup;
import org.bukkit.entity.Player;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public interface ParticleRequirement {
String getRequirementName(Player player);
ParticleRequirementPredicate getRequirement();
ParticleRequirement NO_REQUIRMENT = new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return null;
}
@Override
public ParticleRequirementPredicate getRequirement() {
return (player, eventTeilname, eggHuntConfig) -> true;
}
};
ParticleRequirement HAS_TEAM = new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_TEAM", player);
}
@Override
public ParticleRequirementPredicate getRequirement() {
return (steamwarUser, eventTeilname, eggHuntConfig) -> steamwarUser.getTeam() != 0 || steamwarUser.getUserGroup() != UserGroup.Member;
}
};
ParticleRequirement EVENT_PARTICIPATION = new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EVENT", player);
}
@Override
public ParticleRequirementPredicate getRequirement() {
return (steamwarUser, eventTeilname, eggHuntConfig) -> !eventTeilname.isEmpty();
}
};
ParticleRequirement SERVER_TEAM = new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SERVER_TEAM", player);
}
@Override
public ParticleRequirementPredicate getRequirement() {
return (steamwarUser, eventTeilname, eggHuntConfig) -> false;
}
};
ParticleRequirement EGG_HUNT_EASY = _easterEggHuntDifficulty(EggDifficulty.EASY);
ParticleRequirement EGG_HUNT_MEDIUM = _easterEggHuntDifficulty(EggDifficulty.MEDIUM);
ParticleRequirement EGG_HUNT_HARD = _easterEggHuntDifficulty(EggDifficulty.HARD);
ParticleRequirement EGG_HUNT_EXTREME = _easterEggHuntDifficulty(EggDifficulty.EXTREME);
ParticleRequirement EGG_HUNT_ADVANCED = _easterEggHuntDifficulty(EggDifficulty.ADVANCED);
ParticleRequirement EGG_HUNT_FOUND_HALF = new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_HALF", player);
}
@Override
public ParticleRequirementPredicate getRequirement() {
return (user, eventTeilname, eggHuntConfig) -> {
if (eggHuntConfig == null) return false;
int count = 0;
for (int i = 0; i < eggHuntConfig.length(); i++) {
if (eggHuntConfig.charAt(i) == '1') {
count++;
}
}
return count >= EggHunt.getEggList().size() / 2;
};
}
};
static ParticleRequirement specificTeam(int teamId) {
if (teamId == 0) return NO_REQUIRMENT;
String teamKuerzel = Team.get(teamId).getTeamKuerzel();
return new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM", player, teamKuerzel);
}
@Override
public ParticleRequirementPredicate getRequirement() {
return (steamwarUser, eventTeilname, eggHuntConfig) -> steamwarUser.getTeam() == teamId;
}
};
}
static ParticleRequirement eventParticipation(int eventId) {
String eventName = Event.get(eventId).getEventName();
return new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION", player, eventName);
}
@Override
public ParticleRequirementPredicate getRequirement() {
return (steamwarUser, eventTeilname, eggHuntConfig) -> eventTeilname.contains(eventId);
}
};
}
static ParticleRequirement eventPlacement(int eventId, int... placementTeams) {
String eventName = Event.get(eventId).getEventName();
Set<Integer> teams = new HashSet<>();
for (int i : placementTeams) teams.add(i);
return new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT", player, eventName);
}
@Override
public ParticleRequirementPredicate getRequirement() {
return (steamwarUser, eventTeilname, eggHuntConfig) -> {
if (!eventTeilname.contains(eventId)) return false;
return teams.contains(steamwarUser.getTeam());
};
}
};
}
static ParticleRequirement _easterEggHuntDifficulty(EggDifficulty difficulty) {
AtomicInteger count = new AtomicInteger();
List<Integer> eggs = EggHunt.getEggList()
.stream()
.map(egg -> {
int id = count.getAndIncrement();
if (egg.getDifficulty() == difficulty) {
return id;
} else {
return null;
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
return new ParticleRequirement() {
@Override
public String getRequirementName(Player player) {
return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_DIFFICULTY", player, LobbySystem.getMessage().parse(difficulty.getMessage(), player));
}
@Override
public ParticleRequirementPredicate getRequirement() {
return (steamwarUser, integers, eggHuntConfig) -> {
if (eggHuntConfig == null) return false;
return eggs.stream().allMatch(id -> eggHuntConfig.length() >= id && eggHuntConfig.charAt(id) == '1');
};
}
};
}
interface ParticleRequirementPredicate {
boolean test(SteamwarUser user, Set<Integer> eventTeilname, String eggHuntConfig);
}
}

Datei anzeigen

@ -0,0 +1,15 @@
package de.steamwar.lobby.particle;
public class ParticleBuilder {
public ParticleBuilder() {
}
public void cloud() {}
public void offset() {}
public void rotated() {}
public void build() {}
}

Datei anzeigen

@ -17,13 +17,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.lobby.listener; package de.steamwar.lobby.particle;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.jumpandrun.JumpAndRun; import de.steamwar.lobby.jumpandrun.JumpAndRun;
import de.steamwar.lobby.particle.BaseParticle; import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.listener.PlayerSpawn;
import de.steamwar.lobby.particle.ParticleInventory;
import de.steamwar.lobby.particle.particles.ParticleEnum; import de.steamwar.lobby.particle.particles.ParticleEnum;
import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

Datei anzeigen

@ -0,0 +1,102 @@
package de.steamwar.lobby.special.easter;
import de.steamwar.inventory.SWItem;
import de.steamwar.lobby.LobbySystem;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.profile.PlayerProfile;
import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
public class Egg {
private static final World world = Bukkit.getWorlds().get(0);
private final int x;
private final int y;
private final int z;
private final String message;
private final EggDifficulty difficulty;
private Optional<PlayerProfile> playerProfile = null;
public Egg(Map<String, ?> config) {
this.x = (int) config.get("x");
this.y = (int) config.get("y");
this.z = (int) config.get("z");
this.message = (String) config.get("name");
this.difficulty = EggDifficulty.valueOf(((String) config.get("difficulty")).toUpperCase());
}
public Vector getVector() {
return new Vector(x, y, z);
}
public String getMessage() {
return message;
}
public EggDifficulty getDifficulty() {
return difficulty;
}
public Block getBlock() {
Block block = world.getBlockAt(x, y, z);
if (block.getType() != Material.PLAYER_HEAD && block.getType() != Material.PLAYER_WALL_HEAD) {
System.out.println("Block is not a skull: " + block.getType() + " " + x + "," + y + "," + z);
return null;
}
return block;
}
public SWItem getItem(Player player, boolean found) {
if (playerProfile == null) {
Block block = getBlock();
if (block == null) {
playerProfile = Optional.empty();
return null;
}
Skull skull = (Skull) block.getState();
PlayerProfile playerProfile = skull.getOwnerProfile();
if (playerProfile == null) {
this.playerProfile = Optional.empty();
return null;
}
this.playerProfile = Optional.of(playerProfile);
}
if (!playerProfile.isPresent()) {
return null;
}
SWItem swItem;
if (found) {
swItem = new SWItem();
ItemStack itemStack = new ItemStack(Material.PLAYER_HEAD);
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
skullMeta.setOwnerProfile(playerProfile.get());
itemStack.setItemMeta(skullMeta);
swItem.setItemStack(itemStack);
} else {
swItem = SWItem.getPlayerSkull("MHF_Question");
}
swItem.setLore(Arrays.asList(LobbySystem.getMessage().parse(difficulty.getMessage(), player)));
try {
swItem.setName("§f" + LobbySystem.getMessage().parse(message, player));
} catch (Exception e) {
swItem.setName("§f" + message);
}
return swItem;
}
}

Datei anzeigen

@ -0,0 +1,64 @@
package de.steamwar.lobby.special.easter;
import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.listener.BasicListener;
import de.steamwar.sql.UserConfig;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
public class EggClickListener extends BasicListener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
Block block = event.getClickedBlock();
if (block == null) {
return;
}
Vector vector = block.getLocation().toVector();
Egg egg = null;
int index = -1;
for (Egg egg1 : EggHunt.getEggList()) {
index++;
if (egg1.getVector().equals(vector)) {
egg = egg1;
break;
}
}
if (egg == null) {
return;
}
Player player = event.getPlayer();
String found = UserConfig.getConfig(player.getUniqueId(), "egghunt");
if (found == null) {
found = "";
}
StringBuilder builder = new StringBuilder(found);
while (builder.length() <= index) {
builder.append("0");
}
if (builder.charAt(index) == '1') {
return;
}
try {
player.sendTitle(LobbySystem.getMessage().parse(egg.getMessage(), player), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 80, 5);
} catch (Exception e) {
player.sendTitle(egg.getMessage(), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 10, 5);
}
player.spawnParticle(Particle.END_ROD, block.getLocation().add(0.5, 0.5, 0.5), 10, 0.5, 0.5, 0.5, 0.1);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.25f, 1.0f);
builder.setCharAt(index, '1');
UserConfig.updatePlayerConfig(player.getUniqueId(), "egghunt", builder.toString());
}
}

Datei anzeigen

@ -0,0 +1,19 @@
package de.steamwar.lobby.special.easter;
public enum EggDifficulty {
EASY("DIFFICULTY_EASY"),
MEDIUM("DIFFICULTY_MEDIUM"),
HARD("DIFFICULTY_HARD"),
EXTREME("DIFFICULTY_EXTREME"),
ADVANCED("DIFFICULTY_ADVANCED");
private final String message;
EggDifficulty(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}

Datei anzeigen

@ -0,0 +1,35 @@
package de.steamwar.lobby.special.easter;
import de.steamwar.lobby.LobbySystem;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class EggHunt {
private static List<Egg> eggList = new ArrayList<>();
public static void init() {
}
static {
new EggHuntCommand();
new EggClickListener();
File file = new File(LobbySystem.getPlugin().getDataFolder(), "eggs.yml");
FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file);
fileConfiguration.getList("eggs")
.forEach(o -> {
if (!(o instanceof Map)) return;
eggList.add(new Egg((Map) o));
});
}
public static List<Egg> getEggList() {
return eggList;
}
}

Datei anzeigen

@ -0,0 +1,38 @@
package de.steamwar.lobby.special.easter;
import de.steamwar.command.SWCommand;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.sql.UserConfig;
import org.bukkit.entity.Player;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
public class EggHuntCommand extends SWCommand {
public EggHuntCommand() {
super("egghunt", "easteregg", "easter", "egg", "eh");
}
@Register
public void genericCommand(Player player) {
AtomicInteger atomicInteger = new AtomicInteger();
String found = UserConfig.getConfig(player.getUniqueId(), "egghunt");
List<SWListInv.SWListEntry<Egg>> entries = EggHunt.getEggList().stream()
.map(egg -> {
int index = atomicInteger.getAndIncrement();
SWItem swItem = egg.getItem(player, found != null && found.length() > index && found.charAt(index) == '1');
if (swItem == null) return null;
return new SWListInv.SWListEntry<>(swItem, egg);
})
.sorted(Comparator.comparing(eggSWListEntry -> eggSWListEntry.getObject().getDifficulty()))
.filter(Objects::nonNull).collect(Collectors.toList());
SWListInv<Egg> inv = new SWListInv<>(player, "", entries, (clickType, egg) -> {
});
inv.open();
}
}