Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from datetime import datetime, timedelta
- import time
- import sys
- import pexpect
- import time
- import os
- # SETTINGS
- playername='brantje' # set this to your minecraft username
- minX=-5000 #Minimal x axis
- maxX=5000 #Maximal x axis
- minY=-5000 #Minimal y axis
- maxY=5000 #Maximal y axis
- timeout=1 # Time between teleports. Smaller value means more stress for the server.
- diff1=maxX-minX
- diff2=maxY-minY
- total=diff1+diff2
- # Print iterations progress
- def printProgress (iteration, total, prefix = '', suffix = '', decimals = 2, barLength = 100, to = 0):
- """
- Call in a loop to create terminal progress bar
- @params:
- iterations - Required : current iteration (Int)
- total - Required : total iterations (Int)
- prefix - Optional : prefix string (Str)
- suffix - Optional : suffix string (Str)
- """
- filledLength = int(round(barLength * iteration / float(total)))
- percents = round(100.00 * (iteration / float(total)), decimals)
- bar = '#' * filledLength + '-' * (barLength - filledLength)
- remainingTime = (total-iteration)*to
- m, s = divmod(remainingTime, 60)
- h, m = divmod(m, 60)
- x = datetime.now() + timedelta(seconds=remainingTime)
- sys.stdout.write('%s [%s] %s%s %s\r' % (prefix, bar, percents, '%', suffix)),
- sys.stdout.write("\n %s of %s total\n" % (iteration, total)),
- sys.stdout.write("Remaining %02d:%02d:%02d " % (h, m, s)),
- sys.stdout.write("ETA: "+ x.strftime("%Y-%m-%d %H:%M") +"\n"),
- sys.stdout.flush()
- if iteration == total:
- print("\n")
- def deleteContent(pfile):
- pfile.seek(0)
- pfile.truncate()
- print "A total of "+ str(total) +" teleports \n"
- counter=0;
- child = pexpect.spawn('java -Xms3048M -Xmx3048M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M -jar minecraft_server.jar nogui')
- child.timeout=6000
- f=open('status','r')
- lastResult=f.readline()
- coords=lastResult.split('|');
- lastX=float(coords[0])
- lastY=float(coords[1])
- f.close()
- print "Last X: "+ str(lastX) + " Last Y: "+ str(lastY)
- child.logfile = sys.stdout
- child.expect('%s joined the game' % playername)
- child.sendline('gamemode 1 %s' % playername)
- for xcoord in range(minX, maxX, 16):
- x = float(xcoord)
- if lastX > x:
- continue
- for ycoord in range(minY, maxY, 16):
- y = float(ycoord)
- if lastY > y:
- counter=counter+1
- continue
- printProgress(counter, total, prefix = 'teleports', suffix='', barLength = 100)
- val=child.sendline('tp %s %i 255 %i' % (playername, xcoord, ycoord))
- os.system('clear')
- printProgress(counter, total, prefix = 'teleports', suffix='', barLength = 100, to = timeout)
- child.expect('Teleported %s' % playername)
- txt=str(xcoord) + '|' + str(ycoord)
- f = open("status", "w")
- f.write(txt)
- f.close()
- counter=counter+1
- time.sleep(timeout)
- child.sendline('say all done!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement