Skip to content

Commit

Permalink
Merge pull request #33 from notdevcody/master
Browse files Browse the repository at this point in the history
Create IntelliJ format action
  • Loading branch information
Moresteck authored Jan 6, 2024
2 parents 90283f4 + e2da663 commit 011f498
Show file tree
Hide file tree
Showing 475 changed files with 3,672 additions and 3,360 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: IntelliJ Format

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
formatting:
runs-on: ubuntu-latest
steps:
- if: github.event_name != 'pull_request'
uses: actions/checkout@v3
- if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@v3
- uses: notdevcody/intellij-format-action@v1
with:
include-glob: '*.java'
path: src/main/java/
10 changes: 5 additions & 5 deletions src/main/java/com/legacyminecraft/poseidon/PoseidonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void reload() {

public void resetConfig() {
// Delete all the config options
for(String key : this.getKeys()) {
for (String key : this.getKeys()) {
this.removeProperty(key);
}
// Reload the config
Expand Down Expand Up @@ -60,7 +60,7 @@ private void write() {

generateConfigOption("settings.fix-drowning-push-down.enabled", true);
generateConfigOption("settings.fix-drowning-push-down.info", "This setting fixes taking drowning damage pushing you down.");

generateConfigOption("settings.player-knockback-fix.enabled", true);
generateConfigOption("settings.player-knockback-fix.info", "This setting fixes reduced knockback for certain players on the server.");

Expand Down Expand Up @@ -142,7 +142,7 @@ private void write() {
generateConfigOption("version.worldgen.generate_tallgrass", true);
generateConfigOption("version.worldgen.ores.world.custom_seed", false);
generateConfigOption("version.worldgen.ores.world.seed", 0L);

generateConfigOption("version.mechanics.tile_grass_drop_seeds", false);
generateConfigOption("version.mechanics.flammable_fences_stairs", true);
generateConfigOption("version.mechanics.glowstone_pre1_6_6", false);
Expand Down Expand Up @@ -179,10 +179,10 @@ private void write() {
generateConfigOption("version.mechanics.pre_b1_5_block_placement_rules", false);
generateConfigOption("version.mechanics.trample_farmland_above_fence", false);
generateConfigOption("version.mechanics.seeds_replace_blocks", false);

generateConfigOption("version.mechanics.boats.drop_boat_not_wood", false);
generateConfigOption("version.mechanics.boats.break_boat_on_collision", true);

generateConfigOption("version.experimental.force_fix_chunk_coords_corruption", false);
generateConfigOption("version.allow_join.protocol", "14");
generateConfigOption("version.allow_join.info", "Specify client versions to accept (separated by commas - first PVN is treated as target PVN of the server)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
public class PoseidonPlugin implements Plugin {





@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
import com.google.gson.stream.JsonReader;

public class CrackedAllowlist {

private static CrackedAllowlist singleton;
private final Gson parser = new GsonBuilder().setPrettyPrinting().create();
private JsonArray namesJsonArray;
private File crackedListFile = new File("cracked-allowlist.json");

public CrackedAllowlist() {

if (!crackedListFile.exists()) {
namesJsonArray = new JsonArray();
saveAllowlist();
Expand All @@ -31,7 +31,7 @@ public CrackedAllowlist() {

try {
System.out.println("[Poseidon] Reading cracked-allowlist.json for Project Poseidon");

JsonReader reader = new JsonReader(new FileReader(crackedListFile));
namesJsonArray = parser.fromJson(reader, JsonArray.class);

Expand All @@ -49,7 +49,7 @@ public CrackedAllowlist() {
public void saveAllowlist() {
try {
System.out.println("[Poseidon] Saving cracked names allowlist");

Files.write(crackedListFile.toPath(), parser.toJson(namesJsonArray).getBytes("UTF-8"));
} catch (Throwable t) {
t.printStackTrace();
Expand All @@ -58,7 +58,7 @@ public void saveAllowlist() {

/**
* Adds username to cracked names allowlist.
*
*
* @param name username to allowlist
* @return true if added, false if already on the list
*/
Expand All @@ -67,15 +67,15 @@ public boolean addName(String name) {
if (namesJsonArray.contains(jsonString)) {
return false;
}

namesJsonArray.add(jsonString);
saveAllowlist();
return true;
}

/**
* Removes username from cracked names allowlist.
*
*
* @param name username to remove
* @return true if removed, false if the name wasn't on the list
*/
Expand All @@ -84,7 +84,7 @@ public boolean removeName(String name) {

boolean removed = namesJsonArray.remove(jsonString);
saveAllowlist();

return removed;
}

Expand All @@ -95,7 +95,8 @@ public boolean contains(String name) {
}

public List<String> getAsList() {
Type listType = new TypeToken<List<String>>() {}.getType();
Type listType = new TypeToken<List<String>>() {
}.getType();
return parser.fromJson(namesJsonArray, listType);
}

Expand Down
18 changes: 7 additions & 11 deletions src/main/java/com/legacyminecraft/poseidon/util/HTTPResponse.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
package com.legacyminecraft.poseidon.util;

public class HTTPResponse
{
public class HTTPResponse {
private String response;
private int responseCode;

public HTTPResponse(String response, int responseCode)
{

public HTTPResponse(String response, int responseCode) {
this.response = response;
this.responseCode = responseCode;
}

public String getResponse()
{

public String getResponse() {
return response;
}

public int getResponseCode()
{

public int getResponseCode() {
return responseCode;
}
}
24 changes: 9 additions & 15 deletions src/main/java/com/legacyminecraft/poseidon/util/SessionAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,23 @@

/**
* A wrapper class for the Minecraft session API
*
* <p>
* TODO maybe make the HTTP requests asynchronous? idk if it really matters
*
*
* @author moderator_man
*/
public class SessionAPI
{
public class SessionAPI {
public static final String SESSION_BASE = "http://session.minecraft.net/game/";

public static boolean hasJoined(String username, String serverId)
{
public static boolean hasJoined(String username, String serverId) {
HTTPResponse response = httpGetRequest(SESSION_BASE + String.format("checkserver.jsp?user=%s&serverId=%s", username, serverId));
if (response.getResponse() != "YES")
return false;
return true;
}

public static void hasJoined(String username, String serverId, String ip, SessionRequestRunnable callback)
{
try
{
public static void hasJoined(String username, String serverId, String ip, SessionRequestRunnable callback) {
try {
boolean checkIP = ip == "127.0.0.1" || ip == "localhost";
StringBuilder sb = new StringBuilder();
sb.append("https://sessionserver.mojang.com/session/minecraft/hasJoined");
Expand All @@ -39,7 +35,7 @@ public static void hasJoined(String username, String serverId, String ip, Sessio
if (checkIP)
sb.append("&ip=" + ip);
String requestUrl = sb.toString();

HTTPResponse response = httpGetRequest(requestUrl);
JSONObject obj = (JSONObject) new JSONParser().parse(response.getResponse());
String res_username = (obj.containsKey("name") ? (String) obj.get("name") : "nousername");
Expand All @@ -52,10 +48,8 @@ public static void hasJoined(String username, String serverId, String ip, Sessio
}
}

private static HTTPResponse httpGetRequest(String url)
{
try
{
private static HTTPResponse httpGetRequest(String url) {
try {
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("GET");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.legacyminecraft.poseidon.util;

public interface SessionRequestRunnable
{
public interface SessionRequestRunnable {
public void callback(int responseCode, String username, String uuid, String ip);
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private static HttpURLConnection createConnection() throws Exception {
}

private static UUID getUUID(String id) {
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" +id.substring(20, 32));
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
}

public static byte[] toBytes(UUID uuid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void run() {
} else {
System.out.println("[Poseidon-Watchdog] A server tick hasn't occurred in " + ((int) ((System.currentTimeMillis() / 1000L) - lastTick)) + " seconds.");
//Server debug timeout
if((lastTick + debugTimeout) < (System.currentTimeMillis() / 1000L) && debugTimeoutEnabled && !printedDebug) {
if ((lastTick + debugTimeout) < (System.currentTimeMillis() / 1000L) && debugTimeoutEnabled && !printedDebug) {
System.out.println("[Poseidon-Watchdog] Server hang detected. Printing debug as debug timeout has been exceeded.");
System.out.println("--------------------[Stacktrace For Developers]--------------------");
Arrays.asList(serverThread.getStackTrace()).forEach(System.out::println);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public boolean isActive() {
* This method is for Poseidon, not plugin use. DON'T TOUCH THIS IF YOU DON'T KNOW WHAT YOU ARE DOING.
*/
public void setActive(boolean active) {
if(!active)
if (!active)
this.completionTime = System.currentTimeMillis();
this.active = active;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/me/devcody/uberbukkit/util/math/Vec3i.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,31 @@ public Vec3i(int x, int y, int z) {
public int getX() {
return x;
}

public void setX(int x) {
this.x = x;
}

public int getY() {
return y;
}

public void setY(int y) {
this.y = y;
}

public int getZ() {
return z;
}

public void setZ(int z) {
this.z = z;
}

public Vec3i add(Vec3i vec) {
return new Vec3i(x + vec.x, y + vec.y, z + vec.z);
}

public Vec3i subtract(Vec3i vec) {
return new Vec3i(x - vec.x, y - vec.y, z - vec.z);
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/net/minecraft/server/AchievementList.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ public class AchievementList {
public static Achievement t = (new Achievement(14, "killCow", 7, -3, Item.LEATHER, r)).c();
public static Achievement u = (new Achievement(15, "flyPig", 8, -4, Item.SADDLE, t)).b().c();

public AchievementList() {}
public AchievementList() {
}

public static void a() {}
public static void a() {
}

static {
System.out.println(e.size() + " achievements");
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/minecraft/server/BedBlockTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

public class BedBlockTextures {

public static final int[] a = new int[] { 3, 4, 2, 5};
public static final int[] b = new int[] { 2, 3, 0, 1};
public static final int[][] c = new int[][] { { 1, 0, 3, 2, 5, 4}, { 1, 0, 5, 4, 2, 3}, { 1, 0, 2, 3, 4, 5}, { 1, 0, 4, 5, 3, 2}};
public static final int[] a = new int[]{3, 4, 2, 5};
public static final int[] b = new int[]{2, 3, 0, 1};
public static final int[][] c = new int[][]{{1, 0, 3, 2, 5, 4}, {1, 0, 5, 4, 2, 3}, {1, 0, 2, 3, 4, 5}, {1, 0, 4, 5, 3, 2}};

public BedBlockTextures() {}
public BedBlockTextures() {
}
}
3 changes: 2 additions & 1 deletion src/main/java/net/minecraft/server/BiomeDesert.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

public class BiomeDesert extends BiomeBase {

public BiomeDesert() {}
public BiomeDesert() {
}
}
3 changes: 2 additions & 1 deletion src/main/java/net/minecraft/server/BiomeRainforest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

public class BiomeRainforest extends BiomeBase {

public BiomeRainforest() {}
public BiomeRainforest() {
}

public WorldGenerator a(Random random) {
return (WorldGenerator) (random.nextInt(3) == 0 ? new WorldGenBigTree() : new WorldGenTrees());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/minecraft/server/BiomeSwamp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

public class BiomeSwamp extends BiomeBase {

public BiomeSwamp() {}
public BiomeSwamp() {
}
}
2 changes: 1 addition & 1 deletion src/main/java/net/minecraft/server/BlockBed.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class BlockBed extends Block {

public static final int[][] a = new int[][] { { 0, 1}, { -1, 0}, { 0, -1}, { 1, 0}};
public static final int[][] a = new int[][]{{0, 1}, {-1, 0}, {0, -1}, {1, 0}};

public BlockBed(int i) {
super(i, 134, Material.CLOTH);
Expand Down
Loading

0 comments on commit 011f498

Please sign in to comment.