Skip to content

Commit

Permalink
Add cUUID class (cuberite#3871)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbell10 authored and bearbin committed Aug 25, 2017
1 parent 86d52c3 commit f4f2fc7
Show file tree
Hide file tree
Showing 54 changed files with 1,339 additions and 508 deletions.
156 changes: 142 additions & 14 deletions Server/Plugins/APIDump/APIDesc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ end
{
{
Name = "UUID",
Type = "string",
Type = "cUUID",
},
},
Returns =
Expand All @@ -1472,7 +1472,7 @@ end
Type = "boolean",
},
},
Notes = "Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID. We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. Accepts both 32-char and 36-char UUIDs (with and without dashes). If the string given is not a valid UUID, returns false.",
Notes = "Returns true if the UUID is generated by online auth, false if it is an offline-generated UUID. We use Version-3 UUIDs for offline UUIDs, online UUIDs are Version-4, thus we can tell them apart. Accepts both 32-char and 36-char UUIDs (with and without dashes).",
},
Kick =
{
Expand Down Expand Up @@ -8485,10 +8485,9 @@ a_Player:OpenWindow(Window);
<p>
All the functions are static, call them using the <code>cMojangAPI:Function()</code> convention.</p>
<p>
Mojang uses two formats for UUIDs, short and dashed. Cuberite works with short UUIDs internally, but
will convert to dashed UUIDs where needed - in the protocol login for example. The MakeUUIDShort()
and MakeUUIDDashed() functions are provided for plugins to use for conversion between the two
formats.</p>
Mojang uses two formats for UUIDs, short and dashed. Cuberite will accept either format for any
functions taking a UUID. The MakeUUIDShort() and MakeUUIDDashed() functions are provided for plugins
to use for conversion between the two formats.</p>
<p>
This class will cache values returned by the API service. The cache will hold the values for 7 days
by default, after that, they will no longer be available. This is in order to not let the server get
Expand All @@ -8509,10 +8508,10 @@ a_Player:OpenWindow(Window);
},
{
Name = "UUID",
Type = "string",
Type = "cUUID",
},
},
Notes = "Adds the specified PlayerName-to-UUID mapping into the cache, with current timestamp. Accepts both short or dashed UUIDs. ",
Notes = "Adds the specified PlayerName-to-UUID mapping into the cache, with current timestamp.",
},
GetPlayerNameFromUUID =
{
Expand All @@ -8521,7 +8520,7 @@ a_Player:OpenWindow(Window);
{
{
Name = "UUID",
Type = "string",
Type = "cUUID",
},
{
Name = "UseOnlyCached",
Expand Down Expand Up @@ -8592,7 +8591,7 @@ a_Player:OpenWindow(Window);
{
{
Name = "UUID",
Type = "string",
Type = "cUUID",
},
},
Returns =
Expand All @@ -8602,7 +8601,7 @@ a_Player:OpenWindow(Window);
Type = "string",
},
},
Notes = "Converts the UUID to a dashed format (\"01234567-8901-2345-6789-012345678901\"). Accepts both dashed or short UUIDs. Logs a warning and returns an empty string if UUID format not recognized.",
Notes = "Converts the UUID to a dashed format (\"01234567-8901-2345-6789-012345678901\"). An alias for cUUID:ToLongString()",
},
MakeUUIDShort =
{
Expand All @@ -8611,7 +8610,7 @@ a_Player:OpenWindow(Window);
{
{
Name = "UUID",
Type = "string",
Type = "cUUID",
},
},
Returns =
Expand All @@ -8621,7 +8620,7 @@ a_Player:OpenWindow(Window);
Type = "string",
},
},
Notes = "Converts the UUID to a short format (without dashes, \"01234567890123456789012345678901\"). Accepts both dashed or short UUIDs. Logs a warning and returns an empty string if UUID format not recognized.",
Notes = "Converts the UUID to a short format (without dashes, \"01234567890123456789012345678901\"). An alias for cUUID:ToShortString()",
},
},
},
Expand Down Expand Up @@ -11181,7 +11180,7 @@ a_Player:OpenWindow(Window);
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
{
Name = "CallbackFunction",
Expand Down Expand Up @@ -12441,6 +12440,135 @@ end
},
},
},
cUUID =
{
Desc = [[
Class representing a Universally Unique Identifier.
Note that all Cuberite's API functions that take a cUUID parameter will also
accept a string in its place, as long as that string can be converted to a cUUID
(using the {{#FromString_1|cUUID:FromString}} function).
]],
Functions =
{
constructor =
{
Returns =
{
{
Type = "cUUID",
},
},
Notes = "Constructs a nil-valued UUID (all zeros)",
},
Compare =
{
Params =
{
{
Name = "Other",
Type = "cUUID",
},
},
Returns =
{
{
Type = "number",
},
},
Notes = [[
Compares this UUID with the specified Other UUID, Returns:
0 when equal to Other,
< 0 when less than Other,
> 0 when greater than Other
]],
},
IsNil =
{
Returns =
{
{
Type = "boolean",
},
},
Notes = "Returns true if this contains the \"nil\" UUID with all bits set to 0",
},
FromString =
{
Params =
{
{
Name = "StringUUID",
Type = "string",
},
},
Returns =
{
{
Type = "boolean",
},
},
Notes = "Tries to interpret the string as a short or long form UUID and assign from it. On error, returns false and does not set the value.",
},
ToShortString =
{
Returns =
{
{
Type = "string",
},
},
Notes = "Converts the UUID to a short form string (i.e without dashes).",
},
ToLongString =
{
Returns =
{
{
Type = "string",
},
},
Notes = "Converts the UUID to a long form string (i.e with dashes).",
},
Version =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the version number of the UUID.",
},
Variant =
{
Returns =
{
{
Type = "number",
},
},
Notes = "Returns the variant number of the UUID",
},
GenerateVersion3 =
{
IsStatic = true,
Params =
{
{
Name = "Name",
Type = "string",
},
},
Returns =
{
{
Type = "cUUID",
},
},
Notes = "Generates a version 3, variant 1 UUID based on the md5 hash of Name."
},
},
},
cWebPlugin =
{
Desc = "",
Expand Down
16 changes: 8 additions & 8 deletions Server/Plugins/APIDump/Classes/RankManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ return
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
},
Returns =
Expand All @@ -276,7 +276,7 @@ return
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
},
Returns =
Expand All @@ -303,7 +303,7 @@ return
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
},
Returns =
Expand All @@ -322,7 +322,7 @@ return
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
},
Returns =
Expand All @@ -340,7 +340,7 @@ return
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
},
Returns =
Expand Down Expand Up @@ -502,7 +502,7 @@ return
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
},
Returns =
Expand Down Expand Up @@ -604,7 +604,7 @@ return
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
},
Notes = "Removes the player's rank; the player's left without a rank. Note that this doesn't change the {{cPlayer}} instances for the already connected players, you need to update all the instances manually. No action if the player has no rank assigned to them already.",
Expand Down Expand Up @@ -699,7 +699,7 @@ return
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
{
Name = "PlayerName",
Expand Down
4 changes: 2 additions & 2 deletions Server/Plugins/APIDump/Classes/World.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ return
Each world runs several separate threads used for various housekeeping purposes, the most important
of those is the Tick thread. This thread updates the game logic 20 times per second, and it is
the thread where all the gameplay actions are evaluated. Liquid physics, entity interactions,
player ovement etc., all are applied in this thread.</p>
player movement etc., all are applied in this thread.</p>
<p>
Additional threads include the generation thread (generates new chunks as needed, storage thread
(saves and loads chunk from the disk), lighting thread (updates block light values) and the
Expand Down Expand Up @@ -901,7 +901,7 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
{
{
Name = "PlayerUUID",
Type = "string",
Type = "cUUID",
},
{
Name = "CallbackFunction",
Expand Down
2 changes: 2 additions & 0 deletions Tools/ProtoProxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ set_exe_flags()
set(SHARED_SRC
../../src/ByteBuffer.cpp
../../src/StringUtils.cpp
../../src/UUID.cpp
../../src/PolarSSL++/AesCfb128Decryptor.cpp
../../src/PolarSSL++/AesCfb128Encryptor.cpp
../../src/PolarSSL++/CryptoKey.cpp
Expand All @@ -41,6 +42,7 @@ set(SHARED_SRC
set(SHARED_HDR
../../src/ByteBuffer.h
../../src/StringUtils.h
../../src/UUID.h
../../src/PolarSSL++/AesCfb128Decryptor.h
../../src/PolarSSL++/AesCfb128Encryptor.h
../../src/PolarSSL++/CryptoKey.h
Expand Down
9 changes: 6 additions & 3 deletions src/Bindings/AllToLua.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ inheritance doesn't work properly (#1789).
$#include "../Globals.h"

// Typedefs from Globals.h, so that we don't have to process that file:
typedef long long Int64;
typedef int Int32;
typedef short Int16;
typedef signed long long Int64;
typedef signed int Int32;
typedef signed short Int16;
typedef signed char Int8;

typedef unsigned long long UInt64;
typedef unsigned int UInt32;
typedef unsigned short UInt16;
typedef unsigned char UInt8;


$cfile "../Vector3.h"
Expand Down Expand Up @@ -69,6 +71,7 @@ $cfile "../MapManager.h"
$cfile "../Scoreboard.h"
$cfile "../Statistics.h"
$cfile "../Protocol/MojangAPI.h"
$cfile "../UUID.h"

// Entities:
$cfile "../Entities/Entity.h"
Expand Down
1 change: 1 addition & 0 deletions src/Bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ set(BINDING_DEPENDENCIES
../StringUtils.h
../Tracer.h
../UI/Window.h
../UUID.h
../Vector3.h
../WebAdmin.h
../World.h
Expand Down
Loading

0 comments on commit f4f2fc7

Please sign in to comment.