Skip to content

Commit

Permalink
1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
WispySparks committed Aug 22, 2022
1 parent 2d8c990 commit 99de4f9
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 146 deletions.
22 changes: 6 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,24 @@ buildscript {
}
}
apply plugin: 'net.minecraftforge.gradle.forge'

apply plugin: 'java'

sourceCompatibility = targetCompatibility = '1.8'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
// options.compilerArgs << "-Xlint:unchecked"
}
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

/*
for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot
plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "1.4.1"
version = "1.4.2"
group= "com.wispy.skyhead"
archivesBaseName = "SkyHead"

minecraft {
version = "1.8.9-11.15.1.2318-1.8.9"
runDir = "run"
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "stable_22"
makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
mappings = "stable_22" // simply re-run your setup task after changing the mappings to update your workspace.
makeObfSourceJar = false
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
22 changes: 11 additions & 11 deletions src/main/java/com/wispy/skyhead/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static void addPlayer(String player, String level) { // add player to cac
switch (SkyHead.mode) {
case 0: playerCacheSW.put(player, level); break;
case 1: playerCacheBW.put(player, level); break;
default: break;
}
}

Expand All @@ -24,22 +25,20 @@ public static String queryCache(String player) { // get level for player from ca
}
}

public static boolean inCache(String player) { // check if a player is in the cache
public static boolean inCache(String player, Boolean tab) { // check if a player is in the cache
switch (SkyHead.mode) {
case 0:
for (String key : playerCacheSW.keySet()) {
if (key.equals(player)) {
if (playerCacheSW.get(key).equals(" §fLimit") || playerCacheSW.get(key).equals(" §fbadkey")) return false; // if a level wasn't grabbed before try and get it again
return true; // otherwise yes it is in the cache
}
if (playerCacheSW.containsKey(player)) {
if (tab) return true; // tab doesn't ever change things so it can render these label
if (playerCacheSW.get(player).equals(" §fLimit") || playerCacheSW.get(player).equals(" §fbadkey")) return false; // if a level wasn't grabbed before try and get it again
return true; // otherwise yes it is in the cache
}
return false;
case 1:
for (String key : playerCacheBW.keySet()) { // same thing but for bedwars
if (key.equals(player)) {
if (playerCacheBW.get(key).equals(" §fLimit") || playerCacheBW.get(key).equals(" §fbadkey")) return false; // if a level wasn't grabbed before try and get it again
return true;
}
if (playerCacheBW.containsKey(player)) {
if (tab) return true; // tab doesn't ever change things so it can render these label
if (playerCacheBW.get(player).equals(" §fLimit") || playerCacheBW.get(player).equals(" §fbadkey")) return false; // if a level wasn't grabbed before try and get it again
return true; // otherwise yes it is in the cache
}
return false;
default: return false;
Expand All @@ -58,6 +57,7 @@ public static void clearCache() { // clear the cache
switch (SkyHead.mode) {
case 0: playerCacheSW.clear(); break;
case 1: playerCacheBW.clear(); break;
default: break;
}
}

Expand Down
82 changes: 0 additions & 82 deletions src/main/java/com/wispy/skyhead/Events.java

This file was deleted.

12 changes: 9 additions & 3 deletions src/main/java/com/wispy/skyhead/SkyHead.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import java.io.File;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.wispy.skyhead.api.API;
import com.wispy.skyhead.commands.SkyheadCommands;
import com.wispy.skyhead.events.Events;

import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
Expand All @@ -17,12 +21,14 @@
/**
* Main mod class where the startup events are fired.
*/
@Mod(modid = SkyHead.modID, version = SkyHead.version, clientSideOnly = true, updateJSON = "https://github.com/WispySparks/SkyHead/blob/master/update.json")
@Mod(modid = SkyHead.modID, version = SkyHead.version, clientSideOnly = true, updateJSON = SkyHead.updateLink)
public class SkyHead
{

public static final String modID = "skyhead";
public static final String version = "1.4.1";
public static final String version = "1.4.2";
public static final String updateLink = "https://raw.githubusercontent.com/WispySparks/SkyHead/master/update.json";
public static final Logger logger = LogManager.getLogger(modID);
public static Configuration config; // config
public static boolean enabled; // mod on/off
public static boolean tabEnabled; // whether tab mode is on or off
Expand Down Expand Up @@ -50,5 +56,5 @@ public void init(FMLInitializationEvent event) // register my mod stuff
MinecraftForge.EVENT_BUS.register(new Events()); // register events handler
MinecraftForge.EVENT_BUS.register(this); // register my mod
}

}
2 changes: 1 addition & 1 deletion src/main/java/com/wispy/skyhead/api/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static String getLevel(String uuid) { // get a player's skywars level usi
Header[] timeLimit = response.getHeaders("RateLimit-Reset"); // get the initial time left for starting the clock
APILimiter.start(Integer.parseInt(timeLimit[0].getValue())); // start clock with that time left
json = new BasicResponseHandler().handleResponse(response);
} catch (Exception e) {System.out.println(e);}
} catch (Exception e) {SkyHead.logger.error(e);}
if (json != null) { // parse the json and grab the player's level or do level 1 if nothing is there
JsonElement jelement = new JsonParser().parse(json);
JsonObject jsonObject = jelement.getAsJsonObject();
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/wispy/skyhead/api/APILimiter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.wispy.skyhead.api;

import com.wispy.skyhead.SkyHead;
import com.wispy.skyhead.gui.Display;

/**
* Helper class to limit the API from going over the request limit of 120 a minute.
*/
Expand All @@ -25,7 +28,8 @@ public void run() {
Thread.sleep(timeLeft);
APILimiter.requests = 0;
APILimiter.timeLeft = 60000;
} catch (InterruptedException e) {System.out.println(e);}
Display.setLevels();
} catch (InterruptedException e) {SkyHead.logger.error(e);}
}
}
});
Expand Down
34 changes: 10 additions & 24 deletions src/main/java/com/wispy/skyhead/commands/SkyheadCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
import java.util.List;

import com.wispy.skyhead.Cache;
import com.wispy.skyhead.Events;
import com.wispy.skyhead.SkyHead;
import com.wispy.skyhead.api.API;
import com.wispy.skyhead.api.APILimiter;
import com.wispy.skyhead.gui.Display;
import com.wispy.skyhead.util.Text;

import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
Expand All @@ -38,7 +37,7 @@ public SkyheadCommands() { // make sh also a valid command and add tab completio
tabComplete.add("key");
tabComplete.add("requests");
tabComplete.add("size");
tabComplete.add("clear");
tabComplete.add("clear");
}

@Override
Expand Down Expand Up @@ -76,15 +75,15 @@ public void processCommand(ICommandSender sender, String[] args) throws CommandE
prop.setValue(true);
SkyHead.config.save();
SkyHead.enabled = true;
retrieveLevels();
Display.setLevels();
mc.thePlayer.addChatMessage(Text.ChatText("Skyhead ON", "§a"));
}
else if (args[0].equals("off")) { // turn mod off
Property prop = SkyHead.config.get(Configuration.CATEGORY_CLIENT, "enabled", true); // get config property and set it so that it persists between launches
prop.setValue(false);
SkyHead.config.save();
SkyHead.enabled = false;
retrieveLevels();
Display.setLevels();
mc.thePlayer.addChatMessage(Text.ChatText("Skyhead OFF", "§c"));
}
else if (args[0].equals("tab")) { // toggle tab levels on and off
Expand All @@ -106,15 +105,15 @@ else if (args[0].equals("sw")) { // set mod mode to skywars levels
prop.setValue(0);
SkyHead.config.save();
SkyHead.mode = 0; // set mode in config and current instance
retrieveLevels();
Display.setLevels();
mc.thePlayer.addChatMessage(Text.ChatText("Set to Skywars Mode", "§6"));
}
else if (args[0].equals("bw")) { // set mod mode to bedwars levels
Property prop = SkyHead.config.get(Configuration.CATEGORY_CLIENT, "mode", 0);
prop.setValue(1);
SkyHead.config.save();
SkyHead.mode = 1; // set mode in config and current instance
retrieveLevels();
Display.setLevels();
mc.thePlayer.addChatMessage(Text.ChatText("Set to Bedwars Mode", "§6"));
}
else if (args[0].equals("key")) { // set api key
Expand All @@ -125,6 +124,7 @@ else if (args[0].equals("key")) { // set api key
API.apikey = args[1];
SkyHead.enabled = true;
mc.thePlayer.addChatMessage(Text.ChatText("Set API Key to " + args[1], "§6"));
Display.setLevels();
}
else {
mc.thePlayer.addChatMessage(Text.ChatText("Must Specify API Key", "§6"));
Expand All @@ -134,13 +134,12 @@ else if (args[0].equals("help")) { // help command
mc.thePlayer.addChatMessage(Text.ChatText("Welcome to SkyHead. Here is an explanation of every command."
+ " On and off will turn the whole mod on or off, tab will toggle showing levels in tab on and off, abbreviations are used to change the mode"
+ " such as sw or bw. Key is used to set the api key to be used by the mod, size tells you the current size of the players cached for"
+ " the mode you're currently in, and requests tells you how many requests have been sent to the api this minute. Using clearcache empties the player cache for"
+ " the current mode", "§6"));
+ " the mode you're currently in, and requests tells you how many requests have been sent to the api this minute.", "§6"));
}
else if (args[0].equals("clear")) { // clear player cache
else if (args[0].equals("clear")) { // clear player cache, unstable
Cache.clearCache();
mc.thePlayer.addChatMessage(Text.ChatText("Cleared Cache", "§6"));
retrieveLevels();
Display.setLevels();
}
else { // if not a valid subcommand
mc.thePlayer.addChatMessage(Text.ChatText("Invalid Subcommand, " + options, "§6"));
Expand Down Expand Up @@ -176,17 +175,4 @@ private String convertMode(int mode) { // convert the mode to text
}
}

private void retrieveLevels() {
Minecraft mc = Minecraft.getMinecraft();
if (SkyHead.enabled) {
for (EntityPlayer player : mc.theWorld.playerEntities) { // set the names of everyone in the lobby
Events.setLevel(player);
}
} else {
for (EntityPlayer player : mc.theWorld.playerEntities) { // clear the names of everyone in the lobby
player.refreshDisplayName();
}
}
}

}
Loading

0 comments on commit 99de4f9

Please sign in to comment.