me.ryanhamshire.GriefPrevention.GriefPrevention Java Examples

The following examples show how to use me.ryanhamshire.GriefPrevention.GriefPrevention. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GriefPreventionExtra.java    From TradePlus with GNU General Public License v3.0 7 votes vote down vote up
@Override
public void onTradeEnd() {
  GriefPrevention inst = GriefPrevention.instance;
  PlayerData data1 = inst.dataStore.getPlayerData(player1.getUniqueId());
  PlayerData data2 = inst.dataStore.getPlayerData(player2.getUniqueId());
  if (value1 > 0) {
    data1.setAccruedClaimBlocks(data1.getAccruedClaimBlocks() - (int) value1);
    data2.setAccruedClaimBlocks(
        data2.getAccruedClaimBlocks() + (int) (value1 - ((value1 / 100) * taxPercent)));
  }
  if (value2 > 0) {
    data2.setAccruedClaimBlocks(data2.getAccruedClaimBlocks() - (int) value2);
    data1.setAccruedClaimBlocks(
        data1.getAccruedClaimBlocks() + (int) (value2 - ((value2 / 100) * taxPercent)));
  }
  inst.dataStore.savePlayerData(player1.getUniqueId(), data1);
  inst.dataStore.savePlayerData(player2.getUniqueId(), data2);
}
 
Example #2
Source File: GriefPreventionHandler.java    From Parties with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Result isManager(Player claimer) {
	if (active) {
		Claim claim = GriefPrevention.instance.dataStore.getClaimAt(claimer.getLocation(), false, null);
		if (claim == null) {
			return Result.NOEXIST;
		}
		if (!claim.getOwnerName().equalsIgnoreCase(claimer.getName())) {
			if (BukkitConfigMain.ADDONS_GRIEFPREVENTION_NEEDOWNER || !claim.managers.contains(claimer.getUniqueId().toString())) {
				return Result.NOMANAGER;
			}
		}
		return Result.SUCCESS;
	}
	return Result.NOEXIST;
}
 
Example #3
Source File: GriefPreventionHandler.java    From Parties with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void addPartyPermission(Player claimer, PartyImpl party, PermissionType perm) {
	if (active) {
		Claim claim = GriefPrevention.instance.dataStore.getClaimAt(claimer.getLocation(), false, null);
		for (UUID uuid : party.getMembers()) {
			if (claimer.getUniqueId().equals(uuid))
				continue;
			if (perm.isRemove())
				claim.dropPermission(uuid.toString());
			else
				claim.setPermission(uuid.toString(), perm.convertPermission());
		}
		GriefPrevention.instance.dataStore.saveClaim(claim);
	}
}
 
Example #4
Source File: ClaimChecks.java    From WildernessTp with MIT License 5 votes vote down vote up
private boolean greifPrevnClaim(Location loc) {
    if (wild.getConfig().getBoolean("GriefPrevention")) {
        if (GriefPrevention.instance.dataStore.getClaimAt(loc, false, null) != null && checkSurroundingsClaims(loc))
            return true;
        else
            return false;

    } else
        return false;

}
 
Example #5
Source File: ClaimChecks.java    From WildernessTp with MIT License 5 votes vote down vote up
private boolean checkSurroundingsClaims(Location loc) {
    int distance = range / 2;
    Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
    Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
    for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
        for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
            if (GriefPrevention.instance.dataStore.getClaimAt(new Location(loc.getWorld(), x, loc.getWorld().getHighestBlockYAt(x, z), z), false, null) != null)
                return true;
        }
    }

    return false;
}
 
Example #6
Source File: RedProtectUtil.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public int convertFromGP() {
    int claimed = 0;
    Collection<Claim> claims = GriefPrevention.instance.dataStore.getClaims();
    for (Claim claim : claims) {
        if (Bukkit.getWorlds().contains(claim.getGreaterBoundaryCorner().getWorld())) {
            World w = claim.getGreaterBoundaryCorner().getWorld();
            String pname = claim.getOwnerName().replace(" ", "_").toLowerCase();
            if (claim.ownerID != null) {
                pname = claim.ownerID.toString();
            }
            Set<PlayerRegion> leaders = new HashSet<>();
            leaders.add(new PlayerRegion(claim.ownerID != null ? claim.ownerID.toString() : pname, pname));
            Location newmin = claim.getGreaterBoundaryCorner();
            Location newmax = claim.getLesserBoundaryCorner();
            newmin.setY(0);
            newmax.setY(w.getMaxHeight());

            Region r = new Region(nameGen(claim.getOwnerName().replace(" ", "_").toLowerCase(), w.getName()), new HashSet<>(), new HashSet<>(), leaders,
                    newmin, newmax, RedProtect.get().config.getDefFlagsValues(), "GriefPrevention region", 0, w.getName(), dateNow(), 0, null, true, true);

            Region other = RedProtect.get().rm.getTopRegion(w.getName(), r.getCenterX(), r.getCenterY(), r.getCenterZ());
            if (other == null || !r.getWelcome().equals(other.getWelcome())) {
                RedProtect.get().rm.add(r, w.getName());
                RedProtect.get().logger.debug(LogLevel.DEFAULT, "Region: " + r.getName());
                claimed++;
            }
        }
    }
    return claimed;
}
 
Example #7
Source File: HookGriefPrevention.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static GriefPrevention getAPI() {
    return JavaPlugin.getPlugin(GriefPrevention.class);
}
 
Example #8
Source File: HookGriefPrevention.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isSafeZone(Location location) {
    GriefPrevention api = getAPI();
    Claim claim = api.dataStore.getClaimAt(location, false, null);

    return (claim != null);
}
 
Example #9
Source File: GriefPreventionExtra.java    From TradePlus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public double getMax(Player player) {
  PlayerData data = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId());
  return data.getRemainingClaimBlocks();
}
 
Example #10
Source File: ShopChest.java    From ShopChest with MIT License 4 votes vote down vote up
private void loadExternalPlugins() {
    Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
    if (townyPlugin instanceof Towny) {
        towny = (Towny) townyPlugin;
    }

    Plugin authMePlugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe");
    if (authMePlugin instanceof AuthMe) {
        authMe = (AuthMe) authMePlugin;
    }

    Plugin uSkyBlockPlugin = Bukkit.getServer().getPluginManager().getPlugin("uSkyBlock");
    if (uSkyBlockPlugin instanceof uSkyBlockAPI) {
        uSkyBlock = (uSkyBlockAPI) uSkyBlockPlugin;
    }

    Plugin aSkyBlockPlugin = Bukkit.getServer().getPluginManager().getPlugin("ASkyBlock");
    if (aSkyBlockPlugin instanceof ASkyBlock) {
        aSkyBlock = (ASkyBlock) aSkyBlockPlugin;
    }

    Plugin islandWorldPlugin = Bukkit.getServer().getPluginManager().getPlugin("IslandWorld");
    if (islandWorldPlugin instanceof IslandWorld) {
        islandWorld = (IslandWorld) islandWorldPlugin;
    }

    Plugin griefPreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
    if (griefPreventionPlugin instanceof GriefPrevention) {
        griefPrevention = (GriefPrevention) griefPreventionPlugin;
    }

    Plugin areaShopPlugin = Bukkit.getServer().getPluginManager().getPlugin("AreaShop");
    if (areaShopPlugin instanceof AreaShop) {
        areaShop = (AreaShop) areaShopPlugin;
    }

    Plugin bentoBoxPlugin = getServer().getPluginManager().getPlugin("BentoBox");
    if (bentoBoxPlugin instanceof BentoBox) {
        bentoBox = (BentoBox) bentoBoxPlugin;
    }

    if (hasWorldGuard()) {
        WorldGuardWrapper.getInstance().registerEvents(this);
    }

    if (hasPlotSquared()) {
        try {
            Class.forName("com.plotsquared.core.PlotSquared");
            PlotSquaredShopFlag.register(this);
        } catch (ClassNotFoundException ex) {
            PlotSquaredOldShopFlag.register(this);
        }
    }

    if (hasBentoBox()) {
        BentoBoxShopFlag.register(this);
    }
}
 
Example #11
Source File: ShopChest.java    From ShopChest with MIT License 4 votes vote down vote up
/**
 * @return An instance of {@link GriefPrevention} or {@code null} if GriefPrevention is not enabled
 */
public GriefPrevention getGriefPrevention() {
    return griefPrevention;
}
 
Example #12
Source File: GriefPreventionVariables.java    From ScoreboardStats with MIT License 4 votes vote down vote up
public GriefPreventionVariables(ReplacerAPI replaceManager, GriefPrevention plugin) {
    super(replaceManager, plugin);
}