Sueta

SafeTrading

1.3

Great player to player safe item trading script.

·Script

header.png

SafeTrade
SafeTrade is a script that makes trading items between players easy and simple.

Features

- Safe and simple way for people to trade items
- Configurable messages
- Inventory checker for full inventory
- Creative mode option
- Configurable trade cool down and trade time out
- Configurable distance and same world checker
- Configurable countdown timer when trading for safety
- Configurable sounds for specific functions
- Configurable GUI items
- Blacklist items based on name, lore, item type, or exact item

Commands

- /trade [<player>] - Request a trade / Accept a trade
- /tradetoggle - Enable or disable trading
- /tblacklist [<create,remove,set>] [<id>] - Create blacklist ids (Edit in blacklist.yml)
- /treload - Reload the config of the script

Permissions

- trade.use (for /trade and /tradetoggle)
- trade.reload (for /treload)
- trade.blacklist (for /tblacklist)

Blacklisting Guide

When you first load up the file, a blank blacklist.yml file will be created. I recommend not editing this file when it is empty.
1. To make a blacklist item, you have to create it using the '/tblacklist create <id>' command. The <id> can be anything you want.
2. After using the create command, it will be created in the blacklist.yml file. You can then go change the settings for that id.
3. To set an exact item, hold an item that is not air in your hand and use command '/tblacklist set <id>'. This will make it to where whatever you are holding cannot be traded.
4. Make sure to read the top of the blacklist.yml for directions on what options do what. After you create your first blacklist id, the directions will generate.

Required Plugins

Skript Bensku fork 2.3.6: https://github.com/SkriptLang/Skript/releases
SkQuery fork: https://www.spigotmc.org/resources/unofficial-skquery-fork-1-6-1-12.36631/
Skellett: https://www.spigotmc.org/resources/skript-java-addon-skellett.34361/
Skript-Yaml: https://www.spigotmc.org/resources/skript-yaml.49829/

Installation

1. Drop all the plugins above into plugins folder and restart server.
2. Download this resource (trade.sk) and put it in the plugins/Skript/scripts folder
3. You can either restart the server again or do /sk reload trade
4. Your done!

Extra Information

1. To put items up for trade, you have to shift click the items. There is a reason for this and I will not change it.
2. Feel free to edit the script's source code to your liking but do not claim it as your own.
3. I will most likely not add economy support to this. If you want to have eco with this trade, then either make a physical currency or use a plugin that allows you to convert virtual currency to physical currency.
4. Here is my discord if you have any questions or need help: AsuDev#0714

Pictures
example.png

config.yml

## WARNING: DO NOT SET A GUI ITEM TO AIR! IT WILL CAUSE THE TRADING TO BREAK!  
 
Messages  :  
    Prefix   :  '&8&l  [  &e&lTRADING&8&l  ]  '  
    TradeNoPermission   :  '  {  prefix  }  &cYou do not have permission to trade.'  
    TradeToggleDisabled   :  '  {  prefix  }  &cYou disabled trading.'  
    TradeToggleEnabled   :  '  {  prefix  }  &aYou enabled trading.'  
    BlacklistedIDExists   :  '  {  prefix  }  &7The blacklisted item id you specified already 
        exists.'  
    BlacklistedIDDoesNotExist   :  '  {  prefix  }  &7The blacklisted item id you specified does 
        not exist.'  
    BlacklistedItem   :  '  {  prefix  }  &7That item cannot be traded.'  
    BlacklistedIDCreated   :  '  {  prefix  }  &7You &acreated &7a blacklist id called &6  {  id  }  &7. 
        To edit this, you have to edit the &ablacklist.yml &7file.'  
    BlacklistedIDRemoved   :  '  {  prefix  }  &7You &cremoved &7the blacklist id called &6  {  id  }  &7.'  
    BlacklistedIDExactItem   :  '  {  prefix  }  &7You &3set &7the exact item of blacklist id 
        called &6  {  id  }  &7to your held item.'  
    TradeSelf   :  '  {  prefix  }  &7Yeah, because I would definitely allow you to trade yourself.'  
    TradeCooldown   :  '  {  prefix  }  &7Please wait a few seconds before using this command 
        again.'  
    PlayerHasTradingDisabled   :  '  {  prefix  }  &7The player you specified has trading disabled.'  
    NoTradeInCreative   :  '  {  prefix  }  &7You cannot trade in creative mode.'  
    NoTradeInCreative2   :  '  {  prefix  }  &7The other player is in creative mode.'  
    NotSameWorld   :  '  {  prefix  }  &7You must be in the same world as the specified player 
        to trade them.'  
    OutOfDistance   :  '  {  prefix  }  &7You are too far away from the specified player to trade 
        them.'  
    AlreadyInTrade   :  '  {  prefix  }  &7The other player is already currently in a trade.'  
    RequestAlreadySent   :  '  {  prefix  }  &7You already sent this player a trade request  ...  '  
    ClickCorrection   :  '  {  prefix  }  &7Shift click items in your inventory to put up trade 
        offers.'  
    GuiName   :  '&a★You★              &c★Other★'  
    RequestSent   :  '  {  prefix  }  &7You sent a trade request to &6  {  target  }  &7.'  
    TradeCanceled   :  '&8&l  [  &4✘&8&l  ]  &cThe other player canceled the trade. &8&l  [  &4✘&8&l  ]  '  
    TradeCanceled2   :  '&8&l  [  &4✘&8&l  ]  &cYou canceled the trade. &8&l  [  &4✘&8&l  ]  '  
    TradeAccepted   :  '&8&l  [  &a✔&8&l  ]  &bTrade complete. &7Please report  any  scams! &8&l  [  &a✔&8&l  ]  '  
    TradeReloaded   :  '  {  prefix  }  &aThe trade config has been reloaded.'  
    RequestReceived   :  '  {  prefix  }  &6  {  player  }  &7sent you a trade request. Use &a/trade 
         {  player  }  &7to accept it.' 

 # Does /trade have a cooldown? Put true or false  
 # Cooldown duration in seconds   
TradeCooldown  :  
    Enabled   :  true  
    Timer   :  5 

 # The timout duration of a trade offer  
 # The countdown of trade ending  
 # Cooldown duration in seconds  
 # Do players have to be in same world to trade  
 # Distance limit for trading (Set to Infinite for no limit)  
 # Should players be able to trade in creative? true/false   
Trade  :  
    TimeOut   :  20  
    CountDown   :  6  
    SameWorld   :  true  
    Distance   :  Infinite  
    TradeInCreative   :  false 

 # Sound played when adding an item to a trade  
 # Is this sound enabled? Put true/false  
 # The name of the sound played  
 # How loud the played sound is  
 # The pitch of the sound played  
 # Sounds found at: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html   
AddOffer  :  
    PlaySound   :  true  
    SoundName   :  ENTITY_EXPERIENCE_ORB_PICKUP  
    Volume   :  1  
    Pitch   :  1 

 # Sound played when the trade is successful  
 # Is this sound enabled? Put true/false  
 # The name of the sound played  
 # How loud the played sound is  
 # The pitch of the sound played  
 # Sounds found at: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html   
TradeComplete  :  
    PlaySound   :  true  
    SoundName   :  ENTITY_PLAYER_LEVELUP  
    Volume   :  1  
    Pitch   :  1 

 # Sound played when the trade is not successful  
 # Is this sound enabled? Put true/false  
 # The name of the sound played  
 # How loud the played sound is  
 # The pitch of the sound played  
 # Sounds found at: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html   
TradeCanceled  :  
    PlaySound   :  true  
    SoundName   :  BLOCK_ANVIL_LAND  
    Volume   :  1  
    Pitch   :  0.1 

 # The gui item for Not Ready (DO NOT SET TO AIR)   
NotReady  :  
    ItemID   :  gray dye  
    Name   :  '&7Not Ready  ...  '  
    Lore   : 
    - Empty 

 # The gui item for Ready (DO NOT SET TO AIR)   
Ready  :  
    ItemID   :  lime dye  
    Name   :  '&a&lREADY'  
    Lore   : 
    - Empty 

 # The gui item for Accept Trade button (DO NOT SET TO AIR)   
Accept  :  
    ItemID   :  green stained glass pane  
    Name   :  '&a&lACCEPT TRADE'  
    Lore   : 
    - '&7&oClick to accept trade.' 

 # The gui item for Cancel Trade button (DO NOT SET TO AIR)   
Cancel  :  
    ItemID   :  red stained glass pane  
    Name   :  '&4&lCANCEL TRADE'  
    Lore   : 
    - '&7&oClick to cancel trade.' 

 # The gui item for Divider line (DO NOT SET TO AIR)   
Divider  :  
    ItemID   :  iron bars  
    Name   :  '&4'  
    Lore   : 
    - Empty 

 # The gui item for Stop Timer item (DO NOT SET TO AIR)   
StopTimer  :  
    ItemID   :  barrier  
    Name   :  '&c&lSTOP TIMER'  
    Lore   : 
    - '&7&oClick to stop the timer.' 

 # The gui item for Blank Slot item (DO NOT SET TO AIR)   
BlankSlot  :  
    ItemID   :  light gray stained glass pane  
    Name   :  '&4'  
    Lore   : 
    - Empty

blacklist.yml

## This is the item blacklist for trading.  
 ## Use /tblacklist <create,remove,set> <id> for managing the item blacklist.  
 ##  
 ## Detection Types:  
 ##   'Name' = Detect blacklisted item by name (For DetectionType Option)  
 ##   'Lore' = Detect blacklisted item by lore (For DetectionType Option)  
 ##   'Both' = Detect blacklisted item by name and lore (For DetectionType Option)  
 ##   'Type' = Detect blacklisted item by type (For DetectionType Option)  
 ##   'ExactItem' = Detect blacklisted item by exact item (For DetectionType Option)  
 ##  
 ## Text Detection Types:  
 ##   'Contains' = If name of blacklisted item CONTAINS certain text (For TextDetectionType Option) Does not work with lore.  
 ##   'Is' = If name of blacklisted item IS certain text (For TextDetectionType Option) Does not work for lore.  
 ##  
 ## ItemName = The text to find in the name of a item (Applies when DetectionType is set to 'Name' or 'Both')  
 ## ItemLore = The text to find in the lore of a item (Applies when DetectionType is set to 'Lore' or 'Both'  
 ## ItemType = The item type of the item you want to blacklist (Applies when DetectionType is set to 'Type')  
 ## ExactItem = Detection for an exact item (Applies when DetectionType is set to 'ExactItem'. To set an exact item, use /tblacklist set <id>)  
 
'1'  :  
    DetectionType   :  Name  
    TextDetectionType   :  Contains  
    ItemName   :  '&dGod Sword' 
 
'2'  :  
    DetectionType   :  Lore  
    TextDetectionType   :  Contains  
    ItemLore   :  '&7&oUntradeable  ...  ' 
 
'3'  :  
    DetectionType   :  Both  
    TextDetectionType   :  Contains  
    ItemName   :  '&cForbidden Item'  
    ItemLore   :  '&7&oThis item cannot be traded.' 
 
'4'  :  
    DetectionType   :  Type  
    ItemType   :  'diamond sword' 
 
'5'  :  
    DetectionType   :  ExactItem  
    ExactItem  :  
        ==   :  org.bukkit.inventory.ItemStack  
        type   :  DIAMOND_SWORD  
        meta  :  
            ==   :  ItemMeta  
            meta-type   :  UNSPECIFIC  
            display-name   :  §bBlargghhh  
            lore   : 
            - §9Trolls use this weapon  ...

Similar projects

Script →