Skip to content
This repository has been archived by the owner on Oct 29, 2022. It is now read-only.

Async/Await + Libasynql #465

Draft
wants to merge 47 commits into
base: API4
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ac6939c
Swapped data storage to use libasynql
jasonw4331 Feb 5, 2022
65f8781
Converted save function to async/await format
jasonw4331 Feb 5, 2022
88c6948
Converted getPlotsOfPlayer function to async/await format
jasonw4331 Feb 5, 2022
49d326d
Converted getNextFreePlot function to async/await format
jasonw4331 Feb 5, 2022
a03fad9
Converted getPlotByPosition function to async/await format
jasonw4331 Feb 5, 2022
21801d3
Converted getPlotPosition function to async/await format
jasonw4331 Feb 5, 2022
0042529
Converted isPositionBorderingPlot function to async/await format
jasonw4331 Feb 5, 2022
b13d409
Converted getPlotBorderingPosition function to async/await format
jasonw4331 Feb 5, 2022
73d357d
Converted getPlotBB function to async/await format
jasonw4331 Feb 5, 2022
430bca7
Converted renamePlot function to async/await format
jasonw4331 Feb 5, 2022
48b4a6e
Fixed getPlotBorderingPosition missing its promise resolution
jasonw4331 Feb 5, 2022
5e5ce0b
Converted disposePlot to async/await format
jasonw4331 Feb 5, 2022
5599012
Converted claimPlot to async/await format
jasonw4331 Feb 5, 2022
58ecfc4
Added missing function param
jasonw4331 Feb 5, 2022
f2f2473
Added some utility functions for more generators
jasonw4331 Feb 5, 2022
aec3814
use new utility functions in getPlotBB
jasonw4331 Feb 5, 2022
3f120c1
publicize getPlotFast for a non-async way to get a plot object
jasonw4331 Feb 5, 2022
87d5e37
Updated clonePlot to Async/Await format
jasonw4331 Feb 5, 2022
73be908
Updated clearPlot to Async/Await format
jasonw4331 Feb 5, 2022
339bcf1
Updated resetPlot to Async/Await format
jasonw4331 Feb 5, 2022
bff40b5
Updated setPlotBiome to Async/Await format
jasonw4331 Feb 5, 2022
b15e883
Updated setPlotPvp to Async/Await format
jasonw4331 Feb 5, 2022
aa8cc79
Updated addPlotHelper to Async/Await format
jasonw4331 Feb 5, 2022
50f3ef8
Updated removePlotHelper to Async/Await format
jasonw4331 Feb 5, 2022
ff11da3
Updated addPlotDenied to Async/Await format
jasonw4331 Feb 5, 2022
3d623cb
Updated removePlotDenied to Async/Await format
jasonw4331 Feb 5, 2022
0481a83
Updated buyPlot to Async/Await format
jasonw4331 Feb 5, 2022
b06d1b1
Updated mergePlots to Async/Await format
jasonw4331 Feb 5, 2022
ccd237d
Updated sellPlot to Async/Await format
jasonw4331 Feb 5, 2022
7789756
Extract await-style API into InternalAPI class
jasonw4331 Mar 6, 2022
c74cdd5
Remove unused static getPlotPosition
jasonw4331 Mar 6, 2022
dcedb75
Extract plot into 3 types
jasonw4331 Mar 6, 2022
ca8480d
Added await-generator virion in poggit
jasonw4331 Mar 6, 2022
95e0f1a
Making InternalAPI fit our needs better
jasonw4331 Mar 9, 2022
057d93d
Make the Internal and External APIs consistant
jasonw4331 Mar 9, 2022
e92efbb
Updated subcommands to use new API
jasonw4331 Mar 9, 2022
55a9eb1
Finalize some classes
jasonw4331 Mar 9, 2022
a6d0535
fix some sql bugs
jasonw4331 Mar 9, 2022
3a4ab36
Added sql for merge entry deletion
jasonw4331 Mar 9, 2022
90ef3b5
Formatted SQL
jasonw4331 Mar 10, 2022
20d8359
Clarify logic based on Plot object types
jasonw4331 Mar 10, 2022
b413bc4
Implemented MergedPlot caching
jasonw4331 Mar 10, 2022
967f9ed
Increase Default Cache
jasonw4331 Mar 10, 2022
34f04d5
Refactor everything
jasonw4331 Apr 6, 2022
3056bca
Fix await-generator (#473)
AIPTU Apr 7, 2022
ce4e7c4
Fixed bad argument
jasonw4331 Apr 7, 2022
1a0dc77
capitalization change
jasonw4331 Apr 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .poggit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ projects:
icon: "icon.png"
path: ""
libs:
- src: poggit/libasynql/libasynql
version: ^3.3.0
- src: SOF3/await-generator/await-generator
version: ^3.1.1
- src: dktapps-pm-pl/pmforms/pmforms
version: ^2.0.0
lint: false
Expand All @@ -15,4 +19,4 @@ projects:
- .gitignore
- CONTRIBUTING.md
- SECURITY.md
...
...
5 changes: 3 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ authors:
description: "Plots and Protection Plugin for PocketMine-MP Servers"
load: STARTUP
softdepend:
- EconomyAPI
- Capital
- DEVirion
- WorldStyler
- EasyCommandAutofill
- EconomyAPI
- WorldStyler
permissions:
myplot.command:
default: true
Expand Down
42 changes: 25 additions & 17 deletions resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,25 @@ Custom Messages: false
UI Forms: true

# The data provider where plot data is stored.
# Current providers are: sqlite, mysql, json, and yaml.
DataProvider: sqlite

# contains settings for mysql provider to use when selected
MySQLSettings:
Host: 127.0.0.1
Port: 3306
Username: default
Password: password
DatabaseName: MyPlot
ShutdownOnFailure: false
Database:
# The database type. "sqlite" and "mysql" are supported.
type: sqlite

# Edit these settings only if you choose "sqlite".
sqlite:
# The file name of the database in the plugin data folder.
# You can also put an absolute path here.
file: plots.db
# Edit these settings only if you choose "mysql".
mysql:
host: 127.0.0.1
# Avoid using the "root" user for security reasons.
username: default
password: password
schema: myplot
# The maximum number of simultaneous SQL queries
# Recommended: 1 for sqlite, 2 for MySQL. You may want to further increase this value if your MySQL connection is very slow.
worker-limit: 1

# Use an economy with MyPlot. This will allow for plot pricing such as claiming, clearing, etc.
# Currently supported economy plugins: Economy$
Expand All @@ -56,7 +64,7 @@ UseEconomy: false

# Amount of plots to be cached.
# Increasing this number will improve performance, but also increase memory usage.
PlotCacheSize: 256
PlotCacheSize: 2500

# When a player enters a plot, a popup with basic info will be shown
ShowPlotPopup: true
Expand Down Expand Up @@ -121,12 +129,12 @@ DefaultWorld:
RoadWidth: 7

# The block that the road is made of (Default is Oak Planks)
RoadBlock: '5:0'
RoadBlock: oak planks
# The block that plot walls are made of (Default is Stone Slabs)
WallBlock: '44:0'
WallBlock: stone slab
# The block used as the plot floor (Default is Grass)
PlotFloorBlock: '2:0'
PlotFloorBlock: grass
# The block that fills the rest of the plot (Default is Dirt)
PlotFillBlock: '3:0'
PlotFillBlock: dirt
# The block at the bottom (Default is Bedrock)
BottomBlock: '7:0'
BottomBlock: bedrock
4 changes: 2 additions & 2 deletions resources/eng.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ command.name=plot
command.alias=p
command.desc=Claim and manage your plots
command.usage=/p [help]
command.usable=You cannot use this command right now
command.unknown=Unknown command. Try /p help for a list of commands

subcommand.usage=Usage: {%0}
Expand Down Expand Up @@ -282,8 +283,7 @@ clone.wrongid="The plot id should be in the format X;Z"
clone.nomoney=You do not have enough money to clone this plot
clone.success=Plot {%0} has been successfully cloned to plot {%1}
clone.form=Clone
clone.formlabel1=Origin Plot Location
clone.formlabel2=Clone Plot Location
clone.formcoordslabel=Clone Plot Location
clone.formxcoord=Plot X Coordinate
clone.formzcoord=Plot Z Coordinate
clone.formworld=Plot World Name
Expand Down
4 changes: 2 additions & 2 deletions resources/langtemplate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ command.name=plot
command.alias=p
command.desc=
command.usage=/p [help]
command.usable=
command.unknown=

subcommand.usage=
Expand Down Expand Up @@ -269,8 +270,7 @@ clone.wrongid=
clone.nomoney=
clone.success=
clone.form=
clone.formlabel1=
clone.formlabel2=
clone.formcoordslabel=
clone.formxcoord=
clone.formzcoord=
clone.formworld=
Expand Down
223 changes: 223 additions & 0 deletions resources/mysql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
-- #!mysql
-- #{myplot
-- # {init
-- # {plots
CREATE TABLE IF NOT EXISTS plotsV2
(
level TEXT,
X INT,
Z INT,
name TEXT,
owner TEXT,
helpers TEXT,
denied TEXT,
biome TEXT,
pvp INT,
price FLOAT,
PRIMARY KEY (level, X, Z)
);
-- # }
-- # {mergedPlots
CREATE TABLE IF NOT EXISTS mergedPlotsV2
(
level TEXT,
originX INT,
originZ INT,
mergedX INT,
mergedZ INT,
PRIMARY KEY (level, originX, originZ, mergedX, mergedZ)
);
-- # }
-- # }
-- # {test
-- # {table
-- # :tableName string
SELECT COUNT(*) AS tables
FROM information_schema.tables
WHERE table_schema = DATABASE()
AND table_name = :tableName;
-- # }
-- # }
-- # {add
-- # {plot
-- # :level string
-- # :X int
-- # :Z int
-- # :name string
-- # :owner string
-- # :helpers string
-- # :denied string
-- # :biome string
-- # :pvp bool false
-- # :price float
INSERT INTO plotsV2 (level, X, Z, name, owner, helpers, denied, biome, pvp, price)
VALUES (:level, :X, :Z, :name, :owner, :helpers, :denied, :biome, :pvp, :price)
ON DUPLICATE KEY UPDATE name = VALUES(:name),
owner = VALUES(:owner),
helpers = VALUES(:helpers),
denied = VALUES(:denied),
biome = VALUES(:biome),
pvp = VALUES(:pvp),
price = VALUES(:price);
-- # }
-- # {merge
-- # :level string
-- # :originX int
-- # :originZ int
-- # :mergedX int
-- # :mergedZ int
INSERT IGNORE INTO mergedPlotsV2 (`level`, `originX`, `originZ`, `mergedX`, `mergedZ`)
VALUES (:level, :originX, :originZ, :mergedX, :mergedZ);
-- # }
-- # }
-- # {get
-- # {plot
-- # {by-xz
-- # :level string
-- # :X int
-- # :Z int
SELECT name, owner, helpers, denied, biome, pvp, price
FROM plotsV2
WHERE level = :level
AND X = :x
AND Z = :z;
-- # }
-- # }
-- # {all-plots
-- # {by-owner
-- # :owner string
SELECT level, X, Z
FROM plotsV2
WHERE owner = :owner;
-- # }
-- # }
-- # {all-plots
-- # {by-owner-and-level
-- # :owner string
-- # :level string
SELECT level, X, Z
FROM plotsV2
WHERE owner = :owner
AND level = :level;
-- # }
-- # }
-- # {highest-existing
-- # {by-interval
-- # :level string
-- # :number int
SELECT X, Z
FROM plotsV2
WHERE (level = :level AND ((abs(X) = :number AND abs(Z) <= :number) OR (abs(Z) = :number AND abs(X) <= :number)));
-- # }
-- # }
-- # {merge-plots
-- # {by-origin
-- # :level string
-- # :originX int
-- # :originZ int
SELECT plotsV2.level,
X,
Z,
name,
owner,
helpers,
denied,
biome,
pvp,
price
FROM plotsV2
LEFT JOIN mergedPlotsV2
ON mergedPlotsV2.level = plotsV2.level
AND mergedX = X
AND mergedZ = Z
WHERE mergedPlotsV2.level = :level
AND originX = :originX
AND originZ = :originZ;
-- # }
-- # }
-- # {merge-plots
-- # {by-merged
-- # :level string
-- # :mergedX int
-- # :mergedZ int
SELECT plotsV2.level,
X,
Z,
name,
owner,
helpers,
denied,
biome,
pvp,
price
FROM plotsV2
LEFT JOIN mergedPlotsV2
ON mergedPlotsV2.level = plotsV2.level
AND mergedX = X
AND mergedZ = Z
WHERE mergedPlotsV2.level = :level
AND originX = (
SELECT originX
FROM mergedPlotsV2
WHERE mergedX = :mergedX
AND mergedZ = :mergedZ
AND mergedPlotsV2.level = :level
)
AND originZ = (
SELECT originZ
FROM mergedPlotsV2
WHERE mergedX = :mergedX
AND mergedZ = :mergedZ
AND mergedPlotsV2.level = :level
);
-- # }
-- # }
-- # }
-- # {remove
-- # {plot
-- # {by-xz
-- # :level string
-- # :x int
-- # :z int
DELETE
FROM plotsV2
WHERE level = :level
AND X = :X
AND Z = :Z;
-- # }
-- # }
-- # {merge
-- # {by-xz
-- # :level string
-- # :x int
-- # :z int
-- # :pvp bool false
-- # :price float
UPDATE plotsV2
SET name = '',
owner = '',
helpers = '',
denied = '',
pvp = :pvp,
price = :price
WHERE level = :level
AND X = :x
AND Z = :z;
-- # }
-- # }
-- # {merge-entry
-- # :level string
-- # :originX int
-- # :originZ int
-- # :mergedX int
-- # :mergedZ int
DELETE
FROM mergedPlotsV2
WHERE level = :level
AND originX = :originX
AND originZ = :originZ
AND mergedX = :mergedX
AND mergedZ = :mergedZ;
-- # }
-- # }
-- #}
Loading