def perform(self, recordUndo=True): self.player = input_text_buttons("Enter a Player Name: ", 160) if not self.player: return if len(self.player) > 16: alert("Name to long. Maximum name length is 16.") return elif len(self.player) < 4: alert("Name to short. Minimum name length is 4.") return try: self.uuid = version_utils.getUUIDFromPlayerName(self.player) self.player = version_utils.getPlayerNameFromUUID(self.uuid) #Case Corrected except: action = ask("Could not get {}'s UUID. Please make sure that you are connected to the internet and that the player {} exists.".format(self.player, self.player), ["Enter UUID manually", "Cancel"]) if action != "Enter UUID manually": return self.uuid = input_text_buttons("Enter a Player UUID: ", 160) if not self.uuid: return self.player = version_utils.getPlayerNameFromUUID(self.uuid) if self.player == self.uuid.replace("-", ""): if ask("UUID was not found. Continue anyways?") == "Cancel": return if self.uuid in self.level.players: alert("Player already exists in this World.") return self.playerTag = self.newPlayer() if self.tool.panel: self.tool.panel.players.append(self.player) if self.level.oldPlayerFolderFormat: self.level.playerTagCache[self.level.getPlayerPath(self.player)] = self.playerTag self.level.players.append(self.player) if self.tool.panel: self.tool.panel.player_UUID[self.player] = self.player else: self.level.playerTagCache[self.level.getPlayerPath(self.uuid)] = self.playerTag self.level.players.append(self.uuid) if self.tool.panel: self.tool.panel.player_UUID[self.player] = self.uuid self.tool.playerPos[(0,0,0)] = self.uuid self.tool.revPlayerPos[self.uuid] = (0,0,0) self.tool.playerTexture[self.uuid] = loadPNGTexture(version_utils.getPlayerSkin(self.uuid, force=False)) self.tool.markerList.invalidate() self.tool.recordMove = False self.tool.movingPlayer = self.uuid if self.tool.panel: self.tool.hidePanel() self.tool.showPanel() self.canUndo = True
def __init__(self, playerNBTFile): self.nbtFile = playerNBTFile self.nbtFileName = playerNBTFile.split("\\")[-1] self.root_tag = nbt.load(playerNBTFile) # Properties setup self._uuid = self.nbtFileName.split(".")[0] playerName = version_utils.getPlayerNameFromUUID(self._uuid) if playerName != self._uuid: self._name = playerName else: self._name = None self._gametype = self.root_tag["playerGameType"].value self._pos = [ self.root_tag["Pos"][0].value, self.root_tag["Pos"][1].value, self.root_tag["Pos"][2].value ] self._rot = [ self.root_tag["Rotation"][0].value, self.root_tag["Rotation"][1].value ] self._health = self.root_tag["Health"].value self._healf = self.root_tag["HealF"].value self._xp_level = self.root_tag["XpLevel"].value
def perform(self, recordUndo=True): if self.level.saving: alert(_("Cannot perform action while saving is taking place")) return if self.player == "Player": answer = ask(_("Are you sure you want to delete the default player?"), ["Yes", "Cancel"]) if answer == "Cancel": return if recordUndo: self.undoTag = self.level.getPlayerTag(self.player) self.level.players.remove(self.player) if self.tool.panel: if self.player != "Player": self.tool.panel.players.remove(version_utils.getPlayerNameFromUUID(self.player)) else: self.tool.panel.players.remove("Player") while self.tool.panel.table.index >= len(self.tool.panel.players): self.tool.panel.table.index -= 1 if len(self.tool.panel.players) == 0: self.tool.hidePanel() self.tool.showPanel() self.tool.markerList.invalidate() pos = self.tool.revPlayerPos[self.player] del self.tool.playerPos[pos] if self.player != "Player": del self.tool.playerTexture[self.player] else: del self.level.root_tag["Data"]["Player"] del self.tool.revPlayerPos[self.player] self.canUndo = True
def __init__(self, tool): Panel.__init__(self) self.tool = tool self.player_UUID = {} self.level = tool.editor.level if hasattr(self.level, 'players'): players = self.level.players or ["[No players]"] if not self.level.oldPlayerFolderFormat: for player in players: if player != "Player" and player != "[No players]": self.player_UUID[version_utils.getPlayerNameFromUUID(player)] = player if "Player" in players: self.player_UUID["Player"] = "Player" if "[No players]" not in players: players = sorted(self.player_UUID.keys(), key=lambda x: False if x == "Player" else x.lower()) else: players = ["Player"] self.players = players max_height = self.tool.editor.mainViewport.height - self.tool.editor.netherPanel.height - self.tool.editor.subwidgets[0].height - self.margin - 2 addButton = Button("Add Player", action=self.tool.addPlayer) removeButton = Button("Remove Player", action=self.tool.removePlayer) gotoButton = Button("Goto Player", action=self.tool.gotoPlayer) gotoCameraButton = Button("Goto Player's View", action=self.tool.gotoPlayerCamera) moveButton = Button("Move Player", action=self.tool.movePlayer) moveToCameraButton = Button("Align Player to Camera", action=self.tool.movePlayerToCamera) reloadSkin = Button("Reload Skins", action=self.tool.reloadSkins, tooltipText="This pulls skins from the online server, so this may take a while") print max_height max_height -= sum((a.height for a in (addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin))) print max_height tableview = TableView(columns=[ TableColumn("Player Name(s):", 200), ], height=max_height) tableview.index = 0 tableview.num_rows = lambda: len(players) tableview.row_data = lambda i: (players[i],) tableview.row_is_selected = lambda x: x == tableview.index tableview.zebra_color = (0, 0, 0, 48) def selectTableRow(i, evt): tableview.index = i tableview.click_row = selectTableRow self.table = tableview col = [self.table] col.extend([addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin]) col = Column(col, margin=0, spacing=2) col.shrink_wrap() self.add(col) self.shrink_wrap()
def undo(self): if not (self.undoTag is None): if self.player != "Player": self.level.playerTagCache[self.level.getPlayerPath(self.player)] = self.undoTag else: self.level.root_tag["Data"]["Player"] = self.undoTag self.level.players.append(self.player) if self.tool.panel: if self.player != "Player": self.tool.panel.players.append(version_utils.getPlayerNameFromUUID(self.player)) else: self.tool.panel.players.append("Player") if "[No players]" in self.tool.panel.players: self.tool.panel.players.remove("[No players]") self.tool.hidePanel() self.tool.showPanel() self.tool.markerList.invalidate()
def __init__(self, playerNBTFile): self.nbtFile = playerNBTFile self.nbtFileName = playerNBTFile.split("\\")[-1] self.root_tag = nbt.load(playerNBTFile) # Properties setup self._uuid = self.nbtFileName.split(".")[0] playerName = version_utils.getPlayerNameFromUUID(self._uuid) if playerName != self._uuid: self._name = playerName else: self._name = None self._gametype = self.root_tag["playerGameType"].value self._pos = [self.root_tag["Pos"][0].value, self.root_tag["Pos"][1].value, self.root_tag["Pos"][2].value] self._rot = [self.root_tag["Rotation"][0].value, self.root_tag["Rotation"][1].value] self._health = self.root_tag["Health"].value self._healf = self.root_tag["HealF"].value self._xp_level = self.root_tag["XpLevel"].value
def undo(self): if not (self.undoTag is None): if self.player != "Player": self.level.playerTagCache[self.level.getPlayerPath( self.player)] = self.undoTag else: self.level.root_tag["Data"]["Player"] = self.undoTag self.level.players.append(self.player) if self.tool.panel: if self.player != "Player": self.tool.panel.players.append( version_utils.getPlayerNameFromUUID(self.player)) else: self.tool.panel.players.append("Player") if "[No players]" in self.tool.panel.players: self.tool.panel.players.remove("[No players]") self.tool.hidePanel() self.tool.showPanel() self.tool.markerList.invalidate()
def perform(self, recordUndo=True): if self.level.saving: alert(_("Cannot perform action while saving is taking place")) return if self.player == "Player": answer = ask( _("Are you sure you want to delete the default player?"), ["Yes", "Cancel"]) if answer == "Cancel": return if recordUndo: self.undoTag = self.level.getPlayerTag(self.player) self.level.players.remove(self.player) if self.tool.panel: if self.player != "Player": self.tool.panel.players.remove( version_utils.getPlayerNameFromUUID(self.player)) else: self.tool.panel.players.remove("Player") while self.tool.panel.table.index >= len(self.tool.panel.players): self.tool.panel.table.index -= 1 if len(self.tool.panel.players) == 0: self.tool.hidePanel() self.tool.showPanel() self.tool.markerList.invalidate() pos = self.tool.revPlayerPos[self.player] del self.tool.playerPos[pos] if self.player != "Player": del self.tool.playerTexture[self.player] else: del self.level.root_tag["Data"]["Player"] del self.tool.revPlayerPos[self.player] self.canUndo = True
def __init__(self, tool): Panel.__init__(self) self.tool = tool self.player_UUID = {} self.level = tool.editor.level if hasattr(self.level, 'players'): players = self.level.players or ["[No players]"] if not self.level.oldPlayerFolderFormat: for player in players: if player != "Player" and player != "[No players]": self.player_UUID[version_utils.getPlayerNameFromUUID( player)] = player if "Player" in players: self.player_UUID["Player"] = "Player" if "[No players]" not in players: players = sorted(self.player_UUID.keys(), key=lambda x: False if x == "Player" else x.lower()) else: players = ["Player"] self.players = players max_height = self.tool.editor.mainViewport.height - self.tool.editor.netherPanel.height - self.tool.editor.subwidgets[ 0].height - self.margin - 2 addButton = Button("Add Player", action=self.tool.addPlayer) removeButton = Button("Remove Player", action=self.tool.removePlayer) gotoButton = Button("Goto Player", action=self.tool.gotoPlayer) gotoCameraButton = Button("Goto Player's View", action=self.tool.gotoPlayerCamera) moveButton = Button("Move Player", action=self.tool.movePlayer) moveToCameraButton = Button("Align Player to Camera", action=self.tool.movePlayerToCamera) reloadSkin = Button( "Reload Skins", action=self.tool.reloadSkins, tooltipText= "This pulls skins from the online server, so this may take a while" ) max_height -= sum( (a.height for a in (addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin))) tableview = TableView(columns=[ TableColumn("Player Name(s):", 200), ], height=max_height) tableview.index = 0 tableview.num_rows = lambda: len(players) tableview.row_data = lambda i: (players[i], ) tableview.row_is_selected = lambda x: x == tableview.index tableview.zebra_color = (0, 0, 0, 48) def selectTableRow(i, evt): tableview.index = i tableview.click_row = selectTableRow self.table = tableview col = [self.table] col.extend([ addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin ]) col = Column(col, margin=0, spacing=2) col.shrink_wrap() self.add(col) self.shrink_wrap()
def perform(self, recordUndo=True): self.player = input_text_buttons("Enter a Player Name: ", 160) if not self.player: return if len(self.player) > 16: alert("Name to long. Maximum name length is 16.") return elif len(self.player) < 4: alert("Name to short. Minimum name length is 4.") return try: self.uuid = version_utils.getUUIDFromPlayerName(self.player) self.player = version_utils.getPlayerNameFromUUID( self.uuid) #Case Corrected except: action = ask( "Could not get {}'s UUID. Please make sure that you are connected to the internet and that the player {} exists." .format(self.player, self.player), ["Enter UUID manually", "Cancel"]) if action != "Enter UUID manually": return self.uuid = input_text_buttons("Enter a Player UUID: ", 160) if not self.uuid: return self.player = version_utils.getPlayerNameFromUUID(self.uuid) if self.player == self.uuid.replace("-", ""): if ask("UUID was not found. Continue anyways?") == "Cancel": return if self.uuid in self.level.players: alert("Player already exists in this World.") return self.playerTag = self.newPlayer() if self.tool.panel: self.tool.panel.players.append(self.player) if self.level.oldPlayerFolderFormat: self.level.playerTagCache[self.level.getPlayerPath( self.player)] = self.playerTag self.level.players.append(self.player) if self.tool.panel: self.tool.panel.player_UUID[self.player] = self.player else: self.level.playerTagCache[self.level.getPlayerPath( self.uuid)] = self.playerTag self.level.players.append(self.uuid) if self.tool.panel: self.tool.panel.player_UUID[self.player] = self.uuid self.tool.playerPos[(0, 0, 0)] = self.uuid self.tool.revPlayerPos[self.uuid] = (0, 0, 0) self.tool.playerTexture[self.uuid] = loadPNGTexture( version_utils.getPlayerSkin(self.uuid, force=False)) self.tool.markerList.invalidate() self.tool.recordMove = False self.tool.movingPlayer = self.uuid if self.tool.panel: self.tool.hidePanel() self.tool.showPanel() self.canUndo = True