fpdhpily
대표칭호 없음
Pily7 db22eed523b6474c8d914cf21ee09eb5
이해도 | 초보자 |
---|---|
게임버전 (JE) | 1.16.5 |
게임버전 (BE) | 관련없음 |
package pily.emeraldrush; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; import java.util.HashMap; import java.util.Map; public class Emeraldrush extends JavaPlugin implements Listener { private Map<String, Location> teamSpawnPoints = new HashMap<>(); private Map<String, Location> teamProtectPoints = new HashMap<>(); private Map<String, Integer> teamLives = new HashMap<>(); private Map<String, Material> teamWoolColors = new HashMap<>(); private Map<String, Integer> teamEmeralds = new HashMap<>(); @Override public void onEnable() { try { synchronized (this) { wait(500); // 0.5초 기다리기 } if (getLogger() == null) { // getLogger()가 null이면 기본 로그를 사용하도록 수정 getLogger().severe("로거를 가져올 수 없어 플러그인을 비활성화합니다."); getServer().getPluginManager().disablePlugin(this); return; } getCommand("emeraldrush").setExecutor(new EmeraldRushCommand(this)); getServer().getPluginManager().registerEvents(this, this); getLogger().info("zl존 개쩌는 플러그인이 활성화되었습니다!"); } catch (Exception e) { e.printStackTrace(); } } private class EmeraldRushCommand implements CommandExecutor { private final Emeraldrush plugin; public EmeraldRushCommand(Emeraldrush plugin) { this.plugin = plugin; } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args){ if (!(sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "플레이어만 이 명령어를 사용할 수 있습니다."); return false; } Player player = (Player) sender; if (args.length == 2 && args[0].equalsIgnoreCase("start")) { startGame(); return true; } if (args.length < 4) { player.sendMessage(ChatColor.RED + "올바른 명령어 형식이 아닙니다."); return false; } String teamName = args[1].toLowerCase(); String action = args[0].toLowerCase(); double x = Double.parseDouble(args[2]); double y = Double.parseDouble(args[3]); double z = Double.parseDouble(args[4]); Location location = new Location(player.getWorld(), x, y, z); if (action.equals("emerald_spawn")) { teamSpawnPoints.put(teamName, location); player.sendMessage(ChatColor.GREEN + "에메랄드 스폰 지점이 설정되었습니다."); } else if (action.equals("team")) { handleTeamCommand(player, args); } else { player.sendMessage(ChatColor.RED + "올바른 명령어 형식이 아닙니다."); return false; } return true; } private void startGame() { // 게임 시작 로직 구현 for (Player player : getServer().getOnlinePlayers()) { preparePlayerForGame(player); } // 게임 시작 전 대기 시간 설정 getServer().getScheduler().runTaskLater(Emeraldrush.this, () -> { for (Player player : getServer().getOnlinePlayers()) { player.sendMessage("게임이 시작되었습니다!"); player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_GROWL, 1.0f, 1.0f); placeWoolBlocks(player); } }, 5 * 20L); // 5초 대기 (20 틱 = 1초) } private void preparePlayerForGame(Player player) { // 부활할 때 갑옷, 무기, 도구 설정 player.setGameMode(GameMode.SURVIVAL); player.setHealth(20); player.setFoodLevel(20); ItemStack sword = new ItemStack(Material.IRON_SWORD); ItemStack pickaxe = new ItemStack(Material.IRON_PICKAXE); ItemStack axe = new ItemStack(Material.IRON_AXE); ItemStack shears = new ItemStack(Material.SHEARS); ItemStack wool = new ItemStack(Material.WHITE_WOOL, 64); player.getInventory().clear(); // 인벤토리 초기화 player.getInventory().addItem(sword, pickaxe, axe, shears, wool); // 5초 동안 움직일 수 없도록 설정 player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5 * 20, 255, false, false)); // 팀 스폰 지점으로 이동 String teamName = getTeamName(player); Location spawnPoint = teamSpawnPoints.getOrDefault(teamName, player.getWorld().getSpawnLocation()); player.teleport(spawnPoint); // 5초 동안 대기하는 타이틀 표시 player.sendTitle("", "게임 시작까지 5초", 10, 70, 20); } private void placeWoolBlocks(Player player) { String teamName = getTeamName(player); Location protectPoint = teamProtectPoints.getOrDefault(teamName, player.getWorld().getSpawnLocation()); Material woolColor = teamWoolColors.getOrDefault(teamName, Material.WHITE_WOOL); protectPoint.getBlock().setType(woolColor); } private void handleTeamCommand(Player player, String[] args) { if (args.length < 5) { player.sendMessage(ChatColor.RED + "올바른 명령어 형식이 아닙니다."); return; } String teamName = args[1].toLowerCase(); String subCommand = args[2].toLowerCase(); double x = Double.parseDouble(args[3]); double y = Double.parseDouble(args[4]); double z = Double.parseDouble(args[5]); Location location = new Location(player.getWorld(), x, y, z); if (subCommand.equals("spawnpoint")) { teamSpawnPoints.put(teamName, location); player.sendMessage(ChatColor.GREEN + "스폰 지점이 설정되었습니다."); } else if (subCommand.equals("protectpoint")) { teamProtectPoints.put(teamName, location); player.sendMessage(ChatColor.GREEN + "보호 지점이 설정되었습니다."); } else { player.sendMessage(ChatColor.RED + "올바른 명령어 형식이 아닙니다."); } } private String getTeamName(Player player) { // 팀 이름을 가져오는 로직을 추가하세요. // 예: 플레이어의 팀 정보를 저장하는 플레이어 데이터 사용 return "Red"; // 임시로 Red를 반환 } } private String getTeamName(Player player) { // 플레이어의 팀 정보를 가져오는 로직을 추가하세요. // 여기에서는 teamWoolColors 맵을 사용하여 팀 이름을 가져오는 예시를 보여줍니다. for (Map.Entry<String, Material> entry : teamWoolColors.entrySet()) { if (player.getInventory().contains(entry.getValue())) { return entry.getKey(); } } // 팀을 찾지 못한 경우 기본값으로 "Unknown"을 반환합니다. return "Unknown"; } @EventHandler public void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); String teamName = getTeamName(player); if (isWoolBlock(event.getBlock().getType(), teamName)) { event.setCancelled(true); handleWoolBreak(player, event.getBlock().getLocation()); } } private boolean isWoolBlock(Material material, String teamName) { // 양털 블록이며 특정 팀에 해당하는지 확인하는 로직을 추가하세요. Material woolColor = teamWoolColors.get(teamName); return material == woolColor; } private void handleWoolBreak(Player player, Location woolLocation) { String teamName = getTeamName(player); int currentLives = teamLives.getOrDefault(teamName, 0); if (currentLives > 0) { // 플레이어의 팀 목숨이 0보다 큰 경우에만 부활 및 처리 respawnPlayer(player); player.sendMessage(ChatColor.RED + "팀 목숨이 감소했습니다. 부활하셨습니다."); // 애매랄드 생성 지점 로직 추가 spawnEmeralds(teamName); } else { // 플레이어의 팀 목숨이 0인 경우 처리 player.sendMessage(ChatColor.RED + "팀 목숨이 모두 소진되었습니다. 부활할 수 없습니다."); } woolLocation.getBlock().setType(Material.AIR); // 양털 블록 파괴 } private void respawnPlayer(Player player) { String teamName = getTeamName(player); Location spawnLocation = teamSpawnPoints.getOrDefault(teamName, player.getWorld().getSpawnLocation()); // 갑옷, 무기, 도구 설정 player.setGameMode(GameMode.SURVIVAL); player.setHealth(20); player.setFoodLevel(20); ItemStack sword = new ItemStack(Material.IRON_SWORD); ItemStack pickaxe = new ItemStack(Material.IRON_PICKAXE); ItemStack axe = new ItemStack(Material.IRON_AXE); ItemStack shears = new ItemStack(Material.SHEARS); ItemStack wool = new ItemStack(Material.WHITE_WOOL, 64); player.getInventory().clear(); // 인벤토리 초기화 player.getInventory().addItem(sword, pickaxe, axe, shears, wool); // 5초 동안 움직일 수 없도록 설정 player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5 * 20, 255, false, false)); // 팀 스폰 지점으로 이동 player.teleport(spawnLocation); // 5초 동안 대기하는 타이틀 표시 player.sendTitle("", "게임 시작까지 5초", 10, 70, 20); } private void spawnEmeraldAtLocation(Location location) { location.getBlock().setType(Material.EMERALD_BLOCK); } private void spawnEmeralds(String teamName) { Location emeraldSpawnLocation = teamProtectPoints.getOrDefault(teamName, null); if (emeraldSpawnLocation != null) { new BukkitRunnable() { @Override public void run() { // 추가된 null 체크 if (teamProtectPoints.containsKey(teamName)) { // 에메랄드 스폰 로직 spawnEmeraldAtLocation(emeraldSpawnLocation); } } }.runTaskTimer(this, 0, 30 * 20); // 30초 간격으로 스폰 } } }
name: Emeraldrush version: 1.0.0 main: pily.emeraldrush.Emeraldrush commands: emeraldrush: description: Your command description here usage: /emeraldrush [args]
왜 이런 오류가 나요? 선생님 구합니다 ㅠㅠ
작은거인
2024.01.121. 대체 wait는 왜한건가요.
2. getLogger()는 null일 수가 없습니다.
3. 오류 저렇게 보내지 말고 파일로 풀 로그 보내주세요.
fpdhpily
2024.01.12C:\Users\user\Desktop\minecraft server>java -Xms1G -Xmx1G -jar paper-1.16.5.jar
System Info: Java 11 (Eclipse OpenJ9 VM openj9-0.27.0) Host: Windows 10 10.0 (amd64)
Loading libraries, please wait...
[13:22:16 INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[13:22:17 INFO]: Reloading ResourceManager: Default, bukkit
[13:22:17 INFO]: Loaded 7 recipes
[13:22:20 INFO]: Starting minecraft server version 1.16.5
[13:22:20 INFO]: Loading properties
[13:22:21 INFO]: This server is running Paper version git-Paper-794 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
[13:22:21 INFO]: Using 4 threads for Netty based IO
[13:22:21 INFO]: Server Ping Player Sample Count: 12
[13:22:21 INFO]: Debug logging is disabled
[13:22:21 INFO]: Default game type: SURVIVAL
[13:22:21 INFO]: Generating keypair
[13:22:21 INFO]: Starting Minecraft server on *:25565
[13:22:21 INFO]: Using default channel type
[13:22:21 INFO]: [emeraldrush] Loading emeraldrush v1.0-SNAPSHOT
[13:22:22 INFO]: Server permissions file permissions.yml is empty, ignoring it
[13:22:22 INFO]: Preparing level "world"
[13:22:22 INFO]: Preparing start region for dimension minecraft:overworld
[13:22:22 INFO]: Preparing spawn area: 0%
[13:22:22 INFO]: Preparing spawn area: 0%
[13:22:22 INFO]: Time elapsed: 627 ms
[13:22:22 INFO]: Preparing start region for dimension minecraft:the_nether
[13:22:23 INFO]: Time elapsed: 183 ms
[13:22:23 INFO]: Preparing start region for dimension minecraft:the_end
[13:22:23 INFO]: Time elapsed: 94 ms
[13:22:23 INFO]: [emeraldrush] Enabling emeraldrush v1.0-SNAPSHOT
[13:22:23 WARN]: java.lang.NullPointerException
[13:22:23 WARN]: at pily.emeraldrush.Emeraldrush.onEnable(Emeraldrush.java:47)
[13:22:23 WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263)
[13:22:23 WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370)
[13:22:23 WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500)
[13:22:23 WARN]: at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518)
[13:22:23 WARN]: at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432)
[13:22:23 WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599)
[13:22:23 WARN]: at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298)
[13:22:23 WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074)
[13:22:23 WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291)
[13:22:23 WARN]: at net.minecraft.server.v1_16_R3.MinecraftServer$$Lambda$3136/0x0000000000000000.run(Unknown Source)
[13:22:23 WARN]: at java.base/java.lang.Thread.run(Thread.java:866)
[13:22:23 INFO]: Running delayed init tasks
[13:22:23 INFO]: Done (2.998s)! For help, type "help"
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] ************************************************************
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * WARNING - YOU ARE RUNNING AN OUTDATED VERSION OF JAVA.
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * PAPER WILL STOP BEING COMPATIBLE WITH THIS VERSION OF
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * JAVA WHEN MINECRAFT 1.17 IS RELEASED.
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] *
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * Please update the version of Java you use to run Paper
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * to at least Java 16. When Paper for Minecraft 1.17 is
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * released support for versions of Java before 16 will
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * be dropped.
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] *
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * Current Java version: 11.0.12
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] *
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * Check this forum post for more information:
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] * https://papermc.io/java16
[13:22:23 WARN]: [io.papermc.paper.util.PaperJvmChecker] ************************************************************
[13:22:23 INFO]: Timings Reset
>
이렇게 나왔습니다
작은거인
2024.01.12Emeraldrush.java:47