Paste #39454: Edit of P#39444 - Edit of P#39423 - Edit of P#39422 - Stuff

Date: 2017/01/30 12:24:20 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


WorldEvents:
  type: world
  debug: false
  events:
    on player enters cuboid1:
    - adjust <player> send_to:server@shift1
    on player enters cuboid2:
    - adjust <player> send_to:server@shift2
    on player enters cuboid3:
    - adjust <player> send_to:server@shift3
    on player enters cuboid4:
    - adjust <player> send_to:server@shift4
    on system time 05:00:
    - run safe_shutdown
    on system time 11:00:
    - run safe_shutdown
    on system time 17:00:
    - run safe_shutdown
    on system time 23:00:
    - run safe_shutdown

    # Isn't this a nicer and neater way to do announcements?
    on system time minutely:
    - if <context.minute.mod[4]> == 0 {
      - announce '<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>='
      - random {
        - announce '                <&a><&l>Welcome to the XPCraft Server!'
        - announce '                      <&a>Type /vote for voting links!'
        - announce '       <&a>Use the server selector or portals to play games!'
        - announce '             <&a>Sign up on our forums at www.xpcraft.com!'
        - announce '     <&a>Click the tutorial holograms to learn about our games!'
        - announce '<&a>Use coupon code XPCRAFT for 50% off any store purchases!'
        }
      - announce '<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>-<&6>-<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>=<&2>=<&6>='
      }

    on restart command:
    - if <context.server> || !<player.is_op> {
      - queue clear
      }
    - determine cancelled passively
    - run safe_shutdown
    on stop command:
    - if <context.server> || !<player.is_op> {
      - queue clear
      }
    - determine cancelled passively
    - run safe_shutdown
    on shutdown command:
    - if <context.server> || !<player.is_op> {
      - queue clear
      }
    - determine cancelled passively
    - run safe_shutdown
    on weather rains in MainLobby:
    - determine cancelled
    on player quit:
    - flag player messager:!
    - wait 1t
    - adjust <player> 'location:l@-54.5,52.1,-94.5,0,90,MainLobby'

    on server start:
    - run Player_Count_Refresh
    - run locally spawnloc
    - run locally start

  start:
  # SQLManager expects you to have this subscript so it can restart things if needed.
  # It's also not a bad idea for you to have a command to restart your own script systems.
  # The command simply runs the start subscript. Or maybe on scripts reloaded event too.
    - define yamlName 'XPCore'
    - define scriptName '<script.name>'
    - if !<server.has_file[%yamlName%/config.yml]> {
      - run s@ConfigFileGeneratorHelper def:%yamlName%|Configurations instantly
      }
    - if <yaml.list.contains[%yamlName%_config]> {
      - yaml unload 'id:%yamlName%_config'
      }
    - yaml 'load:%yamlName%/config.yml' 'id:%yamlName%_config'
    - define db '<yaml[%yamlName%_config].read[config.MySQL.database]||false>'
    - inject s@XPCoreSQL
    # This checks the status as set by SQLManager to not duplicate restart
    # processes. This is the only time this script needs to set the status. The
    # SQLManager will handle every other situation.
    - repeat 5:
      - if <yaml.list.contains[SQLManager_Offline].not> {
        - announce to_console "XPCore<&co> Waiting for SQLManager to come online..."
        - wait 1s
        }
    - if <yaml.list.contains[SQLManager_Offline].not> {
      - announce to_console "XPCore<&co> SQLManager FAILED!"
      - announce to_console "XPCore<&co> Aborting startup!"
      - queue clear
      }
    - define status '<yaml[SQLManager_Offline].read[Offline_Cache.databases.%db%.status]||null>'
    - if <def[status].is[==].to[connecting]> {
      - announce "<&b>SQLManager<&co><&c> Already attempting to reconnect to %db% database!" to_console
      }
      else {
      - yaml set 'id:SQLManager_Offline' 'Offline_Cache.databases.%db%.status:connecting'
      - yaml 'savefile:SQLManager/cache.yml' 'id:SQLManager_Offline'
      - inject s@SQLManager
      }

  # A place to do whatever you need to do to fully unload XPCore
  # SQLManager runs this in the event that the DB goes offline and can not be reconnected to.
  unload:
    - ^if <yaml.list.contains[XPCore_config]> {
      - announce "<&b>XPCore<&co><&3> Unloading config.yml file..." to_console
      - yaml unload 'id:XPCore_config'
      }

  spawnloc:
    - foreach <server.list_players>
      - adjust <def[value]> 'location:l@-54.5,52.1,-94.5,0,90,MainLobby'

  cuboids:
  # You really shouldn't have to recreate cuboids on every server start
    - note cu@-19,51,-114,Mainlobby|-19,58,-104,Mainlobby as:cuboid1
    - note cu@-19,51,-86,Mainlobby|-19,38,-76,Mainlobby as:cuboid2
    - note cu@-46,51,-59,Mainlobby|-36,58,-59,Mainlobby as:cuboid3
    - note cu@-64,51,-59,Mainlobby|-74,58,-59,Mainlobby as:cuboid4

#### Just keep this in the same file it's totally sane i swear ####
XPCoreSQL:
  type: task
  debug: true
  script:
  - define sqlScriptName '<script.name>'
  - define sqlFile '<script.relative_filename>'
  - if <yaml.list.contains[%sqlScriptName%]> {
    - yaml unload 'id:%sqlScriptName%'
    }
  - yaml 'load:%sqlFile%' 'id:%sqlScriptName%'
  - if !<yaml.list.contains[%sqlScriptName%]> {
    - announce "<&c>XPCore<&co><&b> An error occurred while loading %sqlScriptname%!" to_console
    - announce "<&b>XPCore<&co><&3> Aborting..." to_console
    - inject s@%scriptName% p:unload
    }

  tables:
    XPCoreValues:
      columns:
        ID: INT NOT NULL AUTO_INCREMENT PRIMARY KEY
        PLAYERUUID: varchar(255) NOT NULL UNIQUE
        XP: int
        CLAIMEDCODES: tinyint
        RANK: varchar(25)
        NORMALPACKS: TINYINT NOT NULL DEFAULT '0'
        SUPERPACKS: TINYINT NOT NULL DEFAULT '0'
        MEDALLIONS: INT NOT NULL DEFAULT '0'
        PLAYPOINTS: INT NOT NULL DEFAULT '0'
        TOURNAMENTPOINTS: SMALLINT NOT NULL DEFAULT '0'


# Install CFG https://www.spigotmc.org/resources/denizen-confgfilegenerator.26837/ #
XPCore_Configurations:
  type: yaml data

  config:
    MySQL:
      connection:
        retry: 3
        retryDelay: 10s
        keepAlive: 5m
        host: localhost
        port: 3306
        username: root
        password: goeatachode
      database: Server
      tables:
        XPCoreValues: XPCore