Fixes, added commands, version to 1.2
Fixed /tbm-enable and /tbm-disable not working in singleplayer. Added /tbm-enable-all and /tbm-disable-all to enable/disable for all players.
This commit is contained in:
parent
8e473c8649
commit
cbe2476990
8 changed files with 169 additions and 4 deletions
|
@ -10,7 +10,7 @@ buildscript {
|
|||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||
|
||||
version = "1.1"
|
||||
version = "1.2"
|
||||
group = "com.seodisparate.TurnBasedMinecraft" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "TurnBasedMinecraft"
|
||||
|
||||
|
|
|
@ -35,10 +35,11 @@ public class CommandTBMDisable extends CommandBase
|
|||
{
|
||||
EntityPlayerMP player = null;
|
||||
player = getCommandSenderAsPlayer(sender);
|
||||
if(!config.getIfOnlyOPsCanDisableTurnBasedForSelf() || player.getServer().getPlayerList().getOppedPlayers().getEntry(player.getGameProfile()) != null)
|
||||
if(!config.getIfOnlyOPsCanDisableTurnBasedForSelf() || player.getServer().isSinglePlayer() || player.getServer().getPlayerList().getOppedPlayers().getEntry(player.getGameProfile()) != null)
|
||||
{
|
||||
config.addBattleIgnoringPlayer(player.getEntityId());
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Disabled turn-based-combat for current player"), player);
|
||||
TurnBasedMinecraftMod.logger.info("Disabled turn-based-combat for " + player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package com.seodisparate.TurnBasedMinecraft.common;
|
||||
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class CommandTBMDisableAll extends CommandBase
|
||||
{
|
||||
public static final String usage = "/tbm-disable-all (Disables turn-based-battle for everyone";
|
||||
private Config config;
|
||||
|
||||
public CommandTBMDisableAll(Config config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "tbm-disable-all";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender)
|
||||
{
|
||||
return usage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
|
||||
{
|
||||
config.setBattleDisabledForAll(true);
|
||||
for(Entity player : server.getPlayerList().getPlayers())
|
||||
{
|
||||
config.addBattleIgnoringPlayer(player.getEntityId());
|
||||
}
|
||||
EntityPlayerMP senderPlayer = null;
|
||||
try {
|
||||
senderPlayer = getCommandSenderAsPlayer(sender);
|
||||
} catch(Throwable t)
|
||||
{
|
||||
// Ignore case when sender EntityPlayer cannot be found
|
||||
}
|
||||
if(senderPlayer != null)
|
||||
{
|
||||
TurnBasedMinecraftMod.logger.info(senderPlayer.getName() + " disabled turn-based-combat for everyone");
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("You disabled turn-based-combat for everyone"), senderPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
TurnBasedMinecraftMod.logger.info("An admin disabled turn-based-combat for everyone");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
|
@ -35,10 +35,11 @@ public class CommandTBMEnable extends CommandBase
|
|||
{
|
||||
EntityPlayerMP player = null;
|
||||
player = getCommandSenderAsPlayer(sender);
|
||||
if(!config.getIfOnlyOPsCanDisableTurnBasedForSelf() || player.getServer().getPlayerList().getOppedPlayers().getEntry(player.getGameProfile()) != null)
|
||||
if(!config.getIfOnlyOPsCanDisableTurnBasedForSelf() || player.getServer().isSinglePlayer() || player.getServer().getPlayerList().getOppedPlayers().getEntry(player.getGameProfile()) != null)
|
||||
{
|
||||
config.removeBattleIgnoringPlayer(player.getEntityId());
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Enabled turn-based-combat for current player"), player);
|
||||
TurnBasedMinecraftMod.logger.info("Enabled turn-based-combat for " + player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package com.seodisparate.TurnBasedMinecraft.common;
|
||||
|
||||
import com.seodisparate.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class CommandTBMEnableAll extends CommandBase
|
||||
{
|
||||
public static final String usage = "/tbm-enable-all (enables turn-based-combat for everyone)";
|
||||
private Config config;
|
||||
|
||||
public CommandTBMEnableAll(Config config)
|
||||
{
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "tbm-enable-all";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender)
|
||||
{
|
||||
return usage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
|
||||
{
|
||||
config.setBattleDisabledForAll(false);
|
||||
config.clearBattleIgnoringPlayers();
|
||||
EntityPlayerMP senderPlayer = null;
|
||||
try {
|
||||
senderPlayer = getCommandSenderAsPlayer(sender);
|
||||
} catch(Throwable t)
|
||||
{
|
||||
// Ignore case when sender EntityPlayer cannot be found
|
||||
}
|
||||
if(senderPlayer != null)
|
||||
{
|
||||
TurnBasedMinecraftMod.logger.info(senderPlayer.getName() + " enabled turn-based-combat for everyone");
|
||||
TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("You enabled turn-based-combat for everyone"), senderPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
TurnBasedMinecraftMod.logger.info("An admin enabled turn-based-combat for everyone");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ public class Config
|
|||
private int configVersion = 0;
|
||||
private Set<Integer> battleIgnoringPlayers = null;
|
||||
private boolean onlyOPsSelfDisableTB = true;
|
||||
private boolean battleDisabledForAll = false;
|
||||
|
||||
public Config(Logger logger)
|
||||
{
|
||||
|
@ -606,4 +607,14 @@ public class Config
|
|||
{
|
||||
return onlyOPsSelfDisableTB;
|
||||
}
|
||||
|
||||
protected void setBattleDisabledForAll(boolean isDisabled)
|
||||
{
|
||||
battleDisabledForAll = isDisabled;
|
||||
}
|
||||
|
||||
protected boolean getBattleDisabledForAll()
|
||||
{
|
||||
return battleDisabledForAll;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.seodisparate.TurnBasedMinecraft.common;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class PlayerJoinEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void entityJoinHandler(EntityJoinWorldEvent event)
|
||||
{
|
||||
if(event.getEntity().world.isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(event.getEntity() instanceof EntityPlayer && TurnBasedMinecraftMod.proxy.getConfig().getBattleDisabledForAll())
|
||||
{
|
||||
TurnBasedMinecraftMod.proxy.getConfig().addBattleIgnoringPlayer(event.getEntity().getEntityId());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ public class TurnBasedMinecraftMod
|
|||
{
|
||||
public static final String MODID = "com.seodisparate.turnbasedminecraft";
|
||||
public static final String NAME = "Turn Based Minecraft Mod";
|
||||
public static final String VERSION = "1.1";
|
||||
public static final String VERSION = "1.2";
|
||||
public static final String CONFIG_FILENAME = "TBM_Config.xml";
|
||||
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
|
||||
public static final String CONFIG_FILE_PATH = CONFIG_DIRECTORY + CONFIG_FILENAME;
|
||||
|
@ -83,6 +83,7 @@ public class TurnBasedMinecraftMod
|
|||
|
||||
// register event handler(s)
|
||||
MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -106,6 +107,8 @@ public class TurnBasedMinecraftMod
|
|||
event.registerServerCommand(new CommandTBMDisable(proxy.getConfig()));
|
||||
event.registerServerCommand(new CommandTBMEnable(proxy.getConfig()));
|
||||
event.registerServerCommand(new CommandTBMSet(proxy.getConfig()));
|
||||
event.registerServerCommand(new CommandTBMDisableAll(proxy.getConfig()));
|
||||
event.registerServerCommand(new CommandTBMEnableAll(proxy.getConfig()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
Loading…
Reference in a new issue