-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1aac66e
commit adacd36
Showing
21 changed files
with
509 additions
and
11 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ softdepend: | |
- GUIShop | ||
- DiscordSRV | ||
- Multiverse-Core | ||
- LuckPerms | ||
|
||
permissions: | ||
tne.*: | ||
|
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
46 changes: 46 additions & 0 deletions
46
Bukkit/src/net/tnemc/bukkit/hook/misc/LuckBalanceContext.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,46 @@ | ||
package net.tnemc.bukkit.hook.misc; | ||
/* | ||
* The New Economy | ||
* Copyright (C) 2022 - 2023 Daniel "creatorfromhell" Vidmar | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import net.luckperms.api.context.ContextCalculator; | ||
import net.luckperms.api.context.ContextConsumer; | ||
import net.luckperms.api.context.ContextSet; | ||
import net.tnemc.core.hook.luckperms.BalanceContext; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* LuckBalanceContext | ||
* | ||
* @author creatorfromhell | ||
* @since 0.1.2.0 | ||
*/ | ||
public class LuckBalanceContext implements ContextCalculator<Player> { | ||
|
||
final BalanceContext context = new BalanceContext(); | ||
|
||
@Override | ||
public void calculate(@NotNull Player player, @NotNull ContextConsumer contextConsumer) { | ||
context.calculate(player.getUniqueId(), contextConsumer); | ||
} | ||
|
||
@Override | ||
public ContextSet estimatePotentialContexts() { | ||
return context.estimate(); | ||
} | ||
} |
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,37 @@ | ||
package net.tnemc.bukkit.hook.misc; | ||
/* | ||
* The New Economy | ||
* Copyright (C) 2022 - 2023 Daniel "creatorfromhell" Vidmar | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import net.luckperms.api.LuckPerms; | ||
import net.tnemc.bukkit.TNE; | ||
|
||
/** | ||
* LuckPermsHook | ||
* | ||
* @author creatorfromhell | ||
* @since 0.1.2.0 | ||
*/ | ||
public class LuckPermsHook { | ||
|
||
public static void register() { | ||
final LuckPerms luckAPI = TNE.instance().getServer().getServicesManager().load(LuckPerms.class); | ||
if(luckAPI != null) { | ||
luckAPI.getContextManager().registerCalculator(new LuckBalanceContext()); | ||
} | ||
} | ||
} |
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
69 changes: 69 additions & 0 deletions
69
Core/src/net/tnemc/core/hook/luckperms/BalanceContext.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,69 @@ | ||
package net.tnemc.core.hook.luckperms; | ||
/* | ||
* The New Economy | ||
* Copyright (C) 2022 - 2023 Daniel "creatorfromhell" Vidmar | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import net.luckperms.api.context.ContextConsumer; | ||
import net.luckperms.api.context.ContextSet; | ||
import net.luckperms.api.context.ImmutableContextSet; | ||
import net.tnemc.core.TNECore; | ||
import net.tnemc.core.account.Account; | ||
import net.tnemc.core.currency.Currency; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
/** | ||
* BalanceContext | ||
* | ||
* @author creatorfromhell | ||
* @since 0.1.2.0 | ||
*/ | ||
public class BalanceContext { | ||
|
||
final String KEY = "tne:balance-"; | ||
|
||
public void calculate(@NonNull UUID uuid, @NonNull ContextConsumer contextConsumer) { | ||
final Optional<Account> account = TNECore.eco().account().findAccount(uuid); | ||
|
||
if(account.isPresent()) { | ||
|
||
final String region = TNECore.eco().region().getMode().region(uuid); | ||
for(Currency currency : TNECore.eco().currency().currencies()) { | ||
contextConsumer.accept(KEY + currency.getIdentifier(), account.get().getHoldingsTotal(region, currency.getUid()).toPlainString()); | ||
} | ||
} else { | ||
|
||
for(Currency currency : TNECore.eco().currency().currencies()) { | ||
contextConsumer.accept(KEY + currency.getIdentifier(), currency.getStartingHoldings().toPlainString()); | ||
} | ||
} | ||
} | ||
|
||
public ContextSet estimate() { | ||
final ImmutableContextSet.Builder builder = ImmutableContextSet.builder(); | ||
|
||
for(Currency currency : TNECore.eco().currency().currencies()) { | ||
builder.add(KEY + currency.getIdentifier(), "0"); | ||
builder.add(KEY + currency.getIdentifier(), "100"); | ||
builder.add(KEY + currency.getIdentifier(), "500"); | ||
builder.add(KEY + currency.getIdentifier(), "1000"); | ||
} | ||
return builder.build(); | ||
} | ||
} |
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
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
46 changes: 46 additions & 0 deletions
46
PaperCore/src/net/tnemc/paper/hook/misc/LuckBalanceContext.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,46 @@ | ||
package net.tnemc.paper.hook.misc; | ||
/* | ||
* The New Economy | ||
* Copyright (C) 2022 - 2023 Daniel "creatorfromhell" Vidmar | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import net.luckperms.api.context.ContextCalculator; | ||
import net.luckperms.api.context.ContextConsumer; | ||
import net.luckperms.api.context.ContextSet; | ||
import net.tnemc.core.hook.luckperms.BalanceContext; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* LuckBalanceContext | ||
* | ||
* @author creatorfromhell | ||
* @since 0.1.2.0 | ||
*/ | ||
public class LuckBalanceContext implements ContextCalculator<Player> { | ||
|
||
final BalanceContext context = new BalanceContext(); | ||
|
||
@Override | ||
public void calculate(@NotNull Player player, @NotNull ContextConsumer contextConsumer) { | ||
context.calculate(player.getUniqueId(), contextConsumer); | ||
} | ||
|
||
@Override | ||
public ContextSet estimatePotentialContexts() { | ||
return context.estimate(); | ||
} | ||
} |
Oops, something went wrong.