mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Allow payment for crafting items with predefined names
This commit is contained in:
parent
59e258734b
commit
73332fad38
@ -541,7 +541,6 @@ public class Jobs extends JavaPlugin {
|
||||
// Cloning to avoid issues
|
||||
HashMap<UUID, PlayerInfo> temp = new HashMap<UUID, PlayerInfo>(Jobs.getPlayerManager().getPlayersInfoUUIDMap());
|
||||
Iterator<Entry<UUID, PlayerInfo>> it = temp.entrySet().iterator();
|
||||
Jobs.consoleMsg("map size: " + temp.size());
|
||||
while (it.hasNext()) {
|
||||
Entry<UUID, PlayerInfo> one = it.next();
|
||||
if (!running)
|
||||
|
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Jobs Plugin for Bukkit
|
||||
* Copyright (C) 2011 Zak Ford <zak.j.ford@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.gamingmesh.jobs.actions;
|
||||
|
||||
import com.gamingmesh.jobs.container.ActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.BaseActionInfo;
|
||||
|
||||
public class ItemNameActionInfo extends BaseActionInfo implements ActionInfo {
|
||||
private String name;
|
||||
|
||||
public ItemNameActionInfo(String name, ActionType type) {
|
||||
super(type);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameWithSub() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
@ -589,6 +589,8 @@ public class ConfigManager {
|
||||
}
|
||||
Jobs.getExplore().setExploreEnabled();
|
||||
Jobs.getExplore().setPlayerAmount(amount + 1);
|
||||
} else if (actionType == ActionType.CRAFT && myKey.startsWith("!")) {
|
||||
type = myKey.substring(1, myKey.length());
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
|
@ -26,6 +26,7 @@ import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -85,6 +86,7 @@ import com.gamingmesh.jobs.actions.EnchantActionInfo;
|
||||
import com.gamingmesh.jobs.actions.EntityActionInfo;
|
||||
import com.gamingmesh.jobs.actions.ExploreActionInfo;
|
||||
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||
import com.gamingmesh.jobs.actions.ItemNameActionInfo;
|
||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.BlockProtection;
|
||||
@ -93,7 +95,6 @@ import com.gamingmesh.jobs.container.ExploreRespond;
|
||||
import com.gamingmesh.jobs.container.FastPayment;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
@ -514,9 +515,14 @@ public class JobsPaymentListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
Debug.D("Crafted item " + resultStack.getType().name() + " " + resultStack.getAmount());
|
||||
|
||||
// If we need to pay only by each craft action we will skip calculation how much was crafted
|
||||
if (!Jobs.getGCManager().PayForEachCraft) {
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
|
||||
if (resultStack.getItemMeta().hasDisplayName())
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(ChatColor.stripColor(resultStack.getItemMeta().getDisplayName()), ActionType.CRAFT));
|
||||
else
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -533,7 +539,10 @@ public class JobsPaymentListener implements Listener {
|
||||
int newItemsCount = toCraft.getAmount();
|
||||
while (newItemsCount >= 0) {
|
||||
newItemsCount--;
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
|
||||
if (resultStack.getItemMeta().hasDisplayName())
|
||||
Jobs.action(jPlayer, new ItemNameActionInfo(ChatColor.stripColor(resultStack.getItemMeta().getDisplayName()), ActionType.CRAFT));
|
||||
else
|
||||
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.CRAFT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -308,6 +308,10 @@ Jobs:
|
||||
LEATHER_BOOTS:
|
||||
income: 1.0
|
||||
experience: 6.0
|
||||
# Add ! at front when you want to pay for crafted items with special names
|
||||
"!Healing Bandage":
|
||||
income: 1.0
|
||||
experience: 6.0
|
||||
# Smelting ores
|
||||
Smelt:
|
||||
IRON_INGOT:
|
||||
|
Loading…
Reference in New Issue
Block a user