-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This update adds functionality to save UUIDs / usernames into playerdata when queries are made for those UUIDs (but not already saved, afterwards, such as adding to whitelist). This way, you can speed up future searches, without having to have that player have been on the whitelist at some point. This is optional, and can be turned off in the config. It is true, by default. Additionally, there is now a 'getid' function, which will allow a user to see search for a player's UUID by their username. This will hook into SaveQueries, if enabled, and save that information to playerdata. As you can see from an alias assembler in previous versions of Executor.java, this was already a planned feature.
- Loading branch information
FerusGrim
committed
Apr 29, 2014
1 parent
fa9d1d6
commit ed45767
Showing
7 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
src/main/java/io/github/ferusgrim/GrimList/Commands/GetUUID.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/** | ||
* @author FerusGrim | ||
* @website http://ferusgrim.github.io/ | ||
* Copyright under GPLv3 to Nicholas Badger (FerusGrim) - 2014 | ||
*/ | ||
|
||
package io.github.ferusgrim.GrimList.Commands; | ||
|
||
import io.github.ferusgrim.GrimList.GrimList; | ||
import io.github.ferusgrim.GrimList.utils.AsyncThenSyncOperation; | ||
import io.github.ferusgrim.GrimList.utils.UUIDFetcher; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
public class GetUUID { | ||
private GrimList plugin; | ||
|
||
public GetUUID(GrimList plugin){ | ||
this.plugin = plugin; | ||
} | ||
|
||
public boolean run(CommandSender sender, String name){ | ||
switch(plugin.focusOn){ | ||
case "file": | ||
String uuid = plugin.filem.getUUID(name); | ||
if(uuid.isEmpty()){ | ||
runOperation(sender, name); | ||
}else{ | ||
outputText(sender, uuid, name); | ||
} | ||
break; | ||
} | ||
return true; | ||
} | ||
|
||
public void outputText(CommandSender sender, String uuid, String name){ | ||
if (sender instanceof Player){ | ||
sender.sendMessage(plugin.mStart + "UUID of " + name + ":"); | ||
sender.sendMessage(plugin.mStart + uuid); | ||
} else { | ||
plugin.log("INFO", "UUID of " + name + ":"); | ||
plugin.log("INFO", uuid); | ||
} | ||
} | ||
|
||
public void runOperation(CommandSender sender, String name){ | ||
if (sender instanceof Player) { | ||
sender.sendMessage(plugin.mStart + "Looking up UUID. This can take a moment..."); | ||
} else { | ||
plugin.log("INFO", "Looking up UUID. This can take a moment..."); | ||
} | ||
new AsyncThenSyncOperation(plugin, true){ | ||
private Map<String, UUID> response = null; | ||
|
||
@Override | ||
protected void execAsyncFirst() { | ||
try{ | ||
response = new UUIDFetcher(Arrays.asList(name.toLowerCase())).call(); | ||
} catch (Exception e) { | ||
plugin.log("WARNING", "Exception while running UUIDFetcher!"); | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void execSyncThen() { | ||
if (response.get(name.toLowerCase()) == null) { | ||
if (sender instanceof Player) { | ||
sender.sendMessage(plugin.mStart + "UUID Query returned null! Invalid username?"); | ||
} else { | ||
plugin.log("WARNING", "UUID Query returned null! Username might not exist.?"); | ||
} | ||
return; | ||
} | ||
String uuid = response.get(name.toLowerCase()).toString(); | ||
switch(plugin.focusOn){ | ||
case "file": | ||
if (plugin.filem.recordExists(uuid)) { | ||
outputText(sender, uuid, name); | ||
} else { | ||
if (!plugin.filem.recordExists(uuid) && plugin.getConfig().getBoolean("SaveQueries")) { | ||
plugin.filem.newPlayerRecord(uuid, name); | ||
outputText(sender, uuid, name); | ||
return; | ||
} | ||
} | ||
if (sender instanceof Player) { | ||
sender.sendMessage(plugin.mStart + "Player record not found!"); | ||
}else{ | ||
plugin.log("WARNING", "Player record not found!"); | ||
} | ||
break; | ||
} | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters