use of net.geforcemods.securitycraft.api.IPasswordProtected in project SecurityCraft by Geforce132.
the class ItemAdminTool method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
if (worldIn.getTileEntity(pos) != null) {
TileEntity te = worldIn.getTileEntity(pos);
boolean hasInfo = false;
if (te instanceof IOwnable) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.owner.name").replace("#", (((IOwnable) te).getOwner().getName() == null ? "????" : ((IOwnable) te).getOwner().getName())), TextFormatting.DARK_PURPLE);
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.owner.uuid").replace("#", (((IOwnable) te).getOwner().getUUID() == null ? "????" : ((IOwnable) te).getOwner().getUUID())), TextFormatting.DARK_PURPLE);
hasInfo = true;
}
if (te instanceof IPasswordProtected) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.password").replace("#", (((IPasswordProtected) te).getPassword() == null ? "????" : ((IPasswordProtected) te).getPassword())), TextFormatting.DARK_PURPLE);
hasInfo = true;
}
if (te instanceof CustomizableSCTE) {
List<EnumCustomModules> modules = ((CustomizableSCTE) te).getModules();
if (!modules.isEmpty()) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.equippedModules"), TextFormatting.DARK_PURPLE);
for (EnumCustomModules module : modules) PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), "-" + module.getName(), TextFormatting.DARK_PURPLE);
hasInfo = true;
}
}
if (!hasInfo)
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
return EnumActionResult.FAIL;
}
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
}
return EnumActionResult.FAIL;
}
use of net.geforcemods.securitycraft.api.IPasswordProtected in project SecurityCraft by Geforce132.
the class ItemAdminTool method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
if (worldIn.getTileEntity(pos) != null) {
TileEntity te = worldIn.getTileEntity(pos);
boolean hasInfo = false;
if (te instanceof IOwnable) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.owner.name").replace("#", (((IOwnable) te).getOwner().getName() == null ? "????" : ((IOwnable) te).getOwner().getName())), TextFormatting.DARK_PURPLE);
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.owner.uuid").replace("#", (((IOwnable) te).getOwner().getUUID() == null ? "????" : ((IOwnable) te).getOwner().getUUID())), TextFormatting.DARK_PURPLE);
hasInfo = true;
}
if (te instanceof IPasswordProtected) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.password").replace("#", (((IPasswordProtected) te).getPassword() == null ? "????" : ((IPasswordProtected) te).getPassword())), TextFormatting.DARK_PURPLE);
hasInfo = true;
}
if (te instanceof CustomizableSCTE) {
List<EnumCustomModules> modules = ((CustomizableSCTE) te).getModules();
if (!modules.isEmpty()) {
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.equippedModules"), TextFormatting.DARK_PURPLE);
for (EnumCustomModules module : modules) PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), "-" + module.getName(), TextFormatting.DARK_PURPLE);
hasInfo = true;
}
}
if (!hasInfo)
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
return EnumActionResult.FAIL;
}
PlayerUtils.sendMessageToPlayer(playerIn, ClientUtils.localize("item.adminTool.name"), ClientUtils.localize("messages.adminTool.noInfo"), TextFormatting.DARK_PURPLE);
}
return EnumActionResult.FAIL;
}
use of net.geforcemods.securitycraft.api.IPasswordProtected in project SecurityCraft by Geforce132.
the class GuiSCManual method updateRecipeAndIcons.
private void updateRecipeAndIcons() {
if (currentPage < 0) {
recipe = null;
hoverCheckers.clear();
return;
}
hoverCheckers.clear();
if (SecurityCraft.instance.manualPages.get(currentPage).hasCustomRecipe())
recipe = SecurityCraft.instance.manualPages.get(currentPage).getRecipe();
else
for (Object object : CraftingManager.getInstance().getRecipeList()) {
if (object instanceof ShapedRecipes) {
ShapedRecipes recipe = (ShapedRecipes) object;
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
this.recipe = recipe.recipeItems;
break;
}
} else if (object instanceof ShapelessRecipes) {
ShapelessRecipes recipe = (ShapelessRecipes) object;
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() == SecurityCraft.instance.manualPages.get(currentPage).getItem()) {
this.recipe = toItemStackArray(recipe.recipeItems);
break;
}
}
recipe = null;
}
if (recipe != null) {
outer: for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if ((i * 3) + j == recipe.length)
break outer;
if (recipe[(i * 3) + j] != null)
hoverCheckers.add(new CustomHoverChecker(144 + (i * 20), 144 + (i * 20) + 16, (k + 100) + (j * 20), (k + 100) + (j * 20) + 16, 20, recipe[(i * 3) + j].getDisplayName()));
}
}
} else if (SecurityCraft.instance.manualPages.get(currentPage).isRecipeDisabled())
hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.disabled")));
else if (SecurityCraft.instance.manualPages.get(currentPage).getHelpInfo().equals("help.reinforced.info"))
hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.recipe.reinforced")));
else {
String name = SecurityCraft.instance.manualPages.get(currentPage).getItem().getUnlocalizedName().substring(5);
hoverCheckers.add(new CustomHoverChecker(144, 144 + (2 * 20) + 16, k + 100, (k + 100) + (2 * 20) + 16, 20, StatCollector.translateToLocal("gui.scManual.recipe." + name)));
}
Item item = SecurityCraft.instance.manualPages.get(currentPage).getItem();
TileEntity te = ((item instanceof ItemBlock && ((ItemBlock) item).getBlock() instanceof ITileEntityProvider) ? ((ITileEntityProvider) ((ItemBlock) item).getBlock()).createNewTileEntity(Minecraft.getMinecraft().theWorld, 0) : null);
Block itemBlock = ((item instanceof ItemBlock) ? ((ItemBlock) item).getBlock() : null);
if (te != null) {
if (te instanceof IOwnable)
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 29, (k + 29) + 16, 20, StatCollector.translateToLocal("gui.scManual.ownableBlock")));
if (te instanceof IPasswordProtected)
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 55, (k + 55) + 16, 20, StatCollector.translateToLocal("gui.scManual.passwordProtectedBlock")));
if (te instanceof TileEntitySCTE && ((TileEntitySCTE) te).isActivatedByView())
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 81, (k + 81) + 16, 20, StatCollector.translateToLocal("gui.scManual.viewActivatedBlock")));
if (itemBlock instanceof IExplosive)
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 107, (k + 107) + 16, 20, StatCollector.translateToLocal("gui.scManual.explosiveBlock")));
if (te instanceof CustomizableSCTE)
hoverCheckers.add(new CustomHoverChecker(118, 118 + 16, k + 213, (k + 213) + 16, 20, StatCollector.translateToLocal("gui.scManual.customizableBlock")));
}
}
use of net.geforcemods.securitycraft.api.IPasswordProtected in project SecurityCraft by Geforce132.
the class GuiSetPassword method actionPerformed.
@Override
protected void actionPerformed(GuiButton guibutton) {
switch(guibutton.id) {
case 0:
if (keycodeTextbox.getText().isEmpty()) {
flag = true;
updateButtonText();
return;
}
((IPasswordProtected) tileEntity).setPassword(keycodeTextbox.getText());
SecurityCraft.network.sendToServer(new PacketSSetPassword(tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ(), keycodeTextbox.getText()));
ClientUtils.closePlayerScreen();
Minecraft.getMinecraft().thePlayer.openGui(SecurityCraft.instance, GuiHandler.INSERT_PASSWORD_ID, tileEntity.getWorld(), tileEntity.getPos().getX(), tileEntity.getPos().getY(), tileEntity.getPos().getZ());
}
}
use of net.geforcemods.securitycraft.api.IPasswordProtected in project SecurityCraft by Geforce132.
the class SCEventHandler method handleCodebreaking.
private boolean handleCodebreaking(PlayerInteractEvent event) {
World world = event.entityPlayer.worldObj;
TileEntity tileEntity = event.entityPlayer.worldObj.getTileEntity(event.pos);
if (// safety so when codebreakers are disabled they can't take damage
SecurityCraft.config.allowCodebreakerItem)
event.entityPlayer.getCurrentEquippedItem().damageItem(1, event.entityPlayer);
if (tileEntity != null && tileEntity instanceof IPasswordProtected && new Random().nextInt(3) == 1)
return ((IPasswordProtected) tileEntity).onCodebreakerUsed(world.getBlockState(event.pos), event.entityPlayer, !SecurityCraft.config.allowCodebreakerItem);
return false;
}
Aggregations