Minecraft PE Server Without Xbox Live Requirement

Yeah, a Minecraft server... Probably one of the most annoying games that most children are completely addicted to. The issue I have with this game is the requirement for an Xbox Live account in order to play on a server. Not the traditional online server, but rather the local server. Like most parents, I'd like to have a little control over what my kids do on the internet, and playing a game with strangers at their age isn't something I'm ready for. And, since they both enjoy playing together but still want to play in the same world when each other aren't around, having to self-host a local game doesn't seem to solve their problem.

So, I set out on a mission to find the best way to solve this. The solution seemed simple, host a server and bypass the Microsoft requirement so I don't have to give them an Xbox account. This wasn't as much of a problem as I had anticipated based on what options are provided from the Bedrock Server edition.

Simply switching 'online-mode' to false in the server.properties allowed local server connections. The benefit is that no outsiders can join because I control port forwarding.

My choice for server was the Bedrock edition because of the simplicity and ease of setup coupled with the basic configuration. Another great benefit was the ability to take on of the save files from their tablets and upload it as a server world (so they didn't have to "start over").

Installing on Arch Linux was pretty intuitive. I downloaded the server files from Mojang's website, unzipped it to my /srv folder and launched the server (from within 'screen').

In the default folder is the properties file, that was easy to configure as well. I changed all of the game settings for the server to match one of the world's they created (seed, name, difficulty, etc)and FTPed the files to the 'worlds' folder. The last thing I did was change the settings to disable online mode. This allowed them both to join without having an Xbox account.

C++ Programming: Image Blur Code

Another block of code that simulates blurring an image. This reads the position of x and y of a pixel and the surrounding values and applies a simple algorithm to find the average of all values and reapply the new value resulting in a blurry effect.

void blur(int img[][MAX_COL], int h, int w) {

  //for loop to cycle through the image positions
  for ( int x = 0; x < h; x++ ) {
    for ( int y = 0; y < w; y++ ) {
      //formula to calculate the values of the surrounding pixels
      int sum = 2 * ( img[x][y] + //center center
                      img[x-1][y-1] + //top left
                      img[x-1][y] + //top center
                      img[x-1][y+1] + //top right
                      img[x][y-1] + // center left
                      img[x][y+1] + //center right
                      img[x+1][y-1] + //bottom left
                      img[x+1][y] + //bottom center
                      img[x+1][y+1] //bottom right
                    );
      // position modifier with the new value
      img[x][y] = sum/14;
    }
  }
}

If there is a better way to accomplish this, please leave a comment. I am always open to learning new ways to code.

C++ Programming: Converting Time Between 12/24 Hours

I decided to stick my code in a place that I would keep track of it all. I had to write this program to demonstrate the use of functions. While it might not be the most intuitive way of accomplishing the task, I think it will do just fine.

/* * * * * * * * * * * * * * * * * * * * * * 
 * This program will convert a user inputted time between 12 and 24 hours
 * based on the selection.  The user will be able to use the program until
 * they quit.  This program will demonstrate the use of multiple fucntions
 * to complete the task.
 * * * * * * * * * * * * * * * * * * * * * * */

#include <iostream>
#include <string>

//Used to convert time to/from 12/24 hour.
//o is option, h is hour, m is minute, p is period
std::string convertTime( int o, int h, int m, char p ) {

  //default statement for time
  std::string time = "\nThe time is: ";

  //declared for AM or PM
  std::string period;

  //if the option is 1, convert hour to 24 hours
  if ( o == 1 ) {
    if ( p == 'p') {
      h += 12;
    }
  }

  //if the option is 2, convert hours to 12 hours
  //if the time is greater than 12, then subtract 12 from hour
  if ( o == 2 ) {
    period = "AM";
    if ( h > 12 ) {
      h -= 12;
      period = "PM";
    }
  }

  //convert time to strings
  std::string hour = std::to_string(h);
  std::string minute;

  // if minutes are less than 10, add the leading zero
  if ( m < 10 ) {
    minute = std::to_string(m);
    minute = '0' + minute;
  } else {
    minute = std::to_string(m);
  }

  //concactinate the time
  time += hour + ":" + minute;

  //add the period to the end of the time
  if ( o == 2 ) {
    time += " " + period;
  }

  //return the time
  return time;
}

//used to store the menu option
void menu() {
  std::cout << "Options -- " << std::endl;
  std::cout << "1: To convert time from 12-hour notation to 24-hour notation." << std::endl;
  std::cout << "2: To convert time from 24-hour notation to 12-hour notation." << std::endl;
  std::cout << "0: To quit the program." << std::endl;
  std::cout << "Choose: ";
}

//main program
int main() {
  //declared variables for user input
  int option, hour, minutes;
  char period;

  //continuous loop until user chooses to quit
  do {
    //display the menu
    menu();

    //queue user for option from the menu
    std::cin >> option;

    //if an invalid option is chosen, tell user to choose valid option
    if ( (option < 1 || option > 2) && option != 0 ) {
      std::cout << "\nNot a valid option, please choose a valid option. \n" << std::endl;
      menu();
      std::cin >> option;
    }

    //if user chooses to quit
    if (option == 0 ) {

      //end the program with success
      return 0;
    }

    //ask user for hours and minutes
    if ( option == 1 ) {
      do {
      std::cout << "\nEnter hours: ";
      std::cin >> hour;

      //check if hours are valid entry
      if ( hour > 12 ) {
        std::cout << "Not a valid entry, minutes must be less than or equal to 12.";
      }

      } while ( hour > 12 );
    }

    //ask user for hours and minutes
    if ( option == 2 ) {
      do {
      std::cout << "\nEnter hours: ";
      std::cin >> hour;

      //check if hours are valid entry
      if ( hour > 24 ) {
        std::cout << "Not a valid entry, minutes must be less than or equal to 24.";
      }

      } while ( hour > 24 );
    }

  do {
    std::cout << "Enter minutes: "; 
    std::cin >> minutes;

    //check if minutes are valid entry
    if ( minutes > 59 ) {
      std::cout << "Not a valid entry, minutes must be less than 60.\n";
    }

    } while ( minutes > 59 );

    //if user wants to convert 12 to 24 hour, ask for period
    if ( option == 1 ) {
      std::cout << "Enter AM/PM (A or P): ";
      std::cin >> period;

      //if invalid option is chosen, ask user for valid option
      while ( period != 'a' && period != 'p' ) {
        std::cout << "\nInvalid period of day, please choose A or P: ";
        std::cin >> period;
      }

      //forces period to lowercase
      period = std::tolower(period);
    }

    //displays the time based on the convertTime function
    //passes option, hour, minutes and period variables to 
    //convertTime input variables 'o', 'h', 'm' and 'p'
    std::cout << convertTime(option,hour,minutes,period) << "\n\n";

  } while ( option > 0 );

  //end program with success
  return 0;
}

Updating SSL Certificates with 'certbot'

I found the easiest way to update certificates with certbot (on my server) is to temporarily stop apache / nginx and to run the following command. Once you have the congratulations line, you can restart your web services.</p>

$ sudo systemctl stop lighttpd
$ sudo certbot certonly --standalone --email [EMAIL-ADDRESS] -d thebytes.net,www.thebytes.net,[ALL OTHER SUBDOMAINS]

Enable Wifi Hotspot on Android Pie

Of course, you pay for unlimited internet through your cell phone provider, but they still require you to pay more just to put your device into a mobile hotspot.  There is an easy fix, you simply have to edit the build.prop on your device.  Of course, you will have to be rooted, such a small price to pay though.

Enabling your Android device to utilize a hotspot is still pretty easy; All you have to do is add the following line to your build.prop file.  I used the Build.Prop Editor app in the Google Store.

net.tethering.noprovisioning=true

Bash: Clean Movie Folder

Here is another script to help clean up movie folders.  Until recently, I preferred having all of my movies in the same directory.  After switching to Plex Media Server, I soon realized that Plex downloads fanart and other related movie files.  The issue is that all of these additional files were also in the main movie directory.  The following script went through and created a sub-directory for each movie name and then the second half moved the files into their respective folder.

$ for i in `find . -maxdepth 1 -type f -printf '%f\n' |sed "s/^\(.*\)\..*$/\1/"`; do mkdir $i; done

and then

$ for i in `find . -maxdepth 1 -type f -printf '%f\n' |sed "s/^\(.*\)\..*$/\1/"`; do mv $i* $i; done