Skip to content
This repository was archived by the owner on Nov 14, 2021. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Build with Maven
run: mvn -V clean package --file pom.xml
2 changes: 1 addition & 1 deletion HEADER.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This file is part of server4je, licensed under the MIT License (MIT).
This file is part of reformcloud2, licensed under the MIT License (MIT).

Copyright (c) ReformCloud <https://github.com/ReformCloud>
Copyright (c) contributors
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pipeline {
agent any

tools {
jdk "1.8.0_222"
jdk "11.0.8"
}

options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>

<!-- bungee repo -->
<!-- used for bungeecord and gomint -->
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>

<!-- velocity repo -->
Expand Down Expand Up @@ -95,6 +95,14 @@
<scope>provided</scope>
</dependency>

<!-- gomint api -->
<dependency>
<groupId>io.gomint</groupId>
<artifactId>gomint-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<!-- velocity api -->
<dependency>
<groupId>com.velocitypowered</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This file is part of reformcloud2, licensed under the MIT License (MIT).
*
* Copyright (c) ReformCloud <https://github.com/ReformCloud>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package systems.reformcloud.reformcloud2.permissions.gomint;

import io.gomint.GoMint;
import io.gomint.plugin.Plugin;
import io.gomint.plugin.PluginName;
import io.gomint.plugin.Version;
import systems.reformcloud.reformcloud2.permissions.gomint.listeners.GoMintPermissionListener;
import systems.reformcloud.reformcloud2.permissions.util.PermissionPluginUtil;

@Version(major = 2, minor = 0)
@PluginName("ReformCloud2GoMintPermissions")
public class GoMintPermissionPlugin extends Plugin {

@Override
public void onInstall() {
PermissionPluginUtil.awaitConnection(() -> GoMint.instance().getPluginManager().registerListener(this, new GoMintPermissionListener()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* This file is part of reformcloud2, licensed under the MIT License (MIT).
*
* Copyright (c) ReformCloud <https://github.com/ReformCloud>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package systems.reformcloud.reformcloud2.permissions.gomint.listeners;

import io.gomint.event.EventHandler;
import io.gomint.event.EventListener;
import io.gomint.event.player.PlayerLoginEvent;
import io.gomint.event.player.PlayerQuitEvent;
import systems.reformcloud.reformcloud2.permissions.PermissionManagement;
import systems.reformcloud.reformcloud2.permissions.gomint.manager.DefaultPermissionManager;

public class GoMintPermissionListener implements EventListener {

@EventHandler
public void handle(PlayerLoginEvent event) {
event.getPlayer().setPermissionManager(new DefaultPermissionManager(event.getPlayer().getUUID()));
}

@EventHandler
public void handle(PlayerQuitEvent event) {
PermissionManagement.getInstance().handleDisconnect(event.getPlayer().getUUID());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* This file is part of reformcloud2, licensed under the MIT License (MIT).
*
* Copyright (c) ReformCloud <https://github.com/ReformCloud>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package systems.reformcloud.reformcloud2.permissions.gomint.manager;

import io.gomint.permission.Group;
import io.gomint.permission.PermissionManager;
import systems.reformcloud.reformcloud2.permissions.PermissionManagement;
import systems.reformcloud.reformcloud2.permissions.nodes.NodeGroup;
import systems.reformcloud.reformcloud2.permissions.nodes.PermissionNode;
import systems.reformcloud.reformcloud2.permissions.objects.user.PermissionUser;

import java.util.UUID;

public class DefaultPermissionManager implements PermissionManager {

private final UUID uniqueId;

public DefaultPermissionManager(UUID uniqueId) {
this.uniqueId = uniqueId;
}

@Override
public boolean hasPermission(String s) {
return PermissionManagement.getInstance().loadUser(this.uniqueId).hasPermission(s);
}

@Override
public boolean hasPermission(String s, boolean b) {
return this.hasPermission(s); // TODO: should we change the api here?
}

@Override
public void addGroup(Group group) {
PermissionUser permissionUser = PermissionManagement.getInstance().loadUser(this.uniqueId);
if (permissionUser.isInGroup(group.getName())) {
return;
}

permissionUser.getGroups().add(new NodeGroup(System.currentTimeMillis(), -1, group.getName()));
PermissionManagement.getInstance().updateUser(permissionUser);
}

@Override
public void removeGroup(Group group) {
PermissionUser permissionUser = PermissionManagement.getInstance().loadUser(this.uniqueId);
if (!permissionUser.isInGroup(group.getName())) {
return;
}

if (permissionUser.getGroups().removeIf(nodeGroup -> nodeGroup.getGroupName().equals(group.getName()))) {
PermissionManagement.getInstance().updateUser(permissionUser);
}
}

@Override
public void setPermission(String s, boolean b) {
PermissionManagement.getInstance().addUserPermission(this.uniqueId, PermissionNode.createNode(s, -1, b));
}

@Override
public void removePermission(String s) {
PermissionUser permissionUser = PermissionManagement.getInstance().loadUser(this.uniqueId);
if (permissionUser.getPermissionNodes().removeIf(node -> node.getActualPermission().equals(s))) {
PermissionManagement.getInstance().updateUser(permissionUser);
}
}

@Override
public void toggleOp() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>

<!-- gomint -->
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -75,6 +81,13 @@
<version>7.3.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<!-- gomint api -->
<dependency>
<groupId>io.gomint</groupId>
<artifactId>gomint-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This file is part of reformcloud2, licensed under the MIT License (MIT).
*
* Copyright (c) ReformCloud <https://github.com/ReformCloud>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package systems.reformcloud.reformcloud2.signs.gomint;

import io.gomint.plugin.Depends;
import io.gomint.plugin.Plugin;
import io.gomint.plugin.PluginName;
import io.gomint.plugin.Version;
import systems.reformcloud.reformcloud2.signs.gomint.adapter.GoMintSignSystemAdapter;
import systems.reformcloud.reformcloud2.signs.util.ConfigRequesterUtil;

@Version(major = 2, minor = 0)
@Depends("ReformCloud2GoMintExecutor")
@PluginName("ReformCloud2GoMintSigns")
public class GoMintPlugin extends Plugin {

@Override
public void onInstall() {
ConfigRequesterUtil.requestSignConfigAsync(config -> new GoMintSignSystemAdapter(config, this));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* This file is part of reformcloud2, licensed under the MIT License (MIT).
*
* Copyright (c) ReformCloud <https://github.com/ReformCloud>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package systems.reformcloud.reformcloud2.signs.gomint.adapter;

import io.gomint.GoMint;
import io.gomint.math.BlockPosition;
import io.gomint.world.World;
import io.gomint.world.block.Block;
import io.gomint.world.block.BlockSign;
import org.apache.commons.math3.util.FastMath;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import systems.refomcloud.reformcloud2.embedded.Embedded;
import systems.reformcloud.reformcloud2.signs.util.converter.SignConverter;
import systems.reformcloud.reformcloud2.signs.util.sign.CloudLocation;
import systems.reformcloud.reformcloud2.signs.util.sign.CloudSign;

public class GoMintSignConverter implements SignConverter<BlockSign> {

protected static final SignConverter<BlockSign> INSTANCE = new GoMintSignConverter();

private GoMintSignConverter() {
}

@Nullable
@Override
public BlockSign from(@NotNull CloudSign cloudSign) {
World world = GoMint.instance().getWorld(cloudSign.getLocation().getWorld());
if (world == null) {
return null;
}

Block block = world.getBlockAt(toInt(cloudSign.getLocation().getX()), toInt(cloudSign.getLocation().getY()), toInt(cloudSign.getLocation().getZ()));
return block instanceof BlockSign ? (BlockSign) block : null;
}

@Override
public @NotNull CloudSign to(@NotNull BlockSign blockSign, @NotNull String group) {
return new CloudSign(group, this.to(blockSign));
}

@Override
public @NotNull CloudLocation to(@NotNull BlockSign blockSign) {
final BlockPosition position = blockSign.getPosition();
return new CloudLocation(
blockSign.getWorld().getWorldName(),
Embedded.getInstance().getCurrentProcessInformation().getProcessGroup().getName(),
position.getX(),
position.getY(),
position.getZ(),
0,
0
);
}

private static int toInt(double d) {
return FastMath.toIntExact(FastMath.round(d));
}
}
Loading