mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
try to remove voiceserver
This commit is contained in:
19 files changed
+1
-864
No files matched your search
@@ -15,7 +15,6 @@ public class MekanismConfig
|
||||
public static boolean controlCircuitOreDict = true;
|
||||
public static boolean logPackets = false;
|
||||
public static boolean dynamicTankEasterEgg = false;
|
||||
public static boolean voiceServerEnabled = true;
|
||||
public static boolean cardboardSpawners = true;
|
||||
public static boolean enableWorldRegeneration = true;
|
||||
public static boolean spawnBabySkeletons = true;
|
||||
@@ -27,7 +26,6 @@ public class MekanismConfig
|
||||
public static int saltPerChunk = 2;
|
||||
public static int obsidianTNTDelay = 100;
|
||||
public static int UPDATE_DELAY = 10;
|
||||
public static int VOICE_PORT = 36123;
|
||||
public static int maxUpgradeMultiplier = 10;
|
||||
public static int userWorldGenVersion = 0;
|
||||
public static double ENERGY_PER_REDSTONE = 10000;
|
||||
@@ -259,7 +257,6 @@ public class MekanismConfig
|
||||
public static boolean enableTeleporterCore = true;
|
||||
public static boolean enableConfigurator = true;
|
||||
public static boolean enableNetworkReader = true;
|
||||
public static boolean enableWalkieTalkie = true;
|
||||
public static boolean enableJetpacks = true;
|
||||
public static boolean enableScubaSet = true;
|
||||
public static boolean enableFreeRunners = true;
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package mekanism.client;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.client.voice.VoiceClient;
|
||||
import mekanism.common.Mekanism;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientConnectionHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void onConnection(ClientConnectedToServerEvent event)
|
||||
{
|
||||
if(general.voiceServerEnabled)
|
||||
{
|
||||
if(event.isLocal)
|
||||
{
|
||||
//If the client is connecting to its own corresponding integrated server.
|
||||
try {
|
||||
MekanismClient.voiceClient = new VoiceClient("127.0.0.1");
|
||||
//Will probably not work when multiple integrateds are running on one computer
|
||||
} catch(Throwable e) {
|
||||
Mekanism.logger.error("Unable to establish VoiceClient on local connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
//If the client is connecting to a foreign integrated or dedicated server.
|
||||
try {
|
||||
MekanismClient.voiceClient = new VoiceClient(((InetSocketAddress)event.manager.getSocketAddress()).getHostString());
|
||||
} catch(Throwable e) {
|
||||
Mekanism.logger.error("Unable to establish VoiceClient on remote connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,7 +351,6 @@ public class ClientProxy extends CommonProxy
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), handler);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), handler);
|
||||
MinecraftForgeClient.registerItemRenderer(MekanismItems.Robit, handler);
|
||||
MinecraftForgeClient.registerItemRenderer(MekanismItems.WalkieTalkie, handler);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.GasTank), handler);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.ObsidianTNT), handler);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.BasicBlock), handler);
|
||||
@@ -646,11 +645,6 @@ public class ClientProxy extends CommonProxy
|
||||
public void onConfigSync(boolean fromPacket)
|
||||
{
|
||||
super.onConfigSync(fromPacket);
|
||||
|
||||
if(fromPacket && general.voiceServerEnabled && MekanismClient.voiceClient != null)
|
||||
{
|
||||
MekanismClient.voiceClient.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,6 @@ import mekanism.api.MekanismAPI;
|
||||
import mekanism.api.MekanismAPI.BoxBlacklistEvent;
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.client.voice.VoiceClient;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IModule;
|
||||
import mekanism.common.content.boiler.SynchronizedBoilerData;
|
||||
@@ -20,8 +19,6 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
public class MekanismClient extends Mekanism
|
||||
{
|
||||
public static Map<String, SecurityData> clientSecurityMap = new HashMap<String, SecurityData>();
|
||||
|
||||
public static VoiceClient voiceClient;
|
||||
|
||||
public static long ticksPassed = 0;
|
||||
|
||||
@@ -39,15 +36,6 @@ public class MekanismClient extends Mekanism
|
||||
public static void reset()
|
||||
{
|
||||
clientSecurityMap.clear();
|
||||
|
||||
if(general.voiceServerEnabled)
|
||||
{
|
||||
if(MekanismClient.voiceClient != null)
|
||||
{
|
||||
MekanismClient.voiceClient.disconnect();
|
||||
MekanismClient.voiceClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
ClientTickHandler.tickingSet.clear();
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import mekanism.common.item.ItemFlamethrower;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
import mekanism.common.item.ItemJetpack.JetpackMode;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import mekanism.common.network.PacketConfiguratorState.ConfiguratorStateMessage;
|
||||
import mekanism.common.network.PacketElectricBowState.ElectricBowStateMessage;
|
||||
import mekanism.common.network.PacketFlamethrowerData;
|
||||
@@ -22,7 +21,6 @@ import mekanism.common.network.PacketJetpackData.JetpackPacket;
|
||||
import mekanism.common.network.PacketPortableTankState.PortableTankStateMessage;
|
||||
import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage;
|
||||
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
|
||||
import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
@@ -47,17 +45,15 @@ public class MekanismKeyHandler extends MekKeyHandler
|
||||
public static final String keybindCategory = "Mekanism";
|
||||
public static KeyBinding modeSwitchKey = new KeyBinding("Mekanism " + LangUtils.localize("key.mode"), Keyboard.KEY_M, keybindCategory);
|
||||
public static KeyBinding armorModeSwitchKey = new KeyBinding("Mekanism " + LangUtils.localize("key.armorMode"), Keyboard.KEY_F, keybindCategory);
|
||||
public static KeyBinding voiceKey = new KeyBinding("Mekanism " + LangUtils.localize("key.voice"), Keyboard.KEY_U, keybindCategory);
|
||||
public static KeyBinding sneakKey = Minecraft.getMinecraft().gameSettings.keyBindSneak;
|
||||
public static KeyBinding jumpKey = Minecraft.getMinecraft().gameSettings.keyBindJump;
|
||||
|
||||
public MekanismKeyHandler()
|
||||
{
|
||||
super(new KeyBinding[] {modeSwitchKey, armorModeSwitchKey, voiceKey}, new boolean[] {false, false, true});
|
||||
super(new KeyBinding[] {modeSwitchKey, armorModeSwitchKey}, new boolean[] {false, false, true});
|
||||
|
||||
ClientRegistry.registerKeyBinding(modeSwitchKey);
|
||||
ClientRegistry.registerKeyBinding(armorModeSwitchKey);
|
||||
ClientRegistry.registerKeyBinding(voiceKey);
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
@@ -106,18 +102,6 @@ public class MekanismKeyHandler extends MekKeyHandler
|
||||
player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.portableTank.bucketMode") + ": " + (machine.getBucketMode(toolStack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.transOnOff(machine.getBucketMode(toolStack))));
|
||||
}
|
||||
}
|
||||
else if(player.isSneaking() && item instanceof ItemWalkieTalkie)
|
||||
{
|
||||
ItemWalkieTalkie wt = (ItemWalkieTalkie)item;
|
||||
|
||||
if(wt.getOn(toolStack))
|
||||
{
|
||||
int newChan = wt.getChannel(toolStack) < 9 ? wt.getChannel(toolStack) + 1 : 1;
|
||||
wt.setChannel(toolStack, newChan);
|
||||
Mekanism.packetHandler.sendToServer(new WalkieTalkieStateMessage(newChan));
|
||||
SoundHandler.playSound("mekanism:etc.Ding");
|
||||
}
|
||||
}
|
||||
else if(player.isSneaking() && item instanceof ItemFlamethrower)
|
||||
{
|
||||
ItemFlamethrower flamethrower = (ItemFlamethrower)item;
|
||||
|
||||
@@ -43,7 +43,6 @@ import mekanism.common.item.ItemFreeRunners;
|
||||
import mekanism.common.item.ItemGasMask;
|
||||
import mekanism.common.item.ItemRobit;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import mekanism.common.multipart.ItemGlowPanel;
|
||||
import mekanism.common.multipart.ItemPartTransmitter;
|
||||
import mekanism.common.multipart.TransmitterType;
|
||||
@@ -101,11 +100,6 @@ public class ItemRenderingHandler implements IItemRenderer
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type)
|
||||
{
|
||||
if(item.getItem() == MekanismItems.WalkieTalkie)
|
||||
{
|
||||
return type != ItemRenderType.INVENTORY;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -327,20 +321,6 @@ public class ItemRenderingHandler implements IItemRenderer
|
||||
obsidianTNT.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if(item.getItem() instanceof ItemWalkieTalkie)
|
||||
{
|
||||
if(((ItemWalkieTalkie)item.getItem()).getOn(item))
|
||||
{
|
||||
MekanismRenderer.glowOn();
|
||||
}
|
||||
|
||||
MekanismRenderer.renderItem(item);
|
||||
|
||||
if(((ItemWalkieTalkie)item.getItem()).getOn(item))
|
||||
{
|
||||
MekanismRenderer.glowOff();
|
||||
}
|
||||
}
|
||||
else if(MachineType.get(item) == MachineType.PERSONAL_CHEST)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
package mekanism.client.voice;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.Socket;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.common.Mekanism;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class VoiceClient extends Thread
|
||||
{
|
||||
public Socket socket;
|
||||
|
||||
public String ip;
|
||||
|
||||
public AudioFormat format = new AudioFormat(16000F, 16, 1, true, true);
|
||||
|
||||
public VoiceInput inputThread;
|
||||
public VoiceOutput outputThread;
|
||||
|
||||
public DataInputStream input;
|
||||
public DataOutputStream output;
|
||||
|
||||
public boolean running;
|
||||
|
||||
public VoiceClient(String s)
|
||||
{
|
||||
ip = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Mekanism.logger.info("VoiceServer: Starting client connection...");
|
||||
|
||||
try {
|
||||
socket = new Socket(ip, general.VOICE_PORT);
|
||||
running = true;
|
||||
|
||||
input = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
|
||||
output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
|
||||
|
||||
(outputThread = new VoiceOutput(this)).start();
|
||||
(inputThread = new VoiceInput(this)).start();
|
||||
|
||||
Mekanism.logger.info("VoiceServer: Successfully connected to server.");
|
||||
} catch(ConnectException e) {
|
||||
Mekanism.logger.error("VoiceServer: Server's VoiceServer is disabled.");
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while starting client connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect()
|
||||
{
|
||||
Mekanism.logger.info("VoiceServer: Stopping client connection...");
|
||||
|
||||
try {
|
||||
try {
|
||||
inputThread.interrupt();
|
||||
outputThread.interrupt();
|
||||
} catch(Exception e) {}
|
||||
|
||||
try {
|
||||
interrupt();
|
||||
} catch(Exception e) {}
|
||||
|
||||
try {
|
||||
inputThread.close();
|
||||
outputThread.close();
|
||||
} catch(Exception e) {}
|
||||
|
||||
try {
|
||||
output.flush();
|
||||
output.close();
|
||||
output = null;
|
||||
} catch(Exception e) {}
|
||||
|
||||
try {
|
||||
input.close();
|
||||
input = null;
|
||||
} catch(Exception e) {}
|
||||
|
||||
try {
|
||||
socket.close();
|
||||
socket = null;
|
||||
} catch(Exception e) {}
|
||||
|
||||
|
||||
running = false;
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while stopping client connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package mekanism.client.voice;
|
||||
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.DataLine;
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
|
||||
import mekanism.client.MekanismKeyHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class VoiceInput extends Thread
|
||||
{
|
||||
public VoiceClient voiceClient;
|
||||
|
||||
public DataLine.Info microphone;
|
||||
|
||||
public TargetDataLine targetLine;
|
||||
|
||||
public VoiceInput(VoiceClient client)
|
||||
{
|
||||
voiceClient = client;
|
||||
microphone = new DataLine.Info(TargetDataLine.class, voiceClient.format, 2200);
|
||||
|
||||
setDaemon(true);
|
||||
setName("VoiceServer Client Input Thread");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
targetLine = ((TargetDataLine)AudioSystem.getLine(microphone));
|
||||
targetLine.open(voiceClient.format, 2200);
|
||||
targetLine.start();
|
||||
AudioInputStream audioInput = new AudioInputStream(targetLine);
|
||||
|
||||
boolean doFlush = false;
|
||||
|
||||
while(voiceClient.running)
|
||||
{
|
||||
if(MekanismKeyHandler.voiceKey.getIsKeyPressed())
|
||||
{
|
||||
targetLine.flush();
|
||||
|
||||
while(voiceClient.running && MekanismKeyHandler.voiceKey.getIsKeyPressed())
|
||||
{
|
||||
try {
|
||||
int availableBytes = audioInput.available();
|
||||
byte[] audioData = new byte[availableBytes > 2200 ? 2200 : availableBytes];
|
||||
int bytesRead = audioInput.read(audioData, 0, audioData.length);
|
||||
|
||||
if(bytesRead > 0)
|
||||
{
|
||||
voiceClient.output.writeShort(audioData.length);
|
||||
voiceClient.output.write(audioData);
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(200L);
|
||||
} catch(Exception e) {}
|
||||
|
||||
doFlush = true;
|
||||
}
|
||||
else if(doFlush)
|
||||
{
|
||||
try {
|
||||
voiceClient.output.flush();
|
||||
} catch(Exception e) {}
|
||||
|
||||
doFlush = false;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(20L);
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
audioInput.close();
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while running client input thread.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
targetLine.flush();
|
||||
targetLine.close();
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package mekanism.client.voice;
|
||||
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.DataLine;
|
||||
import javax.sound.sampled.SourceDataLine;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class VoiceOutput extends Thread
|
||||
{
|
||||
public VoiceClient voiceClient;
|
||||
|
||||
public DataLine.Info speaker;
|
||||
|
||||
public SourceDataLine sourceLine;
|
||||
|
||||
public VoiceOutput(VoiceClient client)
|
||||
{
|
||||
voiceClient = client;
|
||||
speaker = new DataLine.Info(SourceDataLine.class, voiceClient.format, 2200);
|
||||
|
||||
setDaemon(true);
|
||||
setName("VoiceServer Client Output Thread");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
sourceLine = ((SourceDataLine)AudioSystem.getLine(speaker));
|
||||
sourceLine.open(voiceClient.format, 2200);
|
||||
sourceLine.start();
|
||||
|
||||
while(voiceClient.running)
|
||||
{
|
||||
try {
|
||||
short byteCount = voiceClient.input.readShort();
|
||||
byte[] audioData = new byte[byteCount];
|
||||
voiceClient.input.readFully(audioData);
|
||||
|
||||
sourceLine.write(audioData, 0, audioData.length);
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while running client output thread.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
sourceLine.flush();
|
||||
sourceLine.close();
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,6 @@ public class CommonProxy implements IGuiProvider
|
||||
general.controlCircuitOreDict = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ControlCircuitOreDict", true).getBoolean();
|
||||
general.logPackets = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "LogPackets", false).getBoolean();
|
||||
general.dynamicTankEasterEgg = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DynamicTankEasterEgg", false).getBoolean();
|
||||
general.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", false).getBoolean();
|
||||
general.cardboardSpawners = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true).getBoolean();
|
||||
general.enableWorldRegeneration = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableWorldRegeneration", false).getBoolean();
|
||||
general.enableBoPProgression = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "enableBoPProgression", true).getBoolean();
|
||||
@@ -275,7 +274,6 @@ public class CommonProxy implements IGuiProvider
|
||||
general.METHANE_BURN_TIME = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MethaneBurnTime", 10).getInt();
|
||||
general.ENERGY_PER_REDSTONE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000D).getDouble();
|
||||
general.DISASSEMBLER_USAGE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisassemblerEnergyUsage", 10).getInt();
|
||||
general.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123, null, 1, 65535).getInt();
|
||||
//If this is less than 1, upgrades make machines worse. If less than 0, I don't even know.
|
||||
general.maxUpgradeMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpgradeModifier", 10, null, 1, Integer.MAX_VALUE).getInt();
|
||||
general.minerSilkMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MinerSilkMultiplier", 6).getDouble();
|
||||
@@ -485,7 +483,6 @@ public class CommonProxy implements IGuiProvider
|
||||
recipes.enableTeleporterCore = Mekanism.configurationrecipes.get("Recipes","enableTeleporterCore", true).getBoolean();
|
||||
recipes.enableConfigurator = Mekanism.configurationrecipes.get("Recipes","enableConfigurator", true).getBoolean();
|
||||
recipes.enableNetworkReader = Mekanism.configurationrecipes.get("Recipes","enableNetworkReader", true).getBoolean();
|
||||
recipes.enableWalkieTalkie = Mekanism.configurationrecipes.get("Recipes","enableWalkieTalkie", true).getBoolean();
|
||||
recipes.enableJetpacks = Mekanism.configurationrecipes.get("Recipes","enableJetpacks", true).getBoolean();
|
||||
recipes.enableScubaSet = Mekanism.configurationrecipes.get("Recipes","enableScubaSet", true).getBoolean();
|
||||
recipes.enableFreeRunners = Mekanism.configurationrecipes.get("Recipes","enableFreeRunners", true).getBoolean();
|
||||
|
||||
@@ -85,7 +85,6 @@ import mekanism.common.tile.TileEntitySuperheatingElement;
|
||||
import mekanism.common.tile.TileEntityThermalEvaporationBlock;
|
||||
import mekanism.common.tile.TileEntityThermalEvaporationValve;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.voice.VoiceServerManager;
|
||||
import mekanism.common.world.GenHandler;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -194,9 +193,6 @@ public class Mekanism
|
||||
/** The recent news which is received from the Mekanism server */
|
||||
public static String recentNews;
|
||||
|
||||
/** The VoiceServer manager for walkie talkies */
|
||||
public static VoiceServerManager voiceManager;
|
||||
|
||||
/** A list of the usernames of players who have donated to Mekanism. */
|
||||
public static List<String> donators = new ArrayList<String>();
|
||||
|
||||
@@ -1362,10 +1358,6 @@ public class Mekanism
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
if(general.voiceServerEnabled)
|
||||
{
|
||||
voiceManager.start();
|
||||
}
|
||||
|
||||
//Load cached furnace recipes
|
||||
Recipe.ENERGIZED_SMELTER.get().clear();
|
||||
|
||||
@@ -32,7 +32,6 @@ import mekanism.common.item.ItemScubaTank;
|
||||
import mekanism.common.item.ItemSeismicReader;
|
||||
import mekanism.common.item.ItemShard;
|
||||
import mekanism.common.item.ItemUpgrade;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import mekanism.common.multipart.ItemGlowPanel;
|
||||
import mekanism.common.multipart.ItemPartTransmitter;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -77,7 +76,6 @@ public class MekanismItems
|
||||
public static final ItemPortableTeleporter PortableTeleporter = (ItemPortableTeleporter)new ItemPortableTeleporter().setUnlocalizedName("PortableTeleporter");
|
||||
public static final ItemConfigurator Configurator = (ItemConfigurator)new ItemConfigurator().setUnlocalizedName("Configurator");
|
||||
public static final ItemNetworkReader NetworkReader = (ItemNetworkReader)new ItemNetworkReader().setUnlocalizedName("NetworkReader");
|
||||
public static final Item WalkieTalkie = new ItemWalkieTalkie().setUnlocalizedName("WalkieTalkie");
|
||||
public static final ItemElectricBow ElectricBow = (ItemElectricBow)new ItemElectricBow().setUnlocalizedName("ElectricBow");
|
||||
public static final ItemFlamethrower Flamethrower = (ItemFlamethrower)new ItemFlamethrower().setUnlocalizedName("Flamethrower");
|
||||
public static final ItemSeismicReader SeismicReader = (ItemSeismicReader)new ItemSeismicReader().setUnlocalizedName("SeismicReader");
|
||||
@@ -142,7 +140,6 @@ public class MekanismItems
|
||||
GameRegistry.registerItem(DirtyDust, "DirtyDust");
|
||||
GameRegistry.registerItem(Configurator, "Configurator");
|
||||
GameRegistry.registerItem(NetworkReader, "NetworkReader");
|
||||
GameRegistry.registerItem(WalkieTalkie, "WalkieTalkie");
|
||||
GameRegistry.registerItem(Jetpack, "Jetpack");
|
||||
GameRegistry.registerItem(Dictionary, "Dictionary");
|
||||
GameRegistry.registerItem(GasMask, "GasMask");
|
||||
|
||||
@@ -67,8 +67,6 @@ import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.network.PacketTransmitterUpdate;
|
||||
import mekanism.common.network.PacketTransmitterUpdate.TransmitterUpdateMessage;
|
||||
import mekanism.common.network.PacketWalkieTalkieState;
|
||||
import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -113,7 +111,6 @@ public class PacketHandler
|
||||
netHandler.registerMessage(PacketPortableTeleporter.class, PortableTeleporterMessage.class, 10, Side.SERVER);
|
||||
netHandler.registerMessage(PacketRemoveUpgrade.class, RemoveUpgradeMessage.class, 11, Side.SERVER);
|
||||
netHandler.registerMessage(PacketRedstoneControl.class, RedstoneControlMessage.class, 12, Side.SERVER);
|
||||
netHandler.registerMessage(PacketWalkieTalkieState.class, WalkieTalkieStateMessage.class, 13, Side.SERVER);
|
||||
netHandler.registerMessage(PacketLogisticalSorterGui.class, LogisticalSorterGuiMessage.class, 14, Side.CLIENT);
|
||||
netHandler.registerMessage(PacketLogisticalSorterGui.class, LogisticalSorterGuiMessage.class, 14, Side.SERVER);
|
||||
netHandler.registerMessage(PacketNewFilter.class, NewFilterMessage.class, 15, Side.SERVER);
|
||||
|
||||
@@ -156,11 +156,6 @@ public final class OreDictManager
|
||||
" B ", "ECE", "OOO", Character.valueOf('B'), Items.bucket, Character.valueOf('E'), MekanismItems.EnrichedAlloy, Character.valueOf('C'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('O'), "ingot" + s
|
||||
}));
|
||||
}
|
||||
if (MekanismConfig.recipes.enableWalkieTalkie) {
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.WalkieTalkie), new Object[]{
|
||||
" O", "SCS", " S ", Character.valueOf('O'), "ingot" + s, Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), MekanismUtils.getControlCircuit(Tier.BaseTier.BASIC)
|
||||
}));
|
||||
}
|
||||
|
||||
if (MekanismConfig.recipes.enableElectroliticCore) {
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.ElectrolyticCore), new Object[]{
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
package mekanism.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemWalkieTalkie extends ItemMekanism
|
||||
{
|
||||
public IIcon[] icons = new IIcon[256];
|
||||
|
||||
public ItemWalkieTalkie()
|
||||
{
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
|
||||
{
|
||||
super.addInformation(itemstack, entityplayer, list, flag);
|
||||
|
||||
list.add((getOn(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.localize("gui." + (getOn(itemstack) ? "on" : "off")));
|
||||
list.add(EnumColor.DARK_AQUA + LangUtils.localize("tooltip.channel") + ": " + EnumColor.GREY + getChannel(itemstack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconIndex(ItemStack itemStack)
|
||||
{
|
||||
if(!getOn(itemStack))
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
return icons[getChannel(itemStack)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register)
|
||||
{
|
||||
icons[0] = register.registerIcon("mekanism:WalkieTalkieOff");
|
||||
|
||||
for(int i = 1; i <= 9; i++)
|
||||
{
|
||||
icons[i] = register.registerIcon("mekanism:WalkieTalkie_ch" + i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
|
||||
{
|
||||
if(player.isSneaking())
|
||||
{
|
||||
setOn(itemStack, !getOn(itemStack));
|
||||
}
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public void setOn(ItemStack itemStack, boolean on)
|
||||
{
|
||||
if(itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.stackTagCompound.setBoolean("on", on);
|
||||
}
|
||||
|
||||
public boolean getOn(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.stackTagCompound == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getBoolean("on");
|
||||
}
|
||||
|
||||
public void setChannel(ItemStack itemStack, int channel)
|
||||
{
|
||||
if(itemStack.stackTagCompound == null)
|
||||
{
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
itemStack.stackTagCompound.setInteger("channel", channel);
|
||||
}
|
||||
|
||||
public int getChannel(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.stackTagCompound == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int channel = itemStack.stackTagCompound.getInteger("channel");
|
||||
|
||||
if(channel == 0)
|
||||
{
|
||||
setChannel(itemStack, 1);
|
||||
}
|
||||
|
||||
return itemStack.stackTagCompound.getInteger("channel");
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,6 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
dataStream.writeBoolean(general.controlCircuitOreDict);
|
||||
dataStream.writeBoolean(general.logPackets);
|
||||
dataStream.writeBoolean(general.dynamicTankEasterEgg);
|
||||
dataStream.writeBoolean(general.voiceServerEnabled);
|
||||
dataStream.writeBoolean(general.cardboardSpawners);
|
||||
dataStream.writeBoolean(general.spawnBabySkeletons);
|
||||
dataStream.writeBoolean(general.enableBoPProgression);
|
||||
@@ -49,7 +48,6 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
dataStream.writeInt(general.METHANE_BURN_TIME);
|
||||
dataStream.writeDouble(general.ENERGY_PER_REDSTONE);
|
||||
dataStream.writeDouble(general.DISASSEMBLER_USAGE);
|
||||
dataStream.writeInt(general.VOICE_PORT);
|
||||
dataStream.writeInt(general.maxUpgradeMultiplier);
|
||||
dataStream.writeInt(general.energyUnit.ordinal());
|
||||
dataStream.writeDouble(general.minerSilkMultiplier);
|
||||
@@ -196,7 +194,6 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
dataStream.writeBoolean(recipes.enableTeleporterCore);
|
||||
dataStream.writeBoolean(recipes.enableConfigurator);
|
||||
dataStream.writeBoolean(recipes.enableNetworkReader);
|
||||
dataStream.writeBoolean(recipes.enableWalkieTalkie);
|
||||
dataStream.writeBoolean(recipes.enableJetpacks);
|
||||
dataStream.writeBoolean(recipes.enableScubaSet);
|
||||
dataStream.writeBoolean(recipes.enableFreeRunners);
|
||||
@@ -228,7 +225,6 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
general.controlCircuitOreDict = dataStream.readBoolean();
|
||||
general.logPackets = dataStream.readBoolean();
|
||||
general.dynamicTankEasterEgg = dataStream.readBoolean();
|
||||
general.voiceServerEnabled = dataStream.readBoolean();
|
||||
general.cardboardSpawners = dataStream.readBoolean();
|
||||
general.spawnBabySkeletons = dataStream.readBoolean();
|
||||
general.enableBoPProgression = dataStream.readBoolean();
|
||||
@@ -244,7 +240,6 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
general.METHANE_BURN_TIME = dataStream.readInt();
|
||||
general.ENERGY_PER_REDSTONE = dataStream.readDouble();
|
||||
general.DISASSEMBLER_USAGE = dataStream.readDouble();
|
||||
general.VOICE_PORT = dataStream.readInt();
|
||||
general.maxUpgradeMultiplier = dataStream.readInt();
|
||||
general.energyUnit = EnergyType.values()[dataStream.readInt()];
|
||||
general.minerSilkMultiplier = dataStream.readDouble();
|
||||
@@ -391,7 +386,6 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
recipes.enableTeleporterCore = dataStream.readBoolean();
|
||||
recipes.enableConfigurator = dataStream.readBoolean();
|
||||
recipes.enableNetworkReader = dataStream.readBoolean();
|
||||
recipes.enableWalkieTalkie = dataStream.readBoolean();
|
||||
recipes.enableJetpacks = dataStream.readBoolean();
|
||||
recipes.enableScubaSet = dataStream.readBoolean();
|
||||
recipes.enableFreeRunners = dataStream.readBoolean();
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package mekanism.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketWalkieTalkieState implements IMessageHandler<WalkieTalkieStateMessage, IMessage>
|
||||
{
|
||||
@Override
|
||||
public IMessage onMessage(WalkieTalkieStateMessage message, MessageContext context)
|
||||
{
|
||||
ItemStack itemstack = PacketHandler.getPlayer(context).getCurrentEquippedItem();
|
||||
|
||||
if(itemstack != null && itemstack.getItem() instanceof ItemWalkieTalkie)
|
||||
{
|
||||
((ItemWalkieTalkie)itemstack.getItem()).setChannel(itemstack, message.channel);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class WalkieTalkieStateMessage implements IMessage
|
||||
{
|
||||
public int channel;
|
||||
|
||||
public WalkieTalkieStateMessage() {}
|
||||
|
||||
public WalkieTalkieStateMessage(int chan)
|
||||
{
|
||||
channel = chan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf dataStream)
|
||||
{
|
||||
dataStream.writeInt(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf dataStream)
|
||||
{
|
||||
channel = dataStream.readInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
package mekanism.common.voice;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class VoiceConnection extends Thread
|
||||
{
|
||||
public Socket socket;
|
||||
|
||||
public String username;
|
||||
|
||||
public boolean open = true;
|
||||
|
||||
public DataInputStream input;
|
||||
public DataOutputStream output;
|
||||
|
||||
public MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
|
||||
public VoiceConnection(Socket s)
|
||||
{
|
||||
socket = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
input = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
|
||||
output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
|
||||
|
||||
synchronized(Mekanism.voiceManager)
|
||||
{
|
||||
int retryCount = 0;
|
||||
|
||||
while(username == null && retryCount <= 100)
|
||||
{
|
||||
try {
|
||||
List l = Collections.synchronizedList((List)((ArrayList)server.getConfigurationManager().playerEntityList).clone());
|
||||
|
||||
for(Object obj : l)
|
||||
{
|
||||
if(obj instanceof EntityPlayerMP)
|
||||
{
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP)obj;
|
||||
String playerIP = playerMP.getPlayerIP();
|
||||
|
||||
if(!server.isDedicatedServer() && playerIP.equals("local") && !Mekanism.voiceManager.foundLocal)
|
||||
{
|
||||
Mekanism.voiceManager.foundLocal = true;
|
||||
username = playerMP.getCommandSenderName();
|
||||
break;
|
||||
}
|
||||
else if(playerIP.equals(socket.getInetAddress().getHostAddress()))
|
||||
{
|
||||
username = playerMP.getCommandSenderName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
retryCount++;
|
||||
Thread.sleep(50);
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
if(username == null)
|
||||
{
|
||||
Mekanism.logger.error("VoiceServer: Unable to trace connection's IP address.");
|
||||
kill();
|
||||
return;
|
||||
}
|
||||
else {
|
||||
Mekanism.logger.info("VoiceServer: Traced IP in " + retryCount + " attempts.");
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while starting server-based connection.");
|
||||
e.printStackTrace();
|
||||
open = false;
|
||||
}
|
||||
|
||||
//Main client listen thread
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
while(open)
|
||||
{
|
||||
try {
|
||||
short byteCount = VoiceConnection.this.input.readShort();
|
||||
byte[] audioData = new byte[byteCount];
|
||||
VoiceConnection.this.input.readFully(audioData);
|
||||
|
||||
if(byteCount > 0)
|
||||
{
|
||||
Mekanism.voiceManager.sendToPlayers(byteCount, audioData, VoiceConnection.this);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
open = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!open)
|
||||
{
|
||||
kill();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void kill()
|
||||
{
|
||||
try {
|
||||
input.close();
|
||||
output.close();
|
||||
socket.close();
|
||||
|
||||
Mekanism.voiceManager.connections.remove(this);
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while stopping server-based connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendToPlayer(short byteCount, byte[] audioData, VoiceConnection connection)
|
||||
{
|
||||
if(!open)
|
||||
{
|
||||
kill();
|
||||
}
|
||||
|
||||
try {
|
||||
output.writeShort(byteCount);
|
||||
output.write(audioData);
|
||||
|
||||
output.flush();
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while sending data to player.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canListen(int channel)
|
||||
{
|
||||
for(ItemStack itemStack : getPlayer().inventory.mainInventory)
|
||||
{
|
||||
if(itemStack != null)
|
||||
{
|
||||
if(itemStack.getItem() instanceof ItemWalkieTalkie)
|
||||
{
|
||||
if(((ItemWalkieTalkie)itemStack.getItem()).getOn(itemStack))
|
||||
{
|
||||
if(((ItemWalkieTalkie)itemStack.getItem()).getChannel(itemStack) == channel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getCurrentChannel()
|
||||
{
|
||||
ItemStack itemStack = getPlayer().getCurrentEquippedItem();
|
||||
|
||||
if(itemStack != null)
|
||||
{
|
||||
ItemWalkieTalkie walkieTalkie = (ItemWalkieTalkie)itemStack.getItem();
|
||||
|
||||
if(walkieTalkie != null)
|
||||
{
|
||||
if(walkieTalkie.getOn(itemStack))
|
||||
{
|
||||
return walkieTalkie.getChannel(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public EntityPlayerMP getPlayer()
|
||||
{
|
||||
return server.getConfigurationManager().func_152612_a(username); //TODO getPlayerForUsername
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package mekanism.common.voice;
|
||||
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mekanism.api.MekanismConfig.general;
|
||||
import mekanism.common.Mekanism;
|
||||
|
||||
public class VoiceServerManager
|
||||
{
|
||||
public Set<VoiceConnection> connections = new HashSet<VoiceConnection>();
|
||||
|
||||
public ServerSocket serverSocket;
|
||||
|
||||
public boolean running;
|
||||
|
||||
public boolean foundLocal = false;
|
||||
|
||||
public Thread listenThread;
|
||||
|
||||
public void start()
|
||||
{
|
||||
Mekanism.logger.info("VoiceServer: Starting up server...");
|
||||
|
||||
try {
|
||||
running = true;
|
||||
serverSocket = new ServerSocket(general.VOICE_PORT);
|
||||
(listenThread = new ListenThread()).start();
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
try {
|
||||
Mekanism.logger.info("VoiceServer: Shutting down server...");
|
||||
|
||||
try {
|
||||
listenThread.interrupt();
|
||||
} catch(Exception e) {}
|
||||
|
||||
foundLocal = false;
|
||||
|
||||
try {
|
||||
serverSocket.close();
|
||||
serverSocket = null;
|
||||
} catch(Exception e) {}
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while shutting down server.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
running = false;
|
||||
}
|
||||
|
||||
public void sendToPlayers(short byteCount, byte[] audioData, VoiceConnection connection)
|
||||
{
|
||||
if(connection.getPlayer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int channel = connection.getCurrentChannel();
|
||||
|
||||
if(channel == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(VoiceConnection iterConn : connections)
|
||||
{
|
||||
if(iterConn.getPlayer() == null || iterConn == connection || !iterConn.canListen(channel))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
iterConn.sendToPlayer(byteCount, audioData, connection);
|
||||
}
|
||||
}
|
||||
|
||||
public class ListenThread extends Thread
|
||||
{
|
||||
public ListenThread()
|
||||
{
|
||||
setDaemon(true);
|
||||
setName("VoiceServer Listen Thread");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
while(running)
|
||||
{
|
||||
try {
|
||||
Socket s = serverSocket.accept();
|
||||
VoiceConnection connection = new VoiceConnection(s);
|
||||
connection.start();
|
||||
connections.add(connection);
|
||||
|
||||
Mekanism.logger.info("VoiceServer: Accepted new connection.");
|
||||
} catch(SocketException e) {
|
||||
} catch(NullPointerException e) {
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while accepting connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user