Browse Source

UUIDs are really working!..

master
SimSonic 10 years ago
parent
commit
01f73d24f1
  1. 31
      src/main/java/ru/simsonic/rscPermissions/API/PlayerType.java
  2. 7
      src/main/java/ru/simsonic/rscPermissions/Backends/DatabaseContents.java
  3. 8
      src/main/java/ru/simsonic/rscPermissions/IndependentMain.java
  4. 4
      src/main/resources/languages/english.yml
  5. 8
      src/main/resources/languages/russian.yml

31
src/main/java/ru/simsonic/rscPermissions/API/PlayerType.java

@ -37,18 +37,45 @@ public enum PlayerType
return INTERNET_SUBNETMASK; return INTERNET_SUBNETMASK;
return INAPPLICABLE; return INAPPLICABLE;
} }
public static String normalize(String entity)
{
if(entity == null || "".equals(entity))
return "";
if(Matchers.isCorrectDashlessUUID(entity))
return Matchers.uuidAddDashes(entity);
return entity;
}
public boolean isEntityApplicable(String entity, String identifier) public boolean isEntityApplicable(String entity, String identifier)
{ {
if(entity == null || "".equals(entity) || identifier == null || "".equals(identifier)) if(entity == null || "".equals(entity) || identifier == null || "".equals(identifier))
return false; return false;
try
{
switch(this) switch(this)
{ {
case NAME: case NAME:
return identifier.equals(entity); return identifier.equals(entity);
case UUID:
identifier = identifier.replace("-", "");
case DASHLESS_UUID: case DASHLESS_UUID:
if(Matchers.isCorrectUUID(identifier))
identifier = Matchers.uuidRemoveDashes(identifier);
if(Matchers.isCorrectDashlessUUID(identifier))
return entity.equalsIgnoreCase(identifier);
break;
case UUID:
if(Matchers.isCorrectDashlessUUID(identifier))
identifier = Matchers.uuidAddDashes(identifier);
if(Matchers.isCorrectUUID(identifier))
return entity.equalsIgnoreCase(identifier); return entity.equalsIgnoreCase(identifier);
break;
case INTERNET_WILDCARD:
case INTERNET_SUBNETMASK:
// TO DO HERE
return false;
case INAPPLICABLE:
default:
break;
}
} catch(IllegalArgumentException ex) {
} }
return false; return false;
} }

7
src/main/java/ru/simsonic/rscPermissions/Backends/DatabaseContents.java

@ -2,6 +2,7 @@ package ru.simsonic.rscPermissions.Backends;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import ru.simsonic.rscPermissions.API.Destination; import ru.simsonic.rscPermissions.API.Destination;
import ru.simsonic.rscPermissions.API.PlayerType;
import ru.simsonic.rscPermissions.API.RowEntity; import ru.simsonic.rscPermissions.API.RowEntity;
import ru.simsonic.rscPermissions.API.RowInheritance; import ru.simsonic.rscPermissions.API.RowInheritance;
import ru.simsonic.rscPermissions.API.RowPermission; import ru.simsonic.rscPermissions.API.RowPermission;
@ -32,7 +33,7 @@ public class DatabaseContents
for(String oneEntity : splittedByEntity) for(String oneEntity : splittedByEntity)
{ {
final RowEntity clone = row.clone(); final RowEntity clone = row.clone();
clone.entity = oneEntity; clone.entity = PlayerType.normalize(oneEntity);
le.add(clone); le.add(clone);
} }
} }
@ -50,7 +51,7 @@ public class DatabaseContents
for(String entity : splittedByEntity) for(String entity : splittedByEntity)
{ {
final RowPermission clone = row.clone(); final RowPermission clone = row.clone();
clone.entity = entity; clone.entity = PlayerType.normalize(entity);
clone.permission = permission; clone.permission = permission;
clone.destination = destination; clone.destination = destination;
lp.add(clone); lp.add(clone);
@ -71,7 +72,7 @@ public class DatabaseContents
for(String entity : splittedByEntity) for(String entity : splittedByEntity)
{ {
final RowInheritance clone = row.clone(); final RowInheritance clone = row.clone();
clone.entity = entity; clone.entity = PlayerType.normalize(entity);
clone.parent = parent; clone.parent = parent;
clone.deriveInstance(); clone.deriveInstance();
clone.destination = destination; clone.destination = destination;

8
src/main/java/ru/simsonic/rscPermissions/IndependentMain.java

@ -21,9 +21,9 @@ public class IndependentMain
System.out.println("https://github.com/SimSonic/rscPermissions/"); System.out.println("https://github.com/SimSonic/rscPermissions/");
// TESTING HERE // TESTING HERE
remoteDb.initialize(null, remoteDb.initialize(null,
"", // DATABASE "s0.voxile.ru:3306/servers-shared", // DATABASE
"", // USERNAME "server-primary", // USERNAME
"", // PASSWORD "zcHzCBFZtTv28JfG", // PASSWORD
"rscp_"); "rscp_");
if(remoteDb.connect()) if(remoteDb.connect())
{ {
@ -44,7 +44,7 @@ public class IndependentMain
} }
intCache.setDefaultGroup("Default", true); intCache.setDefaultGroup("Default", true);
intCache.fill(contents); intCache.fill(contents);
final ResolutionResult result = intCache.resolvePlayer("Reality_SC"); final ResolutionResult result = intCache.resolvePlayer("87f946d8212440539d685eab07f8e266");
// Sorted output // Sorted output
ArrayList<String> perms = new ArrayList<>(result.permissions.keySet()); ArrayList<String> perms = new ArrayList<>(result.permissions.keySet());
Collections.sort(perms); Collections.sort(perms);

4
src/main/resources/languages/english.yml

@ -13,7 +13,7 @@ integration:
residence-yes: "{_LG}Residence was found and integrated." residence-yes: "{_LG}Residence was found and integrated."
residence-no: "{_YL}Residence was not found." residence-no: "{_YL}Residence was not found."
debug: debug:
enable: "{_LS}You will see a lot of debugging information now." enable: "You will see a lot of debugging information now."
disable: "{_LS}Debugging information is now hidden for you." disable: "Debugging information is now hidden for you."
mysql: mysql:
fetched: "Tables have been fetched." fetched: "Tables have been fetched."

8
src/main/resources/languages/russian.yml

@ -3,8 +3,8 @@ generic:
disabled: "[rscp] Плагин rscPermissions выключен." disabled: "[rscp] Плагин rscPermissions выключен."
reloaded: "[rscp] Плагин rscPermissions перезапущен, конфигурация перечитана." reloaded: "[rscp] Плагин rscPermissions перезапущен, конфигурация перечитана."
metrics: "[rscp] Включён сбор метрики (mcstats.org)." metrics: "[rscp] Включён сбор метрики (mcstats.org)."
player-only: "[rscp] Эта команда не может быть использована из консоли." player-only: "{_LR}Эта команда не может быть использована из консоли."
console-only: "[rscp] Эта команда может быть использована только из консоли." console-only: "{_LR}Эта команда может быть использована только из консоли."
integration: integration:
vault-yes: "{_LG}Vault обнаружён и подключён." vault-yes: "{_LG}Vault обнаружён и подключён."
vault-no: "{_LR}Не удаётся найти плагин Vault. Рекомендуется его скорейшая установка." vault-no: "{_LR}Не удаётся найти плагин Vault. Рекомендуется его скорейшая установка."
@ -13,7 +13,7 @@ integration:
residence-yes: "{_LG}Residence обнаружён и подключён." residence-yes: "{_LG}Residence обнаружён и подключён."
residence-no: "{_YL}Residence не обнаружен." residence-no: "{_YL}Residence не обнаружен."
debug: debug:
enable: "{_LS}Теперь Вы будете видеть отладочную информацию." enable: "Теперь Вы будете видеть отладочную информацию."
disable: "{_LS}Отладочная информация теперь скрыта от Вас." disable: "Отладочная информация теперь скрыта от Вас."
mysql: mysql:
fetched: "База данных перечитана." fetched: "База данных перечитана."

Loading…
Cancel
Save