Map resources
This commit is contained in:
parent
f99d2a2039
commit
c487cfa232
25 changed files with 592 additions and 16 deletions
12
core/pom.xml
12
core/pom.xml
|
@ -83,5 +83,17 @@
|
|||
<version>33.1.0-jre</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.21.1-R0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.21.1-R0.1-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.profile.PlayerProfile;
|
||||
import org.bukkit.profile.PlayerTextures;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.net.MalformedURLException;
|
||||
|
@ -71,4 +72,16 @@ public class Util {
|
|||
|
||||
return skull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses string to vector
|
||||
* @param text Text in the form ".5 7.5 -10"
|
||||
* @return Vector
|
||||
*/
|
||||
public static Vector parseVector(final String text)
|
||||
{
|
||||
String[] split = text.split(" ", 3);
|
||||
|
||||
return new Vector(Double.valueOf(split[0]), Double.valueOf(split[1]), Double.valueOf(split[2]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
package org.ef3d0c3e.sheepwars.commands;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.ef3d0c3e.sheepwars.SheepWars;
|
||||
import org.ef3d0c3e.sheepwars.maps.Map;
|
||||
import org.ef3d0c3e.sheepwars.maps.MapManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.ef3d0c3e.sheepwars.game.Game;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
|
@ -33,6 +39,20 @@ public class CmdSheepWars extends Command {
|
|||
sender.sendMessage(" - §astart §fStarts the game");
|
||||
sender.sendMessage(" - §adebug §7<option> §fFor developers");
|
||||
}
|
||||
else if (category.equals("debug"))
|
||||
{
|
||||
final Map map = MapManager.getMap("blimp");
|
||||
Game.start(map);
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run ()
|
||||
{
|
||||
p.teleport(new Location(Game.getLevel().getHandle(), 0, 64, 0));
|
||||
}
|
||||
}.runTaskLater(SheepWars.getPlugin(), 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -51,7 +71,7 @@ public class CmdSheepWars extends Command {
|
|||
}
|
||||
else if (args[0].equals("debug"))
|
||||
{
|
||||
if (args.length == 2) return Lists.newArrayList("<poses>");
|
||||
if (args.length == 2) return Lists.newArrayList("<map>");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -6,7 +6,10 @@ import org.ef3d0c3e.sheepwars.SheepWars;
|
|||
import org.ef3d0c3e.sheepwars.events.EventListenerFactory;
|
||||
import org.ef3d0c3e.sheepwars.events.WantsListen;
|
||||
import org.ef3d0c3e.sheepwars.level.LevelFactory;
|
||||
import org.ef3d0c3e.sheepwars.level.game.GameLevel;
|
||||
import org.ef3d0c3e.sheepwars.level.lobby.LobbyLevel;
|
||||
import org.ef3d0c3e.sheepwars.maps.Map;
|
||||
import org.ef3d0c3e.sheepwars.maps.MapManager;
|
||||
import org.ef3d0c3e.sheepwars.packets.PacketListenerFactory;
|
||||
|
||||
import java.util.Random;
|
||||
|
@ -27,8 +30,8 @@ public class Game {
|
|||
@Getter
|
||||
private static LobbyLevel lobby;
|
||||
|
||||
//@Getter
|
||||
//private static GameLevel level;
|
||||
@Getter
|
||||
private static GameLevel level;
|
||||
|
||||
private static final Random random = new Random();
|
||||
public static int nextInt()
|
||||
|
@ -36,6 +39,19 @@ public class Game {
|
|||
return random.nextInt();
|
||||
}
|
||||
|
||||
public static void start(final Map map)
|
||||
{
|
||||
changePhase(WantsListen.Target.Game);
|
||||
|
||||
level = new GameLevel(map);
|
||||
LevelFactory.add(level);
|
||||
|
||||
try {
|
||||
level.create();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default phase to lobby
|
||||
|
@ -50,6 +66,9 @@ public class Game {
|
|||
//level = new GameLevel();
|
||||
//LevelFactory.add(level);
|
||||
|
||||
// Load maps
|
||||
MapManager.reloadMaps();
|
||||
|
||||
// Create lobby world
|
||||
// Game level is created once it is needed
|
||||
// @see CmdHunt
|
||||
|
|
30
core/src/main/java/org/ef3d0c3e/sheepwars/kits/Kit.java
Normal file
30
core/src/main/java/org/ef3d0c3e/sheepwars/kits/Kit.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package org.ef3d0c3e.sheepwars.kits;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.ef3d0c3e.sheepwars.player.CPlayer;
|
||||
|
||||
public abstract class Kit {
|
||||
/**
|
||||
* Gets kit's name (internal)
|
||||
* @return Kit's name
|
||||
*/
|
||||
public abstract @NonNull String getName();
|
||||
|
||||
/**
|
||||
* Gets kit's localized display name
|
||||
* @param cp Player
|
||||
* @return Display name
|
||||
*/
|
||||
public abstract @NonNull String getDisplayName(final @NonNull CPlayer cp);
|
||||
|
||||
public abstract @NonNull ItemStack getIcon(final @NonNull CPlayer cp);
|
||||
|
||||
/**
|
||||
* Create kit data for player
|
||||
* @param cp Player to create data for
|
||||
* @return Data
|
||||
*/
|
||||
public abstract @NonNull KitData createData(final @NonNull CPlayer cp);
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.ef3d0c3e.sheepwars.kits;
|
||||
|
||||
/**
|
||||
* Data for a kit
|
||||
*/
|
||||
public abstract class KitData {
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package org.ef3d0c3e.sheepwars.level.game;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.ef3d0c3e.sheepwars.SheepWars;
|
||||
import org.ef3d0c3e.sheepwars.level.Level;
|
||||
import org.ef3d0c3e.sheepwars.maps.Map;
|
||||
|
||||
public class GameLevel extends Level {
|
||||
@Getter
|
||||
final Map map;
|
||||
|
||||
public GameLevel(final Map map)
|
||||
{
|
||||
super(SheepWars.getSheepWarsConfig().GAME_WORLD);
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull World generate() throws Exception {
|
||||
return map.generate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoad(Chunk chunk, boolean newChunk) {
|
||||
getHandle().setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
|
||||
getHandle().setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
||||
getHandle().setGameRule(GameRule.SEND_COMMAND_FEEDBACK, false);
|
||||
getHandle().setGameRule(GameRule.RANDOM_TICK_SPEED, 0);
|
||||
getHandle().setGameRule(GameRule.DO_MOB_SPAWNING, false);
|
||||
getHandle().setGameRule(GameRule.DO_INSOMNIA, false);
|
||||
getHandle().setGameRule(GameRule.SPAWN_RADIUS, 0);
|
||||
getHandle().setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
|
||||
getHandle().setGameRule(GameRule.NATURAL_REGENERATION, false);
|
||||
getHandle().setGameRule(GameRule.DO_TILE_DROPS, false);
|
||||
getHandle().setTime(map.getWorldTime());
|
||||
getHandle().setWeatherDuration(0);
|
||||
// TODO: Request a spectator spawn location in the config
|
||||
getHandle().setSpawnLocation(0, getHandle().getHighestBlockYAt(0, 0), 0);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ import org.ef3d0c3e.sheepwars.events.*;
|
|||
import org.ef3d0c3e.sheepwars.game.Game;
|
||||
import org.ef3d0c3e.sheepwars.items.IItem;
|
||||
import org.ef3d0c3e.sheepwars.player.skin.SkinItem;
|
||||
import org.ef3d0c3e.sheepwars.teams.TeamItem;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -41,21 +42,21 @@ public class LobbyEvents implements Listener
|
|||
|
||||
final PlayerInventory inv = ev.getPlayer().getHandle().getInventory();
|
||||
inv.clear();
|
||||
//inv.setItem(0, TeamItem.getItem(ev.getPlayer()));
|
||||
inv.setItem(0, TeamItem.getItem(ev.getPlayer()));
|
||||
//inv.setItem(1, KitItem.getItem(ev.getPlayer()));
|
||||
inv.setItem(4, RocketItem.getItem(ev.getPlayer()));
|
||||
inv.setItem(7, SkinItem.getItem(ev.getPlayer()));
|
||||
}
|
||||
|
||||
/*
|
||||
@EventHandler
|
||||
public void onTeamChange(final TeamChangeEvent ev)
|
||||
{
|
||||
final ItemStack replace = TeamItem.getItem(ev.getPlayer());
|
||||
if (!ItemBase.replace(ev.getPlayer().getHandle().getInventory(), TeamItem.ITEM, replace))
|
||||
if (!IItem.replace(ev.getPlayer().getHandle().getInventory(), TeamItem.ITEM, replace))
|
||||
ev.getPlayer().getHandle().getInventory().setItem(0, replace);
|
||||
}
|
||||
|
||||
/*
|
||||
@EventHandler
|
||||
public void onKitChange(final KitChangeEvent ev)
|
||||
{
|
||||
|
|
124
core/src/main/java/org/ef3d0c3e/sheepwars/maps/Map.java
Normal file
124
core/src/main/java/org/ef3d0c3e/sheepwars/maps/Map.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
package org.ef3d0c3e.sheepwars.maps;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.ef3d0c3e.sheepwars.SheepWars;
|
||||
import org.ef3d0c3e.sheepwars.level.VoidChunkGenerator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Map {
|
||||
@Getter
|
||||
String name; /// Map's internal name
|
||||
@Getter
|
||||
protected String displayName; /// Map's display name (unlocalized)
|
||||
@Getter
|
||||
protected Material icon; /// Map's display icon
|
||||
@Getter
|
||||
protected File schematic; /// Map's schematic file
|
||||
@Getter
|
||||
protected Clipboard mapContent; /// Map's schematic contnet
|
||||
|
||||
@Getter
|
||||
protected int nbVote; /// Number of votes for this map
|
||||
|
||||
@Getter
|
||||
protected Vector offset;
|
||||
@Getter
|
||||
protected Vector lowestPoint;
|
||||
@Getter
|
||||
protected Vector highestPoint;
|
||||
@Getter
|
||||
protected int limboBegin;
|
||||
@Getter
|
||||
protected int limboEnd;
|
||||
@Getter
|
||||
protected int worldTime;
|
||||
@Getter
|
||||
protected Vector lowestWool;
|
||||
@Getter
|
||||
protected Vector highestWool;
|
||||
@Getter
|
||||
protected ArrayList<Vector> redSpawns;
|
||||
@Getter
|
||||
protected float redYaw;
|
||||
@Getter
|
||||
protected ArrayList<Vector> blueSpawns;
|
||||
@Getter
|
||||
protected float blueYaw;
|
||||
|
||||
/**
|
||||
* Generate map in world
|
||||
* @return World the map is in
|
||||
*/
|
||||
public World generate()
|
||||
{
|
||||
try
|
||||
{
|
||||
//final World erase = Bukkit.getWorld("sheepwars");
|
||||
//if (erase != null)
|
||||
//{
|
||||
// Bukkit.getConsoleSender().sendMessage("§cSheepWars>§7 Suppression du monde 'sheepwars'");
|
||||
// Bukkit.getServer().unloadWorld(erase, false);
|
||||
// FileUtils.deleteDirectory(erase.getWorldFolder());
|
||||
//}
|
||||
|
||||
SheepWars.consoleMessage("Creating game world...");
|
||||
final WorldCreator wc = new WorldCreator(SheepWars.getSheepWarsConfig().GAME_WORLD);
|
||||
wc.generator(new VoidChunkGenerator());
|
||||
final World world = wc.createWorld();
|
||||
|
||||
ClipboardFormat format = ClipboardFormats.findByFile(schematic);
|
||||
ClipboardReader reader = format.getReader(new FileInputStream(schematic));
|
||||
mapContent = reader.read();
|
||||
|
||||
com.sk89q.worldedit.world.World adaptedWorld = BukkitAdapter.adapt(world);
|
||||
EditSession editSession = WorldEdit.getInstance().newEditSession(adaptedWorld);
|
||||
Operation operation = new ClipboardHolder(mapContent).createPaste(editSession)
|
||||
.to(BlockVector3.at(offset.getX(), offset.getY()+64, offset.getZ()))
|
||||
.ignoreAirBlocks(true)
|
||||
.build();
|
||||
|
||||
lowestPoint = new Vector(
|
||||
mapContent.getOrigin().x() - mapContent.getMaximumPoint().x() + offset.getX(),
|
||||
mapContent.getMinimumPoint().y() - mapContent.getOrigin().y() + offset.getY() + 64,
|
||||
mapContent.getOrigin().z() - mapContent.getMaximumPoint().z() + offset.getZ()+1
|
||||
);
|
||||
highestPoint = new Vector(
|
||||
mapContent.getOrigin().x() - mapContent.getMinimumPoint().x() + offset.getX()-1,
|
||||
lowestPoint.getY() + mapContent.getDimensions().y() - 1,
|
||||
mapContent.getOrigin().z() - mapContent.getMinimumPoint().z() + offset.getZ()
|
||||
);
|
||||
|
||||
Operations.complete(operation);
|
||||
editSession.close();
|
||||
|
||||
return world;
|
||||
}
|
||||
catch (IOException | WorldEditException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package org.ef3d0c3e.sheepwars.maps;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.ef3d0c3e.sheepwars.SheepWars;
|
||||
import org.ef3d0c3e.sheepwars.Util;
|
||||
import org.ef3d0c3e.sheepwars.player.CPlayer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MapManager {
|
||||
/**
|
||||
* Gets the map folder
|
||||
* @return Gets folder where maps are stored
|
||||
*/
|
||||
public static File getMapFolder()
|
||||
{
|
||||
return new File(SheepWars.getPlugin().getDataFolder().getAbsolutePath() + "/maps");
|
||||
}
|
||||
|
||||
/**
|
||||
* All the discovered maps
|
||||
*/
|
||||
private static HashMap<String, Map> mapList = null;
|
||||
/**
|
||||
* All the votes
|
||||
*/
|
||||
private static HashMap<CPlayer, Map> mapVotes = null;
|
||||
|
||||
public static @Nullable Map getMap(final String name) {
|
||||
return mapList.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads maps from disk
|
||||
*/
|
||||
public static void reloadMaps()
|
||||
{
|
||||
mapList = new HashMap<>();
|
||||
mapVotes = new HashMap<>();
|
||||
File dir = getMapFolder();
|
||||
for (final File file : dir.listFiles())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!file.getName().endsWith(".yml"))
|
||||
continue;
|
||||
|
||||
final String name = file.getName().substring(0, file.getName().lastIndexOf(".yml"));
|
||||
|
||||
final File schematic = new File(file.getParentFile().getAbsolutePath() + "/" + name + ".schem");
|
||||
if (!schematic.exists())
|
||||
throw new FileNotFoundException();
|
||||
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
Map map = new Map();
|
||||
map.name = name;
|
||||
map.displayName = config.getString("displayname");
|
||||
map.icon = Material.getMaterial(config.getString("icon"));
|
||||
map.schematic = schematic;
|
||||
|
||||
map.offset = Util.parseVector(config.getString("offset"));
|
||||
map.limboBegin = config.getInt("limbo-begin");
|
||||
map.limboEnd = config.getInt("limbo-end");
|
||||
map.worldTime = config.getInt("world-time");
|
||||
map.lowestWool = Util.parseVector(config.getString("bonus-lowest"));
|
||||
map.highestWool = Util.parseVector(config.getString("bonus-highest"));
|
||||
map.redSpawns = new ArrayList<>();
|
||||
for (final String spawn : config.getStringList("spawns.red"))
|
||||
map.redSpawns.add(Util.parseVector(spawn));
|
||||
map.redYaw = (float)config.getDouble("yaw.red");
|
||||
|
||||
map.blueSpawns = new ArrayList<>();
|
||||
for (final String spawn : config.getStringList("spawns.blue"))
|
||||
map.blueSpawns.add(Util.parseVector(spawn));
|
||||
map.blueYaw = (float)config.getDouble("yaw.blue");
|
||||
|
||||
mapList.put(name, map);
|
||||
SheepWars.consoleMessage("Added map '" + name + "'");
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.ef3d0c3e.sheepwars.maps;
|
||||
|
||||
public class VoteItem {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.ef3d0c3e.sheepwars.maps;
|
||||
|
||||
public class VoteMenu {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.ef3d0c3e.sheepwars.maps;
|
||||
|
||||
public class VoteNPC {
|
||||
}
|
|
@ -31,6 +31,20 @@ public abstract class PlayerNPC
|
|||
private final UUID uniqueId;
|
||||
@Getter
|
||||
private final int networkId;
|
||||
@Getter
|
||||
private final HashMap<CPlayer, Long> lastInteracted;
|
||||
|
||||
public long lastInteracted(@NonNull CPlayer cp) {
|
||||
final Object last = lastInteracted.get(cp);
|
||||
if (last == null)
|
||||
return 0;
|
||||
else
|
||||
return (long)last;
|
||||
}
|
||||
|
||||
public void setLastInteracted(@NonNull CPlayer cp) {
|
||||
lastInteracted.put(cp, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -40,6 +54,7 @@ public abstract class PlayerNPC
|
|||
{
|
||||
uniqueId = UUID.randomUUID();
|
||||
this.networkId = networkId;
|
||||
lastInteracted = new HashMap<>();
|
||||
}
|
||||
|
||||
protected abstract @NonNull String getName();
|
||||
|
|
|
@ -12,6 +12,8 @@ import org.ef3d0c3e.sheepwars.SheepWars;
|
|||
import org.ef3d0c3e.sheepwars.events.CPlayerJoinEvent;
|
||||
import org.ef3d0c3e.sheepwars.events.CPlayerQuitEvent;
|
||||
import org.ef3d0c3e.sheepwars.events.WantsListen;
|
||||
import org.ef3d0c3e.sheepwars.kits.Kit;
|
||||
import org.ef3d0c3e.sheepwars.kits.KitData;
|
||||
import org.ef3d0c3e.sheepwars.locale.Locale;
|
||||
import org.ef3d0c3e.sheepwars.teams.Team;
|
||||
|
||||
|
@ -159,6 +161,18 @@ public class CPlayer {
|
|||
this.team = team;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player's kit
|
||||
*/
|
||||
@Getter
|
||||
private Kit kit = null;
|
||||
/**
|
||||
* Data for the player's kit
|
||||
* May not be null if kit is not null!
|
||||
*/
|
||||
@Getter
|
||||
private KitData kitData = null;
|
||||
|
||||
/**
|
||||
* Events for the player wrapper
|
||||
* When a player joins or quits
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
package org.ef3d0c3e.sheepwars.player;
|
||||
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.ef3d0c3e.sheepwars.events.CPlayerJoinEvent;
|
||||
import org.ef3d0c3e.sheepwars.events.SkinChangeEvent;
|
||||
import org.ef3d0c3e.sheepwars.events.WantsListen;
|
||||
import org.ef3d0c3e.sheepwars.player.skin.Skin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.text.MessageFormat;
|
||||
|
@ -54,8 +59,24 @@ public class CosmeticManager {
|
|||
public static class Events implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onChat(final AsyncPlayerChatEvent ev)
|
||||
public void onChat(final AsyncChatEvent ev)
|
||||
{
|
||||
ev.renderer((player, displayName, message, viewer) -> {
|
||||
final CPlayer cp = CPlayer.get(ev.getPlayer());
|
||||
|
||||
if (cp.getTeam() == null) {
|
||||
return displayName.color(TextColor.color(220, 220, 240))
|
||||
.append(Component.text(": ").color(TextColor.color(95, 95, 95)))
|
||||
.append(message.color(TextColor.color(187, 187, 187)));
|
||||
} else {
|
||||
return cp.getTeam().getColoredName(cp)
|
||||
.append(Component.text(" | ").color(cp.getTeam().getColor()))
|
||||
.append(displayName.color(TextColor.color(220, 220, 240)))
|
||||
.append(Component.text(": ").color(TextColor.color(95, 95, 95)))
|
||||
.append(message.color(TextColor.color(187, 187, 187)));
|
||||
}
|
||||
});
|
||||
/*
|
||||
if (ev.isCancelled()) return;
|
||||
|
||||
ev.setCancelled(true);
|
||||
|
@ -68,7 +89,9 @@ public class CosmeticManager {
|
|||
message = MessageFormat.format("{0} | {1}§8:§7 {2}", cp.getTeam().getName(cp), cp.getHandle().getName(), ev.getMessage());
|
||||
}
|
||||
|
||||
Bukkit.spigot().bro
|
||||
Bukkit.broadcastMessage(message);
|
||||
*/
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
|
|
|
@ -10,7 +10,9 @@ import net.kyori.adventure.text.Component;
|
|||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.ef3d0c3e.sheepwars.events.CPlayerJoinEvent;
|
||||
import org.ef3d0c3e.sheepwars.events.TeamChangeEvent;
|
||||
|
@ -26,12 +28,16 @@ public abstract class Team {
|
|||
private final ChatColor chatColor;
|
||||
@Getter
|
||||
private final TextColor color;
|
||||
@Getter
|
||||
private final Material banner;
|
||||
|
||||
private HashSet<CPlayer> players;
|
||||
|
||||
private Team(final ChatColor chatColor, final TextColor color)
|
||||
private Team(final ChatColor chatColor, final TextColor color, final Material banner)
|
||||
{
|
||||
this.chatColor = chatColor;
|
||||
this.color = color;
|
||||
this.banner = banner;
|
||||
players = new HashSet<>();
|
||||
}
|
||||
|
||||
|
@ -84,14 +90,14 @@ public abstract class Team {
|
|||
Bukkit.getPluginManager().callEvent(new TeamChangeEvent(cp, oldTeam, team));
|
||||
}
|
||||
|
||||
public static Team RED = new Team(ChatColor.RED, TextColor.color(255, 0, 0)) {
|
||||
public static Team RED = new Team(ChatColor.RED, TextColor.color(255, 0, 0), Material.RED_BANNER) {
|
||||
@Override
|
||||
public String getName(CPlayer cp) {
|
||||
return cp.getLocale().TEAM_RED;
|
||||
}
|
||||
};
|
||||
|
||||
public static Team BLUE = new Team(ChatColor.BLUE, TextColor.color(0, 0, 255)) {
|
||||
public static Team BLUE = new Team(ChatColor.BLUE, TextColor.color(0, 0, 255), Material.BLUE_BANNER) {
|
||||
@Override
|
||||
public String getName(CPlayer cp) {
|
||||
return cp.getLocale().TEAM_BLUE;
|
||||
|
@ -101,7 +107,7 @@ public abstract class Team {
|
|||
@WantsListen(phase = WantsListen.Target.Lobby)
|
||||
public static class Events implements Listener
|
||||
{
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onJoin(final CPlayerJoinEvent ev)
|
||||
{
|
||||
if (RED.count() < BLUE.count())
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package org.ef3d0c3e.sheepwars.teams;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.ef3d0c3e.sheepwars.Util;
|
||||
import org.ef3d0c3e.sheepwars.items.IItem;
|
||||
import org.ef3d0c3e.sheepwars.items.ItemFactory;
|
||||
import org.ef3d0c3e.sheepwars.player.CPlayer;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
public class TeamItem extends IItem {
|
||||
public TeamItem()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onInteract(final Player p, final ItemStack item, final Action action, final EquipmentSlot hand, final Block clicked, final BlockFace face)
|
||||
{
|
||||
final CPlayer cp = CPlayer.get(p);
|
||||
if (cp.getTeam() == Team.RED) {
|
||||
Team.setPlayerTeam(cp, Team.BLUE);
|
||||
} else {
|
||||
Team.setPlayerTeam(cp, Team.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onDrop(final Player p, final ItemStack item) { return true; }
|
||||
|
||||
static final public TeamItem ITEM = new TeamItem();
|
||||
/**
|
||||
* Gets item for player
|
||||
* @param cp Player to get item for
|
||||
* @return Item
|
||||
*/
|
||||
public static @NonNull ItemStack getItem(final CPlayer cp)
|
||||
{
|
||||
final ItemStack item = new ItemStack(cp.getTeam().getBanner());
|
||||
final ItemMeta meta = item.getItemMeta();
|
||||
if (cp.getTeam() == null)
|
||||
meta.setDisplayName(MessageFormat.format("§a{0} §7{1}", cp.getLocale().ITEMS_TEAM, cp.getLocale().ITEMS_RIGHTCLICK));
|
||||
else
|
||||
meta.setDisplayName(MessageFormat.format("§a{0}§8 : {1} §7{2}", cp.getLocale().ITEMS_TEAM, cp.getTeam().getColoredName(cp), cp.getLocale().ITEMS_RIGHTCLICK));
|
||||
meta.setLore(Util.coloredLore("§7", cp.getLocale().ITEMS_TEAMLORE));
|
||||
item.setItemMeta(meta);
|
||||
|
||||
ItemFactory.registerItem(ITEM);
|
||||
return ITEM.apply(item);
|
||||
}
|
||||
|
||||
}
|
|
@ -31,12 +31,12 @@ public class TeamNPC extends PlayerNPC {
|
|||
|
||||
@Override
|
||||
protected @NonNull String getName() {
|
||||
return "skin";
|
||||
return "team";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull List<Component> getNametag(@NonNull CPlayer cp) {
|
||||
if (cp.getCosmetics().getCurrentSkin() == null)
|
||||
if (cp.getTeam() == null) // May not happen in lobby mode
|
||||
return Lists.newArrayList(
|
||||
Component.text(cp.getLocale().TEAM_NPCNAME)
|
||||
.color(TextColor.color(207, 50, 200))
|
||||
|
@ -49,8 +49,7 @@ public class TeamNPC extends PlayerNPC {
|
|||
Component.text(cp.getLocale().TEAM_NPCCURRENT)
|
||||
.color(TextColor.color(85, 85, 127))
|
||||
.decorate(TextDecoration.UNDERLINED),
|
||||
Component.text(cp.getCosmetics().getCurrentSkin().getName())
|
||||
.color(TextColor.color(180, 85, 120))
|
||||
cp.getTeam().getColoredName(cp)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -76,6 +75,9 @@ public class TeamNPC extends PlayerNPC {
|
|||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (System.currentTimeMillis() - lastInteracted(cp) < 1000)
|
||||
return;
|
||||
|
||||
if (!cp.isOnline()) return;
|
||||
|
||||
if (cp.getTeam() == Team.RED) {
|
||||
|
@ -83,6 +85,8 @@ public class TeamNPC extends PlayerNPC {
|
|||
} else {
|
||||
Team.setPlayerTeam(cp, Team.RED);
|
||||
}
|
||||
|
||||
setLastInteracted(cp);
|
||||
}
|
||||
}.runTask(SheepWars.getPlugin());
|
||||
}
|
||||
|
|
BIN
core/src/main/resources/exports/maps/blimp.schem
Normal file
BIN
core/src/main/resources/exports/maps/blimp.schem
Normal file
Binary file not shown.
24
core/src/main/resources/exports/maps/blimp.yml
Normal file
24
core/src/main/resources/exports/maps/blimp.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
displayname: Dirigeables
|
||||
offset: 0 24 0
|
||||
icon: WHITE_WOOL
|
||||
limbo-begin: 63
|
||||
limbo-end: 60
|
||||
world-time: 6000
|
||||
bonus-lowest: -17 83 -4
|
||||
bonus-highest: 17 94 4
|
||||
spawns:
|
||||
red:
|
||||
- -15.5 84 -15.5
|
||||
- 12.5 84 14.5
|
||||
- 0.5 90 -15.5
|
||||
- 37.5 101 -1.5
|
||||
- -5.5 97 -15.5
|
||||
blue:
|
||||
- 16.5 84 15.5
|
||||
- -11.5 84 14.5
|
||||
- 0.5 90 15.5
|
||||
- 38.5 101 1.5
|
||||
- 6.5 97 15.5
|
||||
yaw:
|
||||
red: 0
|
||||
blue: 180
|
BIN
core/src/main/resources/exports/maps/flying.schem
Normal file
BIN
core/src/main/resources/exports/maps/flying.schem
Normal file
Binary file not shown.
28
core/src/main/resources/exports/maps/flying.yml
Normal file
28
core/src/main/resources/exports/maps/flying.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
displayname: Machines Volantes
|
||||
offset: 0 20 0
|
||||
icon: OAK_PLANKS
|
||||
limbo-begin: 63
|
||||
limbo-end: 60
|
||||
world-time: 6000
|
||||
bonus-lowest: -12 83 -6
|
||||
bonus-highest: 12 93 8
|
||||
spawns:
|
||||
red:
|
||||
- -20.5 80.5 -18.5
|
||||
- -19.5 76 -18.5
|
||||
- 2.5 78.5 -21.5
|
||||
- 7.5 77 -18.5
|
||||
- -3.5 72.5 -18.5
|
||||
- 0.5 69 -10.5
|
||||
- 16.5 79.5 -18.5
|
||||
blue:
|
||||
- 21.5 80.5 21.5
|
||||
- 20.5 76 21.5
|
||||
- -1.5 78.5 24.5
|
||||
- 4.5 77 21.5
|
||||
- 7.5 72.5 21.5
|
||||
- 1.5 69 13.5
|
||||
- 15.5 79.5 21.5
|
||||
yaw:
|
||||
red: 0
|
||||
blue: 180
|
BIN
core/src/main/resources/exports/maps/oilrig.schem
Normal file
BIN
core/src/main/resources/exports/maps/oilrig.schem
Normal file
Binary file not shown.
26
core/src/main/resources/exports/maps/oilrig.yml
Normal file
26
core/src/main/resources/exports/maps/oilrig.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
displayname: Plateforme Pétrolière
|
||||
offset: 0 0 0
|
||||
icon: IRON_BLOCK
|
||||
limbo-begin: 69
|
||||
limbo-end: 63
|
||||
world-time: 6000
|
||||
bonus-lowest: -1 89 -4
|
||||
bonus-highest: 9 97 10
|
||||
spawns:
|
||||
red:
|
||||
- -14.5 88 16.5
|
||||
- -27.5 88 0.5
|
||||
- -24.5 89 -12.5
|
||||
- -27.5 103 0.5
|
||||
- -21.5 99 -12.5
|
||||
- -10.5 83.0625 18.5
|
||||
blue:
|
||||
- 20.5 88 -9.5
|
||||
- 33.5 88 6.5
|
||||
- 30.5 89 19.5
|
||||
- 33.5 103 6.5
|
||||
- 27.5 99 19.5
|
||||
- 16.5 83.0625 -11.5
|
||||
yaw:
|
||||
red: -90
|
||||
blue: 90
|
Loading…
Reference in a new issue