forked from Dragoboss/PlayerHeads
-
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.
make ignoring external heads configurable
- Loading branch information
1 parent
6946b56
commit 49b6b12
Showing
5 changed files
with
75 additions
and
69 deletions.
There are no files selected for viewing
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
57 changes: 0 additions & 57 deletions
57
...java/com/github/crashdemons/playerheads/compatibility/plugins/heads/ExternalHeadType.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
...in/java/com/github/crashdemons/playerheads/compatibility/plugins/heads/ExternalHeads.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,58 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/ . | ||
*/ | ||
package com.github.crashdemons.playerheads.compatibility.plugins.heads; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import org.bukkit.configuration.ConfigurationSection; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* | ||
* @author crashdemons (crashenator at gmail.com) | ||
*/ | ||
public class ExternalHeads { | ||
private ExternalHeads(){} | ||
|
||
private static final HashMap<String,ExternalHeadHandling> nameToHandling = new HashMap<>(); | ||
private static final HashMap<UUID,ExternalHeadHandling> idToHandling = new HashMap<>(); | ||
|
||
public static void loadNamesFromConfig(ConfigurationSection section, String key, ExternalHeadHandling handling){ | ||
List<String> names = section.getStringList(key); | ||
if(names==null) return; | ||
for(String name : names) | ||
nameToHandling.put(name,handling); | ||
} | ||
|
||
public static void loadIdsFromConfig(ConfigurationSection section, String key, ExternalHeadHandling handling){ | ||
List<String> ids = section.getStringList(key); | ||
if(ids==null) return; | ||
for(String id : ids){ | ||
UUID uuid = null; | ||
try{ | ||
uuid = UUID.fromString(id); | ||
idToHandling.put(uuid,handling); | ||
}catch(IllegalArgumentException e){ | ||
//do nothing - invalid UUID String, no logging facility for this internal class. | ||
} | ||
} | ||
} | ||
|
||
@Nullable | ||
public static ExternalHeadHandling getHandling(String username){ | ||
if(username==null) return null; | ||
return nameToHandling.get(username); | ||
} | ||
|
||
@Nullable | ||
public static ExternalHeadHandling getHandling(UUID id){ | ||
if(id==null) return null; | ||
return idToHandling.get(id); | ||
} | ||
|
||
|
||
} |
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