Solved Permissions Plugin

Discussion in 'Plugin Development' started by PhilDEV_Acc, Apr 20, 2020.

Thread Status:
Not open for further replies.
  1. So im creating a permissions plugin with MySQl. Im getting a connection that is not the problem.
    Code:Java
    1.  
    2. public class PermissionMain extends JavaPlugin {
    3.  
    4. public ArrayList<UUID> data = new ArrayList<>();
    5. public ArrayList<String> owner = new ArrayList<>();
    6.  
    7. @Override
    8. public void onEnable() {
    9.  
    10. PluginManager pm = this.getServer().getPluginManager();
    11.  
    12. pm.registerEvents(new JoinListener(this), this);
    13.  
    14. MySql sql = new MySql("localhost", "phil", "******", "Server", 3306);
    15. ResultSet rs = sql.query("SELECT * FROM `Gruppen` WHERE `GroupName`='Owner'");
    16. ResultSet rs2 = sql.query("SELECT * FROM `Register` WHERE `register`='true'");
    17. ResultSet rs3 = sql.query("SELECT * FROM `User` WHERE `Gruppe`='Owner'");
    18.  
    19. try {
    20. System.out.println("1");
    21.  
    22. while (rs3.next()) {
    23. System.out.println("2");
    24. String user = rs3.getString("User");
    25. owner.add(user);
    26. }
    27. while (rs2.next()) {
    28. System.out.println("3");
    29. String uuid = rs2.getString("uuid");
    30. data.add(UUID.fromString(uuid));
    31. }
    32. while (rs.next()) {
    33. System.out.println("4");
    34. String permission = rs.getString("Permission");
    35. for (String player : owner) {
    36. System.out.println("5");
    37. System.out.println(permission);
    38. Player user = getServer().getPlayer(player);
    39. user.isPermissionSet(permission);
    40. }
    41.  
    42. }
    43. } catch (SQLException e) {
    44. e.printStackTrace();
    45. }
    46. }
    47.  
    48. public void onDisable() {
    49.  
    50. }
    51.  

    Thats my code but it doesnt work. Does somebody know the problem?

    Made some Changes here is my log @timtower

    Code:
    [PermissionPlugin] Enabling PermissionPlugin v1.0
    [13:40:52] [Server thread/WARN]: Mon Apr 20 13:40:52 CEST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    [13:40:52] [Server thread/INFO]: 1
    [13:40:52] [Server thread/INFO]: 2
    [13:40:52] [Server thread/INFO]: 3
    [13:40:52] [Server thread/INFO]: 4
    [13:40:52] [Server thread/INFO]: 5
    [13:40:52] [Server thread/INFO]: bukkit.*
    [13:40:52] [Server thread/INFO]: 4
    [13:40:52] [Server thread/INFO]: 5
    [13:40:52] [Server thread/INFO]: minecraft.*
    [13:40:52] [Server thread/INFO]: 4
    [13:40:52] [Server thread/INFO]: 5
    [13:40:52] [Server thread/INFO]: bukkit.command.reload
    [13:40:52] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [13:40:52] [Server thread/INFO]: CONSOLE: Reload complete.
    
    Thanks regards Philipp
     
    Last edited: Apr 20, 2020
  2. Online

    timtower Administrator Administrator Moderator

    @PhilDEV_Acc Define "doesn't work"
    Does not work in what way? Do you get errors?
     
  3. Offline

    yPedx

    @PhilDEV_Acc
    Are there any errors in the logs? (timtower is a ninja)
    Since I don't know much of MySQL, all I can say is that you try printing some values.
     
  4. So when I join the Server I don't have the permission. I dont get any errors. @timtower
     
  5. Online

    timtower Administrator Administrator Moderator

  6. So I used the link and wrote a new code:
    Code:Java
    1.  
    2. Player user = getServer().getPlayer(player);
    3. PermissionAttachment attachment = user.addAttachment(); //there schould be a plugin class but I dont have a clue how to get it
    4. attachment.setPermission(permission, true);
    5.  
     
  7. Online

    timtower Administrator Administrator Moderator

  8. I cant use "this" because it gives a nullpointerexception.
     
  9. Online

    timtower Administrator Administrator Moderator

    Code with marked error line please.
     
  10. OK it worked after all;). Thanks A LOT.
     
    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page