Skip to content

Commit

Permalink
refactor: Re-indent with tab
Browse files Browse the repository at this point in the history
(cherry picked from commit 94e6f62)
  • Loading branch information
JasperLorelai committed Mar 28, 2024
1 parent a16e639 commit 73e5047
Show file tree
Hide file tree
Showing 59 changed files with 1,830 additions and 1,825 deletions.
132 changes: 66 additions & 66 deletions src/main/java/eu/jasperlorelai/circe/CirceExpansion.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,71 +14,71 @@

public class CirceExpansion extends PlaceholderExpansion {

private static final String IDENTIFIER = "circe";
private static final String AUTHOR = "JasperLorelai";
private static final String VERSION = "0.1.0";
private static final String NAME = "Circe";

@NotNull
public String getIdentifier() {
return IDENTIFIER;
}

@NotNull
public String getAuthor() {
return AUTHOR;
}

@NotNull
public String getVersion() {
return VERSION;
}

@NotNull
public String getName() {
return NAME;
}

public String onRequest(OfflinePlayer player, @NotNull String identifier) {
String code = identifier;
if (code.startsWith("file:")) {
String fileName = code.replaceFirst("file:", "")
.replaceFirst("\\.circe$", "")
.trim();

// Read the file.
File folder = new File(getPlaceholderAPI().getDataFolder(), "circe");
try {
//noinspection ResultOfMethodCallIgnored
folder.mkdir();
File file = new File(folder, fileName + ".circe");
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuilder string = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
string.append(line).append(System.lineSeparator());
}
code = string.toString();
reader.close();
} catch (SecurityException | IOException e) {
severe("Failed read file: circe/" + fileName + ".circe");
}
}

code = bracketPlaceholders(player, code);
boolean hasDebug = code.startsWith("debug;");
if (hasDebug) code = code.replaceFirst("debug;", "");

try {
code = new Parser().parse(code);
} catch (UnknownTokenException | ParserException | FunctionCallException exception) {
if (hasDebug) return exception.getClass().getSimpleName() + ": " + exception.getMessage();
}
return bracketPlaceholders(player, code);
}

private static String bracketPlaceholders(OfflinePlayer player, String string) {
return PlaceholderAPI.setBracketPlaceholders(player, string);
}
private static final String IDENTIFIER = "circe";
private static final String AUTHOR = "JasperLorelai";
private static final String VERSION = "0.1.0";
private static final String NAME = "Circe";

@NotNull
public String getIdentifier() {
return IDENTIFIER;
}

@NotNull
public String getAuthor() {
return AUTHOR;
}

@NotNull
public String getVersion() {
return VERSION;
}

@NotNull
public String getName() {
return NAME;
}

public String onRequest(OfflinePlayer player, @NotNull String identifier) {
String code = identifier;
if (code.startsWith("file:")) {
String fileName = code.replaceFirst("file:", "")
.replaceFirst("\\.circe$", "")
.trim();

// Read the file.
File folder = new File(getPlaceholderAPI().getDataFolder(), "circe");
try {
//noinspection ResultOfMethodCallIgnored
folder.mkdir();
File file = new File(folder, fileName + ".circe");
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuilder string = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
string.append(line).append(System.lineSeparator());
}
code = string.toString();
reader.close();
} catch (SecurityException | IOException e) {
severe("Failed read file: circe/" + fileName + ".circe");
}
}

code = bracketPlaceholders(player, code);
boolean hasDebug = code.startsWith("debug;");
if (hasDebug) code = code.replaceFirst("debug;", "");

try {
code = new Parser().parse(code);
} catch (UnknownTokenException | ParserException | FunctionCallException exception) {
if (hasDebug) return exception.getClass().getSimpleName() + ": " + exception.getMessage();
}
return bracketPlaceholders(player, code);
}

private static String bracketPlaceholders(OfflinePlayer player, String string) {
return PlaceholderAPI.setBracketPlaceholders(player, string);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class FunctionCallException extends RuntimeException {

public FunctionCallException(String message) {
super(message);
}
public FunctionCallException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class ParserException extends RuntimeException {

public ParserException(String message) {
super(message);
}
public ParserException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class UnknownTokenException extends RuntimeException {

public UnknownTokenException(String message) {
super(message);
}
public UnknownTokenException(String message) {
super(message);
}

}
Loading

0 comments on commit 73e5047

Please sign in to comment.