-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a12a3db
Showing
10 changed files
with
336 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SplashHelper | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package cc.dxxxxy.sh; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.scoreboard.ScoreObjective; | ||
import net.minecraft.scoreboard.Scoreboard; | ||
import net.minecraft.util.ChatComponentText; | ||
import net.minecraft.util.IChatComponent; | ||
import net.minecraftforge.client.event.ClientChatReceivedEvent; | ||
import net.minecraftforge.common.config.Configuration; | ||
import net.minecraftforge.common.config.Property; | ||
import net.minecraftforge.fml.client.event.ConfigChangedEvent; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.common.gameevent.InputEvent; | ||
import net.minecraftforge.fml.common.gameevent.TickEvent; | ||
import org.apache.logging.log4j.Logger; | ||
import org.lwjgl.input.Keyboard; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class Events { | ||
private final Configuration config = SplashHelper.getConfig(); | ||
private final Logger logger = SplashHelper.getLogger(); | ||
private final Minecraft mc = Minecraft.getMinecraft(); | ||
private String name = null; | ||
private final Property isOn = config.get("shs", "Enabled", false); | ||
private final Property feeK = config.get("shs", "Fee Amount", 0); | ||
private final Property joinMsg = config.get("shs", "Join Message", ""); | ||
public static ArrayList<String> members = new ArrayList<String>(); | ||
|
||
|
||
public static String getBoardTitle(Scoreboard board) { | ||
ScoreObjective titleObjective = board.getObjectiveInDisplaySlot(1); | ||
if (board.getObjectiveInDisplaySlot(0) != null) { | ||
return board.getObjectiveInDisplaySlot(0).getName(); | ||
} else { | ||
return board.getObjectiveInDisplaySlot(1).getName(); | ||
} | ||
} | ||
|
||
public static void sendMessage(String msg) { | ||
Minecraft.getMinecraft().thePlayer.addChatComponentMessage((IChatComponent) new ChatComponentText(msg)); | ||
} | ||
|
||
@SubscribeEvent | ||
public void onChatReceived(ClientChatReceivedEvent e) { | ||
String msg = e.message.getFormattedText(); | ||
if (mc.isSingleplayer()) return; | ||
if (!mc.getCurrentServerData().serverIP.contains(".hypixel.net")) return; | ||
if (!getBoardTitle(mc.theWorld.getScoreboard()).equals("SBScoreboard")) return; | ||
if (msg.contains(":")) return; | ||
if (isOn.getBoolean()) { | ||
if (msg.contains("Trade completed with")) { | ||
if (msg.contains("]")) { | ||
name = msg.substring(msg.indexOf("]") + 2, msg.indexOf("!") - 4); | ||
return; | ||
} | ||
name = msg.substring(msg.indexOf("h") + 6, msg.indexOf("!") - 4); | ||
} | ||
if (msg.contains("+") && msg.contains("coins") && name != null) { | ||
int fee = Integer.parseInt(msg.substring(15, msg.indexOf("k"))); | ||
if (fee >= feeK.getInt()) { | ||
mc.thePlayer.sendChatMessage("/p " + name); | ||
name = null; | ||
} | ||
} | ||
if (!joinMsg.getString().equals("")) { | ||
if (msg.contains("joined the party.")) { | ||
mc.thePlayer.sendChatMessage("/pc " + joinMsg.getString()); | ||
} | ||
} | ||
if (msg.contains("joined the party.")) { | ||
if (!ReinviteCommand.reInv) { | ||
if (msg.contains("]")) { | ||
//sendMessage(msg.substring(msg.indexOf("]") + 2, msg.indexOf("joined") - 5)); | ||
members.add(msg.substring(msg.indexOf("]") + 2, msg.indexOf("joined the") - 5)); | ||
return; | ||
} | ||
//sendMessage(msg.substring(0, msg.indexOf("joined") - 5)); | ||
members.add(msg.substring(2, msg.indexOf("joined the") - 5)); | ||
} | ||
} | ||
if (msg.contains("left the party.")) { | ||
if (msg.contains("You")) return; | ||
if (msg.contains("]")) { | ||
members.remove(members.indexOf(msg.substring(msg.indexOf("]") + 2, msg.indexOf("has left") - 5))); | ||
return; | ||
} | ||
members.remove(members.indexOf(msg.substring(2, msg.indexOf("has left") - 5))); | ||
} | ||
if (msg.contains("You have joined")) { | ||
if (isOn.getBoolean()) { | ||
isOn.set(!isOn.getBoolean()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onKeyTyped(InputEvent.KeyInputEvent e) { | ||
if (Keyboard.getEventKey() == SplashHelper.openGui.getKeyCode()) { | ||
Minecraft.getMinecraft().displayGuiScreen(new GuiConfig(Minecraft.getMinecraft().currentScreen)); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onConfigChanged(ConfigChangedEvent e) { | ||
if (e.modID.equals(Reference.ID)) { | ||
config.save(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cc.dxxxxy.sh; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.FontRenderer; | ||
import net.minecraftforge.client.event.RenderGameOverlayEvent; | ||
import net.minecraftforge.common.config.Configuration; | ||
import net.minecraftforge.common.config.Property; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
|
||
import java.awt.*; | ||
|
||
public class Gui extends net.minecraft.client.gui.Gui { | ||
Configuration config = SplashHelper.getConfig(); | ||
|
||
Property isOn = config.get("shs", "Enabled", false); | ||
Property fee = config.get("shs", "Fee Amount", 0); | ||
Property joinMsg = config.get("shs", "Join Message", ""); | ||
Property showInHub = config.get("shs", "Show Members in Hub", false); | ||
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; | ||
|
||
@SubscribeEvent | ||
public void renderOverlay(RenderGameOverlayEvent e) { | ||
if (showInHub.getBoolean()) { | ||
if (e.type.equals(RenderGameOverlayEvent.ElementType.TEXT)) { | ||
drawString(fr,"A", 9, 9, Color.cyan.getRGB()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cc.dxxxxy.sh; | ||
|
||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraftforge.common.config.ConfigElement; | ||
|
||
public class GuiConfig extends net.minecraftforge.fml.client.config.GuiConfig { | ||
public GuiConfig(GuiScreen guiScreen) { | ||
super(guiScreen, | ||
new ConfigElement(SplashHelper.getConfig().getCategory("shs")).getChildElements(), | ||
Reference.ID, | ||
false, | ||
false, | ||
"Splash Helper Settings"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package cc.dxxxxy.sh; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraftforge.fml.client.IModGuiFactory; | ||
|
||
import java.util.Set; | ||
|
||
public class GuiFactory implements IModGuiFactory { | ||
@Override | ||
public void initialize(Minecraft minecraftInstance) { } | ||
|
||
@Override | ||
public Class<? extends GuiScreen> mainConfigGuiClass() { | ||
return GuiConfig.class; | ||
} | ||
|
||
@Override | ||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package cc.dxxxxy.sh; | ||
|
||
public class Reference { | ||
public static final String ID = "sh"; | ||
public static final String NAME = "Splash Helper"; | ||
public static final String VERSION = "1.0"; | ||
public static final String GUI = "cc.dxxxxy.sh.GuiFactory"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package cc.dxxxxy.sh; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.command.CommandBase; | ||
import net.minecraft.command.CommandException; | ||
import net.minecraft.command.ICommandSender; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
import net.minecraftforge.fml.common.gameevent.TickEvent; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public class ReinviteCommand extends CommandBase { | ||
private final Logger logger = SplashHelper.getLogger(); | ||
public static boolean reInv; | ||
public String rem; | ||
public int tickcount; | ||
public int counter; | ||
@Override | ||
public String getCommandName() { | ||
return "sh-reinv"; | ||
} | ||
|
||
@Override | ||
public String getCommandUsage(ICommandSender sender) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void processCommand(ICommandSender sender, String[] args) throws CommandException { | ||
reInv = true; | ||
} | ||
|
||
@SubscribeEvent | ||
public void onServerTick(TickEvent.ClientTickEvent e) { | ||
if (e.phase.equals(TickEvent.Phase.END)) { | ||
if (reInv) { | ||
tickcount++; | ||
if (counter > 0) { | ||
Events.members.remove(rem); | ||
} | ||
for (String name : Events.members) { | ||
if (tickcount == 2 * 20) { | ||
Minecraft.getMinecraft().thePlayer.sendChatMessage("/p " + name); | ||
rem = name; | ||
tickcount = 0; | ||
counter++; | ||
} | ||
} | ||
if (Events.members.isEmpty()) { | ||
reInv = false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public boolean canCommandSenderUseCommand(ICommandSender sender) { return true; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package cc.dxxxxy.sh; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.settings.KeyBinding; | ||
import net.minecraftforge.client.ClientCommandHandler; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.common.config.Configuration; | ||
import net.minecraftforge.common.config.Property; | ||
import net.minecraftforge.fml.client.registry.ClientRegistry; | ||
import net.minecraftforge.fml.common.Loader; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.common.Mod.EventHandler; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.lwjgl.input.Keyboard; | ||
|
||
import java.io.*; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
|
||
@Mod(modid = Reference.ID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI) | ||
public class SplashHelper { | ||
private static Configuration config; | ||
private static Logger logger = LogManager.getLogger(Reference.ID); | ||
static String currentVersion; | ||
static String newVersion; | ||
public static final KeyBinding openGui = new KeyBinding("Open Gui", Keyboard.KEY_RSHIFT, "Splash Helper"); | ||
|
||
@EventHandler | ||
public void preInit(FMLPreInitializationEvent e) { | ||
File configFile = new File(Loader.instance().getConfigDir(), "sh.cfg"); | ||
config = new Configuration(configFile); | ||
config.load(); | ||
Property isOn = config.get("shs", "Enabled", false); | ||
Property fee = config.get("shs", "Fee Amount", 0); | ||
Property joinMsg = config.get("shs", "Join Message", ""); | ||
Property showInHub = config.get("shs", "Show Members in Hub", false); | ||
if(config.hasChanged()){ | ||
config.save(); | ||
} | ||
ClientRegistry.registerKeyBinding(openGui); | ||
//ClientCommandHandler.instance.registerCommand(new ReinviteCommand()); | ||
MinecraftForge.EVENT_BUS.register(new Events()); | ||
//MinecraftForge.EVENT_BUS.register(new ReinviteCommand()); | ||
} | ||
|
||
public void updateChecker() { | ||
try { | ||
HttpURLConnection c = (HttpURLConnection)new URL("https://api.spigotmc.org/legacy/update.php?resource=72777").openConnection(); | ||
newVersion = new BufferedReader((Reader)new InputStreamReader(c.getInputStream())).readLine(); | ||
c.disconnect(); | ||
if (newVersion.equals(currentVersion)) { | ||
//On latest version | ||
} | ||
else { | ||
//Update available | ||
} | ||
} | ||
catch (IOException ex) { | ||
//Error | ||
ex.printStackTrace(); | ||
} | ||
} | ||
|
||
public static Configuration getConfig() { return config; } | ||
|
||
public static Logger getLogger() { return logger; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"modid": "sh", | ||
"name": "Splash Helper", | ||
"description": "A mod developed by DxxxxY#5818", | ||
"version": "${version}", | ||
"mcversion": "${mcversion}", | ||
"url": "", | ||
"updateUrl": "", | ||
"authorList": ["DxxxxY"], | ||
"credits": "DxxxxY#5818", | ||
"logoFile": "", | ||
"screenshots": [], | ||
"dependencies": [] | ||
} | ||
] |