Skip to content

Commit

Permalink
Assorted changes, inc. fix item sacrifice exploit
Browse files Browse the repository at this point in the history
  • Loading branch information
galacticwarrior9 committed Jul 30, 2021
1 parent 036d1c0 commit 18949d7
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 39 deletions.
9 changes: 5 additions & 4 deletions lang/english_general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Info:
GodsHelp: Use $PlayerName for a list of commands
AltarHelp: Use $PlayerName for info about how to build an altar
PrayForHelp: Use $PlayerName for info about spending your prayer power
InviteHelp: Use /g invite to invite a player to your religion!
FollowersHelp: Use /g followers to keep track of your followers!
DescriptionHelp: Use /g desc to set a description for your religion!
InviteHelp: Use /gods invite to invite a player to your religion!
FollowersHelp: Use /gods followers to keep track of your followers!
DescriptionHelp: Use /gods desc to set a description for your religion!
PrayAlterHelp: Right click the sign on the altar to pray to your god.
PrayToBlacklistedGodNotAllowed: You cannot pray to a God with such a name
TeleportIntoHolylandNotAllowed: You cannot teleport into the Holy Land of $PlayerName
Expand Down Expand Up @@ -48,7 +48,7 @@ Info:
NowHunting: You now hunting
BelieverPower: Your belief in your God is now $Amount
QuestTargetRange: You are $Amount blocks from the quest target
QuestTargetHelp: Use /g hunt to hunt for the quest target!
QuestTargetHelp: Use /gods hunt to hunt for the quest target!
GodToBelieverQuestionHelp: Use $PlayerName to answer the God
NotEnoughPrayerPower: You need $Amount more prayer power for that
PrayedForBlessing: You prayed to $PlayerName for a blessing!
Expand Down Expand Up @@ -388,6 +388,7 @@ Mobs:
SLIME: slime
SKELETON: skeleton
VILLAGER: villager
ILLUSIONER: illusioner
UNKNOWN: unknown
GodTypes:
FROST: $Gender of Frost
Expand Down
2 changes: 1 addition & 1 deletion lang/english_thunder_female.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ GodToBelieversPilgrimageQuestFailed:
- My Children, I am displeased in you. You have not shown respect for our faith...
- My Children, I am displeased in you. You have failed to complete this simple task for me...
GodToBelieversPilgrimageQuestHelp:
- You must find your way to the holy mountain before any other! Type /g hunt
- You must find your way to the holy mountain before any other! Type /gods hunt
GodToBelieversPilgrimageQuestRange:
- You are only $Amount blocks away from mount $Type!
- You must Hurry! You are $Amount blocks away from the holy mountain!
Expand Down
2 changes: 1 addition & 1 deletion src/com/dogonfire/gods/Gods.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void run()
{
GodManager.instance().update();
}
}.runTaskTimer(this, 20L, 200L);
}.runTaskTimer(this, 20L, 12000L);

}

Expand Down
4 changes: 2 additions & 2 deletions src/com/dogonfire/gods/commands/CommandHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void helpAltar(CommandSender sender)
sender.sendMessage(ChatColor.WHITE + " 4 - Write the name of your God on the sign");
sender.sendMessage("");
sender.sendMessage(ChatColor.AQUA + "You can now pray to your God by right-clicking the sign!");
sender.sendMessage(ChatColor.AQUA + "Check what type of god you can make with " + ChatColor.WHITE + "/g help blocks");
sender.sendMessage(ChatColor.AQUA + "Check what type of god you can make with " + ChatColor.WHITE + "/gods help blocks");
}

private void helpBlocks(CommandSender sender)
Expand All @@ -155,7 +155,7 @@ private void helpBlocks(CommandSender sender)
}

sender.sendMessage("");
sender.sendMessage(ChatColor.AQUA + "Check how to build an altar with " + ChatColor.WHITE + "/g help altar");
sender.sendMessage(ChatColor.AQUA + "Check how to build an altar with " + ChatColor.WHITE + "/gods help altar");

}

Expand Down
2 changes: 1 addition & 1 deletion src/com/dogonfire/gods/commands/CommandListGods.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void onCommand(CommandSender sender, String command, String... args)
}
if (sender != null)
{
Gods.instance().sendInfo(player.getUniqueId(), LanguageManager.LANGUAGESTRING.InfoHelp, ChatColor.AQUA, 0, ChatColor.WHITE + "/g info <godname>", 80);
Gods.instance().sendInfo(player.getUniqueId(), LanguageManager.LANGUAGESTRING.InfoHelp, ChatColor.AQUA, 0, ChatColor.WHITE + "/gods info <godname>", 80);
}

}
Expand Down
16 changes: 8 additions & 8 deletions src/com/dogonfire/gods/commands/CommandPrayFor.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void onCommand(CommandSender sender, String command, String... args)
sender.sendMessage(stringNoPermission);
return;
}
if (sender instanceof Player == false)
if (!(sender instanceof Player))
{
sender.sendMessage(stringPlayerOnly);
return;
Expand Down Expand Up @@ -68,18 +68,18 @@ public void onCommand(CommandSender sender, String command, String... args)

private void prayForHelp(CommandSender sender)
{
sender.sendMessage(ChatColor.YELLOW + "--------------- How to pray for things ---------------");
sender.sendMessage(ChatColor.AQUA + "Pray for something specific from your God:");
sender.sendMessage(ChatColor.YELLOW + "--------------- How to request for things ---------------");
sender.sendMessage(ChatColor.AQUA + "Pray for something specific from your god:");
sender.sendMessage("");
sender.sendMessage(ChatColor.WHITE + "/g prayfor item - " + ChatColor.AQUA + " pray for an item");
sender.sendMessage(ChatColor.WHITE + "/g prayfor health - " + ChatColor.AQUA + " pray for health");
sender.sendMessage(ChatColor.WHITE + "/g prayfor blessing - " + ChatColor.AQUA + " pray for a magical blessing");
sender.sendMessage(ChatColor.WHITE + "/gods prayfor item - " + ChatColor.AQUA + " request an item");
sender.sendMessage(ChatColor.WHITE + "/gods prayfor health - " + ChatColor.AQUA + " request health");
sender.sendMessage(ChatColor.WHITE + "/gods prayfor blessing - " + ChatColor.AQUA + "request a potion effect");
if (GodsConfiguration.instance().isQuestsEnabled())
{
sender.sendMessage(ChatColor.WHITE + "/g prayfor quest - " + ChatColor.AQUA + " pray for a quest");
sender.sendMessage(ChatColor.WHITE + "/gods prayfor quest - " + ChatColor.AQUA + " request a quest");
}
sender.sendMessage("");
sender.sendMessage(ChatColor.AQUA + "Note that you need prayer power to perform these prayers.");
sender.sendMessage(ChatColor.AQUA + "Note that you need prayer power to perform these requests.");
}

private void prayForBlessing(CommandSender sender)
Expand Down
2 changes: 1 addition & 1 deletion src/com/dogonfire/gods/config/GodsConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ public void loadSettings()
this.commandmentsBroadcastFoodEaten = config.getBoolean("Commandments.BroadcastFoodEaten", true);
this.commandmentsBroadcastMobSlain = config.getBoolean("Commandments.BroadcastMobSlain", true);

this.questsEnabled = config.getBoolean("Quests.Enabled", false);
this.questsEnabled = config.getBoolean("Quests.Enabled", true);
this.minMinutesBetweenQuests = config.getInt("Quests.MinMinutesBetweenQuests", 180);

this.globalQuestsPercentChance = config.getInt("Quests.GlobalQuestsPercentChance", 1);
Expand Down
18 changes: 13 additions & 5 deletions src/com/dogonfire/gods/listeners/BlockListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public void OnEntityCombust(EntityCombustEvent event)
return;
}

((Item) event.getEntity()).setPickupDelay(100);
event.getEntity().setGlowing(true);

String believerName = AltarManager.instance().getDroppedItemPlayer(event.getEntity().getEntityId());
if (believerName == null) {
return;
Expand All @@ -149,9 +152,9 @@ public void OnEntityCombust(EntityCombustEvent event)
return;
}

GodManager.instance().handleSacrifice(godName, player, item.getItemStack().getType());

event.getEntity().remove();

GodManager.instance().handleSacrifice(godName, player, item.getItemStack().getType());
}

@EventHandler
Expand Down Expand Up @@ -303,14 +306,17 @@ public void onEntityExplode(EntityExplodeEvent event)
public void OnPlayerConsume(PlayerItemConsumeEvent event)
{
Player player = event.getPlayer();

// CCNet: Do not process non-vanilla foods.
if (event.getItem().hasItemMeta()) {
return;
}
String godName = BelieverManager.instance().getGodForBeliever(event.getPlayer().getUniqueId());
Material type = player.getInventory().getItemInMainHand().getType();
if (godName != null)
{
Long lastEatTime = this.lastEatTimes.get(player.getName());
Long currentTime = Long.valueOf(System.currentTimeMillis());
if ((lastEatTime == null) || (currentTime.longValue() - lastEatTime.longValue() > 10000L))
Long currentTime = System.currentTimeMillis();
if ((lastEatTime == null) || (currentTime - lastEatTime > 10000L))
{
if ((GodsConfiguration.instance().isCommandmentsEnabled()) && (player.getHealth() != player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()))
{
Expand Down Expand Up @@ -362,6 +368,7 @@ public void onPlayerDeath(PlayerDeathEvent event)
Gods.instance().sendInfo(killer.getUniqueId(), LanguageManager.LANGUAGESTRING.YouEarnedPowerBySlayingHeathen, ChatColor.AQUA, (int) (powerAfter - powerBefore), killerGodName, 20);
}
}
/*
else
{
List<String> warRelations = GodManager.instance().getWarRelations(killerGodName);
Expand All @@ -378,6 +385,7 @@ public void onPlayerDeath(PlayerDeathEvent event)
}
}
}
*/
}
}
}
Expand Down
22 changes: 15 additions & 7 deletions src/com/dogonfire/gods/listeners/ChatListener.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dogonfire.gods.listeners;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -12,6 +13,8 @@
import com.dogonfire.gods.managers.ChatManager;
import com.dogonfire.gods.managers.GodManager;

import java.util.concurrent.atomic.AtomicBoolean;

public class ChatListener implements Listener
{
@EventHandler
Expand Down Expand Up @@ -39,14 +42,19 @@ public void onPlayerChat(AsyncPlayerChatEvent event)
String otherGod = BelieverManager.instance().getGodForBeliever(otherPlayer.getUniqueId());
if ((otherGod != null) && (otherGod.equals(godName)))
{
if (GodManager.instance().isPriest(player.getUniqueId()))
{
otherPlayer.sendMessage(ChatColor.YELLOW + "[" + godName + "Chat] " + player.getName() + ": " + ChatColor.WHITE + event.getMessage());
}
else
{
//AtomicBoolean isPriest = new AtomicBoolean(false);
//Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(
// Gods.instance(), () -> {
// isPriest.set(GodManager.instance().isPriest(player.getUniqueId()));
// });
//if (isPriest.get())
//{
// otherPlayer.sendMessage(ChatColor.YELLOW + "[" + godName + "Chat] " + player.getName() + ": " + ChatColor.WHITE + event.getMessage());
//}
//else
//{
otherPlayer.sendMessage(ChatColor.YELLOW + "[" + godName + "Chat] " + ChatColor.RED + player.getName() + ChatColor.YELLOW + ": " + ChatColor.WHITE + event.getMessage());
}
//}
}
}
Gods.instance().log(player.getName() + "(GODCHAT): " + event.getMessage());
Expand Down
20 changes: 14 additions & 6 deletions src/com/dogonfire/gods/managers/AltarManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.Player;
import org.bukkit.event.block.SignChangeEvent;

Expand Down Expand Up @@ -380,20 +379,29 @@ public boolean isAltarBlock(Block block)

public boolean isAltarSign(Block block)
{
if (!(block instanceof WallSign)) {
if ((block == null) || (block.getType() != Material.OAK_WALL_SIGN))
{
return false;
}

BlockData bd = block.getBlockData();
if (!(bd instanceof Directional)) {
return false;
}
Directional directional = (Directional) bd;

Block altarBlock = block.getRelative(directional.getFacing().getOppositeFace());

Gods.instance().logDebug("isAltarSign(): AltarBlock block is " + altarBlock.getType().name());
if (getGodTypeForAltarBlockType(altarBlock.getType()) == null) {
if (getGodTypeForAltarBlockType(altarBlock.getType()) == null)
{
return false;
}

return (altarBlock.getRelative(BlockFace.UP).getType().equals(Material.TORCH)) || (altarBlock.getRelative(BlockFace.UP).getType().equals(Material.REDSTONE_TORCH));

if ((!altarBlock.getRelative(BlockFace.UP).getType().equals(Material.TORCH)) && (!altarBlock.getRelative(BlockFace.UP).getType().equals(Material.REDSTONE_TORCH)))
{
return false;
}
return true;
}

public boolean isAltarTorch(Block block)
Expand Down
6 changes: 3 additions & 3 deletions src/com/dogonfire/gods/managers/QuestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2636,11 +2636,11 @@ public void resetItemRewardValues()
this.rewardValues.put(Material.GLOWSTONE, 50);
this.rewardValues.put(Material.COAL, 5);
this.rewardValues.put(Material.IRON_INGOT, 10);
this.rewardValues.put(Material.GOLD_INGOT, 50);
//this.rewardValues.put(Material.GOLD_INGOT, 50);
this.rewardValues.put(Material.DIAMOND, 100);
this.rewardValues.put(Material.PLAYER_HEAD, 75);
this.rewardValues.put(Material.ENCHANTED_BOOK, 75);
this.rewardValues.put(Material.POTION, 75);
//this.rewardValues.put(Material.ENCHANTED_BOOK, 75);
//this.rewardValues.put(Material.POTION, 75);
this.rewardValues.put(Material.COCOA, 30);
this.rewardValues.put(Material.BLAZE_ROD, 50);
this.rewardValues.put(Material.BOOK, 30);
Expand Down

0 comments on commit 18949d7

Please sign in to comment.