Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)

IntelliJ Code Format

+34 -32
+1 -2
src/main/java/com/legacyminecraft/poseidon/PoseidonConfig.java
··· 144 144 generateConfigOption("world.settings.mob-spawner-area-limit.enable", true); 145 145 generateConfigOption("world.settings.mob-spawner-area-limit.limit", 150); 146 146 generateConfigOption("world.settings.mob-spawner-area-limit.chunk-radius", 8); 147 - generateConfigOption("world.settings.mob-spawner-area-limit.info", 148 - "This setting controls the maximum number of entities of a mob spawner type that can exist within the defined chunk radius around a mob spawner. If the number of entities exceeds this limit, the spawner will stop spawning additional entities of that type. This is useful to stop the extreme lag that can be caused by mob spawners."); 147 + generateConfigOption("world.settings.mob-spawner-area-limit.info", "This setting controls the maximum number of entities of a mob spawner type that can exist within the defined chunk radius around a mob spawner. If the number of entities exceeds this limit, the spawner will stop spawning additional entities of that type. This is useful to stop the extreme lag that can be caused by mob spawners."); 149 148 150 149 151 150 //generateConfigOption("world-settings.eject-from-vehicle-on-teleport.enabled", true);
+7 -7
src/main/java/com/legacyminecraft/poseidon/util/ServerLogRotator.java
··· 27 27 28 28 /** 29 29 * Checks if the date in the log line is today's date 30 + * 30 31 * @param date The date in the log line. Format: "yyyy-MM-dd" 31 32 * @return True if the date in the log line is today's date, false otherwise 32 33 */ 33 34 private boolean isToday(String date) { 34 - String[] dateParts = date.split("-"); 35 + String[] dateParts = date.split("-"); 35 36 LocalDateTime logLineDateTime = LocalDateTime.of(Integer.parseInt(dateParts[0]), Integer.parseInt(dateParts[1]), Integer.parseInt(dateParts[2]), 0, 0, 0); 36 37 LocalDateTime now = LocalDateTime.now(); 37 38 return logLineDateTime.getYear() == now.getYear() && logLineDateTime.getMonthValue() == now.getMonthValue() && logLineDateTime.getDayOfMonth() == now.getDayOfMonth(); ··· 39 40 40 41 /** 41 42 * Archives a log line to a log file with the same date as the date in the log line 43 + * 42 44 * @param parts The log line to archive to a log file haven been split already e.g. ["2024-03-20", "13:02:27", "[INFO]", "This is a log message..."] 43 45 */ 44 46 private void archiveLine(String[] parts) { ··· 60 62 writer.println(date + " " + time + " " + logLevel + " " + message); 61 63 writer.close(); 62 64 63 - // catch any exceptions that occur during the process, and log them. IOExceptions are possible when calling createNewFile() 65 + // catch any exceptions that occur during the process, and log them. IOExceptions are possible when calling createNewFile() 64 66 } catch (IOException e) { 65 67 logger.log(Level.SEVERE, "[Poseidon] Failed to create new log file!"); 66 68 logger.log(Level.SEVERE, e.toString()); ··· 120 122 121 123 logger.log(Level.INFO, "[Poseidon] Logs built from latest.log!"); 122 124 123 - // catch any exceptions that occur during the process, and log them 125 + // catch any exceptions that occur during the process, and log them 124 126 } catch (Exception e) { 125 127 logger.log(Level.SEVERE, "[Poseidon] Failed to build logs from latest.log!"); 126 128 logger.log(Level.SEVERE, e.toString()); ··· 131 133 // Calculate the initial delay and period for the log rotation task 132 134 ZonedDateTime now = ZonedDateTime.now(); 133 135 ZonedDateTime nextRun = now.withHour(0).withMinute(0).withSecond(0).withNano(0); 134 - if(now.compareTo(nextRun) > 0) 135 - nextRun = nextRun.plusDays(1); 136 + if (now.compareTo(nextRun) > 0) nextRun = nextRun.plusDays(1); 136 137 Duration duration = Duration.between(now, nextRun); 137 138 long initialDelay = duration.getSeconds(); 138 139 long period = TimeUnit.DAYS.toSeconds(1); ··· 142 143 143 144 // Schedule the log rotation task to run every day at midnight offset by one second to avoid missing logs 144 145 logger.log(Level.INFO, "[Poseidon] Log rotation task scheduled for run in " + initialDelay + " seconds, and then every " + period + " seconds."); 145 - logger.log(Level.INFO, "[Poseidon] If latest.log contains logs from earlier, not previously archived dates, they will be archived to the appropriate log files " + 146 - "upon first run of the log rotation task. If log files already exist for these dates, the logs will be appended to the existing log files!"); 146 + logger.log(Level.INFO, "[Poseidon] If latest.log contains logs from earlier, not previously archived dates, they will be archived to the appropriate log files " + "upon first run of the log rotation task. If log files already exist for these dates, the logs will be appended to the existing log files!"); 147 147 Bukkit.getScheduler().scheduleAsyncRepeatingTask(new PoseidonPlugin(), this::buildHistoricalLogsFromLatestLogFile, (initialDelay + 1) * 20, period * 20); 148 148 } 149 149 }
+1 -1
src/main/java/com/legacyminecraft/poseidon/uuid/ThreadUUIDFetcher.java
··· 46 46 loginProcessHandler.userUUIDReceived(uuidResult.getUuid(), true); 47 47 return; 48 48 } else if (uuidResult.getReturnType().equals(UUIDResult.ReturnType.ONLINE)) { 49 - if(PoseidonConfig.getInstance().getConfigBoolean("settings.uuid-fetcher.get.enforce-case-sensitivity.enabled")) { 49 + if (PoseidonConfig.getInstance().getConfigBoolean("settings.uuid-fetcher.get.enforce-case-sensitivity.enabled")) { 50 50 System.out.println("[Poseidon] Fetched UUID from Mojang for " + loginPacket.name + " using GET - " + uuidResult.getUuid().toString() + " however, the username returned was " + uuidAndUsernameResult.getReturnedUsername() + ". The user has been kicked as the server is configured to use case sensitive usernames"); 51 51 loginProcessHandler.cancelLoginProcess(ChatColor.RED + "Sorry, that username has invalid casing"); 52 52 return;
+5 -5
src/main/java/net/minecraft/server/Block.java
··· 313 313 if (world.random.nextFloat() < f) { 314 314 //Project Poseidon Start - New way to handle block drops to allow for plugins to know what items a block will drop 315 315 Optional<List<ItemStack>> items = getDrops(world, i, j, k, l); 316 - if(items.isPresent()) { 317 - for(ItemStack item : items.get()) { 316 + if (items.isPresent()) { 317 + for (ItemStack item : items.get()) { 318 318 this.a(world, i, j, k, item); 319 319 } 320 320 } ··· 325 325 } 326 326 327 327 //Project Poseidon - API to get the drops of a block 328 - public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data){ 328 + public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data) { 329 329 int id = this.a(data, world.random); 330 - if(id <= 0){ 330 + if (id <= 0) { 331 331 return Optional.empty(); 332 - }else{ 332 + } else { 333 333 return Optional.of(Arrays.asList(new ItemStack(id, 1, this.a_(data)))); 334 334 } 335 335 }
+2 -2
src/main/java/net/minecraft/server/BlockBed.java
··· 195 195 return null; 196 196 } 197 197 198 - public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data){ 199 - if(!d(data)){ 198 + public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data) { 199 + if (!d(data)) { 200 200 return super.getDrops(world, x, y, z, data); 201 201 } 202 202 return Optional.empty();
+3 -3
src/main/java/net/minecraft/server/BlockCrops.java
··· 89 89 return this.textureId + j; 90 90 } 91 91 92 - public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data){ 92 + public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data) { 93 93 Optional<List<ItemStack>> ret = super.getDrops(world, x, y, z, data); 94 94 List<ItemStack> stacks = ret.orElse(new ArrayList<>(3)); 95 - for(int i = 0; i < 3; i++){ 96 - if(world.random.nextInt(15) <= 1){ 95 + for (int i = 0; i < 3; i++) { 96 + if (world.random.nextInt(15) <= 1) { 97 97 stacks.add(new ItemStack(Item.SEEDS)); 98 98 } 99 99 }
+3 -3
src/main/java/net/minecraft/server/BlockPistonMoving.java
··· 58 58 } 59 59 60 60 61 - public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data){ 61 + public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data) { 62 62 TileEntityPiston tileentitypiston = this.b(world, x, y, z); 63 - if(tileentitypiston != null){ 63 + if (tileentitypiston != null) { 64 64 return Block.byId[tileentitypiston.a()].getDrops(world, x, y, z, tileentitypiston.e()); 65 - }else{ 65 + } else { 66 66 return Optional.empty(); 67 67 } 68 68 }
+1 -1
src/main/java/net/minecraft/server/BlockStairs.java
··· 123 123 this.a.remove(world, i, j, k); 124 124 } 125 125 126 - public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data){ 126 + public Optional<List<ItemStack>> getDrops(World world, int x, int y, int z, int data) { 127 127 return this.a.getDrops(world, x, y, z, data); 128 128 } 129 129
+1 -2
src/main/java/net/minecraft/server/MinecraftServer.java
··· 522 522 if (currentTime - lastTick >= 1000) { 523 523 double tps = tickCount / ((currentTime - lastTick) / 1000.0); 524 524 tpsRecords.addFirst(tps); 525 - if(tpsRecords.size() > 900) { //Don't keep more than 15 minutes of data 525 + if (tpsRecords.size() > 900) { //Don't keep more than 15 minutes of data 526 526 tpsRecords.removeLast(); 527 527 } 528 528 ··· 531 531 } 532 532 533 533 //Project Poseidon End - Tick Update 534 - 535 534 536 535 537 536 for (j = 0; j < this.worlds.size(); ++j) { // CraftBukkit
+1 -1
src/main/java/net/minecraft/server/TileEntityMobSpawner.java
··· 78 78 } 79 79 80 80 //Poseidon Start - Ensure the mob cound of the specific type of mob is under the defined limit within the area 81 - if(poseidonAreaLimit) { 81 + if (poseidonAreaLimit) { 82 82 double chunkSize = 16.0D; 83 83 AxisAlignedBB searchArea = AxisAlignedBB.b(this.x - poseidonChunkRadius * chunkSize, 0.0D, this.z - poseidonChunkRadius * chunkSize, this.x + poseidonChunkRadius * chunkSize, 128, this.z + poseidonChunkRadius * chunkSize); 84 84 List<Entity> existingEntities = this.world.a(entityliving.getClass(), searchArea);
+1 -1
src/main/java/org/bukkit/ChatColor.java
··· 127 127 /** 128 128 * Translates alternate color codes in the given text to Minecraft color codes. 129 129 * 130 - * @param altColorChar The character used to denote color codes '&'. 130 + * @param altColorChar The character used to denote color codes '&'. 131 131 * @param textToTranslate The text containing the alternate color codes. 132 132 * @return The text with the alternate color codes replaced by Minecraft color codes. 133 133 */
+4
src/main/java/org/bukkit/block/Block.java
··· 285 285 286 286 /** 287 287 * Returns a list of items which would drop by destroying this block 288 + * 288 289 * @return a list of dropped items for this type of block 289 290 */ 290 291 Collection<ItemStack> getDrops(); 291 292 292 293 /** 293 294 * Returns a list of items which would drop by destroying this block with a specific tool 295 + * 294 296 * @param tool The tool or item in hand used for digging 295 297 * @return a list of dropped items for this type of block 296 298 */ ··· 298 300 299 301 /** 300 302 * Breaks the block and spawns items as if a player had digged it regardless of the tool 303 + * 301 304 * @return true if the block was broken 302 305 */ 303 306 boolean breakNaturally(); 304 307 305 308 /** 306 309 * Breaks the block and spawns items as if a player had digged it 310 + * 307 311 * @param tool The tool or item in hand used for digging 308 312 * @return true if the block was broken 309 313 */
+1 -1
src/main/java/org/bukkit/command/SimpleCommandMap.java
··· 50 50 register("uberbukkit", new FlushInvCommand()); 51 51 register("uberbukkit", new UuidLookupCommand()); 52 52 register("uberbukkit", new CrackedAllowlistCommand()); 53 - 53 + 54 54 register("bukkit", new VersionCommand("version")); 55 55 register("bukkit", new ReloadCommand("reload")); 56 56 register("bukkit", new PluginsCommand("plugins"));
+3 -3
src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
··· 342 342 net.minecraft.server.Block block = net.minecraft.server.Block.byId[getTypeId()]; 343 343 if (block == null) { 344 344 return new ArrayList<ItemStack>(); 345 - } else if(block.material.i()) { 346 - return Arrays.asList(block.getDrops(((CraftWorld) this.getWorld()).getHandle(), x, y, z, (int)getData()).map((list) -> list.stream().map(itemStack -> new CraftItemStack(itemStack)).toArray(ItemStack[]::new)).orElse(new ItemStack[0])); 345 + } else if (block.material.i()) { 346 + return Arrays.asList(block.getDrops(((CraftWorld) this.getWorld()).getHandle(), x, y, z, (int) getData()).map((list) -> list.stream().map(itemStack -> new CraftItemStack(itemStack)).toArray(ItemStack[]::new)).orElse(new ItemStack[0])); 347 347 } else { 348 348 return new ArrayList<ItemStack>(); 349 349 } ··· 355 355 if (block == null) { 356 356 return new ArrayList<ItemStack>(); 357 357 } else if (block.material.i() || ((CraftItemStack) tool).getHandle().b(block)) { 358 - return Arrays.asList(block.getDrops(((CraftWorld) this.getWorld()).getHandle(), x, y, z, (int)getData()).map((list) -> list.stream().map(itemStack -> new CraftItemStack(itemStack)).toArray(ItemStack[]::new)).orElse(new ItemStack[0])); 358 + return Arrays.asList(block.getDrops(((CraftWorld) this.getWorld()).getHandle(), x, y, z, (int) getData()).map((list) -> list.stream().map(itemStack -> new CraftItemStack(itemStack)).toArray(ItemStack[]::new)).orElse(new ItemStack[0])); 359 359 } else { 360 360 return new ArrayList<ItemStack>(); 361 361 }