Remove the API component - closes #51

This commit is contained in:
Focusvity
2022-08-02 22:08:52 +10:00
parent f806470fd5
commit d6b44863aa
63 changed files with 191 additions and 492 deletions

View File

@ -27,8 +27,8 @@ public class GameRuleUtil
private static <T> void readGameRules(World world, String s)
{
String gameRule = s.split(";")[0];
T value = (T) s.split(";")[1];
GameRule<T> rule = (GameRule<T>) GameRule.getByName(gameRule);
T value = (T)s.split(";")[1];
GameRule<T> rule = (GameRule<T>)GameRule.getByName(gameRule);
if (rule != null && check(value).getClass().equals(rule.getType()))
{
world.setGameRule(rule, value);

View File

@ -38,7 +38,7 @@ public class MojangUtils
return null;
}
client.close();
AshconInfo ashconInfo = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, (JsonDeserializer<ZonedDateTime>) (json1, typeOfT, context) ->
AshconInfo ashconInfo = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, (JsonDeserializer<ZonedDateTime>)(json1, typeOfT, context) ->
ZonedDateTime.ofInstant(Instant.from(DateTimeFormatter.ISO_INSTANT.parse(json1.getAsJsonPrimitive().getAsString())), ZoneId.of(Plex.get().config.getString("server.timezone")))).create().fromJson(json, AshconInfo.class);
Arrays.sort(ashconInfo.getUsernameHistories(), (o1, o2) ->

View File

@ -54,14 +54,15 @@ public class PlexUtils implements PlexBase
public static void disabledEffectMultiple(Player[] players, Location location)
{
if (players.length < 1) {
if (players.length < 1)
{
return;
}
Particle.CLOUD.builder().location(location).receivers(players).extra(0).offset(0.5, 0.5, 0.5).count(5).spawn();
Particle.FLAME.builder().location(location).receivers(players).extra(0).offset(0.5, 0.5, 0.5).count(3).spawn();
Particle.SOUL_FIRE_FLAME.builder().location(location).receivers(players).offset(0.5, 0.5, 0.5).extra(0).count(2)
.spawn();
.spawn();
// note that the sound is played to everyone who is close enough to hear it
players[0].getWorld().playSound(location, org.bukkit.Sound.BLOCK_FIRE_EXTINGUISH, 0.5f, 0.5f);
}
@ -179,7 +180,7 @@ public class PlexUtils implements PlexBase
{
try
{
return ((TextComponent) component).content();
return ((TextComponent)component).content();
}
catch (Exception e)
{

View File

@ -49,7 +49,7 @@ public class ReflectionsUtil
{
if (clazz.getSuperclass() == subType || Arrays.asList(clazz.getInterfaces()).contains(subType))
{
classes.add((Class<? extends T>) clazz);
classes.add((Class<? extends T>)clazz);
}
});
return Collections.unmodifiableSet(classes);

View File

@ -13,7 +13,6 @@ import org.apache.commons.lang3.math.NumberUtils;
public class TimeUtils
{
public static String TIMEZONE = Plex.get().config.getString("server.timezone");
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a z");
private static final Set<String> TIMEZONES = Set.of(TimeZone.getAvailableIDs());
private static final List<String> timeUnits = new ArrayList<>()
@ -26,6 +25,7 @@ public class TimeUtils
add("mo");
add("y");
}};
public static String TIMEZONE = Plex.get().config.getString("server.timezone");
private static int parseInteger(String s) throws NumberFormatException
{

View File

@ -38,8 +38,8 @@ public class UpdateChecker implements PlexBase
* > 0 = Number of commits behind
*/
private final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/";
private String BRANCH = plugin.config.getString("update_branch");
private final String REPO = plugin.config.getString("update_repo");
private String BRANCH = plugin.config.getString("update_branch");
private int distance = -4;
// Adapted from Paper
@ -47,7 +47,7 @@ public class UpdateChecker implements PlexBase
{
try
{
HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
HttpURLConnection connection = (HttpURLConnection)new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
connection.connect();
if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
{

View File

@ -17,7 +17,7 @@ public class WebUtils
try
{
URL u = new URL(url);
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
HttpURLConnection connection = (HttpURLConnection)u.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
@ -39,13 +39,13 @@ public class WebUtils
public static UUID getFromName(String name)
{
JSONObject profile;
profile = (JSONObject) simpleGET("https://api.ashcon.app/mojang/v2/user/" + name);
profile = (JSONObject)simpleGET("https://api.ashcon.app/mojang/v2/user/" + name);
if (profile == null)
{
PlexLog.error("Profile from Ashcon API returned null!");
return null;
}
String uuidString = (String) profile.get("uuid");
String uuidString = (String)profile.get("uuid");
return UUID.fromString(uuidString);
}
}