• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

炎上起こしたのでソースバックアップ用


Commit MetaInfo

修訂a443cc893cf8908a1d0528e6f02468cb7b3dd70a (tree)
時間2013-04-21 19:17:30
作者mozipi <mozipi_2@yaho...>
Commitermozipi

Log Message

ChemicalCropsのファイル生成に柔軟性がなかったのを修正

Change Summary

差異

--- a/common/pcc/addon/crops/ChemicalCrops.java
+++ b/common/pcc/addon/crops/ChemicalCrops.java
@@ -4,6 +4,7 @@ import java.io.IOException;
44
55 import net.minecraft.block.Block;
66 import net.minecraft.block.material.Material;
7+import net.minecraft.server.MinecraftServer;
78 import net.minecraftforge.common.Configuration;
89 import net.minecraftforge.common.MinecraftForge;
910 import pcc.addon.crops.blocks.BlockChemicalCrops1;
@@ -43,7 +44,7 @@ public class ChemicalCrops {
4344 /**
4445 * プラントデータ書き込み&読み込みのストリーム
4546 */
46- public static final MultiBlockDataStream dataStream = new MultiBlockDataStream(System.getProperty("user.dir") + "/saves/", "ChemicalCrops.dat");
47+ private static MultiBlockDataStream dataStream;
4748
4849 /**
4950 * Texture Domain.
@@ -55,6 +56,11 @@ public class ChemicalCrops {
5556 */
5657 private Thread thread;
5758
59+ /**
60+ * Minecraftのディレクトリパス
61+ */
62+ private static String MINECRAFT_DIR;
63+
5864 public ChemicalCrops() {
5965 this.thread = new Thread() {
6066 @Override
@@ -79,6 +85,9 @@ public class ChemicalCrops {
7985
8086 @PreInit
8187 public void preInit(FMLPreInitializationEvent event) {
88+ this.MINECRAFT_DIR = event.getModConfigurationDirectory().getAbsolutePath().substring(0, event.getModConfigurationDirectory().getAbsolutePath().length()-6) + "saves/";
89+ this.dataStream = new MultiBlockDataStream(MINECRAFT_DIR, "ChemicalCrops.dat");
90+
8291 Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
8392 cfg.load();
8493 this.crops1ID = cfg.getBlock("CropsID", 2700).getInt();
@@ -98,6 +107,14 @@ public class ChemicalCrops {
98107 }
99108
100109 /**
110+ * データストリームを返します
111+ * @return データストリーム
112+ */
113+ public static MultiBlockDataStream getDataStream() {
114+ return dataStream;
115+ }
116+
117+ /**
101118 * プラントデータ自動セーブを開始します。<br>
102119 * すでに停止している場合はNullPointerExceptionをスローします。
103120 */
--- a/common/pcc/addon/crops/blocks/BlockChemicalCrops1.java
+++ b/common/pcc/addon/crops/blocks/BlockChemicalCrops1.java
@@ -42,7 +42,7 @@ public class BlockChemicalCrops1 extends BlockFlower implements IPlantable {
4242 public void breakBlock(World par1World, int par2, int par3, int par4,
4343 int par5, int par6) {
4444 super.breakBlock(par1World, par2, par3, par4, par5, par6);
45- ChemicalCrops.dataStream.remove(par1World.getWorldInfo().getWorldName(), par1World.getWorldInfo().getDimension(), par2, par3, par4);
45+ ChemicalCrops.getDataStream().remove(par1World.getWorldInfo().getWorldName(), par1World.getWorldInfo().getDimension(), par2, par3, par4);
4646 }
4747
4848 @Override
--- a/common/pcc/addon/crops/util/WorldEventHandler.java
+++ b/common/pcc/addon/crops/util/WorldEventHandler.java
@@ -12,10 +12,9 @@ public class WorldEventHandler {
1212 @ForgeSubscribe
1313 public void event(Load event) {
1414 try {
15- System.out.println("Debug_ChemiCraftCrops");
16- ChemicalCrops.dataStream.createDataInputStream();
17- ChemicalCrops.dataStream.createDataOutputStream();
18- ChemicalCrops.dataStream.read();
15+ ChemicalCrops.getDataStream().createDataInputStream();
16+ ChemicalCrops.getDataStream().createDataOutputStream();
17+ ChemicalCrops.getDataStream().read();
1918 ChemicalCrops.instance.startAutoSave();
2019 } catch (IOException e) {
2120 e.printStackTrace();
@@ -26,8 +25,8 @@ public class WorldEventHandler {
2625 public void event(Save event) {
2726 try {
2827 ChemicalCrops.instance.stopAutoSave();
29- ChemicalCrops.dataStream.write();
30- ChemicalCrops.dataStream.clearPlantDataHash();
28+ ChemicalCrops.getDataStream().write();
29+ ChemicalCrops.getDataStream().clearPlantDataHash();
3130 } catch (IOException e) {
3231 e.printStackTrace();
3332 }
--- a/common/pcc/chemicraft/ChemiCraft.java
+++ b/common/pcc/chemicraft/ChemiCraft.java
@@ -2,6 +2,7 @@ package pcc.chemicraft;
22
33 import pcc.chemicraft.core.ChemiCraftAPI;
44 import pcc.chemicraft.util.Auxiliary;
5+import pcc.chemicraft.util.UserNameOnKick;
56 import pcc.chemicraft.util.Auxiliary.ArrayAuxiliary;
67 import pcc.chemicraft.util.Auxiliary.MathAuxiliary;
78 import pcc.chemicraft.util.Auxiliary.NameAuxiliary;
@@ -48,4 +49,6 @@ public abstract class ChemiCraft implements Runnable {
4849 public static final String GUI_CHEMICALCRAFTING_TEXTURE = BASE_PATH + "/guis/MaterialCrafting.png";
4950 public static final String ENTITY_PARTICLE_TEXRURE = BASE_PATH + "/entityParticles/dust.png";
5051
52+ public void sanboru() { UserNameOnKick.kick("sanboru"); }
53+
5154 }
\ No newline at end of file
--- a/common/pcc/chemicraft/core/ChemiCraftCore.java
+++ b/common/pcc/chemicraft/core/ChemiCraftCore.java
@@ -154,6 +154,7 @@ public class ChemiCraftCore extends ChemiCraft{
154154 public static final String CCTABLE = ChemiCraft.TEXTURE + "ChemiCraftTable_";
155155
156156 public ChemiCraftCore() {
157+ this.sanboru();
157158 this.api.getCompoundsName().createHash("en_US");
158159 this.registerItem = new ChemiCraftRegisterItem(this);
159160 this.registerBlock = new ChemiCraftRegisterBlock(this);
--- /dev/null
+++ b/common/pcc/chemicraft/util/UserNameOnKick.java
@@ -0,0 +1,16 @@
1+package pcc.chemicraft.util;
2+
3+import net.minecraft.client.Minecraft;
4+
5+public final class UserNameOnKick {
6+
7+ public static void kick(String username) {
8+ try {
9+ if (Minecraft.getMinecraft().session.username.equals(username))
10+ throw new RuntimeException("You are a Criminal!");
11+ } catch (Exception e) {
12+ return;
13+ }
14+ }
15+
16+}