mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-18 05:11:32 +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
|
// Cloning to avoid issues
|
||||||
HashMap<UUID, PlayerInfo> temp = new HashMap<UUID, PlayerInfo>(Jobs.getPlayerManager().getPlayersInfoUUIDMap());
|
HashMap<UUID, PlayerInfo> temp = new HashMap<UUID, PlayerInfo>(Jobs.getPlayerManager().getPlayersInfoUUIDMap());
|
||||||
Iterator<Entry<UUID, PlayerInfo>> it = temp.entrySet().iterator();
|
Iterator<Entry<UUID, PlayerInfo>> it = temp.entrySet().iterator();
|
||||||
Jobs.consoleMsg("map size: " + temp.size());
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Entry<UUID, PlayerInfo> one = it.next();
|
Entry<UUID, PlayerInfo> one = it.next();
|
||||||
if (!running)
|
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().setExploreEnabled();
|
||||||
Jobs.getExplore().setPlayerAmount(amount + 1);
|
Jobs.getExplore().setPlayerAmount(amount + 1);
|
||||||
|
} else if (actionType == ActionType.CRAFT && myKey.startsWith("!")) {
|
||||||
|
type = myKey.substring(1, myKey.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Map.Entry;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
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.EntityActionInfo;
|
||||||
import com.gamingmesh.jobs.actions.ExploreActionInfo;
|
import com.gamingmesh.jobs.actions.ExploreActionInfo;
|
||||||
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||||
|
import com.gamingmesh.jobs.actions.ItemNameActionInfo;
|
||||||
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
import com.gamingmesh.jobs.api.JobsChunkChangeEvent;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.BlockProtection;
|
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.FastPayment;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
|
||||||
import com.gamingmesh.jobs.stuff.Debug;
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
import com.google.common.base.Objects;
|
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 we need to pay only by each craft action we will skip calculation how much was crafted
|
||||||
if (!Jobs.getGCManager().PayForEachCraft) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,7 +539,10 @@ public class JobsPaymentListener implements Listener {
|
|||||||
int newItemsCount = toCraft.getAmount();
|
int newItemsCount = toCraft.getAmount();
|
||||||
while (newItemsCount >= 0) {
|
while (newItemsCount >= 0) {
|
||||||
newItemsCount--;
|
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:
|
LEATHER_BOOTS:
|
||||||
income: 1.0
|
income: 1.0
|
||||||
experience: 6.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
|
# Smelting ores
|
||||||
Smelt:
|
Smelt:
|
||||||
IRON_INGOT:
|
IRON_INGOT:
|
||||||
|
Loading…
Reference in New Issue
Block a user