Skip to content

Commit fc44758

Browse files
committed
Begin on ladder support
1 parent 79e8a58 commit fc44758

File tree

15 files changed

+159
-30
lines changed

15 files changed

+159
-30
lines changed

API/src/main/java/me/innectic/permissify/api/database/DatabaseHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
package me.innectic.permissify.api.database;
2626

2727
import lombok.Getter;
28-
import lombok.Setter;
29-
import me.innectic.permissify.api.permission.Permission;
30-
import me.innectic.permissify.api.permission.PermissionGroup;
28+
import me.innectic.permissify.api.group.Permission;
29+
import me.innectic.permissify.api.group.group.PermissionGroup;
3130
import me.innectic.permissify.api.profile.PermissifyProfile;
3231

3332
import java.util.*;

API/src/main/java/me/innectic/permissify/api/database/handlers/SQLHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import me.innectic.permissify.api.PermissifyAPI;
2828
import me.innectic.permissify.api.database.ConnectionError;
2929
import me.innectic.permissify.api.database.DatabaseHandler;
30-
import me.innectic.permissify.api.permission.Permission;
30+
import me.innectic.permissify.api.group.Permission;
3131
import me.innectic.permissify.api.database.ConnectionInformation;
32-
import me.innectic.permissify.api.permission.PermissionGroup;
32+
import me.innectic.permissify.api.group.group.PermissionGroup;
3333
import me.innectic.permissify.api.profile.PermissifyProfile;
3434
import me.innectic.permissify.api.util.FormatterType;
3535

API/src/main/java/me/innectic/permissify/api/permission/Permission.java renamed to API/src/main/java/me/innectic/permissify/api/group/Permission.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
* SOFTWARE.
2424
*/
25-
package me.innectic.permissify.api.permission;
25+
package me.innectic.permissify.api.group;
2626

2727
import lombok.AllArgsConstructor;
2828
import lombok.Getter;

API/src/main/java/me/innectic/permissify/api/permission/PermissionGroup.java renamed to API/src/main/java/me/innectic/permissify/api/group/group/PermissionGroup.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
* SOFTWARE.
2424
*/
25-
package me.innectic.permissify.api.permission;
25+
package me.innectic.permissify.api.group.group;
2626

2727
import lombok.Getter;
2828
import lombok.RequiredArgsConstructor;
29-
import lombok.Setter;
29+
import me.innectic.permissify.api.group.Permission;
30+
import me.innectic.permissify.api.group.ladder.AbstractLadder;
3031

3132
import java.io.Serializable;
3233
import java.util.*;
@@ -43,6 +44,7 @@ public class PermissionGroup implements Serializable {
4344
@Getter private final String suffix;
4445
@Getter private List<Permission> permissions = new ArrayList<>();
4546
@Getter private Map<UUID, Boolean> players = new HashMap<>();
47+
@Getter private AbstractLadder ladder; // TODO: Ask the database for the ladder
4648

4749
/**
4850
* Remove a permission from the group
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
*
3+
* This file is part of Permissify, licensed under the MIT License (MIT).
4+
* Copyright (c) Innectic
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
package me.innectic.permissify.api.group.ladder;
26+
27+
import lombok.Getter;
28+
29+
import java.io.Serializable;
30+
import java.util.*;
31+
32+
/**
33+
* @author Innectic
34+
* @since 9/1/2017
35+
*/
36+
public abstract class AbstractLadder implements Serializable {
37+
@Getter protected Map<UUID, LadderLevel> players = new HashMap<>();
38+
@Getter protected List<LadderLevel> levels = new ArrayList<>();
39+
40+
public final void reset() {
41+
drop();
42+
registerLadders();
43+
}
44+
45+
public final void drop() {
46+
players = new HashMap<>();
47+
levels = new ArrayList<>();
48+
}
49+
50+
public abstract void registerLadders();
51+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
*
3+
* This file is part of Permissify, licensed under the MIT License (MIT).
4+
* Copyright (c) Innectic
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
package me.innectic.permissify.api.group.ladder;
26+
27+
import lombok.AllArgsConstructor;
28+
import lombok.Getter;
29+
30+
import java.io.Serializable;
31+
import java.util.Optional;
32+
33+
/**
34+
* @author Innectic
35+
* @since 9/1/2017
36+
*/
37+
@AllArgsConstructor
38+
public class LadderLevel implements Serializable {
39+
@Getter private int power;
40+
@Getter private Optional<String> displayName;
41+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
*
3+
* This file is part of Permissify, licensed under the MIT License (MIT).
4+
* Copyright (c) Innectic
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
*/
25+
package me.innectic.permissify.api.group.ladder.impl;
26+
27+
import me.innectic.permissify.api.group.ladder.AbstractLadder;
28+
import me.innectic.permissify.api.group.ladder.LadderLevel;
29+
30+
import java.util.Optional;
31+
32+
/**
33+
* @author Innectic
34+
* @since 9/1/2017
35+
*
36+
* Default ladder that will be used within groups if none is specified.
37+
*/
38+
public class DefaultLadder extends AbstractLadder {
39+
40+
@Override
41+
public void registerLadders() {
42+
// Default ladders will only have 2 levels: default, admin. I don't care about display differences.
43+
// TODO: Should I actually care about having names for the default ladders?
44+
45+
this.levels.add(new LadderLevel(0, Optional.empty()));
46+
this.levels.add(new LadderLevel(1, Optional.empty()));
47+
}
48+
}

API/src/main/java/me/innectic/permissify/api/profile/PermissifyProfile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
import lombok.AllArgsConstructor;
2828
import lombok.Getter;
29-
import me.innectic.permissify.api.permission.Permission;
30-
import me.innectic.permissify.api.permission.PermissionGroup;
29+
import me.innectic.permissify.api.group.Permission;
30+
import me.innectic.permissify.api.group.group.PermissionGroup;
3131

3232
import java.io.Serializable;
3333
import java.util.List;

API/src/main/java/me/innectic/permissify/api/util/ChatFormatter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626

2727
import me.innectic.permissify.api.PermissifyAPI;
2828
import me.innectic.permissify.api.database.DatabaseHandler;
29-
import me.innectic.permissify.api.permission.PermissionGroup;
29+
import me.innectic.permissify.api.group.group.PermissionGroup;
3030

31-
import java.util.List;
3231
import java.util.Optional;
3332
import java.util.UUID;
3433

Spigot/src/main/java/me/innectic/permissify/spigot/commands/permissify/CacheCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import me.innectic.permissify.api.PermissifyConstants;
2828
import me.innectic.permissify.api.database.DatabaseHandler;
29-
import me.innectic.permissify.api.permission.PermissionGroup;
29+
import me.innectic.permissify.api.group.group.PermissionGroup;
3030
import me.innectic.permissify.api.util.ArgumentUtil;
3131
import me.innectic.permissify.spigot.PermissifyMain;
3232
import me.innectic.permissify.spigot.commands.CommandResponse;

0 commit comments

Comments
 (0)