Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
NC5.0 (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
Librazy authored Jul 3, 2018
1 parent 8e79a66 commit 566fe2b
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Gaming utilities/helpers for NyaaCat Minecraft Server

Detailed function manual please refer to [Wiki](https://github.com/NyaaCat/nyaautils/wiki).

Using NyaaCore API version 4.1
Using NyaaCore API version 5.0

[![Build Status](https://travis-ci.org/NyaaCat/NyaaUtils.svg?branch=master)](https://travis-ci.org/NyaaCat/NyaaUtils)

8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ plugins {
id 'maven-publish'
}

configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

// Version strings used for CI
// Note the spaces before and after the equals sign
ext.majorVersion = 4
ext.majorVersion = 5
ext.minorVersion = 0
ext.minecraftVersion = "1.12"

Expand Down Expand Up @@ -57,7 +61,7 @@ repositories {

dependencies {
compile 'org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT'
compile('cat.nyaa:nyaacore:4.1-SNAPSHOT') {
compile('cat.nyaa:nyaacore:5.0-SNAPSHOT') {
transitive = false
}
compile files('lib/LocketteProAPI.jar')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package cat.nyaa.nyaautils.dropprotect;

import cat.nyaa.nyaacore.database.Database;
import cat.nyaa.nyaacore.database.DatabaseUtils;
import cat.nyaa.nyaacore.database.KeyValueDB;
import cat.nyaa.nyaautils.NyaaUtils;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
Expand All @@ -22,7 +25,7 @@

public class DropProtectListener implements Listener {
final private NyaaUtils plugin;
final private Set<UUID> bypassPlayer = new HashSet<>();
final private KeyValueDB<UUID,UUID> bypassPlayer = DatabaseUtils.get("database.dpbypass").connect();
final private Cache<Integer, UUID> items;

public DropProtectListener(NyaaUtils pl) {
Expand All @@ -40,11 +43,11 @@ public DropProtectListener(NyaaUtils pl) {
* false: drop protect is disabled
*/
public boolean toggleStatus(UUID uuid) {
if (bypassPlayer.contains(uuid)) {
if (bypassPlayer.containsKey(uuid)) {
bypassPlayer.remove(uuid);
return true;
} else {
bypassPlayer.add(uuid);
bypassPlayer.put(uuid, uuid);
return false;
}
}
Expand All @@ -53,7 +56,7 @@ public boolean toggleStatus(UUID uuid) {
public void onPlayerDeath(PlayerDeathEvent e) {
if (plugin.cfg.dropProtectMode == DropProtectMode.OFF) return;
UUID id = e.getEntity().getUniqueId();
if (bypassPlayer.contains(id)) return;
if (bypassPlayer.containsKey(id)) return;
List<ItemStack> dropStacks = e.getDrops();
Location loc = e.getEntity().getLocation();
Bukkit.getScheduler().runTaskLater(plugin, () -> {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cat/nyaa/nyaautils/elytra/ElytraCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ public void commandGiveFuel(CommandSender sender, Arguments args) {
@DefaultCommand(permission = "nu.elytratoggle")
public void commandElytraToggle(CommandSender sender, Arguments args) {
Player player = asPlayer(sender);
if (ElytraEnhanceListener.disableFuelMode.contains(player.getUniqueId())) {
if (ElytraEnhanceListener.disableFuelMode.containsKey(player.getUniqueId())) {
ElytraEnhanceListener.disableFuelMode.remove(player.getUniqueId());
msg(sender, "user.elytra_enhance.fuelmode_on");
} else {
ElytraEnhanceListener.disableFuelMode.add(player.getUniqueId());
ElytraEnhanceListener.disableFuelMode.put(player.getUniqueId(), player.getUniqueId());
msg(sender, "user.elytra_enhance.fuelmode_off");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cat.nyaa.nyaautils.elytra;


import cat.nyaa.nyaacore.database.DatabaseUtils;
import cat.nyaa.nyaacore.database.KeyValueDB;
import cat.nyaa.nyaautils.I18n;
import cat.nyaa.nyaautils.NyaaUtils;
import org.bukkit.Material;
Expand All @@ -19,7 +20,7 @@

public class ElytraEnhanceListener implements Listener {
public static List<UUID> FuelMode = new ArrayList<>();
public static List<UUID> disableFuelMode = new ArrayList<>();
public static KeyValueDB<UUID, UUID> disableFuelMode = DatabaseUtils.get("database.fueldisabled").connect();
public static HashMap<UUID, Long> duration = new HashMap<UUID, Long>();
public NyaaUtils plugin;

Expand All @@ -36,7 +37,7 @@ public void playerMove(PlayerMoveEvent e) {
!plugin.cfg.disabled_world.contains(player.getWorld().getName()) &&
player.getLocation().getBlock().getType() == Material.AIR &&
player.getEyeLocation().getBlock().getType() == Material.AIR &&
!disableFuelMode.contains(player.getUniqueId()) &&
!disableFuelMode.containsKey(player.getUniqueId()) &&
!player.isSneaking()) {
if (!FuelMode.contains(player.getUniqueId()) &&
player.getVelocity().length() >= 0.75 &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cat.nyaa.nyaautils.lootprotect;

import cat.nyaa.nyaacore.database.DatabaseUtils;
import cat.nyaa.nyaacore.database.KeyValueDB;
import cat.nyaa.nyaautils.NyaaUtils;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
Expand All @@ -15,8 +17,8 @@

public class LootProtectListener implements Listener {
final private NyaaUtils plugin;
final private Set<UUID> bypassPlayer = new HashSet<>();
final private Map<UUID, VanillaStrategy> bypassVanillaPlayer = new HashMap<>();
final private KeyValueDB<UUID, UUID> bypassPlayer = DatabaseUtils.get("database.lpbypass").connect();
final private KeyValueDB<UUID, VanillaStrategy> bypassVanillaPlayer = DatabaseUtils.get("database.lpstrategy").connect();

public enum VanillaStrategy {
IGNORE,
Expand All @@ -34,11 +36,11 @@ public LootProtectListener(NyaaUtils pl) {
* false: loot protect is disabled
*/
public boolean toggleStatus(UUID uuid) {
if (bypassPlayer.contains(uuid)) {
if (bypassPlayer.containsKey(uuid)) {
bypassPlayer.remove(uuid);
return true;
} else {
bypassPlayer.add(uuid);
bypassPlayer.put(uuid, uuid);
return false;
}
}
Expand Down Expand Up @@ -66,7 +68,7 @@ public void onMobKilled(EntityDeathEvent ev) {
p = ev.getEntity().getKiller();
}
if (p == null) return;
if (bypassPlayer.contains(p.getUniqueId())) return;
if (bypassPlayer.containsKey(p.getUniqueId())) return;
if (bypassVanillaPlayer.get(p.getUniqueId()) != null) {
List<ItemStack> customItems = ev.getDrops().stream().filter(item -> item.hasItemMeta() && item.getItemMeta().hasLore()).collect(Collectors.toList());
ev.getDrops().removeAll(customItems);
Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
database:
lpstrategy:
provider: map
connection:
key: java.util.UUID
value: cat.nyaa.nyaautils.lootprotect.LootProtectListener$VanillaStrategy
lpbypass:
provider: map
connection:
key: java.util.UUID
value: java.util.UUID
fueldisabled:
provider: map
connection:
key: java.util.UUID
value: java.util.UUID
dpbypass:
provider: map
connection:
key: java.util.UUID
value: java.util.UUID
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: NyaaUtils
main: cat.nyaa.nyaautils.NyaaUtils
description: "Helper/utilities plugin for Nyaacat Minecraft Server"
version: 4.0-dev
version: 5.0-dev
depend: [WorldEdit,Essentials,NyaaCore,LangUtils]
softdepend: [LockettePro,HamsterEcoHelper]
authors: [RecursiveG,Cylin,Librazy]
Expand Down

0 comments on commit 566fe2b

Please sign in to comment.