13
0

TeamHalle #6

Zusammengeführt
Lixfel hat 16 Commits von TeamHalle nach master 2022-03-26 16:28:22 +01:00 zusammengeführt
2 geänderte Dateien mit 49 neuen und 14 gelöschten Zeilen
Nur Änderungen aus Commit 7d150d24e1 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -3,6 +3,10 @@ TIME = HH:mm:ss
DATE=........ DATE=........
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===--- COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
# ServerTeamNPC's
NPC_CHAT_1 = §fHallo, ich bin {0} und habe den Rang {1}.
NPC_CHAT_2 = §fWillkommen auf §eSteam§8War§f, viel Spaß dir.
# Portal Command # Portal Command
PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Listet alle Portale auf PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Listet alle Portale auf
PORTAL_COMMAND_ADD_HELP = §8/§7portal §ecreate §8[§7PortalType§8] §8[§7PortalName§8] §8- §7Fügt ein Portal hinzu PORTAL_COMMAND_ADD_HELP = §8/§7portal §ecreate §8[§7PortalType§8] §8[§7PortalName§8] §8- §7Fügt ein Portal hinzu

Datei anzeigen

@ -29,10 +29,13 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager; import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityInteractEvent; import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@ -43,20 +46,6 @@ import java.util.stream.Collectors;
public class TeamPlayer extends BasicListener { public class TeamPlayer extends BasicListener {
@AllArgsConstructor
private static class Cuboid {
private double x1;
private double y1;
private double z1;
private double x2;
private double y2;
private double z2;
public boolean contains(Location location) {
return location.getX() >= x1 && location.getX() <= x2 && location.getY() >= y1 && location.getY() <= y2 && location.getZ() >= z1 && location.getZ() <= z2;
}
}
private static final List<Cuboid> cuboids = new ArrayList<>(); private static final List<Cuboid> cuboids = new ArrayList<>();
static { static {
@ -70,6 +59,15 @@ public class TeamPlayer extends BasicListener {
private static final World world = Bukkit.getWorlds().get(0); private static final World world = Bukkit.getWorlds().get(0);
private static final Map<String, NPC> entities = new HashMap<>(); private static final Map<String, NPC> entities = new HashMap<>();
private Set<Player> players = new HashSet<>();
private Random random = new Random();
private List<String> strings = new ArrayList<>();
{
strings.add("NPC_CHAT_1");
strings.add("NPC_CHAT_2");
}
public static void spawnTeamPlayer(World world, SteamwarUser steamwarUser) { public static void spawnTeamPlayer(World world, SteamwarUser steamwarUser) {
Location location = new Location(world, 1524.5, 52, 1484.5); Location location = new Location(world, 1524.5, 52, 1484.5);
String name = steamwarUser.getUserName(); String name = steamwarUser.getUserName();
@ -157,6 +155,25 @@ public class TeamPlayer extends BasicListener {
return false; return false;
} }
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (!(event.getRightClicked() instanceof Villager)) {
return;
}
if (!players.add(event.getPlayer())) {
players.remove(event.getPlayer());
return;
}
SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName());
String message = strings.get(random.nextInt(strings.size()));
LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), user.getUserGroup().getColorCode() + user.getUserGroup().name());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
players.remove(event.getPlayer());
}
@EventHandler @EventHandler
public void onEntityInteract(EntityInteractEvent event) { public void onEntityInteract(EntityInteractEvent event) {
if (event.getEntityType() == EntityType.VILLAGER) { if (event.getEntityType() == EntityType.VILLAGER) {
@ -170,4 +187,18 @@ public class TeamPlayer extends BasicListener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@AllArgsConstructor
private static class Cuboid {
private double x1;
private double y1;
private double z1;
private double x2;
private double y2;
private double z2;
public boolean contains(Location location) {
return location.getX() >= x1 && location.getX() <= x2 && location.getY() >= y1 && location.getY() <= y2 && location.getZ() >= z1 && location.getZ() <= z2;
}
}
} }