Compare commits

..

No commits in common. "main" and "v.1.7.0" have entirely different histories.

18 changed files with 279 additions and 728 deletions

268
README.md
View File

@ -1,11 +1,7 @@
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./assets/branding/pluget-logo-white.png">
<source media="(prefers-color-scheme: light)" srcset="./assets/branding/pluget-logo-black.png">
<img src="./assets/branding/pluget-logo-black.png" alt="pluGET" border="0">
</picture>
<img src="https://i.ibb.co/JyCxnQn/logoreal.png" alt="pluGET" border="0"></a>
</p>
<p align="center">
@ -21,7 +17,7 @@
# pluGET
A powerful package manager which updates [Plugins](https://www.spigotmc.org/resources/) and Server Software for minecraft servers.
#### A powerful package manager which updates [Plugins](https://www.spigotmc.org/resources/) and Server Software for minecraft servers.
<img src="https://user-images.githubusercontent.com/13088544/177011216-1360d444-278a-475e-9863-966c48c60ba7.gif" alt="pluGET.gif" border="0" />
@ -39,22 +35,44 @@ A powerful package manager which updates [Plugins](https://www.spigotmc.org/reso
</details>
# About
pluGET is a standalone package manager written in python for minecraft [Spigot](https://www.spigotmc.org/) servers and its forks (e.g. [PaperMC](https://papermc.io/)). The program works with a locally installed servers or with a remote host through SFTP/FTP, when configured in the config. It uses the [Spiget](https://spiget.org/) API to download and compare plugin versions and download the latest version of plugins from the [Spigot](https://www.spigotmc.org/) site. It can also compare and download the latest update of specific server software (e.g. [PaperMC](https://papermc.io/)).
Plugin management is the hard part of managing a minecraft server. The time it takes to manually check the [Spigot resources](https://www.spigotmc.org/resources/) page for updates and manually downloading all plugins is too long and daunting. So I built pluGET to automate and ease the plugin handling of a minecraft server and to turn the most time consuming part of managing a minecraft server to an easy one.
This program is suited for minecraft server owners who want to save time and stay on top of their plugin versions. The program input and the associated config file are pretty simple so every server owner and not only the most tech savy ones can use pluGET to ease their plugin handling.
<img src="https://i.ibb.co/82dnyrK/image.png" alt="meme" border="0" height="350" width="350"></a>
# Features
- Works locally or through SFTP/FTP
- Runs directly from the console with command line arguments
- Checks for updates and downloads the latest version of all/specific plugins
- Checks for updates and downloads the latest version of your server software
## Issues? Found a bug?
[Create an issue.](https://github.com/Neocky/pluGET/issues/new/choose)
## About
This is a package manager for minecraft [Spigot](https://www.spigotmc.org/) servers and its forks (e.g. [PaperMC](https://papermc.io/)).
This is a standalone program written in python.
The program works with a locally installed server or with a remote host through SFTP/FTP, when configured in the config.
It uses the [Spiget](https://spiget.org/) API to download and compare plugin versions and can download the latest version of plugins from the [Spigot](https://www.spigotmc.org/) site.
It can also compare and download the latest update of specific server software (e.g. [PaperMC](https://papermc.io/)).
Plugin management was the hard part of managing a minecraft server. The time it took to check the [Spigot resource](https://www.spigotmc.org/resources/) page for updates for the installed plugins and updating all plugins manually which have available updates was too long and daunting.
So I built pluGET to automate and ease the plugin handling of a minecraft server and to turn the most time consuming part of managing a minecraft server to an easy one.
This program is suited for minecraft server owners who want to save time and stay on top of their plugin versions.
The program input and the associated config file are pretty simple so every server owner and not only the most tech savy ones can use pluGET to ease their plugin handling.
Follow the [Installation](https://github.com/Neocky/pluGET#installation) guide below for an easy and hassle free setup of pluGET.
Read [Usage](https://github.com/Neocky/pluGET#usage) below to get some example inputs when using pluGET.
If you still have questions [here](https://github.com/Neocky/pluGET#need-help) is the best place to ask for support.
So what can it do exactly?
pluGET can:
- work locally or through SFTP/FTP
- run directly from the console with command line arguments
- manage plugins:
- download the latest version of a plugin
- update every installed/one specific plugin
- check for an update of every installed/one specific plugin
- manage server software:
- download a specific server software version
- check installed server software for update
- update installed server software to a specific version
- supported server software:
- [PaperMc](https://papermc.io/)
- [Purpur](https://purpurmc.org/)
- [Waterfall](https://papermc.io/downloads#Waterfall)
- [Velocity](https://papermc.io/downloads#Velocity)
@ -64,30 +82,42 @@ There are more features in the work. Check [Projects](https://github.com/Neocky/
[Get the latest release here.](https://github.com/Neocky/pluGET/releases)
# Donations ☕
If you feel like showing your love and/or appreciation for this project then how about buying me a coffee? ☕🤎
## Donations :coffee:
If you feel like showing your love and/or appreciation for this project then how about buying me a coffee? :coffe::brown_heart:
[<img src="https://ko-fi.com/img/githubbutton_sm.svg" alt="ko-fi" width="300"/>](https://ko-fi.com/Y8Y1CKZ43)
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Y8Y1CKZ43)
# Need help?
[<img src="https://i.ibb.co/PQv3KtJ/Discord-Logo-Wordmark-Color.png" alt="Discord" width="300"/>](https://discord.gg/475Uf4NBPF)
## Need help?
[<img src="https://i.ibb.co/CMKbT0L/rsz-1rsz-discord.png" alt="Discord" width="272"/>](https://discord.gg/475Uf4NBPF)
# Installation
## 1. Python 3.10.4
Python needs to be installed on your machine. Get it [here](https://www.python.org/downloads/).
## Installation
### 1. Python 3.10.4
Python needs to be installed on your machine.
Get it [here](https://www.python.org/downloads/).
### 2. Dependencies
Install the needed packages for this project.
#### Automatically (Windows only)
Execute the `install_requirements.py` file to automaticcally install the needed packages for this project.
## 2. Dependencies
In order to install dependencies run the `install_requirements_WINDOWS/LINUX` file, of course depending on your system.
#### Manually
Execute this command in the `\plugGET` folder:
```python
# Windows:
py -m pip install -r requirements.txt
# Linux
pip install -r requirements.txt
```
## 3. Edit the config
When run pluGET for the first time, the `pluGET_config.yaml` file will be created in the main folder and the program will close.
### 3. Edit the Config
When run the first time, the `pluGET_config.yaml` file will be created in the main folder and the program will close.
Edit the config to your needs and relaunch pluGET.
**Now you are good to go!**
## 4. Running the program
## Start pluGET
Execute the `pluget.py` file with python in the `\pluGET` folder.
This will launch pluGET correctly.
```python
@ -97,127 +127,143 @@ py pluget.py
python3 pluget.py
```
# Usage
### Command line arguments
pluGET supports all commands directly through direct calling from the command line.
Get all available command line arguments with the `-h` argument.
Example direct command line call:
```shell
py pluget.py check all # runs the update checking for all plugins from pluget
```
## Usage
> As always, if you update plugins, shut down your server!
## Commands:
The following are examples of input for the general usage:
(Hint: [thingsInBrackets] are optional & 'all' can always be exchanged through the plugin name or the plugin id and reverse)
### • Show the information about all commands.
<!-- <details>
### General
#### Command help:
`help command [all/command]`
```
help command
```
<details>
<summary>Output</summary>
![Example output](https://i.ibb.co/9VZCjD6/pluget-help2.png)
![Output](https://i.ibb.co/9VZCjD6/pluget-help2.png)
</details> -->
</details>
### Manage Plugins
#### Download the latest update of a specific package:
`get [pluginID/pluginName]`
```
help command [all/command]
get 'pluginID'
```
or:
```
get 'pluginName'
```
#### Check all plugins/one specific plugin for updates with optional changelog output:
`check [all/pluginName] [changelog]`
```
check all
```
or:
```
check 'pluginName' changelog
```
### • Exit program:
```
exit .
```
### • Get link to this page:
```
help .
```
## Manage Plugins
### • Download the latest update of a specific package:
```
get [pluginID/pluginName]
```
### • Check all plugins/one specific plugin for updates with optional changelog output:
<!-- <details>
<details>
<summary>Output</summary>
![Output](https://i.ibb.co/VmSNh6K/pluget-checkall.png)
</details> -->
</details>
```
check [all/pluginName] [changelog]
```
### • Update all plugins/one specific plugin:
#### Update all plugins/one specific plugin:
`update [all/pluginName]`
```
update [all/pluginName]
update all
```
### • Remove a plugin with the ID/Name:
or:
```
remove [pluginID/pluginName]
update 'pluginName'
```
### • Search for a plugin:
#### Remove a plugin with the ID/Name:
`remove [pluginID/pluginName]`
```
search [pluginName]
remove 'pluginID'
```
## Manage Server Software
### • Check installed server software for updates:
or:
```
remove 'pluginName'
```
#### Search for a plugin:
`search [pluginName]`
```
search 'pluginName'
```
#### Exit program:
`exit [anything]`
```
exit .
```
#### Get link to here:
`help [anything]`
```
help .
```
### Manage Server Software
#### Check installed server software for updates:
`check serverjar`
```
check serverjar
```
### • Update installed server software to latest/specific version:
### Update installed server software to latest/specific version:
`update serverjar [Version]`
```
update serverjar [Version]
update serverjar 'PaperMCVersion'
```
### Download specific paper version:
`get-paper [paperBuild] [minecraftVersion]`
```
get-paper 550 1.16.5
```
### Download specific waterfall version:
`get-waterfall [waterfallBuild] [minecraftVersion]`
```
get-waterfall 496 1.19
```
### Download specific waterfall version:
`get-velocity [velocityBuild] [minecraftVersion]`
```
get-velocity 158 3.1.2-SNAPSHOT
```
### • Download specific paper version:
```
get-paper [paperBuild] [minecraftVersion]
```
## Known problems
### • Download specific waterfall version:
```
get-waterfall [waterfallBuild] [minecraftVersion]
```
### Can't get latest version/Update available
### • Download specific velocity version:
```
get-velocity [velocityBuild] [minecraftVersion]
```
### • Download specific purpur version:
```
get-purpur [purpurBuild] [minecraftVersion]
```
# Command line arguments
pluGET supports all commands directly through the command line. Get the list of all available command line arguments with the `-h` argument.
Example direct command line call:
```shell
py pluget.py check all
```
# Known problems
## Can't get latest version/Update available
### Inconsistent Names and Versions
Example:
#### Inconsistent Names and Versions
For example:
![EssentialsX](https://i.ibb.co/fDyCYQ8/essentialsx.png)
EssentialsX is a prominent example of inconsisten version naming. The installed version is `2.18.2.0` but on [Spigot](https://www.spigotmc.org/resources/essentialsx.9089/update?update=371379) the version is only described as `2.18.2`.
That's the reason pluGET can't detect it automatically.
> There are of course many more plugins which have some sort of inconsistency which makes it sadly impossible for pluGET to detect them all. EssentialsX is used only as an example.
### Solution
#### Solution
Download the plugins with the `get [pluginName]` command to make them detectable for pluGET.
After downloading EssentialsX with `get EssentialsX` and using `check all`:
![EssentialsX](https://i.ibb.co/ws5wHTj/essentialsx-2.png)
EssentialsX is now detected from pluGET and can update automatically when a new version comes out.
### Bukkit plugins
Example:
#### Bukkit plugins
For example:
![worldguard](https://i.ibb.co/7NJ9HRG/pluget-checkallonlyone.png)
As you can see the installed version was found but not the latest version for this plugin.
This is because this is a plugin which is not available on [Spigot](https://www.spigotmc.org/resources/).
pluGET supports currently only plugins from [Spigot](https://www.spigotmc.org/resources/).
In this example this is a bukkit plugin.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
sodipodi:docname="pluget-logo.svg"
inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
xml:space="preserve"
id="svg5"
version="1.1"
viewBox="0 0 101.31679 30.525789"
height="30.525789mm"
width="101.31679mm"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview7"
pagecolor="#505050"
bordercolor="#ffffff"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="1"
inkscape:deskcolor="#505050"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="2.8284271"
inkscape:cx="60.811183"
inkscape:cy="81.31728"
inkscape:window-width="1920"
inkscape:window-height="1051"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" /><defs
id="defs2"><inkscape:path-effect
effect="mirror_symmetry"
start_point="66.717927,194.91922"
end_point="66.717927,196.6932"
center_point="66.717927,195.80621"
id="path-effect2543"
is_visible="true"
lpeversion="1.2"
lpesatellites=""
mode="free"
discard_orig_path="false"
fuse_paths="false"
oposite_fuse="false"
split_items="false"
split_open="false"
link_styles="false" /></defs><g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-244.05501,27.440776)"><path
style="display:inline;fill:none;stroke:#ffffff;stroke-width:1.08823;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 269.92243,-15.41098 0.89279,-0.51545 c 2.31137,-1.33446 4.26969,-0.85065 3.74023,2.09491 -0.52947,2.94556 -2.57765,6.63243 0.19723,7.52795 1.17498,0.3792 3.00732,-0.24884 3.52934,-2.54794 0.70271,-3.09482 -0.37661,-6.7641 -1.62003,-10.38648 l -0.87139,-2.53855"
id="path2515"
sodipodi:nodetypes="cszsssc"
inkscape:label="wire" /><g
id="g2525"
transform="matrix(1.5194714,-0.52157949,0.52157949,1.5194714,111.14245,-282.32695)"
style="display:inline;stroke:none"
inkscape:label="plug"><g
id="g2521"
transform="matrix(1.8835345,0,0,1.8835345,-81.40728,-180.76428)"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-opacity:1"
inkscape:label="pins"><rect
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.744316;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"
id="rect2517"
width="0.39793873"
height="1.5362287"
x="66.120705"
y="193.25238"
ry="0.19896936"
inkscape:label="left" /><rect
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.744316;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"
id="rect2519"
width="0.39793873"
height="1.5362287"
x="66.940681"
y="193.25238"
ry="0.19896936"
inkscape:label="right" /></g><path
id="path2523"
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.439285;stroke-linecap:round"
d="m 65.710577,195.23133 c 0,0.68804 0.25868,1.46187 1.00735,1.46187 v -1.77398 c -0.889087,0 -1.00735,0 -1.00735,0.31211 z m 2.0147,0 c 0,0.68804 -0.25868,1.46187 -1.00735,1.46187 v -1.77398 c 0.889087,0 1.00735,0 1.00735,0.31211 z"
sodipodi:nodetypes="cccc"
class="UnoptimicedTransforms"
transform="matrix(1.8835345,0,0,1.8835345,-81.385177,-182.13354)"
inkscape:label="body"
inkscape:original-d="m 65.710577,195.23133 c 0,0.68804 0.25868,1.46187 1.00735,1.46187 v -1.77398 c -0.889087,0 -1.00735,0 -1.00735,0.31211 z"
inkscape:path-effect="#path-effect2543" /></g><path
id="path2531"
style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.989574;stroke-linejoin:round"
class="UnoptimicedTransforms"
inkscape:label="top side"
inkscape:transform-center-x="5.3509257"
inkscape:transform-center-y="-7.3394763"
transform="matrix(0.95451618,0,0,0.95451618,236.87111,-259.69297)"
d="m 15.626149,255.26898 5.938704,3.42871 13.318093,-7.68921 -5.938698,-3.42871 z m -7.3793868,-4.26049 5.9804058,3.45279 13.318085,-7.68921 -5.980399,-3.45279 z"
sodipodi:nodetypes="cccccccccc" /><path
transform="matrix(-0.47725809,-0.82663525,0.82663525,-0.47725809,53.21073,137.01425)"
style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.989574;stroke-linejoin:round"
class="UnoptimicedTransforms"
id="path2537"
d="M 14.905808,254.85309 28.223899,262.5423 41.541992,254.85309 28.2239,247.16388 Z"
inkscape:label="blank side" /><path
id="path2533"
style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.989574;stroke-linejoin:round"
class="UnoptimicedTransforms"
d="m 14.905755,254.85285 13.31825,7.68919 13.317866,-7.68907 -13.318249,-7.6892 z m 4.297769,-0.63465 2.921445,-1.6867 3.373173,1.94776 1.460956,-0.84349 -1.686685,-0.9735 4.381932,-2.52991 1.686685,0.97351 -1.460956,0.84348 3.373642,1.94748 1.460488,-0.84321 1.686685,0.97351 -4.381932,2.52991 -1.686686,-0.97351 -1.460487,0.84321 3.373173,1.94776 -2.921444,1.6867 -3.373174,-1.94776 2.921445,-1.6867 -3.373642,-1.94748 -2.921445,1.6867 z"
transform="matrix(-0.47725809,0.82663526,-0.82663526,-0.47725809,488.59969,90.37568)"
inkscape:label="creeper face side" /><text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.0938px;line-height:1.25;font-family:Comfortaa;-inkscape-font-specification:'Comfortaa, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;letter-spacing:0px;display:inline;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.427346"
x="281.58862"
y="-7.4172397"
id="text2529"
inkscape:label="text"><tspan
sodipodi:role="line"
id="tspan2527"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:17.0938px;font-family:Comfortaa;-inkscape-font-specification:'Comfortaa, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#ffffff;fill-opacity:1;stroke-width:0.427346"
x="281.58862"
y="-7.4172397"
dx="0 -0.51999998 -0.18000001 -0.69 -0.5 0.57999998">pluGET</tspan></text></g></svg>

Before

Width:  |  Height:  |  Size: 6.9 KiB

13
install_requirements.py Normal file
View File

@ -0,0 +1,13 @@
"""
Install the needed python packages through this script
"""
import os
try:
print("Installing Python packages and dependencies from requirements.txt...\n")
os.system('py -m pip install -r requirements.txt' if os.name=='nt' else 'pip install -r requirements.txt')
print("\nStart pluGET by launching the 'pluGET.py' file!")
except:
print("Requirements couldn't be installed. Check if file 'requirements.txt' is in the same folder and that Python3\
and pip is installed!")

View File

@ -1,4 +0,0 @@
#!/bin/bash
echo "Installing Python packages and dependencies from requirements.txt... Please wait."
pip install -r requirements.txt

View File

@ -1,4 +0,0 @@
@echo off
title Installing requirements...
echo Installing Python packages and dependencies from requirements.txt... Please wait.
py -m pip install -r requirements.txt

View File

@ -3,14 +3,11 @@ Handles the input through the pluGET command line
"""
from src.utils.console_output import rich_print_error
from src.utils.utilities import get_command_help
from src.plugin.plugin_remover import delete_plugin
from src.plugin.plugin_downloader import get_specific_plugin_spiget, search_specific_plugin_spiget
from src.plugin.plugin_updatechecker import check_installed_plugins, update_installed_plugins
from src.serverjar.serverjar_updatechecker import \
check_update_available_installed_server_jar, update_installed_server_jar
from src.serverjar.serverjar_paper_velocity_waterfall import serverjar_papermc_update
from src.serverjar.serverjar_purpur import serverjar_purpur_update
# check
@ -19,11 +16,10 @@ from src.serverjar.serverjar_purpur import serverjar_purpur_update
# get-paper
# get-waterfall
# get-velocity
# get-purpur
# get-purpur ???
# exit
# remove
# search
# help
def handle_input(
@ -61,15 +57,6 @@ def handle_input(
case _:
search_specific_plugin_spiget(input_selected_object)
case "get-paper":
serverjar_papermc_update(input_selected_object, input_parameter, None, "paper")
case "get-velocity":
serverjar_papermc_update(input_selected_object, input_parameter, None, "velocity")
case "get-waterfall":
serverjar_papermc_update(input_selected_object, input_parameter, None, "waterfall")
case "get-purpur":
serverjar_purpur_update(input_selected_object, input_parameter, None)
case "update":
match input_selected_object:
case "serverjar":
@ -86,15 +73,21 @@ def handle_input(
case "search":
search_specific_plugin_spiget(input_selected_object)
case "remove":
delete_plugin(input_selected_object)
case "help":
get_command_help(input_selected_object)
# TODO add remover
#case "remove":
# print("remove package")
# #removePlugin(inputSelectedObject)
case "get-paper":
serverjar_papermc_update(input_selected_object, input_parameter, None, "paper")
case "get-velocity":
serverjar_papermc_update(input_selected_object, input_parameter, None, "velocity")
case "get-waterfall":
serverjar_papermc_update(input_selected_object, input_parameter, None, "waterfall")
case "exit":
return
case _:
rich_print_error("Error: Command not found. Please try again. :(")
rich_print_error("Use [bright_blue]'help all' [bright_red]to get a list of all available commands.")
rich_print_error("Use: 'help command' to get all available commands")
# return to break out of while loop if pluGET was started with arguments from console
if arguments_from_console:
@ -121,7 +114,7 @@ def get_input() -> str:
continue
else:
rich_print_error("Wrong input! Use: > 'command' 'selectedObject' [optionalParams]")
rich_print_error("Use: [bright_blue]'help all' [bright_red]to get a list of all available commands.")
rich_print_error("Use: 'help command' to get all available commands")
except KeyboardInterrupt:
return
input_parameter = input_parameter[0] if input_parameter else None

View File

@ -1,56 +0,0 @@
"""
Removes the specified plugin file from the ./plugins folder
"""
import os
import re
from pathlib import Path
from rich.console import Console
from src.handlers.handle_config import config_value
from src.utils.console_output import rich_print_error
from src.handlers.handle_sftp import sftp_create_connection, sftp_list_all
from src.handlers.handle_ftp import ftp_create_connection, ftp_list_all
def delete_plugin(plugin_name: str) -> None:
"""
Deletes the specific plugin file
:param plugin_name: Name of plugin file to delete
:returns: None
"""
config_values = config_value()
rich_console = Console()
match config_values.connection:
case "sftp":
connection = sftp_create_connection()
plugin_list = sftp_list_all()
case "ftp":
connection = ftp_create_connection()
plugin_list = ftp_list_all()
case "local":
plugin_list = os.listdir(config_values.path_to_plugin_folder)
for plugin_file in plugin_list:
# skip all other plugins
if not re.search(plugin_name, plugin_file, re.IGNORECASE):
continue
try:
match config_values.connection:
case "sftp":
plugin_path = f"{config_values.remote_plugin_folder_on_server}/{plugin_file}"
connection = sftp_create_connection()
connection.remove(plugin_path)
case "ftp":
plugin_path = f"{config_values.remote_plugin_folder_on_server}/{plugin_file}"
connection = ftp_create_connection()
connection.delete(plugin_path)
case "local":
pluginPath = Path(f"{config_values.path_to_plugin_folder}/{plugin_file}")
os.remove(pluginPath)
rich_console.print(f"[not bold][bright_green]Successfully removed: [bright_magenta]{plugin_file}")
except:
rich_print_error(f"[not bold]Error: Couldn't remove [bright_magenta]{plugin_file}")
return None

View File

@ -225,8 +225,8 @@ def egg_cracking_jar(plugin_file_name: str) -> str:
case "ftp":
path_temp_plugin_folder = create_temp_plugin_folder()
connection = ftp_create_connection()
ftp_download_file(connection, plugin_file_name)
path_plugin_jar = Path(f"{path_temp_plugin_folder}/{plugin_file_name}")
ftp_download_file(connection, path_plugin_jar, plugin_file_name)
case _:
path_plugin_folder = config_values.path_to_plugin_folder
path_plugin_jar = Path(f"{path_plugin_folder}/{plugin_file_name}")
@ -520,18 +520,6 @@ def search_plugin_spiget(plugin_file: str, plugin_file_name: str, plugin_file_ve
"""
url = f"https://api.spiget.org/v2/search/resources/{plugin_file_name}?field=name&sort=-downloads"
plugin_list = api_do_request(url)
# Handle failed api request
"""
{'error': 'Unexpected Exception', 'msg': 'Unexpected Exception. Please report this to
https://github.com/SpiGetOrg/api.spiget.org/issues'}
"""
if "error" in plugin_list:
rich_print_error(
f"[not bold]Error: Spiget error occurred whilst searching for plugin '{plugin_file}': {plugin_list['msg']}"
)
return plugin_list['msg']
else:
plugin_file_version2 = plugin_file_version
for i in range(4):
if i == 1:

View File

@ -20,6 +20,22 @@ from src.utils.utilities import \
api_do_request, create_temp_plugin_folder, remove_temp_plugin_folder, convert_file_size_down
def get_installed_mc_version(file_server_jar_full_name) -> str:
"""
Gets the used minecraft version from the file name
:param file_server_jar_full_name: Full file name of the installed serverjar
:returns: Used minecraft version
"""
mc_version_full = re.search(r"(\d*\.*\d)+", file_server_jar_full_name)
try:
mc_version = mc_version_full.group()
except AttributeError:
mc_version = mc_version_full
return mc_version
def get_installed_serverjar_version(file_server_jar_full_name) -> str:
"""
Gets the installed version of the installed serverjar
@ -34,7 +50,6 @@ def get_installed_serverjar_version(file_server_jar_full_name) -> str:
except AttributeError:
serverjar_version = serverjar_version_full
serverjar_version = serverjar_version.replace('.jar', '')
return serverjar_version
@ -115,6 +130,14 @@ def serverjar_papermc_check_update(file_server_jar_full_name) -> None:
:returns: None
"""
"""
mc_version = get_installed_mc_version(file_server_jar_full_name)
if mc_version == None:
rich_print_error("Error: An error occured while checking the mc version of the serverjar")
return None
print(mc_version)
"""
serverjar_version = get_installed_serverjar_version(file_server_jar_full_name)
if serverjar_version == None:
rich_print_error("Error: An error occured while checking the installed serverjar version")
@ -201,7 +224,6 @@ def serverjar_papermc_update(
if server_jar_version == "latest" or server_jar_version == None:
server_jar_version = find_latest_available_version(papermc_serverjar, mc_version)
# use rich console for nice colors
rich_console = Console()
rich_console.print(
f"\n [not bold][bright_white]● [bright_magenta]{papermc_serverjar.capitalize()}" + \
@ -260,6 +282,7 @@ def serverjar_papermc_update(
progress.update(download_task, advance=len(data))
#f.flush()
# use rich console for nice colors
file_size_data = convert_file_size_down(convert_file_size_down(file_size))
rich_console.print(" [not bold][bright_green]Downloaded[bright_magenta] " + (str(file_size_data)).rjust(9) + \

View File

@ -1,208 +0,0 @@
"""
Handles the update checking and downloading of these serverjars:
Purpur
"""
import re
import requests
from pathlib import Path
from rich.table import Table
from rich.console import Console
from rich.progress import Progress
from src.handlers.handle_config import config_value
from src.utils.console_output import rich_print_error
from src.handlers.handle_sftp import sftp_create_connection, sftp_upload_server_jar
from src.handlers.handle_ftp import ftp_create_connection, ftp_upload_server_jar
from src.utils.utilities import \
api_do_request, create_temp_plugin_folder, remove_temp_plugin_folder, convert_file_size_down
from src.serverjar.serverjar_paper_velocity_waterfall import \
get_installed_serverjar_version, get_version_group, get_versions_behind
def find_latest_available_version(version_group) -> int:
"""
Gets the latest available version of the installed serverjar version
:param version_group: Minecraft version group of the serverjar
:returns: Latest available version as int
"""
url = f"https://api.purpurmc.org/v2/purpur/{version_group}/"
versions = api_do_request(url)
if "status" in versions: # Checks if the API returns a status. This means that there was an error.
return None
latest_version = versions["builds"]["all"][-1]
return latest_version
def get_purpur_download_file_name(mc_version, serverjar_version) -> str:
"""
Gets the download name from the purpur api and merge it together in the right format
:param mc_version: Minecraft version
:param serverjar_version: Version of the serverjar
:param file_server_jar_full_name: Serverjar name
:returns: Download name of the file
"""
url = f"https://api.purpurmc.org/v2/purpur/{mc_version}/{serverjar_version}/"
build_details = api_do_request(url)
purpur_build_version = build_details["build"]
purpur_project_name = build_details["project"]
purpur_mc_version = build_details["version"]
download_name = f"{purpur_project_name}-{purpur_mc_version}-{purpur_build_version}.jar"
return download_name
def serverjar_purpur_check_update(file_server_jar_full_name) -> None:
"""
Checks the installed purpur serverjar if an update is available
:param file_server_jar_full_name: Full name of the purpu server jar file name
:returns: None
"""
serverjar_version = get_installed_serverjar_version(file_server_jar_full_name)
if serverjar_version == None:
rich_print_error("Error: An error occured while checking the installed serverjar version")
return None
version_group = get_version_group(file_server_jar_full_name)
if version_group == None:
rich_print_error(
"Error: An error occured while checking the installed version group of the installed serverjar"
)
return None
latest_version = find_latest_available_version(version_group)
if latest_version == None:
rich_print_error("Error: An error occured while checking for the latest available version of the serverjar")
return None
versions_behind = get_versions_behind(serverjar_version, latest_version)
rich_table = Table(box=None)
rich_table.add_column("Name", style="bright_magenta")
rich_table.add_column("Installed V.", justify="right", style="green")
rich_table.add_column("Latest V.", justify="right", style="bright_green")
rich_table.add_column("Versions behind", justify="right", style="cyan")
rich_table.add_row(
file_server_jar_full_name,
serverjar_version,
str(latest_version),
str(versions_behind)
)
rich_console = Console()
rich_console.print(rich_table)
return None
def serverjar_purpur_update(
server_jar_version: str="latest",
mc_version: str=None,
file_server_jar_full_name: str=None
) -> bool:
"""
Handles the downloading of the papermc serverjar
:param server_jar_version: Version of the serverjar which should get downloaded
:param mc_version: Minecraft version
:param no_confirmation: If no confirmation message should pop up
:param file_server_jar_full_name: The old serverjar file
:returns: True/False if the serverjar was downloaded successfully
"""
config_values = config_value()
match config_values.connection:
case "local":
path_server_root = config_values.path_to_plugin_folder
# need help_path or else TypeError will be thrown
help_path = Path('/plugins')
help_path_str = str(help_path)
path_server_root = Path(str(path_server_root).replace(help_path_str, ''))
case _:
path_server_root = create_temp_plugin_folder()
# exit if the mc version can't be found
if file_server_jar_full_name == None and mc_version == None:
rich_print_error("Error: Please specifiy the minecraft version as third argument!")
return False
if mc_version == None:
mc_version = get_version_group(file_server_jar_full_name)
if server_jar_version == "latest" or server_jar_version == None:
server_jar_version = find_latest_available_version(mc_version)
if file_server_jar_full_name == None:
serverjar_name = "purpur"
else:
serverjar_name = file_server_jar_full_name
# use rich console for nice colors
rich_console = Console()
rich_console.print(
f"\n [not bold][bright_white]● [bright_magenta]{serverjar_name.capitalize()}" + \
f" [cyan]→ [bright_green]{server_jar_version}"
)
if file_server_jar_full_name != None:
serverjar_version = get_installed_serverjar_version(file_server_jar_full_name)
if get_versions_behind(serverjar_version, server_jar_version) == 0:
rich_console.print(" [not bold][bright_green]No updates currently available!")
return False
try:
download_file_name = get_purpur_download_file_name(mc_version, server_jar_version)
except KeyError:
rich_print_error(f" Error: This version wasn't found for {mc_version}")
rich_print_error(f" Reverting to latest version for {mc_version}")
try:
server_jar_version = find_latest_available_version(mc_version)
download_file_name = get_purpur_download_file_name(mc_version, server_jar_version)
except KeyError:
rich_print_error(
f" Error: Version {mc_version} wasn't found for {serverjar_name.capitalize()} in the purpur api"
)
return False
url = f"https://api.purpurmc.org/v2/purpur/{mc_version}/{server_jar_version}/download/"
download_path = Path(f"{path_server_root}/{download_file_name}")
with Progress(transient=True) as progress:
header = {'user-agent': 'pluGET/1.0'}
r = requests.get(url, headers=header, stream=True)
try:
file_size = int(r.headers.get('Content-Length'))
# create progress bar
download_task = progress.add_task(" [cyan]Downloading...", total=file_size)
except TypeError:
# Content-lenght returned nothing
file_size = 0
with open(download_path, 'wb') as f:
# split downloaded data in chunks of 65536
for data in r.iter_content(chunk_size=65536):
f.write(data)
# don't show progress bar if no content-length was returned
if file_size == 0:
continue
progress.update(download_task, advance=len(data))
#f.flush()
file_size_data = convert_file_size_down(convert_file_size_down(file_size))
rich_console.print(" [not bold][bright_green]Downloaded[bright_magenta] " + (str(file_size_data)).rjust(9) + \
f" MB [cyan]→ [white]{download_path}")
if config_values.connection == "sftp":
sftp_session = sftp_create_connection()
sftp_upload_server_jar(sftp_session, download_path)
remove_temp_plugin_folder()
elif config_values.connection == "ftp":
ftp_session = ftp_create_connection()
ftp_upload_server_jar(ftp_session, download_path)
remove_temp_plugin_folder()
return True

View File

@ -11,7 +11,6 @@ from src.utils.console_output import rich_print_error
from src.handlers.handle_sftp import sftp_create_connection, sftp_list_files_in_server_root
from src.handlers.handle_ftp import ftp_create_connection, ftp_list_files_in_server_root
from src.serverjar.serverjar_paper_velocity_waterfall import serverjar_papermc_check_update, serverjar_papermc_update
from src.serverjar.serverjar_purpur import serverjar_purpur_check_update, serverjar_purpur_update
def get_installed_server_jar_file(config_values) -> str:
@ -62,18 +61,13 @@ def check_update_available_installed_server_jar() -> None:
return None
# TODO: Add other serverjars here
# Paper / Velocity / Waterfall
if "paper" in file_server_jar_full_name or \
"waterfall" in file_server_jar_full_name or \
"velocity" in file_server_jar_full_name:
serverjar_papermc_check_update(file_server_jar_full_name)
# Purpur
elif "purpur" in file_server_jar_full_name:
serverjar_purpur_check_update(file_server_jar_full_name)
else:
rich_print_error(f"[not bold]Error: [bright_magenta]{file_server_jar_full_name} [bright_red]isn't supported")
rich_print_error(f"{file_server_jar_full_name} isn't supported")
return None
@ -105,22 +99,11 @@ def update_installed_server_jar(server_jar_version: str="latest") -> None:
server_jar_path = f"{path_server_root}/{file_server_jar_full_name}"
rich_console = Console()
download_successfull = False
# TODO: Add other serverjars here
# Paper / Velocity / Waterfall
if "paper" in file_server_jar_full_name or \
"waterfall" in file_server_jar_full_name or \
"velocity" in file_server_jar_full_name:
download_successfull = serverjar_papermc_update(server_jar_version, None, file_server_jar_full_name, None)
# Purpur
elif "purpur" in file_server_jar_full_name:
download_successfull = serverjar_purpur_update(server_jar_version, None, file_server_jar_full_name)
else:
rich_print_error(f"[not bold]Error: [bright_magenta]{file_server_jar_full_name} [bright_red]isn't supported")
# remove old serverjar when the serverjar was sucessfully updated
if download_successfull is True:
match config_values.connection:
case "local":
@ -136,4 +119,7 @@ def update_installed_server_jar(server_jar_version: str="latest") -> None:
f"{file_server_jar_full_name}"
)
else:
rich_print_error(f"{file_server_jar_full_name} isn't supported")
return None

View File

@ -5,4 +5,4 @@ PLUGETVERSION = current version of pluGET
"""
# constant values
PLUGETVERSION = "1.7.2"
PLUGETVERSION = "1.7.0"

View File

@ -3,6 +3,14 @@ import unittest
from src.serverjar import serverjar_paper_velocity_waterfall
class TestCases(unittest.TestCase):
def test_get_installed_mc_version(self):
# paper-1.19-40.jar -> 1.19
serverjar_file_name = "paper-1.19-40.jar"
mc_version = "1.19"
result = serverjar_paper_velocity_waterfall.get_installed_mc_version(serverjar_file_name)
self.assertEqual(result, mc_version)
def test_get_installed_serverjar_version(self):
# paper-1.19-40.jar -> 40
serverjar_file_name = "paper-1.19-40.jar"

View File

@ -1,40 +0,0 @@
import unittest
from src.serverjar import serverjar_purpur
from src.serverjar import serverjar_paper_velocity_waterfall
class TestCases(unittest.TestCase):
def test_get_installed_serverjar_version(self):
# purpur-1.19-40.jar -> 40
serverjar_file_name = "purpur-1.19-40.jar"
serverjar_version = "40"
result = serverjar_paper_velocity_waterfall.get_installed_serverjar_version(serverjar_file_name)
self.assertEqual(result, serverjar_version)
def test_get_version_group(self):
# 1.18.2 -> 1.18
mc_version = "1.18.2"
mc_version_group = "1.18.2"
result = serverjar_paper_velocity_waterfall.get_version_group(mc_version)
self.assertEqual(result, mc_version_group)
def test_find_latest_available_version(self):
# Get latest available purpur version for 1.15.2 which should be '606'
file_server_jar_full_name = "purpur-1.15.2-40.jar"
version_group = "1.15.2"
result = serverjar_purpur.find_latest_available_version(version_group)
self.assertEqual(result, str(606))
def test_get_versions_behind(self):
# 161 - 157 = 4
serverjar_version = 157
latest_version = 161
result = serverjar_paper_velocity_waterfall.get_versions_behind(serverjar_version, latest_version)
self.assertEqual(result, 4)
if __name__ == "__main__":
unittest.main()

View File

@ -21,7 +21,6 @@ def rename_console_title() -> None:
"""
Renames the console title on first startup
"""
if os.name == "nt":
os.system("title " + "pluGET │ By Neocky")
return None

View File

@ -9,7 +9,6 @@ import shutil
import re
from pathlib import Path
from rich.console import Console
from rich.table import Table
from src.handlers.handle_sftp import sftp_create_connection
from src.handlers.handle_ftp import ftp_create_connection
@ -18,72 +17,6 @@ from src.handlers.handle_config import config_value
from src.settings import PLUGETVERSION
def get_command_help(command: str) -> None:
"""
Prints the help page for all commands and individual commands
:param command: Console command which the help page should show
:returns: None
"""
rich_console = Console()
rich_table = Table(box=None)
rich_table.add_column("Command", justify="left", style="bright_blue", no_wrap=True)
rich_table.add_column("Object", style="bright_magenta")
rich_table.add_column("Params", justify="left", style="cyan")
rich_table.add_column("Description", justify="left", style="white")
match command:
case "all":
rich_table.add_row("check", "Name/all", None, "Check for an update of an installed plugin")
rich_table.add_row("check", "serverjar", None, "Check for an update for the installed serverjar")
rich_table.add_row("exit", "./anything", None, "Exit pluGET")
rich_table.add_row("get", "Name/ID", None, "Downloads the latest version of a plugin")
rich_table.add_row("get-paper", "PaperVersion", "McVersion", "Downloads a specific PaperMc version")
rich_table.add_row("get-purpur", "PurpurVersion", "McVersion", "Downloads a specific Purpur version")
rich_table.add_row("get-velocity", "VelocityVersion", "McVersion", "Downloads a specific Velocity version")
rich_table.add_row(
"get-waterfall", "WaterfallVersion", "McVersion", "Downloads a specific waterfall version"
)
rich_table.add_row("help", "./anything", None, "Get specific help to the commands of pluGET")
rich_table.add_row("remove", "Name", None, "Delete an installed plugin from the plugin folder")
rich_table.add_row("search", "Name/all", None, "Search for a plugin and download the latest version")
rich_table.add_row("update", "Name/all", None, "Update installed plugins to the latest version")
rich_table.add_row("update", "serverjar", None, "Update the installed serverjar to the latest version")
case "check":
rich_table.add_row("check", "Name/all", None, "Check for an update of an installed plugin")
rich_table.add_row("check", "serverjar", None, "Check for an update for the installed serverjar")
case "exit":
rich_table.add_row("exit", "./anything", None, "Exit pluGET")
case "get":
rich_table.add_row("get", "Name/ID", None, "Downloads the latest version of a plugin")
case "get-paper":
rich_table.add_row("get-paper", "PaperVersion", "McVersion", "Downloads a specific PaperMc version")
case "get-purpur":
rich_table.add_row("get-purpur", "PurpurVersion", "McVersion", "Downloads a specific Purpur version")
case "get-velocity":
rich_table.add_row("get-velocity", "VelocityVersion", "McVersion", "Downloads a specific Velocity version")
case "get-waterfall":
rich_table.add_row(
"get-waterfall", "WaterfallVersion", "McVersion", "Downloads a specific Waterfall version"
)
case "help" | "all":
rich_table.add_row("help", "./anything", None, "Get specific help to the commands of pluGET")
case "remove":
rich_table.add_row("remove", "Name", None, "Delete an installed plugin from the plugin folder")
case "search":
rich_table.add_row("search", "Name/all", None, "Search for a plugin and download the latest version")
case "update":
rich_table.add_row("update", "Name/all", None, "Update installed plugins to the latest version")
rich_table.add_row("update", "serverjar", None, "Update the installed serverjar to the latest version")
case _:
rich_print_error(f"[not bold]Error: Help for command [bright_magenta]'{command}' [bright_red]not found!")
rich_print_error("Use [bright_blue]'help all' [bright_red]to get a list of all commands.")
return None
rich_console.print(rich_table)
def check_for_pluGET_update() -> None:
"""
Check with the github api if there is a new version for pluGET available and print download message if this is