Skip to content

Commit

Permalink
Give player message if no schematics detected
Browse files Browse the repository at this point in the history
  • Loading branch information
OreCruncher committed Sep 26, 2015
1 parent 3d8611d commit 0ee7568
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/recycling/lang/en_US.lang
Original file line number Diff line number Diff line change
@@ -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?

0 comments on commit 0ee7568

Please sign in to comment.