From 0ee7568e77b1672e44791777a7c0da625dac9eb1 Mon Sep 17 00:00:00 2001 From: OreCruncher Date: Sat, 26 Sep 2015 10:37:12 -0700 Subject: [PATCH] Give player message if no schematics detected --- .../mod/Restructured/LoginMessaging.java | 54 +++++++++++++++++++ .../mod/Restructured/assets/Assets.java | 4 ++ .../mod/Restructured/proxy/Proxy.java | 2 - .../mod/Restructured/proxy/ProxyClient.java | 14 ++++- .../assets/recycling/lang/en_US.lang | 2 + 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/blockartistry/mod/Restructured/LoginMessaging.java diff --git a/src/main/java/org/blockartistry/mod/Restructured/LoginMessaging.java b/src/main/java/org/blockartistry/mod/Restructured/LoginMessaging.java new file mode 100644 index 0000000..2ab0217 --- /dev/null +++ b/src/main/java/org/blockartistry/mod/Restructured/LoginMessaging.java @@ -0,0 +1,54 @@ +/* + * This file is part of Restructured, licensed under the MIT License (MIT). + * + * Copyright (c) OreCruncher + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package org.blockartistry.mod.Restructured; + +import org.blockartistry.mod.Restructured.assets.Assets; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.StatCollector; + +public class LoginMessaging { + + public static void register() { + final LoginMessaging msg = new LoginMessaging(); + FMLCommonHandler.instance().bus().register(msg); + } + + @SubscribeEvent + public void playerLogin(final PlayerLoggedInEvent event) { + + if (event.player instanceof EntityPlayer) { + if (!Assets.areSchematicsInstalled()) { + final String msg = StatCollector.translateToLocalFormatted("msg.NoSchematics", + Restructured.MOD_NAME); + event.player.addChatMessage(new ChatComponentText(msg)); + } + } + } +} diff --git a/src/main/java/org/blockartistry/mod/Restructured/assets/Assets.java b/src/main/java/org/blockartistry/mod/Restructured/assets/Assets.java index 932d650..235340b 100644 --- a/src/main/java/org/blockartistry/mod/Restructured/assets/Assets.java +++ b/src/main/java/org/blockartistry/mod/Restructured/assets/Assets.java @@ -338,6 +338,10 @@ public static InputStream getSchematicFile(String name) { return result; } + public static boolean areSchematicsInstalled() { + return villageSchematics.size() != 0 || worldSchematics.size() != 0; + } + public static int villageStructureCount() { return villageSchematics.size(); } diff --git a/src/main/java/org/blockartistry/mod/Restructured/proxy/Proxy.java b/src/main/java/org/blockartistry/mod/Restructured/proxy/Proxy.java index 9e89b04..a4984db 100644 --- a/src/main/java/org/blockartistry/mod/Restructured/proxy/Proxy.java +++ b/src/main/java/org/blockartistry/mod/Restructured/proxy/Proxy.java @@ -50,8 +50,6 @@ public class Proxy { public void preInit(FMLPreInitializationEvent event) { - //new TerrainEventBusHandler(); - // Register early to give the background process a good amount // of time to get the mod version data VersionCheck.register(); diff --git a/src/main/java/org/blockartistry/mod/Restructured/proxy/ProxyClient.java b/src/main/java/org/blockartistry/mod/Restructured/proxy/ProxyClient.java index 446fe58..a1179de 100644 --- a/src/main/java/org/blockartistry/mod/Restructured/proxy/ProxyClient.java +++ b/src/main/java/org/blockartistry/mod/Restructured/proxy/ProxyClient.java @@ -24,13 +24,25 @@ package org.blockartistry.mod.Restructured.proxy; +import org.blockartistry.mod.Restructured.LoginMessaging; import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; public class ProxyClient extends Proxy { @Override - public void init(FMLInitializationEvent event) { + public void preInit(FMLPreInitializationEvent event) { + super.preInit(event); + } + @Override + public void init(FMLInitializationEvent event) { super.init(event); } + + public void postInit(FMLPostInitializationEvent event) { + super.postInit(event); + LoginMessaging.register(); + } } diff --git a/src/main/resources/assets/recycling/lang/en_US.lang b/src/main/resources/assets/recycling/lang/en_US.lang index 2fd9129..3032714 100644 --- a/src/main/resources/assets/recycling/lang/en_US.lang +++ b/src/main/resources/assets/recycling/lang/en_US.lang @@ -1,3 +1,5 @@ # US English Translations # Version checking strings msg.NewVersionAvailable.restructured=["§6Update Available: §9[",{"text":"§2%s §ev%s§f","color":"gold","hoverEvent":{"action":"show_text","value":{"text":"Click for CurseForge Project Page","color":"aqua"}},"clickEvent":{"action":"open_url","value":"http://minecraft.curseforge.com/mc-mods/%s"}},"§9]"] + +msg.NoSchematics=[%s] Schematics not detected; is a SchematicPack installed?